diff --git a/ddl/ddl_api.go b/ddl/ddl_api.go index 69655c969a0bf..81ece375d4dde 100644 --- a/ddl/ddl_api.go +++ b/ddl/ddl_api.go @@ -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 diff --git a/ddl/partition.go b/ddl/partition.go index 7e799a350592c..481f0da5d2be2 100644 --- a/ddl/partition.go +++ b/ddl/partition.go @@ -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