Commit 0dadb313 authored by unknown's avatar unknown

BUG#18198: Partition function handling

Review fixes


mysql-test/r/partition_range.result:
  New test cases
mysql-test/t/partition_hash.test:
  New test cases
mysql-test/t/partition_range.test:
  New test cases
sql/item.h:
  Review fixes
sql/partition_info.cc:
  Review fixes
sql/sql_partition.cc:
  Review fixes
parent 5df362ff
drop table if exists t1;
create table t1 (a varchar(10) charset latin1 collate latin1_bin, b int)
partition by range (length(a) * b)
(partition p0 values less than (2), partition p1 values less than (10));
insert into t1 values ('a ', 2),('a',3);
drop table t1;
create table t1 (a varchar(10) charset latin1 collate latin1_bin, b int)
partition by range (b* length(a) * b)
(partition p0 values less than (2), partition p1 values less than (10));
insert into t1 values ('a ', 2),('a',3);
drop table t1;
create table t1 (a varchar(10) charset latin1 collate latin1_bin,
b varchar(10) charset latin1 collate latin1_bin)
partition by range (length(b) * length(a))
(partition p0 values less than (2), partition p1 values less than (10));
insert into t1 values ('a ', 'b '),('a','b');
drop table t1;
create table t1 (a varchar(10) charset latin1 collate latin1_bin,
b varchar(10) charset latin1 collate latin1_bin)
partition by range (length(a) * length(b))
(partition p0 values less than (2), partition p1 values less than (10));
insert into t1 values ('a ', 'b '),('a','b');
drop table t1;
create table t1 (a varchar(10) charset latin1 collate latin1_bin,
b varchar(10) charset latin1 collate latin1_bin, c int)
partition by range (length(a) * c)
(partition p0 values less than (2), partition p1 values less than (10));
insert into t1 values ('a ', 'b ', 2),('a','b', 3);
drop table t1;
create table t1 (a varchar(10) charset latin1 collate latin1_bin,
b varchar(10) charset latin1 collate latin1_bin, c int)
partition by range (c * length(a))
(partition p0 values less than (2), partition p1 values less than (10));
insert into t1 values ('a ', 'b ', 2),('a','b', 3);
drop table t1;
create table t1 (a int unsigned)
partition by range (a)
(partition pnull values less than (0),
......
......@@ -9,6 +9,18 @@
drop table if exists t1;
--enable_warnings
#
# BUG 18198: Partition functions handling
#
create table t1 (a varchar(10) charset latin1 collate latin1_bin)
partition by hash(length(a))
partitions 10;
insert into t1 values (''),(' '),('a'),('a '),('a ');
explain partitions select * from t1 where a='a ';
explain partitions select * from t1 where a='a';
explain partitions select * from t1 where a='a ' OR a='a';
drop table t1;
#
# More partition pruning tests, especially on interval walking
#
......
......@@ -9,6 +9,49 @@
drop table if exists t1;
--enable_warnings
#
# BUG 18198: Various tests for partition functions
#
create table t1 (a varchar(10) charset latin1 collate latin1_bin, b int)
partition by range (length(a) * b)
(partition p0 values less than (2), partition p1 values less than (10));
insert into t1 values ('a ', 2),('a',3);
drop table t1;
create table t1 (a varchar(10) charset latin1 collate latin1_bin, b int)
partition by range (b* length(a) * b)
(partition p0 values less than (2), partition p1 values less than (10));
insert into t1 values ('a ', 2),('a',3);
drop table t1;
create table t1 (a varchar(10) charset latin1 collate latin1_bin,
b varchar(10) charset latin1 collate latin1_bin)
partition by range (length(b) * length(a))
(partition p0 values less than (2), partition p1 values less than (10));
insert into t1 values ('a ', 'b '),('a','b');
drop table t1;
create table t1 (a varchar(10) charset latin1 collate latin1_bin,
b varchar(10) charset latin1 collate latin1_bin)
partition by range (length(a) * length(b))
(partition p0 values less than (2), partition p1 values less than (10));
insert into t1 values ('a ', 'b '),('a','b');
drop table t1;
create table t1 (a varchar(10) charset latin1 collate latin1_bin,
b varchar(10) charset latin1 collate latin1_bin, c int)
partition by range (length(a) * c)
(partition p0 values less than (2), partition p1 values less than (10));
insert into t1 values ('a ', 'b ', 2),('a','b', 3);
drop table t1;
create table t1 (a varchar(10) charset latin1 collate latin1_bin,
b varchar(10) charset latin1 collate latin1_bin, c int)
partition by range (c * length(a))
(partition p0 values less than (2), partition p1 values less than (10));
insert into t1 values ('a ', 'b ', 2),('a','b', 3);
drop table t1;
#
# More checks for partition pruning
#
......
......@@ -831,12 +831,20 @@ class Item {
Check if a partition function is allowed
SYNOPSIS
check_partition_func_processor()
int_arg Return argument
int_arg Ignored
RETURN VALUE
0
TRUE Partition function not accepted
FALSE Partition function accepted
DESCRIPTION
check_partition_func_processor is used to check if a partition function
uses an allowed function. The default is that an item is not allowed
uses an allowed function. An allowed function will always ensure that
X=Y guarantees that also part_function(X)=part_function(Y) where X is
a set of partition fields and so is Y. The problems comes mainly from
character sets where two equal strings can be quite unequal. E.g. the
german character for double s is equal to 2 s.
The default is that an item is not allowed
in a partition function. However all mathematical functions, string
manipulation functions, date functions are allowed. Allowed functions
can never depend on server version, they cannot depend on anything
......
......@@ -838,11 +838,12 @@ bool partition_info::check_partition_info(THD *thd, handlerton **eng_type,
/*
Print error for no partition found
SYNOPSIS
print_no_partition_found()
table Table object
RETURN VALUES
NONE
*/
void partition_info::print_no_partition_found(TABLE *table)
......@@ -863,10 +864,11 @@ void partition_info::print_no_partition_found(TABLE *table)
Set up buffers and arrays for fields requiring preparation
SYNOPSIS
set_up_charset_field_preps()
part_info Partition info object
RETURN VALUES
TRUE Memory Allocation error
FALSE Success
DESCRIPTION
Set up arrays and buffers for fields that require special care for
calculation of partition id. This is used for string fields with
......@@ -1025,5 +1027,4 @@ bool partition_info::set_up_charset_field_preps()
mem_alloc_error(size);
DBUG_RETURN(TRUE);
}
#endif
/* WITH_PARTITION_STORAGE_ENGINE */
#endif /* WITH_PARTITION_STORAGE_ENGINE */
......@@ -1437,9 +1437,11 @@ static uint32 get_part_id_from_linear_hash(longlong hash_value, uint mask,
/*
Check if a particular field is in need of character set
handling for partition functions.
SYNOPSIS
field_is_partition_charset()
field The field to check
RETURN VALUES
FALSE Not in need of character set handling
TRUE In need of character set handling
......@@ -1461,8 +1463,9 @@ bool field_is_partition_charset(Field *field)
/*
Check that partition function do not contain any forbidden
Check that partition function doesn't contain any forbidden
character sets and collations.
SYNOPSIS
check_part_func_fields()
ptr Array of Field pointers
......@@ -1471,6 +1474,7 @@ bool field_is_partition_charset(Field *field)
RETURN VALUES
FALSE Success
TRUE Error
DESCRIPTION
We will check in this routine that the fields of the partition functions
do not contain unallowed parts. It can also be used to check if there
......@@ -2390,9 +2394,13 @@ static uint32 get_part_id_linear_key(partition_info *part_info,
/*
Copy to field buffers and set up field pointers
SYNOPSIS
copy_to_part_field_buffers()
ptr Array of fields to copy
field_bufs Array of field buffers to copy to
restore_ptr Array of pointers to restore to
RETURN VALUES
NONE
DESCRIPTION
......@@ -2451,8 +2459,9 @@ static void copy_to_part_field_buffers(Field **ptr,
SYNOPSIS
restore_part_field_pointers()
ptr Array of fields to restore
restore_ptr Array of field pointers to restore to
RETURN VALUES
NONE
*/
static void restore_part_field_pointers(Field **ptr, char **restore_ptr)
......
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