summaryrefslogtreecommitdiff
path: root/src/include
diff options
context:
space:
mode:
authorTom Lane2008-09-01 20:42:46 +0000
committerTom Lane2008-09-01 20:42:46 +0000
commitb153c0920960a6059b67969469166fb29c0105d7 (patch)
tree4e7100ecdca88746c369ae2a6a43468925f3194d /src/include
parent9ac4299163247645c6e391f5f65735c6cb78ccb9 (diff)
Add a bunch of new error location reports to parse-analysis error messages.
There are still some weak spots around JOIN USING and relation alias lists, but most errors reported within backend/parser/ now have locations.
Diffstat (limited to 'src/include')
-rw-r--r--src/include/catalog/catversion.h4
-rw-r--r--src/include/nodes/makefuncs.h4
-rw-r--r--src/include/nodes/parsenodes.h17
-rw-r--r--src/include/nodes/primnodes.h3
-rw-r--r--src/include/optimizer/var.h7
-rw-r--r--src/include/parser/gramparse.h3
-rw-r--r--src/include/parser/parse_node.h17
-rw-r--r--src/include/parser/parse_relation.h12
-rw-r--r--src/include/rewrite/rewriteManip.h3
-rw-r--r--src/include/utils/elog.h3
10 files changed, 47 insertions, 26 deletions
diff --git a/src/include/catalog/catversion.h b/src/include/catalog/catversion.h
index 8e287a80db1..ecf10048384 100644
--- a/src/include/catalog/catversion.h
+++ b/src/include/catalog/catversion.h
@@ -37,7 +37,7 @@
* Portions Copyright (c) 1996-2008, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $PostgreSQL: pgsql/src/include/catalog/catversion.h,v 1.481 2008/08/28 23:09:48 tgl Exp $
+ * $PostgreSQL: pgsql/src/include/catalog/catversion.h,v 1.482 2008/09/01 20:42:45 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -53,6 +53,6 @@
*/
/* yyyymmddN */
-#define CATALOG_VERSION_NO 200808281
+#define CATALOG_VERSION_NO 200808311
#endif
diff --git a/src/include/nodes/makefuncs.h b/src/include/nodes/makefuncs.h
index d8ffa442247..d4e58cfe5f3 100644
--- a/src/include/nodes/makefuncs.h
+++ b/src/include/nodes/makefuncs.h
@@ -7,7 +7,7 @@
* Portions Copyright (c) 1996-2008, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $PostgreSQL: pgsql/src/include/nodes/makefuncs.h,v 1.62 2008/08/28 23:09:48 tgl Exp $
+ * $PostgreSQL: pgsql/src/include/nodes/makefuncs.h,v 1.63 2008/09/01 20:42:45 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -56,7 +56,7 @@ extern Alias *makeAlias(const char *aliasname, List *colnames);
extern RelabelType *makeRelabelType(Expr *arg, Oid rtype, int32 rtypmod,
CoercionForm rformat);
-extern RangeVar *makeRangeVar(char *schemaname, char *relname);
+extern RangeVar *makeRangeVar(char *schemaname, char *relname, int location);
extern TypeName *makeTypeName(char *typnam);
extern TypeName *makeTypeNameFromNameList(List *names);
diff --git a/src/include/nodes/parsenodes.h b/src/include/nodes/parsenodes.h
index 7eea3175896..2a4f6f1421a 100644
--- a/src/include/nodes/parsenodes.h
+++ b/src/include/nodes/parsenodes.h
@@ -13,7 +13,7 @@
* Portions Copyright (c) 1996-2008, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $PostgreSQL: pgsql/src/include/nodes/parsenodes.h,v 1.373 2008/08/30 01:39:14 tgl Exp $
+ * $PostgreSQL: pgsql/src/include/nodes/parsenodes.h,v 1.374 2008/09/01 20:42:45 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -358,10 +358,11 @@ typedef struct ResTarget
typedef struct SortBy
{
NodeTag type;
- SortByDir sortby_dir; /* ASC/DESC/USING */
+ Node *node; /* expression to sort on */
+ SortByDir sortby_dir; /* ASC/DESC/USING/default */
SortByNulls sortby_nulls; /* NULLS FIRST/LAST */
List *useOp; /* name of op to use, if SORTBY_USING */
- Node *node; /* expression to sort on */
+ int location; /* operator location, or -1 if none/unknown */
} SortBy;
/*
@@ -466,7 +467,9 @@ typedef struct DefElem
* LockingClause - raw representation of FOR UPDATE/SHARE options
*
* Note: lockedRels == NIL means "all relations in query". Otherwise it
- * is a list of String nodes giving relation eref names.
+ * is a list of RangeVar nodes. (We use RangeVar mainly because it carries
+ * a location field --- currently, parse analysis insists on unqualified
+ * names in LockingClause.)
*/
typedef struct LockingClause
{
@@ -1742,7 +1745,7 @@ typedef struct RuleStmt
typedef struct NotifyStmt
{
NodeTag type;
- RangeVar *relation; /* qualified name to notify */
+ char *conditionname; /* condition name to notify */
} NotifyStmt;
/* ----------------------
@@ -1752,7 +1755,7 @@ typedef struct NotifyStmt
typedef struct ListenStmt
{
NodeTag type;
- RangeVar *relation; /* name to listen on */
+ char *conditionname; /* condition name to listen on */
} ListenStmt;
/* ----------------------
@@ -1762,7 +1765,7 @@ typedef struct ListenStmt
typedef struct UnlistenStmt
{
NodeTag type;
- RangeVar *relation; /* name to unlisten on, or NULL for all */
+ char *conditionname; /* name to unlisten on, or NULL for all */
} UnlistenStmt;
/* ----------------------
diff --git a/src/include/nodes/primnodes.h b/src/include/nodes/primnodes.h
index e4de091a751..e144251dd1c 100644
--- a/src/include/nodes/primnodes.h
+++ b/src/include/nodes/primnodes.h
@@ -10,7 +10,7 @@
* Portions Copyright (c) 1996-2008, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $PostgreSQL: pgsql/src/include/nodes/primnodes.h,v 1.140 2008/08/28 23:09:48 tgl Exp $
+ * $PostgreSQL: pgsql/src/include/nodes/primnodes.h,v 1.141 2008/09/01 20:42:45 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -76,6 +76,7 @@ typedef struct RangeVar
* on children? */
bool istemp; /* is this a temp relation/sequence? */
Alias *alias; /* table alias & optional column aliases */
+ int location; /* token location, or -1 if unknown */
} RangeVar;
/*
diff --git a/src/include/optimizer/var.h b/src/include/optimizer/var.h
index b0980b5e7d5..4a8f84e5532 100644
--- a/src/include/optimizer/var.h
+++ b/src/include/optimizer/var.h
@@ -7,7 +7,7 @@
* Portions Copyright (c) 1996-2008, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $PostgreSQL: pgsql/src/include/optimizer/var.h,v 1.37 2008/01/01 19:45:58 momjian Exp $
+ * $PostgreSQL: pgsql/src/include/optimizer/var.h,v 1.38 2008/09/01 20:42:45 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -19,11 +19,10 @@
extern Relids pull_varnos(Node *node);
extern void pull_varattnos(Node *node, Bitmapset **varattnos);
-extern bool contain_var_reference(Node *node, int varno, int varattno,
- int levelsup);
extern bool contain_var_clause(Node *node);
extern bool contain_vars_of_level(Node *node, int levelsup);
-extern bool contain_vars_above_level(Node *node, int levelsup);
+extern int locate_var_of_level(Node *node, int levelsup);
+extern int locate_var_of_relation(Node *node, int relid, int levelsup);
extern int find_minimum_var_level(Node *node);
extern List *pull_var_clause(Node *node, bool includeUpperVars);
extern Node *flatten_join_alias_vars(PlannerInfo *root, Node *node);
diff --git a/src/include/parser/gramparse.h b/src/include/parser/gramparse.h
index 6bb87c67515..e99f0017cbc 100644
--- a/src/include/parser/gramparse.h
+++ b/src/include/parser/gramparse.h
@@ -7,7 +7,7 @@
* Portions Copyright (c) 1996-2008, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $PostgreSQL: pgsql/src/include/parser/gramparse.h,v 1.41 2008/04/04 11:47:19 mha Exp $
+ * $PostgreSQL: pgsql/src/include/parser/gramparse.h,v 1.42 2008/09/01 20:42:45 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -47,6 +47,7 @@ extern int filtered_base_yylex(void);
extern void scanner_init(const char *str);
extern void scanner_finish(void);
extern int base_yylex(void);
+extern int scanner_errposition(int location);
extern void base_yyerror(const char *message);
/* from gram.y */
diff --git a/src/include/parser/parse_node.h b/src/include/parser/parse_node.h
index fa6b14d4d3a..460655d3b14 100644
--- a/src/include/parser/parse_node.h
+++ b/src/include/parser/parse_node.h
@@ -7,7 +7,7 @@
* Portions Copyright (c) 1996-2008, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $PostgreSQL: pgsql/src/include/parser/parse_node.h,v 1.55 2008/08/28 23:09:48 tgl Exp $
+ * $PostgreSQL: pgsql/src/include/parser/parse_node.h,v 1.56 2008/09/01 20:42:45 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -82,10 +82,23 @@ typedef struct ParseState
RangeTblEntry *p_target_rangetblentry;
} ParseState;
+/* Support for parser_errposition_callback function */
+typedef struct ParseCallbackState
+{
+ ParseState *pstate;
+ int location;
+ ErrorContextCallback errcontext;
+} ParseCallbackState;
+
+
extern ParseState *make_parsestate(ParseState *parentParseState);
extern void free_parsestate(ParseState *pstate);
extern int parser_errposition(ParseState *pstate, int location);
+extern void setup_parser_errposition_callback(ParseCallbackState *pcbstate,
+ ParseState *pstate, int location);
+extern void cancel_parser_errposition_callback(ParseCallbackState *pcbstate);
+
extern Var *make_var(ParseState *pstate, RangeTblEntry *rte, int attrno,
int location);
extern Oid transformArrayType(Oid arrayType);
@@ -96,6 +109,6 @@ extern ArrayRef *transformArraySubscripts(ParseState *pstate,
int32 elementTypMod,
List *indirection,
Node *assignFrom);
-extern Const *make_const(Value *value, int location);
+extern Const *make_const(ParseState *pstate, Value *value, int location);
#endif /* PARSE_NODE_H */
diff --git a/src/include/parser/parse_relation.h b/src/include/parser/parse_relation.h
index 04889541e70..1c4e1b6b8ed 100644
--- a/src/include/parser/parse_relation.h
+++ b/src/include/parser/parse_relation.h
@@ -7,7 +7,7 @@
* Portions Copyright (c) 1996-2008, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $PostgreSQL: pgsql/src/include/parser/parse_relation.h,v 1.57 2008/01/01 19:45:58 momjian Exp $
+ * $PostgreSQL: pgsql/src/include/parser/parse_relation.h,v 1.58 2008/09/01 20:42:45 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -21,6 +21,7 @@ extern bool add_missing_from;
extern RangeTblEntry *refnameRangeTblEntry(ParseState *pstate,
const char *schemaname,
const char *refname,
+ int location,
int *sublevels_up);
extern void checkNameSpaceConflicts(ParseState *pstate, List *namespace1,
List *namespace2);
@@ -40,6 +41,8 @@ extern Node *qualifiedNameToVar(ParseState *pstate,
char *colname,
bool implicitRTEOK,
int location);
+extern Relation parserOpenTable(ParseState *pstate, const RangeVar *relation,
+ int lockmode);
extern RangeTblEntry *addRangeTableEntry(ParseState *pstate,
RangeVar *relation,
Alias *alias,
@@ -72,13 +75,12 @@ extern RangeTblEntry *addRangeTableEntryForJoin(ParseState *pstate,
extern void addRTEtoQuery(ParseState *pstate, RangeTblEntry *rte,
bool addToJoinList,
bool addToRelNameSpace, bool addToVarNameSpace);
-extern RangeTblEntry *addImplicitRTE(ParseState *pstate, RangeVar *relation,
- int location);
+extern RangeTblEntry *addImplicitRTE(ParseState *pstate, RangeVar *relation);
extern void expandRTE(RangeTblEntry *rte, int rtindex, int sublevels_up,
- bool include_dropped,
+ int location, bool include_dropped,
List **colnames, List **colvars);
extern List *expandRelAttrs(ParseState *pstate, RangeTblEntry *rte,
- int rtindex, int sublevels_up);
+ int rtindex, int sublevels_up, int location);
extern int attnameAttNum(Relation rd, const char *attname, bool sysColOK);
extern Name attnumAttName(Relation rd, int attid);
extern Oid attnumTypeId(Relation rd, int attid);
diff --git a/src/include/rewrite/rewriteManip.h b/src/include/rewrite/rewriteManip.h
index a870ce889b0..50b4443de0d 100644
--- a/src/include/rewrite/rewriteManip.h
+++ b/src/include/rewrite/rewriteManip.h
@@ -7,7 +7,7 @@
* Portions Copyright (c) 1996-2008, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $PostgreSQL: pgsql/src/include/rewrite/rewriteManip.h,v 1.46 2008/08/22 00:16:04 tgl Exp $
+ * $PostgreSQL: pgsql/src/include/rewrite/rewriteManip.h,v 1.47 2008/09/01 20:42:45 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -36,6 +36,7 @@ extern void AddQual(Query *parsetree, Node *qual);
extern void AddInvertedQual(Query *parsetree, Node *qual);
extern bool contain_aggs_of_level(Node *node, int levelsup);
+extern int locate_agg_of_level(Node *node, int levelsup);
extern bool checkExprHasAggs(Node *node);
extern bool checkExprHasSubLink(Node *node);
diff --git a/src/include/utils/elog.h b/src/include/utils/elog.h
index b7777e8f5f9..034fd420b51 100644
--- a/src/include/utils/elog.h
+++ b/src/include/utils/elog.h
@@ -7,7 +7,7 @@
* Portions Copyright (c) 1996-2008, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $PostgreSQL: pgsql/src/include/utils/elog.h,v 1.93 2008/04/16 23:59:40 tgl Exp $
+ * $PostgreSQL: pgsql/src/include/utils/elog.h,v 1.94 2008/09/01 20:42:45 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -151,6 +151,7 @@ extern int errposition(int cursorpos);
extern int internalerrposition(int cursorpos);
extern int internalerrquery(const char *query);
+extern int geterrcode(void);
extern int geterrposition(void);
extern int getinternalerrposition(void);