[Commits] Rev 3369: Part 2 of the fix for bug mdev-504. in file:///home/igor/maria/maria-5.5-mwl248-bugs/

Igor Babaev igor at askmonty.org
Sun Sep 9 06:33:04 EEST 2012


At file:///home/igor/maria/maria-5.5-mwl248-bugs/

------------------------------------------------------------
revno: 3369
revision-id: igor at askmonty.org-20120909033303-kpamq9csf6hckgp6
parent: igor at askmonty.org-20120908190714-cguiubk7dubk6w08
committer: Igor Babaev <igor at askmonty.org>
branch nick: maria-5.5-mwl248-bugs
timestamp: Sat 2012-09-08 20:33:03 -0700
message:
  Part 2 of the fix for bug mdev-504.
  Any Field object should use current_thd instead of table->in_use 
  when THD is needed if table == NULL.
  This patch fixes the crash of test case from mdev-504.test.
-------------- next part --------------
=== modified file 'sql/field.cc'
--- a/sql/field.cc	2012-08-30 01:50:38 +0000
+++ b/sql/field.cc	2012-09-09 03:33:03 +0000
@@ -1319,7 +1319,7 @@
 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)
-  :ptr(ptr_arg), null_ptr(null_ptr_arg), table(0), orig_table(0), thd(0),
+  :ptr(ptr_arg), null_ptr(null_ptr_arg), table(0), orig_table(0),
   table_name(0), field_name(field_name_arg), option_list(0),
   option_struct(0), key_start(0), part_of_key(0),
   part_of_key_not_clustered(0), part_of_sortkey(0),
@@ -1874,12 +1874,11 @@
 }
 
 
-Field *Field::clone(THD *thd_arg, MEM_ROOT *root, my_ptrdiff_t diff)
+Field *Field::clone(MEM_ROOT *root, my_ptrdiff_t diff)
 {
   Field *tmp;
   if ((tmp= (Field*) memdup_root(root,(char*) this,size_of())))
   {
-    tmp->thd= thd_arg;
     tmp->move_field_offset(diff);
   }
   return tmp;
@@ -2780,7 +2779,7 @@
   }
   if (store_value(&decimal_value))
     err= 1;
-  else if (err && !thd->got_warning)
+  else if (err && !get_thd()->got_warning)
     err= warn_if_overflow(err);
   return err;
 }

=== modified file 'sql/field.h'
--- a/sql/field.h	2012-07-27 00:50:08 +0000
+++ b/sql/field.h	2012-09-09 03:33:03 +0000
@@ -175,7 +175,6 @@
   */
   TABLE *table;                                 // Pointer for table
   TABLE *orig_table;                            // Pointer to original table
-  THD *thd;                                     // Used when table == NULL
   const char * const *table_name;
   const char *field_name;
   /** reference to the list of options or NULL */
@@ -452,7 +451,7 @@
   */
   inline bool real_maybe_null(void) { return null_ptr != 0; }
 
-  inline THD *get_thd() { return table ? table->in_use : thd; }
+  inline THD *get_thd() { return table ? table->in_use : current_thd; }
 
   enum {
     LAST_NULL_BYTE_UNDEF= 0
@@ -492,7 +491,7 @@
   Field *clone(MEM_ROOT *mem_root, TABLE *new_table);
   Field *clone(MEM_ROOT *mem_root, TABLE *new_table, my_ptrdiff_t diff,
                bool stat_flag= FALSE);
-  Field *clone(THD *thd_arg, MEM_ROOT *mem_root, my_ptrdiff_t diff);
+  Field *clone(MEM_ROOT *mem_root, my_ptrdiff_t diff);
   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;

=== modified file 'sql/sql_statistics.cc'
--- a/sql/sql_statistics.cc	2012-09-08 19:04:31 +0000
+++ b/sql/sql_statistics.cc	2012-09-09 03:33:03 +0000
@@ -1586,7 +1586,7 @@
         Field *fld;
         table_field= *field_ptr;
         my_ptrdiff_t diff= record - table_share->default_values;
-        if (!(fld= table_field->clone(thd, &table_share->mem_root, diff)))
+        if (!(fld= table_field->clone(&table_share->mem_root, diff)))
           continue;
         store_address_if_first(i == 0 ?
                                (void **) &table_field->read_stats->min_value :



More information about the commits mailing list