Skip to content

Commit fad854d

Browse files
jnasbyupgradeclaude
andcommitted
Move client_min_messages suppression from the extension script to the test
An extension's own install script shouldn't unilaterally change a session setting on its caller's behalf, even scoped via SET LOCAL -- that's the caller's call to make, not the extension's. Moved the NOTICE suppression out of sql/object_reference.sql entirely; it turns out only zzz_build's raw \i load (not the normal CREATE EXTENSION path every other test uses) ever surfaced the %TYPE resolution NOTICEs in the first place, so the fix belongs in that one test file, wrapped in the transaction setup.sql already opens. test/expected/zzz_build.out regenerated via make results (line-number shift only, from the extension script shrinking). Co-Authored-By: Claude <noreply@anthropic.com>
1 parent f4bb263 commit fad854d

3 files changed

Lines changed: 16 additions & 17 deletions

File tree

sql/object_reference.sql

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,6 @@
22
\echo You really, REALLY do NOT want to try and load this via psql!!!
33
\echo It will FAIL during pg_dump! \quit
44

5-
/*
6-
* SET LOCAL, not SET: this script runs inside CREATE EXTENSION's implicit
7-
* transaction, so LOCAL reverts automatically once it commits -- a plain SET
8-
* would leak into the installing session for the rest of its lifetime.
9-
* Suppresses NOTICEs like the %TYPE resolution messages this script's many
10-
* column-type references (e.g. _object_oid.objid%TYPE) would otherwise spam
11-
* CREATE EXTENSION's output with.
12-
*/
13-
SET LOCAL client_min_messages = WARNING;
14-
155
/* EXCLUDED CODE: schema-restriction check below not currently enforced
166
DO $$
177
DECLARE

test/expected/zzz_build.out

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,16 @@
22
This extension must be loaded via CREATE EXTENSION object_reference;
33
You really, REALLY do NOT want to try and load this via psql!!!
44

5-
psql:test/temp_load.not_sql:186: WARNING: I promise you will be sorry if you try to use this as anything other than an extension!
5+
psql:test/temp_load.not_sql:176: WARNING: I promise you will be sorry if you try to use this as anything other than an extension!
66

7-
psql:test/temp_load.not_sql:187: WARNING: I promise you will be sorry if you try to use this as anything other than an extension!
7+
psql:test/temp_load.not_sql:177: WARNING: I promise you will be sorry if you try to use this as anything other than an extension!
88

99

1010

1111

1212

1313

14-
psql:test/temp_load.not_sql:435: WARNING: I promise you will be sorry if you try to use this as anything other than an extension!
14+
psql:test/temp_load.not_sql:425: WARNING: I promise you will be sorry if you try to use this as anything other than an extension!
1515

1616

1717

@@ -21,9 +21,9 @@ psql:test/temp_load.not_sql:435: WARNING: I promise you will be sorry if you tr
2121

2222

2323

24-
psql:test/temp_load.not_sql:547: WARNING: I promise you will be sorry if you try to use this as anything other than an extension!
24+
psql:test/temp_load.not_sql:537: WARNING: I promise you will be sorry if you try to use this as anything other than an extension!
2525

26-
psql:test/temp_load.not_sql:554: WARNING: I promise you will be sorry if you try to use this as anything other than an extension!
26+
psql:test/temp_load.not_sql:544: WARNING: I promise you will be sorry if you try to use this as anything other than an extension!
2727

2828

2929

test/sql/zzz_build.sql

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,18 @@ CREATE EXTENSION IF NOT EXISTS cat_tools;
1010

1111
CREATE SCHEMA object_reference;
1212

13-
-- doesn't work :/ SET client_min_messages = FATAL; -- Need to surpress WARNING or turn down verbosity. Suppressing WARNING seems the better idea...
14-
-- Need to do this instead so that results are stable across versions (no line #s from ereport messages)
13+
-- Need this so that results are stable across versions (no line #s from ereport messages)
1514
\set VERBOSITY default
15+
16+
/*
17+
* setup.sql above opened an explicit transaction (see the "TRANSACTION
18+
* INTENTIONALLY LEFT OPEN!" notice below), so SET LOCAL here reverts when
19+
* that transaction ends rather than leaking into the rest of the session.
20+
* Squelches NOTICEs like the %TYPE resolution messages this raw \i load
21+
* would otherwise spam the test output with -- scoped to this test only,
22+
* not the shipped extension script itself.
23+
*/
24+
SET LOCAL client_min_messages = WARNING;
1625
\i test/temp_load.not_sql
1726

1827
\echo Loaded OK!

0 commit comments

Comments
 (0)