Skip to content

Commit b101683

Browse files
committed
Don't drop NOTICE messages in isolation tests.
For its entire existence, isolationtester.c has forced client_min_messages to WARNING, but that seems like a very poor choice of test design. It should be up to individual test scripts to manage whether they emit notices and to ensure that the results are stable. (There were no NOTICE messages in the original set of isolation tests, so this was certainly dead code when committed, but perhaps it was needed at some earlier point.) It's possible that the original motivation was due to platform-dependent variations in the timing of stdout vs. stderr output. That should be moot since commits 73bcb76/6eda3e9c2, but just in case, adjust isotesterNoticeProcessor to print to stdout not stderr. (stderr seems like the wrong thing anyway: it should be for error printouts not expected test output.) Back-patch of commit ebd4992 into v12. I'll separately push this into older branches, but this is as much change as v12 needs. Discussion: https://postgr.es/m/14616.1564251339@sss.pgh.pa.us Discussion: https://postgr.es/m/E1i7IqC-0000Uc-5H@gemulon.postgresql.org
1 parent 97fb88e commit b101683

File tree

4 files changed

+54
-23
lines changed

4 files changed

+54
-23
lines changed

src/test/isolation/expected/insert-conflict-specconflict.out

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,11 @@ pg_advisory_locksess lock
1313
step controller_show: SELECT * FROM upserttest;
1414
key data
1515

16+
s1: NOTICE: called for k1
17+
s1: NOTICE: blocking 3
1618
step s1_upsert: INSERT INTO upserttest(key, data) VALUES('k1', 'inserted s1') ON CONFLICT (blurt_and_lock(key)) DO UPDATE SET data = upserttest.data || ' with conflict update s1'; <waiting ...>
19+
s2: NOTICE: called for k1
20+
s2: NOTICE: blocking 3
1721
step s2_upsert: INSERT INTO upserttest(key, data) VALUES('k1', 'inserted s2') ON CONFLICT (blurt_and_lock(key)) DO UPDATE SET data = upserttest.data || ' with conflict update s2'; <waiting ...>
1822
step controller_show: SELECT * FROM upserttest;
1923
key data
@@ -30,10 +34,14 @@ step controller_unlock_1_3: SELECT pg_advisory_unlock(1, 3);
3034
pg_advisory_unlock
3135

3236
t
37+
s1: NOTICE: called for k1
38+
s1: NOTICE: blocking 2
3339
step controller_unlock_2_3: SELECT pg_advisory_unlock(2, 3);
3440
pg_advisory_unlock
3541

3642
t
43+
s2: NOTICE: called for k1
44+
s2: NOTICE: blocking 2
3745
step controller_show: SELECT * FROM upserttest;
3846
key data
3947

@@ -50,6 +58,10 @@ step controller_unlock_1_2: SELECT pg_advisory_unlock(1, 2);
5058
pg_advisory_unlock
5159

5260
t
61+
s1: NOTICE: called for k1
62+
s1: NOTICE: blocking 2
63+
s1: NOTICE: called for k1
64+
s1: NOTICE: blocking 2
5365
step s1_upsert: <... completed>
5466
step controller_show: SELECT * FROM upserttest;
5567
key data
@@ -69,7 +81,11 @@ pg_advisory_locksess lock
6981
step controller_show: SELECT * FROM upserttest;
7082
key data
7183

84+
s1: NOTICE: called for k1
85+
s1: NOTICE: blocking 3
7286
step s1_upsert: INSERT INTO upserttest(key, data) VALUES('k1', 'inserted s1') ON CONFLICT (blurt_and_lock(key)) DO UPDATE SET data = upserttest.data || ' with conflict update s1'; <waiting ...>
87+
s2: NOTICE: called for k1
88+
s2: NOTICE: blocking 3
7389
step s2_upsert: INSERT INTO upserttest(key, data) VALUES('k1', 'inserted s2') ON CONFLICT (blurt_and_lock(key)) DO UPDATE SET data = upserttest.data || ' with conflict update s2'; <waiting ...>
7490
step controller_show: SELECT * FROM upserttest;
7591
key data
@@ -86,10 +102,14 @@ step controller_unlock_1_3: SELECT pg_advisory_unlock(1, 3);
86102
pg_advisory_unlock
87103

