I have a problem that in Postgres 14 a NULL check on my UDT does no longer work after I modify the type.
My composite UDT that has two attributes.
create type A as (
foo text
);
create type B as (
bar text
);
create type AorB as (
a a,
b b
);
create table elements (
attr AorB
)
I will only ever set one of the two attributes and want to access them based on which one it is.
insert into elements (attr)
values
(
(
ROW('aa')::A,
NULL
)::AorB
),
(
(
NULL,
ROW('bb')::B
)::AorB
);
select * from elements where (attr).a IS NOT NULL;
The query gives me the correct answer
| attr |
|---|
| ("(aa)",) |
However, if I modify a type like this
alter type A add attribute bla text;
and repeat the same query I get an empty result. I do, however, see all the data if I drop the where clause. Here is a playground with my example: https://www.db-fiddle.com/f/4jyoMCicNSZpjMt4jFYoz5/10961
What could be the issue and how can I resolve it?