Database Reference
In-Depth Information
Now, when running
make
, the
add_funcs.sql.in
is compiled into a file
add_funcs.sql
with
MODULE_PATHNAME
replaced by the real path where the
module will be installed.
[add_func]$ make
sed 's,MODULE_PATHNAME,$libdir/add_func,g'
add_func.sql.in >add_func.sql
Also,
sudo make install
will copy the generated
.sql
file into the directory with
other
.sql
files for extensions.
[add_func]$ sudo make install /usr/bin/mkdir -p
'/usr/pgsql-9.2/share/contrib'
/usr/bin/mkdir -p '/usr/pgsql-9.2/lib'
/bin/sh /usr/pgsql-9.2/lib/pgxs/src/makefiles/
../../config/install-sh -c -m 644 add_func.sql
'/usr/pgsql-9.2/share/contrib/'
/bin/sh /usr/pgsql-9.2/lib/pgxs/src/makefiles/
../../config/install-sh -c -m 755 add_func.so
'/usr/pgsql-9.2/lib/'
After this, the introduction of your C functions to a PostgreSQL database is as simple
as
hannu=# \i /usr/pgsql-9.2/share/contrib/add_func.sql
.
CREATE FUNCTION
The path
/usr/pgsql-9.2/share/contrib/
to
add_func.sql
needs to be
looked up from the output of the
make install
command.
Note
There is an even cleaner way to package up your code called Extensions where
you don't need to look up for any paths and the preceding step would just be as
follows: