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-07 17:19:15
Message-ID: 1037878.1741367955@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

jian he <jian(dot)universality(at)gmail(dot)com> writes:
> 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.

No, you misunderstand how that works:

errmsg_internal("%s", _(msg)),

The useful translation happens in the invocation of "_(msg)",
that is gettext(msg). Using errmsg_internal instead of
errmsg just indicates that there's no point in trying to
translate the string "%s". We do it like this rather than
simply writing

errmsg(msg),

because of the risk of sprintf doing something unexpected
with '%' characters in the translated message.

regards, tom lane

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Robert Haas 2025-03-07 17:19:45 Re: TOAST versus toast
Previous Message Peter Geoghegan 2025-03-07 17:18:10 Re: Showing primitive index scan count in EXPLAIN ANALYZE (for skip scan and SAOP scans)