Skip to content

Commit

Permalink
ddl: create partition table fail with strconv.ParseInt invalid syntax (
Browse files Browse the repository at this point in the history
  • Loading branch information
sre-bot authored Apr 17, 2020
1 parent ab57dc6 commit 0c67b23
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
17 changes: 17 additions & 0 deletions ddl/db_partition_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,23 @@ func (s *testIntegrationSuite9) TestCreateTableWithPartition(c *C) {
PARTITION p2 VALUES LESS THAN (2000),
PARTITION p3 VALUES LESS THAN (2005)
);`, tmysql.ErrBadField)

// Fix a timezone dependent check bug introduced in https://github.com/pingcap/tidb/pull/10655
tk.MustExec(`create table t34 (dt timestamp(3)) partition by range (floor(unix_timestamp(dt))) (
partition p0 values less than (unix_timestamp('2020-04-04 00:00:00')),
partition p1 values less than (unix_timestamp('2020-04-05 00:00:00')));`)

tk.MustGetErrCode(`create table t35 (dt timestamp(3)) partition by range (unix_timestamp(date(dt))) (
partition p0 values less than (unix_timestamp('2020-04-04 00:00:00')),
partition p1 values less than (unix_timestamp('2020-04-05 00:00:00')));`, tmysql.ErrWrongExprInPartitionFunc)

tk.MustGetErrCode(`create table t35 (dt datetime) partition by range (unix_timestamp(dt)) (
partition p0 values less than (unix_timestamp('2020-04-04 00:00:00')),
partition p1 values less than (unix_timestamp('2020-04-05 00:00:00')));`, tmysql.ErrWrongExprInPartitionFunc)

// Fix https://github.com/pingcap/tidb/issues/16333
tk.MustExec(`create table t35 (dt timestamp) partition by range (unix_timestamp(dt))
(partition p0 values less than (unix_timestamp('2020-04-15 00:00:00')));`)
}

func (s *testIntegrationSuite7) TestCreateTableWithHashPartition(c *C) {
Expand Down
2 changes: 1 addition & 1 deletion ddl/partition.go
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,7 @@ func checkPartitionFuncType(ctx sessionctx.Context, s *ast.CreateTableStmt, cols
// Side effect: it may simplify the partition range definition from a constant expression to an integer.
func checkCreatePartitionValue(ctx sessionctx.Context, tblInfo *model.TableInfo, pi *model.PartitionInfo, cols []*table.Column) error {
defs := pi.Definitions
if len(defs) <= 1 {
if len(defs) == 0 {
return nil
}

Expand Down

0 comments on commit 0c67b23

Please sign in to comment.