diff options
author | unknown <ingo@mysql.com> | 2005-08-29 16:54:33 +0200 |
---|---|---|
committer | unknown <ingo@mysql.com> | 2005-08-29 16:54:33 +0200 |
commit | 0f7161b050d398971495bbe1b674684665162753 (patch) | |
tree | a8552252801267060754c1595ab9cd2a5166ed36 /sql/sql_parse.cc | |
parent | f876fae9c87b8330b3405a51ad886151ee300db4 (diff) | |
download | mariadb-git-0f7161b050d398971495bbe1b674684665162753.tar.gz |
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.
Diffstat (limited to 'sql/sql_parse.cc')
-rw-r--r-- | sql/sql_parse.cc | 19 |
1 files changed, 18 insertions, 1 deletions
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, |