1
0
mirror of https://github.com/postgres/postgres.git synced 2025-07-31 22:04:40 +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

@ -15,7 +15,7 @@
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/nodes/copyfuncs.c,v 1.424 2009/02/24 10:06:32 petere Exp $
* $PostgreSQL: pgsql/src/backend/nodes/copyfuncs.c,v 1.425 2009/02/25 03:30:37 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@ -1624,22 +1624,6 @@ _copyRestrictInfo(RestrictInfo *from)
return newnode;
}
/*
* _copyFlattenedSubLink
*/
static FlattenedSubLink *
_copyFlattenedSubLink(FlattenedSubLink *from)
{
FlattenedSubLink *newnode = makeNode(FlattenedSubLink);
COPY_SCALAR_FIELD(jointype);
COPY_BITMAPSET_FIELD(lefthand);
COPY_BITMAPSET_FIELD(righthand);
COPY_NODE_FIELD(quals);
return newnode;
}
/*
* _copyPlaceHolderVar
*/
@ -3710,9 +3694,6 @@ copyObject(void *from)
case T_RestrictInfo:
retval = _copyRestrictInfo(from);
break;
case T_FlattenedSubLink:
retval = _copyFlattenedSubLink(from);
break;
case T_PlaceHolderVar:
retval = _copyPlaceHolderVar(from);
break;

View File

@ -22,7 +22,7 @@
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/nodes/equalfuncs.c,v 1.348 2009/02/24 10:06:32 petere Exp $
* $PostgreSQL: pgsql/src/backend/nodes/equalfuncs.c,v 1.349 2009/02/25 03:30:37 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@ -766,17 +766,6 @@ _equalRestrictInfo(RestrictInfo *a, RestrictInfo *b)
return true;
}
static bool
_equalFlattenedSubLink(FlattenedSubLink *a, FlattenedSubLink *b)
{
COMPARE_SCALAR_FIELD(jointype);
COMPARE_BITMAPSET_FIELD(lefthand);
COMPARE_BITMAPSET_FIELD(righthand);
COMPARE_NODE_FIELD(quals);
return true;
}
static bool
_equalPlaceHolderVar(PlaceHolderVar *a, PlaceHolderVar *b)
{
@ -2496,9 +2485,6 @@ equal(void *a, void *b)
case T_RestrictInfo:
retval = _equalRestrictInfo(a, b);
break;
case T_FlattenedSubLink:
retval = _equalFlattenedSubLink(a, b);
break;
case T_PlaceHolderVar:
retval = _equalPlaceHolderVar(a, b);
break;

View File

@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/nodes/nodeFuncs.c,v 1.37 2009/01/01 17:23:43 momjian Exp $
* $PostgreSQL: pgsql/src/backend/nodes/nodeFuncs.c,v 1.38 2009/02/25 03:30:37 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@ -1309,14 +1309,6 @@ expression_tree_walker(Node *node,
/* groupClauses are deemed uninteresting */
}
break;
case T_FlattenedSubLink:
{
FlattenedSubLink *fslink = (FlattenedSubLink *) node;
if (walker(fslink->quals, context))
return true;
}
break;
case T_PlaceHolderVar:
return walker(((PlaceHolderVar *) node)->phexpr, context);
case T_AppendRelInfo:
@ -1972,17 +1964,6 @@ expression_tree_mutator(Node *node,
return (Node *) newnode;
}
break;
case T_FlattenedSubLink:
{
FlattenedSubLink *fslink = (FlattenedSubLink *) node;
FlattenedSubLink *newnode;
FLATCOPY(newnode, fslink, FlattenedSubLink);
/* Assume we need not copy the relids bitmapsets */
MUTATE(newnode->quals, fslink->quals, Expr *);
return (Node *) newnode;
}
break;
case T_PlaceHolderVar:
{
PlaceHolderVar *phv = (PlaceHolderVar *) node;

View File

@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/nodes/outfuncs.c,v 1.352 2009/02/06 23:43:23 tgl Exp $
* $PostgreSQL: pgsql/src/backend/nodes/outfuncs.c,v 1.353 2009/02/25 03:30:37 tgl Exp $
*
* NOTES
* Every node type that can appear in stored rules' parsetrees *must*
@ -1630,17 +1630,6 @@ _outInnerIndexscanInfo(StringInfo str, InnerIndexscanInfo *node)
WRITE_NODE_FIELD(cheapest_total_innerpath);
}
static void
_outFlattenedSubLink(StringInfo str, FlattenedSubLink *node)
{
WRITE_NODE_TYPE("FLATTENEDSUBLINK");
WRITE_ENUM_FIELD(jointype, JoinType);
WRITE_BITMAPSET_FIELD(lefthand);
WRITE_BITMAPSET_FIELD(righthand);
WRITE_NODE_FIELD(quals);
}
static void
_outPlaceHolderVar(StringInfo str, PlaceHolderVar *node)
{
@ -2660,9 +2649,6 @@ _outNode(StringInfo str, void *obj)
case T_InnerIndexscanInfo:
_outInnerIndexscanInfo(str, obj);
break;
case T_FlattenedSubLink:
_outFlattenedSubLink(str, obj);
break;
case T_PlaceHolderVar:
_outPlaceHolderVar(str, obj);
break;