Re: Feature request: include script file into function body

Поиск
Список
Период
Сортировка
От Jasen Betts
Тема Re: Feature request: include script file into function body
Дата
Msg-id iie41h$b91$1@reversiblemaps.ath.cx
обсуждение исходный текст
Ответ на Feature request: include script file into function body  (Steve White <swhite@aip.de>)
Список pgsql-bugs
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.

В списке pgsql-bugs по дате отправления:

Предыдущее
От: Craig Ringer
Дата:
Сообщение: Re: BUG #5862: Postgres dumps core upon a connection attempt
Следующее
От: Jasen Betts
Дата:
Сообщение: Re: Feature request: include script file into function body