Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

util: fix codec for negative zero | tidb-test=pr/2427 #57343

Merged
merged 5 commits into from
Nov 15, 2024

Conversation

wshwsh12
Copy link
Contributor

What problem does this PR solve?

Issue Number: close #41878
Negative zero is incorrectly converted to zero after being encoded and then decoded.

Problem Summary:
Correctly handle the encoding issue of negative zero.

What changed and how does it work?

Check List

Tests

  • Unit test
  • Integration test
  • Manual test (add detailed scripts or steps below)
tidb> CREATE TABLE t1 (c0 decimal(10,0));
Query OK, 0 rows affected (0.11 sec)

tidb> INSERT INTO t1 VALUES (0);
Query OK, 1 row affected (0.02 sec)

tidb> SELECT c0 FROM t1 WHERE CAST(ATAN2(((t1.c0) IS NULL), (- (''))) AS TIME); -- actual: {}, expected: {0}
+------+
| c0   |
+------+
|    0 |
+------+
1 row in set (0.00 sec)
  • No need to test
    • I checked and no code files have been changed.

Side effects

  • Performance regression: Consumes more CPU
  • Performance regression: Consumes more Memory
  • Breaking backward compatibility

Documentation

  • Affects user behaviors
  • Contains syntax changes
  • Contains variable changes
  • Contains experimental features
  • Changes MySQL compatibility

Release note

Please refer to Release Notes Language Style Guide to write a quality release note.

None

@ti-chi-bot ti-chi-bot bot added do-not-merge/needs-triage-completed release-note-none Denotes a PR that doesn't merit a release note. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Nov 13, 2024
Copy link

tiprow bot commented Nov 13, 2024

Hi @wshwsh12. Thanks for your PR.

PRs from untrusted users cannot be marked as trusted with /ok-to-test in this repo meaning untrusted PR authors can never trigger tests themselves. Collaborators can still trigger tests on the PR using /test all.

I understand the commands that are listed here.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

Copy link

codecov bot commented Nov 13, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 73.4596%. Comparing base (4fded5f) to head (cf74ab5).
Report is 11 commits behind head on master.

Additional details and impacted files
@@               Coverage Diff                @@
##             master     #57343        +/-   ##
================================================
+ Coverage   72.9236%   73.4596%   +0.5359%     
================================================
  Files          1672       1672                
  Lines        462267     462315        +48     
