diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2002-04-28 19:54:29 +0000 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2002-04-28 19:54:29 +0000 |
commit | 6c5988694218a62c6bc90fc625cbc64f732520cc (patch) | |
tree | cdc64472760a6ecbf73e2334bf23ae0767bf2f21 /src/include | |
parent | c8996f9c6bd82765849da85a9cde5de27f8cae79 (diff) |
Second try at fixing join alias variables. Instead of attaching miscellaneous
lists to join RTEs, attach a list of Vars and COALESCE expressions that will
replace the join's alias variables during planning. This simplifies
flatten_join_alias_vars while still making it easy to fix up varno references
when transforming the query tree. Add regression test cases for interactions
of subqueries with outer joins.
Diffstat (limited to 'src/include')
-rw-r--r-- | src/include/catalog/catversion.h | 4 | ||||
-rw-r--r-- | src/include/nodes/parsenodes.h | 17 | ||||
-rw-r--r-- | src/include/nodes/plannodes.h | 6 | ||||
-rw-r--r-- | src/include/optimizer/planmain.h | 4 | ||||
-rw-r--r-- | src/include/optimizer/var.h | 6 | ||||
-rw-r--r-- | src/include/parser/parse_relation.h | 7 |
6 files changed, 16 insertions, 28 deletions
diff --git a/src/include/catalog/catversion.h b/src/include/catalog/catversion.h index 6ebe79cc6a3..e135782bd58 100644 --- a/src/include/catalog/catversion.h +++ b/src/include/catalog/catversion.h @@ -37,7 +37,7 @@ * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: catversion.h,v 1.128 2002/04/27 21:24:34 tgl Exp $ + * $Id: catversion.h,v 1.129 2002/04/28 19:54:28 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -53,6 +53,6 @@ */ /* yyyymmddN */ -#define CATALOG_VERSION_NO 200204271 +#define CATALOG_VERSION_NO 200204281 #endif diff --git a/src/include/nodes/parsenodes.h b/src/include/nodes/parsenodes.h index 60703a06dcc..5bd0e89b185 100644 --- a/src/include/nodes/parsenodes.h +++ b/src/include/nodes/parsenodes.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: parsenodes.h,v 1.174 2002/04/24 02:48:55 momjian Exp $ + * $Id: parsenodes.h,v 1.175 2002/04/28 19:54:28 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -510,17 +510,14 @@ typedef struct RangeTblEntry /* * Fields valid for a join RTE (else NULL/zero): * - * joincoltypes/joincoltypmods identify the column datatypes of the - * join result. joinleftcols and joinrightcols identify the source - * columns from the join's inputs: each entry is either a source column - * AttrNumber or zero. For normal columns exactly one is nonzero, - * but both are nonzero for a column "merged" by USING or NATURAL. + * joinaliasvars is a list of Vars or COALESCE expressions corresponding + * to the columns of the join result. An alias Var referencing column + * K of the join result can be replaced by the K'th element of + * joinaliasvars --- but to simplify the task of reverse-listing aliases + * correctly, we do not do that until planning time. */ JoinType jointype; /* type of join */ - List *joincoltypes; /* integer list of column type OIDs */ - List *joincoltypmods; /* integer list of column typmods */ - List *joinleftcols; /* integer list of left-side column #s */ - List *joinrightcols; /* integer list of right-side column #s */ + List *joinaliasvars; /* list of alias-var expansions */ /* * Fields valid in all RTEs: diff --git a/src/include/nodes/plannodes.h b/src/include/nodes/plannodes.h index 66db9cf3640..9ba1caca327 100644 --- a/src/include/nodes/plannodes.h +++ b/src/include/nodes/plannodes.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: plannodes.h,v 1.54 2002/03/12 00:52:01 tgl Exp $ + * $Id: plannodes.h,v 1.55 2002/04/28 19:54:28 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -254,7 +254,6 @@ typedef struct SubqueryScan * jointype: rule for joining tuples from left and right subtrees * joinqual: qual conditions that came from JOIN/ON or JOIN/USING * (plan.qual contains conditions that came from WHERE) - * joinrti: rtable index of corresponding JOIN RTE, if any (0 if none) * * When jointype is INNER, joinqual and plan.qual are semantically * interchangeable. For OUTER jointypes, the two are *not* interchangeable; @@ -263,8 +262,6 @@ typedef struct SubqueryScan * (But plan.qual is still applied before actually returning a tuple.) * For an outer join, only joinquals are allowed to be used as the merge * or hash condition of a merge or hash join. - * - * joinrti is for the convenience of setrefs.c; it's not used in execution. * ---------------- */ typedef struct Join @@ -272,7 +269,6 @@ typedef struct Join Plan plan; JoinType jointype; List *joinqual; /* JOIN quals (in addition to plan.qual) */ - Index joinrti; /* JOIN RTE, if any */ } Join; /* ---------------- diff --git a/src/include/optimizer/planmain.h b/src/include/optimizer/planmain.h index 919f3d23de4..3956555a2e0 100644 --- a/src/include/optimizer/planmain.h +++ b/src/include/optimizer/planmain.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: planmain.h,v 1.55 2002/03/12 00:52:03 tgl Exp $ + * $Id: planmain.h,v 1.56 2002/04/28 19:54:28 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -59,7 +59,7 @@ extern void process_implied_equality(Query *root, Node *item1, Node *item2, extern void set_plan_references(Query *root, Plan *plan); extern List *join_references(List *clauses, Query *root, List *outer_tlist, List *inner_tlist, - Index acceptable_rel, Index join_rti); + Index acceptable_rel); extern void fix_opids(Node *node); /* diff --git a/src/include/optimizer/var.h b/src/include/optimizer/var.h index 1153604e48a..c9a22b8f55a 100644 --- a/src/include/optimizer/var.h +++ b/src/include/optimizer/var.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: var.h,v 1.18 2002/03/12 00:52:04 tgl Exp $ + * $Id: var.h,v 1.19 2002/04/28 19:54:28 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -23,8 +23,6 @@ extern bool contain_var_reference(Node *node, int varno, int varattno, extern bool contain_whole_tuple_var(Node *node, int varno, int levelsup); extern bool contain_var_clause(Node *node); extern List *pull_var_clause(Node *node, bool includeUpperVars); -extern Node *flatten_join_alias_vars(Node *node, Query *root, int expandRTI); -extern void build_join_alias_subvars(Query *root, Var *aliasvar, - Var **leftsubvar, Var **rightsubvar); +extern Node *flatten_join_alias_vars(Node *node, Query *root, bool force); #endif /* VAR_H */ diff --git a/src/include/parser/parse_relation.h b/src/include/parser/parse_relation.h index 038931d9b6d..353ce8957c7 100644 --- a/src/include/parser/parse_relation.h +++ b/src/include/parser/parse_relation.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: parse_relation.h,v 1.31 2002/03/22 02:56:37 tgl Exp $ + * $Id: parse_relation.h,v 1.32 2002/04/28 19:54:29 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -44,10 +44,7 @@ extern RangeTblEntry *addRangeTableEntryForSubquery(ParseState *pstate, extern RangeTblEntry *addRangeTableEntryForJoin(ParseState *pstate, List *colnames, JoinType jointype, - List *coltypes, - List *coltypmods, - List *leftcols, - List *rightcols, + List *aliasvars, Alias *alias, bool inFromCl); extern void addRTEtoQuery(ParseState *pstate, RangeTblEntry *rte, |