diff --git a/mysql-test/main/alter_table.result b/mysql-test/main/alter_table.result index a2a7310d2ea..f9a208dfe95 100644 --- a/mysql-test/main/alter_table.result +++ b/mysql-test/main/alter_table.result @@ -991,10 +991,14 @@ CREATE TEMPORARY TABLE `#sql1` (c1 INT); CREATE TEMPORARY TABLE `@0023sql2` (c1 INT); SHOW TABLES; Tables_in_test +@0023sql2 +#sql1 ALTER TABLE `#sql1` RENAME `@0023sql1`; ALTER TABLE `@0023sql2` RENAME `#sql2`; SHOW TABLES; Tables_in_test +#sql2 +@0023sql1 INSERT INTO `#sql2` VALUES (1); INSERT INTO `@0023sql1` VALUES (2); SHOW CREATE TABLE `#sql2`; diff --git a/mysql-test/main/create_or_replace2.result b/mysql-test/main/create_or_replace2.result index c84d54004ca..c02a384e152 100644 --- a/mysql-test/main/create_or_replace2.result +++ b/mysql-test/main/create_or_replace2.result @@ -9,6 +9,7 @@ CREATE OR REPLACE TABLE t1 LIKE tmp; SET debug_dbug=@old_debug; SHOW TABLES; Tables_in_test +tmp t1 show create table t1; Table Create Table diff --git a/mysql-test/main/grant5.result b/mysql-test/main/grant5.result index 76a5f5375e9..ef7c173b9e6 100644 --- a/mysql-test/main/grant5.result +++ b/mysql-test/main/grant5.result @@ -260,10 +260,13 @@ connect con1,localhost,foo,,db; create temporary table tmp (a int, key(a)); show tables; Tables_in_db +tmp show full tables; Tables_in_db Table_type +tmp TEMPORARY TABLE show table status; Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment Max_index_length Temporary +tmp MyISAM 10 Fixed 0 0 X X X X X X X X latin1_swedish_ci NULL X Y show index in tmp; Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Ignored tmp 1 a 1 a A NULL NULL NULL YES BTREE NO diff --git a/mysql-test/main/grant5.test b/mysql-test/main/grant5.test index 49e0ab1abf1..5a09288404d 100644 --- a/mysql-test/main/grant5.test +++ b/mysql-test/main/grant5.test @@ -225,6 +225,7 @@ grant create temporary tables on db.* to bar@localhost; create temporary table tmp (a int, key(a)); show tables; show full tables; +--replace_column 7 X 8 X 9 X 10 X 11 X 12 X 13 X 14 X 19 X show table status; show index in tmp; show columns in tmp; diff --git a/mysql-test/main/information_schema_temp_table.result b/mysql-test/main/information_schema_temp_table.result new file mode 100644 index 00000000000..c95c7f8a017 --- /dev/null +++ b/mysql-test/main/information_schema_temp_table.result @@ -0,0 +1,202 @@ +# +# MDEV-12459: The information_schema tables for getting temporary tables +# info is missing, at least for innodb, there is no +# INNODB_TEMP_TABLE_INFO +# +# ------------------------------- +# Test shadowing of a base table +# ------------------------------- +create database some_db; +use some_db; +# Creating temporary table with the same name shadows the base table +# in `show create` and by design, should not raise any warning +create table t(t int); +create temporary table t(t int); +show create table t; +Table Create Table +t CREATE TEMPORARY TABLE `t` ( + `t` int(11) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci +select table_schema, table_name, temporary from information_schema.tables where table_name='t'; +table_schema table_name temporary +some_db t Y +some_db t N +drop table t; +drop table t; +use test; +# ------------------------ +# IS.tables tests +# ------------------------ +# Create first temporary table +create temporary table test.t_temp(t int); +insert into t_temp values (1),(2), (3); +# Show results +select table_schema, table_name, temporary from information_schema.tables where table_type='temporary'; +table_schema table_name temporary +test t_temp Y +# Create the base table with the same name (both should be visible) +create table test.t_temp(t int); +insert into t_temp values (-1),(-2); +# Show results +select table_schema, table_name, temporary from information_schema.tables where table_type='temporary'; +table_schema table_name temporary +test t_temp Y +create database my_db; +# Create the temporary table with the same name in new DB +create temporary table my_db.t_temp (t int); +insert into my_db.t_temp values (-2),(-1); +# Show results +select table_schema, table_name, temporary from information_schema.tables where table_type='temporary' + order by table_schema desc, table_name desc, table_type desc; +table_schema table_name temporary +test t_temp Y +my_db t_temp Y +connect con1,localhost,root,,my_db,,; +# Create the temporary table with the same name in new connection +create temporary table t_temp(t int); +insert into t_temp values (4),(5),(6), (7); +# Show results +select table_schema, table_name, temporary from information_schema.tables where table_type='temporary' + order by table_schema desc, table_name desc, table_type desc; +table_schema table_name temporary +my_db t_temp Y +connection default; +# Show results in default connection +select table_schema, table_name, temporary from information_schema.tables where table_type='temporary' + order by table_schema desc, table_name desc, table_type desc; +table_schema table_name temporary +test t_temp Y +my_db t_temp Y +# Check shadowing and (no)warning with explicit referencing database +create table some_db.my_t (t int); +show warnings; +Level Code Message +create temporary table some_db.my_t (t int); +show warnings; +Level Code Message +# Show results +select table_schema, table_name, temporary from information_schema.tables where table_type='temporary' + order by table_schema desc, table_name desc, table_type desc; +table_schema table_name temporary +test t_temp Y +some_db my_t Y +my_db t_temp Y +use test; +create table t1 (a int); +create sequence s1; +create temporary table t1 (b int); +create temporary sequence s1; +create temporary sequence s2; +select table_schema, table_name, table_type, temporary from information_schema.tables where table_schema = 'test' + order by table_schema desc, table_name desc, table_type desc; +table_schema table_name table_type temporary +test t_temp TEMPORARY Y +test t_temp BASE TABLE N +test t1 TEMPORARY Y +test t1 BASE TABLE N +test s2 TEMPORARY SEQUENCE Y +test s1 TEMPORARY SEQUENCE Y +test s1 SEQUENCE N +drop table t1; +drop table t1; +drop table s1; +drop table s1; +drop table s2; +drop table some_db.my_t; +drop table some_db.my_t; +disconnect con1; +drop table test.t_temp; +drop table test.t_temp; +drop database my_db; +drop database some_db; +# +# MDEV-28332: Alter on temporary table causes ER_TABLE_EXISTS_ERROR note +# +create table t (a int); +create temporary table t (b int); +alter table t add c int; +drop temporary table t; +drop table t; +# +# MDEV-28334: SHOW TABLE STATUS shows all temporary tables +# ignoring database and conditions +# +create temporary table test.tmp_in_test (a int); +create table test.base_in_test (t int); +create table test.tmp_in_test (t int); +create temporary table test.tmp_innodb_in_test (a int) engine=InnoDB; +create database mysqltest; +use mysqltest; +show table status; +Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment Max_index_length Temporary +show table status in mysqltest; +Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment Max_index_length Temporary +show table status in test; +Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment Max_index_length Temporary +tmp_innodb_in_test InnoDB 10 Dynamic 0 0 16384 0 0 6291456 NULL # # # latin1_swedish_ci NULL 0 Y +tmp_in_test MyISAM 10 Fixed 0 0 0 1970324836974591 1024 0 NULL # # # latin1_swedish_ci NULL 17179868160 Y +base_in_test MyISAM 10 Fixed 0 0 0 1970324836974591 1024 0 NULL # # # latin1_swedish_ci NULL 17179868160 N +tmp_in_test MyISAM 10 Fixed 0 0 0 1970324836974591 1024 0 NULL # # # latin1_swedish_ci NULL 17179868160 N +show table status from test; +Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment Max_index_length Temporary +tmp_innodb_in_test InnoDB 10 Dynamic 0 0 16384 0 0 6291456 NULL # # # latin1_swedish_ci NULL 0 Y +tmp_in_test MyISAM 10 Fixed 0 0 0 1970324836974591 1024 0 NULL # # # latin1_swedish_ci NULL 17179868160 Y +base_in_test MyISAM 10 Fixed 0 0 0 1970324836974591 1024 0 NULL # # # latin1_swedish_ci NULL 17179868160 N +tmp_in_test MyISAM 10 Fixed 0 0 0 1970324836974591 1024 0 NULL # # # latin1_swedish_ci NULL 17179868160 N +# check that InnoDB temporary table +# has a NULL value for `Create time` column (MDEV-28333) +select create_time from information_schema.tables where table_name='tmp_innodb_in_test'; +create_time +NULL +show table status like 'nonexisting'; +Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment Max_index_length Temporary +drop database mysqltest; +drop table test.base_in_test; +drop table test.tmp_in_test; +drop table test.tmp_in_test; +# +# MDEV-28453: SHOW commands are inconsistent for temporary tables +# +create database mysqltest; +use mysqltest; +create table t (a int, key(a)) engine=Aria; +create temporary table t (b int, key(b)) engine=MyISAM; +create table base_table(t int); +create temporary table tmp_table (b int, key(b)); +create sequence s1; +create temporary sequence s1; +create temporary sequence s2; +show tables; +Tables_in_mysqltest +s2 +s1 +tmp_table +t +base_table +s1 +t +show full tables; +Tables_in_mysqltest Table_type +s2 TEMPORARY SEQUENCE +s1 TEMPORARY SEQUENCE +tmp_table TEMPORARY TABLE +t TEMPORARY TABLE +base_table BASE TABLE +s1 SEQUENCE +t BASE TABLE +show table status; +Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment Max_index_length Temporary +s2 MyISAM 10 Fixed 1 58 58 16325548649218047 1024 0 NULL # # # latin1_swedish_ci NULL 17179868160 Y +s1 MyISAM 10 Fixed 1 58 58 16325548649218047 1024 0 NULL # # # latin1_swedish_ci NULL 17179868160 Y +tmp_table MyISAM 10 Fixed 0 0 0 1970324836974591 1024 0 NULL # # # latin1_swedish_ci NULL 288230376151710720 Y +t MyISAM 10 Fixed 0 0 0 1970324836974591 1024 0 NULL # # # latin1_swedish_ci NULL 288230376151710720 Y +base_table MyISAM 10 Fixed 0 0 0 1970324836974591 1024 0 NULL # # # latin1_swedish_ci NULL 17179868160 N +s1 MyISAM 10 Fixed 1 58 58 16325548649218047 1024 0 NULL # # # latin1_swedish_ci NULL 17179868160 N +t Aria 10 Page 0 0 8192 17592186011648 8192 0 NULL # # # latin1_swedish_ci NULL transactional=1 9007199254732800 N +show columns in t; +Field Type Null Key Default Extra +b int(11) YES MUL NULL +show index in t; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Ignored +t 1 b 1 b A NULL NULL NULL YES BTREE NO +drop database mysqltest; diff --git a/mysql-test/main/information_schema_temp_table.test b/mysql-test/main/information_schema_temp_table.test new file mode 100644 index 00000000000..c1b9f00c862 --- /dev/null +++ b/mysql-test/main/information_schema_temp_table.test @@ -0,0 +1,197 @@ +--echo # +--echo # MDEV-12459: The information_schema tables for getting temporary tables +--echo # info is missing, at least for innodb, there is no +--echo # INNODB_TEMP_TABLE_INFO +--echo # + +# Save the initial number of concurrent sessions +--source include/count_sessions.inc +--source include/have_innodb.inc + +--echo # ------------------------------- +--echo # Test shadowing of a base table +--echo # ------------------------------- + +create database some_db; +use some_db; + +--echo # Creating temporary table with the same name shadows the base table +--echo # in `show create` and by design, should not raise any warning +create table t(t int); +create temporary table t(t int); +show create table t; +select table_schema, table_name, temporary from information_schema.tables where table_name='t'; +drop table t; +drop table t; +use test; + +--echo # ------------------------ +--echo # IS.tables tests +--echo # ------------------------ + +--echo # Create first temporary table +create temporary table test.t_temp(t int); +insert into t_temp values (1),(2), (3); + +--echo # Show results +select table_schema, table_name, temporary from information_schema.tables where table_type='temporary'; + +--echo # Create the base table with the same name (both should be visible) +# Create the base table with the same name as temporary table. +create table test.t_temp(t int); +insert into t_temp values (-1),(-2); + +--echo # Show results +select table_schema, table_name, temporary from information_schema.tables where table_type='temporary'; + +create database my_db; +--echo # Create the temporary table with the same name in new DB +create temporary table my_db.t_temp (t int); +insert into my_db.t_temp values (-2),(-1); +--echo # Show results +--horizontal_results +select table_schema, table_name, temporary from information_schema.tables where table_type='temporary' + order by table_schema desc, table_name desc, table_type desc; + +connect (con1,localhost,root,,my_db,,); + +--echo # Create the temporary table with the same name in new connection +create temporary table t_temp(t int); +insert into t_temp values (4),(5),(6), (7); +--echo # Show results +select table_schema, table_name, temporary from information_schema.tables where table_type='temporary' + order by table_schema desc, table_name desc, table_type desc; + +connection default; + +--echo # Show results in default connection +select table_schema, table_name, temporary from information_schema.tables where table_type='temporary' + order by table_schema desc, table_name desc, table_type desc; + +--echo # Check shadowing and (no)warning with explicit referencing database +create table some_db.my_t (t int); +show warnings; +create temporary table some_db.my_t (t int); +show warnings; + +--echo # Show results +select table_schema, table_name, temporary from information_schema.tables where table_type='temporary' + order by table_schema desc, table_name desc, table_type desc; + +# Check with sequences +use test; +create table t1 (a int); +create sequence s1; +create temporary table t1 (b int); +create temporary sequence s1; +create temporary sequence s2; +select table_schema, table_name, table_type, temporary from information_schema.tables where table_schema = 'test' + order by table_schema desc, table_name desc, table_type desc; + +drop table t1; +drop table t1; +drop table s1; +drop table s1; +drop table s2; + +# First we are removing temporary table and after base table +drop table some_db.my_t; +drop table some_db.my_t; + +disconnect con1; + +# Drop both temporary and "real" table from test. +drop table test.t_temp; +drop table test.t_temp; + +drop database my_db; +drop database some_db; + +# Wait till all disconnects are completed +--source include/wait_until_count_sessions.inc + +--echo # +--echo # MDEV-28332: Alter on temporary table causes ER_TABLE_EXISTS_ERROR note +--echo # +create table t (a int); +create temporary table t (b int); +alter table t add c int; + +# Cleanup +drop temporary table t; +drop table t; + +--echo # +--echo # MDEV-28334: SHOW TABLE STATUS shows all temporary tables +--echo # ignoring database and conditions +--echo # + +create temporary table test.tmp_in_test (a int); +create table test.base_in_test (t int); +# The base table with the same name as temporary table +create table test.tmp_in_test (t int); +# The temporary InnoDB table - CREATE TIME should be NULL, MDEV-28333 +create temporary table test.tmp_innodb_in_test (a int) engine=InnoDB; + +create database mysqltest; +use mysqltest; + +# This should show tables from currently used DB +# no temporary tables created and empty result set should be returned +show table status; + +# The same as before +show table status in mysqltest; + +# The should show all ables from `test` DB +--replace_column 12 # 13 # 14 # +--horizontal_results +show table status in test; + +# The same as before +--replace_column 12 # 13 # 14 # +--horizontal_results +show table status from test; + + +--echo # check that InnoDB temporary table +--echo # has a NULL value for `Create time` column (MDEV-28333) +select create_time from information_schema.tables where table_name='tmp_innodb_in_test'; + +# This shouldn't give any results +show table status like 'nonexisting'; + +# Cleanup +drop database mysqltest; +drop table test.base_in_test; +# We need first to drop temporary table that shadows the base table +drop table test.tmp_in_test; +drop table test.tmp_in_test; + +--echo # +--echo # MDEV-28453: SHOW commands are inconsistent for temporary tables +--echo # +create database mysqltest; +use mysqltest; +create table t (a int, key(a)) engine=Aria; +create temporary table t (b int, key(b)) engine=MyISAM; +create table base_table(t int); +create temporary table tmp_table (b int, key(b)); +create sequence s1; +create temporary sequence s1; +create temporary sequence s2; + +# This should show all tables +show tables; +# This should show all tables with additional table_type +show full tables; +# This is already showing all tables (not related to bug) +--replace_column 12 # 13 # 14 # +show table status; +# This is showing temporary table as expected since it is shadowing base table +show columns in t; +# This is showing temporary table as expected since it is shadowing base table +show index in t; + +# Cleanup +drop database mysqltest; diff --git a/mysql-test/main/mysqldump.result b/mysql-test/main/mysqldump.result index 2c15a4841eb..9ee40ee36c3 100644 --- a/mysql-test/main/mysqldump.result +++ b/mysql-test/main/mysqldump.result @@ -5482,6 +5482,8 @@ Warnings: Warning 1105 Event scheduler is switched off, use SET GLOBAL event_scheduler=ON to enable it. SHOW TABLES FROM bug25717383; Tables_in_bug25717383 +temp +one tab one view @@ -5503,6 +5505,8 @@ proc one SHOW TABLES FROM bug25717383; Tables_in_bug25717383 +temp +one tab one view diff --git a/mysql-test/main/rename.result b/mysql-test/main/rename.result index 64ccf385958..dfa78e5a61d 100644 --- a/mysql-test/main/rename.result +++ b/mysql-test/main/rename.result @@ -106,6 +106,8 @@ rename table t2 to tmp, tmp to t2; rename table t1_tmp to tmp, tmp to t1_tmp; show tables; Tables_in_test +t2 +t1_tmp t1_tmp t2 SHOW CREATE TABLE t1_tmp; diff --git a/mysql-test/main/temp_table.result b/mysql-test/main/temp_table.result index 7f005bde37c..4ec979273b5 100644 --- a/mysql-test/main/temp_table.result +++ b/mysql-test/main/temp_table.result @@ -329,6 +329,7 @@ i 1 SHOW TABLES; Tables_in_temp_db +temp_t1 DROP TABLE temp_t1; # # Create and drop a temporary table. diff --git a/mysql-test/suite/engines/funcs/r/tc_temporary_column.result b/mysql-test/suite/engines/funcs/r/tc_temporary_column.result index 03627817a35..e2efd0d4c95 100644 --- a/mysql-test/suite/engines/funcs/r/tc_temporary_column.result +++ b/mysql-test/suite/engines/funcs/r/tc_temporary_column.result @@ -2,6 +2,7 @@ DROP TABLE IF EXISTS t1; CREATE TEMPORARY TABLE t1(c1 BIT NULL); SHOW TABLES; Tables_in_test +t1 SHOW CREATE TABLE t1; Table Create Table t1 CREATE TEMPORARY TABLE `t1` ( @@ -13,6 +14,7 @@ Tables_in_test CREATE TEMPORARY TABLE t1(c1 TINYINT NULL); SHOW TABLES; Tables_in_test +t1 SHOW CREATE TABLE t1; Table Create Table t1 CREATE TEMPORARY TABLE `t1` ( @@ -24,6 +26,7 @@ Tables_in_test CREATE TEMPORARY TABLE t1(c1 SMALLINT NULL); SHOW TABLES; Tables_in_test +t1 SHOW CREATE TABLE t1; Table Create Table t1 CREATE TEMPORARY TABLE `t1` ( @@ -35,6 +38,7 @@ Tables_in_test CREATE TEMPORARY TABLE t1(c1 MEDIUMINT NULL); SHOW TABLES; Tables_in_test +t1 SHOW CREATE TABLE t1; Table Create Table t1 CREATE TEMPORARY TABLE `t1` ( @@ -46,6 +50,7 @@ Tables_in_test CREATE TEMPORARY TABLE t1(c1 INT NULL); SHOW TABLES; Tables_in_test +t1 SHOW CREATE TABLE t1; Table Create Table t1 CREATE TEMPORARY TABLE `t1` ( @@ -57,6 +62,7 @@ Tables_in_test CREATE TEMPORARY TABLE t1(c1 INTEGER NULL); SHOW TABLES; Tables_in_test +t1 SHOW CREATE TABLE t1; Table Create Table t1 CREATE TEMPORARY TABLE `t1` ( @@ -68,6 +74,7 @@ Tables_in_test CREATE TEMPORARY TABLE t1(c1 BIGINT NULL); SHOW TABLES; Tables_in_test +t1 SHOW CREATE TABLE t1; Table Create Table t1 CREATE TEMPORARY TABLE `t1` ( @@ -79,6 +86,7 @@ Tables_in_test CREATE TEMPORARY TABLE t1(c1 DECIMAL NULL); SHOW TABLES; Tables_in_test +t1 SHOW CREATE TABLE t1; Table Create Table t1 CREATE TEMPORARY TABLE `t1` ( @@ -90,6 +98,7 @@ Tables_in_test CREATE TEMPORARY TABLE t1(c1 DEC NULL); SHOW TABLES; Tables_in_test +t1 SHOW CREATE TABLE t1; Table Create Table t1 CREATE TEMPORARY TABLE `t1` ( @@ -101,6 +110,7 @@ Tables_in_test CREATE TEMPORARY TABLE t1(c1 FIXED NULL); SHOW TABLES; Tables_in_test +t1 SHOW CREATE TABLE t1; Table Create Table t1 CREATE TEMPORARY TABLE `t1` ( @@ -112,6 +122,7 @@ Tables_in_test CREATE TEMPORARY TABLE t1(c1 NUMERIC NULL); SHOW TABLES; Tables_in_test +t1 SHOW CREATE TABLE t1; Table Create Table t1 CREATE TEMPORARY TABLE `t1` ( @@ -123,6 +134,7 @@ Tables_in_test CREATE TEMPORARY TABLE t1(c1 DOUBLE NULL); SHOW TABLES; Tables_in_test +t1 SHOW CREATE TABLE t1; Table Create Table t1 CREATE TEMPORARY TABLE `t1` ( @@ -134,6 +146,7 @@ Tables_in_test CREATE TEMPORARY TABLE t1(c1 REAL NULL); SHOW TABLES; Tables_in_test +t1 SHOW CREATE TABLE t1; Table Create Table t1 CREATE TEMPORARY TABLE `t1` ( @@ -145,6 +158,7 @@ Tables_in_test CREATE TEMPORARY TABLE t1(c1 DOUBLE PRECISION NULL); SHOW TABLES; Tables_in_test +t1 SHOW CREATE TABLE t1; Table Create Table t1 CREATE TEMPORARY TABLE `t1` ( @@ -156,6 +170,7 @@ Tables_in_test CREATE TEMPORARY TABLE t1(c1 FLOAT NULL); SHOW TABLES; Tables_in_test +t1 SHOW CREATE TABLE t1; Table Create Table t1 CREATE TEMPORARY TABLE `t1` ( @@ -167,6 +182,7 @@ Tables_in_test CREATE TEMPORARY TABLE t1(c1 DATE NULL); SHOW TABLES; Tables_in_test +t1 SHOW CREATE TABLE t1; Table Create Table t1 CREATE TEMPORARY TABLE `t1` ( @@ -178,6 +194,7 @@ Tables_in_test CREATE TEMPORARY TABLE t1(c1 TIME NULL); SHOW TABLES; Tables_in_test +t1 SHOW CREATE TABLE t1; Table Create Table t1 CREATE TEMPORARY TABLE `t1` ( @@ -189,6 +206,7 @@ Tables_in_test CREATE TEMPORARY TABLE t1(c1 TIMESTAMP NULL); SHOW TABLES; Tables_in_test +t1 SHOW CREATE TABLE t1; Table Create Table t1 CREATE TEMPORARY TABLE `t1` ( @@ -200,6 +218,7 @@ Tables_in_test CREATE TEMPORARY TABLE t1(c1 DATETIME NULL); SHOW TABLES; Tables_in_test +t1 SHOW CREATE TABLE t1; Table Create Table t1 CREATE TEMPORARY TABLE `t1` ( @@ -211,6 +230,7 @@ Tables_in_test CREATE TEMPORARY TABLE t1(c1 YEAR NULL); SHOW TABLES; Tables_in_test +t1 SHOW CREATE TABLE t1; Table Create Table t1 CREATE TEMPORARY TABLE `t1` ( @@ -222,6 +242,7 @@ Tables_in_test CREATE TEMPORARY TABLE t1(c1 TINYBLOB NULL); SHOW TABLES; Tables_in_test +t1 SHOW CREATE TABLE t1; Table Create Table t1 CREATE TEMPORARY TABLE `t1` ( @@ -233,6 +254,7 @@ Tables_in_test CREATE TEMPORARY TABLE t1(c1 BLOB NULL); SHOW TABLES; Tables_in_test +t1 SHOW CREATE TABLE t1; Table Create Table t1 CREATE TEMPORARY TABLE `t1` ( @@ -244,6 +266,7 @@ Tables_in_test CREATE TEMPORARY TABLE t1(c1 MEDIUMBLOB NULL); SHOW TABLES; Tables_in_test +t1 SHOW CREATE TABLE t1; Table Create Table t1 CREATE TEMPORARY TABLE `t1` ( @@ -255,6 +278,7 @@ Tables_in_test CREATE TEMPORARY TABLE t1(c1 LONGBLOB NULL); SHOW TABLES; Tables_in_test +t1 SHOW CREATE TABLE t1; Table Create Table t1 CREATE TEMPORARY TABLE `t1` ( @@ -266,6 +290,7 @@ Tables_in_test CREATE TEMPORARY TABLE t1(c1 TINYTEXT NULL); SHOW TABLES; Tables_in_test +t1 SHOW CREATE TABLE t1; Table Create Table t1 CREATE TEMPORARY TABLE `t1` ( @@ -277,6 +302,7 @@ Tables_in_test CREATE TEMPORARY TABLE t1(c1 TEXT NULL); SHOW TABLES; Tables_in_test +t1 SHOW CREATE TABLE t1; Table Create Table t1 CREATE TEMPORARY TABLE `t1` ( @@ -288,6 +314,7 @@ Tables_in_test CREATE TEMPORARY TABLE t1(c1 MEDIUMTEXT NULL); SHOW TABLES; Tables_in_test +t1 SHOW CREATE TABLE t1; Table Create Table t1 CREATE TEMPORARY TABLE `t1` ( @@ -299,6 +326,7 @@ Tables_in_test CREATE TEMPORARY TABLE t1(c1 LONGTEXT NULL); SHOW TABLES; Tables_in_test +t1 SHOW CREATE TABLE t1; Table Create Table t1 CREATE TEMPORARY TABLE `t1` ( @@ -310,6 +338,7 @@ Tables_in_test CREATE TEMPORARY TABLE t1(c1 BIT NOT NULL); SHOW TABLES; Tables_in_test +t1 SHOW CREATE TABLE t1; Table Create Table t1 CREATE TEMPORARY TABLE `t1` ( @@ -321,6 +350,7 @@ Tables_in_test CREATE TEMPORARY TABLE t1(c1 TINYINT NOT NULL); SHOW TABLES; Tables_in_test +t1 SHOW CREATE TABLE t1; Table Create Table t1 CREATE TEMPORARY TABLE `t1` ( @@ -332,6 +362,7 @@ Tables_in_test CREATE TEMPORARY TABLE t1(c1 SMALLINT NOT NULL); SHOW TABLES; Tables_in_test +t1 SHOW CREATE TABLE t1; Table Create Table t1 CREATE TEMPORARY TABLE `t1` ( @@ -343,6 +374,7 @@ Tables_in_test CREATE TEMPORARY TABLE t1(c1 MEDIUMINT NOT NULL); SHOW TABLES; Tables_in_test +t1 SHOW CREATE TABLE t1; Table Create Table t1 CREATE TEMPORARY TABLE `t1` ( @@ -354,6 +386,7 @@ Tables_in_test CREATE TEMPORARY TABLE t1(c1 INT NOT NULL); SHOW TABLES; Tables_in_test +t1 SHOW CREATE TABLE t1; Table Create Table t1 CREATE TEMPORARY TABLE `t1` ( @@ -365,6 +398,7 @@ Tables_in_test CREATE TEMPORARY TABLE t1(c1 INTEGER NOT NULL); SHOW TABLES; Tables_in_test +t1 SHOW CREATE TABLE t1; Table Create Table t1 CREATE TEMPORARY TABLE `t1` ( @@ -376,6 +410,7 @@ Tables_in_test CREATE TEMPORARY TABLE t1(c1 BIGINT NOT NULL); SHOW TABLES; Tables_in_test +t1 SHOW CREATE TABLE t1; Table Create Table t1 CREATE TEMPORARY TABLE `t1` ( @@ -387,6 +422,7 @@ Tables_in_test CREATE TEMPORARY TABLE t1(c1 DECIMAL NOT NULL); SHOW TABLES; Tables_in_test +t1 SHOW CREATE TABLE t1; Table Create Table t1 CREATE TEMPORARY TABLE `t1` ( @@ -398,6 +434,7 @@ Tables_in_test CREATE TEMPORARY TABLE t1(c1 DEC NOT NULL); SHOW TABLES; Tables_in_test +t1 SHOW CREATE TABLE t1; Table Create Table t1 CREATE TEMPORARY TABLE `t1` ( @@ -409,6 +446,7 @@ Tables_in_test CREATE TEMPORARY TABLE t1(c1 FIXED NOT NULL); SHOW TABLES; Tables_in_test +t1 SHOW CREATE TABLE t1; Table Create Table t1 CREATE TEMPORARY TABLE `t1` ( @@ -420,6 +458,7 @@ Tables_in_test CREATE TEMPORARY TABLE t1(c1 NUMERIC NOT NULL); SHOW TABLES; Tables_in_test +t1 SHOW CREATE TABLE t1; Table Create Table t1 CREATE TEMPORARY TABLE `t1` ( @@ -431,6 +470,7 @@ Tables_in_test CREATE TEMPORARY TABLE t1(c1 DOUBLE NOT NULL); SHOW TABLES; Tables_in_test +t1 SHOW CREATE TABLE t1; Table Create Table t1 CREATE TEMPORARY TABLE `t1` ( @@ -442,6 +482,7 @@ Tables_in_test CREATE TEMPORARY TABLE t1(c1 REAL NOT NULL); SHOW TABLES; Tables_in_test +t1 SHOW CREATE TABLE t1; Table Create Table t1 CREATE TEMPORARY TABLE `t1` ( @@ -453,6 +494,7 @@ Tables_in_test CREATE TEMPORARY TABLE t1(c1 DOUBLE PRECISION NOT NULL); SHOW TABLES; Tables_in_test +t1 SHOW CREATE TABLE t1; Table Create Table t1 CREATE TEMPORARY TABLE `t1` ( @@ -464,6 +506,7 @@ Tables_in_test CREATE TEMPORARY TABLE t1(c1 FLOAT NOT NULL); SHOW TABLES; Tables_in_test +t1 SHOW CREATE TABLE t1; Table Create Table t1 CREATE TEMPORARY TABLE `t1` ( @@ -475,6 +518,7 @@ Tables_in_test CREATE TEMPORARY TABLE t1(c1 DATE NOT NULL); SHOW TABLES; Tables_in_test +t1 SHOW CREATE TABLE t1; Table Create Table t1 CREATE TEMPORARY TABLE `t1` ( @@ -486,6 +530,7 @@ Tables_in_test CREATE TEMPORARY TABLE t1(c1 TIME NOT NULL); SHOW TABLES; Tables_in_test +t1 SHOW CREATE TABLE t1; Table Create Table t1 CREATE TEMPORARY TABLE `t1` ( @@ -497,6 +542,7 @@ Tables_in_test CREATE TEMPORARY TABLE t1(c1 TIMESTAMP NOT NULL); SHOW TABLES; Tables_in_test +t1 SHOW CREATE TABLE t1; Table Create Table t1 CREATE TEMPORARY TABLE `t1` ( @@ -508,6 +554,7 @@ Tables_in_test CREATE TEMPORARY TABLE t1(c1 DATETIME NOT NULL); SHOW TABLES; Tables_in_test +t1 SHOW CREATE TABLE t1; Table Create Table t1 CREATE TEMPORARY TABLE `t1` ( @@ -519,6 +566,7 @@ Tables_in_test CREATE TEMPORARY TABLE t1(c1 YEAR NOT NULL); SHOW TABLES; Tables_in_test +t1 SHOW CREATE TABLE t1; Table Create Table t1 CREATE TEMPORARY TABLE `t1` ( @@ -530,6 +578,7 @@ Tables_in_test CREATE TEMPORARY TABLE t1(c1 TINYBLOB NOT NULL); SHOW TABLES; Tables_in_test +t1 SHOW CREATE TABLE t1; Table Create Table t1 CREATE TEMPORARY TABLE `t1` ( @@ -541,6 +590,7 @@ Tables_in_test CREATE TEMPORARY TABLE t1(c1 BLOB NOT NULL); SHOW TABLES; Tables_in_test +t1 SHOW CREATE TABLE t1; Table Create Table t1 CREATE TEMPORARY TABLE `t1` ( @@ -552,6 +602,7 @@ Tables_in_test CREATE TEMPORARY TABLE t1(c1 MEDIUMBLOB NOT NULL); SHOW TABLES; Tables_in_test +t1 SHOW CREATE TABLE t1; Table Create Table t1 CREATE TEMPORARY TABLE `t1` ( @@ -563,6 +614,7 @@ Tables_in_test CREATE TEMPORARY TABLE t1(c1 LONGBLOB NOT NULL); SHOW TABLES; Tables_in_test +t1 SHOW CREATE TABLE t1; Table Create Table t1 CREATE TEMPORARY TABLE `t1` ( @@ -574,6 +626,7 @@ Tables_in_test CREATE TEMPORARY TABLE t1(c1 TINYTEXT NOT NULL); SHOW TABLES; Tables_in_test +t1 SHOW CREATE TABLE t1; Table Create Table t1 CREATE TEMPORARY TABLE `t1` ( @@ -585,6 +638,7 @@ Tables_in_test CREATE TEMPORARY TABLE t1(c1 TEXT NOT NULL); SHOW TABLES; Tables_in_test +t1 SHOW CREATE TABLE t1; Table Create Table t1 CREATE TEMPORARY TABLE `t1` ( @@ -596,6 +650,7 @@ Tables_in_test CREATE TEMPORARY TABLE t1(c1 MEDIUMTEXT NOT NULL); SHOW TABLES; Tables_in_test +t1 SHOW CREATE TABLE t1; Table Create Table t1 CREATE TEMPORARY TABLE `t1` ( @@ -607,6 +662,7 @@ Tables_in_test CREATE TEMPORARY TABLE t1(c1 LONGTEXT NOT NULL); SHOW TABLES; Tables_in_test +t1 SHOW CREATE TABLE t1; Table Create Table t1 CREATE TEMPORARY TABLE `t1` ( diff --git a/mysql-test/suite/engines/funcs/r/tc_temporary_column_length.result b/mysql-test/suite/engines/funcs/r/tc_temporary_column_length.result index f1a9a775440..659043d9393 100644 --- a/mysql-test/suite/engines/funcs/r/tc_temporary_column_length.result +++ b/mysql-test/suite/engines/funcs/r/tc_temporary_column_length.result @@ -2,6 +2,7 @@ DROP TABLE IF EXISTS t5; CREATE TEMPORARY TABLE t5(c1 BIT(10) NULL); SHOW TABLES; Tables_in_test +t5 SHOW CREATE TABLE t5; Table Create Table t5 CREATE TEMPORARY TABLE `t5` ( @@ -13,6 +14,7 @@ Tables_in_test CREATE TEMPORARY TABLE t5(c1 TINYINT(10) NULL); SHOW TABLES; Tables_in_test +t5 SHOW CREATE TABLE t5; Table Create Table t5 CREATE TEMPORARY TABLE `t5` ( @@ -24,6 +26,7 @@ Tables_in_test CREATE TEMPORARY TABLE t5(c1 SMALLINT(10) NULL); SHOW TABLES; Tables_in_test +t5 SHOW CREATE TABLE t5; Table Create Table t5 CREATE TEMPORARY TABLE `t5` ( @@ -35,6 +38,7 @@ Tables_in_test CREATE TEMPORARY TABLE t5(c1 MEDIUMINT(10) NULL); SHOW TABLES; Tables_in_test +t5 SHOW CREATE TABLE t5; Table Create Table t5 CREATE TEMPORARY TABLE `t5` ( @@ -46,6 +50,7 @@ Tables_in_test CREATE TEMPORARY TABLE t5(c1 INT(10) NULL); SHOW TABLES; Tables_in_test +t5 SHOW CREATE TABLE t5; Table Create Table t5 CREATE TEMPORARY TABLE `t5` ( @@ -57,6 +62,7 @@ Tables_in_test CREATE TEMPORARY TABLE t5(c1 INTEGER(10) NULL); SHOW TABLES; Tables_in_test +t5 SHOW CREATE TABLE t5; Table Create Table t5 CREATE TEMPORARY TABLE `t5` ( @@ -68,6 +74,7 @@ Tables_in_test CREATE TEMPORARY TABLE t5(c1 BIGINT(10) NULL); SHOW TABLES; Tables_in_test +t5 SHOW CREATE TABLE t5; Table Create Table t5 CREATE TEMPORARY TABLE `t5` ( @@ -79,6 +86,7 @@ Tables_in_test CREATE TEMPORARY TABLE t5(c1 CHAR(10) NULL); SHOW TABLES; Tables_in_test +t5 SHOW CREATE TABLE t5; Table Create Table t5 CREATE TEMPORARY TABLE `t5` ( @@ -90,6 +98,7 @@ Tables_in_test CREATE TEMPORARY TABLE t5(c1 VARCHAR(10) NULL); SHOW TABLES; Tables_in_test +t5 SHOW CREATE TABLE t5; Table Create Table t5 CREATE TEMPORARY TABLE `t5` ( @@ -101,6 +110,7 @@ Tables_in_test CREATE TEMPORARY TABLE t5(c1 BINARY(10) NULL); SHOW TABLES; Tables_in_test +t5 SHOW CREATE TABLE t5; Table Create Table t5 CREATE TEMPORARY TABLE `t5` ( @@ -112,6 +122,7 @@ Tables_in_test CREATE TEMPORARY TABLE t5(c1 VARBINARY(10) NULL); SHOW TABLES; Tables_in_test +t5 SHOW CREATE TABLE t5; Table Create Table t5 CREATE TEMPORARY TABLE `t5` ( @@ -123,6 +134,7 @@ Tables_in_test CREATE TEMPORARY TABLE t5(c1 BIT(10) NOT NULL); SHOW TABLES; Tables_in_test +t5 SHOW CREATE TABLE t5; Table Create Table t5 CREATE TEMPORARY TABLE `t5` ( @@ -134,6 +146,7 @@ Tables_in_test CREATE TEMPORARY TABLE t5(c1 TINYINT(10) NOT NULL); SHOW TABLES; Tables_in_test +t5 SHOW CREATE TABLE t5; Table Create Table t5 CREATE TEMPORARY TABLE `t5` ( @@ -145,6 +158,7 @@ Tables_in_test CREATE TEMPORARY TABLE t5(c1 SMALLINT(10) NOT NULL); SHOW TABLES; Tables_in_test +t5 SHOW CREATE TABLE t5; Table Create Table t5 CREATE TEMPORARY TABLE `t5` ( @@ -156,6 +170,7 @@ Tables_in_test CREATE TEMPORARY TABLE t5(c1 MEDIUMINT(10) NOT NULL); SHOW TABLES; Tables_in_test +t5 SHOW CREATE TABLE t5; Table Create Table t5 CREATE TEMPORARY TABLE `t5` ( @@ -167,6 +182,7 @@ Tables_in_test CREATE TEMPORARY TABLE t5(c1 INT(10) NOT NULL); SHOW TABLES; Tables_in_test +t5 SHOW CREATE TABLE t5; Table Create Table t5 CREATE TEMPORARY TABLE `t5` ( @@ -178,6 +194,7 @@ Tables_in_test CREATE TEMPORARY TABLE t5(c1 INTEGER(10) NOT NULL); SHOW TABLES; Tables_in_test +t5 SHOW CREATE TABLE t5; Table Create Table t5 CREATE TEMPORARY TABLE `t5` ( @@ -189,6 +206,7 @@ Tables_in_test CREATE TEMPORARY TABLE t5(c1 BIGINT(10) NOT NULL); SHOW TABLES; Tables_in_test +t5 SHOW CREATE TABLE t5; Table Create Table t5 CREATE TEMPORARY TABLE `t5` ( @@ -200,6 +218,7 @@ Tables_in_test CREATE TEMPORARY TABLE t5(c1 CHAR(10) NOT NULL); SHOW TABLES; Tables_in_test +t5 SHOW CREATE TABLE t5; Table Create Table t5 CREATE TEMPORARY TABLE `t5` ( @@ -211,6 +230,7 @@ Tables_in_test CREATE TEMPORARY TABLE t5(c1 VARCHAR(10) NOT NULL); SHOW TABLES; Tables_in_test +t5 SHOW CREATE TABLE t5; Table Create Table t5 CREATE TEMPORARY TABLE `t5` ( @@ -222,6 +242,7 @@ Tables_in_test CREATE TEMPORARY TABLE t5(c1 BINARY(10) NOT NULL); SHOW TABLES; Tables_in_test +t5 SHOW CREATE TABLE t5; Table Create Table t5 CREATE TEMPORARY TABLE `t5` ( @@ -233,6 +254,7 @@ Tables_in_test CREATE TEMPORARY TABLE t5(c1 VARBINARY(10) NOT NULL); SHOW TABLES; Tables_in_test +t5 SHOW CREATE TABLE t5; Table Create Table t5 CREATE TEMPORARY TABLE `t5` ( diff --git a/mysql-test/suite/funcs_1/r/is_tables.result b/mysql-test/suite/funcs_1/r/is_tables.result index 35f7d43d437..67bbb0aede5 100644 --- a/mysql-test/suite/funcs_1/r/is_tables.result +++ b/mysql-test/suite/funcs_1/r/is_tables.result @@ -387,6 +387,8 @@ ENGINE = AS SELECT 1; SELECT table_name, table_type FROM information_schema.tables WHERE table_name = 't1_my_tablex'; +table_name t1_my_tablex +table_type TEMPORARY DROP TEMPORARY TABLE test.t1_my_tablex; CREATE TABLE db_datadict.t1_my_tablex ENGINE = AS diff --git a/mysql-test/suite/funcs_1/r/is_tables_embedded.result b/mysql-test/suite/funcs_1/r/is_tables_embedded.result index de0c2fb4804..4761ed8deca 100644 --- a/mysql-test/suite/funcs_1/r/is_tables_embedded.result +++ b/mysql-test/suite/funcs_1/r/is_tables_embedded.result @@ -395,6 +395,8 @@ ENGINE = AS SELECT 1; SELECT table_name, table_type FROM information_schema.tables WHERE table_name = 't1_my_tablex'; +table_name t1_my_tablex +table_type TEMPORARY DROP TEMPORARY TABLE test.t1_my_tablex; CREATE TABLE db_datadict.t1_my_tablex ENGINE = AS diff --git a/mysql-test/suite/rpl/r/rpl_ddl.result b/mysql-test/suite/rpl/r/rpl_ddl.result index 27d84fea1e4..2de5b0228b7 100644 --- a/mysql-test/suite/rpl/r/rpl_ddl.result +++ b/mysql-test/suite/rpl/r/rpl_ddl.result @@ -343,6 +343,7 @@ TEST-INFO: SLAVE: The INSERT is committed (Succeeded) connection master; SHOW TABLES LIKE 't2'; Tables_in_mysqltest1 (t2) +t23 connection slave; SHOW TABLES LIKE 't2'; Tables_in_mysqltest1 (t2) diff --git a/mysql-test/suite/rpl/r/rpl_row_create_table.result b/mysql-test/suite/rpl/r/rpl_row_create_table.result index e63212db65e..197b4be2c9f 100644 --- a/mysql-test/suite/rpl/r/rpl_row_create_table.result +++ b/mysql-test/suite/rpl/r/rpl_row_create_table.result @@ -243,6 +243,11 @@ Warnings: Warning 1196 Some non-transactional changed tables couldn't be rolled back SHOW TABLES; Tables_in_test +tt7 +tt6 +tt5 +tt4 +tt3 t1 t2 t3 diff --git a/mysql-test/suite/rpl/r/rpl_row_drop.result b/mysql-test/suite/rpl/r/rpl_row_drop.result index 8753764e81e..8546960b7fb 100644 --- a/mysql-test/suite/rpl/r/rpl_row_drop.result +++ b/mysql-test/suite/rpl/r/rpl_row_drop.result @@ -6,6 +6,7 @@ CREATE TABLE t2 (a int); CREATE TEMPORARY TABLE t2 (a int, b int); SHOW TABLES; Tables_in_test +t2 t1 t2 connection slave; @@ -28,6 +29,7 @@ connection master; CREATE TEMPORARY TABLE t2 (a int, b int); SHOW TABLES; Tables_in_test +t2 t1 t2 connection slave; diff --git a/sql/sql_show.cc b/sql/sql_show.cc index 37e2f789a36..e3408c8c900 100644 --- a/sql/sql_show.cc +++ b/sql/sql_show.cc @@ -70,6 +70,7 @@ #include "lex_symbol.h" #define KEYWORD_SIZE 64 +#define IS_USER_TEMP_TABLE(A) (A->tmp_table != NO_TMP_TABLE) extern SYMBOL symbols[]; extern size_t symbols_length; @@ -161,6 +162,7 @@ static const LEX_CSTRING *view_algorithm(TABLE_LIST *table); bool get_lookup_field_values(THD *, COND *, bool, TABLE_LIST *, LOOKUP_FIELD_VALUES *); +void process_i_s_table_temporary_tables(THD *thd, TABLE * table, TABLE *tmp_tbl); /** Try to lock a mutex, but give up after a short while to not cause deadlocks @@ -5189,6 +5191,7 @@ public: } }; + /** @brief Fill I_S tables whose data are retrieved from frm files and storage engine @@ -5329,6 +5332,49 @@ int get_all_tables(THD *thd, TABLE_LIST *tables, COND *cond) #endif { Dynamic_array table_names(PSI_INSTRUMENT_MEM); + + /* Separate handling for session temporary tables from the backup state + for table IS.tables and SHOW TABLES commands. + */ + if ((schema_table_idx == SCH_TABLES || schema_table_idx == SCH_TABLE_NAMES) && + open_tables_state_backup.temporary_tables) + { + All_tmp_tables_list::Iterator it(*open_tables_state_backup.temporary_tables); + TMP_TABLE_SHARE *share_temp; + while ((share_temp= it++)) + { + DBUG_ASSERT(IS_USER_TEMP_TABLE(share_temp)); + if (my_strcasecmp(system_charset_info, db_name->str, + share_temp->db.str)) + continue; + + All_share_tables_list::Iterator it2(share_temp->all_tmp_tables); + while (TABLE *tmp_tbl= it2++) + { + if (schema_table_idx == SCH_TABLE_NAMES) + { + LEX_CSTRING *table_name= &tmp_tbl->s->table_name; + restore_record(table, s->default_values); + table->field[schema_table->idx_field1]-> + store(db_name->str, db_name->length, system_charset_info); + table->field[schema_table->idx_field2]-> + store(table_name->str, table_name->length, + system_charset_info); + if (tmp_tbl->s->table_type == TABLE_TYPE_SEQUENCE) + table->field[3]->store(STRING_WITH_LEN("TEMPORARY SEQUENCE"), + system_charset_info); + else + table->field[3]->store(STRING_WITH_LEN("TEMPORARY TABLE"), + system_charset_info); + schema_table_store_record(thd, table); + } + else /* SCH_TABLE */ + { + process_i_s_table_temporary_tables(thd, table, tmp_tbl); + } + } + } + } int res= make_table_name_list(thd, &table_names, lex, &plan->lookup_field_vals, db_name); if (unlikely(res == 2)) /* Not fatal error, continue */ @@ -5336,9 +5382,9 @@ int get_all_tables(THD *thd, TABLE_LIST *tables, COND *cond) if (unlikely(res)) goto err; - for (size_t i=0; i < table_names.elements(); i++) + for (size_t j=0; j < table_names.elements(); j++) { - LEX_CSTRING *table_name= table_names.at(i); + LEX_CSTRING *table_name= table_names.at(j); DBUG_ASSERT(table_name->length <= NAME_LEN); #ifndef NO_EMBEDDED_ACCESS_CHECKS @@ -5593,8 +5639,12 @@ static int get_schema_tables_record(THD *thd, TABLE_LIST *tables, if (share->tmp_table == SYSTEM_TMP_TABLE) table->field[3]->store(STRING_WITH_LEN("SYSTEM VIEW"), cs); + else if (IS_USER_TEMP_TABLE(share) && share->table_type == TABLE_TYPE_SEQUENCE) + table->field[3]->store(STRING_WITH_LEN("TEMPORARY SEQUENCE"), cs); else if (share->table_type == TABLE_TYPE_SEQUENCE) table->field[3]->store(STRING_WITH_LEN("SEQUENCE"), cs); + else if (IS_USER_TEMP_TABLE(share)) + table->field[3]->store(STRING_WITH_LEN("TEMPORARY"), cs); else { DBUG_ASSERT(share->tmp_table == NO_TMP_TABLE); @@ -5871,6 +5921,25 @@ err: } +/** + @brief Fill IS.table with temporary tables + @param[in] thd thread handler + @param[in] table I_S table (TABLE) + @param[in] tmp_tbl temporary table to be represetned by IS.table + @return Operation status + @retval 0 - success + @retval 1 - failure +*/ +void process_i_s_table_temporary_tables(THD *thd, TABLE * table, TABLE *tmp_tbl) +{ + TABLE_LIST table_list; + bzero((char*) &table_list, sizeof(TABLE_LIST)); + table_list.table= tmp_tbl; + get_schema_tables_record(thd, &table_list, table, + 0, &tmp_tbl->s->db, &tmp_tbl->s->table_name); +} + + /** @brief Store field characteristics into appropriate I_S table columns