public inbox for [email protected]
help / color / mirror / Atom feedFrom: Paul A Jungwirth <[email protected]>
To: jian he <[email protected]>
Cc: Kirill Reshke <[email protected]>
Cc: PostgreSQL-development <[email protected]>
Cc: Peter Eisentraut <[email protected]>
Subject: Re: DELETE/UPDATE FOR PORTION OF with rule system is not working
Date: Wed, 15 Apr 2026 15:40:41 -0700
Message-ID: <CA+renyXkcs=5P3dd=OoyM+A=UKA7iR_zS4TAQ42F9NTv+2RNiA@mail.gmail.com> (raw)
In-Reply-To: <CACJufxGjgdWnhq5X5VL9orLXyKx-ZayT_Zj_-bAKr=kf0pZ_Nw@mail.gmail.com>
References: <CACJufxHs1Hs00EqsZ4NbuAjmYzMzjJyP1sAj12Ne=cBsEVmQOA@mail.gmail.com>
<CALdSSPiRHCyC0fYy_E=gO+c7sbwU=7=Fz2CF-4aEa3mAe7yYAg@mail.gmail.com>
<CACJufxGjgdWnhq5X5VL9orLXyKx-ZayT_Zj_-bAKr=kf0pZ_Nw@mail.gmail.com>
On Mon, Apr 13, 2026 at 2:01 AM jian he <[email protected]> wrote:
>
> hi.
> Actually it's supported.
I also don't see any reason not to support this.
> We forgot to WALK (expression_tree_walker_impl)
> ForPortionOfExpr->rangeVar and ForPortionOfExpr->rangeTargetList.
> We need to WALK those two fields of ForPortionOfExpr in
> rewriteRuleAction (ChangeVarNodes,
> ReplaceVarsFromTargetList, etc.), and maybe elsewhere.
>
> i am surprised that nothing else has broken because of this.
Thank you for investigating and sending a fix.
The patch looks fine to me. I like the diversity of tests; I don't
think we need any more.
+-- UPDATE/DELETE FOR PORTION OF with RULEs
+CREATE TABLE fpo_rule (f1 bigint, f2 int4range);
+INSERT INTO fpo_rule VALUES (1, '[1, 10]');
+
+CREATE RULE fpo_rule1 AS ON INSERT TO fpo_rule DO INSTEAD UPDATE
fpo_rule FOR PORTION OF f2 FROM 1 TO 4 SET f1 = 2;
+INSERT INTO fpo_rule VALUES (1, '[1, 10]');
+SELECT * FROM fpo_rule ORDER BY f1;
I only have two small suggestions:
Please use '[1, 11)' syntax to match the other tests.
Breaking these long lines would be nice. For example:
+CREATE RULE fpo_rule1 AS ON INSERT TO fpo_rule
+ DO INSTEAD UPDATE fpo_rule FOR PORTION OF f2 FROM 1 TO 4 SET f1 = 2;
Yours,
--
Paul ~{:-)
[email protected]
view thread (9+ messages) latest in thread
reply
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: [email protected]
Cc: [email protected], [email protected], [email protected], [email protected]
Subject: Re: DELETE/UPDATE FOR PORTION OF with rule system is not working
In-Reply-To: <CA+renyXkcs=5P3dd=OoyM+A=UKA7iR_zS4TAQ42F9NTv+2RNiA@mail.gmail.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox