1
0
mirror of https://github.com/MariaDB/server.git synced 2025-08-07 00:04:31 +03:00

Bug#51347: assertion with show create table + partition by columns

on decimal column

The problem was that there was no check to disallow DECIMAL
columns in the code (it was accepted as if it was INTEGER).

Solution was to correctly disallow DECIMAL columns in
COLUMNS partitioning. As documented.

mysql-test/r/partition_column.result:
  Bug#51347: assertion with show create table + partition by columns
  on decimal column
  
  updated test result
mysql-test/t/partition_column.test:
  Bug#51347: assertion with show create table + partition by columns
  on decimal column
  
  Added test to verify column types that is not supported
sql/sql_partition.cc:
  Bug#51347: assertion with show create table + partition by columns
  on decimal column
  
  Moved DECIMAL types to be disallowed as column types in COLUMNS
  partitioning
This commit is contained in:
Mattias Jonsson
2010-03-04 11:24:39 +01:00
parent aca943f0b1
commit 5eaa7936f6
3 changed files with 95 additions and 24 deletions

View File

@@ -1,4 +1,44 @@
drop table if exists t1; drop table if exists t1;
CREATE TABLE t1 (a DECIMAL)
PARTITION BY RANGE COLUMNS (a)
(PARTITION p0 VALUES LESS THAN (0));
ERROR HY000: Field 'a' is of a not allowed type for this type of partitioning
CREATE TABLE t1 (a BLOB)
PARTITION BY RANGE COLUMNS (a)
(PARTITION p0 VALUES LESS THAN ("X"));
ERROR HY000: A BLOB field is not allowed in partition function
CREATE TABLE t1 (a TEXT)
PARTITION BY RANGE COLUMNS (a)
(PARTITION p0 VALUES LESS THAN ("X"));
ERROR HY000: A BLOB field is not allowed in partition function
CREATE TABLE t1 (a FLOAT)
PARTITION BY RANGE COLUMNS (a)
(PARTITION p0 VALUES LESS THAN (0.0));
ERROR HY000: Field 'a' is of a not allowed type for this type of partitioning
CREATE TABLE t1 (a DOUBLE)
PARTITION BY RANGE COLUMNS (a)
(PARTITION p0 VALUES LESS THAN (0.0));
ERROR HY000: Field 'a' is of a not allowed type for this type of partitioning
CREATE TABLE t1 (d TIMESTAMP)
PARTITION BY RANGE COLUMNS(d)
(PARTITION p0 VALUES LESS THAN ('2000-01-01'),
PARTITION p1 VALUES LESS THAN ('2040-01-01'));
ERROR HY000: Field 'd' is of a not allowed type for this type of partitioning
CREATE TABLE t1 (d BIT(1))
PARTITION BY RANGE COLUMNS(d)
(PARTITION p0 VALUES LESS THAN (0),
PARTITION p1 VALUES LESS THAN (1));
ERROR HY000: Field 'd' is of a not allowed type for this type of partitioning
CREATE TABLE t1 (d ENUM("YES","NO"))
PARTITION BY RANGE COLUMNS(d)
(PARTITION p0 VALUES LESS THAN ("NO"),
PARTITION p1 VALUES LESS THAN (MAXVALUE));
ERROR HY000: Field 'd' is of a not allowed type for this type of partitioning
CREATE TABLE t1 (d SET("Car","MC"))
PARTITION BY RANGE COLUMNS(d)
(PARTITION p0 VALUES LESS THAN ("MC"),
PARTITION p1 VALUES LESS THAN (MAXVALUE));
ERROR HY000: Field 'd' is of a not allowed type for this type of partitioning
create table t1 (a int, b int) create table t1 (a int, b int)
partition by range columns (a,b) partition by range columns (a,b)
( partition p0 values less than (maxvalue, 10), ( partition p0 values less than (maxvalue, 10),
@@ -430,16 +470,6 @@ partition by range columns(d)
( partition p0 values less than ('2000-01-01'), ( partition p0 values less than ('2000-01-01'),
partition p1 values less than ('2040-01-01')); partition p1 values less than ('2040-01-01'));
ERROR HY000: Partition column values of incorrect type ERROR HY000: Partition column values of incorrect type
create table t1 (d timestamp)
partition by range columns(d)
( partition p0 values less than ('2000-01-01'),
partition p1 values less than ('2040-01-01'));
ERROR HY000: Field 'd' is of a not allowed type for this type of partitioning
create table t1 (d bit(1))
partition by range columns(d)
( partition p0 values less than (0),
partition p1 values less than (1));
ERROR HY000: Field 'd' is of a not allowed type for this type of partitioning
create table t1 (a int, b int) create table t1 (a int, b int)
partition by range columns(a,b) partition by range columns(a,b)
(partition p0 values less than (maxvalue, 10)); (partition p0 values less than (maxvalue, 10));

View File

@@ -8,6 +8,59 @@
drop table if exists t1; drop table if exists t1;
--enable_warnings --enable_warnings
#
# Bug#51347: assertion with show create table + partition by columns
# on decimal column
#
--error ER_FIELD_TYPE_NOT_ALLOWED_AS_PARTITION_FIELD
CREATE TABLE t1 (a DECIMAL)
PARTITION BY RANGE COLUMNS (a)
(PARTITION p0 VALUES LESS THAN (0));
--error ER_BLOB_FIELD_IN_PART_FUNC_ERROR
CREATE TABLE t1 (a BLOB)
PARTITION BY RANGE COLUMNS (a)
(PARTITION p0 VALUES LESS THAN ("X"));
--error ER_BLOB_FIELD_IN_PART_FUNC_ERROR
CREATE TABLE t1 (a TEXT)
PARTITION BY RANGE COLUMNS (a)
(PARTITION p0 VALUES LESS THAN ("X"));
--error ER_FIELD_TYPE_NOT_ALLOWED_AS_PARTITION_FIELD
CREATE TABLE t1 (a FLOAT)
PARTITION BY RANGE COLUMNS (a)
(PARTITION p0 VALUES LESS THAN (0.0));
--error ER_FIELD_TYPE_NOT_ALLOWED_AS_PARTITION_FIELD
CREATE TABLE t1 (a DOUBLE)
PARTITION BY RANGE COLUMNS (a)
(PARTITION p0 VALUES LESS THAN (0.0));
--error ER_FIELD_TYPE_NOT_ALLOWED_AS_PARTITION_FIELD
CREATE TABLE t1 (d TIMESTAMP)
PARTITION BY RANGE COLUMNS(d)
(PARTITION p0 VALUES LESS THAN ('2000-01-01'),
PARTITION p1 VALUES LESS THAN ('2040-01-01'));
--error ER_FIELD_TYPE_NOT_ALLOWED_AS_PARTITION_FIELD
CREATE TABLE t1 (d BIT(1))
PARTITION BY RANGE COLUMNS(d)
(PARTITION p0 VALUES LESS THAN (0),
PARTITION p1 VALUES LESS THAN (1));
--error ER_FIELD_TYPE_NOT_ALLOWED_AS_PARTITION_FIELD
CREATE TABLE t1 (d ENUM("YES","NO"))
PARTITION BY RANGE COLUMNS(d)
(PARTITION p0 VALUES LESS THAN ("NO"),
PARTITION p1 VALUES LESS THAN (MAXVALUE));
--error ER_FIELD_TYPE_NOT_ALLOWED_AS_PARTITION_FIELD
CREATE TABLE t1 (d SET("Car","MC"))
PARTITION BY RANGE COLUMNS(d)
(PARTITION p0 VALUES LESS THAN ("MC"),
PARTITION p1 VALUES LESS THAN (MAXVALUE));
# #
# BUG#49180, Possible to define empty intervals for column list partitioning # BUG#49180, Possible to define empty intervals for column list partitioning
# #
@@ -285,18 +338,6 @@ partition by range columns(d)
( partition p0 values less than ('2000-01-01'), ( partition p0 values less than ('2000-01-01'),
partition p1 values less than ('2040-01-01')); partition p1 values less than ('2040-01-01'));
--error ER_FIELD_TYPE_NOT_ALLOWED_AS_PARTITION_FIELD
create table t1 (d timestamp)
partition by range columns(d)
( partition p0 values less than ('2000-01-01'),
partition p1 values less than ('2040-01-01'));
--error ER_FIELD_TYPE_NOT_ALLOWED_AS_PARTITION_FIELD
create table t1 (d bit(1))
partition by range columns(d)
( partition p0 values less than (0),
partition p1 values less than (1));
create table t1 (a int, b int) create table t1 (a int, b int)
partition by range columns(a,b) partition by range columns(a,b)
(partition p0 values less than (maxvalue, 10)); (partition p0 values less than (maxvalue, 10));

View File

@@ -2128,8 +2128,6 @@ static int check_part_field(enum_field_types sql_type,
} }
switch (sql_type) switch (sql_type)
{ {
case MYSQL_TYPE_NEWDECIMAL:
case MYSQL_TYPE_DECIMAL:
case MYSQL_TYPE_TINY: case MYSQL_TYPE_TINY:
case MYSQL_TYPE_SHORT: case MYSQL_TYPE_SHORT:
case MYSQL_TYPE_LONG: case MYSQL_TYPE_LONG:
@@ -2151,6 +2149,8 @@ static int check_part_field(enum_field_types sql_type,
*result_type= STRING_RESULT; *result_type= STRING_RESULT;
*need_cs_check= TRUE; *need_cs_check= TRUE;
return FALSE; return FALSE;
case MYSQL_TYPE_NEWDECIMAL:
case MYSQL_TYPE_DECIMAL:
case MYSQL_TYPE_TIMESTAMP: case MYSQL_TYPE_TIMESTAMP:
case MYSQL_TYPE_NULL: case MYSQL_TYPE_NULL:
case MYSQL_TYPE_FLOAT: case MYSQL_TYPE_FLOAT: