List:Commits« Previous MessageNext Message »
From:ingo Date:July 4 2007 12:44pm
Subject:bk commit into 6.0-falcon tree (istruewing:1.2583) BUG#26827
View as plain text  
Below is the list of changes that have just been committed into a local
6.0-falcon repository of istruewing. When istruewing 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@stripped, 2007-07-04 14:44:03+02:00, istruewing@stripped +3 -0
  Bug#26827 - table->read_set is set incorrectly,
              causing update of a different column
  
  Add-on patch to the previous patch.
  
  Fixed a valgrind error: Optimized bitmap buffer allocation:
  thd->alloc() does not require free.
  
  Optimized bitmap handling. Used the new bitmap for adding
  partition fields to read_set. Do so only if needed (not for SELECT).

  sql/ha_partition.cc@stripped, 2007-07-04 14:43:58+02:00, istruewing@stripped +34 -40
    Bug#26827 - table->read_set is set incorrectly,
                causing update of a different column
    Optimized bitmap handling. Used the new bitmap for adding
    partition fields to read_set. Do so only if needed
    (not for SELECT). Consequently removed
    include_partition_fields_in_used_fields().

  sql/ha_partition.h@stripped, 2007-07-04 14:43:58+02:00, istruewing@stripped +0 -1
    Bug#26827 - table->read_set is set incorrectly,
                causing update of a different column
    Removed declaration of
    include_partition_fields_in_used_fields().

  sql/sql_partition.cc@stripped, 2007-07-04 14:43:58+02:00, istruewing@stripped +12 -3
    Bug#26827 - table->read_set is set incorrectly,
                causing update of a different column
    Optimized bitmap buffer allocation.
    thd->alloc() does not require free.
    create_full_part_field_array() needs a THD parameter now.

# 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:	istruewing
# Host:	chilla.local
# Root:	/home/mydev/mysql-5.1-falcon-bug26827

--- 1.89/sql/ha_partition.cc	2007-07-04 14:44:13 +02:00
+++ 1.90/sql/ha_partition.cc	2007-07-04 14:44:13 +02:00
@@ -2960,18 +2960,33 @@ int ha_partition::rnd_init(bool scan)
   uint32 part_id;
   DBUG_ENTER("ha_partition::rnd_init");
 
-  include_partition_fields_in_used_fields();
-
   /*
-    If write_set contains any of the fields used in partition and
-    subpartition expression, we need to set all bits in read_set because
-    the row may need to be inserted in a different [sub]partition. In
-    other words update_row() can be converted into write_row(), which
-    requires a complete record.
+    For operations that may need to change data, we may need to extend
+    read_set.
   */
-  if (bitmap_is_overlapping(&m_part_info->full_part_field_set,
-                            table->write_set))
-    bitmap_set_all(table->read_set);
+  if (m_lock_type == F_WRLCK)
+  {
+    /*
+      If write_set contains any of the fields used in partition and
+      subpartition expression, we need to set all bits in read_set because
+      the row may need to be inserted in a different [sub]partition. In
+      other words update_row() can be converted into write_row(), which
+      requires a complete record.
+    */
+    if (bitmap_is_overlapping(&m_part_info->full_part_field_set,
+                              table->write_set))
+      bitmap_set_all(table->read_set);
+    else
+    {
+      /*
+        Some handlers only read fields as specified by the bitmap for the
+        read set. For partitioned handlers we always require that the
+        fields of the partition functions are read such that we can
+        calculate the partition id to place updated and deleted records.
+      */
+      bitmap_union(table->read_set, &m_part_info->full_part_field_set);
+    }
+  }
 
   /* Now we see what the index of our first important partition is */
   DBUG_PRINT("info", ("m_part_info->used_partitions: 0x%lx",
@@ -3286,7 +3301,15 @@ int ha_partition::index_init(uint inx, b
   m_start_key.length= 0;
   m_ordered= sorted;
   m_curr_key_info= table->key_info+inx;
-  include_partition_fields_in_used_fields();
+  /*
+    Some handlers only read fields as specified by the bitmap for the
+    read set. For partitioned handlers we always require that the
+    fields of the partition functions are read such that we can
+    calculate the partition id to place updated and deleted records.
+    But this is required for operations that may need to change data only.
+  */
+  if (m_lock_type == F_WRLCK)
+    bitmap_union(table->read_set, &m_part_info->full_part_field_set);
   file= m_file;
   do
   {
@@ -4152,35 +4175,6 @@ int ha_partition::handle_ordered_prev(uc
   return_top_record(buf);
   DBUG_PRINT("info", ("Record returned from partition %d", m_top_entry));
   DBUG_RETURN(0);
-}
-
-
-/*
-  Set fields in partition functions in read set for underlying handlers
-
-  SYNOPSIS
-    include_partition_fields_in_used_fields()
-
-  RETURN VALUE
-    NONE
-
-  DESCRIPTION
-    Some handlers only read fields as specified by the bitmap for the
-    read set. For partitioned handlers we always require that the
-    fields of the partition functions are read such that we can
-    calculate the partition id to place updated and deleted records.
-*/
-
-void ha_partition::include_partition_fields_in_used_fields()
-{
-  Field **ptr= m_part_field_array;
-  DBUG_ENTER("ha_partition::include_partition_fields_in_used_fields");
-
-  do
-  {
-    bitmap_set_bit(table->read_set, (*ptr)->field_index);
-  } while (*(++ptr));
-  DBUG_VOID_RETURN;
 }
 
 

--- 1.36/sql/ha_partition.h	2007-07-04 14:44:13 +02:00
+++ 1.37/sql/ha_partition.h	2007-07-04 14:44:13 +02:00
@@ -449,7 +449,6 @@ private:
   int handle_ordered_next(uchar * buf, bool next_same);
   int handle_ordered_prev(uchar * buf);
   void return_top_record(uchar * buf);
-  void include_partition_fields_in_used_fields();
 public:
   /*
     -------------------------------------------------------------------------

--- 1.107/sql/sql_partition.cc	2007-07-04 14:44:13 +02:00
+++ 1.108/sql/sql_partition.cc	2007-07-04 14:44:13 +02:00
@@ -523,6 +523,7 @@ static bool set_up_field_array(TABLE *ta
 
   SYNOPSIS
     create_full_part_field_array()
+    thd                  Thread handle
     table                TABLE object for which partition fields are set-up
     part_info            Reference to partitioning data structure
 
@@ -537,11 +538,12 @@ static bool set_up_field_array(TABLE *ta
     This function is called from fix_partition_func
 */
 
-static bool create_full_part_field_array(TABLE *table,
+static bool create_full_part_field_array(THD *thd, TABLE *table,
                                          partition_info *part_info)
 {
   bool result= FALSE;
   Field **ptr;
+  my_bitmap_map *bitmap_buf;
   DBUG_ENTER("create_full_part_field_array");
 
   if (!part_info->is_sub_partitioned())
@@ -585,7 +587,14 @@ static bool create_full_part_field_array
     when updating. We need to set all bits in read_set because the row
     may need to be inserted in a different [sub]partition.
   */
-  if (bitmap_init(&part_info->full_part_field_set, NULL,
+  if (!(bitmap_buf= (my_bitmap_map*)
+        thd->alloc(bitmap_buffer_size(table->s->fields))))
+  {
+    mem_alloc_error(bitmap_buffer_size(table->s->fields));
+    result= TRUE;
+    goto end;
+  }
+  if (bitmap_init(&part_info->full_part_field_set, bitmap_buf,
                   table->s->fields, FALSE))
   {
     mem_alloc_error(table->s->fields);
@@ -1658,7 +1667,7 @@ bool fix_partition_func(THD *thd, TABLE 
     my_error(ER_PARTITION_FUNCTION_IS_NOT_ALLOWED, MYF(0));
     goto end;
   }
-  if (unlikely(create_full_part_field_array(table, part_info)))
+  if (unlikely(create_full_part_field_array(thd, table, part_info)))
     goto end;
   if (unlikely(check_primary_key(table)))
     goto end;
Thread
bk commit into 6.0-falcon tree (istruewing:1.2583) BUG#26827ingo4 Jul