1
0
mirror of https://github.com/postgres/postgres.git synced 2025-10-27 00:12:01 +03:00

Improve the planner's simplification of NOT constructs.

This patch merges the responsibility for NOT-flattening into
eval_const_expressions' processing.  It wasn't done that way originally
because prepqual.c is far older than eval_const_expressions.  But putting
this work into eval_const_expressions saves one pass over the qual trees,
and in fact saves even more than that because we can exploit the knowledge
that the subexpressions have already been recursively simplified.  Doing it
this way also lets us do it uniformly over all expressions, whereas
prepqual.c formerly just did it at top level to save cycles.  That should
improve the planner's ability to recognize logically-equivalent constructs.

While at it, also add the ability to fold a NOT into BooleanTest and
NullTest constructs (the latter only for the scalar-datatype case).

Per discussion of bug #5702.
This commit is contained in:
Tom Lane
2010-10-10 23:19:50 -04:00
parent b48b9cb3a4
commit 220e45bf32
3 changed files with 236 additions and 180 deletions

View File

@@ -33,6 +33,7 @@ extern Relids get_relids_for_join(PlannerInfo *root, int joinrelid);
/*
* prototypes for prepqual.c
*/
extern Node *negate_clause(Node *node);
extern Expr *canonicalize_qual(Expr *qual);
/*