summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergei Golubchik <serg@mariadb.org>2015-11-28 18:25:05 +0100
committerSergei Golubchik <serg@mariadb.org>2016-04-01 22:45:52 +0200
commit44a6fae309f22478607ba2ed79ca6e68ef58a515 (patch)
tree835746104e4b18880ee757a8a63600ef9327002a
parent4307a23a90725e3ff0960419ec7bc056b9ae60d8 (diff)
downloadmariadb-git-44a6fae309f22478607ba2ed79ca6e68ef58a515.tar.gz
cleanup: remove dead (half-merged) code from partition_info.*
-rw-r--r--sql/partition_info.cc309
-rw-r--r--sql/partition_info.h37
2 files changed, 1 insertions, 345 deletions
diff --git a/sql/partition_info.cc b/sql/partition_info.cc
index df018ac75aa..71f0b38094d 100644
--- a/sql/partition_info.cc
+++ b/sql/partition_info.cc
@@ -255,7 +255,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);
@@ -282,249 +281,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 (table->triggers &&
- table->triggers->has_triggers(TRG_EVENT_INSERT, TRG_ACTION_BEFORE) &&
- table->triggers->is_fields_updated_in_trigger(&full_part_field_set,
- 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 (table->triggers &&
- table->triggers->has_triggers(TRG_EVENT_UPDATE,
- TRG_ACTION_BEFORE) &&
- table->triggers->is_fields_updated_in_trigger(&full_part_field_set,
- 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))
- goto err;
- }
- else
- {
- 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.
@@ -2170,71 +1926,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
diff --git a/sql/partition_info.h b/sql/partition_info.h
index 1ccc3e4c310..2ebc8a4a500 100644
--- a/sql/partition_info.h
+++ b/sql/partition_info.h
@@ -237,15 +237,6 @@ public:
bool is_auto_partitioned;
bool has_null_value;
bool column_list; // COLUMNS PARTITIONING, 5.5+
- /**
- True if pruning has been completed and can not be pruned any further,
- even if there are subqueries or stored programs in the condition.
-
- Some times it is needed to run prune_partitions() a second time to prune
- read partitions after tables are locked, when subquery and
- stored functions might have been evaluated.
- */
- bool is_pruning_completed;
partition_info()
: get_partition_id(NULL), get_part_partition_id(NULL),
@@ -279,7 +270,7 @@ public:
list_of_part_fields(FALSE), list_of_subpart_fields(FALSE),
linear_hash_ind(FALSE), fixed(FALSE),
is_auto_partitioned(FALSE),
- has_null_value(FALSE), column_list(FALSE), is_pruning_completed(false)
+ has_null_value(FALSE), column_list(FALSE)
{
all_fields_in_PF.clear_all();
all_fields_in_PPF.clear_all();
@@ -344,30 +335,6 @@ public:
char *file_name,
uint32 *part_id);
void report_part_expr_error(bool use_subpart_expr);
- bool set_used_partition(List<Item> &fields,
- List<Item> &values,
- COPY_INFO &info,
- bool copy_default_values,
- MY_BITMAP *used_partitions);
- /**
- PRUNE_NO - Unable to prune.
- PRUNE_DEFAULTS - Partitioning field is only set to
- DEFAULT values, only need to check
- pruning for one row where the DEFAULTS
- values are set.
- PRUNE_YES - Pruning is possible, calculate the used partition set
- by evaluate the partition_id on row by row basis.
- */
- enum enum_can_prune {PRUNE_NO=0, PRUNE_DEFAULTS, PRUNE_YES};
- bool 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);
bool has_same_partitioning(partition_info *new_part_info);
private:
static int list_part_cmp(const void* a, const void* b);
@@ -381,8 +348,6 @@ private:
const char *part_name);
bool prune_partition_bitmaps(TABLE_LIST *table_list);
bool add_named_partition(const char *part_name, uint length);
- bool is_field_in_part_expr(List<Item> &fields);
- bool is_full_part_expr_in_fields(List<Item> &fields);
public:
bool has_unique_name(partition_element *element);
};