Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I am running a number of PostgreSQL scripts that used to produce excessive log output. I managed to reduce most of the output to an acceptable amount by passing --quiet as parameter to the psql command line client and adding SET client_min_messages='warning'; to the beginning of my SQL scripts.

This works fine for most basic statements like SELECT, INSERT, UPDATE, etc.) However, when I call a stored function in a script using e.g. SELECT my_func(my_args);, there is still log output similar to

my_func

(omitted a long with many '-' here because SF thinks that's a headline)

(1 row)

The output is useless; it only makes me having to scroll back up a long way after the script has run and also makes it much harder than necessary to spot any relevant error output.

How can I get rid of it ?

share|improve this question

2 Answers 2

up vote 1 down vote accepted

Since you seem to be running the script from psql, you could do

copy ( select my_func(my_args) ) to stdout;

or even

\copy ( select my_func(my_args) ) to /dev/null

You could specify "-A -t" on the psql command line to globally quieten the output of all query statements to a single line.

share|improve this answer
    
fantastic! thanks for the tip! :-) If -q is added to the -A -t parameters, the COPY log output is also suppressed. Now all I see is warnings and errors, just what I wanted. –  ssc Jan 13 '11 at 4:23
    
PS: care to remove the \ in front of \copy so later readers don't get confused ? –  ssc Jan 13 '11 at 4:24
    
The second \ is intentional... you can't do COPY ... TO file unless you're a superuser, whereas a client-side \copy will work for everyone. –  araqnid Jan 13 '11 at 4:28

Either

\o /dev/null
SELECT my_func(my_args);

or

SELECT my_func(my_args) \g /dev/null
share|improve this answer
    
That's much more elegant that copy/\copy hackage. –  araqnid Jan 13 '11 at 20:13

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.