libpg: large object problems - Mailing list pgsql-novice

From Seth Nickell
Subject libpg: large object problems
Date
Msg-id 1051933842.10718.14.camel@beauty.stanford.edu
Whole thread Raw
Responses Re: libpg: large object problems
List pgsql-novice
Hi,

I'm trying to figure out how to get large objects working using libpg.
The problem is that whenever I do an lo_open on an object, I get back
"-1" as the file descriptor (and of course, an lo_read on that fails).

  Oid id = lo_creat (dbConn, INV_READ | INV_WRITE);
  fd = lo_open (dbConn, id, INV_WRITE);

That's what I'm basically doing. "id" ends up being a somewhat sensible
looking large-ish number.

I've also tried doing lo_open's of files that I lo_import'ed (and can
successfully lo_export using the console, so I know they're "in there").
Same problem.

Any ideas what I'm doing wrong? I've included the full text of my simple
test case below. I've also tried this with a remote PostgreSQL server,
both times verifying that I could run queries and such (so the
connection to the server is working on at least that level :-)

thanks!

-Seth


---------Full Text of Test Program--------

static PGconn *dbConn = NULL;

int main(int argc, char **argv) {
  char * error;
  Oid id;
  int fd;

  dbConn = PQconnectdb("");
  error = PQerrorMessage(dbConn);

  if(strlen(error) > 0){
    fprintf(stderr, "DB connection error to gargamel: %s\n", error);
    return -1;
  }

  Oid id = lo_creat (dbConn, INV_READ | INV_WRITE);

  fd = lo_open (dbConn, id, INV_WRITE);

  printf ("fd is: %d, id is: %d\n", fd, id);

  return 0;
}


pgsql-novice by date:

Previous
From: Tom Lane
Date:
Subject: Re: Search speed issues
Next
From: greg@turnstep.com
Date:
Subject: Re: libpg: large object problems