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.94.2) (envelope-from ) id 1qWRst-003IPM-6z for pgsql-admin@arkaria.postgresql.org; Thu, 17 Aug 2023 01:33:11 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1qWRsq-00BVes-Kx for pgsql-admin@arkaria.postgresql.org; Thu, 17 Aug 2023 01:33:08 +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.94.2) (envelope-from ) id 1qWRsq-00BVei-9K for pgsql-admin@lists.postgresql.org; Thu, 17 Aug 2023 01:33:08 +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.94.2) (envelope-from ) id 1qWRsl-000XX8-0w for pgsql-admin@lists.postgresql.org; Thu, 17 Aug 2023 01:33:05 +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 37H1X02V1717989; Wed, 16 Aug 2023 21:33:00 -0400 From: Tom Lane To: "James Pang (chaolpan)" cc: "pgsql-admin@lists.postgresql.org" Subject: Re: inserts bypass encoding conversion In-reply-to: References: <1320633.1692194575@sss.pgh.pa.us> Comments: In-reply-to "James Pang (chaolpan)" message dated "Thu, 17 Aug 2023 01:08:21 -0000" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <1717987.1692235980.1@sss.pgh.pa.us> Date: Wed, 16 Aug 2023 21:33:00 -0400 Message-ID: <1717988.1692235980@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk "James Pang (chaolpan)" writes: > In this case, the real value stored in database is UTF8 byte sequence > instead of LATIN1 encoding text, right? Not if you have server_encoding = LATIN1, as you stated earlier. In that case, the data in the database is in LATIN1, and chr() interprets its argument as a LATIN1 code value --- which happens to look enough like a Unicode code point to be possibly confusing, until you try to use code points that aren't within LATIN1. regards, tom lane