From: | Alvaro Herrera <alvherre(at)commandprompt(dot)com> |
---|---|
To: | vanessa <vanessaknell(at)gmail(dot)com> |
Cc: | pgsql-general(at)postgresql(dot)org |
Subject: | Re: How to use slash commands in a function |
Date: | 2007-02-16 01:54:12 |
Message-ID: | 20070216015412.GE4682@alvh.no-ip.org |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | 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
From | Date | Subject | |
---|---|---|---|
Next Message | ITAGAKI Takahiro | 2007-02-16 02:40:19 | Inequality operators are not deduced. |
Previous Message | Alvaro Herrera | 2007-02-16 01:50:52 | Re: Where art thou pg_clog? |