Commit 654236c0 authored by Oleksandr Byelkin's avatar Oleksandr Byelkin

MDEV-26456: SIGSEGV in flush_tables_with_read_lock on FLUSH TABLE

It is legal that open table can leave unopened tables in SP and other
parts of the code shoud expect it.
parent 0ea221e1
......@@ -6920,5 +6920,20 @@ Drop View v3;
Drop View v4;
Drop table t1;
#
# MDEV-26456: SIGSEGV in flush_tables_with_read_lock on FLUSH TABLE
#
CREATE FUNCTION f() RETURNS INT RETURN (SELECT 1 FROM t);
CREATE VIEW v AS SELECT f();
SELECT * FROM v;
ERROR HY000: View 'test.v' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them
FLUSH TABLE v WITH READ LOCK;
UNLOCK TABLES;
FLUSH TABLES v FOR EXPORT;
UNLOCK TABLES;
SELECT * FROM v;
ERROR HY000: View 'test.v' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them
DROP VIEW v;
DROP FUNCTION f;
#
# End of 10.6 tests
#
......@@ -6653,6 +6653,24 @@ Drop View v3;
Drop View v4;
Drop table t1;
--echo #
--echo # MDEV-26456: SIGSEGV in flush_tables_with_read_lock on FLUSH TABLE
--echo #
CREATE FUNCTION f() RETURNS INT RETURN (SELECT 1 FROM t);
CREATE VIEW v AS SELECT f();
--error ER_VIEW_INVALID
SELECT * FROM v;
FLUSH TABLE v WITH READ LOCK;
UNLOCK TABLES;
FLUSH TABLES v FOR EXPORT;
UNLOCK TABLES;
--error ER_VIEW_INVALID
SELECT * FROM v;
DROP VIEW v;
DROP FUNCTION f;
--echo #
--echo # End of 10.6 tests
--echo #
......@@ -601,6 +601,7 @@ bool flush_tables_with_read_lock(THD *thd, TABLE_LIST *all_tables)
if (table_list->is_view_or_derived())
continue;
if (thd->lex->type & REFRESH_FOR_EXPORT &&
table_list->table &&
!(table_list->table->file->ha_table_flags() & HA_CAN_EXPORT))
{
my_error(ER_ILLEGAL_HA, MYF(0),table_list->table->file->table_type(),
......@@ -608,6 +609,7 @@ bool flush_tables_with_read_lock(THD *thd, TABLE_LIST *all_tables)
goto error_reset_bits;
}
if (thd->lex->type & REFRESH_READ_LOCK &&
table_list->table &&
table_list->table->file->extra(HA_EXTRA_FLUSH))
goto error_reset_bits;
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment