For completeness, here's the exact reproducer I should have included: drop schema if exists cast_repro cascade; create schema cast_repro; set search_path = cast_repro, pg_catalog;
create type key_t as (v int); create function cast_old(key_t) returns int language sql immutable strict as 'select ($1).v'; create function cast_new(key_t) returns int language sql immutable strict as 'select ($1).v + 100'; create cast (key_t as int) with function cast_old(key_t) as implicit; prepare q(key_t) as select $1::int; execute q(row(1)::key_t); drop cast (key_t as int); create cast (key_t as int) with function cast_new(key_t) as implicit; select row(1)::key_t::int as direct_after; execute q(row(1)::key_t); On unpatched master this returns 1, 101, 1. The last value should be 101. With the patch it returns 1, 101, 101. Thanks, Nik
