List:Commits« Previous MessageNext Message »
From:Davi Arnaut Date:April 15 2008 5:25pm
Subject:bk commit into 6.0 tree (davi:1.2643) 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-15 14:25:01-03:00, davi@stripped +19 -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.

  mysql-test/r/partition.result@stripped, 2008-04-15 14:24:56-03:00, davi@stripped +4 -2
    Update test case result which reflects new rules for
    condition area cleaning inde stored procedures.

  mysql-test/r/sp-dynamic.result@stripped, 2008-04-15 14:24:56-03:00, davi@stripped +0 -8
    Update test case result which reflects new rules for
    condition area cleaning inde stored procedures.

  mysql-test/r/sp-error.result@stripped, 2008-04-15 14:24:56-03:00, davi@stripped +77 -0
    Add test case result for Bug#23032

  mysql-test/r/sp-prelocking.result@stripped, 2008-04-15 14:24:56-03:00, davi@stripped +0 -6
    Update test case result which reflects new rules for
    condition area cleaning inde stored procedures.

  mysql-test/r/sp-vars.result@stripped, 2008-04-15 14:24:56-03:00, davi@stripped +10 -21
    Update test case result which reflects new rules for
    condition area cleaning inde stored procedures.

  mysql-test/r/sp.result@stripped, 2008-04-15 14:24:56-03:00, davi@stripped +3 -62
    Update test case result which reflects new rules for
    condition area cleaning inde stored procedures.

  mysql-test/r/trigger.result@stripped, 2008-04-15 14:24:57-03:00, davi@stripped +0 -12
    Update test case result which reflects new rules for
    condition area cleaning inde stored procedures.

  mysql-test/r/view_grant.result@stripped, 2008-04-15 14:24:57-03:00, davi@stripped +0 -8
    Update test case result which reflects new rules for
    condition area cleaning inde stored procedures.

  mysql-test/suite/rpl/r/rpl_sp_effects.result@stripped, 2008-04-15 14:24:57-03:00, davi@stripped +0 -2
    Update test case result which reflects new rules for
    condition area cleaning inde stored procedures.

  mysql-test/t/partition.test@stripped, 2008-04-15 14:24:57-03:00, davi@stripped +2 -0
    Show that the message list is preserved.

  mysql-test/t/sp-error.test@stripped, 2008-04-15 14:24:57-03:00, davi@stripped +77 -0
    Add test case for Bug#23032

  mysql-test/t/sp-vars.test@stripped, 2008-04-15 14:24:57-03:00, davi@stripped +10 -0
    Show that the message list is preserved.

  mysql-test/t/sp.test@stripped, 2008-04-15 14:24:57-03:00, davi@stripped +2 -0
    Show that the message list is preserved.

  sql/mysqld.cc@stripped, 2008-04-15 14:24:57-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-15 14:24:58-03:00, davi@stripped +56 -84
    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.
    
    Remove redundant code now that search for a handler is
    done after execution, errors are always pushed.

  sql/sp_rcontext.cc@stripped, 2008-04-15 14:24:58-03:00, davi@stripped +27 -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-15 14:24:58-03:00, davi@stripped +5 -14
    Move find_handler as a private function add new method signature.

  sql/sql_class.cc@stripped, 2008-04-15 14:24:58-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-15 14:24:58-03:00, davi@stripped +1 -6
    Remove unnecessary casts and SP runtime context error handler.

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-15 14:24:56 -03:00
@@ -816,11 +816,13 @@ ROLLBACK to savepoint t1_save;
 COMMIT;
 END|
 CALL test.p1(12);
-Warnings:
+SHOW WARNINGS;
+Level	Code	Message
 Note	1051	Unknown table 't1'
 Warning	1196	Some non-transactional changed tables couldn't be rolled back
 CALL test.p1(13);
