From 2c0e2a147dd5f71538c5bf8b9a2a414208ea28b9 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 29 Sep 2005 08:34:38 +0300 Subject: [PATCH 1/2] Fixed a bug checksum table locks the InnoDB table and does not use a consistent read (Bug #12669). This fixes InnoDB part of the bug. mysql-test/r/innodb.result: Added results for a checksum test. mysql-test/t/innodb.test: Addeed a test case for a checksum bug #12669. sql/ha_innodb.cc: Use consistent read for checksum table. --- mysql-test/r/innodb.result | 28 +++++++++++++++++++++++++++ mysql-test/t/innodb.test | 39 ++++++++++++++++++++++++++++++++++++++ sql/ha_innodb.cc | 5 +++++ 3 files changed, 72 insertions(+) diff --git a/mysql-test/r/innodb.result b/mysql-test/r/innodb.result index 0d8de3a8e7d..8579d94595f 100644 --- a/mysql-test/r/innodb.result +++ b/mysql-test/r/innodb.result @@ -2616,3 +2616,31 @@ SET FOREIGN_KEY_CHECKS=1; INSERT INTO t2 VALUES(3); ERROR 23000: Cannot add or update a child row: a foreign key constraint fails (`test/t2`, CONSTRAINT `c1` FOREIGN KEY (`v`) REFERENCES `t1` (`id`)) DROP TABLE t2; +create table test_checksum(a int not null) engine=innodb DEFAULT CHARSET=latin1; +insert into test_checksum values (1),(2); +set autocommit=0; +checksum table test_checksum; +Table Checksum +test.test_checksum 1531596814 +insert into test_checksum values(3); +checksum table test_checksum; +Table Checksum +test.test_checksum 1531596814 +commit; +checksum table test_checksum; +Table Checksum +test.test_checksum 2050879373 +commit; +drop table test_checksum; +create table test_checksum(a int not null) engine=innodb DEFAULT CHARSET=latin1; +insert into test_checksum values (1),(2); +set autocommit=1; +checksum table test_checksum; +Table Checksum +test.test_checksum 1531596814 +set autocommit=1; +insert into test_checksum values(3); +checksum table test_checksum; +Table Checksum +test.test_checksum 2050879373 +drop table test_checksum; diff --git a/mysql-test/t/innodb.test b/mysql-test/t/innodb.test index 9023521c086..25cc6036e1a 100644 --- a/mysql-test/t/innodb.test +++ b/mysql-test/t/innodb.test @@ -1564,3 +1564,42 @@ SET FOREIGN_KEY_CHECKS=1; INSERT INTO t2 VALUES(3); DROP TABLE t2; +# +# Test that checksum table uses a consistent read Bug #12669 +# +connect (a,localhost,root,,); +connect (b,localhost,root,,); +connection a; +create table test_checksum(a int not null) engine=innodb DEFAULT CHARSET=latin1; +insert into test_checksum values (1),(2); +set autocommit=0; +checksum table test_checksum; +connection b; +insert into test_checksum values(3); +connection a; +# +# Here checksum should not see insert +# +checksum table test_checksum; +connection a; +commit; +checksum table test_checksum; +commit; +drop table test_checksum; +# +# autocommit = 1 +# +connection a; +create table test_checksum(a int not null) engine=innodb DEFAULT CHARSET=latin1; +insert into test_checksum values (1),(2); +set autocommit=1; +checksum table test_checksum; +connection b; +set autocommit=1; +insert into test_checksum values(3); +connection a; +# +# Here checksum sees insert +# +checksum table test_checksum; +drop table test_checksum; diff --git a/sql/ha_innodb.cc b/sql/ha_innodb.cc index afa8570c144..c78a127319c 100644 --- a/sql/ha_innodb.cc +++ b/sql/ha_innodb.cc @@ -6686,6 +6686,11 @@ ha_innobase::store_lock( without FOR UPDATE or IN SHARE MODE in select, then we use consistent read for select. */ + prebuilt->select_lock_type = LOCK_NONE; + prebuilt->stored_select_lock_type = LOCK_NONE; + } else if (thd->lex->sql_command == SQLCOM_CHECKSUM) { + /* Use consistent read for checksum table */ + prebuilt->select_lock_type = LOCK_NONE; prebuilt->stored_select_lock_type = LOCK_NONE; } else { From 811d98adc84d1deea9465ce889122b8df9d9c02a Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 29 Sep 2005 13:50:27 +0300 Subject: [PATCH 2/2] Fix incorrectly merged changeset, these may not be before a first 5.0 test i.e. range test. --- mysql-test/r/innodb.result | 28 -------------------------- mysql-test/t/innodb.test | 40 -------------------------------------- 2 files changed, 68 deletions(-) diff --git a/mysql-test/r/innodb.result b/mysql-test/r/innodb.result index ef1163b17c9..8579d94595f 100644 --- a/mysql-test/r/innodb.result +++ b/mysql-test/r/innodb.result @@ -1739,34 +1739,6 @@ select min(b) from t1 where a='8'; min(b) 6 drop table t1; -create table test_checksum(a int not null) engine=innodb DEFAULT CHARSET=latin1; -insert into test_checksum values (1),(2); -set autocommit=0; -checksum table test_checksum; -Table Checksum -test.test_checksum 1531596814 -insert into test_checksum values(3); -checksum table test_checksum; -Table Checksum -test.test_checksum 1531596814 -commit; -checksum table test_checksum; -Table Checksum -test.test_checksum 2050879373 -commit; -drop table test_checksum; -create table test_checksum(a int not null) engine=innodb DEFAULT CHARSET=latin1; -insert into test_checksum values (1),(2); -set autocommit=1; -checksum table test_checksum; -Table Checksum -test.test_checksum 1531596814 -set autocommit=1; -insert into test_checksum values(3); -checksum table test_checksum; -Table Checksum -test.test_checksum 2050879373 -drop table test_checksum; create table t1 (x bigint unsigned not null primary key) engine=innodb; insert into t1(x) values (0xfffffffffffffff0),(0xfffffffffffffff1); select * from t1; diff --git a/mysql-test/t/innodb.test b/mysql-test/t/innodb.test index d45ac4fc6c4..7d4e15163ef 100644 --- a/mysql-test/t/innodb.test +++ b/mysql-test/t/innodb.test @@ -1269,46 +1269,6 @@ select min(a) from t1; select min(b) from t1 where a='8'; drop table t1; -# -# Test that checksum table uses a consistent read Bug #12669 -# -connect (a,localhost,root,,); -connect (b,localhost,root,,); -connection a; -create table test_checksum(a int not null) engine=innodb DEFAULT CHARSET=latin1; -insert into test_checksum values (1),(2); -set autocommit=0; -checksum table test_checksum; -connection b; -insert into test_checksum values(3); -connection a; -# -# Here checksum should not see insert -# -checksum table test_checksum; -connection a; -commit; -checksum table test_checksum; -commit; -drop table test_checksum; -# -# autocommit = 1 -# -connection a; -create table test_checksum(a int not null) engine=innodb DEFAULT CHARSET=latin1; -insert into test_checksum values (1),(2); -set autocommit=1; -checksum table test_checksum; -connection b; -set autocommit=1; -insert into test_checksum values(3); -connection a; -# -# Here checksum sees insert -# -checksum table test_checksum; -drop table test_checksum; - # End of 4.1 tests #