Re: Writing Large Objects

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: cjwhite(at)cisco(dot)com
Cc: pgsql-jdbc(at)postgresql(dot)org
Subject: Re: Writing Large Objects
Date: 2002-07-24 07:14:50
Message-ID: 9391.1027494890@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-jdbc

"Chris White" <cjwhite(at)cisco(dot)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

In response to

Browse pgsql-jdbc by date

  From Date Subject
Next Message Elielson Fontanezi 2002-07-24 18:01:03 server-side
Previous Message bluejacksong 2002-07-24 02:54:56 Dave Cramer