diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2008-08-14 18:48:00 +0000 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2008-08-14 18:48:00 +0000 |
commit | e006a24ad152b3faec748afe8c1ff0829699b2e6 (patch) | |
tree | d00e01d25270b4b04aac3c723b9e440a56d8a085 /src/backend/nodes/copyfuncs.c | |
parent | ef1c807c25b47960aa86cd185fb74371e88d0cbf (diff) |
Implement SEMI and ANTI joins in the planner and executor. (Semijoins replace
the old JOIN_IN code, but antijoins are new functionality.) Teach the planner
to convert appropriate EXISTS and NOT EXISTS subqueries into semi and anti
joins respectively. Also, LEFT JOINs with suitable upper-level IS NULL
filters are recognized as being anti joins. Unify the InClauseInfo and
OuterJoinInfo infrastructure into "SpecialJoinInfo". With that change,
it becomes possible to associate a SpecialJoinInfo with every join attempt,
which permits some cleanup of join selectivity estimation. That needs to be
taken much further than this patch does, but the next step is to change the
API for oprjoin selectivity functions, which seems like material for a
separate patch. So for the moment the output size estimates for semi and
especially anti joins are quite bogus.
Diffstat (limited to 'src/backend/nodes/copyfuncs.c')
-rw-r--r-- | src/backend/nodes/copyfuncs.c | 49 |
1 files changed, 25 insertions, 24 deletions
diff --git a/src/backend/nodes/copyfuncs.c b/src/backend/nodes/copyfuncs.c index 90ebd7819a7..83322320b09 100644 --- a/src/backend/nodes/copyfuncs.c +++ b/src/backend/nodes/copyfuncs.c @@ -15,7 +15,7 @@ * Portions Copyright (c) 1994, Regents of the University of California * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/nodes/copyfuncs.c,v 1.399 2008/08/07 19:35:02 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/nodes/copyfuncs.c,v 1.400 2008/08/14 18:47:58 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -1444,36 +1444,37 @@ _copyRestrictInfo(RestrictInfo *from) } /* - * _copyOuterJoinInfo + * _copyFlattenedSubLink */ -static OuterJoinInfo * -_copyOuterJoinInfo(OuterJoinInfo *from) +static FlattenedSubLink * +_copyFlattenedSubLink(FlattenedSubLink *from) { - OuterJoinInfo *newnode = makeNode(OuterJoinInfo); + FlattenedSubLink *newnode = makeNode(FlattenedSubLink); - COPY_BITMAPSET_FIELD(min_lefthand); - COPY_BITMAPSET_FIELD(min_righthand); - COPY_BITMAPSET_FIELD(syn_lefthand); - COPY_BITMAPSET_FIELD(syn_righthand); - COPY_SCALAR_FIELD(is_full_join); - COPY_SCALAR_FIELD(lhs_strict); - COPY_SCALAR_FIELD(delay_upper_joins); + COPY_SCALAR_FIELD(jointype); + COPY_BITMAPSET_FIELD(lefthand); + COPY_BITMAPSET_FIELD(righthand); + COPY_NODE_FIELD(quals); return newnode; } /* - * _copyInClauseInfo + * _copySpecialJoinInfo */ -static InClauseInfo * -_copyInClauseInfo(InClauseInfo *from) +static SpecialJoinInfo * +_copySpecialJoinInfo(SpecialJoinInfo *from) { - InClauseInfo *newnode = makeNode(InClauseInfo); + SpecialJoinInfo *newnode = makeNode(SpecialJoinInfo); - COPY_BITMAPSET_FIELD(lefthand); - COPY_BITMAPSET_FIELD(righthand); - COPY_NODE_FIELD(sub_targetlist); - COPY_NODE_FIELD(in_operators); + COPY_BITMAPSET_FIELD(min_lefthand); + COPY_BITMAPSET_FIELD(min_righthand); + COPY_BITMAPSET_FIELD(syn_lefthand); + COPY_BITMAPSET_FIELD(syn_righthand); + COPY_SCALAR_FIELD(jointype); + COPY_SCALAR_FIELD(lhs_strict); + COPY_SCALAR_FIELD(delay_upper_joins); + COPY_NODE_FIELD(join_quals); return newnode; } @@ -3233,11 +3234,11 @@ copyObject(void *from) case T_RestrictInfo: retval = _copyRestrictInfo(from); break; - case T_OuterJoinInfo: - retval = _copyOuterJoinInfo(from); + case T_FlattenedSubLink: + retval = _copyFlattenedSubLink(from); break; - case T_InClauseInfo: - retval = _copyInClauseInfo(from); + case T_SpecialJoinInfo: + retval = _copySpecialJoinInfo(from); break; case T_AppendRelInfo: retval = _copyAppendRelInfo(from); |