problem with fe/be protocol and large objects

Started by Eric Marsdenalmost 25 years ago4 messages
#1Eric Marsden
emarsden@mail.dotcom.fr

I am trying to debug my socket-level interface to the backend, which
implements the 6.4 protocol. It works for general queries, but I have
a problem with large objects.

lo_create and lo_unlink seem to work OK; I get an oid which looks ok
and there is a corresponding xinv??? file in the base/ directory.
lo_open returns 0 as a file descriptor. However, following up with one
of the other lo functions which take descriptor arguments (such as
lo_write or lo_tell) fails with

ERROR: lo_tell: invalid large object descriptor (0)

Looking at be-fsstubs.c it seems that this arises when cookies[fd] is
NULL. I don't know what this might come from: the lo_tell is sent
right after the lo_open, on the same connection.

Running the sample lo program in C works, so I suppose the problem
must come from the bytes I'm sending. Any ideas what could cause this?

PostgreSQL 7.0.3 on sparc-sun-solaris2.5.1, compiled by gcc 2.95.2

--
Eric Marsden <URL:http://www.laas.fr/~emarsden/&gt;

#2Denis Perchine
dyp@perchine.com
In reply to: Eric Marsden (#1)
Re: problem with fe/be protocol and large objects

On Monday 12 March 2001 03:24, Eric Marsden wrote:

I am trying to debug my socket-level interface to the backend, which
implements the 6.4 protocol. It works for general queries, but I have
a problem with large objects.

lo_create and lo_unlink seem to work OK; I get an oid which looks ok
and there is a corresponding xinv??? file in the base/ directory.
lo_open returns 0 as a file descriptor. However, following up with one
of the other lo functions which take descriptor arguments (such as
lo_write or lo_tell) fails with

ERROR: lo_tell: invalid large object descriptor (0)

You should do ANY operations with LOs in transaction.

Looking at be-fsstubs.c it seems that this arises when cookies[fd] is
NULL. I don't know what this might come from: the lo_tell is sent
right after the lo_open, on the same connection.

Running the sample lo program in C works, so I suppose the problem
must come from the bytes I'm sending. Any ideas what could cause this?

PostgreSQL 7.0.3 on sparc-sun-solaris2.5.1, compiled by gcc 2.95.2

--
Sincerely Yours,
Denis Perchine

----------------------------------
E-Mail: dyp@perchine.com
HomePage: http://www.perchine.com/dyp/
FidoNet: 2:5000/120.5
----------------------------------

#3Tom Lane
tgl@sss.pgh.pa.us
In reply to: Eric Marsden (#1)
Re: problem with fe/be protocol and large objects

Eric Marsden <emarsden@mail.dotcom.fr> writes:

lo_open returns 0 as a file descriptor. However, following up with one
of the other lo functions which take descriptor arguments (such as
lo_write or lo_tell) fails with

ERROR: lo_tell: invalid large object descriptor (0)

Are you remembering to wrap this sequence in a transaction block
(begin/end)? LO descriptors are only valid till end of transaction.

regards, tom lane

#4Eric Marsden
emarsden@mail.dotcom.fr
In reply to: Eric Marsden (#1)
Re: problem with fe/be protocol and large objects

"tl" == Tom Lane <tgl@sss.pgh.pa.us> writes:

ecm> ERROR: lo_tell: invalid large object descriptor (0)

tl> Are you remembering to wrap this sequence in a transaction block
tl> (begin/end)? LO descriptors are only valid till end of
tl> transaction.

that was it, thanks. The code used to work with PostgreSQL 6.3, and I
hadn't seen the relevant warning in the programmer's guide.

--
Eric Marsden <URL:http://www.laas.fr/~emarsden/&gt;