By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
464,782 Members | 1,204 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 464,782 IT Pros & Developers. It's quick & easy.

postgesql-7.3.3 lo_create/lo_open fails

P: n/a
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
main(
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");
PQclear(res);

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");
PQclear(res);
PQfinish(conn);
}

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
--without-zlib

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

Thanks in advance

Colm

--
************************************************** ************
* 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?

http://www.postgresql.org/docs/faqs/FAQ.html

Nov 11 '05 #1
Share this Question
Share on Google+
1 Reply

P: n/a
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.