diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2004-03-21 22:29:11 +0000 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2004-03-21 22:29:11 +0000 |
commit | f938c2b91bebb7f436a3615cf86347d7261f71e8 (patch) | |
tree | 012d53c3414a88b0d35a4210becbcadf3b81a09c /src/bin/psql/common.c | |
parent | bee3b2a0a01eab4b9e8d795fd2e3b5515bf22df3 (diff) |
Revise syntax-error reporting behavior to give pleasant results for
errors in internally-generated queries, such as those submitted by
plpgsql functions. Per recent discussions with Fabien Coelho.
Diffstat (limited to 'src/bin/psql/common.c')
-rw-r--r-- | src/bin/psql/common.c | 23 |
1 files changed, 12 insertions, 11 deletions
diff --git a/src/bin/psql/common.c b/src/bin/psql/common.c index 2a6be545caf..3b1a1228c1e 100644 --- a/src/bin/psql/common.c +++ b/src/bin/psql/common.c @@ -3,7 +3,7 @@ * * Copyright (c) 2000-2003, PostgreSQL Global Development Group * - * $PostgreSQL: pgsql/src/bin/psql/common.c,v 1.84 2004/03/15 10:41:26 ishii Exp $ + * $PostgreSQL: pgsql/src/bin/psql/common.c,v 1.85 2004/03/21 22:29:11 tgl Exp $ */ #include "postgres_fe.h" #include "common.h" @@ -364,18 +364,19 @@ ReportSyntaxErrorPosition(const PGresult *result, const char *query) bool beg_trunc, end_trunc; PQExpBufferData msg; - if (query == NULL) - return; /* nothing to do */ + if (pset.verbosity == PQERRORS_TERSE) + return; + sp = PQresultErrorField(result, PG_DIAG_STATEMENT_POSITION); if (sp == NULL) - return; /* no syntax error location */ - /* - * We punt if the report contains any CONTEXT. This typically means that - * the syntax error is from inside a function, and the cursor position - * is not relevant to the original query string. - */ - if (PQresultErrorField(result, PG_DIAG_CONTEXT) != NULL) - return; + { + sp = PQresultErrorField(result, PG_DIAG_INTERNAL_POSITION); + if (sp == NULL) + return; /* no syntax error */ + query = PQresultErrorField(result, PG_DIAG_INTERNAL_QUERY); + } + if (query == NULL) + return; /* nothing to reference location to */ if (sscanf(sp, "%d", &loc) != 1) { |