Skip to content

Commit 4145ebf

Browse files
committed
MDEV-25906: SIGSEGV in flush_tables_with_read_lock on FTWRL or FTFE | SIGSEGV in ha_maria::extra
1 parent 164a64b commit 4145ebf

File tree

5 files changed

+149
-3
lines changed

5 files changed

+149
-3
lines changed

mysql-test/main/flush.result

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -626,3 +626,37 @@ show status like "Threads_cached";
626626
Variable_name Value
627627
Threads_cached 0
628628
set @@global.thread_cache_size=@save_thread_cache_size;
629+
#
630+
# MDEV-25906: SIGSEGV in flush_tables_with_read_lock on FTWRL or FTFE | SIGSEGV in ha_maria::extra
631+
#
632+
CREATE VIEW v0 AS SELECT 1;
633+
CREATE VIEW v1 AS SELECT 1 FROM (SELECT 1) AS d;
634+
CREATE VIEW v2 AS SELECT * FROM v1;
635+
FLUSH TABLE v0 WITH READ LOCK;
636+
DROP VIEW v0;
637+
ERROR HY000: Can't execute the given command because you have active locked tables or an active transaction
638+
UNLOCK TABLES;
639+
FLUSH TABLE v1 WITH READ LOCK;
640+
DROP VIEW v1;
641+
ERROR HY000: Can't execute the given command because you have active locked tables or an active transaction
642+
UNLOCK TABLES;
643+
FLUSH TABLE v2 WITH READ LOCK;
644+
DROP VIEW v2;
645+
ERROR HY000: Can't execute the given command because you have active locked tables or an active transaction
646+
UNLOCK TABLES;
647+
FLUSH TABLE v0 FOR EXPORT;
648+
DROP VIEW v0;
649+
ERROR HY000: Can't execute the given command because you have active locked tables or an active transaction
650+
UNLOCK TABLES;
651+
FLUSH TABLE v1 FOR EXPORT;
652+
DROP VIEW v1;
653+
ERROR HY000: Can't execute the given command because you have active locked tables or an active transaction
654+
UNLOCK TABLES;
655+
FLUSH TABLE v2 FOR EXPORT;
656+
DROP VIEW v2;
657+
ERROR HY000: Can't execute the given command because you have active locked tables or an active transaction
658+
UNLOCK TABLES;
659+
DROP VIEW v2, v1, v0;
660+
#
661+
# End of 10.6 tests
662+
#

mysql-test/main/flush.test

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -745,3 +745,41 @@ set @@global.thread_cache_size=0;
745745
flush threads;
746746
show status like "Threads_cached";
747747
set @@global.thread_cache_size=@save_thread_cache_size;
748+
749+
--echo #
750+
--echo # MDEV-25906: SIGSEGV in flush_tables_with_read_lock on FTWRL or FTFE | SIGSEGV in ha_maria::extra
751+
--echo #
752+
CREATE VIEW v0 AS SELECT 1;
753+
CREATE VIEW v1 AS SELECT 1 FROM (SELECT 1) AS d;
754+
CREATE VIEW v2 AS SELECT * FROM v1;
755+
756+
FLUSH TABLE v0 WITH READ LOCK;
757+
--error ER_LOCK_OR_ACTIVE_TRANSACTION
758+
DROP VIEW v0;
759+
UNLOCK TABLES;
760+
FLUSH TABLE v1 WITH READ LOCK;
761+
--error ER_LOCK_OR_ACTIVE_TRANSACTION
762+
DROP VIEW v1;
763+
UNLOCK TABLES;
764+
FLUSH TABLE v2 WITH READ LOCK;
765+
--error ER_LOCK_OR_ACTIVE_TRANSACTION
766+
DROP VIEW v2;
767+
UNLOCK TABLES;
768+
769+
FLUSH TABLE v0 FOR EXPORT;
770+
--error ER_LOCK_OR_ACTIVE_TRANSACTION
771+
DROP VIEW v0;
772+
UNLOCK TABLES;
773+
FLUSH TABLE v1 FOR EXPORT;
774+
--error ER_LOCK_OR_ACTIVE_TRANSACTION
775+
DROP VIEW v1;
776+
UNLOCK TABLES;
777+
FLUSH TABLE v2 FOR EXPORT;
778+
--error ER_LOCK_OR_ACTIVE_TRANSACTION
779+
DROP VIEW v2;
780+
UNLOCK TABLES;
781+
DROP VIEW v2, v1, v0;
782+
783+
--echo #
784+
--echo # End of 10.6 tests
785+
--echo #

mysql-test/main/flush_notembedded.result

