Re: Different gettext domain needed for error context - Mailing list pgsql-hackers

From Heikki Linnakangas
Subject Re: Different gettext domain needed for error context
Date
Msg-id 4F8BD4B1.5050901@enterprisedb.com
Whole thread Raw
In response to Re: Different gettext domain needed for error context  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-hackers
On 15.04.2012 00:54, Tom Lane wrote:
> I really think we need to change errcontext itself to pass the correct
> domain.  If we are going to require a domain to be provided (and this
> does require that, for correct operation), then we need to break any
> code that doesn't provide it in a visible fashion.
>
> A possibly more attractive alternative is to redefine errcontext
> with a macro that allows TEXTDOMAIN to be passed in behind-the-scenes,
> thus keeping source-level compatibility.  We can do this with the same
> type of hack we've used for many years for elog():
>
> #define errcontext  set_errcontext_domain(TEXTDOMAIN), errcontext_msg
>
> where the actual message-passing function is now called errcontext_msg.

Ok then, here's a patch using that approach.

I had to rename a few local variables called "errcontext", because the
macro now tries to expands those and you get an error.

Note: If you want to test this at home, the original test case I posted
doesn't currently work because the text of the context messages in
PL/pgSQL have been slightly changed since I posted the original test
case, but the translations have not been updated yet. Until then, you
can manually remove the double quotes in messages like 'function \"%s\"'
in the .po file to test this.

--
   Heikki Linnakangas
   EnterpriseDB   http://www.enterprisedb.com

Attachment

pgsql-hackers by date:

Previous
From: Simon Riggs
Date:
Subject: Re: Last gasp
Next
From: Heikki Linnakangas
Date:
Subject: Re: index-only scans vs. Hot Standby, round two