On Thu, Jul 23, 2026 at 4:57 AM Richard Guo <[email protected]> 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


Reply via email to