pg.ddx.io  pgsql-jdbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Oliver Jowett <oliver@opencloud.com>
To: Vasiliev Ivan <biggod@folksnet.com>
Cc: pgsql-jdbc@postgresql.org
Subject: Re: bug report
Date: Sat, 05 Jun 2004 12:22:35 +1200
Message-ID: <40C1124B.9010701@opencloud.com> (raw)
In-Reply-To: <1701580283984.20040604183311@folksnet.com>
References: <1701580283984.20040604183311@folksnet.com>

Vasiliev Ivan wrote:
> Hello All!
> I use a database with type UNICODE, execute query "select *
> from some_table". One field has type text. There are some Europe symbols,
> which code more than 128.

In theory this should be ok assuming the data was inserted with a 
suitable client_encoding.

> In method
> private synchronized String Enconding#decodeUTF8(byte data[], int offset, int length)
> throws SQLException
> exeption ArrayIndexOutOfBoundsException occures in last else block:
> } else {                // length == 2 (maybe add checking for length > 3, throw exception if it is
>       y = data[i+1] & 0xFF;
>       val = (z - 0xC0)* (pow2_6)+(y-0x80);
>       l_cdata[j++] = (char) val;
>       i+=2;
> }
> Then your PSQLException is created.

Do you have a sample schema & data that shows this problem so we can 
reproduce it? Or can you capture the raw byte-by-byte data given to 
decodeUTF8() that causes the problem?

> But I have made a trick :
> } catch (Exception l_e) {
>        try {
>            return new String(data, offset, length, "UTF-8");
>        } catch(Exception e) {
>            throw new PSQLException("postgresql.con.invalidchar", l_e);
>        }
> }
> And, as no exception occures during string creation, your "fast code"
> decodeUTF8() has an error, I suppose....

I believe the String constructors *ignore* errors in the incoming data, 
replacing them with placeholder characters.

Just to check, your JDBC application is not changing client_encoding, right?

-O



view thread (12+ messages)  latest in thread

Message-ID: <40C1124B.9010701@opencloud.com>
Permalink:  ../40C1124B.9010701@opencloud.com/
Also on:    postgresql.org/message-id/40C1124B.9010701@opencloud.com

 · 

reply

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, biggod@folksnet.com
  Subject: Re: bug report
  In-Reply-To: <40C1124B.9010701@opencloud.com>
  References: <1701580283984.20040604183311@folksnet.com> <40C1124B.9010701@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