From 2b548fe935b126fb4c0c9bfd109ed7dee778382b Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 31 May 2005 18:06:54 +0100 Subject: [PATCH] Bug#10413 - Invalid column name is not rejected Stop ignoring name parts and check for validity mysql-test/r/create.result: Test for bug#10413 mysql-test/t/create.test: Test for bug#10413 sql/sql_yacc.yy: Bug#10413 Stop ignoring parts of fully qualified names. --- mysql-test/r/create.result | 9 +++++++++ mysql-test/t/create.test | 13 +++++++++++++ sql/sql_yacc.yy | 26 +++++++++++++++++++++++++- 3 files changed, 47 insertions(+), 1 deletion(-) diff --git a/mysql-test/r/create.result b/mysql-test/r/create.result index 103bed598ef..cae5e24df18 100644 --- a/mysql-test/r/create.result +++ b/mysql-test/r/create.result @@ -563,3 +563,12 @@ select * from t2; b 1 drop table t1,t2; +create table t1(column.name int); +ERROR 42000: Incorrect table name 'column' +create table t1(test.column.name int); +ERROR 42000: Incorrect table name 'column' +create table t1(xyz.t1.name int); +ERROR 42000: Incorrect database name 'xyz' +create table t1(t1.name int); +create table t2(test.t2.name int); +drop table t1,t2; diff --git a/mysql-test/t/create.test b/mysql-test/t/create.test index ce85e530569..dca662a415e 100644 --- a/mysql-test/t/create.test +++ b/mysql-test/t/create.test @@ -460,3 +460,16 @@ insert into t2 values (); select * from t1; select * from t2; drop table t1,t2; + +# +# Bug#10413: Invalid column name is not rejected +# +--error 1103 +create table t1(column.name int); +--error 1103 +create table t1(test.column.name int); +--error 1102 +create table t1(xyz.t1.name int); +create table t1(t1.name int); +create table t2(test.t2.name int); +drop table t1,t2; diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy index d8a2c997bf8..7585f0b10a0 100644 --- a/sql/sql_yacc.yy +++ b/sql/sql_yacc.yy @@ -5016,7 +5016,31 @@ simple_ident: field_ident: ident { $$=$1;} - | ident '.' ident { $$=$3;} /* Skip schema name in create*/ + | ident '.' ident '.' ident + { + TABLE_LIST *table= (TABLE_LIST*) Select->table_list.first; + if (my_strcasecmp(table_alias_charset, $1.str, table->db)) + { + net_printf(YYTHD, ER_WRONG_DB_NAME, $1.str); + YYABORT; + } + if (my_strcasecmp(table_alias_charset, $3.str, table->real_name)) + { + net_printf(YYTHD, ER_WRONG_TABLE_NAME, $3.str); + YYABORT; + } + $$=$5; + } + | ident '.' ident + { + TABLE_LIST *table= (TABLE_LIST*) Select->table_list.first; + if (my_strcasecmp(table_alias_charset, $1.str, table->alias)) + { + net_printf(YYTHD, ER_WRONG_TABLE_NAME, $1.str); + YYABORT; + } + $$=$3; + } | '.' ident { $$=$2;} /* For Delphi */; table_ident: