BUG #16679: Incorrect encoding of database name

From: PG Bug reporting form <noreply(at)postgresql(dot)org>
To: pgsql-bugs(at)lists(dot)postgresql(dot)org
Cc: alexander(dot)kass(at)jetbrains(dot)com
Subject: BUG #16679: Incorrect encoding of database name
Date: 2020-10-20 10:44:22
Message-ID: 16679-c5176aa79b558094@postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

The following bug has been logged on the website:

Bug reference: 16679
Logged by: Alexander Kass
Email address: alexander(dot)kass(at)jetbrains(dot)com
PostgreSQL version: 13.0
Operating system: Linux
Description:

Steps to reproduce:
1. Create database with name & encoding that won't binary match utf8 encoded
name, e.g:
> create database Français
LC_COLLATE 'fr_FR(at)euro' LC_CTYPE 'fr_FR(at)euro'
encoding 'latin9' template template0;
2. Now check pg_database from different databases:
aurora=> \connect français
français=> select * from pg_database;
datname | datdba | encoding | datcollate | datctype | datistemplate |
datallowconn | datconnlimit | datlastsysoid | datfrozenxid | datminmxid |
dattablespace | datacl
-----------+--------+----------+-------------+-------------+---------------+--------------+--------------+---------------+--------------+------------+---------------+-------------------------------------
postgres | 16399 | 6 | en_US.UTF-8 | en_US.UTF-8 | f |
t | -1 | 13933 | 549 | 1 |
1663 |
français | 16399 | 16 | fr_FR(at)euro | fr_FR(at)euro | f |
t | -1 | 13933 | 549 | 1 |
1663 |
..........

français=> \connect postgres
postgres=> select * from pg_database;
datname | datdba | encoding | datcollate | datctype | datistemplate |
datallowconn | datconnlimit | datlastsysoid | datfrozenxid | datminmxid |
dattablespace | datacl
-----------+--------+----------+-------------+-------------+---------------+--------------+--------------+---------------+--------------+------------+---------------+-------------------------------------
postgres | 16399 | 6 | en_US.UTF-8 | en_US.UTF-8 | f |
t | -1 | 13933 | 549 | 1 |
1663 |
français | 16399 | 16 | fr_FR(at)euro | fr_FR(at)euro | f |
t | -1 | 13933 | 549 | 1 |
1663 |
...........

See incorrectly encoded database name. The same applies for
current_database().
If I do encode(datname::bytea, 'hex') result is matches. It looks like
automatic conversion latin9 -> utf8 is done for français database, but name
is already utf8.
Checked on PG13 & aws aurora

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Alvaro Herrera 2020-10-20 13:41:14 Re: BUG #16676: SELECT ... FETCH FIRST ROW WITH TIES FOR UPDATE SKIP LOCKED locks rows it doesn't return
Previous Message Michael Paquier 2020-10-20 01:52:25 Re: invalid alloc size error possible in shm_mq