From 99cfc5c85536e3a2c3ad5d92c6627d4a44277e3f Mon Sep 17 00:00:00 2001
From: Richard Guo <guofenglinux@gmail.com>
Date: Mon, 25 Mar 2024 17:57:48 +0800
Subject: [PATCH v1] Fix the comment of init_dummy_sjinfo()

This patch fixes the comment of init_dummy_sjinfo() by removing
references to the non-existing 'rel1' and 'rel2'.

In passing, this patch makes consider_new_or_clause() call
init_dummy_sjinfo() to simplify the code a bit.
---
 src/backend/optimizer/path/joinrels.c  |  5 +++--
 src/backend/optimizer/util/orclauses.c | 23 +++++------------------
 2 files changed, 8 insertions(+), 20 deletions(-)

diff --git a/src/backend/optimizer/path/joinrels.c b/src/backend/optimizer/path/joinrels.c
index 17ef825a34..f3a9412d18 100644
--- a/src/backend/optimizer/path/joinrels.c
+++ b/src/backend/optimizer/path/joinrels.c
@@ -656,8 +656,9 @@ join_is_legal(PlannerInfo *root, RelOptInfo *rel1, RelOptInfo *rel2,
 
 /*
  * init_dummy_sjinfo
- *    Populate the given SpecialJoinInfo for a plain inner join between rel1
- *    and rel2
+ *    Populate the given SpecialJoinInfo for a plain inner join between the
+ *    left and right relations specified by left_relids and right_relids
+ *    respectively.
  *
  * Normally, an inner join does not have a SpecialJoinInfo node associated with
  * it. But some functions involved in join planning require one containing at
diff --git a/src/backend/optimizer/util/orclauses.c b/src/backend/optimizer/util/orclauses.c
index d911c6547d..5e2bf26ec4 100644
--- a/src/backend/optimizer/util/orclauses.c
+++ b/src/backend/optimizer/util/orclauses.c
@@ -19,6 +19,7 @@
 #include "nodes/nodeFuncs.h"
 #include "optimizer/optimizer.h"
 #include "optimizer/orclauses.h"
+#include "optimizer/paths.h"
 #include "optimizer/restrictinfo.h"
 
 
@@ -325,24 +326,10 @@ consider_new_or_clause(PlannerInfo *root, RelOptInfo *rel,
 		 * Make up a SpecialJoinInfo for JOIN_INNER semantics.  (Compare
 		 * approx_tuple_count() in costsize.c.)
 		 */
-		sjinfo.type = T_SpecialJoinInfo;
-		sjinfo.min_lefthand = bms_difference(join_or_rinfo->clause_relids,
-											 rel->relids);
-		sjinfo.min_righthand = rel->relids;
-		sjinfo.syn_lefthand = sjinfo.min_lefthand;
-		sjinfo.syn_righthand = sjinfo.min_righthand;
-		sjinfo.jointype = JOIN_INNER;
-		sjinfo.ojrelid = 0;
-		sjinfo.commute_above_l = NULL;
-		sjinfo.commute_above_r = NULL;
-		sjinfo.commute_below_l = NULL;
-		sjinfo.commute_below_r = NULL;
-		/* we don't bother trying to make the remaining fields valid */
-		sjinfo.lhs_strict = false;
-		sjinfo.semi_can_btree = false;
-		sjinfo.semi_can_hash = false;
-		sjinfo.semi_operators = NIL;
-		sjinfo.semi_rhs_exprs = NIL;
+		init_dummy_sjinfo(&sjinfo,
+						  bms_difference(join_or_rinfo->clause_relids,
+										 rel->relids),
+						  rel->relids);
 
 		/* Compute inner-join size */
 		orig_selec = clause_selectivity(root, (Node *) join_or_rinfo,
-- 
2.31.0

