David S
David S

Reputation: 13851

Changing message output in PostgreSQL and pgAdminIII

This is a small thing, but it's a bit annoying to me and seems like there is probably a way to configure it. Let's say I have the following:

CREATE OR REPLACE FUNCTION baz()
  RETURNS void AS
$BODY$
DECLARE
BEGIN
  RAISE NOTICE 'I also did some work!';
END;
$BODY$
  LANGUAGE plpgsql VOLATILE
  COST 100;

CREATE OR REPLACE FUNCTION bar()
  RETURNS void AS
$BODY$
DECLARE
BEGIN
  RAISE NOTICE 'I did a bunch of work and want you to know about it';
  PERFORM baz();
END;
$BODY$
  LANGUAGE plpgsql VOLATILE
  COST 100;

CREATE OR REPLACE FUNCTION foo()
  RETURNS void AS
$BODY$
DECLARE
BEGIN
  PERFORM bar();
END;
$BODY$
  LANGUAGE plpgsql VOLATILE
  COST 100;

select foo();

I get the following output messages:

NOTICE:  I did a bunch of work and want you to know about it
CONTEXT:  SQL statement "SELECT bar()"
PL/pgSQL function "foo" line 4 at PERFORM
NOTICE:  I also did some work!
CONTEXT:  SQL statement "SELECT baz()"
PL/pgSQL function "bar" line 5 at PERFORM
SQL statement "SELECT bar()"
PL/pgSQL function "foo" line 4 at PERFORM
Total query runtime: 31 ms.
1 row retrieved.

What I want (usually) is to just see something like:

NOTICE:  I did a bunch of work and want you to know about it
NOTICE:  I also did some work!
Total query runtime: 31 ms.
1 row retrieved.

Is there a way to control/alter this? Again, it's a small thing and hardly worth a question on Stackoverflow, but if you have a lot of stuff going on it starts to introduce a lot of "noise" into the output and it makes my already overloaded brain hurt trying to sift through it. :)

I'm using PostgreSQL 9.1.5 with pgAdminIII 1.16.0

Upvotes: 4

Views: 2462

Answers (2)

Craig Ringer
Craig Ringer

Reputation: 324435

If you want more control over messaging and interface, it might be worth moving to a real scripting language. Writing database scripts in tools like Python with psycopg2 or Perl with DBD::Pg and DBI is pretty simple.

Not only does using a real scripting language give you total control over messaging, but it also gives you control over error handling, gives you loops and other control structures, and generally offers a much nicer model than raw SQL for scripting tasks.

Upvotes: 0

vol7ron
vol7ron

Reputation: 42099

Try connecting with -q option. The q stands for Quiet and may be what you need.

psql -q -d foo_db

you may also try:

  • \set verbosity terse
  • \set quiet on

Upvotes: 3

Related Questions