summaryrefslogtreecommitdiff
path: root/src/backend/access/hash
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/hash
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/hash')
-rw-r--r--src/backend/access/hash/hash_xlog.c7
-rw-r--r--src/backend/access/hash/hashinsert.c12
2 files changed, 7 insertions, 12 deletions
diff --git a/src/backend/access/hash/hash_xlog.c b/src/backend/access/hash/hash_xlog.c
index d963a0c3702..2a0145f3c9b 100644
--- a/src/backend/access/hash/hash_xlog.c
+++ b/src/backend/access/hash/hash_xlog.c
@@ -137,8 +137,7 @@ hash_xlog_insert(XLogReaderState *record)
page = BufferGetPage(buffer);
- if (PageAddItem(page, (Item) datapos, datalen, xlrec->offnum,
- false, false) == InvalidOffsetNumber)
+ if (PageAddItem(page, datapos, datalen, xlrec->offnum, false, false) == InvalidOffsetNumber)
elog(PANIC, "hash_xlog_insert: failed to add item");
PageSetLSN(page, lsn);
@@ -557,7 +556,7 @@ hash_xlog_move_page_contents(XLogReaderState *record)
data += itemsz;
- l = PageAddItem(writepage, (Item) itup, itemsz, towrite[ninserted], false, false);
+ l = PageAddItem(writepage, itup, itemsz, towrite[ninserted], false, false);
if (l == InvalidOffsetNumber)
elog(ERROR, "hash_xlog_move_page_contents: failed to add item to hash index page, size %d bytes",
(int) itemsz);
@@ -689,7 +688,7 @@ hash_xlog_squeeze_page(XLogReaderState *record)
data += itemsz;
- l = PageAddItem(writepage, (Item) itup, itemsz, towrite[ninserted], false, false);
+ l = PageAddItem(writepage, itup, itemsz, towrite[ninserted], false, false);
if (l == InvalidOffsetNumber)
elog(ERROR, "hash_xlog_squeeze_page: failed to add item to hash index page, size %d bytes",
(int) itemsz);
diff --git a/src/backend/access/hash/hashinsert.c b/src/backend/access/hash/hashinsert.c
index 10de1580dc2..0f9f97f7e3d 100644
--- a/src/backend/access/hash/hashinsert.c
+++ b/src/backend/access/hash/hashinsert.c
@@ -310,10 +310,8 @@ _hash_pgaddtup(Relation rel, Buffer buf, Size itemsize, IndexTuple itup,
itup_off = _hash_binsearch(page, hashkey);
}
- if (PageAddItem(page, (Item) itup, itemsize, itup_off, false, false)
- == InvalidOffsetNumber)
- elog(ERROR, "failed to add index item to \"%s\"",
- RelationGetRelationName(rel));
+ if (PageAddItem(page, itup, itemsize, itup_off, false, false) == InvalidOffsetNumber)
+ elog(ERROR, "failed to add index item to \"%s\"", RelationGetRelationName(rel));
return itup_off;
}
@@ -352,10 +350,8 @@ _hash_pgaddmultitup(Relation rel, Buffer buf, IndexTuple *itups,
itup_offsets[i] = itup_off;
- if (PageAddItem(page, (Item) itups[i], itemsize, itup_off, false, false)
- == InvalidOffsetNumber)
- elog(ERROR, "failed to add index item to \"%s\"",
- RelationGetRelationName(rel));
+ if (PageAddItem(page, itups[i], itemsize, itup_off, false, false) == InvalidOffsetNumber)
+ elog(ERROR, "failed to add index item to \"%s\"", RelationGetRelationName(rel));
}
}