diff --git a/src/backend/executor/nodeIncrementalSort.c b/src/backend/executor/nodeIncrementalSort.c
index 6c0d24ee25..d11d5905b0 100644
--- a/src/backend/executor/nodeIncrementalSort.c
+++ b/src/backend/executor/nodeIncrementalSort.c
@@ -370,7 +370,7 @@ switchToPresortedPrefixMode(PlanState *pstate)
 			 * If this is our first time through the loop, then we need to
 			 * save the first tuple we get as our new group pivot.
 			 */
-			if (TupIsNull(node->group_pivot))
+			if (node->group_pivot != NULL && TTS_EMPTY(node->group_pivot))
 				ExecCopySlot(node->group_pivot, node->transfer_tuple);
 
 			if (isCurrentGroup(node, node->group_pivot, node->transfer_tuple))