List:Commits« Previous MessageNext Message »
From:Davi Arnaut Date:April 18 2008 11:39am
Subject:bk commit into 6.0 tree (davi:1.2618) 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-18 08:39:09-03:00, davi@stripped +18 -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, unless the warning is generated by the last
  statement of the stored procedure.
  
  The solution is to prepare the environment before the execution
  of procedure statements and tightly control if warning were generated
  during the execution of the statement. Also handlers now are only
  called for handling warnings generated in the calling context of the
  executed statement, unless it's the last statement of the stored
  procedure.
  
  Now statements executed inside stored procedure fallow the same
  rules as non-sp statements with respect to effects on the message
  list (refer to SHOW WARNINGS manual entry for more details).
  
  Bug#36185: Incorrect precedence for warning and exception handlers
  
  The problem is that MySQL calls the handler for the first signaled
  condition during the execution of a stored procedure statement,
  meaning that if a warning is signaled first, it will search for a
  handler at that point and if a handler is found it won't look further
  for other handlers even if new warning/exception conditions occur.
  
  The solution is to look for handler only at the end of the execution
  of a statement. At the end, it looks first for error and not found
  conditions. If the execution completed successfully (no errors)
  but warnings were generated, it searches for a single handler in a
  first generated first served schema.

  mysql-test/r/partition.result@stripped, 2008-04-18 08:39:04-03:00, davi@stripped +0 -5
    Update test case result which reflects new rules for
    reset of the message list inside stored procedures.

  mysql-test/r/sp-dynamic.result@stripped, 2008-04-18 08:39:04-03:00, davi@stripped +0 -8
    Update test case result which reflects new rules for
    reset of the message list inside stored procedures.

  mysql-test/r/sp-error.result@stripped, 2008-04-18 08:39:04-03:00, davi@stripped +87 -0
    Add test case result for Bug#23032 and Bug#36185

  mysql-test/r/sp-prelocking.result@stripped, 2008-04-18 08:39:04-03:00, davi@stripped +0 -6
    Update test case result which reflects new rules for
    reset of the message list inside stored procedures.

  mysql-test/r/sp-vars.result@stripped, 2008-04-18 08:39:05-03:00, davi@stripped +0 -96
    Update test case result which reflects new rules for
    reset of the message list inside stored procedures.

  mysql-test/r/sp.result@stripped, 2008-04-18 08:39:05-03:00, davi@stripped +1 -91
    Update test case result which reflects new rules for
    reset of the message list inside stored procedures.

  mysql-test/r/trigger.result@stripped, 2008-04-18 08:39:05-03:00, davi@stripped +0 -12
    Update test case result which reflects new rules for
    reset of the message list inside stored procedures.

  mysql-test/r/view_grant.result@stripped, 2008-04-18 08:39:05-03:00, davi@stripped +0 -8
    Update test case result which reflects new rules for
    reset of the message list inside stored procedures.

  mysql-test/suite/binlog/r/binlog_unsafe.result@stripped, 2008-04-18 08:39:05-03:00, davi@stripped +4 -30
    Update test case result which reflects new rules for
    reset of the message list inside stored procedures.

  mysql-test/t/sp-error.test@stripped, 2008-04-18 08:39:05-03:00, davi@stripped +104 -0
    Add test case for Bug#23032 and Bug#36185

  sql/mysqld.cc@stripped, 2008-04-18 08:39:05-03:00, davi@stripped +0 -17
    Remove the internal error handler for stored procedures,
    now warnings are always pushed and the search for handlers
    is after the statement execution.

  sql/sp_head.cc@stripped, 2008-04-18 08:39:06-03:00, davi@stripped +77 -60
    Reset the per-statement warning count before executing
    a stored procedure instruction.
    
    Move to a separate function code which checks the
    completion status of the executed statement and searches
    for a handler.
    
    Remove redundant code now that search for a handler is
    done after execution, errors are always pushed.

  sql/sp_rcontext.cc@stripped, 2008-04-18 08:39:06-03:00, davi@stripped +0 -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-18 08:39:06-03:00, davi@stripped +0 -13
    Remove handler_error method and now unnused
    found_handler_here method.

  sql/sql_class.cc@stripped, 2008-04-18 08:39:06-03:00, davi@stripped +4 -7
    Handlers now are searched for at the end of the
    execution, default to abort when inside SP.

  sql/sql_error.cc@stripped, 2008-04-18 08:39:06-03:00, davi@stripped +0 -5
    Remove SP runtime context error handler.

  sql/sql_parse.cc@stripped, 2008-04-18 08:39:06-03:00, davi@stripped +1 -1
    Now reset of the message list follows same rules when 
    executing inside stored procedures.

  sql/sql_prepare.cc@stripped, 2008-04-18 08:39:06-03:00, davi@stripped +1 -1
    Now reset of the message list follows same rules when 
    executing inside stored procedures.

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-18 08:39:04 -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-18 08:39:04 -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-04-14 20:28:13 -03:00
+++ b/mysql-test/r/sp-error.result	2008-04-18 08:39:04 -03:00
@@ -1635,3 +1635,90 @@ 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;
+DROP PROCEDURE IF EXISTS p4;
+CREATE PROCEDURE p1()
+BEGIN
+DECLARE c INT DEFAULT 0;
+DECLARE CONTINUE HANDLER FOR SQLWARNING SET c = c + 1;
+CALL p2();
+CALL p3();
+CALL p4();
+SELECT c;
+SELECT @@warning_count;
+SHOW WARNINGS;
+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|
+CREATE PROCEDURE p4()
+BEGIN
+SELECT CAST('10 ' as unsigned integer);
+CALL p2();
+END|
+CALL p1();
+CAST('10 ' as unsigned integer)
+10
+CAST('10 ' as unsigned integer)
+10
+1
+1
+CAST('10 ' as unsigned integer)
+10
+CAST('10 ' as unsigned integer)
+10
+c
+2
+@@warning_count
+1
+Level	Code	Message
+Warning	1292	Truncated incorrect INTEGER value: '10 '
+DROP PROCEDURE p1;
+DROP PROCEDURE p2;
+DROP PROCEDURE p3;
+DROP PROCEDURE p4;
+DROP TABLE IF EXISTS t1;
+DROP PROCEDURE IF EXISTS p1;
+CREATE TABLE t1 (a INT, b INT NOT NULL);
+CREATE PROCEDURE p1()
+BEGIN
+DECLARE CONTINUE HANDLER FOR SQLWARNING SELECT 'warning';
+DECLARE CONTINUE HANDLER FOR SQLEXCEPTION SELECT 'exception';
+INSERT INTO T1 VALUES (CAST('10 ' AS SIGNED), NULL);
+END|
+CALL p1();
+exception
+exception
+DROP TABLE t1;
+DROP PROCEDURE p1;
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-18 08:39:04 -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
@@ -283,8 +279,6 @@ select f_bug22427();
 f_bug22427()
 1
 create table if not exists t1 select f_bug22427() as i;
-Warnings:
-Note	1050	Table 't1' already exists
 create table t1 select f_bug22427() as i;
 ERROR 42S01: Table 't1' already exists
 drop table t1;
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-18 08:39:05 -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;
 
 ---------------------------------------------------------------
@@ -671,8 +591,6 @@ alpha	abc
 CALL p1('alpha', 'abcdef');
 x	y
 alpha	abc
-Warnings:
-Warning	1265	Data truncated for column 'y' at row 1
 DROP PROCEDURE p1;
 
 ---------------------------------------------------------------
@@ -697,8 +615,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 +803,6 @@ var
 CALL p1(1929.003);
 var
 1929.00
-Warnings:
-Note	1265	Data truncated for column 'arg' at row 1
 DROP PROCEDURE p1;
 
 ---------------------------------------------------------------
@@ -903,8 +817,6 @@ END|
 SELECT f1(-2500);
 f1(-2500)
 0
-Warnings:
-Warning	1264	Out of range value for column 'arg' at row 1
 SET @@sql_mode = 'traditional';
 SELECT f1(-2500);
 ERROR 22003: Out of range value for column 'arg' at row 1
@@ -930,8 +842,6 @@ END|
 SELECT f1(8388699);
 f1(8388699)
 8388607
-Warnings:
-Warning	1264	Out of range value for column 'arg' at row 1
 SET @@sql_mode = 'traditional';
 SELECT f1(8388699);
 ERROR 22003: Out of range value for column 'arg' at row 1
@@ -966,8 +876,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;
 
@@ -1020,13 +928,9 @@ END|
 CALL p1('c');
 arg
 
-Warnings:
-Warning	1265	Data truncated for column 'arg' at row 1
 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-18 08:39:05 -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
@@ -1120,8 +1118,6 @@ end|
 select f9()|
 f9()
 6
-Warnings:
-Note	1051	Unknown table 't3'
 select f9() from t1 limit 1|
 f9()
 6
@@ -1162,8 +1158,6 @@ drop temporary table t3|
 select f12_1()|
 f12_1()
 3
-Warnings:
-Note	1051	Unknown table 't3'
 select f12_1() from t1 limit 1|
 f12_1()
 3
@@ -2115,12 +2109,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 +2374,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 +2793,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 +3215,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|
@@ -3745,6 +3722,7 @@ select 3|
 3
 3
 call bug12379_3()|
+bug12379()
 ERROR 23000: Duplicate entry 'X' for key 'PRIMARY'
 select 4|
 4
@@ -3841,9 +3819,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 +4657,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|
@@ -5501,13 +5472,9 @@ end|
 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()|
@@ -5560,13 +5527,9 @@ end|
 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
@@ -6122,8 +6085,6 @@ select bug20777(9223372036854775810) as 
 select bug20777(-9223372036854775808) as 'lower bounds signed bigint';
 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
@@ -6136,13 +6097,9 @@ upper bounds unsigned bigint
 select bug20777(18446744073709551616) as 'upper bounds unsigned bigint + 1';
 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',
@@ -6154,9 +6111,6 @@ bug20777(18446744073709551615) as '2**64
 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
@@ -6200,37 +6154,6 @@ END|
 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|
@@ -6323,22 +6246,13 @@ c1
 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;
