List:Commits« Previous MessageNext Message »
From:Alexander Barkov Date:November 17 2011 6:38pm
Subject:bzr push into mysql-trunk branch (alexander.barkov:3564 to 3565)
Bug#13401354 WL#946
View as plain text  
 3565 Alexander Barkov	2011-11-17
      WL#946: Bug#13401354 ITEM->FIELD_TYPE() == MYSQL_TYPE_TIME || ITEM->FIELD_TYPE() == MYSQL_TYPE_NULL

    modified:
      mysql-test/r/type_temporal_fractional.result
      mysql-test/t/type_temporal_fractional.test
      sql/item_cmpfunc.cc
 3564 Alexander Barkov	2011-11-16
      Bug#13365131 - VALGRIND: CONDITIONAL JUMP OR MOVE DEPENDS ON UNINITIALISED IN MY_TIME_COMPARE

    modified:
      mysql-test/r/type_temporal_fractional.result
      mysql-test/t/type_temporal_fractional.test
      sql/item.cc
=== modified file 'mysql-test/r/type_temporal_fractional.result'
--- a/mysql-test/r/type_temporal_fractional.result	2011-11-16 14:58:34 +0000
+++ b/mysql-test/r/type_temporal_fractional.result	2011-11-17 18:31:32 +0000
@@ -16644,3 +16644,48 @@ Warning	1292	Truncated incorrect time va
 Warning	1292	Truncated incorrect time value: '2002-11-24'
 DROP VIEW v1;
 DROP TABLE t1;
+#
+# Bug#13401354 ITEM->FIELD_TYPE() == MYSQL_TYPE_TIME || ITEM->FIELD_TYPE() == MYSQL_TYPE_NULL
+#
+CREATE TABLE t1 (col_time_not_null TIME NOT NULL);
+SELECT * FROM t1
+WHERE  col_time_not_null = DATE(NULL) AND col_time_not_null = TIME(NULL);
+col_time_not_null
+DROP TABLE t1;
+CREATE TABLE t1 (
+col_date DATE,
+col_time_not_null TIME not null,
+pk TIMESTAMP(6),
+col_timestamp_3_not_null_key TIMESTAMP(3) NOT NULL,
+col_date_not_null DATE NOT NULL,
+col_time_3_key TIME(3),
+col_timestamp_6_key TIMESTAMP(6) NOT NULL,
+col_datetime DATETIME,
+col_datetime_6 DATETIME(6),
+col_timestamp_3_key TIMESTAMP(3) NOT NULL,
+col_time_6_not_null TIME(6) NOT NULL,
+col_time_6 TIME(6),
+col_time_6_not_null_key TIME(6) NOT NULL,
+col_datetime_not_null DATETIME NOT NULL,
+col_datetime_3_not_null_key DATETIME(3) NOT NULL,
+KEY (col_datetime_3_not_null_key));
+SELECT col_time_6 AS c1, NOW() AS c2 FROM t1
+WHERE
+col_datetime_not_null BETWEEN SUBTIME('0000-00-00','00:00:00') AND col_date_not_null
+AND
+col_time_not_null=STR_TO_DATE(DATE_FORMAT(TIME('00:00:00.000000'),CONCAT_WS('-','%s','%k' )),CONCAT_WS(':','%i','%M'))
+AND
+col_date BETWEEN UNIX_TIMESTAMP('0000-00-00 00:00:00') AND col_timestamp_3_key
+AND
+col_datetime_6 NOT IN (col_time_6_not_null,'0000-00-00')
+AND
+col_time_not_null = TIMEDIFF(CURDATE(),'00:00:00.000000')
+AND
+col_time_3_key NOT IN (col_timestamp_6_key,pk)
+AND
+col_timestamp_3_not_null_key < col_datetime;
+c1	c2
+Warnings:
+Warning	1411	Incorrect datetime value: '00-0' for function str_to_date
+Warning	1411	Incorrect datetime value: '00-0' for function str_to_date
+DROP TABLE t1;

=== modified file 'mysql-test/t/type_temporal_fractional.test'
--- a/mysql-test/t/type_temporal_fractional.test	2011-11-16 14:58:34 +0000
+++ b/mysql-test/t/type_temporal_fractional.test	2011-11-17 18:31:32 +0000
@@ -7220,6 +7220,47 @@ DROP VIEW v1;
 DROP TABLE t1;
 
 
+--echo #
+--echo # Bug#13401354 ITEM->FIELD_TYPE() == MYSQL_TYPE_TIME || ITEM->FIELD_TYPE() == MYSQL_TYPE_NULL
+--echo #
+CREATE TABLE t1 (col_time_not_null TIME NOT NULL);
+SELECT * FROM t1
+WHERE  col_time_not_null = DATE(NULL) AND col_time_not_null = TIME(NULL);
+DROP TABLE t1;
+CREATE TABLE t1 (
+  col_date DATE,
+  col_time_not_null TIME not null,
+  pk TIMESTAMP(6),
+  col_timestamp_3_not_null_key TIMESTAMP(3) NOT NULL,
+  col_date_not_null DATE NOT NULL,
+  col_time_3_key TIME(3),
+  col_timestamp_6_key TIMESTAMP(6) NOT NULL,
+  col_datetime DATETIME,
+  col_datetime_6 DATETIME(6),
+  col_timestamp_3_key TIMESTAMP(3) NOT NULL,
+  col_time_6_not_null TIME(6) NOT NULL,
+  col_time_6 TIME(6),
+  col_time_6_not_null_key TIME(6) NOT NULL,
+  col_datetime_not_null DATETIME NOT NULL,
+  col_datetime_3_not_null_key DATETIME(3) NOT NULL,
+  KEY (col_datetime_3_not_null_key));
+SELECT col_time_6 AS c1, NOW() AS c2 FROM t1
+WHERE
+  col_datetime_not_null BETWEEN SUBTIME('0000-00-00','00:00:00') AND col_date_not_null
+AND
+  col_time_not_null=STR_TO_DATE(DATE_FORMAT(TIME('00:00:00.000000'),CONCAT_WS('-','%s','%k' )),CONCAT_WS(':','%i','%M'))
+AND
+  col_date BETWEEN UNIX_TIMESTAMP('0000-00-00 00:00:00') AND col_timestamp_3_key
+AND
+  col_datetime_6 NOT IN (col_time_6_not_null,'0000-00-00')
+AND
+  col_time_not_null = TIMEDIFF(CURDATE(),'00:00:00.000000')
+AND
+  col_time_3_key NOT IN (col_timestamp_6_key,pk)
+AND
+  col_timestamp_3_not_null_key < col_datetime; 
+DROP TABLE t1;
+
 ## TS-TODO: SELECT CAST('00:00:00' AS DATETIME) -> should it use curdate?
 
 ## TS-TODO: reuse count_datetime_length()/count_string_result_length()

=== modified file 'sql/item_cmpfunc.cc'
--- a/sql/item_cmpfunc.cc	2011-11-10 14:58:23 +0000
+++ b/sql/item_cmpfunc.cc	2011-11-17 18:31:32 +0000
@@ -906,8 +906,32 @@ get_time_value(THD *thd, Item ***item_ar
   longlong value;
   Item *item= **item_arg;
 
+  /*
+    Note, it's wrong to assume that we always get
+    a TIME expression or NULL here:
+
   DBUG_ASSERT(item->field_type() == MYSQL_TYPE_TIME || 
               item->field_type() == MYSQL_TYPE_NULL);
+
+    because when this condition is optimized:
+
+    WHERE time_column=DATE(NULL) AND time_column=TIME(NULL);
+
+    rhe first AND part is eliminated and DATE(NULL) is substituted
+    to the second AND part like this:
+
+    WHERE DATE(NULL) = TIME(NULL) // as TIME
+
+    whose Arg_comparator has already get_time_value set for both arguments.
+    Therefore, get_time_value is executed for DATE(NULL).
+    This condition is further evaluated as impossible condition.
+
+    TS-TODO: perhaps such cases should be evaluated without
+    calling get_time_value at all.
+
+    See a similar comment in Arg_comparator::compare_temporal_packed,
+    for DATETIME comparison.
+  */
   value= item->val_time_temporal();
   *is_null= item->null_value;
 

No bundle (reason: useless for push emails).
Thread
bzr push into mysql-trunk branch (alexander.barkov:3564 to 3565)Bug#13401354 WL#946Alexander Barkov18 Nov