-
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: store default value as string when value type is binary or bit #9897
Conversation
/run-all-tests |
Codecov Report
@@ Coverage Diff @@
## master #9897 +/- ##
===========================================
Coverage ? 77.5398%
===========================================
Files ? 403
Lines ? 81847
Branches ? 0
===========================================
Hits ? 63464
Misses ? 13675
Partials ? 4708 |
/run-all-tests |
1 similar comment
/run-all-tests |
// For other kind of fields (e.g. INT), we supply its integer value so that it acts as integers. | ||
return v.GetBinaryLiteral().ToInt(ctx.GetSessionVars().StmtCtx) | ||
// For other kind of fields (e.g. INT), we supply its integer as string value. | ||
value, err := v.GetBinaryLiteral().ToInt(ctx.GetSessionVars().StmtCtx) |
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.
It seems that the default value is TypeBit
, why won't it go through line 528?
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.
The value type is typeBit
, but the column type is Int
.
eg: create table t (a int default b'1');
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
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
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?
In v2.1.4, execute below SQL will be panic: v2.1.5 and after won't panic.
The main reason of panic is we think the ColumnInfo.DefaultValue is a string type( you can check the code of ColumnInfo.DefaultValue usage place ). but in upper SQL situation, the default value will be uint64, and after json Marshal and Unmarshal, the default value type will be float64. That's not what would expect.
Below was a simple example of json marshal and unmarshal:
What is changed and how it works?
Change
getDefaultValue
function to convert uint64 to string before return.Check List
Tests
Code changes
Side effects
Related changes