Re: Writing Large Objects - Mailing list pgsql-jdbc

From Tom Lane
Subject Re: Writing Large Objects
Date
Msg-id 9391.1027494890@sss.pgh.pa.us
Whole thread Raw
In response to Writing Large Objects  ("Chris White" <cjwhite@cisco.com>)
List pgsql-jdbc
"Chris White" <cjwhite@cisco.com> writes:
> Documentation states that you must perform large object calls within a
> transaction. Do I need to do a commit when I have written the large object
> or does the close() on the object commit the object to the database. The
> reason I ask, is that I want to commit the object to the database
> independently of updating tables which will contain the objects oid.

Yes, you can.  The important point is that the "LO handle" you get from
lo_open() is only good for the duration of a transaction, so you must
do lo_write and lo_read calls within the transaction.  But you can hold
onto the LO's oid and write that into tables in separate transactions.

But a question for you: if your client application dies after committing
the LO and before committing the references to it from other tables, how
will you know to clean out the LO later?  I'm not at all sure that your
goal is a good idea.  I'd lean towards committing the LO and its table
reference in one transaction.

            regards, tom lane

pgsql-jdbc by date:

Previous
From: bluejacksong
Date:
Subject: Dave Cramer
Next
From: "Thomas De Vos"
Date:
Subject: Re: Sequence ID from INSERT