Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 8e75372

Browse files
committed
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
1 parent 1e165d0 commit 8e75372

18 files changed

+52
-56
lines changed

src/test/regress/expected/alter_generic.out

+5-1
Original file line numberDiff line numberDiff line change
@@ -673,13 +673,17 @@ SELECT nspname, prsname
673673
---
674674
--- Cleanup resources
675675
---
676-
set client_min_messages to warning; -- suppress cascade notices
676+
\set VERBOSITY terse \\ -- suppress cascade details
677677
DROP FOREIGN DATA WRAPPER alt_fdw2 CASCADE;
678+
NOTICE: drop cascades to server alt_fserv2
678679
DROP FOREIGN DATA WRAPPER alt_fdw3 CASCADE;
680+
NOTICE: drop cascades to server alt_fserv3
679681
DROP LANGUAGE alt_lang2 CASCADE;
680682
DROP LANGUAGE alt_lang3 CASCADE;
681683
DROP SCHEMA alt_nsp1 CASCADE;
684+
NOTICE: drop cascades to 28 other objects
682685
DROP SCHEMA alt_nsp2 CASCADE;
686+
NOTICE: drop cascades to 9 other objects
683687
DROP USER regress_alter_user1;
684688
DROP USER regress_alter_user2;
685689
DROP USER regress_alter_user3;

src/test/regress/expected/create_index.out

+2-2
Original file line numberDiff line numberDiff line change
@@ -3064,6 +3064,6 @@ ERROR: must be owner of schema schema_to_reindex
30643064
-- Clean up
30653065
RESET ROLE;
30663066
DROP ROLE regress_reindexuser;
3067-
SET client_min_messages TO 'warning';
3067+
\set VERBOSITY terse \\ -- suppress cascade details
30683068
DROP SCHEMA schema_to_reindex CASCADE;
3069-
RESET client_min_messages;
3069+
NOTICE: drop cascades to 6 other objects

src/test/regress/expected/create_view.out

+3-1
Original file line numberDiff line numberDiff line change
@@ -1707,6 +1707,8 @@ select pg_get_ruledef(oid, true) from pg_rewrite
17071707
(1 row)
17081708

17091709
-- clean up all the random objects we made above
1710-
set client_min_messages = warning;
1710+
\set VERBOSITY terse \\ -- suppress cascade details
17111711
DROP SCHEMA temp_view_test CASCADE;
1712+
NOTICE: drop cascades to 27 other objects
17121713
DROP SCHEMA testviewschm2 CASCADE;
1714+
NOTICE: drop cascades to 62 other objects

src/test/regress/expected/object_address.out

+3-1
Original file line numberDiff line numberDiff line change
@@ -474,10 +474,12 @@ SELECT (pg_identify_object(addr1.classid, addr1.objid, addr1.objsubid)).*,
474474
---
475475
--- Cleanup resources
476476
---
477-
SET client_min_messages TO 'warning';
477+
\set VERBOSITY terse \\ -- suppress cascade details
478478
DROP FOREIGN DATA WRAPPER addr_fdw CASCADE;
479+
NOTICE: drop cascades to 4 other objects
479480
DROP PUBLICATION addr_pub;
480481
DROP SUBSCRIPTION addr_sub;
481482
DROP SCHEMA addr_nsp CASCADE;
483+
NOTICE: drop cascades to 12 other objects
482484
DROP OWNED BY regress_addr_user;
483485
DROP USER regress_addr_user;

src/test/regress/expected/privileges.out

