Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1h8mqk-0007gp-K9 for pgsql-general@arkaria.postgresql.org; Tue, 26 Mar 2019 14:14:46 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1h8mqi-0004f0-98 for pgsql-general@arkaria.postgresql.org; Tue, 26 Mar 2019 14:14:44 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1h8mqi-0004et-0K for pgsql-general@lists.postgresql.org; Tue, 26 Mar 2019 14:14:44 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1h8mqa-000073-P3 for pgsql-general@lists.postgresql.org; Tue, 26 Mar 2019 14:14:43 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.4/8.14.4) with ESMTP id x2QEEW5I018059; Tue, 26 Mar 2019 10:14:32 -0400 From: Tom Lane To: "Brad Nicholson" cc: Thomas Tignor , "pgsql-general@lists.postgresql.org" , Vijaykumar Jain Subject: Re: [External] postgres 9.5 DB corruption: invalid byte sequence for encoding "UTF8" In-reply-to: References: <1080815989.10741938.1553539577631.ref@mail.yahoo.com> <1080815989.10741938.1553539577631@mail.yahoo.com> <458346306.10942574.1553559949857@mail.yahoo.com> Comments: In-reply-to "Brad Nicholson" message dated "Tue, 26 Mar 2019 08:59:18 -0500" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <18057.1553609672.1@sss.pgh.pa.us> Date: Tue, 26 Mar 2019 10:14:32 -0400 Message-ID: <18058.1553609672@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk "Brad Nicholson" writes: > Thomas Tignor wrote on 03/25/2019 08:25:49 PM: >> Thanks for writing. As I mentioned to Vijay, the "source" is a JVM >> using the postgres v42.0.0 JDBC driver. I do not believe we have any >> explicit encoding set, and so I expect the client encoding is >> SQL_ASCII. The DB is most definitely UTF8. > These statements are contradictory. > The value of client_encoding from your select on pg_settings is SQL_ASCII. > The docs clearly state: > https://www.postgresql.org/docs/9.5/runtime-config-client.html > "Sets the client-side encoding (character set). The default is to use the > database encoding. " > If you don't have client_encoding explicitly, then it is using the database > encoding. Umm ... not necessarily. That bit in runtime-config-client.html correctly states what the *server's* default for client_encoding is, but an awful lot of client-side code will immediately override that. psql will try to set it based on its LANG/LC_CTYPE environment, for example. I don't know what JDBC does; it might be different. But in any case, yes, it'd be more reliable to check pg_database.encoding explicitly. regards, tom lane