From 148ad41d7fc531ad55fbc7e79a7e5c15a587377d Mon Sep 17 00:00:00 2001
From: Antonin Houska <ah@cybertec.at>
Date: Fri, 21 Aug 2026 10:21:20 +0200
Subject: [PATCH] Attempt to reword a comment.

In particular, the phrase "so every output row satisfies them" seems
problematic because an output row of a semijoin is NULL-extended, so the
output row usually does not satisfy the join clauses.
---
 src/backend/optimizer/path/uniquekeys.c | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/src/backend/optimizer/path/uniquekeys.c b/src/backend/optimizer/path/uniquekeys.c
index f9d9c37f447..34b2507d6b7 100644
--- a/src/backend/optimizer/path/uniquekeys.c
+++ b/src/backend/optimizer/path/uniquekeys.c
@@ -538,9 +538,14 @@ populate_joinrel_uniquekeys(PlannerInfo *root, RelOptInfo *joinrel,
 	if (jointype == JOIN_SEMI || jointype == JOIN_ANTI)
 	{
 		/*
-		 * A semijoin emits an LHS row only when some RHS row satisfied the
-		 * join clauses, so every output row satisfies them.  An antijoin
-		 * emits exactly the rows that no RHS row matched.
+		 * A semijoin emits a row only when the LHS satisfied the join clauses
+		 * (for at least one RHS row). Given that all the current unique keys
+		 * originate from the LHS, it's possible that rows having NULL in any
+		 * unique key attribute are filtered out by the join clauses.
+		 *
+		 * (An antijoin emits exactly the rows that do not satisfy the join
+		 * clauses, so rows having NULL in the unique key are not filtered
+		 * out.)
 		 */
 		if (jointype == JOIN_SEMI)
 			strengthen_uniquekeys_for_join(root, joinrel, restrictlist);
-- 
2.52.0

