BUG#47837, Duplicate field names were allowed in both column list partitioning and key partitioning, added check to give error in this case
This commit is contained in:
parent
8ca9f1e987
commit
b216aab1c4
@ -1,4 +1,11 @@
|
|||||||
drop table if exists t1;
|
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)
|
create table t1 (a int signed)
|
||||||
partition by list (a)
|
partition by list (a)
|
||||||
( partition p0 values in (1, 3, 5, 7, 9, NULL),
|
( partition p0 values in (1, 3, 5, 7, 9, NULL),
|
||||||
|
@ -8,6 +8,17 @@
|
|||||||
drop table if exists t1;
|
drop table if exists t1;
|
||||||
--enable_warnings
|
--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 >=
|
# 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
|
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()))
|
if ((same_name= has_unique_names()))
|
||||||
{
|
{
|
||||||
my_error(ER_SAME_NAME_PARTITION, MYF(0), same_name);
|
my_error(ER_SAME_NAME_PARTITION, MYF(0), same_name);
|
||||||
|
@ -271,6 +271,7 @@ public:
|
|||||||
|
|
||||||
bool set_up_defaults_for_partitioning(handler *file, HA_CREATE_INFO *info,
|
bool set_up_defaults_for_partitioning(handler *file, HA_CREATE_INFO *info,
|
||||||
uint start_no);
|
uint start_no);
|
||||||
|
char *has_unique_fields();
|
||||||
char *has_unique_names();
|
char *has_unique_names();
|
||||||
bool check_engine_mix(handlerton *engine_type, bool default_engine);
|
bool check_engine_mix(handlerton *engine_type, bool default_engine);
|
||||||
bool check_range_constants(THD *thd);
|
bool check_range_constants(THD *thd);
|
||||||
|
@ -5822,6 +5822,8 @@ ER_SAME_NAME_PARTITION
|
|||||||
eng "Duplicate partition name %-.192s"
|
eng "Duplicate partition name %-.192s"
|
||||||
ger "Doppelter Partitionsname: %-.192s"
|
ger "Doppelter Partitionsname: %-.192s"
|
||||||
swe "Duplicerat partitionsnamn %-.192s"
|
swe "Duplicerat partitionsnamn %-.192s"
|
||||||
|
ER_SAME_NAME_PARTITION_FIELD
|
||||||
|
eng "Duplicate partition field name %-.192s"
|
||||||
ER_NO_BINLOG_ERROR
|
ER_NO_BINLOG_ERROR
|
||||||
eng "It is not allowed to shut off binlog on this command"
|
eng "It is not allowed to shut off binlog on this command"
|
||||||
ger "Es es nicht erlaubt, bei diesem Befehl binlog abzuschalten"
|
ger "Es es nicht erlaubt, bei diesem Befehl binlog abzuschalten"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user