List:Commits« Previous MessageNext Message »
From:Alexander Nozdrin Date:October 26 2010 11:49am
Subject:bzr push into mysql-5.5-bugteam branch (alexander.nozdrin:3097 to 3098)
Bug#55850
View as plain text  
 3098 Alexander Nozdrin	2010-10-26
      Patch for Bug#55850 (Trigger warnings not cleared).
      
      The problem was that the warnings risen by a trigger were not cleared upon
      successful completion. The warnings should be cleared if the trigger completes
      successfully.
      
      The fix is to skip merging warnings into caller's Warning Info for triggers.

    modified:
      mysql-test/r/signal.result
      mysql-test/r/sp-error.result
      mysql-test/r/trigger.result
      mysql-test/suite/rpl/r/rpl_row_trig003.result
      mysql-test/t/sp-error.test
      sql/sp_head.cc
      sql/sp_head.h
 3097 Marc Alff	2010-10-26 [merge]
      local merge

    removed:
      mysql-test/suite/rpl/t/rpl_mixed_binlog_max_cache_size-master.opt
      mysql-test/suite/rpl/t/rpl_row_binlog_max_cache_size-master.opt
      mysql-test/suite/rpl/t/rpl_stm_binlog_max_cache_size-master.opt
      storage/innobase/handler/mysql_addons.cc
      storage/innobase/include/mysql_addons.h
      storage/innobase/mysql-test/
      storage/innobase/mysql-test/patches/
      storage/innobase/mysql-test/patches/README
      storage/innobase/mysql-test/patches/index_merge_innodb-explain.diff
      storage/innobase/mysql-test/patches/information_schema.diff
      storage/innobase/mysql-test/patches/innodb_change_buffering_basic.diff
      storage/innobase/mysql-test/patches/innodb_file_per_table.diff
      storage/innobase/mysql-test/patches/innodb_lock_wait_timeout.diff
      storage/innobase/mysql-test/patches/innodb_thread_concurrency_basic.diff
      storage/innobase/mysql-test/patches/partition_innodb.diff
    added:
      mysql-test/extra/rpl_tests/rpl_stop_slave.test
      mysql-test/include/have_plugin_interface.inc
      mysql-test/include/have_plugin_server.inc
      mysql-test/r/lowercase_table4.result
      mysql-test/r/plugin_auth_qa.result
      mysql-test/r/plugin_auth_qa_1.result
      mysql-test/r/plugin_auth_qa_2.result
      mysql-test/r/plugin_auth_qa_3.result
      mysql-test/r/plugin_load_option.result
      mysql-test/suite/innodb/r/innodb-truncate.result
      mysql-test/suite/innodb/r/innodb_bug56143.result
      mysql-test/suite/innodb/r/innodb_bug56632.result
      mysql-test/suite/innodb/r/innodb_bug56680.result
      mysql-test/suite/innodb/r/innodb_bug57252.result
      mysql-test/suite/innodb/t/innodb-truncate.test
      mysql-test/suite/innodb/t/innodb_bug56143.test
      mysql-test/suite/innodb/t/innodb_bug56632.test
      mysql-test/suite/innodb/t/innodb_bug56680.test
      mysql-test/suite/innodb/t/innodb_bug57252.test
      mysql-test/suite/rpl/r/rpl_stop_slave.result
      mysql-test/suite/rpl/t/rpl_stop_slave.test
      mysql-test/t/lowercase_table4-master.opt
      mysql-test/t/lowercase_table4.test
      mysql-test/t/plugin_auth_qa-master.opt
      mysql-test/t/plugin_auth_qa.test
      mysql-test/t/plugin_auth_qa_1-master.opt
      mysql-test/t/plugin_auth_qa_1.test
      mysql-test/t/plugin_auth_qa_2-master.opt
      mysql-test/t/plugin_auth_qa_2.test
      mysql-test/t/plugin_auth_qa_3-master.opt
      mysql-test/t/plugin_auth_qa_3.test
      mysql-test/t/plugin_load_option-master.opt
      mysql-test/t/plugin_load_option.test
      plugin/auth/qa_auth_client.c
      plugin/auth/qa_auth_interface.c
      plugin/auth/qa_auth_server.c
    renamed:
      config/ac-macros/ha_ndbcluster.m4 => storage/ndb/ndb_configure.m4
    modified:
      BUILD/SETUP.sh
      CMakeLists.txt
      Makefile.am
      client/mysql.cc
      client/mysqlcheck.c
      client/mysqltest.cc
      client/sql_string.h
      cmake/abi_check.cmake
      cmake/build_configurations/mysql_release.cmake
      cmake/install_layout.cmake
      cmake/os/Linux.cmake
      cmd-line-utils/libedit/common.c
      cmd-line-utils/libedit/readline.c
      cmd-line-utils/libedit/vi.c
      cmd-line-utils/readline/complete.c
      cmd-line-utils/readline/histexpand.c
      cmd-line-utils/readline/histfile.c
      cmd-line-utils/readline/isearch.c
      cmd-line-utils/readline/parens.c
      cmd-line-utils/readline/readline.c
      cmd-line-utils/readline/terminal.c
      cmd-line-utils/readline/text.c
      config/ac-macros/maintainer.m4
      configure.cmake
      configure.in
      dbug/dbug.c
      include/my_compiler.h
      include/my_dbug.h
      include/my_getopt.h
      include/my_pthread.h
      include/mysql/client_plugin.h
      include/mysql/client_plugin.h.pp
      mysql-test/collections/default.experimental
      mysql-test/extra/binlog_tests/implicit.test
      mysql-test/extra/rpl_tests/create_recursive_construct.inc
      mysql-test/extra/rpl_tests/rpl_binlog_max_cache_size.test
      mysql-test/extra/rpl_tests/rpl_get_master_version_and_clock.test
      mysql-test/extra/rpl_tests/rpl_loaddata.test
      mysql-test/extra/rpl_tests/rpl_row_sp003.test
      mysql-test/extra/rpl_tests/rpl_start_stop_slave.test
      mysql-test/include/check_concurrent_insert.inc
      mysql-test/include/check_no_concurrent_insert.inc
      mysql-test/include/get_relay_log_pos.inc
      mysql-test/include/index_merge2.inc
      mysql-test/include/kill_query.inc
      mysql-test/include/kill_query_and_diff_master_slave.inc
      mysql-test/include/mtr_warnings.sql
      mysql-test/include/setup_fake_relay_log.inc
      mysql-test/include/show_events.inc
      mysql-test/include/show_rpl_debug_info.inc
      mysql-test/include/wait_for_slave_io_error.inc
      mysql-test/include/wait_for_slave_param.inc
      mysql-test/include/wait_for_slave_sql_error.inc
      mysql-test/include/wait_for_status_var.inc
      mysql-test/lib/mtr_misc.pl
      mysql-test/lib/mtr_process.pl
      mysql-test/mysql-test-run.pl
      mysql-test/r/cache_innodb.result
      mysql-test/r/delete.result
      mysql-test/r/func_math.result
      mysql-test/r/func_time.result
      mysql-test/r/grant.result
      mysql-test/r/grant3.result
      mysql-test/r/index_merge_myisam.result
      mysql-test/r/information_schema.result
      mysql-test/r/ipv4_as_ipv6.result
      mysql-test/r/lock_sync.result
      mysql-test/r/mdl_sync.result
      mysql-test/r/merge.result
      mysql-test/r/mysqlcheck.result
      mysql-test/r/query_cache_debug.result
      mysql-test/r/select.result
      mysql-test/r/sp-security.result
      mysql-test/r/sp_trans.result
      mysql-test/r/trigger-trans.result
      mysql-test/r/type_datetime.result
      mysql-test/suite/binlog/t/binlog_unsafe.test
      mysql-test/suite/funcs_1/r/innodb_storedproc_06.result
      mysql-test/suite/funcs_1/r/is_columns_is.result
      mysql-test/suite/funcs_1/r/memory_storedproc_06.result
      mysql-test/suite/funcs_1/r/myisam_storedproc_06.result
      mysql-test/suite/funcs_1/storedproc/storedproc_06.inc
      mysql-test/suite/innodb/r/innodb-index.result
      mysql-test/suite/innodb/r/innodb-zip.result
      mysql-test/suite/innodb/r/innodb.result
      mysql-test/suite/innodb/r/innodb_bug52745.result
      mysql-test/suite/innodb/r/innodb_bug53591.result
      mysql-test/suite/innodb/r/innodb_file_format.result
      mysql-test/suite/innodb/r/innodb_mysql.result
      mysql-test/suite/innodb/t/innodb.test
      mysql-test/suite/innodb/t/innodb_mysql.test
      mysql-test/suite/parts/inc/partition_check.inc
      mysql-test/suite/parts/r/partition_alter3_innodb.result
      mysql-test/suite/parts/r/partition_basic_innodb.result
      mysql-test/suite/rpl/r/rpl_do_grant.result
      mysql-test/suite/rpl/r/rpl_heartbeat.result
      mysql-test/suite/rpl/r/rpl_heartbeat_basic.result
      mysql-test/suite/rpl/r/rpl_mixed_binlog_max_cache_size.result
      mysql-test/suite/rpl/r/rpl_row_binlog_max_cache_size.result
      mysql-test/suite/rpl/r/rpl_row_sp003.result
      mysql-test/suite/rpl/r/rpl_stm_binlog_max_cache_size.result
      mysql-test/suite/rpl/r/rpl_stm_start_stop_slave.result
      mysql-test/suite/rpl/r/rpl_temp_table_mix_row.result
      mysql-test/suite/rpl/t/rpl_do_grant.test
      mysql-test/suite/rpl/t/rpl_killed_ddl.test
      mysql-test/suite/rpl/t/rpl_temp_table_mix_row.test
      mysql-test/suite/sys_vars/r/all_vars.result
      mysql-test/suite/sys_vars/r/foreign_key_checks_func.result
      mysql-test/suite/sys_vars/r/innodb_file_format_basic.result
      mysql-test/suite/sys_vars/t/all_vars.test
      mysql-test/suite/sys_vars/t/foreign_key_checks_func.test
      mysql-test/t/cache_innodb.test
      mysql-test/t/delete.test
      mysql-test/t/disabled.def
      mysql-test/t/func_math.test
      mysql-test/t/func_time.test
      mysql-test/t/grant.test
      mysql-test/t/grant3.test
      mysql-test/t/information_schema.test
      mysql-test/t/lock_sync.test
      mysql-test/t/mdl_sync.test
      mysql-test/t/merge.test
      mysql-test/t/mysqlcheck.test
      mysql-test/t/mysqltest.test
      mysql-test/t/query_cache_debug.test
      mysql-test/t/select.test
      mysql-test/t/sp-security.test
      mysql-test/t/sp_trans.test
      mysql-test/t/trigger-trans.test
      mysql-test/t/type_datetime.test
      mysql-test/t/wait_timeout.test
      mysys/my_gethostbyname.c
      mysys/my_gethwaddr.c
      mysys/my_getopt.c
      mysys/my_sync.c
      mysys/thr_mutex.c
      plugin/auth/CMakeLists.txt
      plugin/auth/Makefile.am
      plugin/auth/dialog.c
      regex/main.c
      sql-common/client.c
      sql/field.cc
      sql/ha_ndbcluster.cc
      sql/ha_partition.cc
      sql/ha_partition.h
      sql/handler.cc
      sql/handler.h
      sql/item.cc
      sql/item_func.cc
      sql/item_strfunc.cc
      sql/item_timefunc.cc
      sql/item_timefunc.h
      sql/key.cc
      sql/log.cc
      sql/log_event.cc
      sql/log_event.h
      sql/my_decimal.h
      sql/mysqld.cc
      sql/repl_failsafe.cc
      sql/repl_failsafe.h
      sql/rpl_rli.h
      sql/scheduler.h
      sql/share/errmsg-utf8.txt
      sql/slave.cc
      sql/sp.cc
      sql/sp.h
      sql/sp_head.cc
      sql/sql_acl.cc
      sql/sql_base.cc
      sql/sql_cache.cc
      sql/sql_class.cc
      sql/sql_class.h
      sql/sql_delete.cc
      sql/sql_help.cc
      sql/sql_insert.cc
      sql/sql_lex.h
      sql/sql_parse.cc
      sql/sql_partition.cc
      sql/sql_partition_admin.cc
      sql/sql_partition_admin.h
      sql/sql_plugin.cc
      sql/sql_plugin.h
      sql/sql_show.cc
      sql/sql_show.h
      sql/sql_string.h
      sql/sql_truncate.cc
      sql/sql_truncate.h
      sql/sql_union.cc
      sql/sql_update.cc
      sql/sql_update.h
      sql/sql_yacc.yy
      sql/sys_vars.cc
      sql/sys_vars.h
      sql/table.h
      storage/archive/ha_archive.cc
      storage/archive/ha_archive.h
      storage/blackhole/ha_blackhole.cc
      storage/blackhole/ha_blackhole.h
      storage/example/ha_example.cc
      storage/example/ha_example.h
      storage/federated/ha_federated.cc
      storage/federated/ha_federated.h
      storage/heap/ha_heap.cc
      storage/heap/ha_heap.h
      storage/ibmdb2i/db2i_constraints.cc
      storage/ibmdb2i/ha_ibmdb2i.cc
      storage/innobase/CMakeLists.txt
      storage/innobase/Makefile.am
      storage/innobase/btr/btr0cur.c
      storage/innobase/buf/buf0buddy.c
      storage/innobase/buf/buf0buf.c
      storage/innobase/buf/buf0flu.c
      storage/innobase/buf/buf0lru.c
      storage/innobase/handler/ha_innodb.cc
      storage/innobase/handler/ha_innodb.h
      storage/innobase/ibuf/ibuf0ibuf.c
      storage/innobase/include/btr0cur.h
      storage/innobase/include/buf0buddy.h
      storage/innobase/include/buf0buddy.ic
      storage/innobase/include/buf0buf.h
      storage/innobase/include/buf0flu.h
      storage/innobase/include/data0type.h
      storage/innobase/include/ibuf0ibuf.h
      storage/innobase/include/os0sync.h
      storage/innobase/include/rem0rec.h
      storage/innobase/include/row0mysql.h
      storage/innobase/include/row0row.h
      storage/innobase/include/row0upd.h
      storage/innobase/include/srv0srv.h
      storage/innobase/include/trx0trx.h
      storage/innobase/lock/lock0lock.c
      storage/innobase/log/log0log.c
      storage/innobase/os/os0file.c
      storage/innobase/os/os0sync.c
      storage/innobase/plug.in
      storage/innobase/rem/rem0rec.c
      storage/innobase/row/row0mysql.c
      storage/innobase/row/row0sel.c
      storage/innobase/row/row0upd.c
      storage/innobase/srv/srv0srv.c
      storage/innobase/srv/srv0start.c
      storage/innobase/sync/sync0sync.c
      storage/innobase/trx/trx0i_s.c
      storage/innobase/trx/trx0trx.c
      storage/myisam/ha_myisam.cc
      storage/myisam/ha_myisam.h
      storage/myisam/myisamchk.c
      storage/myisammrg/ha_myisammrg.cc
      storage/myisammrg/ha_myisammrg.h
      storage/ndb/plug.in
      storage/perfschema/ha_perfschema.cc
      storage/perfschema/ha_perfschema.h
      strings/ctype-ucs2.c
      strings/my_vsnprintf.c
      unittest/examples/skip-t.c
      unittest/examples/skip_all-t.c
      unittest/examples/todo-t.c
      unittest/mytap/t/basic-t.c
      unittest/mytap/tap.c
      unittest/mytap/tap.h
      storage/ndb/ndb_configure.m4
=== modified file 'mysql-test/r/signal.result'
--- a/mysql-test/r/signal.result	2010-07-30 15:28:36 +0000
+++ b/mysql-test/r/signal.result	2010-10-26 11:48:08 +0000
@@ -1379,9 +1379,6 @@ MESSAGE_TEXT = msg,
 MYSQL_ERRNO = 1012;
 end $$
 insert into t1 values (1), (2) $$
-Warnings:
-Warning	1012	This trigger SIGNAL a warning, a=1
-Warning	1012	This trigger SIGNAL a warning, a=2
 drop trigger t1_ai $$
 create trigger t1_ai after insert on t1 for each row
 begin
@@ -1416,11 +1413,7 @@ MESSAGE_TEXT = NEW.msg,
 MYSQL_ERRNO = NEW.errno;
 end $$
 insert into t1 set errno=1012, msg='Warning message 1 in trigger' $$
-Warnings:
-Warning	1012	Warning message 1 in trigger
 insert into t1 set errno=1013, msg='Warning message 2 in trigger' $$
-Warnings:
-Warning	1013	Warning message 2 in trigger
 drop table t1 $$
 drop table if exists t1 $$
 drop procedure if exists p1 $$

=== modified file 'mysql-test/r/sp-error.result'
--- a/mysql-test/r/sp-error.result	2010-07-30 15:28:36 +0000
+++ b/mysql-test/r/sp-error.result	2010-10-26 11:48:08 +0000
@@ -1877,9 +1877,6 @@ DROP PROCEDURE p1;
 #
 # Bug#5889: Exit handler for a warning doesn't hide the warning in trigger
 #
