Re: Fix NULL pointer reference in _outPathTarget()
| От | Peter Eisentraut |
|---|---|
| Тема | Re: Fix NULL pointer reference in _outPathTarget() |
| Дата | |
| Msg-id | 68b6d987-7ec8-484e-34f3-1c2fffe3bc0f@enterprisedb.com обсуждение исходный текст |
| Ответ на | Re: Fix NULL pointer reference in _outPathTarget() (Tom Lane <tgl@sss.pgh.pa.us>) |
| Ответы |
Re: Fix NULL pointer reference in _outPathTarget()
|
| Список | 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.
В списке pgsql-hackers по дате отправления: