Commit 4145ebf9 authored by Sergei Golubchik's avatar Sergei Golubchik

MDEV-25906: SIGSEGV in flush_tables_with_read_lock on FTWRL or FTFE | SIGSEGV in ha_maria::extra

parent 164a64ba
......@@ -626,3 +626,37 @@ show status like "Threads_cached";
Variable_name Value
Threads_cached 0
set @@global.thread_cache_size=@save_thread_cache_size;
#
# MDEV-25906: SIGSEGV in flush_tables_with_read_lock on FTWRL or FTFE | SIGSEGV in ha_maria::extra
#
CREATE VIEW v0 AS SELECT 1;
CREATE VIEW v1 AS SELECT 1 FROM (SELECT 1) AS d;
CREATE VIEW v2 AS SELECT * FROM v1;
FLUSH TABLE v0 WITH READ LOCK;
DROP VIEW v0;
ERROR HY000: Can't execute the given command because you have active locked tables or an active transaction
UNLOCK TABLES;
FLUSH TABLE v1 WITH READ LOCK;
DROP VIEW v1;
ERROR HY000: Can't execute the given command because you have active locked tables or an active transaction
UNLOCK TABLES;
FLUSH TABLE v2 WITH READ LOCK;
DROP VIEW v2;
ERROR HY000: Can't execute the given command because you have active locked tables or an active transaction
UNLOCK TABLES;
FLUSH TABLE v0 FOR EXPORT;
DROP VIEW v0;
ERROR HY000: Can't execute the given command because you have active locked tables or an active transaction
UNLOCK TABLES;
FLUSH TABLE v1 FOR EXPORT;
DROP VIEW v1;
ERROR HY000: Can't execute the given command because you have active locked tables or an active transaction
UNLOCK TABLES;
FLUSH TABLE v2 FOR EXPORT;
DROP VIEW v2;
ERROR HY000: Can't execute the given command because you have active locked tables or an active transaction
UNLOCK TABLES;
DROP VIEW v2, v1, v0;
#
# End of 10.6 tests
#
......@@ -745,3 +745,41 @@ set @@global.thread_cache_size=0;
flush threads;
show status like "Threads_cached";
set @@global.thread_cache_size=@save_thread_cache_size;
--echo #
--echo # MDEV-25906: SIGSEGV in flush_tables_with_read_lock on FTWRL or FTFE | SIGSEGV in ha_maria::extra
--echo #
CREATE VIEW v0 AS SELECT 1;
CREATE VIEW v1 AS SELECT 1 FROM (SELECT 1) AS d;
CREATE VIEW v2 AS SELECT * FROM v1;
FLUSH TABLE v0 WITH READ LOCK;
--error ER_LOCK_OR_ACTIVE_TRANSACTION
DROP VIEW v0;
UNLOCK TABLES;
FLUSH TABLE v1 WITH READ LOCK;
--error ER_LOCK_OR_ACTIVE_TRANSACTION
DROP VIEW v1;
UNLOCK TABLES;
FLUSH TABLE v2 WITH READ LOCK;
--error ER_LOCK_OR_ACTIVE_TRANSACTION
DROP VIEW v2;
UNLOCK TABLES;
FLUSH TABLE v0 FOR EXPORT;
--error ER_LOCK_OR_ACTIVE_TRANSACTION
DROP VIEW v0;
UNLOCK TABLES;
FLUSH TABLE v1 FOR EXPORT;
--error ER_LOCK_OR_ACTIVE_TRANSACTION
DROP VIEW v1;
UNLOCK TABLES;
FLUSH TABLE v2 FOR EXPORT;
--error ER_LOCK_OR_ACTIVE_TRANSACTION
DROP VIEW v2;
UNLOCK TABLES;
DROP VIEW v2, v1, v0;
--echo #
--echo # End of 10.6 tests
--echo #
......@@ -14,15 +14,55 @@ flush tables mysqltest1.t1 for export;
ERROR 42000: Access denied for user 'u1'@'localhost' to database 'mysqltest1'
create view v as select * from mysqltest1.t1;
create view v2 as select * from v;
create view v3 as select * from (select * from mysqltest1.t1) x;
flush tables v for export;
ERROR 42000: Access denied for user 'u1'@'localhost' to database 'mysqltest1'
flush tables v2 for export;
ERROR 42000: Access denied for user 'u1'@'localhost' to database 'mysqltest1'
flush tables v3 for export;
ERROR 42000: Access denied for user 'u1'@'localhost' to database 'mysqltest1'
disconnect u1;
connection default;
drop database mysqltest1;
drop view v, v2;
drop view v, v2, v3;
drop user u1@localhost;
#
# MDEV-25906: SIGSEGV in flush_tables_with_read_lock on FTWRL or FTFE | SIGSEGV in ha_maria::extra
#
CREATE VIEW v0 AS SELECT * FROM information_schema.columns;
CREATE VIEW v1 AS SELECT * FROM information_schema.collations;
CREATE VIEW v2 AS SELECT * FROM performance_schema.accounts;
#
# first try to flush tables directly
#
FLUSH TABLE information_schema.collations WITH READ LOCK;
ERROR 42000: Access denied for user 'root'@'localhost' to database 'information_schema'
FLUSH TABLE performance_schema.accounts WITH READ LOCK;
ERROR 42000: SELECT, LOCK TABLES command denied to user 'root'@'localhost' for table 'accounts'
FLUSH TABLE information_schema.colums WITH READ LOCK;
ERROR 42000: Access denied for user 'root'@'localhost' to database 'information_schema'
FLUSH TABLE information_schema.collations FOR EXPORT;
ERROR 42000: Access denied for user 'root'@'localhost' to database 'information_schema'
FLUSH TABLE performance_schema.accounts FOR EXPORT;
ERROR 42000: SELECT, LOCK TABLES command denied to user 'root'@'localhost' for table 'accounts'
FLUSH TABLE information_schema.colums FOR EXPORT;
ERROR 42000: Access denied for user 'root'@'localhost' to database 'information_schema'
#
# and now via views
#
FLUSH TABLE v0 WITH READ LOCK;
ERROR 42000: Access denied for user 'root'@'localhost' to database 'information_schema'
FLUSH TABLE v1 WITH READ LOCK;
ERROR 42000: Access denied for user 'root'@'localhost' to database 'information_schema'
FLUSH TABLE v2 WITH READ LOCK;
ERROR HY000: View 'test.v2' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them
FLUSH TABLE v0 FOR EXPORT;
ERROR 42000: Access denied for user 'root'@'localhost' to database 'information_schema'
FLUSH TABLE v1 FOR EXPORT;
ERROR 42000: Access denied for user 'root'@'localhost' to database 'information_schema'
FLUSH TABLE v2 FOR EXPORT;
ERROR HY000: View 'test.v2' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them
DROP VIEW v0, v1, v2;
#
# End of 10.6 tests
#
source include/not_embedded.inc;
source include/have_perfschema.inc;
--echo #
--echo # MDEV-15888 Implement FLUSH TABLES tbl_name [, tbl_name] ... WITH READ LOCK for views.
......@@ -17,16 +18,49 @@ error ER_DBACCESS_DENIED_ERROR;
flush tables mysqltest1.t1 for export;
create view v as select * from mysqltest1.t1;
create view v2 as select * from v;
create view v3 as select * from (select * from mysqltest1.t1) x;
error ER_DBACCESS_DENIED_ERROR;
flush tables v for export;
error ER_DBACCESS_DENIED_ERROR;
flush tables v2 for export;
error ER_DBACCESS_DENIED_ERROR;
flush tables v3 for export;
disconnect u1;
connection default;
drop database mysqltest1;
drop view v, v2;
drop view v, v2, v3;
drop user u1@localhost;
--echo #
--echo # MDEV-25906: SIGSEGV in flush_tables_with_read_lock on FTWRL or FTFE | SIGSEGV in ha_maria::extra
--echo #
CREATE VIEW v0 AS SELECT * FROM information_schema.columns; # Aria
CREATE VIEW v1 AS SELECT * FROM information_schema.collations; # Heap
CREATE VIEW v2 AS SELECT * FROM performance_schema.accounts;
--disable_abort_on_error
--echo #
--echo # first try to flush tables directly
--echo #
FLUSH TABLE information_schema.collations WITH READ LOCK;
FLUSH TABLE performance_schema.accounts WITH READ LOCK;
FLUSH TABLE information_schema.colums WITH READ LOCK;
FLUSH TABLE information_schema.collations FOR EXPORT;
FLUSH TABLE performance_schema.accounts FOR EXPORT;
FLUSH TABLE information_schema.colums FOR EXPORT;
--echo #
--echo # and now via views
--echo #
FLUSH TABLE v0 WITH READ LOCK;
FLUSH TABLE v1 WITH READ LOCK;
FLUSH TABLE v2 WITH READ LOCK;
FLUSH TABLE v0 FOR EXPORT;
FLUSH TABLE v1 FOR EXPORT;
FLUSH TABLE v2 FOR EXPORT;
--enable_abort_on_error
DROP VIEW v0, v1, v2;
--echo #
--echo # End of 10.6 tests
--echo #
......@@ -598,7 +598,7 @@ bool flush_tables_with_read_lock(THD *thd, TABLE_LIST *all_tables)
table_list->hide_view_error(thd);
goto error_reset_bits;
}
if (table_list->is_view())
if (table_list->is_view_or_derived())
continue;
if (thd->lex->type & REFRESH_FOR_EXPORT &&
!(table_list->table->file->ha_table_flags() & HA_CAN_EXPORT))
......
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