diff options
author | unknown <kaa@polly.local> | 2007-04-23 18:22:33 +0400 |
---|---|---|
committer | unknown <kaa@polly.local> | 2007-04-23 18:22:33 +0400 |
commit | c705567e9c3ecea3bbcf8e5e8ef6ab6123892728 (patch) | |
tree | 24f873cc5431a99425c7bd62ffd427c12c3ded2f /mysql-test/t/update.test | |
parent | f7417a299eddf6212996c357f79b2715af98567b (diff) | |
download | mariadb-git-c705567e9c3ecea3bbcf8e5e8ef6ab6123892728.tar.gz |
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:
Added a test case for bug #22364 "Inconsistent "matched rows" when executing UPDATE"
mysql-test/t/update.test:
Added a test case for bug #22364 "Inconsistent "matched rows" when executing UPDATE"
sql/sql_update.cc:
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.
Diffstat (limited to 'mysql-test/t/update.test')
-rw-r--r-- | mysql-test/t/update.test | 55 |
1 files changed, 55 insertions, 0 deletions
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 |