/* * Fills new root by rightest values from child. * Also called from ginxlog, should not use btree */ void ginEntryFillRoot(GinBtree btree, Page root, BlockNumber lblkno, Page lpage, BlockNumber rblkno, Page rpage) { IndexTuple itup; itup = GinFormInteriorTuple(getRightMostTuple(lpage), lpage, lblkno); if (PageAddItem(root, (Item) itup, IndexTupleSize(itup), InvalidOffsetNumber, false, false) == InvalidOffsetNumber) elog(ERROR, "failed to add item to index root page"); pfree(itup); itup = GinFormInteriorTuple(getRightMostTuple(rpage), rpage, rblkno); if (PageAddItem(root, (Item) itup, IndexTupleSize(itup), InvalidOffsetNumber, false, false) == InvalidOffsetNumber) elog(ERROR, "failed to add item to index root page"); pfree(itup); }
/* * return newly allocated rightmost tuple */ IndexTuple rumPageGetLinkItup(RumBtree btree, Buffer buf, Page page) { IndexTuple itup, nitup; itup = getRightMostTuple(page); nitup = RumFormInteriorTuple(btree, itup, page, BufferGetBlockNumber(buf)); return nitup; }
/* * return newly allocate rightmost tuple */ IndexTuple ginPageGetLinkItup(Buffer buf) { IndexTuple itup, nitup; Page page = BufferGetPage(buf); itup = getRightMostTuple(page); nitup = copyIndexTuple(itup, page); ItemPointerSet(&nitup->t_tid, BufferGetBlockNumber(buf), InvalidOffsetNumber); return nitup; }
/* * Construct insertion payload for inserting the downlink for given buffer. */ static void * entryPrepareDownlink(GinBtree btree, Buffer lbuf) { GinBtreeEntryInsertData *insertData; Page lpage = BufferGetPage(lbuf); BlockNumber lblkno = BufferGetBlockNumber(lbuf); IndexTuple itup; itup = getRightMostTuple(lpage); insertData = palloc(sizeof(GinBtreeEntryInsertData)); insertData->entry = GinFormInteriorTuple(itup, lpage, lblkno); insertData->isDelete = false; return insertData; }
static bool entryIsMoveRight(GinBtree btree, Page page) { IndexTuple itup; if (GinPageRightMost(page)) return FALSE; itup = getRightMostTuple(page); if (compareAttEntries(btree->ginstate, btree->entryAttnum, btree->entryValue, gintuple_get_attrnum(btree->ginstate, itup), gin_index_getattr(btree->ginstate, itup)) > 0) return TRUE; return FALSE; }
static bool entryIsMoveRight(GinBtree btree, Page page) { IndexTuple itup; OffsetNumber attnum; Datum key; GinNullCategory category; if (GinPageRightMost(page)) return FALSE; itup = getRightMostTuple(page); attnum = gintuple_get_attrnum(btree->ginstate, itup); key = gintuple_get_key(btree->ginstate, itup, &category); if (ginCompareAttEntries(btree->ginstate, btree->entryAttnum, btree->entryKey, btree->entryCategory, attnum, key, category) > 0) return TRUE; return FALSE; }
static bool entryIsMoveRight(RumBtree btree, Page page) { IndexTuple itup; OffsetNumber attnum; Datum key; RumNullCategory category; if (RumPageRightMost(page)) return false; itup = getRightMostTuple(page); attnum = rumtuple_get_attrnum(btree->rumstate, itup); key = rumtuple_get_key(btree->rumstate, itup, &category); if (rumCompareAttEntries(btree->rumstate, btree->entryAttnum, btree->entryKey, btree->entryCategory, attnum, key, category) > 0) return true; return false; }