List:Commits« Previous MessageNext Message »
From:Alexander Barkov Date:February 2 2012 10:59am
Subject:bzr push into mysql-trunk branch (alexander.barkov:3825 to 3826) Bug#13616434
View as plain text  
 3826 Alexander Barkov	2012-02-02
       Bug#13616434 ASSERTION FAILED: NANOSECONDS<  1000000000
      
       Problem:
      
       negative lldiv_t values with zero integer part and non-zero fractional part
       (e.g. -0.1111)  were not detected, so negative fractional part was
       later casted to a big unsigned number, which made the assertion crash.
      
       Fix:
      
       Return error if lld.rem is negative.
      
       modified:
        mysql-test/r/type_temporal_fractional.result
        mysql-test/t/type_temporal_fractional.test
        sql/sql_time.cc 

    modified:
      mysql-test/r/type_temporal_fractional.result
      mysql-test/t/type_temporal_fractional.test
      sql/sql_time.cc
 3825 Marko Mäkelseg_current_size.

    modified:
      mysql-test/suite/innodb/r/innodb_monitor.result
=== modified file 'mysql-test/r/type_temporal_fractional.result'
--- a/mysql-test/r/type_temporal_fractional.result	2012-01-31 15:16:16 +0000
+++ b/mysql-test/r/type_temporal_fractional.result	2012-02-02 10:58:18 +0000
@@ -17130,4 +17130,49 @@ SELECT 1 FROM t1 WHERE CASE WHEN 0 then
 SELECT 1 FROM t1 WHERE (SELECT a FROM t1) / a;
 1
 DROP TABLE t1;
+#
+# BUG#13616434 ASSERTION FAILED: NANOSECONDS < 1000000000
+#
+SELECT
+EXTRACT(DAY FROM (-0.1111111111)),
+EXTRACT(YEAR FROM (-0.1111111)),
+EXTRACT(YEAR_MONTH FROM (-0.1111111111)),
+EXTRACT(DAY FROM (-0.1111111)),
+EXTRACT(QUARTER FROM (-0.1111111111)),
+EXTRACT(MONTH FROM (-0.1111111)),
+EXTRACT(WEEK FROM (-0.1111111)),
+DATE(-0.1111111),
+QUARTER(-0.1111111111),
+TIMESTAMP(-0.1111111111),
+LAST_DAY(-0.1111111111),
+DAY(-0.1111111111),
+MONTH(-0.1111111111),
+YEAR(-0.1111111),
+DAYOFMONTH(-0.1111111111),
+TIMESTAMP((-0.1111111111),'{$x'),
+DATE_FORMAT(-0.1111111111,'+'),
+CONVERT(-0.1111111,DATE),
+CAST(-0.1111111111 AS DATE);
+EXTRACT(DAY FROM (-0.1111111111))	EXTRACT(YEAR FROM (-0.1111111))	EXTRACT(YEAR_MONTH FROM (-0.1111111111))	EXTRACT(DAY FROM (-0.1111111))	EXTRACT(QUARTER FROM (-0.1111111111))	EXTRACT(MONTH FROM (-0.1111111))	EXTRACT(WEEK FROM (-0.1111111))	DATE(-0.1111111)	QUARTER(-0.1111111111)	TIMESTAMP(-0.1111111111)	LAST_DAY(-0.1111111111)	DAY(-0.1111111111)	MONTH(-0.1111111111)	YEAR(-0.1111111)	DAYOFMONTH(-0.1111111111)	TIMESTAMP((-0.1111111111),'{$x')	DATE_FORMAT(-0.1111111111,'+')	CONVERT(-0.1111111,DATE)	CAST(-0.1111111111 AS DATE)
+NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL
+Warnings:
+Warning	1292	Incorrect datetime value: '-0.1111111111'
+Warning	1292	Incorrect datetime value: '-0.1111111'
+Warning	1292	Incorrect datetime value: '-0.1111111111'
+Warning	1292	Incorrect datetime value: '-0.1111111'
+Warning	1292	Incorrect datetime value: '-0.1111111111'
+Warning	1292	Incorrect datetime value: '-0.1111111'
+Warning	1292	Incorrect datetime value: '-0.1111111'
+Warning	1292	Incorrect datetime value: '-0.1111111'
+Warning	1292	Incorrect datetime value: '-0.1111111111'
+Warning	1292	Incorrect datetime value: '-0.1111111111'
+Warning	1292	Incorrect datetime value: '-0.1111111111'
+Warning	1292	Incorrect datetime value: '-0.1111111111'
+Warning	1292	Incorrect datetime value: '-0.1111111111'
+Warning	1292	Incorrect datetime value: '-0.1111111'
+Warning	1292	Incorrect datetime value: '-0.1111111111'
+Warning	1292	Incorrect datetime value: '-0.1111111111'
+Warning	1292	Incorrect datetime value: '-0.1111111111'
+Warning	1292	Incorrect datetime value: '-0.1111111'
+Warning	1292	Incorrect datetime value: '-0.1111111111'
 # End of 5.6 tests

