Skip to content
Permalink
Browse files
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.
  • Loading branch information
sanja-byelkin committed Jul 21, 2022
1 parent 0ea221e commit 654236c
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 0 deletions.
@@ -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,13 +601,15 @@ 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(),
table_list->db.str, table_list->table_name.str);
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;
}

0 comments on commit 654236c

Please sign in to comment.