From db0107b801df0f4fd0ef0f978a45c6d2830d748a Mon Sep 17 00:00:00 2001 From: "mskold/marty@mysql.com/linux.site" <> Date: Mon, 8 Jan 2007 10:38:53 +0100 Subject: [PATCH 1/2] bug#24820 CREATE INDEX ....USING HASH on NDB table creates ordered index, not HASH index: Added error checking --- mysql-test/r/ndb_index_ordered.result | 9 +++++++++ mysql-test/t/ndb_index_ordered.test | 14 ++++++++++++++ sql/ha_ndbcluster.cc | 10 ++++++++++ 3 files changed, 33 insertions(+) diff --git a/mysql-test/r/ndb_index_ordered.result b/mysql-test/r/ndb_index_ordered.result index 36bac7b0f9d..54458e1b459 100644 --- a/mysql-test/r/ndb_index_ordered.result +++ b/mysql-test/r/ndb_index_ordered.result @@ -658,3 +658,12 @@ insert into t1 (a, c) values (1,'aaa'),(3,'bbb'); select count(*) from t1 where c<'bbb'; count(*) 1 +create table nationaldish (DishID int(10) unsigned NOT NULL AUTO_INCREMENT, +CountryCode char(3) NOT NULL, +DishTitle varchar(64) NOT NULL, +calories smallint(5) unsigned DEFAULT NULL, +PRIMARY KEY (DishID) +) ENGINE=ndbcluster; +create index i using hash on nationaldish(countrycode,calories); +ERROR HY000: Can't create table './test/#sql-3c51_2.frm' (errno: 138) +drop table nationaldish; diff --git a/mysql-test/t/ndb_index_ordered.test b/mysql-test/t/ndb_index_ordered.test index e6827bdbe12..fa76202c7b7 100644 --- a/mysql-test/t/ndb_index_ordered.test +++ b/mysql-test/t/ndb_index_ordered.test @@ -356,3 +356,17 @@ insert into t1 (a, c) values (1,'aaa'),(3,'bbb'); select count(*) from t1 where c<'bbb'; # End of 4.1 tests + +# bug#24820 CREATE INDEX ....USING HASH on NDB table creates ordered index, not HASH index + +create table nationaldish (DishID int(10) unsigned NOT NULL AUTO_INCREMENT, + CountryCode char(3) NOT NULL, + DishTitle varchar(64) NOT NULL, + calories smallint(5) unsigned DEFAULT NULL, + PRIMARY KEY (DishID) + ) ENGINE=ndbcluster; + +--error ER_CANT_CREATE_TABLE +create index i using hash on nationaldish(countrycode,calories); + +drop table nationaldish; diff --git a/sql/ha_ndbcluster.cc b/sql/ha_ndbcluster.cc index 149a7c83895..34a3a001b21 100644 --- a/sql/ha_ndbcluster.cc +++ b/sql/ha_ndbcluster.cc @@ -1107,6 +1107,16 @@ int ha_ndbcluster::build_index_list(Ndb *ndb, TABLE *tab, enum ILBP phase) error= create_unique_index(unique_index_name, key_info); break; case ORDERED_INDEX: + if (key_info->algorithm == HA_KEY_ALG_HASH) + { + push_warning_printf(current_thd, MYSQL_ERROR::WARN_LEVEL_ERROR, + ER_UNSUPPORTED_EXTENSION, + ER(ER_UNSUPPORTED_EXTENSION), + "Ndb does not support non-unique " + "hash based indexes"); + error= HA_ERR_UNSUPPORTED; + break; + } error= create_ordered_index(index_name, key_info); break; default: From 5ebcc10e368796a23bba37332786fa0ef99324ab Mon Sep 17 00:00:00 2001 From: "mskold/marty@mysql.com/linux.site" <> Date: Mon, 8 Jan 2007 13:53:37 +0100 Subject: [PATCH 2/2] bug#24820 CREATE INDEX ....USING HASH on NDB table creates ordered index, not HASH index: Changed test since error mesage wasn't predictable --- mysql-test/r/ndb_index_ordered.result | 7 +++---- mysql-test/t/ndb_index_ordered.test | 8 +++----- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/mysql-test/r/ndb_index_ordered.result b/mysql-test/r/ndb_index_ordered.result index 54458e1b459..b3e55a23073 100644 --- a/mysql-test/r/ndb_index_ordered.result +++ b/mysql-test/r/ndb_index_ordered.result @@ -662,8 +662,7 @@ create table nationaldish (DishID int(10) unsigned NOT NULL AUTO_INCREMENT, CountryCode char(3) NOT NULL, DishTitle varchar(64) NOT NULL, calories smallint(5) unsigned DEFAULT NULL, -PRIMARY KEY (DishID) +PRIMARY KEY (DishID), +INDEX i USING HASH (countrycode,calories) ) ENGINE=ndbcluster; -create index i using hash on nationaldish(countrycode,calories); -ERROR HY000: Can't create table './test/#sql-3c51_2.frm' (errno: 138) -drop table nationaldish; +ERROR HY000: Can't create table './test/nationaldish.frm' (errno: 138) diff --git a/mysql-test/t/ndb_index_ordered.test b/mysql-test/t/ndb_index_ordered.test index fa76202c7b7..5867140fabb 100644 --- a/mysql-test/t/ndb_index_ordered.test +++ b/mysql-test/t/ndb_index_ordered.test @@ -359,14 +359,12 @@ select count(*) from t1 where c<'bbb'; # bug#24820 CREATE INDEX ....USING HASH on NDB table creates ordered index, not HASH index +--error ER_CANT_CREATE_TABLE create table nationaldish (DishID int(10) unsigned NOT NULL AUTO_INCREMENT, CountryCode char(3) NOT NULL, DishTitle varchar(64) NOT NULL, calories smallint(5) unsigned DEFAULT NULL, - PRIMARY KEY (DishID) + PRIMARY KEY (DishID), + INDEX i USING HASH (countrycode,calories) ) ENGINE=ndbcluster; ---error ER_CANT_CREATE_TABLE -create index i using hash on nationaldish(countrycode,calories); - -drop table nationaldish;