Suppress less info in regression tests using DROP CASCADE.
authorTom Lane
Tue, 1 Aug 2017 20:49:23 +0000 (16:49 -0400)
committerTom Lane
Tue, 1 Aug 2017 20:49:23 +0000 (16:49 -0400)
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

18 files changed:
src/test/regress/expected/alter_generic.out
src/test/regress/expected/create_index.out
src/test/regress/expected/create_view.out
src/test/regress/expected/object_address.out
src/test/regress/expected/privileges.out
src/test/regress/expected/rowsecurity.out
src/test/regress/expected/rules.out
src/test/regress/expected/stats_ext.out
src/test/regress/expected/typed_table.out
src/test/regress/sql/alter_generic.sql
src/test/regress/sql/create_index.sql
src/test/regress/sql/create_view.sql
src/test/regress/sql/object_address.sql
src/test/regress/sql/privileges.sql
src/test/regress/sql/rowsecurity.sql
src/test/regress/sql/rules.sql
src/test/regress/sql/stats_ext.sql
src/test/regress/sql/typed_table.sql

index 62347bc47e84a0ce79ce2b42f04271c3b9abc7a6..9f6ad4de33be71fc1432456051c7546288b130cb 100644 (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;
index 26cd05933cab1d9740d25a0e4067986765fc9c0c..064adb4640bc3c99b7f73df7ae696192bfc86f8a 100644 (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
index 34f0b7641d44e2eecbcd44b75bcbe0c458a63dc0..f909a3cefeb586737af0e743b70cb877d7c017b9 100644 (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
index 3f23a489728bdd8674b1249a605d4051fbe45847..1fdadbc9ef6324716012ac25425d5db3543a96aa 100644 (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;
index 3262aa1d100aac051d461f8996125437d20da904..da37c4faeddba46b36d569b8c1b206bdbdcebcd5 100644 (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;
index 26d28f248b14c3c77377caed70fc92c742b1bb84..de2ee4d2c907cd0ecd216696afa1ac4db4c81c20 100644 (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;
index 2e42b9ec05fab06496a84ab3079029f1a55393ee..05adfa237684b324ab8ab78e7b10888bbf9bf85a 100644 (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
index 085dce7fd782f1eae7b8a73bd31f0278cebcb4c0..441cfaa411b299fae0c8a628a8df4970d28cf17f 100644 (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,
index 5cdd019244e2758441f507074cfbeaf9a1fcaea9..2e47ecbcf50838d4b5f3de23911622ac652c3bab 100644 (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);
index 342f82856e195870c77034bd51cff392b9a79430..311812e351d5e8e8713d6a319b61c3e902fb05b7 100644 (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;
index 16480725688a9a95785aeb2f8529a477f393a8c6..67470db918b7bd6884c1363edd48551270106ce7 100644 (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;
index 04941671dd554e90f8108c5d1c42d639d6fa85a8..b4e7a8793cb4f0b290b4cf4add691c52a2a6b77e 100644 (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;
index ca7ed46e417932e0c4e5fa7bd2e9668e72ab65ec..63821b8008b94f4fb1729f00204bb571f7a10ed1 100644 (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;
index fe83709e1b6e0351c09ddd020f386145985040de..5bc47bcd13724db9aa306117c7b6042788ec167b 100644 (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 -
index ba8fed40f5ce3e867e9f4de5080638ee23af403e..e03a7ab65f32fcd02de750c71e0646ab100dcfff 100644 (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;
index 38751bb8818889d30d3b3e965a88ce185660c2a6..0ded0f01d29119419a4de8a971579b8eba00aefe 100644 (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
index d1ff3a8583e884ae597ae31d779bcea63da41336..46acaadb3932a7a891b480c449214ac442a1bad8 100644 (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 (
index 1cdceef3637e8a648ab69f9629a54ee548fec6de..9ef0cdfcc7e468daafae7e6c8eeae69663f115ae 100644 (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);