MySQL Lists are EOL. Please join:

List:Commits« Previous MessageNext Message »
From:pem Date:April 3 2006 11:36am
Subject:bk commit into 5.0 tree (pem:1.2121) BUG#18344
View as plain text  
Below is the list of changes that have just been committed into a local
5.0 repository of pem. When pem 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.2121 06/04/03 13:35:46 pem@stripped +3 -0
  Fixed BUG#18344: DROP DATABASE does not drop associated routines
    We must use the db key's pack length in sp_drop_db_routines (and not the
    number of characters), or long db names will be truncated in the key.

  sql/sp.cc
    1.110 06/04/03 13:35:42 pem@stripped +14 -11
    In sp_drop_db_routines(), give the key field's ("db") pack_length
    instead of the number of characters to index_read(), or the key
    packing will truncate long db names.

  mysql-test/t/sp.test
    1.182 06/04/03 13:35:42 pem@stripped +30 -0
    Added new test case for BUG#18344.

  mysql-test/r/sp.result
    1.194 06/04/03 13:35:42 pem@stripped +25 -0
    Updated results for new test case (BUG#18344)

# 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:	pem
# Host:	pem.mysql.com
# Root:	/extern/mysql/5.0/bug18344/mysql-5.0-runtime

--- 1.193/mysql-test/r/sp.result	2006-03-28 14:18:44 +02:00
+++ 1.194/mysql-test/r/sp.result	2006-04-03 13:35:42 +02:00
@@ -4837,4 +4837,29 @@
 b	3
 a	1
 delete from t1|
+create database bug18344_012345678901|
+use bug18344_012345678901|
+create procedure bug18344() begin end|
+create database bug18344_0123456789012|
+use bug18344_0123456789012|
+create procedure bug18344() begin end|
+use test|
+select schema_name from information_schema.schemata where 
+schema_name like 'bug18344%'|
+schema_name
+bug18344_012345678901
+bug18344_0123456789012
+select routine_name,routine_schema from information_schema.routines where
+routine_schema like 'bug18344%'|
+routine_name	routine_schema
+bug18344	bug18344_012345678901
+bug18344	bug18344_0123456789012
+drop database bug18344_012345678901|
+drop database bug18344_0123456789012|
+select schema_name from information_schema.schemata where 
+schema_name like 'bug18344%'|
+schema_name
+select routine_name,routine_schema from information_schema.routines where
+routine_schema like 'bug18344%'|
+routine_name	routine_schema
 drop table t1,t2;

--- 1.181/mysql-test/t/sp.test	2006-03-28 14:17:15 +02:00
+++ 1.182/mysql-test/t/sp.test	2006-04-03 13:35:42 +02:00
@@ -5684,6 +5684,36 @@
 
 
 #
+# BUG#18344: DROP DATABASE does not drop associated routines
+# (... if the database name is longer than 21 characters)
+#
+#               1234567890123456789012
+create database bug18344_012345678901| 
+use bug18344_012345678901|
+create procedure bug18344() begin end|
+
+create database bug18344_0123456789012| 
+use bug18344_0123456789012|
+create procedure bug18344() begin end|
+
+use test|
+
+select schema_name from information_schema.schemata where 
+  schema_name like 'bug18344%'|
+select routine_name,routine_schema from information_schema.routines where
+  routine_schema like 'bug18344%'|
+
+drop database bug18344_012345678901| 
+drop database bug18344_0123456789012| 
+
+# Should be nothing left.
+select schema_name from information_schema.schemata where 
+  schema_name like 'bug18344%'|
+select routine_name,routine_schema from information_schema.routines where
+  routine_schema like 'bug18344%'|
+
+
+#
 # BUG#NNNN: New bug synopsis
 #
 #--disable_warnings

--- 1.109/sql/sp.cc	2006-03-28 15:08:04 +02:00
+++ 1.110/sql/sp.cc	2006-04-03 13:35:42 +02:00
@@ -886,28 +886,31 @@
 sp_drop_db_routines(THD *thd, char *db)
 {
   TABLE *table;
-  byte key[64];			// db
-  uint keylen;
+  byte key[MAX_KEY_LENGTH];     // db
+  uint keylen, pack_length;
   int ret;
   DBUG_ENTER("sp_drop_db_routines");
   DBUG_PRINT("enter", ("db: %s", db));
 
-  // Put the key used to read the row together
-  keylen= strlen(db);
-  if (keylen > 64)
-    keylen= 64;
-  memcpy(key, db, keylen);
-  memset(key+keylen, (int)' ', 64-keylen); // Pad with space
-  keylen= sizeof(key);
-
   ret= SP_OPEN_TABLE_FAILED;
   if (!(table= open_proc_table_for_update(thd)))
     goto err;
 
+  /*
+    Put the key used to read the row together. We need the pack length
+    to get the key packing in index_read() right for utf8 charsets.
+  */
+  keylen= strlen(db);
+  pack_length= table->field[MYSQL_PROC_FIELD_DB]->pack_length();
+  if (keylen > pack_length)
+    keylen= pack_length;
+  memcpy(key, db, keylen);
+  memset(key+keylen, (int)' ', pack_length-keylen); // Pad with space
+
   ret= SP_OK;
   table->file->ha_index_init(0);
   if (! table->file->index_read(table->record[0],
-				key, keylen, HA_READ_KEY_EXACT))
+				key, pack_length, HA_READ_KEY_EXACT))
   {
     int nxtres;
     bool deleted= FALSE;
Thread
bk commit into 5.0 tree (pem:1.2121) BUG#18344pem3 Apr