MySQL Lists are EOL. Please join:

List:Commits« Previous MessageNext Message »
From:kgeorge Date:July 26 2007 8:31am
Subject:bk commit into 5.0 tree (gkodinov:1.2486) BUG#29571
View as plain text  
Below is the list of changes that have just been committed into a local
5.0 repository of kgeorge. When kgeorge 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, 2007-07-26 11:31:10+03:00, gkodinov@stripped +3 -0
  Bug #29571: INSERT DELAYED IGNORE written to binary log on 
   the master but on the slave
  
  MySQL can decide to "downgrade" a INSERT DELAYED statement
  to normal insert in certain situations.
  One such situation is when the slave is replaying a 
  replication feed.
  However INSERT DELAYED is logged even if there're no updates
  whereas the NORMAL INSERT is not logged in such cases.
  
  Fixed by always logging a "downgraded" INSERT DELAYED: even 
  if there were no updates.

  mysql-test/r/rpl_insert_delayed.result@stripped, 2007-07-26 11:31:09+03:00, gkodinov@stripped +20 -0
    Bug #29571: test case

  mysql-test/t/rpl_insert_delayed.test@stripped, 2007-07-26 11:31:09+03:00, gkodinov@stripped +29 -0
    Bug #29571: test case

  sql/sql_insert.cc@stripped, 2007-07-26 11:31:09+03:00, gkodinov@stripped +6 -3
    Bug #29571: log INSERT DELAYED even if it was 
    "downgraded" to INSERT (and there were no updates)

diff -Nrup a/mysql-test/r/rpl_insert_delayed.result b/mysql-test/r/rpl_insert_delayed.result
--- a/mysql-test/r/rpl_insert_delayed.result	2007-02-15 16:39:01 +02:00
+++ b/mysql-test/r/rpl_insert_delayed.result	2007-07-26 11:31:09 +03:00
@@ -29,3 +29,23 @@ id	name
 10	my name
 20	is Bond
 drop table t1;
+CREATE TABLE t1(a int, UNIQUE(a));
+INSERT DELAYED IGNORE INTO t1 VALUES(1);
+INSERT DELAYED IGNORE INTO t1 VALUES(1);
+show binlog events limit 11,100;
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+x	x	x	x	x	use `test`; INSERT DELAYED IGNORE INTO t1 VALUES(1)
+x	x	x	x	x	use `test`; INSERT DELAYED IGNORE INTO t1 VALUES(1)
+select * from t1;
+a
+1
+On slave
+show binlog events limit 12,100;
+Log_name	Pos	Event_type	Server_id	End_log_pos	Info
+x	x	x	x	x	use `test`; INSERT DELAYED IGNORE INTO t1 VALUES(1)
+x	x	x	x	x	use `test`; INSERT DELAYED IGNORE INTO t1 VALUES(1)
+select * from t1;
+a
+1
+drop table t1;
+End of 5.0 tests
diff -Nrup a/mysql-test/t/rpl_insert_delayed.test b/mysql-test/t/rpl_insert_delayed.test
--- a/mysql-test/t/rpl_insert_delayed.test	2007-02-15 16:39:01 +02:00
+++ b/mysql-test/t/rpl_insert_delayed.test	2007-07-26 11:31:09 +03:00
@@ -65,3 +65,32 @@ connection master;
 drop table t1;
 sync_slave_with_master;
 connection master;
+
+#
+# Bug #29571: INSERT DELAYED IGNORE written to binary log on the master but
+# on the slave
+#
+CREATE TABLE t1(a int, UNIQUE(a));
+INSERT DELAYED IGNORE INTO t1 VALUES(1);
+INSERT DELAYED IGNORE INTO t1 VALUES(1);
+
+#must show two INSERT DELAYED
+--replace_column 1 x 2 x 3 x 4 x 5 x
+show binlog events limit 11,100;
+select * from t1;
+
+sync_slave_with_master;
+echo On slave;
+#must show two INSERT DELAYED
+--replace_column 1 x 2 x 3 x 4 x 5 x
+show binlog events limit 12,100;
+select * from t1;
+
+
+# clean up
+connection master;
+drop table t1;
+sync_slave_with_master;
+connection master;
+
+--echo End of 5.0 tests
diff -Nrup a/sql/sql_insert.cc b/sql/sql_insert.cc
--- a/sql/sql_insert.cc	2007-07-08 22:02:59 +03:00
+++ b/sql/sql_insert.cc	2007-07-26 11:31:09 +03:00
@@ -560,6 +560,7 @@ bool mysql_insert(THD *thd,TABLE_LIST *t
   int error, res;
   bool transactional_table, joins_freed= FALSE;
   bool changed;
+  bool was_insert_delayed= (table_list->lock_type ==  TL_WRITE_DELAYED);
   uint value_count;
   ulong counter = 1;
   ulonglong id;
@@ -859,14 +860,16 @@ bool mysql_insert(THD *thd,TABLE_LIST *t
 
     transactional_table= table->file->has_transactions();
 
-    if ((changed= (info.copied || info.deleted || info.updated)))
+    if ((changed= (info.copied || info.deleted || info.updated)) ||
+        was_insert_delayed)
     {
       /*
         Invalidate the table in the query cache if something changed.
         For the transactional algorithm to work the invalidation must be
         before binlog writing and ha_autocommit_or_rollback
       */
-      query_cache_invalidate3(thd, table_list, 1);
+      if (changed)
+        query_cache_invalidate3(thd, table_list, 1);
       if (error <= 0 || !transactional_table)
       {
         if (mysql_bin_log.is_open())
@@ -904,7 +907,7 @@ bool mysql_insert(THD *thd,TABLE_LIST *t
           if (mysql_bin_log.write(&qinfo) && transactional_table)
             error=1;
         }
-        if (!transactional_table)
+        if (!transactional_table && changed)
           thd->no_trans_update.all= TRUE;
       }
     }
Thread
bk commit into 5.0 tree (gkodinov:1.2486) BUG#29571kgeorge26 Jul