Investigating a psql error
Error messages can sometimes be cryptic, and you may be left wondering, Why did this error happen at all?
For this purpose, psql
recognizes two variables, VERBOSITY
and CONTEXT
; valid values are terse
, default
, or verbose
for the former, and never
, errors
, or always
for the latter. A more verbose error message will hopefully specify extra detail, and the context information will be included. Here is an example to show the difference:
postgres=# \set VERBOSITY terse postgres=# \set CONTEXT never postgres=# select * from missingtable; ERROR: relation "missingtable" does not exist at character 15
This is quite a simple error, so we don't actually need the extra detail, but it is nevertheless useful for illustrating the extra detail you get when raising verbosity and enabling context information:
postgres=# \set VERBOSITY verbose postgres=# \set CONTEXT errors postgres=# select * from missingtable; ERROR: 42P01: relation "missingtable" does not exist LINE 1: select ...