I believe the 2nd hunk should reset node->hashnulls, rather than reset ->hashtable a 2nd time:
@@ -505,7 +505,10 @@ buildSubPlanHash(SubPlanState *node, ExprContext *econtext) if (nbuckets < 1) nbuckets = 1; - node->hashtable = BuildTupleHashTable(node->parent, + if (node->hashtable) + ResetTupleHashTable(node->hashtable); + else + node->hashtable = BuildTupleHashTableExt(node->parent, node->descRight, ncols, node->keyColIdx, ... @@ -527,7 +531,11 @@ buildSubPlanHash(SubPlanState *node, ExprContext *econtext) if (nbuckets < 1) nbuckets = 1; } - node->hashnulls = BuildTupleHashTable(node->parent, + + if (node->hashnulls) + ResetTupleHashTable(node->hashtable); + else + node->hashnulls = BuildTupleHashTableExt(node->parent, node->descRight, ncols, node->keyColIdx, Added here: commit 356687bd825e5ca7230d43c1bffe7a59ad2e77bd Author: Andres Freund <and...@anarazel.de> Date: Sat Feb 9 00:35:57 2019 -0800 Reset, not recreate, execGrouping.c style hashtables.