summaryrefslogtreecommitdiff
path: root/sql/sp.cc
diff options
context:
space:
mode:
authorunknown <pem@mysql.com>2006-04-18 16:01:01 +0200
committerunknown <pem@mysql.com>2006-04-18 16:01:01 +0200
commit176cd1435216fc1fc3fb8234d8f1ad60f84fbf85 (patch)
treeb75f948f5c82647a0e961c280ee0db1ea9adbf7f /sql/sp.cc
parent750bc26998ce0ccf5bd78d255d54206bf716f1c2 (diff)
downloadmariadb-git-176cd1435216fc1fc3fb8234d8f1ad60f84fbf85.tar.gz
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. mysql-test/r/sp.result: Updated results for new test case (BUG#18344) mysql-test/t/sp.test: Added new test case for BUG#18344. sql/sp.cc: 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.
Diffstat (limited to 'sql/sp.cc')
-rw-r--r--sql/sp.cc20
1 files changed, 8 insertions, 12 deletions
diff --git a/sql/sp.cc b/sql/sp.cc
index cfcf011032d..ab391e531eb 100644
--- a/sql/sp.cc
+++ b/sql/sp.cc
@@ -886,28 +886,23 @@ int
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 @@ sp_drop_db_routines(THD *thd, char *db)
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)