planner: avoid NULLIF type leak from comparison rewrite#68127
Conversation
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
📝 WalkthroughWalkthroughNULLIF rewrite now clones operands and makes the generated IF return type follow the first operand (nullable). Integration tests and expected results updated to cover nested NULLIF, mediumtext/enum/float/double, UNION ALL, CTE+VARIANCE, and scalar/aggregate NULLIF cases. Changes
Sequence Diagram(s)(omitted) Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Suggested labels
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ 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 |
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## master #68127 +/- ##
================================================
- Coverage 77.7559% 77.0548% -0.7011%
================================================
Files 1990 1972 -18
Lines 551769 555027 +3258
================================================
- Hits 429033 427675 -1358
- Misses 121816 127185 +5369
+ Partials 920 167 -753
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
| 77.1500000000000000000000000000000000 | ||
| Level Code Message | ||
| Warning 1265 Data truncated for column '%s' at row %d | ||
| 77.150000 |
There was a problem hiding this comment.
Now, it is the same as MySQL.
Signed-off-by: Weizhen Wang <wangweizhen@pingcap.com>
| nullTp := types.NewFieldType(mysql.TypeNull) | ||
| flen, decimal := mysql.GetDefaultFieldLengthAndDecimal(mysql.TypeNull) | ||
| nullTp.SetFlen(flen) | ||
| nullTp.SetDecimal(decimal) |
There was a problem hiding this comment.
mysql.GetDefaultFieldLengthAndDecimal(mysql.TypeNull) will get flen=0, decimal=0.
There was a problem hiding this comment.
So it is necessary to set flen and decimal.
|
/retest |
|
/test tidb_parser_test |
|
@hawkingrei: The specified target(s) for The following commands are available to trigger optional jobs: Use DetailsIn response to this:
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. |
|
/test check-dev2 |
|
@hawkingrei: The specified target(s) for Use DetailsIn response to this:
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. |
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: guo-shaoge, qw4990 The full list of commands accepted by this bot can be found here. The pull request process is described here DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
[LGTM Timeline notifier]Timeline:
|
What problem does this PR solve?
Issue Number: close #66322
Problem Summary:
NULLIF(a, b)is rewritten asIF(a = b, NULL, a). The comparison branch may coerce or wrap the first argument for equality evaluation. Reusing the same expression object as the returned value branch can leak comparison-side type metadata into theNULLIFresult, which may further affectUNIONresult metadata and values for nestedNULLIFexpressions.What changed and how does it work?
Clone the
NULLIFcomparison arguments before building the equality function, so comparison-side coercion cannot mutate the returned value expression.Build the rewritten
IFreturn type from the rewritten first argument type withNotNullcleared. This keeps theIFfalse branch aligned withNULLIFsemantics and avoids adding comparison-side casts to the value returned when the comparison is false.Add integration coverage for nested
NULLIF(enum, double)and aUNION ALLshape matching the issue.Check List
Tests
Manual test details:
Side effects
Documentation
Release note
Please refer to Release Notes Language Style Guide to write a quality release note.
Summary by CodeRabbit
Bug Fixes
Tests