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, which can be set toterse,default, orverboseCONTEXT, which can be set tonever,errors, oralways
These variables control how much detail is displayed to the user in case of an error.
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 need the extra details, 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"...