From 28c8ac884bd3d5ed95d2a9d3bdcdb99ec46f01d5 Mon Sep 17 00:00:00 2001 From: "magnus@neptunus.(none)" <> Date: Tue, 25 May 2004 14:40:51 +0200 Subject: [PATCH] Corrected index_flags returned when index are created with USING HASH Updated ndb_ test cases --- mysql-test/r/ndb_autodiscover.result | 5 +++- mysql-test/r/ndb_basic.result | 18 ++++++------ mysql-test/r/ndb_index_unique.result | 42 ++++++++++++++++++++++++++++ mysql-test/t/ndb_autodiscover.test | 4 +++ mysql-test/t/ndb_basic.test | 6 ++-- mysql-test/t/ndb_index_unique.test | 41 +++++++++++++++++++++++++++ sql/ha_ndbcluster.cc | 6 ++-- 7 files changed, 107 insertions(+), 15 deletions(-) diff --git a/mysql-test/r/ndb_autodiscover.result b/mysql-test/r/ndb_autodiscover.result index 29fa93cacb0..ea2c7464f5d 100644 --- a/mysql-test/r/ndb_autodiscover.result +++ b/mysql-test/r/ndb_autodiscover.result @@ -128,7 +128,10 @@ select * from t4; id name 1 Automatic select * from t4; -ERROR HY000: Got error 284 'Table not defined in transaction coordinator' from NDBCLUSTER +ERROR HY000: Got error 284 'Table not defined in transaction coordinator' from ndbcluster +flush table t4; +select * from t4; +ERROR HY000: Can't open file: 't4' (errno: 709) show status like 'handler_discover%'; Variable_name Value Handler_discover 0 diff --git a/mysql-test/r/ndb_basic.result b/mysql-test/r/ndb_basic.result index baa51cd018e..0e7b039a5f9 100644 --- a/mysql-test/r/ndb_basic.result +++ b/mysql-test/r/ndb_basic.result @@ -303,26 +303,26 @@ insert into t7 values ("Street Road 78", 3, 92, 3), ("Main street 89C", 5, 71, 4), (NULL, 8, NULL, 12); -select * from t7; +select * from t7 order by a; adress a b c -Street Road 78 3 92 3 Highway 3456 1 23 2 -NULL 8 NULL 12 +Street Road 78 3 92 3 Main street 89C 5 71 4 -select a, b from t7; +NULL 8 NULL 12 +select a, b from t7 order by a; a b -3 92 1 23 -8 NULL +3 92 5 71 +8 NULL update t7 set adress="End of road 09" where a=3; update t7 set adress="Gatuvägen 90C" where a=5 and c=4; update t7 set adress="No adress" where adress is NULL; -select * from t7; +select * from t7 order by a; adress a b c -Gatuvägen 90C 5 71 4 -End of road 09 3 92 3 Highway 3456 1 23 2 +End of road 09 3 92 3 +Gatuvägen 90C 5 71 4 No adress 8 NULL 12 select * from t7 where a=1 and c=2; adress a b c diff --git a/mysql-test/r/ndb_index_unique.result b/mysql-test/r/ndb_index_unique.result index 71e0f414d52..ed97e0b110a 100644 --- a/mysql-test/r/ndb_index_unique.result +++ b/mysql-test/r/ndb_index_unique.result @@ -22,6 +22,48 @@ select * from t1 where b = 4 order by a; a b c 3 4 6 drop table t1; +CREATE TABLE t2 ( +a int unsigned NOT NULL PRIMARY KEY, +b int unsigned not null, +c int unsigned not null, +UNIQUE USING HASH (b, c) +) engine=ndbcluster; +insert t2 values(1, 2, 3), (2, 3, 5), (3, 4, 6), (4, 5, 8), (5,6, 2), (6,7, 2); +select * from t2 where a = 3; +a b c +3 4 6 +select * from t2 where b = 4; +a b c +3 4 6 +select * from t2 where c = 6; +a b c +3 4 6 +insert into t2 values(7,8,3); +select * from t2 where b = 4 order by a; +a b c +3 4 6 +drop table t2; +CREATE TABLE t3 ( +a int unsigned NOT NULL, +b int unsigned not null, +c int unsigned, +PRIMARY KEY USING HASH (a, b) +) engine=ndbcluster; +insert t3 values(1, 2, 3), (2, 3, 5), (3, 4, 6), (4, 5, 8), (5,6, 2), (6,7, 2); +select * from t3 where a = 3; +a b c +3 4 6 +select * from t3 where b = 4; +a b c +3 4 6 +select * from t3 where c = 6; +a b c +3 4 6 +insert into t3 values(7,8,3); +select * from t3 where b = 4 order by a; +a b c +3 4 6 +drop table t3; CREATE TABLE t1 ( cid smallint(5) unsigned NOT NULL default '0', cv varchar(250) NOT NULL default '', diff --git a/mysql-test/t/ndb_autodiscover.test b/mysql-test/t/ndb_autodiscover.test index ddd20632a09..dedcd3f257e 100644 --- a/mysql-test/t/ndb_autodiscover.test +++ b/mysql-test/t/ndb_autodiscover.test @@ -166,6 +166,10 @@ system drop_tab -c "host=localhost:2200;nodeid=5" -d test t4 > /dev/null ; --error 1296 select * from t4; +flush table t4; +--error 1016 +select * from t4; + show status like 'handler_discover%'; drop table t4; flush tables; diff --git a/mysql-test/t/ndb_basic.test b/mysql-test/t/ndb_basic.test index 05fb4e1103e..271357ed561 100644 --- a/mysql-test/t/ndb_basic.test +++ b/mysql-test/t/ndb_basic.test @@ -299,13 +299,13 @@ insert into t7 values ("Street Road 78", 3, 92, 3), ("Main street 89C", 5, 71, 4), (NULL, 8, NULL, 12); -select * from t7; -select a, b from t7; +select * from t7 order by a; +select a, b from t7 order by a; update t7 set adress="End of road 09" where a=3; update t7 set adress="Gatuvägen 90C" where a=5 and c=4; update t7 set adress="No adress" where adress is NULL; -select * from t7; +select * from t7 order by a; select * from t7 where a=1 and c=2; delete from t7 where a=1; delete from t7 where a=3 and c=3; diff --git a/mysql-test/t/ndb_index_unique.test b/mysql-test/t/ndb_index_unique.test index 9ac5a02d054..7cfc9a77452 100644 --- a/mysql-test/t/ndb_index_unique.test +++ b/mysql-test/t/ndb_index_unique.test @@ -23,6 +23,47 @@ select * from t1 where b = 4 order by a; drop table t1; + +# +# Show use of UNIQUE USING HASH indexes +# + +CREATE TABLE t2 ( + a int unsigned NOT NULL PRIMARY KEY, + b int unsigned not null, + c int unsigned not null, + UNIQUE USING HASH (b, c) +) engine=ndbcluster; + +insert t2 values(1, 2, 3), (2, 3, 5), (3, 4, 6), (4, 5, 8), (5,6, 2), (6,7, 2); +select * from t2 where a = 3; +select * from t2 where b = 4; +select * from t2 where c = 6; +insert into t2 values(7,8,3); +select * from t2 where b = 4 order by a; + +drop table t2; + +# +# Show use of PRIMARY KEY USING HASH indexes +# + +CREATE TABLE t3 ( + a int unsigned NOT NULL, + b int unsigned not null, + c int unsigned, + PRIMARY KEY USING HASH (a, b) +) engine=ndbcluster; + +insert t3 values(1, 2, 3), (2, 3, 5), (3, 4, 6), (4, 5, 8), (5,6, 2), (6,7, 2); +select * from t3 where a = 3; +select * from t3 where b = 4; +select * from t3 where c = 6; +insert into t3 values(7,8,3); +select * from t3 where b = 4 order by a; + +drop table t3; + # # More complex tables # diff --git a/sql/ha_ndbcluster.cc b/sql/ha_ndbcluster.cc index 960b6c18b20..e403223999c 100644 --- a/sql/ha_ndbcluster.cc +++ b/sql/ha_ndbcluster.cc @@ -474,7 +474,8 @@ static const ulong index_type_flags[]= 0, /* PRIMARY_KEY_INDEX */ - HA_NOT_READ_PREFIX_LAST, + HA_NOT_READ_PREFIX_LAST | + HA_ONLY_WHOLE_INDEX, /* PRIMARY_KEY_ORDERED_INDEX */ /* @@ -485,7 +486,8 @@ static const ulong index_type_flags[]= HA_NOT_READ_PREFIX_LAST, /* UNIQUE_INDEX */ - HA_NOT_READ_PREFIX_LAST, + HA_NOT_READ_PREFIX_LAST | + HA_ONLY_WHOLE_INDEX, /* UNIQUE_ORDERED_INDEX */ HA_NOT_READ_PREFIX_LAST,