diff options
Diffstat (limited to 'sql/ha_partition.cc')
-rw-r--r-- | sql/ha_partition.cc | 81 |
1 files changed, 48 insertions, 33 deletions
diff --git a/sql/ha_partition.cc b/sql/ha_partition.cc index d874525c4ad..e4924e8e8f2 100644 --- a/sql/ha_partition.cc +++ b/sql/ha_partition.cc @@ -2961,8 +2961,34 @@ int ha_partition::rnd_init(bool scan) uint32 part_id; DBUG_ENTER("ha_partition::rnd_init"); - include_partition_fields_in_used_fields(); - + /* + For operations that may need to change data, we may need to extend + read_set. + */ + if (m_lock_type == F_WRLCK) + { + /* + If write_set contains any of the fields used in partition and + subpartition expression, we need to set all bits in read_set because + the row may need to be inserted in a different [sub]partition. In + other words update_row() can be converted into write_row(), which + requires a complete record. + */ + if (bitmap_is_overlapping(&m_part_info->full_part_field_set, + table->write_set)) + bitmap_set_all(table->read_set); + else + { + /* + Some handlers only read fields as specified by the bitmap for the + read set. For partitioned handlers we always require that the + fields of the partition functions are read such that we can + calculate the partition id to place updated and deleted records. + */ + bitmap_union(table->read_set, &m_part_info->full_part_field_set); + } + } + /* Now we see what the index of our first important partition is */ DBUG_PRINT("info", ("m_part_info->used_partitions: 0x%lx", (long) m_part_info->used_partitions.bitmap)); @@ -3118,7 +3144,7 @@ int ha_partition::rnd_next(uchar *buf) continue; // Probably MyISAM if (result != HA_ERR_END_OF_FILE) - break; // Return error + goto end_dont_reset_start_part; // Return error /* End current partition */ late_extra_no_cache(part_id); @@ -3144,6 +3170,7 @@ int ha_partition::rnd_next(uchar *buf) end: m_part_spec.start_part= NO_CURRENT_PART_ID; +end_dont_reset_start_part: table->status= STATUS_NOT_FOUND; DBUG_RETURN(result); } @@ -3275,7 +3302,15 @@ int ha_partition::index_init(uint inx, bool sorted) m_start_key.length= 0; m_ordered= sorted; m_curr_key_info= table->key_info+inx; - include_partition_fields_in_used_fields(); + /* + Some handlers only read fields as specified by the bitmap for the + read set. For partitioned handlers we always require that the + fields of the partition functions are read such that we can + calculate the partition id to place updated and deleted records. + But this is required for operations that may need to change data only. + */ + if (m_lock_type == F_WRLCK) + bitmap_union(table->read_set, &m_part_info->full_part_field_set); file= m_file; do { @@ -4144,35 +4179,6 @@ int ha_partition::handle_ordered_prev(uchar *buf) } -/* - Set fields in partition functions in read set for underlying handlers - - SYNOPSIS - include_partition_fields_in_used_fields() - - RETURN VALUE - NONE - - DESCRIPTION - Some handlers only read fields as specified by the bitmap for the - read set. For partitioned handlers we always require that the - fields of the partition functions are read such that we can - calculate the partition id to place updated and deleted records. -*/ - -void ha_partition::include_partition_fields_in_used_fields() -{ - Field **ptr= m_part_field_array; - DBUG_ENTER("ha_partition::include_partition_fields_in_used_fields"); - - do - { - bitmap_set_bit(table->read_set, (*ptr)->field_index); - } while (*(++ptr)); - DBUG_VOID_RETURN; -} - - /**************************************************************************** MODULE information calls ****************************************************************************/ @@ -4714,6 +4720,12 @@ void ha_partition::get_dynamic_partition_info(PARTITION_INFO *stat_info, HA_EXTRA_KEY_CACHE: HA_EXTRA_NO_KEY_CACHE: This parameters are no longer used and could be removed. + + 7) Parameters only used by federated tables for query processing + ---------------------------------------------------------------- + HA_EXTRA_INSERT_WITH_UPDATE: + Inform handler that an "INSERT...ON DUPLICATE KEY UPDATE" will be + executed. This condition is unset by HA_EXTRA_NO_IGNORE_DUP_KEY. */ int ha_partition::extra(enum ha_extra_function operation) @@ -4795,6 +4807,9 @@ int ha_partition::extra(enum ha_extra_function operation) */ break; } + /* Category 7), used by federated handlers */ + case HA_EXTRA_INSERT_WITH_UPDATE: + DBUG_RETURN(loop_extra(operation)); default: { /* Temporary crash to discover what is wrong */ |