Re: DELETE/UPDATE FOR PORTION OF with rule system is not working - Mailing list pgsql-hackers

From jian he
Subject Re: DELETE/UPDATE FOR PORTION OF with rule system is not working
Date
Msg-id CACJufxGjgdWnhq5X5VL9orLXyKx-ZayT_Zj_-bAKr=kf0pZ_Nw@mail.gmail.com
Whole thread
In response to Re: DELETE/UPDATE FOR PORTION OF with rule system is not working  (Kirill Reshke <reshkekirill@gmail.com>)
Responses Re: DELETE/UPDATE FOR PORTION OF with rule system is not working
Re: DELETE/UPDATE FOR PORTION OF with rule system is not working
List pgsql-hackers
hi.
Actually it's supported.

The issue mentioned in the first email is caused by:
https://git.postgresql.org/cgit/postgresql.git/commit/?id=8e72d914c52876525a90b28444453de8085c866f

https://git.postgresql.org/cgit/postgresql.git/diff/src/backend/nodes/nodeFuncs.c?id=8e72d914c52876525a90b28444453de8085c866f

--- a/src/backend/nodes/nodeFuncs.c
+++ b/src/backend/nodes/nodeFuncs.c
@@ -2579,6 +2579,20 @@ expression_tree_walker_impl(Node *node,
return true;
}
break;
+ case T_ForPortionOfExpr:
+ {
+ ForPortionOfExpr *forPortionOf = (ForPortionOfExpr *) node;
+
+ if (WALK(forPortionOf->targetFrom))
+ return true;
+ if (WALK(forPortionOf->targetTo))
+ return true;
+ if (WALK(forPortionOf->targetRange))
+ return true;
+ if (WALK(forPortionOf->overlapsExpr))
+ return true;
+ }
+ break;

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.



--
jian
https://www.enterprisedb.com/

Attachment

pgsql-hackers by date:

Previous
From: "cca5507"
Date:
Subject: Return value of XLogInsertRecord() for XLOG_SWITCH record
Next
From: Julien Rouhaud
Date:
Subject: Re: proposal - queryid can be used as filter for auto_explain