From 0f7161b050d398971495bbe1b674684665162753 Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 29 Aug 2005 16:54:33 +0200 Subject: Bug#11493 - Alter table rename to default database does not work without db name qualifying Supplied the default database name for ALTER TABLE ... RENAME for the new table instead of the old tables db like we do for other ALTERs. mysql-test/r/alter_table.result: Bug#11493 - Alter table rename to default database does not work without db name qualifying The test result. mysql-test/t/alter_table.test: Bug#11493 - Alter table rename to default database does not work without db name qualifying The test case. --- sql/sql_parse.cc | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) (limited to 'sql/sql_parse.cc') diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index cd87b097038..caf76b19eb2 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -2599,7 +2599,24 @@ unsent_create_error: break; } if (!select_lex->db) - select_lex->db=tables->db; + { + /* + In the case of ALTER TABLE ... RENAME we should supply the + default database if the new name is not explicitly qualified + by a database. (Bug #11493) + */ + if (lex->alter_info.flags & ALTER_RENAME) + { + if (! thd->db) + { + send_error(thd,ER_NO_DB_ERROR); + goto error; + } + select_lex->db= thd->db; + } + else + select_lex->db=tables->db; + } if (check_access(thd,ALTER_ACL,tables->db,&tables->grant.privilege,0,0) || check_access(thd,INSERT_ACL | CREATE_ACL,select_lex->db,&priv,0,0)|| check_merge_table_access(thd, tables->db, -- cgit v1.2.1