public inbox for [email protected]  
help / color / mirror / Atom feed
From: Andrei Lepikhov <[email protected]>
To: Ranier Vilela <[email protected]>
Cc: jian he <[email protected]>
Cc: Alena Rybakina <[email protected]>
Cc: Alexander Korotkov <[email protected]>
Cc: Robert Haas <[email protected]>
Cc: [email protected]
Cc: Peter Geoghegan <[email protected]>
Cc: Finnerty, Jim <[email protected]>
Cc: Marcos Pegoraro <[email protected]>
Cc: [email protected]
Cc: Tomas Vondra <[email protected]>
Cc: Peter Eisentraut <[email protected]>
Subject: Re: POC, WIP: OR-clause support for indexes
Date: Tue, 20 Feb 2024 10:18:23 +0700
Message-ID: <[email protected]> (raw)
In-Reply-To: <CAEudQAq4XTcwhw2OmfW1AJNqvMfbReEWjuzqv6YTz6ZjbpmL0g@mail.gmail.com>
References: <[email protected]>
	<CACJufxGXhJ823cdAdp2Ho7qC-HZ3_-dtdj-myaAi_u9RQLn45g@mail.gmail.com>
	<CACJufxG=wB6qLbOAWaYEQHccN+qi=6-pw7zKVWZ53ZiDZNRTRA@mail.gmail.com>
	<CACJufxFrZS07oBHMk1_c8P3A84VZ3ysXiZV8NeU6gAnvu+HsVA@mail.gmail.com>
	<[email protected]>
	<CACJufxFS-xcjaWq2Du2OyJUjRAyqCk12Q_zGOPxv61sgrdpw9w@mail.gmail.com>
	<[email protected]>
	<[email protected]>
	<CACJufxFSfSGZpmVt_98SRojdugW2s9H-qYm2sYr0A3o-xPea0g@mail.gmail.com>
	<[email protected]>
	<[email protected]>
	<CACJufxH-zju3VfosSRBu8d3xs99sGENn6+P3AETLuTiAPFY+0g@mail.gmail.com>
	<[email protected]>
	<CACJufxFMFoosvbuFYDiFtpam4sKCSGJeh5jYiZSY8PHjCpEHYA@mail.gmail.com>
	<[email protected]>
	<CAEudQAq4XTcwhw2OmfW1AJNqvMfbReEWjuzqv6YTz6ZjbpmL0g@mail.gmail.com>

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,


Attachments:

  [text/plain] fix.diff (1.2K, ../[email protected]/2-fix.diff)
  download | inline diff:
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,


view thread (41+ 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], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected]
  Subject: Re: POC, WIP: OR-clause support for indexes
  In-Reply-To: <[email protected]>

* 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