[lug] C extensions of PostgreSQL

D. Stimits stimits at comcast.net
Wed Aug 6 11:01:33 MDT 2003


B Giles wrote:

> You don't link against pq, you link against the internal library.  I
> haven't written user-defined functions or types since 7.1, but it's
> probably something like pq-int.
>
> Backend programming is very different from the frontend, although it
> might not be too bad if you're just writing a user-defined function.
> User-defined types are a whole 'nother thing - you have to worry about
> TOASTability, accessor functions if it's a composite object, possibly
> type-specific indexing, etc.

There are apparently some [optional] interface changes since 7.1. The 
changes are supposed to give up on backwards compatibility at some 
future release...for all I know 7.3 already does this, but I'm using 
PostgreSQL from RH 7.3.

My reference page is:
http://www.postgresql.org/docs/7.2/interactive/xfunc-c.html

I am not using any special user defined types, I am interested only in 
some simple stuff that uses default types. The thing that reference page 
lacks is information specific to what libraries must be linked. If you 
find on the page the palloc() function, it is this function which must 
have an implementation somewhere...I can #include the proper 
declaration, but I am unable to figure out what library actually 
implements it. The libpq.so library does not implement it. Using nm, I 
am unable to find a library with the symbols required.

I can see I am going to have to download the full source code and figure 
out from their regression stuff what the heck I must link with, I really 
hate downloading and building a new PostgreSQL just so I can see what 
the link files are, but it looks like that is the only choice.

D. Stimits, stimits AT comcast DOT net

>
> Bear
>
> > From: "D. Stimits"
> > Reply-To: lug at lug.boulder.co.us
> > To: BLUG
> > Subject: [lug] C extensions of PostgreSQL
> > Date: Wed, 06 Aug 2003 06:29:26 -0600
> >
> > I'm trying to write a C function for PostgreSQL on RH 7.3 (KRUD), and
> > running into a problem. The C code must apparently link against a
> > library that provides functions "CurrentMemoryContext" and
> > "MemoryContextAlloc" (probably due to palloc). I've been digging
> > around with nm and fail to find it. I'm currently linking as:
> >   -lkrb5 -lk5crypto -lcom_err -lpq -ldl
> >
> > Can someone tell me what I am missing?
> >
> > D. Stimits, stimits AT comcast DOT net
> >




More information about the LUG mailing list