diff options
author | unknown <ingo@mysql.com> | 2005-11-07 12:16:49 +0100 |
---|---|---|
committer | unknown <ingo@mysql.com> | 2005-11-07 12:16:49 +0100 |
commit | 9871459099cf18cdd2cebebfb10d909e635faddf (patch) | |
tree | a2a5cb9b8ca900cb6ef4eb4e876f7497fbf3bcba | |
parent | ff74f85a5811dea6a71431a3e580069ce40ced7a (diff) | |
download | mariadb-git-9871459099cf18cdd2cebebfb10d909e635faddf.tar.gz |
Bug#14616 - Freshly imported table returns error 124 when using LIMIT
Initialized usable_keys from table->keys_in_use instead of ~0
in test_if_skip_sort_order(). It was possible that a disabled
index was used for sorting.
mysql-test/r/myisam.result:
Bug#14616 - Freshly imported table returns error 124 when using LIMIT
The test result.
mysql-test/t/myisam.test:
Bug#14616 - Freshly imported table returns error 124 when using LIMIT
The test case.
-rw-r--r-- | mysql-test/r/myisam.result | 10 | ||||
-rw-r--r-- | mysql-test/t/myisam.test | 12 | ||||
-rw-r--r-- | sql/sql_select.cc | 8 |
3 files changed, 28 insertions, 2 deletions
diff --git a/mysql-test/r/myisam.result b/mysql-test/r/myisam.result index c55bacdd371..e6df3499eb5 100644 --- a/mysql-test/r/myisam.result +++ b/mysql-test/r/myisam.result @@ -462,3 +462,13 @@ select count(*) from t1 where a is null; count(*) 2 drop table t1; +create table t1 ( +c1 varchar(32), +key (c1) +) engine=myisam; +alter table t1 disable keys; +insert into t1 values ('a'), ('b'); +select c1 from t1 order by c1 limit 1; +c1 +a +drop table t1; diff --git a/mysql-test/t/myisam.test b/mysql-test/t/myisam.test index 57b64e30bac..a502002d30e 100644 --- a/mysql-test/t/myisam.test +++ b/mysql-test/t/myisam.test @@ -446,3 +446,15 @@ explain select count(*) from t1 where a is null; select count(*) from t1 where a is null; drop table t1; +# +# Bug#14616 - Freshly imported table returns error 124 when using LIMIT +# +create table t1 ( + c1 varchar(32), + key (c1) +) engine=myisam; +alter table t1 disable keys; +insert into t1 values ('a'), ('b'); +select c1 from t1 order by c1 limit 1; +drop table t1; + diff --git a/sql/sql_select.cc b/sql/sql_select.cc index 46f0139a608..6dd68a60f88 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -6003,8 +6003,12 @@ test_if_skip_sort_order(JOIN_TAB *tab,ORDER *order,ha_rows select_limit, key_map usable_keys; DBUG_ENTER("test_if_skip_sort_order"); - /* Check which keys can be used to resolve ORDER BY */ - usable_keys= ~(key_map) 0; + /* + Check which keys can be used to resolve ORDER BY. + We must not try to use disabled keys. + */ + usable_keys= table->keys_in_use; + for (ORDER *tmp_order=order; tmp_order ; tmp_order=tmp_order->next) { if ((*tmp_order->item)->type() != Item::FIELD_ITEM) |