diff --git a/src/backend/access/gin/gininsert.c b/src/backend/access/gin/gininsert.c index 16abb76c001..e964f860ab7 100644 --- a/src/backend/access/gin/gininsert.c +++ b/src/backend/access/gin/gininsert.c @@ -2250,7 +2250,7 @@ _gin_build_tuple(OffsetNumber attrnum, unsigned char category, char *ptr; Size tuplen; - int keylen; + Size keylen; dlist_mutable_iter iter; dlist_head segments; diff --git a/src/include/access/gin_tuple.h b/src/include/access/gin_tuple.h index 7bde05e2de4..d2c7b50d1de 100644 --- a/src/include/access/gin_tuple.h +++ b/src/include/access/gin_tuple.h @@ -23,12 +23,17 @@ typedef struct GinTuple { int tuplen; /* length of the whole tuple */ OffsetNumber attrnum; /* attnum of index key */ - uint16 keylen; /* bytes in data for key value */ + Size keylen; /* bytes in data for key value */ int16 typlen; /* typlen for key */ bool typbyval; /* typbyval for key */ signed char category; /* category: normal or NULL? */ int nitems; /* number of TIDs in the data */ - char data[FLEXIBLE_ARRAY_MEMBER]; + + /* + * The key value is accessed in place, so it must be aligned well enough + * for any key type. + */ + char alignas(MAXIMUM_ALIGNOF) data[FLEXIBLE_ARRAY_MEMBER]; } GinTuple; static inline ItemPointer