0002-WIP-Add-const-to-values-and-nulls-arguments-with-ext.patch
text/plain
Filename: 0002-WIP-Add-const-to-values-and-nulls-arguments-with-ext.patch
Type: text/plain
Part: 1
Patch
Format: format-patch
Series: patch 0002
Subject: WIP: Add const to values and nulls arguments with external API changes
| File | + | − |
|---|---|---|
| contrib/amcheck/verify_nbtree.c | 3 | 3 |
| contrib/bloom/blinsert.c | 3 | 3 |
| contrib/bloom/bloom.h | 2 | 2 |
| contrib/bloom/blutils.c | 1 | 1 |
| src/backend/access/brin/brin.c | 3 | 3 |
| src/backend/access/gin/gininsert.c | 3 | 3 |
| src/backend/access/gist/gistbuild.c | 7 | 7 |
| src/backend/access/gist/gist.c | 1 | 1 |
| src/backend/access/hash/hash.c | 5 | 5 |
| src/backend/access/hash/hashutil.c | 1 | 1 |
| src/backend/access/index/indexam.c | 2 | 2 |
| src/backend/access/nbtree/nbtree.c | 1 | 1 |
| src/backend/access/nbtree/nbtsort.c | 6 | 6 |
| src/backend/access/spgist/spgdoinsert.c | 1 | 1 |
| src/backend/access/spgist/spginsert.c | 3 | 3 |
| src/include/access/amapi.h | 2 | 2 |
| src/include/access/brin_internal.h | 1 | 1 |
| src/include/access/genam.h | 1 | 1 |
| src/include/access/gin_private.h | 1 | 1 |
| src/include/access/gist_private.h | 1 | 1 |
| src/include/access/hash.h | 2 | 2 |
| src/include/access/nbtree.h | 1 | 1 |
| src/include/access/spgist.h | 1 | 1 |
| src/include/access/spgist_private.h | 1 | 1 |
| src/include/access/tableam.h | 2 | 2 |
| src/test/modules/dummy_index_am/dummy_index_am.c | 1 | 1 |
From 8729ca6d758b57f7f4922beecdbdfdcc38ce22e1 Mon Sep 17 00:00:00 2001
From: Peter Eisentraut <peter@eisentraut.org>
Date: Fri, 6 Oct 2023 14:57:56 +0200
Subject: [PATCH 2/2] WIP: Add const to values and nulls arguments with
external API changes
---
contrib/amcheck/verify_nbtree.c | 6 +++---
contrib/bloom/blinsert.c | 6 +++---
contrib/bloom/bloom.h | 4 ++--
contrib/bloom/blutils.c | 2 +-
src/backend/access/brin/brin.c | 6 +++---
src/backend/access/gin/gininsert.c | 6 +++---
src/backend/access/gist/gist.c | 2 +-
src/backend/access/gist/gistbuild.c | 14 +++++++-------
src/backend/access/hash/hash.c | 10 +++++-----
src/backend/access/hash/hashutil.c | 2 +-
src/backend/access/index/indexam.c | 4 ++--
src/backend/access/nbtree/nbtree.c | 2 +-
src/backend/access/nbtree/nbtsort.c | 12 ++++++------
src/backend/access/spgist/spgdoinsert.c | 2 +-
src/backend/access/spgist/spginsert.c | 6 +++---
src/include/access/amapi.h | 4 ++--
src/include/access/brin_internal.h | 2 +-
src/include/access/genam.h | 2 +-
src/include/access/gin_private.h | 2 +-
src/include/access/gist_private.h | 2 +-
src/include/access/hash.h | 4 ++--
src/include/access/nbtree.h | 2 +-
src/include/access/spgist.h | 2 +-
src/include/access/spgist_private.h | 2 +-
src/include/access/tableam.h | 4 ++--
src/test/modules/dummy_index_am/dummy_index_am.c | 2 +-
26 files changed, 56 insertions(+), 56 deletions(-)
diff --git a/contrib/amcheck/verify_nbtree.c b/contrib/amcheck/verify_nbtree.c
index dbb83d80f8..206bde6ab2 100644
--- a/contrib/amcheck/verify_nbtree.c
+++ b/contrib/amcheck/verify_nbtree.c
@@ -161,7 +161,7 @@ static void bt_child_highkey_check(BtreeCheckState *state,
static void bt_downlink_missing_check(BtreeCheckState *state, bool rightsplit,
BlockNumber blkno, Page page);
static void bt_tuple_present_callback(Relation index, ItemPointer tid,
- Datum *values, bool *isnull,
+ const Datum *values, const bool *isnull,
bool tupleIsAlive, void *checkstate);
static IndexTuple bt_normalize_tuple(BtreeCheckState *state,
IndexTuple itup);
@@ -2483,8 +2483,8 @@ bt_downlink_missing_check(BtreeCheckState *state, bool rightsplit,
* also allows us to detect the corruption in many cases.
*/
static void
-bt_tuple_present_callback(Relation index, ItemPointer tid, Datum *values,
- bool *isnull, bool tupleIsAlive, void *checkstate)
+bt_tuple_present_callback(Relation index, ItemPointer tid, const Datum *values,
+ const bool *isnull, bool tupleIsAlive, void *checkstate)
{
BtreeCheckState *state = (BtreeCheckState *) checkstate;
IndexTuple itup,
diff --git a/contrib/bloom/blinsert.c b/contrib/bloom/blinsert.c
index b90145148d..8bf171f2ec 100644
--- a/contrib/bloom/blinsert.c
+++ b/contrib/bloom/blinsert.c
@@ -71,8 +71,8 @@ initCachedPage(BloomBuildState *buildstate)
* Per-tuple callback for table_index_build_scan.
*/
static void
-bloomBuildCallback(Relation index, ItemPointer tid, Datum *values,
- bool *isnull, bool tupleIsAlive, void *state)
+bloomBuildCallback(Relation index, ItemPointer tid, const Datum *values,
+ const bool *isnull, bool tupleIsAlive, void *state)
{
BloomBuildState *buildstate = (BloomBuildState *) state;
MemoryContext oldCtx;
@@ -171,7 +171,7 @@ blbuildempty(Relation index)
* Insert new tuple to the bloom index.
*/
bool
-blinsert(Relation index, Datum *values, bool *isnull,
+blinsert(Relation index, const Datum *values, const bool *isnull,
ItemPointer ht_ctid, Relation heapRel,
IndexUniqueCheck checkUnique,
bool indexUnchanged,
diff --git a/contrib/bloom/bloom.h b/contrib/bloom/bloom.h
index 330811ec60..bc427f7632 100644
--- a/contrib/bloom/bloom.h
+++ b/contrib/bloom/bloom.h
@@ -181,14 +181,14 @@ extern void BloomInitMetapage(Relation index, ForkNumber forknum);
extern void BloomInitPage(Page page, uint16 flags);
extern Buffer BloomNewBuffer(Relation index);
extern void signValue(BloomState *state, BloomSignatureWord *sign, Datum value, int attno);
-extern BloomTuple *BloomFormTuple(BloomState *state, ItemPointer iptr, Datum *values, bool *isnull);
+extern BloomTuple *BloomFormTuple(BloomState *state, ItemPointer iptr, const Datum *values, const bool *isnull);
extern bool BloomPageAddItem(BloomState *state, Page page, BloomTuple *tuple);
/* blvalidate.c */
extern bool blvalidate(Oid opclassoid);
/* index access method interface functions */
-extern bool blinsert(Relation index, Datum *values, bool *isnull,
+extern bool blinsert(Relation index, const Datum *values, const bool *isnull,
ItemPointer ht_ctid, Relation heapRel,
IndexUniqueCheck checkUnique,
bool indexUnchanged,
diff --git a/contrib/bloom/blutils.c b/contrib/bloom/blutils.c
index f23fbb1d9e..aed4145dcd 100644
--- a/contrib/bloom/blutils.c
+++ b/contrib/bloom/blutils.c
@@ -290,7 +290,7 @@ signValue(BloomState *state, BloomSignatureWord *sign, Datum value, int attno)
* Make bloom tuple from values.
*/
BloomTuple *
-BloomFormTuple(BloomState *state, ItemPointer iptr, Datum *values, bool *isnull)
+BloomFormTuple(BloomState *state, ItemPointer iptr, const Datum *values, const bool *isnull)
{
int i;
BloomTuple *res = (BloomTuple *) palloc0(state->sizeOfBloomTuple);
diff --git a/src/backend/access/brin/brin.c b/src/backend/access/brin/brin.c
index af392bc032..29e5ce7ea0 100644
--- a/src/backend/access/brin/brin.c
+++ b/src/backend/access/brin/brin.c
@@ -153,7 +153,7 @@ brinhandler(PG_FUNCTION_ARGS)
* it), there's nothing to do for this tuple.
*/
bool
-brininsert(Relation idxRel, Datum *values, bool *nulls,
+brininsert(Relation idxRel, const Datum *values, const bool *nulls,
ItemPointer heaptid, Relation heapRel,
IndexUniqueCheck checkUnique,
bool indexUnchanged,
@@ -781,8 +781,8 @@ brinendscan(IndexScanDesc scan)
static void
brinbuildCallback(Relation index,
ItemPointer tid,
- Datum *values,
- bool *isnull,
+ const Datum *values,
+ const bool *isnull,
bool tupleIsAlive,
void *brstate)
{
diff --git a/src/backend/access/gin/gininsert.c b/src/backend/access/gin/gininsert.c
index b4d216d4c6..78c7ee6ff9 100644
--- a/src/backend/access/gin/gininsert.c
+++ b/src/backend/access/gin/gininsert.c
@@ -277,8 +277,8 @@ ginHeapTupleBulkInsert(GinBuildState *buildstate, OffsetNumber attnum,
}
static void
-ginBuildCallback(Relation index, ItemPointer tid, Datum *values,
- bool *isnull, bool tupleIsAlive, void *state)
+ginBuildCallback(Relation index, ItemPointer tid, const Datum *values,
+ const bool *isnull, bool tupleIsAlive, void *state)
{
GinBuildState *buildstate = (GinBuildState *) state;
MemoryContext oldCtx;
@@ -483,7 +483,7 @@ ginHeapTupleInsert(GinState *ginstate, OffsetNumber attnum,
}
bool
-gininsert(Relation index, Datum *values, bool *isnull,
+gininsert(Relation index, const Datum *values, const bool *isnull,
ItemPointer ht_ctid, Relation heapRel,
IndexUniqueCheck checkUnique,
bool indexUnchanged,
diff --git a/src/backend/access/gist/gist.c b/src/backend/access/gist/gist.c
index 8ef5fa0329..09fe9bf9cc 100644
--- a/src/backend/access/gist/gist.c
+++ b/src/backend/access/gist/gist.c
@@ -155,7 +155,7 @@ gistbuildempty(Relation index)
* It doesn't do any work; just locks the relation and passes the buck.
*/
bool
-gistinsert(Relation r, Datum *values, bool *isnull,
+gistinsert(Relation r, const Datum *values, const bool *isnull,
ItemPointer ht_ctid, Relation heapRel,
IndexUniqueCheck checkUnique,
bool indexUnchanged,
diff --git a/src/backend/access/gist/gistbuild.c b/src/backend/access/gist/gistbuild.c
index 5e0c1447f9..d48099f6b5 100644
--- a/src/backend/access/gist/gistbuild.c
+++ b/src/backend/access/gist/gistbuild.c
@@ -134,7 +134,7 @@ typedef struct GistSortedBuildLevelState
/* prototypes for private functions */
static void gistSortedBuildCallback(Relation index, ItemPointer tid,
- Datum *values, bool *isnull,
+ const Datum *values, const bool *isnull,
bool tupleIsAlive, void *state);
static void gist_indexsortbuild(GISTBuildState *state);
static void gist_indexsortbuild_levelstate_add(GISTBuildState *state,
@@ -148,8 +148,8 @@ static void gistInitBuffering(GISTBuildState *buildstate);
static int calculatePagesPerBuffer(GISTBuildState *buildstate, int levelStep);
static void gistBuildCallback(Relation index,
ItemPointer tid,
- Datum *values,
- bool *isnull,
+ const Datum *values,
+ const bool *isnull,
bool tupleIsAlive,
void *state);
static void gistBufferingBuildInsert(GISTBuildState *buildstate,
@@ -369,8 +369,8 @@ gistbuild(Relation heap, Relation index, IndexInfo *indexInfo)
static void
gistSortedBuildCallback(Relation index,
ItemPointer tid,
- Datum *values,
- bool *isnull,
+ const Datum *values,
+ const bool *isnull,
bool tupleIsAlive,
void *state)
{
@@ -885,8 +885,8 @@ calculatePagesPerBuffer(GISTBuildState *buildstate, int levelStep)
static void
gistBuildCallback(Relation index,
ItemPointer tid,
- Datum *values,
- bool *isnull,
+ const Datum *values,
+ const bool *isnull,
bool tupleIsAlive,
void *state)
{
diff --git a/src/backend/access/hash/hash.c b/src/backend/access/hash/hash.c
index fc5d97f606..e7310fa874 100644
--- a/src/backend/access/hash/hash.c
+++ b/src/backend/access/hash/hash.c
@@ -43,8 +43,8 @@ typedef struct
static void hashbuildCallback(Relation index,
ItemPointer tid,
- Datum *values,
- bool *isnull,
+ const Datum *values,
+ const bool *isnull,
bool tupleIsAlive,
void *state);
@@ -207,8 +207,8 @@ hashbuildempty(Relation index)
static void
hashbuildCallback(Relation index,
ItemPointer tid,
- Datum *values,
- bool *isnull,
+ const Datum *values,
+ const bool *isnull,
bool tupleIsAlive,
void *state)
{
@@ -246,7 +246,7 @@ hashbuildCallback(Relation index,
* Find the appropriate location for the new tuple, and put it there.
*/
bool
-hashinsert(Relation rel, Datum *values, bool *isnull,
+hashinsert(Relation rel, const Datum *values, const bool *isnull,
ItemPointer ht_ctid, Relation heapRel,
IndexUniqueCheck checkUnique,
bool indexUnchanged,
diff --git a/src/backend/access/hash/hashutil.c b/src/backend/access/hash/hashutil.c
index 88089ce02b..ef3eebe4bf 100644
--- a/src/backend/access/hash/hashutil.c
+++ b/src/backend/access/hash/hashutil.c
@@ -317,7 +317,7 @@ _hash_get_indextuple_hashkey(IndexTuple itup)
*/
bool
_hash_convert_tuple(Relation index,
- Datum *user_values, bool *user_isnull,
+ const Datum *user_values, const bool *user_isnull,
Datum *index_values, bool *index_isnull)
{
uint32 hashkey;
diff --git a/src/backend/access/index/indexam.c b/src/backend/access/index/indexam.c
index b25b03f7ab..40e7279fc8 100644
--- a/src/backend/access/index/indexam.c
+++ b/src/backend/access/index/indexam.c
@@ -174,8 +174,8 @@ index_close(Relation relation, LOCKMODE lockmode)
*/
bool
index_insert(Relation indexRelation,
- Datum *values,
- bool *isnull,
+ const Datum *values,
+ const bool *isnull,
ItemPointer heap_t_ctid,
Relation heapRelation,
IndexUniqueCheck checkUnique,
diff --git a/src/backend/access/nbtree/nbtree.c b/src/backend/access/nbtree/nbtree.c
index 6c5b5c69ce..0ad9194fad 100644
--- a/src/backend/access/nbtree/nbtree.c
+++ b/src/backend/access/nbtree/nbtree.c
@@ -187,7 +187,7 @@ btbuildempty(Relation index)
* new tuple, and put it there.
*/
bool
-btinsert(Relation rel, Datum *values, bool *isnull,
+btinsert(Relation rel, const Datum *values, const bool *isnull,
ItemPointer ht_ctid, Relation heapRel,
IndexUniqueCheck checkUnique,
bool indexUnchanged,
diff --git a/src/backend/access/nbtree/nbtsort.c b/src/backend/access/nbtree/nbtsort.c
index c2665fce41..c2cbc2f8fc 100644
--- a/src/backend/access/nbtree/nbtsort.c
+++ b/src/backend/access/nbtree/nbtsort.c
@@ -263,10 +263,10 @@ 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,
- Datum *values, bool *isnull);
+ const Datum *values, const bool *isnull);
static void _bt_leafbuild(BTSpool *btspool, BTSpool *btspool2);
-static void _bt_build_callback(Relation index, ItemPointer tid, Datum *values,
- bool *isnull, bool tupleIsAlive, void *state);
+static void _bt_build_callback(Relation index, ItemPointer tid, const Datum *values,
+ const bool *isnull, bool tupleIsAlive, void *state);
static Page _bt_blnewpage(uint32 level);
static BTPageState *_bt_pagestate(BTWriteState *wstate, uint32 level);
static void _bt_slideleft(Page rightmostpage);
@@ -530,7 +530,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, ItemPointer self, const Datum *values, const bool *isnull)
{
tuplesort_putindextuplevalues(btspool->sortstate, btspool->index,
self, values, isnull);
@@ -587,8 +587,8 @@ _bt_leafbuild(BTSpool *btspool, BTSpool *btspool2)
static void
_bt_build_callback(Relation index,
ItemPointer tid,
- Datum *values,
- bool *isnull,
+ const Datum *values,
+ const bool *isnull,
bool tupleIsAlive,
void *state)
{
diff --git a/src/backend/access/spgist/spgdoinsert.c b/src/backend/access/spgist/spgdoinsert.c
index 3554edcc9a..a1b107d2b6 100644
--- a/src/backend/access/spgist/spgdoinsert.c
+++ b/src/backend/access/spgist/spgdoinsert.c
@@ -1913,7 +1913,7 @@ spgSplitNodeAction(Relation index, SpGistState *state,
*/
bool
spgdoinsert(Relation index, SpGistState *state,
- ItemPointer heapPtr, Datum *datums, bool *isnulls)
+ ItemPointer heapPtr, const Datum *datums, const bool *isnulls)
{
bool result = true;
TupleDesc leafDescriptor = state->leafTupDesc;
diff --git a/src/backend/access/spgist/spginsert.c b/src/backend/access/spgist/spginsert.c
index 4443f1918d..6c9b9098d6 100644
--- a/src/backend/access/spgist/spginsert.c
+++ b/src/backend/access/spgist/spginsert.c
@@ -40,8 +40,8 @@ typedef struct
/* Callback to process one heap tuple during table_index_build_scan */
static void
-spgistBuildCallback(Relation index, ItemPointer tid, Datum *values,
- bool *isnull, bool tupleIsAlive, void *state)
+spgistBuildCallback(Relation index, ItemPointer tid, const Datum *values,
+ const bool *isnull, bool tupleIsAlive, void *state)
{
SpGistBuildState *buildstate = (SpGistBuildState *) state;
MemoryContext oldCtx;
@@ -197,7 +197,7 @@ spgbuildempty(Relation index)
* Insert one new tuple into an SPGiST index.
*/
bool
-spginsert(Relation index, Datum *values, bool *isnull,
+spginsert(Relation index, const Datum *values, const bool *isnull,
ItemPointer ht_ctid, Relation heapRel,
IndexUniqueCheck checkUnique,
bool indexUnchanged,
diff --git a/src/include/access/amapi.h b/src/include/access/amapi.h
index 4476ff7fba..bfa3ec5303 100644
--- a/src/include/access/amapi.h
+++ b/src/include/access/amapi.h
@@ -105,8 +105,8 @@ typedef void (*ambuildempty_function) (Relation indexRelation);
/* insert this tuple */
typedef bool (*aminsert_function) (Relation indexRelation,
- Datum *values,
- bool *isnull,
+ const Datum *values,
+ const bool *isnull,
ItemPointer heap_tid,
Relation heapRelation,
IndexUniqueCheck checkUnique,
diff --git a/src/include/access/brin_internal.h b/src/include/access/brin_internal.h
index 97ddc925b2..45ed31af8a 100644
--- a/src/include/access/brin_internal.h
+++ b/src/include/access/brin_internal.h
@@ -91,7 +91,7 @@ extern void brin_free_desc(BrinDesc *bdesc);
extern IndexBuildResult *brinbuild(Relation heap, Relation index,
struct IndexInfo *indexInfo);
extern void brinbuildempty(Relation index);
-extern bool brininsert(Relation idxRel, Datum *values, bool *nulls,
+extern bool brininsert(Relation idxRel, const Datum *values, const bool *nulls,
ItemPointer heaptid, Relation heapRel,
IndexUniqueCheck checkUnique,
bool indexUnchanged,
diff --git a/src/include/access/genam.h b/src/include/access/genam.h
index 4e626c615e..7ab83bc479 100644
--- a/src/include/access/genam.h
+++ b/src/include/access/genam.h
@@ -142,7 +142,7 @@ extern Relation index_open(Oid relationId, LOCKMODE lockmode);
extern void index_close(Relation relation, LOCKMODE lockmode);
extern bool index_insert(Relation indexRelation,
- Datum *values, bool *isnull,
+ const Datum *values, const bool *isnull,
ItemPointer heap_t_ctid,
Relation heapRelation,
IndexUniqueCheck checkUnique,
diff --git a/src/include/access/gin_private.h b/src/include/access/gin_private.h
index 76b9923201..32a108a5ac 100644
--- a/src/include/access/gin_private.h
+++ b/src/include/access/gin_private.h
@@ -113,7 +113,7 @@ extern Datum gintuple_get_key(GinState *ginstate, IndexTuple tuple,
extern IndexBuildResult *ginbuild(Relation heap, Relation index,
struct IndexInfo *indexInfo);
extern void ginbuildempty(Relation index);
-extern bool gininsert(Relation index, Datum *values, bool *isnull,
+extern bool gininsert(Relation index, const Datum *values, const bool *isnull,
ItemPointer ht_ctid, Relation heapRel,
IndexUniqueCheck checkUnique,
bool indexUnchanged,
diff --git a/src/include/access/gist_private.h b/src/include/access/gist_private.h
index 18c37f0bd8..e4a2b2eea2 100644
--- a/src/include/access/gist_private.h
+++ b/src/include/access/gist_private.h
@@ -400,7 +400,7 @@ typedef struct GiSTOptions
/* gist.c */
extern void gistbuildempty(Relation index);
-extern bool gistinsert(Relation r, Datum *values, bool *isnull,
+extern bool gistinsert(Relation r, const Datum *values, const bool *isnull,
ItemPointer ht_ctid, Relation heapRel,
IndexUniqueCheck checkUnique,
bool indexUnchanged,
diff --git a/src/include/access/hash.h b/src/include/access/hash.h
index 4806ce6c4e..68c30d2e03 100644
--- a/src/include/access/hash.h
+++ b/src/include/access/hash.h
@@ -363,7 +363,7 @@ typedef struct HashOptions
extern IndexBuildResult *hashbuild(Relation heap, Relation index,
struct IndexInfo *indexInfo);
extern void hashbuildempty(Relation index);
-extern bool hashinsert(Relation rel, Datum *values, bool *isnull,
+extern bool hashinsert(Relation rel, const Datum *values, const bool *isnull,
ItemPointer ht_ctid, Relation heapRel,
IndexUniqueCheck checkUnique,
bool indexUnchanged,
@@ -465,7 +465,7 @@ extern uint32 _hash_get_totalbuckets(uint32 splitpoint_phase);
extern void _hash_checkpage(Relation rel, Buffer buf, int flags);
extern uint32 _hash_get_indextuple_hashkey(IndexTuple itup);
extern bool _hash_convert_tuple(Relation index,
- Datum *user_values, bool *user_isnull,
+ const Datum *user_values, const bool *user_isnull,
Datum *index_values, bool *index_isnull);
extern OffsetNumber _hash_binsearch(Page page, uint32 hash_value);
extern OffsetNumber _hash_binsearch_last(Page page, uint32 hash_value);
diff --git a/src/include/access/nbtree.h b/src/include/access/nbtree.h
index 6345e16d78..213857dde3 100644
--- a/src/include/access/nbtree.h
+++ b/src/include/access/nbtree.h
@@ -1127,7 +1127,7 @@ typedef struct BTOptions
* external entry points for btree, in nbtree.c
*/
extern void btbuildempty(Relation index);
-extern bool btinsert(Relation rel, Datum *values, bool *isnull,
+extern bool btinsert(Relation rel, const Datum *values, const bool *isnull,
ItemPointer ht_ctid, Relation heapRel,
IndexUniqueCheck checkUnique,
bool indexUnchanged,
diff --git a/src/include/access/spgist.h b/src/include/access/spgist.h
index fe31d32dbe..002d4b872f 100644
--- a/src/include/access/spgist.h
+++ b/src/include/access/spgist.h
@@ -196,7 +196,7 @@ extern bytea *spgoptions(Datum reloptions, bool validate);
extern IndexBuildResult *spgbuild(Relation heap, Relation index,
struct IndexInfo *indexInfo);
extern void spgbuildempty(Relation index);
-extern bool spginsert(Relation index, Datum *values, bool *isnull,
+extern bool spginsert(Relation index, const Datum *values, const bool *isnull,
ItemPointer ht_ctid, Relation heapRel,
IndexUniqueCheck checkUnique,
bool indexUnchanged,
diff --git a/src/include/access/spgist_private.h b/src/include/access/spgist_private.h
index bc39ee45cc..d18c125c5a 100644
--- a/src/include/access/spgist_private.h
+++ b/src/include/access/spgist_private.h
@@ -538,7 +538,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);
+ ItemPointer heapPtr, const Datum *datums, const 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 230bc39cc0..c5e573405c 100644
--- a/src/include/access/tableam.h
+++ b/src/include/access/tableam.h
@@ -263,8 +263,8 @@ typedef struct TM_IndexDeleteOp
/* Typedef for callback function for table_index_build_scan */
typedef void (*IndexBuildCallback) (Relation index,
ItemPointer tid,
- Datum *values,
- bool *isnull,
+ const Datum *values,
+ const bool *isnull,
bool tupleIsAlive,
void *state);
diff --git a/src/test/modules/dummy_index_am/dummy_index_am.c b/src/test/modules/dummy_index_am/dummy_index_am.c
index c14e0abe0c..542fed0384 100644
--- a/src/test/modules/dummy_index_am/dummy_index_am.c
+++ b/src/test/modules/dummy_index_am/dummy_index_am.c
@@ -163,7 +163,7 @@ dibuildempty(Relation index)
* Insert new tuple to index AM.
*/
static bool
-diinsert(Relation index, Datum *values, bool *isnull,
+diinsert(Relation index, const Datum *values, const bool *isnull,
ItemPointer ht_ctid, Relation heapRel,
IndexUniqueCheck checkUnique,
bool indexUnchanged,
--
2.42.0