@@ -930,7 +930,14 @@ tuplesort_begin_datum(Oid datumType, Oid sortOperator, Oid sortCollation,
930930 state -> sortKeys -> ssup_collation = sortCollation ;
931931 state -> sortKeys -> ssup_nulls_first = nullsFirstFlag ;
932932
933- /* abbreviation is possible here only for by-reference types */
933+ /*
934+ * Abbreviation is possible here only for by-reference types. In theory,
935+ * a pass-by-value datatype could have an abbreviated form that is cheaper
936+ * to compare. In a tuple sort, we could support that, because we can
937+ * always extract the original datum from the tuple is needed. Here, we
938+ * can't, because a datum sort only stores a single copy of the datum;
939+ * the "tuple" field of each sortTuple is NULL.
940+ */
934941 state -> sortKeys -> abbreviate = !typbyval ;
935942
936943 PrepareSortSupportFromOrderingOp (sortOperator , state -> sortKeys );
@@ -1271,7 +1278,7 @@ tuplesort_putindextuplevalues(Tuplesortstate *state, Relation rel,
12711278 * Store ordinary Datum representation, or NULL value. If there is a
12721279 * converter it won't expect NULL values, and cost model is not
12731280 * required to account for NULL, so in that case we avoid calling
1274- * converter and just set datum1 to "void" representation (to be
1281+ * converter and just set datum1 to zeroed representation (to be
12751282 * consistent).
12761283 */
12771284 stup .datum1 = original ;
@@ -3155,7 +3162,7 @@ copytup_heap(Tuplesortstate *state, SortTuple *stup, void *tup)
31553162 * Store ordinary Datum representation, or NULL value. If there is a
31563163 * converter it won't expect NULL values, and cost model is not
31573164 * required to account for NULL, so in that case we avoid calling
3158- * converter and just set datum1 to "void" representation (to be
3165+ * converter and just set datum1 to zeroed representation (to be
31593166 * consistent).
31603167 */
31613168 stup -> datum1 = original ;
@@ -3397,7 +3404,7 @@ copytup_cluster(Tuplesortstate *state, SortTuple *stup, void *tup)
33973404 * Store ordinary Datum representation, or NULL value. If there is a
33983405 * converter it won't expect NULL values, and cost model is not
33993406 * required to account for NULL, so in that case we avoid calling
3400- * converter and just set datum1 to "void" representation (to be
3407+ * converter and just set datum1 to zeroed representation (to be
34013408 * consistent).
34023409 */
34033410 stup -> datum1 = original ;
@@ -3701,7 +3708,7 @@ copytup_index(Tuplesortstate *state, SortTuple *stup, void *tup)
37013708 * Store ordinary Datum representation, or NULL value. If there is a
37023709 * converter it won't expect NULL values, and cost model is not
37033710 * required to account for NULL, so in that case we avoid calling
3704- * converter and just set datum1 to "void" representation (to be
3711+ * converter and just set datum1 to zeroed representation (to be
37053712 * consistent).
37063713 */
37073714 stup -> datum1 = original ;
0 commit comments