Skip to content

Commit

Permalink
ddl: fix admin repair table with range partition expr will parseInt f…
Browse files Browse the repository at this point in the history
…ail (#17982) (#17988)

Signed-off-by: sre-bot <[email protected]>
  • Loading branch information
sre-bot authored Jul 29, 2020
1 parent 4669f68 commit 53af4ef
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
7 changes: 5 additions & 2 deletions ddl/ddl_api.go
Original file line number Diff line number Diff line change
Expand Up @@ -1378,10 +1378,13 @@ func buildTableInfoWithCheck(ctx sessionctx.Context, s *ast.CreateTableStmt, dbC
if err != nil {
return nil, err
}
if err = checkTableInfoValidExtra(tbInfo); err != nil {
// Fix issue 17952 which will cause partition range expr can't be parsed as Int.
// checkTableInfoValidWithStmt will do the constant fold the partition expression first,
// then checkTableInfoValidExtra will pass the tableInfo check successfully.
if err = checkTableInfoValidWithStmt(ctx, tbInfo, s); err != nil {
return nil, err
}
if err = checkTableInfoValidWithStmt(ctx, tbInfo, s); err != nil {
if err = checkTableInfoValidExtra(tbInfo); err != nil {
return nil, err
}
return tbInfo, nil
Expand Down
4 changes: 3 additions & 1 deletion ddl/partition.go
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,9 @@ func checkAndOverridePartitionID(newTableInfo, oldTableInfo *model.TableInfo) er
for i, newOne := range newTableInfo.Partition.Definitions {
found := false
for _, oldOne := range oldTableInfo.Partition.Definitions {
if newOne.Name.L == oldOne.Name.L && stringSliceEqual(newOne.LessThan, oldOne.LessThan) {
// Fix issue 17952 which wanna substitute partition range expr.
// So eliminate stringSliceEqual(newOne.LessThan, oldOne.LessThan) here.
if newOne.Name.L == oldOne.Name.L {
newTableInfo.Partition.Definitions[i].ID = oldOne.ID
found = true
break
Expand Down

0 comments on commit 53af4ef

Please sign in to comment.