================================================
+ Hits         337102     339615      +2513     
+ Misses       104417     102008      -2409     
+ Partials      20748      20692        -56     
Flag Coverage Δ
integration 43.3910% <100.0000%> (?)
unit 72.2869% <100.0000%> (-0.0160%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Components Coverage Δ
dumpling 52.7673% <ø> (ø)
parser ∅ <ø> (∅)
br 45.1133% <ø> (-0.0154%) ⬇️

@wshwsh12 wshwsh12 changed the title util: fix codec for negative zero util: fix codec for negative zero | tidb-test=pr/2427 Nov 14, 2024
@wshwsh12
Copy link
Contributor Author

/retest

Copy link

tiprow bot commented Nov 14, 2024

@wshwsh12: Cannot trigger testing until a trusted user reviews the PR and leaves an /ok-to-test message.

In response to this:

/retest

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@@ -22,7 +22,7 @@ import (

func encodeFloatToCmpUint64(f float64) uint64 {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add some comments to make it more readable

func encodeFloatToCmpUint64(f float64) uint64 {
    u := math.Float64bits(f)
    // Check the sign bit (the highest bit in the IEEE 754 representation).
    // If the sign bit is 0, the number is non-negative (+0 is considered non-negative).
    if u&signMask == 0 {
        // For non-negative numbers (+0 included), set the sign bit to 1.
        // This ensures non-negative numbers are ordered after negative numbers
        // when compared as unsigned integers.
        u |= signMask
    } else {
        // For negative numbers (-0 included), invert all bits.
        // This reorders negative numbers so that the smallest (closest to 0)
        // has the smallest encoded value, and the most negative has the largest.
        u = ^u
    }
    return u
}

@ti-chi-bot ti-chi-bot bot added approved needs-1-more-lgtm Indicates a PR needs 1 more LGTM. labels Nov 15, 2024
Copy link

ti-chi-bot bot commented Nov 15, 2024

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: guo-shaoge, XuHuaiyu

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:
  • OWNERS [XuHuaiyu,guo-shaoge]

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@ti-chi-bot ti-chi-bot bot added lgtm and removed needs-1-more-lgtm Indicates a PR needs 1 more LGTM. labels Nov 15, 2024
Copy link

ti-chi-bot bot commented Nov 15, 2024

[LGTM Timeline notifier]

Timeline:

  • 2024-11-15 09:29:54.367532151 +0000 UTC m=+607756.558401143: ☑️ agreed by XuHuaiyu.
  • 2024-11-15 09:30:35.672407303 +0000 UTC m=+607797.863276300: ☑️ agreed by guo-shaoge.

@wshwsh12
Copy link
Contributor Author

/retest

Copy link

tiprow bot commented Nov 15, 2024

@wshwsh12: Cannot trigger testing until a trusted user reviews the PR and leaves an /ok-to-test message.

In response to this:

/retest

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@wshwsh12
Copy link
Contributor Author

/test fast_test_tiprow

Copy link

ti-chi-bot bot commented Nov 15, 2024

@wshwsh12: The specified target(s) for /test were not found.
The following commands are available to trigger required jobs:

  • /test build
  • /test check-dev
  • /test check-dev2
  • /test mysql-test
  • /test pull-br-integration-test
  • /test pull-integration-ddl-test
  • /test pull-lightning-integration-test
  • /test pull-mysql-client-test
  • /test pull-unit-test-ddlv1
  • /test unit-test

The following commands are available to trigger optional jobs:

  • /test pingcap/tidb/canary_ghpr_unit_test
  • /test pull-common-test
  • /test pull-e2e-test
  • /test pull-integration-common-test
  • /test pull-integration-copr-test
  • /test pull-integration-e2e-test
  • /test pull-integration-jdbc-test
  • /test pull-integration-mysql-test
  • /test pull-integration-nodejs-test
  • /test pull-integration-python-orm-test
  • /test pull-sqllogic-test
  • /test pull-tiflash-test

Use /test all to run the following jobs that were automatically triggered:

  • pingcap/tidb/ghpr_build
  • pingcap/tidb/ghpr_check
  • pingcap/tidb/ghpr_check2
  • pingcap/tidb/ghpr_mysql_test
  • pingcap/tidb/ghpr_unit_test
  • pingcap/tidb/pull_integration_ddl_test
  • pingcap/tidb/pull_mysql_client_test

In response to this:

/test fast_test_tiprow

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

Copy link

tiprow bot commented Nov 15, 2024

@wshwsh12: Cannot trigger testing until a trusted user reviews the PR and leaves an /ok-to-test message.

In response to this:

/test fast_test_tiprow

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@wshwsh12
Copy link
Contributor Author

/ok-to-test

@ti-chi-bot ti-chi-bot bot added the ok-to-test Indicates a PR is ready to be tested. label Nov 15, 2024
@wshwsh12
Copy link
Contributor Author

/test fast_test_tiprow

Copy link

ti-chi-bot bot commented Nov 15, 2024

@wshwsh12: The specified target(s) for /test were not found.
The following commands are available to trigger required jobs:

  • /test build
  • /test check-dev
  • /test check-dev2
  • /test mysql-test
  • /test pull-br-integration-test
  • /test pull-integration-ddl-test
  • /test pull-lightning-integration-test
  • /test pull-mysql-client-test
  • /test pull-unit-test-ddlv1
  • /test unit-test

The following commands are available to trigger optional jobs:

  • /test pingcap/tidb/canary_ghpr_unit_test
  • /test pull-common-test
  • /test pull-e2e-test
  • /test pull-integration-common-test
  • /test pull-integration-copr-test
  • /test pull-integration-e2e-test
  • /test pull-integration-jdbc-test
  • /test pull-integration-mysql-test
  • /test pull-integration-nodejs-test
  • /test pull-integration-python-orm-test
  • /test pull-sqllogic-test
  • /test pull-tiflash-test

Use /test all to run the following jobs that were automatically triggered:

  • pingcap/tidb/ghpr_build
  • pingcap/tidb/ghpr_check
  • pingcap/tidb/ghpr_check2
  • pingcap/tidb/ghpr_mysql_test
  • pingcap/tidb/ghpr_unit_test
  • pingcap/tidb/pull_integration_ddl_test
  • pingcap/tidb/pull_mysql_client_test

In response to this:

/test fast_test_tiprow

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@ti-chi-bot ti-chi-bot bot merged commit 9b26569 into pingcap:master Nov 15, 2024
23 checks passed
@wshwsh12 wshwsh12 added the needs-cherry-pick-release-8.5 Should cherry pick this PR to release-8.5 branch. label Nov 18, 2024
@ti-chi-bot
Copy link
Member

In response to a cherrypick label: new pull request created to branch release-8.5: #57453.

ti-chi-bot bot pushed a commit that referenced this pull request Nov 19, 2024
wshwsh12 added a commit to wshwsh12/tidb that referenced this pull request Nov 19, 2024
wshwsh12 added a commit to wshwsh12/tidb that referenced this pull request Nov 20, 2024
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
approved lgtm needs-cherry-pick-release-8.5 Should cherry pick this PR to release-8.5 branch. ok-to-test Indicates a PR is ready to be tested. release-note-none Denotes a PR that doesn't merit a release note. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

An incorrect query result
4 participants