Fix regression tests conflict in 3ca43dbbb6
authorAlexander Korotkov <[email protected]>
Mon, 13 May 2024 10:26:34 +0000 (13:26 +0300)
committerAlexander Korotkov <[email protected]>
Mon, 13 May 2024 10:26:34 +0000 (13:26 +0300)
3ca43dbbb6 adds regression tests with permission checks.  The conflict has
been observed at buildfarm member piculet.

This commit fixes the conflict in the following way.
1. partition_split.sql now uses role names regress_partition_split_alice and
   regress_partition_split_bob (it mistakenly used
   regress_partition_merge_alice and regress_partition_merge_bob before).
2. Permissions on schemas partitions_merge_schema and partition_split_schema
   are granted to corresponding roles.  Before, the lack of permissions led to
   the creation of objects in the public schema and potential conflict.

Reported-by: Daniel Gustafsson
Discussion: https://postgr.es/m/03A07EF6-98D2-419B-A3AA-A111C64CC207%40yesql.se

src/test/regress/expected/partition_merge.out
src/test/regress/expected/partition_split.out
src/test/regress/sql/partition_merge.sql
src/test/regress/sql/partition_split.sql

index f13f75eefc785a123c69ccfab825c5b9df566d43..6361732d1044808f55e270325ea6dd62eb90d1a0 100644 (file)
@@ -883,6 +883,8 @@ DROP ACCESS METHOD partitions_merge_heap;
 -- the merging partitions to do the merge.
 CREATE ROLE regress_partition_merge_alice;
 CREATE ROLE regress_partition_merge_bob;
+GRANT ALL ON SCHEMA partitions_merge_schema TO regress_partition_merge_alice;
+GRANT ALL ON SCHEMA partitions_merge_schema TO regress_partition_merge_bob;
 SET SESSION AUTHORIZATION regress_partition_merge_alice;
 CREATE TABLE t (i int) PARTITION BY RANGE (i);
 CREATE TABLE tp_0_1 PARTITION OF t FOR VALUES FROM (0) TO (1);
@@ -906,6 +908,8 @@ SET SESSION AUTHORIZATION regress_partition_merge_bob;
 ALTER TABLE t MERGE PARTITIONS (tp_0_1, tp_1_2) INTO tp_0_2;
 RESET SESSION AUTHORIZATION;
 DROP TABLE t;
+REVOKE ALL ON SCHEMA partitions_merge_schema FROM regress_partition_merge_alice;
+REVOKE ALL ON SCHEMA partitions_merge_schema FROM regress_partition_merge_bob;
 DROP ROLE regress_partition_merge_alice;
 DROP ROLE regress_partition_merge_bob;
 RESET search_path;
index 74e19d250e942e05cbc34c2b9267eda96f5473d6..14c4f97c9ff9003eb2baad78fe0f95502e5f6c5e 100644 (file)
@@ -1516,33 +1516,38 @@ DROP TABLE t;
 DROP ACCESS METHOD partition_split_heap;
 -- Test permission checks.  The user needs to own the parent table and the
 -- the partition to split to do the split.
-CREATE ROLE regress_partition_merge_alice;
-CREATE ROLE regress_partition_merge_bob;
-SET SESSION AUTHORIZATION regress_partition_merge_alice;
+CREATE ROLE regress_partition_split_alice;
+CREATE ROLE regress_partition_split_bob;
+GRANT ALL ON SCHEMA partition_split_schema TO regress_partition_split_alice;
+GRANT ALL ON SCHEMA partition_split_schema TO regress_partition_split_bob;
+SET SESSION AUTHORIZATION regress_partition_split_alice;
 CREATE TABLE t (i int) PARTITION BY RANGE (i);
 CREATE TABLE tp_0_2 PARTITION OF t FOR VALUES FROM (0) TO (2);
-SET SESSION AUTHORIZATION regress_partition_merge_bob;
+SET SESSION AUTHORIZATION regress_partition_split_bob;
 ALTER TABLE t SPLIT PARTITION tp_0_2 INTO
   (PARTITION tp_0_1 FOR VALUES FROM (0) TO (1),
    PARTITION tp_1_2 FOR VALUES FROM (1) TO (2));
 ERROR:  must be owner of table t
 RESET SESSION AUTHORIZATION;
-ALTER TABLE t OWNER TO regress_partition_merge_bob;
-SET SESSION AUTHORIZATION regress_partition_merge_bob;
+ALTER TABLE t OWNER TO regress_partition_split_bob;
+SET SESSION AUTHORIZATION regress_partition_split_bob;
 ALTER TABLE t SPLIT PARTITION tp_0_2 INTO
   (PARTITION tp_0_1 FOR VALUES FROM (0) TO (1),
    PARTITION tp_1_2 FOR VALUES FROM (1) TO (2));
 ERROR:  must be owner of table tp_0_2
 RESET SESSION AUTHORIZATION;
-ALTER TABLE tp_0_2 OWNER TO regress_partition_merge_bob;
-SET SESSION AUTHORIZATION regress_partition_merge_bob;
+ALTER TABLE tp_0_2 OWNER TO regress_partition_split_bob;
+SET SESSION AUTHORIZATION regress_partition_split_bob;
 ALTER TABLE t SPLIT PARTITION tp_0_2 INTO
   (PARTITION tp_0_1 FOR VALUES FROM (0) TO (1),
    PARTITION tp_1_2 FOR VALUES FROM (1) TO (2));
 RESET SESSION AUTHORIZATION;
 DROP TABLE t;