-
-# - Case 1
-
 CREATE TABLE t1(a INT, b INT);
 INSERT INTO t1 VALUES (1, 2);
 CREATE TRIGGER t1_bu BEFORE UPDATE ON t1 FOR EACH ROW
@@ -1889,40 +1886,13 @@ SET NEW.a = 10;
 SET NEW.a = 99999999999;
 END|
 UPDATE t1 SET b = 20;
-Warnings:
-Warning	1264	Out of range value for column 'a' at row 1
 SHOW WARNINGS;
 Level	Code	Message
-Warning	1264	Out of range value for column 'a' at row 1
 SELECT * FROM t1;
 a	b
 10	20
 DROP TRIGGER t1_bu;
 DROP TABLE t1;
-
-# - Case 2
-
-CREATE TABLE t1(a INT);
-CREATE TABLE t2(b CHAR(1));
-CREATE TRIGGER t1_bi BEFORE INSERT ON t1 FOR EACH ROW
-BEGIN
-INSERT INTO t2 VALUES('ab'); # Produces a warning.
-INSERT INTO t2 VALUES('b');  # Does not produce a warning,
-# previous warning should be cleared.
-END|
-INSERT INTO t1 VALUES(0);
-SHOW WARNINGS;
-Level	Code	Message
-SELECT * FROM t1;
-a
-0
-SELECT * FROM t2;
-b
-a
-b
-DROP TRIGGER t1_bi;
-DROP TABLE t1;
-DROP TABLE t2;
 #
 # Bug#9857: Stored procedures: handler for sqlwarning ignored
 #
