mirror of
https://git.postgresql.org/git/postgresql.git
synced 2026-02-14 18:37:03 +08:00
Fix misbehavior of DROP OWNED BY with duplicate polroles entries.
Ordinarily, a pg_policy.polroles array wouldn't list the same role more than once; but CREATE POLICY does not prevent that. If we perform DROP OWNED BY on a role that is listed more than once, RemoveRoleFromObjectPolicy either suffered an assertion failure or encountered a tuple-updated-by-self error. Rewrite it to cope correctly with duplicate entries, and add a CommandCounterIncrement call to prevent the other problem. Per discussion, there's other cleanup that ought to happen here, but this seems like the minimum essential fix. Per bug #17062 from Alexander Lakhin. It's been broken all along, so back-patch to all supported branches. Discussion: https://postgr.es/m/17062-11f471ae3199ca23@postgresql.org
This commit is contained in:
@ -1757,6 +1757,16 @@ CREATE POLICY p1 ON dob_t1 TO regress_rls_dob_role1,regress_rls_dob_role2 USING
|
||||
DROP OWNED BY regress_rls_dob_role1;
|
||||
DROP POLICY p1 ON dob_t1; -- should succeed
|
||||
|
||||
-- same cases with duplicate polroles entries
|
||||
CREATE POLICY p1 ON dob_t1 TO regress_rls_dob_role1,regress_rls_dob_role1 USING (true);
|
||||
DROP OWNED BY regress_rls_dob_role1;
|
||||
DROP POLICY p1 ON dob_t1; -- should fail, already gone
|
||||
|
||||
CREATE POLICY p1 ON dob_t1 TO regress_rls_dob_role1,regress_rls_dob_role1,regress_rls_dob_role2 USING (true);
|
||||
DROP OWNED BY regress_rls_dob_role1;
|
||||
DROP POLICY p1 ON dob_t1; -- should succeed
|
||||
|
||||
-- partitioned target
|
||||
CREATE POLICY p1 ON dob_t2 TO regress_rls_dob_role1,regress_rls_dob_role2 USING (true);
|
||||
DROP OWNED BY regress_rls_dob_role1;
|
||||
DROP POLICY p1 ON dob_t2; -- should succeed
|
||||
|
||||
Reference in New Issue
Block a user