summaryrefslogtreecommitdiff
path: root/sql/sp_rcontext.cc
diff options
context:
space:
mode:
authormonty@mysql.com <>2005-06-05 17:01:20 +0300
committermonty@mysql.com <>2005-06-05 17:01:20 +0300
commit25a2c4a71eccb94b0311b9af60acbf8e85ad3db7 (patch)
tree9e3ba3064a7442c6cf9812a9f784e111bd244e0e /sql/sp_rcontext.cc
parenta69f4321155fced6ef3a771e68b7dab1d2f119cc (diff)
downloadmariadb-git-25a2c4a71eccb94b0311b9af60acbf8e85ad3db7.tar.gz
Cleanup during review
Simple optimization for 2 argument usage to function of variable arguments Fix stack overrun when using 1+1+1+1+1+1+1+.... Update crash-me results for 5.0 Don't call post_open if pre_open() fails (optimization)
Diffstat (limited to 'sql/sp_rcontext.cc')
-rw-r--r--sql/sp_rcontext.cc37
1 files changed, 25 insertions, 12 deletions
diff --git a/sql/sp_rcontext.cc b/sql/sp_rcontext.cc
index 2e79a1e2533..0e8210301c1 100644
--- a/sql/sp_rcontext.cc
+++ b/sql/sp_rcontext.cc
@@ -168,8 +168,22 @@ sp_rcontext::pop_cursors(uint count)
*
*/
-// We have split this in two to make it easy for sp_instr_copen
-// to reuse the sp_instr::exec_stmt() code.
+/*
+ pre_open cursor
+
+ SYNOPSIS
+ pre_open()
+ THD Thread handler
+
+ NOTES
+ We have to open cursor in two steps to make it easy for sp_instr_copen
+ to reuse the sp_instr::exec_stmt() code.
+ If this function returns 0, post_open should not be called
+
+ RETURN
+ 0 ERROR
+*/
+
sp_lex_keeper*
sp_cursor::pre_open(THD *thd)
{
@@ -179,32 +193,31 @@ sp_cursor::pre_open(THD *thd)
MYF(0));
return NULL;
}
-
- bzero((char *)&m_mem_root, sizeof(m_mem_root));
init_alloc_root(&m_mem_root, MEM_ROOT_BLOCK_SIZE, MEM_ROOT_PREALLOC);
if ((m_prot= new Protocol_cursor(thd, &m_mem_root)) == NULL)
return NULL;
- m_oprot= thd->protocol; // Save the original protocol
- thd->protocol= m_prot;
-
+ /* Save for execution. Will be restored in post_open */
+ m_oprot= thd->protocol;
m_nseof= thd->net.no_send_eof;
+
+ /* Change protocol for execution */
+ thd->protocol= m_prot;
thd->net.no_send_eof= TRUE;
return m_lex_keeper;
}
+
void
sp_cursor::post_open(THD *thd, my_bool was_opened)
{
thd->net.no_send_eof= m_nseof; // Restore the originals
thd->protocol= m_oprot;
- if (was_opened)
- {
- m_isopen= was_opened;
+ if ((m_isopen= was_opened))
m_current_row= m_prot->data;
- }
}
+
int
sp_cursor::close(THD *thd)
{
@@ -217,6 +230,7 @@ sp_cursor::close(THD *thd)
return 0;
}
+
void
sp_cursor::destroy()
{
@@ -225,7 +239,6 @@ sp_cursor::destroy()
delete m_prot;
m_prot= NULL;
free_root(&m_mem_root, MYF(0));
- bzero((char *)&m_mem_root, sizeof(m_mem_root));
}
m_isopen= FALSE;
}