Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1wEdlW-004Eql-1U for pgsql-general@arkaria.postgresql.org; Mon, 20 Apr 2026 01:49:34 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1wEdlV-000Ahg-1h for pgsql-general@arkaria.postgresql.org; Mon, 20 Apr 2026 01:49:33 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1wEdlV-000AhX-0d for pgsql-general@lists.postgresql.org; Mon, 20 Apr 2026 01:49:33 +0000 Received: from sss.pgh.pa.us ([68.162.161.243]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1wEdlT-00000001qqd-0d7c for pgsql-general@lists.postgresql.org; Mon, 20 Apr 2026 01:49:32 +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 63K1nU6C083951; Sun, 19 Apr 2026 21:49:30 -0400 From: Tom Lane To: Ron Johnson cc: "pgsql-generallists.postgresql.org" Subject: Re: List of encodings In-reply-to: References: <71cd4015-9002-4173-bd9a-075f7afb3c20@aklaver.com> <5f263a8a-9c30-4118-b410-6e25eafde156@aklaver.com> Comments: In-reply-to Ron Johnson message dated "Sun, 19 Apr 2026 21:31:43 -0400" MIME-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-ID: <83949.1776649770.1@sss.pgh.pa.us> Content-Transfer-Encoding: 8bit Date: Sun, 19 Apr 2026 21:49:30 -0400 Message-ID: <83950.1776649770@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Ron Johnson writes: > On Sun, Apr 19, 2026 at 9:13 PM Igor Korot wrote: >> Since all 3 are default character sets, which one would be chosen? >> (in the context of CREATE DATABASE) > Does CREATE DATABASE *convert text*? (I think you might be > misunderstanding the purpose of the pg_conversion table.) Indeed. I doubt that CREATE DATABASE references this catalog at all. > Wouldn't it only *convert* text when a client is inserting text of encoding > X into a table with encoding Y? In the current system structure, where conversion actually happens is at the client interface, when sending/receiving data. All text that's running around inside a backend process is expected to be in the database's encoding, and we convert if the client has declared that it wants to work in some other encoding. So the pg_conversion catalog is actually consulted during connection startup, to see if we can support the requested client_encoding with the database encoding. There is also the convert() function, which allows you to convert a blob of text from one encoding to another --- but the input and output are both declared as bytea, so that they don't have to be valid in the current database encoding. IIRC, the client conversion lookups will only choose "condefault" conversions, so that a non-default conversion is only reachable via convert(). So that feature is really pretty vestigial. regards, tom lane