For completeness, here's the reproducer I should have included. Run as a superuser in a fresh database, with psql -X and ON_ERROR_STOP unset:
\set VERBOSITY sqlstate create schema fk_opfamily; set search_path = fk_opfamily, pg_catalog; create operator family fam using btree; create operator class int_ops for type integer using btree family fam as operator 1 <(integer,integer), operator 2 <=(integer,integer), operator 3 =(integer,integer), operator 4 >=(integer,integer), operator 5 >(integer,integer), function 1 btint4cmp(integer,integer); alter operator family fam using btree add operator 1 <(integer,bigint), operator 2 <=(integer,bigint), operator 3 =(integer,bigint), operator 4 >=(integer,bigint), operator 5 >(integer,bigint), operator 1 <(bigint,integer), operator 2 <=(bigint,integer), operator 3 =(bigint,integer), operator 4 >=(bigint,integer), operator 5 >(bigint,integer), operator 1 <(bigint,bigint), operator 2 <=(bigint,bigint), operator 3 =(bigint,bigint), operator 4 >=(bigint,bigint), operator 5 >(bigint,bigint), function 1 (integer,bigint) btint48cmp(integer,bigint), function 1 (bigint,integer) btint84cmp(bigint,integer), function 1 (bigint,bigint) btint8cmp(bigint,bigint); create operator =#= (leftarg=integer, rightarg=bigint, function=int48eq); create table p(k integer); create unique index p_idx on p(k int_ops); create table warm(k bigint references p(k)); create table cold(k bigint references p(k)); insert into p values (1), (2); insert into warm values (1); select amvalidate(oid) from pg_opclass where opcnamespace = 'fk_opfamily'::regnamespace; select exists (select from pg_backend_memory_contexts where name = 'RI fast-path finfo scratch') as metadata_cached; begin; alter operator family fam using btree drop operator 3(integer,bigint); alter operator family fam using btree add operator 3 =#=(integer,bigint); commit; select amvalidate(oid) from pg_opclass where opcnamespace = 'fk_opfamily'::regnamespace; select exists (select from pg_backend_memory_contexts where name = 'RI fast-path finfo scratch') as metadata_cached; insert into warm values (2); insert into warm values (99); insert into cold values (2); insert into cold values (99); select * from warm order by k; select * from cold order by k; reset search_path; drop schema fk_opfamily cascade; On unpatched master a625fc57 and PG19 f4b511ae, amvalidate returns t before and after the DDL, but metadata_cached stays t and both cold inserts fail with XX000. The warm table contains 1 and 2; cold is empty. With the corresponding patches, metadata_cached goes from t to f. The valid inserts succeed and both inserts of 99 fail with 23503; warm contains 1 and 2, and cold contains 2. Thanks, Nik
