summaryrefslogtreecommitdiff
path: root/sql
diff options
context:
space:
mode:
authorAlexey Botchkov <holyfoot@askmonty.org>2022-01-22 06:59:40 +0400
committerAlexey Botchkov <holyfoot@askmonty.org>2022-01-25 12:58:17 +0400
commit50e66db018d0d0ee49fd2b7196f30ed4594dc2b3 (patch)
treedf5dc4ee0c1c79cdc89ee43d0b120be93bb40796 /sql
parentebc77c6d17a8d07f1c523d21a81e0d9f2ce1089d (diff)
downloadmariadb-git-50e66db018d0d0ee49fd2b7196f30ed4594dc2b3.tar.gz
MDEV-25917 create table like fails if source table is partitioned and engine is myisam or aria with data directory.
Create table like removes data_file_path/index_file_path from the thd->work_partition_info.
Diffstat (limited to 'sql')
-rw-r--r--sql/partition_element.h4
-rw-r--r--sql/partition_info.cc13
-rw-r--r--sql/partition_info.h2
-rw-r--r--sql/sql_table.cc11
4 files changed, 21 insertions, 9 deletions
diff --git a/sql/partition_element.h b/sql/partition_element.h
index 5241d00989f..81a14b4d75e 100644
--- a/sql/partition_element.h
+++ b/sql/partition_element.h
@@ -132,7 +132,9 @@ public:
connect_string(null_lex_str),
part_state(part_elem->part_state),
nodegroup_id(part_elem->nodegroup_id),
- has_null_value(FALSE)
+ has_null_value(FALSE),
+ signed_flag(part_elem->signed_flag),
+ max_value(part_elem->max_value)
{
}
~partition_element() {}
diff --git a/sql/partition_info.cc b/sql/partition_info.cc
index 503b523a66c..c9156108e2e 100644
--- a/sql/partition_info.cc
+++ b/sql/partition_info.cc
@@ -35,7 +35,7 @@
#include "ha_partition.h"
-partition_info *partition_info::get_clone(THD *thd)
+partition_info *partition_info::get_clone(THD *thd, bool empty_data_and_index_file)
{
MEM_ROOT *mem_root= thd->mem_root;
DBUG_ENTER("partition_info::get_clone");
@@ -57,25 +57,28 @@ partition_info *partition_info::get_clone(THD *thd)
{
List_iterator<partition_element> subpart_it(part->subpartitions);
partition_element *subpart;
- partition_element *part_clone= new (mem_root) partition_element();
+ partition_element *part_clone= new (mem_root) partition_element(*part);
if (!part_clone)
{
mem_alloc_error(sizeof(partition_element));
DBUG_RETURN(NULL);
}
- *part_clone= *part;
part_clone->subpartitions.empty();
while ((subpart= (subpart_it++)))
{
- partition_element *subpart_clone= new (mem_root) partition_element();
+ partition_element *subpart_clone= new (mem_root) partition_element(*subpart);
if (!subpart_clone)
{
mem_alloc_error(sizeof(partition_element));
DBUG_RETURN(NULL);
}
- *subpart_clone= *subpart;
+ if (empty_data_and_index_file)
+ subpart_clone->data_file_name= subpart_clone->index_file_name= NULL;
part_clone->subpartitions.push_back(subpart_clone, mem_root);
}
+
+ if (empty_data_and_index_file)
+ part_clone->data_file_name= part_clone->index_file_name= NULL;
clone->partitions.push_back(part_clone, mem_root);
part_clone->list_val_list.empty();
List_iterator<part_elem_value> list_val_it(part->list_val_list);
diff --git a/sql/partition_info.h b/sql/partition_info.h
index d42ef380c8c..edd1e610df5 100644
--- a/sql/partition_info.h
+++ b/sql/partition_info.h
@@ -281,7 +281,7 @@ public:
}
~partition_info() {}
- partition_info *get_clone(THD *thd);
+ partition_info *get_clone(THD *thd, bool empty_data_and_index_file= FALSE);
bool set_named_partition_bitmap(const char *part_name, uint length);
bool set_partition_bitmaps(TABLE_LIST *table_list);
/* Answers the question if subpartitioning is used for a certain table */
diff --git a/sql/sql_table.cc b/sql/sql_table.cc
index 33daa15b9b7..e1f752191ae 100644
--- a/sql/sql_table.cc
+++ b/sql/sql_table.cc
@@ -5547,8 +5547,15 @@ bool mysql_create_like_table(THD* thd, TABLE_LIST* table,
#ifdef WITH_PARTITION_STORAGE_ENGINE
/* Partition info is not handled by mysql_prepare_alter_table() call. */
if (src_table->table->part_info)
- thd->work_part_info= src_table->table->part_info->get_clone(thd);
-#endif
+ {
+ /*
+ The CREATE TABLE LIKE should not inherit the DATA DIRECTORY
+ and INDEX DIRECTORY from the base table.
+ So that TRUE argument for the get_clone.
+ */
+ thd->work_part_info= src_table->table->part_info->get_clone(thd, TRUE);
+ }
+#endif /*WITH_PARTITION_STORAGE_ENGINE*/
/*
Adjust description of source table before using it for creation of