@@ -6579,8 +6493,6 @@ t1	CREATE TABLE `t1` (
 DROP TABLE t1;
 
 CALL p1('text');
-Warnings:
-Warning	1264	Out of range value for column 'v' at row 1
 SHOW CREATE TABLE t1;
 Table	Create Table
 t1	CREATE TABLE `t1` (
@@ -6599,8 +6511,6 @@ t1	CREATE TABLE `t1` (
 DROP TABLE t1;
 
 CALL p2('text');
-Warnings:
-Warning	1366	Incorrect integer value: 'text' for column 'v' at row 1
 SHOW CREATE TABLE t1;
 Table	Create Table
 t1	CREATE TABLE `t1` (
diff -Nrup a/mysql-test/r/trigger.result b/mysql-test/r/trigger.result
--- a/mysql-test/r/trigger.result	2008-02-12 09:44:24 -02:00
+++ b/mysql-test/r/trigger.result	2008-04-18 08:39:05 -03:00
@@ -1422,8 +1422,6 @@ create table t2 (j int);
 insert into t2 values (1), (2);
 set @a:="";
 create table if not exists t1 select * from t2;
-Warnings:
-Note	1050	Table 't1' already exists
 select * from t1;
 i
 7
@@ -1436,8 +1434,6 @@ drop trigger t1_ai;
 create table t3 (isave int);
 create trigger t1_bi before insert on t1 for each row insert into t3 values (new.i);
 create table if not exists t1 select * from t2;
-Warnings:
-Note	1050	Table 't1' already exists
 select * from t1;
 i
 7
@@ -1625,8 +1621,6 @@ truncate t1;
 truncate t1_op_log;
 create table if not exists t1
 select NULL, "CREATE TABLE ... SELECT, inserting a new key";
-Warnings:
-Note	1050	Table 't1' already exists
 set @id=last_insert_id();
 select * from t1;
 id	operation
@@ -1638,8 +1632,6 @@ After INSERT, new=CREATE TABLE ... SELEC
 truncate t1_op_log;
 create table if not exists t1 replace
 select @id, "CREATE TABLE ... REPLACE SELECT, deleting a duplicate key";
-Warnings:
-Note	1050	Table 't1' already exists
 select * from t1;
 id	operation
 1	CREATE TABLE ... REPLACE SELECT, deleting a duplicate key
@@ -1820,8 +1812,6 @@ truncate t1;
 truncate t1_op_log;
 create table if not exists v1
 select NULL, "CREATE TABLE ... SELECT, inserting a new key";
-Warnings:
-Note	1050	Table 'v1' already exists
 set @id=last_insert_id();
 select * from t1;
 id	operation
@@ -1833,8 +1823,6 @@ After INSERT, new=CREATE TABLE ... SELEC
 truncate t1_op_log;
 create table if not exists v1 replace
 select @id, "CREATE TABLE ... REPLACE SELECT, deleting a duplicate key";
-Warnings:
-Note	1050	Table 'v1' already exists
 select * from t1;
 id	operation
 1	CREATE TABLE ... REPLACE SELECT, deleting a duplicate key
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-18 08:39:05 -03:00
@@ -341,13 +341,9 @@ use mysqltest;
 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;
@@ -387,13 +383,9 @@ ERROR HY000: View 'mysqltest.v2' referen
 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-18 08:39:05 -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
@@ -65,13 +59,8 @@ END|
 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.
+SHOW WARNINGS;
+Level	Code	Message
 Warning	1592	Statement is not safe to log in statement format.
 ---- Insert from trigger ----
 CREATE TRIGGER trig
@@ -89,13 +78,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,13 +135,8 @@ 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.
+SHOW WARNINGS;
+Level	Code	Message
 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);
@@ -214,9 +191,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/t/sp-error.test b/mysql-test/t/sp-error.test
--- a/mysql-test/t/sp-error.test	2008-04-14 20:28:13 -03:00
+++ b/mysql-test/t/sp-error.test	2008-04-18 08:39:05 -03:00
@@ -2420,6 +2420,110 @@ 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;
+DROP PROCEDURE IF EXISTS p4;
+--enable_warnings
+
+delimiter |;
+
+CREATE PROCEDURE p1()
+  BEGIN
+    DECLARE c INT DEFAULT 0;
+    DECLARE CONTINUE HANDLER FOR SQLWARNING SET c = c + 1;
+    CALL p2();
+    CALL p3();
+    CALL p4();
+    SELECT c;
+    SELECT @@warning_count;
+    SHOW WARNINGS;
+  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|
+
+CREATE PROCEDURE p4()
+  BEGIN
+    SELECT CAST('10 ' as unsigned integer);
+    CALL p2();
+  END|
+
+delimiter ;|
+
+CALL p1();
+
+DROP PROCEDURE p1;
+DROP PROCEDURE p2;
+DROP PROCEDURE p3;
+DROP PROCEDURE p4;
+
+#
+# Bug#36185: Incorrect precedence for warning and exception handlers
+#
+
+--disable_warnings
+DROP TABLE IF EXISTS t1;
+DROP PROCEDURE IF EXISTS p1;
+--enable_warnings
+
+CREATE TABLE t1 (a INT, b INT NOT NULL);
+
+delimiter |;
+
+CREATE PROCEDURE p1()
+BEGIN
+  DECLARE CONTINUE HANDLER FOR SQLWARNING SELECT 'warning';
+  DECLARE CONTINUE HANDLER FOR SQLEXCEPTION SELECT 'exception';
+  INSERT INTO T1 VALUES (CAST('10 ' AS SIGNED), NULL);
+END|
+
+delimiter ;|
+
+CALL p1();
+
+DROP TABLE t1;
+DROP PROCEDURE p1;
+
+#
 # BUG#NNNN: New bug synopsis
 #
 #--disable_warnings
diff -Nrup a/sql/mysqld.cc b/sql/mysqld.cc
--- a/sql/mysqld.cc	2008-04-16 04:53:13 -03:00
+++ b/sql/mysqld.cc	2008-04-18 08:39:05 -03:00
@@ -2929,10 +2929,6 @@ void my_message_sql(uint error, const ch
                         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_VOID_RETURN;
@@ -2964,19 +2960,6 @@ void my_message_sql(uint error, const ch
         thd->main_da.set_error_status(thd, error, str);
       }
       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_VOID_RETURN;
     }
 
     if (!thd->no_warnings_for_error && !thd->is_fatal_error)
diff -Nrup a/sql/sp_head.cc b/sql/sp_head.cc
--- a/sql/sp_head.cc	2008-04-08 12:37:10 -03:00
+++ b/sql/sp_head.cc	2008-04-18 08:39:06 -03:00
@@ -1027,6 +1027,72 @@ 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
+find_and_push_handler(THD *thd, sp_rcontext *ctx, uint *ip,
+                      sp_instr *instr, Query_arena *execute_arena,
+                      Query_arena *backup_arena)
+{
+  uint hf;
+
+  /* Fatal errors are not catchable. */
+  if (! ctx || thd->is_fatal_error)
+    return FALSE;
+
+  /* Precaution: ditch any previously found handler. */
+  ctx->clear_handler();
+
+  if (thd->is_error())
+    ctx->find_handler(thd, thd->main_da.sql_errno(),
+                      MYSQL_ERROR::WARN_LEVEL_ERROR);
+  else if (thd->total_warn_count)
+  {
+    MYSQL_ERROR *err;
+    List_iterator_fast<MYSQL_ERROR> it(thd->warn_list);
+    while ((err= it++))
+    {
+      if (err->level != MYSQL_ERROR::WARN_LEVEL_WARN)
+        continue;
+      if (ctx->find_handler(thd, err->code, err->level))
+        break;
+    }
+  }
+  else
+    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();
+    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.
   @todo
@@ -1170,7 +1236,6 @@ sp_head::execute(THD *thd)
   do
   {
     sp_instr *i;
-    uint hip;			// Handler ip
 
 #if defined(ENABLED_PROFILING)
     /*
@@ -1191,6 +1256,9 @@ sp_head::execute(THD *thd)
       break;
     }
 
+    /* Reset number of warnings for this query */
+    thd->total_warn_count= 0;
+
     DBUG_PRINT("execute", ("Instruction %u", ip));
 
     /* Don't change NOW() in FUNCTION or TRIGGER */
@@ -1238,30 +1306,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 (find_and_push_handler(thd, ctx, &ip, i, &execute_arena, &backup_arena))
+      err_status= FALSE;
   } while (!err_status && !thd->killed && !thd->is_fatal_error);
 
 #if defined(ENABLED_PROFILING)
@@ -2883,23 +2929,14 @@ 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)
   {
-    /*
-      Failed to evaluate the value, and a handler has been found. Reset the
-      variable to NULL.
-    */
+    /* Failed to evaluate the value. Reset the variable to NULL. */
 
     if (thd->spcont->set_variable(thd, m_offset, 0))
     {
       /* If this also failed, let's abort. */
-
-      sp_rcontext *spcont= thd->spcont;
-
-      thd->spcont= NULL;           /* Avoid handlers */
-      my_error(ER_OUT_OF_RESOURCES, MYF(0));
-      spcont->clear_handler();
-      thd->spcont= spcont;
+      my_error(ER_OUT_OF_RESOURCES, MYF(ME_FATALERROR));
     }
   }
 
@@ -3431,18 +3468,6 @@ sp_instr_copen::execute(THD *thd, uint *
     if (thd->stmt_arena->free_list)
       cleanup_items(thd->stmt_arena->free_list);
     thd->stmt_arena= old_arena;
-    /*
-      Work around the fact that errors in selects are not returned properly
-      (but instead converted into a warning), so if a condition handler
-      caught, we have lost the result code.
-    */
-    if (!res)
-    {
-      uint dummy1, dummy2;
-
-      if (thd->spcont->found_handler(&dummy1, &dummy2))
-        res= -1;
-    }
     /* TODO: Assert here that we either have an error or a cursor */
   }
   DBUG_RETURN(res);
@@ -3618,13 +3643,11 @@ sp_instr_set_case_expr::exec_core(THD *t
 {
   int res= thd->spcont->set_case_expr(thd, m_case_expr_id, &m_case_expr);
 
-  if (res &&
-      !thd->spcont->get_case_expr(m_case_expr_id) &&
-      thd->spcont->found_handler_here())
+  if (res && !thd->spcont->get_case_expr(m_case_expr_id))
   {
     /*
       Failed to evaluate the value, the case expression is still not
-      initialized, and a handler has been found. Set to NULL so we can continue.
+      initialized. Set to NULL so we can continue.
     */
 
     Item *null_item= new Item_null();
@@ -3633,13 +3656,7 @@ sp_instr_set_case_expr::exec_core(THD *t
         thd->spcont->set_case_expr(thd, m_case_expr_id, &null_item))
     {
       /* If this also failed, we have to abort. */
-
-      sp_rcontext *spcont= thd->spcont;
-
-      thd->spcont= NULL;           /* Avoid handlers */
-      my_error(ER_OUT_OF_RESOURCES, MYF(0));
-      spcont->clear_handler();
-      thd->spcont= spcont;
+      my_error(ER_OUT_OF_RESOURCES, MYF(ME_FATALERROR));
     }
   }
   else
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-18 08:39:06 -03:00
@@ -271,46 +271,6 @@ sp_rcontext::find_handler(THD *thd, uint
   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
 sp_rcontext::push_cursor(sp_lex_keeper *lex_keeper, sp_instr_cpush *i)
 {
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-18 08:39:06 -03:00
@@ -115,12 +115,6 @@ class sp_rcontext : public Sql_alloc
   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);
-
   // Returns handler type and sets *ip to location if one was found
   inline int
   found_handler(uint *ip, uint *fp)
@@ -130,13 +124,6 @@ class sp_rcontext : public Sql_alloc
     *ip= m_handler[m_hfound].handler;
     *fp= m_handler[m_hfound].foffset;
     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
diff -Nrup a/sql/sql_class.cc b/sql/sql_class.cc
--- a/sql/sql_class.cc	2008-04-16 04:53:13 -03:00
+++ b/sql/sql_class.cc	2008-04-18 08:39:06 -03:00
@@ -1539,16 +1539,13 @@ bool select_send::send_fields(List<Item>
 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))
+  if (is_result_set_started && thd->spcont)
   {
     /*
       We're executing a stored procedure, have an open result
-      set, an SQL exception condition and a handler for it.
-      In this situation we must abort the current statement,
-      silence the error and start executing the continue/exit
-      handler.
+      set and an SQL exception condition. In this situation we
+      must abort the current statement, silence the error and
+      start executing the continue/exit handler if one is found.
       Before aborting the statement, let's end the open result set, as
       otherwise the client will hang due to the violation of the
       client/server protocol.
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-18 08:39:06 -03:00
@@ -140,11 +140,6 @@ 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);
 
 
diff -Nrup a/sql/sql_parse.cc b/sql/sql_parse.cc
--- a/sql/sql_parse.cc	2008-04-16 04:53:13 -03:00
+++ b/sql/sql_parse.cc	2008-04-18 08:39:06 -03:00
@@ -1845,7 +1845,7 @@ mysql_execute_command(THD *thd)
     variables, but for now this is probably good enough.
     Don't reset warnings when executing a stored routine.
   */
-  if ((all_tables || !lex->is_single_level_stmt()) && !thd->spcont)
+  if (all_tables || !lex->is_single_level_stmt())
     mysql_reset_errors(thd, 0);
 
 #ifdef HAVE_REPLICATION
diff -Nrup a/sql/sql_prepare.cc b/sql/sql_prepare.cc
--- a/sql/sql_prepare.cc	2008-04-15 17:29:39 -03:00
+++ b/sql/sql_prepare.cc	2008-04-18 08:39:06 -03:00
@@ -1730,7 +1730,7 @@ static bool check_prepared_statement(Pre
                                                      get_table_list());
 
   /* Reset warning count for each query that uses tables */
-  if ((tables || !lex->is_single_level_stmt()) && !thd->spcont)
+  if (tables || !lex->is_single_level_stmt())
     mysql_reset_errors(thd, 0);
 
   switch (sql_command) {
Thread
bk commit into 6.0 tree (davi:1.2618) BUG#23032Davi Arnaut18 Apr
  • Re: bk commit into 6.0 tree (davi:1.2618) BUG#23032Konstantin Osipov20 Apr
    • Re: bk commit into 6.0 tree (davi:1.2618) BUG#23032Davi Arnaut21 Apr