Commit 99e2ba48 authored by Sergei Golubchik's avatar Sergei Golubchik

5.2 merge

parents 1a463305 167ad4c4
...@@ -93,7 +93,6 @@ mysqltest_LDADD = $(CXXLDFLAGS) $(CLIENT_THREAD_LIBS) \ ...@@ -93,7 +93,6 @@ mysqltest_LDADD = $(CXXLDFLAGS) $(CLIENT_THREAD_LIBS) \
$(top_builddir)/mysys/libmysys.a \ $(top_builddir)/mysys/libmysys.a \
$(LIBMYSQLCLIENT_LA) \ $(LIBMYSQLCLIENT_LA) \
$(top_builddir)/regex/libregex.la $(top_builddir)/regex/libregex.la
$(CLIENT_THREAD_LIBS)
mysql_upgrade_SOURCES= mysql_upgrade.c \ mysql_upgrade_SOURCES= mysql_upgrade.c \
$(top_srcdir)/mysys/my_getpagesize.c $(top_srcdir)/mysys/my_getpagesize.c
......
...@@ -1968,6 +1968,53 @@ field1 field2 ...@@ -1968,6 +1968,53 @@ field1 field2
2009-02-19 02:05:00 5 2009-02-19 02:05:00 5
SET SESSION SQL_MODE=default; SET SESSION SQL_MODE=default;
drop table t1; drop table t1;
#
# LP bug#967242 Wrong result (extra rows, not grouped) with JOIN, AND in ON condition, multi-part key, GROUP BY, OR in WHERE
#
CREATE TABLE t1 ( a VARCHAR(1) ) ENGINE=MyISAM;
INSERT INTO t1 VALUES ('x');
CREATE TABLE t2 ( b INT, c VARCHAR(1), KEY (c, b) ) ENGINE=MyISAM;
INSERT INTO t2 VALUES
(4, 'd'),(8, 'g'),(3, 'x'),(3, 'f'),
(0, 'p'),(3, 'j'),(8, 'c');
SELECT t2_1.b as zzz
FROM t1 JOIN t2 AS t2_1 JOIN t2 AS t2_2
ON (t2_2.b = t2_1.b ) AND (t2_2.c = t2_1.c )
WHERE
rand() + 1 > 0 OR
a = t2_1.c
GROUP BY zzz;
zzz
0
3
4
8
SELECT t2_1.b as zzz
FROM t1 JOIN t2 AS t2_1 JOIN t2 AS t2_2
ON (t2_2.b = t2_1.b ) AND (t2_2.c = t2_1.c )
WHERE
1 > 0 OR
a = t2_1.c
GROUP BY zzz;
zzz
0
3
4
8
SELECT t2_1.b as zzz
FROM t1 JOIN t2 AS t2_1 JOIN t2 AS t2_2
ON (t2_2.b = t2_1.b ) AND (t2_2.c = t2_1.c )
WHERE
t2_1.b + 1 > 0 OR
a = t2_1.c
GROUP BY zzz;
zzz
0
3
4
8
#TODO: in merge with 5.3 add original test suite
drop table t1, t2;
# End of 5.2 tests # End of 5.2 tests
# #
# BUG#872702: Crash in add_ref_to_table_cond() when grouping by a PK # BUG#872702: Crash in add_ref_to_table_cond() when grouping by a PK
......
...@@ -1342,6 +1342,45 @@ SELECT alias2.f3 AS field1 , alias2.f1 AS field2 FROM t1 AS alias1 JOIN t1 AS al ...@@ -1342,6 +1342,45 @@ SELECT alias2.f3 AS field1 , alias2.f1 AS field2 FROM t1 AS alias1 JOIN t1 AS al
SET SESSION SQL_MODE=default; SET SESSION SQL_MODE=default;
drop table t1; drop table t1;
--echo #
--echo # LP bug#967242 Wrong result (extra rows, not grouped) with JOIN, AND in ON condition, multi-part key, GROUP BY, OR in WHERE
--echo #
CREATE TABLE t1 ( a VARCHAR(1) ) ENGINE=MyISAM;
INSERT INTO t1 VALUES ('x');
CREATE TABLE t2 ( b INT, c VARCHAR(1), KEY (c, b) ) ENGINE=MyISAM;
INSERT INTO t2 VALUES
(4, 'd'),(8, 'g'),(3, 'x'),(3, 'f'),
(0, 'p'),(3, 'j'),(8, 'c');
SELECT t2_1.b as zzz
FROM t1 JOIN t2 AS t2_1 JOIN t2 AS t2_2
ON (t2_2.b = t2_1.b ) AND (t2_2.c = t2_1.c )
WHERE
rand() + 1 > 0 OR
a = t2_1.c
GROUP BY zzz;
SELECT t2_1.b as zzz
FROM t1 JOIN t2 AS t2_1 JOIN t2 AS t2_2
ON (t2_2.b = t2_1.b ) AND (t2_2.c = t2_1.c )
WHERE
1 > 0 OR
a = t2_1.c
GROUP BY zzz;
SELECT t2_1.b as zzz
FROM t1 JOIN t2 AS t2_1 JOIN t2 AS t2_2
ON (t2_2.b = t2_1.b ) AND (t2_2.c = t2_1.c )
WHERE
t2_1.b + 1 > 0 OR
a = t2_1.c
GROUP BY zzz;
--echo #TODO: in merge with 5.3 add original test suite
drop table t1, t2;
--echo # End of 5.2 tests --echo # End of 5.2 tests
--echo # --echo #
......
...@@ -1567,6 +1567,7 @@ class Item_cond :public Item_bool_func ...@@ -1567,6 +1567,7 @@ class Item_cond :public Item_bool_func
friend int setup_conds(THD *thd, TABLE_LIST *tables, TABLE_LIST *leaves, friend int setup_conds(THD *thd, TABLE_LIST *tables, TABLE_LIST *leaves,
COND **conds); COND **conds);
void top_level_item() { abort_on_null=1; } void top_level_item() { abort_on_null=1; }
bool top_level() { return abort_on_null; }
void copy_andor_arguments(THD *thd, Item_cond *item); void copy_andor_arguments(THD *thd, Item_cond *item);
bool walk(Item_processor processor, bool walk_subquery, uchar *arg); bool walk(Item_processor processor, bool walk_subquery, uchar *arg);
Item *transform(Item_transformer transformer, uchar *arg); Item *transform(Item_transformer transformer, uchar *arg);
......
...@@ -11996,9 +11996,10 @@ static COND* substitute_for_best_equal_field(JOIN_TAB *context_tab, ...@@ -11996,9 +11996,10 @@ static COND* substitute_for_best_equal_field(JOIN_TAB *context_tab,
@param cond condition whose multiple equalities are to be checked @param cond condition whose multiple equalities are to be checked
@param table constant table that has been read @param table constant table that has been read
@param const_key mark key parts as constant
*/ */
static void update_const_equal_items(COND *cond, JOIN_TAB *tab) static void update_const_equal_items(COND *cond, JOIN_TAB *tab, bool const_key)
{ {
if (!(cond->used_tables() & tab->table->map)) if (!(cond->used_tables() & tab->table->map))
return; return;
...@@ -12009,7 +12010,10 @@ static void update_const_equal_items(COND *cond, JOIN_TAB *tab) ...@@ -12009,7 +12010,10 @@ static void update_const_equal_items(COND *cond, JOIN_TAB *tab)
List_iterator_fast<Item> li(*cond_list); List_iterator_fast<Item> li(*cond_list);
Item *item; Item *item;
while ((item= li++)) while ((item= li++))
update_const_equal_items(item, tab); update_const_equal_items(item, tab,
(((Item_cond*) cond)->top_level() &&
((Item_cond*) cond)->functype() ==
Item_func::COND_AND_FUNC));
} }
else if (cond->type() == Item::FUNC_ITEM && else if (cond->type() == Item::FUNC_ITEM &&
((Item_cond*) cond)->functype() == Item_func::MULT_EQUAL_FUNC) ((Item_cond*) cond)->functype() == Item_func::MULT_EQUAL_FUNC)
...@@ -12039,7 +12043,8 @@ static void update_const_equal_items(COND *cond, JOIN_TAB *tab) ...@@ -12039,7 +12043,8 @@ static void update_const_equal_items(COND *cond, JOIN_TAB *tab)
TABLE *tab= field->table; TABLE *tab= field->table;
KEYUSE *use; KEYUSE *use;
for (use= stat->keyuse; use && use->table == tab; use++) for (use= stat->keyuse; use && use->table == tab; use++)
if (!use->is_for_hash_join() && possible_keys.is_set(use->key) && if (const_key &&
!use->is_for_hash_join() && possible_keys.is_set(use->key) &&
tab->key_info[use->key].key_part[use->keypart].field == tab->key_info[use->key].key_part[use->keypart].field ==
field) field)
tab->const_key_parts[use->key]|= use->keypart_map; tab->const_key_parts[use->key]|= use->keypart_map;
...@@ -16099,7 +16104,7 @@ join_read_const_table(JOIN_TAB *tab, POSITION *pos) ...@@ -16099,7 +16104,7 @@ join_read_const_table(JOIN_TAB *tab, POSITION *pos)
List_iterator<TABLE_LIST> ti(join->select_lex->leaf_tables); List_iterator<TABLE_LIST> ti(join->select_lex->leaf_tables);
/* Check appearance of new constant items in Item_equal objects */ /* Check appearance of new constant items in Item_equal objects */
if (join->conds) if (join->conds)
update_const_equal_items(join->conds, tab); update_const_equal_items(join->conds, tab, TRUE);
while ((tbl= ti++)) while ((tbl= ti++))
{ {
TABLE_LIST *embedded; TABLE_LIST *embedded;
...@@ -16108,7 +16113,7 @@ join_read_const_table(JOIN_TAB *tab, POSITION *pos) ...@@ -16108,7 +16113,7 @@ join_read_const_table(JOIN_TAB *tab, POSITION *pos)
{ {
embedded= embedding; embedded= embedding;
if (embedded->on_expr) if (embedded->on_expr)
update_const_equal_items(embedded->on_expr, tab); update_const_equal_items(embedded->on_expr, tab, TRUE);
embedding= embedded->embedding; embedding= embedded->embedding;
} }
while (embedding && while (embedding &&
...@@ -17946,7 +17951,7 @@ test_if_skip_sort_order(JOIN_TAB *tab,ORDER *order,ha_rows select_limit_arg, ...@@ -17946,7 +17951,7 @@ test_if_skip_sort_order(JOIN_TAB *tab,ORDER *order,ha_rows select_limit_arg,
int ref_key; int ref_key;
uint ref_key_parts; uint ref_key_parts;
int order_direction= 0; int order_direction= 0;
uint used_key_parts; uint used_key_parts= 0;
TABLE *table=tab->table; TABLE *table=tab->table;
SQL_SELECT *select=tab->select; SQL_SELECT *select=tab->select;
key_map usable_keys; key_map usable_keys;
......
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