@@ -736,7 +736,7 @@ RumDataPageAddItem(Page page, void *data, OffsetNumber offset)
736
736
if (offset <= maxoff )
737
737
memmove (ptr + sizeof (PostingItem ),
738
738
ptr ,
739
- ((uint16_t )(maxoff - offset + 1 )) * sizeof (PostingItem ));
739
+ ((uint16 )(maxoff - offset + 1 )) * sizeof (PostingItem ));
740
740
}
741
741
memcpy (ptr , data , sizeof (PostingItem ));
742
742
RumPageGetOpaque (page )-> maxoff ++ ;
@@ -763,7 +763,7 @@ RumPageDeletePostingItem(Page page, OffsetNumber offset)
763
763
char * dstptr = RumDataPageGetItem (page , offset ),
764
764
* sourceptr = RumDataPageGetItem (page , offset + 1 );
765
765
766
- memmove (dstptr , sourceptr , sizeof (PostingItem ) * (uint16_t )(maxoff - offset ));
766
+ memmove (dstptr , sourceptr , sizeof (PostingItem ) * (uint16 )(maxoff - offset ));
767
767
}
768
768
769
769
RumPageGetOpaque (page )-> maxoff -- ;
@@ -853,7 +853,14 @@ dataPlaceToPage(RumBtree btree, Page page, OffsetNumber off)
853
853
ItemPointerData iptr = {{0 , 0 }, 0 };
854
854
RumItem copyItem ;
855
855
bool copyItemEmpty = true;
856
- char pageCopy [BLCKSZ ];
856
+ /*
857
+ * Must have pageCopy MAXALIGNed to use PG macros to access data in
858
+ * it. Should not rely on compiler alignment preferences to avoid
859
+ * pageCopy overflow related to PG in-memory page items alignment
860
+ * inside rumDataPageLeafRead() or elsewhere.
861
+ */
862
+ char pageCopyStorage [BLCKSZ + MAXIMUM_ALIGNOF ];
863
+ char * pageCopy = (char * ) MAXALIGN (pageCopyStorage );
857
864
int maxoff = RumPageGetOpaque (page )-> maxoff ;
858
865
int freespace ,
859
866
insertCount = 0 ;
@@ -1055,7 +1062,14 @@ dataSplitPageLeaf(RumBtree btree, Buffer lbuf, Buffer rbuf,
1055
1062
RumItem item ;
1056
1063
int totalCount = 0 ;
1057
1064
int maxItemIndex = btree -> curitem ;
1058
- static char lpageCopy [BLCKSZ ];
1065
+ /*
1066
+ * Must have lpageCopy MAXALIGNed to use PG macros to access data in
1067
+ * it. Should not rely on compiler alignment preferences to avoid
1068
+ * lpageCopy overflow related to PG in-memory page items alignment
1069
+ * inside rumDataPageLeafRead() etc.
1070
+ */
1071
+ static char lpageCopyStorage [BLCKSZ + MAXIMUM_ALIGNOF ];
1072
+ char * lpageCopy = (char * ) MAXALIGN (lpageCopyStorage );
1059
1073
1060
1074
memset (& item , 0 , sizeof (item ));
1061
1075
dataPrepareData (btree , newlPage , off );
@@ -1233,8 +1247,14 @@ dataSplitPageInternal(RumBtree btree, Buffer lbuf, Buffer rbuf,
1233
1247
OffsetNumber maxoff = RumPageGetOpaque (newlPage )-> maxoff ;
1234
1248
Size pageSize = PageGetPageSize (newlPage );
1235
1249
Size freeSpace ;
1236
-
1237
- static char vector [2 * BLCKSZ ];
1250
+ /*
1251
+ * Must have vector MAXALIGNed to use PG macros to access data in
1252
+ * it. Should not rely on compiler alignment preferences to avoid
1253
+ * vector overflow related to PG in-memory page items alignment
1254
+ * inside rumDataPageLeafRead() etc.
1255
+ */
1256
+ static char vectorStorage [2 * BLCKSZ + MAXIMUM_ALIGNOF ];
1257
+ char * vector = (char * ) MAXALIGN (vectorStorage );
1238
1258
1239
1259
RumInitPage (rPage , RumPageGetOpaque (newlPage )-> flags , pageSize );
1240
1260
freeSpace = RumDataPageGetFreeSpace (rPage );
@@ -1246,7 +1266,7 @@ dataSplitPageInternal(RumBtree btree, Buffer lbuf, Buffer rbuf,
1246
1266
Assert (!RumPageIsLeaf (newlPage ));
1247
1267
ptr = vector + (off - 1 ) * sizeofitem ;
1248
1268
if (maxoff + 1 - off != 0 )
1249
- memmove (ptr + sizeofitem , ptr , (uint16_t )(maxoff - off + 1 ) * sizeofitem );
1269
+ memmove (ptr + sizeofitem , ptr , (uint16 )(maxoff - off + 1 ) * sizeofitem );
1250
1270
memcpy (ptr , & (btree -> pitem ), sizeofitem );
1251
1271
1252
1272
maxoff ++ ;
@@ -1273,7 +1293,7 @@ dataSplitPageInternal(RumBtree btree, Buffer lbuf, Buffer rbuf,
1273
1293
1274
1294
ptr = RumDataPageGetItem (rPage , FirstOffsetNumber );
1275
1295
memcpy (ptr , vector + separator * sizeofitem ,
1276
- (uint16_t )(maxoff - separator ) * sizeofitem );
1296
+ (uint16 )(maxoff - separator ) * sizeofitem );
1277
1297
RumPageGetOpaque (rPage )-> maxoff = maxoff - separator ;
1278
1298
/* Adjust pd_lower */
1279
1299
((PageHeader ) rPage )-> pd_lower = (ptr +
0 commit comments