MDEV-40245 Match equivalent NULLIF expressions during view analysis #5774
All Vouch review confidence checks passed
Residual risk 0.03 = Change Risk (0.30) × (1 − Review Confidence (0.90)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.30 · 42 lines diff across 4 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.91 · 2 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size
diff_size
0.225
Real PR Conversation Timeline
5 items
Simplify the test case please. I do not think neither CREATE DATABASE nor SET are needed.
How many of these contribute to extra coverage? Remove the extra. Note that the test suite itself runs with prepared statements and with view protocols!
Changes Requested
Thank you for your contribution! This is a preliminary review.
Please simplify the test case.
Approved
Thanks. LGTM. Please stand by for the final review.
gkodinov
DerZc
During view analysis, NULLIF can have two arguments while its fixed form has a third argument for the return value. Generic function comparison rejects these equivalent expressions because their argument counts differ. A view using DISTINCT and ORDER BY can consequently lose distinct rows.
Recognize the two- and three-argument NULLIF forms as equal when both original operands match and the extra argument repeats the first operand.
Regression coverage
Add a seven-line regression to
main.view: create one table with two rows, create a view using DISTINCT, ORDER BY and division by NULLIF(1,0), query it once, and clean up. Both distinct values must survive. No extra SET, database creation, manual prepared statements or duplicate queries are needed.Validation
On current
11.4atf49e838d367f2154b3edb43effa99ff9eb0d8602:main.viewonly on the new query, omitting(NULL, 4.0000).main.view,main.func_group,main.group_by,main.selectandmain.func_ifpass.main.viewpasses.main.viewis skipped in this mode because its existingcount_sessions.increquires the view protocol to be disabled.Bug report: https://jira.mariadb.org/browse/MDEV-40245