lo wrappers - still working on it

From: Scott Holmes <sholmes(at)pacificnet(dot)net>
To: pgsql-general(at)postgresql(dot)org (PG-General)
Subject: lo wrappers - still working on it
Date: 2001-07-04 03:56:20
Message-ID: 200107040356.UAA31502@scotts.mynetwork.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Perhaps someone can point me towards what I'm missing. I've included my make
command, the command for creating a function and the actual code I wrote
(derived from the sample code in the docs). Incidentally, this project is too
far along to change to java or any other interface. I currently am handling
the files to be lo's as system files but the request is in to save them as
blobs.

This is the result of my make:

gcc -O2 -Wall -Wmissing-prototypes -Wmissing-declarations -fpic
-I../../src/interfaces/libpq -I../../src/include -c -o amslo.o amslo.c
amslo.c:19: warning: no previous prototype for `ams_loexport'
gcc -shared -o amslo.so amslo.o

This is the result of my trying to create a function:

wcgc_pg=# create function ams_loexport(Oid, char)
wcgc_pg-# returns opaque
wcgc_pg-# as '/usr/local/postgresql-7.1/contrib/WCGC_PG/amslo.so'
wcgc_pg-# language 'C';
ERROR: Load of file /usr/local/postgresql-7.1/contrib/WCGC_PG/amslo.so
failed: /usr/local/postgresql-7.1/contrib/WCGC_PG/amslo.so: undefined symbol:
PQexec
wcgc_pg=#

And finally, this is my attempt at coding the function:

/*---------------------------------------------------------
*
* amslo.c--
* large object handling for wcgc_pg documents
*
*
*---------------------------------------------------------
*/
#include <stdio.h>
#include "libpq-fe.h"
#include "libpq/libpq-fs.h"

#define BUFSIZE 1024

/*
* ams_loexport * export large object to file
*/
void ams_loexport(Oid lobjId, char *filename)
{
PGconn *conn;
PGresult *res;

conn = PQsetdb(NULL, NULL, NULL, NULL, "wcgc_pg");
if (PQstatus(conn) == CONNECTION_BAD)
{
fprintf(stderr, "Connection to wcgc_pg failed.\n");
fprintf(stderr, "%s", PQerrorMessage(conn));
return;
}

res = PQexec(conn, "begin");
PQclear(res);

lo_export(conn, lobjId, filename);

res = PQexec(conn, "end");
PQclear(res);
PQfinish(conn);
return;
}

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Eric G. Miller 2001-07-04 04:25:07 Re: lo wrappers - still working on it
Previous Message Tom Lane 2001-07-04 03:36:39 Re: [PATCH] Partial indicies almost working (I think)