summaryrefslogtreecommitdiff
path: root/sql/ha_partition.cc
diff options
context:
space:
mode:
authorMattias Jonsson <mattias.jonsson@oracle.com>2012-11-13 09:21:59 +0100
committerMattias Jonsson <mattias.jonsson@oracle.com>2012-11-13 09:21:59 +0100
commit9b50775d82eb003a1da16069ebf8249aaf67200e (patch)
treedf9950951d2804ea00bb935dbd520b66d034c9eb /sql/ha_partition.cc
parent8cde305749fca822bd366f174f1bedaa028f5670 (diff)
downloadmariadb-git-9b50775d82eb003a1da16069ebf8249aaf67200e.tar.gz
Bug#14845133:
The problem is related to the changes made in bug#13025132. get_partition_set can do dynamic pruning which limits the partitions to scan even further. This is not accounted for when setting the correct start of the preallocated record buffer used in the priority queue, thus leading to wrong buffer is used (including wrong preset partitioning id, connected to that buffer). Solution is to fast forward the buffer pointer to point to the correct partition record buffer.
Diffstat (limited to 'sql/ha_partition.cc')
-rw-r--r--sql/ha_partition.cc21
1 files changed, 19 insertions, 2 deletions
diff --git a/sql/ha_partition.cc b/sql/ha_partition.cc
index 4e6f5984934..69cf5f74df6 100644
--- a/sql/ha_partition.cc
+++ b/sql/ha_partition.cc
@@ -4077,6 +4077,7 @@ bool ha_partition::init_record_priority_queue()
{
if (bitmap_is_set(&m_part_info->used_partitions, i))
{
+ DBUG_PRINT("info", ("init rec-buf for part %u", i));
int2store(ptr, i);
ptr+= m_rec_length + PARTITION_BYTES_IN_POS;
}
@@ -4981,11 +4982,27 @@ int ha_partition::handle_ordered_index_scan(uchar *buf, bool reverse_order)
m_top_entry= NO_CURRENT_PART_ID;
queue_remove_all(&m_queue);
- DBUG_PRINT("info", ("m_part_spec.start_part %d", m_part_spec.start_part));
- for (i= m_part_spec.start_part; i <= m_part_spec.end_part; i++)
+ /*
+ Position part_rec_buf_ptr to point to the first used partition >=
+ start_part. There may be partitions marked by used_partitions,
+ but is before start_part. These partitions has allocated record buffers
+ but is dynamically pruned, so those buffers must be skipped.
+ */
+ uint first_used_part= bitmap_get_first_set(&m_part_info->used_partitions);
+ for (; first_used_part < m_part_spec.start_part; first_used_part++)
+ {
+ if (bitmap_is_set(&(m_part_info->used_partitions), first_used_part))
+ part_rec_buf_ptr+= m_rec_length + PARTITION_BYTES_IN_POS;
+ }
+ DBUG_PRINT("info", ("m_part_spec.start_part %u first_used_part %u",
+ m_part_spec.start_part, first_used_part));
+ for (i= first_used_part; i <= m_part_spec.end_part; i++)
{
if (!(bitmap_is_set(&(m_part_info->used_partitions), i)))
continue;
+ DBUG_PRINT("info", ("reading from part %u (scan_type: %u)",
+ i, m_index_scan_type));
+ DBUG_ASSERT(i == uint2korr(part_rec_buf_ptr));
uchar *rec_buf_ptr= part_rec_buf_ptr + PARTITION_BYTES_IN_POS;
int error;
handler *file= m_file[i];