List:Commits« Previous MessageNext Message »
From:Patrick Galbraith Date:January 19 2006 9:08pm
Subject:bk commit into 5.1 tree (patg:1.2082)
View as plain text  
Below is the list of changes that have just been committed into a local
5.1 repository of patg. When patg 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.2082 06/01/19 13:08:03 patg@stripped +2 -0
  WL# 2986
  
  Review changes per Mikael

  sql/ha_partition.h
    1.11 06/01/19 13:07:59 patg@stripped +1 -1
    WL# 2986, review fixes per Mikael

  sql/ha_partition.cc
    1.25 06/01/19 13:07:59 patg@stripped +54 -56
    WL# 2986, review fixes per Mikael

# 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:	patg
# Host:	govinda.patg.net
# Root:	/home/patg/mysql-build/mysql-5.1-wl2986

--- 1.24/sql/ha_partition.cc	2006-01-19 11:30:55 -08:00
+++ 1.25/sql/ha_partition.cc	2006-01-19 13:07:59 -08:00
@@ -239,7 +239,7 @@
   m_top_entry= NO_CURRENT_PART_ID;
   m_rec_length= 0;
   m_last_part= 0;
-  current_partition_index= MY_BIT_NONE;
+  m_current_partition_index= MY_BIT_NONE;
   m_rec0= 0;
   m_curr_key_info= 0;
   /*
@@ -2414,10 +2414,7 @@
 err_handler:
   while (file-- != m_file)
   {
-    if (_bitmap_is_set(&(m_part_info->used_partitions), (file - m_file)))
-    {
-      (*file)->external_lock(thd, F_UNLCK);
-    }
+    (*file)->external_lock(thd, F_UNLCK);
   }
   DBUG_RETURN(error);
 }
@@ -2511,11 +2508,8 @@
   file= m_file;
   do
   {
-    if (_bitmap_is_set(&(m_part_info->used_partitions), (file - m_file)))
-    {
-      if ((error= (*file)->start_stmt(thd, lock_type)))
-        break;
-    }
+    if ((error= (*file)->start_stmt(thd, lock_type)))
+      break;
   } while (*(++file));
   DBUG_RETURN(error);
 }
@@ -2797,9 +2791,8 @@
   file= m_file;
   do
   {
-    if (_bitmap_is_set(&(m_part_info->used_partitions), (file - m_file)))
-      if ((error= (*file)->delete_all_rows()))
-        DBUG_RETURN(error);
+    if ((error= (*file)->delete_all_rows()))
+      DBUG_RETURN(error);
   } while (*(++file));
   DBUG_RETURN(0);
 }
@@ -2833,8 +2826,7 @@
   file= m_file;
   do
   {
-    if (_bitmap_is_set(&(m_part_info->used_partitions),(file - m_file)))
-      (*file)->start_bulk_insert(rows);
+    (*file)->start_bulk_insert(rows);
   } while (*(++file));
   DBUG_VOID_RETURN;
 }
@@ -2861,9 +2853,8 @@
   do
   {
     int tmp;
-    if (_bitmap_is_set(&(m_part_info->used_partitions), (file - m_file)))
-      if ((tmp= (*file)->end_bulk_insert()))
-        error= tmp;
+    if ((tmp= (*file)->end_bulk_insert()))
+      error= tmp;
   } while (*(++file));
   DBUG_RETURN(error);
 }
@@ -2923,9 +2914,9 @@
 
   /* now we see what the index of our first important partition is */
   DBUG_PRINT("info", ("m_part_info->used_partitions %lx", m_part_info->used_partitions.bitmap));
