Commit 8e753726 authored by Tom Lane's avatar Tom Lane

Suppress less info in regression tests using DROP CASCADE.

DROP CASCADE doesn't currently promise to visit dependent objects in
a fixed order, so when the regression tests use it, we typically need
to suppress the details of which objects get dropped in order to have
predictable test output.  Traditionally we've done that by setting
client_min_messages higher than NOTICE, but there's a better way:
we can "\set VERBOSITY terse" in psql.  That suppresses the DETAIL
message with the object list, but we still get the basic notice telling
how many objects were dropped.  So at least the test case can verify
that the expected number of objects were dropped.

The VERBOSITY method was already in use in a few places, but run
around and use it wherever it makes sense.

Discussion: https://postgr.es/m/10766.1501608885@sss.pgh.pa.us
parent 1e165d05
...@@ -673,13 +673,17 @@ SELECT nspname, prsname ...@@ -673,13 +673,17 @@ SELECT nspname, prsname
--- ---
--- Cleanup resources --- Cleanup resources
--- ---
set client_min_messages to warning; -- suppress cascade notices \set VERBOSITY terse \\ -- suppress cascade details
DROP FOREIGN DATA WRAPPER alt_fdw2 CASCADE; DROP FOREIGN DATA WRAPPER alt_fdw2 CASCADE;
NOTICE: drop cascades to server alt_fserv2
DROP FOREIGN DATA WRAPPER alt_fdw3 CASCADE; DROP FOREIGN DATA WRAPPER alt_fdw3 CASCADE;
NOTICE: drop cascades to server alt_fserv3
DROP LANGUAGE alt_lang2 CASCADE; DROP LANGUAGE alt_lang2 CASCADE;
DROP LANGUAGE alt_lang3 CASCADE; DROP LANGUAGE alt_lang3 CASCADE;
DROP SCHEMA alt_nsp1 CASCADE; DROP SCHEMA alt_nsp1 CASCADE;
NOTICE: drop cascades to 28 other objects
DROP SCHEMA alt_nsp2 CASCADE; DROP SCHEMA alt_nsp2 CASCADE;
NOTICE: drop cascades to 9 other objects
DROP USER regress_alter_user1; DROP USER regress_alter_user1;
DROP USER regress_alter_user2; DROP USER regress_alter_user2;
DROP USER regress_alter_user3; DROP USER regress_alter_user3;
...@@ -3064,6 +3064,6 @@ ERROR: must be owner of schema schema_to_reindex ...@@ -3064,6 +3064,6 @@ ERROR: must be owner of schema schema_to_reindex
-- Clean up -- Clean up
RESET ROLE; RESET ROLE;
DROP ROLE regress_reindexuser; DROP ROLE regress_reindexuser;
SET client_min_messages TO 'warning'; \set VERBOSITY terse \\ -- suppress cascade details
DROP SCHEMA schema_to_reindex CASCADE; DROP SCHEMA schema_to_reindex CASCADE;
RESET client_min_messages; NOTICE: drop cascades to 6 other objects
...@@ -1707,6 +1707,8 @@ select pg_get_ruledef(oid, true) from pg_rewrite ...@@ -1707,6 +1707,8 @@ select pg_get_ruledef(oid, true) from pg_rewrite
(1 row) (1 row)
-- clean up all the random objects we made above -- clean up all the random objects we made above
set client_min_messages = warning; \set VERBOSITY terse \\ -- suppress cascade details
DROP SCHEMA temp_view_test CASCADE; DROP SCHEMA temp_view_test CASCADE;
NOTICE: drop cascades to 27 other objects
DROP SCHEMA testviewschm2 CASCADE; DROP SCHEMA testviewschm2 CASCADE;
NOTICE: drop cascades to 62 other objects
...@@ -474,10 +474,12 @@ SELECT (pg_identify_object(addr1.classid, addr1.objid, addr1.objsubid)).*, ...@@ -474,10 +474,12 @@ SELECT (pg_identify_object(addr1.classid, addr1.objid, addr1.objsubid)).*,
--- ---
--- Cleanup resources --- Cleanup resources
--- ---
SET client_min_messages TO 'warning'; \set VERBOSITY terse \\ -- suppress cascade details
DROP FOREIGN DATA WRAPPER addr_fdw CASCADE; DROP FOREIGN DATA WRAPPER addr_fdw CASCADE;
NOTICE: drop cascades to 4 other objects
DROP PUBLICATION addr_pub; DROP PUBLICATION addr_pub;
DROP SUBSCRIPTION addr_sub; DROP SUBSCRIPTION addr_sub;
DROP SCHEMA addr_nsp CASCADE; DROP SCHEMA addr_nsp CASCADE;
NOTICE: drop cascades to 12 other objects
DROP OWNED BY regress_addr_user; DROP OWNED BY regress_addr_user;
DROP USER regress_addr_user; DROP USER regress_addr_user;
...@@ -1620,9 +1620,10 @@ SELECT has_function_privilege('regress_user1', 'testns.testfunc(int)', 'EXECUTE' ...@@ -1620,9 +1620,10 @@ SELECT has_function_privilege('regress_user1', 'testns.testfunc(int)', 'EXECUTE'
f f
(1 row) (1 row)
SET client_min_messages TO 'warning'; \set VERBOSITY terse \\ -- suppress cascade details
DROP SCHEMA testns CASCADE; DROP SCHEMA testns CASCADE;
RESET client_min_messages; NOTICE: drop cascades to 3 other objects
\set VERBOSITY default
-- Change owner of the schema & and rename of new schema owner -- Change owner of the schema & and rename of new schema owner
\c - \c -
CREATE ROLE regress_schemauser1 superuser login; CREATE ROLE regress_schemauser1 superuser login;
...@@ -1644,9 +1645,9 @@ SELECT nspname, rolname FROM pg_namespace, pg_roles WHERE pg_namespace.nspname = ...@@ -1644,9 +1645,9 @@ SELECT nspname, rolname FROM pg_namespace, pg_roles WHERE pg_namespace.nspname =
(1 row) (1 row)
set session role regress_schemauser_renamed; set session role regress_schemauser_renamed;
SET client_min_messages TO 'warning'; \set VERBOSITY terse \\ -- suppress cascade details
DROP SCHEMA testns CASCADE; DROP SCHEMA testns CASCADE;
RESET client_min_messages; \set VERBOSITY default
-- clean up -- clean up
\c - \c -
DROP ROLE regress_schemauser1; DROP ROLE regress_schemauser1;
......
...@@ -1393,10 +1393,10 @@ ERROR: infinite recursion detected in policy for relation "rec1" ...@@ -1393,10 +1393,10 @@ ERROR: infinite recursion detected in policy for relation "rec1"
-- Mutual recursion via .s.b views -- Mutual recursion via .s.b views
-- --
SET SESSION AUTHORIZATION regress_rls_bob; SET SESSION AUTHORIZATION regress_rls_bob;
-- Suppress NOTICE messages when doing a cascaded drop. \set VERBOSITY terse \\ -- suppress cascade details
SET client_min_messages TO 'warning';
DROP VIEW rec1v, rec2v CASCADE; DROP VIEW rec1v, rec2v CASCADE;
RESET client_min_messages; NOTICE: drop cascades to 2 other objects
\set VERBOSITY default
CREATE VIEW rec1v WITH (security_barrier) AS SELECT * FROM rec1; CREATE VIEW rec1v WITH (security_barrier) AS SELECT * FROM rec1;
CREATE VIEW rec2v WITH (security_barrier) AS SELECT * FROM rec2; CREATE VIEW rec2v WITH (security_barrier) AS SELECT * FROM rec2;
SET SESSION AUTHORIZATION regress_rls_alice; SET SESSION AUTHORIZATION regress_rls_alice;
...@@ -2775,10 +2775,10 @@ DROP TABLE test_qual_pushdown; ...@@ -2775,10 +2775,10 @@ DROP TABLE test_qual_pushdown;
-- Plancache invalidate on user change. -- Plancache invalidate on user change.
-- --
RESET SESSION AUTHORIZATION; RESET SESSION AUTHORIZATION;
-- Suppress NOTICE messages when doing a cascaded drop. \set VERBOSITY terse \\ -- suppress cascade details
SET client_min_messages TO 'warning';
DROP TABLE t1 CASCADE; DROP TABLE t1 CASCADE;
RESET client_min_messages; NOTICE: drop cascades to 2 other objects
\set VERBOSITY default
CREATE TABLE t1 (a integer); CREATE TABLE t1 (a integer);
GRANT SELECT ON t1 TO regress_rls_bob, regress_rls_carol; GRANT SELECT ON t1 TO regress_rls_bob, regress_rls_carol;
CREATE POLICY p1 ON t1 TO regress_rls_bob USING ((a % 2) = 0); CREATE POLICY p1 ON t1 TO regress_rls_bob USING ((a % 2) = 0);
...@@ -3902,10 +3902,10 @@ DROP USER regress_rls_dob_role2; ...@@ -3902,10 +3902,10 @@ DROP USER regress_rls_dob_role2;
-- Clean up objects -- Clean up objects
-- --
RESET SESSION AUTHORIZATION; RESET SESSION AUTHORIZATION;
-- Suppress NOTICE messages when doing a cascaded drop. \set VERBOSITY terse \\ -- suppress cascade details
SET client_min_messages TO 'warning';
DROP SCHEMA regress_rls_schema CASCADE; DROP SCHEMA regress_rls_schema CASCADE;
RESET client_min_messages; NOTICE: drop cascades to 29 other objects
\set VERBOSITY default
DROP USER regress_rls_alice; DROP USER regress_rls_alice;
DROP USER regress_rls_bob; DROP USER regress_rls_bob;
DROP USER regress_rls_carol; DROP USER regress_rls_carol;
......
...@@ -2622,9 +2622,10 @@ select * from id_ordered; ...@@ -2622,9 +2622,10 @@ select * from id_ordered;
6 | Test 6 6 | Test 6
(6 rows) (6 rows)
set client_min_messages to warning; -- suppress cascade notices \set VERBOSITY terse \\ -- suppress cascade details
drop table id cascade; drop table id cascade;
reset client_min_messages; NOTICE: drop cascades to 4 other objects
\set VERBOSITY default
-- --
-- check corner case where an entirely-dummy subplan is created by -- check corner case where an entirely-dummy subplan is created by
-- constraint exclusion -- constraint exclusion
......
...@@ -122,10 +122,12 @@ EXCEPTION WHEN wrong_object_type THEN ...@@ -122,10 +122,12 @@ EXCEPTION WHEN wrong_object_type THEN
END; END;
$$; $$;
NOTICE: stats on toast table not created NOTICE: stats on toast table not created
SET client_min_messages TO warning; \set VERBOSITY terse \\ -- suppress cascade details
DROP SCHEMA tststats CASCADE; DROP SCHEMA tststats CASCADE;
NOTICE: drop cascades to 7 other objects
DROP FOREIGN DATA WRAPPER extstats_dummy_fdw CASCADE; DROP FOREIGN DATA WRAPPER extstats_dummy_fdw CASCADE;
RESET client_min_messages; NOTICE: drop cascades to server extstats_dummy_srv
\set VERBOSITY default
-- n-distinct tests -- n-distinct tests
CREATE TABLE ndistinct ( CREATE TABLE ndistinct (
filler1 TEXT, filler1 TEXT,
......
-- Clean up in case a prior regression run failed
SET client_min_messages TO 'warning';
DROP TYPE IF EXISTS person_type CASCADE;
RESET client_min_messages;
CREATE TABLE ttable1 OF nothing; CREATE TABLE ttable1 OF nothing;
ERROR: type "nothing" does not exist ERROR: type "nothing" does not exist
CREATE TYPE person_type AS (id int, name text); CREATE TYPE person_type AS (id int, name text);
......
...@@ -573,7 +573,7 @@ SELECT nspname, prsname ...@@ -573,7 +573,7 @@ SELECT nspname, prsname
--- ---
--- Cleanup resources --- Cleanup resources
--- ---
set client_min_messages to warning; -- suppress cascade notices \set VERBOSITY terse \\ -- suppress cascade details
DROP FOREIGN DATA WRAPPER alt_fdw2 CASCADE; DROP FOREIGN DATA WRAPPER alt_fdw2 CASCADE;
DROP FOREIGN DATA WRAPPER alt_fdw3 CASCADE; DROP FOREIGN DATA WRAPPER alt_fdw3 CASCADE;
......
...@@ -1083,6 +1083,5 @@ REINDEX SCHEMA schema_to_reindex; ...@@ -1083,6 +1083,5 @@ REINDEX SCHEMA schema_to_reindex;
-- Clean up -- Clean up
RESET ROLE; RESET ROLE;
DROP ROLE regress_reindexuser; DROP ROLE regress_reindexuser;
SET client_min_messages TO 'warning'; \set VERBOSITY terse \\ -- suppress cascade details
DROP SCHEMA schema_to_reindex CASCADE; DROP SCHEMA schema_to_reindex CASCADE;
RESET client_min_messages;
...@@ -581,6 +581,6 @@ select pg_get_ruledef(oid, true) from pg_rewrite ...@@ -581,6 +581,6 @@ select pg_get_ruledef(oid, true) from pg_rewrite
where ev_class = 'tt23v'::regclass and ev_type = '1'; where ev_class = 'tt23v'::regclass and ev_type = '1';
-- clean up all the random objects we made above -- clean up all the random objects we made above
set client_min_messages = warning; \set VERBOSITY terse \\ -- suppress cascade details
DROP SCHEMA temp_view_test CASCADE; DROP SCHEMA temp_view_test CASCADE;
DROP SCHEMA testviewschm2 CASCADE; DROP SCHEMA testviewschm2 CASCADE;
...@@ -201,7 +201,7 @@ SELECT (pg_identify_object(addr1.classid, addr1.objid, addr1.objsubid)).*, ...@@ -201,7 +201,7 @@ SELECT (pg_identify_object(addr1.classid, addr1.objid, addr1.objsubid)).*,
--- ---
--- Cleanup resources --- Cleanup resources
--- ---
SET client_min_messages TO 'warning'; \set VERBOSITY terse \\ -- suppress cascade details
DROP FOREIGN DATA WRAPPER addr_fdw CASCADE; DROP FOREIGN DATA WRAPPER addr_fdw CASCADE;
DROP PUBLICATION addr_pub; DROP PUBLICATION addr_pub;
......
...@@ -981,9 +981,9 @@ REVOKE ALL ON ALL FUNCTIONS IN SCHEMA testns FROM PUBLIC; ...@@ -981,9 +981,9 @@ REVOKE ALL ON ALL FUNCTIONS IN SCHEMA testns FROM PUBLIC;
SELECT has_function_privilege('regress_user1', 'testns.testfunc(int)', 'EXECUTE'); -- false SELECT has_function_privilege('regress_user1', 'testns.testfunc(int)', 'EXECUTE'); -- false
SET client_min_messages TO 'warning'; \set VERBOSITY terse \\ -- suppress cascade details
DROP SCHEMA testns CASCADE; DROP SCHEMA testns CASCADE;
RESET client_min_messages; \set VERBOSITY default
-- Change owner of the schema & and rename of new schema owner -- Change owner of the schema & and rename of new schema owner
...@@ -1002,9 +1002,9 @@ ALTER ROLE regress_schemauser2 RENAME TO regress_schemauser_renamed; ...@@ -1002,9 +1002,9 @@ ALTER ROLE regress_schemauser2 RENAME TO regress_schemauser_renamed;
SELECT nspname, rolname FROM pg_namespace, pg_roles WHERE pg_namespace.nspname = 'testns' AND pg_namespace.nspowner = pg_roles.oid; SELECT nspname, rolname FROM pg_namespace, pg_roles WHERE pg_namespace.nspname = 'testns' AND pg_namespace.nspowner = pg_roles.oid;
set session role regress_schemauser_renamed; set session role regress_schemauser_renamed;
SET client_min_messages TO 'warning'; \set VERBOSITY terse \\ -- suppress cascade details
DROP SCHEMA testns CASCADE; DROP SCHEMA testns CASCADE;
RESET client_min_messages; \set VERBOSITY default
-- clean up -- clean up
\c - \c -
......
...@@ -517,11 +517,10 @@ SELECT * FROM rec1; -- fail, mutual recursion via views ...@@ -517,11 +517,10 @@ SELECT * FROM rec1; -- fail, mutual recursion via views
-- Mutual recursion via .s.b views -- Mutual recursion via .s.b views
-- --
SET SESSION AUTHORIZATION regress_rls_bob; SET SESSION AUTHORIZATION regress_rls_bob;
-- Suppress NOTICE messages when doing a cascaded drop.
SET client_min_messages TO 'warning';
\set VERBOSITY terse \\ -- suppress cascade details
DROP VIEW rec1v, rec2v CASCADE; DROP VIEW rec1v, rec2v CASCADE;
RESET client_min_messages; \set VERBOSITY default
CREATE VIEW rec1v WITH (security_barrier) AS SELECT * FROM rec1; CREATE VIEW rec1v WITH (security_barrier) AS SELECT * FROM rec1;
CREATE VIEW rec2v WITH (security_barrier) AS SELECT * FROM rec2; CREATE VIEW rec2v WITH (security_barrier) AS SELECT * FROM rec2;
...@@ -1026,11 +1025,10 @@ DROP TABLE test_qual_pushdown; ...@@ -1026,11 +1025,10 @@ DROP TABLE test_qual_pushdown;
-- Plancache invalidate on user change. -- Plancache invalidate on user change.
-- --
RESET SESSION AUTHORIZATION; RESET SESSION AUTHORIZATION;
-- Suppress NOTICE messages when doing a cascaded drop.
SET client_min_messages TO 'warning';
\set VERBOSITY terse \\ -- suppress cascade details
DROP TABLE t1 CASCADE; DROP TABLE t1 CASCADE;
RESET client_min_messages; \set VERBOSITY default
CREATE TABLE t1 (a integer); CREATE TABLE t1 (a integer);
...@@ -1762,11 +1760,9 @@ DROP USER regress_rls_dob_role2; ...@@ -1762,11 +1760,9 @@ DROP USER regress_rls_dob_role2;
-- --
RESET SESSION AUTHORIZATION; RESET SESSION AUTHORIZATION;
-- Suppress NOTICE messages when doing a cascaded drop. \set VERBOSITY terse \\ -- suppress cascade details
SET client_min_messages TO 'warning';
DROP SCHEMA regress_rls_schema CASCADE; DROP SCHEMA regress_rls_schema CASCADE;
RESET client_min_messages; \set VERBOSITY default
DROP USER regress_rls_alice; DROP USER regress_rls_alice;
DROP USER regress_rls_bob; DROP USER regress_rls_bob;
......
...@@ -936,9 +936,9 @@ update id_ordered set name = 'update 4' where id = 4; ...@@ -936,9 +936,9 @@ update id_ordered set name = 'update 4' where id = 4;
update id_ordered set name = 'update 5' where id = 5; update id_ordered set name = 'update 5' where id = 5;
select * from id_ordered; select * from id_ordered;
set client_min_messages to warning; -- suppress cascade notices \set VERBOSITY terse \\ -- suppress cascade details
drop table id cascade; drop table id cascade;
reset client_min_messages; \set VERBOSITY default
-- --
-- check corner case where an entirely-dummy subplan is created by -- check corner case where an entirely-dummy subplan is created by
......
...@@ -89,10 +89,10 @@ EXCEPTION WHEN wrong_object_type THEN ...@@ -89,10 +89,10 @@ EXCEPTION WHEN wrong_object_type THEN
END; END;
$$; $$;
SET client_min_messages TO warning; \set VERBOSITY terse \\ -- suppress cascade details
DROP SCHEMA tststats CASCADE; DROP SCHEMA tststats CASCADE;
DROP FOREIGN DATA WRAPPER extstats_dummy_fdw CASCADE; DROP FOREIGN DATA WRAPPER extstats_dummy_fdw CASCADE;
RESET client_min_messages; \set VERBOSITY default
-- n-distinct tests -- n-distinct tests
CREATE TABLE ndistinct ( CREATE TABLE ndistinct (
......
-- Clean up in case a prior regression run failed
SET client_min_messages TO 'warning';
DROP TYPE IF EXISTS person_type CASCADE;
RESET client_min_messages;
CREATE TABLE ttable1 OF nothing; CREATE TABLE ttable1 OF nothing;
CREATE TYPE person_type AS (id int, name text); CREATE TYPE person_type AS (id int, name text);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment