Commit 74fdbec6 authored by Igor Babaev's avatar Igor Babaev

Fixed LP bug #848652.

The cause of this bug was the same as for bug 902356 fixed for 5.3.
parent 2be9a419
......@@ -17,3 +17,11 @@ id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t2 index NULL fkey 5 NULL 5 Using index
1 SIMPLE t1 eq_ref PRIMARY PRIMARY 4 test.t2.fkey 1 Using where
DROP TABLE t1,t2;
CREATE TABLE t1(a int, b int, KEY (a), PRIMARY KEY (b)) ENGINE=InnoDB;
CREATE TABLE t2 (b int, PRIMARY KEY (b));
INSERT INTO t2 VALUES (4),(9);
SELECT STRAIGHT_JOIN t1.a FROM t1 RIGHT JOIN t2 ON t1.b = t2.b
WHERE (t1.b NOT BETWEEN 1 AND 7 OR t1.a IS NULL AND t1.b = t2.b) AND t2.b = 4
GROUP BY 1;
a
DROP TABLE t1,t2;
......@@ -24,3 +24,18 @@ SELECT COUNT(*) FROM t2 LEFT JOIN t1 ON t2.fkey = t1.id
WHERE t1.name LIKE 'A%' OR FALSE;
DROP TABLE t1,t2;
#
# Bug #848652: crash with RIGHT JOIN and GROUP BY
#
CREATE TABLE t1(a int, b int, KEY (a), PRIMARY KEY (b)) ENGINE=InnoDB;
CREATE TABLE t2 (b int, PRIMARY KEY (b));
INSERT INTO t2 VALUES (4),(9);
SELECT STRAIGHT_JOIN t1.a FROM t1 RIGHT JOIN t2 ON t1.b = t2.b
WHERE (t1.b NOT BETWEEN 1 AND 7 OR t1.a IS NULL AND t1.b = t2.b) AND t2.b = 4
GROUP BY 1;
DROP TABLE t1,t2;
......@@ -13725,8 +13725,8 @@ find_field_in_item_list (Field *field, void *data)
while ((item= li++))
{
if (item->type() == Item::FIELD_ITEM &&
((Item_field*) item)->field->eq(field))
if (item->real_item()->type() == Item::FIELD_ITEM &&
((Item_field*) (item->real_item()))->field->eq(field))
{
part_found= 1;
break;
......@@ -13994,7 +13994,8 @@ test_if_skip_sort_order(JOIN_TAB *tab,ORDER *order,ha_rows select_limit,
uint used_pk_parts= 0;
if (used_key_parts > used_index_parts)
used_pk_parts= used_key_parts-used_index_parts;
rec_per_key= keyinfo->rec_per_key[used_key_parts-1];
rec_per_key= used_key_parts ?
keyinfo->rec_per_key[used_key_parts-1] : 1;
/* Take into account the selectivity of the used pk prefix */
if (used_pk_parts)
{
......
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