pg.ddx.io pgsql-jdbc@postgresql.org mailing list archive
help / color / mirror / Atom feedBug in JDBC driver w/BLOBs
2+ messages / 2 participants
[nested] [flat]
* Bug in JDBC driver w/BLOBs
@ 2005-06-21 15:41 Tristan Tarrant <tristan.tarrant@dataforte.net>
2005-06-21 15:56 ` Re: Bug in JDBC driver w/BLOBs Kris Jurka <books@ejurka.com>
0 siblings, 1 reply; 2+ messages in thread
From: Tristan Tarrant @ 2005-06-21 15:41 UTC (permalink / raw)
To: pgsql-jdbc
Dear all,
first of all I would like to thank all you hard-working postgresql JDBC
hackers: I have been using your work for quite a while, and I appreciate
what you do.
Now the bad news: I believe I have found a bug in the pgsql jdbc driver
regarding read access of BLOBs. According to Sun's JDBC documentation,
BLOBs are 1-based, but the driver makes the assumption they are 0-based.
Here is the excerpt from javadoc:
public byte[] getBytes(long pos, int length)
throws SQLException
Retrieves all or part of the BLOB value that this Blob object
represents, as an array of bytes. This byte array contains up to
length consecutive bytes starting at position pos.
Parameters:
pos - the ordinal position of the first byte in the BLOB value
to be extracted; the first byte is at position 1
length - the number of consecutive bytes to be copied
After patching org/postgresql/jdbc2/AbstractJdbc2Blob.java (I am using
the 8.0 311 sources) as follows:
inline patch 1: AbstractJdbc2Blob.java (+1/-1 lines) download inline-1.patch
--- AbstractJdbc2Blob.java~ 2005-06-21 17:11:20.000000000 +0200
+++ AbstractJdbc2Blob.java 2005-06-21 17:11:20.000000000 +0200
@@ -38,7 +38,7 @@
public byte[] getBytes(long pos, int length) throws SQLException
{
- lo.seek((int)pos, LargeObject.SEEK_SET);
+ lo.seek((int)(pos-1), LargeObject.SEEK_SET);
return lo.read(length);
}
everything works as advertised.
Am I right ? Am I completely wrong ?
Let me know.
Tristan
Attachments:
smime.p7s (application/x-pkcs7-signature, 3.1K) download
^ permalink raw reply [nested|flat] 2+ messages in thread
* Re: Bug in JDBC driver w/BLOBs
2005-06-21 15:41 Bug in JDBC driver w/BLOBs Tristan Tarrant <tristan.tarrant@dataforte.net>
@ 2005-06-21 15:56 ` Kris Jurka <books@ejurka.com>
0 siblings, 0 replies; 2+ messages in thread
From: Kris Jurka @ 2005-06-21 15:56 UTC (permalink / raw)
To: Tristan Tarrant <tristan.tarrant@dataforte.net>; +Cc: pgsql-jdbc
On Tue, 21 Jun 2005, Tristan Tarrant wrote:
> Now the bad news: I believe I have found a bug in the pgsql jdbc driver
> regarding read access of BLOBs. According to Sun's JDBC documentation,
> BLOBs are 1-based, but the driver makes the assumption they are 0-based.
Right. This was found and fixed a while ago:
http://gborg.postgresql.org/pipermail/pgjdbc-commit/2005-May/000289.html
I guess we need to put out a new stable release.
Kris Jurka
^ permalink raw reply [nested|flat] 2+ messages in thread
end of thread, other threads:[~2005-06-21 15:56 UTC | newest]
Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2005-06-21 15:41 Bug in JDBC driver w/BLOBs Tristan Tarrant <tristan.tarrant@dataforte.net>
2005-06-21 15:56 ` Kris Jurka <books@ejurka.com>
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