diff --git a/src/backend/nodes/outfuncs.c b/src/backend/nodes/outfuncs.c index 6a02f81ad5..9f45b07936 100644 --- a/src/backend/nodes/outfuncs.c +++ b/src/backend/nodes/outfuncs.c @@ -2666,10 +2666,13 @@ _outPathKey(StringInfo str, const PathKey *node) static void _outPathTarget(StringInfo str, const PathTarget *node) { + int refnos_len = node->sortgrouprefs ? + list_length(node->exprs) : 0; + WRITE_NODE_TYPE("PATHTARGET"); WRITE_NODE_FIELD(exprs); - WRITE_INDEX_ARRAY(sortgrouprefs, list_length(node->exprs)); + WRITE_INDEX_ARRAY(sortgrouprefs, refnos_len); WRITE_FLOAT_FIELD(cost.startup, "%.2f"); WRITE_FLOAT_FIELD(cost.per_tuple, "%.2f"); WRITE_INT_FIELD(width);