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

From Tom Lane
Subject Re: Different gettext domain needed for error context
Date
Msg-id 13653.1334440469@sss.pgh.pa.us
Whole thread Raw
In response to Re: Different gettext domain needed for error context  (Heikki Linnakangas <heikki.linnakangas@enterprisedb.com>)
Responses Re: Different gettext domain needed for error context  (Heikki Linnakangas <heikki.linnakangas@enterprisedb.com>)
List pgsql-hackers
Heikki Linnakangas <heikki.linnakangas@enterprisedb.com> writes:
> 3. In the callback function, call a new function to set the domain to be 
> used for the errcontext() calls in that callback:

>     /* use the right domain to translate the errcontext() calls */
>     set_errtextdomain();

>     errcontext("PL/Perl anonymous code block");

> Attached is a patch using this approach, I like it the most.

I don't like it at all.  It seems horridly error-prone to me: there
*will* be sins of omission all over the place.

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.
        regards, tom lane


pgsql-hackers by date:

Previous
From: Robert Haas
Date:
Subject: Re: [BUGS] BUG #6572: The example of SPI_execute is bogus
Next
From: Robert Haas
Date:
Subject: Re: Last gasp