Re: Bug: Rule actions see wrong values for generated columns (NEW.gen reads OLD value) - Mailing list pgsql-hackers

From Dean Rasheed
Subject Re: Bug: Rule actions see wrong values for generated columns (NEW.gen reads OLD value)
Date
Msg-id CAEZATCURLESGChXr5ZweoGCGQ9dadM4Hs2eSUjBmXV3OguN4WQ@mail.gmail.com
Whole thread
In response to Re: Bug: Rule actions see wrong values for generated columns (NEW.gen reads OLD value)  (Richard Guo <guofenglinux@gmail.com>)
List pgsql-hackers
On Mon, 20 Apr 2026 at 08:29, Richard Guo <guofenglinux@gmail.com> wrote:
>
> I noticed a couple of issues after a further look.
>
> 1. The ReplaceVarsFromTargetList call on "gen_cols" fails to handle
> hasSubLinks.  This can cause error if targetList contains SubLinks:
>
> update t set a = (select max(a) from t);
> ERROR:  replace_rte_variables inserted a SubLink, but has noplace to record it
>

Doh, yes, careless copy-and-pasting. The updates look good.

> 2. The same bug fixed in this patch also exists in rule quals:
>
> I think we should apply the same fix to CopyAndAddInvertedQual.
>

Agreed.

> Attached v3 fixes them.
>

LGTM.

Regards,
Dean



pgsql-hackers by date:

Previous
From: Daniel Gustafsson
Date:
Subject: Re: [PATCH] Reject ENCODING option for COPY TO FORMAT JSON
Next
From: Yuchen Li
Date:
Subject: Re: EXCEPT TABLE - Case inconsistency for describe \d and \dRp+