Skip to content

Commit

Permalink
cherry pick pingcap#16436 to release-3.1
Browse files Browse the repository at this point in the history
Signed-off-by: sre-bot <sre-bot@pingcap.com>
  • Loading branch information
tiancaiamao authored and sre-bot committed Apr 16, 2020
1 parent bbc3206 commit bd31804
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
20 changes: 20 additions & 0 deletions ddl/db_partition_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,26 @@ func (s *testIntegrationSuite9) TestCreateTableWithPartition(c *C) {
PARTITION p2 VALUES LESS THAN (2000),
PARTITION p3 VALUES LESS THAN (2005)
);`, tmysql.ErrBadField)
<<<<<<< HEAD
=======

// 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 t34 (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 t34 (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')));`)
>>>>>>> 22664a7... ddl: create partition table fail with strconv.ParseInt invalid syntax (#16436)
}

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 @@ -325,7 +325,7 @@ func checkPartitionFuncType(ctx sessionctx.Context, s *ast.CreateTableStmt, tblI
func checkCreatePartitionValue(ctx sessionctx.Context, tblInfo *model.TableInfo) error {
pi := tblInfo.Partition
defs := pi.Definitions
if len(defs) <= 1 {
if len(defs) == 0 {
return nil
}

Expand Down

0 comments on commit bd31804

Please sign in to comment.