Commit 98135fed authored by Michael Widenius's avatar Michael Widenius

Merge with 5.1

parents a0afa025 74fdbec6
......@@ -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;
......@@ -191,6 +191,8 @@ bool end_active_trans(THD *thd)
error=1;
#ifdef WITH_ARIA_STORAGE_ENGINE
ha_maria::implicit_commit(thd, TRUE);
if (ha_storage_engine_is_enabled(maria_hton))
ha_maria::implicit_commit(thd, TRUE);
#endif
}
thd->options&= ~(OPTION_BEGIN | OPTION_KEEP_LOG);
......@@ -1236,6 +1238,7 @@ bool dispatch_command(enum enum_server_command command, THD *thd,
char *beginning_of_next_stmt= (char*) end_of_stmt;
#ifdef WITH_ARIA_STORAGE_ENGINE
if (ha_storage_engine_is_enabled(maria_hton))
ha_maria::implicit_commit(thd, FALSE);
#endif
......@@ -1662,6 +1665,8 @@ bool dispatch_command(enum enum_server_command command, THD *thd,
#ifdef WITH_ARIA_STORAGE_ENGINE
ha_maria::implicit_commit(thd, FALSE);
if (ha_storage_engine_is_enabled(maria_hton))
ha_maria::implicit_commit(thd, FALSE);
#endif
if (!(sql_command_flags[thd->lex->sql_command] & CF_CHANGES_DATA))
......
......@@ -13761,8 +13761,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;
......@@ -14030,7 +14030,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