mirror of
https://github.com/postgres/postgres.git
synced 2025-11-21 00:42:43 +03:00
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.
This commit is contained in:
@@ -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:
|
||||
|
||||
@@ -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;
|
||||
|
||||
/* ----------------
|
||||
|
||||
Reference in New Issue
Block a user