Hi Jian,
v2 fixes the ROW() cases on 19 and master, and all tests pass.
Named composite types still have the problem. ALTER TYPE can add a
timestamptz after the index is built.
CREATE TYPE c AS (x int);
CREATE TABLE t (v c);
CREATE INDEX ON t ((json_array(v returning jsonb)));
ALTER TYPE c ADD ATTRIBUTE ts timestamptz;
SET TimeZone = 'UTC';
INSERT INTO t VALUES (row(1, '2026-01-01 00:00+00'));
SET TimeZone = 'Asia/Shanghai';
SELECT count(*) FROM t
WHERE json_array(v returning jsonb) =
json_array(row(1, '2026-01-01 00:00+00')::c returning jsonb);
The index scan returns 0 and the seq scan returns 1. 18 rejects the
CREATE INDEX.
Thanks,
Shihao