Thread: BUG #2823: API largeobject calls

BUG #2823: API largeobject calls

From
"Gregor"
Date:
The following bug has been logged online:

Bug reference:      2823
Logged by:          Gregor
Email address:      gtm2@interia.pl
PostgreSQL version: 8.2, 8.1
Operating system:   Windows
Description:        API largeobject calls
Details:

Hello,
API funtions lo_open, lo_write, lo_import don't work.
While lo_create returns positive integr value ( and the record with this
loid is inserted into pg_largeobject table) lo_open return always zero
value
with when this non-zero positive loid value obtained from lo_create is
passed to lo_open. And lo_write returns -1 when this zero value obtained
from lo_open is passed to lo_write.

Re: BUG #2823: API largeobject calls

From
Tom Lane
Date:
"Gregor" <gtm2@interia.pl> writes:
> API funtions lo_open, lo_write, lo_import don't work.

You need to do lo_open/lo_write/etc inside a transaction block, because
the LO handle returned by lo_open is only good until end of transaction.
(And yes, zero is a valid handle.)  See the example program in the docs:
http://www.postgresql.org/docs/8.2/static/lo-examplesect.html
and note the begin/commit commands it issues.

            regards, tom lane