Re: eval function
От | Ziga Kranjec |
---|---|
Тема | Re: eval function |
Дата | |
Msg-id | 51930.193.77.243.249.1085341256.squirrel@webmail.ljudmila.org обсуждение исходный текст |
Ответ на | Re: Latest requests from IRC (Tom Lane <tgl@sss.pgh.pa.us>) |
Список | pgsql-hackers |
> Bruno Wolff III <bruno@wolff.to> writes: >> Christopher Kings-Lynne <chriskl@familyhealth.com.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?
В списке pgsql-hackers по дате отправления: