List:Commits« Previous MessageNext Message »
From:Davi Arnaut Date:April 7 2008 5:29pm
Subject:bk commit into 6.0 tree (davi:1.2622) BUG#23032
View as plain text  
Below is the list of changes that have just been committed into a local
6.0 repository of davi.  When davi does a push these changes
will be propagated to the main repository and, within 24 hours after the
push, to the public repository.
For information on how to access the public repository
see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html

ChangeSet@stripped, 2008-04-07 14:29:44-03:00, davi@stripped +22 -0
  Bug#23032: Handlers declared in a SP do not handle warnings generated in sub-SP
  
  The problem is that warnings generated by a statement executed
  inside a stored procedure should only invoke handlers in the
  calling context. Also, the diagnostics and condition areas must
  be cleaned before the execution of stored procedure statements.
  
  The solution is to prepare the enviorement before the execution
  of procedure statements by clearing the diagnostics area (and
  thus condition area). Also handlers now are only called for
  handling warnings generated in the calling context of the executed
  statement.

  include/my_sys.h@stripped, 2008-04-07 14:29:38-03:00, davi@stripped +9 -11
    Removed unused/useless return value from error functions
    and remove the unused MYSYS_PROGRAM_USES_CURSES.

  mysql-test/r/partition.result@stripped, 2008-04-07 14:29:38-03:00, davi@stripped +0 -5
    Update test case result which reflects new rules for
    condition area cleaning.

  mysql-test/r/sp-dynamic.result@stripped, 2008-04-07 14:29:38-03:00, davi@stripped +0 -8
    Update test case result which reflects new rules for
    condition area cleaning.

  mysql-test/r/sp-error.result@stripped, 2008-04-07 14:29:38-03:00, davi@stripped +53 -0
    Add test case result for Bug#23032

  mysql-test/r/sp-prelocking.result@stripped, 2008-04-07 14:29:38-03:00, davi@stripped +0 -4
    Update test case result which reflects new rules for
    condition area cleaning.

  mysql-test/r/sp-vars.result@stripped, 2008-04-07 14:29:38-03:00, davi@stripped +0 -88
    Update test case result which reflects new rules for
    condition area cleaning.

  mysql-test/r/sp.result@stripped, 2008-04-07 14:29:38-03:00, davi@stripped +0 -73
    Update test case result which reflects new rules for
    condition area cleaning.

  mysql-test/r/view_grant.result@stripped, 2008-04-07 14:29:38-03:00, davi@stripped +0 -4
    Update test case result which reflects new rules for
    condition area cleaning.

  mysql-test/suite/binlog/r/binlog_unsafe.result@stripped, 2008-04-07 14:29:38-03:00, davi@stripped +0 -31
    Update test case result which reflects new rules for
    condition area cleaning.

  mysql-test/suite/rpl/r/rpl_sp_effects.result@stripped, 2008-04-07 14:29:39-03:00, davi@stripped +0 -1
    Update test case result which reflects new rules for
    condition area cleaning.

  mysql-test/t/sp-error.test@stripped, 2008-04-07 14:29:39-03:00, davi@stripped +64 -0
    Add test case for Bug#23032

  mysys/my_error.c@stripped, 2008-04-07 14:29:39-03:00, davi@stripped +8 -10
    Remove unused/unecesasry return value from error setting
    and handling functions.

  mysys/my_messnc.c@stripped, 2008-04-07 14:29:39-03:00, davi@stripped +2 -2
    Drop unnecessary return value.

  mysys/my_static.c@stripped, 2008-04-07 14:29:39-03:00, davi@stripped +2 -2
    Drop unused/uncessary return value from error handling
    functions.

  sql/backup/error.h@stripped, 2008-04-07 14:29:40-03:00, davi@stripped +2 -3
    my_printf_error doesn't returns nothing now.

  sql/mysqld.cc@stripped, 2008-04-07 14:29:39-03:00, davi@stripped +4 -21
    Drop unused/uncessary return value from error handling
    functions. SP error handling doesn't use errors handlers
    anymore.

  sql/sp_head.cc@stripped, 2008-04-07 14:29:40-03:00, davi@stripped +86 -39
    Clear the diagnostics area and the condition area in
    preparation for the execution of SP statements. Move
    exception checking code to it's own function and reset
    the condition area after a handler has been found.

  sql/sp_head.h@stripped, 2008-04-07 14:29:40-03:00, davi@stripped +22 -0
    Add virtual method which prepares the environment for the
    execution of a stored procedure statement.

  sql/sp_rcontext.cc@stripped, 2008-04-07 14:29:40-03:00, davi@stripped +26 -40
    Remove runtime error handler for SP and add helper function
    which finds a handler for the current status of the diagnostics
    area.

  sql/sp_rcontext.h@stripped, 2008-04-07 14:29:40-03:00, davi@stripped +5 -14
    Move find_handler as a private function add new method signature.

  sql/sql_class.cc@stripped, 2008-04-07 14:29:40-03:00, davi@stripped +1 -2
    Check if there is a handler for the current values of
    the diagnostic area.

  sql/sql_error.cc@stripped, 2008-04-07 14:29:40-03:00, davi@stripped +1 -7
    Remove unnecessary casts and SP runtime context error handler.

diff -Nrup a/include/my_sys.h b/include/my_sys.h
--- a/include/my_sys.h	2008-03-28 14:47:45 -03:00
+++ b/include/my_sys.h	2008-04-07 14:29:38 -03:00
@@ -35,7 +35,6 @@ extern int NEAR my_errno;		/* Last error
 #include <stdarg.h>
 #include <typelib.h>
 
-#define MYSYS_PROGRAM_USES_CURSES()  { error_handler_hook = my_message_curses;	mysys_uses_curses=1; }
 #define MYSYS_PROGRAM_DONT_USE_CURSES()  { error_handler_hook = my_message_no_curses; mysys_uses_curses=0;}
 #define MY_INIT(name);		{ my_progname= name; my_init(); }
 
@@ -209,9 +208,9 @@ extern char NEAR errbuff[NRERRBUFFS][ERR
 extern char *home_dir;			/* Home directory for user */
 extern const char *my_progname;		/* program-name (printed in errors) */
 extern char NEAR curr_dir[];		/* Current directory for user */
-extern int (*error_handler_hook)(uint my_err, const char *str,myf MyFlags);
-extern int (*fatal_error_handler_hook)(uint my_err, const char *str,
-				       myf MyFlags);
+extern void (*error_handler_hook)(uint my_err, const char *str,myf MyFlags);
+extern void (*fatal_error_handler_hook)(uint my_err, const char *str,
+                                        myf MyFlags);
 extern uint my_file_limit;
 
 #ifdef HAVE_LARGE_PAGES
@@ -633,15 +632,14 @@ extern FILE *my_fdopen(File Filedes,cons
 extern int my_fclose(FILE *fd,myf MyFlags);
 extern int my_chsize(File fd,my_off_t newlength, int filler, myf MyFlags);
 extern int my_sync(File fd, myf my_flags);
-extern int my_error _VARARGS((int nr,myf MyFlags, ...));
-extern int my_printf_error _VARARGS((uint my_err, const char *format,
-				     myf MyFlags, ...))
-				    ATTRIBUTE_FORMAT(printf, 2, 4);
+extern void my_error _VARARGS((int nr,myf MyFlags, ...));
+extern void my_printf_error _VARARGS((uint my_err, const char *format,
+                                      myf MyFlags, ...))
+				      ATTRIBUTE_FORMAT(printf, 2, 4);
 extern int my_error_register(const char **errmsgs, int first, int last);
 extern const char **my_error_unregister(int first, int last);
-extern int my_message(uint my_err, const char *str,myf MyFlags);
-extern int my_message_no_curses(uint my_err, const char *str,myf MyFlags);
-extern int my_message_curses(uint my_err, const char *str,myf MyFlags);
+extern void my_message(uint my_err, const char *str,myf MyFlags);
+extern void my_message_no_curses(uint my_err, const char *str,myf MyFlags);
 extern my_bool my_init(void);
 extern void my_end(int infoflag);
 extern int my_redel(const char *from, const char *to, int MyFlags);
diff -Nrup a/mysql-test/r/partition.result b/mysql-test/r/partition.result
--- a/mysql-test/r/partition.result	2008-03-27 15:58:36 -03:00
+++ b/mysql-test/r/partition.result	2008-04-07 14:29:38 -03:00
@@ -816,12 +816,7 @@ ROLLBACK to savepoint t1_save;
 COMMIT;
 END|
 CALL test.p1(12);
-Warnings:
-Note	1051	Unknown table 't1'
-Warning	1196	Some non-transactional changed tables couldn't be rolled back
 CALL test.p1(13);
-Warnings:
-Warning	1196	Some non-transactional changed tables couldn't be rolled back
 drop table t1;
 drop procedure test.p1;
 CREATE TABLE t1 (a int not null)
diff -Nrup a/mysql-test/r/sp-dynamic.result b/mysql-test/r/sp-dynamic.result
--- a/mysql-test/r/sp-dynamic.result	2007-06-22 10:10:36 -03:00
+++ b/mysql-test/r/sp-dynamic.result	2008-04-07 14:29:38 -03:00
@@ -97,8 +97,6 @@ end|
 call p1()|
 a
 1
-Warnings:
-Note	1051	Unknown table 't1'
 call p1()|
 a
 1
@@ -371,9 +369,6 @@ call p1(@a)|
 create table t1 (a int)
 @rsql
 create table t2 (a int)
-Warnings:
-Note	1051	Unknown table 't1'
-Note	1051	Unknown table 't2'
 select @a|
 @a
 0
@@ -382,9 +377,6 @@ call p1(@a)|
 create table t1 (a int)
 @rsql
 create table t2 (a int)
-Warnings:
-Note	1051	Unknown table 't1'
-Note	1051	Unknown table 't2'
 select @a|
 @a
 0
diff -Nrup a/mysql-test/r/sp-error.result b/mysql-test/r/sp-error.result
--- a/mysql-test/r/sp-error.result	2008-03-28 14:47:45 -03:00
+++ b/mysql-test/r/sp-error.result	2008-04-07 14:29:38 -03:00
@@ -1634,3 +1634,56 @@ end|
 call p1(1);
 set @@max_sp_recursion_depth = @old_recursion_depth;
 drop procedure p1;
+DROP PROCEDURE IF EXISTS p1;
+DROP PROCEDURE IF EXISTS p2;
+CREATE PROCEDURE p1()
+BEGIN
+SELECT CAST('10 ' as unsigned integer);
+SELECT 1;
+CALL p2();
+END|
+CREATE PROCEDURE p2()
+BEGIN
+SELECT CAST('10 ' as unsigned integer);
+END|
+CALL p1();
+CAST('10 ' as unsigned integer)
+10
+1
+1
+CAST('10 ' as unsigned integer)
+10
+Warnings:
+Warning	1292	Truncated incorrect INTEGER value: '10 '
+DROP PROCEDURE p1;
+DROP PROCEDURE p2;
+DROP PROCEDURE IF EXISTS p1;
+DROP PROCEDURE IF EXISTS p2;
+DROP PROCEDURE IF EXISTS p3;
+CREATE PROCEDURE p1()
+BEGIN
+DECLARE CONTINUE HANDLER FOR SQLWARNING SELECT 'warning';
+CALL p2();
+CALL p3();
+END|
+CREATE PROCEDURE p2()
+BEGIN
+SELECT CAST('10 ' as unsigned integer);
+END|
+CREATE PROCEDURE p3()
+BEGIN
+SELECT CAST('10 ' as unsigned integer);
+SELECT 1;
+END|
+CALL p1();
+CAST('10 ' as unsigned integer)
+10
+warning
+warning
+CAST('10 ' as unsigned integer)
+10
+1
+1
+DROP PROCEDURE p1;
+DROP PROCEDURE p2;
+DROP PROCEDURE p3;
diff -Nrup a/mysql-test/r/sp-prelocking.result b/mysql-test/r/sp-prelocking.result
--- a/mysql-test/r/sp-prelocking.result	2007-07-27 11:57:55 -03:00
+++ b/mysql-test/r/sp-prelocking.result	2008-04-07 14:29:38 -03:00
@@ -21,8 +21,6 @@ mysqltest
 call sp1();
 my-col
 1
-Warnings:
-Note	1051	Unknown table 't1'
 select database();
 database()
 mysqltest
@@ -33,8 +31,6 @@ test
 call mysqltest.sp1();
 my-col
 1
-Warnings:
-Note	1051	Unknown table 't1'
 select database();
 database()
 test
diff -Nrup a/mysql-test/r/sp-vars.result b/mysql-test/r/sp-vars.result
--- a/mysql-test/r/sp-vars.result	2007-05-18 09:29:22 -03:00
+++ b/mysql-test/r/sp-vars.result	2008-04-07 14:29:38 -03:00
@@ -109,26 +109,6 @@ v7	v8	v9	v10	v11	v12	v13	v14	v15	v16
 10	10	10	0	0	10	10	10	10	0
 v17	v18	v19	v20
 12.00	12.12	12.00	12.12
-Warnings:
-Warning	1264	Out of range value for column 'v1' at row 1
-Warning	1264	Out of range value for column 'v1u' at row 1
-Warning	1264	Out of range value for column 'v2' at row 1
-Warning	1264	Out of range value for column 'v2u' at row 1
-Warning	1264	Out of range value for column 'v3' at row 1
-Warning	1264	Out of range value for column 'v3u' at row 1
-Warning	1264	Out of range value for column 'v4' at row 1
-Warning	1264	Out of range value for column 'v4u' at row 1
-Warning	1264	Out of range value for column 'v5' at row 1
-Warning	1264	Out of range value for column 'v5u' at row 1
-Warning	1264	Out of range value for column 'v6' at row 1
-Warning	1264	Out of range value for column 'v6u' at row 1
-Warning	1366	Incorrect integer value: 'String 10 ' for column 'v10' at row 1
-Warning	1366	Incorrect integer value: 'String10' for column 'v11' at row 1
-Warning	1265	Data truncated for column 'v12' at row 1
-Warning	1265	Data truncated for column 'v13' at row 1
-Warning	1366	Incorrect integer value: 'Hello, world' for column 'v16' at row 1
-Note	1265	Data truncated for column 'v18' at row 1
-Note	1265	Data truncated for column 'v20' at row 1
 CALL sp_vars_check_assignment();
 i1	i2	i3	i4
 127	-128	127	-128
@@ -142,23 +122,6 @@ d1	d2	d3
 1234.00	1234.12	1234.12
 d1	d2	d3
 1234.00	1234.12	1234.12
-Warnings:
-Warning	1264	Out of range value for column 'i1' at row 1
-Warning	1264	Out of range value for column 'i2' at row 1
-Warning	1264	Out of range value for column 'i3' at row 1
-Warning	1264	Out of range value for column 'i4' at row 1
-Warning	1264	Out of range value for column 'i1' at row 1
-Warning	1264	Out of range value for column 'i2' at row 1
-Warning	1264	Out of range value for column 'i3' at row 1
-Warning	1264	Out of range value for column 'i4' at row 1
-Warning	1264	Out of range value for column 'u1' at row 1
-Warning	1264	Out of range value for column 'u2' at row 1
-Warning	1264	Out of range value for column 'u3' at row 1
-Warning	1264	Out of range value for column 'u4' at row 1
-Warning	1264	Out of range value for column 'u1' at row 1
-Warning	1264	Out of range value for column 'u2' at row 1
-Note	1265	Data truncated for column 'd3' at row 1
-Note	1265	Data truncated for column 'd3' at row 1
 SELECT sp_vars_check_ret1();
 sp_vars_check_ret1()
 127
@@ -197,26 +160,6 @@ v7	v8	v9	v10	v11	v12	v13	v14	v15	v16
 10	10	10	0	0	10	10	10	10	0
 v17	v18	v19	v20
 12.00	12.12	12.00	12.12
-Warnings:
-Warning	1264	Out of range value for column 'v1' at row 1
-Warning	1264	Out of range value for column 'v1u' at row 1
-Warning	1264	Out of range value for column 'v2' at row 1
-Warning	1264	Out of range value for column 'v2u' at row 1
-Warning	1264	Out of range value for column 'v3' at row 1
-Warning	1264	Out of range value for column 'v3u' at row 1
-Warning	1264	Out of range value for column 'v4' at row 1
-Warning	1264	Out of range value for column 'v4u' at row 1
-Warning	1264	Out of range value for column 'v5' at row 1
-Warning	1264	Out of range value for column 'v5u' at row 1
-Warning	1264	Out of range value for column 'v6' at row 1
-Warning	1264	Out of range value for column 'v6u' at row 1
-Warning	1366	Incorrect integer value: 'String 10 ' for column 'v10' at row 1
-Warning	1366	Incorrect integer value: 'String10' for column 'v11' at row 1
-Warning	1265	Data truncated for column 'v12' at row 1
-Warning	1265	Data truncated for column 'v13' at row 1
-Warning	1366	Incorrect integer value: 'Hello, world' for column 'v16' at row 1
-Note	1265	Data truncated for column 'v18' at row 1
-Note	1265	Data truncated for column 'v20' at row 1
 CALL sp_vars_check_assignment();
 i1	i2	i3	i4
 127	-128	127	-128
@@ -230,23 +173,6 @@ d1	d2	d3
 1234.00	1234.12	1234.12
 d1	d2	d3
 1234.00	1234.12	1234.12
-Warnings:
-Warning	1264	Out of range value for column 'i1' at row 1
-Warning	1264	Out of range value for column 'i2' at row 1
-Warning	1264	Out of range value for column 'i3' at row 1
-Warning	1264	Out of range value for column 'i4' at row 1
-Warning	1264	Out of range value for column 'i1' at row 1
-Warning	1264	Out of range value for column 'i2' at row 1
-Warning	1264	Out of range value for column 'i3' at row 1
-Warning	1264	Out of range value for column 'i4' at row 1
-Warning	1264	Out of range value for column 'u1' at row 1
-Warning	1264	Out of range value for column 'u2' at row 1
-Warning	1264	Out of range value for column 'u3' at row 1
-Warning	1264	Out of range value for column 'u4' at row 1
-Warning	1264	Out of range value for column 'u1' at row 1
-Warning	1264	Out of range value for column 'u2' at row 1
-Note	1265	Data truncated for column 'd3' at row 1
-Note	1265	Data truncated for column 'd3' at row 1
 SELECT sp_vars_check_ret1();
 sp_vars_check_ret1()
 127
@@ -450,12 +376,6 @@ HEX(v9)
 FF
 HEX(v10)
 FF
-Warnings:
-Warning	1264	Out of range value for column 'v8' at row 1
-Warning	1264	Out of range value for column 'v9' at row 1
-Warning	1264	Out of range value for column 'v10' at row 1
-Warning	1264	Out of range value for column 'v1' at row 1
-Warning	1264	Out of range value for column 'v5' at row 1
 DROP PROCEDURE p1;
 
 ---------------------------------------------------------------
@@ -697,8 +617,6 @@ Table	Create Table
 t1	CREATE TABLE "t1" (
   "x" datetime DEFAULT NULL
 )
-Warnings:
-Warning	1264	Out of range value for column 'x' at row 1
 DROP PROCEDURE p1;
 
 ---------------------------------------------------------------
@@ -887,8 +805,6 @@ var
 CALL p1(1929.003);
 var
 1929.00
-Warnings:
-Note	1265	Data truncated for column 'arg' at row 1
 DROP PROCEDURE p1;
 
 ---------------------------------------------------------------
@@ -966,8 +882,6 @@ sp_var
 0
 @user_var
 0
-Warnings:
-Warning	1366	Incorrect integer value: 'Hello, world!' for column 'sp_var' at row 1
 DROP PROCEDURE p1;
 DROP TABLE t1;
 
@@ -1025,8 +939,6 @@ Warning	1265	Data truncated for column '
 CALL p2('a');
 arg	var
 a	
-Warnings:
-Warning	1265	Data truncated for column 'var' at row 1
 SELECT f1('a');
 f1('a')
 
diff -Nrup a/mysql-test/r/sp.result b/mysql-test/r/sp.result
--- a/mysql-test/r/sp.result	2008-03-27 06:56:01 -03:00
+++ b/mysql-test/r/sp.result	2008-04-07 14:29:38 -03:00
@@ -526,8 +526,6 @@ end|
 delete from t1|
 create table t3 ( s char(16), d int)|
 call into_test4()|
-Warnings:
-Warning	1329	No data - zero rows fetched, selected, or processed
 select * from t3|
 s	d
 into4	NULL
@@ -1121,7 +1119,6 @@ select f9()|
 f9()
 6
 Warnings:
-Note	1051	Unknown table 't3'
 select f9() from t1 limit 1|
 f9()
 6
@@ -1163,7 +1160,6 @@ select f12_1()|
 f12_1()
 3
 Warnings:
-Note	1051	Unknown table 't3'
 select f12_1() from t1 limit 1|
 f12_1()
 3
@@ -2115,12 +2111,7 @@ end if;
 insert into t4 values (2, rc, t3);
 end|
 call bug1863(10)|
-Warnings:
-Note	1051	Unknown table 'temp_t1'
-Warning	1329	No data - zero rows fetched, selected, or processed
 call bug1863(10)|
-Warnings:
-Warning	1329	No data - zero rows fetched, selected, or processed
 select * from t4|
 f1	rc	t3
 2	0	NULL
@@ -2385,11 +2376,7 @@ begin
 end|
 call bug4579_1()|
 call bug4579_1()|
-Warnings:
-Warning	1329	No data - zero rows fetched, selected, or processed
 call bug4579_1()|
-Warnings:
-Warning	1329	No data - zero rows fetched, selected, or processed
 drop procedure bug4579_1|
 drop procedure bug4579_2|
 drop table t3|
@@ -2808,16 +2795,12 @@ var
 call bug7743("OneWord")|
 var
 NULL
-Warnings:
-Warning	1329	No data - zero rows fetched, selected, or processed
 call bug7743("anotherword")|
 var
 2
 call bug7743("AnotherWord")|
 var
 NULL
-Warnings:
-Warning	1329	No data - zero rows fetched, selected, or processed
 drop procedure bug7743|
 drop table t4|
 delete from t3|
@@ -3234,11 +3217,7 @@ end|
 create procedure bug9004_2(x char(16))
 call bug9004_1(x)|
 call bug9004_1('12345678901234567')|
-Warnings:
-Warning	1265	Data truncated for column 'x' at row 1
 call bug9004_2('12345678901234567890')|
-Warnings:
-Warning	1265	Data truncated for column 'x' at row 1
 delete from t1|
 drop procedure bug9004_1|
 drop procedure bug9004_2|
@@ -3841,9 +3820,6 @@ Table	Create Table
 tm1	CREATE TEMPORARY TABLE `tm1` (
   `spv1` decimal(3,3) DEFAULT NULL
 ) ENGINE=MyISAM DEFAULT CHARSET=latin1
-Warnings:
-Warning	1264	Out of range value for column 'spv1' at row 1
-Warning	1366	Incorrect decimal value: 'test' for column 'spv1' at row 1
 call bug12589_2()|
 Table	Create Table
 tm1	CREATE TEMPORARY TABLE `tm1` (
@@ -4682,13 +4658,9 @@ Before NOT FOUND condition is triggered
 After NOT FOUND condtition is triggered
 xid	xdone
 1	0
-Warnings:
-Warning	1329	No data - zero rows fetched, selected, or processed
 call bug15231_3()|
 Result
 Missed it (correct)
-Warnings:
-Warning	1366	Incorrect decimal value: 'zap' for column 'x' at row 1
 drop table if exists t3|
 drop procedure if exists bug15231_1|
 drop procedure if exists bug15231_2|
@@ -5502,12 +5474,10 @@ select func_20028_a()|
 func_20028_a()
 0
 Warnings:
-Warning	1329	No data - zero rows fetched, selected, or processed
 select func_20028_b()|
 func_20028_b()
 0
 Warnings:
-Warning	1329	No data - zero rows fetched, selected, or processed
 select func_20028_c()|
 ERROR 22012: Division by 0
 call proc_20028_a()|
@@ -5561,12 +5531,10 @@ select func_20028_a()|
 func_20028_a()
 0
 Warnings:
-Warning	1329	No data - zero rows fetched, selected, or processed
 select func_20028_b()|
 func_20028_b()
 0
 Warnings:
-Warning	1329	No data - zero rows fetched, selected, or processed
 select func_20028_c()|
 func_20028_c()
 NULL
@@ -6123,7 +6091,6 @@ select bug20777(-9223372036854775808) as
 lower bounds signed bigint
 0
 Warnings:
-Warning	1264	Out of range value for column 'f1' at row 1
 select bug20777(9223372036854775807) as 'upper bounds signed bigint';
 upper bounds signed bigint
 9223372036854775807
@@ -6137,12 +6104,10 @@ select bug20777(18446744073709551616) as
 upper bounds unsigned bigint + 1
 18446744073709551615
 Warnings:
-Warning	1264	Out of range value for column 'f1' at row 1
 select bug20777(-1) as 'lower bounds unsigned bigint - 1';
 lower bounds unsigned bigint - 1
 0
 Warnings:
-Warning	1264	Out of range value for column 'f1' at row 1
 create table examplebug20777 as select 
 0 as 'i',
 bug20777(9223372036854775806) as '2**63-2',
@@ -6155,8 +6120,6 @@ bug20777(18446744073709551616) as '2**64
 bug20777(0) as '0',
 bug20777(-1) as '-1';
 Warnings:
-Warning	1264	Out of range value for column 'f1' at row 1
-Warning	1264	Out of range value for column 'f1' at row 1
 insert into examplebug20777 values (1, 9223372036854775806, 9223372036854775807, 223372036854775808, 9223372036854775809, 18446744073709551614, 18446744073709551615, 8446744073709551616, 0, -1);
 Warnings:
 Warning	1264	Out of range value for column '-1' at row 1
@@ -6201,36 +6164,6 @@ SELECT bug5274_f2()|
 bug5274_f2()
 x
 Warnings:
-Warning	1265	Data truncated for column 'bug5274_f1' at row 1
-Warning	1265	Data truncated for column 'bug5274_f1' at row 1
-Warning	1265	Data truncated for column 'bug5274_f1' at row 1
-Warning	1265	Data truncated for column 'bug5274_f1' at row 1
-Warning	1265	Data truncated for column 'bug5274_f1' at row 1
-Warning	1265	Data truncated for column 'bug5274_f1' at row 1
-Warning	1265	Data truncated for column 'bug5274_f1' at row 1
-Warning	1265	Data truncated for column 'bug5274_f1' at row 1
-Warning	1265	Data truncated for column 'bug5274_f1' at row 1
-Warning	1265	Data truncated for column 'bug5274_f1' at row 1
-Warning	1265	Data truncated for column 'bug5274_f1' at row 1
-Warning	1265	Data truncated for column 'bug5274_f1' at row 1
-Warning	1265	Data truncated for column 'bug5274_f1' at row 1
-Warning	1265	Data truncated for column 'bug5274_f1' at row 1
-Warning	1265	Data truncated for column 'bug5274_f1' at row 1
-Warning	1265	Data truncated for column 'bug5274_f1' at row 1
-Warning	1265	Data truncated for column 'bug5274_f1' at row 1
-Warning	1265	Data truncated for column 'bug5274_f1' at row 1
-Warning	1265	Data truncated for column 'bug5274_f1' at row 1
-Warning	1265	Data truncated for column 'bug5274_f1' at row 1
-Warning	1265	Data truncated for column 'bug5274_f1' at row 1
-Warning	1265	Data truncated for column 'bug5274_f1' at row 1
-Warning	1265	Data truncated for column 'bug5274_f1' at row 1
-Warning	1265	Data truncated for column 'bug5274_f1' at row 1
-Warning	1265	Data truncated for column 'bug5274_f1' at row 1
-Warning	1265	Data truncated for column 'bug5274_f1' at row 1
-Warning	1265	Data truncated for column 'bug5274_f1' at row 1
-Warning	1265	Data truncated for column 'bug5274_f1' at row 1
-Warning	1265	Data truncated for column 'bug5274_f1' at row 1
-Warning	1265	Data truncated for column 'bug5274_f1' at row 1
 DROP FUNCTION bug5274_f1|
 DROP FUNCTION bug5274_f2|
 drop procedure if exists proc_21513|
@@ -6324,21 +6257,15 @@ SELECT f1(2);
 f1(2)
 0
 Warnings:
-Warning	1329	No data - zero rows fetched, selected, or processed
-Warning	1329	No data - zero rows fetched, selected, or processed
 PREPARE s1 FROM 'SELECT f1(2)';
 EXECUTE s1;
 f1(2)
 0
 Warnings:
-Warning	1329	No data - zero rows fetched, selected, or processed
-Warning	1329	No data - zero rows fetched, selected, or processed
 EXECUTE s1;
 f1(2)
 0
 Warnings:
-Warning	1329	No data - zero rows fetched, selected, or processed
-Warning	1329	No data - zero rows fetched, selected, or processed
 DROP PROCEDURE p1;
 DROP PROCEDURE p2;
 DROP FUNCTION f1;
diff -Nrup a/mysql-test/r/view_grant.result b/mysql-test/r/view_grant.result
--- a/mysql-test/r/view_grant.result	2008-03-22 05:02:23 -03:00
+++ b/mysql-test/r/view_grant.result	2008-04-07 14:29:38 -03:00
@@ -342,12 +342,10 @@ select * from v1;
 f2()
 NULL
 Warnings:
-Warning	1329	No data - zero rows fetched, selected, or processed
 select * from v2;
 f2()
 NULL
 Warnings:
-Warning	1329	No data - zero rows fetched, selected, or processed
 select * from v3;
 ERROR HY000: View 'mysqltest.v3' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them
 select * from v4;
@@ -388,12 +386,10 @@ select * from v3;
 f2()
 NULL
 Warnings:
-Warning	1329	No data - zero rows fetched, selected, or processed
 select * from v4;
 f2()
 NULL
 Warnings:
-Warning	1329	No data - zero rows fetched, selected, or processed
 select * from v5;
 ERROR HY000: View 'mysqltest.v5' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them
 drop view v1, v2, v3, v4, v5;
diff -Nrup a/mysql-test/suite/binlog/r/binlog_unsafe.result b/mysql-test/suite/binlog/r/binlog_unsafe.result
--- a/mysql-test/suite/binlog/r/binlog_unsafe.result	2008-03-27 07:13:12 -03:00
+++ b/mysql-test/suite/binlog/r/binlog_unsafe.result	2008-04-07 14:29:38 -03:00
@@ -43,12 +43,6 @@ END|
 CALL proc();
 Warnings:
 Warning	1592	Statement is not safe to log in statement format.
-Warning	1592	Statement is not safe to log in statement format.
-Warning	1592	Statement is not safe to log in statement format.
-Warning	1592	Statement is not safe to log in statement format.
-Warning	1592	Statement is not safe to log in statement format.
-Warning	1592	Statement is not safe to log in statement format.
-Warning	1592	Statement is not safe to log in statement format.
 ---- Insert from stored function ----
 CREATE FUNCTION func()
 RETURNS INT
@@ -66,13 +60,6 @@ SELECT func();
 func()
 0
 Warnings:
-Warning	1592	Statement is not safe to log in statement format.
-Warning	1592	Statement is not safe to log in statement format.
-Warning	1592	Statement is not safe to log in statement format.
-Warning	1592	Statement is not safe to log in statement format.
-Warning	1592	Statement is not safe to log in statement format.
-Warning	1592	Statement is not safe to log in statement format.
-Warning	1592	Statement is not safe to log in statement format.
 ---- Insert from trigger ----
 CREATE TRIGGER trig
 BEFORE INSERT ON trigger_table
@@ -89,13 +76,6 @@ END|
 INSERT INTO trigger_table VALUES ('bye.');
 Warnings:
 Warning	1592	Statement is not safe to log in statement format.
-Warning	1592	Statement is not safe to log in statement format.
-Warning	1592	Statement is not safe to log in statement format.
-Warning	1592	Statement is not safe to log in statement format.
-Warning	1592	Statement is not safe to log in statement format.
-Warning	1592	Statement is not safe to log in statement format.
-Warning	1592	Statement is not safe to log in statement format.
-Warning	1592	Statement is not safe to log in statement format.
 ---- Insert from prepared statement ----
 PREPARE p1 FROM 'INSERT INTO t1 VALUES (@@global.sync_binlog)';
 PREPARE p2 FROM 'INSERT INTO t1 VALUES (@@session.insert_id)';
@@ -153,14 +133,6 @@ PREPARE prep6 FROM 'SELECT func5()'|
 EXECUTE prep6;
 func5()
 0
-Warnings:
-Warning	1592	Statement is not safe to log in statement format.
-Warning	1592	Statement is not safe to log in statement format.
-Warning	1592	Statement is not safe to log in statement format.
-Warning	1592	Statement is not safe to log in statement format.
-Warning	1592	Statement is not safe to log in statement format.
-Warning	1592	Statement is not safe to log in statement format.
-Warning	1592	Statement is not safe to log in statement format.
 ==== Variables that should *not* be unsafe ====
 INSERT INTO t1 VALUES (@@session.pseudo_thread_id);
 INSERT INTO t1 VALUES (@@session.pseudo_thread_id);
@@ -214,9 +186,6 @@ DELETE FROM t1 LIMIT 1;
 END|
 CALL p1();
 Warnings:
-Warning	1592	Statement is not safe to log in statement format.
-Warning	1592	Statement is not safe to log in statement format.
-Warning	1592	Statement is not safe to log in statement format.
 Warning	1592	Statement is not safe to log in statement format.
 DROP PROCEDURE p1;
 DROP TABLE t1;
diff -Nrup a/mysql-test/suite/rpl/r/rpl_sp_effects.result b/mysql-test/suite/rpl/r/rpl_sp_effects.result
--- a/mysql-test/suite/rpl/r/rpl_sp_effects.result	2007-10-30 09:49:34 -02:00
+++ b/mysql-test/suite/rpl/r/rpl_sp_effects.result	2008-04-07 14:29:39 -03:00
@@ -254,7 +254,6 @@ select sf_bug26199(b'101111111');
 sf_bug26199(b'101111111')
 0
 Warnings:
-Warning	1264	Out of range value for column 'b' at row 1
 select sf_bug26199('\'');
 sf_bug26199('\'')
 0
diff -Nrup a/mysql-test/t/sp-error.test b/mysql-test/t/sp-error.test
--- a/mysql-test/t/sp-error.test	2008-03-28 14:47:45 -03:00
+++ b/mysql-test/t/sp-error.test	2008-04-07 14:29:39 -03:00
@@ -2419,6 +2419,70 @@ set @@max_sp_recursion_depth = @old_recu
 drop procedure p1;
 
 #
+# Bug#23032: Handlers declared in a SP do not handle warnings generated in sub-SP
+#
+
+--disable_warnings
+DROP PROCEDURE IF EXISTS p1;
+DROP PROCEDURE IF EXISTS p2;
+--enable_warnings
+
+delimiter |;
+
+CREATE PROCEDURE p1()
+  BEGIN
+    SELECT CAST('10 ' as unsigned integer);
+    SELECT 1;
+    CALL p2();
+  END|
+
+CREATE PROCEDURE p2()
+  BEGIN
+    SELECT CAST('10 ' as unsigned integer);
+  END|
+
+delimiter ;|
+
+CALL p1();
+
+DROP PROCEDURE p1;
+DROP PROCEDURE p2;
+
+--disable_warnings
+DROP PROCEDURE IF EXISTS p1;
+DROP PROCEDURE IF EXISTS p2;
+DROP PROCEDURE IF EXISTS p3;
+--enable_warnings
+
+delimiter |;
+
+CREATE PROCEDURE p1()
+  BEGIN
+    DECLARE CONTINUE HANDLER FOR SQLWARNING SELECT 'warning';
+    CALL p2();
+    CALL p3();
+  END|
+
+CREATE PROCEDURE p2()
+  BEGIN
+    SELECT CAST('10 ' as unsigned integer);
+  END|
+
+CREATE PROCEDURE p3()
+  BEGIN
+    SELECT CAST('10 ' as unsigned integer);
+    SELECT 1;
+  END|
+
+delimiter ;|
+
+CALL p1();
+
+DROP PROCEDURE p1;
+DROP PROCEDURE p2;
+DROP PROCEDURE p3;
+
+#
 # BUG#NNNN: New bug synopsis
 #
 #--disable_warnings
diff -Nrup a/mysys/my_error.c b/mysys/my_error.c
--- a/mysys/my_error.c	2007-05-10 06:59:25 -03:00
+++ b/mysys/my_error.c	2008-04-07 14:29:39 -03:00
@@ -64,13 +64,9 @@ static struct my_err_head *my_errmsgs_li
        nr	Errno
        MyFlags	Flags
        ...	variable list
-
-  RETURN
-    What (*error_handler_hook)() returns:
-    0   OK
 */
 
-int my_error(int nr, myf MyFlags, ...)
+void my_error(int nr, myf MyFlags, ...)
 {
   const char *format;
   struct my_err_head *meh_p;
@@ -99,7 +95,8 @@ int my_error(int nr, myf MyFlags, ...)
     (void) my_vsnprintf (ebuff, sizeof(ebuff), format, args);
     va_end(args);
   }
-  DBUG_RETURN((*error_handler_hook)(nr, ebuff, MyFlags));
+  (*error_handler_hook)(nr, ebuff, MyFlags);
+  DBUG_VOID_RETURN;
 }
 
 
@@ -114,7 +111,7 @@ int my_error(int nr, myf MyFlags, ...)
       ...	variable list
 */
 
-int my_printf_error(uint error, const char *format, myf MyFlags, ...)
+void my_printf_error(uint error, const char *format, myf MyFlags, ...)
 {
   va_list args;
   char ebuff[ERRMSGSIZE+20];
@@ -125,7 +122,8 @@ int my_printf_error(uint error, const ch
   va_start(args,MyFlags);
   (void) my_vsnprintf (ebuff, sizeof(ebuff), format, args);
   va_end(args);
-  DBUG_RETURN((*error_handler_hook)(error, ebuff, MyFlags));
+  (*error_handler_hook)(error, ebuff, MyFlags);
+  DBUG_VOID_RETURN;
 }
 
 /*
@@ -138,9 +136,9 @@ int my_printf_error(uint error, const ch
       MyFlags	Flags
 */
 
-int my_message(uint error, const char *str, register myf MyFlags)
+void my_message(uint error, const char *str, register myf MyFlags)
 {
-  return (*error_handler_hook)(error, str, MyFlags);
+  (*error_handler_hook)(error, str, MyFlags);
 }
 
 
diff -Nrup a/mysys/my_messnc.c b/mysys/my_messnc.c
--- a/mysys/my_messnc.c	2006-12-23 17:04:07 -02:00
+++ b/mysys/my_messnc.c	2008-04-07 14:29:39 -03:00
@@ -15,7 +15,7 @@
 
 #include "mysys_priv.h"
 
-int my_message_no_curses(uint error __attribute__((unused)),
+void my_message_no_curses(uint error __attribute__((unused)),
 			 const char *str, myf MyFlags)
 {
   DBUG_ENTER("my_message_no_curses");
@@ -34,5 +34,5 @@ int my_message_no_curses(uint error __at
   (void)fputs(str,stderr);
   (void)fputc('\n',stderr);
   (void)fflush(stderr);
-  DBUG_RETURN(0);
+  DBUG_VOID_RETURN;
 }
diff -Nrup a/mysys/my_static.c b/mysys/my_static.c
--- a/mysys/my_static.c	2007-08-13 10:11:10 -03:00
+++ b/mysys/my_static.c	2008-04-07 14:29:39 -03:00
@@ -87,9 +87,9 @@ ulong my_time_to_wait_for_lock=2;	/* In 
 char * NEAR globerrs[GLOBERRS];		/* my_error_messages is here */
 #endif
 void (*my_abort_hook)(int) = (void(*)(int)) exit;
-int (*error_handler_hook)(uint error,const char *str,myf MyFlags)=
+void (*error_handler_hook)(uint error,const char *str,myf MyFlags)=
     my_message_no_curses;
-int (*fatal_error_handler_hook)(uint error,const char *str,myf MyFlags)=
+void (*fatal_error_handler_hook)(uint error,const char *str,myf MyFlags)=
   my_message_no_curses;
 
 #ifdef __WIN__
diff -Nrup a/sql/backup/error.h b/sql/backup/error.h
--- a/sql/backup/error.h	2008-02-06 15:50:12 -02:00
+++ b/sql/backup/error.h	2008-04-07 14:29:40 -03:00
@@ -23,12 +23,11 @@ int report_mysql_error(THD* thd, MYSQL_E
 
   case MYSQL_ERROR::WARN_LEVEL_ERROR:
   {
-    int ret;
     bool old_value= thd->no_warnings_for_error;
     thd->no_warnings_for_error= TRUE;
-    ret= my_printf_error(err->code ? err->code : code, err->msg, MYF(0));
+    my_printf_error(err->code ? err->code : code, err->msg, MYF(0));
     thd->no_warnings_for_error= old_value;
-    return ret;
+    return 0;
   }
   default: // Q: What to do with warnings and notes? push them... ?
     return -1;
diff -Nrup a/sql/mysqld.cc b/sql/mysqld.cc
--- a/sql/mysqld.cc	2008-03-28 14:47:46 -03:00
+++ b/sql/mysqld.cc	2008-04-07 14:29:39 -03:00
@@ -2905,9 +2905,9 @@ static void check_data_home(const char *
   for the client.
 */
 /* ARGSUSED */
-extern "C" int my_message_sql(uint error, const char *str, myf MyFlags);
+extern "C" void my_message_sql(uint error, const char *str, myf MyFlags);
 
-int my_message_sql(uint error, const char *str, myf MyFlags)
+void my_message_sql(uint error, const char *str, myf MyFlags)
 {
   THD *thd;
   DBUG_ENTER("my_message_sql");
@@ -2929,13 +2929,9 @@ int my_message_sql(uint error, const cha
                         thd->row_count);
 
 
-    /*
-      TODO: There are two exceptions mechanism (THD and sp_rcontext),
-      this could be improved by having a common stack of handlers.
-    */
     if (thd->handle_error(error, str,
                           MYSQL_ERROR::WARN_LEVEL_ERROR))
-      DBUG_RETURN(0);
+      DBUG_VOID_RETURN;
 
     thd->is_slave_error=  1; // needed to catch query errors during replication
 
@@ -2965,19 +2961,6 @@ int my_message_sql(uint error, const cha
       }
       query_cache_abort(&thd->query_cache_tls);
     }
-    /*
-      If a continue handler is found, the error message will be cleared
-      by the stored procedures code.
-    */
-    if (!thd->is_fatal_error && thd->spcont &&
-        thd->spcont->handle_error(error, MYSQL_ERROR::WARN_LEVEL_ERROR, thd))
-    {
-      /*
-        Do not push any warnings, a handled error must be completely
-        silenced.
-      */
-      DBUG_RETURN(0);
-    }
 
     if (!thd->no_warnings_for_error && !thd->is_fatal_error)
     {
@@ -2992,7 +2975,7 @@ int my_message_sql(uint error, const cha
   }
   if (!thd || MyFlags & ME_NOREFRESH)
     sql_print_error("%s: %s",my_progname,str); /* purecov: inspected */
-  DBUG_RETURN(0);
+  DBUG_VOID_RETURN;
 }
 
 
diff -Nrup a/sql/sp_head.cc b/sql/sp_head.cc
--- a/sql/sp_head.cc	2008-03-28 14:47:47 -03:00
+++ b/sql/sp_head.cc	2008-04-07 14:29:40 -03:00
@@ -1026,6 +1026,52 @@ void sp_head::recursion_level_error(THD 
 }
 
 
+/*
+  Check if an exception has occurred and a handler has been found
+
+  @param thd thread handle
+  @param ctx runtime context of the stored routine
+  @param ip location of the found handler
+  @param instr stored procedure instruction
+  @param execute_arena per-instruction arena
+  @param backup_arena per-instruction arena
+
+  @return TRUE if a handler has been found, FALSE otherwise.
+*/
+
+static bool
+exception(THD *thd, sp_rcontext *ctx, uint *ip, sp_instr *instr,
+          Query_arena *execute_arena, Query_arena *backup_arena)
+{
+  uint hf;
+
+  ctx->clear_handler();
+
+  if (! ctx->find_handler(thd))
+    return FALSE;
+
+  switch (ctx->found_handler(ip, &hf)) {
+  case SP_HANDLER_NONE:
+    break;
+  case SP_HANDLER_CONTINUE:
+    thd->restore_active_arena(execute_arena, backup_arena);
+    thd->set_n_backup_active_arena(execute_arena, backup_arena);
+    ctx->push_hstack(instr->get_cont_dest());
+    // Fall through
+  default:
+    ctx->clear_handler();
+    ctx->enter_handler(*ip);
+    thd->clear_error();
+    mysql_reset_errors(thd, 1);
+    thd->is_fatal_error= 0;
+    thd->killed= THD::NOT_KILLED;
+    thd->mysys_var->abort= 0;
+    return TRUE;
+  }
+  return FALSE;
+}
+
+
 /**
   Execute the routine. The main instruction jump loop is there.
   Assume the parameters already set.
@@ -1170,10 +1216,9 @@ sp_head::execute(THD *thd)
   do
   {
     sp_instr *i;
-    uint hip;			// Handler ip
 
 #if defined(ENABLED_PROFILING)
-    /* 
+    /*
      Treat each "instr" of a routine as discrete unit that could be profiled.
      Profiling only records information for segments of code that set the
      source of the query, and almost all kinds of instructions in s-p do not.
@@ -1191,12 +1236,21 @@ sp_head::execute(THD *thd)
       break;
     }
 
+    /*
+      Clear the Diagnostics Area and the Condition Area in preparation for
+      the next command, use a reference to the last instruction because each
+      instruction needs to clean up it's own mess. Although this is happening
+      at the end of the execution, it's the same as cleaning the areas at the
+      beginning of the execution of the next statement.
+    */
+    i->reset(thd);
+
     DBUG_PRINT("execute", ("Instruction %u", ip));
 
     /* Don't change NOW() in FUNCTION or TRIGGER */
     if (!thd->in_sub_stmt)
       thd->set_time();		// Make current_time() et al work
-    
+
     /*
       We have to set thd->stmt_arena before executing the instruction
       to store in the instruction free_list all new items, created
@@ -1204,20 +1258,20 @@ sp_head::execute(THD *thd)
       items made during other permanent subquery transformations).
     */
     thd->stmt_arena= i;
-    
-    /* 
-      Will write this SP statement into binlog separately 
+
+    /*
+      Will write this SP statement into binlog separately
       (TODO: consider changing the condition to "not inside event union")
     */
     if (thd->prelocked_mode == NON_PRELOCKED)
       thd->user_var_events_alloc= thd->mem_root;
-    
+
     err_status= i->execute(thd, &ip);
 
     if (i->free_list)
       cleanup_items(i->free_list);
-    
-    /* 
+
+    /*
       If we've set thd->user_var_events_alloc to mem_root of this SP
       statement, clean all the events allocated in it.
     */
@@ -1229,7 +1283,7 @@ sp_head::execute(THD *thd)
 
     /* we should cleanup free_list and memroot, used by instruction */
     thd->cleanup_after_query();
-    free_root(&execute_mem_root, MYF(0));    
+    free_root(&execute_mem_root, MYF(0));
 
     /*
       Check if an exception has occurred and a handler has been found
@@ -1238,30 +1292,8 @@ sp_head::execute(THD *thd)
       if thd->killed != 0, since some errors return with this even when a
       handler has been found (e.g. "bad data").
     */
-    if (ctx)
-    {
-      uint hf;
-
-      switch (ctx->found_handler(&hip, &hf)) {
-      case SP_HANDLER_NONE:
-	break;
-      case SP_HANDLER_CONTINUE:
-        thd->restore_active_arena(&execute_arena, &backup_arena);
-        thd->set_n_backup_active_arena(&execute_arena, &backup_arena);
-        ctx->push_hstack(i->get_cont_dest());
-        // Fall through
-      default:
-	ip= hip;
-	err_status= FALSE;
-	ctx->clear_handler();
-	ctx->enter_handler(hip);
-        thd->clear_error();
-        thd->is_fatal_error= 0;
-	thd->killed= THD::NOT_KILLED;
-        thd->mysys_var->abort= 0;
-	continue;
-      }
-    }
+    if (ctx && exception(thd, ctx, &ip, i, &execute_arena, &backup_arena))
+      err_status= FALSE;
   } while (!err_status && !thd->killed && !thd->is_fatal_error);
 
 #if defined(ENABLED_PROFILING)
@@ -2742,6 +2774,23 @@ sp_lex_keeper::reset_lex_and_exec_core(T
   sp_instr class functions
 */
 
+void sp_instr::reset(THD *thd)
+{
+  /*
+    At the beginning of the execution of any <SQL procedure
+    statement> that is not an <SQL diagnostics statement>,
+    the first diagnostics area is emptied.
+  */
+  thd->main_da.reset_diagnostics_area();
+
+  /*
+    Also reset any warnings at the beginning of the execution.
+    The Condition Area is part of the Diagnostics Area, so when
+    the Diagnostics Area is "emptied" the Condition Area is cleared.
+  */
+  mysql_reset_errors(thd, 0);
+}
+
 int sp_instr::exec_open_and_lock_tables(THD *thd, TABLE_LIST *tables)
 {
   int result;
@@ -2885,7 +2934,7 @@ sp_instr_set::exec_core(THD *thd, uint *
 {
   int res= thd->spcont->set_variable(thd, m_offset, &m_value);
 
-  if (res && thd->spcont->found_handler_here())
+  if (res && thd->spcont->find_handler(thd))
   {
     /*
       Failed to evaluate the value, and a handler has been found. Reset the
@@ -3440,9 +3489,7 @@ sp_instr_copen::execute(THD *thd, uint *
     */
     if (!res)
     {
-      uint dummy1, dummy2;
-
-      if (thd->spcont->found_handler(&dummy1, &dummy2))
+      if (thd->spcont->find_handler(thd))
         res= -1;
     }
     /* TODO: Assert here that we either have an error or a cursor */
@@ -3622,7 +3669,7 @@ sp_instr_set_case_expr::exec_core(THD *t
 
   if (res &&
       !thd->spcont->get_case_expr(m_case_expr_id) &&
-      thd->spcont->found_handler_here())
+      thd->spcont->find_handler(thd))
   {
     /*
       Failed to evaluate the value, the case expression is still not
diff -Nrup a/sql/sp_head.h b/sql/sp_head.h
--- a/sql/sp_head.h	2008-01-25 18:27:10 -02:00
+++ b/sql/sp_head.h	2008-04-07 14:29:40 -03:00
@@ -547,6 +547,13 @@ public:
   virtual ~sp_instr()
   { free_items(); }
 
+  /*
+    Reset the Diagnostics Area and the ondition Area at the
+    beginning of the execution of any <SQL procedure tatement>
+    that is not an <SQL diagnostics statement>.
+  */
+
+  virtual void reset(THD *thd);
 
   /**
     Execute this instruction
@@ -877,6 +884,9 @@ public:
   virtual ~sp_instr_jump()
   {}
 
+  virtual void reset(THD *thd)
+  {}
+
   virtual int execute(THD *thd, uint *nextp);
 
   virtual void print(String *str);
@@ -1012,6 +1022,9 @@ public:
     m_cond.empty();
   }
 
+  virtual void reset(THD *thd)
+  {}
+
   virtual int execute(THD *thd, uint *nextp);
 
   virtual void print(String *str);
@@ -1052,6 +1065,9 @@ public:
   virtual ~sp_instr_hpop()
   {}
 
+  virtual void reset(THD *thd)
+  {}
+
   virtual int execute(THD *thd, uint *nextp);
 
   virtual void print(String *str);
@@ -1111,6 +1127,9 @@ public:
   virtual ~sp_instr_cpush()
   {}
 
+  virtual void reset(THD *thd)
+  {}
+
   virtual int execute(THD *thd, uint *nextp);
 
   virtual void print(String *str);
@@ -1141,6 +1160,9 @@ public:
   {}
 
   virtual ~sp_instr_cpop()
+  {}
+
+  virtual void reset(THD *thd)
   {}
 
   virtual int execute(THD *thd, uint *nextp);
diff -Nrup a/sql/sp_rcontext.cc b/sql/sp_rcontext.cc
--- a/sql/sp_rcontext.cc	2008-01-23 20:36:39 -02:00
+++ b/sql/sp_rcontext.cc	2008-04-07 14:29:40 -03:00
@@ -161,6 +161,32 @@ sp_rcontext::set_return_value(THD *thd, 
   return sp_eval_expr(thd, m_return_value_fld, return_value_item);
 }
 
+bool
+sp_rcontext::find_handler(THD *thd)
+{
+  uint sql_errno;
+  MYSQL_ERROR::enum_warning_level level;
+
+  /* Fatal errors are not catchable. */
+  if (thd->is_fatal_error)
+    return FALSE;
+
+  if (thd->is_error())
+  {
+    sql_errno= thd->main_da.sql_errno();
+    level= MYSQL_ERROR::WARN_LEVEL_ERROR;
+  }
+  else if (thd->warn_list.elements)
+  {
+    MYSQL_ERROR *err= thd->warn_list.head();
+    sql_errno= err->code;
+    level= err->level;
+  }
+  else
+    return FALSE;
+
+  return find_handler(thd, sql_errno, level);
+}
 
 #define IS_WARNING_CONDITION(S)   ((S)[0] == '0' && (S)[1] == '1')
 #define IS_NOT_FOUND_CONDITION(S) ((S)[0] == '0' && (S)[1] == '2')
@@ -269,46 +295,6 @@ sp_rcontext::find_handler(THD *thd, uint
   }
   m_hfound= found;
   return TRUE;
-}
-
-/*
-   Handle the error for a given errno.
-   The severity of the error is adjusted depending of the current sql_mode.
-   If an handler is present for the error (see find_handler()),
-   this function will return true.
-   If a handler is found and if the severity of the error indicate
-   that the current instruction executed should abort,
-   the flag thd->net.report_error is also set.
-   This will cause the execution of the current instruction in a
-   sp_instr* to fail, and give control to the handler code itself
-   in the sp_head::execute() loop.
-
-  SYNOPSIS
-    sql_errno     The error code
-    level         Warning level
-    thd           The current thread
-
-  RETURN
-    TRUE       if a handler was found.
-    FALSE      if no handler was found.
-*/
-bool
-sp_rcontext::handle_error(uint sql_errno,
-                          MYSQL_ERROR::enum_warning_level level,
-                          THD *thd)
-{
-  MYSQL_ERROR::enum_warning_level elevated_level= level;
-
-
-  /* Depending on the sql_mode of execution,
-     warnings may be considered errors */
-  if ((level == MYSQL_ERROR::WARN_LEVEL_WARN) &&
-      thd->really_abort_on_warning())
-  {
-    elevated_level= MYSQL_ERROR::WARN_LEVEL_ERROR;
-  }
-
-  return find_handler(thd, sql_errno, elevated_level);
 }
 
 void
diff -Nrup a/sql/sp_rcontext.h b/sql/sp_rcontext.h
--- a/sql/sp_rcontext.h	2008-01-23 18:26:39 -02:00
+++ b/sql/sp_rcontext.h	2008-04-07 14:29:40 -03:00
@@ -113,13 +113,7 @@ class sp_rcontext : public Sql_alloc
 
   // Returns 1 if a handler was found, 0 otherwise.
   bool
-  find_handler(THD *thd, uint sql_errno,MYSQL_ERROR::enum_warning_level level);
-
-  // If there is an error handler for this error, handle it and return TRUE.
-  bool
-  handle_error(uint sql_errno,
-               MYSQL_ERROR::enum_warning_level level,
-               THD *thd);
+  find_handler(THD *thd);
 
   // Returns handler type and sets *ip to location if one was found
   inline int
@@ -132,13 +126,6 @@ class sp_rcontext : public Sql_alloc
     return m_handler[m_hfound].type;
   }
 
-  // Returns true if we found a handler in this context
-  inline bool
-  found_handler_here()
-  {
-    return (m_hfound >= 0);
-  }
-
   // Clears the handler find state
   inline void
   clear_handler()
@@ -228,6 +215,10 @@ private:
 
   /* Previous runtime context (NULL if none) */
   sp_rcontext *m_prev_runtime_ctx;
+
+  // Returns 1 if a handler was found, 0 otherwise.
+  bool
+  find_handler(THD *thd, uint sql_errno, MYSQL_ERROR::enum_warning_level level);
 
 private:
   bool init_var_table(THD *thd);
diff -Nrup a/sql/sql_class.cc b/sql/sql_class.cc
--- a/sql/sql_class.cc	2008-03-28 11:00:34 -03:00
+++ b/sql/sql_class.cc	2008-04-07 14:29:40 -03:00
@@ -1538,8 +1538,7 @@ void select_send::abort()
 {
   DBUG_ENTER("select_send::abort");
   if (is_result_set_started && thd->spcont &&
-      thd->spcont->find_handler(thd, thd->main_da.sql_errno(),
-                                MYSQL_ERROR::WARN_LEVEL_ERROR))
+      thd->spcont->find_handler(thd))
   {
     /*
       We're executing a stored procedure, have an open result
diff -Nrup a/sql/sql_error.cc b/sql/sql_error.cc
--- a/sql/sql_error.cc	2008-02-19 09:59:07 -03:00
+++ b/sql/sql_error.cc	2008-04-07 14:29:40 -03:00
@@ -118,7 +118,7 @@ MYSQL_ERROR *push_warning(THD *thd, MYSQ
   thd->got_warning= 1;
 
   /* Abort if we are using strict mode and we are not using IGNORE */
-  if ((int) level >= (int) MYSQL_ERROR::WARN_LEVEL_WARN &&
+  if (level >= MYSQL_ERROR::WARN_LEVEL_WARN &&
       thd->really_abort_on_warning())
   {
     /* Avoid my_message() calling push_warning */
@@ -140,13 +140,7 @@ MYSQL_ERROR *push_warning(THD *thd, MYSQ
   if (thd->handle_error(code, msg, level))
     DBUG_RETURN(NULL);
 
-  if (thd->spcont &&
-      thd->spcont->handle_error(code, level, thd))
-  {
-    DBUG_RETURN(NULL);
-  }
   query_cache_abort(&thd->query_cache_tls);
-
 
   if (thd->warn_list.elements < thd->variables.max_error_count)
   {
Thread
bk commit into 6.0 tree (davi:1.2622) BUG#23032Davi Arnaut7 Apr
  • Re: bk commit into 6.0 tree (davi:1.2622) BUG#23032Konstantin Osipov8 Apr
    • Re: bk commit into 6.0 tree (davi:1.2622) BUG#23032Davi Arnaut8 Apr