List:Commits« Previous MessageNext Message »
From:Sergey Glukhov Date:January 28 2011 1:44pm
Subject:bzr commit into mysql-5.5 branch (sergey.glukhov:3277) Bug#59685
View as plain text  
#At file:///home/gluh/MySQL/mysql-5.5/ based on revid:anders.song@stripped

 3277 Sergey Glukhov	2011-01-28
      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 with DATETIME values.
     @ 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
        subselect with DATETIME values.

    modified:
      mysql-test/r/type_date.result
      mysql-test/t/type_date.test
      sql/item_cmpfunc.cc
=== modified file 'mysql-test/r/type_date.result'
--- a/mysql-test/r/type_date.result	2010-11-04 13:18:27 +0000
+++ b/mysql-test/r/type_date.result	2011-01-28 13:44:06 +0000
@@ -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'

=== modified file 'mysql-test/t/type_date.test'
--- a/mysql-test/t/type_date.test	2010-11-04 13:18:27 +0000
+++ b/mysql-test/t/type_date.test	2011-01-28 13:44:06 +0000
@@ -266,6 +266,18 @@ SELECT * FROM t1 JOIN v1 ON addtime( t1.
 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 #

=== modified file 'sql/item_cmpfunc.cc'
--- a/sql/item_cmpfunc.cc	2011-01-19 14:12:43 +0000
+++ b/sql/item_cmpfunc.cc	2011-01-28 13:44:06 +0000
@@ -403,6 +403,16 @@ static bool convert_constant_item(THD *t
   Field *field= field_item->field;
   int result= 0;
 
+  /*
+    Item_subselect uses Item_cache as result holder, Item_cache
+    can't correctly convert a DATETIME value from string to int
+    representation.
+  */
+  if ((*item)->result_type() == STRING_RESULT &&
+      (*item)->is_datetime() &&
+      (*item)->with_subselect)
+    return 0;
+
   if ((*item)->const_item())
   {
     TABLE *table= field->table;


Attachment: [text/bzr-bundle] bzr/sergey.glukhov@oracle.com-20110128134406-ouuurdmwe5kp1o33.bundle
Thread
bzr commit into mysql-5.5 branch (sergey.glukhov:3277) Bug#59685Sergey Glukhov28 Jan