summaryrefslogtreecommitdiff
path: root/sql/sp_pcontext.cc
diff options
context:
space:
mode:
authorpem@mysql.comhem.se <>2005-02-28 18:07:06 +0100
committerpem@mysql.comhem.se <>2005-02-28 18:07:06 +0100
commit54a2448bce10cbe222e3d17957a67cf9658d15c7 (patch)
tree541ebb69474f5c6881039a34e9d6b5e24fe87969 /sql/sp_pcontext.cc
parent07a87c9887740f2e59944ff017357b00a5cc1919 (diff)
downloadmariadb-git-54a2448bce10cbe222e3d17957a67cf9658d15c7.tar.gz
Fixed BUG#8760: Stored Procedures: Invalid SQLSTATE is allowed in
a DECLARE ? HANDLER FOR stmt.
Diffstat (limited to 'sql/sp_pcontext.cc')
-rw-r--r--sql/sp_pcontext.cc24
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)