Database Reference
In-Depth Information
From this point forward, we are only going to discuss Version 1 Calling Conventions
for a C function.
In case you are interested, there is some more information on Version 0 at ht-
tp://www.postgresql.org/docs/current/static/xfunc-c.html#AEN50495 , in the section
titled 35.9.3. Version 0 Calling Conventions .
Makefile
The next step is compiling and linking the .c source file into a form that can be
loaded into PostgreSQL server. This can all be done as a series of commands
defined in a Makefile function.
The PostgreSQL manual has a complete section about what flags and included
paths you should pass on each of the supported platforms and how to determine
correct paths for including files and libraries.
Fortunately, all of this is also automated nicely for developers via the PostgreSQL
Extension Building Infrastructure—or PGXS for short—which makes this really easy
for most modules.
Note
Depending on which version of PostgreSQL you have installed, you may need to
add the development package for your platform. These are usually the -dev or
-devel packages.
Now, let's create our Makefile function. It will look like the following code:
MODULES = add_func
PG_CONFIG = pg_config
PGXS := $(shell $(PG_CONFIG) --pgxs)
include $(PGXS)
And you can compile and link the module by simply running make :
Search WWH ::




Custom Search