summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorkaa@polly.local <>2007-04-26 20:51:02 +0400
committerkaa@polly.local <>2007-04-26 20:51:02 +0400
commit02f2616ee3c5b57be5911f5cdd49fbd1182a5975 (patch)
treefafc3f23469fd0c6f6f4414e688cf647005ba1ee
parent27418637d707fcb050b4620af94e93b64a0de496 (diff)
parent9a99aa81552178b2d7995ea41e0878dc59061c9b (diff)
downloadmariadb-git-02f2616ee3c5b57be5911f5cdd49fbd1182a5975.tar.gz
Merge polly.local:/home/kaa/src/maint/bug22364/my50-bug22364
into polly.local:/home/kaa/src/maint/mysql-5.0-maint
-rw-r--r--mysql-test/r/update.result35
-rw-r--r--mysql-test/t/update.test55
-rw-r--r--sql/sql_update.cc19
3 files changed, 99 insertions, 10 deletions
diff --git a/mysql-test/r/update.result b/mysql-test/r/update.result
index 748c2644eb9..dc7c7642a9b 100644
--- a/mysql-test/r/update.result
+++ b/mysql-test/r/update.result
@@ -457,3 +457,38 @@ 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;
+insert into t2(a) select a from t2;
+insert into t2(a) select a from t2;
+update t2 set a=id;
+insert into t1 select * from t2;
+select count(*) from t1 join t2 on (t1.a=t2.a);
+count(*)
+64
+update t1 join t2 on (t1.a=t2.a) set t1.id=t2.id;
+affected rows: 0
+info: Rows matched: 64 Changed: 0 Warnings: 0
+insert into t2(a) select a from t2;
+update t2 set a=id;
+truncate t1;
+insert into t1 select * from t2;
+select count(*) from t1 join t2 on (t1.a=t2.a);
+count(*)
+128
+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
+update t1 set a=1;
+update t2 set a=1;
+select count(*) from t1 join t2 on (t1.a=t2.a);
+count(*)
+16384
+update t1 join t2 on (t1.a=t2.a) set t1.id=t2.id;
+affected rows: 127
+info: Rows matched: 128 Changed: 127 Warnings: 0
+drop table t1,t2;
+End of 5.0 tests
diff --git a/mysql-test/t/update.test b/mysql-test/t/update.test
index 6cec940d286..f79c9e773aa 100644
--- a/mysql-test/t/update.test
+++ b/mysql-test/t/update.test
@@ -376,3 +376,58 @@ 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 the test tables
+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;
+insert into t2(a) select a from t2;
+insert into t2(a) select a from t2;
+update t2 set a=id;
+insert into t1 select * from t2;
+
+# Check that the number of matched rows is correct when the temporary
+# table is small enough to not be converted to MyISAM
+select count(*) from t1 join t2 on (t1.a=t2.a);
+--enable_info
+update t1 join t2 on (t1.a=t2.a) set t1.id=t2.id;
+--disable_info
+
+# Increase table sizes
+insert into t2(a) select a from t2;
+update t2 set a=id;
+truncate t1;
+insert into t1 select * from t2;
+
+# Check that the number of matched rows is correct when the temporary
+# table has to be converted to MyISAM
+select count(*) from t1 join t2 on (t1.a=t2.a);
+--enable_info
+update t1 join t2 on (t1.a=t2.a) set t1.id=t2.id;
+--disable_info
+
+# Check that the number of matched rows is correct when there are duplicate
+# key errors
+update t1 set a=1;
+update t2 set a=1;
+select count(*) from t1 join t2 on (t1.a=t2.a);
+--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
diff --git a/sql/sql_update.cc b/sql/sql_update.cc
index 6f6c4538040..e17c71ae541 100644
--- a/sql/sql_update.cc
+++ b/sql/sql_update.cc
@@ -1354,19 +1354,18 @@ bool multi_update::send_data(List<Item> &not_used_values)
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);