From: Dario Fassi <software@sistemat.com.ar>
To: Oliver Jowett <oliver@opencloud.com>
Cc: Kris Jurka <books@ejurka.com>
Cc: pgsql-jdbc@postgresql.org <pgsql-jdbc@postgresql.org>
Subject: Re: Very strange Error in Updates
Date: Thu, 15 Jul 2004 04:23:01 -0300
Message-ID: <40F630D5.8030907@sistemat.com.ar> (raw)
In-Reply-To: <40F628DA.5010002@opencloud.com>
References: <40F6172D.10301@sistemat.com.ar>
<Pine.BSO.4.56.0407150039290.12845@leary.csoft.net>
<40F61DED.9090609@sistemat.com.ar>
<Pine.BSO.4.56.0407150056540.20585@leary.csoft.net>
<40F62587.1040101@sistemat.com.ar>
<40F628DA.5010002@opencloud.com>
Oliver , you are right ! It's no semantic , the problem remain.
But you can explain why the *exactly* sames values can be inserted and
not updated ?
And why via ODBC , the same statements with the same servers and with
the same Dbs , run without problem ?
Dario.
Oliver Jowett wrote:
> 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
>
> ---------------------------(end of broadcast)---------------------------
> TIP 8: explain analyze is your friend
>
>
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-jdbc@postgresql.org
Cc: software@sistemat.com.ar, oliver@opencloud.com, books@ejurka.com
Subject: Re: Very strange Error in Updates
In-Reply-To: <40F630D5.8030907@sistemat.com.ar>
References: <40F6172D.10301@sistemat.com.ar> <Pine.BSO.4.56.0407150039290.12845@leary.csoft.net> <40F61DED.9090609@sistemat.com.ar> <Pine.BSO.4.56.0407150056540.20585@leary.csoft.net> <40F62587.1040101@sistemat.com.ar> <40F628DA.5010002@opencloud.com> <40F630D5.8030907@sistemat.com.ar>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox