Commit 95ec38c5 authored by Gleb Shchepa's avatar Gleb Shchepa

Bug #55472: Assertion failed in heap_rfirst function of hp_rfirst.c on

            DELETE statement

Single-table delete ordered by a field that has a hash-type index
may cause an assertion failure or a crash.

An optimization added by the fix for the bug 36569 forced the
optimizer to use ORDER BY-compatible indices when applicable.

However, the existence of unsorted indices (HASH index algorithm
for some engines such as MEMORY/HEAP, NDB) was ignored.

The test_if_order_by_key function has been modified to skip
unsorted indices.
parent ed434ce0
......@@ -382,3 +382,14 @@ INSERT INTO t1 VALUES('A ', 'A ');
ERROR 23000: Duplicate entry 'A -A ' for key 'key1'
DROP TABLE t1;
End of 5.0 tests
#
# Bug #55472: Assertion failed in heap_rfirst function of hp_rfirst.c
# on DELETE statement
#
CREATE TABLE t1 (col_int_nokey INT,
col_int_key INT,
INDEX(col_int_key) USING HASH) ENGINE = HEAP;
INSERT INTO t1 (col_int_nokey, col_int_key) VALUES (3, 0), (4, 0), (3, 1);
DELETE FROM t1 WHERE col_int_nokey = 5 ORDER BY col_int_key LIMIT 2;
DROP TABLE t1;
End of 5.5 tests
......@@ -284,3 +284,20 @@ INSERT INTO t1 VALUES('A ', 'A ');
DROP TABLE t1;
--echo End of 5.0 tests
--echo #
--echo # Bug #55472: Assertion failed in heap_rfirst function of hp_rfirst.c
--echo # on DELETE statement
--echo #
CREATE TABLE t1 (col_int_nokey INT,
col_int_key INT,
INDEX(col_int_key) USING HASH) ENGINE = HEAP;
INSERT INTO t1 (col_int_nokey, col_int_key) VALUES (3, 0), (4, 0), (3, 1);
DELETE FROM t1 WHERE col_int_nokey = 5 ORDER BY col_int_key LIMIT 2;
DROP TABLE t1;
--echo End of 5.5 tests
......@@ -13244,7 +13244,7 @@ static int test_if_order_by_key(ORDER *order, TABLE *table, uint idx,
DBUG_RETURN(0);
}
if (key_part->field != field)
if (key_part->field != field || !field->part_of_sortkey.is_set(idx))
DBUG_RETURN(0);
/* set flag to 1 if we can use read-next on key, else to -1 */
......
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