88104
t
105+
s1: NOTICE: called for k1
106+
s1: NOTICE: blocking 2
89107
step controller_unlock_2_3: SELECT pg_advisory_unlock(2, 3);
90108
pg_advisory_unlock
91109

92110
t
111+
s2: NOTICE: called for k1
112+
s2: NOTICE: blocking 2
93113
step controller_show: SELECT * FROM upserttest;
94114
key data
95115

@@ -106,6 +126,10 @@ step controller_unlock_2_2: SELECT pg_advisory_unlock(2, 2);
106126
pg_advisory_unlock
107127

108128
t
129+
s2: NOTICE: called for k1
130+
s2: NOTICE: blocking 2
131+
s2: NOTICE: called for k1
132+
s2: NOTICE: blocking 2
109133
step s2_upsert: <... completed>
110134
step controller_show: SELECT * FROM upserttest;
111135
key data
@@ -127,7 +151,11 @@ key data
127151

128152
step s1_begin: BEGIN;
129153
step s2_begin: BEGIN;
154+
s1: NOTICE: called for k1
155+
s1: NOTICE: blocking 3
130156
step s1_upsert: INSERT INTO upserttest(key, data) VALUES('k1', 'inserted s1') ON CONFLICT (blurt_and_lock(key)) DO UPDATE SET data = upserttest.data || ' with conflict update s1'; <waiting ...>
157+
s2: NOTICE: called for k1
158+
s2: NOTICE: blocking 3
131159
step s2_upsert: INSERT INTO upserttest(key, data) VALUES('k1', 'inserted s2') ON CONFLICT (blurt_and_lock(key)) DO UPDATE SET data = upserttest.data || ' with conflict update s2'; <waiting ...>
132160
step controller_show: SELECT * FROM upserttest;
133161
key data
@@ -144,10 +172,14 @@ step controller_unlock_1_3: SELECT pg_advisory_unlock(1, 3);
144172
pg_advisory_unlock
145173

146174
t
175+
s1: NOTICE: called for k1
176+
s1: NOTICE: blocking 2
147177
step controller_unlock_2_3: SELECT pg_advisory_unlock(2, 3);
148178
pg_advisory_unlock
149179

150180
t
181+
s2: NOTICE: called for k1
182+
s2: NOTICE: blocking 2
151183
step controller_show: SELECT * FROM upserttest;
152184
key data
153185

@@ -163,10 +195,16 @@ step controller_unlock_2_2: SELECT pg_advisory_unlock(2, 2);
163195
pg_advisory_unlock
164196

165197
t
198+
s2: NOTICE: called for k1
199+
s2: NOTICE: blocking 2
200+
s2: NOTICE: called for k1
201+
s2: NOTICE: blocking 2
166202
step controller_show: SELECT * FROM upserttest;
167203
key data
168204

169205
step s1_commit: COMMIT;
206+
s2: NOTICE: called for k1
207+
s2: NOTICE: blocking 2
170208
step s2_upsert: <... completed>
171209
step controller_show: SELECT * FROM upserttest;
172210
key data

src/test/isolation/expected/plpgsql-toast.out

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ do $$
2222
delete from test1;
2323
commit;
2424
perform pg_advisory_lock(1);
25-
raise notice 'x = %', x;
25+
raise notice 'length(x) = %', length(x);
2626
end;
2727
$$;
2828
<waiting ...>
@@ -35,6 +35,7 @@ step unlock:
3535
pg_advisory_unlock
3636

3737
t
38+
s1: NOTICE: length(x) = 6000
3839
step assign1: <... completed>
3940

4041
starting permutation: lock assign2 vacuum unlock
@@ -59,7 +60,7 @@ do $$
5960
delete from test1;
6061
commit;
6162
perform pg_advisory_lock(1);
62-
raise notice 'x = %', x;
63+
raise notice 'length(x) = %', length(x);
6364
end;
6465
$$;
6566
<waiting ...>
@@ -72,6 +73,7 @@ step unlock:
7273
pg_advisory_unlock
7374

7475
t
76+
s1: NOTICE: length(x) = 6000
7577
step assign2: <... completed>
7678

