aboutsummaryrefslogtreecommitdiff
path: root/src/include/parser
diff options
context:
space:
mode:
Diffstat (limited to 'src/include/parser')
-rw-r--r--src/include/parser/gramparse.h17
-rw-r--r--src/include/parser/parse_clause.h5
-rw-r--r--src/include/parser/parse_func.h10
-rw-r--r--src/include/parser/parse_node.h24
-rw-r--r--src/include/parser/parse_relation.h40
-rw-r--r--src/include/parser/parsetree.h31
6 files changed, 58 insertions, 69 deletions
diff --git a/src/include/parser/gramparse.h b/src/include/parser/gramparse.h
index 02c95745fee..54d6e869ad9 100644
--- a/src/include/parser/gramparse.h
+++ b/src/include/parser/gramparse.h
@@ -1,28 +1,31 @@
/*-------------------------------------------------------------------------
*
* gramparse.h
- * scanner support routines. used by both the bootstrap lexer
- * as well as the normal lexer
+ * Declarations for routines exported from lexer and parser files.
+ *
*
* Portions Copyright (c) 1996-2000, PostgreSQL, Inc
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: gramparse.h,v 1.12 2000/04/12 17:16:44 momjian Exp $
+ * $Id: gramparse.h,v 1.13 2000/09/12 21:07:12 tgl Exp $
*
*-------------------------------------------------------------------------
*/
#ifndef GRAMPARSE_H
-#define GRAMPARSE_H /* include once only */
+#define GRAMPARSE_H
-/* from scan.l */
-extern void init_io(void);
+/* from parser.c */
extern int yylex(void);
+
+/* from scan.l */
+extern void scanner_init(void);
+extern int base_yylex(void);
extern void yyerror(const char *message);
/* from gram.y */
-extern Oid param_type(int t);
extern void parser_init(Oid *typev, int nargs);
+extern Oid param_type(int t);
extern int yyparse(void);
#endif /* GRAMPARSE_H */
diff --git a/src/include/parser/parse_clause.h b/src/include/parser/parse_clause.h
index b9a868d4420..fd1cfdb3604 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.18 2000/06/09 01:44:29 momjian Exp $
+ * $Id: parse_clause.h,v 1.19 2000/09/12 21:07:12 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -17,7 +17,8 @@
#include "parser/parse_node.h"
extern void makeRangeTable(ParseState *pstate, List *frmList);
-extern void setTargetTable(ParseState *pstate, char *relname, bool inh);
+extern void setTargetTable(ParseState *pstate, char *relname,
+ bool inh, bool inJoinSet);
extern Node *transformWhereClause(ParseState *pstate, Node *where);
extern List *transformGroupClause(ParseState *pstate, List *grouplist,
List *targetlist);
diff --git a/src/include/parser/parse_func.h b/src/include/parser/parse_func.h
index be96652cfb2..d221c600c8e 100644
--- a/src/include/parser/parse_func.h
+++ b/src/include/parser/parse_func.h
@@ -7,7 +7,7 @@
* Portions Copyright (c) 1996-2000, PostgreSQL, Inc
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: parse_func.h,v 1.26 2000/08/20 00:44:17 tgl Exp $
+ * $Id: parse_func.h,v 1.27 2000/09/12 21:07:12 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -39,11 +39,11 @@ typedef struct _CandidateList
} *CandidateList;
extern Node *ParseNestedFuncOrColumn(ParseState *pstate, Attr *attr,
- int *curr_resno, int precedence);
+ int precedence);
extern Node *ParseFuncOrColumn(ParseState *pstate,
- char *funcname, List *fargs,
- bool agg_star, bool agg_distinct,
- int *curr_resno, int precedence);
+ char *funcname, List *fargs,
+ bool agg_star, bool agg_distinct,
+ int precedence);
extern bool func_get_detail(char *funcname, int nargs, Oid *argtypes,
Oid *funcid, Oid *rettype,
diff --git a/src/include/parser/parse_node.h b/src/include/parser/parse_node.h
index d4231e8819d..002391d6530 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.20 2000/05/12 01:33:52 tgl Exp $
+ * $Id: parse_node.h,v 1.21 2000/09/12 21:07:12 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -16,36 +16,28 @@
#include "nodes/parsenodes.h"
#include "utils/rel.h"
-/* State information used during parse analysis
- * p_join_quals is a list of untransformed qualification expressions
- * (implicitly ANDed together) found in the FROM clause.
- * Needs to be available later to merge with other qualifiers from the
- * WHERE clause.
+/*
+ * State information used during parse analysis
*/
typedef struct ParseState
{
- int p_last_resno;
- List *p_rtable;
- struct ParseState *parentParseState;
+ struct ParseState *parentParseState; /* stack link */
+ List *p_rtable; /* range table so far */
+ List *p_jointree; /* join tree so far */
+ int p_last_resno; /* last targetlist resno assigned */
bool p_hasAggs;
bool p_hasSubLinks;
bool p_is_insert;
bool p_is_update;
- bool p_is_rule;
- bool p_in_where_clause;
Relation p_target_relation;
RangeTblEntry *p_target_rangetblentry;
- List *p_shape;
- List *p_alias;
- List *p_join_quals;
} ParseState;
extern ParseState *make_parsestate(ParseState *parentParseState);
extern Expr *make_op(char *opname, Node *ltree, Node *rtree);
extern Node *make_operand(char *opname, Node *tree,
Oid orig_typeId, Oid target_typeId);
-extern Var *make_var(ParseState *pstate, Oid relid, char *refname,
- char *attrname);
+extern Var *make_var(ParseState *pstate, RangeTblEntry *rte, int attrno);
extern ArrayRef *transformArraySubscripts(ParseState *pstate,
Node *arrayBase,
List *indirection,
diff --git a/src/include/parser/parse_relation.h b/src/include/parser/parse_relation.h
index 4f89bcc65c3..7c7a04844e4 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.18 2000/06/08 22:37:53 momjian Exp $
+ * $Id: parse_relation.h,v 1.19 2000/09/12 21:07:12 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -16,23 +16,35 @@
#include "parser/parse_node.h"
-extern RangeTblEntry *refnameRangeTableEntry(ParseState *pstate, char *refname);
+extern Node *refnameRangeOrJoinEntry(ParseState *pstate,
+ char *refname,
+ int *sublevels_up);
+extern RangeTblEntry *refnameRangeTableEntry(ParseState *pstate,
+ char *refname);
extern int refnameRangeTablePosn(ParseState *pstate,
- char *refname,
- int *sublevels_up);
-extern RangeTblEntry *colnameRangeTableEntry(ParseState *pstate, char *colname);
+ char *refname,
+ int *sublevels_up);
+extern int RTERangeTablePosn(ParseState *pstate,
+ RangeTblEntry *rte,
+ int *sublevels_up);
+extern JoinExpr *scanJoinTreeForRefname(Node *jtnode, char *refname);
+extern Node *colnameToVar(ParseState *pstate, char *colname);
+extern Node *qualifiedNameToVar(ParseState *pstate, char *refname,
+ char *colname, bool implicitRTEOK);
extern RangeTblEntry *addRangeTableEntry(ParseState *pstate,
- 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);
+ char *relname,
+ Attr *alias,
+ bool inh,
+ bool inFromCl);
+extern void addRTEtoJoinTree(ParseState *pstate, RangeTblEntry *rte);
+extern RangeTblEntry *addImplicitRTE(ParseState *pstate, char *relname);
+extern void expandRTE(ParseState *pstate, RangeTblEntry *rte,
+ List **colnames, List **colvars);
+extern List *expandRelAttrs(ParseState *pstate, RangeTblEntry *rte);
+extern List *expandJoinAttrs(ParseState *pstate, JoinExpr *join,
+ int sublevels_up);
extern int attnameAttNum(Relation rd, char *a);
extern int specialAttNum(char *a);
extern Oid attnumTypeId(Relation rd, int attid);
-extern void warnAutoRange(ParseState *pstate, char *refname);
#endif /* PARSE_RELATION_H */
diff --git a/src/include/parser/parsetree.h b/src/include/parser/parsetree.h
index 277bc32a504..ff727cfd07a 100644
--- a/src/include/parser/parsetree.h
+++ b/src/include/parser/parsetree.h
@@ -8,41 +8,26 @@
* Portions Copyright (c) 1996-2000, PostgreSQL, Inc
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: parsetree.h,v 1.10 2000/06/12 19:40:51 momjian Exp $
+ * $Id: parsetree.h,v 1.11 2000/09/12 21:07:12 tgl Exp $
*
*-------------------------------------------------------------------------
*/
#ifndef PARSETREE_H
-#define PARSETREE_H /* include once only */
+#define PARSETREE_H
#include "nodes/parsenodes.h"
#include "nodes/pg_list.h"
/* ----------------
- * need pg_list.h for definitions of CAR(), etc. macros
+ * need pg_list.h for definitions of nth(), etc.
* ----------------
*/
/* ----------------
* range table macros
- *
- * parse tree:
- * (root targetlist qual)
- * ^^^^
- * parse root:
- * (numlevels cmdtype resrel rangetable priority ruleinfo nestdotinfo)
- * ^^^^^^^^^^
- * range table:
- * (rtentry ...)
- * rtentry:
* ----------------
*/
-#define rt_relname(rt_entry) \
- ((!strcmp(((rt_entry)->ref->relname),"*OLD*") ||\
- !strcmp(((rt_entry)->ref->relname),"*NEW*")) ? ((rt_entry)->ref->relname) : \
- ((char *)(rt_entry)->relname))
-
/*
* rt_fetch
* rt_store
@@ -51,22 +36,18 @@
*
*/
#define rt_fetch(rangetable_index, rangetable) \
- ((RangeTblEntry*)nth((rangetable_index)-1, rangetable))
+ ((RangeTblEntry*) nth((rangetable_index)-1, rangetable))
#define rt_store(rangetable_index, rangetable, rt) \
set_nth(rangetable, (rangetable_index)-1, rt)
/*
* getrelid
- * getrelname
*
* Given the range index of a relation, return the corresponding
- * relation id or relation name.
+ * relation OID.
*/
#define getrelid(rangeindex,rangetable) \
- ((RangeTblEntry*)nth((rangeindex)-1, rangetable))->relid
-
-#define getrelname(rangeindex, rangetable) \
- rt_relname((RangeTblEntry*)nth((rangeindex)-1, rangetable))
+ (rt_fetch(rangeindex, rangetable)->relid)
#endif /* PARSETREE_H */