Feature request: include script file into function body - Mailing list pgsql-bugs

From Steve White
Subject Feature request: include script file into function body
Date
Msg-id 20110201112120.GA1327@cashmere.aip.de
Whole thread Raw
Responses Re: Feature request: include script file into function body  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-bugs
Hi

I asked on pgsql-general 31 Jan 2011 if there were a way to do this, and got
no response, so let's make it a feature request.

It would be really nice to have a way to load script (especially Python
and Perl) from a separate file into a function body.  Some advantages would
be: to run a code checker outside of Postgresql, and to make things easier
for source code colorizers.

I have in mind syntax something like

================================================
CREATE OR REPLACE FUNCTION
        myfunc( ... )
RETURNS VOID FROM 'ScriptFile.py' LANGUAGE PLPYTHONU;
================================================

I think the FROM keyword fits here, and serves to distinguish behavior
from AS.  This is just a suggestion though.

The file name ought to work in the usual way:  without a leading slash
to be interpreted as a path relative to the current directory (in case the
command is inside an .sql file, that would be the directory containing the
.sql file).  With a leading slash, it would be taken as an absolute path.

For distribution purposes, it would also be nice to have some portable means
of indicating the installation directory of the running PostgreSQL, perhaps
with an environment variable replacement (e.g. $LIBDIR).

Cheers!

--
| -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -
| 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-bugs by date:

Previous
From:
Date:
Subject: pg_dump doesn't save altered column information for inherited columns
Next
From: Steve White
Date:
Subject: Portable, simple means of determining distribution directory