Mark ItemPointer arguments as const thoughoutly
Hi Hacker,
This is a follow up 991295f. I searched over the src/ and make all
ItemPointer arguments as const as much as possible.
I made clean build and no waring found. And "make check" also passes. I
will create a patch on CF to see if CI passes.
Best regards,
Chao Li (Evan)
---------------------
HighGo Software Co., Ltd.
https://www.highgo.com/
Attachments:
v1-0001-Mark-ItemPointer-arguments-as-const-thoughoutly.patchapplication/octet-stream; name=v1-0001-Mark-ItemPointer-arguments-as-const-thoughoutly.patchDownload
From 712f67e1c473bb9c2a1792419a316648201c12a6 Mon Sep 17 00:00:00 2001
From: "Chao Li (Evan)" <lic@highgo.com>
Date: Wed, 10 Sep 2025 10:18:30 +0800
Subject: [PATCH v1] Mark ItemPointer arguments as const thoughoutly
This is a follow up 991295f. I searched over the src/ and make all
ItemPointer arguments as const as much as possible.
Author: Chao Li <li.evan.chao@gmail.com>
---
src/backend/access/common/tidstore.c | 2 +-
src/backend/access/hash/hashsort.c | 2 +-
src/backend/access/heap/heapam.c | 36 +++++++++++-----------
src/backend/access/heap/heapam_handler.c | 8 ++---
src/backend/access/nbtree/nbtdedup.c | 2 +-
src/backend/access/nbtree/nbtsearch.c | 4 +--
src/backend/access/nbtree/nbtsort.c | 4 +--
src/backend/access/nbtree/nbtsplitloc.c | 4 +--
src/backend/access/spgist/spgdoinsert.c | 2 +-
src/backend/access/spgist/spgutils.c | 2 +-
src/backend/access/spgist/spgvacuum.c | 4 +--
src/backend/access/table/tableam.c | 4 +--
src/backend/catalog/index.c | 4 +--
src/backend/catalog/indexing.c | 6 ++--
src/backend/commands/vacuum.c | 4 +--
src/backend/executor/execIndexing.c | 8 ++---
src/backend/executor/nodeModifyTable.c | 4 +--
src/backend/storage/lmgr/predicate.c | 8 ++---
src/backend/storage/page/itemptr.c | 4 +--
src/backend/utils/adt/tid.c | 6 ++--
src/backend/utils/sort/tuplesortvariants.c | 2 +-
src/include/access/genam.h | 2 +-
src/include/access/hash.h | 2 +-
src/include/access/heapam.h | 16 +++++-----
src/include/access/nbtree.h | 2 +-
src/include/access/spgist_private.h | 4 +--
src/include/access/tableam.h | 22 ++++++-------
src/include/access/tidstore.h | 2 +-
src/include/catalog/index.h | 2 +-
src/include/catalog/indexing.h | 6 ++--
src/include/executor/executor.h | 4 +--
src/include/storage/itemptr.h | 10 +++---
src/include/storage/predicate.h | 4 +--
src/include/utils/tuplesort.h | 2 +-
34 files changed, 99 insertions(+), 99 deletions(-)
diff --git a/src/backend/access/common/tidstore.c b/src/backend/access/common/tidstore.c
index 5bd75fb499c..fb807d9fe59 100644
--- a/src/backend/access/common/tidstore.c
+++ b/src/backend/access/common/tidstore.c
@@ -418,7 +418,7 @@ TidStoreSetBlockOffsets(TidStore *ts, BlockNumber blkno, OffsetNumber *offsets,
/* Return true if the given TID is present in the TidStore */
bool
-TidStoreIsMember(TidStore *ts, ItemPointer tid)
+TidStoreIsMember(TidStore *ts, const ItemPointerData *tid)
{
int wordnum;
int bitnum;
diff --git a/src/backend/access/hash/hashsort.c b/src/backend/access/hash/hashsort.c
index 6e8c0e68a92..92ae3cf53f5 100644
--- a/src/backend/access/hash/hashsort.c
+++ b/src/backend/access/hash/hashsort.c
@@ -106,7 +106,7 @@ _h_spooldestroy(HSpool *hspool)
* spool an index entry into the sort file.
*/
void
-_h_spool(HSpool *hspool, ItemPointer self, const Datum *values, const bool *isnull)
+_h_spool(HSpool *hspool, const ItemPointerData *self, const Datum *values, const bool *isnull)
{
tuplesort_putindextuplevalues(hspool->sortstate, hspool->index,
self, values, isnull);
diff --git a/src/backend/access/heap/heapam.c b/src/backend/access/heap/heapam.c
index 4c5ae205a7a..68260590c05 100644
--- a/src/backend/access/heap/heapam.c
+++ b/src/backend/access/heap/heapam.c
@@ -72,7 +72,7 @@ static Bitmapset *HeapDetermineColumnsInfo(Relation relation,
Bitmapset *external_cols,
HeapTuple oldtup, HeapTuple newtup,
bool *has_external);
-static bool heap_acquire_tuplock(Relation relation, ItemPointer tid,
+static bool heap_acquire_tuplock(Relation relation, const ItemPointerData *tid,
LockTupleMode mode, LockWaitPolicy wait_policy,
bool *have_tuple_lock);
static inline BlockNumber heapgettup_advance_block(HeapScanDesc scan,
@@ -86,7 +86,7 @@ static void compute_new_xmax_infomask(TransactionId xmax, uint16 old_infomask,
TransactionId *result_xmax, uint16 *result_infomask,
uint16 *result_infomask2);
static TM_Result heap_lock_updated_tuple(Relation rel, HeapTuple tuple,
- ItemPointer ctid, TransactionId xid,
+ const ItemPointerData *ctid, TransactionId xid,
LockTupleMode mode);
static void GetMultiXactIdHintBits(MultiXactId multi, uint16 *new_infomask,
uint16 *new_infomask2);
@@ -95,7 +95,7 @@ static TransactionId MultiXactIdGetUpdateXid(TransactionId xmax,
static bool DoesMultiXactIdConflict(MultiXactId multi, uint16 infomask,
LockTupleMode lockmode, bool *current_is_member);
static void MultiXactIdWait(MultiXactId multi, MultiXactStatus status, uint16 infomask,
- Relation rel, ItemPointer ctid, XLTW_Oper oper,
+ Relation rel, const ItemPointerData *ctid, XLTW_Oper oper,
int *remaining);
static bool ConditionalMultiXactIdWait(MultiXactId multi, MultiXactStatus status,
uint16 infomask, Relation rel, int *remaining,
@@ -1422,8 +1422,8 @@ heap_getnextslot(TableScanDesc sscan, ScanDirection direction, TupleTableSlot *s
}
void
-heap_set_tidrange(TableScanDesc sscan, ItemPointer mintid,
- ItemPointer maxtid)
+heap_set_tidrange(TableScanDesc sscan, const ItemPointerData *mintid,
+ const ItemPointerData *maxtid)
{
HeapScanDesc scan = (HeapScanDesc) sscan;
BlockNumber startBlk;
@@ -2775,7 +2775,7 @@ xmax_infomask_changed(uint16 new_infomask, uint16 old_infomask)
* generated by another transaction).
*/
TM_Result
-heap_delete(Relation relation, ItemPointer tid,
+heap_delete(Relation relation, const ItemPointerData *tid,
CommandId cid, Snapshot crosscheck, bool wait,
TM_FailureData *tmfd, bool changingPart)
{
@@ -3198,7 +3198,7 @@ l1:
* via ereport().
*/
void
-simple_heap_delete(Relation relation, ItemPointer tid)
+simple_heap_delete(Relation relation, const ItemPointerData *tid)
{
TM_Result result;
TM_FailureData tmfd;
@@ -3244,7 +3244,7 @@ simple_heap_delete(Relation relation, ItemPointer tid)
* generated by another transaction).
*/
TM_Result
-heap_update(Relation relation, ItemPointer otid, HeapTuple newtup,
+heap_update(Relation relation, const ItemPointerData *otid, HeapTuple newtup,
CommandId cid, Snapshot crosscheck, bool wait,
TM_FailureData *tmfd, LockTupleMode *lockmode,
TU_UpdateIndexes *update_indexes)
@@ -4227,7 +4227,7 @@ l2:
*/
static void
check_lock_if_inplace_updateable_rel(Relation relation,
- ItemPointer otid,
+ const ItemPointerData *otid,
HeapTuple newtup)
{
/* LOCKTAG_TUPLE acceptable for any catalog */
@@ -4488,7 +4488,7 @@ HeapDetermineColumnsInfo(Relation relation,
* via ereport().
*/
void
-simple_heap_update(Relation relation, ItemPointer otid, HeapTuple tup,
+simple_heap_update(Relation relation, const ItemPointerData *otid, HeapTuple tup,
TU_UpdateIndexes *update_indexes)
{
TM_Result result;
@@ -5275,7 +5275,7 @@ out_unlocked:
* wait_policy is Skip.
*/
static bool
-heap_acquire_tuplock(Relation relation, ItemPointer tid, LockTupleMode mode,
+heap_acquire_tuplock(Relation relation, const ItemPointerData *tid, LockTupleMode mode,
LockWaitPolicy wait_policy, bool *have_tuple_lock)
{
if (*have_tuple_lock)
@@ -5696,7 +5696,7 @@ test_lockmode_for_conflict(MultiXactStatus status, TransactionId xid,
* version as well.
*/
static TM_Result
-heap_lock_updated_tuple_rec(Relation rel, ItemPointer tid, TransactionId xid,
+heap_lock_updated_tuple_rec(Relation rel, const ItemPointerData *tid, TransactionId xid,
LockTupleMode mode)
{
TM_Result result;
@@ -6041,7 +6041,7 @@ out_unlocked:
* levels, because that would lead to a serializability failure.
*/
static TM_Result
-heap_lock_updated_tuple(Relation rel, HeapTuple tuple, ItemPointer ctid,
+heap_lock_updated_tuple(Relation rel, HeapTuple tuple, const ItemPointerData *ctid,
TransactionId xid, LockTupleMode mode)
{
/*
@@ -6086,7 +6086,7 @@ heap_lock_updated_tuple(Relation rel, HeapTuple tuple, ItemPointer ctid,
* An explicit confirmation WAL record also makes logical decoding simpler.
*/
void
-heap_finish_speculative(Relation relation, ItemPointer tid)
+heap_finish_speculative(Relation relation, const ItemPointerData *tid)
{
Buffer buffer;
Page page;
@@ -6173,7 +6173,7 @@ heap_finish_speculative(Relation relation, ItemPointer tid)
* confirmation records.
*/
void
-heap_abort_speculative(Relation relation, ItemPointer tid)
+heap_abort_speculative(Relation relation, const ItemPointerData *tid)
{
TransactionId xid = GetCurrentTransactionId();
ItemId lp;
@@ -7695,7 +7695,7 @@ DoesMultiXactIdConflict(MultiXactId multi, uint16 infomask,
static bool
Do_MultiXactIdWait(MultiXactId multi, MultiXactStatus status,
uint16 infomask, bool nowait,
- Relation rel, ItemPointer ctid, XLTW_Oper oper,
+ Relation rel, const ItemPointerData *ctid, XLTW_Oper oper,
int *remaining, bool logLockFailure)
{
bool result = true;
@@ -7772,7 +7772,7 @@ Do_MultiXactIdWait(MultiXactId multi, MultiXactStatus status,
*/
static void
MultiXactIdWait(MultiXactId multi, MultiXactStatus status, uint16 infomask,
- Relation rel, ItemPointer ctid, XLTW_Oper oper,
+ Relation rel, const ItemPointerData *ctid, XLTW_Oper oper,
int *remaining)
{
(void) Do_MultiXactIdWait(multi, status, infomask, false,
@@ -8058,7 +8058,7 @@ index_delete_prefetch_buffer(Relation rel,
static inline void
index_delete_check_htid(TM_IndexDeleteOp *delstate,
Page page, OffsetNumber maxoff,
- ItemPointer htid, TM_IndexStatus *istatus)
+ const ItemPointerData *htid, TM_IndexStatus *istatus)
{
OffsetNumber indexpagehoffnum = ItemPointerGetOffsetNumber(htid);
ItemId iid;
diff --git a/src/backend/access/heap/heapam_handler.c b/src/backend/access/heap/heapam_handler.c
index bcbac844bb6..6d23a21841c 100644
--- a/src/backend/access/heap/heapam_handler.c
+++ b/src/backend/access/heap/heapam_handler.c
@@ -181,7 +181,7 @@ heapam_index_fetch_tuple(struct IndexFetchTableData *scan,
static bool
heapam_fetch_row_version(Relation relation,
- ItemPointer tid,
+ const ItemPointerData *tid,
Snapshot snapshot,
TupleTableSlot *slot)
{
@@ -204,7 +204,7 @@ heapam_fetch_row_version(Relation relation,
}
static bool
-heapam_tuple_tid_valid(TableScanDesc scan, ItemPointer tid)
+heapam_tuple_tid_valid(TableScanDesc scan, const ItemPointerData *tid)
{
HeapScanDesc hscan = (HeapScanDesc) scan;
@@ -300,7 +300,7 @@ heapam_tuple_complete_speculative(Relation relation, TupleTableSlot *slot,
}
static TM_Result
-heapam_tuple_delete(Relation relation, ItemPointer tid, CommandId cid,
+heapam_tuple_delete(Relation relation, const ItemPointerData *tid, CommandId cid,
Snapshot snapshot, Snapshot crosscheck, bool wait,
TM_FailureData *tmfd, bool changingPart)
{
@@ -314,7 +314,7 @@ heapam_tuple_delete(Relation relation, ItemPointer tid, CommandId cid,
static TM_Result
-heapam_tuple_update(Relation relation, ItemPointer otid, TupleTableSlot *slot,
+heapam_tuple_update(Relation relation, const ItemPointerData *otid, TupleTableSlot *slot,
CommandId cid, Snapshot snapshot, Snapshot crosscheck,
bool wait, TM_FailureData *tmfd,
LockTupleMode *lockmode, TU_UpdateIndexes *update_indexes)
diff --git a/src/backend/access/nbtree/nbtdedup.c b/src/backend/access/nbtree/nbtdedup.c
index ab0b6946cb0..f430c8bc3ee 100644
--- a/src/backend/access/nbtree/nbtdedup.c
+++ b/src/backend/access/nbtree/nbtdedup.c
@@ -862,7 +862,7 @@ _bt_singleval_fillfactor(Page page, BTDedupState state, Size newitemsz)
* returned posting list tuple (they must be included in htids array.)
*/
IndexTuple
-_bt_form_posting(IndexTuple base, ItemPointer htids, int nhtids)
+_bt_form_posting(IndexTuple base, const ItemPointerData *htids, int nhtids)
{
uint32 keysize,
newsize;
diff --git a/src/backend/access/nbtree/nbtsearch.c b/src/backend/access/nbtree/nbtsearch.c
index d69798795b4..7ae2bc8b66a 100644
--- a/src/backend/access/nbtree/nbtsearch.c
+++ b/src/backend/access/nbtree/nbtsearch.c
@@ -37,7 +37,7 @@ static bool _bt_readpage(IndexScanDesc scan, ScanDirection dir,
static void _bt_saveitem(BTScanOpaque so, int itemIndex,
OffsetNumber offnum, IndexTuple itup);
static int _bt_setuppostingitems(BTScanOpaque so, int itemIndex,
- OffsetNumber offnum, ItemPointer heapTid,
+ OffsetNumber offnum, const ItemPointerData *heapTid,
IndexTuple itup);
static inline void _bt_savepostingitem(BTScanOpaque so, int itemIndex,
OffsetNumber offnum,
@@ -2079,7 +2079,7 @@ _bt_saveitem(BTScanOpaque so, int itemIndex,
*/
static int
_bt_setuppostingitems(BTScanOpaque so, int itemIndex, OffsetNumber offnum,
- ItemPointer heapTid, IndexTuple itup)
+ const ItemPointerData *heapTid, IndexTuple itup)
{
BTScanPosItem *currItem = &so->currPos.items[itemIndex];
diff --git a/src/backend/access/nbtree/nbtsort.c b/src/backend/access/nbtree/nbtsort.c
index 8828a7a8f89..235f19b86ab 100644
--- a/src/backend/access/nbtree/nbtsort.c
+++ b/src/backend/access/nbtree/nbtsort.c
@@ -257,7 +257,7 @@ typedef struct BTWriteState
static double _bt_spools_heapscan(Relation heap, Relation index,
BTBuildState *buildstate, IndexInfo *indexInfo);
static void _bt_spooldestroy(BTSpool *btspool);
-static void _bt_spool(BTSpool *btspool, ItemPointer self,
+static void _bt_spool(BTSpool *btspool, const ItemPointerData *self,
Datum *values, bool *isnull);
static void _bt_leafbuild(BTSpool *btspool, BTSpool *btspool2);
static void _bt_build_callback(Relation index, ItemPointer tid, Datum *values,
@@ -525,7 +525,7 @@ _bt_spooldestroy(BTSpool *btspool)
* spool an index entry into the sort file.
*/
static void
-_bt_spool(BTSpool *btspool, ItemPointer self, Datum *values, bool *isnull)
+_bt_spool(BTSpool *btspool, const ItemPointerData *self, Datum *values, bool *isnull)
{
tuplesort_putindextuplevalues(btspool->sortstate, btspool->index,
self, values, isnull);
diff --git a/src/backend/access/nbtree/nbtsplitloc.c b/src/backend/access/nbtree/nbtsplitloc.c
index b88c396195a..f0082f88c76 100644
--- a/src/backend/access/nbtree/nbtsplitloc.c
+++ b/src/backend/access/nbtree/nbtsplitloc.c
@@ -69,7 +69,7 @@ static void _bt_deltasortsplits(FindSplitData *state, double fillfactormult,
static int _bt_splitcmp(const void *arg1, const void *arg2);
static bool _bt_afternewitemoff(FindSplitData *state, OffsetNumber maxoff,
int leaffillfactor, bool *usemult);
-static bool _bt_adjacenthtid(ItemPointer lowhtid, ItemPointer highhtid);
+static bool _bt_adjacenthtid(const ItemPointerData *lowhtid, const ItemPointerData *highhtid);
static OffsetNumber _bt_bestsplitloc(FindSplitData *state, int perfectpenalty,
bool *newitemonleft, FindSplitStrat strategy);
static int _bt_defaultinterval(FindSplitData *state);
@@ -747,7 +747,7 @@ _bt_afternewitemoff(FindSplitData *state, OffsetNumber maxoff,
* transaction.
*/
static bool
-_bt_adjacenthtid(ItemPointer lowhtid, ItemPointer highhtid)
+_bt_adjacenthtid(const ItemPointerData *lowhtid, const ItemPointerData *highhtid)
{
BlockNumber lowblk,
highblk;
diff --git a/src/backend/access/spgist/spgdoinsert.c b/src/backend/access/spgist/spgdoinsert.c
index af6b27b2135..c78c3794261 100644
--- a/src/backend/access/spgist/spgdoinsert.c
+++ b/src/backend/access/spgist/spgdoinsert.c
@@ -1912,7 +1912,7 @@ spgSplitNodeAction(Relation index, SpGistState *state,
*/
bool
spgdoinsert(Relation index, SpGistState *state,
- ItemPointer heapPtr, Datum *datums, bool *isnulls)
+ const ItemPointerData *heapPtr, Datum *datums, bool *isnulls)
{
bool result = true;
TupleDesc leafDescriptor = state->leafTupDesc;
diff --git a/src/backend/access/spgist/spgutils.c b/src/backend/access/spgist/spgutils.c
index 9b86c016acb..09d1df090cf 100644
--- a/src/backend/access/spgist/spgutils.c
+++ b/src/backend/access/spgist/spgutils.c
@@ -868,7 +868,7 @@ SpGistGetLeafTupleSize(TupleDesc tupleDescriptor,
* Construct a leaf tuple containing the given heap TID and datum values
*/
SpGistLeafTuple
-spgFormLeafTuple(SpGistState *state, ItemPointer heapPtr,
+spgFormLeafTuple(SpGistState *state, const ItemPointerData *heapPtr,
const Datum *datums, const bool *isnulls)
{
SpGistLeafTuple tup;
diff --git a/src/backend/access/spgist/spgvacuum.c b/src/backend/access/spgist/spgvacuum.c
index 8f8a1ad7796..b552c01ebcd 100644
--- a/src/backend/access/spgist/spgvacuum.c
+++ b/src/backend/access/spgist/spgvacuum.c
@@ -61,7 +61,7 @@ typedef struct spgBulkDeleteState
* ensures that scans of the list don't miss items added during the scan.
*/
static void
-spgAddPendingTID(spgBulkDeleteState *bds, ItemPointer tid)
+spgAddPendingTID(spgBulkDeleteState *bds, const ItemPointerData *tid)
{
spgVacPendingItem *pitem;
spgVacPendingItem **listLink;
@@ -967,7 +967,7 @@ spgbulkdelete(IndexVacuumInfo *info, IndexBulkDeleteResult *stats,
/* Dummy callback to delete no tuples during spgvacuumcleanup */
static bool
-dummy_callback(ItemPointer itemptr, void *state)
+dummy_callback(const ItemPointerData *itemptr, void *state)
{
return false;
}
diff --git a/src/backend/access/table/tableam.c b/src/backend/access/table/tableam.c
index a56c5eceb14..c643ec2106d 100644
--- a/src/backend/access/table/tableam.c
+++ b/src/backend/access/table/tableam.c
@@ -288,7 +288,7 @@ simple_table_tuple_insert(Relation rel, TupleTableSlot *slot)
* via ereport().
*/
void
-simple_table_tuple_delete(Relation rel, ItemPointer tid, Snapshot snapshot)
+simple_table_tuple_delete(Relation rel, const ItemPointerData *tid, Snapshot snapshot)
{
TM_Result result;
TM_FailureData tmfd;
@@ -333,7 +333,7 @@ simple_table_tuple_delete(Relation rel, ItemPointer tid, Snapshot snapshot)
* via ereport().
*/
void
-simple_table_tuple_update(Relation rel, ItemPointer otid,
+simple_table_tuple_update(Relation rel, const ItemPointerData *otid,
TupleTableSlot *slot,
Snapshot snapshot,
TU_UpdateIndexes *update_indexes)
diff --git a/src/backend/catalog/index.c b/src/backend/catalog/index.c
index c4029a4f3d3..ebc1f448f06 100644
--- a/src/backend/catalog/index.c
+++ b/src/backend/catalog/index.c
@@ -126,7 +126,7 @@ static void index_update_stats(Relation rel,
static void IndexCheckExclusion(Relation heapRelation,
Relation indexRelation,
IndexInfo *indexInfo);
-static bool validate_index_callback(ItemPointer itemptr, void *opaque);
+static bool validate_index_callback(const ItemPointerData *itemptr, void *opaque);
static bool ReindexIsCurrentlyProcessingIndex(Oid indexOid);
static void SetReindexProcessing(Oid heapOid, Oid indexOid);
static void ResetReindexProcessing(void);
@@ -3480,7 +3480,7 @@ validate_index(Oid heapId, Oid indexId, Snapshot snapshot)
* validate_index_callback - bulkdelete callback to collect the index TIDs
*/
static bool
-validate_index_callback(ItemPointer itemptr, void *opaque)
+validate_index_callback(const ItemPointerData *itemptr, void *opaque)
{
ValidateIndexState *state = (ValidateIndexState *) opaque;
int64 encoded = itemptr_encode(itemptr);
diff --git a/src/backend/catalog/indexing.c b/src/backend/catalog/indexing.c
index 25c4b6bdc87..004c5121000 100644
--- a/src/backend/catalog/indexing.c
+++ b/src/backend/catalog/indexing.c
@@ -310,7 +310,7 @@ CatalogTuplesMultiInsertWithInfo(Relation heapRel, TupleTableSlot **slot,
* (Use CatalogTupleUpdateWithInfo in such cases.)
*/
void
-CatalogTupleUpdate(Relation heapRel, ItemPointer otid, HeapTuple tup)
+CatalogTupleUpdate(Relation heapRel, const ItemPointerData *otid, HeapTuple tup)
{
CatalogIndexState indstate;
TU_UpdateIndexes updateIndexes = TU_All;
@@ -334,7 +334,7 @@ CatalogTupleUpdate(Relation heapRel, ItemPointer otid, HeapTuple tup)
* so that callers needn't trouble over this ... but we don't do so today.
*/
void
-CatalogTupleUpdateWithInfo(Relation heapRel, ItemPointer otid, HeapTuple tup,
+CatalogTupleUpdateWithInfo(Relation heapRel, const ItemPointerData *otid, HeapTuple tup,
CatalogIndexState indstate)
{
TU_UpdateIndexes updateIndexes = TU_All;
@@ -362,7 +362,7 @@ CatalogTupleUpdateWithInfo(Relation heapRel, ItemPointer otid, HeapTuple tup,
* it might be better to do something about caching CatalogIndexState.
*/
void
-CatalogTupleDelete(Relation heapRel, ItemPointer tid)
+CatalogTupleDelete(Relation heapRel, const ItemPointerData *tid)
{
simple_heap_delete(heapRel, tid);
}
diff --git a/src/backend/commands/vacuum.c b/src/backend/commands/vacuum.c
index 733ef40ae7c..a5e0f8e2a03 100644
--- a/src/backend/commands/vacuum.c
+++ b/src/backend/commands/vacuum.c
@@ -128,7 +128,7 @@ static bool vacuum_rel(Oid relid, RangeVar *relation, VacuumParams params,
BufferAccessStrategy bstrategy);
static double compute_parallel_delay(void);
static VacOptValue get_vacoptval_from_boolean(DefElem *def);
-static bool vac_tid_reaped(ItemPointer itemptr, void *state);
+static bool vac_tid_reaped(const ItemPointerData *itemptr, void *state);
/*
* GUC check function to ensure GUC value specified is within the allowable
@@ -2674,7 +2674,7 @@ vac_cleanup_one_index(IndexVacuumInfo *ivinfo, IndexBulkDeleteResult *istat)
* This has the right signature to be an IndexBulkDeleteCallback.
*/
static bool
-vac_tid_reaped(ItemPointer itemptr, void *state)
+vac_tid_reaped(const ItemPointerData *itemptr, void *state)
{
TidStore *dead_items = (TidStore *) state;
diff --git a/src/backend/executor/execIndexing.c b/src/backend/executor/execIndexing.c
index ca33a854278..401606f840a 100644
--- a/src/backend/executor/execIndexing.c
+++ b/src/backend/executor/execIndexing.c
@@ -128,7 +128,7 @@ typedef enum
static bool check_exclusion_or_unique_constraint(Relation heap, Relation index,
IndexInfo *indexInfo,
- ItemPointer tupleid,
+ const ItemPointerData *tupleid,
const Datum *values, const bool *isnull,
EState *estate, bool newIndex,
CEOUC_WAIT_MODE waitMode,
@@ -541,7 +541,7 @@ ExecInsertIndexTuples(ResultRelInfo *resultRelInfo,
bool
ExecCheckIndexConstraints(ResultRelInfo *resultRelInfo, TupleTableSlot *slot,
EState *estate, ItemPointer conflictTid,
- ItemPointer tupleid, List *arbiterIndexes)
+ const ItemPointerData *tupleid, List *arbiterIndexes)
{
int i;
int numIndices;
@@ -703,7 +703,7 @@ ExecCheckIndexConstraints(ResultRelInfo *resultRelInfo, TupleTableSlot *slot,
static bool
check_exclusion_or_unique_constraint(Relation heap, Relation index,
IndexInfo *indexInfo,
- ItemPointer tupleid,
+ const ItemPointerData *tupleid,
const Datum *values, const bool *isnull,
EState *estate, bool newIndex,
CEOUC_WAIT_MODE waitMode,
@@ -955,7 +955,7 @@ retry:
void
check_exclusion_constraint(Relation heap, Relation index,
IndexInfo *indexInfo,
- ItemPointer tupleid,
+ const ItemPointerData *tupleid,
const Datum *values, const bool *isnull,
EState *estate, bool newIndex)
{
diff --git a/src/backend/executor/nodeModifyTable.c b/src/backend/executor/nodeModifyTable.c
index 4c5647ac38a..56ad7194e99 100644
--- a/src/backend/executor/nodeModifyTable.c
+++ b/src/backend/executor/nodeModifyTable.c
@@ -396,7 +396,7 @@ ExecCheckTupleVisible(EState *estate,
static void
ExecCheckTIDVisible(EState *estate,
ResultRelInfo *relinfo,
- ItemPointer tid,
+ const ItemPointerData *tid,
TupleTableSlot *tempSlot)
{
Relation rel = relinfo->ri_RelationDesc;
@@ -1490,7 +1490,7 @@ ExecDeletePrologue(ModifyTableContext *context, ResultRelInfo *resultRelInfo,
*/
static TM_Result
ExecDeleteAct(ModifyTableContext *context, ResultRelInfo *resultRelInfo,
- ItemPointer tupleid, bool changingPart)
+ const ItemPointerData *tupleid, bool changingPart)
{
EState *estate = context->estate;
diff --git a/src/backend/storage/lmgr/predicate.c b/src/backend/storage/lmgr/predicate.c
index c1d8511ad17..bb807d8c9cd 100644
--- a/src/backend/storage/lmgr/predicate.c
+++ b/src/backend/storage/lmgr/predicate.c
@@ -168,7 +168,7 @@
* PredicateLockRelation(Relation relation, Snapshot snapshot)
* PredicateLockPage(Relation relation, BlockNumber blkno,
* Snapshot snapshot)
- * PredicateLockTID(Relation relation, ItemPointer tid, Snapshot snapshot,
+ * PredicateLockTID(Relation relation, const ItemPointerData *tid, Snapshot snapshot,
* TransactionId tuple_xid)
* PredicateLockPageSplit(Relation relation, BlockNumber oldblkno,
* BlockNumber newblkno)
@@ -180,7 +180,7 @@
* conflict detection (may also trigger rollback)
* CheckForSerializableConflictOut(Relation relation, TransactionId xid,
* Snapshot snapshot)
- * CheckForSerializableConflictIn(Relation relation, ItemPointer tid,
+ * CheckForSerializableConflictIn(Relation relation, const ItemPointerData *tid,
* BlockNumber blkno)
* CheckTableForSerializableConflictIn(Relation relation)
*
@@ -2618,7 +2618,7 @@ PredicateLockPage(Relation relation, BlockNumber blkno, Snapshot snapshot)
* Skip if this is a temporary table.
*/
void
-PredicateLockTID(Relation relation, ItemPointer tid, Snapshot snapshot,
+PredicateLockTID(Relation relation, const ItemPointerData *tid, Snapshot snapshot,
TransactionId tuple_xid)
{
PREDICATELOCKTARGETTAG tag;
@@ -4333,7 +4333,7 @@ CheckTargetForConflictsIn(PREDICATELOCKTARGETTAG *targettag)
* tuple itself.
*/
void
-CheckForSerializableConflictIn(Relation relation, ItemPointer tid, BlockNumber blkno)
+CheckForSerializableConflictIn(Relation relation, const ItemPointerData *tid, BlockNumber blkno)
{
PREDICATELOCKTARGETTAG targettag;
diff --git a/src/backend/storage/page/itemptr.c b/src/backend/storage/page/itemptr.c
index ad658215721..cedb27d6cc5 100644
--- a/src/backend/storage/page/itemptr.c
+++ b/src/backend/storage/page/itemptr.c
@@ -32,7 +32,7 @@ StaticAssertDecl(sizeof(ItemPointerData) == 3 * sizeof(uint16),
* Asserts that the disk item pointers are both valid!
*/
bool
-ItemPointerEquals(ItemPointer pointer1, ItemPointer pointer2)
+ItemPointerEquals(const ItemPointerData *pointer1, const ItemPointerData *pointer2)
{
if (ItemPointerGetBlockNumber(pointer1) ==
ItemPointerGetBlockNumber(pointer2) &&
@@ -48,7 +48,7 @@ ItemPointerEquals(ItemPointer pointer1, ItemPointer pointer2)
* Generic btree-style comparison for item pointers.
*/
int32
-ItemPointerCompare(ItemPointer arg1, ItemPointer arg2)
+ItemPointerCompare(const ItemPointerData *arg1, const ItemPointerData *arg2)
{
/*
* Use ItemPointerGet{Offset,Block}NumberNoCheck to avoid asserting
diff --git a/src/backend/utils/adt/tid.c b/src/backend/utils/adt/tid.c
index 39dab3e42df..0cfb0bd3735 100644
--- a/src/backend/utils/adt/tid.c
+++ b/src/backend/utils/adt/tid.c
@@ -42,7 +42,7 @@
#define DELIM ','
#define NTIDARGS 2
-static ItemPointer currtid_for_view(Relation viewrel, ItemPointer tid);
+static ItemPointer currtid_for_view(Relation viewrel, const ItemPointerData *tid);
/* ----------------------------------------------------------------
* tidin
@@ -293,7 +293,7 @@ hashtidextended(PG_FUNCTION_ARGS)
* relation "rel".
*/
static ItemPointer
-currtid_internal(Relation rel, ItemPointer tid)
+currtid_internal(Relation rel, const ItemPointerData *tid)
{
ItemPointer result;
AclResult aclresult;
@@ -335,7 +335,7 @@ currtid_internal(Relation rel, ItemPointer tid)
* correspond to the CTID of a base relation.
*/
static ItemPointer
-currtid_for_view(Relation viewrel, ItemPointer tid)
+currtid_for_view(Relation viewrel, const ItemPointerData *tid)
{
TupleDesc att = RelationGetDescr(viewrel);
RuleLock *rulelock;
diff --git a/src/backend/utils/sort/tuplesortvariants.c b/src/backend/utils/sort/tuplesortvariants.c
index 890cdbe1204..41ac4afbf49 100644
--- a/src/backend/utils/sort/tuplesortvariants.c
+++ b/src/backend/utils/sort/tuplesortvariants.c
@@ -816,7 +816,7 @@ tuplesort_putheaptuple(Tuplesortstate *state, HeapTuple tup)
*/
void
tuplesort_putindextuplevalues(Tuplesortstate *state, Relation rel,
- ItemPointer self, const Datum *values,
+ const ItemPointerData *self, const Datum *values,
const bool *isnull)
{
SortTuple stup;
diff --git a/src/include/access/genam.h b/src/include/access/genam.h
index 5b2ab181b5f..b4a0d8b7885 100644
--- a/src/include/access/genam.h
+++ b/src/include/access/genam.h
@@ -107,7 +107,7 @@ typedef struct IndexBulkDeleteResult
} IndexBulkDeleteResult;
/* Typedef for callback function to determine if a tuple is bulk-deletable */
-typedef bool (*IndexBulkDeleteCallback) (ItemPointer itemptr, void *state);
+typedef bool (*IndexBulkDeleteCallback) (const ItemPointerData *itemptr, void *state);
/* struct definitions appear in relscan.h */
typedef struct IndexScanDescData *IndexScanDesc;
diff --git a/src/include/access/hash.h b/src/include/access/hash.h
index 073ad29b19b..2374d5cf049 100644
--- a/src/include/access/hash.h
+++ b/src/include/access/hash.h
@@ -453,7 +453,7 @@ typedef struct HSpool HSpool; /* opaque struct in hashsort.c */
extern HSpool *_h_spoolinit(Relation heap, Relation index, uint32 num_buckets);
extern void _h_spooldestroy(HSpool *hspool);
-extern void _h_spool(HSpool *hspool, ItemPointer self,
+extern void _h_spool(HSpool *hspool, const ItemPointerData *self,
const Datum *values, const bool *isnull);
extern void _h_indexbuild(HSpool *hspool, Relation heapRel);
diff --git a/src/include/access/heapam.h b/src/include/access/heapam.h
index a2bd5a897f8..339b23379ec 100644
--- a/src/include/access/heapam.h
+++ b/src/include/access/heapam.h
@@ -299,8 +299,8 @@ extern void heap_endscan(TableScanDesc sscan);
extern HeapTuple heap_getnext(TableScanDesc sscan, ScanDirection direction);
extern bool heap_getnextslot(TableScanDesc sscan,
ScanDirection direction, struct TupleTableSlot *slot);
-extern void heap_set_tidrange(TableScanDesc sscan, ItemPointer mintid,
- ItemPointer maxtid);
+extern void heap_set_tidrange(TableScanDesc sscan, const ItemPointerData *mintid,
+ const ItemPointerData *maxtid);
extern bool heap_getnextslot_tidrange(TableScanDesc sscan,
ScanDirection direction,
TupleTableSlot *slot);
@@ -321,12 +321,12 @@ extern void heap_insert(Relation relation, HeapTuple tup, CommandId cid,
extern void heap_multi_insert(Relation relation, struct TupleTableSlot **slots,
int ntuples, CommandId cid, int options,
BulkInsertState bistate);
-extern TM_Result heap_delete(Relation relation, ItemPointer tid,
+extern TM_Result heap_delete(Relation relation, const ItemPointerData *tid,
CommandId cid, Snapshot crosscheck, bool wait,
struct TM_FailureData *tmfd, bool changingPart);
-extern void heap_finish_speculative(Relation relation, ItemPointer tid);
-extern void heap_abort_speculative(Relation relation, ItemPointer tid);
-extern TM_Result heap_update(Relation relation, ItemPointer otid,
+extern void heap_finish_speculative(Relation relation, const ItemPointerData *tid);
+extern void heap_abort_speculative(Relation relation, const ItemPointerData *tid);
+extern TM_Result heap_update(Relation relation, const ItemPointerData *otid,
HeapTuple newtup,
CommandId cid, Snapshot crosscheck, bool wait,
struct TM_FailureData *tmfd, LockTupleMode *lockmode,
@@ -363,8 +363,8 @@ extern bool heap_tuple_should_freeze(HeapTupleHeader tuple,
extern bool heap_tuple_needs_eventual_freeze(HeapTupleHeader tuple);
extern void simple_heap_insert(Relation relation, HeapTuple tup);
-extern void simple_heap_delete(Relation relation, ItemPointer tid);
-extern void simple_heap_update(Relation relation, ItemPointer otid,
+extern void simple_heap_delete(Relation relation, const ItemPointerData *tid);
+extern void simple_heap_update(Relation relation, const ItemPointerData *otid,
HeapTuple tup, TU_UpdateIndexes *update_indexes);
extern TransactionId heap_index_delete_tuples(Relation rel,
diff --git a/src/include/access/nbtree.h b/src/include/access/nbtree.h
index 9ab467cb8fd..dd167a9257b 100644
--- a/src/include/access/nbtree.h
+++ b/src/include/access/nbtree.h
@@ -1233,7 +1233,7 @@ extern void _bt_dedup_start_pending(BTDedupState state, IndexTuple base,
OffsetNumber baseoff);
extern bool _bt_dedup_save_htid(BTDedupState state, IndexTuple itup);
extern Size _bt_dedup_finish_pending(Page newpage, BTDedupState state);
-extern IndexTuple _bt_form_posting(IndexTuple base, ItemPointer htids,
+extern IndexTuple _bt_form_posting(IndexTuple base, const ItemPointerData *htids,
int nhtids);
extern void _bt_update_posting(BTVacuumPosting vacposting);
extern IndexTuple _bt_swap_posting(IndexTuple newitem, IndexTuple oposting,
diff --git a/src/include/access/spgist_private.h b/src/include/access/spgist_private.h
index 56ac64f0597..9441f6cec15 100644
--- a/src/include/access/spgist_private.h
+++ b/src/include/access/spgist_private.h
@@ -511,7 +511,7 @@ extern unsigned int SpGistGetInnerTypeSize(SpGistTypeDesc *att, Datum datum);
extern Size SpGistGetLeafTupleSize(TupleDesc tupleDescriptor,
const Datum *datums, const bool *isnulls);
extern SpGistLeafTuple spgFormLeafTuple(SpGistState *state,
- ItemPointer heapPtr,
+ const ItemPointerData *heapPtr,
const Datum *datums, const bool *isnulls);
extern SpGistNodeTuple spgFormNodeTuple(SpGistState *state,
Datum label, bool isnull);
@@ -541,7 +541,7 @@ extern void spgPageIndexMultiDelete(SpGistState *state, Page page,
int firststate, int reststate,
BlockNumber blkno, OffsetNumber offnum);
extern bool spgdoinsert(Relation index, SpGistState *state,
- ItemPointer heapPtr, Datum *datums, bool *isnulls);
+ const ItemPointerData *heapPtr, Datum *datums, bool *isnulls);
/* spgproc.c */
extern double *spg_key_orderbys_distances(Datum key, bool isLeaf,
diff --git a/src/include/access/tableam.h b/src/include/access/tableam.h
index b2ce35e2a34..1afd9b8da2b 100644
--- a/src/include/access/tableam.h
+++ b/src/include/access/tableam.h
@@ -368,8 +368,8 @@ typedef struct TableAmRoutine
* further calls to scan_getnextslot_tidrange.
*/
void (*scan_set_tidrange) (TableScanDesc scan,
- ItemPointer mintid,
- ItemPointer maxtid);
+ const ItemPointerData *mintid,
+ const ItemPointerData *maxtid);
/*
* Return next tuple from `scan` that's in the range of TIDs defined by
@@ -470,7 +470,7 @@ typedef struct TableAmRoutine
* test, returns true, false otherwise.
*/
bool (*tuple_fetch_row_version) (Relation rel,
- ItemPointer tid,
+ const ItemPointerData *tid,
Snapshot snapshot,
TupleTableSlot *slot);
@@ -478,7 +478,7 @@ typedef struct TableAmRoutine
* Is tid valid for a scan of this relation.
*/
bool (*tuple_tid_valid) (TableScanDesc scan,
- ItemPointer tid);
+ const ItemPointerData *tid);
/*
* Return the latest version of the tuple at `tid`, by updating `tid` to
@@ -530,7 +530,7 @@ typedef struct TableAmRoutine
/* see table_tuple_delete() for reference about parameters */
TM_Result (*tuple_delete) (Relation rel,
- ItemPointer tid,
+ const ItemPointerData *tid,
CommandId cid,
Snapshot snapshot,
Snapshot crosscheck,
@@ -540,7 +540,7 @@ typedef struct TableAmRoutine
/* see table_tuple_update() for reference about parameters */
TM_Result (*tuple_update) (Relation rel,
- ItemPointer otid,
+ const ItemPointerData *otid,
TupleTableSlot *slot,
CommandId cid,
Snapshot snapshot,
@@ -1251,7 +1251,7 @@ extern bool table_index_fetch_tuple_check(Relation rel,
*/
static inline bool
table_tuple_fetch_row_version(Relation rel,
- ItemPointer tid,
+ const ItemPointerData *tid,
Snapshot snapshot,
TupleTableSlot *slot)
{
@@ -1453,7 +1453,7 @@ table_multi_insert(Relation rel, TupleTableSlot **slots, int nslots,
* TM_FailureData for additional info.
*/
static inline TM_Result
-table_tuple_delete(Relation rel, ItemPointer tid, CommandId cid,
+table_tuple_delete(Relation rel, const ItemPointerData *tid, CommandId cid,
Snapshot snapshot, Snapshot crosscheck, bool wait,
TM_FailureData *tmfd, bool changingPart)
{
@@ -1497,7 +1497,7 @@ table_tuple_delete(Relation rel, ItemPointer tid, CommandId cid,
* for additional info.
*/
static inline TM_Result
-table_tuple_update(Relation rel, ItemPointer otid, TupleTableSlot *slot,
+table_tuple_update(Relation rel, const ItemPointerData *otid, TupleTableSlot *slot,
CommandId cid, Snapshot snapshot, Snapshot crosscheck,
bool wait, TM_FailureData *tmfd, LockTupleMode *lockmode,
TU_UpdateIndexes *update_indexes)
@@ -2004,9 +2004,9 @@ table_scan_sample_next_tuple(TableScanDesc scan,
*/
extern void simple_table_tuple_insert(Relation rel, TupleTableSlot *slot);
-extern void simple_table_tuple_delete(Relation rel, ItemPointer tid,
+extern void simple_table_tuple_delete(Relation rel, const ItemPointerData *tid,
Snapshot snapshot);
-extern void simple_table_tuple_update(Relation rel, ItemPointer otid,
+extern void simple_table_tuple_update(Relation rel, const ItemPointerData *otid,
TupleTableSlot *slot, Snapshot snapshot,
TU_UpdateIndexes *update_indexes);
diff --git a/src/include/access/tidstore.h b/src/include/access/tidstore.h
index 041091df278..048e1df0e84 100644
--- a/src/include/access/tidstore.h
+++ b/src/include/access/tidstore.h
@@ -40,7 +40,7 @@ extern void TidStoreUnlock(TidStore *ts);
extern void TidStoreDestroy(TidStore *ts);
extern void TidStoreSetBlockOffsets(TidStore *ts, BlockNumber blkno, OffsetNumber *offsets,
int num_offsets);
-extern bool TidStoreIsMember(TidStore *ts, ItemPointer tid);
+extern bool TidStoreIsMember(TidStore *ts, const ItemPointerData *tid);
extern TidStoreIter *TidStoreBeginIterate(TidStore *ts);
extern TidStoreIterResult *TidStoreIterateNext(TidStoreIter *iter);
extern int TidStoreGetBlockOffsets(TidStoreIterResult *result,
diff --git a/src/include/catalog/index.h b/src/include/catalog/index.h
index 4daa8bef5ee..dda95e54903 100644
--- a/src/include/catalog/index.h
+++ b/src/include/catalog/index.h
@@ -187,7 +187,7 @@ extern void IndexSetParentIndex(Relation partitionIdx, Oid parentOid);
* As noted in validate_index(), this can be significantly faster.
*/
static inline int64
-itemptr_encode(ItemPointer itemptr)
+itemptr_encode(const ItemPointerData *itemptr)
{
BlockNumber block = ItemPointerGetBlockNumber(itemptr);
OffsetNumber offset = ItemPointerGetOffsetNumber(itemptr);
diff --git a/src/include/catalog/indexing.h b/src/include/catalog/indexing.h
index 667aca7ace8..77c17d3fb7a 100644
--- a/src/include/catalog/indexing.h
+++ b/src/include/catalog/indexing.h
@@ -44,11 +44,11 @@ extern void CatalogTuplesMultiInsertWithInfo(Relation heapRel,
TupleTableSlot **slot,
int ntuples,
CatalogIndexState indstate);
-extern void CatalogTupleUpdate(Relation heapRel, ItemPointer otid,
+extern void CatalogTupleUpdate(Relation heapRel, const ItemPointerData *otid,
HeapTuple tup);
extern void CatalogTupleUpdateWithInfo(Relation heapRel,
- ItemPointer otid, HeapTuple tup,
+ const ItemPointerData *otid, HeapTuple tup,
CatalogIndexState indstate);
-extern void CatalogTupleDelete(Relation heapRel, ItemPointer tid);
+extern void CatalogTupleDelete(Relation heapRel, const ItemPointerData *tid);
#endif /* INDEXING_H */
diff --git a/src/include/executor/executor.h b/src/include/executor/executor.h
index 31133514e84..cb506d254de 100644
--- a/src/include/executor/executor.h
+++ b/src/include/executor/executor.h
@@ -745,11 +745,11 @@ extern List *ExecInsertIndexTuples(ResultRelInfo *resultRelInfo,
extern bool ExecCheckIndexConstraints(ResultRelInfo *resultRelInfo,
TupleTableSlot *slot,
EState *estate, ItemPointer conflictTid,
- ItemPointer tupleid,
+ const ItemPointerData *tupleid,
List *arbiterIndexes);
extern void check_exclusion_constraint(Relation heap, Relation index,
IndexInfo *indexInfo,
- ItemPointer tupleid,
+ const ItemPointerData *tupleid,
const Datum *values, const bool *isnull,
EState *estate, bool newIndex);
diff --git a/src/include/storage/itemptr.h b/src/include/storage/itemptr.h
index 74b87a9114a..2d48e55a7d7 100644
--- a/src/include/storage/itemptr.h
+++ b/src/include/storage/itemptr.h
@@ -132,7 +132,7 @@ ItemPointerGetOffsetNumber(const ItemPointerData *pointer)
* Sets a disk item pointer to the specified block and offset.
*/
static inline void
-ItemPointerSet(ItemPointerData *pointer, BlockNumber blockNumber, OffsetNumber offNum)
+ItemPointerSet(ItemPointer pointer, BlockNumber blockNumber, OffsetNumber offNum)
{
Assert(PointerIsValid(pointer));
BlockIdSet(&pointer->ip_blkid, blockNumber);
@@ -144,7 +144,7 @@ ItemPointerSet(ItemPointerData *pointer, BlockNumber blockNumber, OffsetNumber o
* Sets a disk item pointer to the specified block.
*/
static inline void
-ItemPointerSetBlockNumber(ItemPointerData *pointer, BlockNumber blockNumber)
+ItemPointerSetBlockNumber(ItemPointer pointer, BlockNumber blockNumber)
{
Assert(PointerIsValid(pointer));
BlockIdSet(&pointer->ip_blkid, blockNumber);
@@ -155,7 +155,7 @@ ItemPointerSetBlockNumber(ItemPointerData *pointer, BlockNumber blockNumber)
* Sets a disk item pointer to the specified offset.
*/
static inline void
-ItemPointerSetOffsetNumber(ItemPointerData *pointer, OffsetNumber offsetNumber)
+ItemPointerSetOffsetNumber(ItemPointer pointer, OffsetNumber offsetNumber)
{
Assert(PointerIsValid(pointer));
pointer->ip_posid = offsetNumber;
@@ -217,8 +217,8 @@ ItemPointerSetMovedPartitions(ItemPointerData *pointer)
* ----------------
*/
-extern bool ItemPointerEquals(ItemPointer pointer1, ItemPointer pointer2);
-extern int32 ItemPointerCompare(ItemPointer arg1, ItemPointer arg2);
+extern bool ItemPointerEquals(const ItemPointerData *pointer1, const ItemPointerData *pointer2);
+extern int32 ItemPointerCompare(const ItemPointerData *arg1, const ItemPointerData *arg2);
extern void ItemPointerInc(ItemPointer pointer);
extern void ItemPointerDec(ItemPointer pointer);
diff --git a/src/include/storage/predicate.h b/src/include/storage/predicate.h
index c1e3a4d9f64..8f5f0348a23 100644
--- a/src/include/storage/predicate.h
+++ b/src/include/storage/predicate.h
@@ -54,7 +54,7 @@ extern void SetSerializableTransactionSnapshot(Snapshot snapshot,
extern void RegisterPredicateLockingXid(TransactionId xid);
extern void PredicateLockRelation(Relation relation, Snapshot snapshot);
extern void PredicateLockPage(Relation relation, BlockNumber blkno, Snapshot snapshot);
-extern void PredicateLockTID(Relation relation, ItemPointer tid, Snapshot snapshot,
+extern void PredicateLockTID(Relation relation, const ItemPointerData *tid, Snapshot snapshot,
TransactionId tuple_xid);
extern void PredicateLockPageSplit(Relation relation, BlockNumber oldblkno, BlockNumber newblkno);
extern void PredicateLockPageCombine(Relation relation, BlockNumber oldblkno, BlockNumber newblkno);
@@ -64,7 +64,7 @@ extern void ReleasePredicateLocks(bool isCommit, bool isReadOnlySafe);
/* conflict detection (may also trigger rollback) */
extern bool CheckForSerializableConflictOutNeeded(Relation relation, Snapshot snapshot);
extern void CheckForSerializableConflictOut(Relation relation, TransactionId xid, Snapshot snapshot);
-extern void CheckForSerializableConflictIn(Relation relation, ItemPointer tid, BlockNumber blkno);
+extern void CheckForSerializableConflictIn(Relation relation, const ItemPointerData *tid, BlockNumber blkno);
extern void CheckTableForSerializableConflictIn(Relation relation);
/* final rollback checking */
diff --git a/src/include/utils/tuplesort.h b/src/include/utils/tuplesort.h
index ef79f259f93..0bf55902aa1 100644
--- a/src/include/utils/tuplesort.h
+++ b/src/include/utils/tuplesort.h
@@ -458,7 +458,7 @@ extern void tuplesort_puttupleslot(Tuplesortstate *state,
TupleTableSlot *slot);
extern void tuplesort_putheaptuple(Tuplesortstate *state, HeapTuple tup);
extern void tuplesort_putindextuplevalues(Tuplesortstate *state,
- Relation rel, ItemPointer self,
+ Relation rel, const ItemPointerData *self,
const Datum *values, const bool *isnull);
extern void tuplesort_putbrintuple(Tuplesortstate *state, BrinTuple *tuple, Size size);
extern void tuplesort_putgintuple(Tuplesortstate *state, GinTuple *tuple, Size size);
--
2.39.5 (Apple Git-154)
v2 tries to fix the CI failure.
Chao Li (Evan)
---------------------
HighGo Software Co., Ltd.
https://www.highgo.com/
Attachments:
v2-0001-Mark-ItemPointer-arguments-as-const-thoughoutly.patchapplication/octet-stream; name=v2-0001-Mark-ItemPointer-arguments-as-const-thoughoutly.patchDownload
From 2144f43551d2ac562b8692c4c5cfe33e309780d6 Mon Sep 17 00:00:00 2001
From: "Chao Li (Evan)" <lic@highgo.com>
Date: Wed, 10 Sep 2025 10:18:30 +0800
Subject: [PATCH v2] Mark ItemPointer arguments as const thoughoutly
This is a follow up 991295f. I searched over the src/ and make all
ItemPointer arguments as const as much as possible.
Author: Chao Li <li.evan.chao@gmail.com>
Discussion: https://www.postgresql.org/message-id/CAEoWx2nBaypg16Z5ciHuKw66pk850RFWw9ACS2DqqJ_AkKeRsw%40mail.gmail.com
---
src/backend/access/common/tidstore.c | 2 +-
src/backend/access/hash/hashsort.c | 2 +-
src/backend/access/heap/heapam.c | 38 +++++++++++-----------
src/backend/access/heap/heapam_handler.c | 8 ++---
src/backend/access/nbtree/nbtdedup.c | 2 +-
src/backend/access/nbtree/nbtsearch.c | 4 +--
src/backend/access/nbtree/nbtsort.c | 4 +--
src/backend/access/nbtree/nbtsplitloc.c | 4 +--
src/backend/access/spgist/spgdoinsert.c | 2 +-
src/backend/access/spgist/spgutils.c | 2 +-
src/backend/access/spgist/spgvacuum.c | 4 +--
src/backend/access/table/tableam.c | 4 +--
src/backend/catalog/index.c | 4 +--
src/backend/catalog/indexing.c | 6 ++--
src/backend/commands/vacuum.c | 4 +--
src/backend/executor/execIndexing.c | 8 ++---
src/backend/executor/nodeModifyTable.c | 4 +--
src/backend/storage/lmgr/predicate.c | 8 ++---
src/backend/storage/page/itemptr.c | 4 +--
src/backend/utils/adt/tid.c | 6 ++--
src/backend/utils/sort/tuplesortvariants.c | 2 +-
src/include/access/genam.h | 2 +-
src/include/access/hash.h | 2 +-
src/include/access/heapam.h | 16 ++++-----
src/include/access/nbtree.h | 2 +-
src/include/access/spgist_private.h | 4 +--
src/include/access/tableam.h | 22 ++++++-------
src/include/access/tidstore.h | 2 +-
src/include/catalog/index.h | 2 +-
src/include/catalog/indexing.h | 6 ++--
src/include/executor/executor.h | 4 +--
src/include/storage/itemptr.h | 10 +++---
src/include/storage/predicate.h | 4 +--
src/include/utils/tuplesort.h | 2 +-
34 files changed, 100 insertions(+), 100 deletions(-)
diff --git a/src/backend/access/common/tidstore.c b/src/backend/access/common/tidstore.c
index 5bd75fb499c..fb807d9fe59 100644
--- a/src/backend/access/common/tidstore.c
+++ b/src/backend/access/common/tidstore.c
@@ -418,7 +418,7 @@ TidStoreSetBlockOffsets(TidStore *ts, BlockNumber blkno, OffsetNumber *offsets,
/* Return true if the given TID is present in the TidStore */
bool
-TidStoreIsMember(TidStore *ts, ItemPointer tid)
+TidStoreIsMember(TidStore *ts, const ItemPointerData *tid)
{
int wordnum;
int bitnum;
diff --git a/src/backend/access/hash/hashsort.c b/src/backend/access/hash/hashsort.c
index 6e8c0e68a92..92ae3cf53f5 100644
--- a/src/backend/access/hash/hashsort.c
+++ b/src/backend/access/hash/hashsort.c
@@ -106,7 +106,7 @@ _h_spooldestroy(HSpool *hspool)
* spool an index entry into the sort file.
*/
void
-_h_spool(HSpool *hspool, ItemPointer self, const Datum *values, const bool *isnull)
+_h_spool(HSpool *hspool, const ItemPointerData *self, const Datum *values, const bool *isnull)
{
tuplesort_putindextuplevalues(hspool->sortstate, hspool->index,
self, values, isnull);
diff --git a/src/backend/access/heap/heapam.c b/src/backend/access/heap/heapam.c
index 4c5ae205a7a..3aa4466b8a4 100644
--- a/src/backend/access/heap/heapam.c
+++ b/src/backend/access/heap/heapam.c
@@ -63,7 +63,7 @@ static XLogRecPtr log_heap_update(Relation reln, Buffer oldbuf,
bool all_visible_cleared, bool new_all_visible_cleared);
#ifdef USE_ASSERT_CHECKING
static void check_lock_if_inplace_updateable_rel(Relation relation,
- ItemPointer otid,
+ const ItemPointerData *otid,
HeapTuple newtup);
static void check_inplace_rel_lock(HeapTuple oldtup);
#endif
@@ -72,7 +72,7 @@ static Bitmapset *HeapDetermineColumnsInfo(Relation relation,
Bitmapset *external_cols,
HeapTuple oldtup, HeapTuple newtup,
bool *has_external);
-static bool heap_acquire_tuplock(Relation relation, ItemPointer tid,
+static bool heap_acquire_tuplock(Relation relation, const ItemPointerData *tid,
LockTupleMode mode, LockWaitPolicy wait_policy,
bool *have_tuple_lock);
static inline BlockNumber heapgettup_advance_block(HeapScanDesc scan,
@@ -86,7 +86,7 @@ static void compute_new_xmax_infomask(TransactionId xmax, uint16 old_infomask,
TransactionId *result_xmax, uint16 *result_infomask,
uint16 *result_infomask2);
static TM_Result heap_lock_updated_tuple(Relation rel, HeapTuple tuple,
- ItemPointer ctid, TransactionId xid,
+ const ItemPointerData *ctid, TransactionId xid,
LockTupleMode mode);
static void GetMultiXactIdHintBits(MultiXactId multi, uint16 *new_infomask,
uint16 *new_infomask2);
@@ -95,7 +95,7 @@ static TransactionId MultiXactIdGetUpdateXid(TransactionId xmax,
static bool DoesMultiXactIdConflict(MultiXactId multi, uint16 infomask,
LockTupleMode lockmode, bool *current_is_member);
static void MultiXactIdWait(MultiXactId multi, MultiXactStatus status, uint16 infomask,
- Relation rel, ItemPointer ctid, XLTW_Oper oper,
+ Relation rel, const ItemPointerData *ctid, XLTW_Oper oper,
int *remaining);
static bool ConditionalMultiXactIdWait(MultiXactId multi, MultiXactStatus status,
uint16 infomask, Relation rel, int *remaining,
@@ -1422,8 +1422,8 @@ heap_getnextslot(TableScanDesc sscan, ScanDirection direction, TupleTableSlot *s
}
void
-heap_set_tidrange(TableScanDesc sscan, ItemPointer mintid,
- ItemPointer maxtid)
+heap_set_tidrange(TableScanDesc sscan, const ItemPointerData *mintid,
+ const ItemPointerData *maxtid)
{
HeapScanDesc scan = (HeapScanDesc) sscan;
BlockNumber startBlk;
@@ -2775,7 +2775,7 @@ xmax_infomask_changed(uint16 new_infomask, uint16 old_infomask)
* generated by another transaction).
*/
TM_Result
-heap_delete(Relation relation, ItemPointer tid,
+heap_delete(Relation relation, const ItemPointerData *tid,
CommandId cid, Snapshot crosscheck, bool wait,
TM_FailureData *tmfd, bool changingPart)
{
@@ -3198,7 +3198,7 @@ l1:
* via ereport().
*/
void
-simple_heap_delete(Relation relation, ItemPointer tid)
+simple_heap_delete(Relation relation, const ItemPointerData *tid)
{
TM_Result result;
TM_FailureData tmfd;
@@ -3244,7 +3244,7 @@ simple_heap_delete(Relation relation, ItemPointer tid)
* generated by another transaction).
*/
TM_Result
-heap_update(Relation relation, ItemPointer otid, HeapTuple newtup,
+heap_update(Relation relation, const ItemPointerData *otid, HeapTuple newtup,
CommandId cid, Snapshot crosscheck, bool wait,
TM_FailureData *tmfd, LockTupleMode *lockmode,
TU_UpdateIndexes *update_indexes)
@@ -4227,7 +4227,7 @@ l2:
*/
static void
check_lock_if_inplace_updateable_rel(Relation relation,
- ItemPointer otid,
+ const ItemPointerData *otid,
HeapTuple newtup)
{
/* LOCKTAG_TUPLE acceptable for any catalog */
@@ -4488,7 +4488,7 @@ HeapDetermineColumnsInfo(Relation relation,
* via ereport().
*/
void
-simple_heap_update(Relation relation, ItemPointer otid, HeapTuple tup,
+simple_heap_update(Relation relation, const ItemPointerData *otid, HeapTuple tup,
TU_UpdateIndexes *update_indexes)
{
TM_Result result;
@@ -5275,7 +5275,7 @@ out_unlocked:
* wait_policy is Skip.
*/
static bool
-heap_acquire_tuplock(Relation relation, ItemPointer tid, LockTupleMode mode,
+heap_acquire_tuplock(Relation relation, const ItemPointerData *tid, LockTupleMode mode,
LockWaitPolicy wait_policy, bool *have_tuple_lock)
{
if (*have_tuple_lock)
@@ -5696,7 +5696,7 @@ test_lockmode_for_conflict(MultiXactStatus status, TransactionId xid,
* version as well.
*/
static TM_Result
-heap_lock_updated_tuple_rec(Relation rel, ItemPointer tid, TransactionId xid,
+heap_lock_updated_tuple_rec(Relation rel, const ItemPointerData *tid, TransactionId xid,
LockTupleMode mode)
{
TM_Result result;
@@ -6041,7 +6041,7 @@ out_unlocked:
* levels, because that would lead to a serializability failure.
*/
static TM_Result
-heap_lock_updated_tuple(Relation rel, HeapTuple tuple, ItemPointer ctid,
+heap_lock_updated_tuple(Relation rel, HeapTuple tuple, const ItemPointerData *ctid,
TransactionId xid, LockTupleMode mode)
{
/*
@@ -6086,7 +6086,7 @@ heap_lock_updated_tuple(Relation rel, HeapTuple tuple, ItemPointer ctid,
* An explicit confirmation WAL record also makes logical decoding simpler.
*/
void
-heap_finish_speculative(Relation relation, ItemPointer tid)
+heap_finish_speculative(Relation relation, const ItemPointerData *tid)
{
Buffer buffer;
Page page;
@@ -6173,7 +6173,7 @@ heap_finish_speculative(Relation relation, ItemPointer tid)
* confirmation records.
*/
void
-heap_abort_speculative(Relation relation, ItemPointer tid)
+heap_abort_speculative(Relation relation, const ItemPointerData *tid)
{
TransactionId xid = GetCurrentTransactionId();
ItemId lp;
@@ -7695,7 +7695,7 @@ DoesMultiXactIdConflict(MultiXactId multi, uint16 infomask,
static bool
Do_MultiXactIdWait(MultiXactId multi, MultiXactStatus status,
uint16 infomask, bool nowait,
- Relation rel, ItemPointer ctid, XLTW_Oper oper,
+ Relation rel, const ItemPointerData *ctid, XLTW_Oper oper,
int *remaining, bool logLockFailure)
{
bool result = true;
@@ -7772,7 +7772,7 @@ Do_MultiXactIdWait(MultiXactId multi, MultiXactStatus status,
*/
static void
MultiXactIdWait(MultiXactId multi, MultiXactStatus status, uint16 infomask,
- Relation rel, ItemPointer ctid, XLTW_Oper oper,
+ Relation rel, const ItemPointerData *ctid, XLTW_Oper oper,
int *remaining)
{
(void) Do_MultiXactIdWait(multi, status, infomask, false,
@@ -8058,7 +8058,7 @@ index_delete_prefetch_buffer(Relation rel,
static inline void
index_delete_check_htid(TM_IndexDeleteOp *delstate,
Page page, OffsetNumber maxoff,
- ItemPointer htid, TM_IndexStatus *istatus)
+ const ItemPointerData *htid, TM_IndexStatus *istatus)
{
OffsetNumber indexpagehoffnum = ItemPointerGetOffsetNumber(htid);
ItemId iid;
diff --git a/src/backend/access/heap/heapam_handler.c b/src/backend/access/heap/heapam_handler.c
index bcbac844bb6..6d23a21841c 100644
--- a/src/backend/access/heap/heapam_handler.c
+++ b/src/backend/access/heap/heapam_handler.c
@@ -181,7 +181,7 @@ heapam_index_fetch_tuple(struct IndexFetchTableData *scan,
static bool
heapam_fetch_row_version(Relation relation,
- ItemPointer tid,
+ const ItemPointerData *tid,
Snapshot snapshot,
TupleTableSlot *slot)
{
@@ -204,7 +204,7 @@ heapam_fetch_row_version(Relation relation,
}
static bool
-heapam_tuple_tid_valid(TableScanDesc scan, ItemPointer tid)
+heapam_tuple_tid_valid(TableScanDesc scan, const ItemPointerData *tid)
{
HeapScanDesc hscan = (HeapScanDesc) scan;
@@ -300,7 +300,7 @@ heapam_tuple_complete_speculative(Relation relation, TupleTableSlot *slot,
}
static TM_Result
-heapam_tuple_delete(Relation relation, ItemPointer tid, CommandId cid,
+heapam_tuple_delete(Relation relation, const ItemPointerData *tid, CommandId cid,
Snapshot snapshot, Snapshot crosscheck, bool wait,
TM_FailureData *tmfd, bool changingPart)
{
@@ -314,7 +314,7 @@ heapam_tuple_delete(Relation relation, ItemPointer tid, CommandId cid,
static TM_Result
-heapam_tuple_update(Relation relation, ItemPointer otid, TupleTableSlot *slot,
+heapam_tuple_update(Relation relation, const ItemPointerData *otid, TupleTableSlot *slot,
CommandId cid, Snapshot snapshot, Snapshot crosscheck,
bool wait, TM_FailureData *tmfd,
LockTupleMode *lockmode, TU_UpdateIndexes *update_indexes)
diff --git a/src/backend/access/nbtree/nbtdedup.c b/src/backend/access/nbtree/nbtdedup.c
index ab0b6946cb0..f430c8bc3ee 100644
--- a/src/backend/access/nbtree/nbtdedup.c
+++ b/src/backend/access/nbtree/nbtdedup.c
@@ -862,7 +862,7 @@ _bt_singleval_fillfactor(Page page, BTDedupState state, Size newitemsz)
* returned posting list tuple (they must be included in htids array.)
*/
IndexTuple
-_bt_form_posting(IndexTuple base, ItemPointer htids, int nhtids)
+_bt_form_posting(IndexTuple base, const ItemPointerData *htids, int nhtids)
{
uint32 keysize,
newsize;
diff --git a/src/backend/access/nbtree/nbtsearch.c b/src/backend/access/nbtree/nbtsearch.c
index d69798795b4..7ae2bc8b66a 100644
--- a/src/backend/access/nbtree/nbtsearch.c
+++ b/src/backend/access/nbtree/nbtsearch.c
@@ -37,7 +37,7 @@ static bool _bt_readpage(IndexScanDesc scan, ScanDirection dir,
static void _bt_saveitem(BTScanOpaque so, int itemIndex,
OffsetNumber offnum, IndexTuple itup);
static int _bt_setuppostingitems(BTScanOpaque so, int itemIndex,
- OffsetNumber offnum, ItemPointer heapTid,
+ OffsetNumber offnum, const ItemPointerData *heapTid,
IndexTuple itup);
static inline void _bt_savepostingitem(BTScanOpaque so, int itemIndex,
OffsetNumber offnum,
@@ -2079,7 +2079,7 @@ _bt_saveitem(BTScanOpaque so, int itemIndex,
*/
static int
_bt_setuppostingitems(BTScanOpaque so, int itemIndex, OffsetNumber offnum,
- ItemPointer heapTid, IndexTuple itup)
+ const ItemPointerData *heapTid, IndexTuple itup)
{
BTScanPosItem *currItem = &so->currPos.items[itemIndex];
diff --git a/src/backend/access/nbtree/nbtsort.c b/src/backend/access/nbtree/nbtsort.c
index 8828a7a8f89..235f19b86ab 100644
--- a/src/backend/access/nbtree/nbtsort.c
+++ b/src/backend/access/nbtree/nbtsort.c
@@ -257,7 +257,7 @@ typedef struct BTWriteState
static double _bt_spools_heapscan(Relation heap, Relation index,
BTBuildState *buildstate, IndexInfo *indexInfo);
static void _bt_spooldestroy(BTSpool *btspool);
-static void _bt_spool(BTSpool *btspool, ItemPointer self,
+static void _bt_spool(BTSpool *btspool, const ItemPointerData *self,
Datum *values, bool *isnull);
static void _bt_leafbuild(BTSpool *btspool, BTSpool *btspool2);
static void _bt_build_callback(Relation index, ItemPointer tid, Datum *values,
@@ -525,7 +525,7 @@ _bt_spooldestroy(BTSpool *btspool)
* spool an index entry into the sort file.
*/
static void
-_bt_spool(BTSpool *btspool, ItemPointer self, Datum *values, bool *isnull)
+_bt_spool(BTSpool *btspool, const ItemPointerData *self, Datum *values, bool *isnull)
{
tuplesort_putindextuplevalues(btspool->sortstate, btspool->index,
self, values, isnull);
diff --git a/src/backend/access/nbtree/nbtsplitloc.c b/src/backend/access/nbtree/nbtsplitloc.c
index b88c396195a..f0082f88c76 100644
--- a/src/backend/access/nbtree/nbtsplitloc.c
+++ b/src/backend/access/nbtree/nbtsplitloc.c
@@ -69,7 +69,7 @@ static void _bt_deltasortsplits(FindSplitData *state, double fillfactormult,
static int _bt_splitcmp(const void *arg1, const void *arg2);
static bool _bt_afternewitemoff(FindSplitData *state, OffsetNumber maxoff,
int leaffillfactor, bool *usemult);
-static bool _bt_adjacenthtid(ItemPointer lowhtid, ItemPointer highhtid);
+static bool _bt_adjacenthtid(const ItemPointerData *lowhtid, const ItemPointerData *highhtid);
static OffsetNumber _bt_bestsplitloc(FindSplitData *state, int perfectpenalty,
bool *newitemonleft, FindSplitStrat strategy);
static int _bt_defaultinterval(FindSplitData *state);
@@ -747,7 +747,7 @@ _bt_afternewitemoff(FindSplitData *state, OffsetNumber maxoff,
* transaction.
*/
static bool
-_bt_adjacenthtid(ItemPointer lowhtid, ItemPointer highhtid)
+_bt_adjacenthtid(const ItemPointerData *lowhtid, const ItemPointerData *highhtid)
{
BlockNumber lowblk,
highblk;
diff --git a/src/backend/access/spgist/spgdoinsert.c b/src/backend/access/spgist/spgdoinsert.c
index af6b27b2135..c78c3794261 100644
--- a/src/backend/access/spgist/spgdoinsert.c
+++ b/src/backend/access/spgist/spgdoinsert.c
@@ -1912,7 +1912,7 @@ spgSplitNodeAction(Relation index, SpGistState *state,
*/
bool
spgdoinsert(Relation index, SpGistState *state,
- ItemPointer heapPtr, Datum *datums, bool *isnulls)
+ const ItemPointerData *heapPtr, Datum *datums, bool *isnulls)
{
bool result = true;
TupleDesc leafDescriptor = state->leafTupDesc;
diff --git a/src/backend/access/spgist/spgutils.c b/src/backend/access/spgist/spgutils.c
index 9b86c016acb..09d1df090cf 100644
--- a/src/backend/access/spgist/spgutils.c
+++ b/src/backend/access/spgist/spgutils.c
@@ -868,7 +868,7 @@ SpGistGetLeafTupleSize(TupleDesc tupleDescriptor,
* Construct a leaf tuple containing the given heap TID and datum values
*/
SpGistLeafTuple
-spgFormLeafTuple(SpGistState *state, ItemPointer heapPtr,
+spgFormLeafTuple(SpGistState *state, const ItemPointerData *heapPtr,
const Datum *datums, const bool *isnulls)
{
SpGistLeafTuple tup;
diff --git a/src/backend/access/spgist/spgvacuum.c b/src/backend/access/spgist/spgvacuum.c
index 8f8a1ad7796..b552c01ebcd 100644
--- a/src/backend/access/spgist/spgvacuum.c
+++ b/src/backend/access/spgist/spgvacuum.c
@@ -61,7 +61,7 @@ typedef struct spgBulkDeleteState
* ensures that scans of the list don't miss items added during the scan.
*/
static void
-spgAddPendingTID(spgBulkDeleteState *bds, ItemPointer tid)
+spgAddPendingTID(spgBulkDeleteState *bds, const ItemPointerData *tid)
{
spgVacPendingItem *pitem;
spgVacPendingItem **listLink;
@@ -967,7 +967,7 @@ spgbulkdelete(IndexVacuumInfo *info, IndexBulkDeleteResult *stats,
/* Dummy callback to delete no tuples during spgvacuumcleanup */
static bool
-dummy_callback(ItemPointer itemptr, void *state)
+dummy_callback(const ItemPointerData *itemptr, void *state)
{
return false;
}
diff --git a/src/backend/access/table/tableam.c b/src/backend/access/table/tableam.c
index a56c5eceb14..c643ec2106d 100644
--- a/src/backend/access/table/tableam.c
+++ b/src/backend/access/table/tableam.c
@@ -288,7 +288,7 @@ simple_table_tuple_insert(Relation rel, TupleTableSlot *slot)
* via ereport().
*/
void
-simple_table_tuple_delete(Relation rel, ItemPointer tid, Snapshot snapshot)
+simple_table_tuple_delete(Relation rel, const ItemPointerData *tid, Snapshot snapshot)
{
TM_Result result;
TM_FailureData tmfd;
@@ -333,7 +333,7 @@ simple_table_tuple_delete(Relation rel, ItemPointer tid, Snapshot snapshot)
* via ereport().
*/
void
-simple_table_tuple_update(Relation rel, ItemPointer otid,
+simple_table_tuple_update(Relation rel, const ItemPointerData *otid,
TupleTableSlot *slot,
Snapshot snapshot,
TU_UpdateIndexes *update_indexes)
diff --git a/src/backend/catalog/index.c b/src/backend/catalog/index.c
index c4029a4f3d3..ebc1f448f06 100644
--- a/src/backend/catalog/index.c
+++ b/src/backend/catalog/index.c
@@ -126,7 +126,7 @@ static void index_update_stats(Relation rel,
static void IndexCheckExclusion(Relation heapRelation,
Relation indexRelation,
IndexInfo *indexInfo);
-static bool validate_index_callback(ItemPointer itemptr, void *opaque);
+static bool validate_index_callback(const ItemPointerData *itemptr, void *opaque);
static bool ReindexIsCurrentlyProcessingIndex(Oid indexOid);
static void SetReindexProcessing(Oid heapOid, Oid indexOid);
static void ResetReindexProcessing(void);
@@ -3480,7 +3480,7 @@ validate_index(Oid heapId, Oid indexId, Snapshot snapshot)
* validate_index_callback - bulkdelete callback to collect the index TIDs
*/
static bool
-validate_index_callback(ItemPointer itemptr, void *opaque)
+validate_index_callback(const ItemPointerData *itemptr, void *opaque)
{
ValidateIndexState *state = (ValidateIndexState *) opaque;
int64 encoded = itemptr_encode(itemptr);
diff --git a/src/backend/catalog/indexing.c b/src/backend/catalog/indexing.c
index 25c4b6bdc87..004c5121000 100644
--- a/src/backend/catalog/indexing.c
+++ b/src/backend/catalog/indexing.c
@@ -310,7 +310,7 @@ CatalogTuplesMultiInsertWithInfo(Relation heapRel, TupleTableSlot **slot,
* (Use CatalogTupleUpdateWithInfo in such cases.)
*/
void
-CatalogTupleUpdate(Relation heapRel, ItemPointer otid, HeapTuple tup)
+CatalogTupleUpdate(Relation heapRel, const ItemPointerData *otid, HeapTuple tup)
{
CatalogIndexState indstate;
TU_UpdateIndexes updateIndexes = TU_All;
@@ -334,7 +334,7 @@ CatalogTupleUpdate(Relation heapRel, ItemPointer otid, HeapTuple tup)
* so that callers needn't trouble over this ... but we don't do so today.
*/
void
-CatalogTupleUpdateWithInfo(Relation heapRel, ItemPointer otid, HeapTuple tup,
+CatalogTupleUpdateWithInfo(Relation heapRel, const ItemPointerData *otid, HeapTuple tup,
CatalogIndexState indstate)
{
TU_UpdateIndexes updateIndexes = TU_All;
@@ -362,7 +362,7 @@ CatalogTupleUpdateWithInfo(Relation heapRel, ItemPointer otid, HeapTuple tup,
* it might be better to do something about caching CatalogIndexState.
*/
void
-CatalogTupleDelete(Relation heapRel, ItemPointer tid)
+CatalogTupleDelete(Relation heapRel, const ItemPointerData *tid)
{
simple_heap_delete(heapRel, tid);
}
diff --git a/src/backend/commands/vacuum.c b/src/backend/commands/vacuum.c
index 733ef40ae7c..a5e0f8e2a03 100644
--- a/src/backend/commands/vacuum.c
+++ b/src/backend/commands/vacuum.c
@@ -128,7 +128,7 @@ static bool vacuum_rel(Oid relid, RangeVar *relation, VacuumParams params,
BufferAccessStrategy bstrategy);
static double compute_parallel_delay(void);
static VacOptValue get_vacoptval_from_boolean(DefElem *def);
-static bool vac_tid_reaped(ItemPointer itemptr, void *state);
+static bool vac_tid_reaped(const ItemPointerData *itemptr, void *state);
/*
* GUC check function to ensure GUC value specified is within the allowable
@@ -2674,7 +2674,7 @@ vac_cleanup_one_index(IndexVacuumInfo *ivinfo, IndexBulkDeleteResult *istat)
* This has the right signature to be an IndexBulkDeleteCallback.
*/
static bool
-vac_tid_reaped(ItemPointer itemptr, void *state)
+vac_tid_reaped(const ItemPointerData *itemptr, void *state)
{
TidStore *dead_items = (TidStore *) state;
diff --git a/src/backend/executor/execIndexing.c b/src/backend/executor/execIndexing.c
index ca33a854278..401606f840a 100644
--- a/src/backend/executor/execIndexing.c
+++ b/src/backend/executor/execIndexing.c
@@ -128,7 +128,7 @@ typedef enum
static bool check_exclusion_or_unique_constraint(Relation heap, Relation index,
IndexInfo *indexInfo,
- ItemPointer tupleid,
+ const ItemPointerData *tupleid,
const Datum *values, const bool *isnull,
EState *estate, bool newIndex,
CEOUC_WAIT_MODE waitMode,
@@ -541,7 +541,7 @@ ExecInsertIndexTuples(ResultRelInfo *resultRelInfo,
bool
ExecCheckIndexConstraints(ResultRelInfo *resultRelInfo, TupleTableSlot *slot,
EState *estate, ItemPointer conflictTid,
- ItemPointer tupleid, List *arbiterIndexes)
+ const ItemPointerData *tupleid, List *arbiterIndexes)
{
int i;
int numIndices;
@@ -703,7 +703,7 @@ ExecCheckIndexConstraints(ResultRelInfo *resultRelInfo, TupleTableSlot *slot,
static bool
check_exclusion_or_unique_constraint(Relation heap, Relation index,
IndexInfo *indexInfo,
- ItemPointer tupleid,
+ const ItemPointerData *tupleid,
const Datum *values, const bool *isnull,
EState *estate, bool newIndex,
CEOUC_WAIT_MODE waitMode,
@@ -955,7 +955,7 @@ retry:
void
check_exclusion_constraint(Relation heap, Relation index,
IndexInfo *indexInfo,
- ItemPointer tupleid,
+ const ItemPointerData *tupleid,
const Datum *values, const bool *isnull,
EState *estate, bool newIndex)
{
diff --git a/src/backend/executor/nodeModifyTable.c b/src/backend/executor/nodeModifyTable.c
index 4c5647ac38a..56ad7194e99 100644
--- a/src/backend/executor/nodeModifyTable.c
+++ b/src/backend/executor/nodeModifyTable.c
@@ -396,7 +396,7 @@ ExecCheckTupleVisible(EState *estate,
static void
ExecCheckTIDVisible(EState *estate,
ResultRelInfo *relinfo,
- ItemPointer tid,
+ const ItemPointerData *tid,
TupleTableSlot *tempSlot)
{
Relation rel = relinfo->ri_RelationDesc;
@@ -1490,7 +1490,7 @@ ExecDeletePrologue(ModifyTableContext *context, ResultRelInfo *resultRelInfo,
*/
static TM_Result
ExecDeleteAct(ModifyTableContext *context, ResultRelInfo *resultRelInfo,
- ItemPointer tupleid, bool changingPart)
+ const ItemPointerData *tupleid, bool changingPart)
{
EState *estate = context->estate;
diff --git a/src/backend/storage/lmgr/predicate.c b/src/backend/storage/lmgr/predicate.c
index c1d8511ad17..bb807d8c9cd 100644
--- a/src/backend/storage/lmgr/predicate.c
+++ b/src/backend/storage/lmgr/predicate.c
@@ -168,7 +168,7 @@
* PredicateLockRelation(Relation relation, Snapshot snapshot)
* PredicateLockPage(Relation relation, BlockNumber blkno,
* Snapshot snapshot)
- * PredicateLockTID(Relation relation, ItemPointer tid, Snapshot snapshot,
+ * PredicateLockTID(Relation relation, const ItemPointerData *tid, Snapshot snapshot,
* TransactionId tuple_xid)
* PredicateLockPageSplit(Relation relation, BlockNumber oldblkno,
* BlockNumber newblkno)
@@ -180,7 +180,7 @@
* conflict detection (may also trigger rollback)
* CheckForSerializableConflictOut(Relation relation, TransactionId xid,
* Snapshot snapshot)
- * CheckForSerializableConflictIn(Relation relation, ItemPointer tid,
+ * CheckForSerializableConflictIn(Relation relation, const ItemPointerData *tid,
* BlockNumber blkno)
* CheckTableForSerializableConflictIn(Relation relation)
*
@@ -2618,7 +2618,7 @@ PredicateLockPage(Relation relation, BlockNumber blkno, Snapshot snapshot)
* Skip if this is a temporary table.
*/
void
-PredicateLockTID(Relation relation, ItemPointer tid, Snapshot snapshot,
+PredicateLockTID(Relation relation, const ItemPointerData *tid, Snapshot snapshot,
TransactionId tuple_xid)
{
PREDICATELOCKTARGETTAG tag;
@@ -4333,7 +4333,7 @@ CheckTargetForConflictsIn(PREDICATELOCKTARGETTAG *targettag)
* tuple itself.
*/
void
-CheckForSerializableConflictIn(Relation relation, ItemPointer tid, BlockNumber blkno)
+CheckForSerializableConflictIn(Relation relation, const ItemPointerData *tid, BlockNumber blkno)
{
PREDICATELOCKTARGETTAG targettag;
diff --git a/src/backend/storage/page/itemptr.c b/src/backend/storage/page/itemptr.c
index ad658215721..cedb27d6cc5 100644
--- a/src/backend/storage/page/itemptr.c
+++ b/src/backend/storage/page/itemptr.c
@@ -32,7 +32,7 @@ StaticAssertDecl(sizeof(ItemPointerData) == 3 * sizeof(uint16),
* Asserts that the disk item pointers are both valid!
*/
bool
-ItemPointerEquals(ItemPointer pointer1, ItemPointer pointer2)
+ItemPointerEquals(const ItemPointerData *pointer1, const ItemPointerData *pointer2)
{
if (ItemPointerGetBlockNumber(pointer1) ==
ItemPointerGetBlockNumber(pointer2) &&
@@ -48,7 +48,7 @@ ItemPointerEquals(ItemPointer pointer1, ItemPointer pointer2)
* Generic btree-style comparison for item pointers.
*/
int32
-ItemPointerCompare(ItemPointer arg1, ItemPointer arg2)
+ItemPointerCompare(const ItemPointerData *arg1, const ItemPointerData *arg2)
{
/*
* Use ItemPointerGet{Offset,Block}NumberNoCheck to avoid asserting
diff --git a/src/backend/utils/adt/tid.c b/src/backend/utils/adt/tid.c
index 39dab3e42df..0cfb0bd3735 100644
--- a/src/backend/utils/adt/tid.c
+++ b/src/backend/utils/adt/tid.c
@@ -42,7 +42,7 @@
#define DELIM ','
#define NTIDARGS 2
-static ItemPointer currtid_for_view(Relation viewrel, ItemPointer tid);
+static ItemPointer currtid_for_view(Relation viewrel, const ItemPointerData *tid);
/* ----------------------------------------------------------------
* tidin
@@ -293,7 +293,7 @@ hashtidextended(PG_FUNCTION_ARGS)
* relation "rel".
*/
static ItemPointer
-currtid_internal(Relation rel, ItemPointer tid)
+currtid_internal(Relation rel, const ItemPointerData *tid)
{
ItemPointer result;
AclResult aclresult;
@@ -335,7 +335,7 @@ currtid_internal(Relation rel, ItemPointer tid)
* correspond to the CTID of a base relation.
*/
static ItemPointer
-currtid_for_view(Relation viewrel, ItemPointer tid)
+currtid_for_view(Relation viewrel, const ItemPointerData *tid)
{
TupleDesc att = RelationGetDescr(viewrel);
RuleLock *rulelock;
diff --git a/src/backend/utils/sort/tuplesortvariants.c b/src/backend/utils/sort/tuplesortvariants.c
index 890cdbe1204..41ac4afbf49 100644
--- a/src/backend/utils/sort/tuplesortvariants.c
+++ b/src/backend/utils/sort/tuplesortvariants.c
@@ -816,7 +816,7 @@ tuplesort_putheaptuple(Tuplesortstate *state, HeapTuple tup)
*/
void
tuplesort_putindextuplevalues(Tuplesortstate *state, Relation rel,
- ItemPointer self, const Datum *values,
+ const ItemPointerData *self, const Datum *values,
const bool *isnull)
{
SortTuple stup;
diff --git a/src/include/access/genam.h b/src/include/access/genam.h
index 5b2ab181b5f..b4a0d8b7885 100644
--- a/src/include/access/genam.h
+++ b/src/include/access/genam.h
@@ -107,7 +107,7 @@ typedef struct IndexBulkDeleteResult
} IndexBulkDeleteResult;
/* Typedef for callback function to determine if a tuple is bulk-deletable */
-typedef bool (*IndexBulkDeleteCallback) (ItemPointer itemptr, void *state);
+typedef bool (*IndexBulkDeleteCallback) (const ItemPointerData *itemptr, void *state);
/* struct definitions appear in relscan.h */
typedef struct IndexScanDescData *IndexScanDesc;
diff --git a/src/include/access/hash.h b/src/include/access/hash.h
index 073ad29b19b..2374d5cf049 100644
--- a/src/include/access/hash.h
+++ b/src/include/access/hash.h
@@ -453,7 +453,7 @@ typedef struct HSpool HSpool; /* opaque struct in hashsort.c */
extern HSpool *_h_spoolinit(Relation heap, Relation index, uint32 num_buckets);
extern void _h_spooldestroy(HSpool *hspool);
-extern void _h_spool(HSpool *hspool, ItemPointer self,
+extern void _h_spool(HSpool *hspool, const ItemPointerData *self,
const Datum *values, const bool *isnull);
extern void _h_indexbuild(HSpool *hspool, Relation heapRel);
diff --git a/src/include/access/heapam.h b/src/include/access/heapam.h
index a2bd5a897f8..339b23379ec 100644
--- a/src/include/access/heapam.h
+++ b/src/include/access/heapam.h
@@ -299,8 +299,8 @@ extern void heap_endscan(TableScanDesc sscan);
extern HeapTuple heap_getnext(TableScanDesc sscan, ScanDirection direction);
extern bool heap_getnextslot(TableScanDesc sscan,
ScanDirection direction, struct TupleTableSlot *slot);
-extern void heap_set_tidrange(TableScanDesc sscan, ItemPointer mintid,
- ItemPointer maxtid);
+extern void heap_set_tidrange(TableScanDesc sscan, const ItemPointerData *mintid,
+ const ItemPointerData *maxtid);
extern bool heap_getnextslot_tidrange(TableScanDesc sscan,
ScanDirection direction,
TupleTableSlot *slot);
@@ -321,12 +321,12 @@ extern void heap_insert(Relation relation, HeapTuple tup, CommandId cid,
extern void heap_multi_insert(Relation relation, struct TupleTableSlot **slots,
int ntuples, CommandId cid, int options,
BulkInsertState bistate);
-extern TM_Result heap_delete(Relation relation, ItemPointer tid,
+extern TM_Result heap_delete(Relation relation, const ItemPointerData *tid,
CommandId cid, Snapshot crosscheck, bool wait,
struct TM_FailureData *tmfd, bool changingPart);
-extern void heap_finish_speculative(Relation relation, ItemPointer tid);
-extern void heap_abort_speculative(Relation relation, ItemPointer tid);
-extern TM_Result heap_update(Relation relation, ItemPointer otid,
+extern void heap_finish_speculative(Relation relation, const ItemPointerData *tid);
+extern void heap_abort_speculative(Relation relation, const ItemPointerData *tid);
+extern TM_Result heap_update(Relation relation, const ItemPointerData *otid,
HeapTuple newtup,
CommandId cid, Snapshot crosscheck, bool wait,
struct TM_FailureData *tmfd, LockTupleMode *lockmode,
@@ -363,8 +363,8 @@ extern bool heap_tuple_should_freeze(HeapTupleHeader tuple,
extern bool heap_tuple_needs_eventual_freeze(HeapTupleHeader tuple);
extern void simple_heap_insert(Relation relation, HeapTuple tup);
-extern void simple_heap_delete(Relation relation, ItemPointer tid);
-extern void simple_heap_update(Relation relation, ItemPointer otid,
+extern void simple_heap_delete(Relation relation, const ItemPointerData *tid);
+extern void simple_heap_update(Relation relation, const ItemPointerData *otid,
HeapTuple tup, TU_UpdateIndexes *update_indexes);
extern TransactionId heap_index_delete_tuples(Relation rel,
diff --git a/src/include/access/nbtree.h b/src/include/access/nbtree.h
index 9ab467cb8fd..dd167a9257b 100644
--- a/src/include/access/nbtree.h
+++ b/src/include/access/nbtree.h
@@ -1233,7 +1233,7 @@ extern void _bt_dedup_start_pending(BTDedupState state, IndexTuple base,
OffsetNumber baseoff);
extern bool _bt_dedup_save_htid(BTDedupState state, IndexTuple itup);
extern Size _bt_dedup_finish_pending(Page newpage, BTDedupState state);
-extern IndexTuple _bt_form_posting(IndexTuple base, ItemPointer htids,
+extern IndexTuple _bt_form_posting(IndexTuple base, const ItemPointerData *htids,
int nhtids);
extern void _bt_update_posting(BTVacuumPosting vacposting);
extern IndexTuple _bt_swap_posting(IndexTuple newitem, IndexTuple oposting,
diff --git a/src/include/access/spgist_private.h b/src/include/access/spgist_private.h
index 56ac64f0597..9441f6cec15 100644
--- a/src/include/access/spgist_private.h
+++ b/src/include/access/spgist_private.h
@@ -511,7 +511,7 @@ extern unsigned int SpGistGetInnerTypeSize(SpGistTypeDesc *att, Datum datum);
extern Size SpGistGetLeafTupleSize(TupleDesc tupleDescriptor,
const Datum *datums, const bool *isnulls);
extern SpGistLeafTuple spgFormLeafTuple(SpGistState *state,
- ItemPointer heapPtr,
+ const ItemPointerData *heapPtr,
const Datum *datums, const bool *isnulls);
extern SpGistNodeTuple spgFormNodeTuple(SpGistState *state,
Datum label, bool isnull);
@@ -541,7 +541,7 @@ extern void spgPageIndexMultiDelete(SpGistState *state, Page page,
int firststate, int reststate,
BlockNumber blkno, OffsetNumber offnum);
extern bool spgdoinsert(Relation index, SpGistState *state,
- ItemPointer heapPtr, Datum *datums, bool *isnulls);
+ const ItemPointerData *heapPtr, Datum *datums, bool *isnulls);
/* spgproc.c */
extern double *spg_key_orderbys_distances(Datum key, bool isLeaf,
diff --git a/src/include/access/tableam.h b/src/include/access/tableam.h
index b2ce35e2a34..1afd9b8da2b 100644
--- a/src/include/access/tableam.h
+++ b/src/include/access/tableam.h
@@ -368,8 +368,8 @@ typedef struct TableAmRoutine
* further calls to scan_getnextslot_tidrange.
*/
void (*scan_set_tidrange) (TableScanDesc scan,
- ItemPointer mintid,
- ItemPointer maxtid);
+ const ItemPointerData *mintid,
+ const ItemPointerData *maxtid);
/*
* Return next tuple from `scan` that's in the range of TIDs defined by
@@ -470,7 +470,7 @@ typedef struct TableAmRoutine
* test, returns true, false otherwise.
*/
bool (*tuple_fetch_row_version) (Relation rel,
- ItemPointer tid,
+ const ItemPointerData *tid,
Snapshot snapshot,
TupleTableSlot *slot);
@@ -478,7 +478,7 @@ typedef struct TableAmRoutine
* Is tid valid for a scan of this relation.
*/
bool (*tuple_tid_valid) (TableScanDesc scan,
- ItemPointer tid);
+ const ItemPointerData *tid);
/*
* Return the latest version of the tuple at `tid`, by updating `tid` to
@@ -530,7 +530,7 @@ typedef struct TableAmRoutine
/* see table_tuple_delete() for reference about parameters */
TM_Result (*tuple_delete) (Relation rel,
- ItemPointer tid,
+ const ItemPointerData *tid,
CommandId cid,
Snapshot snapshot,
Snapshot crosscheck,
@@ -540,7 +540,7 @@ typedef struct TableAmRoutine
/* see table_tuple_update() for reference about parameters */
TM_Result (*tuple_update) (Relation rel,
- ItemPointer otid,
+ const ItemPointerData *otid,
TupleTableSlot *slot,
CommandId cid,
Snapshot snapshot,
@@ -1251,7 +1251,7 @@ extern bool table_index_fetch_tuple_check(Relation rel,
*/
static inline bool
table_tuple_fetch_row_version(Relation rel,
- ItemPointer tid,
+ const ItemPointerData *tid,
Snapshot snapshot,
TupleTableSlot *slot)
{
@@ -1453,7 +1453,7 @@ table_multi_insert(Relation rel, TupleTableSlot **slots, int nslots,
* TM_FailureData for additional info.
*/
static inline TM_Result
-table_tuple_delete(Relation rel, ItemPointer tid, CommandId cid,
+table_tuple_delete(Relation rel, const ItemPointerData *tid, CommandId cid,
Snapshot snapshot, Snapshot crosscheck, bool wait,
TM_FailureData *tmfd, bool changingPart)
{
@@ -1497,7 +1497,7 @@ table_tuple_delete(Relation rel, ItemPointer tid, CommandId cid,
* for additional info.
*/
static inline TM_Result
-table_tuple_update(Relation rel, ItemPointer otid, TupleTableSlot *slot,
+table_tuple_update(Relation rel, const ItemPointerData *otid, TupleTableSlot *slot,
CommandId cid, Snapshot snapshot, Snapshot crosscheck,
bool wait, TM_FailureData *tmfd, LockTupleMode *lockmode,
TU_UpdateIndexes *update_indexes)
@@ -2004,9 +2004,9 @@ table_scan_sample_next_tuple(TableScanDesc scan,
*/
extern void simple_table_tuple_insert(Relation rel, TupleTableSlot *slot);
-extern void simple_table_tuple_delete(Relation rel, ItemPointer tid,
+extern void simple_table_tuple_delete(Relation rel, const ItemPointerData *tid,
Snapshot snapshot);
-extern void simple_table_tuple_update(Relation rel, ItemPointer otid,
+extern void simple_table_tuple_update(Relation rel, const ItemPointerData *otid,
TupleTableSlot *slot, Snapshot snapshot,
TU_UpdateIndexes *update_indexes);
diff --git a/src/include/access/tidstore.h b/src/include/access/tidstore.h
index 041091df278..048e1df0e84 100644
--- a/src/include/access/tidstore.h
+++ b/src/include/access/tidstore.h
@@ -40,7 +40,7 @@ extern void TidStoreUnlock(TidStore *ts);
extern void TidStoreDestroy(TidStore *ts);
extern void TidStoreSetBlockOffsets(TidStore *ts, BlockNumber blkno, OffsetNumber *offsets,
int num_offsets);
-extern bool TidStoreIsMember(TidStore *ts, ItemPointer tid);
+extern bool TidStoreIsMember(TidStore *ts, const ItemPointerData *tid);
extern TidStoreIter *TidStoreBeginIterate(TidStore *ts);
extern TidStoreIterResult *TidStoreIterateNext(TidStoreIter *iter);
extern int TidStoreGetBlockOffsets(TidStoreIterResult *result,
diff --git a/src/include/catalog/index.h b/src/include/catalog/index.h
index 4daa8bef5ee..dda95e54903 100644
--- a/src/include/catalog/index.h
+++ b/src/include/catalog/index.h
@@ -187,7 +187,7 @@ extern void IndexSetParentIndex(Relation partitionIdx, Oid parentOid);
* As noted in validate_index(), this can be significantly faster.
*/
static inline int64
-itemptr_encode(ItemPointer itemptr)
+itemptr_encode(const ItemPointerData *itemptr)
{
BlockNumber block = ItemPointerGetBlockNumber(itemptr);
OffsetNumber offset = ItemPointerGetOffsetNumber(itemptr);
diff --git a/src/include/catalog/indexing.h b/src/include/catalog/indexing.h
index 667aca7ace8..77c17d3fb7a 100644
--- a/src/include/catalog/indexing.h
+++ b/src/include/catalog/indexing.h
@@ -44,11 +44,11 @@ extern void CatalogTuplesMultiInsertWithInfo(Relation heapRel,
TupleTableSlot **slot,
int ntuples,
CatalogIndexState indstate);
-extern void CatalogTupleUpdate(Relation heapRel, ItemPointer otid,
+extern void CatalogTupleUpdate(Relation heapRel, const ItemPointerData *otid,
HeapTuple tup);
extern void CatalogTupleUpdateWithInfo(Relation heapRel,
- ItemPointer otid, HeapTuple tup,
+ const ItemPointerData *otid, HeapTuple tup,
CatalogIndexState indstate);
-extern void CatalogTupleDelete(Relation heapRel, ItemPointer tid);
+extern void CatalogTupleDelete(Relation heapRel, const ItemPointerData *tid);
#endif /* INDEXING_H */
diff --git a/src/include/executor/executor.h b/src/include/executor/executor.h
index 31133514e84..cb506d254de 100644
--- a/src/include/executor/executor.h
+++ b/src/include/executor/executor.h
@@ -745,11 +745,11 @@ extern List *ExecInsertIndexTuples(ResultRelInfo *resultRelInfo,
extern bool ExecCheckIndexConstraints(ResultRelInfo *resultRelInfo,
TupleTableSlot *slot,
EState *estate, ItemPointer conflictTid,
- ItemPointer tupleid,
+ const ItemPointerData *tupleid,
List *arbiterIndexes);
extern void check_exclusion_constraint(Relation heap, Relation index,
IndexInfo *indexInfo,
- ItemPointer tupleid,
+ const ItemPointerData *tupleid,
const Datum *values, const bool *isnull,
EState *estate, bool newIndex);
diff --git a/src/include/storage/itemptr.h b/src/include/storage/itemptr.h
index 74b87a9114a..2d48e55a7d7 100644
--- a/src/include/storage/itemptr.h
+++ b/src/include/storage/itemptr.h
@@ -132,7 +132,7 @@ ItemPointerGetOffsetNumber(const ItemPointerData *pointer)
* Sets a disk item pointer to the specified block and offset.
*/
static inline void
-ItemPointerSet(ItemPointerData *pointer, BlockNumber blockNumber, OffsetNumber offNum)
+ItemPointerSet(ItemPointer pointer, BlockNumber blockNumber, OffsetNumber offNum)
{
Assert(PointerIsValid(pointer));
BlockIdSet(&pointer->ip_blkid, blockNumber);
@@ -144,7 +144,7 @@ ItemPointerSet(ItemPointerData *pointer, BlockNumber blockNumber, OffsetNumber o
* Sets a disk item pointer to the specified block.
*/
static inline void
-ItemPointerSetBlockNumber(ItemPointerData *pointer, BlockNumber blockNumber)
+ItemPointerSetBlockNumber(ItemPointer pointer, BlockNumber blockNumber)
{
Assert(PointerIsValid(pointer));
BlockIdSet(&pointer->ip_blkid, blockNumber);
@@ -155,7 +155,7 @@ ItemPointerSetBlockNumber(ItemPointerData *pointer, BlockNumber blockNumber)
* Sets a disk item pointer to the specified offset.
*/
static inline void
-ItemPointerSetOffsetNumber(ItemPointerData *pointer, OffsetNumber offsetNumber)
+ItemPointerSetOffsetNumber(ItemPointer pointer, OffsetNumber offsetNumber)
{
Assert(PointerIsValid(pointer));
pointer->ip_posid = offsetNumber;
@@ -217,8 +217,8 @@ ItemPointerSetMovedPartitions(ItemPointerData *pointer)
* ----------------
*/
-extern bool ItemPointerEquals(ItemPointer pointer1, ItemPointer pointer2);
-extern int32 ItemPointerCompare(ItemPointer arg1, ItemPointer arg2);
+extern bool ItemPointerEquals(const ItemPointerData *pointer1, const ItemPointerData *pointer2);
+extern int32 ItemPointerCompare(const ItemPointerData *arg1, const ItemPointerData *arg2);
extern void ItemPointerInc(ItemPointer pointer);
extern void ItemPointerDec(ItemPointer pointer);
diff --git a/src/include/storage/predicate.h b/src/include/storage/predicate.h
index c1e3a4d9f64..8f5f0348a23 100644
--- a/src/include/storage/predicate.h
+++ b/src/include/storage/predicate.h
@@ -54,7 +54,7 @@ extern void SetSerializableTransactionSnapshot(Snapshot snapshot,
extern void RegisterPredicateLockingXid(TransactionId xid);
extern void PredicateLockRelation(Relation relation, Snapshot snapshot);
extern void PredicateLockPage(Relation relation, BlockNumber blkno, Snapshot snapshot);
-extern void PredicateLockTID(Relation relation, ItemPointer tid, Snapshot snapshot,
+extern void PredicateLockTID(Relation relation, const ItemPointerData *tid, Snapshot snapshot,
TransactionId tuple_xid);
extern void PredicateLockPageSplit(Relation relation, BlockNumber oldblkno, BlockNumber newblkno);
extern void PredicateLockPageCombine(Relation relation, BlockNumber oldblkno, BlockNumber newblkno);
@@ -64,7 +64,7 @@ extern void ReleasePredicateLocks(bool isCommit, bool isReadOnlySafe);
/* conflict detection (may also trigger rollback) */
extern bool CheckForSerializableConflictOutNeeded(Relation relation, Snapshot snapshot);
extern void CheckForSerializableConflictOut(Relation relation, TransactionId xid, Snapshot snapshot);
-extern void CheckForSerializableConflictIn(Relation relation, ItemPointer tid, BlockNumber blkno);
+extern void CheckForSerializableConflictIn(Relation relation, const ItemPointerData *tid, BlockNumber blkno);
extern void CheckTableForSerializableConflictIn(Relation relation);
/* final rollback checking */
diff --git a/src/include/utils/tuplesort.h b/src/include/utils/tuplesort.h
index ef79f259f93..0bf55902aa1 100644
--- a/src/include/utils/tuplesort.h
+++ b/src/include/utils/tuplesort.h
@@ -458,7 +458,7 @@ extern void tuplesort_puttupleslot(Tuplesortstate *state,
TupleTableSlot *slot);
extern void tuplesort_putheaptuple(Tuplesortstate *state, HeapTuple tup);
extern void tuplesort_putindextuplevalues(Tuplesortstate *state,
- Relation rel, ItemPointer self,
+ Relation rel, const ItemPointerData *self,
const Datum *values, const bool *isnull);
extern void tuplesort_putbrintuple(Tuplesortstate *state, BrinTuple *tuple, Size size);
extern void tuplesort_putgintuple(Tuplesortstate *state, GinTuple *tuple, Size size);
--
2.39.5 (Apple Git-154)
On Sep 10, 2025, at 12:20, Chao Li <li.evan.chao@gmail.com> wrote:
v2 tries to fix the CI failure.
Chao Li (Evan)
---------------------
HighGo Software Co., Ltd.
https://www.highgo.com/<v2-0001-Mark-ItemPointer-arguments-as-const-thoughoutly.patch>
Here is the CF patch https://commitfest.postgresql.org/patch/6046/, and the CI tests passed.
Best regards,
--
Chao Li (Evan)
HighGo Software Co., Ltd.
https://www.highgo.com/
Hi,
On Wed, 10 Sept 2025 at 05:27, Chao Li <li.evan.chao@gmail.com> wrote:
Hi Hacker,
This is a follow up 991295f. I searched over the src/ and make all ItemPointer arguments as const as much as possible.
I made clean build and no waring found. And "make check" also passes. I will create a patch on CF to see if CI passes.
If you would like to run CI yourself, you can do so by forking the
Postgres GitHub repository and enabling Cirrus CI on your fork. Once
that is done, each commit will trigger a CI run. More details are
available in the README [1]https://git.postgresql.org/cgit/postgresql.git/tree/src/tools/ci/README.
[1]: https://git.postgresql.org/cgit/postgresql.git/tree/src/tools/ci/README
--
Regards,
Nazir Bilal Yavuz
Microsoft
On Wed, Sep 10, 2025 at 1:20 PM Chao Li <li.evan.chao@gmail.com> wrote:
On Sep 10, 2025, at 12:20, Chao Li <li.evan.chao@gmail.com> wrote:
v2 tries to fix the CI failure.
Chao Li (Evan)
---------------------
HighGo Software Co., Ltd.
https://www.highgo.com/<v2-0001-Mark-ItemPointer-arguments-as-const-thoughoutly.patch>
Here is the CF patch https://commitfest.postgresql.org/patch/6046/, and
the CI tests passed.
Rebased again to v3.
Chao Li (Evan)
---------------------
HighGo Software Co., Ltd.
https://www.highgo.com/
Attachments:
v3-0001-Mark-ItemPointer-arguments-as-const-thoughoutly.patchapplication/octet-stream; name=v3-0001-Mark-ItemPointer-arguments-as-const-thoughoutly.patchDownload
From 8ed854f841de31d1c7045bcb2c7b8330761c3581 Mon Sep 17 00:00:00 2001
From: "Chao Li (Evan)" <lic@highgo.com>
Date: Wed, 10 Sep 2025 10:18:30 +0800
Subject: [PATCH v3] Mark ItemPointer arguments as const thoughoutly
This is a follow up 991295f. I searched over the src/ and make all
ItemPointer arguments as const as much as possible.
Author: Chao Li <li.evan.chao@gmail.com>
Discussion: https://www.postgresql.org/message-id/CAEoWx2nBaypg16Z5ciHuKw66pk850RFWw9ACS2DqqJ_AkKeRsw%40mail.gmail.com
---
src/backend/access/common/tidstore.c | 2 +-
src/backend/access/hash/hashsort.c | 2 +-
src/backend/access/heap/heapam.c | 38 +++++++++++-----------
src/backend/access/heap/heapam_handler.c | 8 ++---
src/backend/access/nbtree/nbtdedup.c | 2 +-
src/backend/access/nbtree/nbtsearch.c | 4 +--
src/backend/access/nbtree/nbtsort.c | 4 +--
src/backend/access/nbtree/nbtsplitloc.c | 4 +--
src/backend/access/spgist/spgdoinsert.c | 2 +-
src/backend/access/spgist/spgutils.c | 2 +-
src/backend/access/spgist/spgvacuum.c | 4 +--
src/backend/access/table/tableam.c | 4 +--
src/backend/catalog/index.c | 4 +--
src/backend/catalog/indexing.c | 6 ++--
src/backend/commands/vacuum.c | 4 +--
src/backend/executor/execIndexing.c | 8 ++---
src/backend/executor/nodeModifyTable.c | 4 +--
src/backend/storage/lmgr/predicate.c | 8 ++---
src/backend/storage/page/itemptr.c | 4 +--
src/backend/utils/adt/tid.c | 6 ++--
src/backend/utils/sort/tuplesortvariants.c | 2 +-
src/include/access/genam.h | 2 +-
src/include/access/hash.h | 2 +-
src/include/access/heapam.h | 16 ++++-----
src/include/access/nbtree.h | 2 +-
src/include/access/spgist_private.h | 4 +--
src/include/access/tableam.h | 22 ++++++-------
src/include/access/tidstore.h | 2 +-
src/include/catalog/index.h | 2 +-
src/include/catalog/indexing.h | 6 ++--
src/include/executor/executor.h | 4 +--
src/include/storage/itemptr.h | 10 +++---
src/include/storage/predicate.h | 4 +--
src/include/utils/tuplesort.h | 2 +-
34 files changed, 100 insertions(+), 100 deletions(-)
diff --git a/src/backend/access/common/tidstore.c b/src/backend/access/common/tidstore.c
index 5bd75fb499c..fb807d9fe59 100644
--- a/src/backend/access/common/tidstore.c
+++ b/src/backend/access/common/tidstore.c
@@ -418,7 +418,7 @@ TidStoreSetBlockOffsets(TidStore *ts, BlockNumber blkno, OffsetNumber *offsets,
/* Return true if the given TID is present in the TidStore */
bool
-TidStoreIsMember(TidStore *ts, ItemPointer tid)
+TidStoreIsMember(TidStore *ts, const ItemPointerData *tid)
{
int wordnum;
int bitnum;
diff --git a/src/backend/access/hash/hashsort.c b/src/backend/access/hash/hashsort.c
index 6e8c0e68a92..92ae3cf53f5 100644
--- a/src/backend/access/hash/hashsort.c
+++ b/src/backend/access/hash/hashsort.c
@@ -106,7 +106,7 @@ _h_spooldestroy(HSpool *hspool)
* spool an index entry into the sort file.
*/
void
-_h_spool(HSpool *hspool, ItemPointer self, const Datum *values, const bool *isnull)
+_h_spool(HSpool *hspool, const ItemPointerData *self, const Datum *values, const bool *isnull)
{
tuplesort_putindextuplevalues(hspool->sortstate, hspool->index,
self, values, isnull);
diff --git a/src/backend/access/heap/heapam.c b/src/backend/access/heap/heapam.c
index ed0c0c2dc9f..283be71f767 100644
--- a/src/backend/access/heap/heapam.c
+++ b/src/backend/access/heap/heapam.c
@@ -63,7 +63,7 @@ static XLogRecPtr log_heap_update(Relation reln, Buffer oldbuf,
bool all_visible_cleared, bool new_all_visible_cleared);
#ifdef USE_ASSERT_CHECKING
static void check_lock_if_inplace_updateable_rel(Relation relation,
- ItemPointer otid,
+ const ItemPointerData *otid,
HeapTuple newtup);
static void check_inplace_rel_lock(HeapTuple oldtup);
#endif
@@ -72,7 +72,7 @@ static Bitmapset *HeapDetermineColumnsInfo(Relation relation,
Bitmapset *external_cols,
HeapTuple oldtup, HeapTuple newtup,
bool *has_external);
-static bool heap_acquire_tuplock(Relation relation, ItemPointer tid,
+static bool heap_acquire_tuplock(Relation relation, const ItemPointerData *tid,
LockTupleMode mode, LockWaitPolicy wait_policy,
bool *have_tuple_lock);
static inline BlockNumber heapgettup_advance_block(HeapScanDesc scan,
@@ -86,7 +86,7 @@ static void compute_new_xmax_infomask(TransactionId xmax, uint16 old_infomask,
TransactionId *result_xmax, uint16 *result_infomask,
uint16 *result_infomask2);
static TM_Result heap_lock_updated_tuple(Relation rel, HeapTuple tuple,
- ItemPointer ctid, TransactionId xid,
+ const ItemPointerData *ctid, TransactionId xid,
LockTupleMode mode);
static void GetMultiXactIdHintBits(MultiXactId multi, uint16 *new_infomask,
uint16 *new_infomask2);
@@ -95,7 +95,7 @@ static TransactionId MultiXactIdGetUpdateXid(TransactionId xmax,
static bool DoesMultiXactIdConflict(MultiXactId multi, uint16 infomask,
LockTupleMode lockmode, bool *current_is_member);
static void MultiXactIdWait(MultiXactId multi, MultiXactStatus status, uint16 infomask,
- Relation rel, ItemPointer ctid, XLTW_Oper oper,
+ Relation rel, const ItemPointerData *ctid, XLTW_Oper oper,
int *remaining);
static bool ConditionalMultiXactIdWait(MultiXactId multi, MultiXactStatus status,
uint16 infomask, Relation rel, int *remaining,
@@ -1422,8 +1422,8 @@ heap_getnextslot(TableScanDesc sscan, ScanDirection direction, TupleTableSlot *s
}
void
-heap_set_tidrange(TableScanDesc sscan, ItemPointer mintid,
- ItemPointer maxtid)
+heap_set_tidrange(TableScanDesc sscan, const ItemPointerData *mintid,
+ const ItemPointerData *maxtid)
{
HeapScanDesc scan = (HeapScanDesc) sscan;
BlockNumber startBlk;
@@ -2775,7 +2775,7 @@ xmax_infomask_changed(uint16 new_infomask, uint16 old_infomask)
* generated by another transaction).
*/
TM_Result
-heap_delete(Relation relation, ItemPointer tid,
+heap_delete(Relation relation, const ItemPointerData *tid,
CommandId cid, Snapshot crosscheck, bool wait,
TM_FailureData *tmfd, bool changingPart)
{
@@ -3198,7 +3198,7 @@ l1:
* via ereport().
*/
void
-simple_heap_delete(Relation relation, ItemPointer tid)
+simple_heap_delete(Relation relation, const ItemPointerData *tid)
{
TM_Result result;
TM_FailureData tmfd;
@@ -3244,7 +3244,7 @@ simple_heap_delete(Relation relation, ItemPointer tid)
* generated by another transaction).
*/
TM_Result
-heap_update(Relation relation, ItemPointer otid, HeapTuple newtup,
+heap_update(Relation relation, const ItemPointerData *otid, HeapTuple newtup,
CommandId cid, Snapshot crosscheck, bool wait,
TM_FailureData *tmfd, LockTupleMode *lockmode,
TU_UpdateIndexes *update_indexes)
@@ -4227,7 +4227,7 @@ l2:
*/
static void
check_lock_if_inplace_updateable_rel(Relation relation,
- ItemPointer otid,
+ const ItemPointerData *otid,
HeapTuple newtup)
{
/* LOCKTAG_TUPLE acceptable for any catalog */
@@ -4488,7 +4488,7 @@ HeapDetermineColumnsInfo(Relation relation,
* via ereport().
*/
void
-simple_heap_update(Relation relation, ItemPointer otid, HeapTuple tup,
+simple_heap_update(Relation relation, const ItemPointerData *otid, HeapTuple tup,
TU_UpdateIndexes *update_indexes)
{
TM_Result result;
@@ -5274,7 +5274,7 @@ out_unlocked:
* wait_policy is Skip.
*/
static bool
-heap_acquire_tuplock(Relation relation, ItemPointer tid, LockTupleMode mode,
+heap_acquire_tuplock(Relation relation, const ItemPointerData *tid, LockTupleMode mode,
LockWaitPolicy wait_policy, bool *have_tuple_lock)
{
if (*have_tuple_lock)
@@ -5695,7 +5695,7 @@ test_lockmode_for_conflict(MultiXactStatus status, TransactionId xid,
* version as well.
*/
static TM_Result
-heap_lock_updated_tuple_rec(Relation rel, ItemPointer tid, TransactionId xid,
+heap_lock_updated_tuple_rec(Relation rel, const ItemPointerData *tid, TransactionId xid,
LockTupleMode mode)
{
TM_Result result;
@@ -6040,7 +6040,7 @@ out_unlocked:
* levels, because that would lead to a serializability failure.
*/
static TM_Result
-heap_lock_updated_tuple(Relation rel, HeapTuple tuple, ItemPointer ctid,
+heap_lock_updated_tuple(Relation rel, HeapTuple tuple, const ItemPointerData *ctid,
TransactionId xid, LockTupleMode mode)
{
/*
@@ -6085,7 +6085,7 @@ heap_lock_updated_tuple(Relation rel, HeapTuple tuple, ItemPointer ctid,
* An explicit confirmation WAL record also makes logical decoding simpler.
*/
void
-heap_finish_speculative(Relation relation, ItemPointer tid)
+heap_finish_speculative(Relation relation, const ItemPointerData *tid)
{
Buffer buffer;
Page page;
@@ -6172,7 +6172,7 @@ heap_finish_speculative(Relation relation, ItemPointer tid)
* confirmation records.
*/
void
-heap_abort_speculative(Relation relation, ItemPointer tid)
+heap_abort_speculative(Relation relation, const ItemPointerData *tid)
{
TransactionId xid = GetCurrentTransactionId();
ItemId lp;
@@ -7694,7 +7694,7 @@ DoesMultiXactIdConflict(MultiXactId multi, uint16 infomask,
static bool
Do_MultiXactIdWait(MultiXactId multi, MultiXactStatus status,
uint16 infomask, bool nowait,
- Relation rel, ItemPointer ctid, XLTW_Oper oper,
+ Relation rel, const ItemPointerData *ctid, XLTW_Oper oper,
int *remaining, bool logLockFailure)
{
bool result = true;
@@ -7771,7 +7771,7 @@ Do_MultiXactIdWait(MultiXactId multi, MultiXactStatus status,
*/
static void
MultiXactIdWait(MultiXactId multi, MultiXactStatus status, uint16 infomask,
- Relation rel, ItemPointer ctid, XLTW_Oper oper,
+ Relation rel, const ItemPointerData *ctid, XLTW_Oper oper,
int *remaining)
{
(void) Do_MultiXactIdWait(multi, status, infomask, false,
@@ -8057,7 +8057,7 @@ index_delete_prefetch_buffer(Relation rel,
static inline void
index_delete_check_htid(TM_IndexDeleteOp *delstate,
Page page, OffsetNumber maxoff,
- ItemPointer htid, TM_IndexStatus *istatus)
+ const ItemPointerData *htid, TM_IndexStatus *istatus)
{
OffsetNumber indexpagehoffnum = ItemPointerGetOffsetNumber(htid);
ItemId iid;
diff --git a/src/backend/access/heap/heapam_handler.c b/src/backend/access/heap/heapam_handler.c
index bcbac844bb6..6d23a21841c 100644
--- a/src/backend/access/heap/heapam_handler.c
+++ b/src/backend/access/heap/heapam_handler.c
@@ -181,7 +181,7 @@ heapam_index_fetch_tuple(struct IndexFetchTableData *scan,
static bool
heapam_fetch_row_version(Relation relation,
- ItemPointer tid,
+ const ItemPointerData *tid,
Snapshot snapshot,
TupleTableSlot *slot)
{
@@ -204,7 +204,7 @@ heapam_fetch_row_version(Relation relation,
}
static bool
-heapam_tuple_tid_valid(TableScanDesc scan, ItemPointer tid)
+heapam_tuple_tid_valid(TableScanDesc scan, const ItemPointerData *tid)
{
HeapScanDesc hscan = (HeapScanDesc) scan;
@@ -300,7 +300,7 @@ heapam_tuple_complete_speculative(Relation relation, TupleTableSlot *slot,
}
static TM_Result
-heapam_tuple_delete(Relation relation, ItemPointer tid, CommandId cid,
+heapam_tuple_delete(Relation relation, const ItemPointerData *tid, CommandId cid,
Snapshot snapshot, Snapshot crosscheck, bool wait,
TM_FailureData *tmfd, bool changingPart)
{
@@ -314,7 +314,7 @@ heapam_tuple_delete(Relation relation, ItemPointer tid, CommandId cid,
static TM_Result
-heapam_tuple_update(Relation relation, ItemPointer otid, TupleTableSlot *slot,
+heapam_tuple_update(Relation relation, const ItemPointerData *otid, TupleTableSlot *slot,
CommandId cid, Snapshot snapshot, Snapshot crosscheck,
bool wait, TM_FailureData *tmfd,
LockTupleMode *lockmode, TU_UpdateIndexes *update_indexes)
diff --git a/src/backend/access/nbtree/nbtdedup.c b/src/backend/access/nbtree/nbtdedup.c
index ab0b6946cb0..f430c8bc3ee 100644
--- a/src/backend/access/nbtree/nbtdedup.c
+++ b/src/backend/access/nbtree/nbtdedup.c
@@ -862,7 +862,7 @@ _bt_singleval_fillfactor(Page page, BTDedupState state, Size newitemsz)
* returned posting list tuple (they must be included in htids array.)
*/
IndexTuple
-_bt_form_posting(IndexTuple base, ItemPointer htids, int nhtids)
+_bt_form_posting(IndexTuple base, const ItemPointerData *htids, int nhtids)
{
uint32 keysize,
newsize;
diff --git a/src/backend/access/nbtree/nbtsearch.c b/src/backend/access/nbtree/nbtsearch.c
index d69798795b4..7ae2bc8b66a 100644
--- a/src/backend/access/nbtree/nbtsearch.c
+++ b/src/backend/access/nbtree/nbtsearch.c
@@ -37,7 +37,7 @@ static bool _bt_readpage(IndexScanDesc scan, ScanDirection dir,
static void _bt_saveitem(BTScanOpaque so, int itemIndex,
OffsetNumber offnum, IndexTuple itup);
static int _bt_setuppostingitems(BTScanOpaque so, int itemIndex,
- OffsetNumber offnum, ItemPointer heapTid,
+ OffsetNumber offnum, const ItemPointerData *heapTid,
IndexTuple itup);
static inline void _bt_savepostingitem(BTScanOpaque so, int itemIndex,
OffsetNumber offnum,
@@ -2079,7 +2079,7 @@ _bt_saveitem(BTScanOpaque so, int itemIndex,
*/
static int
_bt_setuppostingitems(BTScanOpaque so, int itemIndex, OffsetNumber offnum,
- ItemPointer heapTid, IndexTuple itup)
+ const ItemPointerData *heapTid, IndexTuple itup)
{
BTScanPosItem *currItem = &so->currPos.items[itemIndex];
diff --git a/src/backend/access/nbtree/nbtsort.c b/src/backend/access/nbtree/nbtsort.c
index 8828a7a8f89..235f19b86ab 100644
--- a/src/backend/access/nbtree/nbtsort.c
+++ b/src/backend/access/nbtree/nbtsort.c
@@ -257,7 +257,7 @@ typedef struct BTWriteState
static double _bt_spools_heapscan(Relation heap, Relation index,
BTBuildState *buildstate, IndexInfo *indexInfo);
static void _bt_spooldestroy(BTSpool *btspool);
-static void _bt_spool(BTSpool *btspool, ItemPointer self,
+static void _bt_spool(BTSpool *btspool, const ItemPointerData *self,
Datum *values, bool *isnull);
static void _bt_leafbuild(BTSpool *btspool, BTSpool *btspool2);
static void _bt_build_callback(Relation index, ItemPointer tid, Datum *values,
@@ -525,7 +525,7 @@ _bt_spooldestroy(BTSpool *btspool)
* spool an index entry into the sort file.
*/
static void
-_bt_spool(BTSpool *btspool, ItemPointer self, Datum *values, bool *isnull)
+_bt_spool(BTSpool *btspool, const ItemPointerData *self, Datum *values, bool *isnull)
{
tuplesort_putindextuplevalues(btspool->sortstate, btspool->index,
self, values, isnull);
diff --git a/src/backend/access/nbtree/nbtsplitloc.c b/src/backend/access/nbtree/nbtsplitloc.c
index b88c396195a..f0082f88c76 100644
--- a/src/backend/access/nbtree/nbtsplitloc.c
+++ b/src/backend/access/nbtree/nbtsplitloc.c
@@ -69,7 +69,7 @@ static void _bt_deltasortsplits(FindSplitData *state, double fillfactormult,
static int _bt_splitcmp(const void *arg1, const void *arg2);
static bool _bt_afternewitemoff(FindSplitData *state, OffsetNumber maxoff,
int leaffillfactor, bool *usemult);
-static bool _bt_adjacenthtid(ItemPointer lowhtid, ItemPointer highhtid);
+static bool _bt_adjacenthtid(const ItemPointerData *lowhtid, const ItemPointerData *highhtid);
static OffsetNumber _bt_bestsplitloc(FindSplitData *state, int perfectpenalty,
bool *newitemonleft, FindSplitStrat strategy);
static int _bt_defaultinterval(FindSplitData *state);
@@ -747,7 +747,7 @@ _bt_afternewitemoff(FindSplitData *state, OffsetNumber maxoff,
* transaction.
*/
static bool
-_bt_adjacenthtid(ItemPointer lowhtid, ItemPointer highhtid)
+_bt_adjacenthtid(const ItemPointerData *lowhtid, const ItemPointerData *highhtid)
{
BlockNumber lowblk,
highblk;
diff --git a/src/backend/access/spgist/spgdoinsert.c b/src/backend/access/spgist/spgdoinsert.c
index af6b27b2135..c78c3794261 100644
--- a/src/backend/access/spgist/spgdoinsert.c
+++ b/src/backend/access/spgist/spgdoinsert.c
@@ -1912,7 +1912,7 @@ spgSplitNodeAction(Relation index, SpGistState *state,
*/
bool
spgdoinsert(Relation index, SpGistState *state,
- ItemPointer heapPtr, Datum *datums, bool *isnulls)
+ const ItemPointerData *heapPtr, Datum *datums, bool *isnulls)
{
bool result = true;
TupleDesc leafDescriptor = state->leafTupDesc;
diff --git a/src/backend/access/spgist/spgutils.c b/src/backend/access/spgist/spgutils.c
index 9b86c016acb..09d1df090cf 100644
--- a/src/backend/access/spgist/spgutils.c
+++ b/src/backend/access/spgist/spgutils.c
@@ -868,7 +868,7 @@ SpGistGetLeafTupleSize(TupleDesc tupleDescriptor,
* Construct a leaf tuple containing the given heap TID and datum values
*/
SpGistLeafTuple
-spgFormLeafTuple(SpGistState *state, ItemPointer heapPtr,
+spgFormLeafTuple(SpGistState *state, const ItemPointerData *heapPtr,
const Datum *datums, const bool *isnulls)
{
SpGistLeafTuple tup;
diff --git a/src/backend/access/spgist/spgvacuum.c b/src/backend/access/spgist/spgvacuum.c
index 8f8a1ad7796..b552c01ebcd 100644
--- a/src/backend/access/spgist/spgvacuum.c
+++ b/src/backend/access/spgist/spgvacuum.c
@@ -61,7 +61,7 @@ typedef struct spgBulkDeleteState
* ensures that scans of the list don't miss items added during the scan.
*/
static void
-spgAddPendingTID(spgBulkDeleteState *bds, ItemPointer tid)
+spgAddPendingTID(spgBulkDeleteState *bds, const ItemPointerData *tid)
{
spgVacPendingItem *pitem;
spgVacPendingItem **listLink;
@@ -967,7 +967,7 @@ spgbulkdelete(IndexVacuumInfo *info, IndexBulkDeleteResult *stats,
/* Dummy callback to delete no tuples during spgvacuumcleanup */
static bool
-dummy_callback(ItemPointer itemptr, void *state)
+dummy_callback(const ItemPointerData *itemptr, void *state)
{
return false;
}
diff --git a/src/backend/access/table/tableam.c b/src/backend/access/table/tableam.c
index 5e41404937e..17cc2c445b5 100644
--- a/src/backend/access/table/tableam.c
+++ b/src/backend/access/table/tableam.c
@@ -288,7 +288,7 @@ simple_table_tuple_insert(Relation rel, TupleTableSlot *slot)
* via ereport().
*/
void
-simple_table_tuple_delete(Relation rel, ItemPointer tid, Snapshot snapshot)
+simple_table_tuple_delete(Relation rel, const ItemPointerData *tid, Snapshot snapshot)
{
TM_Result result;
TM_FailureData tmfd;
@@ -333,7 +333,7 @@ simple_table_tuple_delete(Relation rel, ItemPointer tid, Snapshot snapshot)
* via ereport().
*/
void
-simple_table_tuple_update(Relation rel, ItemPointer otid,
+simple_table_tuple_update(Relation rel, const ItemPointerData *otid,
TupleTableSlot *slot,
Snapshot snapshot,
TU_UpdateIndexes *update_indexes)
diff --git a/src/backend/catalog/index.c b/src/backend/catalog/index.c
index 5d9db167e59..1fad80bcce9 100644
--- a/src/backend/catalog/index.c
+++ b/src/backend/catalog/index.c
@@ -126,7 +126,7 @@ static void index_update_stats(Relation rel,
static void IndexCheckExclusion(Relation heapRelation,
Relation indexRelation,
IndexInfo *indexInfo);
-static bool validate_index_callback(ItemPointer itemptr, void *opaque);
+static bool validate_index_callback(const ItemPointerData *itemptr, void *opaque);
static bool ReindexIsCurrentlyProcessingIndex(Oid indexOid);
static void SetReindexProcessing(Oid heapOid, Oid indexOid);
static void ResetReindexProcessing(void);
@@ -3480,7 +3480,7 @@ validate_index(Oid heapId, Oid indexId, Snapshot snapshot)
* validate_index_callback - bulkdelete callback to collect the index TIDs
*/
static bool
-validate_index_callback(ItemPointer itemptr, void *opaque)
+validate_index_callback(const ItemPointerData *itemptr, void *opaque)
{
ValidateIndexState *state = (ValidateIndexState *) opaque;
int64 encoded = itemptr_encode(itemptr);
diff --git a/src/backend/catalog/indexing.c b/src/backend/catalog/indexing.c
index 25c4b6bdc87..004c5121000 100644
--- a/src/backend/catalog/indexing.c
+++ b/src/backend/catalog/indexing.c
@@ -310,7 +310,7 @@ CatalogTuplesMultiInsertWithInfo(Relation heapRel, TupleTableSlot **slot,
* (Use CatalogTupleUpdateWithInfo in such cases.)
*/
void
-CatalogTupleUpdate(Relation heapRel, ItemPointer otid, HeapTuple tup)
+CatalogTupleUpdate(Relation heapRel, const ItemPointerData *otid, HeapTuple tup)
{
CatalogIndexState indstate;
TU_UpdateIndexes updateIndexes = TU_All;
@@ -334,7 +334,7 @@ CatalogTupleUpdate(Relation heapRel, ItemPointer otid, HeapTuple tup)
* so that callers needn't trouble over this ... but we don't do so today.
*/
void
-CatalogTupleUpdateWithInfo(Relation heapRel, ItemPointer otid, HeapTuple tup,
+CatalogTupleUpdateWithInfo(Relation heapRel, const ItemPointerData *otid, HeapTuple tup,
CatalogIndexState indstate)
{
TU_UpdateIndexes updateIndexes = TU_All;
@@ -362,7 +362,7 @@ CatalogTupleUpdateWithInfo(Relation heapRel, ItemPointer otid, HeapTuple tup,
* it might be better to do something about caching CatalogIndexState.
*/
void
-CatalogTupleDelete(Relation heapRel, ItemPointer tid)
+CatalogTupleDelete(Relation heapRel, const ItemPointerData *tid)
{
simple_heap_delete(heapRel, tid);
}
diff --git a/src/backend/commands/vacuum.c b/src/backend/commands/vacuum.c
index 733ef40ae7c..a5e0f8e2a03 100644
--- a/src/backend/commands/vacuum.c
+++ b/src/backend/commands/vacuum.c
@@ -128,7 +128,7 @@ static bool vacuum_rel(Oid relid, RangeVar *relation, VacuumParams params,
BufferAccessStrategy bstrategy);
static double compute_parallel_delay(void);
static VacOptValue get_vacoptval_from_boolean(DefElem *def);
-static bool vac_tid_reaped(ItemPointer itemptr, void *state);
+static bool vac_tid_reaped(const ItemPointerData *itemptr, void *state);
/*
* GUC check function to ensure GUC value specified is within the allowable
@@ -2674,7 +2674,7 @@ vac_cleanup_one_index(IndexVacuumInfo *ivinfo, IndexBulkDeleteResult *istat)
* This has the right signature to be an IndexBulkDeleteCallback.
*/
static bool
-vac_tid_reaped(ItemPointer itemptr, void *state)
+vac_tid_reaped(const ItemPointerData *itemptr, void *state)
{
TidStore *dead_items = (TidStore *) state;
diff --git a/src/backend/executor/execIndexing.c b/src/backend/executor/execIndexing.c
index ca33a854278..401606f840a 100644
--- a/src/backend/executor/execIndexing.c
+++ b/src/backend/executor/execIndexing.c
@@ -128,7 +128,7 @@ typedef enum
static bool check_exclusion_or_unique_constraint(Relation heap, Relation index,
IndexInfo *indexInfo,
- ItemPointer tupleid,
+ const ItemPointerData *tupleid,
const Datum *values, const bool *isnull,
EState *estate, bool newIndex,
CEOUC_WAIT_MODE waitMode,
@@ -541,7 +541,7 @@ ExecInsertIndexTuples(ResultRelInfo *resultRelInfo,
bool
ExecCheckIndexConstraints(ResultRelInfo *resultRelInfo, TupleTableSlot *slot,
EState *estate, ItemPointer conflictTid,
- ItemPointer tupleid, List *arbiterIndexes)
+ const ItemPointerData *tupleid, List *arbiterIndexes)
{
int i;
int numIndices;
@@ -703,7 +703,7 @@ ExecCheckIndexConstraints(ResultRelInfo *resultRelInfo, TupleTableSlot *slot,
static bool
check_exclusion_or_unique_constraint(Relation heap, Relation index,
IndexInfo *indexInfo,
- ItemPointer tupleid,
+ const ItemPointerData *tupleid,
const Datum *values, const bool *isnull,
EState *estate, bool newIndex,
CEOUC_WAIT_MODE waitMode,
@@ -955,7 +955,7 @@ retry:
void
check_exclusion_constraint(Relation heap, Relation index,
IndexInfo *indexInfo,
- ItemPointer tupleid,
+ const ItemPointerData *tupleid,
const Datum *values, const bool *isnull,
EState *estate, bool newIndex)
{
diff --git a/src/backend/executor/nodeModifyTable.c b/src/backend/executor/nodeModifyTable.c
index 4c5647ac38a..56ad7194e99 100644
--- a/src/backend/executor/nodeModifyTable.c
+++ b/src/backend/executor/nodeModifyTable.c
@@ -396,7 +396,7 @@ ExecCheckTupleVisible(EState *estate,
static void
ExecCheckTIDVisible(EState *estate,
ResultRelInfo *relinfo,
- ItemPointer tid,
+ const ItemPointerData *tid,
TupleTableSlot *tempSlot)
{
Relation rel = relinfo->ri_RelationDesc;
@@ -1490,7 +1490,7 @@ ExecDeletePrologue(ModifyTableContext *context, ResultRelInfo *resultRelInfo,
*/
static TM_Result
ExecDeleteAct(ModifyTableContext *context, ResultRelInfo *resultRelInfo,
- ItemPointer tupleid, bool changingPart)
+ const ItemPointerData *tupleid, bool changingPart)
{
EState *estate = context->estate;
diff --git a/src/backend/storage/lmgr/predicate.c b/src/backend/storage/lmgr/predicate.c
index c1d8511ad17..bb807d8c9cd 100644
--- a/src/backend/storage/lmgr/predicate.c
+++ b/src/backend/storage/lmgr/predicate.c
@@ -168,7 +168,7 @@
* PredicateLockRelation(Relation relation, Snapshot snapshot)
* PredicateLockPage(Relation relation, BlockNumber blkno,
* Snapshot snapshot)
- * PredicateLockTID(Relation relation, ItemPointer tid, Snapshot snapshot,
+ * PredicateLockTID(Relation relation, const ItemPointerData *tid, Snapshot snapshot,
* TransactionId tuple_xid)
* PredicateLockPageSplit(Relation relation, BlockNumber oldblkno,
* BlockNumber newblkno)
@@ -180,7 +180,7 @@
* conflict detection (may also trigger rollback)
* CheckForSerializableConflictOut(Relation relation, TransactionId xid,
* Snapshot snapshot)
- * CheckForSerializableConflictIn(Relation relation, ItemPointer tid,
+ * CheckForSerializableConflictIn(Relation relation, const ItemPointerData *tid,
* BlockNumber blkno)
* CheckTableForSerializableConflictIn(Relation relation)
*
@@ -2618,7 +2618,7 @@ PredicateLockPage(Relation relation, BlockNumber blkno, Snapshot snapshot)
* Skip if this is a temporary table.
*/
void
-PredicateLockTID(Relation relation, ItemPointer tid, Snapshot snapshot,
+PredicateLockTID(Relation relation, const ItemPointerData *tid, Snapshot snapshot,
TransactionId tuple_xid)
{
PREDICATELOCKTARGETTAG tag;
@@ -4333,7 +4333,7 @@ CheckTargetForConflictsIn(PREDICATELOCKTARGETTAG *targettag)
* tuple itself.
*/
void
-CheckForSerializableConflictIn(Relation relation, ItemPointer tid, BlockNumber blkno)
+CheckForSerializableConflictIn(Relation relation, const ItemPointerData *tid, BlockNumber blkno)
{
PREDICATELOCKTARGETTAG targettag;
diff --git a/src/backend/storage/page/itemptr.c b/src/backend/storage/page/itemptr.c
index ad658215721..cedb27d6cc5 100644
--- a/src/backend/storage/page/itemptr.c
+++ b/src/backend/storage/page/itemptr.c
@@ -32,7 +32,7 @@ StaticAssertDecl(sizeof(ItemPointerData) == 3 * sizeof(uint16),
* Asserts that the disk item pointers are both valid!
*/
bool
-ItemPointerEquals(ItemPointer pointer1, ItemPointer pointer2)
+ItemPointerEquals(const ItemPointerData *pointer1, const ItemPointerData *pointer2)
{
if (ItemPointerGetBlockNumber(pointer1) ==
ItemPointerGetBlockNumber(pointer2) &&
@@ -48,7 +48,7 @@ ItemPointerEquals(ItemPointer pointer1, ItemPointer pointer2)
* Generic btree-style comparison for item pointers.
*/
int32
-ItemPointerCompare(ItemPointer arg1, ItemPointer arg2)
+ItemPointerCompare(const ItemPointerData *arg1, const ItemPointerData *arg2)
{
/*
* Use ItemPointerGet{Offset,Block}NumberNoCheck to avoid asserting
diff --git a/src/backend/utils/adt/tid.c b/src/backend/utils/adt/tid.c
index 39dab3e42df..0cfb0bd3735 100644
--- a/src/backend/utils/adt/tid.c
+++ b/src/backend/utils/adt/tid.c
@@ -42,7 +42,7 @@
#define DELIM ','
#define NTIDARGS 2
-static ItemPointer currtid_for_view(Relation viewrel, ItemPointer tid);
+static ItemPointer currtid_for_view(Relation viewrel, const ItemPointerData *tid);
/* ----------------------------------------------------------------
* tidin
@@ -293,7 +293,7 @@ hashtidextended(PG_FUNCTION_ARGS)
* relation "rel".
*/
static ItemPointer
-currtid_internal(Relation rel, ItemPointer tid)
+currtid_internal(Relation rel, const ItemPointerData *tid)
{
ItemPointer result;
AclResult aclresult;
@@ -335,7 +335,7 @@ currtid_internal(Relation rel, ItemPointer tid)
* correspond to the CTID of a base relation.
*/
static ItemPointer
-currtid_for_view(Relation viewrel, ItemPointer tid)
+currtid_for_view(Relation viewrel, const ItemPointerData *tid)
{
TupleDesc att = RelationGetDescr(viewrel);
RuleLock *rulelock;
diff --git a/src/backend/utils/sort/tuplesortvariants.c b/src/backend/utils/sort/tuplesortvariants.c
index 890cdbe1204..41ac4afbf49 100644
--- a/src/backend/utils/sort/tuplesortvariants.c
+++ b/src/backend/utils/sort/tuplesortvariants.c
@@ -816,7 +816,7 @@ tuplesort_putheaptuple(Tuplesortstate *state, HeapTuple tup)
*/
void
tuplesort_putindextuplevalues(Tuplesortstate *state, Relation rel,
- ItemPointer self, const Datum *values,
+ const ItemPointerData *self, const Datum *values,
const bool *isnull)
{
SortTuple stup;
diff --git a/src/include/access/genam.h b/src/include/access/genam.h
index ac62f6a6abd..fc4ea62621d 100644
--- a/src/include/access/genam.h
+++ b/src/include/access/genam.h
@@ -109,7 +109,7 @@ typedef struct IndexBulkDeleteResult
} IndexBulkDeleteResult;
/* Typedef for callback function to determine if a tuple is bulk-deletable */
-typedef bool (*IndexBulkDeleteCallback) (ItemPointer itemptr, void *state);
+typedef bool (*IndexBulkDeleteCallback) (const ItemPointerData *itemptr, void *state);
/* struct definitions appear in relscan.h */
typedef struct IndexScanDescData *IndexScanDesc;
diff --git a/src/include/access/hash.h b/src/include/access/hash.h
index 073ad29b19b..2374d5cf049 100644
--- a/src/include/access/hash.h
+++ b/src/include/access/hash.h
@@ -453,7 +453,7 @@ typedef struct HSpool HSpool; /* opaque struct in hashsort.c */
extern HSpool *_h_spoolinit(Relation heap, Relation index, uint32 num_buckets);
extern void _h_spooldestroy(HSpool *hspool);
-extern void _h_spool(HSpool *hspool, ItemPointer self,
+extern void _h_spool(HSpool *hspool, const ItemPointerData *self,
const Datum *values, const bool *isnull);
extern void _h_indexbuild(HSpool *hspool, Relation heapRel);
diff --git a/src/include/access/heapam.h b/src/include/access/heapam.h
index e60d34dad25..e98f4ec942a 100644
--- a/src/include/access/heapam.h
+++ b/src/include/access/heapam.h
@@ -294,8 +294,8 @@ extern void heap_endscan(TableScanDesc sscan);
extern HeapTuple heap_getnext(TableScanDesc sscan, ScanDirection direction);
extern bool heap_getnextslot(TableScanDesc sscan,
ScanDirection direction, TupleTableSlot *slot);
-extern void heap_set_tidrange(TableScanDesc sscan, ItemPointer mintid,
- ItemPointer maxtid);
+extern void heap_set_tidrange(TableScanDesc sscan, const ItemPointerData *mintid,
+ const ItemPointerData *maxtid);
extern bool heap_getnextslot_tidrange(TableScanDesc sscan,
ScanDirection direction,
TupleTableSlot *slot);
@@ -316,12 +316,12 @@ extern void heap_insert(Relation relation, HeapTuple tup, CommandId cid,
extern void heap_multi_insert(Relation relation, TupleTableSlot **slots,
int ntuples, CommandId cid, int options,
BulkInsertState bistate);
-extern TM_Result heap_delete(Relation relation, ItemPointer tid,
+extern TM_Result heap_delete(Relation relation, const ItemPointerData *tid,
CommandId cid, Snapshot crosscheck, bool wait,
TM_FailureData *tmfd, bool changingPart);
-extern void heap_finish_speculative(Relation relation, ItemPointer tid);
-extern void heap_abort_speculative(Relation relation, ItemPointer tid);
-extern TM_Result heap_update(Relation relation, ItemPointer otid,
+extern void heap_finish_speculative(Relation relation, const ItemPointerData * tid);
+extern void heap_abort_speculative(Relation relation, const ItemPointerData * tid);
+extern TM_Result heap_update(Relation relation, const ItemPointerData * otid,
HeapTuple newtup,
CommandId cid, Snapshot crosscheck, bool wait,
TM_FailureData *tmfd, LockTupleMode *lockmode,
@@ -358,8 +358,8 @@ extern bool heap_tuple_should_freeze(HeapTupleHeader tuple,
extern bool heap_tuple_needs_eventual_freeze(HeapTupleHeader tuple);
extern void simple_heap_insert(Relation relation, HeapTuple tup);
-extern void simple_heap_delete(Relation relation, ItemPointer tid);
-extern void simple_heap_update(Relation relation, ItemPointer otid,
+extern void simple_heap_delete(Relation relation, const ItemPointerData *tid);
+extern void simple_heap_update(Relation relation, const ItemPointerData *otid,
HeapTuple tup, TU_UpdateIndexes *update_indexes);
extern TransactionId heap_index_delete_tuples(Relation rel,
diff --git a/src/include/access/nbtree.h b/src/include/access/nbtree.h
index 9ab467cb8fd..dd167a9257b 100644
--- a/src/include/access/nbtree.h
+++ b/src/include/access/nbtree.h
@@ -1233,7 +1233,7 @@ extern void _bt_dedup_start_pending(BTDedupState state, IndexTuple base,
OffsetNumber baseoff);
extern bool _bt_dedup_save_htid(BTDedupState state, IndexTuple itup);
extern Size _bt_dedup_finish_pending(Page newpage, BTDedupState state);
-extern IndexTuple _bt_form_posting(IndexTuple base, ItemPointer htids,
+extern IndexTuple _bt_form_posting(IndexTuple base, const ItemPointerData *htids,
int nhtids);
extern void _bt_update_posting(BTVacuumPosting vacposting);
extern IndexTuple _bt_swap_posting(IndexTuple newitem, IndexTuple oposting,
diff --git a/src/include/access/spgist_private.h b/src/include/access/spgist_private.h
index 56ac64f0597..9441f6cec15 100644
--- a/src/include/access/spgist_private.h
+++ b/src/include/access/spgist_private.h
@@ -511,7 +511,7 @@ extern unsigned int SpGistGetInnerTypeSize(SpGistTypeDesc *att, Datum datum);
extern Size SpGistGetLeafTupleSize(TupleDesc tupleDescriptor,
const Datum *datums, const bool *isnulls);
extern SpGistLeafTuple spgFormLeafTuple(SpGistState *state,
- ItemPointer heapPtr,
+ const ItemPointerData *heapPtr,
const Datum *datums, const bool *isnulls);
extern SpGistNodeTuple spgFormNodeTuple(SpGistState *state,
Datum label, bool isnull);
@@ -541,7 +541,7 @@ extern void spgPageIndexMultiDelete(SpGistState *state, Page page,
int firststate, int reststate,
BlockNumber blkno, OffsetNumber offnum);
extern bool spgdoinsert(Relation index, SpGistState *state,
- ItemPointer heapPtr, Datum *datums, bool *isnulls);
+ const ItemPointerData *heapPtr, Datum *datums, bool *isnulls);
/* spgproc.c */
extern double *spg_key_orderbys_distances(Datum key, bool isLeaf,
diff --git a/src/include/access/tableam.h b/src/include/access/tableam.h
index e16bf025692..4a9ae2daf62 100644
--- a/src/include/access/tableam.h
+++ b/src/include/access/tableam.h
@@ -369,8 +369,8 @@ typedef struct TableAmRoutine
* further calls to scan_getnextslot_tidrange.
*/
void (*scan_set_tidrange) (TableScanDesc scan,
- ItemPointer mintid,
- ItemPointer maxtid);
+ const ItemPointerData *mintid,
+ const ItemPointerData *maxtid);
/*
* Return next tuple from `scan` that's in the range of TIDs defined by
@@ -471,7 +471,7 @@ typedef struct TableAmRoutine
* test, returns true, false otherwise.
*/
bool (*tuple_fetch_row_version) (Relation rel,
- ItemPointer tid,
+ const ItemPointerData *tid,
Snapshot snapshot,
TupleTableSlot *slot);
@@ -479,7 +479,7 @@ typedef struct TableAmRoutine
* Is tid valid for a scan of this relation.
*/
bool (*tuple_tid_valid) (TableScanDesc scan,
- ItemPointer tid);
+ const ItemPointerData *tid);
/*
* Return the latest version of the tuple at `tid`, by updating `tid` to
@@ -531,7 +531,7 @@ typedef struct TableAmRoutine
/* see table_tuple_delete() for reference about parameters */
TM_Result (*tuple_delete) (Relation rel,
- ItemPointer tid,
+ const ItemPointerData *tid,
CommandId cid,
Snapshot snapshot,
Snapshot crosscheck,
@@ -541,7 +541,7 @@ typedef struct TableAmRoutine
/* see table_tuple_update() for reference about parameters */
TM_Result (*tuple_update) (Relation rel,
- ItemPointer otid,
+ const ItemPointerData *otid,
TupleTableSlot *slot,
CommandId cid,
Snapshot snapshot,
@@ -1251,7 +1251,7 @@ extern bool table_index_fetch_tuple_check(Relation rel,
*/
static inline bool
table_tuple_fetch_row_version(Relation rel,
- ItemPointer tid,
+ const ItemPointerData *tid,
Snapshot snapshot,
TupleTableSlot *slot)
{
@@ -1454,7 +1454,7 @@ table_multi_insert(Relation rel, TupleTableSlot **slots, int nslots,
* TM_FailureData for additional info.
*/
static inline TM_Result
-table_tuple_delete(Relation rel, ItemPointer tid, CommandId cid,
+table_tuple_delete(Relation rel, const ItemPointerData *tid, CommandId cid,
Snapshot snapshot, Snapshot crosscheck, bool wait,
TM_FailureData *tmfd, bool changingPart)
{
@@ -1499,7 +1499,7 @@ table_tuple_delete(Relation rel, ItemPointer tid, CommandId cid,
* for additional info.
*/
static inline TM_Result
-table_tuple_update(Relation rel, ItemPointer otid, TupleTableSlot *slot,
+table_tuple_update(Relation rel, const ItemPointerData *otid, TupleTableSlot *slot,
CommandId cid, Snapshot snapshot, Snapshot crosscheck,
bool wait, TM_FailureData *tmfd, LockTupleMode *lockmode,
TU_UpdateIndexes *update_indexes)
@@ -2006,9 +2006,9 @@ table_scan_sample_next_tuple(TableScanDesc scan,
*/
extern void simple_table_tuple_insert(Relation rel, TupleTableSlot *slot);
-extern void simple_table_tuple_delete(Relation rel, ItemPointer tid,
+extern void simple_table_tuple_delete(Relation rel, const ItemPointerData *tid,
Snapshot snapshot);
-extern void simple_table_tuple_update(Relation rel, ItemPointer otid,
+extern void simple_table_tuple_update(Relation rel, const ItemPointerData *otid,
TupleTableSlot *slot, Snapshot snapshot,
TU_UpdateIndexes *update_indexes);
diff --git a/src/include/access/tidstore.h b/src/include/access/tidstore.h
index 041091df278..048e1df0e84 100644
--- a/src/include/access/tidstore.h
+++ b/src/include/access/tidstore.h
@@ -40,7 +40,7 @@ extern void TidStoreUnlock(TidStore *ts);
extern void TidStoreDestroy(TidStore *ts);
extern void TidStoreSetBlockOffsets(TidStore *ts, BlockNumber blkno, OffsetNumber *offsets,
int num_offsets);
-extern bool TidStoreIsMember(TidStore *ts, ItemPointer tid);
+extern bool TidStoreIsMember(TidStore *ts, const ItemPointerData *tid);
extern TidStoreIter *TidStoreBeginIterate(TidStore *ts);
extern TidStoreIterResult *TidStoreIterateNext(TidStoreIter *iter);
extern int TidStoreGetBlockOffsets(TidStoreIterResult *result,
diff --git a/src/include/catalog/index.h b/src/include/catalog/index.h
index 4daa8bef5ee..dda95e54903 100644
--- a/src/include/catalog/index.h
+++ b/src/include/catalog/index.h
@@ -187,7 +187,7 @@ extern void IndexSetParentIndex(Relation partitionIdx, Oid parentOid);
* As noted in validate_index(), this can be significantly faster.
*/
static inline int64
-itemptr_encode(ItemPointer itemptr)
+itemptr_encode(const ItemPointerData *itemptr)
{
BlockNumber block = ItemPointerGetBlockNumber(itemptr);
OffsetNumber offset = ItemPointerGetOffsetNumber(itemptr);
diff --git a/src/include/catalog/indexing.h b/src/include/catalog/indexing.h
index 667aca7ace8..77c17d3fb7a 100644
--- a/src/include/catalog/indexing.h
+++ b/src/include/catalog/indexing.h
@@ -44,11 +44,11 @@ extern void CatalogTuplesMultiInsertWithInfo(Relation heapRel,
TupleTableSlot **slot,
int ntuples,
CatalogIndexState indstate);
-extern void CatalogTupleUpdate(Relation heapRel, ItemPointer otid,
+extern void CatalogTupleUpdate(Relation heapRel, const ItemPointerData *otid,
HeapTuple tup);
extern void CatalogTupleUpdateWithInfo(Relation heapRel,
- ItemPointer otid, HeapTuple tup,
+ const ItemPointerData *otid, HeapTuple tup,
CatalogIndexState indstate);
-extern void CatalogTupleDelete(Relation heapRel, ItemPointer tid);
+extern void CatalogTupleDelete(Relation heapRel, const ItemPointerData *tid);
#endif /* INDEXING_H */
diff --git a/src/include/executor/executor.h b/src/include/executor/executor.h
index 3248e78cd28..1607eea37ba 100644
--- a/src/include/executor/executor.h
+++ b/src/include/executor/executor.h
@@ -745,11 +745,11 @@ extern List *ExecInsertIndexTuples(ResultRelInfo *resultRelInfo,
extern bool ExecCheckIndexConstraints(ResultRelInfo *resultRelInfo,
TupleTableSlot *slot,
EState *estate, ItemPointer conflictTid,
- ItemPointer tupleid,
+ const ItemPointerData *tupleid,
List *arbiterIndexes);
extern void check_exclusion_constraint(Relation heap, Relation index,
IndexInfo *indexInfo,
- ItemPointer tupleid,
+ const ItemPointerData *tupleid,
const Datum *values, const bool *isnull,
EState *estate, bool newIndex);
diff --git a/src/include/storage/itemptr.h b/src/include/storage/itemptr.h
index 2e251fb64ed..6b04e67ca86 100644
--- a/src/include/storage/itemptr.h
+++ b/src/include/storage/itemptr.h
@@ -132,7 +132,7 @@ ItemPointerGetOffsetNumber(const ItemPointerData *pointer)
* Sets a disk item pointer to the specified block and offset.
*/
static inline void
-ItemPointerSet(ItemPointerData *pointer, BlockNumber blockNumber, OffsetNumber offNum)
+ItemPointerSet(ItemPointer pointer, BlockNumber blockNumber, OffsetNumber offNum)
{
Assert(pointer);
BlockIdSet(&pointer->ip_blkid, blockNumber);
@@ -144,7 +144,7 @@ ItemPointerSet(ItemPointerData *pointer, BlockNumber blockNumber, OffsetNumber o
* Sets a disk item pointer to the specified block.
*/
static inline void
-ItemPointerSetBlockNumber(ItemPointerData *pointer, BlockNumber blockNumber)
+ItemPointerSetBlockNumber(ItemPointer pointer, BlockNumber blockNumber)
{
Assert(pointer);
BlockIdSet(&pointer->ip_blkid, blockNumber);
@@ -155,7 +155,7 @@ ItemPointerSetBlockNumber(ItemPointerData *pointer, BlockNumber blockNumber)
* Sets a disk item pointer to the specified offset.
*/
static inline void
-ItemPointerSetOffsetNumber(ItemPointerData *pointer, OffsetNumber offsetNumber)
+ItemPointerSetOffsetNumber(ItemPointer pointer, OffsetNumber offsetNumber)
{
Assert(pointer);
pointer->ip_posid = offsetNumber;
@@ -217,8 +217,8 @@ ItemPointerSetMovedPartitions(ItemPointerData *pointer)
* ----------------
*/
-extern bool ItemPointerEquals(ItemPointer pointer1, ItemPointer pointer2);
-extern int32 ItemPointerCompare(ItemPointer arg1, ItemPointer arg2);
+extern bool ItemPointerEquals(const ItemPointerData *pointer1, const ItemPointerData *pointer2);
+extern int32 ItemPointerCompare(const ItemPointerData *arg1, const ItemPointerData *arg2);
extern void ItemPointerInc(ItemPointer pointer);
extern void ItemPointerDec(ItemPointer pointer);
diff --git a/src/include/storage/predicate.h b/src/include/storage/predicate.h
index c1e3a4d9f64..8f5f0348a23 100644
--- a/src/include/storage/predicate.h
+++ b/src/include/storage/predicate.h
@@ -54,7 +54,7 @@ extern void SetSerializableTransactionSnapshot(Snapshot snapshot,
extern void RegisterPredicateLockingXid(TransactionId xid);
extern void PredicateLockRelation(Relation relation, Snapshot snapshot);
extern void PredicateLockPage(Relation relation, BlockNumber blkno, Snapshot snapshot);
-extern void PredicateLockTID(Relation relation, ItemPointer tid, Snapshot snapshot,
+extern void PredicateLockTID(Relation relation, const ItemPointerData *tid, Snapshot snapshot,
TransactionId tuple_xid);
extern void PredicateLockPageSplit(Relation relation, BlockNumber oldblkno, BlockNumber newblkno);
extern void PredicateLockPageCombine(Relation relation, BlockNumber oldblkno, BlockNumber newblkno);
@@ -64,7 +64,7 @@ extern void ReleasePredicateLocks(bool isCommit, bool isReadOnlySafe);
/* conflict detection (may also trigger rollback) */
extern bool CheckForSerializableConflictOutNeeded(Relation relation, Snapshot snapshot);
extern void CheckForSerializableConflictOut(Relation relation, TransactionId xid, Snapshot snapshot);
-extern void CheckForSerializableConflictIn(Relation relation, ItemPointer tid, BlockNumber blkno);
+extern void CheckForSerializableConflictIn(Relation relation, const ItemPointerData *tid, BlockNumber blkno);
extern void CheckTableForSerializableConflictIn(Relation relation);
/* final rollback checking */
diff --git a/src/include/utils/tuplesort.h b/src/include/utils/tuplesort.h
index ef79f259f93..0bf55902aa1 100644
--- a/src/include/utils/tuplesort.h
+++ b/src/include/utils/tuplesort.h
@@ -458,7 +458,7 @@ extern void tuplesort_puttupleslot(Tuplesortstate *state,
TupleTableSlot *slot);
extern void tuplesort_putheaptuple(Tuplesortstate *state, HeapTuple tup);
extern void tuplesort_putindextuplevalues(Tuplesortstate *state,
- Relation rel, ItemPointer self,
+ Relation rel, const ItemPointerData *self,
const Datum *values, const bool *isnull);
extern void tuplesort_putbrintuple(Tuplesortstate *state, BrinTuple *tuple, Size size);
extern void tuplesort_putgintuple(Tuplesortstate *state, GinTuple *tuple, Size size);
--
2.39.5 (Apple Git-154)
On 26.09.25 04:54, Chao Li wrote:
On Wed, Sep 10, 2025 at 1:20 PM Chao Li <li.evan.chao@gmail.com
<mailto:li.evan.chao@gmail.com>> wrote:On Sep 10, 2025, at 12:20, Chao Li <li.evan.chao@gmail.com
<mailto:li.evan.chao@gmail.com>> wrote:v2 tries to fix the CI failure.
Chao Li (Evan)
---------------------
HighGo Software Co., Ltd.
https://www.highgo.com/ <https://www.highgo.com/><v2-0001-Mark-ItemPointer-arguments-as-const-thoughoutly.patch>
Here is the CF patch https://commitfest.postgresql.org/patch/6046/
<https://commitfest.postgresql.org/patch/6046/>, and the CI tests
passed.
I have committed most of this patch.
I didn't like the few places in itemptr.h where you changed an existing
ItemPointerData* back to ItemPointer, so I left those out.
More importantly, some of the proposed changes change the signatures of
callback functions in the index or table AM APIs. (And also the
documentation wasn't updated.) This would break source code
compatibility with existing extensions that use those APIs. There are
have been previous proposals like this in [0]/messages/by-id/14c31f4a-0347-0805-dce8-93a9072c05a5@eisentraut.org, [1]/messages/by-id/f8c739d9-f48d-4187-b214-df3391ba41ab@eisentraut.org where the changes to
those APIs were not committed. And your other patch 'Mark function
arguments of type "Datum *" as "const Datum *" where possible' might
have similar problems (although it looks like it's touching different
places than [0]/messages/by-id/14c31f4a-0347-0805-dce8-93a9072c05a5@eisentraut.org and [1]/messages/by-id/f8c739d9-f48d-4187-b214-df3391ba41ab@eisentraut.org). So I left those changes out of what I committed.
That doesn't mean we can never change these APIs. We certainly change
many backend APIs all the time, and extensions providing table or index
AMs are sophisticated and will need to make adjustments anyway. But it
would be better if we did any changes in a deliberate way with explicit
notice and advice for extensions (like commit 76acf4b722f for example).
[0]: /messages/by-id/14c31f4a-0347-0805-dce8-93a9072c05a5@eisentraut.org
/messages/by-id/14c31f4a-0347-0805-dce8-93a9072c05a5@eisentraut.org
[1]: /messages/by-id/f8c739d9-f48d-4187-b214-df3391ba41ab@eisentraut.org
/messages/by-id/f8c739d9-f48d-4187-b214-df3391ba41ab@eisentraut.org
Hi Peter,
On Oct 30, 2025, at 21:30, Peter Eisentraut <peter@eisentraut.org> wrote:
I have committed most of this patch.
Thank you so much for committing my patch and for your guidance. I’m still ramping up on PostgreSQL development, and your guidance has been super helpful to me.
I didn't like the few places in itemptr.h where you changed an existing ItemPointerData* back to ItemPointer, so I left those out.
More importantly, some of the proposed changes change the signatures of callback functions in the index or table AM APIs. (And also the documentation wasn't updated.) This would break source code compatibility with existing extensions that use those APIs. There are have been previous proposals like this in [0], [1] where the changes to those APIs were not committed. And your other patch 'Mark function arguments of type "Datum *" as "const Datum *" where possible' might have similar problems (although it looks like it's touching different places than [0] and [1]). So I left those changes out of what I committed.
I will revisit that patch once I am back from vacation.
Best regards,
--
Chao Li (Evan)
HighGo Software Co., Ltd.
https://www.highgo.com/