@@ -1961,3 +1931,64 @@ Warning	1365	Division by 0
 DROP PROCEDURE p1;
 DROP PROCEDURE p2;
 SET sql_mode = @sql_mode_saved;
+#
+# Bug#55850: Trigger warnings not cleared.
+#
+DROP TABLE IF EXISTS t1;
+DROP TABLE IF EXISTS t2;
+DROP PROCEDURE IF EXISTS p1;
+CREATE TABLE t1(x SMALLINT, y SMALLINT, z SMALLINT);
+CREATE TABLE t2(a SMALLINT, b SMALLINT, c SMALLINT,
+d SMALLINT, e SMALLINT, f SMALLINT);
+CREATE TRIGGER t1_bi BEFORE INSERT ON t1 FOR EACH ROW
+INSERT INTO t2(a, b, c) VALUES(99999, 99999, 99999);
+CREATE TRIGGER t1_ai AFTER INSERT ON t1 FOR EACH ROW
+INSERT INTO t2(d, e, f) VALUES(99999, 99999, 99999);
+CREATE PROCEDURE p1()
+INSERT INTO t1 VALUES(99999, 99999, 99999);
+
+CALL p1();
+Warnings:
+Warning	1264	Out of range value for column 'x' at row 1
+Warning	1264	Out of range value for column 'y' at row 1
+Warning	1264	Out of range value for column 'z' at row 1
+
+SHOW WARNINGS;
+Level	Code	Message
+Warning	1264	Out of range value for column 'x' at row 1
+Warning	1264	Out of range value for column 'y' at row 1
+Warning	1264	Out of range value for column 'z' at row 1
+
+DROP TABLE t1;
+DROP TABLE t2;
+DROP PROCEDURE p1;
+# ----------------------------------------------------------------------
+CREATE TABLE t1(x SMALLINT, y SMALLINT, z SMALLINT);
+CREATE TABLE t2(a SMALLINT, b SMALLINT, c SMALLINT NOT NULL);
+CREATE TRIGGER t1_bi BEFORE INSERT ON t1 FOR EACH ROW
+BEGIN
+INSERT INTO t2 VALUES(
+CAST('111111 ' AS SIGNED),
+CAST('222222 ' AS SIGNED),
+NULL);
+END|
+CREATE PROCEDURE p1()
+INSERT INTO t1 VALUES(99999, 99999, 99999);
+
+CALL p1();
+ERROR 23000: Column 'c' cannot be null
+
+SHOW WARNINGS;
+Level	Code	Message
+Warning	1264	Out of range value for column 'x' at row 1
+Warning	1264	Out of range value for column 'y' at row 1
+Warning	1264	Out of range value for column 'z' at row 1
+Warning	1292	Truncated incorrect INTEGER value: '111111 '
+Warning	1264	Out of range value for column 'a' at row 1
+Warning	1292	Truncated incorrect INTEGER value: '222222 '
+Warning	1264	Out of range value for column 'b' at row 1
+Error	1048	Column 'c' cannot be null
+
+DROP TABLE t1;
+DROP TABLE t2;
+DROP PROCEDURE p1;

