Re: BUG #5637: JDBC driver method setClob always uses getAsciiStream()

From: Kris Jurka <books(at)ejurka(dot)com>
To: Jochen Terstiege <jochen(dot)terstiege(at)quinscape(dot)de>
Cc: pgsql-bugs(at)postgresql(dot)org
Subject: Re: BUG #5637: JDBC driver method setClob always uses getAsciiStream()
Date: 2010-09-03 22:54:21
Message-ID: alpine.BSO.2.00.1009031845260.2391@leary.csoft.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

On Thu, 2 Sep 2010, Jochen Terstiege wrote:

> The following bug has been logged online:
>
> Bug reference: 5637
> Description: JDBC driver method setClob always uses getAsciiStream()
> Details:
>
> Using driver: postgresql-8.4-701.jdbc3.jar
>
> The method setClob() in the AbstractJdbc2Statement calls the method
> getAsciiStream() on the provided Clob.
> This leads to problems if the given Clob contains an UTF-8 encoded string.
>
> Should the driver call getCharacterStream() instead? Can this problem be
> solved in a different way?
>

The issue here is that postgresql doesn't have a real Clob type on the
server, only a Blob type (and even that has some quirks). So the JDBC
driver allows you to retrieve a large object as either a Blob or a Clob.
This means that the data the driver gets is a simple binary stream with
no encoding information.

The JDBC driver uses getAsciiStream because it returns an InputStream
which does not have to deal with encoding conversion which could fail
because it doesn't know the source data's encoding. This is
important so that it can faithfully reproduce an arbitrary PG Clob.
Your complaint is that this doesn't work when passed a non-PG Clob. I
suppose we could try to inspect the Clob to determine if it was a PG Clob
or not and choose different methods based on that determination.

Kris Jurka

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message David Platt 2010-09-04 15:55:01 BUG #5642: pg_upgrade does not handle shared libraries for language handlers
Previous Message Hiroshi Inoue 2010-09-03 22:04:03 Re: BUG #5640: ODBC driver installed but not found