Re: [PATCH] Invalidate cached plans when casts change

From: Nikolay Samokhvalov <nik(at)postgres(dot)ai>
To: pgsql-hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Cc: Amit Langote <amitlangote09(at)gmail(dot)com>
Subject: Re: [PATCH] Invalidate cached plans when casts change
Date: 2026-09-15 09:00:34
Message-ID: CAM527d-8tXT=b0N4y6tdsri7ZfJVq7SN=Hp_SY5hhh04mQ9QZQ@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

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

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Nikolay Samokhvalov 2026-09-15 09:00:46 Re: PG19 FK fast path: OOB write and missed FK checks during batched
Previous Message Nikolay Samokhvalov 2026-09-15 09:00:18 Re: PG19: two RI fast-path issues found while testing the batching revert