Commit 576dd76a authored by Mikael Ronstrom's avatar Mikael Ronstrom

BUG#47837, Duplicate field names were allowed in both column list partitioning...

BUG#47837, Duplicate field names were allowed in both column list partitioning and key partitioning, added check to give error in this case
parent 2ef1c756
drop table if exists t1;
create table t1 (a int, b int)
partition by key (a,a);
ERROR HY000: Duplicate partition field name a
create table t1 (a int, b int)
partition by list column_list(a,a)
( partition p values in (column_list(1,1)));
ERROR HY000: Duplicate partition field name a
create table t1 (a int signed)
partition by list (a)
( partition p0 values in (1, 3, 5, 7, 9, NULL),
......
......@@ -8,6 +8,17 @@
drop table if exists t1;
--enable_warnings
#
# BUG#47837, Crash when two same fields in column list processing
#
--error ER_SAME_NAME_PARTITION_FIELD
create table t1 (a int, b int)
partition by key (a,a);
--error ER_SAME_NAME_PARTITION_FIELD
create table t1 (a int, b int)
partition by list column_list(a,a)
( partition p values in (column_list(1,1)));
#
# BUG#47838, List partitioning have problems with <= and >=
#
......
......@@ -333,6 +333,49 @@ bool partition_info::set_up_defaults_for_partitioning(handler *file,
}
/*
Support routine for check_partition_info
SYNOPSIS
has_unique_fields
no parameters
RETURN VALUE
Erroneus field name Error, there are two fields with same name
NULL Ok, no field defined twice
DESCRIPTION
Check that the user haven't defined the same field twice in
key or column list partitioning.
*/
char* partition_info::has_unique_fields()
{
char *field_name_outer, *field_name_inner;
List_iterator<char> it_outer(part_field_list);
uint num_fields= part_field_list.elements;
uint i,j;
DBUG_ENTER("partition_info::has_unique_fields");
for (i= 0; i < num_fields; i++)
{
field_name_outer= it_outer++;
List_iterator<char> it_inner(part_field_list);
for (j= 0; j < num_fields; j++)
{
field_name_inner= it_inner++;
if (i == j)
continue;
if (!(my_strcasecmp(system_charset_info,
field_name_outer,
field_name_inner)))
{
DBUG_RETURN(field_name_outer);
}
}
}
DBUG_RETURN(NULL);
}
/*
A support function to check if a partition element's name is unique
......@@ -1143,6 +1186,12 @@ bool partition_info::check_partition_info(THD *thd, handlerton **eng_type,
}
}
if (part_field_list.elements > 0 &&
(same_name= has_unique_fields()))
{
my_error(ER_SAME_NAME_PARTITION_FIELD, MYF(0), same_name);
goto end;
}
if ((same_name= has_unique_names()))
{
my_error(ER_SAME_NAME_PARTITION, MYF(0), same_name);
......
......@@ -271,6 +271,7 @@ class partition_info : public Sql_alloc
bool set_up_defaults_for_partitioning(handler *file, HA_CREATE_INFO *info,
uint start_no);
char *has_unique_fields();
char *has_unique_names();
bool check_engine_mix(handlerton *engine_type, bool default_engine);
bool check_range_constants(THD *thd);
......
......@@ -5822,6 +5822,8 @@ ER_SAME_NAME_PARTITION
eng "Duplicate partition name %-.192s"
ger "Doppelter Partitionsname: %-.192s"
swe "Duplicerat partitionsnamn %-.192s"
ER_SAME_NAME_PARTITION_FIELD
eng "Duplicate partition field name %-.192s"
ER_NO_BINLOG_ERROR
eng "It is not allowed to shut off binlog on this command"
ger "Es es nicht erlaubt, bei diesem Befehl binlog abzuschalten"
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment