summaryrefslogtreecommitdiff
path: root/sql/sql_parse.cc
diff options
context:
space:
mode:
authorunknown <gkodinov/kgeorge@macbook.gmz>2006-09-04 18:40:30 +0300
committerunknown <gkodinov/kgeorge@macbook.gmz>2006-09-04 18:40:30 +0300
commit1431966d029ffd710c678080bee9e1d884205127 (patch)
tree7791cbe549cd4f2437153138cbf3487b0e3257ef /sql/sql_parse.cc
parent85c064f6b19ee5e596540f7a0d0937b0abb9b3ba (diff)
downloadmariadb-git-1431966d029ffd710c678080bee9e1d884205127.tar.gz
Bug #21392: multi-table delete with alias table name fails with
1003: Incorrect table name in multi-table DELETE the set of tables to delete from actually references then tables in the other list, e.g: DELETE alias_of_t1 FROM t1 alias_of_t1 WHERE .... is a valid statement. So we must turn off table name syntactical validity check for alias_of_t1 because it's not a table name (even if it looks like one). In order to do that we add a special flag (TL_OPTION_ALIAS) to disable the name checking for the aliases in multi-table DELETE. mysql-test/r/delete.result: Bug #21392: multi-table delete with alias table name fails with 1003: Incorrect table name - test case mysql-test/t/delete.test: Bug #21392: multi-table delete with alias table name fails with 1003: Incorrect table name - test case sql/mysql_priv.h: Bug #21392: multi-table delete with alias table name fails with 1003: Incorrect table name - add a special flag to disable the name checking for the aliases in multi-table DELETE sql/sql_parse.cc: Bug #21392: multi-table delete with alias table name fails with 1003: Incorrect table name - add a special flag to disable the name checking for the aliases in multi-table DELETE sql/sql_yacc.yy: Bug #21392: multi-table delete with alias table name fails with 1003: Incorrect table name - add a special flag to disable the name checking for the aliases in multi-table DELETE
Diffstat (limited to 'sql/sql_parse.cc')
-rw-r--r--sql/sql_parse.cc4
1 files changed, 3 insertions, 1 deletions
diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc
index cf1f50aed63..c84c96e1e75 100644
--- a/sql/sql_parse.cc
+++ b/sql/sql_parse.cc
@@ -4863,6 +4863,7 @@ bool add_to_list(THD *thd, SQL_LIST &list,Item *item,bool asc)
table_options A set of the following bits:
TL_OPTION_UPDATING Table will be updated
TL_OPTION_FORCE_INDEX Force usage of index
+ TL_OPTION_ALIAS an alias in multi table DELETE
lock_type How table should be locked
use_index List of indexed used in USE INDEX
ignore_index List of indexed used in IGNORE INDEX
@@ -4888,7 +4889,8 @@ TABLE_LIST *st_select_lex::add_table_to_list(THD *thd,
if (!table)
DBUG_RETURN(0); // End of memory
alias_str= alias ? alias->str : table->table.str;
- if (check_table_name(table->table.str,table->table.length) ||
+ if (!test(table_options & TL_OPTION_ALIAS) &&
+ check_table_name(table->table.str,table->table.length) ||
table->db.str && check_db_name(table->db.str))
{
net_printf(thd, ER_WRONG_TABLE_NAME, table->table.str);