Re: Add column name to error description

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: jian he <jian(dot)universality(at)gmail(dot)com>
Cc: Erik Wienhold <ewie(at)ewie(dot)name>, 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-06 20:56:46
Message-ID: 897633.1741294606@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

[ sorry about having let this thread fall off my radar ]

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.

regards, tom lane

Attachment Content-Type Size
v3-0001-improve-error-message-in-build_attrmap_by_positio.patch text/x-diff 8.8 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Jacob Champion 2025-03-06 20:57:24 Re: [PoC] Federated Authn/z with OAUTHBEARER
Previous Message Nathan Bossart 2025-03-06 20:50:46 Re: Statistics Import and Export