List:Commits« Previous MessageNext Message »
From:Alexander Barkov Date:November 19 2011 7:49pm
Subject:bzr push into mysql-trunk branch (alexander.barkov:3600 to 3601)
Bug#13394031 WL#946
View as plain text  
 3601 Alexander Barkov	2011-11-19
      WL#946: Bug#13394031 VALGRIND: CONDITIONAL JUMP/MOVE DEPENDS ON UNINITIALISED IN FIELD::IS_REAL_NULL

    modified:
      mysql-test/r/type_temporal_fractional.result
      mysql-test/t/type_temporal_fractional.test
      sql/item.cc
      sql/item.h
      sql/item_cmpfunc.h
      sql/opt_range.cc
 3600 Alexander Barkov	2011-11-18 [merge]
      Merging latest bug fixes from mysql-trunk-wl946

    modified:
      mysql-test/r/timezone2.result
      mysql-test/r/type_temporal_fractional.result
      mysql-test/t/timezone2.test
      mysql-test/t/type_temporal_fractional.test
      sql/field.cc
      sql/field.h
      sql/item.cc
      sql/item.h
      sql/item_cmpfunc.cc
      sql/item_timefunc.cc
      sql/sql_time.cc
      sql/sql_time.h
      unittest/gunit/field-t.cc
=== modified file 'mysql-test/r/type_temporal_fractional.result'
--- a/mysql-test/r/type_temporal_fractional.result	2011-11-18 13:26:35 +0000
+++ b/mysql-test/r/type_temporal_fractional.result	2011-11-19 19:47:50 +0000
@@ -16795,3 +16795,30 @@ c1
 DROP VIEW v1;
 DROP TABLE t1;
 SET timestamp=DEFAULT;
+#
+# Bug#13394031 VALGRIND: CONDITIONAL JUMP/MOVE DEPENDS ON UNINITIALISED IN FIELD::IS_REAL_NULL
+#
+CREATE TABLE t1 (
+pk time,
+c_timestamp timestamp NULL DEFAULT 0,
+c_time time,
+primary key (pk),
+key (c_timestamp)
+) ENGINE=INNODB;
+INSERT INTO t1 VALUES
+(SEC_TO_TIME(2),'20000627024305.040518','00:00:00.000000'),      
+(SEC_TO_TIME(4),'0000-00-00','20010412233415.034269'),                  
+(SEC_TO_TIME(46),'20030628121312.000376','20020323065409.039577'),            
+(SEC_TO_TIME(48),'20071219173306.048009',NULL),            
+(SEC_TO_TIME(50),'0000-00-00',NULL);
+SELECT c_time FROM t1;
+c_time
+00:00:00
+23:34:15
+06:54:09
+NULL
+NULL
+SELECT c_time AS c1 FROM t1
+WHERE c_timestamp NOT IN (NULL, '0000-00-00 00:00:00');
+c1
+DROP TABLE t1;

=== modified file 'mysql-test/t/type_temporal_fractional.test'
--- a/mysql-test/t/type_temporal_fractional.test	2011-11-18 13:26:35 +0000
+++ b/mysql-test/t/type_temporal_fractional.test	2011-11-19 19:47:50 +0000
@@ -7331,6 +7331,27 @@ DROP VIEW v1;
 DROP TABLE t1;
 SET timestamp=DEFAULT;
 
+--echo #
+--echo # Bug#13394031 VALGRIND: CONDITIONAL JUMP/MOVE DEPENDS ON UNINITIALISED IN FIELD::IS_REAL_NULL
+--echo #
+CREATE TABLE t1 (
+  pk time,
+  c_timestamp timestamp NULL DEFAULT 0,
+  c_time time,
+  primary key (pk),
+  key (c_timestamp)
+) ENGINE=INNODB;  
+INSERT INTO t1 VALUES
+(SEC_TO_TIME(2),'20000627024305.040518','00:00:00.000000'),      
+(SEC_TO_TIME(4),'0000-00-00','20010412233415.034269'),                  
+(SEC_TO_TIME(46),'20030628121312.000376','20020323065409.039577'),            
+(SEC_TO_TIME(48),'20071219173306.048009',NULL),            
+(SEC_TO_TIME(50),'0000-00-00',NULL);                  
+SELECT c_time FROM t1;
+SELECT c_time AS c1 FROM t1
+WHERE c_timestamp NOT IN (NULL, '0000-00-00 00:00:00');
+DROP TABLE t1;
+
 
 ## TS-TODO: SELECT CAST('00:00:00' AS DATETIME) -> should it use curdate?
 

=== modified file 'sql/item.cc'
--- a/sql/item.cc	2011-11-18 13:26:35 +0000
+++ b/sql/item.cc	2011-11-19 19:47:50 +0000
@@ -1420,18 +1420,6 @@ int Item::save_in_field_no_warnings(Fiel
 }
 
 
