MySQL Lists are EOL. Please join:

List:Commits« Previous MessageNext Message »
From:Andrei Elkin Date:March 29 2008 10:55pm
Subject:bk commit into 5.1 tree (aelkin:1.2554) BUG#35675
View as plain text  
Below is the list of changes that have just been committed into a local
5.1 repository of aelkin.  When aelkin 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-03-30 00:54:08+02:00, aelkin@mysql1000.(none) +9 -0
  Bug #35675  	reset master finds assert if a binlog file can not be deleted
  
  If a binlog file is manually replaced with a namesake directory the internal purging did
  not handle the error of deleting the file so that eventually
  a post-execution guards fires an assert.
  
  Fixed with reusing a snippet of code for bug@18199 to tolerate lack of the file but no other error 
  at an attempt to delete it.
  The same applied to the index file deletion.
  
  The cset carries pieces of manual merging.

  mysql-test/r/binlog_index.result@stripped, 2008-03-30 00:54:06+02:00, aelkin@mysql1000.(none) +2 -2
    new results

  mysql-test/r/ctype_big5.result@stripped, 2008-03-30 00:54:06+02:00, aelkin@mysql1000.(none) +2 -2
    results changed

  mysql-test/suite/binlog/r/binlog_auto_increment_bug33029.result@stripped, 2008-03-30 00:54:06+02:00, aelkin@mysql1000.(none) +1 -0
    new results

  mysql-test/suite/binlog/r/binlog_stm_blackhole.result@stripped, 2008-03-30 00:54:06+02:00, aelkin@mysql1000.(none) +7 -0
    new results

  mysql-test/suite/binlog/t/binlog_auto_increment_bug33029.test@stripped, 2008-03-30 00:54:06+02:00, aelkin@mysql1000.(none) +7 -0
    cleanup. still todo: to let the test run multiple times w/o restarting the server (just ./mtr test)

  mysql-test/suite/rpl/r/rpl_stm_auto_increment_bug33029.result@stripped, 2008-03-30 00:54:06+02:00, aelkin@mysql1000.(none) +4 -0
    results changed

  mysql-test/suite/rpl/r/rpl_stm_auto_increment_bug33029.result@stripped, 2008-03-30 00:52:21+02:00, aelkin@mysql1000.(none) +0 -0
    Rename: mysql-test/r/rpl_auto_increment_bug33029.result -> mysql-test/suite/rpl/r/rpl_stm_auto_increment_bug33029.result

  mysql-test/suite/rpl/t/rpl_stm_auto_increment_bug33029.test@stripped, 2008-03-30 00:54:06+02:00, aelkin@mysql1000.(none) +1 -0
    guarding the test with statement format condition as the logics of the test requires

  mysql-test/suite/rpl/t/rpl_stm_auto_increment_bug33029.test@stripped, 2008-03-30 00:52:21+02:00, aelkin@mysql1000.(none) +0 -0
    Rename: mysql-test/t/rpl_auto_increment_bug33029.test -> mysql-test/suite/rpl/t/rpl_stm_auto_increment_bug33029.test

  sql/log.cc@stripped, 2008-03-30 00:54:06+02:00, aelkin@mysql1000.(none) +57 -17
    two changes. One for the bug, other manual merge.
    The bug change needs MYF(0) to pass to my_delete because not all error out of the function
    are critical. The finer check is done on the caller of my_delete similarly how it was implemented
    for bug@18199 fixes. Non-existance of a file is not a critical error.

  sql/sql_class.cc@stripped, 2008-03-30 00:54:06+02:00, aelkin@mysql1000.(none) +0 -13
    manual merge, removing extra automatically brought hunk.

diff -Nrup a/mysql-test/r/binlog_index.result b/mysql-test/r/binlog_index.result
--- a/mysql-test/r/binlog_index.result	2008-03-17 20:19:03 +02:00
+++ b/mysql-test/r/binlog_index.result	2008-03-30 00:54:06 +02:00
@@ -9,7 +9,7 @@ master-bin.000003	#
 master-bin.000004	#
 purge binary logs TO 'master-bin.000004';
 Warnings:
-Warning	1476	Being purged log MYSQLTEST_VARDIR/log/master-bin.000001 was not found
+Warning	1611	Being purged log MYSQLTEST_VARDIR/log/master-bin.000001 was not found
 *** must show a list starting from the 'TO' argument of PURGE ***
 show binary logs;
 Log_name	File_size
@@ -20,7 +20,7 @@ flush logs;
 flush logs;
 *** must be a warning master-bin.000001 was not found ***
 Warnings:
-Warning	1476	Being purged log MYSQLTEST_VARDIR/log/master-bin.000001 was not found
+Warning	1611	Being purged log MYSQLTEST_VARDIR/log/master-bin.000001 was not found
 *** must show one record, of the active binlog, left in the index file after PURGE ***
 show binary logs;
 Log_name	File_size
diff -Nrup a/mysql-test/r/ctype_big5.result b/mysql-test/r/ctype_big5.result
--- a/mysql-test/r/ctype_big5.result	2008-03-26 11:37:42 +02:00
+++ b/mysql-test/r/ctype_big5.result	2008-03-30 00:54:06 +02:00
@@ -78,8 +78,8 @@ level smallint unsigned);
 show create table t1;
 Table	Create Table
 t1	CREATE TABLE `t1` (
-  `name` varchar(10) default NULL,
-  `level` smallint(5) unsigned default NULL
+  `name` varchar(10) DEFAULT NULL,
+  `level` smallint(5) unsigned DEFAULT NULL
 ) ENGINE=MyISAM DEFAULT CHARSET=big5
 insert into t1 values ('string',1);
 select concat(name,space(level)), concat(name, repeat(' ',level)) from t1;
diff -Nrup a/mysql-test/r/rpl_auto_increment_bug33029.result b/mysql-test/r/rpl_auto_increment_bug33029.result
--- a/mysql-test/r/rpl_auto_increment_bug33029.result	2008-03-27 07:42:30 +02:00
+++ /dev/null	Wed Dec 31 16:00:00 196900
@@ -1,165 +0,0 @@
-stop slave;
-drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
-reset master;
-reset slave;
-drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
-start slave;
-DROP TABLE IF EXISTS t1, t2;
-DROP PROCEDURE IF EXISTS p1;
-DROP PROCEDURE IF EXISTS p2;
-DROP TRIGGER IF EXISTS tr1;
-DROP FUNCTION IF EXISTS f1;
-CREATE TABLE t1 (id INT AUTO_INCREMENT PRIMARY KEY);
-CREATE TABLE t2 (id INT AUTO_INCREMENT PRIMARY KEY);
-CREATE PROCEDURE p1()
-BEGIN
-DECLARE ins_count INT DEFAULT 10; 
-WHILE ins_count > 0 DO
-INSERT INTO t1 VALUES (NULL);
-SET ins_count = ins_count - 1;
-END WHILE;
-DELETE FROM t1 WHERE id = 1;
-DELETE FROM t1 WHERE id = 2;
-DELETE FROM t2 WHERE id = 1;
-DELETE FROM t2 WHERE id = 2;
-END//
-CREATE PROCEDURE p2()
-BEGIN
-INSERT INTO t1 VALUES (NULL);
-DELETE FROM t1 WHERE id = f1(3);
-DELETE FROM t1 WHERE id = f1(4);
-DELETE FROM t2 WHERE id = 3;
-DELETE FROM t2 WHERE id = 4;
-END//
-CREATE TRIGGER tr1 BEFORE DELETE
-ON t1 FOR EACH ROW 
-BEGIN
-INSERT INTO t2  VALUES (NULL);
-END//
-CREATE FUNCTION f1 (i int) RETURNS int
-BEGIN
-INSERT INTO t2 VALUES (NULL);
-RETURN i;
-END//
-CALL p1();
-show binlog events from <binlog_start>;
-Log_name	Pos	Event_type	Server_id	End_log_pos	Info
-master-bin.000001	#	Intvar	#	#	INSERT_ID=1
-master-bin.000001	#	Query	#	#	use `test`; INSERT INTO t1 VALUES (NULL)
-master-bin.000001	#	Intvar	#	#	INSERT_ID=2
-master-bin.000001	#	Query	#	#	use `test`; INSERT INTO t1 VALUES (NULL)
-master-bin.000001	#	Intvar	#	#	INSERT_ID=3
-master-bin.000001	#	Query	#	#	use `test`; INSERT INTO t1 VALUES (NULL)
-master-bin.000001	#	Intvar	#	#	INSERT_ID=4
-master-bin.000001	#	Query	#	#	use `test`; INSERT INTO t1 VALUES (NULL)
-master-bin.000001	#	Intvar	#	#	INSERT_ID=5
-master-bin.000001	#	Query	#	#	use `test`; INSERT INTO t1 VALUES (NULL)
-master-bin.000001	#	Intvar	#	#	INSERT_ID=6
-master-bin.000001	#	Query	#	#	use `test`; INSERT INTO t1 VALUES (NULL)
-master-bin.000001	#	Intvar	#	#	INSERT_ID=7
-master-bin.000001	#	Query	#	#	use `test`; INSERT INTO t1 VALUES (NULL)
-master-bin.000001	#	Intvar	#	#	INSERT_ID=8
-master-bin.000001	#	Query	#	#	use `test`; INSERT INTO t1 VALUES (NULL)
-master-bin.000001	#	Intvar	#	#	INSERT_ID=9
-master-bin.000001	#	Query	#	#	use `test`; INSERT INTO t1 VALUES (NULL)
-master-bin.000001	#	Intvar	#	#	INSERT_ID=10
-master-bin.000001	#	Query	#	#	use `test`; INSERT INTO t1 VALUES (NULL)
-master-bin.000001	#	Query	#	#	use `test`; DELETE FROM t1 WHERE id = 1
-master-bin.000001	#	Query	#	#	use `test`; DELETE FROM t1 WHERE id = 2
-master-bin.000001	#	Query	#	#	use `test`; DELETE FROM t2 WHERE id = 1
-master-bin.000001	#	Query	#	#	use `test`; DELETE FROM t2 WHERE id = 2
-# Result on master
-SELECT * FROM t1;
-id
-3
-4
-5
-6
-7
-8
-9
-10
-SELECT * FROM t2;
-id
-# Result on slave
-SELECT * FROM t1;
-id
-3
-4
-5
-6
-7
-8
-9
-10
-SELECT * FROM t2;
-id
-DROP TRIGGER tr1;
-CALL p2();
-show binlog events from <binlog_start>;
-Log_name	Pos	Event_type	Server_id	End_log_pos	Info
-master-bin.000001	#	Intvar	#	#	INSERT_ID=11
-master-bin.000001	#	Query	#	#	use `test`; INSERT INTO t1 VALUES (NULL)
-master-bin.000001	#	Query	#	#	use `test`; DELETE FROM t1 WHERE id = f1(3)
-master-bin.000001	#	Query	#	#	use `test`; DELETE FROM t1 WHERE id = f1(4)
-master-bin.000001	#	Query	#	#	use `test`; DELETE FROM t2 WHERE id = 3
-master-bin.000001	#	Query	#	#	use `test`; DELETE FROM t2 WHERE id = 4
-# Result on master
-SELECT * FROM t1;
-id
-5
-6
-7
-8
-9
-10
-11
-SELECT * FROM t2;
-id
-5
-6
-7
-8
-9
-10
-11
-12
-13
-14
-15
-16
-17
-18
-19
-# Result on slave
-SELECT * FROM t1;
-id
-5
-6
-7
-8
-9
-10
-11
-SELECT * FROM t2;
-id
-5
-6
-7
-8
-9
-10
-11
-12
-13
-14
-15
-16
-17
-18
-19
-DROP TABLE IF EXISTS t1, t2;
-DROP PROCEDURE IF EXISTS p1;
-DROP PROCEDURE IF EXISTS p2;
-DROP FUNCTION IF EXISTS f1;
-DROP TRIGGER IF EXISTS tr1;
diff -Nrup a/mysql-test/suite/binlog/r/binlog_auto_increment_bug33029.result b/mysql-test/suite/binlog/r/binlog_auto_increment_bug33029.result
--- a/mysql-test/suite/binlog/r/binlog_auto_increment_bug33029.result	2008-03-27 07:47:59 +02:00
+++ b/mysql-test/suite/binlog/r/binlog_auto_increment_bug33029.result	2008-03-30 00:54:06 +02:00
@@ -36,3 +36,4 @@ DROP PROCEDURE IF EXISTS p1;
 DROP PROCEDURE IF EXISTS p2;
 DROP FUNCTION IF EXISTS f1;
 DROP TRIGGER IF EXISTS tr1;
+stop slave sql_thread;
diff -Nrup a/mysql-test/suite/binlog/r/binlog_stm_blackhole.result b/mysql-test/suite/binlog/r/binlog_stm_blackhole.result
--- a/mysql-test/suite/binlog/r/binlog_stm_blackhole.result	2008-03-29 15:00:10 +02:00
+++ b/mysql-test/suite/binlog/r/binlog_stm_blackhole.result	2008-03-30 00:54:06 +02:00
@@ -172,6 +172,7 @@ master-bin.000001	#	Query	#	#	use `test`
 master-bin.000001	#	Query	#	#	use `test`; insert into t1 values(1)
 master-bin.000001	#	Query	#	#	use `test`; COMMIT
 drop table if exists t1;
+reset master;
 create table t1 (a int auto_increment, primary key (a)) engine=blackhole;
 insert into t1 values (11), (NULL), (NULL), (NULL);
 set insert_id= 3;
@@ -181,10 +182,16 @@ insert into t1 values (55), (NULL);
 show binlog events from <binlog_start>;
 Log_name	Pos	Event_type	Server_id	End_log_pos	Info
 master-bin.000001	#	Query	1	#	use `test`; create table t1 (a int auto_increment, primary key (a)) engine=blackhole
+master-bin.000001	#	Query	1	#	use `test`; BEGIN
 master-bin.000001	#	Intvar	1	#	INSERT_ID=1
 master-bin.000001	#	Query	1	#	use `test`; insert into t1 values (11), (NULL), (NULL), (NULL)
