Don't bother copying empty support arrays in a zero-column MergeJoin.
authorTom Lane <tgl@sss.pgh.pa.us>
Mon, 9 Apr 2012 15:41:54 +0000 (11:41 -0400)
committerTom Lane <tgl@sss.pgh.pa.us>
Mon, 9 Apr 2012 15:41:54 +0000 (11:41 -0400)
The case could not arise when this code was originally written, but it can
now (since we made zero-column MergeJoins work for the benefit of FULL JOIN
ON TRUE).  I don't think there is any actual bug here, but we might as well
treat it consistently with other uses of COPY_POINTER_FIELD().  Per comment
from Ashutosh Bapat.

src/backend/nodes/copyfuncs.c

index f864af5d667769f51b77f06ca040ba63e4f09ece..c94799b15c7fbfb630241a8b472161afa5f85e6a 100644 (file)
@@ -672,10 +672,13 @@ _copyMergeJoin(const MergeJoin *from)
         */
        COPY_NODE_FIELD(mergeclauses);
        numCols = list_length(from->mergeclauses);
-       COPY_POINTER_FIELD(mergeFamilies, numCols * sizeof(Oid));
-       COPY_POINTER_FIELD(mergeCollations, numCols * sizeof(Oid));
-       COPY_POINTER_FIELD(mergeStrategies, numCols * sizeof(int));
-       COPY_POINTER_FIELD(mergeNullsFirst, numCols * sizeof(bool));
+       if (numCols > 0)
+       {
+               COPY_POINTER_FIELD(mergeFamilies, numCols * sizeof(Oid));
+               COPY_POINTER_FIELD(mergeCollations, numCols * sizeof(Oid));
+               COPY_POINTER_FIELD(mergeStrategies, numCols * sizeof(int));
+               COPY_POINTER_FIELD(mergeNullsFirst, numCols * sizeof(bool));
+       }
 
        return newnode;
 }