Conversation
gkodinov
requested changes
Sep 28, 2026
gkodinov
left a comment
Member
There was a problem hiding this comment.
Thank you for your contribution! This is a preliminary review.
Please simplify the test case.
NULLIF has two arguments during view analysis and gains a third return-value argument when fixed. The generic function comparison rejects these equivalent forms because their argument counts differ. A view using DISTINCT and ORDER BY can consequently lose distinct rows. Recognize the two- and three-argument forms as equal when both original operands match and the extra argument repeats the first operand. Add a view using DISTINCT, ORDER BY and division by NULLIF(1,0). Check that querying it preserves both distinct input values. Bug report: https://jira.mariadb.org/browse/MDEV-40245
DerZc
force-pushed
the
fix-mdev-40245
branch
from
September 29, 2026 07:36
1c09a73 to
2f383d9
Compare
gkodinov
approved these changes
Sep 29, 2026
gkodinov
left a comment
Member
There was a problem hiding this comment.
Thanks. LGTM. Please stand by for the final review.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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