-
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: support modify decimal column precision in some cases. #14617
Conversation
/run-all-tests |
Please update the release note by adding descriptions to the cases. |
/run-all-tests |
/run-all-tests |
Signed-off-by: crazycs <crazycs520@gmail.com>
/run-all-tests |
/run-unit-test |
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 tikv=pr/6532 |
1 similar comment
/run-all-tests tikv=pr/6532 |
@@ -172,10 +175,18 @@ func TruncateIndexValuesIfNeeded(tblInfo *model.TableInfo, idxInfo *model.IndexI | |||
v.SetString(v.GetString(), tblInfo.Columns[ic.Offset].Collate) | |||
} | |||
} | |||
case types.KindMysqlDecimal: |
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 we need this?
Which version started to support this feature? |
background
PR #10433 prohibit modify decimal column precision, because change decimal column precision may cause data inconsistency when there is an index covering the decimal column.
What problem does this PR solve?
After think over, we can support modify a decimal column when satisfying the following conditions:
decimal(5,2)
todecimal(10,5)
is ok.decimal(5,2)
todecimal(4, 2)
is not support.decimal(5,2)
todecimal(5, 3)
is not support, because it may cause the column out range value error.After TiDB supports all column type changes, there will be no such restrictions.
eg:
What is changed and how it works?
Below is an example if only change
ddl
pkg to supportmodify decimal precision
:decimal(2,1)
, and write the data1.1
decimal(4,2)
, and get the data1.1
, but the expect data is1.10
.Below is sql example:
Since the decimal already encodes the precision info, So after modifying the decimal column precision, we must convert the decimal value to the new precision when reading the old decimal value.
So Also need to change the
decode
logical, both in TiDB and TiKV.Related TiKV PR tikv/tikv#6532.
Check List
Tests
Code changes
Related changes
Release note