Re: Add column name to error description

From: Erik Wienhold <ewie(at)ewie(dot)name>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: jian he <jian(dot)universality(at)gmail(dot)com>, Marcos Pegoraro <marcos(at)f10(dot)com(dot)br>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: Add column name to error description
Date: 2025-03-07 01:42:00
Message-ID: 4b9cff17-103e-4792-98bf-fef46171d7fe@ewie.name
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 2025-03-06 21:56 +0100, Tom Lane wrote:
> jian he <jian(dot)universality(at)gmail(dot)com> writes:
> > if we print out NameStr(att->attname) then error becomes:
> > +DETAIL: Returned type unknown does not match expected type character
> > varying in column "f2" (position 2).
>
> > In this case, printing out {column \"%s\"} is not helpful at all.
>
> Actually, the problem is that we should be printing the expected
> column name not the input column name. At least in the test cases
> we have, that gives a user-supplied name in every case. Even if
> there are some cases where you just get "f2", that's not horrible.
> So I don't think this is worth the amount of code churn involved in
> the v2 patch --- let's just print it unconditionally, as attached.
> I do still think that including the column number is potentially
> helpful, though, so I didn't remove that.

+1

But I don't see the point in keeping variables atttypid and atttypmod
around when those values are now available via outatt. Removing these
two variables makes the code easier to read IMO. Done so in the
attached v4.

--
Erik Wienhold

Attachment Content-Type Size
v4-0001-improve-error-message-in-build_attrmap_by_positio.patch text/plain 8.9 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Jeff Davis 2025-03-07 01:42:30 Re: Statistics Import and Export
Previous Message Peter Smith 2025-03-07 01:33:21 Re: Parallel heap vacuum