Commit 654dd03f authored by Sergey Glukhov's avatar Sergey Glukhov

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).


mysql-test/r/type_date.result:
  test case
mysql-test/t/type_date.test:
  test case
sql/item_cmpfunc.cc:
  disable constant item convertion for subselects.
parent fbb0e5b2
......@@ -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'
......
......@@ -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 #
......
......@@ -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;
......
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