SCH_VARIABLES,
--- a/sql/mysqld.cc
+++ b/sql/mysqld.cc
-@@ -3101,6 +3101,7 @@
+@@ -2951,6 +2951,7 @@
{"show_storage_engines", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_SHOW_STORAGE_ENGINES]), SHOW_LONG_STATUS},
{"show_table_status", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_SHOW_TABLE_STATUS]), SHOW_LONG_STATUS},
{"show_tables", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_SHOW_TABLES]), SHOW_LONG_STATUS},
{"show_triggers", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_SHOW_TRIGGERS]), SHOW_LONG_STATUS},
{"show_variables", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_SHOW_VARIABLES]), SHOW_LONG_STATUS},
{"show_warnings", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_SHOW_WARNS]), SHOW_LONG_STATUS},
-@@ -7802,6 +7803,7 @@
+@@ -7670,6 +7671,7 @@
PSI_mutex_key key_LOCK_des_key_file;
#endif /* HAVE_OPENSSL */
PSI_mutex_key key_BINLOG_LOCK_index, key_BINLOG_LOCK_prep_xids,
key_delayed_insert_mutex, key_hash_filo_lock, key_LOCK_active_mi,
key_LOCK_connection_count, key_LOCK_crypt, key_LOCK_delayed_create,
-@@ -7855,6 +7857,7 @@
+@@ -7723,6 +7725,7 @@
{ &key_LOCK_system_variables_hash, "LOCK_system_variables_hash", PSI_FLAG_GLOBAL},
{ &key_LOCK_table_share, "LOCK_table_share", PSI_FLAG_GLOBAL},
{ &key_LOCK_thd_data, "THD::LOCK_thd_data", 0},
sql_command_flags[SQLCOM_SHOW_TABLE_STATUS]= (CF_STATUS_COMMAND |
CF_SHOW_TABLE_COMMAND |
CF_REEXECUTION_FRAGILE);
-@@ -1510,6 +1513,8 @@
+@@ -1520,6 +1523,8 @@
case SCH_TABLE_NAMES:
case SCH_TABLES:
case SCH_VIEWS:
case SCH_TRIGGERS:
case SCH_EVENTS:
-@@ -2083,6 +2088,7 @@
+@@ -2110,6 +2115,7 @@
}
case SQLCOM_SHOW_DATABASES:
case SQLCOM_SHOW_TABLES:
case SQLCOM_SHOW_TRIGGERS:
case SQLCOM_SHOW_TABLE_STATUS:
case SQLCOM_SHOW_OPEN_TABLES:
-@@ -4846,6 +4852,8 @@
+@@ -4919,6 +4925,8 @@
case SCH_TABLE_NAMES:
case SCH_TABLES:
case SQLCOM_SHOW_TRIGGERS:
case SQLCOM_SHOW_EVENTS:
thd->make_lex_string(&lookup_field_values->db_value,
-@@ -3279,6 +3280,231 @@
+@@ -3283,6 +3284,231 @@
return (uint) OPEN_FULL_TABLE;
}
/**
Try acquire high priority share metadata lock on a table (with
-@@ -7023,6 +7249,25 @@
+@@ -7046,6 +7272,25 @@
{0, 0, MYSQL_TYPE_STRING, 0, 0, 0, SKIP_OPEN_TABLE}
};
ST_FIELD_INFO columns_fields_info[]=
{
-@@ -7637,6 +7882,9 @@
+@@ -7660,6 +7905,9 @@
hton_fill_schema_table, 0, 0, -1, -1, 0, 0},
{"GLOBAL_STATUS", variables_fields_info, create_schema_table,
fill_status, make_old_format, 0, 0, -1, 0, 0},
{"GLOBAL_VARIABLES", variables_fields_info, create_schema_table,
fill_variables, make_old_format, 0, 0, -1, 0, 0},
{"KEY_COLUMN_USAGE", key_column_usage_fields_info, create_schema_table,
-@@ -7686,6 +7934,9 @@
+@@ -7709,6 +7957,9 @@
get_all_tables, make_table_names_old_format, 0, 1, 2, 1, 0},
{"TABLE_PRIVILEGES", table_privileges_fields_info, create_schema_table,
fill_schema_table_privileges, 0, 0, -1, -1, 0, 0},
OPEN_TRIGGER_ONLY|OPTIMIZE_I_S_TABLE},
--- a/sql/sql_yacc.yy
+++ b/sql/sql_yacc.yy
-@@ -10873,6 +10873,15 @@
+@@ -10898,6 +10898,15 @@
if (prepare_schema_table(YYTHD, lex, 0, SCH_TABLE_NAMES))
MYSQL_YYABORT;
}
LEX *lex= Lex;
--- a/sql/mysqld.h
+++ b/sql/mysqld.h
-@@ -233,6 +233,7 @@
+@@ -234,6 +234,7 @@
extern PSI_mutex_key key_LOCK_des_key_file;
#endif
key_LOCK_connection_count, key_LOCK_crypt, key_LOCK_delayed_create,
--- a/sql/sql_base.cc
+++ b/sql/sql_base.cc
-@@ -1588,12 +1588,16 @@
+@@ -1651,12 +1651,16 @@
if (!mysql_bin_log.is_open())
{
TABLE *tmp_next;
DBUG_RETURN(FALSE);
}
-@@ -1606,6 +1610,8 @@
+@@ -1669,6 +1673,8 @@
memcpy(buf, stub, stub_len);
/*
Insertion sort of temp tables by pseudo_thread_id to build ordered list
of sublists of equal pseudo_thread_id
-@@ -1727,6 +1733,8 @@
+@@ -1790,6 +1796,8 @@
thd->variables.option_bits&= ~OPTION_QUOTE_SHOW_CREATE; /* restore option */
thd->temporary_tables=0;
DBUG_RETURN(error);
}
-@@ -2104,6 +2112,8 @@
+@@ -2167,6 +2175,8 @@
table->s->db.str, table->s->table_name.str,
(long) table, table->alias));
if (table->prev)
{
table->prev->next= table->next;
-@@ -2130,6 +2140,9 @@
+@@ -2193,6 +2203,9 @@
slave_open_temp_tables--;
}
close_temporary(table, free_share, delete_table);
DBUG_VOID_RETURN;
}
-@@ -5854,6 +5867,7 @@
+@@ -5932,6 +5945,7 @@
if (add_to_temporary_tables_list)
{
/* growing temp list at the head */
tmp_table->next= thd->temporary_tables;
if (tmp_table->next)
tmp_table->next->prev= tmp_table;
-@@ -5861,6 +5875,7 @@
+@@ -5939,6 +5953,7 @@
thd->temporary_tables->prev= 0;
if (thd->slave_thread)
slave_open_temp_tables++;
DBUG_PRINT("tmptable", ("opened table: '%s'.'%s' 0x%lx", tmp_table->s->db.str,
--- a/sql/sql_class.cc
+++ b/sql/sql_class.cc
-@@ -837,6 +837,8 @@
+@@ -836,6 +836,8 @@
active_vio = 0;
#endif
mysql_mutex_init(key_LOCK_thd_data, &LOCK_thd_data, MY_MUTEX_INIT_FAST);
/* Variables with default values */
proc_info="login";
-@@ -1349,6 +1351,7 @@
+@@ -1348,6 +1350,7 @@
db= NULL;
free_root(&transaction.mem_root,MYF(0));
mysql_mutex_destroy(&LOCK_thd_data);
#endif
--- a/sql/sql_class.h
+++ b/sql/sql_class.h
-@@ -1004,6 +1004,11 @@
+@@ -1002,6 +1002,11 @@
XXX Why are internal temporary tables added to this list?
*/
TABLE *temporary_tables;
TABLE *derived_tables;
/*
During a MySQL session, one can lock tables in two modes: automatic
+--- /dev/null
++++ b/mysql-test/r/percona_show_temp_tables.result
+@@ -0,0 +1,58 @@
++drop table if exists t1,t2,t3;
++drop database if exists showtemp;
++create database if not exists showtemp;
++use test;
++create temporary table t1(id int);
++create temporary table t2(id int);
++create temporary table showtemp.t3(id int);
++insert into t1 values(10),(20),(30),(40);
++insert into showtemp.t3 values(999);
++show temporary tables;
++Temp_tables_in_test
++t2
++t1
++show temporary tables from test;
++Temp_tables_in_test
++t2
++t1
++show temporary tables in showtemp;
++Temp_tables_in_showtemp
++t3
++select table_schema, table_name, engine, table_rows from Information_schema.temporary_tables;
++table_schema table_name engine table_rows
++showtemp t3 MyISAM 1
++test t2 MyISAM 0
++test t1 MyISAM 4
++select table_schema, table_name, engine, table_rows from Information_schema.global_temporary_tables;
++table_schema table_name engine table_rows
++showtemp t3 MyISAM 1
++test t2 MyISAM 0
++test t1 MyISAM 4
++select table_schema, table_name, engine, table_rows from Information_schema.global_temporary_tables where table_schema='showtemp';
++table_schema table_name engine table_rows
++showtemp t3 MyISAM 1
++select table_schema, table_name, engine, table_rows from Information_schema.global_temporary_tables where table_schema='temp';
++table_schema table_name engine table_rows
++drop table if exists showtemp.t2;
++create temporary table t1(id int);
++create temporary table showtemp.t2(id int);
++show temporary tables;
++Temp_tables_in_test
++t1
++select table_schema, table_name, engine, table_rows from Information_schema.global_temporary_tables;
++table_schema table_name engine table_rows
++showtemp t2 MyISAM 0
++test t1 MyISAM 0
++showtemp t3 MyISAM 1
++test t2 MyISAM 0
++test t1 MyISAM 4
++drop table showtemp.t2;
++drop table t1;
++select table_schema, table_name, engine, table_rows from Information_schema.global_temporary_tables;
++table_schema table_name engine table_rows
++showtemp t3 MyISAM 1
++test t2 MyISAM 0
++test t1 MyISAM 4
++drop table t1, t2;
++drop table showtemp.t3;
++drop database showtemp;
+--- /dev/null
++++ b/mysql-test/t/percona_show_temp_tables.test
+@@ -0,0 +1,65 @@
++# Uses GRANT commands that usually disabled in embedded server
++-- source include/not_embedded.inc
++
++# Save the initial number of concurrent sessions
++--source include/count_sessions.inc
++
++#
++# Test of SHOW [GLOBAL] TEMPORARY TABLES [FROM/IN] DB and
++# Information_schema.temporary_tables and global_temporary_tables
++#
++
++connect(stcon1,localhost,root,,test);
++connect(stcon2,localhost,root,,test);
++
++connection stcon1;
++
++--disable_warnings
++drop table if exists t1,t2,t3;
++drop database if exists showtemp;
++create database if not exists showtemp;
++--enable_warnings
++
++use test;
++create temporary table t1(id int);
++create temporary table t2(id int);
++create temporary table showtemp.t3(id int);
++insert into t1 values(10),(20),(30),(40);
++insert into showtemp.t3 values(999);
++
++show temporary tables;
++# "Session" is not same value always. mysql-test cannot test it always.
++#show global temporary tables;
++show temporary tables from test;
++show temporary tables in showtemp;
++select table_schema, table_name, engine, table_rows from Information_schema.temporary_tables;
++select table_schema, table_name, engine, table_rows from Information_schema.global_temporary_tables;
++select table_schema, table_name, engine, table_rows from Information_schema.global_temporary_tables where table_schema='showtemp';
++select table_schema, table_name, engine, table_rows from Information_schema.global_temporary_tables where table_schema='temp';
++
++connection stcon2;
++
++--disable_warnings
++drop table if exists showtemp.t2;
++--enable_warnings
++create temporary table t1(id int);
++create temporary table showtemp.t2(id int);
++show temporary tables;
++select table_schema, table_name, engine, table_rows from Information_schema.global_temporary_tables;
++drop table showtemp.t2;
++drop table t1;
++
++disconnect stcon2;
++
++connection stcon1;
++select table_schema, table_name, engine, table_rows from Information_schema.global_temporary_tables;
++
++drop table t1, t2;
++drop table showtemp.t3;
++drop database showtemp;
++
++connection default;
++disconnect stcon1;
++
++# Wait till all disconnects are completed
++--source include/wait_until_count_sessions.inc