1
0
mirror of https://github.com/postgres/postgres.git synced 2025-10-27 00:12:01 +03:00

Restructure representation of join alias variables. An explicit JOIN

now has an RTE of its own, and references to its outputs now are Vars
referencing the JOIN RTE, rather than CASE-expressions.  This allows
reverse-listing in ruleutils.c to use the correct alias easily, rather
than painfully reverse-engineering the alias namespace as it used to do.
Also, nested FULL JOINs work correctly, because the result of the inner
joins are simple Vars that the planner can cope with.  This fixes a bug
reported a couple times now, notably by Tatsuo on 18-Nov-01.  The alias
Vars are expanded into COALESCE expressions where needed at the very end
of planning, rather than during parsing.
Also, beginnings of support for showing plan qualifier expressions in
EXPLAIN.  There are probably still cases that need work.
initdb forced due to change of stored-rule representation.
This commit is contained in:
Tom Lane
2002-03-12 00:52:10 +00:00
parent 66b6bf67a1
commit 6eeb95f0f5
41 changed files with 1950 additions and 996 deletions

View File

@@ -7,7 +7,7 @@
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
* $Id: pathnode.h,v 1.41 2001/11/05 17:46:34 momjian Exp $
* $Id: pathnode.h,v 1.42 2002/03/12 00:52:03 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -67,9 +67,11 @@ extern HashPath *create_hashjoin_path(Query *root,
/*
* prototypes for relnode.c
*/
extern RelOptInfo *build_base_rel(Query *root, int relid);
extern void build_base_rel(Query *root, int relid);
extern RelOptInfo *build_other_rel(Query *root, int relid);
extern RelOptInfo *find_base_rel(Query *root, int relid);
extern RelOptInfo *find_other_rel(Query *root, int relid);
extern RelOptInfo *find_other_rel_for_join(Query *root, List *relids);
extern RelOptInfo *build_join_rel(Query *root,
RelOptInfo *outer_rel,
RelOptInfo *inner_rel,

View File

@@ -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.54 2001/11/05 17:46:34 momjian Exp $
* $Id: planmain.h,v 1.55 2002/03/12 00:52:03 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -47,18 +47,19 @@ extern Result *make_result(List *tlist, Node *resconstantqual, Plan *subplan);
/*
* prototypes for plan/initsplan.c
*/
extern List *add_base_rels_to_query(Query *root, Node *jtnode);
extern void build_base_rel_tlists(Query *root, List *tlist);
extern Relids distribute_quals_to_rels(Query *root, Node *jtnode);
extern List *add_missing_rels_to_query(Query *root, Node *jtnode);
extern void process_implied_equality(Query *root, Node *item1, Node *item2,
Oid sortop1, Oid sortop2);
/*
* prototypes for plan/setrefs.c
*/
extern void set_plan_references(Plan *plan);
extern List *join_references(List *clauses, List *outer_tlist,
List *inner_tlist, Index acceptable_rel);
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);
extern void fix_opids(Node *node);
/*

View File

@@ -7,14 +7,15 @@
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
* $Id: var.h,v 1.17 2001/11/05 17:46:34 momjian Exp $
* $Id: var.h,v 1.18 2002/03/12 00:52:04 tgl Exp $
*
*-------------------------------------------------------------------------
*/
#ifndef VAR_H
#define VAR_H
#include "nodes/primnodes.h"
#include "nodes/parsenodes.h"
extern List *pull_varnos(Node *node);
extern bool contain_var_reference(Node *node, int varno, int varattno,
@@ -22,5 +23,8 @@ 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);
#endif /* VAR_H */