Skip to content

Commit

Permalink
ddl: check partition name unique when create hash type partition table (
Browse files Browse the repository at this point in the history
  • Loading branch information
xiongjiwei authored Nov 24, 2020
1 parent 83c1652 commit 7a19c70
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
4 changes: 4 additions & 0 deletions ddl/db_partition_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -695,6 +695,10 @@ func (s *testIntegrationSuite1) TestCreateTableWithListColumnsPartition(c *C) {
"create table t (a int, b datetime) partition by list columns (a,b) (partition p0 values in ((1)));",
ast.ErrPartitionColumnList,
},
{
"create table t(b int) partition by hash ( b ) partitions 3 (partition p1, partition p2, partition p2);",
ddl.ErrSameNamePartition,
},
}
for i, t := range cases {
_, err := tk.Exec(t.sql)
Expand Down
3 changes: 3 additions & 0 deletions ddl/ddl_api.go
Original file line number Diff line number Diff line change
Expand Up @@ -1944,6 +1944,9 @@ func buildViewInfo(ctx sessionctx.Context, s *ast.CreateViewStmt) (*model.ViewIn

func checkPartitionByHash(ctx sessionctx.Context, tbInfo *model.TableInfo, s *ast.CreateTableStmt) error {
pi := tbInfo.Partition
if err := checkPartitionNameUnique(pi); err != nil {
return err
}
if err := checkAddPartitionTooManyPartitions(pi.Num); err != nil {
return err
}
Expand Down

0 comments on commit 7a19c70

Please sign in to comment.