diff options
author | unknown <pem@mysql.comhem.se> | 2003-11-13 19:34:56 +0100 |
---|---|---|
committer | unknown <pem@mysql.comhem.se> | 2003-11-13 19:34:56 +0100 |
commit | c9232c60e2ec287932158b6d820352dd98e85fd7 (patch) | |
tree | df91989d7134f7e1e4a3a6c110312d910b30c970 /sql/sp_pcontext.h | |
parent | 4696bb41b4cce563ffff8d7b6c32576214109113 (diff) | |
download | mariadb-git-c9232c60e2ec287932158b6d820352dd98e85fd7.tar.gz |
Various bug fixes:
- Duplicate parameters/variables, conditions and cursors (not allowed).
- ITERATE in labelled BEGIN-END (not allowed).
- Missing SQLSTATE [VALUE] keywords in CONDITION/HANDLER declaration (added).
- Empty BEGIN-END (now allowed).
- End label (now optional).
include/mysqld_error.h:
New error code for duplicate things (vars et al) in SPs.
mysql-test/r/sp-error.result:
New error tests for ITERATE in begin-end block and duplicate variables,
conditions and cursors.
mysql-test/r/sp.result:
New tests for empty begin-end blocks, overriding local variables outside scope
only, leave a begin-end block, and SQLSTATE [VALUE] words for CONDITION/HANDLER
declarations.
mysql-test/t/sp-error.test:
New error tests for ITERATE in begin-end block and duplicate variables,
conditions and cursors.
mysql-test/t/sp.test:
New tests for empty begin-end blocks, overriding local variables outside scope
only, leave a begin-end block, and SQLSTATE [VALUE] words for CONDITION/HANDLER
declarations.
sql/lex.h:
New SQLSTATE keyword.
sql/share/czech/errmsg.txt:
New error message for duplicate things (vars et al) in SPs.
sql/share/danish/errmsg.txt:
New error message for duplicate things (vars et al) in SPs.
sql/share/dutch/errmsg.txt:
New error message for duplicate things (vars et al) in SPs.
sql/share/english/errmsg.txt:
New error message for duplicate things (vars et al) in SPs.
sql/share/estonian/errmsg.txt:
New error message for duplicate things (vars et al) in SPs.
sql/share/french/errmsg.txt:
New error message for duplicate things (vars et al) in SPs.
sql/share/german/errmsg.txt:
New error message for duplicate things (vars et al) in SPs.
sql/share/greek/errmsg.txt:
New error message for duplicate things (vars et al) in SPs.
sql/share/hungarian/errmsg.txt:
New error message for duplicate things (vars et al) in SPs.
sql/share/italian/errmsg.txt:
New error message for duplicate things (vars et al) in SPs.
sql/share/japanese/errmsg.txt:
New error message for duplicate things (vars et al) in SPs.
sql/share/korean/errmsg.txt:
New error message for duplicate things (vars et al) in SPs.
sql/share/norwegian-ny/errmsg.txt:
New error message for duplicate things (vars et al) in SPs.
sql/share/norwegian/errmsg.txt:
New error message for duplicate things (vars et al) in SPs.
sql/share/polish/errmsg.txt:
New error message for duplicate things (vars et al) in SPs.
sql/share/portuguese/errmsg.txt:
New error message for duplicate things (vars et al) in SPs.
sql/share/romanian/errmsg.txt:
New error message for duplicate things (vars et al) in SPs.
sql/share/russian/errmsg.txt:
New error message for duplicate things (vars et al) in SPs.
sql/share/serbian/errmsg.txt:
New error message for duplicate things (vars et al) in SPs.
sql/share/slovak/errmsg.txt:
New error message for duplicate things (vars et al) in SPs.
sql/share/spanish/errmsg.txt:
New error message for duplicate things (vars et al) in SPs.
sql/share/swedish/errmsg.txt:
New error message for duplicate things (vars et al) in SPs.
sql/share/ukrainian/errmsg.txt:
New error message for duplicate things (vars et al) in SPs.
sql/sp_pcontext.cc:
Keep track on scope limits for error checking of duplicate variables,
conditions and cursors.
sql/sp_pcontext.h:
Keep track on scope limits for error checking of duplicate variables,
conditions and cursors.
Also need to flag BEGIN labels to check for illegal ITERATEs.
sql/sql_yacc.yy:
End-labels in SPs loop and begin-end blocks are now optional.
SQLSTATE [VALUE] added to syntax for sqlstates.
Check for duplicate variable, condition and cursor declarations, but
only in the same scope.
Empty BEGIN-END statements now allowed.
Check if ITERATE is referring to a BEGIN label.
Diffstat (limited to 'sql/sp_pcontext.h')
-rw-r--r-- | sql/sp_pcontext.h | 20 |
1 files changed, 17 insertions, 3 deletions
diff --git a/sql/sp_pcontext.h b/sql/sp_pcontext.h index 23be38edcbf..02134e3604f 100644 --- a/sql/sp_pcontext.h +++ b/sql/sp_pcontext.h @@ -42,6 +42,7 @@ typedef struct sp_label { char *name; uint ip; // Instruction index + my_bool isbegin; // For ITERATE error checking } sp_label_t; typedef struct sp_cond_type @@ -57,6 +58,11 @@ typedef struct sp_cond sp_cond_type_t *val; } sp_cond_t; +typedef struct sp_scope +{ + uint vars, conds, curs; +} sp_scope_t; + class sp_pcontext : public Sql_alloc { sp_pcontext(const sp_pcontext &); /* Prevent use of these */ @@ -70,6 +76,13 @@ class sp_pcontext : public Sql_alloc void destroy(); + // For error checking of duplicate things + void + push_scope(); + + void + pop_scope(); + // // Parameters and variables // @@ -130,7 +143,7 @@ class sp_pcontext : public Sql_alloc // Find by name sp_pvar_t * - find_pvar(LEX_STRING *name); + find_pvar(LEX_STRING *name, my_bool scoped=0); // Find by index sp_pvar_t * @@ -182,7 +195,7 @@ class sp_pcontext : public Sql_alloc } sp_cond_type_t * - find_cond(LEX_STRING *name); + find_cond(LEX_STRING *name, my_bool scoped=0); // // Handlers @@ -208,7 +221,7 @@ class sp_pcontext : public Sql_alloc push_cursor(LEX_STRING *name); my_bool - find_cursor(LEX_STRING *name, uint *poff); + find_cursor(LEX_STRING *name, uint *poff, my_bool scoped=0); inline void pop_cursor(uint num) @@ -233,6 +246,7 @@ private: DYNAMIC_ARRAY m_pvar; // Parameters/variables DYNAMIC_ARRAY m_cond; // Conditions DYNAMIC_ARRAY m_cursor; // Cursors + DYNAMIC_ARRAY m_scopes; // For error checking List<sp_label_t> m_label; // The label list |