Fix the public schema's permissions in a separate test script.
authorTom Lane <tgl@sss.pgh.pa.us>
Fri, 17 Dec 2021 21:22:26 +0000 (16:22 -0500)
committerTom Lane <tgl@sss.pgh.pa.us>
Fri, 17 Dec 2021 21:22:26 +0000 (16:22 -0500)
In the wake of commit b073c3ccd, it's necessary to grant create
permissions on the public schema to PUBLIC to get many of the
core regression test scripts to pass.  That commit did so via the
quick-n-dirty expedient of adding the GRANT to the tablespace test,
which runs first.  This is problematic for single-machine
replication testing, though.  The least painful way to run the
regression tests on such a setup is to skip the tablespace test,
and that no longer works.

To fix, let's invent a separate "test_setup" script to run first,
and put the GRANT there.  Revert b073c3ccd's changes to
the tablespace.source files.

In the future it might be good to try to reduce coupling between
the various test scripts by having test_setup create widely-used
objects, with the goal that most of the scripts could run after
having run only test_setup.  That's going to take some effort,
so this commit just addresses my immediate pain point.

Discussion: https://postgr.es/m/1363170.1639763559@sss.pgh.pa.us

src/test/regress/expected/test_setup.out [new file with mode: 0644]
src/test/regress/input/tablespace.source
src/test/regress/output/tablespace.source
src/test/regress/parallel_schedule
src/test/regress/sql/test_setup.sql [new file with mode: 0644]

diff --git a/src/test/regress/expected/test_setup.out b/src/test/regress/expected/test_setup.out
new file mode 100644 (file)
index 0000000..bea7a7e
--- /dev/null
@@ -0,0 +1,3 @@
+-- Postgres formerly made the public schema read/write by default,
+-- and most of the core regression tests still expect that.
+GRANT ALL ON SCHEMA public TO public;
index cb9774ecc852051c280b9c68dc50c7715e842e5e..c133e73499f1f8cf9d3a162857d2a115ae8f5787 100644 (file)
@@ -388,7 +388,7 @@ CREATE INDEX k ON testschema.tablespace_acl (c) TABLESPACE regress_tblspace;
 ALTER TABLE testschema.tablespace_acl OWNER TO regress_tablespace_user2;
 
 SET SESSION ROLE regress_tablespace_user2;
-CREATE TEMP TABLE tablespace_table (i int) TABLESPACE regress_tblspace; -- fail
+CREATE TABLE tablespace_table (i int) TABLESPACE regress_tblspace; -- fail
 ALTER TABLE testschema.tablespace_acl ALTER c TYPE bigint;
 REINDEX (TABLESPACE regress_tblspace) TABLE tablespace_table; -- fail
 REINDEX (TABLESPACE regress_tblspace, CONCURRENTLY) TABLE tablespace_table; -- fail
@@ -409,6 +409,3 @@ DROP SCHEMA testschema CASCADE;
 
 DROP ROLE regress_tablespace_user1;
 DROP ROLE regress_tablespace_user2;
-
--- Rest of this suite can use the public schema freely.
-GRANT ALL ON SCHEMA public TO public;
index e7629d470e5386deaeaac05fc025a067ecd77725..1bbe7e03236c0fddba78aacb938df00d671968d4 100644 (file)
@@ -908,7 +908,7 @@ CREATE TABLE testschema.tablespace_acl (c int);
 CREATE INDEX k ON testschema.tablespace_acl (c) TABLESPACE regress_tblspace;
 ALTER TABLE testschema.tablespace_acl OWNER TO regress_tablespace_user2;
 SET SESSION ROLE regress_tablespace_user2;
-CREATE TEMP TABLE tablespace_table (i int) TABLESPACE regress_tblspace; -- fail
+CREATE TABLE tablespace_table (i int) TABLESPACE regress_tblspace; -- fail
 ERROR:  permission denied for tablespace regress_tblspace
 ALTER TABLE testschema.tablespace_acl ALTER c TYPE bigint;
 REINDEX (TABLESPACE regress_tblspace) TABLE tablespace_table; -- fail
@@ -934,5 +934,3 @@ drop cascades to table testschema.atable
 drop cascades to table testschema.tablespace_acl
 DROP ROLE regress_tablespace_user1;
 DROP ROLE regress_tablespace_user2;
--- Rest of this suite can use the public schema freely.
-GRANT ALL ON SCHEMA public TO public;
index 017e962fed246e79869938134654e41efada3a3c..5b0c73d7e37d069c9391b317c091446f337166a3 100644 (file)
@@ -5,7 +5,10 @@
 # this limits the number of connections needed to run the tests.
 # ----------
 
-# run tablespace by itself, and first, because it forces a checkpoint;
+# required setup steps
+test: test_setup
+
+# run tablespace by itself, and early, because it forces a checkpoint;
 # we'd prefer not to have checkpoints later in the tests because that
 # interferes with crash-recovery testing.
 test: tablespace
diff --git a/src/test/regress/sql/test_setup.sql b/src/test/regress/sql/test_setup.sql
new file mode 100644 (file)
index 0000000..bea7a7e
--- /dev/null
@@ -0,0 +1,3 @@
+-- Postgres formerly made the public schema read/write by default,
+-- and most of the core regression tests still expect that.
+GRANT ALL ON SCHEMA public TO public;