List:Commits« Previous MessageNext Message »
From:Dmitry Shulga Date:July 3 2012 10:06am
Subject:bzr push into mysql-trunk branch (Dmitry.Shulga:3900 to 3901) WL#6030
View as plain text  
 3901 Dmitry Shulga	2012-07-03
      This is a prerequisite patch for WL#6030. This patch introduces
      dedicated attibute is_nullable to control the Field's nullability.

    modified:
      sql/field.cc
      sql/field.h
      sql/field_conv.cc
 3900 Dmitry Shulga	2012-06-29
      This is a prerequisite patch for WL#6030. This patch replaces all references
      to Field::null_ptr by call the Field::real_maybe_null() to check for
      Field's nullability.

    modified:
      sql/field.cc
      sql/field.h
      sql/field_conv.cc
      unittest/gunit/field_date-t.cc
      unittest/gunit/field_datetime-t.cc
      unittest/gunit/field_long-t.cc
      unittest/gunit/field_newdecimal-t.cc
      unittest/gunit/mock_field_timestamp.h
      unittest/gunit/mock_field_timestampf.h
=== modified file 'sql/field.cc'
--- a/sql/field.cc	2012-06-29 10:54:21 +0000
+++ b/sql/field.cc	2012-07-03 10:04:33 +0000
@@ -1359,6 +1359,7 @@ Field::Field(uchar *ptr_arg,uint32 lengt
    is_created_from_null_item(FALSE)
 {
   flags=null_ptr ? 0: NOT_NULL_FLAG;
+  is_nullable= null_ptr ? true: false;
   comment.str= (char*) "";
   comment.length=0;
   field_index= 0;
@@ -1894,8 +1895,7 @@ Field *Field::new_key_field(MEM_ROOT *ro
   if ((tmp= new_field(root, new_table, table == new_table)))
   {
     tmp->ptr=      new_ptr;
-    tmp->null_ptr= new_null_ptr;
-    tmp->null_bit= new_null_bit;
+    tmp->set_null_ptr(new_null_ptr, new_null_bit);
   }
   return tmp;
 }

=== modified file 'sql/field.h'
--- a/sql/field.h	2012-06-29 10:54:21 +0000
+++ b/sql/field.h	2012-07-03 10:04:33 +0000
@@ -489,6 +489,13 @@ private:
   */
   uchar		*null_ptr;
 
+  /**
+    This attribute is used to mark the field as NULLable, i.e. the field
+    that can have NULL as its value. Actual NULL value for the field is defined
+    by the value of data member null_ptr.
+  */
+  bool is_nullable;
+
 public:
   /*
     Note that you can use table->in_use as replacement for current_thd member 
@@ -909,7 +916,7 @@ public:
 
   /// @return true if this field is NULL-able, false otherwise.
   bool real_maybe_null(void) const
-  { return null_ptr != 0; }
+  { return is_nullable; }
 
   uint null_offset(const uchar *record) const
   { return (uint) (null_ptr - record); }
@@ -917,10 +924,12 @@ public:
   uint null_offset() const
   { return null_offset(table->record[0]); }
 
-  void set_null_ptr(uchar *p_null_ptr, uint p_null_bit)
+  inline void set_null_ptr(uchar *p_null_ptr, uint p_null_bit)
   {
     null_ptr= p_null_ptr;
     null_bit= p_null_bit;
+    if (null_ptr)
+      is_nullable= true;
   }
 
   enum {
@@ -1005,7 +1014,8 @@ public:
   virtual Field *clone(MEM_ROOT *mem_root) const =0;
   inline void move_field(uchar *ptr_arg,uchar *null_ptr_arg,uchar null_bit_arg)
   {
-    ptr=ptr_arg; null_ptr=null_ptr_arg; null_bit=null_bit_arg;
+    ptr=ptr_arg;
+    set_null_ptr(null_ptr_arg, null_bit_arg);
   }
   inline void move_field(uchar *ptr_arg) { ptr=ptr_arg; }
   virtual void move_field_offset(my_ptrdiff_t ptr_diff)

=== modified file 'sql/field_conv.cc'
--- a/sql/field_conv.cc	2012-06-29 10:54:21 +0000
+++ b/sql/field_conv.cc	2012-07-03 10:04:33 +0000
@@ -545,6 +545,11 @@ static void do_varstring(Copy_field *cop
 void Copy_field::set(uchar *to,Field *from)
 {
   from_ptr=from->ptr;
+  /**
+    We need to know the value of from Field to get nullability flag later
+    during executing the procedure do_field_to_null_str.
+  */
+  from_field= from;
   to_ptr=to;
   from_length=from->pack_length();
   null_row= &from->table->null_row;

No bundle (reason: useless for push emails).
Thread
bzr push into mysql-trunk branch (Dmitry.Shulga:3900 to 3901) WL#6030Dmitry Shulga3 Jul