Thread: lo_open problems

lo_open problems

From
James Leigh
Date:
I am using some large object, but lo_open always returns -1.  I don't
know why.
Here is a code snipet (compiled with g++ for C++).

    /*
     * create the large object
     */
    Oid lobjId = lo_creat(conn, INV_READ | INV_WRITE);// works
    if (lobjId == 0){
    fprintf(stderr, "can't create large object\n");
    return 0;
    }

    int lobj_fd = lo_open(conn, lobjId, INV_WRITE);// == -1
    if(lobj_fd < 0){
    fprintf(stderr, "can't open large object (%d)\n", lobjId);
    return 0;
    }

lo_creat works and I can use psql with '\dl' to see the new lo created,
but lo_open returns '-1'.  In what cases would lo_open fail after a
successfull lo_creat?

Running the provided sample program works, so lo support is there, but
in my large application I cannot open the lo.

any ideas?
james


Re: lo_open problems

From
Tom Lane
Date:
James Leigh <james.leigh@ottawa.com> writes:
> I am using some large object, but lo_open always returns -1.  I don't
> know why.

Are you doing this inside a transaction block?

            regards, tom lane

Re: lo_open problems

From
James Leigh
Date:
Tthat was it, Thanks.  I did not see that in the docs, it should be
added.

cheers,
james


On Mon, 2002-03-04 at 18:10, Tom Lane wrote:
> James Leigh <james.leigh@ottawa.com> writes:
> > I am using some large object, but lo_open always returns -1.  I don't
> > know why.
>
> Are you doing this inside a transaction block?
>
>             regards, tom lane



Re: lo_open problems

From
Bruce Momjian
Date:
James Leigh wrote:
> Tthat was it, Thanks.  I did not see that in the docs, it should be
> added.
>
> cheers,
> james
>
>
> On Mon, 2002-03-04 at 18:10, Tom Lane wrote:
> > James Leigh <james.leigh@ottawa.com> writes:
> > > I am using some large object, but lo_open always returns -1.  I don't
> > > know why.
> >
> > Are you doing this inside a transaction block?
> >

I see it in the docs.  It is missing somewhere else?

    <note>
     <para>
      All large object manipulation <emphasis>must</emphasis> take
      place within an SQL transaction. This requirement is strictly
      enforced as of <productname>PostgreSQL 6.5</>, though it has been an
      implicit requirement in previous versions, resulting in
      misbehavior if ignored.
     </para>
    </note>
   </para>

--
  Bruce Momjian                        |  http://candle.pha.pa.us
  pgman@candle.pha.pa.us               |  (610) 853-3000
  +  If your life is a hard drive,     |  830 Blythe Avenue
  +  Christ can be your backup.        |  Drexel Hill, Pennsylvania 19026