summaryrefslogtreecommitdiff
path: root/sql/sp_head.cc
diff options
context:
space:
mode:
authorpem@mysql.comhem.se <>2004-09-08 14:23:14 +0200
committerpem@mysql.comhem.se <>2004-09-08 14:23:14 +0200
commitb83af8607ada799ab5612d9ce6b3793c9ff9cfb9 (patch)
treebf5ec7b5d6fd4a091b16a9fb6c6ca68cc5d2c22b /sql/sp_head.cc
parent3aa2a62f37cb4e34b86a8d1f495c90727a461621 (diff)
downloadmariadb-git-b83af8607ada799ab5612d9ce6b3793c9ff9cfb9.tar.gz
Fixed BUG#5000: SPs can be created with no default database.
Easy to prevent crash, but the question was how to treat this case? We ended up implementing the "global" SPs (i.e. with no associated db), which were planned but left unresolved when SPs moved into dbs. So now things like "call .p()" work too.
Diffstat (limited to 'sql/sp_head.cc')
-rw-r--r--sql/sp_head.cc12
1 files changed, 4 insertions, 8 deletions
diff --git a/sql/sp_head.cc b/sql/sp_head.cc
index 4bb06fd8172..5222f8e6fbe 100644
--- a/sql/sp_head.cc
+++ b/sql/sp_head.cc
@@ -296,16 +296,11 @@ sp_head::init_strings(THD *thd, LEX *lex, sp_name *name)
name->m_db.length, name->m_db.str,
name->m_name.length, name->m_name.str));
/* We have to copy strings to get them into the right memroot */
+ m_db.length= name->m_db.length;
if (name->m_db.length == 0)
- {
- m_db.length= (thd->db ? strlen(thd->db) : 0);
- m_db.str= strmake_root(root, (thd->db ? thd->db : ""), m_db.length);
- }
+ m_db.str= NULL;
else
- {
- m_db.length= name->m_db.length;
m_db.str= strmake_root(root, name->m_db.str, name->m_db.length);
- }
m_name.length= name->m_name.length;
m_name.str= strmake_root(root, name->m_name.str, name->m_name.length);
@@ -453,7 +448,8 @@ sp_head::execute(THD *thd)
#endif
dbchanged= FALSE;
- if ((ret= sp_use_new_db(thd, m_db.str, olddb, sizeof(olddb), 0, &dbchanged)))
+ if (m_db.length &&
+ (ret= sp_use_new_db(thd, m_db.str, olddb, sizeof(olddb), 0, &dbchanged)))
goto done;
if ((ctx= thd->spcont))