470,581 Members | 2,460 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,581 developers. It's quick & easy.

postgesql-7.3.3 lo_create/lo_open fails

Hi Guys,

I'm currenlty involved in a port of our gateway code from a Solaris 8
environment to a HP-UX11.11 incorporating postgresql-7.3.3. We're having
some problems with creation and opening of large objects and was hoping
that you may be able to shed some light on them.

I extracted the LO code into the test program as below and am able to
recreate the problems:

int argc,
char * argv[]
char chBytes[] = "FILLER";
int iLength = strlen(chBytes);

char * chTempDB = NULL;
chTempDB = getenv ("CMN_DBNAME");
char *chTempUserName=NULL;
chTempUserName = getenv ("CMN_DBUSERNAME");

PGconn * conn = PQsetdbLogin(NULL, NULL, NULL, NULL, chTempDB,
chTempUserName, NULL);

* check to see that the backend connection was successfully made
if (PQstatus(conn) == CONNECTION_BAD)
cout << "Large object connection is bad " << endl;

PGresult * res = PQexec(conn, "begin");

Oid lobjId = lo_creat(conn, INV_READ|INV_WRITE);
if (lobjId != -1)
cout << "Large object ID created :" << lobjId << endl;
int lobj_fd = lo_open(conn, lobjId, INV_WRITE);
cout << "Large object file descriptor :" << lobj_fd << endl;
if (lobj_fd != -1)
// write the large object
int nbytes_out = lo_write(conn, lobj_fd, chBytes, iLength);
cout << "Large object written - no of bytes :" << nbytes_out << endl;
(void) lo_close(conn, lobj_fd);

res = PQexec(conn, "end");

all worked fine on the Solaris box but on the HP the lo_creat returns 0
for the oid - subsequently lo_open returns -1 when an attempt is made to
open the object.

The configuration used to install postgresql-7.3.3 on the HP environment
is as follows:

configure CC=/bin/cc AR=/bin/ar CFLAGS=+DA2.0W --without-readline

Has anyone come across this problem ? Any help on this would be much

Thanks in advance


************************************************** ************
* Colm Dobbs Email: c.*****@aepona.com *
* Software Engineer Web: www.aepona.com *
* Aepona LTD,Interpoint Building, Phone: +44 (0)2890 269186 *
* 20-24 York Street, Belfast Fax: +44 (0)2890 269111 *
* BT15 1AQ N.Ireland *
************************************************** ************
---------------------------(end of broadcast)---------------------------
TIP 5: Have you checked our extensive FAQ?


Nov 11 '05 #1
1 2535
Colm Dobbs <Co********@aepona.com> writes:
Oid lobjId = lo_creat(conn, INV_READ|INV_WRITE);
if (lobjId != -1)

This coding is wrong --- lo_creat would return 0 (InvalidOid) on
failure, not -1. As for *why* it's failing, PQerrorMessage might
offer some hint. I'm a tad surprised by that myself; never heard
of it happening with a connection not already in an error state.

regards, tom lane

---------------------------(end of broadcast)---------------------------
TIP 3: if posting/reading through Usenet, please send an appropriate
subscribe-nomail command to ma*******@postgresql.org so that your
message can get through to the mailing list cleanly

Nov 11 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by Mage | last post: by
1 post views Thread by James Moe | last post: by
1 post views Thread by Derrick Betts | last post: by
1 post views Thread by Domagoj Čajić | last post: by
2 posts views Thread by Phil Campaigne | last post: by
1 post views Thread by livre | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.