summaryrefslogtreecommitdiff
path: root/src/include
diff options
context:
space:
mode:
authorThomas G. Lockhart2000-02-15 03:38:29 +0000
committerThomas G. Lockhart2000-02-15 03:38:29 +0000
commita344a6e7b5d7b2b87f33a155c3ef88bdfdce3fd8 (patch)
tree78c19baad416cfe014237bc726baff63aff2b150 /src/include
parent92c8437d8de8efeb5324fcccb0175beec8e66619 (diff)
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.
Diffstat (limited to 'src/include')
-rw-r--r--src/include/nodes/makefuncs.h5
-rw-r--r--src/include/nodes/parsenodes.h18
-rw-r--r--src/include/parser/parse_clause.h7
-rw-r--r--src/include/parser/parse_node.h11
-rw-r--r--src/include/parser/parse_relation.h21
-rw-r--r--src/include/parser/parsetree.h6
6 files changed, 42 insertions, 26 deletions
diff --git a/src/include/nodes/makefuncs.h b/src/include/nodes/makefuncs.h
index 2b3c5339c61..f934eb5e63a 100644
--- a/src/include/nodes/makefuncs.h
+++ b/src/include/nodes/makefuncs.h
@@ -7,7 +7,7 @@
* Portions Copyright (c) 1996-2000, PostgreSQL, Inc
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: makefuncs.h,v 1.22 2000/01/26 05:58:16 momjian Exp $
+ * $Id: makefuncs.h,v 1.23 2000/02/15 03:38:13 thomas Exp $
*
*-------------------------------------------------------------------------
*/
@@ -46,4 +46,7 @@ extern Const *makeConst(Oid consttype,
bool constisset,
bool constiscast);
+extern Attr *
+makeAttr(char *relname, char *attname);
+
#endif /* MAKEFUNC_H */
diff --git a/src/include/nodes/parsenodes.h b/src/include/nodes/parsenodes.h
index 288e7f96b8d..6eb47618c5e 100644
--- a/src/include/nodes/parsenodes.h
+++ b/src/include/nodes/parsenodes.h
@@ -7,7 +7,7 @@
* Portions Copyright (c) 1996-2000, PostgreSQL, Inc
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: parsenodes.h,v 1.97 2000/01/27 18:11:44 tgl Exp $
+ * $Id: parsenodes.h,v 1.98 2000/02/15 03:38:14 thomas Exp $
*
*-------------------------------------------------------------------------
*/
@@ -1031,7 +1031,7 @@ typedef struct RangeVar
{
NodeTag type;
RelExpr *relExpr; /* the relation expression */
- char *name; /* the name to be referenced (optional) */
+ Attr *name; /* the name to be referenced (optional) */
} RangeVar;
/*
@@ -1064,9 +1064,11 @@ typedef struct JoinExpr
{
NodeTag type;
int jointype;
- RangeVar *larg;
- Node *rarg;
- List *quals;
+ bool isNatural; /* Natural join? Will need to shape table */
+ Node *larg; /* RangeVar or join expression */
+ Node *rarg; /* RangeVar or join expression */
+ Attr *alias; /* table and column aliases, if any */
+ List *quals; /* qualifiers on join, if any */
} JoinExpr;
@@ -1122,8 +1124,10 @@ typedef struct RangeTblEntry
{
NodeTag type;
char *relname; /* real name of the relation */
- char *refname; /* the reference name (as specified in the
- * FROM clause) */
+// char *refname; /* reference name (given in FROM clause) */
+#ifndef DISABLE_JOIN_SYNTAX
+ Attr *ref; /* reference names (given in FROM clause) */
+#endif
Oid relid; /* OID of the relation */
bool inh; /* inheritance requested? */
bool inFromCl; /* present in FROM clause */
diff --git a/src/include/parser/parse_clause.h b/src/include/parser/parse_clause.h
index 235a02bc4c2..58b8fc60fa4 100644
--- a/src/include/parser/parse_clause.h
+++ b/src/include/parser/parse_clause.h
@@ -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,
diff --git a/src/include/parser/parse_node.h b/src/include/parser/parse_node.h
index 4ba502ebaf3..16641b530a2 100644
--- a/src/include/parser/parse_node.h
+++ b/src/include/parser/parse_node.h
@@ -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);
diff --git a/src/include/parser/parse_relation.h b/src/include/parser/parse_relation.h
index b9fe0b1b778..5ba5db3f9d0 100644
--- a/src/include/parser/parse_relation.h
+++ b/src/include/parser/parse_relation.h
@@ -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);
diff --git a/src/include/parser/parsetree.h b/src/include/parser/parsetree.h
index 979ebf327e8..3f5e09cc1df 100644
--- a/src/include/parser/parsetree.h
+++ b/src/include/parser/parsetree.h
@@ -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))
/*