diff options
author | unknown <sanja@montyprogram.com> | 2013-06-19 14:32:14 +0300 |
---|---|---|
committer | unknown <sanja@montyprogram.com> | 2013-06-19 14:32:14 +0300 |
commit | dfcc502ab540b4d93fe3d40d0bac15fa3ae449dd (patch) | |
tree | ab179c039dab8cb251a20efcdd65f96a1eabf9a6 /sql/sql_error.cc | |
parent | 2534521f9a7d66b48cb9ca9402e82a0c58b156d8 (diff) | |
download | mariadb-git-dfcc502ab540b4d93fe3d40d0bac15fa3ae449dd.tar.gz |
Finished merging wl5986 started by Igor.
Diffstat (limited to 'sql/sql_error.cc')
-rw-r--r-- | sql/sql_error.cc | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/sql/sql_error.cc b/sql/sql_error.cc index fc5beb31218..2fb16a49c2b 100644 --- a/sql/sql_error.cc +++ b/sql/sql_error.cc @@ -1001,3 +1001,32 @@ uint32 convert_error_message(char *to, uint32 to_length, CHARSET_INFO *to_cs, *errors= error_count; return (uint32) (to - to_start); } + + +/** + Sanity check for SQLSTATEs. The function does not check if it's really an + existing SQL-state (there are just too many), it just checks string length and + looks for bad characters. + + @param sqlstate the condition SQLSTATE. + + @retval true if it's ok. + @retval false if it's bad. +*/ + +bool is_sqlstate_valid(const LEX_STRING *sqlstate) +{ + if (sqlstate->length != 5) + return false; + + for (int i= 0 ; i < 5 ; ++i) + { + char c = sqlstate->str[i]; + + if ((c < '0' || '9' < c) && + (c < 'A' || 'Z' < c)) + return false; + } + + return true; +} |