summaryrefslogtreecommitdiff
path: root/sql/sp_pcontext.cc
diff options
context:
space:
mode:
authorAlexander Barkov <bar@mariadb.org>2016-10-11 11:48:08 +0400
committerAlexander Barkov <bar@mariadb.org>2017-04-05 15:02:52 +0400
commitde6d40592cc96e93368eae00adbda6bddd3a8b7e (patch)
tree33dc089540ee4f9ca33bbaa88a4ccf24f5bfe4d6 /sql/sp_pcontext.cc
parentf7043858bab996030413b66df3a898cd15c2ffa0 (diff)
downloadmariadb-git-de6d40592cc96e93368eae00adbda6bddd3a8b7e.tar.gz
MDEV-10411 Providing compatibility for basic PL/SQL constructs
An additional change for "Part 9: EXCEPTION handlers" This construct: EXCEPTION WHEN OTHERS THEN ...; now catches warning-alike conditions, e.g. NO_DATA_FOUND.
Diffstat (limited to 'sql/sp_pcontext.cc')
-rw-r--r--sql/sp_pcontext.cc12
1 files changed, 10 insertions, 2 deletions
diff --git a/sql/sp_pcontext.cc b/sql/sp_pcontext.cc
index 20ff92e3cf1..87ec5f98557 100644
--- a/sql/sp_pcontext.cc
+++ b/sql/sp_pcontext.cc
@@ -410,8 +410,16 @@ sp_pcontext::find_handler(const char *sql_state,
break;
case sp_condition_value::EXCEPTION:
- if (is_sqlstate_exception(sql_state) &&
- level == Sql_condition::WARN_LEVEL_ERROR && !found_cv)
+ /*
+ In sql_mode=ORACLE this construct should catch errors and warnings:
+ EXCEPTION
+ WHEN OTHERS THEN ...;
+ E.g. NO_DATA_FOUND is more like a warning than an error,
+ and it should be caught.
+ */
+ if (((current_thd->variables.sql_mode & MODE_ORACLE) ||
+ (is_sqlstate_exception(sql_state) &&
+ level == Sql_condition::WARN_LEVEL_ERROR)) && !found_cv)
{
found_cv= cv;
found_handler= h;