On 20.04.22 18:53, Tom Lane wrote:
I think we could put the if (node->fldname) inside the WRITE_INDEX_ARRAY
macro.

Yeah, that's another way to do it.  I think though that the unresolved
question is whether or not we want the field name to appear in the output
when the field is null.  I believe that I intentionally made it not appear
originally, so that that case could readily be distinguished.  You could
argue that that would complicate life greatly for a _readPathTarget()
function, which is true, but I don't foresee that we'll need one.

We could adapt the convention to print NULL values as "<>", like

diff --git a/src/backend/nodes/outfuncs.c b/src/backend/nodes/outfuncs.c
index 6a02f81ad5..4eb5be3787 100644
--- a/src/backend/nodes/outfuncs.c
+++ b/src/backend/nodes/outfuncs.c
@@ -127,8 +127,11 @@ static void outChar(StringInfo str, char c);
 #define WRITE_INDEX_ARRAY(fldname, len) \
    do { \
        appendStringInfoString(str, " :" CppAsString(fldname) " "); \
-       for (int i = 0; i < len; i++) \
-           appendStringInfo(str, " %u", node->fldname[i]); \
+       if (node->fldname) \
+           for (int i = 0; i < len; i++) \
+               appendStringInfo(str, " %u", node->fldname[i]); \
+       else \
+           appendStringInfoString(str, "<>"); \
    } while(0)

 #define WRITE_INT_ARRAY(fldname, len) \

There is currently no read function for this that would need to be changed. But looking at peers such as WRITE_INT_ARRAY/READ_INT_ARRAY it shouldn't be hard to sort out if it became necessary.


Reply via email to