summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorpem@mysql.comhem.se <>2004-04-06 16:29:38 +0200
committerpem@mysql.comhem.se <>2004-04-06 16:29:38 +0200
commit1541f2e7949416d6e172ef6406ecf140d3b26659 (patch)
treeae095b62a9d2d9b061936884abf818a3fdb1efdc
parent4a6e6251e760450197d0dce26b5e9b9a6a0ac8a1 (diff)
downloadmariadb-git-1541f2e7949416d6e172ef6406ecf140d3b26659.tar.gz
Fixed BUG#2780: Stored procedure exit handler ignored for warnings.
Actually catch pushed warnings.
-rw-r--r--mysql-test/r/sp.result22
-rw-r--r--mysql-test/t/sp.test26
-rw-r--r--sql/sql_error.cc4
3 files changed, 52 insertions, 0 deletions
diff --git a/mysql-test/r/sp.result b/mysql-test/r/sp.result
index fb563e60ac2..cfe3e1255f7 100644
--- a/mysql-test/r/sp.result
+++ b/mysql-test/r/sp.result
@@ -1044,6 +1044,28 @@ select @x|
42
drop procedure bug2776_1|
drop procedure bug2776_2|
+drop table if exists t3|
+create table t3 (s1 smallint)|
+insert into t3 values (123456789012)|
+Warnings:
+Warning 1263 Data truncated, out of range for column 's1' at row 1
+create procedure bug2780()
+begin
+declare exit handler for sqlwarning set @x = 1;
+set @x = 0;
+insert into t3 values (123456789012);
+insert into t3 values (0);
+end|
+call bug2780()|
+select @x|
+@x
+1
+select * from t3|
+s1
+32767
+32767
+drop procedure bug2780|
+drop table t3|
drop table if exists fac|
create table fac (n int unsigned not null primary key, f bigint unsigned)|
create procedure ifac(n int unsigned)
diff --git a/mysql-test/t/sp.test b/mysql-test/t/sp.test
index 58bfc8b7120..c86de916d16 100644
--- a/mysql-test/t/sp.test
+++ b/mysql-test/t/sp.test
@@ -1215,6 +1215,32 @@ select @x|
drop procedure bug2776_1|
drop procedure bug2776_2|
+#
+# BUG#2780
+#
+--disable_warnings
+drop table if exists t3|
+--enable_warnings
+create table t3 (s1 smallint)|
+
+insert into t3 values (123456789012)|
+
+create procedure bug2780()
+begin
+ declare exit handler for sqlwarning set @x = 1;
+
+ set @x = 0;
+ insert into t3 values (123456789012);
+ insert into t3 values (0);
+end|
+
+call bug2780()|
+select @x|
+select * from t3|
+
+drop procedure bug2780|
+drop table t3|
+
#
# Some "real" examples
diff --git a/sql/sql_error.cc b/sql/sql_error.cc
index c94d5e52bcf..8aa7bdf9a7f 100644
--- a/sql/sql_error.cc
+++ b/sql/sql_error.cc
@@ -43,6 +43,7 @@ This file contains the implementation of error and warnings related
***********************************************************************/
#include "mysql_priv.h"
+#include "sp_rcontext.h"
/*
Store a new message in an error object
@@ -108,6 +109,9 @@ MYSQL_ERROR *push_warning(THD *thd, MYSQL_ERROR::enum_warning_level level,
MYSQL_ERROR *err= NULL;
+ if (thd->spcont && thd->spcont->find_handler(code))
+ DBUG_RETURN(NULL);
+
if (thd->warn_list.elements < thd->variables.max_error_count)
{
/*