How best to load modules? - Mailing list pgsql-general

From Steve White
Subject How best to load modules?
Date
Msg-id 20110128113925.GA10489@cashmere.aip.de
Whole thread Raw
Responses Re: How best to load modules?  (Dimitri Fontaine <dimitri@2ndQuadrant.fr>)
Re: How best to load modules?  (Steve White <swhite@aip.de>)
List pgsql-general
Hello, all!

What are best practices regarding the loading of postgresql modules, say
from the contrib/ directory; specifically, with regard to portability?

I would like to distribute an SQL script which loads a module, and works
with as little further fiddling as possible.

known options
=============

Within a session, or in a script, one can use
    \i <explicit file path>
But within a script this has the weakness that the file path varies from
one system distribution to another.

One can start psql with
    psql ... -f <explicit file path>
but that's a measure taken outside the script, to done either with session,
or else be done by a further measure such as a shell script.

Ideally, the location of the default modules directory (or installation
directory) should be available within a session in some variable or from
some function call.

There are some pre-defined variables, listed in a session by
    show all;
but I don't see anything like a directory path there.
Maybe a built-in function returning this directory?  Searched to no avail:
    http://www.postgresql.org/docs/8.2/interactive/functions.html

There has been talk about a bigger solution on
    http://wiki.postgresql.org/wiki/Module_Manager
but little seems to have happened there in some years.

An environment variable
    $libdir,
is mentioned
    http://www.postgresql.org/docs/8.2/static/runtime-config-client.html
but this seems not to be present within a session.
It seems to be expanded within the LANGUAGE C environment, for instance in
tablefunc.sql
 -------------------------------------------------
CREATE OR REPLACE FUNCTION crosstab2(text)
RETURNS setof tablefunc_crosstab_2
AS '$libdir/tablefunc','crosstab'
LANGUAGE C STABLE STRICT;
 -------------------------------------------------

Thanks!

--
| -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -
| Steve White                                             +49(331)7499-202
| E-Science                                        Zi. 27  Villa Turbulenz
| -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -
| Astrophysikalisches Institut Potsdam (AIP)
| An der Sternwarte 16, D-14482 Potsdam
|
| Vorstand: Prof. Dr. Matthias Steinmetz, Peter A. Stolz
|
| Stiftung privaten Rechts, Stiftungsverzeichnis Brandenburg: III/7-71-026
| -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -

pgsql-general by date:

Previous
From: Pavel Stehule
Date:
Subject: Re: Executing SQL expression from C-functions
Next
From: Jorge Arévalo
Date:
Subject: Re: Executing SQL expression from C-functions