Skip to content

Commit d8da97b

Browse files
committed
MDEV-14762 Server crashes in MDL_ticket::has_stronger_or_equal_type upon inserting into temporary sequence
Fix is to not upgrade MDL locks for temporary tables
1 parent 3dd0166 commit d8da97b

File tree

3 files changed

+22
-3
lines changed

3 files changed

+22
-3
lines changed

mysql-test/suite/sql_sequence/temporary.result

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,10 @@ select * from s1;
1010
next_not_cached_value minimum_value maximum_value start_value increment cache_size cycle_option cycle_count
1111
1001 1 9223372036854775806 1 1 1000 0 0
1212
drop temporary sequence s1;
13+
#
14+
# MDEV-14762 Server crashes in MDL_ticket::has_stronger_or_equal_type
15+
# upon inserting into temporary sequence
16+
#
17+
CREATE TEMPORARY SEQUENCE s1 ENGINE=InnoDB;
18+
INSERT INTO s1 VALUES (1, 1, 1000, 1, 1, 1, 1, 0);
19+
DROP TEMPORARY SEQUENCE s1;

mysql-test/suite/sql_sequence/temporary.test

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,12 @@ alter table s1 engine myisam;
1414
select nextval(s1);
1515
select * from s1;
1616
drop temporary sequence s1;
17+
18+
--echo #
19+
--echo # MDEV-14762 Server crashes in MDL_ticket::has_stronger_or_equal_type
20+
--echo # upon inserting into temporary sequence
21+
--echo #
22+
23+
CREATE TEMPORARY SEQUENCE s1 ENGINE=InnoDB;
24+
INSERT INTO s1 VALUES (1, 1, 1000, 1, 1, 1, 1, 0);
25+
DROP TEMPORARY SEQUENCE s1;

sql/ha_sequence.cc

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -237,9 +237,12 @@ int ha_sequence::write_row(uchar *buf)
237237
THD *thd= table->in_use;
238238
if (thd->lock->table_count != 1)
239239
DBUG_RETURN(ER_WRONG_INSERT_INTO_SEQUENCE);
240-
if (thd->mdl_context.upgrade_shared_lock(table->mdl_ticket, MDL_EXCLUSIVE,
241-
thd->variables.lock_wait_timeout))
242-
DBUG_RETURN(ER_LOCK_WAIT_TIMEOUT);
240+
if (table->s->tmp_table == NO_TMP_TABLE &&
241+
thd->mdl_context.upgrade_shared_lock(table->mdl_ticket,
242+
MDL_EXCLUSIVE,
243+
thd->variables.
244+
lock_wait_timeout))
245+
DBUG_RETURN(ER_LOCK_WAIT_TIMEOUT);
243246

244247
tmp_seq.read_fields(table);
245248
if (tmp_seq.check_and_adjust(0))

0 commit comments

Comments
 (0)