Skip site navigation (1) Skip section navigation (2)

Re: Two BLOBs (OID) in table?

From: Stanislav Mironov <smironov(at)gmail(dot)com>
To: Kris Jurka <books(at)ejurka(dot)com>
Cc: pgsql-jdbc(at)postgresql(dot)org
Subject: Re: Two BLOBs (OID) in table?
Date: 2008-04-14 09:18:51
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-jdbc
Kris Jurka wrote:
> On Sun, 13 Apr 2008, Stanislav Mironov wrote:
>> I created entity with 2 BLOB columns in one table: one for image and 
>> one for thumbnail. Storing image and getting it back in another 
>> session works pretty good.
>> But when I set thumbnail BLOB successfully, the original BLOB becomes 
>> empty. Retrieved entity returns length 0 for image BLOB.
>> @Lob private Blob image;
>> @Lob private Blob thumbnail;
>> Hibernate 3.2.6, Annotations 3.3.0, PostgreSQL 8.3.1, JDBC 8.3-603.
>> The problem is 100% reproducible. Please, help?
> It's not clear what JDBC calls this actually involves, so it's 
> difficult to tell where things are going wrong.  If you can create a 
> test case that shows the failure using the postgresql JDBC driver 
> alone, I'd be happy to look at it.

Sorry, I cannot emulate Hibernate (it's too complicated), but I've 
created hibernate test that reproduces this bug.
After some experiments it seems like I've figured out bug sequence: it 
happens because I create thumbnail BLOB with data from image BLOB.

1. getBinaryStream or getBytes on first BLOB before setting second BLOB 
causes first BLOB truncation to zero.

2. Any access (even length()) to first BLOB after setting second BLOB 
with setBlob and executeUpdate causes this bug:
SEVERE: ERROR: invalid large-object descriptor: 0
org.postgresql.util.PSQLException: ERROR: invalid large-object descriptor: 0
    at org.postgresql.fastpath.Fastpath.fastpath(
    at org.postgresql.fastpath.Fastpath.fastpath(
    at org.postgresql.fastpath.Fastpath.getInteger(
    at org.postgresql.largeobject.LargeObject.tell(
    at org.postgresql.largeobject.LargeObject.size(
    at org.hibernate.lob.SerializableBlob.length(

When I replace first BLOB access with fake generated data - everything 
works perfectly as it should. Both BLOBs are stored and retrieved right.
Also original code worked fine with Apache Derby, H2 and MySQL so this 
makes me think the trouble is on PostgreSQL JDBC side.

I'm ready to provide more data on demand.
Thanks in advance!

Stanislav Mironov

In response to


pgsql-jdbc by date

Next:From: Kris JurkaDate: 2008-04-14 15:35:59
Subject: Re: invalid message format and I/O error while comunicating with backend
Previous:From: Sergi VeraDate: 2008-04-14 08:04:57
Subject: Re: invalid message format and I/O error while comunicating with backend

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group