1
0
mirror of https://github.com/postgres/postgres.git synced 2025-11-07 19:06:32 +03:00

Extend the parser location infrastructure to include a location field in

most node types used in expression trees (both before and after parse
analysis).  This allows us to place an error cursor in many situations
where we formerly could not, because the information wasn't available
beyond the very first level of parse analysis.  There's a fair amount
of work still to be done to persuade individual ereport() calls to actually
include an error location, but this gets the initdb-forcing part of the
work out of the way; and the situation is already markedly better than
before for complaints about unimplementable implicit casts, such as
CASE and UNION constructs with incompatible alternative data types.
Per my proposal of a few days ago.
This commit is contained in:
Tom Lane
2008-08-28 23:09:48 +00:00
parent 6734182c16
commit a2794623d2
44 changed files with 1295 additions and 502 deletions

View File

@@ -3,11 +3,17 @@
* parsenodes.h
* definitions for parse tree nodes
*
* Many of the node types used in parsetrees include a "location" field.
* This is a byte (not character) offset in the original source text, to be
* used for positioning an error cursor when there is an error related to
* the node. Access to the original source text is needed to make use of
* the location.
*
*
* 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.371 2008/08/07 01:11:51 tgl Exp $
* $PostgreSQL: pgsql/src/include/nodes/parsenodes.h,v 1.372 2008/08/28 23:09:48 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -141,11 +147,6 @@ typedef struct Query
* Most of these node types appear in raw parsetrees output by the grammar,
* and get transformed to something else by the analyzer. A few of them
* are used as-is in transformed querytrees.
*
* Many of the node types used in raw parsetrees include a "location" field.
* This is a byte (not character) offset in the original source text, to be
* used for positioning an error cursor when there is an analysis-time
* error related to the node.
****************************************************************************/
/*
@@ -199,6 +200,7 @@ typedef struct ParamRef
{
NodeTag type;
int number; /* the number of the parameter */
int location; /* token location, or -1 if unknown */
} ParamRef;
/*
@@ -235,6 +237,7 @@ typedef struct A_Const
{
NodeTag type;
Value val; /* value (includes type info, see value.h) */
int location; /* token location, or -1 if unknown */
} A_Const;
/*
@@ -245,6 +248,7 @@ typedef struct TypeCast
NodeTag type;
Node *arg; /* the expression being casted */
TypeName *typename; /* the target type */
int location; /* token location, or -1 if unknown */
} TypeCast;
/*
@@ -305,6 +309,7 @@ typedef struct A_ArrayExpr
{
NodeTag type;
List *elements; /* array element expressions */
int location; /* token location, or -1 if unknown */
} A_ArrayExpr;
/*
@@ -459,14 +464,15 @@ typedef struct LockingClause
} LockingClause;
/*
* XMLSERIALIZE
* XMLSERIALIZE (in raw parse tree only)
*/
typedef struct XmlSerialize
{
NodeTag type;
XmlOptionType xmloption;
XmlOptionType xmloption; /* DOCUMENT or CONTENT */
Node *expr;
TypeName *typename;
int location; /* token location, or -1 if unknown */
} XmlSerialize;