MySQL Lists are EOL. Please join:

List:Commits« Previous MessageNext Message »
From:Georgi Kodinov Date:September 12 2008 3:52pm
Subject:bzr commit into mysql-5.0 branch (kgeorge:2685) Bug#39353
View as plain text  
#At file:///home/kgeorge/mysql/bzr/B39353-5.0-5.1.29-rc/

 2685 Georgi Kodinov	2008-09-12
      Bug #39353: Multiple conditions on timestamp column crashes server
      
      The fix for bug 31887 was incomplete : it assumes that all the 
      field types returned by the IS_NUM macro are descendants of 
      Item_num and tries to zero-fill the values before doing constant
      substitution with such fields when thy are compared to constant string
      values.
      The only exception to this is Field_timestamp : it's in the IS_NUM
      macro, but is not a descendant of Field_num.
      Fixed by excluding timestamp fields (Field_timestamp) when zero-filling
      when converting the constant to compare with to a string.
modified:
  mysql-test/r/compare.result
  mysql-test/t/compare.test
  sql/item.cc

per-file messages:
  mysql-test/r/compare.result
    Bug #39353: test case
  mysql-test/t/compare.test
    Bug #39353: test case
  sql/item.cc
    Bug #39353: Don't zero fill constants compared to Field_timestamp
=== modified file 'mysql-test/r/compare.result'
--- a/mysql-test/r/compare.result	2008-02-15 13:47:32 +0000
+++ b/mysql-test/r/compare.result	2008-09-12 15:52:03 +0000
@@ -90,4 +90,8 @@ Note	1276	Field or reference 'test.t2.a'
 Note	1276	Field or reference 'test.t2.a' of SELECT #2 was resolved in SELECT #1
 Note	1003	select `test`.`t2`.`a` AS `a`,(select count(0) AS `COUNT(*)` from `test`.`t1` where ((`test`.`t1`.`b` = `test`.`t2`.`a`) and (concat(`test`.`t1`.`b`,`test`.`t1`.`c`) = concat(_latin1'0',`test`.`t2`.`a`,_latin1'01')))) AS `x` from `test`.`t2` order by `test`.`t2`.`a`
 DROP TABLE t1,t2;
+CREATE TABLE t1 (a TIMESTAMP);
+SELECT * FROM t1 WHERE a > '2008-01-01' AND a = '0000-00-00';
+a
+DROP TABLE t1;
 End of 5.0 tests

=== modified file 'mysql-test/t/compare.test'
--- a/mysql-test/t/compare.test	2008-02-15 13:47:32 +0000
+++ b/mysql-test/t/compare.test	2008-09-12 15:52:03 +0000
@@ -76,4 +76,12 @@ FROM t2 ORDER BY a;
 
 DROP TABLE t1,t2;
 
+#
+# Bug #39353: Multiple conditions on timestamp column crashes server
+#
+
+CREATE TABLE t1 (a TIMESTAMP); 
+SELECT * FROM t1 WHERE a > '2008-01-01' AND a = '0000-00-00';
+DROP TABLE t1;
+
 --echo End of 5.0 tests

=== modified file 'sql/item.cc'
--- a/sql/item.cc	2008-09-03 07:59:48 +0000
+++ b/sql/item.cc	2008-09-12 15:52:03 +0000
@@ -4218,7 +4218,8 @@ Item *Item_field::equal_fields_propagato
   if (!item ||
       (cmp_context != (Item_result)-1 && item->cmp_context != cmp_context))
     item= this;
-  else if (field && (field->flags & ZEROFILL_FLAG) && IS_NUM(field->type()))
+  else if (field && (field->flags & ZEROFILL_FLAG) && IS_NUM(field->type()) &&
+           field->type() != FIELD_TYPE_TIMESTAMP)
   {
     if (item && cmp_context != INT_RESULT)
       convert_zerofill_number_to_string(&item, (Field_num *)field);

Thread
bzr commit into mysql-5.0 branch (kgeorge:2685) Bug#39353Georgi Kodinov12 Sep