summaryrefslogtreecommitdiff
path: root/sql/partition_info.cc
diff options
context:
space:
mode:
authorSergei Golubchik <serg@mariadb.org>2015-11-28 18:25:05 +0100
committerSergei Golubchik <serg@mariadb.org>2016-12-12 20:27:27 +0100
commit9bcfd27b7a5fb01fdc4855fd8e8e4fafc35d9f74 (patch)
tree411cb54a7ac186ca8387c8a8bdb402a144a40872 /sql/partition_info.cc
parent5b716bc2e0cec40780f6276e2f577f5eedf058e3 (diff)
downloadmariadb-git-9bcfd27b7a5fb01fdc4855fd8e8e4fafc35d9f74.tar.gz
cleanup: remove dead (half-merged) code from partition_info.*
Diffstat (limited to 'sql/partition_info.cc')
-rw-r--r--sql/partition_info.cc299
1 files changed, 0 insertions, 299 deletions
diff --git a/sql/partition_info.cc b/sql/partition_info.cc
index 08afcb602a0..74c09b8a3c6 100644
--- a/sql/partition_info.cc
+++ b/sql/partition_info.cc
@@ -253,7 +253,6 @@ bool partition_info::set_partition_bitmaps(TABLE_LIST *table_list)
DBUG_ASSERT(bitmaps_are_initialized);
DBUG_ASSERT(table);
- is_pruning_completed= false;
if (!bitmaps_are_initialized)
DBUG_RETURN(TRUE);
@@ -280,239 +279,6 @@ bool partition_info::set_partition_bitmaps(TABLE_LIST *table_list)
}
-/**
- Checks if possible to do prune partitions on insert.
-
- @param thd Thread context
- @param duplic How to handle duplicates
- @param update In case of ON DUPLICATE UPDATE, default function fields
- @param update_fields In case of ON DUPLICATE UPDATE, which fields to update
- @param fields Listed fields
- @param empty_values True if values is empty (only defaults)
- @param[out] prune_needs_default_values Set on return if copying of default
- values is needed
- @param[out] can_prune_partitions Enum showing if possible to prune
- @param[inout] used_partitions If possible to prune the bitmap
- is initialized and cleared
-
- @return Operation status
- @retval false Success
- @retval true Failure
-*/
-
-bool partition_info::can_prune_insert(THD* thd,
- enum_duplicates duplic,
- COPY_INFO &update,
- List<Item> &update_fields,
- List<Item> &fields,
- bool empty_values,
- enum_can_prune *can_prune_partitions,
- bool *prune_needs_default_values,
- MY_BITMAP *used_partitions)
-{
- uint32 *bitmap_buf;
- uint bitmap_bytes;
- uint num_partitions= 0;
- *can_prune_partitions= PRUNE_NO;
- DBUG_ASSERT(bitmaps_are_initialized);
- DBUG_ENTER("partition_info::can_prune_insert");
-
- if (table->s->db_type()->partition_flags() & HA_USE_AUTO_PARTITION)
- DBUG_RETURN(false);
-
- /*
- If under LOCK TABLES pruning will skip start_stmt instead of external_lock
- for unused partitions.
-
- Cannot prune if there are BEFORE INSERT triggers that changes any
- partitioning column, since they may change the row to be in another
- partition.
- */
- if (is_fields_updated_in_triggers(TRG_EVENT_INSERT, TRG_ACTION_BEFORE))
- DBUG_RETURN(false);
-
- if (table->found_next_number_field)
- {
- /*
- If the field is used in the partitioning expression, we cannot prune.
- TODO: If all rows have not null values and
- is not 0 (with NO_AUTO_VALUE_ON_ZERO sql_mode), then pruning is possible!
- */
- if (bitmap_is_set(&full_part_field_set,
- table->found_next_number_field->field_index))
- DBUG_RETURN(false);
- }
-
- /*
- If updating a field in the partitioning expression, we cannot prune.
-
- Note: TIMESTAMP_AUTO_SET_ON_INSERT is handled by converting Item_null
- to the start time of the statement. Which will be the same as in
- write_row(). So pruning of TIMESTAMP DEFAULT CURRENT_TIME will work.
- But TIMESTAMP_AUTO_SET_ON_UPDATE cannot be pruned if the timestamp
- column is a part of any part/subpart expression.
- */
- if (duplic == DUP_UPDATE)
- {
- /*
- TODO: add check for static update values, which can be pruned.
- */
- if (is_field_in_part_expr(update_fields))
- DBUG_RETURN(false);
-
- /*
- Cannot prune if there are BEFORE UPDATE triggers that changes any
- partitioning column, since they may change the row to be in another
- partition.
- */
- if (is_fields_updated_in_triggers(TRG_EVENT_UPDATE, TRG_ACTION_BEFORE))
- DBUG_RETURN(false);
- }
-
- /*
- If not all partitioning fields are given,
- we also must set all non given partitioning fields
- to get correct defaults.
- TODO: If any gain, we could enhance this by only copy the needed default
- fields by
- 1) check which fields needs to be set.
- 2) only copy those fields from the default record.
- */
- *prune_needs_default_values= false;
- if (fields.elements)
- {
- if (!is_full_part_expr_in_fields(fields))
- *prune_needs_default_values= true;
- }
- else if (empty_values)
- {
- *prune_needs_default_values= true; // like 'INSERT INTO t () VALUES ()'
- }
- else
- {
- /*
- In case of INSERT INTO t VALUES (...) we must get values for
- all fields in table from VALUES (...) part, so no defaults
- are needed.
- */
- }
-
- /* Pruning possible, have to initialize the used_partitions bitmap. */
- num_partitions= lock_partitions.n_bits;
- bitmap_bytes= bitmap_buffer_size(num_partitions);
- if (!(bitmap_buf= (uint32*) thd->alloc(bitmap_bytes)))
- {
- mem_alloc_error(bitmap_bytes);
- DBUG_RETURN(true);
- }
- /* Also clears all bits. */
- if (my_bitmap_init(used_partitions, bitmap_buf, num_partitions, false))
- {
- /* purecov: begin deadcode */
- /* Cannot happen, due to pre-alloc. */
- mem_alloc_error(bitmap_bytes);
- DBUG_RETURN(true);
- /* purecov: end */
- }
- /*
- If no partitioning field in set (e.g. defaults) check pruning only once.
- */
- if (fields.elements &&
- !is_field_in_part_expr(fields))
- *can_prune_partitions= PRUNE_DEFAULTS;
- else
- *can_prune_partitions= PRUNE_YES;
-
- DBUG_RETURN(false);
-}
-
-
-/**
- Mark the partition, the record belongs to, as used.
-
- @param fields Fields to set
- @param values Values to use
- @param info COPY_INFO used for default values handling
- @param copy_default_values True if we should copy default values
- @param used_partitions Bitmap to set
-
- @returns Operational status
- @retval false Success
- @retval true Failure
-*/
-
-bool partition_info::set_used_partition(List<Item> &fields,
- List<Item> &values,
- COPY_INFO &info,
- bool copy_default_values,
- MY_BITMAP *used_partitions)
-{
- THD *thd= table->in_use;
- uint32 part_id;
- longlong func_value;
- Dummy_error_handler error_handler;
- bool ret= true;
- DBUG_ENTER("set_partition");
- DBUG_ASSERT(thd);
-
- /* Only allow checking of constant values */
- List_iterator_fast<Item> v(values);
- Item *item;
- thd->push_internal_handler(&error_handler);
- while ((item= v++))
- {
- if (!item->const_item())
- goto err;
- }
-
- if (copy_default_values)
- restore_record(table,s->default_values);
-
- if (fields.elements || !values.elements)
- {
- if (fill_record(thd, table, fields, values, false, !copy_default_values))
- goto err;
- }
- else
- {
- /* All fields has a value */
- if (fill_record(thd, table, table->field, values, false, false))
- goto err;
- }
- DBUG_ASSERT(!table->auto_increment_field_not_null);
-
- /*
- Evaluate DEFAULT functions like CURRENT_TIMESTAMP.
- TODO: avoid setting non partitioning fields default value, to avoid
- overhead. Not yet done, since mostly only one DEFAULT function per
- table, or at least very few such columns.
- */
-// if (info.function_defaults_apply_on_columns(&full_part_field_set))
-// info.set_function_defaults(table);
-
- {
- /*
- This function is used in INSERT; 'values' are supplied by user,
- or are default values, not values read from a table, so read_set is
- irrelevant.
- */
- my_bitmap_map *old_map= dbug_tmp_use_all_columns(table, table->read_set);
- const int rc= get_partition_id(this, &part_id, &func_value);
- dbug_tmp_restore_column_map(table->read_set, old_map);
- if (rc)
- goto err;
- }
-
- DBUG_PRINT("info", ("Insert into partition %u", part_id));
- bitmap_set_bit(used_partitions, part_id);
- ret= false;
-
-err:
- thd->pop_internal_handler();
- DBUG_RETURN(ret);
-}
-
-
/*
Create a memory area where default partition names are stored and fill it
up with the names.
@@ -2167,71 +1933,6 @@ void partition_info::report_part_expr_error(bool use_subpart_expr)
}
-/**
- Check if fields are in the partitioning expression.
-
- @param fields List of Items (fields)
-
- @return True if any field in the fields list is used by a partitioning expr.
- @retval true At least one field in the field list is found.
- @retval false No field is within any partitioning expression.
-*/
-
-bool partition_info::is_field_in_part_expr(List<Item> &fields)
-{
- List_iterator<Item> it(fields);
- Item *item;
- Item_field *field;
- DBUG_ENTER("is_fields_in_part_expr");
- while ((item= it++))
- {
- field= item->field_for_view_update();
- DBUG_ASSERT(field->field->table == table);
- if (bitmap_is_set(&full_part_field_set, field->field->field_index))
- DBUG_RETURN(true);
- }
- DBUG_RETURN(false);
-}
-
-
-/**
- Check if all partitioning fields are included.
-*/
-
-bool partition_info::is_full_part_expr_in_fields(List<Item> &fields)
-{
- Field **part_field= full_part_field_array;
- DBUG_ASSERT(*part_field);
- DBUG_ENTER("is_full_part_expr_in_fields");
- /*
- It is very seldom many fields in full_part_field_array, so it is OK
- to loop over all of them instead of creating a bitmap fields argument
- to compare with.
- */
- do
- {
- List_iterator<Item> it(fields);
- Item *item;
- Item_field *field;
- bool found= false;
-
- while ((item= it++))
- {
- field= item->field_for_view_update();
- DBUG_ASSERT(field->field->table == table);
- if (*part_field == field->field)
- {
- found= true;
- break;
- }
- }
- if (!found)
- DBUG_RETURN(false);
- } while (*(++part_field));
- DBUG_RETURN(true);
-}
-
-
/*
Create a new column value in current list with maxvalue
Called from parser