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]


Reply via email to