Re: protocol version negotiation (Re: [HACKERS] Libpq PGRES_COPY_BOTH- version compatibility)

Поиск
Список
Период
Сортировка
От Craig Ringer
Тема Re: protocol version negotiation (Re: [HACKERS] Libpq PGRES_COPY_BOTH- version compatibility)
Дата
Msg-id CAMsr+YEAWN_7JQaGWfUMgDjyO9d-Z-Sdj7hiosprVHVh_Kt42g@mail.gmail.com
обсуждение исходный текст
Ответ на Re: protocol version negotiation (Re: [HACKERS] Libpq PGRES_COPY_BOTH- version compatibility)  (Craig Ringer <craig@2ndquadrant.com>)
Список pgsql-hackers
On 29 June 2017 at 09:44, Craig Ringer <craig@2ndquadrant.com> wrote:

> I
> can't personally think of much right away that wouldn't work pretty
> well in a follow-on message.

Actually, I take that back, there's one thing that's bugged me for a
while that wouldn't work well this way: determining the correct text
encoding with which to interpret the database name, user name, and any
string GUC values. Right now we take a wild stab in the dark and use
the server encoding.

e.g. in a terminal with LC_ALL=en_US.UTF-8 I run

postgres=# CREATE ROLE "café";
CREATE ROLE
postgres=# CREATE DATABASE "café" with owner "café";
CREATE DATABASE
postgres=# \du ca*           List of rolesRole name |  Attributes  | Member of
-----------+--------------+-----------café      | Cannot login | {}

postgres=# \l ca*                           List of databasesName | Owner | Encoding |   Collate   |    Ctype    |
Accessprivileges 
------+-------+----------+-------------+-------------+-------------------café | café  | UTF8     | en_AU.UTF-8 |
en_AU.UTF-8| 
(1 row)


then in a terminal with LC_ALL=en_US.ISO-8859-1 I run:

[craig@ayaki-localdomain log]$ psql -U "café"
psql: FATAL:  role "café" does not exist
[craig@ayaki-localdomain log]$ psql
psql (9.6.3, server 9.5.7)
Type "help" for help.

craig=> \du ca*           List of rolesRole name |  Attributes  | Member of
-----------+--------------+-----------café      | Cannot login | {}

craig=> \l ca*                           List of databasesName | Owner | Encoding |   Collate   |    Ctype    | Access
privileges
------+-------+----------+-------------+-------------+-------------------café | café  | UTF8     | en_AU.UTF-8 |
en_AU.UTF-8| 
(1 row)

craig=> \c café
FATAL:  database "café" does not exist
Previous connection kept


Um, say what?

This happens because psql does server=>client encoding conversion once
connected, but there's no way to convert the startup message with the
username.

That IMO is an argument to allow startup message format change. (It'd
also then let the server reply with correctly-encoded pre-auth
messages for errors, something we currently fail to do).

-- Craig Ringer                   http://www.2ndQuadrant.com/PostgreSQL Development, 24x7 Support, Training & Services



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

Предыдущее
От: Michael Paquier
Дата:
Сообщение: Re: [HACKERS] What does it mean by XLOG_BACKUP_RECORD?
Следующее
От: Bruce Momjian
Дата:
Сообщение: Re: [HACKERS] Broken hint bits (freeze)