List:Commits« Previous MessageNext Message »
From:knielsen Date:June 21 2006 11:35am
Subject:bk commit into 5.1 tree (knielsen:1.2211) BUG#20549
View as plain text  
Below is the list of changes that have just been committed into a local
5.1 repository of knielsen. When knielsen does a push these changes will
be propagated to the main repository and, within 24 hours after the
push, to the public repository.
For information on how to access the public repository
see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html

ChangeSet
  1.2211 06/06/21 13:35:20 knielsen@stripped +2 -0
  BUG#20549: Fix missing memory initialization.
  
  Some values were not initialized, causing Valgrind errors (and potential
  random bugs):
  
   - NDB binlog thread thd->variables.pseudo_thread_id.
   - Table null bytes.
   - Field bytes for columns with NULL values.

  sql/ha_ndbcluster_binlog.cc
    1.66 06/06/21 13:35:15 knielsen@stripped +14 -3
    Fix initialization of thd->variables.pseudo_thread_id.
    Change double alloc_root() call to multi_alloc_root().
    Initialize table records from default values at allocation.

  sql/ha_ndbcluster.cc
    1.327 06/06/21 13:35:15 knielsen@stripped +5 -3
    Fix handling of NULL bits in ndb_unpack_record().
    The NULL bits should not be bzero()'ed, as unused bits must be set to 1.
    Instead initialize them all from default values at table load, and set
    them at each unpack explicit with set_null() and set_notnull().

# This is a BitKeeper patch.  What follows are the unified diffs for the
# set of deltas contained in the patch.  The rest of the patch, the part
# that BitKeeper cares about, is below these diffs.
# User:	knielsen
# Host:	rt.int.sifira.dk
# Root:	/usr/local/mysql/mysql-5.1tmp

--- 1.326/sql/ha_ndbcluster.cc	2006-06-16 12:29:00 +02:00
+++ 1.327/sql/ha_ndbcluster.cc	2006-06-21 13:35:15 +02:00
@@ -2924,8 +2924,6 @@
   my_bitmap_map *old_map= dbug_tmp_use_all_columns(table, table->write_set);
   DBUG_ENTER("ndb_unpack_record");
 
-  // Set null flag(s)
-  bzero(buf, table->s->null_bytes);
   for ( ; field;
        p_field++, value++, field= *p_field)
   {
@@ -2936,11 +2934,11 @@
         int is_null= (*value).rec->isNULL();
         if (is_null)
         {
+          field->set_null(row_offset);
           if (is_null > 0)
           {
             DBUG_PRINT("info",("[%u] NULL",
                                (*value).rec->getColumn()->getColumnNo()));
-            field->set_null(row_offset);
           }
           else
           {
@@ -2954,6 +2952,7 @@
         {
           Field_bit *field_bit= static_cast<Field_bit*>(field);
 
+          field->set_notnull(row_offset);
           /*
             Move internal field pointer to point to 'buf'.  Calling
             the correct member function directly since we know the
@@ -2986,6 +2985,7 @@
         }
         else
         {
+          field->set_notnull(row_offset);
           DBUG_PRINT("info",("[%u] SET",
                              (*value).rec->getColumn()->getColumnNo()));
           DBUG_DUMP("info", (const char*) field->ptr, field->pack_length());
@@ -3005,6 +3005,7 @@
         else if (isNull == -1)
         {
           DBUG_PRINT("info",("[%u] UNDEFINED", col_no));
+          field->set_null(row_offset);
           bitmap_clear_bit(defined, col_no);
         }
         else
@@ -3013,6 +3014,7 @@
           // pointer vas set in get_ndb_blobs_value
           Field_blob *field_blob= (Field_blob*)field;
           char* ptr;
+          field->set_notnull(row_offset);
           field_blob->get_ptr(&ptr, row_offset);
           uint32 len= field_blob->get_length(row_offset);
           DBUG_PRINT("info",("[%u] SET ptr=%p len=%u", col_no, ptr, len));

--- 1.65/sql/ha_ndbcluster_binlog.cc	2006-06-14 01:20:29 +02:00
+++ 1.66/sql/ha_ndbcluster_binlog.cc	2006-06-21 13:35:15 +02:00
@@ -311,8 +311,13 @@
   if (!reopen)
   {
     // allocate memory on ndb share so it can be reused after online alter table
-    share->record[0]= (byte*) alloc_root(&share->mem_root, table->s->rec_buff_length);
-    share->record[1]= (byte*) alloc_root(&share->mem_root, table->s->rec_buff_length);
+    (void)multi_alloc_root(&share->mem_root,
+                           &(share->record[0]), table->s->rec_buff_length,
+                           &(share->record[1]), table->s->rec_buff_length,
+                           NULL);
+    // Initialize to default values.
+    memcpy(share->record[0], table->s->default_values, table->s->reclength);
+    memcpy(share->record[1], table->s->default_values, table->s->reclength);
   }
   {
     my_ptrdiff_t row_offset= share->record[0] - table->record[0];
@@ -3275,6 +3280,13 @@
   thd= new THD; /* note that contructor of THD uses DBUG_ */
   THD_CHECK_SENTRY(thd);
 
+  /* We need to set thd->thread_id before thd->store_globals, or it will
+     set an invalid value for thd->variables.pseudo_thread_id.
+  */
+  pthread_mutex_lock(&LOCK_thread_count);
+  thd->thread_id= thread_id++;
+  pthread_mutex_unlock(&LOCK_thread_count);
+
   thd->thread_stack= (char*) &thd; /* remember where our stack is */
   if (thd->store_globals())
   {
@@ -3307,7 +3319,6 @@
   pthread_detach_this_thread();
   thd->real_id= pthread_self();
   pthread_mutex_lock(&LOCK_thread_count);
-  thd->thread_id= thread_id++;
   threads.append(thd);
   pthread_mutex_unlock(&LOCK_thread_count);
   thd->lex->start_transaction_opt= 0;
Thread
bk commit into 5.1 tree (knielsen:1.2211) BUG#20549knielsen21 Jun