[parser] ddl: some partition expression should return syntax error (#1087)
* fix partition bug * update parser * update parser * add test * fix test Co-authored-by: Arenatlx <ailinsilence4@gmail.com>
This commit is contained in:
1862
parser/parser.go
1862
parser/parser.go
File diff suppressed because it is too large
Load Diff
@ -3497,7 +3497,7 @@ SubPartitionMethod:
|
||||
ColumnNames: $5.([]*ast.ColumnName),
|
||||
}
|
||||
}
|
||||
| LinearOpt "HASH" '(' Expression ')'
|
||||
| LinearOpt "HASH" '(' BitExpr ')'
|
||||
{
|
||||
$$ = &ast.PartitionMethod{
|
||||
Tp: model.PartitionTypeHash,
|
||||
@ -3514,7 +3514,7 @@ PartitionKeyAlgorithmOpt:
|
||||
|
||||
PartitionMethod:
|
||||
SubPartitionMethod
|
||||
| "RANGE" '(' Expression ')'
|
||||
| "RANGE" '(' BitExpr ')'
|
||||
{
|
||||
$$ = &ast.PartitionMethod{
|
||||
Tp: model.PartitionTypeRange,
|
||||
@ -3528,7 +3528,7 @@ PartitionMethod:
|
||||
ColumnNames: $4.([]*ast.ColumnName),
|
||||
}
|
||||
}
|
||||
| "LIST" '(' Expression ')'
|
||||
| "LIST" '(' BitExpr ')'
|
||||
{
|
||||
$$ = &ast.PartitionMethod{
|
||||
Tp: model.PartitionTypeList,
|
||||
@ -4595,7 +4595,7 @@ MaxValueOrExpression:
|
||||
{
|
||||
$$ = &ast.MaxValueExpr{}
|
||||
}
|
||||
| Expression
|
||||
| BitExpr
|
||||
|
||||
FulltextSearchModifierOpt:
|
||||
/* empty */
|
||||
|
||||
@ -2162,6 +2162,13 @@ func (s *testParserSuite) TestDDL(c *C) {
|
||||
{"ALTER TABLE d_n.t_n ALGORITHM = DEFAULT , MAX_ROWS 10, UNION ( d_n.t_n ) , ROW_FORMAT REDUNDANT, STATS_PERSISTENT = DEFAULT", true, "ALTER TABLE `d_n`.`t_n` ALGORITHM = DEFAULT, MAX_ROWS = 10, UNION = (`d_n`.`t_n`), ROW_FORMAT = REDUNDANT, STATS_PERSISTENT = DEFAULT /* TableOptionStatsPersistent is not supported */ "},
|
||||
|
||||
// partition option
|
||||
{"create table t (b int) partition by range columns (b) (partition p0 values less than (not 3), partition p2 values less than (20));", false, ""},
|
||||
{"create table t (b int) partition by range columns (b) (partition p0 values less than (1 or 3), partition p2 values less than (20));", false, ""},
|
||||
{"create table t (b int) partition by range columns (b) (partition p0 values less than (3 is null), partition p2 values less than (20));", false, ""},
|
||||
{"create table t (b int) partition by range (b is null) (partition p0 values less than (10));", false, ""},
|
||||
{"create table t (b int) partition by list (not b) (partition p0 values in (10, 20));", false, ""},
|
||||
{"create table t (b int) partition by hash ( not b );", false, ""},
|
||||
{"create table t (b int) partition by range columns (b) (partition p0 values less than (3 in (3, 4, 5)), partition p2 values less than (20));", false, ""},
|
||||
{"CREATE TABLE t (id int) ENGINE = INNDB PARTITION BY RANGE (id) (PARTITION p0 VALUES LESS THAN (10), PARTITION p1 VALUES LESS THAN (20));", true, "CREATE TABLE `t` (`id` INT) ENGINE = INNDB PARTITION BY RANGE (`id`) (PARTITION `p0` VALUES LESS THAN (10),PARTITION `p1` VALUES LESS THAN (20))"},
|
||||
{"create table t (c int) PARTITION BY HASH (c) PARTITIONS 32;", true, "CREATE TABLE `t` (`c` INT) PARTITION BY HASH (`c`) PARTITIONS 32"},
|
||||
{"create table t (c int) PARTITION BY HASH (Year(VDate)) (PARTITION p1980 VALUES LESS THAN (1980) ENGINE = MyISAM, PARTITION p1990 VALUES LESS THAN (1990) ENGINE = MyISAM, PARTITION pothers VALUES LESS THAN MAXVALUE ENGINE = MyISAM)", false, ""},
|
||||
|
||||
Reference in New Issue
Block a user