From: | Guillaume Lelarge <guillaume(at)lelarge(dot)info> |
---|---|
To: | leaf_yxj <leaf_yxj(at)163(dot)com> |
Cc: | pgsql-general(at)postgresql(dot)org |
Subject: | Re: create one function to let other user execute vacuum command. got such an error. |
Date: | 2012-03-28 06:44:26 |
Message-ID: | 1332917066.2249.2.camel@localhost.localdomain |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
On Tue, 2012-03-27 at 18:51 -0700, leaf_yxj wrote:
> create one function to let other user execute vacuum command. got such an
> error. Please help. Thanks. Regards . Grace
>
> rrp=> create function vacuum_f ( tablename char(100))
> Returns char(100) AS $$
> vacuum tablename;
> $$ Language plpgsql security definer;
> ERROR: syntax error at or near "vacuum"
> LINE 3: vacuum tablename;
> ^
> rrp=>
>
Well, first, it doesn't follow PL/pgsql guidelines. You need at least a
BEGIN at the beginning of the function, and an END at the end.
But even with this, you cannot use VACUUM in a function. Don't remember
the reason why right now, but all you'll get is this error:
ERROR: VACUUM cannot be executed from a function or multi-command
string
--
Guillaume
http://blog.guillaume.lelarge.info
http://www.dalibo.com
From | Date | Subject | |
---|---|---|---|
Next Message | Greg Jaskiewicz | 2012-03-28 06:50:23 | Re: create one function to let other user execute vacuum command. got such an error. |
Previous Message | leaf_yxj | 2012-03-28 01:51:53 | create one function to let other user execute vacuum command. got such an error. |