Commit fcf3b691 authored by Peter Geoghegan's avatar Peter Geoghegan

Rename nbtree tuple macros.

Rename two function-style macros, removing the word "inner".  This makes
things more consistent.
parent 5d43c3c5
...@@ -758,7 +758,7 @@ bt_check_level_from_leftmost(BtreeCheckState *state, BtreeLevel level) ...@@ -758,7 +758,7 @@ bt_check_level_from_leftmost(BtreeCheckState *state, BtreeLevel level)
state->target, state->target,
P_FIRSTDATAKEY(opaque)); P_FIRSTDATAKEY(opaque));
itup = (IndexTuple) PageGetItem(state->target, itemid); itup = (IndexTuple) PageGetItem(state->target, itemid);
nextleveldown.leftmost = BTreeInnerTupleGetDownLink(itup); nextleveldown.leftmost = BTreeTupleGetDownLink(itup);
nextleveldown.level = opaque->btpo.level - 1; nextleveldown.level = opaque->btpo.level - 1;
} }
else else
...@@ -978,7 +978,7 @@ bt_target_page_check(BtreeCheckState *state) ...@@ -978,7 +978,7 @@ bt_target_page_check(BtreeCheckState *state)
/* Fingerprint downlink blocks in heapallindexed + readonly case */ /* Fingerprint downlink blocks in heapallindexed + readonly case */
if (state->heapallindexed && state->readonly && !P_ISLEAF(topaque)) if (state->heapallindexed && state->readonly && !P_ISLEAF(topaque))
{ {
BlockNumber childblock = BTreeInnerTupleGetDownLink(itup); BlockNumber childblock = BTreeTupleGetDownLink(itup);
bloom_add_element(state->downlinkfilter, bloom_add_element(state->downlinkfilter,
(unsigned char *) &childblock, (unsigned char *) &childblock,
...@@ -1267,7 +1267,7 @@ bt_target_page_check(BtreeCheckState *state) ...@@ -1267,7 +1267,7 @@ bt_target_page_check(BtreeCheckState *state)
*/ */
if (!P_ISLEAF(topaque) && state->readonly) if (!P_ISLEAF(topaque) && state->readonly)
{ {
BlockNumber childblock = BTreeInnerTupleGetDownLink(itup); BlockNumber childblock = BTreeTupleGetDownLink(itup);
bt_downlink_check(state, skey, childblock); bt_downlink_check(state, skey, childblock);
} }
...@@ -1746,7 +1746,7 @@ bt_downlink_missing_check(BtreeCheckState *state) ...@@ -1746,7 +1746,7 @@ bt_downlink_missing_check(BtreeCheckState *state)
itemid = PageGetItemIdCareful(state, state->targetblock, state->target, itemid = PageGetItemIdCareful(state, state->targetblock, state->target,
P_FIRSTDATAKEY(topaque)); P_FIRSTDATAKEY(topaque));
itup = (IndexTuple) PageGetItem(state->target, itemid); itup = (IndexTuple) PageGetItem(state->target, itemid);
childblk = BTreeInnerTupleGetDownLink(itup); childblk = BTreeTupleGetDownLink(itup);
for (;;) for (;;)
{ {
CHECK_FOR_INTERRUPTS(); CHECK_FOR_INTERRUPTS();
...@@ -1771,7 +1771,7 @@ bt_downlink_missing_check(BtreeCheckState *state) ...@@ -1771,7 +1771,7 @@ bt_downlink_missing_check(BtreeCheckState *state)
itemid = PageGetItemIdCareful(state, childblk, child, itemid = PageGetItemIdCareful(state, childblk, child,
P_FIRSTDATAKEY(copaque)); P_FIRSTDATAKEY(copaque));
itup = (IndexTuple) PageGetItem(child, itemid); itup = (IndexTuple) PageGetItem(child, itemid);
childblk = BTreeInnerTupleGetDownLink(itup); childblk = BTreeTupleGetDownLink(itup);
/* Be slightly more pro-active in freeing this memory, just in case */ /* Be slightly more pro-active in freeing this memory, just in case */
pfree(child); pfree(child);
} }
......
...@@ -1807,7 +1807,7 @@ _bt_insert_parent(Relation rel, ...@@ -1807,7 +1807,7 @@ _bt_insert_parent(Relation rel,
/* form an index tuple that points at the new right page */ /* form an index tuple that points at the new right page */
new_item = CopyIndexTuple(ritem); new_item = CopyIndexTuple(ritem);
BTreeInnerTupleSetDownLink(new_item, rbknum); BTreeTupleSetDownLink(new_item, rbknum);
/* /*
* Re-find and write lock the parent of buf. * Re-find and write lock the parent of buf.
...@@ -1991,7 +1991,7 @@ _bt_getstackbuf(Relation rel, BTStack stack, BlockNumber child) ...@@ -1991,7 +1991,7 @@ _bt_getstackbuf(Relation rel, BTStack stack, BlockNumber child)
itemid = PageGetItemId(page, offnum); itemid = PageGetItemId(page, offnum);
item = (IndexTuple) PageGetItem(page, itemid); item = (IndexTuple) PageGetItem(page, itemid);
if (BTreeInnerTupleGetDownLink(item) == child) if (BTreeTupleGetDownLink(item) == child)
{ {
/* Return accurate pointer to where link is now */ /* Return accurate pointer to where link is now */
stack->bts_blkno = blkno; stack->bts_blkno = blkno;
...@@ -2007,7 +2007,7 @@ _bt_getstackbuf(Relation rel, BTStack stack, BlockNumber child) ...@@ -2007,7 +2007,7 @@ _bt_getstackbuf(Relation rel, BTStack stack, BlockNumber child)
itemid = PageGetItemId(page, offnum); itemid = PageGetItemId(page, offnum);
item = (IndexTuple) PageGetItem(page, itemid); item = (IndexTuple) PageGetItem(page, itemid);
if (BTreeInnerTupleGetDownLink(item) == child) if (BTreeTupleGetDownLink(item) == child)
{ {
/* Return accurate pointer to where link is now */ /* Return accurate pointer to where link is now */
stack->bts_blkno = blkno; stack->bts_blkno = blkno;
...@@ -2096,7 +2096,7 @@ _bt_newroot(Relation rel, Buffer lbuf, Buffer rbuf) ...@@ -2096,7 +2096,7 @@ _bt_newroot(Relation rel, Buffer lbuf, Buffer rbuf)
left_item_sz = sizeof(IndexTupleData); left_item_sz = sizeof(IndexTupleData);
left_item = (IndexTuple) palloc(left_item_sz); left_item = (IndexTuple) palloc(left_item_sz);
left_item->t_info = left_item_sz; left_item->t_info = left_item_sz;
BTreeInnerTupleSetDownLink(left_item, lbkno); BTreeTupleSetDownLink(left_item, lbkno);
BTreeTupleSetNAtts(left_item, 0); BTreeTupleSetNAtts(left_item, 0);
/* /*
...@@ -2107,7 +2107,7 @@ _bt_newroot(Relation rel, Buffer lbuf, Buffer rbuf) ...@@ -2107,7 +2107,7 @@ _bt_newroot(Relation rel, Buffer lbuf, Buffer rbuf)
right_item_sz = ItemIdGetLength(itemid); right_item_sz = ItemIdGetLength(itemid);
item = (IndexTuple) PageGetItem(lpage, itemid); item = (IndexTuple) PageGetItem(lpage, itemid);
right_item = CopyIndexTuple(item); right_item = CopyIndexTuple(item);
BTreeInnerTupleSetDownLink(right_item, rbkno); BTreeTupleSetDownLink(right_item, rbkno);
/* NO EREPORT(ERROR) from here till newroot op is logged */ /* NO EREPORT(ERROR) from here till newroot op is logged */
START_CRIT_SECTION(); START_CRIT_SECTION();
......
...@@ -1605,17 +1605,17 @@ _bt_mark_page_halfdead(Relation rel, Buffer leafbuf, BTStack stack) ...@@ -1605,17 +1605,17 @@ _bt_mark_page_halfdead(Relation rel, Buffer leafbuf, BTStack stack)
#ifdef USE_ASSERT_CHECKING #ifdef USE_ASSERT_CHECKING
itemid = PageGetItemId(page, topoff); itemid = PageGetItemId(page, topoff);
itup = (IndexTuple) PageGetItem(page, itemid); itup = (IndexTuple) PageGetItem(page, itemid);
Assert(BTreeInnerTupleGetDownLink(itup) == target); Assert(BTreeTupleGetDownLink(itup) == target);
#endif #endif
nextoffset = OffsetNumberNext(topoff); nextoffset = OffsetNumberNext(topoff);
itemid = PageGetItemId(page, nextoffset); itemid = PageGetItemId(page, nextoffset);
itup = (IndexTuple) PageGetItem(page, itemid); itup = (IndexTuple) PageGetItem(page, itemid);
if (BTreeInnerTupleGetDownLink(itup) != rightsib) if (BTreeTupleGetDownLink(itup) != rightsib)
ereport(ERROR, ereport(ERROR,
(errcode(ERRCODE_INDEX_CORRUPTED), (errcode(ERRCODE_INDEX_CORRUPTED),
errmsg_internal("right sibling %u of block %u is not next child %u of block %u in index \"%s\"", errmsg_internal("right sibling %u of block %u is not next child %u of block %u in index \"%s\"",
rightsib, target, BTreeInnerTupleGetDownLink(itup), rightsib, target, BTreeTupleGetDownLink(itup),
BufferGetBlockNumber(topparent), RelationGetRelationName(rel)))); BufferGetBlockNumber(topparent), RelationGetRelationName(rel))));
/* /*
...@@ -1638,7 +1638,7 @@ _bt_mark_page_halfdead(Relation rel, Buffer leafbuf, BTStack stack) ...@@ -1638,7 +1638,7 @@ _bt_mark_page_halfdead(Relation rel, Buffer leafbuf, BTStack stack)
itemid = PageGetItemId(page, topoff); itemid = PageGetItemId(page, topoff);
itup = (IndexTuple) PageGetItem(page, itemid); itup = (IndexTuple) PageGetItem(page, itemid);
BTreeInnerTupleSetDownLink(itup, rightsib); BTreeTupleSetDownLink(itup, rightsib);
nextoffset = OffsetNumberNext(topoff); nextoffset = OffsetNumberNext(topoff);
PageIndexTupleDelete(page, nextoffset); PageIndexTupleDelete(page, nextoffset);
...@@ -1902,7 +1902,7 @@ _bt_unlink_halfdead_page(Relation rel, Buffer leafbuf, bool *rightsib_empty) ...@@ -1902,7 +1902,7 @@ _bt_unlink_halfdead_page(Relation rel, Buffer leafbuf, bool *rightsib_empty)
/* remember the next non-leaf child down in the branch. */ /* remember the next non-leaf child down in the branch. */
itemid = PageGetItemId(page, P_FIRSTDATAKEY(opaque)); itemid = PageGetItemId(page, P_FIRSTDATAKEY(opaque));
nextchild = BTreeInnerTupleGetDownLink((IndexTuple) PageGetItem(page, itemid)); nextchild = BTreeTupleGetDownLink((IndexTuple) PageGetItem(page, itemid));
if (nextchild == leafblkno) if (nextchild == leafblkno)
nextchild = InvalidBlockNumber; nextchild = InvalidBlockNumber;
} }
......
...@@ -142,7 +142,7 @@ _bt_search(Relation rel, BTScanInsert key, Buffer *bufP, int access, ...@@ -142,7 +142,7 @@ _bt_search(Relation rel, BTScanInsert key, Buffer *bufP, int access,
offnum = _bt_binsrch(rel, key, *bufP); offnum = _bt_binsrch(rel, key, *bufP);
itemid = PageGetItemId(page, offnum); itemid = PageGetItemId(page, offnum);
itup = (IndexTuple) PageGetItem(page, itemid); itup = (IndexTuple) PageGetItem(page, itemid);
blkno = BTreeInnerTupleGetDownLink(itup); blkno = BTreeTupleGetDownLink(itup);
par_blkno = BufferGetBlockNumber(*bufP); par_blkno = BufferGetBlockNumber(*bufP);
/* /*
...@@ -2120,7 +2120,7 @@ _bt_get_endpoint(Relation rel, uint32 level, bool rightmost, ...@@ -2120,7 +2120,7 @@ _bt_get_endpoint(Relation rel, uint32 level, bool rightmost,
offnum = P_FIRSTDATAKEY(opaque); offnum = P_FIRSTDATAKEY(opaque);
itup = (IndexTuple) PageGetItem(page, PageGetItemId(page, offnum)); itup = (IndexTuple) PageGetItem(page, PageGetItemId(page, offnum));
blkno = BTreeInnerTupleGetDownLink(itup); blkno = BTreeTupleGetDownLink(itup);
buf = _bt_relandgetbuf(rel, buf, blkno, BT_READ); buf = _bt_relandgetbuf(rel, buf, blkno, BT_READ);
page = BufferGetPage(buf); page = BufferGetPage(buf);
......
...@@ -982,7 +982,7 @@ _bt_buildadd(BTWriteState *wstate, BTPageState *state, IndexTuple itup) ...@@ -982,7 +982,7 @@ _bt_buildadd(BTWriteState *wstate, BTPageState *state, IndexTuple itup)
P_LEFTMOST((BTPageOpaque) PageGetSpecialPointer(opage))); P_LEFTMOST((BTPageOpaque) PageGetSpecialPointer(opage)));
Assert(BTreeTupleGetNAtts(state->btps_lowkey, wstate->index) == 0 || Assert(BTreeTupleGetNAtts(state->btps_lowkey, wstate->index) == 0 ||
!P_LEFTMOST((BTPageOpaque) PageGetSpecialPointer(opage))); !P_LEFTMOST((BTPageOpaque) PageGetSpecialPointer(opage)));
BTreeInnerTupleSetDownLink(state->btps_lowkey, oblkno); BTreeTupleSetDownLink(state->btps_lowkey, oblkno);
_bt_buildadd(wstate, state->btps_next, state->btps_lowkey); _bt_buildadd(wstate, state->btps_next, state->btps_lowkey);
pfree(state->btps_lowkey); pfree(state->btps_lowkey);
...@@ -1089,7 +1089,7 @@ _bt_uppershutdown(BTWriteState *wstate, BTPageState *state) ...@@ -1089,7 +1089,7 @@ _bt_uppershutdown(BTWriteState *wstate, BTPageState *state)
P_LEFTMOST(opaque)); P_LEFTMOST(opaque));
Assert(BTreeTupleGetNAtts(s->btps_lowkey, wstate->index) == 0 || Assert(BTreeTupleGetNAtts(s->btps_lowkey, wstate->index) == 0 ||
!P_LEFTMOST(opaque)); !P_LEFTMOST(opaque));
BTreeInnerTupleSetDownLink(s->btps_lowkey, blkno); BTreeTupleSetDownLink(s->btps_lowkey, blkno);
_bt_buildadd(wstate, s->btps_next, s->btps_lowkey); _bt_buildadd(wstate, s->btps_next, s->btps_lowkey);
pfree(s->btps_lowkey); pfree(s->btps_lowkey);
s->btps_lowkey = NULL; s->btps_lowkey = NULL;
......
...@@ -597,11 +597,11 @@ btree_xlog_mark_page_halfdead(uint8 info, XLogReaderState *record) ...@@ -597,11 +597,11 @@ btree_xlog_mark_page_halfdead(uint8 info, XLogReaderState *record)
nextoffset = OffsetNumberNext(poffset); nextoffset = OffsetNumberNext(poffset);
itemid = PageGetItemId(page, nextoffset); itemid = PageGetItemId(page, nextoffset);
itup = (IndexTuple) PageGetItem(page, itemid); itup = (IndexTuple) PageGetItem(page, itemid);
rightsib = BTreeInnerTupleGetDownLink(itup); rightsib = BTreeTupleGetDownLink(itup);
itemid = PageGetItemId(page, poffset); itemid = PageGetItemId(page, poffset);
itup = (IndexTuple) PageGetItem(page, itemid); itup = (IndexTuple) PageGetItem(page, itemid);
BTreeInnerTupleSetDownLink(itup, rightsib); BTreeTupleSetDownLink(itup, rightsib);
nextoffset = OffsetNumberNext(poffset); nextoffset = OffsetNumberNext(poffset);
PageIndexTupleDelete(page, nextoffset); PageIndexTupleDelete(page, nextoffset);
......
...@@ -298,10 +298,10 @@ typedef struct BTMetaPageData ...@@ -298,10 +298,10 @@ typedef struct BTMetaPageData
#define BT_N_KEYS_OFFSET_MASK 0x0FFF #define BT_N_KEYS_OFFSET_MASK 0x0FFF
#define BT_HEAP_TID_ATTR 0x1000 #define BT_HEAP_TID_ATTR 0x1000
/* Get/set downlink block number */ /* Get/set downlink block number in pivot tuple */
#define BTreeInnerTupleGetDownLink(itup) \ #define BTreeTupleGetDownLink(itup) \
ItemPointerGetBlockNumberNoCheck(&((itup)->t_tid)) ItemPointerGetBlockNumberNoCheck(&((itup)->t_tid))
#define BTreeInnerTupleSetDownLink(itup, blkno) \ #define BTreeTupleSetDownLink(itup, blkno) \
ItemPointerSetBlockNumber(&((itup)->t_tid), (blkno)) ItemPointerSetBlockNumber(&((itup)->t_tid), (blkno))
/* /*
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment