Thread: Qualified tables in error messages

Qualified tables in error messages

From
Rod Taylor
Date:
ERROR:  update or delete on "ftp" violates foreign key constraint "$1"
on "ftp"
DETAIL:  Key (ftp_id)=(11) is still referenced from "ftp".

Considering I have several different FTP tables in various schemas, this
message doesn't have much detail. The "Error Message Style Guide" does
not indicate one way or the other whether tables, etc. should be fully
qualified or not. Possibly not in ERROR, but qualified makes sense for
DETAIL.

Re: Qualified tables in error messages

From
Tom Lane
Date:
Rod Taylor <rbt@rbt.ca> writes:
> Considering I have several different FTP tables in various schemas, this
> message doesn't have much detail. The "Error Message Style Guide" does
> not indicate one way or the other whether tables, etc. should be fully
> qualified or not. Possibly not in ERROR, but qualified makes sense for
> DETAIL.

I deliberately haven't done that because it would be awfully noisy.
It would be wrong to write only one set of quotes:
ERROR: table "schema.foo" does not exist

since it's not clear here if the dot is in the name or not.  We'd have
to write
ERROR: table "schema"."foo" does not exist

which is just plain ugly.

There are error fields defined in the SQL spec for table name, schema
name, etc, and at some point we should consider expanding the
error-message structure to allow passing those fields back to the
client --- *not* as part of the text messages, but as separate detail
fields.  Didn't get around to it for 7.4 though.
        regards, tom lane


Re: Qualified tables in error messages

From
Rod Taylor
Date:
> since it's not clear here if the dot is in the name or not.  We'd have
> to write
>
>     ERROR: table "schema"."foo" does not exist
>
> which is just plain ugly.

Yes, it certainly is.

> There are error fields defined in the SQL spec for table name, schema
> name, etc, and at some point we should consider expanding the

I see, this would be ideal.


Re: Qualified tables in error messages

From
"Mendola Gaetano"
Date:
"Tom Lane" <tgl@sss.pgh.pa.us> wrote:
> ERROR: table "schema"."foo" does not exist
> 
> which is just plain ugly.

I think that is better for the moment this ugly message
that have lack of information.


Regards
Gaetano Mendola






Re: Qualified tables in error messages

From
"Christopher Kings-Lynne"
Date:
> "Tom Lane" <tgl@sss.pgh.pa.us> wrote:
> > ERROR: table "schema"."foo" does not exist
> >
> > which is just plain ugly.

Why not wrap all 'identifier' outputs in a call to the quoting function, so
the above message would in fact appear as:

table schema.foo does not exist

but with a space in it it would appear like this:

table "schema 2".foo does not exist

Chris



Re: Qualified tables in error messages

From
Tom Lane
Date:
"Christopher Kings-Lynne" <chriskl@familyhealth.com.au> writes:
> Why not wrap all 'identifier' outputs in a call to the quoting function, so
> the above message would in fact appear as:
> table schema.foo does not exist
> but with a space in it it would appear like this:
> table "schema 2".foo does not exist

This doesn't conform to the message style guidelines we agreed to,
which specify quoting of user identifiers in messages.  I think the
guidelines are correct on this point --- consider for instancetable exists does not exist
which could easily be a tad confusing...
        regards, tom lane