From: Date: June 26 2008 1:08pm Subject: bzr commit into mysql-5.1-telco-6.4 tree (frazer:2671) Bug#37516 List-Archive: http://lists.mysql.com/commits/48561 X-Bug: 37516 Message-Id: <200806261108.m5QB8D06006358@forth.ndb.mysql.com> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="===============0721542036==" --===============0721542036== MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Content-Disposition: inline #At file:///home/frazer/bzr/mysql-5.1-telco-6.4/ ------------------------------------------------------------ revno: 2671 revision-id: frazer@stripped parent: jonas@stripped parent: frazer@stripped committer: Frazer Clement branch nick: mysql-5.1-telco-6.4 timestamp: Thu 2008-06-26 12:07:51 +0100 message: Merge 6.3 -> 6.4 added: mysql-test/suite/ndb/r/ndb_hidden_pk.result ndb_hidden_pk.result-20080619120456-kvd0l74zrvp6fl96-1 mysql-test/suite/ndb/t/ndb_hidden_pk.test ndb_hidden_pk.test-20080619120445-10hgl937fdkdln4r-1 modified: sql/ha_ndbcluster.cc sp1f-ha_ndbcluster.cc-20040414175836-rvqnoxrkqexyhfu3d62s4t345ip7rez2 ------------------------------------------------------------ revno: 2585.8.2 revision-id: frazer@stripped parent: frazer@stripped parent: jonas@stripped committer: Frazer Clement branch nick: mysql-5.1-telco-6.3 timestamp: Thu 2008-06-26 11:46:06 +0100 message: Merge added: storage/ndb/test/run-test/conf-fimafeng08.cnf conffimafeng08.cnf-20080624140805-rbdj4pe7kcnjwsi9-1 modified: BUILD/compile-ndb-autotest sp1f-compilendbautotest-20060621072052-epq5zpjusgpsl2nnt6qmogxenxm6bxrr storage/ndb/src/ndbapi/NdbEventOperationImpl.cpp sp1f-ndbeventoperationimp-20040414082425-hg5aiqrtvpekpavvqa6cc3kvy2mjllud storage/ndb/test/run-test/Makefile.am sp1f-makefile.am-20040526111411-l4ppdj636zpq7aeuphj2i5kst5izlawe storage/ndb/test/run-test/autotest-boot.sh sp1f-autotestboot.sh-20070213013847-6htzi6tpzsvgdiips4ks6htfchtbzxlf storage/ndb/test/run-test/autotest-run.sh sp1f-autotestrun.sh-20070213013847-a5cyfgilhltmal6tvleacwnanazbb3wk ------------------------------------------------------------ revno: 2585.8.1 revision-id: frazer@stripped parent: tomas.ulin@stripped committer: Frazer Clement branch nick: mysql-5.1-telco-6.3 timestamp: Thu 2008-06-26 10:35:14 +0100 message: Bug#37516 DELETE using UNIQUE index deletes the wrong row Code for the read-before-write removal optimisation when using unique indexes did not work correctly when the base table had no primary key (i.e. hidden primary key). added: mysql-test/suite/ndb/r/ndb_hidden_pk.result ndb_hidden_pk.result-20080619120456-kvd0l74zrvp6fl96-1 mysql-test/suite/ndb/t/ndb_hidden_pk.test ndb_hidden_pk.test-20080619120445-10hgl937fdkdln4r-1 modified: sql/ha_ndbcluster.cc sp1f-ha_ndbcluster.cc-20040414175836-rvqnoxrkqexyhfu3d62s4t345ip7rez2 --===============0721542036== MIME-Version: 1.0 Content-Type: text/text/x-diff; charset="us-ascii"; name="patch-2671.diff" Content-Transfer-Encoding: 7bit Content-Disposition: inline === added file 'mysql-test/suite/ndb/r/ndb_hidden_pk.result' --- a/mysql-test/suite/ndb/r/ndb_hidden_pk.result 1970-01-01 00:00:00 +0000 +++ b/mysql-test/suite/ndb/r/ndb_hidden_pk.result 2008-06-26 09:35:14 +0000 @@ -0,0 +1,265 @@ +DROP TABLE IF EXISTS t1; +CREATE TABLE t1 ( +attr1 INT +) ENGINE=ndbcluster; +insert into t1 values (0), (1), (2), (3), (4), (1), (1), (1), (2), (2), (2), (3), (3), (3), (NULL), (NULL), (NULL); +select * from t1 order by attr1; +attr1 +NULL +NULL +NULL +0 +1 +1 +1 +1 +2 +2 +2 +2 +3 +3 +3 +3 +4 +select * from t1 where attr1 = 1; +attr1 +1 +1 +1 +1 +select * from t1 where attr1 IS NULL; +attr1 +NULL +NULL +NULL +select * from t1 where attr1 = 4; +attr1 +4 +select * from t1 where attr1 = 1000; +attr1 +update t1 set attr1=7 where attr1=4; +select * from t1 order by attr1; +attr1 +NULL +NULL +NULL +0 +1 +1 +1 +1 +2 +2 +2 +2 +3 +3 +3 +3 +7 +update t1 set attr1=10 where attr1=1; +select * from t1 order by attr1; +attr1 +NULL +NULL +NULL +0 +2 +2 +2 +2 +3 +3 +3 +3 +7 +10 +10 +10 +10 +update t1 set attr1=20 where attr1 IS NULL; +select * from t1 order by attr1; +attr1 +0 +2 +2 +2 +2 +3 +3 +3 +3 +7 +10 +10 +10 +10 +20 +20 +20 +update t1 set attr1=NULL where attr1=20; +select * from t1 order by attr1; +attr1 +NULL +NULL +NULL +0 +2 +2 +2 +2 +3 +3 +3 +3 +7 +10 +10 +10 +10 +delete from t1 where attr1=0; +select * from t1 order by attr1; +attr1 +NULL +NULL +NULL +2 +2 +2 +2 +3 +3 +3 +3 +7 +10 +10 +10 +10 +delete from t1 where attr1 IS NULL; +select * from t1 order by attr1; +attr1 +2 +2 +2 +2 +3 +3 +3 +3 +7 +10 +10 +10 +10 +drop table t1; +CREATE TABLE t1 ( +b blob +) ENGINE=ndbcluster; +Warnings: +Error 1478 Table storage engine 'ndbcluster' does not support the create option 'Binlog of table with BLOB attribute and no PK' +insert into t1 values (NULL), (NULL), ('Something'), (''), (REPEAT('Lots', 2000)); +select * from t1 order by b; +b +NULL +NULL + +LotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLots! LotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLots! LotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLo! tsLotsLo tsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLot! sLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLot! sLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsL! otsLotsL otsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLo! tsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLo! tsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLots! LotsLots LotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsL! otsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLotsLots +Something +select * from t1 where b IS NULL; +b +NULL +NULL +select * from t1 where b='Something'; +b +Something +select count(*) from t1 where b=REPEAT('Lots', 2000); +count(*) +1 +select * from t1 where b='Imaginary'; +b +drop table t1; +CREATE TABLE t1 ( +a int, +b int, +UNIQUE(a) +) ENGINE=NDBCLUSTER; +insert into t1 values (NULL, NULL), (NULL, NULL), (NULL, 1), (1, 1), (2, 2), (3, 3); +select * from t1 order by a, b; +a b +NULL NULL +NULL NULL +NULL 1 +1 1 +2 2 +3 3 +select * from t1 where a IS NULL order by b; +a b +NULL NULL +NULL NULL +NULL 1 +select * from t1 where a=2; +a b +2 2 +select * from t1 where a=10; +a b +update t1 set b=12 where a=12; +select * from t1 order by a, b; +a b +NULL NULL +NULL NULL +NULL 1 +1 1 +2 2 +3 3 +update t1 set b=4 where a=3; +select * from t1 order by a, b; +a b +NULL NULL +NULL NULL +NULL 1 +1 1 +2 2 +3 4 +update t1 set b=2 where a=1; +select * from t1 order by a, b; +a b +NULL NULL +NULL NULL +NULL 1 +1 2 +2 2 +3 4 +update t1 set b=14 where a IS NULL; +select * from t1 order by a,b; +a b +NULL 14 +NULL 14 +NULL 14 +1 2 +2 2 +3 4 +delete from t1 where a = 999; +select * from t1 order by a, b; +a b +NULL 14 +NULL 14 +NULL 14 +1 2 +2 2 +3 4 +delete from t1 where a=3; +select * from t1 order by a, b; +a b +NULL 14 +NULL 14 +NULL 14 +1 2 +2 2 +delete from t1 where a IS NULL; +select * from t1 order by a, b; +a b +1 2 +2 2 +drop table t1; === added file 'mysql-test/suite/ndb/t/ndb_hidden_pk.test' --- a/mysql-test/suite/ndb/t/ndb_hidden_pk.test 1970-01-01 00:00:00 +0000 +++ b/mysql-test/suite/ndb/t/ndb_hidden_pk.test 2008-06-26 09:35:14 +0000 @@ -0,0 +1,142 @@ +-- source include/have_ndb.inc + +--disable_warnings +DROP TABLE IF EXISTS t1; +--enable_warnings + +# +# ndb_hidden_pk.test +# Test use of tables with hidden primary key +# + +# Bag of nullable ints +CREATE TABLE t1 ( + attr1 INT +) ENGINE=ndbcluster; + +insert into t1 values (0), (1), (2), (3), (4), (1), (1), (1), (2), (2), (2), (3), (3), (3), (NULL), (NULL), (NULL); + +# all +select * from t1 order by attr1; + +# many +select * from t1 where attr1 = 1; + +# many NULLs +select * from t1 where attr1 IS NULL; + +# one +select * from t1 where attr1 = 4; + +# none +select * from t1 where attr1 = 1000; + +# Single value update +update t1 set attr1=7 where attr1=4; +select * from t1 order by attr1; + + +# Multi value update +update t1 set attr1=10 where attr1=1; +select * from t1 order by attr1; + +# Multi NULL value update +update t1 set attr1=20 where attr1 IS NULL; +select * from t1 order by attr1; + +# Put them back... +update t1 set attr1=NULL where attr1=20; +select * from t1 order by attr1; + +# Single value delete +delete from t1 where attr1=0; +select * from t1 order by attr1; + + +# Multi value delete +delete from t1 where attr1 IS NULL; +select * from t1 order by attr1; + + +drop table t1; + + +# Hidden primary key and blob only +CREATE TABLE t1 ( + b blob +) ENGINE=ndbcluster; + +insert into t1 values (NULL), (NULL), ('Something'), (''), (REPEAT('Lots', 2000)); + +# all +select * from t1 order by b; + +# many null +select * from t1 where b IS NULL; + +# one +select * from t1 where b='Something'; + +# large +select count(*) from t1 where b=REPEAT('Lots', 2000); + +# none +select * from t1 where b='Imaginary'; + +drop table t1; + + +# Unique index instead of PK +# +CREATE TABLE t1 ( + a int, + b int, + UNIQUE(a) +) ENGINE=NDBCLUSTER; + + +insert into t1 values (NULL, NULL), (NULL, NULL), (NULL, 1), (1, 1), (2, 2), (3, 3); + +# select all +select * from t1 order by a, b; + +# select many null +select * from t1 where a IS NULL order by b; + +# select one +select * from t1 where a=2; + +# select none +select * from t1 where a=10; + +# update none +update t1 set b=12 where a=12; +select * from t1 order by a, b; + +# update one +update t1 set b=4 where a=3; +select * from t1 order by a, b; + +# update many +update t1 set b=2 where a=1; +select * from t1 order by a, b; + +# update many null +update t1 set b=14 where a IS NULL; +select * from t1 order by a,b; + +# Bug # 37516 had problems with delete via unique index +# on table with hidden PK +# delete none +delete from t1 where a = 999; +select * from t1 order by a, b; + +# delete one +delete from t1 where a=3; +select * from t1 order by a, b; + +# delete many null +delete from t1 where a IS NULL; +select * from t1 order by a, b; + +drop table t1; === modified file 'sql/ha_ndbcluster.cc' --- a/sql/ha_ndbcluster.cc 2008-06-17 07:32:16 +0000 +++ b/sql/ha_ndbcluster.cc 2008-06-26 11:07:51 +0000 @@ -3650,29 +3650,30 @@ bool use_active_index) { DBUG_ENTER("setup_key_ref_for_ndb_record"); - if (table_share->primary_key != MAX_KEY) - { - if (use_active_index) - { - /* - Using unique key and getting read before write removal - optimisation working. Use key_rec according to this - unique index instead of primary key index - */ - *key_rec= m_index[active_index].ndb_unique_record_row; - } - else - *key_rec= m_index[table_share->primary_key].ndb_unique_record_row; - *key_row= record; - DBUG_VOID_RETURN; + if (use_active_index) + { + /* Use unique key to access table */ + DBUG_PRINT("info", ("Using unique index (%u)", active_index)); + *key_rec= m_index[active_index].ndb_unique_record_row; + *key_row= record; + } + else if (table_share->primary_key != MAX_KEY) + { + /* Use primary key to access table */ + DBUG_PRINT("info", ("Using primary key")); + *key_rec= m_index[table_share->primary_key].ndb_unique_record_row; + *key_row= record; } else { /* Use hidden primary key previously read into m_ref. */ + DBUG_PRINT("info", ("Using hidden primary key (%l)", m_ref)); + /* Can't use hidden pk if we didn't read it first */ + DBUG_ASSERT(m_read_before_write_removal_used == false); *key_rec= m_ndb_hidden_key_record; *key_row= (const uchar *)(&m_ref); - DBUG_VOID_RETURN; } + DBUG_VOID_RETURN; } @@ -10441,6 +10442,8 @@ ppartitionId=&partitionId; } + DBUG_PRINT("info", ("Generating Pk/Unique key read for range %u", + i)); if (!(op= pk_unique_index_read_key(active_index, r->start_key.key, row_buf, lm, @@ -10461,6 +10464,8 @@ const NdbOperation* rangeOp= lastOp ? lastOp->next() : trans->getFirstDefinedOperation(); + DBUG_PRINT("info", ("Executing reads")); + if (execute_no_commit_ie(m_thd_ndb, trans) == 0) { m_multi_range_result_ptr= buffer->buffer; --===============0721542036==--