List:Commits« Previous MessageNext Message »
From:Jon Olav Hauglid Date:August 25 2010 2:13pm
Subject:bzr commit into mysql-next-mr-bugfixing branch (jon.hauglid:3246) Bug#6295
View as plain text  
#At file:///export/home/x/mysql-next-mr-bugfixing-bug6295/ based on revid:holyfoot@stripped

 3246 Jon Olav Hauglid	2010-08-25
      A pre-requisite patch for Bug#6295.
      
      This patch prepares the way for fixing
      "Triggers are not processed for NOT NULL columns"
      by implementing the following changes:
      
      Since NOT NULL fields now must be able to store NULL temporarily,
      we can no longer use null_ptr (i.e. the ability to store NULL)
      to check for nullability. Nullability is now checked using the
      NOT_NULL_FLAG rather than using null_ptr directly.
      
      Changed Field constructors to have nullability as an explicit
      parameter since we cannot rely on checking null_ptr != NULL.
      
      Changed nullability checks to use Field functions rather than 
      directly accessing Field member variables. This is done to make
      it easier to split nullability from the ability to store NULL.
      
      Renamed maybe_null to is_nullable.

    modified:
      sql/field.cc
      sql/field.h
      sql/field_conv.cc
      sql/filesort.cc
      sql/item.cc
      sql/item_subselect.cc
      sql/key.cc
      sql/log_event.cc
      sql/log_event_old.cc
      sql/opt_range.cc
      sql/opt_sum.cc
      sql/rpl_record.cc
      sql/sql_join_cache.cc
      sql/sql_load.cc
      sql/sql_partition.cc
      sql/sql_select.cc
      sql/sql_select.h
      sql/sql_show.cc
      sql/sql_table.cc
      sql/table.cc
      sql/unireg.cc
      storage/csv/ha_tina.cc
      storage/federated/ha_federated.cc
      storage/heap/ha_heap.cc
      storage/ibmdb2i/ha_ibmdb2i.cc
      storage/innobase/handler/ha_innodb.cc
      storage/myisam/ha_myisam.cc
