summaryrefslogtreecommitdiff
path: root/sql/sql_partition.cc
diff options
context:
space:
mode:
Diffstat (limited to 'sql/sql_partition.cc')
-rw-r--r--sql/sql_partition.cc65
1 files changed, 65 insertions, 0 deletions
diff --git a/sql/sql_partition.cc b/sql/sql_partition.cc
index a0fd64c72ad..802e62585d4 100644
--- a/sql/sql_partition.cc
+++ b/sql/sql_partition.cc
@@ -4788,6 +4788,69 @@ bool compare_partition_options(HA_CREATE_INFO *table_create_info,
}
+/**
+ Check if the ALTER command tries to change DATA DIRECTORY
+ or INDEX DIRECTORY for its partitions and warn if so.
+ @param thd THD
+ @param part_elem partition_element to check
+ */
+static void warn_if_datadir_altered(THD *thd,
+ const partition_element *part_elem)
+{
+ DBUG_ASSERT(part_elem);
+
+ if (part_elem->engine_type &&
+ part_elem->engine_type->db_type != DB_TYPE_INNODB)
+ return;
+
+ if (part_elem->data_file_name)
+ {
+ push_warning_printf(thd, Sql_condition::WARN_LEVEL_WARN,
+ WARN_INNODB_PARTITION_OPTION_IGNORED,
+ ER(WARN_INNODB_PARTITION_OPTION_IGNORED),
+ "DATA DIRECTORY");
+ }
+ if (part_elem->index_file_name)
+ {
+ push_warning_printf(thd, Sql_condition::WARN_LEVEL_WARN,
+ WARN_INNODB_PARTITION_OPTION_IGNORED,
+ ER(WARN_INNODB_PARTITION_OPTION_IGNORED),
+ "INDEX DIRECTORY");
+ }
+}
+
+
+/**
+ Currently changing DATA DIRECTORY and INDEX DIRECTORY for InnoDB partitions is
+ not possible. This function checks it and warns on that case.
+ @param thd THD
+ @param tab_part_info old partition info
+ @param alt_part_info new partition info
+ */
+static void check_datadir_altered_for_innodb(THD *thd,
+ partition_info *tab_part_info,
+ partition_info *alt_part_info)
+{
+ if (tab_part_info->default_engine_type->db_type != DB_TYPE_INNODB)
+ return;
+
+ for (List_iterator_fast<partition_element> it(alt_part_info->partitions);
+ partition_element *part_elem= it++;)
+ {
+ if (alt_part_info->is_sub_partitioned())
+ {
+ for (List_iterator_fast<partition_element> it2(part_elem->subpartitions);
+ const partition_element *sub_part_elem= it2++;)
+ {
+ warn_if_datadir_altered(thd, sub_part_elem);
+ }
+ }
+ else
+ warn_if_datadir_altered(thd, part_elem);
+ }
+}
+
+
/*
Prepare for ALTER TABLE of partition structure
@@ -5623,6 +5686,8 @@ state of p1.
{
goto err;
}
+ check_datadir_altered_for_innodb(thd, tab_part_info, alt_part_info);
+
/*
Online handling:
REORGANIZE PARTITION: