Re: protocol version negotiation (Re: Libpq PGRES_COPY_BOTH - version compatibility)

From: Craig Ringer <craig(at)2ndquadrant(dot)com>
To: Robert Haas <robertmhaas(at)gmail(dot)com>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Peter Eisentraut <peter_e(at)gmx(dot)net>, Magnus Hagander <magnus(at)hagander(dot)net>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: protocol version negotiation (Re: Libpq PGRES_COPY_BOTH - version compatibility)
Date: 2017-06-29 01:55:17
Message-ID: CAMsr+YEAWN_7JQaGWfUMgDjyO9d-Z-Sdj7hiosprVHVh_Kt42g@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 29 June 2017 at 09:44, Craig Ringer <craig(at)2ndquadrant(dot)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 roles
Role name | Attributes | Member of
-----------+--------------+-----------
café | Cannot login | {}

postgres=# \l ca*
List of databases
Name | Owner | Encoding | Collate | Ctype | Access privileges
------+-------+----------+-------------+-------------+-------------------
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(at)ayaki-localdomain log]$ psql -U "café"
psql: FATAL: role "café" does not exist
[craig(at)ayaki-localdomain log]$ psql
psql (9.6.3, server 9.5.7)
Type "help" for help.

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

craig=> \l ca*
List of databases
Name | 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

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Bruce Momjian 2017-06-29 02:11:35 Re: Broken hint bits (freeze)
Previous Message Michael Paquier 2017-06-29 01:49:09 Re: What does it mean by XLOG_BACKUP_RECORD?