> 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?