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: 4803217B.4060206@gmail.com (view raw or flat)
Thread:
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.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:1548)
    at 
org.postgresql.core.v3.QueryExecutorImpl.receiveFastpathResult(QueryExecutorImpl.java:586)
    at 
org.postgresql.core.v3.QueryExecutorImpl.fastpathCall(QueryExecutorImpl.java:485)
    at org.postgresql.fastpath.Fastpath.fastpath(Fastpath.java:74)
    at org.postgresql.fastpath.Fastpath.fastpath(Fastpath.java:114)
    at org.postgresql.fastpath.Fastpath.getInteger(Fastpath.java:126)
    at org.postgresql.largeobject.LargeObject.tell(LargeObject.java:264)
    at org.postgresql.largeobject.LargeObject.size(LargeObject.java:279)
    at 
org.postgresql.jdbc2.AbstractJdbc2BlobClob.length(AbstractJdbc2BlobClob.java:44)
    at org.hibernate.lob.SerializableBlob.length(SerializableBlob.java:31)
    at 
ru.smilabs.mir.centre.db.PostgreSQLTest$3.run(PostgreSQLTest.java:142)

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

Responses

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-2014 The PostgreSQL Global Development Group