[prev in list] [next in list] [prev in thread] [next in thread] 

List:       pgsql-hackers
Subject:    Re: [HACKERS] Encoding of early PG messages
From:       Shay Rojansky <roji () roji ! org>
Date:       2015-07-31 14:28:11
Message-ID: CADT4RqA_7V_s-HiSKkAsqGDvaoXA3yupZnNcATcOdydYM5QBzg () mail ! gmail ! com
[Download RAW message or body]

Thanks for the suggestions Tom.

As I'm developing a general-purpose driver I can't do anything in
PostgreSQL config, but it's a good workaround suggestion for users who
encounter this error.

Sending lc_messages in the startup packet could work, but if I understand
correctly that setting combines both encoding and language. I guess I can
look at the user's locale preference on the client machine, try to
translate that into a PostgreSQL language/encoding and send that in
lc_messages - that seems like it might work.

Shay

On Fri, Jul 31, 2015 at 3:46 PM, Tom Lane <tgl@sss.pgh.pa.us> wrote:

> Shay Rojansky <roji@roji.org> writes:
> > Developing Npgsql I've encountered the problem described in
> >
> http://www.postgresql.org/message-id/20081223212414.GD3894@merkur.hilbert.loc
> :
> > a German installation of PostgreSQL seems to respond to an incorrect
> > password with a non-UTF8 encoding of the error messages, even if the
> > startup message contains client_encoding=UTF8.
>
> I wouldn't hold your breath waiting for that to change.
>
> A possible workaround is to run the postmaster with lc_messages=C and
> then switch to your desired message language per-session.  It would
> certainly work to send lc_messages along with client_encoding in the
> startup packet; or possibly you could set those settings as per-database
> or per-role settings to avoid needing to teach the application code
> about it.  This would mean that bad-password and similar errors would
> come out in English, but at least they'd be validly encoded ...
>
>                         regards, tom lane
>

[Attachment #3 (text/html)]

<div dir="ltr">Thanks for the suggestions Tom.<div><br></div><div>As I&#39;m \
developing a general-purpose driver I can&#39;t do anything in PostgreSQL config, but \
it&#39;s a good workaround suggestion for users who encounter this \
error.</div><div><br></div><div>Sending lc_messages in the startup packet could work, \
but if I understand correctly that setting combines both encoding and language. I \
guess I can look at the user&#39;s locale preference on the client machine, try to \
translate that into a PostgreSQL language/encoding and send that in lc_messages - \
that seems like it might work.</div><div><br></div><div>Shay<br><div \
class="gmail_extra"><br><div class="gmail_quote">On Fri, Jul 31, 2015 at 3:46 PM, Tom \
Lane <span dir="ltr">&lt;<a href="mailto:tgl@sss.pgh.pa.us" \
target="_blank">tgl@sss.pgh.pa.us</a>&gt;</span> wrote:<br><blockquote \
class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc \
solid;padding-left:1ex"><span class="">Shay Rojansky &lt;<a \
href="mailto:roji@roji.org">roji@roji.org</a>&gt; writes:<br> &gt; Developing Npgsql \
I&#39;ve encountered the problem described in<br> &gt; <a \
href="http://www.postgresql.org/message-id/20081223212414.GD3894@merkur.hilbert.loc" \
rel="noreferrer" target="_blank">http://www.postgresql.org/message-id/20081223212414.GD3894@merkur.hilbert.loc</a>:<br>
 &gt; a German installation of PostgreSQL seems to respond to an incorrect<br>
&gt; password with a non-UTF8 encoding of the error messages, even if the<br>
&gt; startup message contains client_encoding=UTF8.<br>
<br>
</span>I wouldn&#39;t hold your breath waiting for that to change.<br>
<br>
A possible workaround is to run the postmaster with lc_messages=C and<br>
then switch to your desired message language per-session.   It would<br>
certainly work to send lc_messages along with client_encoding in the<br>
startup packet; or possibly you could set those settings as per-database<br>
or per-role settings to avoid needing to teach the application code<br>
about it.   This would mean that bad-password and similar errors would<br>
come out in English, but at least they&#39;d be validly encoded ...<br>
<br>
                                    regards, tom lane<br>
</blockquote></div><br></div></div></div>



[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic