Skip to content

Commit bdeb2c4

Browse files
committed
Add WRITE_INDEX_ARRAY
We have a few WRITE_{name of type}_ARRAY macros, but the one case using the Index type was hand-coded. Wrap it into a macro as well. This also changes the behavior slightly: Before, the field name was skipped if the length was zero. Now it prints the field name even in that case. This is more consistent with how other array fields are handled. Reviewed-by: Jacob Champion <pchampion@vmware.com> Discussion: https://www.postgresql.org/message-id/c091e5cd-45f8-69ee-6a9b-de86912cc7e7@enterprisedb.com
1 parent 308da17 commit bdeb2c4

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

src/backend/nodes/outfuncs.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,13 @@ static void outChar(StringInfo str, char c);
124124
appendStringInfo(str, " %u", node->fldname[i]); \
125125
} while(0)
126126

127+
#define WRITE_INDEX_ARRAY(fldname, len) \
128+
do { \
129+
appendStringInfoString(str, " :" CppAsString(fldname) " "); \
130+
for (int i = 0; i < len; i++) \
131+
appendStringInfo(str, " %u", node->fldname[i]); \
132+
} while(0)
133+
127134
#define WRITE_INT_ARRAY(fldname, len) \
128135
do { \
129136
appendStringInfoString(str, " :" CppAsString(fldname) " "); \
@@ -2510,14 +2517,7 @@ _outPathTarget(StringInfo str, const PathTarget *node)
25102517
WRITE_NODE_TYPE("PATHTARGET");
25112518

25122519
WRITE_NODE_FIELD(exprs);
2513-
if (node->sortgrouprefs)
2514-
{
2515-
int i;
2516-
2517-
appendStringInfoString(str, " :sortgrouprefs");
2518-
for (i = 0; i < list_length(node->exprs); i++)
2519-
appendStringInfo(str, " %u", node->sortgrouprefs[i]);
2520-
}
2520+
WRITE_INDEX_ARRAY(sortgrouprefs, list_length(node->exprs));
25212521
WRITE_FLOAT_FIELD(cost.startup, "%.2f");
25222522
WRITE_FLOAT_FIELD(cost.per_tuple, "%.2f");
25232523
WRITE_INT_FIELD(width);

0 commit comments

Comments
 (0)