diff --git a/src/test/regress/sql/plancache.sql b/src/test/regress/sql/plancache.sql index cb2a551487..41be0d6bf4 100644 --- a/src/test/regress/sql/plancache.sql +++ b/src/test/regress/sql/plancache.sql @@ -140,6 +140,21 @@ create temp sequence seq; execute p2; +-- Check that invalidation deals with casting const value to temporary +-- composite type reinitialized on each new transaction + +create function cache_query_with_composite_const() returns void as $$ +begin + create temp table tbl(id int) on commit drop; + + -- Plan of the next query has to be rebuilt on each new call of function + -- due to casting first argument 'null' to recreated temprary table 'tbl' + perform json_populate_record(null::tbl, '{"id": 0}'::json); +end$$ language plpgsql; + +select cache_query_with_composite_const(); +select cache_query_with_composite_const(); + -- Check DDL via SPI, immediately followed by SPI plan re-use -- (bug in original coding)