7779
starting permutation: lock assign3 vacuum unlock
@@ -97,7 +99,7 @@ do $$
9799
delete from test1;
98100
commit;
99101
perform pg_advisory_lock(1);
100-
raise notice 'r = %', r;
102+
raise notice 'length(r) = %', length(r::text);
101103
end;
102104
$$;
103105
<waiting ...>
@@ -110,6 +112,7 @@ step unlock:
110112
pg_advisory_unlock
111113

112114
t
115+
s1: NOTICE: length(r) = 6004
113116
step assign3: <... completed>
114117

115118
starting permutation: lock assign4 vacuum unlock
@@ -134,7 +137,7 @@ do $$
134137
delete from test1;
135138
commit;
136139
perform pg_advisory_lock(1);
137-
raise notice 'r = %', r;
140+
raise notice 'length(r) = %', length(r::text);
138141
end;
139142
$$;
140143
<waiting ...>
@@ -147,6 +150,7 @@ step unlock:
147150
pg_advisory_unlock
148151

149152
t
153+
s1: NOTICE: length(r) = 6004
150154
step assign4: <... completed>
151155

152156
starting permutation: lock assign5 vacuum unlock
@@ -173,7 +177,7 @@ do $$
173177
delete from test1;
174178
commit;
175179
perform pg_advisory_lock(1);
176-
raise notice 'r = %', r;
180+
raise notice 'length(r) = %', length(r::text);
177181
end;
178182
$$;
179183
<waiting ...>
@@ -186,4 +190,5 @@ step unlock:
186190
pg_advisory_unlock
187191

188192
t
193+
s1: NOTICE: length(r) = 6002
189194
step assign5: <... completed>

src/test/isolation/isolationtester.c

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -187,18 +187,6 @@ main(int argc, char **argv)
187187
blackholeNoticeProcessor,
188188
NULL);
189189

190-
/*
191-
* Suppress NOTIFY messages, which otherwise pop into results at odd
192-
* places.
193-
*/
194-
res = PQexec(conns[i], "SET client_min_messages = warning;");
195-
if (PQresultStatus(res) != PGRES_COMMAND_OK)
196-
{
197-
fprintf(stderr, "message level setup failed: %s", PQerrorMessage(conns[i]));
198-
exit(1);
199-
}
200-
PQclear(res);
201-
202190
/* Get the backend pid for lock wait checking. */
203191
res = PQexec(conns[i], "SELECT pg_catalog.pg_backend_pid()");
204192
if (PQresultStatus(res) == PGRES_TUPLES_OK)
@@ -921,7 +909,7 @@ printResultSet(PGresult *res)
921909
static void
922910
isotesterNoticeProcessor(void *arg, const char *message)
923911
{
924-
fprintf(stderr, "%s: %s", (char *) arg, message);
912+
printf("%s: %s", (char *) arg, message);
925913
}
926914

927915
/* notice processor, hides the message */

src/test/isolation/specs/plpgsql-toast.spec

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ do $$
4040
delete from test1;
4141
commit;
4242
perform pg_advisory_lock(1);
43-
raise notice 'x = %', x;
43+
raise notice 'length(x) = %', length(x);
4444
end;
4545
$$;
4646
}
@@ -56,7 +56,7 @@ do $$
5656
delete from test1;
5757
commit;
5858
perform pg_advisory_lock(1);
59-
raise notice 'x = %', x;
59+
raise notice 'length(x) = %', length(x);
6060
end;
6161
$$;
6262
}
@@ -73,7 +73,7 @@ do $$
7373
delete from test1;
7474
commit;
7575
perform pg_advisory_lock(1);
76-
raise notice 'r = %', r;
76+
raise notice 'length(r) = %', length(r::text);
7777
end;
7878
$$;
7979
}
@@ -89,7 +89,7 @@ do $$
8989
delete from test1;
9090
commit;
9191
perform pg_advisory_lock(1);
92-
raise notice 'r = %', r;
92+
raise notice 'length(r) = %', length(r::text);
9393
end;
9494
$$;
9595
}
@@ -107,7 +107,7 @@ do $$
107107
delete from test1;
108108
commit;
109109
perform pg_advisory_lock(1);
110-
raise notice 'r = %', r;
110+
raise notice 'length(r) = %', length(r::text);
111111
end;
112112
$$;
113113
}

0 commit comments

Comments
 (0)