List:Commits« Previous MessageNext Message »
From:Mattias Jonsson Date:July 9 2010 12:59pm
Subject:bzr commit into mysql-5.1-bugteam branch (mattias.jonsson:3475)
View as plain text  
#At file:///Users/mattiasj/mysql-bzr/topush-51-bugteam/ based on revid:davi.arnaut@stripped

 3475 Mattias Jonsson	2010-07-09 [merge]
      merge

    modified:
      sql/ha_partition.cc
      sql/ha_partition.h
=== modified file 'sql/ha_partition.cc'
--- a/sql/ha_partition.cc	2010-05-25 13:41:00 +0000
+++ b/sql/ha_partition.cc	2010-07-08 23:09:31 +0000
@@ -4220,6 +4220,58 @@ int ha_partition::index_read_last_map(uc
 
 
 /*
+  Optimization of the default implementation to take advantage of dynamic
+  partition pruning.
+*/
+int ha_partition::index_read_idx_map(uchar *buf, uint index,
+                                     const uchar *key,
+                                     key_part_map keypart_map,
+                                     enum ha_rkey_function find_flag)
+{
+  int error= HA_ERR_KEY_NOT_FOUND;
+  DBUG_ENTER("ha_partition::index_read_idx_map");
+
+  if (find_flag == HA_READ_KEY_EXACT)
+  {
+    uint part;
+    m_start_key.key= key;
+    m_start_key.keypart_map= keypart_map;
+    m_start_key.flag= find_flag;
+    m_start_key.length= calculate_key_len(table, index, m_start_key.key,
+                                          m_start_key.keypart_map);
+
+    get_partition_set(table, buf, index, &m_start_key, &m_part_spec);
+
+    /* How can it be more than one partition with the current use? */
+    DBUG_ASSERT(m_part_spec.start_part == m_part_spec.end_part);
+
+    for (part= m_part_spec.start_part; part <= m_part_spec.end_part; part++)
+    {
+      if (bitmap_is_set(&(m_part_info->used_partitions), part))
+      {
+        error= m_file[part]->index_read_idx_map(buf, index, key,
+                                                keypart_map, find_flag);
+        if (error != HA_ERR_KEY_NOT_FOUND &&
+            error != HA_ERR_END_OF_FILE)
+          break;
+      }
+    }
+  }
+  else
+  {
+    /*
+      If not only used with READ_EXACT, we should investigate if possible
+      to optimize for other find_flag's as well.
+    */
+    DBUG_ASSERT(0);
+    /* fall back on the default implementation */
+    error= handler::index_read_idx_map(buf, index, key, keypart_map, find_flag);
+  }
+  DBUG_RETURN(error);
+}
+
+
+/*
   Read next record in a forward index scan
 
   SYNOPSIS

=== modified file 'sql/ha_partition.h'
--- a/sql/ha_partition.h	2009-11-17 19:02:16 +0000
+++ b/sql/ha_partition.h	2010-07-08 23:09:31 +0000
@@ -448,6 +448,15 @@ public:
   virtual int index_init(uint idx, bool sorted);
   virtual int index_end();
 
+  /**
+    @breif
+    Positions an index cursor to the index specified in the hanlde. Fetches the
+    row if available. If the key value is null, begin at first key of the
+    index.
+  */
+  virtual int index_read_idx_map(uchar *buf, uint index, const uchar *key,
+                                 key_part_map keypart_map,
+                                 enum ha_rkey_function find_flag);
   /*
     These methods are used to jump to next or previous entry in the index
     scan. There are also methods to jump to first and last entry.


Attachment: [text/bzr-bundle] bzr/mattias.jonsson@oracle.com-20100709125940-xgan11um91pgpgmq.bundle
Thread
bzr commit into mysql-5.1-bugteam branch (mattias.jonsson:3475) Mattias Jonsson9 Jul