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
This commit is contained in:
Tom Lane 2021-12-17 16:22:26 -05:00
parent 3c6f8c011f
commit 944dc45d1b
5 changed files with 12 additions and 8 deletions

View File

@ -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;

View 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;

View 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;

View 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

View File

@ -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;