Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ddl: fix admin repair table with range partition expr will parseInt fail (#17982) #17988

Merged
merged 7 commits into from
Jul 29, 2020
7 changes: 5 additions & 2 deletions ddl/ddl_api.go
Original file line number Diff line number Diff line change
Expand Up @@ -1375,10 +1375,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