mirror of
https://github.com/postgres/postgres.git
synced 2025-05-11 05:41:32 +03:00
Add regression test for DROP OWNED BY with default ACLs
DROP OWNED BY has a specific code path to remove ACLs stored in pg_default_acl when cleaning up shared dependencies that had no coverage with the existing tests. This issue has been found while digging into the bug fixed by 21378e1. As ALTER DEFAULT PRIVILEGES impacts the ACLs of all objects created while the default permissions are visible, the test uses a transaction rollback to isolate the test and avoid any impact with other sessions running in parallel. Reviewed-by: Álvaro Herrera Discussion: https://postgr.es/m/YAbQ1OD+3ip4lRv8@paquier.xyz
This commit is contained in:
parent
21378e1fef
commit
a36dc04d42
@ -1760,6 +1760,35 @@ SELECT has_schema_privilege('regress_priv_user2', 'testns4', 'CREATE'); -- yes
|
||||
|
||||
ALTER DEFAULT PRIVILEGES REVOKE ALL ON SCHEMAS FROM regress_priv_user2;
|
||||
COMMIT;
|
||||
-- Test for DROP OWNED BY with shared dependencies. This is done in a
|
||||
-- separate, rollbacked, transaction to avoid any trouble with other
|
||||
-- regression sessions.
|
||||
BEGIN;
|
||||
ALTER DEFAULT PRIVILEGES GRANT ALL ON FUNCTIONS TO regress_priv_user2;
|
||||
ALTER DEFAULT PRIVILEGES GRANT ALL ON SCHEMAS TO regress_priv_user2;
|
||||
ALTER DEFAULT PRIVILEGES GRANT ALL ON SEQUENCES TO regress_priv_user2;
|
||||
ALTER DEFAULT PRIVILEGES GRANT ALL ON TABLES TO regress_priv_user2;
|
||||
ALTER DEFAULT PRIVILEGES GRANT ALL ON TYPES TO regress_priv_user2;
|
||||
SELECT count(*) FROM pg_shdepend
|
||||
WHERE deptype = 'a' AND
|
||||
refobjid = 'regress_priv_user2'::regrole AND
|
||||
classid = 'pg_default_acl'::regclass;
|
||||
count
|
||||
-------
|
||||
5
|
||||
(1 row)
|
||||
|
||||
DROP OWNED BY regress_priv_user2, regress_priv_user2;
|
||||
SELECT count(*) FROM pg_shdepend
|
||||
WHERE deptype = 'a' AND
|
||||
refobjid = 'regress_priv_user2'::regrole AND
|
||||
classid = 'pg_default_acl'::regclass;
|
||||
count
|
||||
-------
|
||||
0
|
||||
(1 row)
|
||||
|
||||
ROLLBACK;
|
||||
CREATE SCHEMA testns5;
|
||||
SELECT has_schema_privilege('regress_priv_user2', 'testns5', 'USAGE'); -- no
|
||||
has_schema_privilege
|
||||
|
@ -1049,6 +1049,26 @@ ALTER DEFAULT PRIVILEGES REVOKE ALL ON SCHEMAS FROM regress_priv_user2;
|
||||
|
||||
COMMIT;
|
||||
|
||||
-- Test for DROP OWNED BY with shared dependencies. This is done in a
|
||||
-- separate, rollbacked, transaction to avoid any trouble with other
|
||||
-- regression sessions.
|
||||
BEGIN;
|
||||
ALTER DEFAULT PRIVILEGES GRANT ALL ON FUNCTIONS TO regress_priv_user2;
|
||||
ALTER DEFAULT PRIVILEGES GRANT ALL ON SCHEMAS TO regress_priv_user2;
|
||||
ALTER DEFAULT PRIVILEGES GRANT ALL ON SEQUENCES TO regress_priv_user2;
|
||||
ALTER DEFAULT PRIVILEGES GRANT ALL ON TABLES TO regress_priv_user2;
|
||||
ALTER DEFAULT PRIVILEGES GRANT ALL ON TYPES TO regress_priv_user2;
|
||||
SELECT count(*) FROM pg_shdepend
|
||||
WHERE deptype = 'a' AND
|
||||
refobjid = 'regress_priv_user2'::regrole AND
|
||||
classid = 'pg_default_acl'::regclass;
|
||||
DROP OWNED BY regress_priv_user2, regress_priv_user2;
|
||||
SELECT count(*) FROM pg_shdepend
|
||||
WHERE deptype = 'a' AND
|
||||
refobjid = 'regress_priv_user2'::regrole AND
|
||||
classid = 'pg_default_acl'::regclass;
|
||||
ROLLBACK;
|
||||
|
||||
CREATE SCHEMA testns5;
|
||||
|
||||
SELECT has_schema_privilege('regress_priv_user2', 'testns5', 'USAGE'); -- no
|
||||
|
Loading…
x
Reference in New Issue
Block a user