-DROP ROLE regress_partition_merge_alice;
-DROP ROLE regress_partition_merge_bob;
+REVOKE ALL ON SCHEMA partition_split_schema FROM regress_partition_split_alice;
+REVOKE ALL ON SCHEMA partition_split_schema FROM regress_partition_split_bob;
+DROP ROLE regress_partition_split_alice;
+DROP ROLE regress_partition_split_bob;
+RESET search_path;
 --
 DROP SCHEMA partition_split_schema;
 DROP SCHEMA partition_split_schema2;
index 9bfeb0d7ef303d202da4125ba7bdcac27376f503..5a741efa09baa957f882c11bec726416fd93a3ad 100644 (file)
@@ -553,6 +553,8 @@ DROP ACCESS METHOD partitions_merge_heap;
 -- the merging partitions to do the merge.
 CREATE ROLE regress_partition_merge_alice;
 CREATE ROLE regress_partition_merge_bob;
+GRANT ALL ON SCHEMA partitions_merge_schema TO regress_partition_merge_alice;
+GRANT ALL ON SCHEMA partitions_merge_schema TO regress_partition_merge_bob;
 
 SET SESSION AUTHORIZATION regress_partition_merge_alice;
 CREATE TABLE t (i int) PARTITION BY RANGE (i);
@@ -579,6 +581,8 @@ ALTER TABLE t MERGE PARTITIONS (tp_0_1, tp_1_2) INTO tp_0_2;
 RESET SESSION AUTHORIZATION;
 
 DROP TABLE t;
+REVOKE ALL ON SCHEMA partitions_merge_schema FROM regress_partition_merge_alice;
+REVOKE ALL ON SCHEMA partitions_merge_schema FROM regress_partition_merge_bob;
 DROP ROLE regress_partition_merge_alice;
 DROP ROLE regress_partition_merge_bob;
 
index bb52514b7ed79f2fc048638f12d94f1e845b02e7..70d70499ec6d519af88b5e0a7e1fef82195add6b 100644 (file)
@@ -896,37 +896,42 @@ DROP ACCESS METHOD partition_split_heap;
 
 -- Test permission checks.  The user needs to own the parent table and the
 -- the partition to split to do the split.
-CREATE ROLE regress_partition_merge_alice;
-CREATE ROLE regress_partition_merge_bob;
+CREATE ROLE regress_partition_split_alice;
+CREATE ROLE regress_partition_split_bob;
+GRANT ALL ON SCHEMA partition_split_schema TO regress_partition_split_alice;
+GRANT ALL ON SCHEMA partition_split_schema TO regress_partition_split_bob;
 
-SET SESSION AUTHORIZATION regress_partition_merge_alice;
+SET SESSION AUTHORIZATION regress_partition_split_alice;
 CREATE TABLE t (i int) PARTITION BY RANGE (i);
 CREATE TABLE tp_0_2 PARTITION OF t FOR VALUES FROM (0) TO (2);
 
-SET SESSION AUTHORIZATION regress_partition_merge_bob;
+SET SESSION AUTHORIZATION regress_partition_split_bob;
 ALTER TABLE t SPLIT PARTITION tp_0_2 INTO
   (PARTITION tp_0_1 FOR VALUES FROM (0) TO (1),
    PARTITION tp_1_2 FOR VALUES FROM (1) TO (2));
 RESET SESSION AUTHORIZATION;
 
-ALTER TABLE t OWNER TO regress_partition_merge_bob;
-SET SESSION AUTHORIZATION regress_partition_merge_bob;
+ALTER TABLE t OWNER TO regress_partition_split_bob;
+SET SESSION AUTHORIZATION regress_partition_split_bob;
 ALTER TABLE t SPLIT PARTITION tp_0_2 INTO
   (PARTITION tp_0_1 FOR VALUES FROM (0) TO (1),
    PARTITION tp_1_2 FOR VALUES FROM (1) TO (2));
 RESET SESSION AUTHORIZATION;
 
-ALTER TABLE tp_0_2 OWNER TO regress_partition_merge_bob;
-SET SESSION AUTHORIZATION regress_partition_merge_bob;
+ALTER TABLE tp_0_2 OWNER TO regress_partition_split_bob;
+SET SESSION AUTHORIZATION regress_partition_split_bob;
 ALTER TABLE t SPLIT PARTITION tp_0_2 INTO
   (PARTITION tp_0_1 FOR VALUES FROM (0) TO (1),
    PARTITION tp_1_2 FOR VALUES FROM (1) TO (2));
 RESET SESSION AUTHORIZATION;
 
 DROP TABLE t;
-DROP ROLE regress_partition_merge_alice;
-DROP ROLE regress_partition_merge_bob;
+REVOKE ALL ON SCHEMA partition_split_schema FROM regress_partition_split_alice;
+REVOKE ALL ON SCHEMA partition_split_schema FROM regress_partition_split_bob;
+DROP ROLE regress_partition_split_alice;
+DROP ROLE regress_partition_split_bob;
 
+RESET search_path;
 
 --
 DROP SCHEMA partition_split_schema;