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
This commit is contained in:
Tom Lane 2017-08-01 16:49:23 -04:00
parent 1e165d05fe
commit 8e7537261c
18 changed files with 52 additions and 56 deletions

View File

@ -673,13 +673,17 @@ SELECT nspname, prsname
---
--- Cleanup resources
---
set client_min_messages to warning; -- suppress cascade notices
\set VERBOSITY terse \\ -- suppress cascade details
DROP FOREIGN DATA WRAPPER alt_fdw2 CASCADE;
NOTICE: drop cascades to server alt_fserv2
DROP FOREIGN DATA WRAPPER alt_fdw3 CASCADE;
NOTICE: drop cascades to server alt_fserv3
DROP LANGUAGE alt_lang2 CASCADE;
DROP LANGUAGE alt_lang3 CASCADE;
DROP SCHEMA alt_nsp1 CASCADE;
NOTICE: drop cascades to 28 other objects
DROP SCHEMA alt_nsp2 CASCADE;
NOTICE: drop cascades to 9 other objects
DROP USER regress_alter_user1;
DROP USER regress_alter_user2;
DROP USER regress_alter_user3;

View File

@ -3064,6 +3064,6 @@ ERROR: must be owner of schema schema_to_reindex
-- Clean up
RESET ROLE;
DROP ROLE regress_reindexuser;
SET client_min_messages TO 'warning';
\set VERBOSITY terse \\ -- suppress cascade details
DROP SCHEMA schema_to_reindex CASCADE;
RESET client_min_messages;
NOTICE: drop cascades to 6 other objects

View File

@ -1707,6 +1707,8 @@ select pg_get_ruledef(oid, true) from pg_rewrite
(1 row)
-- 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;
NOTICE: drop cascades to 27 other objects
DROP SCHEMA testviewschm2 CASCADE;
NOTICE: drop cascades to 62 other objects

View File

@ -474,10 +474,12 @@ SELECT (pg_identify_object(addr1.classid, addr1.objid, addr1.objsubid)).*,
---
--- Cleanup resources
---
SET client_min_messages TO 'warning';
\set VERBOSITY terse \\ -- suppress cascade details
DROP FOREIGN DATA WRAPPER addr_fdw CASCADE;
NOTICE: drop cascades to 4 other objects
DROP PUBLICATION addr_pub;
DROP SUBSCRIPTION addr_sub;
DROP SCHEMA addr_nsp CASCADE;
NOTICE: drop cascades to 12 other objects
DROP OWNED BY regress_addr_user;
DROP USER regress_addr_user;

View File

