Re: PG19 regression in ecd9288624a: JSON_ARRAY() indexes that go stale

From: Nikolay Samokhvalov <nik(at)postgres(dot)ai>
To: pgsql-hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Cc: "manuelreyesbravo(at)gmail(dot)com" <manuelreyesbravo(at)gmail(dot)com>, andrew(at)dunslane(dot)net, jian(dot)universality(at)gmail(dot)com, robertmhaas(at)gmail(dot)com, zhong950419(at)gmail(dot)com
Subject: Re: PG19 regression in ecd9288624a: JSON_ARRAY() indexes that go stale
Date: 2026-11-04 06:37:52
Message-ID: CAM527d8pjRKWcZSfh0+4Ye-J7apOAx2G0_rLNef-_tcZ9f__Ug@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Tue, Nov 3, 2026 at 8:58 AM Manu <manuelreyesbravo(at)gmail(dot)com> wrote:
> - float4, float8, then extra_float_digits = 0: stale / stale / stale,
> since float8out is still IMMUTABLE in 18 and 19; on master it is
> STABLE now, and there v5 rejects them

True for scalars, but accepting arrays of them here is new in 19.
18 rejects every array here; 19 recurses into the element type, and on
REL_19_STABLE
float4out, float8out, byteaout and the geometric output functions are
still IMMUTABLE (e75fcc9867fd made them STABLE on master only [1]). So
19 with v5 accepts float4[], float8[], bytea[], point[] etc., and the
index goes stale:

create table t (f float8[]);
insert into t values ('{0.30000000000000004}');
create index t_i on t ((json_array(f returning jsonb)));
set extra_float_digits = 0;
set enable_seqscan = off;
select count(*) from t where json_array(f returning jsonb) = '[[0.3]]';

On REL_19_STABLE 4b1abd678223 with v5 the index scan returns 0, a seq
scan returns 1. 18.6 rejects the CREATE INDEX. bytea[] with
bytea_output = escape behaves the same.

AI found this while testing v5 and prepared the attached patch; I
haven't manually reviewed the code yet. It is for REL_19_STABLE only,
on top of v5: arrays of float4, float8, bytea and the geometric types,
or of domains over them, are mutable. Scalars keep the 18 behavior, so
existing schemas still restore. Master doesn't need it, there v5
already rejects all of these. The file name starts with nocfbot so
cfbot keeps testing v5.

Tested on REL_19_STABLE 4b1abd678223 + v5 + this patch, assertions
on: the regress suite passes; without the jsonfuncs.c hunk the new
sqljson test fails. On master b6178c942ea7 + v5, the same statements
are rejected already.

[1]
https://git.postgresql.org/gitweb/?p=postgresql.git;a=commit;h=e75fcc9867fdfe295957ad5c9a98cbe2e1b4c5c3

Nik

Attachment Content-Type Size
nocfbot-v5-REL_19-float-json-immutability.patch application/x-patch 7.1 KB

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Nikolay Samokhvalov 2026-11-04 06:41:15 Re: pgsql: Reduce "Var IS [NOT] NULL" quals during constant folding
Previous Message Yugo Nagata 2026-11-04 06:32:18 Re: Track skipped tables during autovacuum and autoanalyze