libpq: large objects
От | Philipp Käser |
---|---|
Тема | libpq: large objects |
Дата | |
Msg-id | 8FBC19E64A26D411B0E3009027F688FB1F030E@indoor.intra.openmind.ch обсуждение исходный текст |
Список | pgsql-general |
hej, I'm having some troubles importing/exporting large objects using the libpq C interface. I wrote a simple test program to see where the error might be, but not even this seems to work: test.cpp should import a file /tmp/redball.gif, and just try to open the large object. then, there is a manually inserted object in the database which I want to export as /tmp/redball1.gif. All functions fail with errors. However, when doing the same import/export procedure using the psql commandline tool, there's no problem. do you have any suggestions what might be wrong? is the large object interface of libpq still very much under development? Did I forget anything of great importance? postgres version is 7.0.2-2, compiled from source, under SuSE 6.4 (kernel 2.2.16; libc 2.1.3-91); program, database and psql tool are run resp. owned by the user "webdev" (having all necessary access rights). I'd gladly appreciate ANY help & suggestions, Philipp Käser pkaeser@obtree.com ------ test.cpp - test program to import/export some data ------ // link/compile using // g++ -I/usr/local/pgsql/include -L/usr/local/pgsql/lib -lpq test.cpp -o test #include "libpq-fe.h" #include "libpq/libpq-fs.h" PGconn *myconn; void main(void) { int tmpid, lofd; printf("opening db\n"); myconn = PQconnectdb("host=localhost port=5432 dbname=PGSQLTest user=webdev password=oms98"); if (PQstatus(myconn) != CONNECTION_OK) { printf("error\n"); exit(-1); } printf("trying to import object /tmp/redball.gif..."); tmpid = lo_import(myconn, "/tmp/redball.gif"); printf("done, at id = %d\n", tmpid); printf("ERROR MESSAGE %s\n", PQerrorMessage(myconn)); printf("trying to open obj with id = %d...", tmpid); lofd = lo_open(myconn, tmpid, INV_READ); printf(" ... done, at lofd = %d\n", lofd); tmpid = 75201; printf("trying to export to file /tmp/redball1.gif, from oid = %d", tmpid); lofd = lo_export(myconn, tmpid, "/tmp/redball1.gif"); printf(" ... done, retval = %d\n", lofd); printf("ERROR MESSAGE %s\n", PQerrorMessage(myconn)); printf("terminating db connection\n"); PQfinish(myconn); } ------ output when test is run ------ opening db trying to import object /tmp/redball.gif...done, at id = 0 ERROR MESSAGE lo_import: could not open inv object oid 82753 trying to open obj with id = 0... ... done, at lofd = -1 trying to export to file /tmp/redball1.gif, from oid = 75201 ... done, retval = -1 ERROR MESSAGE lo_export: can't open inv object 75201 terminating db connection ------ how it looks when exporting the already existing data, using psql ------ PGSQLTest=# select lo_export(75201, '/tmp/redball.gif'); lo_export ----------- 1 (1 row) PGSQLTest=#
В списке pgsql-general по дате отправления: