Обсуждение: NULL Blob column error
My code has a table with an OID that's allowed to be NULL. When I went to
retrieve the blob using a ResultSet.getBlob() call, I got an exception. It
appears that a NULL OID value is not being handled correctly since it should
set the state within ResultSet so that I can call ResultSet.wasNull() to see
if the object was retrieved or not.
I received the following exception on 7.2.2:
FastPath call returned ERROR: inv_open: large object 0 not found
at org.postgresql.fastpath.Fastpath.fastpath(Fastpath.java:131)
at org.postgresql.fastpath.Fastpath.fastpath(Fastpath.java:181)
at org.postgresql.fastpath.Fastpath.getInteger(Fastpath.java:193)
at
org.postgresql.largeobject.LargeObject.<init>(LargeObject.java:89)
at
org.postgresql.largeobject.LargeObjectManager.open(LargeObjectManager.java:1
33)
at org.postgresql.largeobject.PGblob.<init>(PGblob.java:37)
at org.postgresql.jdbc2.ResultSet.getBlob(ResultSet.java:934)
Thanks,
David
Originally I thought this was going to be worse than I thought since I'm not
familiar with the fastpath code at all. However, a check of ResultSet.java
shows that the null check simply was not being done for getBlob().
Therefore, this patch for 7.2.2 will resolve the "FastPath call returned
ERROR: inv_open: large object 0 not found" exception when retrieving
Blob/OID that is NULL. I noted that this bug remains in the latest CVS as
well.
[postgresql@dev1 jdbc2]$ diff -c ResultSet.orig ResultSet.java
*** ResultSet.orig Sat Jan 5 14:26:22 2002
--- ResultSet.java Tue Sep 10 11:03:11 2002
***************
*** 931,936 ****
--- 931,940 ----
public Blob getBlob(int i) throws SQLException
{
+ wasNullFlag = (this_row[i - 1] == null);
+ if (wasNullFlag)
+ return null;
+
return new org.postgresql.largeobject.PGblob(connection,
getInt(i));
}
David
Patch applied.
--Barry
David Wall wrote:
> Originally I thought this was going to be worse than I thought since I'm not
> familiar with the fastpath code at all. However, a check of ResultSet.java
> shows that the null check simply was not being done for getBlob().
> Therefore, this patch for 7.2.2 will resolve the "FastPath call returned
> ERROR: inv_open: large object 0 not found" exception when retrieving
> Blob/OID that is NULL. I noted that this bug remains in the latest CVS as
> well.
>
> [postgresql@dev1 jdbc2]$ diff -c ResultSet.orig ResultSet.java
> *** ResultSet.orig Sat Jan 5 14:26:22 2002
> --- ResultSet.java Tue Sep 10 11:03:11 2002
> ***************
> *** 931,936 ****
> --- 931,940 ----
>
> public Blob getBlob(int i) throws SQLException
> {
> + wasNullFlag = (this_row[i - 1] == null);
> + if (wasNullFlag)
> + return null;
> +
> return new org.postgresql.largeobject.PGblob(connection,
> getInt(i));
> }
>
>
> David
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 3: if posting/reading through Usenet, please send an appropriate
> subscribe-nomail command to majordomo@postgresql.org so that your
> message can get through to the mailing list cleanly
>