Skip to content

Commit c2ebe81

Browse files
author
Alexey Botchkov
committed
MDEV-25837 Assertion `thd->locked_tables_mode == LTM_NONE' failed in Locked_tables_list::init_locked_tables.
don't do prelocking for the FLUSH command.
1 parent 0237e9b commit c2ebe81

File tree

3 files changed

+26
-1
lines changed

3 files changed

+26
-1
lines changed

mysql-test/main/flush.result

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -606,6 +606,17 @@ drop view v1, v2;
606606
drop table t1;
607607
disconnect con1;
608608
#
609+
# MDEV-25837 Assertion `thd->locked_tables_mode == LTM_NONE' failed in Locked_tables_list::init_locked_tables.
610+
#
611+
CREATE FUNCTION f() RETURNS INTEGER RETURN 1;
612+
CREATE TABLE t (a INT);
613+
CREATE VIEW v AS SELECT 2 FROM t WHERE f() < 3;
614+
FLUSH TABLE v WITH READ LOCK;
615+
UNLOCK TABLES;
616+
DROP VIEW v;
617+
DROP FUNCTION f;
618+
DROP TABLE t;
619+
#
609620
# Test FLUSH THREADS
610621
#
611622
set @save_thread_cache_size=@@global.thread_cache_size;

mysql-test/main/flush.test

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -722,6 +722,19 @@ drop view v1, v2;
722722
drop table t1;
723723
disconnect con1;
724724

725+
--echo #
726+
--echo # MDEV-25837 Assertion `thd->locked_tables_mode == LTM_NONE' failed in Locked_tables_list::init_locked_tables.
727+
--echo #
728+
729+
CREATE FUNCTION f() RETURNS INTEGER RETURN 1;
730+
CREATE TABLE t (a INT);
731+
CREATE VIEW v AS SELECT 2 FROM t WHERE f() < 3;
732+
FLUSH TABLE v WITH READ LOCK;
733+
734+
UNLOCK TABLES;
735+
DROP VIEW v;
736+
DROP FUNCTION f;
737+
DROP TABLE t;
725738

726739
--echo #
727740
--echo # Test FLUSH THREADS

sql/sql_base.cc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5553,7 +5553,8 @@ bool lock_tables(THD *thd, TABLE_LIST *tables, uint count, uint flags)
55535553
DEBUG_SYNC(thd, "after_lock_tables_takes_lock");
55545554

55555555
if (thd->lex->requires_prelocking() &&
5556-
thd->lex->sql_command != SQLCOM_LOCK_TABLES)
5556+
thd->lex->sql_command != SQLCOM_LOCK_TABLES &&
5557+
thd->lex->sql_command != SQLCOM_FLUSH)
55575558
{
55585559
/*
55595560
We just have done implicit LOCK TABLES, and now we have

0 commit comments

Comments
 (0)