From: Kris Jurka <books@ejurka.com>
To: Michael Barker <mike@middlesoft.co.uk>
Cc: pgsql-jdbc@postgresql.org
Subject: Re: [Patch] JDBC3 Blob support
Date: Sun, 20 Mar 2005 17:39:46 -0500 (EST)
Message-ID: <Pine.BSO.4.56.0503201658370.32696@leary.csoft.net> (raw)
In-Reply-To: <1109997557.3838.1.camel@corona>
References: <1108864694.5883.5.camel@corona>
<Pine.BSO.4.56.0502191512160.18612@leary.csoft.net>
<1109997557.3838.1.camel@corona>
On Fri, 4 Mar 2005, Michael Barker wrote:
> Attached is a patch for Blob and Clob support with JUnits.
>
I've finally gotten around to reviewing this. The real problem is how to
deal with Clobs and encodings. PostgreSQL doesn't really have any
specific character large object support and the jdbc driver just
layers the Clob type on the existing binary large objects. From
the server's perspective it is all just binary data which makes
things like length return a number of bytes instead of the number
of characters, at least for a multibyte encoding.
As I see it we've got a number of poor options:
1) Always use a single byte encoding (like US-ASCII) for storing data even
though this cannot store all characters.
2) Always use a multibyte encoding (like UTF-8) for storing data even
though this will break many length/positioning methods.
3) Allow the user to select the encoding via a URL parameter.
4) Use the database's server encoding even though this won't always have a
JVM equivalent.
5) Use the JVM's encoding.
3) Seems like the only way to really allow a user to pick their poison.
Anyone else have an opinion? I suppose we could move a lot of the large
object exection from the server to the JDBC driver so it could correctly
count characters, but that'd we quite a performance hit.
I've attached the version of the patch that I've adjusted slightly and
pretty much ignores encoding entirely.
Finally some technical comments on the original patch:
You shouldn't throw a SQLException without a SQL State. To help enforce
this we throw org.postgresql.util.PSQLException that doesn't have a
constructor without a SQL state aregument.
In the unit tests you write:
if (rs.next()) {
// do something
} else {
assertFalse("Message", true);
}
We don't use assertFalse in order to retain compatibility with junit 3.7.
Also this is written more clearly as:
assertTrue(rs.next());
// do something
Kris Jurka
Attachments:
blobclob.patch.gz (application/octet-stream, 4.7K) download
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: books@ejurka.com, mike@middlesoft.co.uk
Subject: Re: [Patch] JDBC3 Blob support
In-Reply-To: <Pine.BSO.4.56.0503201658370.32696@leary.csoft.net>
References: <1108864694.5883.5.camel@corona> <Pine.BSO.4.56.0502191512160.18612@leary.csoft.net> <1109997557.3838.1.camel@corona> <Pine.BSO.4.56.0503201658370.32696@leary.csoft.net>
* 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