diff options
Diffstat (limited to 'sql/ha_partition.cc')
-rw-r--r-- | sql/ha_partition.cc | 31 |
1 files changed, 29 insertions, 2 deletions
diff --git a/sql/ha_partition.cc b/sql/ha_partition.cc index deb3bedb203..713be1b7b5d 100644 --- a/sql/ha_partition.cc +++ b/sql/ha_partition.cc @@ -1366,6 +1366,7 @@ int ha_partition::change_partitions(HA_CREATE_INFO *create_info, i= 0; part_count= 0; orig_count= 0; + first= TRUE; part_it.rewind(); do { @@ -1393,9 +1394,16 @@ int ha_partition::change_partitions(HA_CREATE_INFO *create_info, DBUG_RETURN(ER_OUTOFMEMORY); } } while (++j < no_subparts); + if (part_elem->part_state == PART_CHANGED) + orig_count+= no_subparts; + else if (temp_partitions && first) + { + orig_count+= (no_subparts * temp_partitions); + first= FALSE; + } } } while (++i < no_parts); - + first= FALSE; /* Step 5: Create the new partitions and also open, lock and call external_lock @@ -2664,7 +2672,10 @@ int ha_partition::write_row(byte * buf) #endif dbug_tmp_restore_column_map(table->read_set, old_map); if (unlikely(error)) + { + m_part_info->err_value= func_value; DBUG_RETURN(error); + } m_last_part= part_id; DBUG_PRINT("info", ("Insert in partition %d", part_id)); DBUG_RETURN(m_file[part_id]->write_row(buf)); @@ -2713,6 +2724,7 @@ int ha_partition::update_row(const byte *old_data, byte *new_data) m_part_info, &old_part_id, &new_part_id, &func_value))) { + m_part_info->err_value= func_value; DBUG_RETURN(error); } @@ -3657,7 +3669,10 @@ int ha_partition::read_range_first(const key_range *start_key, if (!start_key) // Read first record { - m_index_scan_type= partition_index_first; + if (m_ordered) + m_index_scan_type= partition_index_first; + else + m_index_scan_type= partition_index_first_unordered; error= common_first_last(m_rec0); } else @@ -3871,6 +3886,18 @@ int ha_partition::handle_unordered_scan_next_partition(byte * buf) DBUG_PRINT("info", ("index_first on partition %d", i)); error= file->index_first(buf); break; + case partition_index_first_unordered: + /* + We perform a scan without sorting and this means that we + should not use the index_first since not all handlers + support it and it is also unnecessary to restrict sort + order. + */ + DBUG_PRINT("info", ("read_range_first on partition %d", i)); + table->record[0]= buf; + error= file->read_range_first(0, end_range, eq_range, 0); + table->record[0]= m_rec0; + break; default: DBUG_ASSERT(FALSE); DBUG_RETURN(1); |