From 944dc45d1b633c4d612cdff9f15153ed609eaa35 Mon Sep 17 00:00:00 2001 From: Tom Lane Date: Fri, 17 Dec 2021 16:22:26 -0500 Subject: [PATCH] Fix the public schema's permissions in a separate test script. 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 | 3 +++ src/test/regress/input/tablespace.source | 5 +---- src/test/regress/output/tablespace.source | 4 +--- src/test/regress/parallel_schedule | 5 ++++- src/test/regress/sql/test_setup.sql | 3 +++ 5 files changed, 12 insertions(+), 8 deletions(-) create mode 100644 src/test/regress/expected/test_setup.out create mode 100644 src/test/regress/sql/test_setup.sql diff --git a/src/test/regress/expected/test_setup.out b/src/test/regress/expected/test_setup.out new file mode 100644 index 00000000000..bea7a7e2654 --- /dev/null +++ b/src/test/regress/expected/test_setup.out @@ -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; diff --git a/src/test/regress/input/tablespace.source b/src/test/regress/input/tablespace.source index cb9774ecc85..c133e73499f 100644 --- a/src/test/regress/input/tablespace.source +++ b/src/test/regress/input/tablespace.source @@ -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; diff --git a/src/test/regress/output/tablespace.source b/src/test/regress/output/tablespace.source index e7629d470e5..1bbe7e03236 100644 --- a/src/test/regress/output/tablespace.source +++ b/src/test/regress/output/tablespace.source @@ -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; diff --git a/src/test/regress/parallel_schedule b/src/test/regress/parallel_schedule index 017e962fed2..5b0c73d7e37 100644 --- a/src/test/regress/parallel_schedule +++ b/src/test/regress/parallel_schedule @@ -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 index 00000000000..bea7a7e2654 --- /dev/null +++ b/src/test/regress/sql/test_setup.sql @@ -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;