On 19/2/2024 19:53, Ranier Vilela wrote:
v17-0002
1) move the vars *arrayconst and *dest, to after if, to avoid makeNode (palloc).
+ Const   *arrayconst;
+ ScalarArrayOpExpr  *dest;
+
+ pd = (PredicatesData *) lfirst(lc);
+ if (pd->elems == NIL)
+ /* The index doesn't participate in this operation */
+ continue;

+ arrayconst = lsecond_node(Const, saop->args);
+ dest = makeNode(ScalarArrayOpExpr);
Thanks for the review!
I'm not sure I understand you clearly. Does the patch in attachment fix the issue you raised?

--
regards,
Andrei Lepikhov
Postgres Professional
diff --git a/src/backend/optimizer/path/indxpath.c 
b/src/backend/optimizer/path/indxpath.c
index 56b04541db..1545876e2f 100644
--- a/src/backend/optimizer/path/indxpath.c
+++ b/src/backend/optimizer/path/indxpath.c
@@ -1284,7 +1284,7 @@ build_paths_for_SAOP(PlannerInfo *root, RelOptInfo *rel, 
RestrictInfo *rinfo,
                ArrayType                  *arrayval = NULL;
                ArrayExpr                  *arr = NULL;
                Const                      *arrayconst = lsecond_node(Const, 
saop->args);
-               ScalarArrayOpExpr  *dest = makeNode(ScalarArrayOpExpr);
+               ScalarArrayOpExpr       dest;
 
                pd = (PredicatesData *) lfirst(lc);
                if (pd->elems == NIL)
@@ -1302,10 +1302,10 @@ build_paths_for_SAOP(PlannerInfo *root, RelOptInfo 
*rel, RestrictInfo *rinfo,
                arr->multidims = false;
 
                /* Compose new SAOP, partially covering the source one */
-               memcpy(dest, saop, sizeof(ScalarArrayOpExpr));
-               dest->args = list_make2(linitial(saop->args), arr);
+               memcpy(&dest, saop, sizeof(ScalarArrayOpExpr));
+               dest.args = list_make2(linitial(saop->args), arr);
 
-               clause = (Expr *) estimate_expression_value(root, (Node *) 
dest);
+               clause = (Expr *) estimate_expression_value(root, (Node *) 
&dest);
 
                /*
                 * Create new RestrictInfo. It maybe more heavy than just copy 
node,

Reply via email to