Mention column name in error messages - Mailing list pgsql-hackers

From Franck Verrot
Subject Mention column name in error messages
Date
Msg-id CANfkH5k-6nNt-4cSv1vPB80nq2BZCzhFVR5O4VznYbsX0wZmow@mail.gmail.com
Whole thread Raw
Responses Re: Mention column name in error messages
List pgsql-hackers
Hi all,

As far as I know, there is currently no way to find which column is triggering
an error on an INSERT or ALTER COLUMN statement. Example:
   # create table foo(bar varchar(4), baz varchar(2));   CREATE TABLE   # insert into foo values ('foo!', 'ok');   INSERT 0 1   # insert into foo values ('foo2!', 'ok');   ERROR:  value too long for type character varying(4)   # insert into foo values ('foo!', 'ok2');   ERROR:  value too long for type character varying(2)


I browsed the list and found a conversation from last year
(http://www.postgresql.org/message-id/3214.1390155040@sss.pgh.pa.us) that
discussed adding the actual value in the output.

The behavior I am proposing differs in the sense we will be able to see in
the "ERROR: xxxx" what column triggered the error:
   # create table foo(bar varchar(4), baz varchar(2));   CREATE TABLE   # insert into foo values ('foo!', 'ok');   INSERT 0 1   # insert into foo values ('foo2!', 'ok');   ERROR:  value too long for bar of type character varying(4)   # insert into foo values ('foo!', 'ok2');   ERROR:  value too long for baz of type character varying(2)


In that same conversation, Tom Lane said:

>  [...] People have speculated about ways to
>  name the target column in the error report, which would probably be
>  far more useful; but it's not real clear how to do that in our system
>  structure.

Given my very restricted knowledge of PG's codebase I am not sure whether my
modifications are legitimate or not, so please don't hesitate to comment on
it and pointing where things are subpar to PG's codebase. In any case, it's
to be considered as WIP for the moment.
Thanks in advance,
Franck


--
Attachment

pgsql-hackers by date:

Previous
From: Heikki Linnakangas
Date:
Subject: Re: LWLock deadlock and gdb advice
Next
From: Andres Freund
Date:
Subject: Re: LWLock deadlock and gdb advice