List:Commits« Previous MessageNext Message »
From:Patrick Galbraith Date:December 31 2005 12:58am
Subject:bk commit into 5.1 tree (patg:1.2009)
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.2009 05/12/30 16:58:20 patg@stripped +1 -0
  Merge pgalbraith@stripped:/users/rburnett/mysql-5.1-wl2682
  into  govinda.site:/home/patg/mysql-build/mysql-5.1-wl2682

  sql/ha_partition.cc
    1.21 05/12/30 16:58:17 patg@stripped +6 -11
    WL# 2682 Merged reggies changes with mine

# 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.site
# Root:	/home/patg/mysql-build/mysql-5.1-wl2682/RESYNC

--- 1.20/sql/ha_partition.cc	2005-12-30 16:28:14 -08:00
+++ 1.21/sql/ha_partition.cc	2005-12-30 16:58:17 -08:00
@@ -88,19 +88,6 @@
 }
 
 
-bool is_partition_in_table(PARTITION_SHARE *share, char *name)
-{
-  PARTITION_NAME *partition_name;
-  DBUG_ENTER("is_partition_in_table");
-  partition_name= (PARTITION_NAME*)hash_search(&share->partition_names,
-                                               (byte*) name,
-                                               strlen(name));
-  if (partition_name && partition_name->partition_name)
-    DBUG_RETURN(1);
-
-  DBUG_RETURN(0);
-}
-
 /****************************************************************************
                 MODULE create/delete handler object
 ****************************************************************************/
@@ -925,40 +912,6 @@
 	}
   }
   return 0;
-
-/*  for (i= 0; i < m_part_info->no_parts; i++)
-  {
-    PARTITION_NAME *partition_name = (PARTITION_NAME*)my_malloc(sizeof(PARTITION_NAME), MYF(MY_WME));
-    partition_element *part_elem= part_it++;
-    partition_name->partition_name= part_elem->partition_name;
-    partition_name->partition_name_length= strlen(part_elem->partition_name);
-    partition_name->partition_number=part_num_counter++;
-    partition_name->is_sub_partition= FALSE;
-    if (my_hash_insert(&share->partition_names, (byte *)partition_name))
-      goto err_handler;
-    if (is_sub_partitioned(m_part_info))
-    {
-        List_iterator<partition_element> sub_it(part_elem->subpartitions);
-        for (j= 0; j < m_part_info->no_subparts; j++)
-        {
-          partition_element *sub_elem= sub_it++;
-          if (!strcmp(sub_elem->partition_name, part_elem->partition_name))
-          {
-            PARTITION_NAME *sub_partition_name =
-              (PARTITION_NAME*)my_malloc(sizeof(PARTITION_NAME), MYF(MY_WME));
-            sub_partition_name->partition_name= sub_elem->partition_name;
-            sub_partition_name->partition_name_length= strlen(sub_elem->partition_name);
-            sub_partition_name->partition_number=part_num_counter++;
-            sub_partition_name->is_sub_partition= TRUE;
-          }
-          else
-          {
-            continue;
-          }
-        }
-    }
-    DBUG_PRINT("info", ("partition name %s", part_elem->partition_name));
-  }*/
 }
 
 
@@ -1095,14 +1048,8 @@
   file= m_file;
   do
   {
-    //PARTITION_NAME *partition_name;
     partition_element *part_elem= part_it++;
-    //partition_name= (PARTITION_NAME*)hash_search(&share->partition_names,
-      //                                            (byte*) part_elem->partition_name,
-        //                                          strlen(part_elem->partition_name));
     VOID(hash_delete(&(m_part_info->partition_names), (byte*)part_it++));
-//    DBUG_PRINT("info", ("partition_name->partition_name %s", partition_name->partition_name));
-  //  my_free((gptr) partition_name, MYF(0));
     (*file)->close();
   } while (*(++file));
   DBUG_RETURN(0);
@@ -1139,12 +1086,13 @@
 
 int ha_partition::external_lock(THD *thd, int lock_type)
 {
+  int i= 0;
   uint error;
   handler **file;
   bool is_in_list;
   DBUG_ENTER("ha_partition::external_lock");
   
-  /* 
+  /*
     if thd->lex->part_info is non-null, then we were given a 
     specific partition to target
   */
@@ -1165,23 +1113,25 @@
     }
   }
 
+  DBUG_PRINT("info", ("is_in_list %d", is_in_list));
+
   /*
     Now we loop over all the partitions starting at first_partition_set calling
     external_lock for each one
   */
-  int i;
   for (i= current_partition_index; i < (int) m_part_info->no_parts; i++)
   {
     if (_bitmap_is_set(&(m_part_info->used_partitions), i))
       if ((error= m_file[i]->external_lock(thd, lock_type)))
       {
-        DBUG_PRINT("info", ("(file)->s->table_name.str", m_file[i]->table_share->table_name.str));
+        DBUG_PRINT("info", ("(file)->s->table_name.str",
+                            (*file)->table_share->table_name.str));
         if (lock_type != F_UNLCK)
           goto err_handler;
       }
   }
 
-  m_lock_type= lock_type;                       // For the future (2009?)
+  m_lock_type= lock_type;
   DBUG_RETURN(0);
 
 err_handler:
@@ -1245,15 +1195,15 @@
 
 int ha_partition::start_stmt(THD *thd, thr_lock_type lock_type)
 {
+  int i= 0;
   int error= 0;
-  handler **file;
   DBUG_ENTER("ha_partition::start_stmt");
-  file= m_file;
-  do
+  for (i= 0; i < (int) m_part_info->no_parts; i++)
   {
-    if ((error= (*file)->start_stmt(thd, lock_type)))
-      break;
-  } while (*(++file));
+    if (_bitmap_is_set(&(m_part_info->used_partitions), i))
+      if ((error= m_file[i]->start_stmt(thd, lock_type)))
+        break;
+  }
   DBUG_RETURN(error);
 }
 
@@ -1460,15 +1410,15 @@
 
 int ha_partition::delete_all_rows()
 {
+  int i= 0;
   int error;
-  handler **file;
   DBUG_ENTER("ha_partition::delete_all_rows");
-  file= m_file;
-  do
+  for (i= 0; i < (int) m_part_info->no_parts; i++)
   {
-    if ((error= (*file)->delete_all_rows()))
-      DBUG_RETURN(error);
-  } while (*(++file));
+    if (_bitmap_is_set(&(m_part_info->used_partitions), i))
+      if ((error= m_file[i]->delete_all_rows()))
+        DBUG_RETURN(error);
+  }
   DBUG_RETURN(0);
 }
 
@@ -1478,7 +1428,7 @@
 
 void ha_partition::start_bulk_insert(ha_rows rows)
 {
-  handler **file;
+  int i= 0;
   DBUG_ENTER("ha_partition::start_bulk_insert");
   if (!rows)
   {
@@ -1486,29 +1436,28 @@
     DBUG_VOID_RETURN;
   }
   rows= rows/m_tot_parts + 1;
-  file= m_file;
-  do
+  for (i= 0; i < (int) m_part_info->no_parts; i++)
   {
-    (*file)->start_bulk_insert(rows);
-  } while (*(++file));
+    if (_bitmap_is_set(&(m_part_info->used_partitions), i))
+      m_file[i]->start_bulk_insert(rows);
+  }
   DBUG_VOID_RETURN;
 }
 
 
 int ha_partition::end_bulk_insert()
 {
+  int i= 0;
   int error= 0;
-  handler **file;
   DBUG_ENTER("ha_partition::end_bulk_insert");
 
-  file= m_file;
-  do
+  for (i= 0; i < (int) m_part_info->no_parts; i++)
   {
     int tmp;
-    /* We want to execute end_bulk_insert() on all handlers */
-    if ((tmp= (*file)->end_bulk_insert()))
-      error= tmp;
-  } while (*(++file));
+    if (_bitmap_is_set(&(m_part_info->used_partitions), i))
+      if ((tmp= m_file[i]->end_bulk_insert()))
+        error= tmp;
+  }
   DBUG_RETURN(error);
 }
 
@@ -1540,7 +1489,7 @@
 int ha_partition::rnd_init(bool scan)
 {
   int error;
-  int i= 0;
+  uint i= 0;
   handler **file;
   DBUG_ENTER("ha_partition::rnd_init");
 
@@ -1557,8 +1506,8 @@
     bitmap_clear_all(&(m_part_info->used_partitions));
     bitmap_set_bit(&(m_part_info->used_partitions), current_partition_index);
   }