-Warnings:
+SHOW WARNINGS;
+Level	Code	Message
 Warning	1196	Some non-transactional changed tables couldn't be rolled back
 drop table t1;
 drop procedure test.p1;
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-15 14:24:56 -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 22:15:26 -03:00
+++ b/mysql-test/r/sp-error.result	2008-04-15 14:24:56 -03:00
@@ -1636,3 +1636,80 @@ 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 '
+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
+4
+Level	Code	Message
+Warning	1292	Truncated incorrect INTEGER value: '10 '
+Warning	1292	Truncated incorrect INTEGER value: '10 '
+Warning	1292	Truncated incorrect INTEGER value: '10 '
+Warning	1292	Truncated incorrect INTEGER value: '10 '
+DROP PROCEDURE p1;
+DROP PROCEDURE p2;
+DROP PROCEDURE p3;
+DROP PROCEDURE p4;
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-15 14:24:56 -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	2008-04-14 22:15:26 -03:00
+++ b/mysql-test/r/sp-vars.result	2008-04-15 14:24:56 -03:00
@@ -109,7 +109,8 @@ 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:
+SHOW WARNINGS;
+Level	Code	Message
 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
@@ -142,7 +143,8 @@ d1	d2	d3
 1234.00	1234.12	1234.12
 d1	d2	d3
 1234.00	1234.12	1234.12
-Warnings:
+SHOW WARNINGS;
+Level	Code	Message
 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
@@ -197,7 +199,8 @@ 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:
+SHOW WARNINGS;
+Level	Code	Message
 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
@@ -230,7 +233,8 @@ d1	d2	d3
 1234.00	1234.12	1234.12
 d1	d2	d3
 1234.00	1234.12	1234.12
-Warnings:
+SHOW WARNINGS;
+Level	Code	Message
 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
@@ -450,7 +454,8 @@ HEX(v9)
 FF
 HEX(v10)
 FF
-Warnings:
+SHOW WARNINGS;
+Level	Code	Message
 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
@@ -682,8 +687,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;
 
 ---------------------------------------------------------------
@@ -708,8 +711,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;
 
 ---------------------------------------------------------------
@@ -898,8 +899,6 @@ var
 CALL p1(1929.003);
 var
 1929.00
-Warnings:
-Note	1265	Data truncated for column 'arg' at row 1
 DROP PROCEDURE p1;
 
 ---------------------------------------------------------------
@@ -914,8 +913,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
@@ -941,8 +938,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
@@ -977,8 +972,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;
 
@@ -1031,13 +1024,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-04-14 22:15:26 -03:00
+++ b/mysql-test/r/sp.result	2008-04-15 14:24:56 -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|
@@ -3235,11 +3216,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|
@@ -3842,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` (
@@ -4284,7 +4258,7 @@ call bug14643_1()|
 Handler
 boo
 v	isnull(v)
-NULL	1
+0	0
 call bug14643_2()|
 Handler
 boo
@@ -4686,13 +4660,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|
@@ -5505,13 +5475,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()|
@@ -5564,13 +5530,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
@@ -6139,8 +6101,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
@@ -6153,13 +6113,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',
@@ -6171,9 +6127,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
@@ -6217,7 +6170,8 @@ END|
 SELECT bug5274_f2()|
 bug5274_f2()
 x
-Warnings:
+SHOW WARNINGS|
+Level	Code	Message
 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
@@ -6340,22 +6294,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;
@@ -6596,8 +6541,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` (
@@ -6616,8 +6559,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-04-14 22:15:26 -03:00
+++ b/mysql-test/r/trigger.result	2008-04-15 14:24:57 -03:00
@@ -1423,8 +1423,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
@@ -1437,8 +1435,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
@@ -1626,8 +1622,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
@@ -1639,8 +1633,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
@@ -1821,8 +1813,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
@@ -1834,8 +1824,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-15 14:24:57 -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/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-15 14:24:57 -03:00
@@ -253,8 +253,6 @@ sf_bug26199(b'1111111')
 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/partition.test b/mysql-test/t/partition.test
--- a/mysql-test/t/partition.test	2008-03-27 15:58:37 -03:00
+++ b/mysql-test/t/partition.test	2008-04-15 14:24:57 -03:00
@@ -985,7 +985,9 @@ BEGIN
 END|
 delimiter ;|
 CALL test.p1(12);
+SHOW WARNINGS;
 CALL test.p1(13);
+SHOW WARNINGS;
 drop table t1;
 drop procedure test.p1;
 
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-15 14:24:57 -03:00
@@ -2420,6 +2420,83 @@ 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#NNNN: New bug synopsis
 #
 #--disable_warnings
diff -Nrup a/mysql-test/t/sp-vars.test b/mysql-test/t/sp-vars.test
--- a/mysql-test/t/sp-vars.test	2007-05-18 09:28:00 -03:00
+++ b/mysql-test/t/sp-vars.test	2008-04-15 14:24:57 -03:00
@@ -40,8 +40,12 @@ SET @@sql_mode = 'ansi';
 
 CALL sp_vars_check_dflt();
 
+SHOW WARNINGS;
+
 CALL sp_vars_check_assignment();
 
+SHOW WARNINGS;
+
 SELECT sp_vars_check_ret1();
 
 SELECT sp_vars_check_ret2();
@@ -65,8 +69,12 @@ SET @@sql_mode = 'traditional';
 
 CALL sp_vars_check_dflt();
 
+SHOW WARNINGS;
+
 CALL sp_vars_check_assignment();
 
+SHOW WARNINGS;
+
 SELECT sp_vars_check_ret1();
 
 SELECT sp_vars_check_ret2();
@@ -190,6 +198,8 @@ END|
 delimiter ;|
 
 CALL p1();
+
+SHOW WARNINGS;
 
 #
 # Cleanup.
diff -Nrup a/mysql-test/t/sp.test b/mysql-test/t/sp.test
--- a/mysql-test/t/sp.test	2008-03-27 06:56:02 -03:00
+++ b/mysql-test/t/sp.test	2008-04-15 14:24:57 -03:00
@@ -7170,6 +7170,8 @@ END|
  
 SELECT bug5274_f2()|
 
+SHOW WARNINGS|
+
 # Cleanup.
 
 DROP FUNCTION bug5274_f1|
diff -Nrup a/sql/mysqld.cc b/sql/mysqld.cc
--- a/sql/mysqld.cc	2008-04-14 07:09:59 -03:00
+++ b/sql/mysqld.cc	2008-04-15 14:24:57 -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-15 14:24:58 -03:00
@@ -1026,6 +1026,53 @@ 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;
+
+  /* Ditch any previously found handler. */
+  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();
+    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,7 +1217,6 @@ sp_head::execute(THD *thd)
   do
   {
     sp_instr *i;
-    uint hip;			// Handler ip
 
 #if defined(ENABLED_PROFILING)
     /*
@@ -1191,6 +1237,9 @@ sp_head::execute(THD *thd)
       break;
     }
 
+    /* Reset the per instruction warning count. */
+    thd->main_da.reset_condition_area();
+
     DBUG_PRINT("execute", ("Instruction %u", ip));
 
     /* Don't change NOW() in FUNCTION or TRIGGER */
@@ -1238,30 +1287,9 @@ 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 && 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)
@@ -2882,28 +2910,8 @@ int
 sp_instr_set::exec_core(THD *thd, uint *nextp)
 {
   int res= thd->spcont->set_variable(thd, m_offset, &m_value);
-
-  if (res && thd->spcont->found_handler_here())
-  {
-    /*
-      Failed to evaluate the value, and a handler has been found. 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;
-    }
-  }
-
-  *nextp = m_ip+1;
+  if (! res)
+    *nextp = m_ip+1;
   return res;
 }
 
@@ -3431,18 +3439,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,31 +3614,7 @@ 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())
-  {
-    /*
-      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.
-    */
-
-    Item *null_item= new Item_null();
-
-    if (!null_item ||
-        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;
-    }
-  }
-  else
+  if (! res)
     *nextp= m_ip+1;
 
   return res;
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-15 14:24:58 -03:00
@@ -161,6 +161,33 @@ 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->main_da.partial_warn_count())
+  {
+    DBUG_ASSERT(! thd->main_da.warn_list.is_empty());
+    MYSQL_ERROR *err= thd->main_da.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 +296,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-15 14:24:58 -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-04-14 22:15:30 -03:00
+++ b/sql/sql_class.cc	2008-04-15 14:24:58 -03:00
@@ -1662,8 +1662,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-04-14 22:15:30 -03:00
+++ b/sql/sql_error.cc	2008-04-15 14:24:58 -03:00
@@ -82,7 +82,7 @@ MYSQL_ERROR *push_warning(THD *thd, MYSQ
     DBUG_RETURN(0);
 
   /* 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 */
@@ -104,11 +104,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);
 
   DBUG_RETURN(thd->main_da.push_warning(thd, level, code, msg));
Thread
bk commit into 6.0 tree (davi:1.2643) BUG#23032Davi Arnaut15 Apr