Bug#59685 crash in String::length with date types

The crash happens because Item_cache which is result
holder for Item_subselect can't correctly convert
a DATETIME value from string to int representation.
The fix is to disable constant item convertion for
subselect(partial rollback of bug52157 fix).
This commit is contained in:
Sergey Glukhov 2011-02-11 12:54:16 +03:00
parent 6a59562415
commit e9fc441a52
3 changed files with 25 additions and 1 deletions

View file

@ -296,6 +296,18 @@ the_date the_time the_date the_time
2010-01-01 01:01:01 2010-01-01 01:01:01
DROP TABLE t1;
DROP VIEW v1;
#
# Bug#59685 crash in String::length with date types
#
CREATE TABLE t1(a DATE, b YEAR, KEY(a));
INSERT INTO t1 VALUES ('2011-01-01',2011);
SELECT b = (SELECT CONVERT(a, DATE) FROM t1 GROUP BY a) FROM t1;
b = (SELECT CONVERT(a, DATE) FROM t1 GROUP BY a)
0
SELECT b = CONVERT((SELECT CONVERT(a, DATE) FROM t1 GROUP BY a), DATE) FROM t1;
b = CONVERT((SELECT CONVERT(a, DATE) FROM t1 GROUP BY a), DATE)
0
DROP TABLE t1;
End of 5.1 tests
#
# Bug #33629: last_day function can return null, but has 'not null'

View file

@ -266,6 +266,18 @@ SELECT * FROM t1 JOIN v1 ON addtime( t1.the_date, t1.the_time ) =
DROP TABLE t1;
DROP VIEW v1;
--echo #
--echo # Bug#59685 crash in String::length with date types
--echo #
CREATE TABLE t1(a DATE, b YEAR, KEY(a));
INSERT INTO t1 VALUES ('2011-01-01',2011);
SELECT b = (SELECT CONVERT(a, DATE) FROM t1 GROUP BY a) FROM t1;
SELECT b = CONVERT((SELECT CONVERT(a, DATE) FROM t1 GROUP BY a), DATE) FROM t1;
DROP TABLE t1;
--echo End of 5.1 tests
--echo #

View file

@ -403,7 +403,7 @@ static bool convert_constant_item(THD *thd, Item_field *field_item,
Field *field= field_item->field;
int result= 0;
if ((*item)->const_item())
if (!(*item)->with_subselect && (*item)->const_item())
{
TABLE *table= field->table;
ulonglong orig_sql_mode= thd->variables.sql_mode;