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 8D6DCD1B1BC for ; Thu, 15 Jul 2004 03:49:08 -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 20774-05 for ; Thu, 15 Jul 2004 06:49:11 +0000 (GMT) Received: from yass.opencloud.co.nz (yass.opencloud.co.nz [203.79.85.162]) by svr1.postgresql.org (Postfix) with ESMTP id E0A64D1B1AA for ; Thu, 15 Jul 2004 03:49:03 -0300 (ADT) Received: from flood.opencloud.co.nz ([192.168.0.31] helo=opencloud.com ident=oliver) by yass.opencloud.co.nz with esmtp (Exim 3.35 #1 (Debian)) id 1Bl03C-0006HC-00; Thu, 15 Jul 2004 18:49:02 +1200 Message-ID: <40F628DA.5010002@opencloud.com> Date: Thu, 15 Jul 2004 18:48:58 +1200 From: Oliver Jowett User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.6b) Gecko/20031205 Thunderbird/0.4 X-Accept-Language: en-us, en MIME-Version: 1.0 To: "Dario V. Fassi" Cc: Kris Jurka , "pgsql-jdbc@postgresql.org" Subject: Re: Very strange Error in Updates References: <40F6172D.10301@sistemat.com.ar> <40F61DED.9090609@sistemat.com.ar> <40F62587.1040101@sistemat.com.ar> In-Reply-To: <40F62587.1040101@sistemat.com.ar> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit 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/175 X-Sequence-Number: 10559 Dario V. Fassi wrote: > Server 7.3.4 for W2K and Linux too. > Encoding SQL_ASCII in both cases. > > I understand the source of the problem , but the ASCII encoding are > not 7 bits , it has 8 bits with international charsets in codepages, > like values in examples. > You are talking about US-ASCII charset , that is a Unicode subset of 7 bits. You're arguing over nomenclature here. At the end of the day, a postgresql database encoding of SQL_ASCII means 7-bit ASCII; if you call that US-ASCII, fine, but it doesn't change the problem. With an encoding of SQL_ASCII the server does not have sufficient information to translate characters >127 between the database encoding and UNICODE, which is required by the JDBC driver (even if the JDBC driver did not set client_encoding to UNICODE, it'd still have to somehow do this translation itself since Java strings are represented as UTF-16). See http://www.postgresql.org/docs/current/static/multibyte.html for some more details. The JDBC driver will always use a "client character set" of UNICODE when talking to a >= 7.3 server. > No matter that , and speaking in CHARS , if I'm putting a 30 chars > length string at a field of 30 chars length , > I think that the driver can/must assure, a 30 chars length string transfer. > May be a "data truncation" warning can be acceptable, or a replacement > byte/char, or cutting the eight bit , > but it's no sufficient reason to abort the update. > > What 's your opinion ? The server already does a replacement -- the problem is that the replacement may be longer than one character (see the referenced docs above for handling of unrepresentable characters). So the server-side representation of a "30 character" Java string may actually be longer than 30 characters in the database encoding. Either way there's nothing the driver can really do about it -- we don't want to duplicate all the knowledge about charset conversions on the driver side (currently, the driver does know some details about encodings, but that's only there to support pre-7.3 servers). We just hand off a valid UNICODE string and let the server deal with it. If the server generates an error and aborts the transaction -- too bad, it's not the driver's fault. The best option is to fix your database encoding; UNICODE is your best bet if you're only talking to it via JDBC. If you really want silent truncation (bad idea!) you can get that via an explicit cast to varchar(30) in your query. -O