Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.1k views
in Technique[技术] by (71.8m points)

postgresql - How to suppress INFO messages when running psql scripts

I'm seeing INFO messages when I run my tests and I thought that I had gotten rid of them by setting the client_min_messages PGOPTION. Here's my command:


PGOPTIONS='--client-min-messages=warning' 
          psql  -h localhost 
                -p 5432 
                -d my_db 
                -U my_user 
                --no-align 
                --field-separator '|' 
                --pset footer 
                --quiet 
                -v AUTOCOMMIT=off 
                -X 
                -v VERBOSITY=terse 
                -v ON_ERROR_STOP=1 
                --pset pager=off 
                -f tests/test.sql 
                -o "$test_results"

Can someone advise me on how to turn off the INFO messages?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

This works for me: Postgres 9.1.4 on Debian GNU Linux with bash:

env PGOPTIONS='-c client_min_messages=WARNING' psql ...

(Still works for Postgres 12 on Ubuntu 18.04 LTS with bash.)

It's also what the manual suggests. In most shells, setting environment variables also works without an explicit leading env. See maxschlepzig's comment.

Note, however, that there is no message level INFO for client_min_messages.
That's only applicable to log_min_messages and log_min_error_statement.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...