Commit 8dad7dfa authored by Sergei Golubchik's avatar Sergei Golubchik

5.3->5.5 merge

parents 9d8ee74b 926b0f54
...@@ -5302,4 +5302,24 @@ INSERT INTO t2 VALUES (3),(4); ...@@ -5302,4 +5302,24 @@ INSERT INTO t2 VALUES (3),(4);
SELECT * FROM t1, t2 WHERE a=3 AND a=b; SELECT * FROM t1, t2 WHERE a=3 AND a=b;
a b a b
drop table t1,t2; drop table t1,t2;
#
# Bug mdev-4250: wrong transformation of WHERE condition with OR
#
CREATE TABLE t1 (pk int PRIMARY KEY, a int);
INSERT INTO t1 VALUES (3,0), (2,0), (4,1), (5,0), (1,0);
SELECT * FROM t1 WHERE (1=2 OR t1.pk=2) AND t1.a <> 0;
pk a
EXPLAIN EXTENDED
SELECT * FROM t1 WHERE (1=2 OR t1.pk=2) AND t1.a <> 0;
id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
Warnings:
Note 1003 select 2 AS `pk`,0 AS `a` from `test`.`t1` where ((0 <> 0))
DROP TABLE t1;
SELECT * FROM mysql.time_zone
WHERE ( NOT (Use_leap_seconds <= Use_leap_seconds AND Time_zone_id != 1)
AND Time_zone_id = Time_zone_id
OR Time_zone_id <> Time_zone_id )
AND Use_leap_seconds <> 'N';
Time_zone_id Use_leap_seconds
End of 5.3 tests End of 5.3 tests
...@@ -5313,6 +5313,26 @@ INSERT INTO t2 VALUES (3),(4); ...@@ -5313,6 +5313,26 @@ INSERT INTO t2 VALUES (3),(4);
SELECT * FROM t1, t2 WHERE a=3 AND a=b; SELECT * FROM t1, t2 WHERE a=3 AND a=b;
a b a b
drop table t1,t2; drop table t1,t2;
#
# Bug mdev-4250: wrong transformation of WHERE condition with OR
#
CREATE TABLE t1 (pk int PRIMARY KEY, a int);
INSERT INTO t1 VALUES (3,0), (2,0), (4,1), (5,0), (1,0);
SELECT * FROM t1 WHERE (1=2 OR t1.pk=2) AND t1.a <> 0;
pk a
EXPLAIN EXTENDED
SELECT * FROM t1 WHERE (1=2 OR t1.pk=2) AND t1.a <> 0;
id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
Warnings:
Note 1003 select 2 AS `pk`,0 AS `a` from `test`.`t1` where ((0 <> 0))
DROP TABLE t1;
SELECT * FROM mysql.time_zone
WHERE ( NOT (Use_leap_seconds <= Use_leap_seconds AND Time_zone_id != 1)
AND Time_zone_id = Time_zone_id
OR Time_zone_id <> Time_zone_id )
AND Use_leap_seconds <> 'N';
Time_zone_id Use_leap_seconds
End of 5.3 tests End of 5.3 tests
set join_cache_level=default; set join_cache_level=default;
show variables like 'join_cache_level'; show variables like 'join_cache_level';
......
...@@ -5302,4 +5302,24 @@ INSERT INTO t2 VALUES (3),(4); ...@@ -5302,4 +5302,24 @@ INSERT INTO t2 VALUES (3),(4);
SELECT * FROM t1, t2 WHERE a=3 AND a=b; SELECT * FROM t1, t2 WHERE a=3 AND a=b;
a b a b
drop table t1,t2; drop table t1,t2;
#
# Bug mdev-4250: wrong transformation of WHERE condition with OR
#
CREATE TABLE t1 (pk int PRIMARY KEY, a int);
INSERT INTO t1 VALUES (3,0), (2,0), (4,1), (5,0), (1,0);
SELECT * FROM t1 WHERE (1=2 OR t1.pk=2) AND t1.a <> 0;
pk a
EXPLAIN EXTENDED
SELECT * FROM t1 WHERE (1=2 OR t1.pk=2) AND t1.a <> 0;
id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
Warnings:
Note 1003 select 2 AS `pk`,0 AS `a` from `test`.`t1` where ((0 <> 0))
DROP TABLE t1;
SELECT * FROM mysql.time_zone
WHERE ( NOT (Use_leap_seconds <= Use_leap_seconds AND Time_zone_id != 1)
AND Time_zone_id = Time_zone_id
OR Time_zone_id <> Time_zone_id )
AND Use_leap_seconds <> 'N';
Time_zone_id Use_leap_seconds
End of 5.3 tests End of 5.3 tests
...@@ -1854,3 +1854,18 @@ a ...@@ -1854,3 +1854,18 @@ a
DROP TABLE t1; DROP TABLE t1;
End of 5.1 tests End of 5.1 tests
#
# MDEV-4241: Assertion failure: scale >= 0 && precision > 0 &&
# scale <= precision in decimal_bin_size
#
CREATE TABLE t1 (
f1 enum('1','2','3','4','5')
) ENGINE=MyISAM;
INSERT INTO t1 VALUES (1),(2);
SELECT AVG(f1) FROM t1;
Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr
def AVG(f1) 246 7 6 Y 32896 4 63
AVG(f1)
1.5000
drop table t1;
End of 5.3 tests
......
...@@ -4460,5 +4460,24 @@ INSERT INTO t2 VALUES (3),(4); ...@@ -4460,5 +4460,24 @@ INSERT INTO t2 VALUES (3),(4);
SELECT * FROM t1, t2 WHERE a=3 AND a=b; SELECT * FROM t1, t2 WHERE a=3 AND a=b;
drop table t1,t2; drop table t1,t2;
--echo #
--echo # Bug mdev-4250: wrong transformation of WHERE condition with OR
--echo #
CREATE TABLE t1 (pk int PRIMARY KEY, a int);
INSERT INTO t1 VALUES (3,0), (2,0), (4,1), (5,0), (1,0);
SELECT * FROM t1 WHERE (1=2 OR t1.pk=2) AND t1.a <> 0;
EXPLAIN EXTENDED
SELECT * FROM t1 WHERE (1=2 OR t1.pk=2) AND t1.a <> 0;
DROP TABLE t1;
SELECT * FROM mysql.time_zone
WHERE ( NOT (Use_leap_seconds <= Use_leap_seconds AND Time_zone_id != 1)
AND Time_zone_id = Time_zone_id
OR Time_zone_id <> Time_zone_id )
AND Use_leap_seconds <> 'N';
--echo End of 5.3 tests --echo End of 5.3 tests
...@@ -221,3 +221,18 @@ SELECT a FROM t1 WHERE a=0; ...@@ -221,3 +221,18 @@ SELECT a FROM t1 WHERE a=0;
DROP TABLE t1; DROP TABLE t1;
--echo End of 5.1 tests --echo End of 5.1 tests
--echo #
--echo # MDEV-4241: Assertion failure: scale >= 0 && precision > 0 &&
--echo # scale <= precision in decimal_bin_size
--echo #
CREATE TABLE t1 (
f1 enum('1','2','3','4','5')
) ENGINE=MyISAM;
INSERT INTO t1 VALUES (1),(2);
--enable_metadata
SELECT AVG(f1) FROM t1;
--disable_metadata
drop table t1;
--echo End of 5.3 tests
......
...@@ -1999,6 +1999,7 @@ public: ...@@ -1999,6 +1999,7 @@ public:
bool has_charset(void) const { return TRUE; } bool has_charset(void) const { return TRUE; }
/* enum and set are sorted as integers */ /* enum and set are sorted as integers */
CHARSET_INFO *sort_charset(void) const { return &my_charset_bin; } CHARSET_INFO *sort_charset(void) const { return &my_charset_bin; }
uint decimals() const { return 0; }
virtual uchar *pack(uchar *to, const uchar *from, uint max_length); virtual uchar *pack(uchar *to, const uchar *from, uint max_length);
virtual const uchar *unpack(uchar *to, const uchar *from, virtual const uchar *unpack(uchar *to, const uchar *from,
......
...@@ -1791,6 +1791,15 @@ public: ...@@ -1791,6 +1791,15 @@ public:
{ {
upper_levels= 0; upper_levels= 0;
} }
void copy(COND_EQUAL &cond_equal)
{
max_members= cond_equal.max_members;
upper_levels= cond_equal.upper_levels;
if (cond_equal.current_level.is_empty())
current_level.empty();
else
current_level= cond_equal.current_level;
}
}; };
......
...@@ -775,7 +775,7 @@ ulong JOIN_CACHE::get_min_join_buffer_size() ...@@ -775,7 +775,7 @@ ulong JOIN_CACHE::get_min_join_buffer_size()
tab= next_linear_tab(join, tab, WITHOUT_BUSH_ROOTS)) tab= next_linear_tab(join, tab, WITHOUT_BUSH_ROOTS))
{ {
len+= tab->get_max_used_fieldlength(); len+= tab->get_max_used_fieldlength();
len_last=+ tab->get_used_fieldlength(); len_last+= tab->get_used_fieldlength();
} }
size_t len_addon= get_record_max_affix_length() + size_t len_addon= get_record_max_affix_length() +
get_max_key_addon_space_per_record(); get_max_key_addon_space_per_record();
......
...@@ -11659,7 +11659,9 @@ static COND *build_equal_items_for_cond(THD *thd, COND *cond, ...@@ -11659,7 +11659,9 @@ static COND *build_equal_items_for_cond(THD *thd, COND *cond,
item_equal->n_field_items()); item_equal->n_field_items());
} }
((Item_cond_and*)cond)->cond_equal= cond_equal; ((Item_cond_and*)cond)->cond_equal.copy(cond_equal);
cond_equal.current_level=
((Item_cond_and*)cond)->cond_equal.current_level;
inherited= &(((Item_cond_and*)cond)->cond_equal); inherited= &(((Item_cond_and*)cond)->cond_equal);
} }
/* /*
...@@ -11737,7 +11739,8 @@ static COND *build_equal_items_for_cond(THD *thd, COND *cond, ...@@ -11737,7 +11739,8 @@ static COND *build_equal_items_for_cond(THD *thd, COND *cond,
set_if_bigger(thd->lex->current_select->max_equal_elems, set_if_bigger(thd->lex->current_select->max_equal_elems,
item_equal->n_field_items()); item_equal->n_field_items());
} }
and_cond->cond_equal= cond_equal; and_cond->cond_equal.copy(cond_equal);
cond_equal.current_level= and_cond->cond_equal.current_level;
args->concat((List<Item> *)&cond_equal.current_level); args->concat((List<Item> *)&cond_equal.current_level);
return and_cond; return and_cond;
......
...@@ -1445,7 +1445,9 @@ int decimal_bin_size(int precision, int scale) ...@@ -1445,7 +1445,9 @@ int decimal_bin_size(int precision, int scale)
intg0=intg/DIG_PER_DEC1, frac0=scale/DIG_PER_DEC1, intg0=intg/DIG_PER_DEC1, frac0=scale/DIG_PER_DEC1,
intg0x=intg-intg0*DIG_PER_DEC1, frac0x=scale-frac0*DIG_PER_DEC1; intg0x=intg-intg0*DIG_PER_DEC1, frac0x=scale-frac0*DIG_PER_DEC1;
DBUG_ASSERT(scale >= 0 && precision > 0 && scale <= precision); DBUG_ASSERT(scale >= 0);
DBUG_ASSERT(precision > 0);
DBUG_ASSERT(scale <= precision);
return intg0*sizeof(dec1)+dig2bytes[intg0x]+ return intg0*sizeof(dec1)+dig2bytes[intg0x]+
frac0*sizeof(dec1)+dig2bytes[frac0x]; frac0*sizeof(dec1)+dig2bytes[frac0x];
} }
......
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