diff options
author | Alexey Botchkov <holyfoot@askmonty.org> | 2021-02-09 00:59:55 +0400 |
---|---|---|
committer | Alexey Botchkov <holyfoot@askmonty.org> | 2021-02-09 00:59:55 +0400 |
commit | 308c28e8a60ed3cbeb33db9154764142d7931923 (patch) | |
tree | eeae192742b55db035b51387b97ecfd3176392af | |
parent | 786bc312b85e58857cb26a24ab6e997ba0fdfc32 (diff) | |
download | mariadb-git-bb-10.6-mdev15888-hf.tar.gz |
MDEV-15888 Implement FLUSH TABLES tbl_name [, tbl_name] ... WITH READ LOCK for views.bb-10.6-mdev15888-hf
Kind of 'naive' solution that surprisingly worked so trying to
understand why.
-rw-r--r-- | mysql-test/main/flush-innodb.result | 2 | ||||
-rw-r--r-- | mysql-test/main/flush-innodb.test | 2 | ||||
-rw-r--r-- | mysql-test/main/flush.result | 10 | ||||
-rw-r--r-- | mysql-test/main/flush.test | 10 | ||||
-rw-r--r-- | sql/sql_reload.cc | 8 | ||||
-rw-r--r-- | sql/sql_yacc.yy | 2 |
6 files changed, 18 insertions, 16 deletions
diff --git a/mysql-test/main/flush-innodb.result b/mysql-test/main/flush-innodb.result index 21e5bda7785..2c886e4f9fc 100644 --- a/mysql-test/main/flush-innodb.result +++ b/mysql-test/main/flush-innodb.result @@ -60,7 +60,7 @@ DROP TABLE export; CREATE VIEW v1 AS SELECT 1; CREATE TEMPORARY TABLE t1 (a INT); FLUSH TABLES v1 FOR EXPORT; -ERROR HY000: 'test.v1' is not of type 'BASE TABLE' +UNLOCK TABLES; FLUSH TABLES t1 FOR EXPORT; ERROR 42S02: Table 'test.t1' doesn't exist FLUSH TABLES non_existent FOR EXPORT; diff --git a/mysql-test/main/flush-innodb.test b/mysql-test/main/flush-innodb.test index bf7b79bb5a3..309ec5de014 100644 --- a/mysql-test/main/flush-innodb.test +++ b/mysql-test/main/flush-innodb.test @@ -93,8 +93,8 @@ DROP TABLE export; CREATE VIEW v1 AS SELECT 1; CREATE TEMPORARY TABLE t1 (a INT); ---error ER_WRONG_OBJECT FLUSH TABLES v1 FOR EXPORT; +UNLOCK TABLES; --error ER_NO_SUCH_TABLE FLUSH TABLES t1 FOR EXPORT; --error ER_NO_SUCH_TABLE diff --git a/mysql-test/main/flush.result b/mysql-test/main/flush.result index 39e0b9432fe..577d6eee401 100644 --- a/mysql-test/main/flush.result +++ b/mysql-test/main/flush.result @@ -295,16 +295,16 @@ create view v1 as select 1; create view v2 as select * from t1; create view v3 as select * from v2; flush table v1, v2, v3 with read lock; -ERROR HY000: 'test.v1' is not of type 'BASE TABLE' +unlock tables; flush table v1 with read lock; -ERROR HY000: 'test.v1' is not of type 'BASE TABLE' +unlock tables; flush table v2 with read lock; -ERROR HY000: 'test.v2' is not of type 'BASE TABLE' +unlock tables; flush table v3 with read lock; -ERROR HY000: 'test.v3' is not of type 'BASE TABLE' +unlock tables; create temporary table v1 (a int); flush table v1 with read lock; -ERROR HY000: 'test.v1' is not of type 'BASE TABLE' +unlock tables; drop view v1; create table v1 (a int); flush table v1 with read lock; diff --git a/mysql-test/main/flush.test b/mysql-test/main/flush.test index 6d76196bf54..d3eaa3e413c 100644 --- a/mysql-test/main/flush.test +++ b/mysql-test/main/flush.test @@ -377,17 +377,17 @@ create view v1 as select 1; create view v2 as select * from t1; create view v3 as select * from v2; ---error ER_WRONG_OBJECT flush table v1, v2, v3 with read lock; ---error ER_WRONG_OBJECT +unlock tables; flush table v1 with read lock; ---error ER_WRONG_OBJECT +unlock tables; flush table v2 with read lock; ---error ER_WRONG_OBJECT +unlock tables; flush table v3 with read lock; +unlock tables; create temporary table v1 (a int); ---error ER_WRONG_OBJECT flush table v1 with read lock; +unlock tables; drop view v1; create table v1 (a int); flush table v1 with read lock; diff --git a/sql/sql_reload.cc b/sql/sql_reload.cc index 8f87d633d19..c146b7693c1 100644 --- a/sql/sql_reload.cc +++ b/sql/sql_reload.cc @@ -543,6 +543,7 @@ bool flush_tables_with_read_lock(THD *thd, TABLE_LIST *all_tables) if (thd->lex->type & REFRESH_READ_LOCK) { +#ifdef MDEV15887 /* Acquire SNW locks on tables to be flushed. Don't acquire global IX and database-scope IX locks on the tables as this will make @@ -559,6 +560,7 @@ 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) table_list->mdl_request.ticket= NULL; +#endif /*MDEV15887*/ } thd->variables.option_bits|= OPTION_TABLE_LOCK; @@ -584,7 +586,8 @@ 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->table->file->ha_table_flags() & HA_CAN_EXPORT)) + if (!(table_list->is_view() || + 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); @@ -598,7 +601,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->table->file->extra(HA_EXTRA_FLUSH)) + if (!table_list->is_view() && + table_list->table->file->extra(HA_EXTRA_FLUSH)) goto error_reset_bits; } } diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy index 5aeb14535e3..dbc1d3c6a3f 100644 --- a/sql/sql_yacc.yy +++ b/sql/sql_yacc.yy @@ -14082,8 +14082,6 @@ opt_flush_lock: for (; tables; tables= tables->next_global) { tables->mdl_request.set_type(MDL_SHARED_NO_WRITE); - /* Don't try to flush views. */ - tables->required_type= TABLE_TYPE_NORMAL; /* Ignore temporary tables. */ tables->open_type= OT_BASE_ONLY; } |