Re: Add column name to error description
jian he <jian.universality@gmail.com>
From: jian he <jian.universality@gmail.com>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: Erik Wienhold <ewie@ewie.name>, Marcos Pegoraro <marcos@f10.com.br>, PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>
Date: 2025-03-07T14:54:25Z
Lists: pgsql-hackers
On Fri, Mar 7, 2025 at 11:05 AM Tom Lane <tgl@sss.pgh.pa.us> wrote: > > Erik Wienhold <ewie@ewie.name> writes: > > 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. > > I think the idea of the original coding was to keep those values in > registers in the inner loop rather than re-fetching them each time. > But that's probably an unmeasurably microscopic optimization, if > real at all (modern compilers might figure it out for themselves). > Do others agree Erik's version improves readability? > i think so. While looking at it, in build_attrmap_by_position I guess errmsg may be better than errmsg_internal since there are around 10 related error messages in src/pl/plpgsql/src/expected/plpgsql_record.out, so it's user visible. but I am confused by the below errmsg_internal comments about translation message infinite error recursion. /* * errmsg_internal --- add a primary error message text to the current error * * This is exactly like errmsg() except that strings passed to errmsg_internal * are not translated, and are customarily left out of the * internationalization message dictionary. This should be used for "can't * happen" cases that are probably not worth spending translation effort on. * We also use this for certain cases where we *must* not try to translate * the message because the translation would fail and result in infinite * error recursion. */
Commits
-
Include column name in build_attrmap_by_position's error reports.
- 34c3c5ce1c0b 18.0 landed
-
Instead of supposing (wrongly, in the general case) that the rowtype
- 12b1b5d837b5 8.0.0 cited