Re: Supression of NOTICEs with an ERROR

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "Greg Sabino Mullane" <greg(at)turnstep(dot)com>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: Supression of NOTICEs with an ERROR
Date: 2002-02-06 15:55:56
Message-ID: 6331.1013010956@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

"Greg Sabino Mullane" <greg(at)turnstep(dot)com> writes:
> I'd like some opinions on fixing the following behavior in
> psql (and postgres in general):

> foobar=> CREATE TABLE foo (bar INTEGER);
> CREATE
> foobar=> CREATE TABLE foo (bar INTEGER UNIQUE);
> NOTICE: CREATE TABLE / UNIQUE will create implicit index 'foo_bar_key' for table 'foo'
> ERROR: Relation 'foo' already exists
> turnstep=>

> I think that this notice should not appear in this case, since
> the ERROR negates the actual table creation. My first question:
> is this worth pursuing?

I'd argue that it is not broken. This isn't really different from the
case of
BEGIN;
do something provoking a NOTICE;
ROLLBACK;
Would you have the system suppress the NOTICE in this case?

Perhaps more to the point, this particular notice might be useful in
figuring out the reason for the failure --- for example, it might be
that the relation name conflict is not on your table name, but on the
name of an implicitly created index or sequence. So suppressing the
notice might discard valuable information.

Not everyone likes these notices, and so there has been some talk of
a server configuration variable that could be set to make the server
somewhat less chatty. This is quite independent of whether the command
ultimately succeeds or fails, however. In any case I doubt that
hacking psql is a rational way to approach the issue; psql can't be
expected to know all about every sort of notice the backend might issue.

regards, tom lane

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Peter Eisentraut 2002-02-06 16:14:49 Re: i18n
Previous Message Marc G. Fournier 2002-02-06 15:20:12 Re: Threaded PosgreSQL server