Lines changed: 41 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,55 @@ flush tables mysqltest1.t1 for export;
1414
ERROR 42000: Access denied for user 'u1'@'localhost' to database 'mysqltest1'
1515
create view v as select * from mysqltest1.t1;
1616
create view v2 as select * from v;
17+
create view v3 as select * from (select * from mysqltest1.t1) x;
1718
flush tables v for export;
1819
ERROR 42000: Access denied for user 'u1'@'localhost' to database 'mysqltest1'
1920
flush tables v2 for export;
2021
ERROR 42000: Access denied for user 'u1'@'localhost' to database 'mysqltest1'
22+
flush tables v3 for export;
23+
ERROR 42000: Access denied for user 'u1'@'localhost' to database 'mysqltest1'
2124
disconnect u1;
2225
connection default;
2326
drop database mysqltest1;
24-
drop view v, v2;
27+
drop view v, v2, v3;
2528
drop user u1@localhost;
2629
#
30+
# MDEV-25906: SIGSEGV in flush_tables_with_read_lock on FTWRL or FTFE | SIGSEGV in ha_maria::extra
31+
#
32+
CREATE VIEW v0 AS SELECT * FROM information_schema.columns;
33+
CREATE VIEW v1 AS SELECT * FROM information_schema.collations;
34+
CREATE VIEW v2 AS SELECT * FROM performance_schema.accounts;
35+
#
36+
# first try to flush tables directly
37+
#
38+
FLUSH TABLE information_schema.collations WITH READ LOCK;
39+
ERROR 42000: Access denied for user 'root'@'localhost' to database 'information_schema'
40+
FLUSH TABLE performance_schema.accounts WITH READ LOCK;
41+
ERROR 42000: SELECT, LOCK TABLES command denied to user 'root'@'localhost' for table 'accounts'
42+
FLUSH TABLE information_schema.colums WITH READ LOCK;
43+
ERROR 42000: Access denied for user 'root'@'localhost' to database 'information_schema'
44+
FLUSH TABLE information_schema.collations FOR EXPORT;
45+
ERROR 42000: Access denied for user 'root'@'localhost' to database 'information_schema'
46+
FLUSH TABLE performance_schema.accounts FOR EXPORT;
47+
ERROR 42000: SELECT, LOCK TABLES command denied to user 'root'@'localhost' for table 'accounts'
48+
FLUSH TABLE information_schema.colums FOR EXPORT;
49+
ERROR 42000: Access denied for user 'root'@'localhost' to database 'information_schema'
50+
#
51+
# and now via views
52+
#
53+
FLUSH TABLE v0 WITH READ LOCK;
54+
ERROR 42000: Access denied for user 'root'@'localhost' to database 'information_schema'
55+
FLUSH TABLE v1 WITH READ LOCK;
56+
ERROR 42000: Access denied for user 'root'@'localhost' to database 'information_schema'
57+
FLUSH TABLE v2 WITH READ LOCK;
58+
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
59+
FLUSH TABLE v0 FOR EXPORT;
60+
ERROR 42000: Access denied for user 'root'@'localhost' to database 'information_schema'
61+
FLUSH TABLE v1 FOR EXPORT;
62+
ERROR 42000: Access denied for user 'root'@'localhost' to database 'information_schema'
63+
FLUSH TABLE v2 FOR EXPORT;
64+
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
65+
DROP VIEW v0, v1, v2;
66+
#
2767
# End of 10.6 tests
2868
#

mysql-test/main/flush_notembedded.test

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
source include/not_embedded.inc;
2+
source include/have_perfschema.inc;
23

34
--echo #
45
--echo # MDEV-15888 Implement FLUSH TABLES tbl_name [, tbl_name] ... WITH READ LOCK for views.
@@ -17,16 +18,49 @@ error ER_DBACCESS_DENIED_ERROR;
1718
flush tables mysqltest1.t1 for export;
1819
create view v as select * from mysqltest1.t1;
1920
create view v2 as select * from v;
21+
create view v3 as select * from (select * from mysqltest1.t1) x;
2022
error ER_DBACCESS_DENIED_ERROR;
2123
flush tables v for export;
2224
error ER_DBACCESS_DENIED_ERROR;
2325
flush tables v2 for export;
26+
error ER_DBACCESS_DENIED_ERROR;
27+
flush tables v3 for export;
2428
disconnect u1;
2529
connection default;
2630
drop database mysqltest1;
27-
drop view v, v2;
31+
drop view v, v2, v3;
2832
drop user u1@localhost;
2933

34+
--echo #
35+
--echo # MDEV-25906: SIGSEGV in flush_tables_with_read_lock on FTWRL or FTFE | SIGSEGV in ha_maria::extra
36+
--echo #
37+
CREATE VIEW v0 AS SELECT * FROM information_schema.columns; # Aria
38+
CREATE VIEW v1 AS SELECT * FROM information_schema.collations; # Heap
39+
CREATE VIEW v2 AS SELECT * FROM performance_schema.accounts;
40+
41+
--disable_abort_on_error
42+
--echo #
43+
--echo # first try to flush tables directly
44+
--echo #
45+
FLUSH TABLE information_schema.collations WITH READ LOCK;
46+
FLUSH TABLE performance_schema.accounts WITH READ LOCK;
47+
FLUSH TABLE information_schema.colums WITH READ LOCK;
48+
FLUSH TABLE information_schema.collations FOR EXPORT;
49+
FLUSH TABLE performance_schema.accounts FOR EXPORT;
50+
FLUSH TABLE information_schema.colums FOR EXPORT;
51+
52+
--echo #
53+
--echo # and now via views
54+
--echo #
55+
FLUSH TABLE v0 WITH READ LOCK;
56+
FLUSH TABLE v1 WITH READ LOCK;
57+
FLUSH TABLE v2 WITH READ LOCK;
58+
FLUSH TABLE v0 FOR EXPORT;
59+
FLUSH TABLE v1 FOR EXPORT;
60+
FLUSH TABLE v2 FOR EXPORT;
61+
--enable_abort_on_error
62+
DROP VIEW v0, v1, v2;
63+
3064
--echo #
3165
--echo # End of 10.6 tests
3266
--echo #

sql/sql_reload.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -598,7 +598,7 @@ bool flush_tables_with_read_lock(THD *thd, TABLE_LIST *all_tables)
598598
table_list->hide_view_error(thd);
599599
goto error_reset_bits;
600600
}
601-
if (table_list->is_view())
601+
if (table_list->is_view_or_derived())
602602
continue;
603603
if (thd->lex->type & REFRESH_FOR_EXPORT &&
604604
!(table_list->table->file->ha_table_flags() & HA_CAN_EXPORT))

0 commit comments

Comments
 (0)