=== modified file 'sql/field.cc'
--- a/sql/field.cc	2010-08-23 17:43:34 +0000
+++ b/sql/field.cc	2010-08-25 14:13:11 +0000
@@ -1110,10 +1110,10 @@ bool Field::type_can_have_key_part(enum 
   Numeric fields base class constructor.
 */
 Field_num::Field_num(uchar *ptr_arg,uint32 len_arg, uchar *null_ptr_arg,
-                     uchar null_bit_arg, utype unireg_check_arg,
-                     const char *field_name_arg,
+                     uchar null_bit_arg, bool is_nullable,
+                     utype unireg_check_arg, const char *field_name_arg,
                      uint8 dec_arg, bool zero_arg, bool unsigned_arg)
-  :Field(ptr_arg, len_arg, null_ptr_arg, null_bit_arg,
+  :Field(ptr_arg, len_arg, null_ptr_arg, null_bit_arg, is_nullable,
          unireg_check_arg, field_name_arg),
   dec(dec_arg),zerofill(zero_arg),unsigned_flag(unsigned_arg)
 {
@@ -1303,8 +1303,8 @@ String *Field::val_int_as_str(String *va
 
 /// This is used as a table name when the table structure is not set up
 Field::Field(uchar *ptr_arg,uint32 length_arg,uchar *null_ptr_arg,
-	     uchar null_bit_arg,
-	     utype unireg_check_arg, const char *field_name_arg)
+             uchar null_bit_arg, bool is_nullable,
+             utype unireg_check_arg, const char *field_name_arg)
   :ptr(ptr_arg), null_ptr(null_ptr_arg),
    table(0), orig_table(0), table_name(0),
    field_name(field_name_arg),
@@ -1312,7 +1312,7 @@ Field::Field(uchar *ptr_arg,uint32 lengt
    field_length(length_arg), null_bit(null_bit_arg), 
    is_created_from_null_item(FALSE)
 {
-  flags=null_ptr ? 0: NOT_NULL_FLAG;
+  flags=is_nullable ? 0: NOT_NULL_FLAG;
   comment.str= (char*) "";
   comment.length=0;
   field_index= 0;
@@ -1672,9 +1672,10 @@ my_decimal* Field_num::val_decimal(my_de
 
 
 Field_str::Field_str(uchar *ptr_arg,uint32 len_arg, uchar *null_ptr_arg,
-                     uchar null_bit_arg, utype unireg_check_arg,
+                     uchar null_bit_arg, bool is_nullable,
+                     utype unireg_check_arg,
                      const char *field_name_arg, CHARSET_INFO *charset_arg)
-  :Field(ptr_arg, len_arg, null_ptr_arg, null_bit_arg,
+  :Field(ptr_arg, len_arg, null_ptr_arg, null_bit_arg, is_nullable,
          unireg_check_arg, field_name_arg)
 {
   field_charset= charset_arg;
@@ -1832,7 +1833,7 @@ Field *Field::new_field(MEM_ROOT *root, 
 
 Field *Field::new_key_field(MEM_ROOT *root, TABLE *new_table,
                             uchar *new_ptr, uchar *new_null_ptr,
-                            uint new_null_bit)
+                            uint new_null_bit, bool is_nullable)
 {
   Field *tmp;
   if ((tmp= new_field(root, new_table, table == new_table)))
@@ -1840,6 +1841,7 @@ Field *Field::new_key_field(MEM_ROOT *ro
     tmp->ptr=      new_ptr;
     tmp->null_ptr= new_null_ptr;
     tmp->null_bit= new_null_bit;
+    tmp->flags=    is_nullable ? 0: NOT_NULL_FLAG;
   }
   return tmp;
 }
@@ -2484,12 +2486,12 @@ void Field_decimal::sql_type(String &res
 
 Field_new_decimal::Field_new_decimal(uchar *ptr_arg,
                                      uint32 len_arg, uchar *null_ptr_arg,
-                                     uchar null_bit_arg,
+                                     uchar null_bit_arg, bool is_nullable,
                                      enum utype unireg_check_arg,
                                      const char *field_name_arg,
                                      uint8 dec_arg,bool zero_arg,
                                      bool unsigned_arg)
-  :Field_num(ptr_arg, len_arg, null_ptr_arg, null_bit_arg,
+  :Field_num(ptr_arg, len_arg, null_ptr_arg, null_bit_arg, is_nullable,
              unireg_check_arg, field_name_arg, dec_arg, zero_arg, unsigned_arg)
 {
   precision= my_decimal_length_to_precision(len_arg, dec_arg, unsigned_arg);
@@ -2501,12 +2503,11 @@ Field_new_decimal::Field_new_decimal(uch
 
 
 Field_new_decimal::Field_new_decimal(uint32 len_arg,
-                                     bool maybe_null_arg,
+                                     bool is_nullable,
                                      const char *name,
                                      uint8 dec_arg,
                                      bool unsigned_arg)
-  :Field_num((uchar*) 0, len_arg,
-             maybe_null_arg ? (uchar*) "": 0, 0,
+  :Field_num((uchar*) 0, len_arg, is_nullable ? (uchar*) "": 0, 0, is_nullable,
              NONE, name, dec_arg, 0, unsigned_arg)
 {
   precision= my_decimal_length_to_precision(len_arg, dec_arg, unsigned_arg);
@@ -4686,12 +4687,13 @@ void Field_double::sql_type(String &res)
 
 Field_timestamp::Field_timestamp(uchar *ptr_arg, uint32 len_arg,
                                  uchar *null_ptr_arg, uchar null_bit_arg,
+                                 bool is_nullable,
 				 enum utype unireg_check_arg,
 				 const char *field_name_arg,
 				 TABLE_SHARE *share,
 				 CHARSET_INFO *cs)
   :Field_str(ptr_arg, MAX_DATETIME_WIDTH, null_ptr_arg, null_bit_arg,
-	     unireg_check_arg, field_name_arg, cs)
+             is_nullable, unireg_check_arg, field_name_arg, cs)
 {
   /* For 4.0 MYD and 4.0 InnoDB compatibility */
   flags|= ZEROFILL_FLAG | UNSIGNED_FLAG | BINARY_FLAG;
@@ -4706,12 +4708,12 @@ Field_timestamp::Field_timestamp(uchar *
 }
 
 
-Field_timestamp::Field_timestamp(bool maybe_null_arg,
+Field_timestamp::Field_timestamp(bool is_nullable,
                                  const char *field_name_arg,
                                  CHARSET_INFO *cs)
   :Field_str((uchar*) 0, MAX_DATETIME_WIDTH,
-             maybe_null_arg ? (uchar*) "": 0, 0,
-	     NONE, field_name_arg, cs)
+             is_nullable ? (uchar*) "": 0, 0,
+             is_nullable, NONE, field_name_arg, cs)
 {
   /* For 4.0 MYD and 4.0 InnoDB compatibility */
   flags|= ZEROFILL_FLAG | UNSIGNED_FLAG | BINARY_FLAG;
@@ -6748,7 +6750,7 @@ Field *Field_string::new_field(MEM_ROOT 
   Field *field;
   if (type() != MYSQL_TYPE_VAR_STRING || keep_type)
     field= Field::new_field(root, new_table, keep_type);
-  else if ((field= new Field_varstring(field_length, maybe_null(), field_name,
+  else if ((field= new Field_varstring(field_length, is_nullable(), field_name,
                                        new_table->s, charset())))
   {
     /*
@@ -7198,14 +7200,15 @@ Field *Field_varstring::new_field(MEM_RO
 Field *Field_varstring::new_key_field(MEM_ROOT *root,
                                       TABLE *new_table,
                                       uchar *new_ptr, uchar *new_null_ptr,
-                                      uint new_null_bit)
+                                      uint new_null_bit, bool is_nullable)
 {
   Field_varstring *res;
   if ((res= (Field_varstring*) Field::new_key_field(root,
                                                     new_table,
                                                     new_ptr,
                                                     new_null_ptr,
-                                                    new_null_bit)))
+                                                    new_null_bit,
+                                                    is_nullable)))
   {
     /* Keys length prefixes are always packed with 2 bytes */
     res->length_bytes= 2;
@@ -7252,12 +7255,12 @@ void Field_varstring::hash(ulong *nr, ul
 ****************************************************************************/
 
 Field_blob::Field_blob(uchar *ptr_arg, uchar *null_ptr_arg, uchar null_bit_arg,
-		       enum utype unireg_check_arg, const char *field_name_arg,
-                       TABLE_SHARE *share, uint blob_pack_length,
-		       CHARSET_INFO *cs)
+                       bool is_nullable, enum utype unireg_check_arg,
+                       const char *field_name_arg, TABLE_SHARE *share,
+                       uint blob_pack_length, CHARSET_INFO *cs)
   :Field_longstr(ptr_arg, BLOB_PACK_LENGTH_TO_MAX_LENGH(blob_pack_length),
-                 null_ptr_arg, null_bit_arg, unireg_check_arg, field_name_arg,
-                 cs),
+                 null_ptr_arg, null_bit_arg, is_nullable, unireg_check_arg,
+                 field_name_arg, cs),
    packlength(blob_pack_length)
 {
   DBUG_ASSERT(blob_pack_length <= 4); // Only pack lengths 1-4 supported currently
@@ -8489,9 +8492,10 @@ uint Field_num::is_equal(Create_field *n
 */
 
 Field_bit::Field_bit(uchar *ptr_arg, uint32 len_arg, uchar *null_ptr_arg,
-                     uchar null_bit_arg, uchar *bit_ptr_arg, uchar bit_ofs_arg,
-                     enum utype unireg_check_arg, const char *field_name_arg)
-  : Field(ptr_arg, len_arg, null_ptr_arg, null_bit_arg,
+                     uchar null_bit_arg, bool is_nullable, uchar *bit_ptr_arg,
+                     uchar bit_ofs_arg, enum utype unireg_check_arg,
+                     const char *field_name_arg)
+  : Field(ptr_arg, len_arg, null_ptr_arg, null_bit_arg, is_nullable,
           unireg_check_arg, field_name_arg),
     bit_ptr(bit_ptr_arg), bit_ofs(bit_ofs_arg), bit_len(len_arg & 7),
     bytes_in_rec(len_arg / 8)
@@ -8557,12 +8561,12 @@ Field_bit::do_last_null_byte() const
 Field *Field_bit::new_key_field(MEM_ROOT *root,
                                 TABLE *new_table,
                                 uchar *new_ptr, uchar *new_null_ptr,
-                                uint new_null_bit)
+                                uint new_null_bit, bool is_nullable)
 {
   Field_bit *res;
   if ((res= (Field_bit*) Field::new_key_field(root, new_table,
                                               new_ptr, new_null_ptr,
-                                              new_null_bit)))
+                                              new_null_bit, is_nullable)))
   {
     /* Move bits normally stored in null_pointer to new_ptr */
     res->bit_ptr= new_ptr;
@@ -9008,9 +9012,10 @@ void Field_bit::set_default()
 
 Field_bit_as_char::Field_bit_as_char(uchar *ptr_arg, uint32 len_arg,
                                      uchar *null_ptr_arg, uchar null_bit_arg,
+                                     bool is_nullable,
                                      enum utype unireg_check_arg,
                                      const char *field_name_arg)
-  :Field_bit(ptr_arg, len_arg, null_ptr_arg, null_bit_arg, 0, 0,
+  :Field_bit(ptr_arg, len_arg, null_ptr_arg, null_bit_arg, is_nullable, 0, 0,
              unireg_check_arg, field_name_arg)
 {
   flags|= UNSIGNED_FLAG;
@@ -9687,18 +9692,19 @@ Field *make_field(TABLE_SHARE *share, uc
 {
   uchar *UNINIT_VAR(bit_ptr);
   uchar UNINIT_VAR(bit_offset);
+  bool is_nullable= f_maybe_null(pack_flag);
   if (field_type == MYSQL_TYPE_BIT && !f_bit_as_char(pack_flag))
   {
     bit_ptr= null_pos;
     bit_offset= null_bit;
-    if (f_maybe_null(pack_flag))         // if null field
+    if (is_nullable)         // if null field
     {
        bit_ptr+= (null_bit == 7);        // shift bit_ptr and bit_offset
        bit_offset= (bit_offset + 1) & 7;
     }
   }
 
-  if (!f_maybe_null(pack_flag))
+  if (!is_nullable)
   {
     null_pos=0;
     null_bit=0;
@@ -9733,13 +9739,13 @@ Field *make_field(TABLE_SHARE *share, uc
       if (field_type == MYSQL_TYPE_STRING ||
           field_type == MYSQL_TYPE_DECIMAL ||   // 3.23 or 4.0 string
           field_type == MYSQL_TYPE_VAR_STRING)
-        return new Field_string(ptr,field_length,null_pos,null_bit,
+        return new Field_string(ptr,field_length,null_pos,null_bit,is_nullable,
                                 unireg_check, field_name,
                                 field_charset);
       if (field_type == MYSQL_TYPE_VARCHAR)
         return new Field_varstring(ptr,field_length,
                                    HA_VARCHAR_PACKLENGTH(field_length),
-                                   null_pos,null_bit,
+                                   null_pos,null_bit, is_nullable,
                                    unireg_check, field_name,
                                    share,
                                    field_charset);
@@ -9752,22 +9758,22 @@ Field *make_field(TABLE_SHARE *share, uc
 
 #ifdef HAVE_SPATIAL
     if (f_is_geom(pack_flag))
-      return new Field_geom(ptr,null_pos,null_bit,
+      return new Field_geom(ptr,null_pos,null_bit,is_nullable,
 			    unireg_check, field_name, share,
 			    pack_length, geom_type);
 #endif
     if (f_is_blob(pack_flag))
-      return new Field_blob(ptr,null_pos,null_bit,
+      return new Field_blob(ptr,null_pos,null_bit,is_nullable,
 			    unireg_check, field_name, share,
 			    pack_length, field_charset);
     if (interval)
     {
       if (f_is_enum(pack_flag))
-	return new Field_enum(ptr,field_length,null_pos,null_bit,
+        return new Field_enum(ptr,field_length,null_pos,null_bit,is_nullable,
 				  unireg_check, field_name,
 				  pack_length, interval, field_charset);
       else
-	return new Field_set(ptr,field_length,null_pos,null_bit,
+        return new Field_set(ptr,field_length,null_pos,null_bit,is_nullable,
 			     unireg_check, field_name,
 			     pack_length, interval, field_charset);
     }
@@ -9775,82 +9781,82 @@ Field *make_field(TABLE_SHARE *share, uc
 
   switch (field_type) {
   case MYSQL_TYPE_DECIMAL:
-    return new Field_decimal(ptr,field_length,null_pos,null_bit,
+    return new Field_decimal(ptr,field_length,null_pos,null_bit,is_nullable,
 			     unireg_check, field_name,
 			     f_decimals(pack_flag),
 			     f_is_zerofill(pack_flag) != 0,
 			     f_is_dec(pack_flag) == 0);
   case MYSQL_TYPE_NEWDECIMAL:
-    return new Field_new_decimal(ptr,field_length,null_pos,null_bit,
+    return new Field_new_decimal(ptr,field_length,null_pos,null_bit,is_nullable,
                                  unireg_check, field_name,
                                  f_decimals(pack_flag),
                                  f_is_zerofill(pack_flag) != 0,
                                  f_is_dec(pack_flag) == 0);
   case MYSQL_TYPE_FLOAT:
-    return new Field_float(ptr,field_length,null_pos,null_bit,
+    return new Field_float(ptr,field_length,null_pos,null_bit,is_nullable,
 			   unireg_check, field_name,
 			   f_decimals(pack_flag),
 			   f_is_zerofill(pack_flag) != 0,
 			   f_is_dec(pack_flag)== 0);
   case MYSQL_TYPE_DOUBLE:
-    return new Field_double(ptr,field_length,null_pos,null_bit,
+    return new Field_double(ptr,field_length,null_pos,null_bit,is_nullable,
 			    unireg_check, field_name,
 			    f_decimals(pack_flag),
 			    f_is_zerofill(pack_flag) != 0,
 			    f_is_dec(pack_flag)== 0);
   case MYSQL_TYPE_TINY:
-    return new Field_tiny(ptr,field_length,null_pos,null_bit,
+    return new Field_tiny(ptr,field_length,null_pos,null_bit,is_nullable,
 			  unireg_check, field_name,
 			  f_is_zerofill(pack_flag) != 0,
 			  f_is_dec(pack_flag) == 0);
   case MYSQL_TYPE_SHORT:
-    return new Field_short(ptr,field_length,null_pos,null_bit,
+    return new Field_short(ptr,field_length,null_pos,null_bit,is_nullable,
 			   unireg_check, field_name,
 			   f_is_zerofill(pack_flag) != 0,
 			   f_is_dec(pack_flag) == 0);
   case MYSQL_TYPE_INT24:
-    return new Field_medium(ptr,field_length,null_pos,null_bit,
+    return new Field_medium(ptr,field_length,null_pos,null_bit,is_nullable,
 			    unireg_check, field_name,
 			    f_is_zerofill(pack_flag) != 0,
 			    f_is_dec(pack_flag) == 0);
   case MYSQL_TYPE_LONG:
-    return new Field_long(ptr,field_length,null_pos,null_bit,
+    return new Field_long(ptr,field_length,null_pos,null_bit,is_nullable,
 			   unireg_check, field_name,
 			   f_is_zerofill(pack_flag) != 0,
 			   f_is_dec(pack_flag) == 0);
   case MYSQL_TYPE_LONGLONG:
-    return new Field_longlong(ptr,field_length,null_pos,null_bit,
+    return new Field_longlong(ptr,field_length,null_pos,null_bit,is_nullable,
 			      unireg_check, field_name,
 			      f_is_zerofill(pack_flag) != 0,
 			      f_is_dec(pack_flag) == 0);
   case MYSQL_TYPE_TIMESTAMP:
-    return new Field_timestamp(ptr,field_length, null_pos, null_bit,
+    return new Field_timestamp(ptr,field_length, null_pos, null_bit,is_nullable,
                                unireg_check, field_name, share,
                                field_charset);
   case MYSQL_TYPE_YEAR:
-    return new Field_year(ptr,field_length,null_pos,null_bit,
+    return new Field_year(ptr,field_length,null_pos,null_bit,is_nullable,
 			  unireg_check, field_name);
   case MYSQL_TYPE_DATE:
-    return new Field_date(ptr,null_pos,null_bit,
+    return new Field_date(ptr,null_pos,null_bit,is_nullable,
 			  unireg_check, field_name, field_charset);
   case MYSQL_TYPE_NEWDATE:
-    return new Field_newdate(ptr,null_pos,null_bit,
+    return new Field_newdate(ptr,null_pos,null_bit,is_nullable,
 			     unireg_check, field_name, field_charset);
   case MYSQL_TYPE_TIME:
-    return new Field_time(ptr,null_pos,null_bit,
+    return new Field_time(ptr,null_pos,null_bit,is_nullable,
 			  unireg_check, field_name, field_charset);
   case MYSQL_TYPE_DATETIME:
-    return new Field_datetime(ptr,null_pos,null_bit,
+    return new Field_datetime(ptr,null_pos,null_bit,is_nullable,
 			      unireg_check, field_name, field_charset);
   case MYSQL_TYPE_NULL:
     return new Field_null(ptr, field_length, unireg_check, field_name,
                           field_charset);
   case MYSQL_TYPE_BIT:
     return f_bit_as_char(pack_flag) ?
-           new Field_bit_as_char(ptr, field_length, null_pos, null_bit,
-                                 unireg_check, field_name) :
-           new Field_bit(ptr, field_length, null_pos, null_bit, bit_ptr,
-                         bit_offset, unireg_check, field_name);
+      new Field_bit_as_char(ptr, field_length, null_pos, null_bit,
+                            is_nullable, unireg_check, field_name) :
+      new Field_bit(ptr, field_length, null_pos, null_bit, is_nullable, bit_ptr,
+                    bit_offset, unireg_check, field_name);
 
   default:					// Impossible (Wrong version)
     break;

=== modified file 'sql/field.h'
--- a/sql/field.h	2010-07-26 11:34:07 +0000
+++ b/sql/field.h	2010-08-25 14:13:11 +0000
@@ -142,7 +142,7 @@ public:
   bool is_created_from_null_item;
 
   Field(uchar *ptr_arg,uint32 length_arg,uchar *null_ptr_arg,
-        uchar null_bit_arg, utype unireg_check_arg,
+        uchar null_bit_arg, bool is_nullable, utype unireg_check_arg,
         const char *field_name_arg);
   virtual ~Field() {}
   /* Store functions returns 1 on overflow and -1 on fatal error */
@@ -236,7 +236,7 @@ public:
     my_ptrdiff_t l_offset= (my_ptrdiff_t) (table->s->default_values -
 					  table->record[0]);
     memcpy(ptr, ptr + l_offset, pack_length());
-    if (null_ptr)
+    if (real_is_nullable())
       *null_ptr= ((*null_ptr & (uchar) ~null_bit) |
 		  (null_ptr[l_offset] & null_bit));
   }
@@ -269,31 +269,25 @@ public:
   virtual void sql_type(String &str) const =0;
   virtual uint size_of() const =0;		// For new field
   inline bool is_null(my_ptrdiff_t row_offset= 0)
-  { return null_ptr ? (null_ptr[row_offset] & null_bit ? 1 : 0) : table->null_row; }
+  { return real_is_nullable() ? (null_ptr[row_offset] & null_bit ? TRUE : FALSE) : table->null_row; }
   inline bool is_real_null(my_ptrdiff_t row_offset= 0)
-    { return null_ptr ? (null_ptr[row_offset] & null_bit ? 1 : 0) : 0; }
+  { return real_is_nullable() ? (null_ptr[row_offset] & null_bit ? TRUE : FALSE) : FALSE; }
   inline bool is_null_in_record(const uchar *record)
   {
-    if (!null_ptr)
-      return 0;
-    return test(record[(uint) (null_ptr -table->record[0])] &
-		null_bit);
-  }
-  inline bool is_null_in_record_with_offset(my_ptrdiff_t offset)
-  {
-    if (!null_ptr)
-      return 0;
-    return test(null_ptr[offset] & null_bit);
+    if (!real_is_nullable())
+      return FALSE;
+    return test(record[(uint) (null_ptr -table->record[0])] & null_bit);
   }
   inline void set_null(my_ptrdiff_t row_offset= 0)
-    { if (null_ptr) null_ptr[row_offset]|= null_bit; }
+  { if (real_is_nullable()) null_ptr[row_offset]|= null_bit; }
   inline void set_notnull(my_ptrdiff_t row_offset= 0)
-    { if (null_ptr) null_ptr[row_offset]&= (uchar) ~null_bit; }
-  inline bool maybe_null(void) { return null_ptr != 0 || table->maybe_null; }
+  { if (null_ptr) null_ptr[row_offset]&= (uchar) ~null_bit; }
+  inline bool is_nullable(void) { return real_is_nullable() || table->maybe_null; }
   /**
      Signals that this field is NULL-able.
   */
-  inline bool real_maybe_null(void) { return null_ptr != 0; }
+  inline bool real_is_nullable(void)
+  { return !(flags & NOT_NULL_FLAG); }
 
   enum {
     LAST_NULL_BYTE_UNDEF= 0
@@ -337,7 +331,7 @@ public:
                            bool keep_type);
   virtual Field *new_key_field(MEM_ROOT *root, TABLE *new_table,
                                uchar *new_ptr, uchar *new_null_ptr,
-                               uint new_null_bit);
+                               uint new_null_bit, bool is_nullable);
   Field *clone(MEM_ROOT *mem_root, TABLE *new_table);
   inline void move_field(uchar *ptr_arg,uchar *null_ptr_arg,uchar null_bit_arg)
   {
@@ -655,8 +649,8 @@ public:
   const uint8 dec;
   bool zerofill,unsigned_flag;	// Purify cannot handle bit fields
   Field_num(uchar *ptr_arg,uint32 len_arg, uchar *null_ptr_arg,
-	    uchar null_bit_arg, utype unireg_check_arg,
-	    const char *field_name_arg,
+            uchar null_bit_arg, bool is_nullable, utype unireg_check_arg,
+            const char *field_name_arg,
             uint8 dec_arg, bool zero_arg, bool unsigned_arg);
   Item_result result_type () const { return REAL_RESULT; }
   enum Derivation derivation(void) const { return DERIVATION_NUMERIC; }
@@ -693,8 +687,8 @@ protected:
   enum Derivation field_derivation;
 public:
   Field_str(uchar *ptr_arg,uint32 len_arg, uchar *null_ptr_arg,
-	    uchar null_bit_arg, utype unireg_check_arg,
-	    const char *field_name_arg, CHARSET_INFO *charset);
+            uchar null_bit_arg, bool is_nullable, utype unireg_check_arg,
+            const char *field_name_arg, CHARSET_INFO *charset);
   Item_result result_type () const { return STRING_RESULT; }
   uint decimals() const { return NOT_FIXED_DEC; }
   int  store(double nr);
@@ -729,10 +723,10 @@ protected:
                                bool count_spaces);
 public:
   Field_longstr(uchar *ptr_arg, uint32 len_arg, uchar *null_ptr_arg,
-                uchar null_bit_arg, utype unireg_check_arg,
+                uchar null_bit_arg, bool is_nullable, utype unireg_check_arg,
                 const char *field_name_arg, CHARSET_INFO *charset_arg)
-    :Field_str(ptr_arg, len_arg, null_ptr_arg, null_bit_arg, unireg_check_arg,
-               field_name_arg, charset_arg)
+    :Field_str(ptr_arg, len_arg, null_ptr_arg, null_bit_arg, is_nullable,
+               unireg_check_arg, field_name_arg, charset_arg)
     {}
 
   int store_decimal(const my_decimal *d);
@@ -745,11 +739,12 @@ public:
   my_bool not_fixed;
 
   Field_real(uchar *ptr_arg, uint32 len_arg, uchar *null_ptr_arg,
-             uchar null_bit_arg, utype unireg_check_arg,
+             uchar null_bit_arg, bool is_nullable, utype unireg_check_arg,
              const char *field_name_arg,
              uint8 dec_arg, bool zero_arg, bool unsigned_arg)
-    :Field_num(ptr_arg, len_arg, null_ptr_arg, null_bit_arg, unireg_check_arg,
-               field_name_arg, dec_arg, zero_arg, unsigned_arg),
+    :Field_num(ptr_arg, len_arg, null_ptr_arg, null_bit_arg, is_nullable,
+               unireg_check_arg, field_name_arg, dec_arg, zero_arg,
+               unsigned_arg),
     not_fixed(dec_arg >= NOT_FIXED_DEC)
     {}
   int store_decimal(const my_decimal *);
@@ -767,10 +762,10 @@ public:
 class Field_decimal :public Field_real {
 public:
   Field_decimal(uchar *ptr_arg, uint32 len_arg, uchar *null_ptr_arg,
-		uchar null_bit_arg,
-		enum utype unireg_check_arg, const char *field_name_arg,
-		uint8 dec_arg,bool zero_arg,bool unsigned_arg)
-    :Field_real(ptr_arg, len_arg, null_ptr_arg, null_bit_arg,
+                uchar null_bit_arg, bool is_nullable,
+                enum utype unireg_check_arg, const char *field_name_arg,
+                uint8 dec_arg,bool zero_arg,bool unsigned_arg)
+    :Field_real(ptr_arg, len_arg, null_ptr_arg, null_bit_arg, is_nullable,
                 unireg_check_arg, field_name_arg,
                 dec_arg, zero_arg, unsigned_arg)
     {}
@@ -817,10 +812,10 @@ public:
     CREATE TABLE ( DECIMAL(x,y)) 
   */
   Field_new_decimal(uchar *ptr_arg, uint32 len_arg, uchar *null_ptr_arg,
-                    uchar null_bit_arg,
+                    uchar null_bit_arg, bool is_nullable,
                     enum utype unireg_check_arg, const char *field_name_arg,
                     uint8 dec_arg, bool zero_arg, bool unsigned_arg);
-  Field_new_decimal(uint32 len_arg, bool maybe_null_arg,
+  Field_new_decimal(uint32 len_arg, bool is_nullable,
                     const char *field_name_arg, uint8 dec_arg,
                     bool unsigned_arg);
   enum_field_types type() const { return MYSQL_TYPE_NEWDECIMAL;}
@@ -859,12 +854,12 @@ public:
 class Field_tiny :public Field_num {
 public:
   Field_tiny(uchar *ptr_arg, uint32 len_arg, uchar *null_ptr_arg,
-	     uchar null_bit_arg,
-	     enum utype unireg_check_arg, const char *field_name_arg,
-	     bool zero_arg, bool unsigned_arg)
-    :Field_num(ptr_arg, len_arg, null_ptr_arg, null_bit_arg,
-	       unireg_check_arg, field_name_arg,
-	       0, zero_arg,unsigned_arg)
+             uchar null_bit_arg, bool is_nullable,
+             enum utype unireg_check_arg, const char *field_name_arg,
+             bool zero_arg, bool unsigned_arg)
+    :Field_num(ptr_arg, len_arg, null_ptr_arg, null_bit_arg, is_nullable,
+               unireg_check_arg, field_name_arg,
+               0, zero_arg,unsigned_arg)
     {}
   enum Item_result result_type () const { return INT_RESULT; }
   enum_field_types type() const { return MYSQL_TYPE_TINY;}
@@ -903,17 +898,12 @@ public:
 class Field_short :public Field_num {
 public:
   Field_short(uchar *ptr_arg, uint32 len_arg, uchar *null_ptr_arg,
-	      uchar null_bit_arg,
-	      enum utype unireg_check_arg, const char *field_name_arg,
-	      bool zero_arg, bool unsigned_arg)
-    :Field_num(ptr_arg, len_arg, null_ptr_arg, null_bit_arg,
-	       unireg_check_arg, field_name_arg,
-	       0, zero_arg,unsigned_arg)
-    {}
-  Field_short(uint32 len_arg,bool maybe_null_arg, const char *field_name_arg,
-	      bool unsigned_arg)
-    :Field_num((uchar*) 0, len_arg, maybe_null_arg ? (uchar*) "": 0,0,
-	       NONE, field_name_arg, 0, 0, unsigned_arg)
+              uchar null_bit_arg, bool is_nullable,
+              enum utype unireg_check_arg, const char *field_name_arg,
+              bool zero_arg, bool unsigned_arg)
+    :Field_num(ptr_arg, len_arg, null_ptr_arg, null_bit_arg, is_nullable,
+               unireg_check_arg, field_name_arg,
+               0, zero_arg,unsigned_arg)
     {}
   enum Item_result result_type () const { return INT_RESULT; }
   enum_field_types type() const { return MYSQL_TYPE_SHORT;}
@@ -977,12 +967,12 @@ public:
 class Field_medium :public Field_num {
 public:
   Field_medium(uchar *ptr_arg, uint32 len_arg, uchar *null_ptr_arg,
-	      uchar null_bit_arg,
-	      enum utype unireg_check_arg, const char *field_name_arg,
-	      bool zero_arg, bool unsigned_arg)
-    :Field_num(ptr_arg, len_arg, null_ptr_arg, null_bit_arg,
-	       unireg_check_arg, field_name_arg,
-	       0, zero_arg,unsigned_arg)
+               uchar null_bit_arg, bool is_nullable,
+               enum utype unireg_check_arg, const char *field_name_arg,
+               bool zero_arg, bool unsigned_arg)
+    :Field_num(ptr_arg, len_arg, null_ptr_arg, null_bit_arg, is_nullable,
+               unireg_check_arg, field_name_arg,
+               0, zero_arg,unsigned_arg)
     {}
   enum Item_result result_type () const { return INT_RESULT; }
   enum_field_types type() const { return MYSQL_TYPE_INT24;}
@@ -1019,18 +1009,18 @@ public:
 class Field_long :public Field_num {
 public:
   Field_long(uchar *ptr_arg, uint32 len_arg, uchar *null_ptr_arg,
-	     uchar null_bit_arg,
-	     enum utype unireg_check_arg, const char *field_name_arg,
-	     bool zero_arg, bool unsigned_arg)
-    :Field_num(ptr_arg, len_arg, null_ptr_arg, null_bit_arg,
-	       unireg_check_arg, field_name_arg,
-	       0, zero_arg,unsigned_arg)
-    {}
-  Field_long(uint32 len_arg,bool maybe_null_arg, const char *field_name_arg,
-	     bool unsigned_arg)
-    :Field_num((uchar*) 0, len_arg, maybe_null_arg ? (uchar*) "": 0,0,
-	       NONE, field_name_arg,0,0,unsigned_arg)
+             uchar null_bit_arg, bool is_nullable,
+             enum utype unireg_check_arg, const char *field_name_arg,
+             bool zero_arg, bool unsigned_arg)
+    :Field_num(ptr_arg, len_arg, null_ptr_arg, null_bit_arg, is_nullable,
+               unireg_check_arg, field_name_arg,
+               0, zero_arg,unsigned_arg)
     {}
+  Field_long(uint32 len_arg,bool is_nullable, const char *field_name_arg,
+             bool unsigned_arg)
+    :Field_num((uchar*) 0, len_arg, is_nullable ? (uchar*) "": 0,0,
+               is_nullable, NONE, field_name_arg,0,0,unsigned_arg)
+               {}
   enum Item_result result_type () const { return INT_RESULT; }
   enum_field_types type() const { return MYSQL_TYPE_LONG;}
   enum ha_base_keytype key_type() const
@@ -1067,19 +1057,19 @@ public:
 class Field_longlong :public Field_num {
 public:
   Field_longlong(uchar *ptr_arg, uint32 len_arg, uchar *null_ptr_arg,
-	      uchar null_bit_arg,
-	      enum utype unireg_check_arg, const char *field_name_arg,
-	      bool zero_arg, bool unsigned_arg)
-    :Field_num(ptr_arg, len_arg, null_ptr_arg, null_bit_arg,
-	       unireg_check_arg, field_name_arg,
-	       0, zero_arg,unsigned_arg)
-    {}
-  Field_longlong(uint32 len_arg,bool maybe_null_arg,
-		 const char *field_name_arg,
-		  bool unsigned_arg)
-    :Field_num((uchar*) 0, len_arg, maybe_null_arg ? (uchar*) "": 0,0,
-	       NONE, field_name_arg,0,0,unsigned_arg)
+                 uchar null_bit_arg, bool is_nullable,
+                 enum utype unireg_check_arg, const char *field_name_arg,
+                 bool zero_arg, bool unsigned_arg)
+    :Field_num(ptr_arg, len_arg, null_ptr_arg, null_bit_arg, is_nullable,
+               unireg_check_arg, field_name_arg,
+               0, zero_arg,unsigned_arg)
     {}
+  Field_longlong(uint32 len_arg,bool is_nullable,
+                 const char *field_name_arg,
+                 bool unsigned_arg)
+    :Field_num((uchar*) 0, len_arg, is_nullable ? (uchar*) "": 0,0,
+                is_nullable, NONE, field_name_arg,0,0,unsigned_arg)
+               {}
   enum Item_result result_type () const { return INT_RESULT; }
   enum_field_types type() const { return MYSQL_TYPE_LONGLONG;}
   enum ha_base_keytype key_type() const
@@ -1121,18 +1111,13 @@ public:
 class Field_float :public Field_real {
 public:
   Field_float(uchar *ptr_arg, uint32 len_arg, uchar *null_ptr_arg,
-	      uchar null_bit_arg,
-	      enum utype unireg_check_arg, const char *field_name_arg,
+              uchar null_bit_arg, bool is_nullable,
+              enum utype unireg_check_arg, const char *field_name_arg,
               uint8 dec_arg,bool zero_arg,bool unsigned_arg)
-    :Field_real(ptr_arg, len_arg, null_ptr_arg, null_bit_arg,
+    :Field_real(ptr_arg, len_arg, null_ptr_arg, null_bit_arg, is_nullable,
                 unireg_check_arg, field_name_arg,
                 dec_arg, zero_arg, unsigned_arg)
-    {}
-  Field_float(uint32 len_arg, bool maybe_null_arg, const char *field_name_arg,
-	      uint8 dec_arg)
-    :Field_real((uchar*) 0, len_arg, maybe_null_arg ? (uchar*) "": 0, (uint) 0,
-                NONE, field_name_arg, dec_arg, 0, 0)
-    {}
+  {}
   enum_field_types type() const { return MYSQL_TYPE_FLOAT;}
   enum ha_base_keytype key_type() const { return HA_KEYTYPE_FLOAT; }
   int store(const char *to,uint length,CHARSET_INFO *charset);
@@ -1156,23 +1141,23 @@ private:
 class Field_double :public Field_real {
 public:
   Field_double(uchar *ptr_arg, uint32 len_arg, uchar *null_ptr_arg,
-	       uchar null_bit_arg,
-	       enum utype unireg_check_arg, const char *field_name_arg,
-	       uint8 dec_arg,bool zero_arg,bool unsigned_arg)
-    :Field_real(ptr_arg, len_arg, null_ptr_arg, null_bit_arg,
+               uchar null_bit_arg, bool is_nullable,
+               enum utype unireg_check_arg, const char *field_name_arg,
+               uint8 dec_arg,bool zero_arg,bool unsigned_arg)
+    :Field_real(ptr_arg, len_arg, null_ptr_arg, null_bit_arg, is_nullable,
                 unireg_check_arg, field_name_arg,
                 dec_arg, zero_arg, unsigned_arg)
     {}
-  Field_double(uint32 len_arg, bool maybe_null_arg, const char *field_name_arg,
-	       uint8 dec_arg)
-    :Field_real((uchar*) 0, len_arg, maybe_null_arg ? (uchar*) "" : 0, (uint) 0,
-                NONE, field_name_arg, dec_arg, 0, 0)
-    {}
-  Field_double(uint32 len_arg, bool maybe_null_arg, const char *field_name_arg,
+  Field_double(uint32 len_arg, bool is_nullable, const char *field_name_arg,
+               uint8 dec_arg)
+    :Field_real((uchar*) 0, len_arg, is_nullable ? (uchar*) "" : 0, (uint) 0,
+                is_nullable, NONE, field_name_arg, dec_arg, 0, 0)
+                {}
+  Field_double(uint32 len_arg, bool is_nullable, const char *field_name_arg,
 	       uint8 dec_arg, my_bool not_fixed_arg)
-    :Field_real((uchar*) 0, len_arg, maybe_null_arg ? (uchar*) "" : 0, (uint) 0,
-                NONE, field_name_arg, dec_arg, 0, 0)
-    {not_fixed= not_fixed_arg; }
+    :Field_real((uchar*) 0, len_arg, is_nullable ? (uchar*) "" : 0, (uint) 0,
+                is_nullable, NONE, field_name_arg, dec_arg, 0, 0)
+                {not_fixed= not_fixed_arg; }
   enum_field_types type() const { return MYSQL_TYPE_DOUBLE;}
   enum ha_base_keytype key_type() const { return HA_KEYTYPE_DOUBLE; }
   int  store(const char *to,uint length,CHARSET_INFO *charset);
@@ -1201,7 +1186,7 @@ public:
   Field_null(uchar *ptr_arg, uint32 len_arg,
 	     enum utype unireg_check_arg, const char *field_name_arg,
 	     CHARSET_INFO *cs)
-    :Field_str(ptr_arg, len_arg, null, 1,
+    :Field_str(ptr_arg, len_arg, null, 1, TRUE,
 	       unireg_check_arg, field_name_arg, cs)
     {}
   enum_field_types type() const { return MYSQL_TYPE_NULL;}
@@ -1228,11 +1213,11 @@ public:
 class Field_timestamp :public Field_str {
 public:
   Field_timestamp(uchar *ptr_arg, uint32 len_arg,
-                  uchar *null_ptr_arg, uchar null_bit_arg,
-		  enum utype unireg_check_arg, const char *field_name_arg,
-		  TABLE_SHARE *share, CHARSET_INFO *cs);
-  Field_timestamp(bool maybe_null_arg, const char *field_name_arg,
-		  CHARSET_INFO *cs);
+                  uchar *null_ptr_arg, uchar null_bit_arg, bool is_nullable,
+                  enum utype unireg_check_arg, const char *field_name_arg,
+                  TABLE_SHARE *share, CHARSET_INFO *cs);
+  Field_timestamp(bool is_nullable, const char *field_name_arg,
+                  CHARSET_INFO *cs);
   enum_field_types type() const { return MYSQL_TYPE_TIMESTAMP;}
   enum ha_base_keytype key_type() const { return HA_KEYTYPE_ULONG_INT; }
   enum Item_result cmp_type () const { return INT_RESULT; }
@@ -1307,10 +1292,10 @@ public:
 class Field_year :public Field_tiny {
 public:
   Field_year(uchar *ptr_arg, uint32 len_arg, uchar *null_ptr_arg,
-	     uchar null_bit_arg,
-	     enum utype unireg_check_arg, const char *field_name_arg)
-    :Field_tiny(ptr_arg, len_arg, null_ptr_arg, null_bit_arg,
-		unireg_check_arg, field_name_arg, 1, 1)
+             uchar null_bit_arg, bool is_nullable,
+             enum utype unireg_check_arg, const char *field_name_arg)
+    :Field_tiny(ptr_arg, len_arg, null_ptr_arg, null_bit_arg, is_nullable,
+                unireg_check_arg, field_name_arg, 1, 1)
     {}
   enum_field_types type() const { return MYSQL_TYPE_YEAR;}
   int  store(const char *to,uint length,CHARSET_INFO *charset);
@@ -1328,15 +1313,11 @@ public:
 class Field_date :public Field_str {
 public:
   Field_date(uchar *ptr_arg, uchar *null_ptr_arg, uchar null_bit_arg,
-	     enum utype unireg_check_arg, const char *field_name_arg,
-	     CHARSET_INFO *cs)
-    :Field_str(ptr_arg, MAX_DATE_WIDTH, null_ptr_arg, null_bit_arg,
-	       unireg_check_arg, field_name_arg, cs)
+             bool is_nullable, enum utype unireg_check_arg,
+             const char *field_name_arg, CHARSET_INFO *cs)
+    :Field_str(ptr_arg, MAX_DATE_WIDTH, null_ptr_arg, null_bit_arg, is_nullable,
+               unireg_check_arg, field_name_arg, cs)
     { flags|= BINARY_FLAG; }
-  Field_date(bool maybe_null_arg, const char *field_name_arg,
-             CHARSET_INFO *cs)
-    :Field_str((uchar*) 0, MAX_DATE_WIDTH, maybe_null_arg ? (uchar*) "": 0,0,
-	       NONE, field_name_arg, cs) { flags|= BINARY_FLAG; }
   enum_field_types type() const { return MYSQL_TYPE_DATE;}
   enum ha_base_keytype key_type() const { return HA_KEYTYPE_ULONG_INT; }
   enum Item_result cmp_type () const { return INT_RESULT; }
@@ -1376,14 +1357,14 @@ public:
 class Field_newdate :public Field_str {
 public:
   Field_newdate(uchar *ptr_arg, uchar *null_ptr_arg, uchar null_bit_arg,
-		enum utype unireg_check_arg, const char *field_name_arg,
-		CHARSET_INFO *cs)
-    :Field_str(ptr_arg, 10, null_ptr_arg, null_bit_arg,
-	       unireg_check_arg, field_name_arg, cs)
+                bool is_nullable, enum utype unireg_check_arg,
+                const char *field_name_arg,	CHARSET_INFO *cs)
+    :Field_str(ptr_arg, 10, null_ptr_arg, null_bit_arg, is_nullable,
+               unireg_check_arg, field_name_arg, cs)
     { flags|= BINARY_FLAG; }
-  Field_newdate(bool maybe_null_arg, const char *field_name_arg,
+  Field_newdate(bool is_nullable, const char *field_name_arg,
                 CHARSET_INFO *cs)
-    :Field_str((uchar*) 0,10, maybe_null_arg ? (uchar*) "": 0,0,
+    :Field_str((uchar*) 0,10, is_nullable ? (uchar*) "": 0,0, is_nullable,
                NONE, field_name_arg, cs) { flags|= BINARY_FLAG; }
   enum_field_types type() const { return MYSQL_TYPE_DATE;}
   enum_field_types real_type() const { return MYSQL_TYPE_NEWDATE; }
@@ -1416,14 +1397,14 @@ public:
 class Field_time :public Field_str {
 public:
   Field_time(uchar *ptr_arg, uchar *null_ptr_arg, uchar null_bit_arg,
-	     enum utype unireg_check_arg, const char *field_name_arg,
-	     CHARSET_INFO *cs)
-    :Field_str(ptr_arg, 8, null_ptr_arg, null_bit_arg,
-	       unireg_check_arg, field_name_arg, cs)
+             bool is_nullable, enum utype unireg_check_arg,
+             const char *field_name_arg, CHARSET_INFO *cs)
+    :Field_str(ptr_arg, 8, null_ptr_arg, null_bit_arg, is_nullable,
+               unireg_check_arg, field_name_arg, cs)
     { flags|= BINARY_FLAG; }
-  Field_time(bool maybe_null_arg, const char *field_name_arg,
+  Field_time(bool is_nullable, const char *field_name_arg,
              CHARSET_INFO *cs)
-    :Field_str((uchar*) 0,8, maybe_null_arg ? (uchar*) "": 0,0,
+    :Field_str((uchar*) 0,8, is_nullable ? (uchar*) "": 0,0, is_nullable,
 	       NONE, field_name_arg, cs) { flags|= BINARY_FLAG; }
   enum_field_types type() const { return MYSQL_TYPE_TIME;}
   enum ha_base_keytype key_type() const { return HA_KEYTYPE_INT24; }
@@ -1455,15 +1436,15 @@ public:
 class Field_datetime :public Field_str {
 public:
   Field_datetime(uchar *ptr_arg, uchar *null_ptr_arg, uchar null_bit_arg,
-		 enum utype unireg_check_arg, const char *field_name_arg,
-		 CHARSET_INFO *cs)
+                 bool is_nullable, enum utype unireg_check_arg,
+                 const char *field_name_arg, CHARSET_INFO *cs)
     :Field_str(ptr_arg, MAX_DATETIME_WIDTH, null_ptr_arg, null_bit_arg,
-	       unireg_check_arg, field_name_arg, cs)
+               is_nullable, unireg_check_arg, field_name_arg, cs)
     { flags|= BINARY_FLAG; }
-  Field_datetime(bool maybe_null_arg, const char *field_name_arg,
+  Field_datetime(bool is_nullable, const char *field_name_arg,
 		 CHARSET_INFO *cs)
-    :Field_str((uchar*) 0, MAX_DATETIME_WIDTH, maybe_null_arg ? (uchar*) "": 0,0,
-	       NONE, field_name_arg, cs) { flags|= BINARY_FLAG; }
+    :Field_str((uchar*) 0, MAX_DATETIME_WIDTH, is_nullable ? (uchar*) "": 0,0,
+	      is_nullable, NONE, field_name_arg, cs) { flags|= BINARY_FLAG; }
   enum_field_types type() const { return MYSQL_TYPE_DATETIME;}
 #ifdef HAVE_LONG_LONG
   enum ha_base_keytype key_type() const { return HA_KEYTYPE_ULONGLONG; }
@@ -1513,17 +1494,17 @@ class Field_string :public Field_longstr
 public:
   bool can_alter_field_type;
   Field_string(uchar *ptr_arg, uint32 len_arg,uchar *null_ptr_arg,
-	       uchar null_bit_arg,
-	       enum utype unireg_check_arg, const char *field_name_arg,
-	       CHARSET_INFO *cs)
+               uchar null_bit_arg, bool is_nullable,
+               enum utype unireg_check_arg, const char *field_name_arg,
+               CHARSET_INFO *cs)
     :Field_longstr(ptr_arg, len_arg, null_ptr_arg, null_bit_arg,
-                   unireg_check_arg, field_name_arg, cs),
-     can_alter_field_type(1) {};
-  Field_string(uint32 len_arg,bool maybe_null_arg, const char *field_name_arg,
+                   is_nullable, unireg_check_arg, field_name_arg, cs),
+    can_alter_field_type(1) {};
+  Field_string(uint32 len_arg,bool is_nullable, const char *field_name_arg,
                CHARSET_INFO *cs)
-    :Field_longstr((uchar*) 0, len_arg, maybe_null_arg ? (uchar*) "": 0, 0,
-                   NONE, field_name_arg, cs),
-     can_alter_field_type(1) {};
+    :Field_longstr((uchar*) 0, len_arg, is_nullable ? (uchar*) "": 0, 0,
+                   is_nullable, NONE, field_name_arg, cs),
+                   can_alter_field_type(1) {};
 
   enum_field_types type() const
   {
@@ -1593,20 +1574,20 @@ public:
   uint32 length_bytes;
   Field_varstring(uchar *ptr_arg,
                   uint32 len_arg, uint length_bytes_arg,
-                  uchar *null_ptr_arg, uchar null_bit_arg,
-		  enum utype unireg_check_arg, const char *field_name_arg,
-		  TABLE_SHARE *share, CHARSET_INFO *cs)
-    :Field_longstr(ptr_arg, len_arg, null_ptr_arg, null_bit_arg,
+                  uchar *null_ptr_arg, uchar null_bit_arg, bool is_nullable,
+                  enum utype unireg_check_arg, const char *field_name_arg,
+                  TABLE_SHARE *share, CHARSET_INFO *cs)
+    :Field_longstr(ptr_arg, len_arg, null_ptr_arg, null_bit_arg, is_nullable,
                    unireg_check_arg, field_name_arg, cs),
      length_bytes(length_bytes_arg)
   {
     share->varchar_fields++;
   }
-  Field_varstring(uint32 len_arg,bool maybe_null_arg,
+  Field_varstring(uint32 len_arg,bool is_nullable,
                   const char *field_name_arg,
                   TABLE_SHARE *share, CHARSET_INFO *cs)
-    :Field_longstr((uchar*) 0,len_arg, maybe_null_arg ? (uchar*) "": 0, 0,
-                   NONE, field_name_arg, cs),
+    :Field_longstr((uchar*) 0,len_arg, is_nullable ? (uchar*) "": 0, 0,
+                   is_nullable, NONE, field_name_arg, cs),
      length_bytes(len_arg < 256 ? 1 :2)
   {
     share->varchar_fields++;
@@ -1657,7 +1638,7 @@ public:
   Field *new_field(MEM_ROOT *root, TABLE *new_table, bool keep_type);
   Field *new_key_field(MEM_ROOT *root, TABLE *new_table,
                        uchar *new_ptr, uchar *new_null_ptr,
-                       uint new_null_bit);
+                       uint new_null_bit, bool is_nullable);
   uint is_equal(Create_field *new_field);
   void hash(ulong *nr, ulong *nr2);
 private:
@@ -1679,20 +1660,21 @@ protected:
   
 public:
   Field_blob(uchar *ptr_arg, uchar *null_ptr_arg, uchar null_bit_arg,
-	     enum utype unireg_check_arg, const char *field_name_arg,
-	     TABLE_SHARE *share, uint blob_pack_length, CHARSET_INFO *cs);
-  Field_blob(uint32 len_arg,bool maybe_null_arg, const char *field_name_arg,
+             bool is_nullable, enum utype unireg_check_arg,
+             const char *field_name_arg, TABLE_SHARE *share,
+             uint blob_pack_length, CHARSET_INFO *cs);
+  Field_blob(uint32 len_arg,bool is_nullable, const char *field_name_arg,
              CHARSET_INFO *cs)
-    :Field_longstr((uchar*) 0, len_arg, maybe_null_arg ? (uchar*) "": 0, 0,
-                   NONE, field_name_arg, cs),
+    :Field_longstr((uchar*) 0, len_arg, is_nullable ? (uchar*) "": 0, 0,
+                   is_nullable, NONE, field_name_arg, cs),
     packlength(4)
   {
     flags|= BLOB_FLAG;
   }
-  Field_blob(uint32 len_arg,bool maybe_null_arg, const char *field_name_arg,
+  Field_blob(uint32 len_arg,bool is_nullable, const char *field_name_arg,
 	     CHARSET_INFO *cs, bool set_packlength)
-    :Field_longstr((uchar*) 0,len_arg, maybe_null_arg ? (uchar*) "": 0, 0,
-                   NONE, field_name_arg, cs)
+    :Field_longstr((uchar*) 0,len_arg, is_nullable ? (uchar*) "": 0, 0,
+                   is_nullable, NONE, field_name_arg, cs)
   {
     flags|= BLOB_FLAG;
     packlength= 4;
@@ -1705,7 +1687,8 @@ public:
     }
   }
   Field_blob(uint32 packlength_arg)
-    :Field_longstr((uchar*) 0, 0, (uchar*) "", 0, NONE, "temp", system_charset_info),
+    :Field_longstr((uchar*) 0, 0, (uchar*) "", 0, TRUE,
+                   NONE, "temp", system_charset_info),
     packlength(packlength_arg) {}
   enum_field_types type() const { return MYSQL_TYPE_BLOB;}
   enum ha_base_keytype key_type() const
@@ -1845,15 +1828,16 @@ public:
   enum geometry_type geom_type;
 
   Field_geom(uchar *ptr_arg, uchar *null_ptr_arg, uint null_bit_arg,
-	     enum utype unireg_check_arg, const char *field_name_arg,
-	     TABLE_SHARE *share, uint blob_pack_length,
-	     enum geometry_type geom_type_arg)
-     :Field_blob(ptr_arg, null_ptr_arg, null_bit_arg, unireg_check_arg, 
-                 field_name_arg, share, blob_pack_length, &my_charset_bin)
+             bool is_nullable, enum utype unireg_check_arg,
+             const char *field_name_arg, TABLE_SHARE *share,
+             uint blob_pack_length, enum geometry_type geom_type_arg)
+    :Field_blob(ptr_arg, null_ptr_arg, null_bit_arg, is_nullable,
+                unireg_check_arg, field_name_arg, share, blob_pack_length,
+                &my_charset_bin)
   { geom_type= geom_type_arg; }
-  Field_geom(uint32 len_arg,bool maybe_null_arg, const char *field_name_arg,
+  Field_geom(uint32 len_arg,bool is_nullable, const char *field_name_arg,
 	     TABLE_SHARE *share, enum geometry_type geom_type_arg)
-    :Field_blob(len_arg, maybe_null_arg, field_name_arg, &my_charset_bin)
+    :Field_blob(len_arg, is_nullable, field_name_arg, &my_charset_bin)
   { geom_type= geom_type_arg; }
   enum ha_base_keytype key_type() const { return HA_KEYTYPE_VARBINARY2; }
   enum_field_types type() const { return MYSQL_TYPE_GEOMETRY; }
@@ -1863,7 +1847,7 @@ public:
   int  store(longlong nr, bool unsigned_val);
   int  store_decimal(const my_decimal *);
   uint size_of() const { return sizeof(*this); }
-  int  reset(void) { return !maybe_null() || Field_blob::reset(); }
+  int  reset(void) { return !is_nullable() || Field_blob::reset(); }
   geometry_type get_geometry_type() { return geom_type; };
 };
 #endif /*HAVE_SPATIAL*/
@@ -1875,13 +1859,13 @@ protected:
 public:
   TYPELIB *typelib;
   Field_enum(uchar *ptr_arg, uint32 len_arg, uchar *null_ptr_arg,
-             uchar null_bit_arg,
+             uchar null_bit_arg, bool is_nullable,
              enum utype unireg_check_arg, const char *field_name_arg,
              uint packlength_arg,
              TYPELIB *typelib_arg,
              CHARSET_INFO *charset_arg)
-    :Field_str(ptr_arg, len_arg, null_ptr_arg, null_bit_arg,
-	       unireg_check_arg, field_name_arg, charset_arg),
+    :Field_str(ptr_arg, len_arg, null_ptr_arg, null_bit_arg, is_nullable,
+               unireg_check_arg, field_name_arg, charset_arg),
     packlength(packlength_arg),typelib(typelib_arg)
   {
       flags|=ENUM_FLAG;
@@ -1922,14 +1906,13 @@ private:
 class Field_set :public Field_enum {
 public:
   Field_set(uchar *ptr_arg, uint32 len_arg, uchar *null_ptr_arg,
-	    uchar null_bit_arg,
-	    enum utype unireg_check_arg, const char *field_name_arg,
-	    uint32 packlength_arg,
-	    TYPELIB *typelib_arg, CHARSET_INFO *charset_arg)
+            uchar null_bit_arg, bool is_nullable,
+            enum utype unireg_check_arg, const char *field_name_arg,
+            uint32 packlength_arg,
+            TYPELIB *typelib_arg, CHARSET_INFO *charset_arg)
     :Field_enum(ptr_arg, len_arg, null_ptr_arg, null_bit_arg,
-		    unireg_check_arg, field_name_arg,
-                packlength_arg,
-                typelib_arg,charset_arg)
+                is_nullable, unireg_check_arg, field_name_arg,
+                packlength_arg, typelib_arg,charset_arg)
     {
       flags=(flags & ~ENUM_FLAG) | SET_FLAG;
     }
@@ -1966,8 +1949,9 @@ public:
   uint bit_len;       // number of 'uneven' high bits
   uint bytes_in_rec;
   Field_bit(uchar *ptr_arg, uint32 len_arg, uchar *null_ptr_arg,
-            uchar null_bit_arg, uchar *bit_ptr_arg, uchar bit_ofs_arg,
-            enum utype unireg_check_arg, const char *field_name_arg);
+            uchar null_bit_arg, bool is_nullable, uchar *bit_ptr_arg,
+            uchar bit_ofs_arg, enum utype unireg_check_arg,
+            const char *field_name_arg);
   enum_field_types type() const { return MYSQL_TYPE_BIT; }
   enum ha_base_keytype key_type() const { return HA_KEYTYPE_BIT; }
   uint32 key_length() const { return (uint32) (field_length + 7) / 8; }
@@ -2030,7 +2014,7 @@ public:
 
   Field *new_key_field(MEM_ROOT *root, TABLE *new_table,
                        uchar *new_ptr, uchar *new_null_ptr,
-                       uint new_null_bit);
+                       uint new_null_bit, bool is_nullable);
   void set_bit_ptr(uchar *bit_ptr_arg, uchar bit_ofs_arg)
   {
     bit_ptr= bit_ptr_arg;
@@ -2066,7 +2050,7 @@ private:
 class Field_bit_as_char: public Field_bit {
 public:
   Field_bit_as_char(uchar *ptr_arg, uint32 len_arg, uchar *null_ptr_arg,
-                    uchar null_bit_arg,
+                    uchar null_bit_arg, bool is_nullable,
                     enum utype unireg_check_arg, const char *field_name_arg);
   enum ha_base_keytype key_type() const { return HA_KEYTYPE_BINARY; }
   uint size_of() const { return sizeof(*this); }

=== modified file 'sql/field_conv.cc'
--- a/sql/field_conv.cc	2010-07-23 20:59:42 +0000
+++ b/sql/field_conv.cc	2010-08-25 14:13:11 +0000
@@ -116,7 +116,7 @@ static void do_outer_field_to_null_str(C
 int
 set_field_to_null(Field *field)
 {
-  if (field->real_maybe_null())
+  if (field->real_is_nullable())
   {
     field->set_null();
     field->reset();
@@ -159,7 +159,7 @@ set_field_to_null(Field *field)
 int
 set_field_to_null_with_conversions(Field *field, bool no_conversions)
 {
-  if (field->real_maybe_null())
+  if (field->real_is_nullable())
   {
     field->set_null();
     field->reset();
@@ -534,7 +534,7 @@ void Copy_field::set(uchar *to,Field *fr
   from_ptr=from->ptr;
   to_ptr=to;
   from_length=from->pack_length();
-  if (from->maybe_null())
+  if (from->is_nullable())
   {
     from_null_ptr=from->null_ptr;
     from_bit=	  from->null_bit;
@@ -590,11 +590,11 @@ void Copy_field::set(Field *to,Field *fr
 
   // set up null handling
   from_null_ptr=to_null_ptr=0;
-  if (from->maybe_null())
+  if (from->is_nullable())
   {
     from_null_ptr=	from->null_ptr;
     from_bit=		from->null_bit;
-    if (to_field->real_maybe_null())
+    if (to_field->real_is_nullable())
     {
       to_null_ptr=	to->null_ptr;
       to_bit=		to->null_bit;
@@ -616,7 +616,7 @@ void Copy_field::set(Field *to,Field *fr
         do_copy= do_copy_not_null;
     }
   }
-  else if (to_field->real_maybe_null())
+  else if (to_field->real_is_nullable())
   {
     to_null_ptr=	to->null_ptr;
     to_bit=		to->null_bit;

=== modified file 'sql/filesort.cc'
--- a/sql/filesort.cc	2010-08-04 10:34:01 +0000
+++ b/sql/filesort.cc	2010-08-25 14:13:11 +0000
@@ -759,7 +759,7 @@ static void make_sortkey(register SORTPA
     bool maybe_null=0;
     if ((field=sort_field->field))
     {						// Field
-      if (field->maybe_null())
+      if (field->is_nullable())
       {
 	if (field->is_null())
 	{
@@ -1467,7 +1467,7 @@ sortlength(THD *thd, SORT_FIELD *sortord
         *multi_byte_charset= 1;
         sortorder->length= cs->coll->strnxfrmlen(cs, sortorder->length);
       }
-      if (sortorder->field->maybe_null())
+      if (sortorder->field->is_nullable())
 	length++;				// Place for NULL marker
     }
     else
@@ -1582,7 +1582,7 @@ get_addon_fields(THD *thd, Field **ptabf
     if (field->flags & BLOB_FLAG)
       return 0;
     length+= field->max_packed_col_length(field->pack_length());
-    if (field->maybe_null())
+    if (field->is_nullable())
       null_fields++;
     fields++;
   } 
@@ -1604,7 +1604,7 @@ get_addon_fields(THD *thd, Field **ptabf
       continue;
     addonf->field= field;
     addonf->offset= length;
-    if (field->maybe_null())
+    if (field->is_nullable())
     {
       addonf->null_offset= null_fields/8;
       addonf->null_bit= 1<<(null_fields & 7);

=== modified file 'sql/item.cc'
--- a/sql/item.cc	2010-08-25 08:37:49 +0000
+++ b/sql/item.cc	2010-08-25 14:13:11 +0000
@@ -2027,7 +2027,7 @@ Item_field::Item_field(THD *thd, Item_fi
 void Item_field::set_field(Field *field_par)
 {
   field=result_field=field_par;			// for easy coding with fields
-  maybe_null=field->maybe_null();
+  maybe_null=field->is_nullable();
   decimals= field->decimals();
   table_name= *field_par->table_name;
   field_name= field_par->field_name;
@@ -5215,38 +5215,38 @@ Field *Item::tmp_table_field_from_field_
     field= Field_new_decimal::create_from_item(this);
     break;
   case MYSQL_TYPE_TINY:
-    field= new Field_tiny((uchar*) 0, max_length, null_ptr, 0, Field::NONE,
-			  name, 0, unsigned_flag);
+    field= new Field_tiny((uchar*) 0, max_length, null_ptr, 0, maybe_null,
+                          Field::NONE, name, 0, unsigned_flag);
     break;
   case MYSQL_TYPE_SHORT:
-    field= new Field_short((uchar*) 0, max_length, null_ptr, 0, Field::NONE,
-			   name, 0, unsigned_flag);
+    field= new Field_short((uchar*) 0, max_length, null_ptr, 0, maybe_null,
+                           Field::NONE, name, 0, unsigned_flag);
     break;
   case MYSQL_TYPE_LONG:
-    field= new Field_long((uchar*) 0, max_length, null_ptr, 0, Field::NONE,
-			  name, 0, unsigned_flag);
+    field= new Field_long((uchar*) 0, max_length, null_ptr, 0, maybe_null,
+                          Field::NONE, name, 0, unsigned_flag);
     break;
 #ifdef HAVE_LONG_LONG
   case MYSQL_TYPE_LONGLONG:
-    field= new Field_longlong((uchar*) 0, max_length, null_ptr, 0, Field::NONE,
-			      name, 0, unsigned_flag);
+    field= new Field_longlong((uchar*) 0, max_length, null_ptr, 0, maybe_null,
+                              Field::NONE, name, 0, unsigned_flag);
     break;
 #endif
   case MYSQL_TYPE_FLOAT:
-    field= new Field_float((uchar*) 0, max_length, null_ptr, 0, Field::NONE,
-			   name, decimals, 0, unsigned_flag);
+    field= new Field_float((uchar*) 0, max_length, null_ptr, 0, maybe_null,
+                           Field::NONE, name, decimals, 0, unsigned_flag);
     break;
   case MYSQL_TYPE_DOUBLE:
-    field= new Field_double((uchar*) 0, max_length, null_ptr, 0, Field::NONE,
-			    name, decimals, 0, unsigned_flag);
+    field= new Field_double((uchar*) 0, max_length, null_ptr, 0, maybe_null,
+                            Field::NONE, name, decimals, 0, unsigned_flag);
     break;
   case MYSQL_TYPE_NULL:
     field= new Field_null((uchar*) 0, max_length, Field::NONE,
 			  name, &my_charset_bin);
     break;
   case MYSQL_TYPE_INT24:
-    field= new Field_medium((uchar*) 0, max_length, null_ptr, 0, Field::NONE,
-			    name, 0, unsigned_flag);
+    field= new Field_medium((uchar*) 0, max_length, null_ptr, 0, maybe_null,
+                            Field::NONE, name, 0, unsigned_flag);
     break;
   case MYSQL_TYPE_NEWDATE:
   case MYSQL_TYPE_DATE:
@@ -5262,11 +5262,11 @@ Field *Item::tmp_table_field_from_field_
     field= new Field_datetime(maybe_null, name, &my_charset_bin);
     break;
   case MYSQL_TYPE_YEAR:
-    field= new Field_year((uchar*) 0, max_length, null_ptr, 0, Field::NONE,
-			  name);
+    field= new Field_year((uchar*) 0, max_length, null_ptr, 0, maybe_null,
+                          Field::NONE, name);
     break;
   case MYSQL_TYPE_BIT:
-    field= new Field_bit_as_char(NULL, max_length, null_ptr, 0,
+    field= new Field_bit_as_char(NULL, max_length, null_ptr, 0, maybe_null,
                                  Field::NONE, name);
     break;
   default:
@@ -8227,7 +8227,7 @@ Field *Item_type_holder::make_field_by_t
   switch (fld_type) {
   case MYSQL_TYPE_ENUM:
     DBUG_ASSERT(enum_set_typelib);
-    field= new Field_enum((uchar *) 0, max_length, null_ptr, 0,
+    field= new Field_enum((uchar *) 0, max_length, null_ptr, 0, maybe_null,
                           Field::NONE, name,
                           get_enum_pack_length(enum_set_typelib->count),
                           enum_set_typelib, collation.collation);
@@ -8236,7 +8236,7 @@ Field *Item_type_holder::make_field_by_t
     return field;
   case MYSQL_TYPE_SET:
     DBUG_ASSERT(enum_set_typelib);
-    field= new Field_set((uchar *) 0, max_length, null_ptr, 0,
+    field= new Field_set((uchar *) 0, max_length, null_ptr, 0, maybe_null,
                          Field::NONE, name,
                          get_set_pack_length(enum_set_typelib->count),
                          enum_set_typelib, collation.collation);

=== modified file 'sql/item_subselect.cc'
--- a/sql/item_subselect.cc	2010-08-04 10:34:01 +0000
+++ b/sql/item_subselect.cc	2010-08-25 14:13:11 +0000
@@ -3220,7 +3220,7 @@ bool subselect_hash_sj_engine::init_perm
     Item_func_eq *eq_cond; /* New equi-join condition for the current column. */
     /* Item for the corresponding field from the materialized temp table. */
     Item_field *right_col_item;
-    int null_count= test(cur_key_part->field->real_maybe_null());
+    int null_count= test(cur_key_part->field->real_is_nullable());
     tab->ref.items[i]= item_in->left_expr->element_index(i);
 
     if (!(right_col_item= new Item_field(thd, context, cur_key_part->field)) ||

=== modified file 'sql/key.cc'
--- a/sql/key.cc	2010-07-13 17:29:44 +0000
+++ b/sql/key.cc	2010-08-25 14:13:11 +0000
@@ -560,8 +560,8 @@ int key_rec_cmp(void *key_p, uchar *firs
       if (key_part->null_bit)
       {
         /* The key_part can contain NULL values */
-        bool first_is_null= field->is_null_in_record_with_offset(first_diff);
-        bool sec_is_null= field->is_null_in_record_with_offset(sec_diff);
+        bool first_is_null= field->is_real_null(first_diff);
+        bool sec_is_null= field->is_real_null(sec_diff);
         /*
           NULL is smaller then everything so if first is NULL and the other
           not then we know that we should return -1 and for the opposite

=== modified file 'sql/log_event.cc'
--- a/sql/log_event.cc	2010-08-24 12:59:07 +0000
+++ b/sql/log_event.cc	2010-08-25 14:13:11 +0000
@@ -8200,7 +8200,7 @@ Table_map_log_event::Table_map_log_event
 
   bzero(m_null_bits, num_null_bytes);
   for (unsigned int i= 0 ; i < m_table->s->fields ; ++i)
-    if (m_table->field[i]->maybe_null())
+    if (m_table->field[i]->is_nullable())
       m_null_bits[(i / 8)]+= 1 << (i % 8);
 
 }

=== modified file 'sql/log_event_old.cc'
--- a/sql/log_event_old.cc	2010-07-28 23:39:52 +0000
+++ b/sql/log_event_old.cc	2010-08-25 14:13:11 +0000
@@ -445,7 +445,7 @@ copy_extra_record_fields(TABLE *table,
       /*
         Set the null bit according to the values in record[1]
        */
-      if ((*field_ptr)->maybe_null() &&
+      if ((*field_ptr)->is_nullable() &&
           (*field_ptr)->is_null_in_record(reinterpret_cast<uchar*>(table->record[1])))
         (*field_ptr)->set_null();
       else

=== modified file 'sql/opt_range.cc'
--- a/sql/opt_range.cc	2010-08-04 10:34:01 +0000
+++ b/sql/opt_range.cc	2010-08-25 14:13:11 +0000
@@ -1750,7 +1750,7 @@ inline void SEL_ARG::make_root()
 
 SEL_ARG::SEL_ARG(Field *f,const uchar *min_value_arg,
                  const uchar *max_value_arg)
-  :min_flag(0), max_flag(0), maybe_flag(0), maybe_null(f->real_maybe_null()),
+  :min_flag(0), max_flag(0), maybe_flag(0), maybe_null(f->real_is_nullable()),
    elements(1), use_count(1), field(f), min_value((uchar*) min_value_arg),
    max_value((uchar*) max_value_arg), next(0),prev(0),
    next_key_part(0),color(BLACK),type(KEY_RANGE)
@@ -1762,7 +1762,7 @@ SEL_ARG::SEL_ARG(Field *field_,uint8 par
                  uchar *min_value_, uchar *max_value_,
 		 uint8 min_flag_,uint8 max_flag_,uint8 maybe_flag_)
   :min_flag(min_flag_),max_flag(max_flag_),maybe_flag(maybe_flag_),
-   part(part_),maybe_null(field_->real_maybe_null()), elements(1),use_count(1),
+   part(part_),maybe_null(field_->real_is_nullable()), elements(1),use_count(1),
    field(field_), min_value(min_value_), max_value(max_value_),
    next(0),prev(0),next_key_part(0),color(BLACK),type(KEY_RANGE)
 {
@@ -1853,7 +1853,7 @@ static int sel_cmp(Field *field, uchar *
   if (b_flag & (NO_MIN_RANGE | NO_MAX_RANGE))
     return (b_flag & NO_MIN_RANGE) ? 1 : -1;
 
-  if (field->real_maybe_null())			// If null is part of key
+  if (field->real_is_nullable())			// If null is part of key
   {
     if (*a != *b)
     {
@@ -2829,7 +2829,7 @@ void store_key_image_to_rec(Field *field
   /* Do the same as print_key() does */ 
   my_bitmap_map *old_map;
 
-  if (field->real_maybe_null())
+  if (field->real_is_nullable())
   {
     if (*ptr)
     {
@@ -5712,7 +5712,7 @@ static SEL_ARG *
 get_mm_leaf(RANGE_OPT_PARAM *param, Item *conf_func, Field *field,
             KEY_PART *key_part, Item_func::Functype type,Item *value)
 {
-  uint maybe_null=(uint) field->real_maybe_null();
+  uint maybe_null=(uint) field->real_is_nullable();
   bool optimize_range;
   SEL_ARG *tree= 0;
   MEM_ROOT *alloc= param->mem_root;
@@ -10907,7 +10907,7 @@ void QUICK_GROUP_MIN_MAX_SELECT::update_
     }
   }
   else if (have_min && min_max_arg_part &&
-           min_max_arg_part->field->real_maybe_null())
+           min_max_arg_part->field->real_is_nullable())
   {
     /*
       If a MIN/MAX argument value is NULL, we can quickly determine
@@ -11722,7 +11722,7 @@ print_key(KEY_PART *key_part, const ucha
     Field *field=      key_part->field;
     store_length= key_part->store_length;
 
-    if (field->real_maybe_null())
+    if (field->real_is_nullable())
     {
       if (*key)
       {

=== modified file 'sql/opt_sum.cc'
--- a/sql/opt_sum.cc	2010-08-04 10:34:01 +0000
+++ b/sql/opt_sum.cc	2010-08-25 14:13:11 +0000
@@ -160,7 +160,7 @@ static int get_index_min_value(TABLE *ta
          Check if case 1 from above holds. If it does, we should read
          the skipped tuple.
       */
-      if (item_field->field->real_maybe_null() &&
+      if (item_field->field->real_is_nullable() &&
           ref->key_buff[prefix_len] == 1 &&
           /*
             Last keypart (i.e. the argument to MIN) is set to NULL by
@@ -172,7 +172,7 @@ static int get_index_min_value(TABLE *ta
           (error == HA_ERR_KEY_NOT_FOUND ||
            key_cmp_if_same(table, ref->key_buff, ref->key, prefix_len)))
       {
-        DBUG_ASSERT(item_field->field->real_maybe_null());
+        DBUG_ASSERT(item_field->field->real_is_nullable());
         error= table->file->ha_index_read_map(table->record[0],
                                              ref->key_buff,
                                              make_prev_keypart_map(ref->key_parts),

=== modified file 'sql/rpl_record.cc'
--- a/sql/rpl_record.cc	2010-07-24 13:47:42 +0000
+++ b/sql/rpl_record.cc	2010-08-25 14:13:11 +0000
@@ -262,7 +262,7 @@ unpack_row(Relay_log_info const *rli,
 
       if (null_bits & null_mask)
       {
-        if (f->maybe_null())
+        if (f->is_nullable())
         {
           DBUG_PRINT("debug", ("Was NULL; null mask: 0x%x; null bits: 0x%x",
                                null_mask, null_bits));

=== modified file 'sql/sql_join_cache.cc'
--- a/sql/sql_join_cache.cc	2010-07-23 17:51:11 +0000
+++ b/sql/sql_join_cache.cc	2010-08-25 14:13:11 +0000
@@ -742,7 +742,7 @@ bool JOIN_CACHE_BKA::check_emb_key_usage
       return FALSE;
     if (!key_part->field->eq_def(((Item_field *) item)->field))
       return FALSE;
-    if (key_part->field->maybe_null())
+    if (key_part->field->is_nullable())
     {
       return FALSE;
       /*
@@ -1049,7 +1049,7 @@ uint JOIN_CACHE::write_record_data(uchar
   for ( ; copy < copy_end; copy++)
   {
     Field *field= copy->field;
-    if (field && field->maybe_null() && field->is_null())
+    if (field && field->is_nullable() && field->is_null())
     {
       /* Do not copy a field if its value is null */
       if (copy->referenced_field_no)
@@ -1427,7 +1427,7 @@ uint JOIN_CACHE::read_record_field(CACHE
 {
   uint len;
   /* Do not copy the field if its value is null */ 
-  if (copy->field && copy->field->maybe_null() && copy->field->is_null())
+  if (copy->field && copy->field->is_nullable() && copy->field->is_null())
     return 0;           
   if (copy->type == CACHE_BLOB)
   {

=== modified file 'sql/sql_load.cc'
--- a/sql/sql_load.cc	2010-08-16 06:58:42 +0000
+++ b/sql/sql_load.cc	2010-08-25 14:13:11 +0000
@@ -830,7 +830,7 @@ read_fixed_length(THD *thd, COPY_INFO &i
                             ER_WARN_TOO_FEW_RECORDS,
                             ER(ER_WARN_TOO_FEW_RECORDS),
                             thd->warning_info->current_row_for_warning());
-        if (!field->maybe_null() && field->type() == FIELD_TYPE_TIMESTAMP)
+        if (!field->is_nullable() && field->type() == FIELD_TYPE_TIMESTAMP)
             ((Field_timestamp*) field)->set_time();
       }
       else
@@ -959,7 +959,7 @@ read_sep_field(THD *thd, COPY_INFO &info
             DBUG_RETURN(1);
           }
           field->set_null();
-          if (!field->maybe_null())
+          if (!field->is_nullable())
           {
             if (field->type() == MYSQL_TYPE_TIMESTAMP)
               ((Field_timestamp*) field)->set_time();
@@ -1030,7 +1030,7 @@ read_sep_field(THD *thd, COPY_INFO &info
                      thd->warning_info->current_row_for_warning());
             DBUG_RETURN(1);
           }
-          if (!field->maybe_null() && field->type() == FIELD_TYPE_TIMESTAMP)
+          if (!field->is_nullable() && field->type() == FIELD_TYPE_TIMESTAMP)
               ((Field_timestamp*) field)->set_time();
           /*
             QQ: We probably should not throw warning for each field.
@@ -1168,7 +1168,7 @@ read_xml_field(THD *thd, COPY_INFO &info
           field->set_null();
           if (field == table->next_number_field)
             table->auto_increment_field_not_null= TRUE;
-          if (!field->maybe_null())
+          if (!field->is_nullable())
           {
             if (field->type() == FIELD_TYPE_TIMESTAMP)
               ((Field_timestamp *) field)->set_time();

=== modified file 'sql/sql_partition.cc'
--- a/sql/sql_partition.cc	2010-08-23 17:43:34 +0000
+++ b/sql/sql_partition.cc	2010-08-25 14:13:11 +0000
@@ -2917,7 +2917,7 @@ static void copy_to_part_field_buffers(F
   {
     *restore_ptr= field->ptr;
     restore_ptr++;
-    if (!field->maybe_null() || !field->is_null())
+    if (!field->is_nullable() || !field->is_null())
     {
       CHARSET_INFO *cs= ((Field_str*)field)->charset();
       uint max_len= field->pack_length();
@@ -7342,7 +7342,7 @@ uint32 store_tuple_to_record(Field **pfi
   while (value < value_end)
   {
     loc_value= value;
-    if ((*pfield)->real_maybe_null())
+    if ((*pfield)->real_is_nullable())
     {
       if (*loc_value)
         (*pfield)->set_null();
@@ -7659,7 +7659,7 @@ int get_part_iter_for_interval_via_mappi
     Find minimum: Do special handling if the interval has left bound in form
      " NULL <= X ":
   */
-  if (field->real_maybe_null() && part_info->has_null_value && 
+  if (field->real_is_nullable() && part_info->has_null_value && 
       !(flags & (NO_MIN_RANGE | NEAR_MIN)) && *min_value)
   {
     part_iter->ret_null_part= part_iter->ret_null_part_orig= TRUE;
@@ -7790,7 +7790,7 @@ int get_part_iter_for_interval_via_walki
   }
 
   /* Handle the "t.field IS NULL" interval, it is a special case */
-  if (field->real_maybe_null() && !(flags & (NO_MIN_RANGE | NO_MAX_RANGE)) &&
+  if (field->real_is_nullable() && !(flags & (NO_MIN_RANGE | NO_MAX_RANGE)) &&
       *min_value && *max_value)
   {
     /* 
@@ -7824,7 +7824,7 @@ int get_part_iter_for_interval_via_walki
     DBUG_RETURN(0); /* No partitions match */
   }
 
-  if ((field->real_maybe_null() && 
+  if ((field->real_is_nullable() && 
        ((!(flags & NO_MIN_RANGE) && *min_value) ||  // NULL <? X
         (!(flags & NO_MAX_RANGE) && *max_value))) ||  // X <? NULL
       (flags & (NO_MIN_RANGE | NO_MAX_RANGE)))    // -inf at any bound
@@ -8105,7 +8105,7 @@ uint get_partition_field_store_length(Fi
   uint store_length;
 
   store_length= field->key_length();
-  if (field->real_maybe_null())
+  if (field->real_is_nullable())
     store_length+= HA_KEY_NULL_LENGTH;
   if (field->real_type() == MYSQL_TYPE_VARCHAR)
     store_length+= HA_KEY_BLOB_LENGTH;

=== modified file 'sql/sql_select.cc'
--- a/sql/sql_select.cc	2010-08-16 07:30:40 +0000
+++ b/sql/sql_select.cc	2010-08-25 14:13:11 +0000
@@ -621,7 +621,7 @@ JOIN::prepare(Item ***rref_pointer_array
       if (!real_order &&
            /* Not a zero length NOT NULL field */
           ((item->type() != Item::FIELD_ITEM ||
-            ((Item_field *) item)->field->maybe_null() ||
+            ((Item_field *) item)->field->is_nullable() ||
             ((Item_field *) item)->field->sort_length()) &&
            /* AND not a zero length NOT NULL string function. */
            (item->type() != Item::FUNC_ITEM ||
@@ -5188,7 +5188,7 @@ add_key_field(KEY_FIELD **key_fields,uin
   {
     // Don't remove column IS NULL on a LEFT JOIN table
     if (!eq_func || (*value)->type() != Item::NULL_ITEM ||
-        !field->table->maybe_null || field->null_ptr)
+        !field->table->maybe_null || field->real_is_nullable())
       return;					// Not a key. Skip it
     exists_optimize= KEY_OPTIMIZE_EXISTS;
     DBUG_ASSERT(num_values == 1);
@@ -5208,7 +5208,7 @@ add_key_field(KEY_FIELD **key_fields,uin
     if (!(usable_tables & field->table->map))
     {
       if (!eq_func || (*value)->type() != Item::NULL_ITEM ||
-          !field->table->maybe_null || field->null_ptr)
+          !field->table->maybe_null || field->real_is_nullable())
 	return;					// Can't use left join optimize
       exists_optimize= KEY_OPTIMIZE_EXISTS;
     }
@@ -5324,7 +5324,7 @@ add_key_field(KEY_FIELD **key_fields,uin
     if (((cond->functype() == Item_func::EQ_FUNC) ||
          (cond->functype() == Item_func::MULT_EQUAL_FUNC)) &&
         (real->type() == Item::FIELD_ITEM) &&
-        ((Item_field*)real)->field->maybe_null())
+        ((Item_field*)real)->field->is_nullable())
       (*key_fields)->null_rejecting= true;
     else
       (*key_fields)->null_rejecting= false;
@@ -5897,7 +5897,7 @@ update_ref_and_keys(THD *thd, DYNAMIC_AR
         return TRUE;
       /* Mark that we can optimize LEFT JOIN */
       if (field->val->type() == Item::NULL_ITEM &&
-	  !field->field->real_maybe_null())
+	  !field->field->real_is_nullable())
       {
         /*
           Example:
@@ -8017,7 +8017,7 @@ void calc_used_field_length(THD *thd, JO
       rec_length+=field->pack_length();
       if (flags & BLOB_FLAG)
 	blobs++;
-      if (!(flags & NOT_NULL_FLAG))
+      if (field->real_is_nullable())
         null_fields++;
       if (field->type() == MYSQL_TYPE_BIT &&
           ((Field_bit*)field)->bit_len)
@@ -10467,7 +10467,7 @@ bool setup_sj_materialization(JOIN_TAB *
     for (i= 0; i < tmp_key_parts; i++, cur_key_part++, ref_key++)
     {
       tab_ref->items[i]= outer_expr++;
-      int null_count= test(cur_key_part->field->real_maybe_null());
+      int null_count= test(cur_key_part->field->real_is_nullable());
       *ref_key= new store_key_item(thd, cur_key_part->field,
                                    /* TODO:
                                       the NULL byte is taken into account in
@@ -11602,7 +11602,7 @@ static bool check_simple_equality(Item *
 
     /* As (NULL=NULL) != TRUE we can't just remove the predicate f=f */
     if (left_field->eq(right_field)) /* f = f */
-      return (!(left_field->maybe_null() && !left_item_equal)); 
+      return (!(left_field->is_nullable() && !left_item_equal)); 
 
     if (left_item_equal && left_item_equal == right_item_equal)
     {
@@ -14128,7 +14128,7 @@ internal_remove_eq_conds(THD *thd, Item 
       */
       if (((field->type() == MYSQL_TYPE_DATE) ||
            (field->type() == MYSQL_TYPE_DATETIME)) &&
-          (field->flags & NOT_NULL_FLAG) && !field->table->maybe_null)
+          !field->real_is_nullable() && !field->table->maybe_null)
       {
 	Item *new_cond;
 	if ((new_cond= new Item_func_eq(args[0],new Item_int("0", 0, 2))))
@@ -14430,7 +14430,7 @@ Field *create_tmp_field_from_field(THD *
   if (convert_blob_length && convert_blob_length <= Field_varstring::MAX_SIZE &&
       (org_field->flags & BLOB_FLAG))
     new_field= new Field_varstring(convert_blob_length,
-                                   org_field->maybe_null(),
+                                   org_field->is_nullable(),
                                    org_field->field_name, table->s,
                                    org_field->charset());
   else
@@ -14445,7 +14445,7 @@ Field *create_tmp_field_from_field(THD *
     else
       new_field->field_name= name;
     new_field->flags|= (org_field->flags & NO_DEFAULT_VALUE_FLAG);
-    if (org_field->maybe_null() || (item && item->maybe_null))
+    if (org_field->is_nullable() || (item && item->maybe_null))
       new_field->flags&= ~NOT_NULL_FLAG;	// Because of outer join
     if (org_field->type() == MYSQL_TYPE_VAR_STRING ||
         org_field->type() == MYSQL_TYPE_VARCHAR)
@@ -14659,7 +14659,7 @@ Field *create_tmp_field(THD *thd, TABLE 
       If item have to be able to store NULLs but underlaid field can't do it,
       create_tmp_field_from_field() can't be used for tmp field creation.
     */
-    if (field->maybe_null && !field->field->maybe_null())
+    if (field->maybe_null && !field->field->is_nullable())
     {
       result= create_tmp_field_from_item(thd, item, table, NULL,
                                          modify_item, convert_blob_length);
@@ -15047,7 +15047,7 @@ create_tmp_table(THD *thd,TMP_TABLE_PARA
           thd->mem_root= mem_root_save;
           arg= sum_item->set_arg(i, thd, new Item_field(new_field));
           thd->mem_root= &table->mem_root;
-	  if (!(new_field->flags & NOT_NULL_FLAG))
+          if (new_field->real_is_nullable())
           {
 	    null_count++;
             /*
@@ -15100,7 +15100,7 @@ create_tmp_table(THD *thd,TMP_TABLE_PARA
 	((Item_sum *) item)->result_field= new_field;
       tmp_from_field++;
       reclength+=new_field->pack_length();
-      if (!(new_field->flags & NOT_NULL_FLAG))
+      if (new_field->real_is_nullable())
 	null_count++;
       if (new_field->type() == MYSQL_TYPE_BIT)
         total_uneven_bit_length+= new_field->field_length & 7;
@@ -15235,7 +15235,7 @@ create_tmp_table(THD *thd,TMP_TABLE_PARA
     uint length;
     bzero((uchar*) recinfo,sizeof(*recinfo));
 
-    if (!(field->flags & NOT_NULL_FLAG))
+    if (field->real_is_nullable())
     {
       if (field->flags & GROUP_FLAG && !using_unique_constraint)
       {
@@ -15381,7 +15381,8 @@ create_tmp_table(THD *thd,TMP_TABLE_PARA
                                                      group_buff +
                                                      test(maybe_null),
                                                      field->null_ptr,
-                                                     field->null_bit)))
+                                                     field->null_bit,
+                                                     field->real_is_nullable())))
 	  goto err; /* purecov: inspected */
 	if (maybe_null)
 	{
@@ -15456,7 +15457,7 @@ create_tmp_table(THD *thd,TMP_TABLE_PARA
       key_part_info->field= new Field_string(table->record[0],
                                              (uint32) key_part_info->length,
                                              (uchar*) 0,
-                                             (uint) 0,
+                                             (uint) 0, FALSE,
                                              Field::NONE,
                                              NullS, &my_charset_bin);
       if (!key_part_info->field)
@@ -15485,7 +15486,7 @@ create_tmp_table(THD *thd,TMP_TABLE_PARA
       */
       key_part_info->store_length= key_part_info->length;
 
-      if ((*reg_field)->real_maybe_null())
+      if ((*reg_field)->real_is_nullable())
         key_part_info->store_length+= HA_KEY_NULL_LENGTH;
       if ((*reg_field)->type() == MYSQL_TYPE_BLOB || 
           (*reg_field)->real_type() == MYSQL_TYPE_VARCHAR)
@@ -15856,7 +15857,8 @@ TABLE *create_duplicate_weedout_tmp_tabl
 	if (!(key_field= field->new_key_field(thd->mem_root, table,
                                               group_buff,
                                               field->null_ptr,
-                                              field->null_bit)))
+                                              field->null_bit,
+                                              field->real_is_nullable())))
 	  goto err;
         key_part_info->key_part_flag|= HA_END_SPACE_ARE_EQUAL; //todo need this?
       }
@@ -15958,7 +15960,7 @@ TABLE *create_virtual_tmp_table(THD *thd
       goto error;
     (*field)->init(table);
     record_length+= (*field)->pack_length();
-    if (! ((*field)->flags & NOT_NULL_FLAG))
+    if ((*field)->real_is_nullable())
       null_count++;
 
     if ((*field)->flags & BLOB_FLAG)
@@ -15994,7 +15996,7 @@ TABLE *create_virtual_tmp_table(THD *thd
     for (field= table->field; *field; ++field)
     {
       Field *cur_field= *field;
-      if ((cur_field->flags & NOT_NULL_FLAG))
+      if (!cur_field->real_is_nullable())
         cur_field->move_field(field_pos);
       else
       {
@@ -16148,7 +16150,7 @@ static bool create_myisam_tmp_table(TABL
 	    keyinfo->key_part[i].length > 4)
 	  seg->flag|= HA_SPACE_PACK;
       }
-      if (!(field->flags & NOT_NULL_FLAG))
+      if (field->real_is_nullable())
       {
 	seg->null_bit= field->null_bit;
 	seg->null_pos= (uint) (field->null_ptr - (uchar*) table->record[0]);
@@ -19223,7 +19225,7 @@ list_contains_unique_index(TABLE *table,
            key_part < key_part_end;
            key_part++)
       {
-        if (key_part->field->maybe_null() || 
+        if (key_part->field->is_nullable() || 
             !find_func(key_part->field, data))
           break;
       }

=== modified file 'sql/sql_select.h'
--- a/sql/sql_select.h	2010-08-04 10:34:01 +0000
+++ b/sql/sql_select.h	2010-08-25 14:13:11 +0000
@@ -1994,14 +1994,14 @@ public:
         Key segments are always packed with a 2 byte length prefix.
         See mi_rkey for details.
       */
-      to_field= new Field_varstring(ptr, length, 2, null, 1, 
+      to_field= new Field_varstring(ptr, length, 2, null, 1, null != NULL,
                                     Field::NONE, field_arg->field_name,
                                     field_arg->table->s, field_arg->charset());
       to_field->init(field_arg->table);
     }
     else
       to_field=field_arg->new_key_field(thd->mem_root, field_arg->table,
-                                        ptr, null, 1);
+                                        ptr, null, 1, null != NULL);
   }
   virtual ~store_key() {}			/** Not actually needed */
   virtual const char *name() const=0;
@@ -2048,7 +2048,7 @@ class store_key_field: public store_key
                   uchar *null_ptr_arg,
 		  uint length, Field *from_field, const char *name_arg)
     :store_key(thd, to_field_arg,ptr,
-	       null_ptr_arg ? null_ptr_arg : from_field->maybe_null() ? &err
+	       null_ptr_arg ? null_ptr_arg : from_field->is_nullable() ? &err
 	       : (uchar*) 0, length), field_name(name_arg)
   {
     if (to_field)

=== modified file 'sql/sql_show.cc'
--- a/sql/sql_show.cc	2010-08-20 09:15:16 +0000
+++ b/sql/sql_show.cc	2010-08-25 14:13:11 +0000
@@ -1107,7 +1107,7 @@ static bool get_field_default_value(THD 
       else if (quoted)
         def_value->append(STRING_WITH_LEN("''"));
     }
-    else if (field->maybe_null() && quoted)
+    else if (field->is_nullable() && quoted)
       def_value->append(STRING_WITH_LEN("NULL"));    // Null as default
     else
       return 0;
@@ -1255,7 +1255,7 @@ int store_create_info(THD *thd, TABLE_LI
       }
     }
 
-    if (flags & NOT_NULL_FLAG)
+    if (!field->real_is_nullable())
       packet->append(STRING_WITH_LEN(" NOT NULL"));
     else if (field->type() == MYSQL_TYPE_TIMESTAMP)
     {
@@ -4188,7 +4188,7 @@ static int get_schema_column_record(THD 
       table->field[5]->store(type.ptr(), type.length(), cs);
       table->field[5]->set_notnull();
     }
-    pos=(uchar*) ((field->flags & NOT_NULL_FLAG) ?  "NO" : "YES");
+    pos=(uchar*) (!field->real_is_nullable() ?  "NO" : "YES");
     table->field[6]->store((const char*) pos,
                            strlen((const char*) pos), cs);
     store_column_type(table, field, cs, 7);

=== modified file 'sql/sql_table.cc'
--- a/sql/sql_table.cc	2010-08-24 12:59:07 +0000
+++ b/sql/sql_table.cc	2010-08-25 14:13:11 +0000
@@ -5049,7 +5049,7 @@ mysql_compare_tables(TABLE *table,
 
     /* Check that NULL behavior is same for old and new fields */
     if ((tmp_new_field->flags & NOT_NULL_FLAG) !=
-	(uint) (field->flags & NOT_NULL_FLAG))
+        (uint) (!field->real_is_nullable()))
     {
       *need_copy_table= ALTER_TABLE_DATA_CHANGED;
       DBUG_RETURN(0);
@@ -5126,7 +5126,7 @@ mysql_compare_tables(TABLE *table,
          table_part < table_part_end;
          table_part++)
     {
-      not_nullable= not_nullable && (! table_part->field->maybe_null());
+      not_nullable= not_nullable && (! table_part->field->is_nullable());
     }
     if ((table_key->flags & HA_NOSAME) && not_nullable)
       (*candidate_key_count)++;
@@ -6274,7 +6274,7 @@ bool mysql_alter_table(THD *thd,char *ne
                key_part++)
             is_candidate_key=
               (is_candidate_key && 
-               (! table->field[key_part->fieldnr-1]->maybe_null()));
+               (! table->field[key_part->fieldnr-1]->is_nullable()));
           if (is_candidate_key)
             candidate_key_count--;
         }
@@ -6311,7 +6311,7 @@ bool mysql_alter_table(THD *thd,char *ne
              key_part++)
           is_candidate_key=
             (is_candidate_key && 
-             (! table->field[key_part->fieldnr]->maybe_null()));
+             (! table->field[key_part->fieldnr]->is_nullable()));
 
         /*
            Check for "PRIMARY"

=== modified file 'sql/table.cc'
--- a/sql/table.cc	2010-08-20 09:15:16 +0000
+++ b/sql/table.cc	2010-08-25 14:13:11 +0000
@@ -1412,7 +1412,7 @@ static int open_binary_frm(THD *thd, TAB
         null_bit_pos-= 8;
       }
     }
-    if (!(reg_field->flags & NOT_NULL_FLAG))
+    if (reg_field->real_is_nullable())
     {
       if (!(null_bit_pos= (null_bit_pos + 1) & 7))
         null_pos++;
@@ -1467,7 +1467,7 @@ static int open_binary_frm(THD *thd, TAB
 	{
 	  uint fieldnr= key_part[i].fieldnr;
 	  if (!fieldnr ||
-	      share->field[fieldnr-1]->null_ptr ||
+	      share->field[fieldnr-1]->real_is_nullable() ||
 	      share->field[fieldnr-1]->key_length() !=
 	      key_part[i].length)
 	  {
@@ -1492,7 +1492,7 @@ static int open_binary_frm(THD *thd, TAB
         }
         field= key_part->field= share->field[key_part->fieldnr-1];
         key_part->type= field->key_type();
-        if (field->null_ptr)
+        if (field->real_is_nullable())
         {
           key_part->null_offset=(uint) ((uchar*) field->null_ptr -
                                         share->default_values);

=== modified file 'sql/unireg.cc'
--- a/sql/unireg.cc	2010-07-08 21:42:23 +0000
+++ b/sql/unireg.cc	2010-08-25 14:13:11 +0000
@@ -1049,7 +1049,7 @@ static bool make_empty_rec(THD *thd, Fil
 
     if (!(field->flags & NOT_NULL_FLAG))
     {
-      *regfield->null_ptr|= regfield->null_bit;
+      regfield->set_null();
       null_count++;
     }
 

=== modified file 'storage/csv/ha_tina.cc'
--- a/storage/csv/ha_tina.cc	2010-07-29 12:33:56 +0000
+++ b/storage/csv/ha_tina.cc	2010-08-25 14:13:11 +0000
@@ -1668,7 +1668,7 @@ int ha_tina::create(const char *name, TA
   */
   for (Field **field= table_arg->s->field; *field; field++)
   {
-    if ((*field)->real_maybe_null())
+    if ((*field)->real_is_nullable())
     {
       my_error(ER_CHECK_NOT_IMPLEMENTED, MYF(0), "nullable columns");
       DBUG_RETURN(HA_ERR_UNSUPPORTED);

=== modified file 'storage/federated/ha_federated.cc'
--- a/storage/federated/ha_federated.cc	2010-07-23 20:17:55 +0000
+++ b/storage/federated/ha_federated.cc	2010-08-25 14:13:11 +0000
@@ -1714,7 +1714,7 @@ static inline uint field_in_record_is_nu
   int null_offset;
   DBUG_ENTER("ha_federated::field_in_record_is_null");
 
-  if (!field->null_ptr)
+  if (!field->real_is_nullable())
     DBUG_RETURN(0);
 
   null_offset= (uint) ((char*)field->null_ptr - (char*)table->record[0]);

=== modified file 'storage/heap/ha_heap.cc'
--- a/storage/heap/ha_heap.cc	2010-07-23 20:17:55 +0000
+++ b/storage/heap/ha_heap.cc	2010-08-25 14:13:11 +0000
@@ -702,7 +702,7 @@ heap_prepare_hp_create_info(TABLE *table
         seg->charset= &my_charset_bin;
       else
         seg->charset= field->charset_for_protocol();
-      if (field->null_ptr)
+      if (field->real_is_nullable())
       {
 	seg->null_bit= field->null_bit;
 	seg->null_pos= (uint) (field->null_ptr - (uchar*) table_arg->record[0]);

=== modified file 'storage/ibmdb2i/ha_ibmdb2i.cc'
--- a/storage/ibmdb2i/ha_ibmdb2i.cc	2010-07-08 21:20:08 +0000
+++ b/storage/ibmdb2i/ha_ibmdb2i.cc	2010-08-25 14:13:11 +0000
@@ -2377,7 +2377,7 @@ int ha_ibmdb2i::add_index(TABLE *table_a
         for (int j=0 ; j < key_info[i].key_parts ;j++)
         {
           uint fieldnr= key_info[i].key_part[j].fieldnr;
-          if (table_arg->s->field[fieldnr]->null_ptr ||
+          if (table_arg->s->field[fieldnr]->real_is_nullable() ||
               table_arg->s->field[fieldnr]->key_length() !=
               key_info[i].key_part[j].length)
           {

=== modified file 'storage/innobase/handler/ha_innodb.cc'
--- a/storage/innobase/handler/ha_innodb.cc	2010-08-24 16:05:29 +0000
+++ b/storage/innobase/handler/ha_innodb.cc	2010-08-25 14:13:11 +0000
@@ -3954,7 +3954,7 @@ field_in_record_is_null(
 {
 	int	null_offset;
 
-	if (!field->null_ptr) {
+	if (!field->real_is_nullable()) {
 
 		return(0);
 	}
@@ -4668,7 +4668,7 @@ include_field:
 			prebuilt->need_to_access_clustered = TRUE;
 		}
 
-		if (field->null_ptr) {
+		if (field->real_is_nullable()) {
 			templ->mysql_null_byte_offset =
 				(ulint) ((char*) field->null_ptr
 					- (char*) table->record[0]);
@@ -5193,7 +5193,7 @@ calc_row_difference(
 			;
 		}
 
-		if (field->null_ptr) {
+		if (field->real_is_nullable()) {
 			if (field_in_record_is_null(table, field,
 							(char*) old_row)) {
 				o_len = UNIV_SQL_NULL;
@@ -6265,7 +6265,7 @@ create_table_def(
 			goto err_col;
 		}
 
-		if (field->null_ptr) {
+		if (field->real_is_nullable()) {
 			nulls_allowed = 0;
 		} else {
 			nulls_allowed = DATA_NOT_NULL;

=== modified file 'storage/myisam/ha_myisam.cc'
--- a/storage/myisam/ha_myisam.cc	2010-07-13 17:29:44 +0000
+++ b/storage/myisam/ha_myisam.cc	2010-08-25 14:13:11 +0000
@@ -279,7 +279,7 @@ int table2myisam(TABLE *table_arg, MI_KE
       keydef[i].seg[j].bit_pos= 0;
       keydef[i].seg[j].language= field->charset_for_protocol()->number;
 
-      if (field->null_ptr)
+      if (field->real_is_nullable())
       {
         keydef[i].seg[j].null_bit= field->null_bit;
         keydef[i].seg[j].null_pos= (uint) (field->null_ptr-
@@ -363,7 +363,7 @@ int table2myisam(TABLE *table_arg, MI_KE
                                   found->type() == MYSQL_TYPE_VAR_STRING ?
                                   FIELD_SKIP_ENDSPACE :
                                   FIELD_SKIP_PRESPACE);
-    if (found->null_ptr)
+    if (found->real_is_nullable())
     {
       recinfo_pos->null_bit= found->null_bit;
       recinfo_pos->null_pos= (uint) (found->null_ptr -


Attachment: [text/bzr-bundle] bzr/jon.hauglid@oracle.com-20100825141311-1yxtexumf6up5flr.bundle
Thread
bzr commit into mysql-next-mr-bugfixing branch (jon.hauglid:3246) Bug#6295Jon Olav Hauglid25 Aug