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 1rBmB9-00CKdK-MF for pgsql-interfaces@arkaria.postgresql.org; Sat, 09 Dec 2023 01:30:51 +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 1rBmB7-00DkgU-P8 for pgsql-interfaces@arkaria.postgresql.org; Sat, 09 Dec 2023 01:30:49 +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 1rBmB7-00DkgB-Hp for pgsql-interfaces@lists.postgresql.org; Sat, 09 Dec 2023 01:30:49 +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 1rBmB5-009UvD-2K for pgsql-interfaces@postgresql.org; Sat, 09 Dec 2023 01:30:48 +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 3B91Uhsv1571715; Fri, 8 Dec 2023 20:30:43 -0500 From: Tom Lane To: Jean-Yves Garneau cc: "pgsql-interfaces@postgresql.org" Subject: Re: client_encoding is WIN1252 on ErrorMessage at the StartupMessage In-reply-to: References: Comments: In-reply-to Jean-Yves Garneau message dated "Sat, 09 Dec 2023 01:23:01 +0000" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <1571713.1702085443.1@sss.pgh.pa.us> Content-Transfer-Encoding: quoted-printable Date: Fri, 08 Dec 2023 20:30:43 -0500 Message-ID: <1571714.1702085443@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Jean-Yves Garneau writes: > I'm developing the wire protocol on programmable logic controller (PLC) = to communicate with the backend server. > The PostgreSQL server run on Windows 10 French Canadian. > The client_encoding on the server and database encoding is UTF8. > The collation and character type are French_Canada.1252. > The PLC is UTF8. > After TCP/IP connection, the PLC send the "StartupMessage" but receive a= n "ErrorResponse" because no access right. > The error message is in WIN1252 not UTF8! > If grant connect access to user and get data from database all is UTF8! > Is it a bug or bad setup? Bad setup, I'd say. If you have a connection failure before the backend has joined a particular database, it won't have adopted any database-level encoding or locale; moreover I don't think it's capable of doing encoding translation at that point. So any such messages are going to be sent with encoding matching the postmaster process's native locale, which you seem to have chosen more or less at random. If you have a global expectation about what encoding to use, best make the postmaster's startup locale settings match that. regards, tom lane