From: Oliver Jowett <oliver@opencloud.com>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: Dario V. Fassi <software@sistemat.com.ar>
Cc: pgsql-jdbc@postgresql.org <pgsql-jdbc@postgresql.org>
Subject: Re: Very strange Error in Updates
Date: Fri, 16 Jul 2004 11:34:45 +1200
Message-ID: <40F71495.20402@opencloud.com> (raw)
In-Reply-To: <20559.1089900977@sss.pgh.pa.us>
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>
Tom Lane wrote:
>>2) the server converts from client_encoding UNICODE to database encoding
>>SQL_ASCII; for characters that are invalid in SQL_ASCII (>127) it does
>>some arbitary conversion, probably just copying the illegal values
>>unchanged.
>
>
> Not really. SQL_ASCII encoding basically means "we don't know what this
> data is, just store it verbatim". So the UTF-8 string sent by the
> driver is stored verbatim.
Hmm, so SQL_ASCII is not really a first-class encoding -- it doesn't do
encoding conversions at all? It's going to break horribly in the face of
clients using different client_encoding values, and somewhat less
horribly even when everything uses a client_encoding of UNICODE (i.e.
string lengths are wrong)?
I wonder if the server behaviour could be somehow changed so that people
don't shoot themselves in the foot so often (variants on this problem
come up again and again..). The problem is that it works most of the
time, only breaking on certain data, so it's not instantly apparent that
you have a problem.
What about refusing to change client_encoding to something other than
SQL_ASCII on SQL_ASCII databases? (This would make the JDBC driver
unusable against those database even for data that currently appears to
work, though)
Or perhaps the JDBC driver could issue a warning whenever it notices the
underlying encoding is SQL_ASCII (this means another round-trip on
connection setup even when using V3 though). Or refuse to even try to
encode strings with characters >127 when the database encoding is SQL_ASCII.
>>The solution is to use a database encoding that matches your data.
>
> Actually, if you intend to access the database primarily through JDBC,
> it'd be best to use server encoding UNICODE. The JDBC driver will
> always want UNICODE on the wire, and I see no reason to force extra
> character set conversions. Non-UNICODE-aware clients can be handled by
> setting client_encoding properly.
Sure -- it just depends on what other clients use the db. By the sounds
of it in this case the other client is an ODBC client that isn't aware
of encodings at all.. I suppose this can be handled by the default
client_encoding setting in postgresql.conf?
-O
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: oliver@opencloud.com, tgl@sss.pgh.pa.us, software@sistemat.com.ar
Subject: Re: Very strange Error in Updates
In-Reply-To: <40F71495.20402@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> <40F71495.20402@opencloud.com>
* 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