mirror of
https://github.com/MariaDB/server.git
synced 2025-08-01 03:47:19 +03:00
MDEV-32973 SHOW TABLES LIKE shows temporary tables with non-matching names
* compare both db and table name * use the correct charset
This commit is contained in:
@ -271,3 +271,26 @@ CREATE TABLE t1 (a Mariadb_schema.date);
|
|||||||
ERROR HY000: Unknown data type: 'Mariadb_schema.date'
|
ERROR HY000: Unknown data type: 'Mariadb_schema.date'
|
||||||
CREATE TABLE t1 (a mariadb_schema.date);
|
CREATE TABLE t1 (a mariadb_schema.date);
|
||||||
DROP TABLE t1;
|
DROP TABLE t1;
|
||||||
|
# End of 10.3 tests
|
||||||
|
#
|
||||||
|
# MDEV-32973 SHOW TABLES LIKE shows temporary tables with non-matching names
|
||||||
|
#
|
||||||
|
create temporary table t1 (a int);
|
||||||
|
create temporary table t2 (a int);
|
||||||
|
create temporary table T1 (a int);
|
||||||
|
show tables like 't1';
|
||||||
|
Tables_in_test (t1)
|
||||||
|
t1
|
||||||
|
select table_name from information_schema.tables where table_schema='test'
|
||||||
|
and table_name='t1';
|
||||||
|
table_name
|
||||||
|
t1
|
||||||
|
show tables like '_1';
|
||||||
|
Tables_in_test (_1)
|
||||||
|
T1
|
||||||
|
t1
|
||||||
|
show tables like 't%';
|
||||||
|
Tables_in_test (t%)
|
||||||
|
t2
|
||||||
|
t1
|
||||||
|
# End of 11.2 tests
|
||||||
|
@ -146,3 +146,19 @@ CREATE TABLE t1 (a Mariadb_schema.date);
|
|||||||
|
|
||||||
CREATE TABLE t1 (a mariadb_schema.date);
|
CREATE TABLE t1 (a mariadb_schema.date);
|
||||||
DROP TABLE t1;
|
DROP TABLE t1;
|
||||||
|
|
||||||
|
--echo # End of 10.3 tests
|
||||||
|
|
||||||
|
--echo #
|
||||||
|
--echo # MDEV-32973 SHOW TABLES LIKE shows temporary tables with non-matching names
|
||||||
|
--echo #
|
||||||
|
create temporary table t1 (a int);
|
||||||
|
create temporary table t2 (a int);
|
||||||
|
create temporary table T1 (a int);
|
||||||
|
show tables like 't1';
|
||||||
|
select table_name from information_schema.tables where table_schema='test'
|
||||||
|
and table_name='t1';
|
||||||
|
show tables like '_1';
|
||||||
|
show tables like 't%';
|
||||||
|
|
||||||
|
--echo # End of 11.2 tests
|
||||||
|
@ -377,3 +377,36 @@ SHOW CREATE DATABASE db1;
|
|||||||
Database Create Database
|
Database Create Database
|
||||||
db1 CREATE DATABASE `db1` /*!40100 DEFAULT CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci */
|
db1 CREATE DATABASE `db1` /*!40100 DEFAULT CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci */
|
||||||
DROP DATABASE Db1;
|
DROP DATABASE Db1;
|
||||||
|
USE test;
|
||||||
|
# End of 10.4 tests
|
||||||
|
#
|
||||||
|
# MDEV-32973 SHOW TABLES LIKE shows temporary tables with non-matching names
|
||||||
|
#
|
||||||
|
create temporary table t2 (a int);
|
||||||
|
create temporary table T1 (a int);
|
||||||
|
show tables;
|
||||||
|
Tables_in_test
|
||||||
|
t1
|
||||||
|
t2
|
||||||
|
show tables like 't1';
|
||||||
|
Tables_in_test (t1)
|
||||||
|
t1
|
||||||
|
show tables like 'T1';
|
||||||
|
Tables_in_test (T1)
|
||||||
|
t1
|
||||||
|
select table_name from information_schema.tables where table_schema='test'
|
||||||
|
and table_name='t1';
|
||||||
|
table_name
|
||||||
|
t1
|
||||||
|
select table_name from information_schema.tables where table_schema='test'
|
||||||
|
and table_name='T1';
|
||||||
|
table_name
|
||||||
|
t1
|
||||||
|
show tables like '_1';
|
||||||
|
Tables_in_test (_1)
|
||||||
|
t1
|
||||||
|
show tables like 't%';
|
||||||
|
Tables_in_test (t%)
|
||||||
|
t1
|
||||||
|
t2
|
||||||
|
# End of 11.2 tests
|
||||||
|
@ -328,3 +328,24 @@ ALTER DATABASE Db1 DEFAULT CHARACTER SET utf8;
|
|||||||
SHOW CREATE DATABASE Db1;
|
SHOW CREATE DATABASE Db1;
|
||||||
SHOW CREATE DATABASE db1;
|
SHOW CREATE DATABASE db1;
|
||||||
DROP DATABASE Db1;
|
DROP DATABASE Db1;
|
||||||
|
USE test;
|
||||||
|
|
||||||
|
--echo # End of 10.4 tests
|
||||||
|
|
||||||
|
--echo #
|
||||||
|
--echo # MDEV-32973 SHOW TABLES LIKE shows temporary tables with non-matching names
|
||||||
|
--echo #
|
||||||
|
# temp tables don't preserve the letter case despite lower-case-table-names=2
|
||||||
|
create temporary table t2 (a int);
|
||||||
|
create temporary table T1 (a int);
|
||||||
|
show tables;
|
||||||
|
show tables like 't1';
|
||||||
|
show tables like 'T1';
|
||||||
|
select table_name from information_schema.tables where table_schema='test'
|
||||||
|
and table_name='t1';
|
||||||
|
select table_name from information_schema.tables where table_schema='test'
|
||||||
|
and table_name='T1';
|
||||||
|
show tables like '_1';
|
||||||
|
show tables like 't%';
|
||||||
|
|
||||||
|
--echo # End of 11.2 tests
|
||||||
|
@ -343,7 +343,6 @@ TEST-INFO: SLAVE: The INSERT is committed (Succeeded)
|
|||||||
connection master;
|
connection master;
|
||||||
SHOW TABLES LIKE 't2';
|
SHOW TABLES LIKE 't2';
|
||||||
Tables_in_mysqltest1 (t2)
|
Tables_in_mysqltest1 (t2)
|
||||||
t23
|
|
||||||
connection slave;
|
connection slave;
|
||||||
SHOW TABLES LIKE 't2';
|
SHOW TABLES LIKE 't2';
|
||||||
Tables_in_mysqltest1 (t2)
|
Tables_in_mysqltest1 (t2)
|
||||||
|
@ -5215,6 +5215,20 @@ public:
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
static bool wildcmpcs(const LEX_CSTRING &str, const LEX_CSTRING &pat)
|
||||||
|
{
|
||||||
|
return table_alias_charset->wildcmp(str.str, str.str + str.length,
|
||||||
|
pat.str, pat.str + pat.length,
|
||||||
|
'\\', '_', '%');
|
||||||
|
}
|
||||||
|
|
||||||
|
static bool strcmpcs(const LEX_CSTRING &str, const LEX_CSTRING &pat)
|
||||||
|
{
|
||||||
|
return table_alias_charset->strnncoll(str.str, str.length,
|
||||||
|
pat.str, pat.length, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@brief Fill I_S tables whose data are retrieved
|
@brief Fill I_S tables whose data are retrieved
|
||||||
from frm files and storage engine
|
from frm files and storage engine
|
||||||
@ -5346,15 +5360,20 @@ int get_all_tables(THD *thd, TABLE_LIST *tables, COND *cond)
|
|||||||
{
|
{
|
||||||
All_tmp_tables_list::Iterator it(*open_tables_state_backup.temporary_tables);
|
All_tmp_tables_list::Iterator it(*open_tables_state_backup.temporary_tables);
|
||||||
TMP_TABLE_SHARE *share_temp;
|
TMP_TABLE_SHARE *share_temp;
|
||||||
const char *lookup_db= plan->lookup_field_vals.db_value.str;
|
bool (*cmp_db)(const LEX_CSTRING &, const LEX_CSTRING &)=
|
||||||
int (*cmp)(CHARSET_INFO *, const char *, const char *)=
|
plan->lookup_field_vals.wild_db_value ? wildcmpcs : strcmpcs;
|
||||||
plan->lookup_field_vals.wild_db_value
|
bool (*cmp_table)(const LEX_CSTRING &, const LEX_CSTRING &)=
|
||||||
? wild_case_compare : system_charset_info->coll->strcasecmp;
|
plan->lookup_field_vals.wild_table_value ? wildcmpcs : strcmpcs;
|
||||||
while ((share_temp= it++))
|
while ((share_temp= it++))
|
||||||
{
|
{
|
||||||
if (lookup_db)
|
if (plan->lookup_field_vals.db_value.str)
|
||||||
{
|
{
|
||||||
if (cmp(system_charset_info, share_temp->db.str, lookup_db))
|
if (cmp_db(share_temp->db, plan->lookup_field_vals.db_value))
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (plan->lookup_field_vals.table_value.str)
|
||||||
|
{
|
||||||
|
if (cmp_table(share_temp->table_name, plan->lookup_field_vals.table_value))
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user