Skip to content

Commit e54643a

Browse files
committed
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
1 parent f186750 commit e54643a

File tree

3 files changed

+31
-28
lines changed

3 files changed

+31
-28
lines changed

sql/sql_base.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2038,8 +2038,8 @@ bool open_table(THD *thd, TABLE_LIST *table_list, Open_table_context *ot_ctx)
20382038
tc_add_table(thd, table);
20392039
}
20402040

2041-
2042-
if (!(flags & MYSQL_OPEN_HAS_MDL_LOCK))
2041+
if (!(flags & MYSQL_OPEN_HAS_MDL_LOCK) &&
2042+
table->s->table_category < TABLE_CATEGORY_INFORMATION)
20432043
{
20442044
/*
20452045
We are not under LOCK TABLES and going to acquire write-lock/

sql/sql_parse.cc

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1180,10 +1180,8 @@ static bool wsrep_tables_accessible_when_detached(const TABLE_LIST *tables)
11801180
{
11811181
for (const TABLE_LIST *table= tables; table; table= table->next_global)
11821182
{
1183-
TABLE_CATEGORY c;
11841183
LEX_CSTRING db= table->db, tn= table->table_name;
1185-
c= get_table_category(&db, &tn);
1186-
if (c != TABLE_CATEGORY_INFORMATION && c != TABLE_CATEGORY_PERFORMANCE)
1184+
if (get_table_category(&db, &tn) < TABLE_CATEGORY_INFORMATION)
11871185
return false;
11881186
}
11891187
return true;

sql/table.h

Lines changed: 28 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -394,28 +394,6 @@ enum enum_table_category
394394
*/
395395
TABLE_CATEGORY_SYSTEM=3,
396396

397-
/**
398-
Information schema tables.
399-
These tables are an interface provided by the system
400-
to inspect the system metadata.
401-
These tables do *not* honor:
402-
- LOCK TABLE t FOR READ/WRITE
403-
- FLUSH TABLES WITH READ LOCK
404-
- SET GLOBAL READ_ONLY = ON
405-
as there is no point in locking explicitly
406-
an INFORMATION_SCHEMA table.
407-
Nothing is directly written to information schema tables.
408-
Note that this value is not used currently,
409-
since information schema tables are not shared,
410-
but implemented as session specific temporary tables.
411-
*/
412-
/*
413-
TODO: Fixing the performance issues of I_S will lead
414-
to I_S tables in the table cache, which should use
415-
this table type.
416-
*/
417-
TABLE_CATEGORY_INFORMATION=4,
418-
419397
/**
420398
Log tables.
421399
These tables are an interface provided by the system
@@ -436,7 +414,33 @@ enum enum_table_category
436414
The server implementation perform writes.
437415
Log tables are cached in the table cache.
438416
*/
439-
TABLE_CATEGORY_LOG=5,
417+
TABLE_CATEGORY_LOG=4,
418+
419+
/*
420+
Types below are read only tables, not affected by FLUSH TABLES or
421+
MDL locks.
422+
*/
423+
/**
424+
Information schema tables.
425+
These tables are an interface provided by the system
426+
to inspect the system metadata.
427+
These tables do *not* honor:
428+
- LOCK TABLE t FOR READ/WRITE
429+
- FLUSH TABLES WITH READ LOCK
430+
- SET GLOBAL READ_ONLY = ON
431+
as there is no point in locking explicitly
432+
an INFORMATION_SCHEMA table.
433+
Nothing is directly written to information schema tables.
434+
Note that this value is not used currently,
435+
since information schema tables are not shared,
436+
but implemented as session specific temporary tables.
437+
*/
438+
/*
439+
TODO: Fixing the performance issues of I_S will lead
440+
to I_S tables in the table cache, which should use
441+
this table type.
442+
*/
443+
TABLE_CATEGORY_INFORMATION=5,
440444

441445
/**
442446
Performance schema tables.
@@ -460,6 +464,7 @@ enum enum_table_category
460464
*/
461465
TABLE_CATEGORY_PERFORMANCE=6
462466
};
467+
463468
typedef enum enum_table_category TABLE_CATEGORY;
464469

465470
TABLE_CATEGORY get_table_category(const LEX_CSTRING *db,

0 commit comments

Comments
 (0)