57
57
#define COPY_POINTER_FIELD (fldname , sz ) \
58
58
do { \
59
59
Size _size = (sz); \
60
- newnode->fldname = palloc(_size); \
61
- memcpy(newnode->fldname, from->fldname, _size); \
60
+ if (_size > 0) \
61
+ { \
62
+ newnode->fldname = palloc(_size); \
63
+ memcpy(newnode->fldname, from->fldname, _size); \
64
+ } \
62
65
} while (0)
63
66
64
67
/* Copy a parse location field (for Copy, this is same as scalar case) */
@@ -296,12 +299,9 @@ _copyRecursiveUnion(const RecursiveUnion *from)
296
299
*/
297
300
COPY_SCALAR_FIELD (wtParam );
298
301
COPY_SCALAR_FIELD (numCols );
299
- if (from -> numCols > 0 )
300
- {
301
- COPY_POINTER_FIELD (dupColIdx , from -> numCols * sizeof (AttrNumber ));
302
- COPY_POINTER_FIELD (dupOperators , from -> numCols * sizeof (Oid ));
303
- COPY_POINTER_FIELD (dupCollations , from -> numCols * sizeof (Oid ));
304
- }
302
+ COPY_POINTER_FIELD (dupColIdx , from -> numCols * sizeof (AttrNumber ));
303
+ COPY_POINTER_FIELD (dupOperators , from -> numCols * sizeof (Oid ));
304
+ COPY_POINTER_FIELD (dupCollations , from -> numCols * sizeof (Oid ));
305
305
COPY_SCALAR_FIELD (numGroups );
306
306
307
307
return newnode ;
@@ -896,13 +896,10 @@ _copyMergeJoin(const MergeJoin *from)
896
896
COPY_SCALAR_FIELD (skip_mark_restore );
897
897
COPY_NODE_FIELD (mergeclauses );
898
898
numCols = list_length (from -> mergeclauses );
899
- if (numCols > 0 )
900
- {
901
- COPY_POINTER_FIELD (mergeFamilies , numCols * sizeof (Oid ));
902
- COPY_POINTER_FIELD (mergeCollations , numCols * sizeof (Oid ));
903
- COPY_POINTER_FIELD (mergeStrategies , numCols * sizeof (int ));
904
- COPY_POINTER_FIELD (mergeNullsFirst , numCols * sizeof (bool ));
905
- }
899
+ COPY_POINTER_FIELD (mergeFamilies , numCols * sizeof (Oid ));
900
+ COPY_POINTER_FIELD (mergeCollations , numCols * sizeof (Oid ));
901
+ COPY_POINTER_FIELD (mergeStrategies , numCols * sizeof (int ));
902
+ COPY_POINTER_FIELD (mergeNullsFirst , numCols * sizeof (bool ));
906
903
907
904
return newnode ;
908
905
}
@@ -1064,12 +1061,9 @@ _copyAgg(const Agg *from)
1064
1061
COPY_SCALAR_FIELD (aggstrategy );
1065
1062
COPY_SCALAR_FIELD (aggsplit );
1066
1063
COPY_SCALAR_FIELD (numCols );
1067
- if (from -> numCols > 0 )
1068
- {
1069
- COPY_POINTER_FIELD (grpColIdx , from -> numCols * sizeof (AttrNumber ));
1070
- COPY_POINTER_FIELD (grpOperators , from -> numCols * sizeof (Oid ));
1071
- COPY_POINTER_FIELD (grpCollations , from -> numCols * sizeof (Oid ));
1072
- }
1064
+ COPY_POINTER_FIELD (grpColIdx , from -> numCols * sizeof (AttrNumber ));
1065
+ COPY_POINTER_FIELD (grpOperators , from -> numCols * sizeof (Oid ));
1066
+ COPY_POINTER_FIELD (grpCollations , from -> numCols * sizeof (Oid ));
1073
1067
COPY_SCALAR_FIELD (numGroups );
1074
1068
COPY_SCALAR_FIELD (transitionSpace );
1075
1069
COPY_BITMAPSET_FIELD (aggParams );
@@ -1091,19 +1085,13 @@ _copyWindowAgg(const WindowAgg *from)
1091
1085
1092
1086
COPY_SCALAR_FIELD (winref );
1093
1087
COPY_SCALAR_FIELD (partNumCols );
1094
- if (from -> partNumCols > 0 )
1095
- {
1096
- COPY_POINTER_FIELD (partColIdx , from -> partNumCols * sizeof (AttrNumber ));
1097
- COPY_POINTER_FIELD (partOperators , from -> partNumCols * sizeof (Oid ));
1098
- COPY_POINTER_FIELD (partCollations , from -> partNumCols * sizeof (Oid ));
1099
- }
1088
+ COPY_POINTER_FIELD (partColIdx , from -> partNumCols * sizeof (AttrNumber ));
1089
+ COPY_POINTER_FIELD (partOperators , from -> partNumCols * sizeof (Oid ));
1090
+ COPY_POINTER_FIELD (partCollations , from -> partNumCols * sizeof (Oid ));
1100
1091
COPY_SCALAR_FIELD (ordNumCols );
1101
- if (from -> ordNumCols > 0 )
1102
- {
1103
- COPY_POINTER_FIELD (ordColIdx , from -> ordNumCols * sizeof (AttrNumber ));
1104
- COPY_POINTER_FIELD (ordOperators , from -> ordNumCols * sizeof (Oid ));
1105
- COPY_POINTER_FIELD (ordCollations , from -> ordNumCols * sizeof (Oid ));
1106
- }
1092
+ COPY_POINTER_FIELD (ordColIdx , from -> ordNumCols * sizeof (AttrNumber ));
1093
+ COPY_POINTER_FIELD (ordOperators , from -> ordNumCols * sizeof (Oid ));
1094
+ COPY_POINTER_FIELD (ordCollations , from -> ordNumCols * sizeof (Oid ));
1107
1095
COPY_SCALAR_FIELD (frameOptions );
1108
1096
COPY_NODE_FIELD (startOffset );
1109
1097
COPY_NODE_FIELD (endOffset );
0 commit comments