Re: [WIP] plpgsql is not translate-aware

From: Alvaro Herrera <alvherre(at)commandprompt(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Pg Hackers <pgsql-hackers(at)postgresql(dot)org>, Peter Eisentraut <peter_e(at)gmx(dot)net>
Subject: Re: [WIP] plpgsql is not translate-aware
Date: 2008-10-08 23:03:36
Message-ID: 20081008230336.GH4164@alvh.no-ip.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Tom Lane wrote:
> Alvaro Herrera <alvherre(at)commandprompt(dot)com> writes:
> > Now, the obvious big problem I have with this patch is that I have to
> > pass plpgsql's locale path to bindtextdomain(), but I'm not seeing any
> > decent way to do that ... ideas?
>
> Shouldn't it just use the same locale path as the backend? Or are you
> stuck getting hold of my_exec_path so you can call get_locale_path?
> If the latter, it would probably be reasonable for postmaster/backend
> startup to expose the exec path as a global variable.

That would work too. I'm not sure I prefer this, or the hack to have
dfmgr.c expose it to _PG_init, per my v2 patch.

> Two minor nits about the patch itself: the domain field of ErrorData
> should be const char * (it's like funcname, not like message; in fact,
> this coding ought to be giving you a warning about casting away const)

Yeah, I had added it in v2. I had failed to see the warning, but it was
there.

> and there seems some gratuitous inconsistency between the ordering of
> function arguments, field locations, and statements copying one to the
> other.

True, fixed.

> However ---
>
> > ! if (!errstart(elevel, edata->filename, edata->lineno, NULL, edata->funcname))
>
> --- this looks like it could result in passing a NULL to dgettext,
> somewhere along the line. Probably safer to pass "postgres".

Hmm, I was trusting that dgettext is documented to accept a NULL as
meaning "use the domain previously set with textdomain", but then it is
possible that elog() will be called before textdomain is set, so you
might be right. Fixed in this new version.

--
Alvaro Herrera http://www.CommandPrompt.com/
PostgreSQL Replication, Consulting, Custom Development, 24x7 support

Attachment Content-Type Size
plpgsql-i18n-3.patch text/x-diff 7.7 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2008-10-08 23:05:55 Re: [WIP] plpgsql is not translate-aware
Previous Message Tom Lane 2008-10-08 22:56:24 Re: trigger functions broken?