Conversation
…mple The string in the SET sql_mode example opens with an apostrophe and closes with a backtick, so the statement fails when a reader copies it.
The page says that ROUND() on approximate-value numbers behaves differently in TiDB than in MySQL, and the example shows ROUND(25E-1) returning 3. pingcap/tidb#21324 changed approximate-value rounding to "round to nearest even" to match MySQL. It shipped in v4.0.11 through the backport pingcap/tidb#21628, and in v5.0.0 through master, so the example now returns 2. The stale sentence also contradicted the opening line of the page, which states that precision math in TiDB is consistent with MySQL. Move the example out of the list, since its first column illustrates the exact-value rule and its second column the approximate-value one.
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
|
Hi @sary8. Thanks for your PR. I'm waiting for a pingcap member to verify that this patch is reasonable to test. If it is, they should reply with Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. DetailsInstructions 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. |
|
Welcome @sary8! |
📝 WalkthroughWalkthroughThe precision math reference fixes a SQL mode example and updates the documented ChangesPrecision Math Documentation
Priority: ➖ Normal Estimated code review effort: 1 (Trivial) | ~3 minutes Change: Other · Severity of issue fixed: Medium Merge Risk: 🔵 Low · up to Users of older TiDB releases may apply the documented rounding rule incorrectly; the fix is small and localized. 🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
Full details: Linked Issues checkExplanation Issue Resolution Include the integer Full details: Out of Scope Changes checkExplanation The approximate-value
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Advanced
Run ID: eff58eca-8a2e-4895-9fb5-0ea5cb7c1246
📒 Files selected for processing (1)
functions-and-operators/precision-math.md
Included review availability: Your plan provides up to 4 included reviews per hour; 3 remain after this review.
First-time contributors' checklist
What is changed, added, or deleted? (Required)
Two fixes in
functions-and-operators/precision-math.md.1. The approximate-value rounding rule is out of date.
The "Rounding behavior" section says that
ROUND()on approximate-value numbers behaves differently in TiDB than in MySQL, and the example showsROUND(25E-1)returning3.That description predates v4.0.11. pingcap/tidb#21324 changed approximate-value rounding to "round to nearest even" specifically to match MySQL, and it was included in v5.0.0. The change was backported to the 4.0 line as pingcap/tidb#21628, which shipped in v4.0.11 and is listed in the v4.0.11 release notes in this repository. Since v4.0.11, TiDB returns
2for this example.I ran the example on both servers:
They agree on the wider set too.
ROUND(35E-1)is 4,ROUND(45E-1)is 4,ROUND(55E-1)is 6, andROUND(-25E-1)is -2 on both, which is round-to-nearest-even in each case. TiDB's own test expectations record the same result for the example intests/integrationtest/r/expression/builtin.result.The stale sentence also contradicted the opening line of the same page, which states that precision math support in TiDB is consistent with MySQL.
The replacement states the rule TiDB applies and keeps the MySQL nuance: MySQL delegates approximate-value rounding to the C library, so it is not guaranteed on every platform. I left the exact-value bullet untouched. I also moved the example out of the list, because its first column illustrates the exact-value rule and its second column the approximate-value one.
The equivalent page in
pingcap/docs-cnstill contains the stale rounding statement and example; this PR only updates the English documentation.2. A mismatched quote makes an example fail when copied.
The string opens with
'and closes with a backtick, so copying the statement produces a syntax error. I confirmed the corrected form runs on TiDB v8.5.8. The same line is already correct in pingcap/docs-cn, so this one is specific to the English page.Which TiDB version(s) do your changes apply to? (Required)
Tips for choosing the affected version(s):
By default, CHOOSE MASTER ONLY so your changes will be applied to the next TiDB major or minor releases. If your PR involves a product feature behavior change or a compatibility change, CHOOSE THE AFFECTED RELEASE BRANCH(ES) AND MASTER.
For details, see tips for choosing the affected versions.
Master only, since this corrects an inaccurate description and an example value rather than documenting a version-specific behavior change.
The same stale text is present in release-8.5, release-8.1, release-7.5, release-7.1, and release-6.5, and the change can be cherry-picked to those branches without version-specific wording. This page is also referenced from
TOC-tidb-cloud.md, and both errors are currently published on the TiDB Cloud copy of this page, so the correction is relevant there as well.What is the related PR or file link(s)?
AI agent involvement
Do your changes match any of the following descriptions?
Summary by CodeRabbit
ROUND()behavior for approximate-value numbers in TiDB.ROUND(25E-1)returning2.