Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1f86iy-0004BU-5J for pgsql-general@arkaria.postgresql.org; Mon, 16 Apr 2018 16:11:24 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1f86ix-0008SS-2V for pgsql-general@arkaria.postgresql.org; Mon, 16 Apr 2018 16:11:23 +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_SHA384:256) (Exim 4.89) (envelope-from ) id 1f86gv-00014f-8C for pgsql-general@lists.postgresql.org; Mon, 16 Apr 2018 16:09:17 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1f86gr-0000iB-4l for pgsql-general@lists.postgresql.org; Mon, 16 Apr 2018 16:09:16 +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 w3GG99us010582; Mon, 16 Apr 2018 12:09:09 -0400 From: Tom Lane To: Keith Fiske cc: pgsql-general@lists.postgresql.org Subject: Re: client_encoding issue with SQL_ASCII on 8.3 to 10 upgrade In-reply-to: References: Comments: In-reply-to Keith Fiske message dated "Mon, 16 Apr 2018 11:16:40 -0400" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <10580.1523894949.1@sss.pgh.pa.us> Date: Mon, 16 Apr 2018 12:09:09 -0400 Message-ID: <10581.1523894949@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Keith Fiske writes: > Running into an issue with helping a client upgrade from 8.3 to 10 (yes, I > know, please keep the out of support comments to a minimum, thanks :). > The old database was in SQL_ASCII and it needs to stay that way for now > unfortunately. The dump and restore itself works fine, but we're now > running into issues with some data returning encoding errors unless we > specifically set the client_encoding value to SQL_ASCII. I'm guessing you might be hitting this 9.1 change: * Have psql set the client encoding from the operating system locale by default (Heikki Linnakangas) This only happens if the PGCLIENTENCODING environment variable is not set. I think the previous default was to set client encoding equal to the server encoding. > Looking at the 8.3 database, it has the client_encoding value set to UTF8 > and queries seem to work fine. Is this just a bug in the old 8.3 not > enforcing encoding properly? Somewhere along the line we made SQL_ASCII -> something else conversions check that the data was valid per the other encoding, even though no actual data change happens. > The other thing I noticed on the 10 instance was that, while the LOCALE was > set to SQL_ASCII, You mean encoding, I assume. > the COLLATE and CTYPE values for the restored databases > were en_US.UTF-8. Could this be having an affect? This is not a great idea, no. You could be getting strange misbehaviors in e.g. string comparison, because strcoll() will expect UTF8 data and will likely not cope well with data that isn't valid in that encoding. If you can't sanitize the encoding of your data, I'd suggest running with lc_collate and lc_ctype set to "C". regards, tom lane