pg.ddx.io  pgsql-admin@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Michael Fuhr <mike@fuhr.org>
Cc: pgsql-hackers@postgreSQL.org, sandhya <sandhyar@amiindia.co.in>
Subject: Re: [ADMIN] Reg:lo_open error..pls help me
Date: Wed, 01 Mar 2006 11:30:10 -0500
Message-ID: <11346.1141230610@sss.pgh.pa.us> (raw)
In-Reply-To: <20060301161059.GA80123@winnie.fuhr.org>
References: <018201c63d27$34f26ec0$cd00000a@sandhyar>
	<01b701c63d2a$4d640880$cd00000a@sandhyar>
	<11079.1141228992@sss.pgh.pa.us>
	<20060301161059.GA80123@winnie.fuhr.org>

Michael Fuhr <mike@fuhr.org> writes:
> On Wed, Mar 01, 2006 at 11:03:12AM -0500, Tom Lane wrote:
>> Are you sure that's where it's failing?  The fragment you showed looks
>> fine as far as it goes.  The most likely bet is you forgot to wrap it in
>> a transaction (BEGIN/COMMIT commands), but that would result in a
>> failure at the seek/write commands because the object wouldn't be open
>> anymore.

> lo_open() fails if it's not in a transaction.  The error from
> PQerrorMessage is:
> ERROR:  invalid large-object descriptor: 0

Hmm, I wonder why that is [ looks at code ... ]

The culprit seems to be this little bit in libpq's lo_open() function:

        /* have to do this to reset offset in shared fd cache */
        /* but only if fd is valid */
        if (fd >= 0 && lo_lseek(conn, fd, 0L, SEEK_SET) < 0)
            return -1;
        return fd;

Outside a transaction block, this fails since the LO FD is already
closed by the time the lo_lseek request is run.

This hack goes all the way back --- it's in our original CVS version,
and there is equivalent code in Postgres v4r2 --- but it sure looks to
me like a workaround for a long-forgotten bug.  It's forcing an extra
network round trip for every lo_open, so I'm very strongly tempted to
remove it.  Comments?

			regards, tom lane



view thread (5+ messages)

Message-ID: <11346.1141230610@sss.pgh.pa.us>
Permalink:  ../11346.1141230610@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/11346.1141230610@sss.pgh.pa.us

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-admin@postgresql.org
  Cc: tgl@sss.pgh.pa.us, mike@fuhr.org, sandhyar@amiindia.co.in
  Subject: Re: [ADMIN] Reg:lo_open error..pls help me
  In-Reply-To: <11346.1141230610@sss.pgh.pa.us>
  References: <018201c63d27$34f26ec0$cd00000a@sandhyar> <01b701c63d2a$4d640880$cd00000a@sandhyar> <11079.1141228992@sss.pgh.pa.us> <20060301161059.GA80123@winnie.fuhr.org> <11346.1141230610@sss.pgh.pa.us>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox