summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sql/partition_info.h1
-rw-r--r--sql/sql_partition.cc31
-rw-r--r--sql/table.cc63
3 files changed, 52 insertions, 43 deletions
diff --git a/sql/partition_info.h b/sql/partition_info.h
index a0da063041f..c818b792388 100644
--- a/sql/partition_info.h
+++ b/sql/partition_info.h
@@ -351,6 +351,7 @@ public:
return num_parts * (is_sub_partitioned() ? num_subparts : 1);
}
+ bool default_handling(THD *thd, handler *file, const char *normalized_path);
bool set_up_defaults_for_partitioning(THD *thd, uint start_no);
const char *find_duplicate_field();
char *find_duplicate_name();
diff --git a/sql/sql_partition.cc b/sql/sql_partition.cc
index 27f1ef1f0c0..784c4d54fe1 100644
--- a/sql/sql_partition.cc
+++ b/sql/sql_partition.cc
@@ -188,8 +188,7 @@ static bool is_name_in_list(const char *name, List<const char> list_names)
Set-up defaults for partitions.
SYNOPSIS
- partition_default_handling()
- table Table object
+ partition_info::default_handling()
part_info Partition info to set up
normalized_path Normalized path name of table and database
@@ -198,31 +197,30 @@ static bool is_name_in_list(const char *name, List<const char> list_names)
FALSE Success
*/
-bool partition_default_handling(THD *thd, TABLE *table, partition_info *part_info,
- const char *normalized_path)
+bool partition_info::default_handling(THD *thd, handler *file,
+ const char *normalized_path)
{
- DBUG_ENTER("partition_default_handling");
+ DBUG_ENTER("partition_info::default_handling");
- if (part_info->use_default_num_partitions)
+ if (use_default_num_partitions)
{
- if (table->file->get_no_parts(normalized_path, &part_info->num_parts))
+ if (file->get_no_parts(normalized_path, &num_parts))
{
DBUG_RETURN(TRUE);
}
}
- else if (part_info->is_sub_partitioned() &&
- part_info->use_default_num_subpartitions)
+ else if (is_sub_partitioned() && use_default_num_subpartitions)
{
uint num_parts;
- if (table->file->get_no_parts(normalized_path, &num_parts))
+ if (file->get_no_parts(normalized_path, &num_parts))
{
DBUG_RETURN(TRUE);
}
- DBUG_ASSERT(part_info->num_parts > 0);
- DBUG_ASSERT((num_parts % part_info->num_parts) == 0);
- part_info->num_subparts= num_parts / part_info->num_parts;
+ DBUG_ASSERT(num_parts > 0);
+ DBUG_ASSERT((num_parts % num_parts) == 0);
+ num_subparts= num_parts / num_parts;
}
- part_info->set_up_defaults_for_partitioning(thd, 0);
+ set_up_defaults_for_partitioning(thd, 0);
DBUG_RETURN(FALSE);
}
@@ -1918,11 +1916,6 @@ bool fix_partition_func(THD *thd, TABLE *table)
thd->column_usage= COLUMNS_WRITE;
DBUG_PRINT("info", ("thd->column_usage: %d", thd->column_usage));
- if (partition_default_handling(thd, table, part_info,
- table->s->normalized_path.str))
- {
- DBUG_RETURN(TRUE);
- }
if (part_info->is_sub_partitioned())
{
DBUG_ASSERT(part_info->subpart_type == HASH_PARTITION);
diff --git a/sql/table.cc b/sql/table.cc
index 777a3e3d240..28a6bef5c6e 100644
--- a/sql/table.cc
+++ b/sql/table.cc
@@ -1935,30 +1935,6 @@ int TABLE_SHARE::init_from_binary_frm_image(THD *thd, bool write,
goto err;
}
share->part_sql.length= partition_info_str_len;
- /*
- In this execution we must avoid calling thd->change_item_tree since
- we might release memory before statement is completed. We do this
- by changing to a new statement arena. As part of this arena we also
- set the memory root to be the memory root of the table since we
- call the parser and fix_fields which both can allocate memory for
- item objects. We keep the arena to ensure that we can release the
- free_list when closing the table object.
- SEE Bug #21658
- */
-
- Query_arena *backup_stmt_arena_ptr= thd->stmt_arena;
- Query_arena backup_arena;
- Query_arena part_func_arena(&mem_root, Query_arena::STMT_INITIALIZED);
- thd->set_n_backup_active_arena(&part_func_arena, &backup_arena);
- thd->stmt_arena= &part_func_arena;
-
- bool error=
- share->unpack_partition(thd, plugin_hton(share->default_part_plugin));
- thd->stmt_arena= backup_stmt_arena_ptr;
- thd->restore_active_arena(&part_func_arena, &backup_arena);
- share->part_info->item_free_list= part_func_arena.free_list;
- if (error)
- goto err;
}
#else
if (partition_info_str_len)
@@ -2171,6 +2147,45 @@ int TABLE_SHARE::init_from_binary_frm_image(THD *thd, bool write,
if (handler_file->set_ha_share_ref(&share->ha_share))
goto err;
+#ifdef WITH_PARTITION_STORAGE_ENGINE
+ if (share->part_sql.length)
+ {
+ /*
+ NB: we could place that into partition_create_handler()
+ if it had thd in arguments
+ */
+ /*
+ In this execution we must avoid calling thd->change_item_tree since
+ we might release memory before statement is completed. We do this
+ by changing to a new statement arena. As part of this arena we also
+ set the memory root to be the memory root of the table since we
+ call the parser and fix_fields which both can allocate memory for
+ item objects. We keep the arena to ensure that we can release the
+ free_list when closing the table object.
+ SEE Bug #21658
+ */
+
+ Query_arena *backup_stmt_arena_ptr= thd->stmt_arena;
+ Query_arena backup_arena;
+ Query_arena part_func_arena(&share->mem_root, Query_arena::STMT_INITIALIZED);
+ thd->set_n_backup_active_arena(&part_func_arena, &backup_arena);
+ thd->stmt_arena= &part_func_arena;
+
+ bool error=
+ share->unpack_partition(thd, plugin_hton(share->default_part_plugin));
+
+ if (!error)
+ error= share->part_info->default_handling(thd, handler_file,
+ share->normalized_path.str);
+
+ thd->stmt_arena= backup_stmt_arena_ptr;
+ thd->restore_active_arena(&part_func_arena, &backup_arena);
+ share->part_info->item_free_list= part_func_arena.free_list;
+ if (error)
+ goto err;
+ }
+#endif /* WITH_PARTITION_STORAGE_ENGINE */
+
record= share->default_values-1; /* Fieldstart = 1 */
null_bits_are_used= share->null_fields != 0;
if (share->null_field_first)