db-derby-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Oystein Grovlen - Sun Norway <Oystein.Grov...@Sun.COM>
Subject Lifetime of Blob/Clob objects, compatibility issues
Date Fri, 13 Apr 2007 12:28:42 GMT

As part of the work on using locators for Blob/Clob, we will need to
be able to determine when to garbage collect information about locators.
The JDBC spec says the following about lifetime of Blobs [JDBC 4 spec,
section 16.3.1]:

     For locator based implementations, Blob, Clob and NClob objects
     remain valid for at least the duration of the transaction in which
     they are created, unless their free method is invoked or they are
     garbage collected.

     For implementations that fully materialize the Large Object (LOB),
     the Blob, Clob and NClob objects will remain valid until such time
     as the free method is called or the LOB is garbage collected.

     Portable applications should not depend upon the LOB persisting
     past the end of the transaction.

Note that the current Derby behavior diverges from this spec in
several aspects, and I would say the current behavior is quite a mess.
Some observations I have made:

    - In embedded, objects for short LOB values are valid after
      transaction commit, objects for long values are not.  The same
      holds after the connection is closed.
    - On the client, objects are generally valid after commit.
    - On the client, length() may be called on Clob objects after the
      connection is closed.  However, other methods are not allowed.
    - On the client, no operations can be performed on a Blob after
      connection is closed.

In my opinion, we should strive to get the same behavior regardless
of framework or LOB size.  The plan is to change the lifetime of LOB
objects to correspond to the lifetime of the transaction in which it
was created.  A life beyond the close of the connection, is not
possible on the client side, and an implementation where LOB objects
are valid after commit will be pretty complex, both generally on the
client side and for large LOBs in embedded.

Changing the lifetime for Blob/Clob objects, may cause compatibility
issues for existing applications.  Client applications that currently
access LOB objects after commit, and embedded applications that access
small LOB objects after commit, will have to be changed.  Do people
think this is acceptable?


View raw message