Fix plpgsql tests for debug_invalidate_system_caches_always.
authorTom Lane <[email protected]>
Fri, 8 Jan 2021 23:12:07 +0000 (18:12 -0500)
committerTom Lane <[email protected]>
Fri, 8 Jan 2021 23:12:07 +0000 (18:12 -0500)
Commit c9d529848 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.

src/pl/plpgsql/src/expected/plpgsql_cache.out
src/pl/plpgsql/src/expected/plpgsql_cache_1.out
src/pl/plpgsql/src/expected/plpgsql_record.out
src/pl/plpgsql/src/sql/plpgsql_cache.sql
src/pl/plpgsql/src/sql/plpgsql_record.sql

index c2cf0136050f0eb82034c5722ae2e1ce8e3a8db0..cc0c57b8794f58a0485d61dd408851e05ad8c255 100644 (file)
@@ -3,10 +3,10 @@
 --
 -- These tests logically belong in plpgsql_record.sql, and perhaps someday
 -- can be merged back into it.  For now, however, their results are different
--- between regular and CLOBBER_CACHE_ALWAYS builds, so we must have two
+-- depending on debug_invalidate_system_caches_always, so we must have two
 -- expected-output files to cover both cases.  To minimize the maintenance
 -- effort resulting from that, this file should contain only tests that
--- do have different results under CLOBBER_CACHE_ALWAYS.
+-- do have different results under debug_invalidate_system_caches_always.
 --
 -- check behavior with changes of a named rowtype
 create table c_mutable(f1 int, f2 text);
@@ -21,7 +21,7 @@ select c_sillyaddone(42);
 alter table c_mutable drop column f1;
 alter table c_mutable add column f1 float8;
 -- currently, this fails due to cached plan for "r.f1 + 1" expression
--- (but a CLOBBER_CACHE_ALWAYS build will succeed)
+-- (but if debug_invalidate_system_caches_always is on, it will succeed)
 select c_sillyaddone(42);
 ERROR:  type of parameter 4 (double precision) does not match that when preparing the plan (integer)
 CONTEXT:  PL/pgSQL function c_sillyaddone(integer) line 1 at RETURN
@@ -52,7 +52,7 @@ select show_result_type('select 1 as a');
 (1 row)
 
 -- currently this fails due to cached plan for pg_typeof expression
--- (but a CLOBBER_CACHE_ALWAYS build will succeed)
+-- (but if debug_invalidate_system_caches_always is on, it will succeed)
 select show_result_type('select 2.0 as a');
 ERROR:  type of parameter 5 (numeric) does not match that when preparing the plan (integer)
 CONTEXT:  SQL statement "select pg_typeof(r.a)"
index 0ac2c64a15c75efe29d9bf8458c8564a0a81932e..2a42875747ea819bd1c6c56a5136f91a862d8947 100644 (file)
@@ -3,10 +3,10 @@
 --
 -- These tests logically belong in plpgsql_record.sql, and perhaps someday
 -- can be merged back into it.  For now, however, their results are different
--- between regular and CLOBBER_CACHE_ALWAYS builds, so we must have two
+-- depending on debug_invalidate_system_caches_always, so we must have two
 -- expected-output files to cover both cases.  To minimize the maintenance
 -- effort resulting from that, this file should contain only tests that
--- do have different results under CLOBBER_CACHE_ALWAYS.
+-- do have different results under debug_invalidate_system_caches_always.
 --
 -- check behavior with changes of a named rowtype
 create table c_mutable(f1 int, f2 text);
@@ -21,7 +21,7 @@ select c_sillyaddone(42);
 alter table c_mutable drop column f1;
 alter table c_mutable add column f1 float8;
 -- currently, this fails due to cached plan for "r.f1 + 1" expression
--- (but a CLOBBER_CACHE_ALWAYS build will succeed)
+-- (but if debug_invalidate_system_caches_always is on, it will succeed)
 select c_sillyaddone(42);
  c_sillyaddone 
 ---------------
@@ -55,7 +55,7 @@ select show_result_type('select 1 as a');
 (1 row)
 
 -- currently this fails due to cached plan for pg_typeof expression
--- (but a CLOBBER_CACHE_ALWAYS build will succeed)
+-- (but if debug_invalidate_system_caches_always is on, it will succeed)
 select show_result_type('select 2.0 as a');
     show_result_type    
 ------------------------
index 6e835c0751b224e28abb359216a6418eedcc2e02..86d0665924172846c555b0fbc73dfe0c6e9cf551 100644 (file)
@@ -426,8 +426,8 @@ select getf1(row(1,2));
      1
 (1 row)
 
--- a CLOBBER_CACHE_ALWAYS build will report this error with a different
--- context stack than other builds, so suppress context output
+-- the context stack is different when debug_invalidate_system_caches_always
+-- is set, so suppress context output
 \set SHOW_CONTEXT never
 select getf1(row(1,2)::two_int8s);
 ERROR:  record "x" has no field "f1"
@@ -507,9 +507,12 @@ select sillyaddone(42);
 -- test for change of type of column f1 should be here someday;
 -- for now see plpgsql_cache test
 alter table mutable drop column f1;
+-- the context stack is different when debug_invalidate_system_caches_always
+-- is set, so suppress context output
+\set SHOW_CONTEXT never
 select sillyaddone(42);  -- fail
 ERROR:  record "r" has no field "f1"
