aboutsummaryrefslogtreecommitdiff
path: root/src/interfaces/libpq/fe-protocol3.c
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2015-09-05 11:58:20 -0400
committerTom Lane <tgl@sss.pgh.pa.us>2015-09-05 11:58:33 -0400
commit0426f349effb6bde2061f3398a71db7180c97dd9 (patch)
tree741fcee27d57266182690fefd31721b8d6546b1e /src/interfaces/libpq/fe-protocol3.c
parentc80b5f66c6faff085e312492be0aa50754e99eb9 (diff)
downloadpostgresql-0426f349effb6bde2061f3398a71db7180c97dd9.tar.gz
postgresql-0426f349effb6bde2061f3398a71db7180c97dd9.zip
Rearrange the handling of error context reports.
Remove the code in plpgsql that suppressed the innermost line of CONTEXT for messages emitted by RAISE commands. That was never more than a quick backwards-compatibility hack, and it's pretty silly in cases where the RAISE is nested in several levels of function. What's more, it violated our design theory that verbosity of error reports should be controlled on the client side not the server side. To alleviate the resulting noise increase, introduce a feature in libpq and psql whereby the CONTEXT field of messages can be suppressed, either always or only for non-error messages. Printing CONTEXT for errors only is now their default behavior. The actual code changes here are pretty small, but the effects on the regression test outputs are widespread. I had to edit some of the alternative expected outputs by hand; hopefully the buildfarm will soon find anything I fat-fingered. In passing, fix up (again) the output line counts in psql's various help displays. Add some commentary about how to verify them. Pavel Stehule, reviewed by Petr JelĂ­nek, Jeevan Chalke, and others
Diffstat (limited to 'src/interfaces/libpq/fe-protocol3.c')
-rw-r--r--src/interfaces/libpq/fe-protocol3.c15
1 files changed, 10 insertions, 5 deletions
diff --git a/src/interfaces/libpq/fe-protocol3.c b/src/interfaces/libpq/fe-protocol3.c
index dbc0d89a4ed..641804cb068 100644
--- a/src/interfaces/libpq/fe-protocol3.c
+++ b/src/interfaces/libpq/fe-protocol3.c
@@ -250,7 +250,7 @@ pqParseInput3(PGconn *conn)
if (!conn->result)
{
printfPQExpBuffer(&conn->errorMessage,
- libpq_gettext("out of memory"));
+ libpq_gettext("out of memory"));
pqSaveErrorResult(conn);
}
}
@@ -321,7 +321,7 @@ pqParseInput3(PGconn *conn)
if (!conn->result)
{
printfPQExpBuffer(&conn->errorMessage,
- libpq_gettext("out of memory"));
+ libpq_gettext("out of memory"));
pqSaveErrorResult(conn);
}
}
@@ -934,9 +934,14 @@ pqGetErrorNotice3(PGconn *conn, bool isError)
val = PQresultErrorField(res, PG_DIAG_INTERNAL_QUERY);
if (val)
appendPQExpBuffer(&workBuf, libpq_gettext("QUERY: %s\n"), val);
- val = PQresultErrorField(res, PG_DIAG_CONTEXT);
- if (val)
- appendPQExpBuffer(&workBuf, libpq_gettext("CONTEXT: %s\n"), val);
+ if (conn->show_context == PQSHOW_CONTEXT_ALWAYS ||
+ (conn->show_context == PQSHOW_CONTEXT_ERRORS && isError))
+ {
+ val = PQresultErrorField(res, PG_DIAG_CONTEXT);
+ if (val)
+ appendPQExpBuffer(&workBuf, libpq_gettext("CONTEXT: %s\n"),
+ val);
+ }
}
if (conn->verbosity == PQERRORS_VERBOSE)
{