Обсуждение: Writing Large Objects

Поиск
Список
Период
Сортировка

Writing Large Objects

От
"Chris White"
Дата:
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.
 
Chris White

Re: Writing Large Objects

От
Tom Lane
Дата:
"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