Repository navigation
Reduce IS DISTINCT FROM with non-null inputs - #1623
Merged
Merged
Conversation
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.
The
DistinctExprcase of PostgreSQL 19'seval_const_expressionsfor an input that is not a constant (Fold::distinctinrupg-exec). It usesexpr_is_nonnullable(Fold::nonnullable), which already exists: a column with a valid not-null constraint that no outer join makes null, a non-null constant, andCOALESCE,GREATEST/LEASTorCASEover those.trueforIS DISTINCT FROM,falseforIS NOT DISTINCT FROM(afalseWHEREthen makes the scan dummy)=operator of the expression, negated with its negator forIS DISTINCT FROM(<>); aNOTabove it negates it back to=IS NOT NULL, orIS NULLforIS NOT DISTINCT FROM=lets index scans, hash joins and the equivalence classes use the condition.Limits:
DistinctExpr. PostgreSQL makes aNullTestwithargisrow = false, which rupg'sNullTestcannot express.=function.Fixture
connection/distinct_reduce.test, the output of PostgreSQL 19 for the same script. It covers thedist_tabcases ofpredicate.sql(except the row case above), plustextandvarchar, two columns, an expression,COALESCE, a cast,NOT, an outer join inWHEREand inON, the target list, and the hash join withenable_nestloopoff.Regression (changed lines of the diff, against the run after #1622):
predicate122 → 68, no other change in the targeted set. The other tests that useDISTINCT FROMshow no change on aDISTINCT FROMline, and these pass:errors,domain,publication,opr_sanity,type_sanity,txid,xid,tsrf,create_index_spgist.Part of the M7 regression work.