Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitdea1491

Browse files
committed
Teach predtest.c that "foo" implies "foo IS NOT NULL".
Per complaint from Peter Holzer. It's useful to cover this special case,since for a boolean variable "foo", earlier parts of the planner will havereduced variants like "foo = true" to just "foo", and thus we may failto recognize the applicability of a partial index with predicate"foo IS NOT NULL".Back-patch to 9.5, but not further; given the lack of previous complaintsthis doesn't seem like behavior to change in stable branches.
1 parenta6492ff commitdea1491

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

‎src/backend/optimizer/util/predtest.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1028,6 +1028,8 @@ arrayexpr_cleanup_fn(PredIterInfo info)
10281028
* "foo" is NULL, which we can take as equivalent to FALSE because we know
10291029
* we are within an AND/OR subtree of a WHERE clause. (Again, "foo" is
10301030
* already known immutable, so the clause will certainly always fail.)
1031+
* Also, if the clause is just "foo" (meaning it's a boolean variable),
1032+
* the predicate is implied since the clause can't be true if "foo" is NULL.
10311033
*
10321034
* Finally, if both clauses are binary operator expressions, we may be able
10331035
* to prove something using the system's knowledge about operators; those
@@ -1061,6 +1063,8 @@ predicate_implied_by_simple_clause(Expr *predicate, Node *clause)
10611063
list_member_strip(((FuncExpr*)clause)->args,nonnullarg)&&
10621064
func_strict(((FuncExpr*)clause)->funcid))
10631065
return true;
1066+
if (equal(clause,nonnullarg))
1067+
return true;
10641068
}
10651069
return false;/* we can't succeed below... */
10661070
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp