From: | "Ziga Kranjec" <ziga(at)ljudmila(dot)org> |
---|---|
To: | pgsql-hackers(at)postgresql(dot)org |
Subject: | Re: eval function |
Date: | 2004-05-23 19:40:56 |
Message-ID: | 51930.193.77.243.249.1085341256.squirrel@webmail.ljudmila.org |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
> Bruno Wolff III <bruno(at)wolff(dot)to> writes:
>> Christopher Kings-Lynne <chriskl(at)familyhealth(dot)com(dot)au> wrote:
>>> ... people want to be able to grant on all objects in a
>>> database, etc:
For things like this I use simple,
but super-powerful eval function:
CREATE OR REPLACE FUNCTION eval(text)
RETURNS int4
VOLATILE
LANGUAGE 'plpgsql'
SECURITY INVOKER
AS 'DECLARE
body ALIAS FOR $1;
result INT;
BEGIN
EXECUTE body;
GET DIAGNOSTICS result = ROW_COUNT;
RETURN result;
END;
';
Then you say something like:
SELECT eval('GRANT SELECT ON TABLE '||TABLE_NAME||' TO PUBLIC')
FROM INFORMATION_SCHEMA.TABLES
WHERE schema_name=current_schema()
AND type_type='BASE TABLE';
Also works great for other similar operations, such as
renaming, changing owners, etc... anything you can
generate with SQL, which is quite a lot, really.
Is this considered ok or extreme abuse?
From | Date | Subject | |
---|---|---|---|
Next Message | Alvaro Herrera | 2004-05-23 19:51:58 | Timezone fun (bugs and a request) |
Previous Message | Devrim GUNDUZ | 2004-05-23 18:05:13 | Re: Fixing the Turkish problem |