1
0
mirror of https://github.com/postgres/postgres.git synced 2025-11-06 07:49:08 +03:00

Get rid of the rather fuzzily defined FlattenedSubLink node type in favor of

making pull_up_sublinks() construct a full-blown JoinExpr tree representation
of IN/EXISTS SubLinks that it is able to convert to semi or anti joins.
This makes pull_up_sublinks() a shade more complex, but the gain in semantic
clarity is worth it.  I still have more to do in this area to address the
previously-discussed problems, but this commit in itself fixes at least one
bug in HEAD, as shown by added regression test case.
This commit is contained in:
Tom Lane
2009-02-25 03:30:38 +00:00
parent 7380b6384b
commit e549722a8b
18 changed files with 298 additions and 496 deletions

View File

@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/optimizer/util/clauses.c,v 1.275 2009/01/09 15:46:10 tgl Exp $
* $PostgreSQL: pgsql/src/backend/optimizer/util/clauses.c,v 1.276 2009/02/25 03:30:37 tgl Exp $
*
* HISTORY
* AUTHOR DATE MAJOR EVENT
@@ -1300,15 +1300,6 @@ find_nonnullable_rels_walker(Node *node, bool top_level)
expr->booltesttype == IS_NOT_UNKNOWN))
result = find_nonnullable_rels_walker((Node *) expr->arg, false);
}
else if (IsA(node, FlattenedSubLink))
{
/* JOIN_SEMI sublinks preserve strictness, but JOIN_ANTI ones don't */
FlattenedSubLink *expr = (FlattenedSubLink *) node;
if (expr->jointype == JOIN_SEMI)
result = find_nonnullable_rels_walker((Node *) expr->quals,
top_level);
}
else if (IsA(node, PlaceHolderVar))
{
PlaceHolderVar *phv = (PlaceHolderVar *) node;
@@ -1511,15 +1502,6 @@ find_nonnullable_vars_walker(Node *node, bool top_level)
expr->booltesttype == IS_NOT_UNKNOWN))
result = find_nonnullable_vars_walker((Node *) expr->arg, false);
}
else if (IsA(node, FlattenedSubLink))
{
/* JOIN_SEMI sublinks preserve strictness, but JOIN_ANTI ones don't */
FlattenedSubLink *expr = (FlattenedSubLink *) node;
if (expr->jointype == JOIN_SEMI)
result = find_nonnullable_vars_walker((Node *) expr->quals,
top_level);
}
else if (IsA(node, PlaceHolderVar))
{
PlaceHolderVar *phv = (PlaceHolderVar *) node;
@@ -2943,24 +2925,6 @@ eval_const_expressions_mutator(Node *node,
newbtest->booltesttype = btest->booltesttype;
return (Node *) newbtest;
}
if (IsA(node, FlattenedSubLink))
{
FlattenedSubLink *fslink = (FlattenedSubLink *) node;
FlattenedSubLink *newfslink;
Expr *quals;
/* Simplify and also canonicalize the arguments */
quals = (Expr *) eval_const_expressions_mutator((Node *) fslink->quals,
context);
quals = canonicalize_qual(quals);
newfslink = makeNode(FlattenedSubLink);
newfslink->jointype = fslink->jointype;
newfslink->lefthand = fslink->lefthand;
newfslink->righthand = fslink->righthand;
newfslink->quals = quals;
return (Node *) newfslink;
}
if (IsA(node, PlaceHolderVar) && context->estimate)
{
/*