-  current_partition_index = bitmap_get_first_set(&(m_part_info->used_partitions));
-  DBUG_PRINT("info", ("current_partition_index %d", current_partition_index));
-  if (MY_BIT_NONE == current_partition_index)
+  m_current_partition_index = bitmap_get_first_set(&(m_part_info->used_partitions));
+  DBUG_PRINT("info", ("m_current_partition_index %d", m_current_partition_index));
+  if (MY_BIT_NONE == m_current_partition_index)
   {
     /*
       The set of partitions to scan is empty. We return success and return
@@ -2936,11 +2927,11 @@
 
   /* we have a partition and we are scanning with rnd_next so we bump our cache */
   if (scan)
-    late_extra_cache(current_partition_index);
+    late_extra_cache(m_current_partition_index);
 
-  DBUG_PRINT("info", ("rnd_init on partition %d", current_partition_index));
+  DBUG_PRINT("info", ("rnd_init on partition %d", m_current_partition_index));
 
-  for (i= current_partition_index; i < m_tot_parts; i++)
+  for (i= m_current_partition_index; i < m_tot_parts; i++)
   {
     if (_bitmap_is_set(&(m_part_info->used_partitions), i))
       if ((error= m_file[i]->ha_rnd_init(scan)))
@@ -2953,7 +2944,7 @@
   DBUG_RETURN(0);
 
 err:
-  while (i >= current_partition_index)
+  while (i >= m_current_partition_index)
   {
     if (_bitmap_is_set(&(m_part_info->used_partitions), i))
 	  m_file[i--]->ha_rnd_end();
@@ -2982,10 +2973,10 @@
   case 2:                                       // Error
     break;
   case 1:
-    if (MY_BIT_NONE != current_partition_index)         // Table scan
+    if (MY_BIT_NONE != m_current_partition_index)         // Table scan
     {
-      late_extra_no_cache(current_partition_index);
-      m_file[current_partition_index]->ha_rnd_end();
+      late_extra_no_cache(m_current_partition_index);
+      m_file[m_current_partition_index]->ha_rnd_end();
     }
     break;
   case 0:
@@ -3030,7 +3021,7 @@
   DBUG_PRINT("info", ("m_scan_value %d", m_scan_value));
 
 
-  if (MY_BIT_NONE == current_partition_index)
+  if (MY_BIT_NONE == m_current_partition_index)
   {
     /*
       The original set of partitions to scan was empty and thus we report
@@ -3040,7 +3031,7 @@
   }
   
   DBUG_ASSERT(m_scan_value == 1);
-  file= m_file[current_partition_index];
+  file= m_file[m_current_partition_index];
   
   while (TRUE)
   {
@@ -3059,30 +3050,30 @@
       break;                                  // Return error
 
     /* End current partition */
-    late_extra_no_cache(current_partition_index);
-    DBUG_PRINT("info", ("rnd_end on partition %d", current_partition_index));
+    late_extra_no_cache(m_current_partition_index);
+    DBUG_PRINT("info", ("rnd_end on partition %d", m_current_partition_index));
     if ((result= file->ha_rnd_end()))
       break;
     
     /* Shift to next partition */
-    while (++current_partition_index < m_tot_parts &&
-           !bitmap_is_set(&(m_part_info->used_partitions), current_partition_index))
+    while (++m_current_partition_index < m_tot_parts &&
+           !bitmap_is_set(&(m_part_info->used_partitions), m_current_partition_index))
     {
     }
-    if (current_partition_index >= m_tot_parts)
+    if (m_current_partition_index >= m_tot_parts)
     {
       result= HA_ERR_END_OF_FILE;
       break;
     }
-    file= m_file[current_partition_index];
-    DBUG_PRINT("info", ("rnd_init on partition %d", current_partition_index));
+    file= m_file[m_current_partition_index];
+    DBUG_PRINT("info", ("rnd_init on partition %d", m_current_partition_index));
     if ((result= file->ha_rnd_init(1)))
       break;
-    late_extra_cache(current_partition_index);
+    late_extra_cache(m_current_partition_index);
   }
 
 end:
-  current_partition_index= MY_BIT_NONE;
+  m_current_partition_index= MY_BIT_NONE;
   m_part_spec.start_part= NO_CURRENT_PART_ID;  //TODO: should be removed
   table->status= STATUS_NOT_FOUND;
   DBUG_RETURN(result);
@@ -3116,11 +3107,11 @@
 
 void ha_partition::position(const byte *record)
 {
-  handler *file= m_file[current_partition_index];
+  handler *file= m_file[m_current_partition_index];
   DBUG_ENTER("ha_partition::position");
 
   file->position(record);
-  //store_part_id_in_pos(ref, current_partition_index);
+  //store_part_id_in_pos(ref, m_current_partition_index);
   memcpy((ref + PARTITION_BYTES_IN_POS), file->ref,
 	 (ref_length - PARTITION_BYTES_IN_POS));
 
@@ -3162,7 +3153,7 @@
   part_id= uint2korr((const byte *) pos);
   DBUG_ASSERT(part_id < m_tot_parts);
   file= m_file[part_id];
-  current_partition_index= part_id;
+  m_current_partition_index= part_id;
   m_last_part= part_id;  // TODO: remove
   DBUG_RETURN(file->rnd_pos(buf, (pos + PARTITION_BYTES_IN_POS)));
 }
@@ -3882,8 +3873,8 @@
   queue_remove_all(&m_queue);
 
   /* now we see what the index of our first important partition is */
-  current_partition_index = bitmap_get_first_set(&(m_part_info->used_partitions));
-  if (MY_BIT_NONE == current_partition_index)
+  m_current_partition_index = bitmap_get_first_set(&(m_part_info->used_partitions));
+  if (MY_BIT_NONE == m_current_partition_index)
   {
     /*
       The set of partitions to scan is empty. We return success and return
@@ -3892,8 +3883,8 @@
     DBUG_RETURN(0);
   }
 
-  DBUG_PRINT("info", ("current_partition_index %d", current_partition_index));
-  for (i= current_partition_index; i <= m_part_spec.end_part; i++)
+  DBUG_PRINT("info", ("m_current_partition_index %d", m_current_partition_index));
+  for (i= m_current_partition_index; i <= m_part_spec.end_part; i++)
   {
     DBUG_PRINT("info", ("i %d", i));
     if (_bitmap_is_set(&(m_part_info->used_partitions), i))
@@ -4215,14 +4206,17 @@
     file_array= m_file;
     do
     {
-      file= *file_array;
-      file->info(HA_STATUS_VARIABLE);
-      records+= file->records;
-      deleted+= file->deleted;
-      data_file_length+= file->data_file_length;
-      index_file_length+= file->index_file_length;
-      if (file->check_time > check_time)
-	check_time= file->check_time;
+      if (_bitmap_is_set(&(m_part_info->used_partitions), (file_array - m_file)))
+      {
+        file= *file_array;
+        file->info(HA_STATUS_VARIABLE);
+        records+= file->records;
+        deleted+= file->deleted;
+        data_file_length+= file->data_file_length;
+        index_file_length+= file->index_file_length;
+        if (file->check_time > check_time)
+          check_time= file->check_time;
+      }
     } while (*(++file_array));
     if (records < 2 &&
         m_table_flags & HA_NOT_EXACT_COUNT)
@@ -4807,7 +4801,10 @@
   int result= 0, tmp;
   handler **file;
   DBUG_ENTER("ha_partition::loop_extra()");
-
+  /* 
+    TODO, 5.2: this is where you could possibly add optimisations to add the bitmap
+    _if_ a SELECT.
+  */
   for (file= m_file; *file; file++)
   {
     if ((tmp= (*file)->extra(operation)))
@@ -4907,7 +4904,8 @@
   DBUG_ENTER("ha_partition::scan_time");
 
   for (file= m_file; *file; file++)
-    scan_time+= (*file)->scan_time();
+    if (_bitmap_is_set(&(m_part_info->used_partitions), (file - m_file)))
+      scan_time+= (*file)->scan_time();
   DBUG_RETURN(scan_time);
 }
 

--- 1.10/sql/ha_partition.h	2006-01-19 11:30:55 -08:00
+++ 1.11/sql/ha_partition.h	2006-01-19 13:07:59 -08:00
@@ -93,7 +93,7 @@
   uint m_top_entry;                      // Which partition is to
                                          // deliver next result
   uint m_rec_length;                     // Local copy of record length
-  uint current_partition_index;          // Index of current partition in bitmap
+  uint m_current_partition_index;          // Index of current partition in bitmap
 
   bool m_ordered;                        // Ordered/Unordered index scan
   bool m_has_transactions;               // Can we support transactions
Thread
bk commit into 5.1 tree (patg:1.2082)Patrick Galbraith19 Jan