| 2230 | */ |
| 2231 | |
| 2232 | int show_create_table_ex(THD *thd, TABLE_LIST *table_list, const char *force_db, |
| 2233 | const char *force_name, String *packet, |
| 2234 | Table_specification_st *create_info_arg, |
| 2235 | enum_with_db_name with_db_name) |
| 2236 | { |
| 2237 | List<Item> field_list; |
| 2238 | char tmp[MAX_FIELD_WIDTH], *for_str, def_value_buf[MAX_FIELD_WIDTH]; |
| 2239 | LEX_CSTRING alias; |
| 2240 | String type; |
| 2241 | String def_value; |
| 2242 | Field **ptr,*field; |
| 2243 | uint primary_key; |
| 2244 | KEY *key_info; |
| 2245 | TABLE *table= table_list->table; |
| 2246 | TABLE_SHARE *share= table->s; |
| 2247 | TABLE_SHARE::period_info_t &period= share->period; |
| 2248 | sql_mode_t sql_mode= thd->variables.sql_mode; |
| 2249 | bool explicit_fields= false; |
| 2250 | bool foreign_db_mode= sql_mode & (MODE_POSTGRESQL | MODE_ORACLE | |
| 2251 | MODE_MSSQL | MODE_DB2 | |
| 2252 | MODE_MAXDB | MODE_ANSI); |
| 2253 | bool limited_mysql_mode= sql_mode & (MODE_NO_FIELD_OPTIONS | MODE_MYSQL323 | |
| 2254 | MODE_MYSQL40); |
| 2255 | bool show_table_options= !(sql_mode & MODE_NO_TABLE_OPTIONS) && |
| 2256 | !foreign_db_mode; |
| 2257 | bool check_options= !(sql_mode & MODE_IGNORE_BAD_TABLE_OPTIONS) && |
| 2258 | !create_info_arg; |
| 2259 | handlerton *hton; |
| 2260 | int error= 0; |
| 2261 | DBUG_ENTER("show_create_table_ex"); |
| 2262 | DBUG_PRINT("enter",("table: %s", table->s->table_name.str)); |
| 2263 | |
| 2264 | #ifdef WITH_PARTITION_STORAGE_ENGINE |
| 2265 | if (table->part_info) |
| 2266 | hton= table->part_info->default_engine_type; |
| 2267 | else |
| 2268 | #endif |
| 2269 | hton= table->file->ht; |
| 2270 | |
| 2271 | restore_record(table, s->default_values); // Get empty record |
| 2272 | |
| 2273 | packet->append(STRING_WITH_LEN("CREATE ")); |
| 2274 | if (create_info_arg && |
| 2275 | ((create_info_arg->or_replace() && |
| 2276 | !create_info_arg->or_replace_slave_generated()) || |
| 2277 | create_info_arg->table_was_deleted)) |
| 2278 | packet->append(STRING_WITH_LEN("OR REPLACE ")); |
| 2279 | if (share->tmp_table) |
| 2280 | packet->append(STRING_WITH_LEN("TEMPORARY ")); |
| 2281 | packet->append(STRING_WITH_LEN("TABLE ")); |
| 2282 | if (create_info_arg && create_info_arg->if_not_exists()) |
| 2283 | packet->append(STRING_WITH_LEN("IF NOT EXISTS ")); |
| 2284 | |
| 2285 | if (force_name) |
| 2286 | { |
| 2287 | if (force_db) |
| 2288 | { |
| 2289 | append_identifier(thd, packet, force_db, strlen(force_db)); |
no test coverage detected