Commit 417c38db authored by unknown's avatar unknown
Browse files

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 dc9613ca
Loading
Loading
Loading
Loading
+34 −0
Original line number Diff line number Diff line
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),
+12 −0
Original line number Diff line number Diff line
@@ -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
#
+43 −0
Original line number Diff line number Diff line
@@ -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
#
+11 −3
Original line number Diff line number Diff line
@@ -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
+5 −4
Original line number Diff line number Diff line
@@ -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 */
Loading