=== modified file 'mysql-test/t/type_temporal_fractional.test'
--- a/mysql-test/t/type_temporal_fractional.test	2012-01-31 15:16:16 +0000
+++ b/mysql-test/t/type_temporal_fractional.test	2012-02-02 10:58:18 +0000
@@ -7610,5 +7610,29 @@ SELECT 1 FROM t1 WHERE (SELECT a FROM t1
 DROP TABLE t1;
 
 
+--echo #
+--echo # BUG#13616434 ASSERTION FAILED: NANOSECONDS < 1000000000
+--echo #
+SELECT
+  EXTRACT(DAY FROM (-0.1111111111)),
+  EXTRACT(YEAR FROM (-0.1111111)),
+  EXTRACT(YEAR_MONTH FROM (-0.1111111111)),
+  EXTRACT(DAY FROM (-0.1111111)),
+  EXTRACT(QUARTER FROM (-0.1111111111)),
+  EXTRACT(MONTH FROM (-0.1111111)),
+  EXTRACT(WEEK FROM (-0.1111111)),
+  DATE(-0.1111111),
+  QUARTER(-0.1111111111),
+  TIMESTAMP(-0.1111111111),
+  LAST_DAY(-0.1111111111),
+  DAY(-0.1111111111),
+  MONTH(-0.1111111111),
+  YEAR(-0.1111111),
+  DAYOFMONTH(-0.1111111111),
+  TIMESTAMP((-0.1111111111),'{$x'),
+  DATE_FORMAT(-0.1111111111,'+'),
+  CONVERT(-0.1111111,DATE),
+  CAST(-0.1111111111 AS DATE);
+
 
 --echo # End of 5.6 tests

=== modified file 'sql/sql_time.cc'
--- a/sql/sql_time.cc	2011-11-24 12:31:44 +0000
+++ b/sql/sql_time.cc	2012-02-02 10:58:18 +0000
@@ -409,13 +409,14 @@ str_to_datetime_with_warn(String *str, M
 static bool
 lldiv_t_to_datetime(lldiv_t lld, MYSQL_TIME *ltime, uint flags, int *warnings)
 {
-  bool rc= number_to_datetime(lld.quot, ltime, flags, warnings) == LL(-1);
-  if (rc)
+  if (lld.rem < 0 || // Catch negative numbers with zero int part, e.g: -0.1
+      number_to_datetime(lld.quot, ltime, flags, warnings) == LL(-1))
   {
     /* number_to_datetime does not clear ltime in case of ZERO DATE */
     set_zero_time(ltime, MYSQL_TIMESTAMP_ERROR);
     if (!*warnings) /* Neither sets warnings in case of ZERO DATE */
       *warnings|= MYSQL_TIME_WARN_TRUNCATED;
+    return true;
   }
   else if (ltime->time_type == MYSQL_TIMESTAMP_DATE)
   {
@@ -430,9 +431,9 @@ lldiv_t_to_datetime(lldiv_t lld, MYSQL_T
   else if (!(flags & TIME_NO_NSEC_ROUNDING))
   {
     ltime->second_part= lld.rem / 1000;
-    rc= datetime_add_nanoseconds_with_round(ltime, lld.rem % 1000, warnings);
+    return datetime_add_nanoseconds_with_round(ltime, lld.rem % 1000, warnings);
   }
-  return rc;
+  return false;
 }
 
 

No bundle (reason: useless for push emails).
Thread
bzr push into mysql-trunk branch (alexander.barkov:3825 to 3826) Bug#13616434Alexander Barkov2 Feb