Re: client_lc_messages

Lists: pgsql-hackers
From: Alvaro Herrera <alvherre(at)commandprompt(dot)com>
To: Pg Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: client_lc_messages
Date: 2009-10-22 13:59:20
Message-ID: 20091022135920.GB2287@alvh.no-ip.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

So right now we have a single GUC determining the language that log
messages are in, and it is PGC_SUSET to avoid a user from sending
messages to the log that the DBA cannot read.

However, this means that the client cannot get the messages in the
language of his choice.

What I am wondering right now is whether we could have two separate
attributes, one SUSET defining what goes to the log, and another one
USERSET defining what's sent to the client.

This would require a bit of shuffling, because right now we translate
the message pretty early in the call chain -- way before we try to send
it to client or server. This would need to be postponed, or
alternatively, we would need to store a second, untranslated copy so
that another translation can take place later, if necessary.

Thoughts?

--
Alvaro Herrera http://www.CommandPrompt.com/
The PostgreSQL Company - Command Prompt, Inc.


From: Magnus Hagander <magnus(at)hagander(dot)net>
To: Alvaro Herrera <alvherre(at)commandprompt(dot)com>
Cc: Pg Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: client_lc_messages
Date: 2009-10-22 23:59:19
Message-ID: 9837222c0910221659l152513e0vf6b46111980f7100@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

2009/10/22 Alvaro Herrera <alvherre(at)commandprompt(dot)com>:
> So right now we have a single GUC determining the language that log
> messages are in, and it is PGC_SUSET to avoid a user from sending
> messages to the log that the DBA cannot read.
>
> However, this means that the client cannot get the messages in the
> language of his choice.
>
> What I am wondering right now is whether we could have two separate
> attributes, one SUSET defining what goes to the log, and another one
> USERSET defining what's sent to the client.
>
> This would require a bit of shuffling, because right now we translate
> the message pretty early in the call chain -- way before we try to send
> it to client or server.  This would need to be postponed, or
> alternatively, we would need to store a second, untranslated copy so
> that another translation can take place later, if necessary.
>
> Thoughts?

This would allow me to have the client messages in one language and
the log in English, right? If so, +100 or sometihng like that, if it's
not too hard to do. Meaning it's not just encoding, but actual
translation?

--
Magnus Hagander
Me: http://www.hagander.net/
Work: http://www.redpill-linpro.com/


From: Alvaro Herrera <alvherre(at)commandprompt(dot)com>
To: Magnus Hagander <magnus(at)hagander(dot)net>
Cc: Pg Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: client_lc_messages
Date: 2009-10-23 01:25:52
Message-ID: 20091023012552.GA2240@alvh.no-ip.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Magnus Hagander wrote:
> 2009/10/22 Alvaro Herrera <alvherre(at)commandprompt(dot)com>:

> > What I am wondering right now is whether we could have two separate
> > attributes, one SUSET defining what goes to the log, and another one
> > USERSET defining what's sent to the client.

> This would allow me to have the client messages in one language and
> the log in English, right? If so, +100 or sometihng like that, if it's
> not too hard to do.

Yes.

> Meaning it's not just encoding, but actual translation?

Yeah, they would both have to be in server encoding I guess.

--
Alvaro Herrera http://www.CommandPrompt.com/
The PostgreSQL Company - Command Prompt, Inc.


From: Peter Eisentraut <peter_e(at)gmx(dot)net>
To: Alvaro Herrera <alvherre(at)commandprompt(dot)com>
Cc: Pg Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: client_lc_messages
Date: 2009-10-23 05:07:16
Message-ID: 1256274436.12838.9.camel@vanquo.pezone.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On tor, 2009-10-22 at 10:59 -0300, Alvaro Herrera wrote:
> What I am wondering right now is whether we could have two separate
> attributes, one SUSET defining what goes to the log, and another one
> USERSET defining what's sent to the client.

Note that only glibc supports switching the language at run time. And
doing it is probably very expensive if you want to do it twice per
message.

I think you could probably get much of the use case out of this if you
concentrate on making two switches for the client and the log, which can
be set to a language or "untranslated", and if you choose a language it
has to be the same for both.


From: Alvaro Herrera <alvherre(at)commandprompt(dot)com>
To: Peter Eisentraut <peter_e(at)gmx(dot)net>
Cc: Pg Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: client_lc_messages
Date: 2009-10-23 15:28:23
Message-ID: 20091023152823.GB355@alvh.no-ip.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Peter Eisentraut wrote:

> Note that only glibc supports switching the language at run time. And
> doing it is probably very expensive if you want to do it twice per
> message.

Ouch :-(

> I think you could probably get much of the use case out of this if you
> concentrate on making two switches for the client and the log, which can
> be set to a language or "untranslated", and if you choose a language it
> has to be the same for both.

So we'd go with a single setting to define language, which would be the
current lc_messages, and two new settings, say translate_log_messages
and translate_client_messages, the latter being USERSET.

Does that sound reasonable?

--
Alvaro Herrera http://www.CommandPrompt.com/
The PostgreSQL Company - Command Prompt, Inc.


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Alvaro Herrera <alvherre(at)commandprompt(dot)com>
Cc: Peter Eisentraut <peter_e(at)gmx(dot)net>, Pg Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: client_lc_messages
Date: 2009-10-23 16:02:28
Message-ID: 11456.1256313748@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Alvaro Herrera <alvherre(at)commandprompt(dot)com> writes:
> So we'd go with a single setting to define language, which would be the
> current lc_messages, and two new settings, say translate_log_messages
> and translate_client_messages, the latter being USERSET.

> Does that sound reasonable?

How do we get to the point where individual users can choose their
message language, though? If LC_MESSAGES stays as SUSET then you
haven't really made matters better for anybody.

With the above infrastructure, we could get there if there were a way to
say "LC_MESSAGES is USERSET if translate_log_messages is OFF", but there
isn't and I doubt it would be a good idea to try to make it work like
that.

Maybe we should stick to the original design and just document that
you'll take a big performance hit if the settings are different and
both not "C". And of course make sure we avoid the performance hit
otherwise.

regards, tom lane


From: Magnus Hagander <magnus(at)hagander(dot)net>
To: Alvaro Herrera <alvherre(at)commandprompt(dot)com>
Cc: Peter Eisentraut <peter_e(at)gmx(dot)net>, Pg Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: client_lc_messages
Date: 2009-10-23 16:52:47
Message-ID: 9837222c0910230952o5053c9d9o4cd60861e0716fe9@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

2009/10/23 Alvaro Herrera <alvherre(at)commandprompt(dot)com>:
> Peter Eisentraut wrote:
>
>> Note that only glibc supports switching the language at run time.  And
>> doing it is probably very expensive if you want to do it twice per
>> message.
>
> Ouch :-(
>
>> I think you could probably get much of the use case out of this if you
>> concentrate on making two switches for the client and the log, which can
>> be set to a language or "untranslated", and if you choose a language it
>> has to be the same for both.
>
> So we'd go with a single setting to define language, which would be the
> current lc_messages, and two new settings, say translate_log_messages
> and translate_client_messages, the latter being USERSET.
>
> Does that sound reasonable?

Does to me. It would certainly cover my use-case, which is that unless
your logs are in english, it's really hard to google on anything :-)
(I guess it may work for the "big" languages like spanish, french and
german, but that's about it. And even then, you're missing out on a
lot of resources)

--
Magnus Hagander
Me: http://www.hagander.net/
Work: http://www.redpill-linpro.com/