41 #define GIN_DATA (1 << 0)
42 #define GIN_LEAF (1 << 1)
43 #define GIN_DELETED (1 << 2)
44 #define GIN_META (1 << 3)
45 #define GIN_LIST (1 << 4)
46 #define GIN_LIST_FULLROW (1 << 5)
47 #define GIN_INCOMPLETE_SPLIT (1 << 6)
49 #define GIN_COMPRESSED (1 << 7)
52 #define GIN_METAPAGE_BLKNO (0)
53 #define GIN_ROOT_BLKNO (1)
103 #define GIN_CURRENT_VERSION 2
105 #define GinPageGetMeta(p) \
106 ((GinMetaPageData *) PageGetContents(p))
111 #define GinPageGetOpaque(page) ( (GinPageOpaque) PageGetSpecialPointer(page) )
113 #define GinPageIsLeaf(page) ( (GinPageGetOpaque(page)->flags & GIN_LEAF) != 0 )
114 #define GinPageSetLeaf(page) ( GinPageGetOpaque(page)->flags |= GIN_LEAF )
115 #define GinPageSetNonLeaf(page) ( GinPageGetOpaque(page)->flags &= ~GIN_LEAF )
116 #define GinPageIsData(page) ( (GinPageGetOpaque(page)->flags & GIN_DATA) != 0 )
117 #define GinPageSetData(page) ( GinPageGetOpaque(page)->flags |= GIN_DATA )
118 #define GinPageIsList(page) ( (GinPageGetOpaque(page)->flags & GIN_LIST) != 0 )
119 #define GinPageSetList(page) ( GinPageGetOpaque(page)->flags |= GIN_LIST )
120 #define GinPageHasFullRow(page) ( (GinPageGetOpaque(page)->flags & GIN_LIST_FULLROW) != 0 )
121 #define GinPageSetFullRow(page) ( GinPageGetOpaque(page)->flags |= GIN_LIST_FULLROW )
122 #define GinPageIsCompressed(page) ( (GinPageGetOpaque(page)->flags & GIN_COMPRESSED) != 0 )
123 #define GinPageSetCompressed(page) ( GinPageGetOpaque(page)->flags |= GIN_COMPRESSED )
125 #define GinPageIsDeleted(page) ( (GinPageGetOpaque(page)->flags & GIN_DELETED) != 0 )
126 #define GinPageSetDeleted(page) ( GinPageGetOpaque(page)->flags |= GIN_DELETED)
127 #define GinPageSetNonDeleted(page) ( GinPageGetOpaque(page)->flags &= ~GIN_DELETED)
128 #define GinPageIsIncompleteSplit(page) ( (GinPageGetOpaque(page)->flags & GIN_INCOMPLETE_SPLIT) != 0 )
130 #define GinPageRightMost(page) ( GinPageGetOpaque(page)->rightlink == InvalidBlockNumber)
136 #define GinPageGetDeleteXid(page) ( ((PageHeader) (page))->pd_prune_xid )
137 #define GinPageSetDeleteXid(page, xid) ( ((PageHeader) (page))->pd_prune_xid = xid)
144 #define GinItemPointerGetBlockNumber(pointer) \
145 (ItemPointerGetBlockNumberNoCheck(pointer))
147 #define GinItemPointerGetOffsetNumber(pointer) \
148 (ItemPointerGetOffsetNumberNoCheck(pointer))
150 #define GinItemPointerSetBlockNumber(pointer, blkno) \
151 (ItemPointerSetBlockNumber((pointer), (blkno)))
153 #define GinItemPointerSetOffsetNumber(pointer, offnum) \
154 (ItemPointerSetOffsetNumber((pointer), (offnum)))
167 #define ItemPointerSetMin(p) \
168 ItemPointerSet((p), (BlockNumber)0, (OffsetNumber)0)
169 #define ItemPointerIsMin(p) \
170 (GinItemPointerGetOffsetNumber(p) == (OffsetNumber)0 && \
171 GinItemPointerGetBlockNumber(p) == (BlockNumber)0)
172 #define ItemPointerSetMax(p) \
173 ItemPointerSet((p), InvalidBlockNumber, (OffsetNumber)0xffff)
174 #define ItemPointerSetLossyPage(p, b) \
175 ItemPointerSet((p), (b), (OffsetNumber)0xffff)
176 #define ItemPointerIsLossyPage(p) \
177 (GinItemPointerGetOffsetNumber(p) == (OffsetNumber)0xffff && \
178 GinItemPointerGetBlockNumber(p) != InvalidBlockNumber)
190 #define PostingItemGetBlockNumber(pointer) \
191 BlockIdGetBlockNumber(&(pointer)->child_blkno)
193 #define PostingItemSetBlockNumber(pointer, blockNumber) \
194 BlockIdSet(&((pointer)->child_blkno), (blockNumber))
209 #define GIN_CAT_NORM_KEY 0
210 #define GIN_CAT_NULL_KEY 1
211 #define GIN_CAT_EMPTY_ITEM 2
212 #define GIN_CAT_NULL_ITEM 3
213 #define GIN_CAT_EMPTY_QUERY (-1)
218 #define GinCategoryOffset(itup,ginstate) \
219 (IndexInfoFindDataOffset((itup)->t_info) + \
220 ((ginstate)->oneCol ? 0 : sizeof(int16)))
221 #define GinGetNullCategory(itup,ginstate) \
222 (*((GinNullCategory *) ((char*)(itup) + GinCategoryOffset(itup,ginstate))))
223 #define GinSetNullCategory(itup,ginstate,c) \
224 (*((GinNullCategory *) ((char*)(itup) + GinCategoryOffset(itup,ginstate))) = (c))
229 #define GinGetNPosting(itup) GinItemPointerGetOffsetNumber(&(itup)->t_tid)
230 #define GinSetNPosting(itup,n) ItemPointerSetOffsetNumber(&(itup)->t_tid,n)
231 #define GIN_TREE_POSTING ((OffsetNumber)0xffff)
232 #define GinIsPostingTree(itup) (GinGetNPosting(itup) == GIN_TREE_POSTING)
233 #define GinSetPostingTree(itup, blkno) ( GinSetNPosting((itup),GIN_TREE_POSTING), ItemPointerSetBlockNumber(&(itup)->t_tid, blkno) )
234 #define GinGetPostingTree(itup) GinItemPointerGetBlockNumber(&(itup)->t_tid)
236 #define GIN_ITUP_COMPRESSED (1U << 31)
237 #define GinGetPostingOffset(itup) (GinItemPointerGetBlockNumber(&(itup)->t_tid) & (~GIN_ITUP_COMPRESSED))
238 #define GinSetPostingOffset(itup,n) ItemPointerSetBlockNumber(&(itup)->t_tid,(n)|GIN_ITUP_COMPRESSED)
239 #define GinGetPosting(itup) ((Pointer) ((char*)(itup) + GinGetPostingOffset(itup)))
240 #define GinItupIsCompressed(itup) ((GinItemPointerGetBlockNumber(&(itup)->t_tid) & GIN_ITUP_COMPRESSED) != 0)
249 #define GinMaxItemSize \
250 Min(INDEX_SIZE_MASK, \
251 MAXALIGN_DOWN(((BLCKSZ - \
252 MAXALIGN(SizeOfPageHeaderData + 3 * sizeof(ItemIdData)) - \
253 MAXALIGN(sizeof(GinPageOpaqueData))) / 3)))
258 #define GinGetDownlink(itup) GinItemPointerGetBlockNumber(&(itup)->t_tid)
259 #define GinSetDownlink(itup,blkno) ItemPointerSet(&(itup)->t_tid, blkno, InvalidOffsetNumber)
279 #define GinDataLeafPageGetPostingList(page) \
280 (GinPostingList *) ((PageGetContents(page) + MAXALIGN(sizeof(ItemPointerData))))
281 #define GinDataLeafPageGetPostingListSize(page) \
282 (((PageHeader) page)->pd_lower - MAXALIGN(SizeOfPageHeaderData) - MAXALIGN(sizeof(ItemPointerData)))
284 #define GinDataLeafPageIsEmpty(page) \
285 (GinPageIsCompressed(page) ? (GinDataLeafPageGetPostingListSize(page) == 0) : (GinPageGetOpaque(page)->maxoff < FirstOffsetNumber))
287 #define GinDataLeafPageGetFreeSpace(page) PageGetExactFreeSpace(page)
289 #define GinDataPageGetRightBound(page) ((ItemPointer) PageGetContents(page))
296 #define GinDataPageGetData(page) \
297 (PageGetContents(page) + MAXALIGN(sizeof(ItemPointerData)))
299 #define GinDataPageGetPostingItem(page, i) \
300 ((PostingItem *) (GinDataPageGetData(page) + ((i)-1) * sizeof(PostingItem)))
310 #define GinDataPageSetDataSize(page, size) \
312 Assert(size <= GinDataPageMaxDataSize); \
313 ((PageHeader) page)->pd_lower = (size) + MAXALIGN(SizeOfPageHeaderData) + MAXALIGN(sizeof(ItemPointerData)); \
316 #define GinNonLeafDataPageGetFreeSpace(page) \
317 (GinDataPageMaxDataSize - \
318 GinPageGetOpaque(page)->maxoff * sizeof(PostingItem))
320 #define GinDataPageMaxDataSize \
321 (BLCKSZ - MAXALIGN(SizeOfPageHeaderData) \
322 - MAXALIGN(sizeof(ItemPointerData)) \
323 - MAXALIGN(sizeof(GinPageOpaqueData)))
328 #define GinListPageSize \
329 ( BLCKSZ - SizeOfPageHeaderData - MAXALIGN(sizeof(GinPageOpaqueData)) )
343 #define SizeOfGinPostingList(plist) (offsetof(GinPostingList, bytes) + SHORTALIGN((plist)->nbytes) )
344 #define GinNextPostingListSegment(cur) ((GinPostingList *) (((char *) (cur)) + SizeOfGinPostingList((cur))))
#define FLEXIBLE_ARRAY_MEMBER
GinPageOpaqueData * GinPageOpaque
struct GinMetaPageData GinMetaPageData
bool GinPageIsRecyclable(Page page)
struct GinPageOpaqueData GinPageOpaqueData
signed char GinNullCategory
BlockNumber nPendingPages