Loading mysql-test/r/delete.result +11 −0 Original line number Diff line number Diff line Loading @@ -193,4 +193,15 @@ select @a; @a 1 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 mysql-test/t/delete.test +13 −0 Original line number Diff line number Diff line Loading @@ -184,4 +184,17 @@ delete from t1 where (@a:= f1) order by f1 limit 1; select @a; 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 sql/opt_range.cc +2 −1 Original line number Diff line number Diff line Loading @@ -825,6 +825,7 @@ uint get_index_for_order(TABLE *table, ORDER *order, ha_rows limit) if (!(table->keys_in_use_for_query.is_set(idx))) continue; KEY_PART_INFO *keyinfo= table->key_info[idx].key_part; uint n_parts= table->key_info[idx].key_parts; uint partno= 0; /* Loading @@ -834,7 +835,7 @@ uint get_index_for_order(TABLE *table, ORDER *order, ha_rows limit) */ if (!(table->file->index_flags(idx, 0, 1) & HA_READ_ORDER)) 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]; if (!(item->type() == Item::FIELD_ITEM && Loading Loading
mysql-test/r/delete.result +11 −0 Original line number Diff line number Diff line Loading @@ -193,4 +193,15 @@ select @a; @a 1 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
mysql-test/t/delete.test +13 −0 Original line number Diff line number Diff line Loading @@ -184,4 +184,17 @@ delete from t1 where (@a:= f1) order by f1 limit 1; select @a; 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
sql/opt_range.cc +2 −1 Original line number Diff line number Diff line Loading @@ -825,6 +825,7 @@ uint get_index_for_order(TABLE *table, ORDER *order, ha_rows limit) if (!(table->keys_in_use_for_query.is_set(idx))) continue; KEY_PART_INFO *keyinfo= table->key_info[idx].key_part; uint n_parts= table->key_info[idx].key_parts; uint partno= 0; /* Loading @@ -834,7 +835,7 @@ uint get_index_for_order(TABLE *table, ORDER *order, ha_rows limit) */ if (!(table->file->index_flags(idx, 0, 1) & HA_READ_ORDER)) 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]; if (!(item->type() == Item::FIELD_ITEM && Loading