Commit e05d2d06 authored by unknown's avatar unknown
Browse files

BUG#16002: Handle unsigned integer partition functions


mysql-test/r/partition.result:
  Added new test cases
mysql-test/r/partition_error.result:
  Fixed test case
mysql-test/t/partition.test:
  Added new test cases
mysql-test/t/partition_error.test:
  Fixed test case
sql/ha_partition.cc:
  Review fixes
sql/partition_element.h:
  Review fixes
sql/partition_info.cc:
  Review fixes
sql/share/errmsg.txt:
  Review fixes
sql/sql_partition.cc:
  Review fixes
sql/sql_yacc.yy:
  Enabled possibility to use (MAXVALUE) as well as MAXVALUE.
parent 9d371277
Loading
Loading
Loading
Loading
+21 −2
Original line number Diff line number Diff line
drop table if exists t1;
create table t1 (a bigint unsigned);
create table t1 (a bigint)
partition by range (a)
(partition p0 values less than (0xFFFFFFFFFFFFFFFF),
partition p1 values less than (10));
ERROR 42000: VALUES value must be of same type as partition function near '),
partition p1 values less than (10))' at line 3
create table t1 (a bigint)
partition by list (a)
(partition p0 values in (0xFFFFFFFFFFFFFFFF),
partition p1 values in (10));
ERROR 42000: VALUES value must be of same type as partition function near '),
partition p1 values in (10))' at line 3
create table t1 (a bigint unsigned)
partition by range (a)
(partition p0 values less than (100),
partition p1 values less than MAXVALUE);
insert into t1 values (1);
drop table t1;
create table t1 (a bigint unsigned)
partition by hash (a);
insert into t1 values (0xFFFFFFFFFFFFFFFD);
insert into t1 values (0xFFFFFFFFFFFFFFFE);
select * from t1 where (a + 1) < 10;
@@ -852,7 +871,7 @@ DROP TABLE t1;
create table t1 (a bigint unsigned)
partition by list (a)
(partition p0 values in (0-1));
ERROR HY000: Partition function is unsigned, cannot have negative constants
ERROR HY000: Partition constant is out of partition function domain
create table t1 (a bigint unsigned)
partition by range (a)
(partition p0 values less than (10));
+1 −1
Original line number Diff line number Diff line
@@ -557,4 +557,4 @@ drop table t1;
create table t1 (a bigint unsigned)
partition by range (a)
(partition p0 values less than (-1));
ERROR HY000: Partition function is unsigned, cannot have negative constants
ERROR HY000: Partition constant is out of partition function domain
+26 −2
Original line number Diff line number Diff line
@@ -9,7 +9,29 @@
drop table if exists t1;
--enable_warnings

create table t1 (a bigint unsigned);
#
# BUG 16002: Handle unsigned integer functions properly
#
--error 1064
create table t1 (a bigint)
partition by range (a)
(partition p0 values less than (0xFFFFFFFFFFFFFFFF),
 partition p1 values less than (10));
--error 1064
create table t1 (a bigint)
partition by list (a)
(partition p0 values in (0xFFFFFFFFFFFFFFFF),
 partition p1 values in (10));

create table t1 (a bigint unsigned)
partition by range (a)
(partition p0 values less than (100),
 partition p1 values less than MAXVALUE);
insert into t1 values (1);
drop table t1;

create table t1 (a bigint unsigned)
partition by hash (a);
insert into t1 values (0xFFFFFFFFFFFFFFFD);
insert into t1 values (0xFFFFFFFFFFFFFFFE);
select * from t1 where (a + 1) < 10;
@@ -966,7 +988,7 @@ DROP TABLE t1;
#
#BUG 16002 Erroneus handling of unsigned partition functions
#
--error ER_SIGNED_PARTITION_CONSTANT_ERROR
--error ER_PARTITION_CONST_DOMAIN_ERROR
create table t1 (a bigint unsigned)
partition by list (a)
(partition p0 values in (0-1));
@@ -978,6 +1000,8 @@ partition by range (a)
--error ER_NO_PARTITION_FOR_GIVEN_VALUE
insert into t1 values (0xFFFFFFFFFFFFFFFF);

drop table t1;

#
#BUG 18750 Problems with partition names
#
+1 −1
Original line number Diff line number Diff line
@@ -748,7 +748,7 @@ CREATE TABLE t1(a int)
insert into t1 values (10);
drop table t1;

--error ER_SIGNED_PARTITION_CONSTANT_ERROR
--error ER_PARTITION_CONST_DOMAIN_ERROR
create table t1 (a bigint unsigned)
partition by range (a)
(partition p0 values less than (-1));
+4 −7
Original line number Diff line number Diff line
@@ -5162,17 +5162,14 @@ void ha_partition::print_error(int error, myf errflag)
  {
    char buf[100];
    longlong value= m_part_info->part_expr->val_int();
    if (!m_part_info->part_expr->unsigned_flag ||
        m_part_info->part_expr->null_value)
    if (m_part_info->part_expr->null_value)
    {
      my_error(ER_NO_PARTITION_FOR_GIVEN_VALUE, MYF(0),
               m_part_info->part_expr->null_value ? "NULL" :
               llstr(m_part_info->part_expr->val_int(), buf));
      my_error(ER_NO_PARTITION_FOR_GIVEN_VALUE, MYF(0),"NULL");
    }
    else
    {
      ulonglong value= m_part_info->part_expr->val_int();
      longlong2str(value, buf, 10);
      longlong2str(value, buf,
                   m_part_info->part_expr->unsigned_flag ? 10 : -10);
      my_error(ER_NO_PARTITION_FOR_GIVEN_VALUE, MYF(0), buf);
    }
  }
Loading