ddl: fix corrupted default value for bit type column (#18036)#20339
Merged
ti-srebot merged 8 commits intopingcap:release-3.0from Nov 13, 2020
Merged
ddl: fix corrupted default value for bit type column (#18036)#20339ti-srebot merged 8 commits intopingcap:release-3.0from
ti-srebot merged 8 commits intopingcap:release-3.0from
Conversation
Signed-off-by: ti-srebot <ti-srebot@pingcap.com>
Contributor
Author
|
/run-all-tests |
Member
|
Please resolve the conflicts @tangenta |
Member
|
/run-check_dev |
Contributor
|
Waiting for pingcap/parser#1090. |
Member
|
/run-all-tests |
Member
|
LGTM |
Member
|
/merge |
Contributor
Author
|
/run-all-tests |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
cherry-pick #18036 to release-3.0
What problem does this PR solve?
Issue Number: close #17641 close #17642
Problem Summary:
The
ColumnInfo.OriginDefaultValueis corrupted when the column type isBIT.BITtype column values are stored as strings by JSON marshaling and read it by unmarshaling later. However, the data in a string can be changed in this case:If we store it as []byte, the problem disappeared. This is how
DefaultValueBitworks.The same problem exists in
OriginDefaultValue. PR #12168 tried to restore theOriginDefaultValuefromDefaultValueBitin the getter, butOriginDefaultValueis different fromDefaultValue:OriginDefaultValueis used to skip the backfilling phase ofAddColumn(). If a column's default value is modified byALTER TABLE MODIFY COLUMN DEFAULT, they are not equal anymore(see the example in #17641).What is changed and how it works?
This PR adds a field
OriginDefaultValueBittoColumnInfo, which borrows fromDefaultValueBitto solve the problem completely.Proposal: xxx
What's Changed:
OriginDefaultValue.How it Works:
If the column type is
BIT, set/get the content withOriginDefaultValueBit.Related changes
Check List
Tests
Side effects
Release note