From: Oliver Jowett <oliver@opencloud.com>
To: Dario V. Fassi <software@sistemat.com.ar>
Cc: pgsql-jdbc@postgresql.org <pgsql-jdbc@postgresql.org>
Subject: Re: Very strange Error in Updates
Date: Thu, 15 Jul 2004 18:07:10 +1200
Message-ID: <40F61F0E.6020907@opencloud.com> (raw)
In-Reply-To: <40F61CC2.5030704@sistemat.com.ar>
References: <40F6172D.10301@sistemat.com.ar>
<40F619A0.8030506@opencloud.com>
<40F61CC2.5030704@sistemat.com.ar>
Dario V. Fassi wrote:
>
>
> Oliver Jowett wrote:
>
>> Dario V. Fassi wrote:
>>
>>> When the parameter fill the full-length of receiving field and has
>>> any non common character, the update throw a exception like:
>>>
>>> java.sql.SQLException: ERROR: value too long for type character
>>> varying(30)
>>> at
>>> org.postgresql.core.v2.QueryExecutorImpl.receiveErrorMessage(QueryExecutorImpl.java:420)
>>
>>
>>
>>
>>
>> What server version (I'm guessing <= 7.3 since the driver is using the
>> V2 protocol) and database encoding are you using?
>>
>> -O
>
>
> Server 7.3.4 for W2K and Linux too.
> Encoding SQL_ASCII in both cases.
You can only put 7-bit characters into a SQL_ASCII database.
The JDBC driver always speaks UNICODE when it can, since that matches
Java's internal string representation. I suspect that what's happening is:
0) the driver sets client_encoding = UNICODE during connection setup
1) the driver encodes the parameter as UNICODE (== UTF8); for characters
above 127 this encoding will result in more than one byte per character.
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.
3) you end up with extra characters in the resulting value which exceeds
the varchar's size.
The solution is to use a database encoding that matches your data.
-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, software@sistemat.com.ar
Subject: Re: Very strange Error in Updates
In-Reply-To: <40F61F0E.6020907@opencloud.com>
References: <40F6172D.10301@sistemat.com.ar> <40F619A0.8030506@opencloud.com> <40F61CC2.5030704@sistemat.com.ar> <40F61F0E.6020907@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