Skip to content

Commit 39d4a15

Browse files
committed
Fix plpgsql tests for debug_invalidate_system_caches_always.
Commit c9d5298 resulted in having a couple more places where the error context stack for a failure varies depending on debug_invalidate_system_caches_always (nee CLOBBER_CACHE_ALWAYS). This is not very surprising, since we have to re-parse cached plans if the plan cache is clobbered. Stabilize the expected test output by hiding the context stack in these places, as we've done elsewhere in this test script. (Another idea worth considering, now that we have debug_invalidate_system_caches_always, is to force it to zero for these test cases. That seems like it'd risk reducing the coverage of cache-clobber testing, which might or might not be worth being able to verify that we get the expected error output in normal cases. For the moment I just stuck with the existing technique.) In passing, update comments that referred to CLOBBER_CACHE_ALWAYS. Per buildfarm member hyrax.
1 parent afcc877 commit 39d4a15

File tree

5 files changed

+36
-22
lines changed

5 files changed

+36
-22
lines changed

src/pl/plpgsql/src/expected/plpgsql_cache.out

+4-4
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@
33
--
44
-- These tests logically belong in plpgsql_record.sql, and perhaps someday
55
-- can be merged back into it. For now, however, their results are different
6-
-- between regular and CLOBBER_CACHE_ALWAYS builds, so we must have two
6+
-- depending on debug_invalidate_system_caches_always, so we must have two
77
-- expected-output files to cover both cases. To minimize the maintenance
88
-- effort resulting from that, this file should contain only tests that
9-
-- do have different results under CLOBBER_CACHE_ALWAYS.
9+
-- do have different results under debug_invalidate_system_caches_always.
1010
--
1111
-- check behavior with changes of a named rowtype
1212
create table c_mutable(f1 int, f2 text);
@@ -21,7 +21,7 @@ select c_sillyaddone(42);
2121
alter table c_mutable drop column f1;
2222
alter table c_mutable add column f1 float8;
2323
-- currently, this fails due to cached plan for "r.f1 + 1" expression
24-
-- (but a CLOBBER_CACHE_ALWAYS build will succeed)
24+
-- (but if debug_invalidate_system_caches_always is on, it will succeed)
2525
select c_sillyaddone(42);
2626
ERROR: type of parameter 4 (double precision) does not match that when preparing the plan (integer)
2727
CONTEXT: PL/pgSQL function c_sillyaddone(integer) line 1 at RETURN
@@ -52,7 +52,7 @@ select show_result_type('select 1 as a');
5252
(1 row)
5353

5454
-- currently this fails due to cached plan for pg_typeof expression
55-
-- (but a CLOBBER_CACHE_ALWAYS build will succeed)
55+
-- (but if debug_invalidate_system_caches_always is on, it will succeed)
5656
select show_result_type('select 2.0 as a');
5757
ERROR: type of parameter 5 (numeric) does not match that when preparing the plan (integer)
5858
CONTEXT: SQL statement "select pg_typeof(r.a)"

src/pl/plpgsql/src/expected/plpgsql_cache_1.out

+4-4
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@
33
--
44
-- These tests logically belong in plpgsql_record.sql, and perhaps someday
55
-- can be merged back into it. For now, however, their results are different
6-
-- between regular and CLOBBER_CACHE_ALWAYS builds, so we must have two
6+
-- depending on debug_invalidate_system_caches_always, so we must have two
77
-- expected-output files to cover both cases. To minimize the maintenance
88
-- effort resulting from that, this file should contain only tests that
9-
-- do have different results under CLOBBER_CACHE_ALWAYS.
9+
-- do have different results under debug_invalidate_system_caches_always.
1010
--
1111
-- check behavior with changes of a named rowtype
1212
create table c_mutable(f1 int, f2 text);
@@ -21,7 +21,7 @@ select c_sillyaddone(42);
2121
alter table c_mutable drop column f1;
2222
alter table c_mutable add column f1 float8;
2323
-- currently, this fails due to cached plan for "r.f1 + 1" expression
24-
-- (but a CLOBBER_CACHE_ALWAYS build will succeed)
24+
-- (but if debug_invalidate_system_caches_always is on, it will succeed)
2525
select c_sillyaddone(42);
2626
c_sillyaddone
2727
---------------
@@ -55,7 +55,7 @@ select show_result_type('select 1 as a');
5555
(1 row)
5656

5757
-- currently this fails due to cached plan for pg_typeof expression
58-
-- (but a CLOBBER_CACHE_ALWAYS build will succeed)
58+
-- (but if debug_invalidate_system_caches_always is on, it will succeed)
5959
select show_result_type('select 2.0 as a');
6060
show_result_type
6161
------------------------

src/pl/plpgsql/src/expected/plpgsql_record.out

+12-6
Original file line numberDiff line numberDiff line change
@@ -426,8 +426,8 @@ select getf1(row(1,2));
426426
1
427427
(1 row)
428428

429-
-- a CLOBBER_CACHE_ALWAYS build will report this error with a different
430-
-- context stack than other builds, so suppress context output
429+
-- the context stack is different when debug_invalidate_system_caches_always
430+
-- is set, so suppress context output
431431
\set SHOW_CONTEXT never
432432
select getf1(row(1,2)::two_int8s);
433433
ERROR: record "x" has no field "f1"
@@ -507,9 +507,12 @@ select sillyaddone(42);
507507
-- test for change of type of column f1 should be here someday;
508508
-- for now see plpgsql_cache test
509509
alter table mutable drop column f1;
510+
-- the context stack is different when debug_invalidate_system_caches_always
511+
-- is set, so suppress context output
512+
\set SHOW_CONTEXT never
510513
select sillyaddone(42); -- fail
511514
ERROR: record "r" has no field "f1"
512-
CONTEXT: PL/pgSQL function sillyaddone(integer) line 1 at assignment
515+
\set SHOW_CONTEXT errors
513516
create function getf3(x mutable) returns int language plpgsql as
514517
$$ begin return x.f3; end $$;
515518
select getf3(null::mutable); -- doesn't work yet
@@ -524,8 +527,8 @@ select getf3(null::mutable); -- now it works
524527
(1 row)
525528

