Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kUtUI-00047s-AM for pgsql-bugs@arkaria.postgresql.org; Tue, 20 Oct 2020 15:23:46 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1kUtTk-0007sR-VY for pgsql-bugs@arkaria.postgresql.org; Tue, 20 Oct 2020 15:23:12 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kUtTk-0007sK-PT for pgsql-bugs@lists.postgresql.org; Tue, 20 Oct 2020 15:23:12 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kUtTi-0002XL-DA for pgsql-bugs@lists.postgresql.org; Tue, 20 Oct 2020 15:23:12 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 09KFN7Xr607291; Tue, 20 Oct 2020 11:23:07 -0400 From: Tom Lane To: alexander.kass@jetbrains.com cc: pgsql-bugs@lists.postgresql.org Subject: Re: BUG #16679: Incorrect encoding of database name In-reply-to: <16679-c5176aa79b558094@postgresql.org> References: <16679-c5176aa79b558094@postgresql.org> Comments: In-reply-to PG Bug reporting form message dated "Tue, 20 Oct 2020 10:44:22 -0000" MIME-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-ID: <607289.1603207387.1@sss.pgh.pa.us> Content-Transfer-Encoding: 8bit Date: Tue, 20 Oct 2020 11:23:07 -0400 Message-ID: <607290.1603207387@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk PG Bug reporting form writes: > 1. Create database with name & encoding that won't binary match utf8 encoded > name, e.g: > create database Français > LC_COLLATE 'fr_FR@euro' LC_CTYPE 'fr_FR@euro' > encoding 'latin9' template template0; The short answer is don't do that. The name will be stored in pg_database with whatever encoding the source database (the one you were connected to while issuing CREATE DATABASE) uses, and then it will look funny from any database using another encoding. Connecting to the DB will also fail from any client not using the same encoding, since no encoding conversion is performed during startup-packet processing. Really the workable alternatives are (a) use only ASCII characters in database names, or (b) use the same encoding in every database of the cluster. Similar remarks apply to other globally-visible names, ie roles and tablespaces. It'd be nice in the abstract to have a better answer, but the amount of work required, relative to the practical benefit for people who aren't satisfied with either (a) or (b), is discouraging. Notable problems include what to do when a character in pg_database cannot be translated to the encoding you'd like to use. The connection-request encoding problem in particular seems insoluble without a protocol break, which would cause a lot more unhappiness than happiness. regards, tom lane