summaryrefslogtreecommitdiff
path: root/sql/sp_pcontext.cc
diff options
context:
space:
mode:
authorunknown <pem@mysql.comhem.se>2005-04-08 19:58:04 +0200
committerunknown <pem@mysql.comhem.se>2005-04-08 19:58:04 +0200
commitfc5db9351610fed5405df1e26a0e7623d27c5f4d (patch)
tree2e1f1768da174abb00e496a1480fadbefb4e6303 /sql/sp_pcontext.cc
parent452794235c8ff9f70f20813031a4ce77df6e4d3b (diff)
downloadmariadb-git-fc5db9351610fed5405df1e26a0e7623d27c5f4d.tar.gz
Fixed BUG#9073: Able to declare two handlers for same condition in same scope
mysql-test/r/sp-error.result: Added test case for BUG#9073. mysql-test/t/sp-error.test: Added test case for BUG#9073. sql/share/errmsg.txt: New error message for duplicate condition handlers in stored procedures. sql/sp_pcontext.cc: Keep track on condition handlers in the same block for error checking. sql/sp_pcontext.h: Keep track on condition handlers in the same block for error checking. sql/sql_yacc.yy: Keep track on condition handlers in the same block for error checking.
Diffstat (limited to 'sql/sp_pcontext.cc')
-rw-r--r--sql/sp_pcontext.cc37
1 files changed, 37 insertions, 0 deletions
diff --git a/sql/sp_pcontext.cc b/sql/sp_pcontext.cc
index 15d3f87ff29..26f576233f3 100644
--- a/sql/sp_pcontext.cc
+++ b/sql/sp_pcontext.cc
@@ -57,6 +57,7 @@ sp_pcontext::sp_pcontext(sp_pcontext *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));
VOID(my_init_dynamic_array(&m_cursor, sizeof(LEX_STRING), 16, 8));
+ VOID(my_init_dynamic_array(&m_handler, sizeof(sp_cond_type_t *), 16, 8));
m_label.empty();
m_children.empty();
if (!prev)
@@ -82,6 +83,7 @@ sp_pcontext::destroy()
delete_dynamic(&m_pvar);
delete_dynamic(&m_cond);
delete_dynamic(&m_cursor);
+ delete_dynamic(&m_handler);
}
sp_pcontext *
@@ -258,6 +260,41 @@ sp_pcontext::find_cond(LEX_STRING *name, my_bool scoped)
return NULL;
}
+/*
+ * This only searches the current context, for error checking of
+ * duplicates.
+ * Returns TRUE if found.
+ */
+bool
+sp_pcontext::find_handler(sp_cond_type_t *cond)
+{
+ uint i= m_handler.elements;
+
+ while (i--)
+ {
+ sp_cond_type_t *p;
+
+ get_dynamic(&m_handler, (gptr)&p, i);
+ if (cond->type == p->type)
+ {
+ switch (p->type)
+ {
+ case sp_cond_type_t::number:
+ if (cond->mysqlerr == p->mysqlerr)
+ return TRUE;
+ break;
+ case sp_cond_type_t::state:
+ if (strcmp(cond->sqlstate, p->sqlstate) == 0)
+ return TRUE;
+ break;
+ default:
+ return TRUE;
+ }
+ }
+ }
+ return FALSE;
+}
+
void
sp_pcontext::push_cursor(LEX_STRING *name)
{