-
Notifications
You must be signed in to change notification settings - Fork 5.9k
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
*: check float/double display width and scale #6098
Conversation
/run-all-tests |
@@ -97,10 +97,6 @@ func (s *testValidatorSuite) TestValidator(c *C) { | |||
errors.New("[types:1439]Display width out of range for column 'c' (max = 4294967295)")}, | |||
{"alter table t add column c float(4294967296)", true, | |||
errors.New("[types:1439]Display width out of range for column 'c' (max = 4294967295)")}, | |||
{"create table t (c float(54))", true, |
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.
why remove this ?
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.
duplicated with the newly added cases.
@@ -227,6 +227,8 @@ const ( | |||
|
|||
MaxIntWidth = 20 | |||
MaxRealWidth = 23 | |||
MaxFloatingTypeScale = 30 | |||
MaxFloatingTypeWidth = 255 |
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.
is this consistent with mysql ?
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.
yes
@@ -5532,7 +5532,7 @@ NumericType: | |||
x := types.NewFieldType($1.(byte)) | |||
x.Flen = fopt.Flen | |||
if x.Tp == mysql.TypeFloat { | |||
if x.Flen > mysql.PrecisionForFloat { | |||
if x.Flen > 24 { |
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.
should we extract 24
as to a variable like maxFloatScale
?
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.
I think we'd better not define it as a constant to avoid being abused.
This is not a meaningful number got from MySQL manual,
but extracted from the behavior of MySQL. (#351 may be referred.)
LGTM |
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
Before this commit:
After this commit:
PTAL @zz-jason @coocood