From 13e4f61743b99809ecbbcf3454cd6d11d90a4254 Mon Sep 17 00:00:00 2001
From: Yuya Watari <watari.yuya@gmail.com>
Date: Fri, 29 Nov 2024 14:49:43 +0900
Subject: [PATCH v29 7/8] Don't use unlikely(top_parent != NULL)

---
 contrib/postgres_fdw/postgres_fdw.c     |  2 +-
 src/backend/optimizer/path/equivclass.c | 10 +++++-----
 src/backend/optimizer/path/indxpath.c   |  2 +-
 3 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/contrib/postgres_fdw/postgres_fdw.c b/contrib/postgres_fdw/postgres_fdw.c
index e68c116164c..030fe741030 100644
--- a/contrib/postgres_fdw/postgres_fdw.c
+++ b/contrib/postgres_fdw/postgres_fdw.c
@@ -7854,7 +7854,7 @@ find_em_for_rel(PlannerInfo *root, EquivalenceClass *ec, RelOptInfo *rel)
 		 * If child EquivalenceMembers may match the request, we add and
 		 * iterate over them by calling iterate_child_rel_equivalences().
 		 */
-		if (unlikely(top_parent_rel_relids != NULL) && !em->em_is_child &&
+		if (top_parent_rel_relids != NULL && !em->em_is_child &&
 			bms_is_subset(em->em_relids, top_parent_rel_relids))
 			iterate_child_rel_equivalences(&it, root, ec, em, rel->relids);
 
diff --git a/src/backend/optimizer/path/equivclass.c b/src/backend/optimizer/path/equivclass.c
index 022f20020af..86057538c5c 100644
--- a/src/backend/optimizer/path/equivclass.c
+++ b/src/backend/optimizer/path/equivclass.c
@@ -861,7 +861,7 @@ get_eclass_for_sort_expr(PlannerInfo *root,
 			 * If child EquivalenceMembers may match the request, we add and
 			 * iterate over them by calling iterate_child_rel_equivalences().
 			 */
-			if (unlikely(top_parent_rel != NULL) && !cur_em->em_is_child &&
+			if (top_parent_rel != NULL && !cur_em->em_is_child &&
 				bms_equal(cur_em->em_relids, top_parent_rel))
 				iterate_child_rel_equivalences(&it, root, cur_ec, cur_em, rel);
 
@@ -1034,7 +1034,7 @@ find_ec_member_matching_expr(PlannerInfo *root, EquivalenceClass *ec,
 		 * If child EquivalenceMembers may match the request, we add and
 		 * iterate over them by calling iterate_child_rel_equivalences().
 		 */
-		if (unlikely(top_parent_relids != NULL) && !em->em_is_child &&
+		if (top_parent_relids != NULL && !em->em_is_child &&
 			bms_is_subset(em->em_relids, top_parent_relids))
 			iterate_child_rel_equivalences(&it, root, ec, em, relids);
 
@@ -1144,7 +1144,7 @@ find_computable_ec_member(PlannerInfo *root,
 		 * If child EquivalenceMembers may match the request, we add and
 		 * iterate over them by calling iterate_child_rel_equivalences().
 		 */
-		if (unlikely(top_parent_relids != NULL) && !em->em_is_child &&
+		if (top_parent_relids != NULL && !em->em_is_child &&
 			bms_is_subset(em->em_relids, top_parent_relids))
 			iterate_child_rel_equivalences(&it, root, ec, em, relids);
 
@@ -1881,7 +1881,7 @@ generate_join_implied_equalities_normal(PlannerInfo *root,
 		 * If child EquivalenceMembers may match the request, we add and
 		 * iterate over them by calling iterate_child_rel_equivalences().
 		 */
-		if (unlikely(top_parent_join_relids != NULL) && !cur_em->em_is_child &&
+		if (top_parent_join_relids != NULL && !cur_em->em_is_child &&
 			bms_is_subset(cur_em->em_relids, top_parent_join_relids))
 			iterate_child_rel_equivalences(&it, root, ec, cur_em, join_relids);
 
@@ -3616,7 +3616,7 @@ generate_implied_equalities_for_column(PlannerInfo *root,
 			 * If child EquivalenceMembers may match the request, we add and
 			 * iterate over them by calling iterate_child_rel_equivalences().
 			 */
-			if (unlikely(top_parent_rel_relids != NULL) && !cur_em->em_is_child &&
+			if (top_parent_rel_relids != NULL && !cur_em->em_is_child &&
 				bms_equal(cur_em->em_relids, top_parent_rel_relids))
 				iterate_child_rel_equivalences(&it, root, cur_ec, cur_em, rel->relids);
 			if (bms_equal(cur_em->em_relids, rel->relids) &&
diff --git a/src/backend/optimizer/path/indxpath.c b/src/backend/optimizer/path/indxpath.c
index 4a42752486e..9b7d01a85d8 100644
--- a/src/backend/optimizer/path/indxpath.c
+++ b/src/backend/optimizer/path/indxpath.c
@@ -3787,7 +3787,7 @@ match_pathkeys_to_index(PlannerInfo *root, IndexOptInfo *index, List *pathkeys,
 			 * If child EquivalenceMembers may match the request, we add and
 			 * iterate over them by calling iterate_child_rel_equivalences().
 			 */
-			if (unlikely(top_parent_index_relids != NULL) && !member->em_is_child &&
+			if (top_parent_index_relids != NULL && !member->em_is_child &&
 				bms_equal(member->em_relids, top_parent_index_relids))
 				iterate_child_rel_equivalences(&it, root, pathkey->pk_eclass, member,
 											   index->rel->relids);
-- 
2.45.2.windows.1

