Suppressing CONTEXT lines in psql

CONTEXT messages are quite informative, but when you don't need them, they can be real pain in the eyes:

psql:trees.sql:68: NOTICE:  Adding tree structures to table public.testit.
CONTEXT:  SQL function "add_tree_structure" statement 1
psql:trees.sql:68: NOTICE:  Tree table will be public.testit_tree.
CONTEXT:  SQL function "add_tree_structure" statement 1
psql:trees.sql:68: NOTICE:  Primary key in source table is: id
CONTEXT:  SQL function "add_tree_structure" statement 1

I mean – I know the context. I'm writing the sql file right now, how to disable it?

Unfortunately documentation is rather unhelpful. Tom Lane once wrote that showing or hiding these messages is totally up to client. In my case it is psql, but in it's docs I haven't found anything about CONTEXT.

Luckily, with some googling and greping i found correct solution:

In psql prompt enter:

\set VERBOSITY terse

And that's it. Now you got rid of all extra messages. It means that you receive less interesting debug information, but that's exactly what I'm looking for at the moment 🙂

Of course it will work only in current psql session. If you want to make it permanent – put it in your .psqlrc file.

One thought on “Suppressing CONTEXT lines in psql”

  1. This is awesome! I’ve been looking and looking for a way to hide these.

Comments are closed.