-CONTEXT:  PL/pgSQL function sillyaddone(integer) line 1 at assignment
+\set SHOW_CONTEXT errors
 create function getf3(x mutable) returns int language plpgsql as
 $$ begin return x.f3; end $$;
 select getf3(null::mutable);  -- doesn't work yet
@@ -524,8 +527,8 @@ select getf3(null::mutable);  -- now it works
 (1 row)
 
 alter table mutable drop column f3;
--- a CLOBBER_CACHE_ALWAYS build will report this error with a different
--- context stack than other builds, so suppress context output
+-- the context stack is different when debug_invalidate_system_caches_always
+-- is set, so suppress context output
 \set SHOW_CONTEXT never
 select getf3(null::mutable);  -- fails again
 ERROR:  record "x" has no field "f3"
@@ -549,9 +552,12 @@ select sillyaddtwo(42);
 (1 row)
 
 drop table mutable2;
+-- the context stack is different when debug_invalidate_system_caches_always
+-- is set, so suppress context output
+\set SHOW_CONTEXT never
 select sillyaddtwo(42);  -- fail
 ERROR:  type "mutable2" does not exist
-CONTEXT:  PL/pgSQL function sillyaddtwo(integer) line 1 at assignment
+\set SHOW_CONTEXT errors
 create table mutable2(f0 text, f1 int, f2 text);
 select sillyaddtwo(42);
  sillyaddtwo 
index f3b64d9209fd0a00f6354d998313149c67247b88..061f674c9a6eaa98bf3595f3d91643b69805cf7c 100644 (file)
@@ -3,10 +3,10 @@
 --
 -- These tests logically belong in plpgsql_record.sql, and perhaps someday
 -- can be merged back into it.  For now, however, their results are different
--- between regular and CLOBBER_CACHE_ALWAYS builds, so we must have two
+-- depending on debug_invalidate_system_caches_always, so we must have two
 -- expected-output files to cover both cases.  To minimize the maintenance
 -- effort resulting from that, this file should contain only tests that
--- do have different results under CLOBBER_CACHE_ALWAYS.
+-- do have different results under debug_invalidate_system_caches_always.
 --
 
 -- check behavior with changes of a named rowtype
@@ -20,7 +20,7 @@ alter table c_mutable drop column f1;
 alter table c_mutable add column f1 float8;
 
 -- currently, this fails due to cached plan for "r.f1 + 1" expression
--- (but a CLOBBER_CACHE_ALWAYS build will succeed)
+-- (but if debug_invalidate_system_caches_always is on, it will succeed)
 select c_sillyaddone(42);
 
 -- but it's OK if we force plan rebuilding
@@ -42,7 +42,7 @@ $$;
 
 select show_result_type('select 1 as a');
 -- currently this fails due to cached plan for pg_typeof expression
--- (but a CLOBBER_CACHE_ALWAYS build will succeed)
+-- (but if debug_invalidate_system_caches_always is on, it will succeed)
 select show_result_type('select 2.0 as a');
 
 -- but it's OK if we force plan rebuilding
index be10f00b1e6e49ecac6c7203750100988f7c36e1..722048c7308b0ebadc7b9e5829e0a2f77ac56ca3 100644 (file)
@@ -257,8 +257,8 @@ create function getf1(x record) returns int language plpgsql as
 $$ begin return x.f1; end $$;
 select getf1(1);
 select getf1(row(1,2));
--- a CLOBBER_CACHE_ALWAYS build will report this error with a different
--- context stack than other builds, so suppress context output
+-- the context stack is different when debug_invalidate_system_caches_always
+-- is set, so suppress context output
 \set SHOW_CONTEXT never
 select getf1(row(1,2)::two_int8s);
 \set SHOW_CONTEXT errors
@@ -316,7 +316,11 @@ select sillyaddone(42);
 -- for now see plpgsql_cache test
 
 alter table mutable drop column f1;
+-- the context stack is different when debug_invalidate_system_caches_always
+-- is set, so suppress context output
+\set SHOW_CONTEXT never
 select sillyaddone(42);  -- fail
+\set SHOW_CONTEXT errors
 
 create function getf3(x mutable) returns int language plpgsql as
 $$ begin return x.f3; end $$;
@@ -324,8 +328,8 @@ select getf3(null::mutable);  -- doesn't work yet
 alter table mutable add column f3 int;
 select getf3(null::mutable);  -- now it works
 alter table mutable drop column f3;
--- a CLOBBER_CACHE_ALWAYS build will report this error with a different
--- context stack than other builds, so suppress context output
+-- the context stack is different when debug_invalidate_system_caches_always
+-- is set, so suppress context output
 \set SHOW_CONTEXT never
 select getf3(null::mutable);  -- fails again
 \set SHOW_CONTEXT errors
@@ -342,7 +346,11 @@ select sillyaddtwo(42);  -- fail
 create table mutable2(f1 int, f2 text);
 select sillyaddtwo(42);
 drop table mutable2;
+-- the context stack is different when debug_invalidate_system_caches_always
+-- is set, so suppress context output
+\set SHOW_CONTEXT never
 select sillyaddtwo(42);  -- fail
+\set SHOW_CONTEXT errors
 create table mutable2(f0 text, f1 int, f2 text);
 select sillyaddtwo(42);
 select sillyaddtwo(43);