Skip to content

Commit 958e634

Browse files
committed
Fixed failure in mtr --ps sql_sequence.create sql_sequence.read_only
Problem was that we got an error in sequence_insert while opening the newly created sequence table in an prepared statement as the table id didn't match. Fixed by temporarly removing the reprepare observer during sequence_insert as there can never be a table missmatch in this case.
1 parent 099e87e commit 958e634

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

sql/sql_sequence.cc

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -263,6 +263,7 @@ bool sequence_insert(THD *thd, LEX *lex, TABLE_LIST *table_list)
263263
int error;
264264
TABLE *table;
265265
TABLE_LIST::enum_open_strategy save_open_strategy;
266+
Reprepare_observer *save_reprepare_observer;
266267
sequence_definition *seq= lex->create_info.seq_create_info;
267268
bool temporary_table= table_list->table != 0;
268269
MY_BITMAP *save_write_set;
@@ -281,13 +282,20 @@ bool sequence_insert(THD *thd, LEX *lex, TABLE_LIST *table_list)
281282
*/
282283
thd->open_options|= HA_OPEN_FOR_CREATE;
283284
save_open_strategy= table_list->open_strategy;
285+
/*
286+
We have to reset the reprepare observer to be able to open the
287+
table under prepared statements.
288+
*/
289+
save_reprepare_observer= thd->m_reprepare_observer;
290+
thd->m_reprepare_observer= 0;
284291
table_list->open_strategy= TABLE_LIST::OPEN_IF_EXISTS;
285292
table_list->open_type= OT_BASE_ONLY;
286293
error= open_and_lock_tables(thd, table_list, FALSE,
287294
MYSQL_LOCK_IGNORE_TIMEOUT |
288295
MYSQL_OPEN_HAS_MDL_LOCK);
289296
table_list->open_strategy= save_open_strategy;
290297
thd->open_options&= ~HA_OPEN_FOR_CREATE;
298+
thd->m_reprepare_observer= save_reprepare_observer;
291299
if (error)
292300
DBUG_RETURN(TRUE); /* purify inspected */
293301
}

0 commit comments

Comments
 (0)