diff options
author | unknown <evgen@moonbone.local> | 2007-01-11 16:20:08 +0300 |
---|---|---|
committer | unknown <evgen@moonbone.local> | 2007-01-11 16:20:08 +0300 |
commit | 0fdd3dce16caf33148bcc42b98b5d5d6142182f6 (patch) | |
tree | 42f4f8eecbb4a49d8c30d4722ddb998652cfa6c5 | |
parent | 10698df6da76e91df910b533974d853fe3ec27f2 (diff) | |
parent | 661796389f88dc2d436441156dd9d52da2407068 (diff) | |
download | mariadb-git-0fdd3dce16caf33148bcc42b98b5d5d6142182f6.tar.gz |
Merge fix for bug#17711
-rw-r--r-- | mysql-test/r/delete.result | 7 | ||||
-rw-r--r-- | mysql-test/t/delete.test | 10 | ||||
-rw-r--r-- | sql/sql_delete.cc | 2 |
3 files changed, 18 insertions, 1 deletions
diff --git a/mysql-test/r/delete.result b/mysql-test/r/delete.result index 7a6af8fd905..a5c22e66569 100644 --- a/mysql-test/r/delete.result +++ b/mysql-test/r/delete.result @@ -186,4 +186,11 @@ select count(*) from t1; count(*) 0 drop table t1; +create table t1(f1 int primary key); +insert into t1 values (4),(3),(1),(2); +delete from t1 where (@a:= f1) order by f1 limit 1; +select @a; +@a +1 +drop table t1; End of 4.1 tests diff --git a/mysql-test/t/delete.test b/mysql-test/t/delete.test index 2036b59d810..301b2cdbb99 100644 --- a/mysql-test/t/delete.test +++ b/mysql-test/t/delete.test @@ -174,4 +174,14 @@ delete from t1 where a is null; select count(*) from t1; drop table t1; +# +# Bug#17711: DELETE doesn't use index when ORDER BY, LIMIT and +# non-restricting WHERE is present. +# +create table t1(f1 int primary key); +insert into t1 values (4),(3),(1),(2); +delete from t1 where (@a:= f1) order by f1 limit 1; +select @a; +drop table t1; + --echo End of 4.1 tests diff --git a/sql/sql_delete.cc b/sql/sql_delete.cc index 1b00539ed71..b84b2f7eef4 100644 --- a/sql/sql_delete.cc +++ b/sql/sql_delete.cc @@ -142,7 +142,7 @@ int mysql_delete(THD *thd, TABLE_LIST *table_list, COND *conds, DBUG_RETURN(-1); // This will force out message } - if (!select && limit != HA_POS_ERROR) + if ((!select || table->quick_keys.is_clear_all()) && limit != HA_POS_ERROR) usable_index= get_index_for_order(table, (ORDER*)(order->first), limit); if (usable_index == MAX_KEY) |