Copying Permissions - Mailing list pgsql-hackers

From Corey Huinker
Subject Copying Permissions
Date
Msg-id CADkLM=dovdTM4LJ1-_YuNJWjeOU00XrwYvhU5v3-ZytBZ8zDbQ@mail.gmail.com
Whole thread Raw
Responses Re: Copying Permissions  (Stephen Frost <sfrost@snowman.net>)
List pgsql-hackers
Craig's post yesterday about exposing syntax for disabling indexes reminded me of another feature I think we're lacking in areas where we have to do table management.

The issue is to create a *something* that has the exact permissions of another *something*. Usually it's creating a table related to (but not yet inheriting) a parent, but it could also be to drop and recreate a *something*, making sure it has the same permissions it had before. 

BEGIN;

CREATE VIEW dummy AS SELECT 1::text as dummy;

UPDATE pg_class
SET relacl = ( SELECT relacl FROM pg_class
                       WHERE oid = 'foo'::regclass)
WHERE oid = 'dummy'::regclass;

DROP VIEW foo;

CREATE VIEW foo AS <insert new view definition here>;

UPDATE pg_class
SET relacl = ( SELECT relacl FROM pg_class 
                       WHERE oid = 'dummy'::regclass)
WHERE oid = 'foo'::regclass;

END;

I suppose I could have learned how to store a relacl as a scalar and just saved it to a variable, but even then I'd have to twiddle with (and have the permissions to twiddle with) pg_class.

So it'd be nice to:
ALTER TABLE bar SET PERMISSIONS FROM foo;
or maybe even
GRANT SAME PERMISSIONS ON VIEW bar FROM foo; 

Thoughts?

pgsql-hackers by date:

Previous
From: Robert Haas
Date:
Subject: Re: WAL consistency check facility
Next
From: Robert Haas
Date:
Subject: Re: auto_explain vs. parallel query