From d5d74b732a860f477219f28a18d7a1aece26a182 Mon Sep 17 00:00:00 2001
From: Tomas Vondra <tomas@2ndquadrant.com>
Date: Wed, 19 Jun 2024 13:23:48 +0200
Subject: [PATCH v20240619 04/11] fixup: clarify tuplesort_begin_index_gin

---
 src/backend/utils/sort/tuplesortvariants.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/src/backend/utils/sort/tuplesortvariants.c b/src/backend/utils/sort/tuplesortvariants.c
index 060fb64164f..0f0c1d71027 100644
--- a/src/backend/utils/sort/tuplesortvariants.c
+++ b/src/backend/utils/sort/tuplesortvariants.c
@@ -606,7 +606,13 @@ tuplesort_begin_index_gin(int workMem, SortCoordinate coordinate,
 			 sortopt & TUPLESORT_RANDOMACCESS ? 't' : 'f');
 #endif
 
-	base->nKeys = 1;			/* Only the index key */
+	/*
+	 * Only one sort column, the index key.
+	 *
+	 * Multi-column GIN indexes store the value of each attribute separate
+	 * index entries, so each entry has a single sort key.
+	 */
+	base->nKeys = 1;
 
 	base->removeabbrev = removeabbrev_index_gin;
 	base->comparetup = comparetup_index_gin;
-- 
2.45.2

