List:Internals« Previous MessageNext Message »
From:ingo Date:August 9 2005 12:57pm
Subject:bk commit into 4.1 tree (ingo:1.2365) BUG#11493
View as plain text  
Below is the list of changes that have just been committed into a local
4.1 repository of mydev. When mydev does a push these changes will
be propagated to the main repository and, within 24 hours after the
push, to the public repository.
For information on how to access the public repository
see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html

ChangeSet
  1.2365 05/08/09 14:57:36 ingo@stripped +3 -0
  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.

  sql/sql_parse.cc
    1.457 05/08/09 14:57:31 ingo@stripped +18 -1
    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/t/alter_table.test
    1.39 05/08/09 14:57:31 ingo@stripped +31 -0
    Bug#11493 - Alter table rename to default database does not work without db name qualifying
    The test case.

  mysql-test/r/alter_table.result
    1.49 05/08/09 14:57:31 ingo@stripped +15 -0
    Bug#11493 - Alter table rename to default database does not work without db name qualifying
    The test result.

# This is a BitKeeper patch.  What follows are the unified diffs for the
# set of deltas contained in the patch.  The rest of the patch, the part
# that BitKeeper cares about, is below these diffs.
# User:	ingo
# Host:	chilla.local
# Root:	/home/mydev/mysql-4.1-4100

--- 1.456/sql/sql_parse.cc	2005-08-05 15:37:18 +02:00
+++ 1.457/sql/sql_parse.cc	2005-08-09 14:57:31 +02:00
@@ -2599,7 +2599,24 @@
 	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,

--- 1.48/mysql-test/r/alter_table.result	2005-05-14 15:24:32 +02:00
+++ 1.49/mysql-test/r/alter_table.result	2005-08-09 14:57:31 +02:00
@@ -528,3 +528,18 @@
 alter table t1 add unique ( a(1) );
 ERROR HY000: Incorrect sub part key; the used key part isn't a string, the used length is longer than the key part, or the storage engine doesn't support unique sub keys
 drop table t1;
+create database mysqltest1;
+create table t1 (c1 int);
+alter table t1 rename mysqltest1.t1;
+drop table t1;
+ERROR 42S02: Unknown table 't1'
+alter table mysqltest1.t1 rename t1;
+drop table t1;
+create table t1 (c1 int);
+use mysqltest1;
+drop database mysqltest1;
+alter table test.t1 rename t1;
+ERROR 3D000: No database selected
+alter table test.t1 rename test.t1;
+use test;
+drop table t1;

--- 1.38/mysql-test/t/alter_table.test	2005-07-28 02:21:39 +02:00
+++ 1.39/mysql-test/t/alter_table.test	2005-08-09 14:57:31 +02:00
@@ -361,4 +361,35 @@
 alter table t1 add unique ( a(1) );
 drop table t1;
 
+#
+# Bug#11493 - Alter table rename to default database does not work without
+#             db name qualifying
+#
+create database mysqltest1;
+create table t1 (c1 int);
+# Move table to other database.
+alter table t1 rename mysqltest1.t1;
+# Assure that it has moved.
+--error 1051
+drop table t1;
+# Move table back.
+alter table mysqltest1.t1 rename t1;
+# Assure that it is back.
+drop table t1;
+# Now test for correct message if no database is selected.
+# Create t1 in 'test'.
+create table t1 (c1 int);
+# Change to other db.
+use mysqltest1;
+# Drop the current db. This de-selects any db.
+drop database mysqltest1;
+# Now test for correct message.
+--error 1046
+alter table test.t1 rename t1;
+# Check that explicit qualifying works even with no selected db.
+alter table test.t1 rename test.t1;
+# Go back to standard 'test' db.
+use test;
+drop table t1;
+
 # End of 4.1 tests
Thread
bk commit into 4.1 tree (ingo:1.2365) BUG#11493ingo9 Aug