pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Jasen Betts <jasen@xnet.co.nz>
To: pgsql-bugs@postgresql.org
Subject: Re: Feature request: include script file into function body
Date: 3 Feb 2011 11:37:21 GMT
Message-ID: <iie41h$b91$1@reversiblemaps.ath.cx> (raw)
References: <20110201112120.GA1327@cashmere.aip.de>

On 2011-02-01, Steve White <swhite@aip.de> wrote:
> 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;
>================================================

others have complained about the backend reading files 
maybe this coould be implemented in PSQL instead.
(like \i and \copy are...)

something like:

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

psql would then need to slurp the file and quote the function body, but
pq_escape_string_conn is presumably upto that task.

on the other hand binary fuunctions (eg C) are read from files, but
not directly by the backend, dlopen (or equivalent) is used instead.

on the other hand, for symmetry I guess a form that matches yours is
needed too, but, if using named files that will probably need database
superuser permission  (like the other named file functions do). 

Then ther could be an unpriviledged "from stdin" variant that psql could
use to send the content (instead of quoting it and sending it in-line).

ISTR C functions need superuser too.





view thread (33+ messages)  latest in thread

Message-ID: <iie41h$b91$1@reversiblemaps.ath.cx>
Permalink:  ../iie41h$b91$1@reversiblemaps.ath.cx/
Also on:    postgresql.org/message-id/iie41h$b91$1@reversiblemaps.ath.cx

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-bugs@postgresql.org
  Cc: jasen@xnet.co.nz
  Subject: Re: Feature request: include script file into function body
  In-Reply-To: <iie41h$b91$1@reversiblemaps.ath.cx>
  References: <20110201112120.GA1327@cashmere.aip.de> <iie41h$b91$1@reversiblemaps.ath.cx>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox