Skip to content

Commit 86da0f4

Browse files
committed
MDEV-25292 select_create::create_table removed
create_table duplicates select_insert::table_list. Since select_create inherits select_insert and the functional role of the members is the same we should remove one to eliminate the need of keeping them in sync.
1 parent d145dda commit 86da0f4

File tree

2 files changed

+35
-37
lines changed

2 files changed

+35
-37
lines changed

sql/sql_class.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6115,7 +6115,6 @@ class select_insert :public select_result_interceptor {
61156115

61166116

61176117
class select_create: public select_insert {
6118-
TABLE_LIST *create_table;
61196118
Table_specification_st *create_info;
61206119
TABLE_LIST *select_tables;
61216120
Alter_info *alter_info;
@@ -6136,7 +6135,6 @@ class select_create: public select_insert {
61366135
TABLE_LIST *select_tables_arg):
61376136
select_insert(thd_arg, table_arg, NULL, &select_fields, 0, 0, duplic,
61386137
ignore, NULL),
6139-
create_table(table_arg),
61406138
create_info(create_info_par),
61416139
select_tables(select_tables_arg),
61426140
alter_info(alter_info_arg),

sql/sql_insert.cc

Lines changed: 35 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -4507,7 +4507,7 @@ TABLE *select_create::create_table_from_items(THD *thd, List<Item> *items,
45074507
if (!(thd->variables.option_bits & OPTION_EXPLICIT_DEF_TIMESTAMP))
45084508
promote_first_timestamp_column(&alter_info->create_list);
45094509

4510-
if (create_info->fix_create_fields(thd, alter_info, *create_table))
4510+
if (create_info->fix_create_fields(thd, alter_info, *table_list))
45114511
DBUG_RETURN(NULL);
45124512

45134513
while ((item=it++))
@@ -4548,20 +4548,20 @@ TABLE *select_create::create_table_from_items(THD *thd, List<Item> *items,
45484548
}
45494549

45504550
if (create_info->check_fields(thd, alter_info,
4551-
create_table->table_name,
4552-
create_table->db))
4551+
table_list->table_name,
4552+
table_list->db))
45534553
DBUG_RETURN(NULL);
45544554

45554555
DEBUG_SYNC(thd,"create_table_select_before_create");
45564556

45574557
/* Check if LOCK TABLES + CREATE OR REPLACE of existing normal table*/
4558-
if (thd->locked_tables_mode && create_table->table &&
4558+
if (thd->locked_tables_mode && table_list->table &&
45594559
!create_info->tmp_table())
45604560
{
45614561
/* Remember information about the locked table */
45624562
create_info->pos_in_locked_tables=
4563-
create_table->table->pos_in_locked_tables;
4564-
create_info->mdl_ticket= create_table->table->mdl_ticket;
4563+
table_list->table->pos_in_locked_tables;
4564+
create_info->mdl_ticket= table_list->table->mdl_ticket;
45654565
}
45664566

45674567
/*
@@ -4582,48 +4582,48 @@ TABLE *select_create::create_table_from_items(THD *thd, List<Item> *items,
45824582
*/
45834583

45844584
if (!mysql_create_table_no_lock(thd, &ddl_log_state_create, &ddl_log_state_rm,
4585-
&create_table->db,
4586-
&create_table->table_name,
4585+
&table_list->db,
4586+
&table_list->table_name,
45874587
create_info, alter_info, NULL,
4588-
C_ORDINARY_CREATE, create_table))
4588+
C_ORDINARY_CREATE, table_list))
45894589
{
45904590
DEBUG_SYNC(thd,"create_table_select_before_open");
45914591

45924592
/*
45934593
If we had a temporary table or a table used with LOCK TABLES,
45944594
it was closed by mysql_create()
45954595
*/
4596-
create_table->table= 0;
4596+
table_list->table= 0;
45974597

45984598
if (!create_info->tmp_table())
45994599
{
46004600
Open_table_context ot_ctx(thd, MYSQL_OPEN_REOPEN);
46014601
TABLE_LIST::enum_open_strategy save_open_strategy;
46024602

46034603
/* Force the newly created table to be opened */
4604-
save_open_strategy= create_table->open_strategy;
4605-
create_table->open_strategy= TABLE_LIST::OPEN_NORMAL;
4604+
save_open_strategy= table_list->open_strategy;
4605+
table_list->open_strategy= TABLE_LIST::OPEN_NORMAL;
46064606
/*
46074607
Here we open the destination table, on which we already have
46084608
an exclusive metadata lock.
46094609
*/
4610-
if (open_table(thd, create_table, &ot_ctx))
4610+
if (open_table(thd, table_list, &ot_ctx))
46114611
{
4612-
quick_rm_table(thd, create_info->db_type, &create_table->db,
4613-
table_case_name(create_info, &create_table->table_name),
4612+
quick_rm_table(thd, create_info->db_type, &table_list->db,
4613+
table_case_name(create_info, &table_list->table_name),
46144614
0);
46154615
}
46164616
/* Restore */
4617-
create_table->open_strategy= save_open_strategy;
4617+
table_list->open_strategy= save_open_strategy;
46184618
}
46194619
else
46204620
{
46214621
/*
46224622
The pointer to the newly created temporary table has been stored in
46234623
table->create_info.
46244624
*/
4625-
create_table->table= create_info->table;
4626-
if (!create_table->table)
4625+
table_list->table= create_info->table;
4626+
if (!table_list->table)
46274627
{
46284628
/*
46294629
This shouldn't happen as creation of temporary table should make
@@ -4635,9 +4635,9 @@ TABLE *select_create::create_table_from_items(THD *thd, List<Item> *items,
46354635
}
46364636
}
46374637
else
4638-
create_table->table= 0; // Create failed
4638+
table_list->table= 0; // Create failed
46394639

4640-
if (unlikely(!(table= create_table->table)))
4640+
if (unlikely(!(table= table_list->table)))
46414641
{
46424642
if (likely(!thd->is_error())) // CREATE ... IF NOT EXISTS
46434643
my_ok(thd); // succeed, but did nothing
@@ -4679,7 +4679,7 @@ TABLE *select_create::create_table_from_items(THD *thd, List<Item> *items,
46794679
mysql_unlock_tables(thd, *lock);
46804680
*lock= 0;
46814681
}
4682-
drop_open_table(thd, table, &create_table->db, &create_table->table_name);
4682+
drop_open_table(thd, table, &table_list->db, &table_list->table_name);
46834683
ddl_log_complete(&ddl_log_state_rm);
46844684
ddl_log_complete(&ddl_log_state_create);
46854685
DBUG_RETURN(NULL);
@@ -4726,10 +4726,10 @@ int select_create::postlock(THD *thd, TABLE **tables)
47264726
NOTE: for row format CREATE TABLE must be logged before row data.
47274727
*/
47284728
int error;
4729-
TABLE_LIST *save_next_global= create_table->next_global;
4730-
create_table->next_global= select_tables;
4731-
error= thd->decide_logging_format(create_table);
4732-
create_table->next_global= save_next_global;
4729+
TABLE_LIST *save_next_global= table_list->next_global;
4730+
table_list->next_global= select_tables;
4731+
error= thd->decide_logging_format(table_list);
4732+
table_list->next_global= save_next_global;
47334733

47344734
if (unlikely(error))
47354735
return error;
@@ -4768,7 +4768,7 @@ select_create::prepare(List<Item> &_values, SELECT_LEX_UNIT *u)
47684768
if (create_info->or_replace())
47694769
{
47704770
/* Original table was deleted. We have to log it */
4771-
log_drop_table(thd, &create_table->db, &create_table->table_name,
4771+
log_drop_table(thd, &table_list->db, &table_list->table_name,
47724772
&create_info->org_storage_engine_name,
47734773
create_info->db_type == partition_hton,
47744774
&create_info->org_tabledef_version,
@@ -4788,7 +4788,7 @@ select_create::prepare(List<Item> &_values, SELECT_LEX_UNIT *u)
47884788
list to keep them inaccessible from inner statements.
47894789
e.g. CREATE TEMPORARY TABLE `t1` AS SELECT * FROM `t1`;
47904790
*/
4791-
saved_tmp_table_share= thd->save_tmp_table_share(create_table->table);
4791+
saved_tmp_table_share= thd->save_tmp_table_share(table_list->table);
47924792
}
47934793

47944794
if (extra_lock)
@@ -5087,8 +5087,8 @@ bool select_create::send_eof()
50875087
*/
50885088
wsrep_key_arr_t key_arr= {0, 0};
50895089
wsrep_prepare_keys_for_isolation(thd,
5090-
create_table->db.str,
5091-
create_table->table_name.str,
5090+
table_list->db.str,
5091+
table_list->table_name.str,
50925092
table_list,
50935093
&key_arr);
50945094
int rcode= wsrep_thd_append_key(thd, key_arr.keys, key_arr.keys_len,
@@ -5144,8 +5144,8 @@ bool select_create::send_eof()
51445144
else
51455145
lex_string_set(&ddl_log.org_storage_engine_name,
51465146
ha_resolve_storage_engine_name(create_info->db_type));
5147-
ddl_log.org_database= create_table->db;
5148-
ddl_log.org_table= create_table->table_name;
5147+
ddl_log.org_database= table_list->db;
5148+
ddl_log.org_table= table_list->table_name;
51495149
ddl_log.org_table_id= create_info->tabledef_version;
51505150
backup_log_ddl(&ddl_log);
51515151
}
@@ -5260,7 +5260,7 @@ void select_create::abort_result_set()
52605260
m_plock= NULL;
52615261
}
52625262

5263-
drop_open_table(thd, table, &create_table->db, &create_table->table_name);
5263+
drop_open_table(thd, table, &table_list->db, &table_list->table_name);
52645264
table=0; // Safety
52655265
if (thd->log_current_statement())
52665266
{
@@ -5275,7 +5275,7 @@ void select_create::abort_result_set()
52755275
ddl_log_update_xid(&ddl_log_state_create, thd->binlog_xid);
52765276
ddl_log_update_xid(&ddl_log_state_rm, thd->binlog_xid);
52775277
debug_crash_here("ddl_log_create_before_binlog");
5278-
log_drop_table(thd, &create_table->db, &create_table->table_name,
5278+
log_drop_table(thd, &table_list->db, &table_list->table_name,
52795279
&create_info->org_storage_engine_name,
52805280
create_info->db_type == partition_hton,
52815281
&create_info->tabledef_version,
@@ -5291,8 +5291,8 @@ void select_create::abort_result_set()
52915291
ddl_log.query= { C_STRING_WITH_LEN("DROP_AFTER_CREATE") };
52925292
ddl_log.org_partitioned= (create_info->db_type == partition_hton);
52935293
ddl_log.org_storage_engine_name= create_info->org_storage_engine_name;
5294-
ddl_log.org_database= create_table->db;
5295-
ddl_log.org_table= create_table->table_name;
5294+
ddl_log.org_database= table_list->db;
5295+
ddl_log.org_table= table_list->table_name;
52965296
ddl_log.org_table_id= create_info->tabledef_version;
52975297
backup_log_ddl(&ddl_log);
52985298
}

0 commit comments

Comments
 (0)