pg.ddx.io pgsql-jdbc@postgresql.org mailing list archive
help / color / mirror / Atom feedBlob getBinaryStream issue.
2+ messages / 2 participants
[nested] [flat]
* Blob getBinaryStream issue.
@ 2004-06-23 15:28 Pete Lewin-Harris <pete@illumining.com>
0 siblings, 1 reply; 2+ messages in thread
From: Pete Lewin-Harris @ 2004-06-23 15:28 UTC (permalink / raw)
To: pgsql-jdbc
I'm getting an odd result when I try and get the length of a blob after I
have closed it's binary stream. In the snippet below, the final line throws
a PSQL Exception with the message 'FastPath call returned ERROR: invalid
large-object descriptor: 0'. If the final line is removed and
getBinaryStream called again, the second stream fails on first read with a
null pointer exception.
Statement stat = con.createStatement();
ResultSet rs = stat.executeQuery("SELECT blobdata from mytable where id =
1");
if (rs.next())
{
Blob blob = rs.getBlob(1);
InputStream is = blob.getBinaryStream();
is.close();
long len = blob.length();
}
Two questions, really.
Firstly, is it a bug that multiple calls to getBinaryStream do not return
separate InputStream objects or is it just the way it works and I need to
re-get the blob if I want to read the stream again?
Secondly, If this is the correct behaviour the shouldn't the exceptions
thrown be slightly more friendly? Perhaps calling getBinaryStream after the
stream has been closed should return null?
cheers, Pete
^ permalink raw reply [nested|flat] 2+ messages in thread
* Re: Blob getBinaryStream issue.
@ 2004-06-24 07:01 Kris Jurka <books@ejurka.com>
parent: Pete Lewin-Harris <pete@illumining.com>
0 siblings, 0 replies; 2+ messages in thread
From: Kris Jurka @ 2004-06-24 07:01 UTC (permalink / raw)
To: Pete Lewin-Harris <pete@illumining.com>; +Cc: pgsql-jdbc
On Wed, 23 Jun 2004, Pete Lewin-Harris wrote:
> I'm getting an odd result when I try and get the length of a blob after I
> have closed it's binary stream. In the snippet below, the final line throws
> a PSQL Exception with the message 'FastPath call returned ERROR: invalid
> large-object descriptor: 0'. If the final line is removed and
> getBinaryStream called again, the second stream fails on first read with a
> null pointer exception.
>
> Firstly, is it a bug that multiple calls to getBinaryStream do not return
> separate InputStream objects or is it just the way it works and I need to
> re-get the blob if I want to read the stream again?
This looks like a bug to me. They do actually return separate InputStream
objects, but the close method for it closes the underlying shared Blob.
Of course since they are based on the same shared blob, it would be
difficult to use more than one stream at a time since the actual position
information is stored in the shared object. I'll investigate further, but
for now a potential simple fix would be to change
org.postgresql.largeobject.BlobInputStream#close() to not close the
underlying large object.
Kris Jurka
^ permalink raw reply [nested|flat] 2+ messages in thread
end of thread, other threads:[~2004-06-24 07:01 UTC | newest]
Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2004-06-23 15:28 Blob getBinaryStream issue. Pete Lewin-Harris <pete@illumining.com>
2004-06-24 07:01 ` 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