-
Notifications
You must be signed in to change notification settings - Fork 5.8k
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 create partitioned table with bigint column fail #7520
Conversation
ddl/partition.go
Outdated
var offset int | ||
for i, col := range cols { | ||
if col.Name.L == strings.ToLower(pi.Expr) { | ||
offset = i |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need “break” here?
ddl/partition.go
Outdated
for i := 0; i < len(defs); i++ { | ||
if strings.EqualFold(defs[i].LessThan[0], partitionMaxValue) { | ||
return errors.Trace(ErrPartitionMaxvalue) | ||
} | ||
|
||
currentRangeValue, fromExpr, err := getRangeValue(ctx, tblInfo, defs[i].LessThan[0]) | ||
currentRangeValue, fromExpr, err := getRangeValue(ctx, tblInfo, defs[i].LessThan[0], cols, offset) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we replace “cols” and “offset” with “col”?
@tiancaiamao @winkyao @zimulala PTAL . |
ddl/partition.go
Outdated
var prevRangeValue int64 | ||
|
||
var offset int | ||
for i, col := range cols { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cloud we use "FindCol" directly?
ddl/partition.go
Outdated
|
||
if currentRangeValue <= prevRangeValue { | ||
return errors.Trace(ErrRangeNotIncreasing) | ||
if col.Tp == mysql.TypeLonglong && mysql.HasUnsignedFlag(col.Flag) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
col
maybe nil
here ?
ddl/partition.go
Outdated
@@ -187,13 +187,15 @@ func checkCreatePartitionValue(ctx sessionctx.Context, tblInfo *model.TableInfo, | |||
if strings.EqualFold(defs[len(defs)-1].LessThan[0], partitionMaxValue) { | |||
defs = defs[:len(defs)-1] | |||
} | |||
var prevRangeValue int64 | |||
|
|||
col := table.FindCol(cols, strings.ToUpper(pi.Expr)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FindCol use a case-insensitive search, so strings.ToUpper
is not necessary
@tiancaiamao @winkyao @zimulala PTAL . |
ddl/partition.go
Outdated
@@ -388,3 +406,15 @@ func checkConstraintIncludePartKey(partkeys []string, constraints map[string]str | |||
} | |||
return true | |||
} | |||
|
|||
// FindRangePartitionColTp find the type of the partitioning key column type. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
s/FindRangePartitionColTp find the type of the partitioning key column type./FindRangePartitionColTp finds the type of the partitioning key column type.
/run-all-tests |
6a10006
to
2c1fb5b
Compare
/run-all-tests |
ddl/partition.go
Outdated
if value, err := strconv.ParseInt(str, 10, 64); err == nil { | ||
return value, false, nil | ||
} | ||
func getRangeValue(ctx sessionctx.Context, tblInfo *model.TableInfo, str string, ifUnsignedBigint bool) (interface{}, bool, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
s/ifUnsignedBigint/unsignedBigint
ddl/partition.go
Outdated
|
||
// FindRangePartitionColTp finds the type of the partitioning key column type. | ||
// The returned boolean value indicates whether the partitioning key column type is unsigned bigint type. | ||
func FindRangePartitionColTp(cols []*table.Column, pi *model.PartitionInfo) bool { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
s/FindRangePartitionColTp/isRangePartitionColUnsignedBigint
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Find column type returns a boolean is weird.
@tiancaiamao @winkyao @zimulala PTAL . |
LGTM |
@crazycs520 @winkyao @zimulala PTAL . |
@crazycs520 @winkyao @zimulala PTAL . |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
/run-all-tests |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
What problem does this PR solve?
Create partitioned table when partitioning key is of type
bigint
unsigned will fail.What is changed and how it works?
PartitionRangeValue
range comparison.Unsigned bigint
was converted touint64
handle.Bigint
was converted toint64
handle.mysql
master branch
Check List
Tests