summaryrefslogtreecommitdiff
path: root/src/backend/access/nbtree/nbtinsert.c
diff options
context:
space:
mode:
authorPeter Eisentraut <peter@eisentraut.org>2025-10-27 09:54:16 +0100
committerPeter Eisentraut <peter@eisentraut.org>2025-10-27 09:55:59 +0100
commit76acf4b722faa2a552f62034b793c2797909f91b (patch)
tree43ddf923e05c8cfa56097d5634f5f2d4c1d8015c /src/backend/access/nbtree/nbtinsert.c
parent64d2b0968ea494cb11900ffb7681b5784e4112b9 (diff)
Remove Item type
This type is just char * underneath, it provides no real value, no type safety, and just makes the code one level more mysterious. It is more idiomatic to refer to blobs of memory by a combination of void * and size_t, so change it to that. Also, since this type hides the pointerness, we can't apply qualifiers to what is pointed to, which requires some unconstify nonsense. This change allows fixing that. Extension code that uses the Item type can change its code to use void * to be backward compatible. Reviewed-by: Nathan Bossart <nathandbossart@gmail.com> Reviewed-by: Peter Geoghegan <pg@bowt.ie> Discussion: https://www.postgresql.org/message-id/flat/c75cccf5-5709-407b-a36a-2ae6570be766@eisentraut.org
Diffstat (limited to 'src/backend/access/nbtree/nbtinsert.c')
-rw-r--r--src/backend/access/nbtree/nbtinsert.c18
1 files changed, 6 insertions, 12 deletions
diff --git a/src/backend/access/nbtree/nbtinsert.c b/src/backend/access/nbtree/nbtinsert.c
index 85d97a970ac..42727e80c30 100644
--- a/src/backend/access/nbtree/nbtinsert.c
+++ b/src/backend/access/nbtree/nbtinsert.c
@@ -1278,8 +1278,7 @@ _bt_insertonpg(Relation rel,
if (postingoff != 0)
memcpy(oposting, nposting, MAXALIGN(IndexTupleSize(nposting)));
- if (PageAddItem(page, (Item) itup, itemsz, newitemoff, false,
- false) == InvalidOffsetNumber)
+ if (PageAddItem(page, itup, itemsz, newitemoff, false, false) == InvalidOffsetNumber)
elog(PANIC, "failed to add new item to block %u in index \"%s\"",
BufferGetBlockNumber(buf), RelationGetRelationName(rel));
@@ -1700,8 +1699,7 @@ _bt_split(Relation rel, Relation heaprel, BTScanInsert itup_key, Buffer buf,
Assert(BTreeTupleGetNAtts(lefthighkey, rel) <=
IndexRelationGetNumberOfKeyAttributes(rel));
Assert(itemsz == MAXALIGN(IndexTupleSize(lefthighkey)));
- if (PageAddItem(leftpage, (Item) lefthighkey, itemsz, afterleftoff, false,
- false) == InvalidOffsetNumber)
+ if (PageAddItem(leftpage, lefthighkey, itemsz, afterleftoff, false, false) == InvalidOffsetNumber)
elog(ERROR, "failed to add high key to the left sibling"
" while splitting block %u of index \"%s\"",
origpagenumber, RelationGetRelationName(rel));
@@ -1771,8 +1769,7 @@ _bt_split(Relation rel, Relation heaprel, BTScanInsert itup_key, Buffer buf,
Assert(BTreeTupleGetNAtts(righthighkey, rel) > 0);
Assert(BTreeTupleGetNAtts(righthighkey, rel) <=
IndexRelationGetNumberOfKeyAttributes(rel));
- if (PageAddItem(rightpage, (Item) righthighkey, itemsz, afterrightoff,
- false, false) == InvalidOffsetNumber)
+ if (PageAddItem(rightpage, righthighkey, itemsz, afterrightoff, false, false) == InvalidOffsetNumber)
{
elog(ERROR, "failed to add high key to the right sibling"
" while splitting block %u of index \"%s\"",
@@ -2537,8 +2534,7 @@ _bt_newlevel(Relation rel, Relation heaprel, Buffer lbuf, Buffer rbuf)
* benefit of _bt_restore_page().
*/
Assert(BTreeTupleGetNAtts(left_item, rel) == 0);
- if (PageAddItem(rootpage, (Item) left_item, left_item_sz, P_HIKEY,
- false, false) == InvalidOffsetNumber)
+ if (PageAddItem(rootpage, left_item, left_item_sz, P_HIKEY, false, false) == InvalidOffsetNumber)
elog(PANIC, "failed to add leftkey to new root page"
" while splitting block %u of index \"%s\"",
BufferGetBlockNumber(lbuf), RelationGetRelationName(rel));
@@ -2549,8 +2545,7 @@ _bt_newlevel(Relation rel, Relation heaprel, Buffer lbuf, Buffer rbuf)
Assert(BTreeTupleGetNAtts(right_item, rel) > 0);
Assert(BTreeTupleGetNAtts(right_item, rel) <=
IndexRelationGetNumberOfKeyAttributes(rel));
- if (PageAddItem(rootpage, (Item) right_item, right_item_sz, P_FIRSTKEY,
- false, false) == InvalidOffsetNumber)
+ if (PageAddItem(rootpage, right_item, right_item_sz, P_FIRSTKEY, false, false) == InvalidOffsetNumber)
elog(PANIC, "failed to add rightkey to new root page"
" while splitting block %u of index \"%s\"",
BufferGetBlockNumber(lbuf), RelationGetRelationName(rel));
@@ -2654,8 +2649,7 @@ _bt_pgaddtup(Page page,
itemsize = sizeof(IndexTupleData);
}
- if (unlikely(PageAddItem(page, (Item) itup, itemsize, itup_off, false,
- false) == InvalidOffsetNumber))
+ if (unlikely(PageAddItem(page, itup, itemsize, itup_off, false, false) == InvalidOffsetNumber))
return false;
return true;