Skip to content

Commit

Permalink
ddl: fix panic when create table patition by range columns (#7379)
Browse files Browse the repository at this point in the history
  • Loading branch information
winkyao authored and shenli committed Aug 13, 2018
1 parent 23b6f05 commit 71252f7
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
3 changes: 2 additions & 1 deletion ddl/ddl_api.go
Original file line number Diff line number Diff line change
Expand Up @@ -803,7 +803,8 @@ func (d *ddl) CreateTable(ctx sessionctx.Context, s *ast.CreateTableStmt) (err e
if err != nil {
return errors.Trace(err)
}
if s.Partition != nil {
// TODO: Remove the test 's.Partition.Expr != nil' when we support 'PARTITION BY RANGE COLUMNS'
if s.Partition != nil && s.Partition.Expr != nil {
pi := &model.PartitionInfo{
Type: s.Partition.Tp,
Expr: s.Partition.Expr.Text(),
Expand Down
3 changes: 3 additions & 0 deletions ddl/ddl_db_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1469,6 +1469,9 @@ func (s *testDBSuite) TestCreateTableWithPartition(c *C) {
c.Assert(part.Definitions[1].Name, Equals, "p1")
c.Assert(part.Definitions[2].MaxValue, IsTrue)
c.Assert(part.Definitions[2].Name, Equals, "p2")

// Fix issue 7362.
s.tk.MustExec("create table test_partition(id bigint, name varchar(255), primary key(id)) ENGINE=InnoDB DEFAULT CHARSET=utf8 PARTITION BY RANGE COLUMNS(id) (PARTITION p1 VALUES LESS THAN (10) ENGINE = InnoDB);")
}

func (s *testDBSuite) TestTruncateTable(c *C) {
Expand Down

0 comments on commit 71252f7

Please sign in to comment.