Carry column aliases from the parser frontend. Enables queries like

SELECT a FROM t1 tx (a);
Allow join syntax, including queries like
  SELECT * FROM t1 NATURAL JOIN t2;
Update RTE structure to hold column aliases in an Attr structure.
This commit is contained in:
Thomas G. Lockhart
2000-02-15 03:38:29 +00:00
parent 92c8437d8d
commit a344a6e7b5
27 changed files with 1102 additions and 324 deletions

View File

@ -7,7 +7,7 @@
* Portions Copyright (c) 1996-2000, PostgreSQL, Inc
* Portions Copyright (c) 1994, Regents of the University of California
*
* $Id: parse_clause.h,v 1.15 2000/01/27 18:11:47 tgl Exp $
* $Id: parse_clause.h,v 1.16 2000/02/15 03:38:28 thomas Exp $
*
*-------------------------------------------------------------------------
*/
@ -16,10 +16,9 @@
#include "parser/parse_node.h"
extern void makeRangeTable(ParseState *pstate, List *frmList, Node **qual);
extern void makeRangeTable(ParseState *pstate, List *frmList);
extern void setTargetTable(ParseState *pstate, char *relname);
extern Node *transformWhereClause(ParseState *pstate, Node *where,
Node *using);
extern Node *transformWhereClause(ParseState *pstate, Node *where);
extern List *transformGroupClause(ParseState *pstate, List *grouplist,
List *targetlist);
extern List *transformSortClause(ParseState *pstate, List *orderlist,

View File

@ -6,7 +6,7 @@
* Portions Copyright (c) 1996-2000, PostgreSQL, Inc
* Portions Copyright (c) 1994, Regents of the University of California
*
* $Id: parse_node.h,v 1.17 2000/01/26 05:58:27 momjian Exp $
* $Id: parse_node.h,v 1.18 2000/02/15 03:38:29 thomas Exp $
*
*-------------------------------------------------------------------------
*/
@ -16,7 +16,11 @@
#include "nodes/parsenodes.h"
#include "utils/rel.h"
/* state information used during parse analysis */
/* State information used during parse analysis
* p_join_quals is a list of qualification expressions
* found in the FROM clause. Needs to be available later
* to merge with other qualifiers from the WHERE clause.
*/
typedef struct ParseState
{
int p_last_resno;
@ -30,6 +34,9 @@ typedef struct ParseState
bool p_in_where_clause;
Relation p_target_relation;
RangeTblEntry *p_target_rangetblentry;
List *p_shape;
List *p_alias;
Node *p_join_quals;
} ParseState;
extern ParseState *make_parsestate(ParseState *parentParseState);

View File

@ -7,7 +7,7 @@
* Portions Copyright (c) 1996-2000, PostgreSQL, Inc
* Portions Copyright (c) 1994, Regents of the University of California
*
* $Id: parse_relation.h,v 1.14 2000/01/26 05:58:27 momjian Exp $
* $Id: parse_relation.h,v 1.15 2000/02/15 03:38:29 thomas Exp $
*
*-------------------------------------------------------------------------
*/
@ -18,17 +18,20 @@
extern RangeTblEntry *refnameRangeTableEntry(ParseState *pstate, char *refname);
extern int refnameRangeTablePosn(ParseState *pstate,
char *refname, int *sublevels_up);
char *refname,
int *sublevels_up);
extern RangeTblEntry *colnameRangeTableEntry(ParseState *pstate, char *colname);
extern RangeTblEntry *addRangeTableEntry(ParseState *pstate,
char *relname,
char *refname,
bool inh,
bool inFromCl,
bool inJoinSet);
extern List *expandAll(ParseState *pstate, char *relname, char *refname,
int *this_resno);
char *relname,
Attr *ref,
bool inh,
bool inFromCl,
bool inJoinSet);
extern Attr *expandTable(ParseState *pstate, char *refname, bool getaliases);
extern List *expandAll(ParseState *pstate, char *relname, Attr *ref,
int *this_resno);
extern int attnameAttNum(Relation rd, char *a);
extern int specialAttNum(char *a);
extern bool attnameIsSet(Relation rd, char *name);
extern int attnumAttNelems(Relation rd, int attid);
extern Oid attnumTypeId(Relation rd, int attid);

View File

@ -8,7 +8,7 @@
* Portions Copyright (c) 1996-2000, PostgreSQL, Inc
* Portions Copyright (c) 1994, Regents of the University of California
*
* $Id: parsetree.h,v 1.8 2000/01/26 05:58:27 momjian Exp $
* $Id: parsetree.h,v 1.9 2000/02/15 03:38:29 thomas Exp $
*
*-------------------------------------------------------------------------
*/
@ -39,8 +39,8 @@
*/
#define rt_relname(rt_entry) \
((!strcmp(((rt_entry)->refname),"*CURRENT*") ||\
!strcmp(((rt_entry)->refname),"*NEW*")) ? ((rt_entry)->refname) : \
((!strcmp(((rt_entry)->ref->relname),"*CURRENT*") ||\
!strcmp(((rt_entry)->ref->relname),"*NEW*")) ? ((rt_entry)->ref->relname) : \
((char *)(rt_entry)->relname))
/*