-
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
types: fix wrong hash key for decimal #19131
types: fix wrong hash key for decimal #19131
Conversation
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 |
This test case shows that current implementation is still incorrect: func TestDec(t *testing.T) {
dec1 := &MyDecimal{}
if err := dec1.FromString([]byte(".1is column 'ommand den6ser '%-956465")); err != nil {
panic("dec1")
}
dec2 := &MyDecimal{}
if err := dec2.FromString([]byte("0.10s e8s'@'%-.664000000000000000000000000000")); err != nil {
panic("dec2")
}
if dec1.Compare(dec2) != 0 {
panic("dec not equal")
}
h1, err := dec1.ToHashKey()
if err != nil {
panic(err)
}
h2, err := dec2.ToHashKey()
if err != nil {
panic(err)
}
if bytes.Compare(h1, h2) != 0 {
panic("dec1 eq dec2 but dec1 hash not eq dec2 hash")
}
}
|
0.1 and 0.10 have different hash key. It's another bug. |
…ub.com/lzmhhh123/tidb into bug-fix/fix_wrong_hash_key_for_decimal
@breeswish @SunRunAway PTAL. Already fixed. |
Here is a case that value eq but hash not eq using the latest code base:
|
I found some new bugs. "ToHashKey" function will return errors in some cases. I'm not sure whether this case should be handled:
|
TiDB's |
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.
Approve since fuzz test doesn't show anything wrong now.
Codecov Report
@@ Coverage Diff @@
## master #19131 +/- ##
================================================
- Coverage 79.3723% 79.2474% -0.1249%
================================================
Files 549 550 +1
Lines 150647 150391 -256
================================================
- Hits 119572 119181 -391
- Misses 21601 21680 +79
- Partials 9474 9530 +56 |
Would you please add a test case for this issue? It has a minial test case here #17216 (comment) |
…ub.com/lzmhhh123/tidb into bug-fix/fix_wrong_hash_key_for_decimal
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
/merge |
/run-all-tests |
Signed-off-by: ti-srebot <[email protected]>
cherry pick to release-3.0 in PR #19185 |
Signed-off-by: ti-srebot <[email protected]>
cherry pick to release-3.1 in PR #19187 |
Signed-off-by: ti-srebot <[email protected]>
cherry pick to release-4.0 in PR #19188 |
Signed-off-by: ti-srebot <[email protected]>
* cherry pick #19131 to release-4.0 Signed-off-by: ti-srebot <[email protected]> * fix conflicts Co-authored-by: Zhuomin(Charming) Liu <[email protected]> Co-authored-by: jebter <[email protected]>
What problem does this PR solve?
Issue Number: close #19112
What is changed and how it works?
What's Changed:
MyDecimal.ToHashKey
should consider the length ofint
andFrac
.Related changes
pingcap/docs
/pingcap/docs-cn
:Check List
Tests
Side effects
Release note