-int Item::save_in_field_packed_no_warnings(Field *field)
-{
-  int err;
-  longlong nr= val_temporal_with_round(field->type(), field->decimals());
-  TABLE *table= field->table;
-  my_bitmap_map *old_map= dbug_tmp_use_all_columns(table, table->write_set);
-  err= field->store_packed(nr);
-  dbug_tmp_restore_column_map(table->write_set, old_map);
-  return err;
-}
-
-
 bool Item::is_blob_field() const
 {
   DBUG_ASSERT(fixed);
@@ -6112,6 +6100,18 @@ int Item_int::save_in_field(Field *field
 }
 
 
+int Item_temporal::save_in_field(Field *field, bool no_conversions)
+{
+  longlong nr= field->is_temporal_with_time() ?
+               val_temporal_with_round(field->type(), field->decimals()) :
+               val_date_temporal();
+  if (null_value)
+    return set_field_to_null(field);
+  field->set_notnull();
+  return field->store_packed(nr);
+}
+
+
 int Item_decimal::save_in_field(Field *field, bool no_conversions)
 {
   field->set_notnull();
@@ -6155,8 +6155,8 @@ Item *Item_time_with_ref::clone_item()
     We need to evaluate the constant to make sure it works with
     parameter markers.
   */
-  return new Item_temporal(ref->name, ref->val_time_temporal(),
-                           ref->max_length);
+  return new Item_temporal(MYSQL_TYPE_TIME, ref->name,
+                           ref->val_time_temporal(), ref->max_length);
 }
 
 
@@ -6167,8 +6167,8 @@ Item *Item_datetime_with_ref::clone_item
     We need to evaluate the constant to make sure it works with
     parameter markers.
   */
-  return new Item_temporal(ref->name, ref->val_date_temporal(),
-                           ref->max_length);
+  return new Item_temporal(MYSQL_TYPE_DATETIME, ref->name,
+                           ref->val_date_temporal(), ref->max_length);
 }
 
 

=== modified file 'sql/item.h'
--- a/sql/item.h	2011-11-18 09:52:00 +0000
+++ b/sql/item.h	2011-11-19 19:47:50 +0000
@@ -629,7 +629,6 @@ public:
     @retval 0         On success.
     @retval >0        In error.
   */
-  int save_in_field_packed_no_warnings(Field *field);
   virtual int save_in_field(Field *field, bool no_conversions);
   virtual void save_org_in_field(Field *field)
   { (void) save_in_field(field, 1); }
@@ -2323,14 +2322,30 @@ public:
 
      WHERE datetime_column NOT IN
      ('2006-04-25 10:00:00','2006-04-25 10:02:00', ...);
+
+  TS-TODO: Can't we use Item_time_literal, Item_date_literal,
+  TS-TODO: and Item_datetime_literal for this purpose?
 */
 class Item_temporal :public Item_int
 {
+  enum_field_types cached_field_type;
 public:
-  Item_temporal(longlong i): Item_int(i) { }
-  Item_temporal(const char *str_arg, longlong i, uint length): Item_int(i)
-  { max_length= length; name= (char*) str_arg; fixed= 1; }
-  Item *clone_item() { return new Item_temporal(value); }
+  Item_temporal(enum_field_types field_type_arg, longlong i): Item_int(i),
+    cached_field_type(field_type_arg)
+  {
+    DBUG_ASSERT(is_temporal_type(field_type_arg));
+  }
+  Item_temporal(enum_field_types field_type_arg,
+                const char *str_arg, longlong i, uint length): Item_int(i),
+    cached_field_type(field_type_arg)
+  {
+    DBUG_ASSERT(is_temporal_type(field_type_arg));
+    max_length= length;
+    name= (char*) str_arg;
+    fixed= 1;
+  }
+  Item *clone_item() { return new Item_temporal(field_type(), value); }
+  int save_in_field(Field *field, bool no_conversions);
   longlong val_time_temporal() { return val_int(); }
   longlong val_date_temporal() { return val_int(); }
   bool get_date(MYSQL_TIME *ltime, uint fuzzydate)
@@ -2345,8 +2360,7 @@ public:
   }
   enum_field_types field_type() const
   {
-    // Currently we don't need to distinguish between DATE, DATETIME, or TIME.
-    return MYSQL_TYPE_DATETIME;
+    return cached_field_type;
   }
 };
 

=== modified file 'sql/item_cmpfunc.h'
--- a/sql/item_cmpfunc.h	2011-11-10 14:58:23 +0000
+++ b/sql/item_cmpfunc.h	2011-11-19 19:47:50 +0000
@@ -986,7 +986,7 @@ public:
     :in_longlong(elements) {};
   Item *create_item()
   {
-    return new Item_temporal(0LL);
+    return new Item_temporal(MYSQL_TYPE_DATETIME, 0LL);
   }
   void set(uint pos, Item *item);
   uchar *get_value(Item *item);
@@ -1000,7 +1000,7 @@ public:
     :in_longlong(elements) {};
   Item *create_item()
   {
-    return new Item_temporal(0LL);
+    return new Item_temporal(MYSQL_TYPE_TIME, 0LL);
   }
   void set(uint pos, Item *item);
   uchar *get_value(Item *item);
@@ -1030,7 +1030,7 @@ public:
   friend int cmp_longlong(void *cmp_arg, packed_longlong *a,packed_longlong *b);
   Item* create_item()
   { 
-    return new Item_temporal((longlong) 0);
+    return new Item_temporal(MYSQL_TYPE_DATETIME, (longlong) 0);
   }
 };
 

=== modified file 'sql/opt_range.cc'
--- a/sql/opt_range.cc	2011-11-17 13:41:28 +0000
+++ b/sql/opt_range.cc	2011-11-19 19:47:50 +0000
@@ -6466,11 +6466,7 @@ get_mm_leaf(RANGE_OPT_PARAM *param, Item
     field->table->in_use->variables.sql_mode|= MODE_INVALID_DATES;
   {
     // Note that value may be a stored function call, executed here.
-    if (value->type() == Item::INT_ITEM && value->is_temporal() &&
-        field->is_temporal_with_time())
-      err= value->save_in_field_packed_no_warnings(field);
-    else
-      err= value->save_in_field_no_warnings(field, 1);
+    err= value->save_in_field_no_warnings(field, 1);
   }
   if (err > 0)
   {

No bundle (reason: useless for push emails).
Thread
bzr push into mysql-trunk branch (alexander.barkov:3600 to 3601)Bug#13394031 WL#946Alexander Barkov21 Nov