+master-bin.000001	#	Query	1	#	use `test`; COMMIT
+master-bin.000001	#	Query	1	#	use `test`; BEGIN
 master-bin.000001	#	Intvar	1	#	INSERT_ID=3
 master-bin.000001	#	Query	1	#	use `test`; insert into t1 values (NULL), (33), (NULL)
+master-bin.000001	#	Query	1	#	use `test`; COMMIT
+master-bin.000001	#	Query	1	#	use `test`; BEGIN
 master-bin.000001	#	Intvar	1	#	INSERT_ID=5
 master-bin.000001	#	Query	1	#	use `test`; insert into t1 values (55), (NULL)
+master-bin.000001	#	Query	1	#	use `test`; COMMIT
 drop table t1;
diff -Nrup a/mysql-test/suite/binlog/t/binlog_auto_increment_bug33029.test b/mysql-test/suite/binlog/t/binlog_auto_increment_bug33029.test
--- a/mysql-test/suite/binlog/t/binlog_auto_increment_bug33029.test	2008-03-28 16:07:48 +02:00
+++ b/mysql-test/suite/binlog/t/binlog_auto_increment_bug33029.test	2008-03-30 00:54:06 +02:00
@@ -45,3 +45,10 @@ DROP PROCEDURE IF EXISTS p2;
 DROP FUNCTION IF EXISTS f1;
 DROP TRIGGER IF EXISTS tr1;
 enable_warnings;
+
+remove_file $MYSQLTEST_VARDIR/master-data/slave-relay-bin.000001;
+remove_file $MYSQLTEST_VARDIR/master-data/slave-relay-bin.index;
+stop slave sql_thread;
+let $keep_connection=1;
+source include/wait_for_slave_sql_to_stop.inc;
+
diff -Nrup a/mysql-test/suite/rpl/r/rpl_stm_auto_increment_bug33029.result b/mysql-test/suite/rpl/r/rpl_stm_auto_increment_bug33029.result
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/mysql-test/suite/rpl/r/rpl_stm_auto_increment_bug33029.result	2008-03-30 00:54:06 +02:00
@@ -0,0 +1,169 @@
+stop slave;
+drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
+reset master;
+reset slave;
+drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
+start slave;
+DROP TABLE IF EXISTS t1, t2;
+DROP PROCEDURE IF EXISTS p1;
+DROP PROCEDURE IF EXISTS p2;
+DROP TRIGGER IF EXISTS tr1;
+DROP FUNCTION IF EXISTS f1;
+CREATE TABLE t1 (id INT AUTO_INCREMENT PRIMARY KEY);
+CREATE TABLE t2 (id INT AUTO_INCREMENT PRIMARY KEY);
+CREATE PROCEDURE p1()
+BEGIN
+DECLARE ins_count INT DEFAULT 10; 
+WHILE ins_count > 0 DO
+INSERT INTO t1 VALUES (NULL);
+SET ins_count = ins_count - 1;
+END WHILE;
+DELETE FROM t1 WHERE id = 1;
+DELETE FROM t1 WHERE id = 2;
+DELETE FROM t2 WHERE id = 1;
+DELETE FROM t2 WHERE id = 2;
+END//
+CREATE PROCEDURE p2()
+BEGIN
+INSERT INTO t1 VALUES (NULL);
+DELETE FROM t1 WHERE id = f1(3);
+DELETE FROM t1 WHERE id = f1(4);
+DELETE FROM t2 WHERE id = 3;
+DELETE FROM t2 WHERE id = 4;
+END//
+CREATE TRIGGER tr1 BEFORE DELETE
+ON t1 FOR EACH ROW 
+BEGIN
+INSERT INTO t2  VALUES (NULL);
+END//
+CREATE FUNCTION f1 (i int) RETURNS int
+BEGIN
+INSERT INTO t2 VALUES (NULL);
+RETURN i;
+END//
+CALL p1();
+show binlog events from <binlog_start>;
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+master-bin.000001	#	Intvar	#	#	INSERT_ID=1
+master-bin.000001	#	Query	#	#	use `test`; INSERT INTO t1 VALUES (NULL)
+master-bin.000001	#	Intvar	#	#	INSERT_ID=2
+master-bin.000001	#	Query	#	#	use `test`; INSERT INTO t1 VALUES (NULL)
+master-bin.000001	#	Intvar	#	#	INSERT_ID=3
+master-bin.000001	#	Query	#	#	use `test`; INSERT INTO t1 VALUES (NULL)
+master-bin.000001	#	Intvar	#	#	INSERT_ID=4
+master-bin.000001	#	Query	#	#	use `test`; INSERT INTO t1 VALUES (NULL)
+master-bin.000001	#	Intvar	#	#	INSERT_ID=5
+master-bin.000001	#	Query	#	#	use `test`; INSERT INTO t1 VALUES (NULL)
+master-bin.000001	#	Intvar	#	#	INSERT_ID=6
+master-bin.000001	#	Query	#	#	use `test`; INSERT INTO t1 VALUES (NULL)
+master-bin.000001	#	Intvar	#	#	INSERT_ID=7
+master-bin.000001	#	Query	#	#	use `test`; INSERT INTO t1 VALUES (NULL)
+master-bin.000001	#	Intvar	#	#	INSERT_ID=8
+master-bin.000001	#	Query	#	#	use `test`; INSERT INTO t1 VALUES (NULL)
+master-bin.000001	#	Intvar	#	#	INSERT_ID=9
+master-bin.000001	#	Query	#	#	use `test`; INSERT INTO t1 VALUES (NULL)
+master-bin.000001	#	Intvar	#	#	INSERT_ID=10
+master-bin.000001	#	Query	#	#	use `test`; INSERT INTO t1 VALUES (NULL)
+master-bin.000001	#	Intvar	#	#	INSERT_ID=1
+master-bin.000001	#	Query	#	#	use `test`; DELETE FROM t1 WHERE id = 1
+master-bin.000001	#	Intvar	#	#	INSERT_ID=2
+master-bin.000001	#	Query	#	#	use `test`; DELETE FROM t1 WHERE id = 2
+master-bin.000001	#	Query	#	#	use `test`; DELETE FROM t2 WHERE id = 1
+master-bin.000001	#	Query	#	#	use `test`; DELETE FROM t2 WHERE id = 2
+# Result on master
+SELECT * FROM t1;
+id
+3
+4
+5
+6
+7
+8
+9
+10
+SELECT * FROM t2;
+id
+# Result on slave
+SELECT * FROM t1;
+id
+3
+4
+5
+6
+7
+8
+9
+10
+SELECT * FROM t2;
+id
+DROP TRIGGER tr1;
+CALL p2();
+show binlog events from <binlog_start>;
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+master-bin.000001	#	Intvar	#	#	INSERT_ID=11
+master-bin.000001	#	Query	#	#	use `test`; INSERT INTO t1 VALUES (NULL)
+master-bin.000001	#	Intvar	#	#	INSERT_ID=3
+master-bin.000001	#	Query	#	#	use `test`; DELETE FROM t1 WHERE id = f1(3)
+master-bin.000001	#	Intvar	#	#	INSERT_ID=12
+master-bin.000001	#	Query	#	#	use `test`; DELETE FROM t1 WHERE id = f1(4)
+master-bin.000001	#	Query	#	#	use `test`; DELETE FROM t2 WHERE id = 3
+master-bin.000001	#	Query	#	#	use `test`; DELETE FROM t2 WHERE id = 4
+# Result on master
+SELECT * FROM t1;
+id
+5
+6
+7
+8
+9
+10
+11
+SELECT * FROM t2;
+id
+5
+6
+7
+8
+9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+# Result on slave
+SELECT * FROM t1;
+id
+5
+6
+7
+8
+9
+10
+11
+SELECT * FROM t2;
+id
+5
+6
+7
+8
+9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+DROP TABLE IF EXISTS t1, t2;
+DROP PROCEDURE IF EXISTS p1;
+DROP PROCEDURE IF EXISTS p2;
+DROP FUNCTION IF EXISTS f1;
+DROP TRIGGER IF EXISTS tr1;
diff -Nrup a/mysql-test/suite/rpl/t/rpl_stm_auto_increment_bug33029.test b/mysql-test/suite/rpl/t/rpl_stm_auto_increment_bug33029.test
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/mysql-test/suite/rpl/t/rpl_stm_auto_increment_bug33029.test	2008-03-30 00:54:06 +02:00
@@ -0,0 +1,110 @@
+# BUG#33029 5.0 to 5.1 replication fails on dup key when inserting
+# using a trig in SP
+
+# For all 5.0 up to 5.0.58 exclusive, and 5.1 up to 5.1.12 exclusive,
+# if one statement in a SP generated AUTO_INCREMENT value by the top
+# statement, all statements after it would be considered generated
+# AUTO_INCREMENT value by the top statement, and a erroneous INSERT_ID
+# value might be associated with these statement, which could cause
+# duplicate entry error and stop the slave.
+
+source include/have_binlog_format_statement.inc;
+source include/master-slave.inc;
+
+--disable_warnings
+DROP TABLE IF EXISTS t1, t2;
+DROP PROCEDURE IF EXISTS p1;
+DROP PROCEDURE IF EXISTS p2;
+DROP TRIGGER IF EXISTS tr1;
+DROP FUNCTION IF EXISTS f1;
+--enable_warnings
+
+CREATE TABLE t1 (id INT AUTO_INCREMENT PRIMARY KEY);
+CREATE TABLE t2 (id INT AUTO_INCREMENT PRIMARY KEY);
+
+delimiter //;
+
+CREATE PROCEDURE p1()
+BEGIN
+   DECLARE ins_count INT DEFAULT 10; 
+
+   WHILE ins_count > 0 DO
+       INSERT INTO t1 VALUES (NULL);
+       SET ins_count = ins_count - 1;
+   END WHILE;
+
+   DELETE FROM t1 WHERE id = 1;
+   DELETE FROM t1 WHERE id = 2;
+   DELETE FROM t2 WHERE id = 1;
+   DELETE FROM t2 WHERE id = 2;
+END//
+
+CREATE PROCEDURE p2()
+BEGIN
+   INSERT INTO t1 VALUES (NULL);
+   DELETE FROM t1 WHERE id = f1(3);
+   DELETE FROM t1 WHERE id = f1(4);
+   DELETE FROM t2 WHERE id = 3;
+   DELETE FROM t2 WHERE id = 4;
+END//
+
+CREATE TRIGGER tr1 BEFORE DELETE
+    ON t1 FOR EACH ROW 
+    BEGIN
+        INSERT INTO t2  VALUES (NULL);
+    END//
+
+CREATE FUNCTION f1 (i int) RETURNS int
+    BEGIN
+        INSERT INTO t2 VALUES (NULL);
+        RETURN i;
+    END//
+
+delimiter ;//
+
+# the $binlog_start will be used by the show_binlog_events.inc, so
+# that we can skip binlog events we don't care
+let $binlog_start= query_get_value(SHOW MASTER STATUS, Position, 1);
+CALL p1();
+source include/show_binlog_events.inc;
+
+echo # Result on master;
+SELECT * FROM t1;
+SELECT * FROM t2;
+
+sync_slave_with_master;
+
+echo # Result on slave;
+SELECT * FROM t1;
+SELECT * FROM t2;
+
+connection master;
+
+DROP TRIGGER tr1;
+
+# the $binlog_start will be used by the show_binlog_events.inc, so
+# that we can skip binlog events we don't care
+let $binlog_start= query_get_value(SHOW MASTER STATUS, Position, 1);
+CALL p2();
+source include/show_binlog_events.inc;
+
+echo # Result on master;
+SELECT * FROM t1;
+SELECT * FROM t2;
+
+sync_slave_with_master;
+
+echo # Result on slave;
+SELECT * FROM t1;
+SELECT * FROM t2;
+
+# clean up
+connection master;
+disable_warnings;
+DROP TABLE IF EXISTS t1, t2;
+DROP PROCEDURE IF EXISTS p1;
+DROP PROCEDURE IF EXISTS p2;
+DROP FUNCTION IF EXISTS f1;
+DROP TRIGGER IF EXISTS tr1;
+enable_warnings;
+sync_slave_with_master;
diff -Nrup a/mysql-test/t/rpl_auto_increment_bug33029.test b/mysql-test/t/rpl_auto_increment_bug33029.test
--- a/mysql-test/t/rpl_auto_increment_bug33029.test	2008-03-27 07:42:30 +02:00
+++ /dev/null	Wed Dec 31 16:00:00 196900
@@ -1,109 +0,0 @@
-# BUG#33029 5.0 to 5.1 replication fails on dup key when inserting
-# using a trig in SP
-
-# For all 5.0 up to 5.0.58 exclusive, and 5.1 up to 5.1.12 exclusive,
-# if one statement in a SP generated AUTO_INCREMENT value by the top
-# statement, all statements after it would be considered generated
-# AUTO_INCREMENT value by the top statement, and a erroneous INSERT_ID
-# value might be associated with these statement, which could cause
-# duplicate entry error and stop the slave.
-
-source include/master-slave.inc;
-
---disable_warnings
-DROP TABLE IF EXISTS t1, t2;
-DROP PROCEDURE IF EXISTS p1;
-DROP PROCEDURE IF EXISTS p2;
-DROP TRIGGER IF EXISTS tr1;
-DROP FUNCTION IF EXISTS f1;
---enable_warnings
-
-CREATE TABLE t1 (id INT AUTO_INCREMENT PRIMARY KEY);
-CREATE TABLE t2 (id INT AUTO_INCREMENT PRIMARY KEY);
-
-delimiter //;
-
-CREATE PROCEDURE p1()
-BEGIN
-   DECLARE ins_count INT DEFAULT 10; 
-
-   WHILE ins_count > 0 DO
-       INSERT INTO t1 VALUES (NULL);
-       SET ins_count = ins_count - 1;
-   END WHILE;
-
-   DELETE FROM t1 WHERE id = 1;
-   DELETE FROM t1 WHERE id = 2;
-   DELETE FROM t2 WHERE id = 1;
-   DELETE FROM t2 WHERE id = 2;
-END//
-
-CREATE PROCEDURE p2()
-BEGIN
-   INSERT INTO t1 VALUES (NULL);
-   DELETE FROM t1 WHERE id = f1(3);
-   DELETE FROM t1 WHERE id = f1(4);
-   DELETE FROM t2 WHERE id = 3;
-   DELETE FROM t2 WHERE id = 4;
-END//
-
-CREATE TRIGGER tr1 BEFORE DELETE
-    ON t1 FOR EACH ROW 
-    BEGIN
-        INSERT INTO t2  VALUES (NULL);
-    END//
-
-CREATE FUNCTION f1 (i int) RETURNS int
-    BEGIN
-        INSERT INTO t2 VALUES (NULL);
-        RETURN i;
-    END//
-
-delimiter ;//
-
-# the $binlog_start will be used by the show_binlog_events.inc, so
-# that we can skip binlog events we don't care
-let $binlog_start= query_get_value(SHOW MASTER STATUS, Position, 1);
-CALL p1();
-source include/show_binlog_events.inc;
-
-echo # Result on master;
-SELECT * FROM t1;
-SELECT * FROM t2;
-
-sync_slave_with_master;
-
-echo # Result on slave;
-SELECT * FROM t1;
-SELECT * FROM t2;
-
-connection master;
-
-DROP TRIGGER tr1;
-
-# the $binlog_start will be used by the show_binlog_events.inc, so
-# that we can skip binlog events we don't care
-let $binlog_start= query_get_value(SHOW MASTER STATUS, Position, 1);
-CALL p2();
-source include/show_binlog_events.inc;
-
-echo # Result on master;
-SELECT * FROM t1;
-SELECT * FROM t2;
-
-sync_slave_with_master;
-
-echo # Result on slave;
-SELECT * FROM t1;
-SELECT * FROM t2;
-
-# clean up
-connection master;
-disable_warnings;
-DROP TABLE IF EXISTS t1, t2;
-DROP PROCEDURE IF EXISTS p1;
-DROP PROCEDURE IF EXISTS p2;
-DROP FUNCTION IF EXISTS f1;
-DROP TRIGGER IF EXISTS tr1;
-enable_warnings;
-sync_slave_with_master;
diff -Nrup a/sql/log.cc b/sql/log.cc
--- a/sql/log.cc	2008-03-29 15:00:10 +02:00
+++ b/sql/log.cc	2008-03-30 00:54:06 +02:00
@@ -2746,14 +2746,62 @@ bool MYSQL_BIN_LOG::reset_logs(THD* thd)
 
   for (;;)
   {
-    my_delete_allow_opened(linfo.log_file_name, MYF(MY_WME));
+    if ((error= my_delete_allow_opened(linfo.log_file_name, MYF(0))) != 0)
+    {
+      if (my_errno == ENOENT) 
+      {
+        push_warning_printf(current_thd, MYSQL_ERROR::WARN_LEVEL_WARN,
+                            ER_LOG_PURGE_NO_FILE, ER(ER_LOG_PURGE_NO_FILE),
+                            linfo.log_file_name);
+        sql_print_information("Failed to delete file '%s'",
+                              linfo.log_file_name);
+        my_errno= 0;
+        error= 0;
+      }
+      else
+      {
+        push_warning_printf(current_thd, MYSQL_ERROR::WARN_LEVEL_ERROR,
+                            ER_BINLOG_PURGE_FATAL_ERR,
+                            "a problem with deleting %s; "
+                            "consider examining correspondence "
+                            "of your binlog index file "
+                            "to the actual binlog files",
+                            linfo.log_file_name);
+        error= 1;
+        goto err;
+      }
+    }
     if (find_next_log(&linfo, 0))
       break;
   }
 
   /* Start logging with a new file */
   close(LOG_CLOSE_INDEX);
