X-Original-To: pgsql-jdbc-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 93D4ED1B195 for ; Thu, 15 Jul 2004 20:42:22 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 33583-07 for ; Thu, 15 Jul 2004 23:42:22 +0000 (GMT) Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by svr1.postgresql.org (Postfix) with ESMTP id 4B3C8D1B181 for ; Thu, 15 Jul 2004 20:42:16 -0300 (ADT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.12.11/8.12.11) with ESMTP id i6FNgGiQ007941; Thu, 15 Jul 2004 19:42:16 -0400 (EDT) To: Oliver Jowett Cc: "Dario V. Fassi" , "pgsql-jdbc@postgresql.org" Subject: Re: Very strange Error in Updates In-reply-to: <40F71217.8080304@opencloud.com> References: <40F6172D.10301@sistemat.com.ar> <40F619A0.8030506@opencloud.com> <40F61CC2.5030704@sistemat.com.ar> <40F61F0E.6020907@opencloud.com> <20559.1089900977@sss.pgh.pa.us> <40F6B35E.4010600@sistemat.com.ar> <40F71217.8080304@opencloud.com> Comments: In-reply-to Oliver Jowett message dated "Fri, 16 Jul 2004 11:24:07 +1200" Date: Thu, 15 Jul 2004 19:42:16 -0400 Message-ID: <7940.1089934936@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200407/195 X-Sequence-Number: 10579 Oliver Jowett writes: > The problem, as I understand it from Tom's explanation, is that > SQL_ASCII only works if everyone is using the same client_encoding; the > server has no knowledge of the real underlying encoding of the data so > can't do conversions. Not only can the server not do conversions, but it cannot count string lengths "correctly" in strings that are really in a multibyte encoding. When JDBC sends a UTF8 string that contains some non-ASCII characters, the server can store the string safely, but it cannot operate on it in any intelligent way. I wonder whether the JDBC driver ought to warn about it if it sees server_encoding == SQL_ASCII? You're certainly just asking for trouble to use JDBC with such a setting. > JDBC always uses a client_encoding of UNICODE. I don't know what ODBC > does, but apparently it's not using UNICODE. ODBC is probably just passing through the client data as-is, and not doing anything at all with the encoding settings. > Perhaps one option is to set the database encoding to UNICODE, and > either get the ODBC driver to issue an appropriate "SET client_encoding" > on connection setup (I don't know if ODBC lets you do this) or set the > default client_encoding in postgresql.conf to whatever is appropriate > for ODBC clients? That would work. Plan B would be to set the database encoding to whatever the ODBC clients are using, and let encoding conversions happen when talking to a JDBC client. The one thing that is absolutely, positively guaranteed not to work is setting the DB encoding to SQL_ASCII. That defeats any chance you have of getting intelligent encoding behavior from the system. regards, tom lane