Re: Windows locale cause server to send invalid data encoding to client

Поиск
Список
Период
Сортировка
От Julien Rouhaud
Тема Re: Windows locale cause server to send invalid data encoding to client
Дата
Msg-id 20210714135052.bg5ywhl7p23tnjmg@nol
обсуждение исходный текст
Ответ на Windows locale cause server to send invalid data encoding to client  (Antoine <plaskowski.stanislas@gmail.com>)
Ответы Re: Windows locale cause server to send invalid data encoding to client  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-bugs
On Wed, Jul 14, 2021 at 01:49:24PM +0200, Antoine wrote:
> I set up a postgresql server on Windows 10 and connected it using Rust, but
> the Rust client reports invalid UTF-8 data when the password is wrong. I
> use a french locale windows that contain some accents "éèê" etc.
> 
> Windows use WTF-16 <https://simonsapin.github.io/wtf-8/> but the Rust
> client asks UTF-8 to the serveur so we think it's a bug from the server to
> not send UTF-8 even if Windows doesn't use it for its locale translation.

This is unfortunately working as designed.  The client encoding can't be set
during startup (and authentication is part of it), see
https://github.com/postgres/postgres/blob/master/src/backend/utils/mb/mbutils.c#L85-L88
for more details about it:

> /*
>  * During backend startup we can't set client encoding because we (a)
>  * can't look up the conversion functions, and (b) may not know the database
>  * encoding yet either.  So SetClientEncoding() just accepts anything and
>  * remembers it for InitializeClientEncoding() to apply later.
>  */

The driver should be prepared to receive non UTF-8 messages until
authentication succeeded.



В списке pgsql-bugs по дате отправления:

Предыдущее
От: Antoine
Дата:
Сообщение: Windows locale cause server to send invalid data encoding to client
Следующее
От: Tom Lane
Дата:
Сообщение: Re: Windows locale cause server to send invalid data encoding to client