[Chicago-talk] Suppressing "NOTICE:" in postgres

Michael Potter michael at potter.name
Wed Mar 25 16:57:55 PDT 2009

Thanks guys.

To solve the problem of unwanted NOTICE messages while creating tables
in postgres here is what I did:

sub addPrimaryKey
   my $Table = shift;
   my @KeyColArray = @_;

   $dbh->do(qq{ SET client_min_messages = warning });   # postgres only.

   my $KeyColStr = "\"" . join("\", \"", @KeyColArray) . "\"";

   $dbh->do(qq{ ALTER TABLE "${Table}" ADD PRIMARY KEY (${KeyColStr}) });

   $dbh->do(qq{ SET client_min_messages = notice });   # postgres only.

This is basically Andy's solution.

He suggested changing the config file; that led me to how to change it
on the fly.

I am probably going to change it yet again to turn off NOTICEs for the
whole script and eliminate the tedium.

Michael Potter

More information about the Chicago-talk mailing list