summaryrefslogtreecommitdiff
path: root/sql/sp_rcontext.cc
diff options
context:
space:
mode:
authorunknown <bell@sanja.is.com.ua>2004-10-28 11:02:48 +0300
committerunknown <bell@sanja.is.com.ua>2004-10-28 11:02:48 +0300
commit46ce3d00921491398d2e9a00c2b03e67540dee23 (patch)
tree70b19d638c9beac263179291143f76c5af8757f4 /sql/sp_rcontext.cc
parent93678f6bd9be1d320a63ae3fcf24493dae065ae7 (diff)
parentf41bba8c6156a7adf4c67dfa75e16112767a5d3c (diff)
downloadmariadb-git-46ce3d00921491398d2e9a00c2b03e67540dee23.tar.gz
merge
mysql-test/r/sp-security.result: Auto merged mysql-test/r/sp.result: Auto merged mysql-test/t/sp-security.test: Auto merged mysql-test/t/sp.test: Auto merged sql/log_event.cc: Auto merged sql/set_var.cc: Auto merged sql/sp.cc: Auto merged sql/sp_rcontext.cc: Auto merged sql/sql_base.cc: Auto merged sql/sql_insert.cc: Auto merged sql/sql_load.cc: Auto merged sql/sql_yacc.yy: Auto merged
Diffstat (limited to 'sql/sp_rcontext.cc')
-rw-r--r--sql/sp_rcontext.cc39
1 files changed, 22 insertions, 17 deletions
diff --git a/sql/sp_rcontext.cc b/sql/sp_rcontext.cc
index 3f9ab39e358..db298974c45 100644
--- a/sql/sp_rcontext.cc
+++ b/sql/sp_rcontext.cc
@@ -56,7 +56,7 @@ sp_rcontext::set_item_eval(uint idx, Item *i, enum_field_types type)
}
}
-int
+bool
sp_rcontext::find_handler(uint sql_errno,
MYSQL_ERROR::enum_warning_level level)
{
@@ -66,9 +66,9 @@ sp_rcontext::find_handler(uint sql_errno,
return 1; // Already got one
const char *sqlstate= mysql_errno_to_sqlstate(sql_errno);
- int i= m_hcount, found= 0;
+ int i= m_hcount, found= -1;
- while (!found && i--)
+ while (i--)
{
sp_cond_type_t *cond= m_handler[i].cond;
@@ -76,31 +76,36 @@ sp_rcontext::find_handler(uint sql_errno,
{
case sp_cond_type_t::number:
if (sql_errno == cond->mysqlerr)
- found= 1;
+ found= i; // Always the most specific
break;
case sp_cond_type_t::state:
- if (strcmp(sqlstate, cond->sqlstate) == 0)
- found= 1;
+ if (strcmp(sqlstate, cond->sqlstate) == 0 &&
+ (found < 0 || m_handler[found].cond->type > sp_cond_type_t::number))
+ found= i;
break;
case sp_cond_type_t::warning:
- if (sqlstate[0] == '0' && sqlstate[1] == '1' ||
- level == MYSQL_ERROR::WARN_LEVEL_WARN)
- found= 1;
+ if ((sqlstate[0] == '0' && sqlstate[1] == '1' ||
+ level == MYSQL_ERROR::WARN_LEVEL_WARN) &&
+ (found < 0 || m_handler[found].cond->type > sp_cond_type_t::state))
+ found= i;
break;
case sp_cond_type_t::notfound:
- if (sqlstate[0] == '0' && sqlstate[1] == '2')
- found= 1;
+ if (sqlstate[0] == '0' && sqlstate[1] == '2' &&
+ (found < 0 || m_handler[found].cond->type > sp_cond_type_t::state))
+ found= i;
break;
case sp_cond_type_t::exception:
- if (sqlstate[0] != '0' || sqlstate[1] > '2' ||
- level == MYSQL_ERROR::WARN_LEVEL_ERROR)
- found= 1;
+ if ((sqlstate[0] != '0' || sqlstate[1] > '2' ||
+ level == MYSQL_ERROR::WARN_LEVEL_ERROR) &&
+ (found < 0 || m_handler[found].cond->type > sp_cond_type_t::state))
+ found= i;
break;
}
}
- if (found)
- m_hfound= i;
- return found;
+ if (found < 0)
+ return FALSE;
+ m_hfound= found;
+ return TRUE;
}
void