Re: How to use slash commands in a function

Поиск
Список
Период
Сортировка
От Alvaro Herrera
Тема Re: How to use slash commands in a function
Дата
Msg-id 20070216015412.GE4682@alvh.no-ip.org
обсуждение исходный текст
Ответ на How to use slash commands in a function  (vanessa <vanessaknell@gmail.com>)
Список pgsql-general
vanessa escribió:
>
> Hi guys,
>
> I was wondering how could i (if at all possible) to use say a command like:
> \! touch fred.txt     in a function?
> i.e.
>
> CREATE FUNCTION myfunc() RETURNS TRIGGER AS
> 'BEGIN
>         \! touch fred.txt
>          RETURN NEW;
> END;'
> LANGUAGE 'plpgsql';
>
> At the moment i get:
> ERROR: syntax error at or near "\"
> Does this mean i should encapsulate the line in quotation marks or something
> like that?

No, it means you can't do it at all, because backslash commands are
psql-only, thus you cannot put them in functions (which are
server-executed).  PL/pgSQL functions are trusted, meaning you can't
access the outside world (disk, network, etc) with them.  If you really
need to do that, consider using an untrusted language (C, plperlu, etc).
I think there's even a PL/sh (shell) but I don't think you can use it
for trigger functions.

--
Alvaro Herrera                                http://www.CommandPrompt.com/
PostgreSQL Replication, Consulting, Custom Development, 24x7 support

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

Предыдущее
От: Alvaro Herrera
Дата:
Сообщение: Re: Where art thou pg_clog?
Следующее
От: ITAGAKI Takahiro
Дата:
Сообщение: Inequality operators are not deduced.