Thread: Silencing 'NOTICE' messages for PRIMARY KEY

Silencing 'NOTICE' messages for PRIMARY KEY

From
Rajit Singh
Date:
Hi,

I just have a small question.  I discovered the psql -q option, which is great... but I wanna get rid of *all* output
thatisn't something I need to look at after the 1000th time I've run a particular echo 'blah' | psql. 

With the PRIMARY KEY options in some of my schemas, when I use pg_dump <blah> | psql -q, I get:

    NOTICE:  CREATE TABLE/PRIMARY KEY will create implicit index 'blah_pkey' for table 'blah'

I've looked through pg_dump to try and find an option to get it to explicitly create indexes, and I've looked through
'psql'to try and find an option not to display messages like this.  I can't find it. 

I'm considering using the option to get psql to exit on error, and to redirect *all* output to /dev/null or something.
ButI'd like it if I could utilise psql's own error reporting without having to look through hundreds of defunct NOTICE
statements.

All help appreciated,

Rajit

Re: Silencing 'NOTICE' messages for PRIMARY KEY

From
"Richard Huxton"
Date:
----- Original Message -----
From: "Rajit Singh" <singh.raj@studychoice.com>


> Hi,
>
> I just have a small question.  I discovered the psql -q option, which is
great... but I wanna get rid of *all* output that isn't something I need to
look at after the 1000th time I've run a particular echo 'blah' | psql.
>
> With the PRIMARY KEY options in some of my schemas, when I use pg_dump
<blah> | psql -q, I get:
>
> NOTICE:  CREATE TABLE/PRIMARY KEY will create implicit index 'blah_pkey'
for table 'blah'
>
Try piping the error stream through sed. Something like:

  sed -e'/NOTICE/d'

will remove all lines containing NOTICE from the output.

HTH

- Richard Huxton


Re: Silencing 'NOTICE' messages for PRIMARY KEY

From
Rajit Singh
Date:
> Try piping the error stream through sed. Something like:
>
>   sed -e'/NOTICE/d'
>
> will remove all lines containing NOTICE from the output.

Yeah, I considered this.  I don't like the idea of hard-coding something like that.  When guys here in the future
upgradePostgres or something, they'd have to make sure they changed wherever I had written 'sed -e "/NOTICE/d"' (in the
eventof Postgres changing it's reporting mechanism). 

And anyway, I felt if there was some way of getting postgres to only output essential stuff, then I know *it'd* be
makingthe decision... instead of me assuming all NOTICE messages are unimportant. 

Unless, of course, someone can tell me that NOTICE messages are always unimportant, and only ERROR messages need to be
noted.

Any ideas?
Thanks,
Rajit