summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOleksandr Byelkin <sanja@mariadb.com>2021-07-01 11:20:29 +0200
committerOleksandr Byelkin <sanja@mariadb.com>2021-07-01 11:20:29 +0200
commitb29ec61724dcac751592b7c83d33d2d600b6bc2e (patch)
tree84402b2d00fad9cc538db2b197ee1398a419cf36
parent83684fc9a4d81f15fee1888123cc7f7a4e298c4f (diff)
downloadmariadb-git-bb-10.6-MDEV-25906-sanja.tar.gz
MDEV-25906: SIGSEGV in flush_tables_with_read_lock on FTWRL or FTFE | SIGSEGV in ha_maria::extrabb-10.6-MDEV-25906-sanja
Fixed check of derived tables of all kinds (view, derived, information schema).
-rw-r--r--mysql-test/main/flush_derived.result54
-rw-r--r--mysql-test/main/flush_derived.test57
-rw-r--r--sql/sql_reload.cc18
-rw-r--r--sql/table.h5
4 files changed, 130 insertions, 4 deletions
diff --git a/mysql-test/main/flush_derived.result b/mysql-test/main/flush_derived.result
new file mode 100644
index 00000000000..09889ff7e86
--- /dev/null
+++ b/mysql-test/main/flush_derived.result
@@ -0,0 +1,54 @@
+#
+# 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;
+CREATE VIEW v3 AS SELECT * FROM information_schema.collations;
+CREATE VIEW v4 AS SELECT * FROM performance_schema.accounts;
+CREATE VIEW v5 AS SELECT * FROM information_schema.COLUMNS;
+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 v3 WITH READ LOCK;
+DROP VIEW v3;
+ERROR HY000: Can't execute the given command because you have active locked tables or an active transaction
+UNLOCK TABLES;
+FLUSH TABLE v4 WITH READ LOCK;
+DROP VIEW v4;
+ERROR HY000: Can't execute the given command because you have active locked tables or an active transaction
+UNLOCK TABLES;
+FLUSH TABLE v5 WITH READ LOCK;
+DROP VIEW v5;
+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;
+FLUSH TABLE v3 FOR EXPORT;
+ERROR HY000: Storage engine information_schema of the table `information_schema`.`collations` doesn't have this option
+FLUSH TABLE v4 FOR EXPORT;
+ERROR HY000: Storage engine PERFORMANCE_SCHEMA of the table `performance_schema`.`accounts` doesn't have this option
+FLUSH TABLE v5 FOR EXPORT;
+ERROR HY000: Storage engine information_schema of the table `information_schema`.`COLUMNS` doesn't have this option
+DROP VIEW v2, v1, v0, v3, v4, v5;
+# End of 10.6 tests
diff --git a/mysql-test/main/flush_derived.test b/mysql-test/main/flush_derived.test
new file mode 100644
index 00000000000..dd2a9d6dead
--- /dev/null
+++ b/mysql-test/main/flush_derived.test
@@ -0,0 +1,57 @@
+--source include/have_perfschema.inc
+
+--echo #
+--echo # MDEV-25906: SIGSEGV in flush_tables_with_read_lock on FTWRL
+--echo # 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;
+CREATE VIEW v3 AS SELECT * FROM information_schema.collations;
+CREATE VIEW v4 AS SELECT * FROM performance_schema.accounts;
+CREATE VIEW v5 AS SELECT * FROM information_schema.COLUMNS;
+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 v3 WITH READ LOCK;
+--error ER_LOCK_OR_ACTIVE_TRANSACTION
+DROP VIEW v3;
+UNLOCK TABLES;
+FLUSH TABLE v4 WITH READ LOCK;
+--error ER_LOCK_OR_ACTIVE_TRANSACTION
+DROP VIEW v4;
+UNLOCK TABLES;
+FLUSH TABLE v5 WITH READ LOCK;
+--error ER_LOCK_OR_ACTIVE_TRANSACTION
+DROP VIEW v5;
+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;
+--error ER_ILLEGAL_HA
+FLUSH TABLE v3 FOR EXPORT;
+--error ER_ILLEGAL_HA
+FLUSH TABLE v4 FOR EXPORT;
+--error ER_ILLEGAL_HA
+FLUSH TABLE v5 FOR EXPORT;
+DROP VIEW v2, v1, v0, v3, v4, v5;
+
+--echo # End of 10.6 tests
diff --git a/sql/sql_reload.cc b/sql/sql_reload.cc
index 0fa2fa10df8..e41da9680b0 100644
--- a/sql/sql_reload.cc
+++ b/sql/sql_reload.cc
@@ -592,10 +592,19 @@ bool flush_tables_with_read_lock(THD *thd, TABLE_LIST *all_tables)
for (TABLE_LIST *table_list= all_tables; table_list;
table_list= table_list->next_global)
{
- if (!(table_list->is_view() ||
- table_list->table->file->ha_table_flags() & HA_CAN_EXPORT))
+ /*
+ We allow all deriveds and view here, but prohibit information_schema
+ tables (explicitly) and performance_schema tables (implicetly:
+ engine do not suport export)
+ */
+ if (table_list->is_non_derived() &&
+ (!table_list->is_base_table() ||
+ !(table_list->table->file->ha_table_flags() & HA_CAN_EXPORT)))
{
- my_error(ER_ILLEGAL_HA, MYF(0),table_list->table->file->table_type(),
+ my_error(ER_ILLEGAL_HA, MYF(0),
+ (table_list->is_base_table() ?
+ table_list->table->file->table_type():
+ "information_schema"),
table_list->db.str, table_list->table_name.str);
goto error_reset_bits;
}
@@ -607,7 +616,8 @@ bool flush_tables_with_read_lock(THD *thd, TABLE_LIST *all_tables)
for (auto table_list= all_tables; table_list;
table_list= table_list->next_global)
{
- if (!table_list->is_view() &&
+ if (table_list->table &&
+ table_list->is_base_table() &&
table_list->table->file->extra(HA_EXTRA_FLUSH))
goto error_reset_bits;
}
diff --git a/sql/table.h b/sql/table.h
index 183ade8f1d9..313dde4731a 100644
--- a/sql/table.h
+++ b/sql/table.h
@@ -2733,6 +2733,11 @@ struct TABLE_LIST
m_table_ref_version == s->get_table_ref_version());
}
+ bool is_base_table()
+ {
+ return m_table_ref_type == TABLE_REF_BASE_TABLE;
+ }
+
/**
Record the value of metadata version of the corresponding
table definition cache element in this parse tree node.