summaryrefslogtreecommitdiff
path: root/sql/sp_head.cc
diff options
context:
space:
mode:
authorunknown <konstantin@mysql.com>2006-06-27 00:52:56 +0400
committerunknown <konstantin@mysql.com>2006-06-27 00:52:56 +0400
commitcf119987f1e966dcf63e542124cf84f3514d4b69 (patch)
tree01243a7bebf93caf027de3eb8cf04f4d328e2f47 /sql/sp_head.cc
parentc3cb46908c30895e0aafa0f7602370240a3c5a98 (diff)
parentd6bcbfbe92db6aa3cb955ed0fb1f1a8e6f8bbb60 (diff)
downloadmariadb-git-cf119987f1e966dcf63e542124cf84f3514d4b69.tar.gz
Merge bk-internal.mysql.com:/home/bk/mysql-5.0-runtime
into mysql.com:/opt/local/work/mysql-5.0-17199 mysql-test/r/create.result: Auto merged mysql-test/t/create.test: Auto merged sql/item_strfunc.cc: Auto merged sql/log_event.cc: Auto merged sql/slave.cc: Auto merged sql/sp_head.cc: Auto merged sql/sql_class.h: Auto merged sql/sql_db.cc: Auto merged sql/sql_insert.cc: Auto merged sql/sql_lex.h: Auto merged sql/sql_parse.cc: Auto merged sql/sql_table.cc: Auto merged sql/sql_yacc.yy: Auto merged mysql-test/r/sp.result: SCCS merged mysql-test/t/sp.test: SCCS merged
Diffstat (limited to 'sql/sp_head.cc')
-rw-r--r--sql/sp_head.cc66
1 files changed, 18 insertions, 48 deletions
diff --git a/sql/sp_head.cc b/sql/sp_head.cc
index 2a486e3f93d..b3b99557b63 100644
--- a/sql/sp_head.cc
+++ b/sql/sp_head.cc
@@ -376,24 +376,6 @@ sp_name::init_qname(THD *thd)
m_name.length, m_name.str);
}
-sp_name *
-sp_name_current_db_new(THD *thd, LEX_STRING name)
-{
- sp_name *qname;
-
- if (! thd->db)
- qname= new sp_name(name);
- else
- {
- LEX_STRING db;
-
- db.length= strlen(thd->db);
- db.str= thd->strmake(thd->db, db.length);
- qname= new sp_name(db, name);
- }
- qname->init_qname(thd);
- return qname;
-}
/*
Check that the name 'ident' is ok. It's assumed to be an 'ident'
@@ -504,27 +486,20 @@ sp_head::init_strings(THD *thd, LEX *lex, sp_name *name)
/* During parsing, we must use thd->mem_root */
MEM_ROOT *root= thd->mem_root;
+ DBUG_ASSERT(name);
+ /* Must be initialized in the parser */
+ DBUG_ASSERT(name->m_db.str && name->m_db.length);
+
/* We have to copy strings to get them into the right memroot */
- if (name)
- {
- m_db.length= name->m_db.length;
- if (name->m_db.length == 0)
- m_db.str= NULL;
- else
- 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);
-
- if (name->m_qname.length == 0)
- name->init_qname(thd);
- m_qname.length= name->m_qname.length;
- m_qname.str= strmake_root(root, name->m_qname.str, m_qname.length);
- }
- else if (thd->db)
- {
- m_db.length= thd->db_length;
- m_db.str= strmake_root(root, thd->db, m_db.length);
- }
+ 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);
+
+ if (name->m_qname.length == 0)
+ name->init_qname(thd);
+ m_qname.length= name->m_qname.length;
+ m_qname.str= strmake_root(root, name->m_qname.str, m_qname.length);
if (m_param_begin && m_param_end)
{
@@ -933,7 +908,8 @@ bool
sp_head::execute(THD *thd)
{
DBUG_ENTER("sp_head::execute");
- char olddb[128];
+ char old_db_buf[NAME_LEN+1];
+ LEX_STRING old_db= { old_db_buf, sizeof(old_db_buf) };
bool dbchanged;
sp_rcontext *ctx;
bool err_status= FALSE;
@@ -980,10 +956,8 @@ sp_head::execute(THD *thd)
m_first_instance->m_last_cached_sp == this) ||
(m_recursion_level + 1 == m_next_cached_sp->m_recursion_level));
- dbchanged= FALSE;
if (m_db.length &&
- (err_status= sp_use_new_db(thd, m_db.str, olddb, sizeof(olddb), 0,
- &dbchanged)))
+ (err_status= sp_use_new_db(thd, m_db, &old_db, 0, &dbchanged)))
goto done;
if ((ctx= thd->spcont))
@@ -1154,10 +1128,10 @@ sp_head::execute(THD *thd)
{
/*
No access check when changing back to where we came from.
- (It would generate an error from mysql_change_db() when olddb=="")
+ (It would generate an error from mysql_change_db() when old_db=="")
*/
if (! thd->killed)
- err_status|= mysql_change_db(thd, olddb, 1);
+ err_status|= mysql_change_db(thd, old_db.str, 1);
}
m_flags&= ~IS_INVOKED;
DBUG_PRINT("info",
@@ -1815,9 +1789,6 @@ sp_head::reset_thd_mem_root(THD *thd)
(ulong) &mem_root, (ulong) &thd->mem_root));
free_list= thd->free_list; // Keep the old list
thd->free_list= NULL; // Start a new one
- /* Copy the db, since substatements will point to it */
- m_thd_db= thd->db;
- thd->db= thd->strmake(thd->db, thd->db_length);
m_thd= thd;
DBUG_VOID_RETURN;
}
@@ -1833,7 +1804,6 @@ sp_head::restore_thd_mem_root(THD *thd)
DBUG_PRINT("info", ("mem_root 0x%lx returned from thd mem root 0x%lx",
(ulong) &mem_root, (ulong) &thd->mem_root));
thd->free_list= flist; // Restore the old one
- thd->db= m_thd_db; // Restore the original db pointer
thd->mem_root= m_thd_root;
m_thd= NULL;
DBUG_VOID_RETURN;