diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2006-03-14 22:48:25 +0000 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2006-03-14 22:48:25 +0000 |
commit | 20ab467d76d78271006818d2baf4c9c8658d1f38 (patch) | |
tree | 7a536111b5cc4e494ac75558aad5655dfc8ab964 /src/backend/nodes/makefuncs.c | |
parent | 48fb696753e267447f99914c7968d0b4ffb5c5dc (diff) |
Improve parser so that we can show an error cursor position for errors
during parse analysis, not only errors detected in the flex/bison stages.
This is per my earlier proposal. This commit includes all the basic
infrastructure, but locations are only tracked and reported for errors
involving column references, function calls, and operators. More could
be done later but this seems like a good set to start with. I've also
moved the ReportSyntaxErrorPosition logic out of psql and into libpq,
which should make it available to more people --- even within psql this
is an improvement because warnings weren't handled by ReportSyntaxErrorPosition.
Diffstat (limited to 'src/backend/nodes/makefuncs.c')
-rw-r--r-- | src/backend/nodes/makefuncs.c | 44 |
1 files changed, 41 insertions, 3 deletions
diff --git a/src/backend/nodes/makefuncs.c b/src/backend/nodes/makefuncs.c index f69b6e6244b..784dd57831d 100644 --- a/src/backend/nodes/makefuncs.c +++ b/src/backend/nodes/makefuncs.c @@ -9,7 +9,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/nodes/makefuncs.c,v 1.49 2006/03/05 15:58:27 momjian Exp $ + * $PostgreSQL: pgsql/src/backend/nodes/makefuncs.c,v 1.50 2006/03/14 22:48:19 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -25,7 +25,8 @@ * makes an A_Expr node */ A_Expr * -makeA_Expr(A_Expr_Kind kind, List *name, Node *lexpr, Node *rexpr) +makeA_Expr(A_Expr_Kind kind, List *name, + Node *lexpr, Node *rexpr, int location) { A_Expr *a = makeNode(A_Expr); @@ -33,6 +34,7 @@ makeA_Expr(A_Expr_Kind kind, List *name, Node *lexpr, Node *rexpr) a->name = name; a->lexpr = lexpr; a->rexpr = rexpr; + a->location = location; return a; } @@ -42,7 +44,7 @@ makeA_Expr(A_Expr_Kind kind, List *name, Node *lexpr, Node *rexpr) */ A_Expr * makeSimpleA_Expr(A_Expr_Kind kind, const char *name, - Node *lexpr, Node *rexpr) + Node *lexpr, Node *rexpr, int location) { A_Expr *a = makeNode(A_Expr); @@ -50,6 +52,7 @@ makeSimpleA_Expr(A_Expr_Kind kind, const char *name, a->name = list_make1(makeString((char *) name)); a->lexpr = lexpr; a->rexpr = rexpr; + a->location = location; return a; } @@ -253,6 +256,8 @@ makeRangeVar(char *schemaname, char *relname) /* * makeTypeName - * build a TypeName node for an unqualified name. + * + * typmod is defaulted, but can be changed later by caller. */ TypeName * makeTypeName(char *typnam) @@ -261,6 +266,39 @@ makeTypeName(char *typnam) n->names = list_make1(makeString(typnam)); n->typmod = -1; + n->location = -1; + return n; +} + +/* + * makeTypeNameFromNameList - + * build a TypeName node for a String list representing a qualified name. + * + * typmod is defaulted, but can be changed later by caller. + */ +TypeName * +makeTypeNameFromNameList(List *names) +{ + TypeName *n = makeNode(TypeName); + + n->names = names; + n->typmod = -1; + n->location = -1; + return n; +} + +/* + * makeTypeNameFromOid - + * build a TypeName node to represent a type already known by OID. + */ +TypeName * +makeTypeNameFromOid(Oid typeid, int32 typmod) +{ + TypeName *n = makeNode(TypeName); + + n->typeid = typeid; + n->typmod = typmod; + n->location = -1; return n; } |