MySQL Lists are EOL. Please join:

List:Commits« Previous MessageNext Message »
From:pem Date:April 18 2006 2:01pm
Subject:bk commit into 5.0 tree (pem:1.2157) 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.2157 06/04/18 16:01:01 pem@stripped +3 -0
  Fixed BUG#18344: DROP DATABASE does not drop associated routines
    We must use the db key 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/18 16:00:57 pem@stripped +8 -12
    In sp_drop_db_routines(), give the key field's ("db") key 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.184 06/04/18 16:00:57 pem@stripped +32 -0
    Added new test case for BUG#18344.

  mysql-test/r/sp.result
    1.196 06/04/18 16:00:57 pem@stripped +29 -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.195/mysql-test/r/sp.result	2006-04-18 11:20:12 +02:00
+++ 1.196/mysql-test/r/sp.result	2006-04-18 16:00:57 +02:00
@@ -4858,4 +4858,33 @@
 no_such_function()
 NULL
 drop procedure bug18787|
+create database bug18344_012345678901|
+use bug18344_012345678901|
+create procedure bug18344() begin end|
+create procedure bug18344_2() begin end|
+create database bug18344_0123456789012|
+use bug18344_0123456789012|
+create procedure bug18344() begin end|
+create procedure bug18344_2() 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_2	bug18344_012345678901
+bug18344	bug18344_0123456789012
+bug18344_2	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.183/mysql-test/t/sp.test	2006-04-18 11:20:12 +02:00
+++ 1.184/mysql-test/t/sp.test	2006-04-18 16:00:57 +02:00
@@ -5717,6 +5717,38 @@
 
 
 #
+# 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 procedure bug18344_2() begin end|
+
+create database bug18344_0123456789012| 
+use bug18344_0123456789012|
+create procedure bug18344() begin end|
+create procedure bug18344_2() 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-18 16:00:57 +02:00
@@ -886,28 +886,23 @@
 sp_drop_db_routines(THD *thd, char *db)
 {
   TABLE *table;
-  byte key[64];			// db
-  uint keylen;
   int ret;
+  uint key_len;
   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;
 
+  table->field[MYSQL_PROC_FIELD_DB]->store(db, strlen(db), system_charset_info);
+  key_len= table->key_info->key_part[0].store_length;
+
   ret= SP_OK;
   table->file->ha_index_init(0);
   if (! table->file->index_read(table->record[0],
-				key, keylen, HA_READ_KEY_EXACT))
+                                table->field[MYSQL_PROC_FIELD_DB]->ptr,
+				key_len, HA_READ_KEY_EXACT))
   {
     int nxtres;
     bool deleted= FALSE;
@@ -923,7 +918,8 @@
 	break;
       }
     } while (! (nxtres= table->file->index_next_same(table->record[0],
-						     key, keylen)));
+                                        table->field[MYSQL_PROC_FIELD_DB]->ptr,
+						     key_len)));
     if (nxtres != HA_ERR_END_OF_FILE)
       ret= SP_KEY_NOT_FOUND;
     if (deleted)
Thread
bk commit into 5.0 tree (pem:1.2157) BUG#18344pem18 Apr