*** a/doc/src/sgml/libpq.sgml
--- b/doc/src/sgml/libpq.sgml
***************
*** 5418,5423 **** int PQsetClientEncoding(PGconn *conn, const char *VERBOSE>
! mode includes all available fields. Changing the verbosity does not
! affect the messages available from already-existing
! PGresult> objects, only subsequently-created ones.
--- 5431,5442 ----
returned messages include severity, primary text, and position only;
this will normally fit on a single line. The default mode produces
messages that include the above plus any detail, hint, or context
! fields (these might span multiple lines). The COMPACT mode is otherwise
! the same as the default, except the context field will be omitted for
! non-error messages. The VERBOSE> mode includes all
! available fields. Changing the verbosity does not affect the messages
! available from already-existing PGresult> objects, only
! subsequently-created ones.
*** a/src/bin/psql/startup.c
--- b/src/bin/psql/startup.c
***************
*** 796,801 **** verbosity_hook(const char *newval)
--- 796,803 ----
pset.verbosity = PQERRORS_DEFAULT;
else if (strcmp(newval, "terse") == 0)
pset.verbosity = PQERRORS_TERSE;
+ else if (strcmp(newval, "compact") == 0)
+ pset.verbosity = PQERRORS_COMPACT;
else if (strcmp(newval, "verbose") == 0)
pset.verbosity = PQERRORS_VERBOSE;
else
*** a/src/interfaces/libpq/fe-protocol3.c
--- b/src/interfaces/libpq/fe-protocol3.c
***************
*** 915,920 **** pqGetErrorNotice3(PGconn *conn, bool isError)
--- 915,924 ----
if (val)
appendPQExpBuffer(&workBuf, libpq_gettext("QUERY: %s\n"), val);
val = PQresultErrorField(res, PG_DIAG_CONTEXT);
+ }
+ if (isError || (conn->verbosity != PQERRORS_TERSE &&
+ conn->verbosity != PQERRORS_COMPACT))
+ {
if (val)
appendPQExpBuffer(&workBuf, libpq_gettext("CONTEXT: %s\n"), val);
}
*** a/src/interfaces/libpq/libpq-fe.h
--- b/src/interfaces/libpq/libpq-fe.h
***************
*** 106,111 **** typedef enum
--- 106,112 ----
typedef enum
{
PQERRORS_TERSE, /* single-line error messages */
+ PQERRORS_COMPACT, /* single-line error messages on non-error messags */
PQERRORS_DEFAULT, /* recommended style */
PQERRORS_VERBOSE /* all the facts, ma'am */
} PGVerbosity;
*** a/src/pl/plpgsql/src/pl_exec.c
--- b/src/pl/plpgsql/src/pl_exec.c
***************
*** 39,46 ****
#include "utils/typcache.h"
- static const char *const raise_skip_msg = "RAISE";
-
typedef struct
{
int nargs; /* number of arguments */
--- 39,44 ----
***************
*** 867,876 **** plpgsql_exec_error_callback(void *arg)
{
PLpgSQL_execstate *estate = (PLpgSQL_execstate *) arg;
- /* if we are doing RAISE, don't report its location */
- if (estate->err_text == raise_skip_msg)
- return;
-
if (estate->err_text != NULL)
{
/*
--- 865,870 ----
***************
*** 3032,3038 **** exec_stmt_raise(PLpgSQL_execstate *estate, PLpgSQL_stmt_raise *stmt)
/*
* Throw the error (may or may not come back)
*/
- estate->err_text = raise_skip_msg; /* suppress traceback of raise */
ereport(stmt->elog_level,
(err_code ? errcode(err_code) : 0,
--- 3026,3031 ----