From 06691fc3c6a7310669c236f4c533ffeafee3a754 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 7 Mar 2006 13:05:24 +0400 Subject: [PATCH] Bug#17142 Crash if create with encoded name upgrade.result, upgrade.test: Adding test case. table.cc: Don't try to open a table with old-formatted name, if the table name contains "@" character. This is to avoid mixing two different names to each other. Thanks Monty for suggesting this fix. sql/table.cc: Bug#17142 Crash if create with encoded name Don't try to open a table with old-formatted name, if the table name contains "@" character. This is to avoid mixing two different names to each other. mysql-test/t/upgrade.test: Adding test case. mysql-test/r/upgrade.result: Adding test case. --- mysql-test/r/upgrade.result | 16 ++++++++++++++++ mysql-test/t/upgrade.test | 18 ++++++++++++++++++ sql/table.cc | 3 +++ 3 files changed, 37 insertions(+) diff --git a/mysql-test/r/upgrade.result b/mysql-test/r/upgrade.result index bd60b02cb6a..9d35314d0c6 100644 --- a/mysql-test/r/upgrade.result +++ b/mysql-test/r/upgrade.result @@ -41,3 +41,19 @@ t1 t-1 drop database `mysqltest1`; drop database `mysqltest-1`; +drop table if exists `txu@0023P@0023p1`; +drop table if exists `txu#P#p1`; +create table `txu#P#p1` (s1 int); +insert into `txu#P#p1` values (1); +select * from `txu@0023P@0023p1`; +ERROR 42S02: Table 'test.txu@0023P@0023p1' doesn't exist +create table `txu@0023P@0023p1` (s1 int); +insert into `txu@0023P@0023p1` values (2); +select * from `txu@0023P@0023p1`; +s1 +2 +select * from `txu#P#p1`; +s1 +1 +drop table `txu@0023P@0023p1`; +drop table `txu#P#p1`; diff --git a/mysql-test/t/upgrade.test b/mysql-test/t/upgrade.test index 42e32b686c2..f2017d81d5c 100644 --- a/mysql-test/t/upgrade.test +++ b/mysql-test/t/upgrade.test @@ -29,3 +29,21 @@ show tables in `mysqltest1`; show tables in `mysqltest-1`; drop database `mysqltest1`; drop database `mysqltest-1`; + +# +# Bug#17142: Crash if create with encoded name +# +--disable_warnings +drop table if exists `txu@0023P@0023p1`; +drop table if exists `txu#P#p1`; +--enable_warnings +create table `txu#P#p1` (s1 int); +insert into `txu#P#p1` values (1); +--error 1146 +select * from `txu@0023P@0023p1`; +create table `txu@0023P@0023p1` (s1 int); +insert into `txu@0023P@0023p1` values (2); +select * from `txu@0023P@0023p1`; +select * from `txu#P#p1`; +drop table `txu@0023P@0023p1`; +drop table `txu#P#p1`; diff --git a/sql/table.cc b/sql/table.cc index d6a715ae1b4..d0d8e6ad1b1 100644 --- a/sql/table.cc +++ b/sql/table.cc @@ -298,6 +298,9 @@ int open_table_def(THD *thd, TABLE_SHARE *share, uint db_flags) strxmov(path, share->normalized_path.str, reg_ext, NullS); if ((file= my_open(path, O_RDONLY | O_SHARE, MYF(0))) < 0) { + if (strchr(share->table_name.str, '@')) + goto err_not_open; + /* Try unecoded 5.0 name */ uint length; strxnmov(path, sizeof(path)-1,