Commit bdf0ab58 authored by unknown's avatar unknown

Merge bk-internal.mysql.com:/data0/bk/mysql-5.0-opt

into  bk-internal.mysql.com:/data0/bk/mysql-5.1-opt


sql/opt_range.cc:
  Auto merged
parents 4c2d50e4 ba39449e
...@@ -183,6 +183,17 @@ select @a; ...@@ -183,6 +183,17 @@ select @a;
@a @a
1 1
drop table t1; drop table t1;
CREATE TABLE t1 (
`date` date ,
`time` time ,
`seq` int(10) unsigned NOT NULL auto_increment,
PRIMARY KEY (`seq`),
KEY `seq` (`seq`),
KEY `time` (`time`),
KEY `date` (`date`)
);
DELETE FROM t1 ORDER BY date ASC, time ASC LIMIT 1;
drop table t1;
End of 4.1 tests End of 4.1 tests
CREATE TABLE t1 (a int not null,b int not null); CREATE TABLE t1 (a int not null,b int not null);
CREATE TABLE t2 (a int not null, b int not null, primary key (a,b)); CREATE TABLE t2 (a int not null, b int not null, primary key (a,b));
......
...@@ -173,8 +173,20 @@ delete from t1 where (@a:= f1) order by f1 limit 1; ...@@ -173,8 +173,20 @@ delete from t1 where (@a:= f1) order by f1 limit 1;
select @a; select @a;
drop table t1; drop table t1;
# BUG#30385 "Server crash when deleting with order by and limit"
CREATE TABLE t1 (
`date` date ,
`time` time ,
`seq` int(10) unsigned NOT NULL auto_increment,
PRIMARY KEY (`seq`),
KEY `seq` (`seq`),
KEY `time` (`time`),
KEY `date` (`date`)
);
DELETE FROM t1 ORDER BY date ASC, time ASC LIMIT 1;
drop table t1;
--echo End of 4.1 tests --echo End of 4.1 tests
# End of 4.1 tests
# #
# Test of multi-delete where we are not scanning the first table # Test of multi-delete where we are not scanning the first table
......
...@@ -1778,6 +1778,7 @@ uint get_index_for_order(TABLE *table, ORDER *order, ha_rows limit) ...@@ -1778,6 +1778,7 @@ uint get_index_for_order(TABLE *table, ORDER *order, ha_rows limit)
if (!(table->keys_in_use_for_query.is_set(idx))) if (!(table->keys_in_use_for_query.is_set(idx)))
continue; continue;
KEY_PART_INFO *keyinfo= table->key_info[idx].key_part; KEY_PART_INFO *keyinfo= table->key_info[idx].key_part;
uint n_parts= table->key_info[idx].key_parts;
uint partno= 0; uint partno= 0;
/* /*
...@@ -1787,7 +1788,7 @@ uint get_index_for_order(TABLE *table, ORDER *order, ha_rows limit) ...@@ -1787,7 +1788,7 @@ uint get_index_for_order(TABLE *table, ORDER *order, ha_rows limit)
*/ */
if (!(table->file->index_flags(idx, 0, 1) & HA_READ_ORDER)) if (!(table->file->index_flags(idx, 0, 1) & HA_READ_ORDER))
continue; continue;
for (ord= order; ord; ord= ord->next, partno++) for (ord= order; ord && partno < n_parts; ord= ord->next, partno++)
{ {
Item *item= order->item[0]; Item *item= order->item[0];
if (!(item->type() == Item::FIELD_ITEM && if (!(item->type() == Item::FIELD_ITEM &&
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment