Commit 39d4a153 authored by Tom Lane's avatar Tom Lane

Fix plpgsql tests for debug_invalidate_system_caches_always.

Commit c9d52984 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.
parent afcc8772
......@@ -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)"
......
......@@ -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
------------------------
......
......@@ -426,8 +426,8 @@ select getf1(row(1,2));
1
(1 row)
-- a CLOBBER_CACHE_ALWAYS build will report this error with a different
-- 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
-- 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
......
......@@ -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
......
......@@ -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
-- 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
-- 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);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment