@@ -6319,6 +6319,33 @@ int handler::calculate_checksum()
6319
6319
** Some general functions that isn't in the handler class
6320
6320
****************************************************************************/
6321
6321
6322
+ static int ha_create_table_from_share (THD *thd, TABLE_SHARE *share,
6323
+ HA_CREATE_INFO *create_info)
6324
+ {
6325
+ TABLE table;
6326
+
6327
+ if (open_table_from_share (thd, share, &empty_clex_str, 0 , READ_ALL, 0 ,
6328
+ &table, true ))
6329
+ return 1 ;
6330
+
6331
+ update_create_info_from_table (create_info, &table);
6332
+
6333
+ Table_path_buffer name_buff;
6334
+ Lex_cstring name= table.file ->get_canonical_filename (share->path , &name_buff);
6335
+ int error= table.file ->ha_create (name.str , &table, create_info);
6336
+
6337
+ if (error)
6338
+ {
6339
+ if (!thd->is_error ())
6340
+ my_error (ER_CANT_CREATE_TABLE, MYF (0 ), share->db .str ,
6341
+ share->table_name .str , error);
6342
+ table.file ->print_error (error, MYF (ME_WARNING));
6343
+ }
6344
+
6345
+ (void ) closefrm (&table);
6346
+ return error;
6347
+ }
6348
+
6322
6349
/* *
6323
6350
Initiates table-file and calls appropriate database-creator.
6324
6351
@@ -6340,12 +6367,9 @@ int ha_create_table(THD *thd, const char *path, const char *db,
6340
6367
LEX_CUSTRING *frm, bool skip_frm_file)
6341
6368
{
6342
6369
int error= 1 ;
6343
- TABLE table;
6344
- Table_path_buffer name_buff;
6345
- const char *name;
6346
6370
TABLE_SHARE share;
6347
6371
Abort_on_warning_instant_set old_abort_on_warning (thd, 0 );
6348
- bool temp_table __attribute__ ((unused)) =
6372
+ bool is_tmp __attribute__ ((unused)) =
6349
6373
create_info->options & (HA_LEX_CREATE_TMP_TABLE | HA_CREATE_TMP_ALTER);
6350
6374
DBUG_ENTER (" ha_create_table" );
6351
6375
@@ -6372,29 +6396,13 @@ int ha_create_table(THD *thd, const char *path, const char *db,
6372
6396
goto err;
6373
6397
}
6374
6398
6375
- share.m_psi = PSI_CALL_get_table_share (temp_table, &share);
6376
-
6377
- if (open_table_from_share (thd, &share, &empty_clex_str, 0 , READ_ALL, 0 ,
6378
- &table, true ))
6379
- goto err;
6380
-
6381
- update_create_info_from_table (create_info, &table);
6382
-
6383
- name= table.file ->get_canonical_filename (share.path , &name_buff).str ;
6384
-
6385
- error= table.file ->ha_create (name, &table, create_info);
6386
-
6387
- if (unlikely (error))
6399
+ share.m_psi = PSI_CALL_get_table_share (is_tmp, &share);
6400
+ if ((error= ha_create_table_from_share (thd, &share, create_info)))
6388
6401
{
6389
- if (!thd->is_error ())
6390
- my_error (ER_CANT_CREATE_TABLE, MYF (0 ), db, table_name, error);
6391
- table.file ->print_error (error, MYF (ME_WARNING));
6392
- PSI_CALL_drop_table_share (temp_table, share.db .str , (uint)share.db .length ,
6393
- share.table_name .str , (uint)share.table_name .length );
6402
+ PSI_CALL_drop_table_share (is_tmp, share.db .str , (uint)share.db .length ,
6403
+ share.table_name .str , (uint)share.table_name .length );
6394
6404
}
6395
6405
6396
- (void ) closefrm (&table);
6397
-
6398
6406
err:
6399
6407
free_table_share (&share);
6400
6408
DBUG_RETURN (error != 0 );
0 commit comments