+5-4
Original file line numberDiff line numberDiff line change
@@ -1620,9 +1620,10 @@ SELECT has_function_privilege('regress_user1', 'testns.testfunc(int)', 'EXECUTE'
16201620
f
16211621
(1 row)
16221622

1623-
SET client_min_messages TO 'warning';
1623+
\set VERBOSITY terse \\ -- suppress cascade details
16241624
DROP SCHEMA testns CASCADE;
1625-
RESET client_min_messages;
1625+
NOTICE: drop cascades to 3 other objects
1626+
\set VERBOSITY default
16261627
-- Change owner of the schema & and rename of new schema owner
16271628
\c -
16281629
CREATE ROLE regress_schemauser1 superuser login;
@@ -1644,9 +1645,9 @@ SELECT nspname, rolname FROM pg_namespace, pg_roles WHERE pg_namespace.nspname =
16441645
(1 row)
16451646

16461647
set session role regress_schemauser_renamed;
1647-
SET client_min_messages TO 'warning';
1648+
\set VERBOSITY terse \\ -- suppress cascade details
16481649
DROP SCHEMA testns CASCADE;
1649-
RESET client_min_messages;
1650+
\set VERBOSITY default
16501651
-- clean up
16511652
\c -
16521653
DROP ROLE regress_schemauser1;

src/test/regress/expected/rowsecurity.out

+9-9
Original file line numberDiff line numberDiff line change
@@ -1393,10 +1393,10 @@ ERROR: infinite recursion detected in policy for relation "rec1"
13931393
-- Mutual recursion via .s.b views
13941394
--
13951395
SET SESSION AUTHORIZATION regress_rls_bob;
1396-
-- Suppress NOTICE messages when doing a cascaded drop.
1397-
SET client_min_messages TO 'warning';
1396+
\set VERBOSITY terse \\ -- suppress cascade details
13981397
DROP VIEW rec1v, rec2v CASCADE;
1399-
RESET client_min_messages;
1398+
NOTICE: drop cascades to 2 other objects
1399+
\set VERBOSITY default
14001400
CREATE VIEW rec1v WITH (security_barrier) AS SELECT * FROM rec1;
14011401
CREATE VIEW rec2v WITH (security_barrier) AS SELECT * FROM rec2;
14021402
SET SESSION AUTHORIZATION regress_rls_alice;
@@ -2775,10 +2775,10 @@ DROP TABLE test_qual_pushdown;
27752775
-- Plancache invalidate on user change.
27762776
--
27772777
RESET SESSION AUTHORIZATION;
2778-
-- Suppress NOTICE messages when doing a cascaded drop.
2779-
SET client_min_messages TO 'warning';
2778+
\set VERBOSITY terse \\ -- suppress cascade details
27802779
DROP TABLE t1 CASCADE;
2781-
RESET client_min_messages;
2780+
NOTICE: drop cascades to 2 other objects
2781+
\set VERBOSITY default
27822782
CREATE TABLE t1 (a integer);
27832783
GRANT SELECT ON t1 TO regress_rls_bob, regress_rls_carol;
27842784
CREATE POLICY p1 ON t1 TO regress_rls_bob USING ((a % 2) = 0);
@@ -3902,10 +3902,10 @@ DROP USER regress_rls_dob_role2;
39023902
-- Clean up objects
39033903
--
39043904
RESET SESSION AUTHORIZATION;
3905-
-- Suppress NOTICE messages when doing a cascaded drop.
3906-
SET client_min_messages TO 'warning';
3905+
\set VERBOSITY terse \\ -- suppress cascade details
39073906
DROP SCHEMA regress_rls_schema CASCADE;
3908-
RESET client_min_messages;
3907+
NOTICE: drop cascades to 29 other objects
3908+
\set VERBOSITY default
39093909
DROP USER regress_rls_alice;
39103910
DROP USER regress_rls_bob;
39113911
DROP USER regress_rls_carol;

src/test/regress/expected/rules.out

+3-2
Original file line numberDiff line numberDiff line change
@@ -2622,9 +2622,10 @@ select * from id_ordered;
26222622
6 | Test 6
26232623
(6 rows)
26242624

2625-
set client_min_messages to warning; -- suppress cascade notices
2625+
\set VERBOSITY terse \\ -- suppress cascade details
26262626
drop table id cascade;
2627-
reset client_min_messages;
2627+
NOTICE: drop cascades to 4 other objects
2628+
\set VERBOSITY default
26282629
--
26292630
-- check corner case where an entirely-dummy subplan is created by
26302631
-- constraint exclusion

src/test/regress/expected/stats_ext.out

+4-2
Original file line numberDiff line numberDiff line change
@@ -122,10 +122,12 @@ EXCEPTION WHEN wrong_object_type THEN
122122
END;
123123
$$;
124124
NOTICE: stats on toast table not created
125-
SET client_min_messages TO warning;
125+
\set VERBOSITY terse \\ -- suppress cascade details
126126
DROP SCHEMA tststats CASCADE;
127+
NOTICE: drop cascades to 7 other objects
127128
DROP FOREIGN DATA WRAPPER extstats_dummy_fdw CASCADE;
128-
RESET client_min_messages;
129+
NOTICE: drop cascades to server extstats_dummy_srv
130+
\set VERBOSITY default
129131
-- n-distinct tests
130132
CREATE TABLE ndistinct (
131133
filler1 TEXT,

src/test/regress/expected/typed_table.out

-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,3 @@
1-
-- Clean up in case a prior regression run failed
2-
SET client_min_messages TO 'warning';
3-
DROP TYPE IF EXISTS person_type CASCADE;
4-
RESET client_min_messages;
51
CREATE TABLE ttable1 OF nothing;
62
ERROR: type "nothing" does not exist
73
CREATE TYPE person_type AS (id int, name text);

src/test/regress/sql/alter_generic.sql

+1-1
Original file line numberDiff line numberDiff line change
@@ -573,7 +573,7 @@ SELECT nspname, prsname
573573
---
574574
--- Cleanup resources
575575
---
576-
set client_min_messages to warning; -- suppress cascade notices
576+
\set VERBOSITY terse \\ -- suppress cascade details
577577

578578
DROP FOREIGN DATA WRAPPER alt_fdw2 CASCADE;
579579
DROP FOREIGN DATA WRAPPER alt_fdw3 CASCADE;

src/test/regress/sql/create_index.sql

+1-2
Original file line numberDiff line numberDiff line change
@@ -1083,6 +1083,5 @@ REINDEX SCHEMA schema_to_reindex;
10831083
-- Clean up
10841084
RESET ROLE;
10851085
DROP ROLE regress_reindexuser;
1086-
SET client_min_messages TO 'warning';
1086+
\set VERBOSITY terse \\ -- suppress cascade details
10871087
DROP SCHEMA schema_to_reindex CASCADE;
1088-
RESET client_min_messages;

src/test/regress/sql/create_view.sql

+1-1
Original file line numberDiff line numberDiff line change
@@ -581,6 +581,6 @@ select pg_get_ruledef(oid, true) from pg_rewrite
581581
where ev_class = 'tt23v'::regclass and ev_type = '1';
582582

583583
-- clean up all the random objects we made above
584-
set client_min_messages = warning;
584+
\set VERBOSITY terse \\ -- suppress cascade details
585585
DROP SCHEMA temp_view_test CASCADE;
586586
DROP SCHEMA testviewschm2 CASCADE;

src/test/regress/sql/object_address.sql

+1-1
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ SELECT (pg_identify_object(addr1.classid, addr1.objid, addr1.objsubid)).*,
201201
---
202202
--- Cleanup resources
203203
---
204-
SET client_min_messages TO 'warning';
204+
\set VERBOSITY terse \\ -- suppress cascade details
205205

206206
DROP FOREIGN DATA WRAPPER addr_fdw CASCADE;
207207
DROP PUBLICATION addr_pub;

src/test/regress/sql/privileges.sql

+4-4
Original file line numberDiff line numberDiff line change
@@ -981,9 +981,9 @@ REVOKE ALL ON ALL FUNCTIONS IN SCHEMA testns FROM PUBLIC;
981981

982982
SELECT has_function_privilege('regress_user1', 'testns.testfunc(int)', 'EXECUTE'); -- false
983983

984-
SET client_min_messages TO 'warning';
984+
\set VERBOSITY terse \\ -- suppress cascade details
985985
DROP SCHEMA testns CASCADE;
986-
RESET client_min_messages;
986+
\set VERBOSITY default
987987

988988

989989
-- Change owner of the schema & and rename of new schema owner
@@ -1002,9 +1002,9 @@ ALTER ROLE regress_schemauser2 RENAME TO regress_schemauser_renamed;
10021002
SELECT nspname, rolname FROM pg_namespace, pg_roles WHERE pg_namespace.nspname = 'testns' AND pg_namespace.nspowner = pg_roles.oid;
10031003

10041004
set session role regress_schemauser_renamed;
1005-
SET client_min_messages TO 'warning';
1005+
\set VERBOSITY terse \\ -- suppress cascade details
10061006
DROP SCHEMA testns CASCADE;
1007-
RESET client_min_messages;
1007+
\set VERBOSITY default
10081008

10091009
-- clean up
10101010
\c -

src/test/regress/sql/rowsecurity.sql

+6-10
Original file line numberDiff line numberDiff line change
@@ -517,11 +517,10 @@ SELECT * FROM rec1; -- fail, mutual recursion via views
517517
-- Mutual recursion via .s.b views
518518
--
519519
SET SESSION AUTHORIZATION regress_rls_bob;
520-
-- Suppress NOTICE messages when doing a cascaded drop.
521-
SET client_min_messages TO 'warning';
522520

521+
\set VERBOSITY terse \\ -- suppress cascade details
523522
DROP VIEW rec1v, rec2v CASCADE;
524-
RESET client_min_messages;
523+
\set VERBOSITY default
525524

526525
CREATE VIEW rec1v WITH (security_barrier) AS SELECT * FROM rec1;
527526
CREATE VIEW rec2v WITH (security_barrier) AS SELECT * FROM rec2;
@@ -1026,11 +1025,10 @@ DROP TABLE test_qual_pushdown;
10261025
-- Plancache invalidate on user change.
10271026
--
10281027
RESET SESSION AUTHORIZATION;
1029-
-- Suppress NOTICE messages when doing a cascaded drop.
1030-
SET client_min_messages TO 'warning';
10311028

1029+
\set VERBOSITY terse \\ -- suppress cascade details
10321030
DROP TABLE t1 CASCADE;
1033-
RESET client_min_messages;
1031+
\set VERBOSITY default
10341032

10351033
CREATE TABLE t1 (a integer);
10361034

@@ -1762,11 +1760,9 @@ DROP USER regress_rls_dob_role2;
17621760
--
17631761
RESET SESSION AUTHORIZATION;
17641762

1765-
-- Suppress NOTICE messages when doing a cascaded drop.
1766-
SET client_min_messages TO 'warning';
1767-
1763+
\set VERBOSITY terse \\ -- suppress cascade details
17681764
DROP SCHEMA regress_rls_schema CASCADE;
1769-
RESET client_min_messages;
1765+
\set VERBOSITY default
17701766

17711767
DROP USER regress_rls_alice;
17721768
DROP USER regress_rls_bob;

src/test/regress/sql/rules.sql

+2-2
Original file line numberDiff line numberDiff line change
@@ -936,9 +936,9 @@ update id_ordered set name = 'update 4' where id = 4;
936936
update id_ordered set name = 'update 5' where id = 5;
937937
select * from id_ordered;
938938

939-
set client_min_messages to warning; -- suppress cascade notices
939+
\set VERBOSITY terse \\ -- suppress cascade details
940940
drop table id cascade;
941-
reset client_min_messages;
941+
\set VERBOSITY default
942942

943943
--
944944
-- check corner case where an entirely-dummy subplan is created by

src/test/regress/sql/stats_ext.sql

+2-2
Original file line numberDiff line numberDiff line change
@@ -89,10 +89,10 @@ EXCEPTION WHEN wrong_object_type THEN
8989
END;
9090
$$;
9191

92-
SET client_min_messages TO warning;
92+
\set VERBOSITY terse \\ -- suppress cascade details
9393
DROP SCHEMA tststats CASCADE;
9494
DROP FOREIGN DATA WRAPPER extstats_dummy_fdw CASCADE;
95-
RESET client_min_messages;
95+
\set VERBOSITY default
9696

9797
-- n-distinct tests
9898
CREATE TABLE ndistinct (

src/test/regress/sql/typed_table.sql

-7
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,3 @@
1-
-- Clean up in case a prior regression run failed
2-
SET client_min_messages TO 'warning';
3-
4-
DROP TYPE IF EXISTS person_type CASCADE;
5-
6-
RESET client_min_messages;
7-
81
CREATE TABLE ttable1 OF nothing;
92

103
CREATE TYPE person_type AS (id int, name text);

0 commit comments

Comments
 (0)