MySQL Lists are EOL. Please join:

List:Commits« Previous MessageNext Message »
From:Alexey Kopytov Date:April 18 2007 2:14pm
Subject:bk commit into 5.0 tree (kaa:1.2445) BUG#22364
View as plain text  
Below is the list of changes that have just been committed into a local
5.0 repository of kaa. When kaa 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-04-18 18:14:15+04:00, kaa@stripped +3 -0
  Fix for bug #22364 "Inconsistent "matched rows" when executing UPDATE"
  
  In multi_update::send_data(), the counter of matched rows was not correctly incremented, when during insertion of a new row to a temporay table it had to be converted from HEAP to MyISAM.
  
  This fix changes the logic to increment the counter of matched rows in the following cases:
  1. If the error returned from write_row() is zero.
  2. If the error returned from write_row() is non-zero, is neither HA_ERR_FOUND_DUPP_KEY nor HA_ERR_FOUND_DUPP_UNIQUE, and a call to create_myisam_from_heap() succeeds. 

  mysql-test/r/update.result@stripped, 2007-04-18 18:14:10+04:00, kaa@stripped +28 -0
    Added a test case for bug #22364 "Inconsistent "matched rows" when executing UPDATE"

  mysql-test/t/update.test@stripped, 2007-04-18 18:14:10+04:00, kaa@stripped +38 -0
    Added a test case for bug #22364 "Inconsistent "matched rows" when executing UPDATE"

  sql/sql_update.cc@stripped, 2007-04-18 18:14:10+04:00, kaa@stripped +9 -10
    In multi_update::send_data(), the counter of matched rows was not correctly incremented, when during insertion of a new row to a temporay table it had to be converted from HEAP to MyISAM.
    
    This fix changes the logic to increment the counter of matched rows in the following cases:
    1. If the error returned from write_row() is zero.
    2. If the error returned from write_row() is non-zero, is neither HA_ERR_FOUND_DUPP_KEY nor HA_ERR_FOUND_DUPP_UNIQUE, and a call to create_myisam_from_heap() succeeds. 

# This is a BitKeeper patch.  What follows are the unified diffs for the
# set of deltas contained in the patch.  The rest of the patch, the part
# that BitKeeper cares about, is below these diffs.
# User:	kaa
# Host:	polly.local
# Root:	/tmp/maint/bug22364/my50-bug22364

--- 1.212/sql/sql_update.cc	2007-04-18 18:14:24 +04:00
+++ 1.213/sql/sql_update.cc	2007-04-18 18:14:24 +04:00
@@ -1328,19 +1328,18 @@ bool multi_update::send_data(List<Item> 
       memcpy((char*) tmp_table->field[0]->ptr,
 	     (char*) table->file->ref, table->file->ref_length);
       /* Write row, ignoring duplicated updates to a row */
-      if ((error= tmp_table->file->write_row(tmp_table->record[0])))
+      error= tmp_table->file->write_row(tmp_table->record[0]);
+      if (error != HA_ERR_FOUND_DUPP_KEY && error != HA_ERR_FOUND_DUPP_UNIQUE)
       {
-        if (error != HA_ERR_FOUND_DUPP_KEY &&
-            error != HA_ERR_FOUND_DUPP_UNIQUE &&
+        if (error &&
             create_myisam_from_heap(thd, tmp_table,
-                                         tmp_table_param + offset, error, 1))
-	{
-	  do_update=0;
-	  DBUG_RETURN(1);			// Not a table_is_full error
-	}
-      }
-      else
+                                    tmp_table_param + offset, error, 1))
+        {
+          do_update= 0;
+          DBUG_RETURN(1);			// Not a table_is_full error
+        }
         found++;
+      }
     }
   }
   DBUG_RETURN(0);

--- 1.33/mysql-test/r/update.result	2007-04-18 18:14:24 +04:00
+++ 1.34/mysql-test/r/update.result	2007-04-18 18:14:24 +04:00
@@ -457,3 +457,31 @@ a	quux
 2	0.100000000000000000000000000000
 3	NULL
 DROP TABLE t1;
+set tmp_table_size=1024;
+create table t1 (id int, a int, key idx(a));
+create table t2 (id int unsigned not null auto_increment primary key, a int);
+insert into t2(a) values(1),(2),(3),(4),(5),(6),(7),(8);
+insert into t2(a) select a from t2;
+update t2 set a=id;
+truncate t1;
+insert into t1 select * from t2;
+update t1 join t2 on (t1.a=t2.a) set t1.id=t2.id;
+insert into t2(a) select a from t2;
+update t2 set a=id;
+truncate t1;
+insert into t1 select * from t2;
+update t1 join t2 on (t1.a=t2.a) set t1.id=t2.id;
+insert into t2(a) select a from t2;
+update t2 set a=id;
+truncate t1;
+insert into t1 select * from t2;
+update t1 join t2 on (t1.a=t2.a) set t1.id=t2.id;
+insert into t2(a) select a from t2;
+update t2 set a=id;
+truncate t1;
+insert into t1 select * from t2;
+update t1 join t2 on (t1.a=t2.a) set t1.id=t2.id;
+affected rows: 0
+info: Rows matched: 128  Changed: 0  Warnings: 0
+drop table t1,t2;
+End of 5.0 tests

--- 1.31/mysql-test/t/update.test	2007-04-18 18:14:24 +04:00
+++ 1.32/mysql-test/t/update.test	2007-04-18 18:14:24 +04:00
@@ -376,3 +376,41 @@ INSERT INTO t1( a )
 SELECT * FROM t1;
 
 DROP TABLE t1;
+
+#
+# Bug #22364: Inconsistent "matched rows" when executing UPDATE
+#
+
+connect (con1,localhost,root,,test);
+connection con1;
+
+set tmp_table_size=1024;
+
+create table t1 (id int, a int, key idx(a));
+create table t2 (id int unsigned not null auto_increment primary key, a int);
+insert into t2(a) values(1),(2),(3),(4),(5),(6),(7),(8);
+
+insert into t2(a) select a from t2; update t2 set a=id; truncate t1; 
+insert into t1 select * from t2; 
+update t1 join t2 on (t1.a=t2.a) set t1.id=t2.id;
+
+insert into t2(a) select a from t2; update t2 set a=id; truncate t1; 
+insert into t1 select * from t2; 
+update t1 join t2 on (t1.a=t2.a) set t1.id=t2.id;
+
+insert into t2(a) select a from t2; update t2 set a=id; truncate t1; 
+insert into t1 select * from t2; 
+update t1 join t2 on (t1.a=t2.a) set t1.id=t2.id;
+
+insert into t2(a) select a from t2; update t2 set a=id; truncate t1; 
+insert into t1 select * from t2; 
+--enable_info
+update t1 join t2 on (t1.a=t2.a) set t1.id=t2.id;
+--disable_info
+
+drop table t1,t2;
+
+connection default;
+disconnect con1;
+
+--echo End of 5.0 tests
Thread
bk commit into 5.0 tree (kaa:1.2445) BUG#22364Alexey Kopytov18 Apr