14

I already tried both:

SET client_min_messages TO WARNING;

And the -q option when I ran:

psql -q -U postgres -d myDB -f /Users/hoaphan/dev/postgres_dump -p 5432

However its output(pages like this):

 setval
--------
      1
(1 row)

 setval
--------
      1
(1 row)

 setval
--------
      1
(1 row)

 setval
--------
      1
(1 row)

 setval
--------
      1
(1 row)

 setval
--------
      1
(1 row)

 setval
--------
      1
(1 row)

 setval
--------
      1
(1 row)

 setval
--------
      1
(1 row)

 setval
--------
      1
(1 row)

...

2 Answers 2

16

The "quiet" option -q is defined as: "run quietly (no messages, only query output)".

The result of setval() is a query result, not a message, so the quiet option doesn't suppress this.

If you don't want to see query results, you can redirect their output to /dev/null using the -o switch:

psql -o /dev/null -q -U postgres -d myDB -f /Users/hoaphan/dev/postgres_dump -p 5432

(I can't test it on Linux right now, but the equivalent thing works on Windows)

6
  • I thought 'bout this, too. But this this would mean I wouldn't see ERROR if there is either, right? Unless I open that file. Thing is I don't want those ouput because they'r not informative at all, and with my dump file, I have like a lot of scrolling to get through that part. Though I would still like to see ERROR if there is any.
    – HoaPhan
    Mar 27, 2016 at 9:19
  • @HoaPhan: you will still see error messages. It's only the output of select statements that is suppressed. Mar 27, 2016 at 9:22
  • 1
    @HoaPhan: that's the output you are seeing: postgresql.org/docs/current/static/functions-sequence.html Mar 27, 2016 at 9:28
  • 2
    The Windows equivalent of /dev/null is NUL, I believe. No extension, no path, just those 3 letters. You're actually not allowed to create a file by that name, so instead of -o you may have to use output redirect with >
    – coladict
    Mar 28, 2016 at 10:55
  • 1
    @coladict: I did test it with -o nul on Windows and it worked, but I didn't have a Linux with psql around to check it. If you redirect the output then HoaPhan would indeed see no errors I think. Just redirecting the query output should be fine when restoring a dump Mar 28, 2016 at 11:02
0

I don't think you can turn it off without modifiying the dump file, or piping it to a custom filtering command, as that will mean turn off query output, but if you don't need any of the it, just use -o switch to redirect it to the file you like or /dev/null.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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