Re: Fix missing FORMAT when deparsing JSON_ARRAY(query)

From: John Naylor <johncnaylorls(at)gmail(dot)com>
To: Richard Guo <guofenglinux(at)gmail(dot)com>
Cc: Chao Li <li(dot)evan(dot)chao(at)gmail(dot)com>, PostgreSQL-development <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: Fix missing FORMAT when deparsing JSON_ARRAY(query)
Date: 2026-07-23 11:09:13
Message-ID: CANWCAZYFEpJ5Oi45gi4q9Y6LYa4_oiAXxuNNWe-1ym-i0fF8Pw@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Thu, Jul 23, 2026 at 4:57 AM Richard Guo <guofenglinux(at)gmail(dot)com> wrote:
> I plan to push the attached patch soon barring any objections.

No objection, but I'd like to encourage submitters to dig deeper when
they find things like this. Deparsing is relevant to work I'm doing,
and I wanted to see if we can detect this kind of omission earlier. It
turns out my work doesn't enable that, but while looking into it
Claude offered to search for other bugs of this kind and found this:

CREATE TABLE emp (id int, valid daterange, salary int);
CREATE TABLE t (x int);

CREATE RULE r AS ON UPDATE TO t DO INSTEAD
UPDATE emp FOR PORTION OF valid FROM '2020-01-01' TO '2021-01-01'
SET salary = 1;

-- rename column
ALTER TABLE emp RENAME COLUMN valid TO validity;

INSERT INTO emp VALUES (1, daterange('2019-01-01','2022-01-01'), 0);
UPDATE t SET x = 0; -- fires the rule

=# select * from emp ;
id | validity | salary
----+-------------------------+--------
1 | [2020-01-01,2021-01-01) | 1
1 | [2019-01-01,2020-01-01) | 0
1 | [2021-01-01,2022-01-01) | 0
(3 rows)

dump and restore:

ERROR: column "valid" of relation "emp" does not exist
LINE 2: ...ic.t DO INSTEAD UPDATE public.emp FOR PORTION OF valid FROM...

I don't have time to look at a fix right now, but I wanted to flag it
now in case it makes sense to fix these together.

--
John Naylor
Amazon Web Services

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Amit Kapila 2026-07-23 11:43:07 Re: Fix "unexpected logical decoding status change" error; from concurrent logical decoding activation
Previous Message Amit Kapila 2026-07-23 11:05:07 Re: Incorrect check in 037_except.pl?