Skip to content

Commit 152ed78

Browse files
committed
MDEV-37345 sequences and prelocking (11.4 version)
table->pos_in_table_list is problematic, it can become dangled when an SP is reparsed. Let's avoid it and directly prefer TABLEs where a sequence is ready for inserts. followup for 516f68a
1 parent 1093a2f commit 152ed78

File tree

1 file changed

+4
-8
lines changed

1 file changed

+4
-8
lines changed

sql/sql_base.cc

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2048,16 +2048,12 @@ bool open_table(THD *thd, TABLE_LIST *table_list, Open_table_context *ot_ctx)
20482048
{
20492049
int distance= ((int) table->reginfo.lock_type -
20502050
(int) table_list->lock_type) * 2;
2051-
TABLE_LIST *tl= thd->locked_tables_mode == LTM_PRELOCKED
2052-
? table->pos_in_table_list : table->pos_in_locked_tables;
20532051
/*
2054-
note, that merge table children are automatically added to
2055-
prelocking set in ha_myisammrg::add_children_list(), but their
2056-
TABLE_LIST's are on the execution arena, so tl will be invalid
2057-
on the second execution. Let's just skip them below.
2052+
if we need a table for inserting, make sure it has
2053+
its internal tables (a.k.a. sequences) ready
20582054
*/
2059-
if (table_list->parent_l || !tl ||
2060-
table_list->for_insert_data != tl->for_insert_data)
2055+
if (table->internal_tables &&
2056+
table_list->for_insert_data == !table->internal_tables->table)
20612057
distance|= 1;
20622058

20632059
/*

0 commit comments

Comments
 (0)