diff options
author | unknown <pem@mysql.comhem.se> | 2005-02-28 18:07:06 +0100 |
---|---|---|
committer | unknown <pem@mysql.comhem.se> | 2005-02-28 18:07:06 +0100 |
commit | 110f6abd3800f0a3be9febc81e295966d2fb9f77 (patch) | |
tree | 541ebb69474f5c6881039a34e9d6b5e24fe87969 /sql/sp_pcontext.cc | |
parent | cfff7e6e184ab70b262ab36eaf8bee07746f87aa (diff) | |
download | mariadb-git-110f6abd3800f0a3be9febc81e295966d2fb9f77.tar.gz |
Fixed BUG#8760: Stored Procedures: Invalid SQLSTATE is allowed in
a DECLARE ? HANDLER FOR stmt.
mysql-test/r/sp-error.result:
New test case for BUG#8776 (check format of sqlstates in handler declarations).
mysql-test/t/sp-error.test:
New test case for BUG#8776 (check format of sqlstates in handler declarations).
sql/share/errmsg.txt:
New error message for malformed SQLSTATEs.
sql/sp_pcontext.cc:
Added function for checking SQLSTATE format.
sql/sp_pcontext.h:
Added function for checking SQLSTATE format.
sql/sql_yacc.yy:
Check format of SQLSTATE in handler declaration.
Diffstat (limited to 'sql/sp_pcontext.cc')
-rw-r--r-- | sql/sp_pcontext.cc | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/sql/sp_pcontext.cc b/sql/sp_pcontext.cc index 7176498f276..15d3f87ff29 100644 --- a/sql/sp_pcontext.cc +++ b/sql/sp_pcontext.cc @@ -26,6 +26,30 @@ #include "sp_pcontext.h" #include "sp_head.h" +/* + * Sanity check for SQLSTATEs. Will not check if it's really an existing + * state (there are just too many), but will check length and bad characters. + * Returns TRUE if it's ok, FALSE if it's bad. + */ +bool +sp_cond_check(LEX_STRING *sqlstate) +{ + int i; + const char *p; + + if (sqlstate->length != 5) + return FALSE; + for (p= sqlstate->str, i= 0 ; i < 5 ; i++) + { + char c = p[i]; + + if ((c < '0' || '9' < c) && + (c < 'A' || 'Z' < c)) + return FALSE; + } + return TRUE; +} + sp_pcontext::sp_pcontext(sp_pcontext *prev) : Sql_alloc(), m_psubsize(0), m_csubsize(0), m_hsubsize(0), m_handlers(0), m_parent(prev) |