From e54643a0637d232f529516de4727b0f976a4e08c Mon Sep 17 00:00:00 2001 From: Monty Date: Tue, 13 Nov 2018 01:02:53 +0200 Subject: [PATCH] Simplify test for updateable TABLE_CATEGORY's - Re-numbered enum_table_category to make some tests easier - Moved TABLE_CATEGORY_INFORMATION to be first CATEGORY of virtual tables - Don't take MDL locks for not updateable table category's --- sql/sql_base.cc | 4 ++-- sql/sql_parse.cc | 4 +--- sql/table.h | 51 ++++++++++++++++++++++++++---------------------- 3 files changed, 31 insertions(+), 28 deletions(-) diff --git a/sql/sql_base.cc b/sql/sql_base.cc index fa5c4570694..ac63da91864 100644 --- a/sql/sql_base.cc +++ b/sql/sql_base.cc @@ -2038,8 +2038,8 @@ retry_share: tc_add_table(thd, table); } - - if (!(flags & MYSQL_OPEN_HAS_MDL_LOCK)) + if (!(flags & MYSQL_OPEN_HAS_MDL_LOCK) && + table->s->table_category < TABLE_CATEGORY_INFORMATION) { /* We are not under LOCK TABLES and going to acquire write-lock/ diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index 6a2af72e351..1b1c154d78a 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -1180,10 +1180,8 @@ static bool wsrep_tables_accessible_when_detached(const TABLE_LIST *tables) { for (const TABLE_LIST *table= tables; table; table= table->next_global) { - TABLE_CATEGORY c; LEX_CSTRING db= table->db, tn= table->table_name; - c= get_table_category(&db, &tn); - if (c != TABLE_CATEGORY_INFORMATION && c != TABLE_CATEGORY_PERFORMANCE) + if (get_table_category(&db, &tn) < TABLE_CATEGORY_INFORMATION) return false; } return true; diff --git a/sql/table.h b/sql/table.h index 2b3fe1c20d4..38129ef98f8 100644 --- a/sql/table.h +++ b/sql/table.h @@ -394,28 +394,6 @@ enum enum_table_category */ TABLE_CATEGORY_SYSTEM=3, - /** - Information schema tables. - These tables are an interface provided by the system - to inspect the system metadata. - These tables do *not* honor: - - LOCK TABLE t FOR READ/WRITE - - FLUSH TABLES WITH READ LOCK - - SET GLOBAL READ_ONLY = ON - as there is no point in locking explicitly - an INFORMATION_SCHEMA table. - Nothing is directly written to information schema tables. - Note that this value is not used currently, - since information schema tables are not shared, - but implemented as session specific temporary tables. - */ - /* - TODO: Fixing the performance issues of I_S will lead - to I_S tables in the table cache, which should use - this table type. - */ - TABLE_CATEGORY_INFORMATION=4, - /** Log tables. These tables are an interface provided by the system @@ -436,7 +414,33 @@ enum enum_table_category The server implementation perform writes. Log tables are cached in the table cache. */ - TABLE_CATEGORY_LOG=5, + TABLE_CATEGORY_LOG=4, + + /* + Types below are read only tables, not affected by FLUSH TABLES or + MDL locks. + */ + /** + Information schema tables. + These tables are an interface provided by the system + to inspect the system metadata. + These tables do *not* honor: + - LOCK TABLE t FOR READ/WRITE + - FLUSH TABLES WITH READ LOCK + - SET GLOBAL READ_ONLY = ON + as there is no point in locking explicitly + an INFORMATION_SCHEMA table. + Nothing is directly written to information schema tables. + Note that this value is not used currently, + since information schema tables are not shared, + but implemented as session specific temporary tables. + */ + /* + TODO: Fixing the performance issues of I_S will lead + to I_S tables in the table cache, which should use + this table type. + */ + TABLE_CATEGORY_INFORMATION=5, /** Performance schema tables. @@ -460,6 +464,7 @@ enum enum_table_category */ TABLE_CATEGORY_PERFORMANCE=6 }; + typedef enum enum_table_category TABLE_CATEGORY; TABLE_CATEGORY get_table_category(const LEX_CSTRING *db,