Thread
-
Re: Add column name to error description
Erik Wienhold <ewie@ewie.name> — 2025-03-07T01:42:00Z
On 2025-03-06 21:56 +0100, Tom Lane wrote: > jian he <jian.universality@gmail.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