diff --git a/mysql-test/main/view.result b/mysql-test/main/view.result index 712b8629c09..5eee5105f6d 100644 --- a/mysql-test/main/view.result +++ b/mysql-test/main/view.result @@ -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 # diff --git a/mysql-test/main/view.test b/mysql-test/main/view.test index 49b339c9f4c..68512339179 100644 --- a/mysql-test/main/view.test +++ b/mysql-test/main/view.test @@ -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 # diff --git a/sql/sql_reload.cc b/sql/sql_reload.cc index ddada6ad892..e8ff76f868a 100644 --- a/sql/sql_reload.cc +++ b/sql/sql_reload.cc @@ -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; }