Re: [EUC_CN] Failed to connect through user created user/database using simplified Chinese characters

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Neha Sharma <neha(dot)sharma(at)enterprisedb(dot)com>
Cc: PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: [EUC_CN] Failed to connect through user created user/database using simplified Chinese characters
Date: 2019-12-05 15:50:05
Message-ID: 15565.1575561005@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Neha Sharma <neha(dot)sharma(at)enterprisedb(dot)com> writes:
> It was observed that when we try to connect through a user/database
> created using simplified Chinese characters on EUC_CN server_encoding,
> it fails giving error that the object does not exists. Whereas if we
> query the system table we can find their entries there.

This looks like an encoding conversion problem. The connection request
has to spell the user name bitwise identically to the way it is stored
in pg_authid; no conversions will be applied at that point. You have

> postgres=# show server_encoding ;
> server_encoding
> -----------------
> EUC_CN
> (1 行记录)

> postgres=# show client_encoding ;
> client_encoding
> -----------------
> UTF8
> (1 行记录)

> postgres=# create user 伐角 with password '规';
> CREATE ROLE

so what this did, likely, is transmit the characters to the server
in UTF8, then the server converted them to EUC_CN, and stored them
in the catalogs in EUC_CN. But here:

> postgres=# \c - 伐角
> FATAL: role "伐角" does not exist
> Previous connection kept

those characters are again being sent to the server in UTF8,
and it has no context that would tell it to convert to EUC_CN.

This is all pretty messy, and I've not heard any fix proposals that
wouldn't amount to shifting the pain to somebody else's use-case.
The short answer, if you want to use non-ASCII characters in user names,
passwords, or database names, is to always run the server and the client
with the same encodings.

regards, tom lane

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Rushabh Lathia 2019-12-05 16:22:21 Re: backup manifests
Previous Message Tom Lane 2019-12-05 15:38:55 Re: Removal of support for OpenSSL 0.9.8 and 1.0.0