-  
-  /* 
+
+  /*
     we are going to be scanning through rnd_next so we should eliminate as many
     of the partitions as possible.
   */
@@ -1571,7 +1520,7 @@
     rnd_end();
     partition_scan_set_up(rec_buf(0), FALSE);
   }
-  
+
   /* 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)
@@ -1582,7 +1531,7 @@
     */
     DBUG_RETURN(0);
   }
-  
+
   /* we have a partition and we are scanning with rnd_next so we bump our cache */
   if (scan)
     late_extra_cache(current_partition_index);
@@ -1596,7 +1545,6 @@
         goto err;
     if (scan) break;
   }
-  
   m_scan_value= scan ? 1 : 0;
   DBUG_PRINT("info", ("m_scan_value=%d", m_scan_value));
   DBUG_RETURN(0);
@@ -1614,9 +1562,8 @@
 
 int ha_partition::rnd_end()
 {
-  handler **file;
+  int i= 0;
   DBUG_ENTER("ha_partition::rnd_end");
-
   switch (m_scan_value) 
   {
     case 2:                                       // Error
@@ -1824,7 +1771,7 @@
 int ha_partition::index_init(uint inx, bool sorted)
 {
   int error= 0;
-  int i= 0;
+  uint i= 0;
   handler **file;
   DBUG_ENTER("ha_partition::index_init");
 
@@ -1857,7 +1804,7 @@
 int ha_partition::index_end()
 {
   int error= 0;
-  int i= 0;
+  uint i= 0;
   handler **file;
   DBUG_ENTER("ha_partition::index_end");
 
@@ -3006,9 +2953,9 @@
   int result= 0, tmp;
   handler **file;
   DBUG_ENTER("ha_partition::reset");
-  file= m_file;
   if (m_part_info)
     bitmap_clear_all(&m_part_info->used_partitions);
+  file= m_file;
   do
   {
     if ((tmp= (*file)->reset()))
@@ -3017,7 +2964,6 @@
   DBUG_RETURN(result);
 }
 
-
 int ha_partition::extra_opt(enum ha_extra_function operation, ulong cachesize)
 {
   DBUG_ENTER("ha_partition::extra_opt()");
@@ -3133,33 +3079,36 @@
 ha_rows ha_partition::records_in_range(uint inx, key_range *min_key,
 				       key_range *max_key)
 {
+  int i= 0;
   ha_rows in_range= 0;
-  handler **file;
   DBUG_ENTER("ha_partition::records_in_range");
 
-  file= m_file;
-  do
+  for (i= 0; i < (int) m_part_info->no_parts; i++)
   {
-    in_range+= (*file)->records_in_range(inx, min_key, max_key);
-  } while (*(++file));
+    if (_bitmap_is_set(&(m_part_info->used_partitions), i))
+      in_range+= m_file[i]->records_in_range(inx, min_key, max_key);
+  }
   DBUG_RETURN(in_range);
 }
 
 
 ha_rows ha_partition::estimate_rows_upper_bound()
 {
+  int i= 0;
   ha_rows rows, tot_rows= 0;
-  handler **file;
   DBUG_ENTER("ha_partition::estimate_rows_upper_bound");
 
-  file= m_file;
-  do
+  for (i= 0; i < (int) m_part_info->no_parts; i++)
   {
-    rows= (*file)->estimate_rows_upper_bound();
-    if (rows == HA_POS_ERROR)
-      DBUG_RETURN(HA_POS_ERROR);
-    tot_rows+= rows;
-  } while (*(++file));
+    if (_bitmap_is_set(&(m_part_info->used_partitions), i))
+    {
+      rows= m_file[i]->estimate_rows_upper_bound();
+
+      if (rows == HA_POS_ERROR)
+        DBUG_RETURN(HA_POS_ERROR);
+      tot_rows+= rows;
+    }
+  }
   DBUG_RETURN(tot_rows);
 }
 
Thread
bk commit into 5.1 tree (patg:1.2009)Patrick Galbraith31 Dec