aboutsummaryrefslogtreecommitdiff
path: root/src/bin/psql/startup.c
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2019-04-04 17:22:02 -0400
committerTom Lane <tgl@sss.pgh.pa.us>2019-04-04 17:22:02 -0400
commit7bac3acab4d5c3f2c35aa3a7bea08411d83fd5bc (patch)
treec6d41d068592bc1d566c035e5f0d52828f738acf /src/bin/psql/startup.c
parent413ccaa74d9a126b042727c826e65e2844adadac (diff)
downloadpostgresql-7bac3acab4d5c3f2c35aa3a7bea08411d83fd5bc.tar.gz
postgresql-7bac3acab4d5c3f2c35aa3a7bea08411d83fd5bc.zip
Add a "SQLSTATE-only" error verbosity option to libpq and psql.
This is intended for use mostly in test scripts for external tools, which could do without cross-PG-version variations in error message wording. Of course, the SQLSTATE isn't guaranteed stable either, but it should be more so than the error message text. Note: there's a bit of an ABI change for libpq here, but it seems OK because if somebody compiles against a newer version of libpq-fe.h, and then tries to pass PQERRORS_SQLSTATE to PQsetErrorVerbosity() of an older libpq library, it will be accepted and then act like PQERRORS_DEFAULT, thanks to the way the tests in pqBuildErrorMessage3 have historically been phrased. That seems acceptable. Didier Gautheron, reviewed by Dagfinn Ilmari Mannsåker Discussion: https://postgr.es/m/CAJRYxuKyj4zA+JGVrtx8OWAuBfE-_wN4sUMK4H49EuPed=mOBw@mail.gmail.com
Diffstat (limited to 'src/bin/psql/startup.c')
-rw-r--r--src/bin/psql/startup.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/src/bin/psql/startup.c b/src/bin/psql/startup.c
index ac82087445e..855133bbcb4 100644
--- a/src/bin/psql/startup.c
+++ b/src/bin/psql/startup.c
@@ -1110,13 +1110,15 @@ verbosity_hook(const char *newval)
Assert(newval != NULL); /* else substitute hook messed up */
if (pg_strcasecmp(newval, "default") == 0)
pset.verbosity = PQERRORS_DEFAULT;
- else if (pg_strcasecmp(newval, "terse") == 0)
- pset.verbosity = PQERRORS_TERSE;
else if (pg_strcasecmp(newval, "verbose") == 0)
pset.verbosity = PQERRORS_VERBOSE;
+ else if (pg_strcasecmp(newval, "terse") == 0)
+ pset.verbosity = PQERRORS_TERSE;
+ else if (pg_strcasecmp(newval, "sqlstate") == 0)
+ pset.verbosity = PQERRORS_SQLSTATE;
else
{
- PsqlVarEnumError("VERBOSITY", newval, "default, terse, verbose");
+ PsqlVarEnumError("VERBOSITY", newval, "default, verbose, terse, sqlstate");
return false;
}