summaryrefslogtreecommitdiff
path: root/sql/sql_partition.cc
diff options
context:
space:
mode:
authorAleksey Midenkov <midenok@gmail.com>2020-05-26 11:43:43 +0300
committerAleksey Midenkov <midenok@gmail.com>2020-05-26 11:43:43 +0300
commitfbcfbb0e1ce16db6c7debe77119de1141a8c6391 (patch)
treed74cb1a9cf9c6fef8fa5ed2dd05d90c7b8163879 /sql/sql_partition.cc
parent5530a93f47324b847c799d00a2756729a2869d13 (diff)
downloadmariadb-git-fbcfbb0e1ce16db6c7debe77119de1141a8c6391.tar.gz
MDEV-19751 Wrong partitioning by KEY() after primary key dropped
Default (empty) field list in partitioning by KEY() clause is assigned from primary key. If primary key is changed the partitioning field list is changed as well, so repartitioning required. Not applicable to any non-primary keys as default field list may be taken only from primary key.
Diffstat (limited to 'sql/sql_partition.cc')
-rw-r--r--sql/sql_partition.cc22
1 files changed, 22 insertions, 0 deletions
diff --git a/sql/sql_partition.cc b/sql/sql_partition.cc
index 071c9c05129..2334286b039 100644
--- a/sql/sql_partition.cc
+++ b/sql/sql_partition.cc
@@ -5473,6 +5473,28 @@ the generated partition syntax in a correct manner.
*partition_changed= TRUE;
}
}
+ /*
+ Prohibit inplace when partitioned by primary key and the primary key is dropped.
+ */
+ if (!*partition_changed &&
+ tab_part_info->part_field_array &&
+ !tab_part_info->part_field_list.elements &&
+ table->s->primary_key != MAX_KEY)
+ {
+ KEY *primary_key= table->key_info + table->s->primary_key;
+ List_iterator_fast<Alter_drop> drop_it(alter_info->drop_list);
+ const char *primary_name= primary_key->name;
+ const Alter_drop *drop;
+ drop_it.rewind();
+ while ((drop= drop_it++))
+ {
+ if (drop->type == Alter_drop::KEY &&
+ 0 == my_strcasecmp(system_charset_info, primary_name, drop->name))
+ break;
+ }
+ if (drop)
+ *partition_changed= TRUE;
+ }
}
if (thd->work_part_info)
{