summaryrefslogtreecommitdiff
path: root/sql/sp_pcontext.cc
diff options
context:
space:
mode:
authorunknown <pem@mysql.comhem.se>2004-09-02 17:24:25 +0200
committerunknown <pem@mysql.comhem.se>2004-09-02 17:24:25 +0200
commit339859d261ffaf3d588da247284680a3d4ec3104 (patch)
treecc966e471ebe1e3067e75ef8a5f30688101f8080 /sql/sp_pcontext.cc
parent711e8879054f2499b00452762ade52430ce41c44 (diff)
downloadmariadb-git-339859d261ffaf3d588da247284680a3d4ec3104.tar.gz
Fixed BUG#5287: Stored procedure crash if leave outside loop.
Bug in diff_handlers and diff_cursors made it attempt to pop the wrong number at jumps sometimes. mysql-test/r/sp.result: New testcase for BUG#5287. mysql-test/t/sp.test: New testcase for BUG#5287. sql/sp_pcontext.cc: Fixed diff_handlers and diff_cursors methods, they miscounted. sql/sp_pcontext.h: Made m_handlers available for diff_handlers.
Diffstat (limited to 'sql/sp_pcontext.cc')
-rw-r--r--sql/sp_pcontext.cc9
1 files changed, 3 insertions, 6 deletions
diff --git a/sql/sp_pcontext.cc b/sql/sp_pcontext.cc
index c83259c3926..3b60f0936f9 100644
--- a/sql/sp_pcontext.cc
+++ b/sql/sp_pcontext.cc
@@ -28,7 +28,7 @@
sp_pcontext::sp_pcontext(sp_pcontext *prev)
: Sql_alloc(), m_psubsize(0), m_csubsize(0), m_hsubsize(0),
- m_parent(prev), m_handlers(0)
+ m_handlers(0), m_parent(prev)
{
VOID(my_init_dynamic_array(&m_pvar, sizeof(sp_pvar_t *), 16, 8));
VOID(my_init_dynamic_array(&m_cond, sizeof(sp_cond_type_t *), 16, 8));
@@ -94,7 +94,7 @@ sp_pcontext::diff_handlers(sp_pcontext *ctx)
while (pctx && pctx != ctx)
{
- n+= pctx->max_handlers();
+ n+= pctx->m_handlers;
pctx= pctx->parent_context();
}
if (pctx)
@@ -109,12 +109,9 @@ sp_pcontext::diff_cursors(sp_pcontext *ctx)
sp_pcontext *pctx= this;
while (pctx && pctx != ctx)
- {
- n+= pctx->max_cursors();
pctx= pctx->parent_context();
- }
if (pctx)
- return n;
+ return ctx->current_cursors() - pctx->current_cursors();
return 0; // Didn't find ctx
}