@ -1620,9 +1620,10 @@ SELECT has_function_privilege('regress_user1', 'testns.testfunc(int)', 'EXECUTE'
f
(1 row)
SET client_min_messages TO 'warning';
\set VERBOSITY terse \\ -- suppress cascade details
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
\c -
CREATE ROLE regress_schemauser1 superuser login;
@ -1644,9 +1645,9 @@ SELECT nspname, rolname FROM pg_namespace, pg_roles WHERE pg_namespace.nspname =
(1 row)
set session role regress_schemauser_renamed;
SET client_min_messages TO 'warning';
\set VERBOSITY terse \\ -- suppress cascade details
DROP SCHEMA testns CASCADE;
RESET client_min_messages;
\set VERBOSITY default
-- clean up
\c -
DROP ROLE regress_schemauser1;

View File

@ -1393,10 +1393,10 @@ ERROR: infinite recursion detected in policy for relation "rec1"
-- Mutual recursion via .s.b views
--
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;
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 rec2v WITH (security_barrier) AS SELECT * FROM rec2;
SET SESSION AUTHORIZATION regress_rls_alice;
@ -2775,10 +2775,10 @@ DROP TABLE test_qual_pushdown;
-- Plancache invalidate on user change.
--
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;
RESET client_min_messages;
NOTICE: drop cascades to 2 other objects
\set VERBOSITY default
CREATE TABLE t1 (a integer);
GRANT SELECT ON t1 TO regress_rls_bob, regress_rls_carol;
CREATE POLICY p1 ON t1 TO regress_rls_bob USING ((a % 2) = 0);
@ -3902,10 +3902,10 @@ DROP USER regress_rls_dob_role2;
-- Clean up objects
--
RESET SESSION AUTHORIZATION;
-- Suppress NOTICE messages when doing a cascaded drop.
SET client_min_messages TO 'warning';
\set VERBOSITY terse \\ -- suppress cascade details
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_bob;
DROP USER regress_rls_carol;

View File

@ -2622,9 +2622,10 @@ select * from id_ordered;
6 | Test 6
(6 rows)
set client_min_messages to warning; -- suppress cascade notices
\set VERBOSITY terse \\ -- suppress cascade details
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
-- constraint exclusion

View File

@ -122,10 +122,12 @@ EXCEPTION WHEN wrong_object_type THEN
END;
$$;
NOTICE: stats on toast table not created
SET client_min_messages TO warning;
\set VERBOSITY terse \\ -- suppress cascade details
DROP SCHEMA tststats CASCADE;
NOTICE: drop cascades to 7 other objects
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
CREATE TABLE ndistinct (
filler1 TEXT,

View File

@ -1,7 +1,3 @@
-- 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;
ERROR: type "nothing" does not exist
CREATE TYPE person_type AS (id int, name text);

View File

@ -573,7 +573,7 @@ SELECT nspname, prsname
---
--- 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_fdw3 CASCADE;

View File

@ -1083,6 +1083,5 @@ REINDEX SCHEMA schema_to_reindex;
-- Clean up
RESET ROLE;
DROP ROLE regress_reindexuser;
SET client_min_messages TO 'warning';
\set VERBOSITY terse \\ -- suppress cascade details
DROP SCHEMA schema_to_reindex CASCADE;
RESET client_min_messages;

View File

@ -581,6 +581,6 @@ select pg_get_ruledef(oid, true) from pg_rewrite
where ev_class = 'tt23v'::regclass and ev_type = '1';
-- 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 testviewschm2 CASCADE;

View File

@ -201,7 +201,7 @@ SELECT (pg_identify_object(addr1.classid, addr1.objid, addr1.objsubid)).*,
---
--- Cleanup resources
---
SET client_min_messages TO 'warning';
\set VERBOSITY terse \\ -- suppress cascade details
DROP FOREIGN DATA WRAPPER addr_fdw CASCADE;
DROP PUBLICATION addr_pub;

View File

@ -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
SET client_min_messages TO 'warning';
\set VERBOSITY terse \\ -- suppress cascade details
DROP SCHEMA testns CASCADE;
RESET client_min_messages;
\set VERBOSITY default
-- Change owner of the schema & and rename of new schema owner
@ -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;
set session role regress_schemauser_renamed;
SET client_min_messages TO 'warning';
\set VERBOSITY terse \\ -- suppress cascade details
DROP SCHEMA testns CASCADE;
RESET client_min_messages;
\set VERBOSITY default
-- clean up
\c -

View File

@ -517,11 +517,10 @@ SELECT * FROM rec1; -- fail, mutual recursion via views
-- Mutual recursion via .s.b views
--
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;
RESET client_min_messages;
\set VERBOSITY default
CREATE VIEW rec1v WITH (security_barrier) AS SELECT * FROM rec1;
CREATE VIEW rec2v WITH (security_barrier) AS SELECT * FROM rec2;
@ -1026,11 +1025,10 @@ DROP TABLE test_qual_pushdown;
-- Plancache invalidate on user change.
--
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;
RESET client_min_messages;
\set VERBOSITY default
CREATE TABLE t1 (a integer);
@ -1762,11 +1760,9 @@ DROP USER regress_rls_dob_role2;
--
RESET SESSION AUTHORIZATION;
-- Suppress NOTICE messages when doing a cascaded drop.
SET client_min_messages TO 'warning';
\set VERBOSITY terse \\ -- suppress cascade details
DROP SCHEMA regress_rls_schema CASCADE;
RESET client_min_messages;
\set VERBOSITY default
DROP USER regress_rls_alice;
DROP USER regress_rls_bob;

View File

@ -936,9 +936,9 @@ update id_ordered set name = 'update 4' where id = 4;
update id_ordered set name = 'update 5' where id = 5;
select * from id_ordered;
set client_min_messages to warning; -- suppress cascade notices
\set VERBOSITY terse \\ -- suppress cascade details
drop table id cascade;
reset client_min_messages;
\set VERBOSITY default
--
-- check corner case where an entirely-dummy subplan is created by

View File

@ -89,10 +89,10 @@ EXCEPTION WHEN wrong_object_type THEN
END;
$$;
SET client_min_messages TO warning;
\set VERBOSITY terse \\ -- suppress cascade details
DROP SCHEMA tststats CASCADE;
DROP FOREIGN DATA WRAPPER extstats_dummy_fdw CASCADE;
RESET client_min_messages;
\set VERBOSITY default
-- n-distinct tests
CREATE TABLE ndistinct (

View File

@ -1,10 +1,3 @@
-- 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 TYPE person_type AS (id int, name text);