526529
alter table mutable drop column f3;
527-
-- a CLOBBER_CACHE_ALWAYS build will report this error with a different
528-
-- context stack than other builds, so suppress context output
530+
-- the context stack is different when debug_invalidate_system_caches_always
531+
-- is set, so suppress context output
529532
\set SHOW_CONTEXT never
530533
select getf3(null::mutable); -- fails again
531534
ERROR: record "x" has no field "f3"
@@ -549,9 +552,12 @@ select sillyaddtwo(42);
549552
(1 row)
550553

551554
drop table mutable2;
555+
-- the context stack is different when debug_invalidate_system_caches_always
556+
-- is set, so suppress context output
557+
\set SHOW_CONTEXT never
552558
select sillyaddtwo(42); -- fail
553559
ERROR: type "mutable2" does not exist
554-
CONTEXT: PL/pgSQL function sillyaddtwo(integer) line 1 at assignment
560+
\set SHOW_CONTEXT errors
555561
create table mutable2(f0 text, f1 int, f2 text);
556562
select sillyaddtwo(42);
557563
sillyaddtwo

src/pl/plpgsql/src/sql/plpgsql_cache.sql

+4-4
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@
33
--
44
-- These tests logically belong in plpgsql_record.sql, and perhaps someday
55
-- can be merged back into it. For now, however, their results are different
6-
-- between regular and CLOBBER_CACHE_ALWAYS builds, so we must have two
6+
-- depending on debug_invalidate_system_caches_always, so we must have two
77
-- expected-output files to cover both cases. To minimize the maintenance
88
-- effort resulting from that, this file should contain only tests that
9-
-- do have different results under CLOBBER_CACHE_ALWAYS.
9+
-- do have different results under debug_invalidate_system_caches_always.
1010
--
1111

1212
-- check behavior with changes of a named rowtype
@@ -20,7 +20,7 @@ alter table c_mutable drop column f1;
2020
alter table c_mutable add column f1 float8;
2121

2222
-- currently, this fails due to cached plan for "r.f1 + 1" expression
23-
-- (but a CLOBBER_CACHE_ALWAYS build will succeed)
23+
-- (but if debug_invalidate_system_caches_always is on, it will succeed)
2424
select c_sillyaddone(42);
2525

2626
-- but it's OK if we force plan rebuilding
@@ -42,7 +42,7 @@ $$;
4242

4343
select show_result_type('select 1 as a');
4444
-- currently this fails due to cached plan for pg_typeof expression
45-
-- (but a CLOBBER_CACHE_ALWAYS build will succeed)
45+
-- (but if debug_invalidate_system_caches_always is on, it will succeed)
4646
select show_result_type('select 2.0 as a');
4747

4848
-- but it's OK if we force plan rebuilding

src/pl/plpgsql/src/sql/plpgsql_record.sql

+12-4
Original file line numberDiff line numberDiff line change
@@ -257,8 +257,8 @@ create function getf1(x record) returns int language plpgsql as
257257
$$ begin return x.f1; end $$;
258258
select getf1(1);
259259
select getf1(row(1,2));
260-
-- a CLOBBER_CACHE_ALWAYS build will report this error with a different
261-
-- context stack than other builds, so suppress context output
260+
-- the context stack is different when debug_invalidate_system_caches_always
261+
-- is set, so suppress context output
262262
\set SHOW_CONTEXT never
263263
select getf1(row(1,2)::two_int8s);
264264
\set SHOW_CONTEXT errors
@@ -316,16 +316,20 @@ select sillyaddone(42);
316316
-- for now see plpgsql_cache test
317317

318318
alter table mutable drop column f1;
319+
-- the context stack is different when debug_invalidate_system_caches_always
320+
-- is set, so suppress context output
321+
\set SHOW_CONTEXT never
319322
select sillyaddone(42); -- fail
323+
\set SHOW_CONTEXT errors
320324

321325
create function getf3(x mutable) returns int language plpgsql as
322326
$$ begin return x.f3; end $$;
323327
select getf3(null::mutable); -- doesn't work yet
324328
alter table mutable add column f3 int;
325329
select getf3(null::mutable); -- now it works
326330
alter table mutable drop column f3;
327-
-- a CLOBBER_CACHE_ALWAYS build will report this error with a different
328-
-- context stack than other builds, so suppress context output
331+
-- the context stack is different when debug_invalidate_system_caches_always
332+
-- is set, so suppress context output
329333
\set SHOW_CONTEXT never
330334
select getf3(null::mutable); -- fails again
331335
\set SHOW_CONTEXT errors
@@ -342,7 +346,11 @@ select sillyaddtwo(42); -- fail
342346
create table mutable2(f1 int, f2 text);
343347
select sillyaddtwo(42);
344348
drop table mutable2;
349+
-- the context stack is different when debug_invalidate_system_caches_always
350+
-- is set, so suppress context output
351+
\set SHOW_CONTEXT never
345352
select sillyaddtwo(42); -- fail
353+
\set SHOW_CONTEXT errors
346354
create table mutable2(f0 text, f1 int, f2 text);
347355
select sillyaddtwo(42);
348356
select sillyaddtwo(43);

0 commit comments

Comments
 (0)