-  my_delete_allow_opened(index_file_name, MYF(MY_WME));	// Reset (open will update)
+  if ((error= my_delete_allow_opened(index_file_name, MYF(0))))	// Reset (open will update)
+  {
+    if (my_errno == ENOENT) 
+    {
+      push_warning_printf(current_thd, MYSQL_ERROR::WARN_LEVEL_WARN,
+                          ER_LOG_PURGE_NO_FILE, ER(ER_LOG_PURGE_NO_FILE),
+                          index_file_name);
+      sql_print_information("Failed to delete file '%s'",
+                            index_file_name);
+      my_errno= 0;
+      error= 0;
+    }
+    else
+    {
+      push_warning_printf(current_thd, MYSQL_ERROR::WARN_LEVEL_ERROR,
+                          ER_BINLOG_PURGE_FATAL_ERR,
+                          "a problem with deleting %s; "
+                          "consider examining correspondence "
+                          "of your binlog index file "
+                          "to the actual binlog files",
+                          index_file_name);
+      error= 1;
+      goto err;
+    }
+  }
   if (!thd->slave_thread)
     need_start_event=1;
   if (!open_index_file(index_file_name, 0))
@@ -2913,6 +2961,7 @@ int MYSQL_BIN_LOG::update_log_index(LOG_
     0			ok
   @retval
     LOG_INFO_EOF		to_log not found
+    LOG_INFO_EMFILE             too many files opened
     LOG_INFO_FATAL              if any other than ENOENT error from
                                 my_stat() or my_delete()
 */
@@ -3004,28 +3053,19 @@ int MYSQL_BIN_LOG::purge_logs(const char
                               "of your binlog index file "
                               "to the actual binlog files",
                               log_info.log_file_name);
+          if (my_errno == EMFILE)
+          {
+            DBUG_PRINT("info",
+                       ("my_errno: %d, set ret = LOG_INFO_EMFILE", my_errno));
+            error= LOG_INFO_EMFILE;
+          }
           error= LOG_INFO_FATAL;
           goto err;
         }
       }
     }
-    /*
-      It's not fatal if we can't delete a log file ;
-      if we could delete it, take its size into account
-    */
-    DBUG_PRINT("info",("purging %s",log_info.log_file_name));
-    if (!my_delete(log_info.log_file_name, MYF(0)) && decrease_log_space)
-      *decrease_log_space-= file_size;
 
     ha_binlog_index_purge_file(current_thd, log_info.log_file_name);
-    if (current_thd->is_slave_error) {
-      DBUG_PRINT("info",("slave error: %d", current_thd->is_slave_error));
-      if (my_errno == EMFILE) {
-        DBUG_PRINT("info",("my_errno: %d, set ret = LOG_INFO_EMFILE", my_errno));
-        ret = LOG_INFO_EMFILE;
-        break;
-      }
-    }
 
     if (find_next_log(&log_info, 0) || exit_loop)
       break;
diff -Nrup a/sql/sql_class.cc b/sql/sql_class.cc
--- a/sql/sql_class.cc	2008-03-29 15:00:10 +02:00
+++ b/sql/sql_class.cc	2008-03-30 00:54:06 +02:00
@@ -1069,19 +1069,6 @@ bool THD::store_globals()
 
 void THD::cleanup_after_query()
 {
-  last_insert_id_used= FALSE;
-  if (clear_next_insert_id)
-  {
-    clear_next_insert_id= 0;
-    next_insert_id= 0;
-
-    /*
-      BUG#33029, if one statement in a SP set this member to 1, all
-      statment after this statement in the SP would be considered used
-      INSERT_ID value, reset this member after each query to fix this.
-    */
-    insert_id_used= 0;
-  }
   /*
     Reset rand_used so that detection of calls to rand() will save random 
     seeds if needed by the slave.
Thread
bk commit into 5.1 tree (aelkin:1.2554) BUG#35675Andrei Elkin29 Mar