Database Reference
In-Depth Information
Makeile to compile the foreign data wrapper
As we have already discussed that we need the C programming source code ile for
implementation, we now need a
Makefile
to compile the source code to generate a
library. Here is the sample
Makefile
to compile the
dummy_fdw
foreign data wrapper:
# Makefile
MODULE_big = dummy_fdw
OBJS = dummy_fdw.o
EXTENSION = dummy_fdw
DATA = dummy_fdw--1.0.sql
REGRESS = dummy_fdw
DUMMY_CONFIG = dummy_config
subdir = contrib/dummy_fdw
top_builddir = ../..
include $(top_builddir)/src/Makefile.global
include $(top_srcdir)/contrib/contrib-global.mk
Let's consider the various parameters mentioned in the preceding snippet:
•
MODULE_big
: This is the name of the module
•
OBJS
: This is the C source code ile for compilation
•
DATA
: This is the name of SQL ile. For details see the following section
•
REGRESS
: This is the regression ile name
A SQL ile to map SQL functions to C functions
A SQL ile is needed to map the C handler and validate function to the SQL function.
It not only maps the C function with the SQL function, but also creates a foreign
data wrapper using the
CREATE FOREIGN DATA WRAPPER
command in the
following manner:
-- File name=dummy_fdw--1.0.sql
CREATE FUNCTION dummy_fdw_handler()
RETURNS fdw_handler
AS 'MODULE_PATHNAME'
LANGUAGE C STRICT;
CREATE FUNCTION dummy_fdw_validator(text[], oid)
RETURNS void
AS 'MODULE_PATHNAME'