=== modified file 'mysql-test/r/trigger.result'
--- a/mysql-test/r/trigger.result	2010-08-25 10:22:34 +0000
+++ b/mysql-test/r/trigger.result	2010-10-26 11:48:08 +0000
@@ -1072,8 +1072,6 @@ SELECT @x;
 NULL
 SET @x=2;
 UPDATE t1 SET i1 = @x;
-Warnings:
-Warning	1365	Division by 0
 SELECT @x;
 @x
 NULL
@@ -1085,9 +1083,6 @@ SELECT @x;
 NULL
 SET @x=4;
 UPDATE t1 SET i1 = @x;
-Warnings:
-Warning	1365	Division by 0
-Warning	1365	Division by 0
 SELECT @x;
 @x
 NULL
@@ -1198,8 +1193,6 @@ Warnings:
 Warning	1365	Division by 0
 create trigger t1_bi before insert on t1 for each row set @a:=1/0|
 insert into t1 values(20, 20)|
-Warnings:
-Warning	1365	Division by 0
 drop trigger t1_bi|
 create trigger t1_bi before insert on t1 for each row
 begin
@@ -1218,8 +1211,6 @@ set @a:=1/0;
 end|
 set @check=0, @t4_bi_called=0, @t4_bu_called=0|
 insert into t1 values(30, 30)|
