From: | Peter Eisentraut <peter(dot)eisentraut(at)enterprisedb(dot)com> |
---|---|
To: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
Cc: | Richard Guo <guofenglinux(at)gmail(dot)com>, pgsql-hackers(at)lists(dot)postgresql(dot)org |
Subject: | Re: Fix NULL pointer reference in _outPathTarget() |
Date: | 2022-04-22 14:16:02 |
Message-ID: | 68b6d987-7ec8-484e-34f3-1c2fffe3bc0f@enterprisedb.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
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.
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 2022-04-22 14:18:00 | Re: Fix NULL pointer reference in _outPathTarget() |
Previous Message | Bharath Rupireddy | 2022-04-22 14:15:14 | Re: why pg_walfile_name() cannot be executed during recovery? |