summaryrefslogtreecommitdiff
path: root/sql/sp_pcontext.h
diff options
context:
space:
mode:
authorunknown <pem@mysql.telia.com>2003-09-16 14:26:08 +0200
committerunknown <pem@mysql.telia.com>2003-09-16 14:26:08 +0200
commit4deedf6263df02229a30a0aa2f6621074f140b19 (patch)
treedccbb3bbe8e061d9d2956a24883ae6f2b5002f9e /sql/sp_pcontext.h
parente68197450d5f42f1b07138248fff46455190ebce (diff)
downloadmariadb-git-4deedf6263df02229a30a0aa2f6621074f140b19.tar.gz
Implemented SP CONDITIONs and HANDLERs, with the extension of handling
MySQL error codes as well. (No UNDO HANDLERs yet, and no SIGNAL or RESIGNAL.) WL#850 Docs/sp-imp-spec.txt: Spec of CONDITIONs and HANDLERs (and updated some old stuff too). Docs/sp-implemented.txt: Updated info about caching, CONDITIONs and HANDLERs. include/mysqld_error.h: New error for undeclared CONDITION. libmysqld/Makefile.am: New file: sp_rcontext.cc. mysql-test/r/sp-error.result: New tests for CONDITIONs and HANDLERs. mysql-test/r/sp.result: New tests for CONDITIONs and HANDLERs. mysql-test/t/sp-error.test: New tests for CONDITIONs and HANDLERs. mysql-test/t/sp.test: New tests for CONDITIONs and HANDLERs. sql/Makefile.am: New file: sp_rcontext.cc. sql/lex.h: New symbols for CONDITIONs, HANDLERs and CURSORs. sql/mysqld.cc: Catch error if we have a handler for it. sql/protocol.cc: Catch error if we have a handler for it. sql/share/czech/errmsg.txt: New error for undeclared CONDITION. sql/share/danish/errmsg.txt: New error for undeclared CONDITION. sql/share/dutch/errmsg.txt: New error for undeclared CONDITION. sql/share/english/errmsg.txt: New error for undeclared CONDITION. sql/share/estonian/errmsg.txt: New error for undeclared CONDITION. sql/share/french/errmsg.txt: New error for undeclared CONDITION. sql/share/german/errmsg.txt: New error for undeclared CONDITION. sql/share/greek/errmsg.txt: New error for undeclared CONDITION. sql/share/hungarian/errmsg.txt: New error for undeclared CONDITION. sql/share/italian/errmsg.txt: New error for undeclared CONDITION. sql/share/japanese/errmsg.txt: New error for undeclared CONDITION. sql/share/korean/errmsg.txt: New error for undeclared CONDITION. sql/share/norwegian-ny/errmsg.txt: New error for undeclared CONDITION. sql/share/norwegian/errmsg.txt: New error for undeclared CONDITION. sql/share/polish/errmsg.txt: New error for undeclared CONDITION. sql/share/portuguese/errmsg.txt: New error for undeclared CONDITION. sql/share/romanian/errmsg.txt: New error for undeclared CONDITION. sql/share/russian/errmsg.txt: New error for undeclared CONDITION. sql/share/serbian/errmsg.txt: New error for undeclared CONDITION. sql/share/slovak/errmsg.txt: New error for undeclared CONDITION. sql/share/spanish/errmsg.txt: New error for undeclared CONDITION. sql/share/swedish/errmsg.txt: New error for undeclared CONDITION. sql/share/ukrainian/errmsg.txt: New error for undeclared CONDITION. sql/sp_head.cc: New HANDLER code. sql/sp_head.h: New HANDLER code. sql/sp_pcontext.cc: New CONDITION and HANDLER code. sql/sp_pcontext.h: New CONDITION and HANDLER code. sql/sp_rcontext.h: New CONDITION and HANDLER code. sql/sql_yacc.yy: New CONDITION and HANDLER code.
Diffstat (limited to 'sql/sp_pcontext.h')
-rw-r--r--sql/sp_pcontext.h62
1 files changed, 59 insertions, 3 deletions
diff --git a/sql/sp_pcontext.h b/sql/sp_pcontext.h
index 6900e18aa93..6fb56faccf6 100644
--- a/sql/sp_pcontext.h
+++ b/sql/sp_pcontext.h
@@ -44,6 +44,19 @@ typedef struct sp_label
uint ip; // Instruction index
} sp_label_t;
+typedef struct sp_cond_type
+{
+ enum { number, state, warning, notfound, exception } type;
+ char sqlstate[6];
+ uint mysqlerr;
+} sp_cond_type_t;
+
+typedef struct sp_cond
+{
+ LEX_STRING name;
+ sp_cond_type_t *val;
+} sp_cond_t;
+
class sp_pcontext : public Sql_alloc
{
sp_pcontext(const sp_pcontext &); /* Prevent use of these */
@@ -57,6 +70,10 @@ class sp_pcontext : public Sql_alloc
void
destroy();
+ //
+ // Parameters and variables
+ //
+
inline uint
max_framesize()
{
@@ -101,11 +118,11 @@ class sp_pcontext : public Sql_alloc
}
void
- push(LEX_STRING *name, enum enum_field_types type, sp_param_mode_t mode);
+ push_pvar(LEX_STRING *name, enum enum_field_types type, sp_param_mode_t mode);
// Pop the last 'num' slots of the frame
inline void
- pop(uint num = 1)
+ pop_pvar(uint num = 1)
{
while (num--)
pop_dynamic(&m_pvar);
@@ -128,6 +145,10 @@ class sp_pcontext : public Sql_alloc
return p;
}
+ //
+ // Labels
+ //
+
sp_label_t *
push_label(char *name, uint ip);
@@ -146,12 +167,47 @@ class sp_pcontext : public Sql_alloc
return m_label.pop();
}
+ //
+ // Conditions
+ //
+
+ void
+ push_cond(LEX_STRING *name, sp_cond_type_t *val);
+
+ inline void
+ pop_cond(uint num)
+ {
+ while (num--)
+ pop_dynamic(&m_cond);
+ }
+
+ sp_cond_type_t *
+ find_cond(LEX_STRING *name);
+
+ //
+ // Handlers
+ //
+
+ inline void
+ add_handler()
+ {
+ m_handlers+= 1;
+ }
+
+ inline uint
+ handlers()
+ {
+ return m_handlers;
+ }
+
private:
uint m_params; // The number of parameters
uint m_framesize; // The maximum framesize
+ uint m_handlers; // The total number of handlers
- DYNAMIC_ARRAY m_pvar;
+ DYNAMIC_ARRAY m_pvar; // Parameters/variables
+ DYNAMIC_ARRAY m_cond; // Conditions
List<sp_label_t> m_label; // The label list
uint m_genlab; // Gen. label counter