-Warnings:
-Warning	1365	Division by 0
 select @check, @t4_bi_called, @t4_bu_called|
 @check	@t4_bi_called	@t4_bu_called
 2	1	1
@@ -2090,12 +2081,8 @@ SELECT 1 FROM t1 c WHERE
 END//
 SET @bug51650 = 1;
 INSERT IGNORE INTO t2 VALUES();
-Warnings:
-Warning	1329	No data - zero rows fetched, selected, or processed
 INSERT IGNORE INTO t1 SET b = '777';
 INSERT IGNORE INTO t2 SET a = '111';
-Warnings:
-Warning	1329	No data - zero rows fetched, selected, or processed
 SET @bug51650 = 1;
 INSERT IGNORE INTO t2 SET a = '777';
 DROP TRIGGER trg1;
@@ -2177,8 +2164,6 @@ SELECT 'ab' INTO a;
 SELECT 'a' INTO a;
 END|
 INSERT INTO t1 VALUES (1);
-Warnings:
-Warning	1265	Data truncated for column 'a' at row 1
 DROP TRIGGER trg1;
 DROP TABLE t1;
 DROP TRIGGER IF EXISTS trg1;
@@ -2196,20 +2181,12 @@ DECLARE trg2 CHAR;
 SELECT 'ab' INTO trg2;
 END|
 INSERT INTO t1 VALUES (0);
-Warnings:
-Warning	1265	Data truncated for column 'trg1' at row 1
-Warning	1265	Data truncated for column 'trg2' at row 1
 SELECT * FROM t1;
 a
 0
 SHOW WARNINGS;
 Level	Code	Message
 INSERT INTO t1 VALUES (1),(2);
-Warnings:
-Warning	1265	Data truncated for column 'trg1' at row 1
-Warning	1265	Data truncated for column 'trg2' at row 1
-Warning	1265	Data truncated for column 'trg1' at row 1
-Warning	1265	Data truncated for column 'trg2' at row 1
 DROP TRIGGER trg1;
 DROP TRIGGER trg2;
 DROP TABLE t1;

=== modified file 'mysql-test/suite/rpl/r/rpl_row_trig003.result'
--- a/mysql-test/suite/rpl/r/rpl_row_trig003.result	2010-07-30 15:28:36 +0000
+++ b/mysql-test/suite/rpl/r/rpl_row_trig003.result	2010-10-26 11:48:08 +0000
@@ -69,15 +69,9 @@ INSERT INTO test.t2 VALUES(NULL,0,'Testi
 UPDATE test.t1 SET b1 = 0 WHERE b1 = 1;
 INSERT INTO test.t2 VALUES(NULL,1,'This is an after update test.', 'If this works, total will not be zero on the master or slave',1.4321,5.221,0,YEAR(NOW()),NOW());
 UPDATE test.t2 SET b1 = 0 WHERE b1 = 1;
-Warnings:
-Error	1329	No data - zero rows fetched, selected, or processed
 INSERT INTO test.t1 VALUES(NULL,1,'add some more test data test.', 'and hope for the best', 3.321,5.221,0,YEAR(NOW()),NOW());
 DELETE FROM test.t1 WHERE id = 1;
-Warnings:
-Error	1329	No data - zero rows fetched, selected, or processed
 DELETE FROM test.t2 WHERE id = 1;
-Warnings:
-Error	1329	No data - zero rows fetched, selected, or processed
 DROP TRIGGER test.t1_bi;
 DROP TRIGGER test.t2_ai;
 DROP TRIGGER test.t1_bu;

=== modified file 'mysql-test/t/sp-error.test'
--- a/mysql-test/t/sp-error.test	2010-07-30 15:28:36 +0000
+++ b/mysql-test/t/sp-error.test	2010-10-26 11:48:08 +0000
@@ -2719,10 +2719,6 @@ DROP PROCEDURE p1;
 --echo # Bug#5889: Exit handler for a warning doesn't hide the warning in trigger
 --echo #
 
---echo
---echo # - Case 1
---echo
-
 CREATE TABLE t1(a INT, b INT);
 INSERT INTO t1 VALUES (1, 2);
 
@@ -2747,36 +2743,6 @@ SELECT * FROM t1;
 DROP TRIGGER t1_bu;
 DROP TABLE t1;
 
---echo
---echo # - Case 2
---echo
-
-CREATE TABLE t1(a INT);
-CREATE TABLE t2(b CHAR(1));
-
-delimiter |;
-
-CREATE TRIGGER t1_bi BEFORE INSERT ON t1 FOR EACH ROW
-BEGIN
-  INSERT INTO t2 VALUES('ab'); # Produces a warning.
-
-  INSERT INTO t2 VALUES('b');  # Does not produce a warning,
-                               # previous warning should be cleared.
-END|
-
-delimiter ;|
-
-INSERT INTO t1 VALUES(0);
-
-SHOW WARNINGS;
-
-SELECT * FROM t1;
-SELECT * FROM t2;
-
-DROP TRIGGER t1_bi;
-DROP TABLE t1;
-DROP TABLE t2;
-
 --echo #
 --echo # Bug#9857: Stored procedures: handler for sqlwarning ignored
 --echo #
@@ -2813,3 +2779,83 @@ SHOW WARNINGS;
 DROP PROCEDURE p1;
 DROP PROCEDURE p2;
 SET sql_mode = @sql_mode_saved;
+
+--echo #
+--echo # Bug#55850: Trigger warnings not cleared.
+--echo #
+
+--disable_warnings
+DROP TABLE IF EXISTS t1;
+DROP TABLE IF EXISTS t2;
+DROP PROCEDURE IF EXISTS p1;
+--enable_warnings
+
+CREATE TABLE t1(x SMALLINT, y SMALLINT, z SMALLINT);
+CREATE TABLE t2(a SMALLINT, b SMALLINT, c SMALLINT,
+                d SMALLINT, e SMALLINT, f SMALLINT);
+
+CREATE TRIGGER t1_bi BEFORE INSERT ON t1 FOR EACH ROW
+  INSERT INTO t2(a, b, c) VALUES(99999, 99999, 99999);
+
+CREATE TRIGGER t1_ai AFTER INSERT ON t1 FOR EACH ROW
+  INSERT INTO t2(d, e, f) VALUES(99999, 99999, 99999);
+
+CREATE PROCEDURE p1()
+  INSERT INTO t1 VALUES(99999, 99999, 99999);
+
+# What happened before the patch was:
+#  - INSERT INTO t1 added 3 warnings about overflow in 'x', 'y' and 'z' columns;
+#  - t1_bi run and added 3 warnings about overflow in 'a', 'b' and 'c' columns;
+#  - t1_ai run and added 3 warnings about overflow in 'd', 'e' and 'f' columns;
+# => we had 9 warnings.
+#
+# Now what happens is:
+#  - INSERT INTO t1 adds 3 warnings about overflow in 'x', 'y' and 'z' columns;
+#  - t1_bi adds 3 warnings about overflow in 'a', 'b' and 'c' columns;
+#  - The warnings added by triggers are cleared;
+#  - t1_ai run and added 3 warnings about overflow in 'd', 'e' and 'f' columns;
+#  - The warnings added by triggers are cleared;
+# => we have 3 warnings.
+
+--echo
+CALL p1();
+
+--echo
+SHOW WARNINGS;
+
+--echo
+DROP TABLE t1;
+DROP TABLE t2;
+DROP PROCEDURE p1;
+
+--echo # ----------------------------------------------------------------------
+
+CREATE TABLE t1(x SMALLINT, y SMALLINT, z SMALLINT);
+CREATE TABLE t2(a SMALLINT, b SMALLINT, c SMALLINT NOT NULL);
+
+delimiter |;
+
+CREATE TRIGGER t1_bi BEFORE INSERT ON t1 FOR EACH ROW
+BEGIN
+  INSERT INTO t2 VALUES(
+    CAST('111111 ' AS SIGNED),
+    CAST('222222 ' AS SIGNED),
+    NULL);
+END|
+
+delimiter ;|
+
+CREATE PROCEDURE p1()
+  INSERT INTO t1 VALUES(99999, 99999, 99999);
+
+--echo
+--error ER_BAD_NULL_ERROR
+CALL p1();
+
+--echo
+SHOW WARNINGS;
+
+--echo
+DROP TABLE t1;
+DROP TABLE t2;
+DROP PROCEDURE p1;

=== modified file 'sql/sp_head.cc'
--- a/sql/sp_head.cc	2010-10-21 08:41:13 +0000
+++ b/sql/sp_head.cc	2010-10-26 11:48:08 +0000
@@ -1176,10 +1176,17 @@ find_handler_after_execution(THD *thd, s
 /**
   Execute the routine. The main instruction jump loop is there.
   Assume the parameters already set.
+
+  @param thd                  Thread context.
+  @param merge_da_on_success  Flag specifying if Warning Info should be
+                              propagated to the caller on Completion
+                              Condition or not.
+
   @todo
     - Will write this SP statement into binlog separately
     (TODO: consider changing the condition to "not inside event union")
 
+  @return Error status.
   @retval
     FALSE  on success
   @retval
@@ -1187,7 +1194,7 @@ find_handler_after_execution(THD *thd, s
 */
 
 bool
-sp_head::execute(THD *thd)
+sp_head::execute(THD *thd, bool merge_da_on_success)
 {
   DBUG_ENTER("sp_head::execute");
   char saved_cur_db_name_buf[NAME_LEN+1];
@@ -1481,8 +1488,15 @@ sp_head::execute(THD *thd)
   thd->stmt_arena= old_arena;
   state= EXECUTED;
 
-  /* Restore the caller's original warning information area. */
-  saved_warning_info->merge_with_routine_info(thd, thd->warning_info);
+  /*
+    Restore the caller's original warning information area:
+      - warnings generated during trigger execution should not be
+        propagated to the caller on success;
+      - if there was an exception during execution, warning info should be
+        propagated to the caller in any case.
+  */
+  if (err_status || merge_da_on_success)
+    saved_warning_info->merge_with_routine_info(thd, thd->warning_info);
   thd->warning_info= saved_warning_info;
 
  done:
@@ -1704,7 +1718,7 @@ sp_head::execute_trigger(THD *thd,
 
   thd->spcont= nctx;
 
-  err_status= execute(thd);
+  err_status= execute(thd, FALSE);
 
 err_with_cleanup:
   thd->restore_active_arena(&call_arena, &backup_arena);
@@ -1921,7 +1935,7 @@ sp_head::execute_function(THD *thd, Item
   */
   thd->set_n_backup_active_arena(&call_arena, &backup_arena);
 
-  err_status= execute(thd);
+  err_status= execute(thd, TRUE);
 
   thd->restore_active_arena(&call_arena, &backup_arena);
 
@@ -2154,7 +2168,7 @@ sp_head::execute_procedure(THD *thd, Lis
 #endif
 
   if (!err_status)
-    err_status= execute(thd);
+    err_status= execute(thd, TRUE);
 
   if (save_log_general)
     thd->variables.option_bits &= ~OPTION_LOG_OFF;

=== modified file 'sql/sp_head.h'
--- a/sql/sp_head.h	2010-08-16 15:16:07 +0000
+++ b/sql/sp_head.h	2010-10-26 11:48:08 +0000
@@ -527,7 +527,7 @@ private:
   HASH m_sptabs;
 
   bool
-  execute(THD *thd);
+  execute(THD *thd, bool merge_da_on_success);
 
   /**
     Perform a forward flow analysis in the generated code.

No bundle (reason: useless for push emails).
Thread
bzr push into mysql-5.5-bugteam branch (alexander.nozdrin:3097 to 3098)Bug#55850Alexander Nozdrin26 Oct