Skip to content

Commit

Permalink
cherry pick pingcap#19466 to release-3.0
Browse files Browse the repository at this point in the history
Signed-off-by: ti-srebot <ti-srebot@pingcap.com>
  • Loading branch information
lzmhhh123 authored and ti-srebot committed Aug 31, 2020
1 parent 2ca62ad commit 644a35a
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
2 changes: 2 additions & 0 deletions ddl/db_partition_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,8 @@ func (s *testIntegrationSuite9) TestCreateTableWithPartition(c *C) {
tk.MustGetErrCode(`create table t32 (a int not null) partition by range columns( a );`, tmysql.ErrPartitionsMustBeDefined)
tk.MustGetErrCode(`create table t33 (a int, b int) partition by hash(a) partitions 0;`, tmysql.ErrNoParts)
tk.MustGetErrCode(`create table t33 (a timestamp, b int) partition by hash(a) partitions 30;`, tmysql.ErrFieldTypeNotAllowedAsPartitionField)
tk.MustGetErrCode(`CREATE TABLE t34 (c0 INT) PARTITION BY HASH((CASE WHEN 0 THEN 0 ELSE c0 END )) PARTITIONS 1;`, tmysql.ErrPartitionFunctionIsNotAllowed)
tk.MustGetErrCode(`CREATE TABLE t0(c0 INT) PARTITION BY HASH((c0<CURRENT_USER())) PARTITIONS 1;`, tmysql.ErrPartitionFunctionIsNotAllowed)
// TODO: fix this one
// tk.MustGetErrCode(`create table t33 (a timestamp, b int) partition by hash(unix_timestamp(a)) partitions 30;`, tmysql.ErrPartitionFuncNotAllowed)

Expand Down
2 changes: 2 additions & 0 deletions ddl/partition.go
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,8 @@ func checkPartitionExprValid(ctx sessionctx.Context, tblInfo *model.TableInfo, e
return errors.Trace(err)
}
return nil
case *ast.ParenthesesExpr:
return checkPartitionExprValid(ctx, tblInfo, v.Expr)
}
return nil
}
Expand Down

0 comments on commit 644a35a

Please sign in to comment.