From b34e58469a92a1d4c5d4266cf6632c78802c0c16 Mon Sep 17 00:00:00 2001
From: Tomas Vondra <tomas@2ndquadrant.com>
Date: Mon, 17 Jun 2024 16:38:00 +0200
Subject: [PATCH v20240617 36/56] Remove 2 pull_varnos calls with
 rinfo->left|right_relids.

---
 src/backend/statistics/extended_stats.c | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)

diff --git a/src/backend/statistics/extended_stats.c b/src/backend/statistics/extended_stats.c
index 868fc12e77e..c06829eba31 100644
--- a/src/backend/statistics/extended_stats.c
+++ b/src/backend/statistics/extended_stats.c
@@ -3216,8 +3216,11 @@ extract_relation_info(PlannerInfo *root, JoinPairInfo *info, int index,
 static Node *
 get_expression_for_rel(PlannerInfo *root, RelOptInfo *rel, Node *clause)
 {
-	OpExpr	   *opexpr;
-	Node	   *expr;
+	OpExpr *opexpr;
+	Node   *expr;
+	RestrictInfo *rinfo = (RestrictInfo *) clause;
+
+	Assert(IsA(clause, RestrictInfo));
 
 	/*
 	 * Strip the RestrictInfo node, get the actual clause.
@@ -3226,8 +3229,7 @@ get_expression_for_rel(PlannerInfo *root, RelOptInfo *rel, Node *clause)
 	 * (e.g. RelabelType etc.). statext_is_supported_join_clause matches this,
 	 * but maybe we need to relax it?
 	 */
-	if (IsA(clause, RestrictInfo))
-		clause = (Node *) ((RestrictInfo *) clause)->clause;
+	clause = (Node *) rinfo->clause;
 
 	opexpr = (OpExpr *) clause;
 
@@ -3237,11 +3239,11 @@ get_expression_for_rel(PlannerInfo *root, RelOptInfo *rel, Node *clause)
 
 	/* FIXME strip relabel etc. the way examine_opclause_args does */
 	expr = linitial(opexpr->args);
-	if (bms_singleton_member(pull_varnos(root, expr)) == rel->relid)
+	if (bms_singleton_member(rinfo->left_relids) == rel->relid)
 		return expr;
 
 	expr = lsecond(opexpr->args);
-	if (bms_singleton_member(pull_varnos(root, expr)) == rel->relid)
+	if (bms_singleton_member(rinfo->right_relids) == rel->relid)
 		return expr;
 
 	return NULL;
-- 
2.45.2

