public inbox for [email protected]
help / color / mirror / Atom feedget rid of Pointer type, mostly
23+ messages / 8 participants
[nested] [flat]
* get rid of Pointer type, mostly
@ 2025-11-24 10:20 Peter Eisentraut <[email protected]>
2025-11-24 12:03 ` Re: get rid of Pointer type, mostly Chao Li <[email protected]>
2025-11-24 14:54 ` Re: get rid of Pointer type, mostly Bertrand Drouvot <[email protected]>
2025-11-24 16:09 ` Re: get rid of Pointer type, mostly Tom Lane <[email protected]>
0 siblings, 3 replies; 23+ messages in thread
From: Peter Eisentraut @ 2025-11-24 10:20 UTC (permalink / raw)
To: pgsql-hackers
In a previous thread[0], the question was asked, 'Why do we bother with
a "Pointer" type?'. So I looked into get rid of it.
There are two stages to this. One is changing all code that wants to do
pointer arithmetic to use char * instead of relying on Pointer being
char *. Then we can change Pointer to be void * and remove a bunch of
casts.
The second is getting rid of uses of Pointer for variables where you
might as well use void * directly. These are actually not that many.
This gets rid of all uses, except in the GIN code, which is full of
Pointer use, and it's part of the documented API. I'm not touching
that, not least because this kind of code
Pointer **extra_data = (Pointer **) PG_GETARG_POINTER(4);
needs more brain-bending to understand that I'm prepared to spend. So
as far as I'm concerned, the pointer type can continue to exist as a
curiosity of the GIN API, but in all other places, it wasn't really
doing much of anything anyway.
[0]:
https://www.postgresql.org/message-id/CA%2BhUKG%2BNFKnr%3DK4oybwDvT35dW%3DVAjAAfiuLxp%2B5JeZSOV3nBg%...
From d4c4d36810bbfb87d2e20d527c34025ea873de12 Mon Sep 17 00:00:00 2001
From: Peter Eisentraut <[email protected]>
Date: Mon, 24 Nov 2025 11:02:35 +0100
Subject: [PATCH 1/6] Remove useless casts to Pointer
---
contrib/bloom/blutils.c | 2 +-
contrib/bloom/blvacuum.c | 2 +-
src/backend/access/gin/ginxlog.c | 2 +-
src/backend/utils/adt/multirangetypes.c | 2 +-
4 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/contrib/bloom/blutils.c b/contrib/bloom/blutils.c
index 2c0e71eedc6..bf50037a71a 100644
--- a/contrib/bloom/blutils.c
+++ b/contrib/bloom/blutils.c
@@ -336,7 +336,7 @@ BloomPageAddItem(BloomState *state, Page page, BloomTuple *tuple)
/* Copy new tuple to the end of page */
opaque = BloomPageGetOpaque(page);
itup = BloomPageGetTuple(state, page, opaque->maxoff + 1);
- memcpy((Pointer) itup, (Pointer) tuple, state->sizeOfBloomTuple);
+ memcpy(itup, tuple, state->sizeOfBloomTuple);
/* Adjust maxoff and pd_lower */
opaque->maxoff++;
diff --git a/contrib/bloom/blvacuum.c b/contrib/bloom/blvacuum.c
index 9e5f0574fad..044fd85a32a 100644
--- a/contrib/bloom/blvacuum.c
+++ b/contrib/bloom/blvacuum.c
@@ -94,7 +94,7 @@ blbulkdelete(IndexVacuumInfo *info, IndexBulkDeleteResult *stats,
{
/* No; copy it to itupPtr++, but skip copy if not needed */
if (itupPtr != itup)
- memmove((Pointer) itupPtr, (Pointer) itup,
+ memmove(itupPtr, itup,
state.sizeOfBloomTuple);
itupPtr = BloomPageGetNextTuple(&state, itupPtr);
}
diff --git a/src/backend/access/gin/ginxlog.c b/src/backend/access/gin/ginxlog.c
index 75df3d7a680..606741fa396 100644
--- a/src/backend/access/gin/ginxlog.c
+++ b/src/backend/access/gin/ginxlog.c
@@ -212,7 +212,7 @@ ginRedoRecompress(Page page, ginxlogRecompressDataLeaf *data)
if (tailCopy)
{
Assert(writePtr + segsize < PageGetSpecialPointer(page));
- memcpy(writePtr, (Pointer) oldseg, segsize);
+ memcpy(writePtr, oldseg, segsize);
}
writePtr += segsize;
oldseg = GinNextPostingListSegment(oldseg);
diff --git a/src/backend/utils/adt/multirangetypes.c b/src/backend/utils/adt/multirangetypes.c
index 5273b97f7fe..55e0b4fdc31 100644
--- a/src/backend/utils/adt/multirangetypes.c
+++ b/src/backend/utils/adt/multirangetypes.c
@@ -629,7 +629,7 @@ write_multirange_data(MultirangeType *multirange, TypeCacheEntry *rangetyp,
}
flags[i] = *((Pointer) ranges[i] + VARSIZE(ranges[i]) - sizeof(char));
len = VARSIZE(ranges[i]) - sizeof(RangeType) - sizeof(char);
- memcpy(ptr, (Pointer) (ranges[i] + 1), len);
+ memcpy(ptr, ranges[i] + 1, len);
ptr += att_align_nominal(len, elemalign);
}
}
--
2.52.0
From b58263c3df6dc2eb918bde92eb04f7fd5d2a061b Mon Sep 17 00:00:00 2001
From: Peter Eisentraut <[email protected]>
Date: Mon, 24 Nov 2025 11:02:35 +0100
Subject: [PATCH 2/6] Use better DatumGet* function
Use DatumGetCString() instead of DatumGetPointer() for returning a C
string. Right now, they are the same, but that doesn't always have to
be so.
---
src/test/modules/test_resowner/test_resowner_basic.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/test/modules/test_resowner/test_resowner_basic.c b/src/test/modules/test_resowner/test_resowner_basic.c
index 8f794996371..b84ec2cb299 100644
--- a/src/test/modules/test_resowner/test_resowner_basic.c
+++ b/src/test/modules/test_resowner/test_resowner_basic.c
@@ -35,13 +35,13 @@ static const ResourceOwnerDesc string_desc = {
static void
ReleaseString(Datum res)
{
- elog(NOTICE, "releasing string: %s", DatumGetPointer(res));
+ elog(NOTICE, "releasing string: %s", DatumGetCString(res));
}
static char *
PrintString(Datum res)
{
- return psprintf("test string \"%s\"", DatumGetPointer(res));
+ return psprintf("test string \"%s\"", DatumGetCString(res));
}
/* demonstrates phases and priorities between a parent and child context */
--
2.52.0
From 08e6993de9f0ab2b75f023789905770b08b0f03b Mon Sep 17 00:00:00 2001
From: Peter Eisentraut <[email protected]>
Date: Mon, 24 Nov 2025 11:02:35 +0100
Subject: [PATCH 3/6] Don't rely on pointer arithmetic with Pointer type
Use char * explicitly where this is needed.
---
contrib/bloom/bloom.h | 2 +-
contrib/bloom/blutils.c | 4 +--
contrib/bloom/blvacuum.c | 2 +-
src/backend/access/gin/gindatapage.c | 18 ++++++-------
src/backend/access/gin/ginxlog.c | 20 +++++++-------
src/backend/access/rmgrdesc/genericdesc.c | 4 +--
src/backend/utils/adt/multirangetypes.c | 32 +++++++++++------------
src/backend/utils/adt/rangetypes.c | 16 ++++++------
8 files changed, 49 insertions(+), 49 deletions(-)
diff --git a/contrib/bloom/bloom.h b/contrib/bloom/bloom.h
index 648167045f4..b2966d37077 100644
--- a/contrib/bloom/bloom.h
+++ b/contrib/bloom/bloom.h
@@ -72,7 +72,7 @@ typedef BloomPageOpaqueData *BloomPageOpaque;
((BloomTuple *)(PageGetContents(page) \
+ (state)->sizeOfBloomTuple * ((offset) - 1)))
#define BloomPageGetNextTuple(state, tuple) \
- ((BloomTuple *)((Pointer)(tuple) + (state)->sizeOfBloomTuple))
+ ((BloomTuple *)((char *)(tuple) + (state)->sizeOfBloomTuple))
/* Preserved page numbers */
#define BLOOM_METAPAGE_BLKNO (0)
diff --git a/contrib/bloom/blutils.c b/contrib/bloom/blutils.c
index bf50037a71a..bbeefc3a75b 100644
--- a/contrib/bloom/blutils.c
+++ b/contrib/bloom/blutils.c
@@ -324,7 +324,7 @@ BloomPageAddItem(BloomState *state, Page page, BloomTuple *tuple)
{
BloomTuple *itup;
BloomPageOpaque opaque;
- Pointer ptr;
+ char *ptr;
/* We shouldn't be pointed to an invalid page */
Assert(!PageIsNew(page) && !BloomPageIsDeleted(page));
@@ -340,7 +340,7 @@ BloomPageAddItem(BloomState *state, Page page, BloomTuple *tuple)
/* Adjust maxoff and pd_lower */
opaque->maxoff++;
- ptr = (Pointer) BloomPageGetTuple(state, page, opaque->maxoff + 1);
+ ptr = (char *) BloomPageGetTuple(state, page, opaque->maxoff + 1);
((PageHeader) page)->pd_lower = ptr - page;
/* Assert we didn't overrun available space */
diff --git a/contrib/bloom/blvacuum.c b/contrib/bloom/blvacuum.c
index 044fd85a32a..cc0639a3ac4 100644
--- a/contrib/bloom/blvacuum.c
+++ b/contrib/bloom/blvacuum.c
@@ -122,7 +122,7 @@ blbulkdelete(IndexVacuumInfo *info, IndexBulkDeleteResult *stats,
if (BloomPageGetMaxOffset(page) == 0)
BloomPageSetDeleted(page);
/* Adjust pd_lower */
- ((PageHeader) page)->pd_lower = (Pointer) itupPtr - page;
+ ((PageHeader) page)->pd_lower = (char *) itupPtr - page;
/* Finish WAL-logging */
GenericXLogFinish(gxlogState);
}
diff --git a/src/backend/access/gin/gindatapage.c b/src/backend/access/gin/gindatapage.c
index 6c2c6194720..e677bdb2dcb 100644
--- a/src/backend/access/gin/gindatapage.c
+++ b/src/backend/access/gin/gindatapage.c
@@ -140,20 +140,20 @@ GinDataLeafPageGetItems(Page page, int *nitems, ItemPointerData advancePast)
{
GinPostingList *seg = GinDataLeafPageGetPostingList(page);
Size len = GinDataLeafPageGetPostingListSize(page);
- Pointer endptr = ((Pointer) seg) + len;
+ char *endptr = ((char *) seg) + len;
GinPostingList *next;
/* Skip to the segment containing advancePast+1 */
if (ItemPointerIsValid(&advancePast))
{
next = GinNextPostingListSegment(seg);
- while ((Pointer) next < endptr &&
+ while ((char *) next < endptr &&
ginCompareItemPointers(&next->first, &advancePast) <= 0)
{
seg = next;
next = GinNextPostingListSegment(seg);
}
- len = endptr - (Pointer) seg;
+ len = endptr - (char *) seg;
}
if (len > 0)
@@ -1371,8 +1371,8 @@ disassembleLeaf(Page page)
{
disassembledLeaf *leaf;
GinPostingList *seg;
- Pointer segbegin;
- Pointer segend;
+ char *segbegin;
+ char *segend;
leaf = palloc0(sizeof(disassembledLeaf));
dlist_init(&leaf->segments);
@@ -1383,9 +1383,9 @@ disassembleLeaf(Page page)
* Create a leafSegmentInfo entry for each segment.
*/
seg = GinDataLeafPageGetPostingList(page);
- segbegin = (Pointer) seg;
+ segbegin = (char *) seg;
segend = segbegin + GinDataLeafPageGetPostingListSize(page);
- while ((Pointer) seg < segend)
+ while ((char *) seg < segend)
{
leafSegmentInfo *seginfo = palloc(sizeof(leafSegmentInfo));
@@ -1779,7 +1779,7 @@ createPostingTree(Relation index, ItemPointerData *items, uint32 nitems,
Buffer buffer;
Page tmppage;
Page page;
- Pointer ptr;
+ char *ptr;
int nrootitems;
int rootsize;
bool is_build = (buildStats != NULL);
@@ -1795,7 +1795,7 @@ createPostingTree(Relation index, ItemPointerData *items, uint32 nitems,
*/
nrootitems = 0;
rootsize = 0;
- ptr = (Pointer) GinDataLeafPageGetPostingList(tmppage);
+ ptr = (char *) GinDataLeafPageGetPostingList(tmppage);
while (nrootitems < nitems)
{
GinPostingList *segment;
diff --git a/src/backend/access/gin/ginxlog.c b/src/backend/access/gin/ginxlog.c
index 606741fa396..34c01a01165 100644
--- a/src/backend/access/gin/ginxlog.c
+++ b/src/backend/access/gin/ginxlog.c
@@ -119,12 +119,12 @@ ginRedoRecompress(Page page, ginxlogRecompressDataLeaf *data)
int actionno;
int segno;
GinPostingList *oldseg;
- Pointer segmentend;
+ char *segmentend;
char *walbuf;
int totalsize;
- Pointer tailCopy = NULL;
- Pointer writePtr;
- Pointer segptr;
+ void *tailCopy = NULL;
+ char *writePtr;
+ char *segptr;
/*
* If the page is in pre-9.4 format, convert to new format first.
@@ -164,8 +164,8 @@ ginRedoRecompress(Page page, ginxlogRecompressDataLeaf *data)
}
oldseg = GinDataLeafPageGetPostingList(page);
- writePtr = (Pointer) oldseg;
- segmentend = (Pointer) oldseg + GinDataLeafPageGetPostingListSize(page);
+ writePtr = (char *) oldseg;
+ segmentend = (char *) oldseg + GinDataLeafPageGetPostingListSize(page);
segno = 0;
walbuf = ((char *) data) + sizeof(ginxlogRecompressDataLeaf);
@@ -243,7 +243,7 @@ ginRedoRecompress(Page page, ginxlogRecompressDataLeaf *data)
a_action = GIN_SEGMENT_REPLACE;
}
- segptr = (Pointer) oldseg;
+ segptr = (char *) oldseg;
if (segptr != segmentend)
segsize = SizeOfGinPostingList(oldseg);
else
@@ -264,7 +264,7 @@ ginRedoRecompress(Page page, ginxlogRecompressDataLeaf *data)
{
int tailSize = segmentend - segptr;
- tailCopy = (Pointer) palloc(tailSize);
+ tailCopy = palloc(tailSize);
memcpy(tailCopy, segptr, tailSize);
segptr = tailCopy;
oldseg = (GinPostingList *) segptr;
@@ -301,7 +301,7 @@ ginRedoRecompress(Page page, ginxlogRecompressDataLeaf *data)
}
/* Copy the rest of unmodified segments if any. */
- segptr = (Pointer) oldseg;
+ segptr = (char *) oldseg;
if (segptr != segmentend && tailCopy)
{
int restSize = segmentend - segptr;
@@ -311,7 +311,7 @@ ginRedoRecompress(Page page, ginxlogRecompressDataLeaf *data)
writePtr += restSize;
}
- totalsize = writePtr - (Pointer) GinDataLeafPageGetPostingList(page);
+ totalsize = writePtr - (char *) GinDataLeafPageGetPostingList(page);
GinDataPageSetDataSize(page, totalsize);
}
diff --git a/src/backend/access/rmgrdesc/genericdesc.c b/src/backend/access/rmgrdesc/genericdesc.c
index 75dc4108b9a..29a4c9e894b 100644
--- a/src/backend/access/rmgrdesc/genericdesc.c
+++ b/src/backend/access/rmgrdesc/genericdesc.c
@@ -23,8 +23,8 @@
void
generic_desc(StringInfo buf, XLogReaderState *record)
{
- Pointer ptr = XLogRecGetData(record),
- end = ptr + XLogRecGetDataLen(record);
+ const char *ptr = XLogRecGetData(record);
+ const char *end = ptr + XLogRecGetDataLen(record);
while (ptr < end)
{
diff --git a/src/backend/utils/adt/multirangetypes.c b/src/backend/utils/adt/multirangetypes.c
index 55e0b4fdc31..e259644c6ca 100644
--- a/src/backend/utils/adt/multirangetypes.c
+++ b/src/backend/utils/adt/multirangetypes.c
@@ -68,11 +68,11 @@ typedef enum
* Macros for accessing past MultirangeType parts of multirange: items, flags
* and boundaries.
*/
-#define MultirangeGetItemsPtr(mr) ((uint32 *) ((Pointer) (mr) + \
+#define MultirangeGetItemsPtr(mr) ((uint32 *) ((char *) (mr) + \
sizeof(MultirangeType)))
-#define MultirangeGetFlagsPtr(mr) ((uint8 *) ((Pointer) (mr) + \
+#define MultirangeGetFlagsPtr(mr) ((uint8 *) ((char *) (mr) + \
sizeof(MultirangeType) + ((mr)->rangeCount - 1) * sizeof(uint32)))
-#define MultirangeGetBoundariesPtr(mr, align) ((Pointer) (mr) + \
+#define MultirangeGetBoundariesPtr(mr, align) ((char *) (mr) + \
att_align_nominal(sizeof(MultirangeType) + \
((mr)->rangeCount - 1) * sizeof(uint32) + \
(mr)->rangeCount * sizeof(uint8), (align)))
@@ -602,13 +602,13 @@ write_multirange_data(MultirangeType *multirange, TypeCacheEntry *rangetyp,
uint32 prev_offset = 0;
uint8 *flags;
int32 i;
- Pointer begin,
- ptr;
+ const char *begin;
+ char *ptr;
char elemalign = rangetyp->rngelemtype->typalign;
items = MultirangeGetItemsPtr(multirange);
flags = MultirangeGetFlagsPtr(multirange);
- ptr = begin = MultirangeGetBoundariesPtr(multirange, elemalign);
+ begin = ptr = MultirangeGetBoundariesPtr(multirange, elemalign);
for (i = 0; i < range_count; i++)
{
uint32 len;
@@ -627,7 +627,7 @@ write_multirange_data(MultirangeType *multirange, TypeCacheEntry *rangetyp,
items[i - 1] |= MULTIRANGE_ITEM_OFF_BIT;
prev_offset = ptr - begin;
}
- flags[i] = *((Pointer) ranges[i] + VARSIZE(ranges[i]) - sizeof(char));
+ flags[i] = *((char *) ranges[i] + VARSIZE(ranges[i]) - sizeof(char));
len = VARSIZE(ranges[i]) - sizeof(RangeType) - sizeof(char);
memcpy(ptr, ranges[i] + 1, len);
ptr += att_align_nominal(len, elemalign);
@@ -699,8 +699,8 @@ multirange_get_range(TypeCacheEntry *rangetyp,
{
uint32 offset;
uint8 flags;
- Pointer begin,
- ptr;
+ const char *begin;
+ char *ptr;
int16 typlen = rangetyp->rngelemtype->typlen;
char typalign = rangetyp->rngelemtype->typalign;
uint32 len;
@@ -710,7 +710,7 @@ multirange_get_range(TypeCacheEntry *rangetyp,
offset = multirange_get_bounds_offset(multirange, i);
flags = MultirangeGetFlagsPtr(multirange)[i];
- ptr = begin = MultirangeGetBoundariesPtr(multirange, typalign) + offset;
+ begin = ptr = MultirangeGetBoundariesPtr(multirange, typalign) + offset;
/*
* Calculate the size of bound values. In principle, we could get offset
@@ -719,11 +719,11 @@ multirange_get_range(TypeCacheEntry *rangetyp,
* exact size.
*/
if (RANGE_HAS_LBOUND(flags))
- ptr = (Pointer) att_addlength_pointer(ptr, typlen, ptr);
+ ptr = (char *) att_addlength_pointer(ptr, typlen, ptr);
if (RANGE_HAS_UBOUND(flags))
{
- ptr = (Pointer) att_align_pointer(ptr, typalign, typlen, ptr);
- ptr = (Pointer) att_addlength_pointer(ptr, typlen, ptr);
+ ptr = (char *) att_align_pointer(ptr, typalign, typlen, ptr);
+ ptr = (char *) att_addlength_pointer(ptr, typlen, ptr);
}
len = (ptr - begin) + sizeof(RangeType) + sizeof(uint8);
@@ -749,7 +749,7 @@ multirange_get_bounds(TypeCacheEntry *rangetyp,
{
uint32 offset;
uint8 flags;
- Pointer ptr;
+ const char *ptr;
int16 typlen = rangetyp->rngelemtype->typlen;
char typalign = rangetyp->rngelemtype->typalign;
bool typbyval = rangetyp->rngelemtype->typbyval;
@@ -770,7 +770,7 @@ multirange_get_bounds(TypeCacheEntry *rangetyp,
{
/* att_align_pointer cannot be necessary here */
lbound = fetch_att(ptr, typbyval, typlen);
- ptr = (Pointer) att_addlength_pointer(ptr, typlen, ptr);
+ ptr = (char *) att_addlength_pointer(ptr, typlen, ptr);
}
else
lbound = (Datum) 0;
@@ -778,7 +778,7 @@ multirange_get_bounds(TypeCacheEntry *rangetyp,
/* fetch upper bound, if any */
if (RANGE_HAS_UBOUND(flags))
{
- ptr = (Pointer) att_align_pointer(ptr, typalign, typlen, ptr);
+ ptr = (char *) att_align_pointer(ptr, typalign, typlen, ptr);
ubound = fetch_att(ptr, typbyval, typlen);
/* no need for att_addlength_pointer */
}
diff --git a/src/backend/utils/adt/rangetypes.c b/src/backend/utils/adt/rangetypes.c
index 065a8000cf2..b7e9f6dc0a8 100644
--- a/src/backend/utils/adt/rangetypes.c
+++ b/src/backend/utils/adt/rangetypes.c
@@ -72,8 +72,8 @@ static char *range_deparse(char flags, const char *lbound_str,
static char *range_bound_escape(const char *value);
static Size datum_compute_size(Size data_length, Datum val, bool typbyval,
char typalign, int16 typlen, char typstorage);
-static Pointer datum_write(Pointer ptr, Datum datum, bool typbyval,
- char typalign, int16 typlen, char typstorage);
+static char *datum_write(char *ptr, Datum datum, bool typbyval,
+ char typalign, int16 typlen, char typstorage);
static Node *find_simplified_clause(PlannerInfo *root,
Expr *rangeExpr, Expr *elemExpr);
static Expr *build_bound_expr(Expr *elemExpr, Datum val,
@@ -2092,7 +2092,7 @@ range_deserialize(TypeCacheEntry *typcache, const RangeType *range,
int16 typlen;
bool typbyval;
char typalign;
- Pointer ptr;
+ const char *ptr;
Datum lbound;
Datum ubound;
@@ -2108,14 +2108,14 @@ range_deserialize(TypeCacheEntry *typcache, const RangeType *range,
typalign = typcache->rngelemtype->typalign;
/* initialize data pointer just after the range OID */
- ptr = (Pointer) (range + 1);
+ ptr = (char *) (range + 1);
/* fetch lower bound, if any */
if (RANGE_HAS_LBOUND(flags))
{
/* att_align_pointer cannot be necessary here */
lbound = fetch_att(ptr, typbyval, typlen);
- ptr = (Pointer) att_addlength_pointer(ptr, typlen, ptr);
+ ptr = (char *) att_addlength_pointer(ptr, typlen, ptr);
}
else
lbound = (Datum) 0;
@@ -2123,7 +2123,7 @@ range_deserialize(TypeCacheEntry *typcache, const RangeType *range,
/* fetch upper bound, if any */
if (RANGE_HAS_UBOUND(flags))
{
- ptr = (Pointer) att_align_pointer(ptr, typalign, typlen, ptr);
+ ptr = (char *) att_align_pointer(ptr, typalign, typlen, ptr);
ubound = fetch_att(ptr, typbyval, typlen);
/* no need for att_addlength_pointer */
}
@@ -2937,8 +2937,8 @@ datum_compute_size(Size data_length, Datum val, bool typbyval, char typalign,
* Write the given datum beginning at ptr (after advancing to correct
* alignment, if needed). Return the pointer incremented by space used.
*/
-static Pointer
-datum_write(Pointer ptr, Datum datum, bool typbyval, char typalign,
+static char *
+datum_write(char *ptr, Datum datum, bool typbyval, char typalign,
int16 typlen, char typstorage)
{
Size data_length;
--
2.52.0
From 75027ac5cbe10abc785049c7bcfddc526d5cea54 Mon Sep 17 00:00:00 2001
From: Peter Eisentraut <[email protected]>
Date: Mon, 24 Nov 2025 11:02:35 +0100
Subject: [PATCH 4/6] Change Pointer to void *
---
src/include/c.h | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/src/include/c.h b/src/include/c.h
index 729eb8a27de..fd9a89fe5f7 100644
--- a/src/include/c.h
+++ b/src/include/c.h
@@ -527,11 +527,9 @@ typedef void (*pg_funcptr_t) (void);
/*
* Pointer
* Variable holding address of any memory resident object.
- *
- * XXX Pointer arithmetic is done with this, so it can't be void *
- * under "true" ANSI compilers.
+ * (obsolescent; use void * or char *)
*/
-typedef char *Pointer;
+typedef void *Pointer;
/* Historical names for types in <stdint.h>. */
typedef int8_t int8;
--
2.52.0
From 573406a6f5deed046a88eae62becc0bae7b4b24a Mon Sep 17 00:00:00 2001
From: Peter Eisentraut <[email protected]>
Date: Mon, 24 Nov 2025 11:02:35 +0100
Subject: [PATCH 5/6] Remove no longer needed casts to (Pointer)
---
contrib/btree_gist/btree_utils_var.h | 2 +-
src/backend/access/heap/heaptoast.c | 4 ++--
src/backend/catalog/aclchk.c | 18 +++++++++---------
src/backend/catalog/pg_constraint.c | 12 ++++++------
src/backend/utils/adt/arrayfuncs.c | 2 +-
src/backend/utils/adt/datum.c | 6 +++---
src/backend/utils/adt/like_support.c | 4 ++--
src/backend/utils/adt/numeric.c | 6 +++---
src/backend/utils/adt/rangetypes.c | 4 ++--
src/backend/utils/adt/rowtypes.c | 4 ++--
src/backend/utils/cache/evtcache.c | 2 +-
src/include/fmgr.h | 2 +-
12 files changed, 33 insertions(+), 33 deletions(-)
diff --git a/contrib/btree_gist/btree_utils_var.h b/contrib/btree_gist/btree_utils_var.h
index 75ad33d24fc..6cb3aadf3c3 100644
--- a/contrib/btree_gist/btree_utils_var.h
+++ b/contrib/btree_gist/btree_utils_var.h
@@ -49,7 +49,7 @@ typedef struct
*/
#define GBT_FREE_IF_COPY(ptr1, ptr2) \
do { \
- if ((Pointer) (ptr1) != DatumGetPointer(ptr2)) \
+ if ((ptr1) != DatumGetPointer(ptr2)) \
pfree(ptr1); \
} while (0)
diff --git a/src/backend/access/heap/heaptoast.c b/src/backend/access/heap/heaptoast.c
index e148c9be482..60e765fbfce 100644
--- a/src/backend/access/heap/heaptoast.c
+++ b/src/backend/access/heap/heaptoast.c
@@ -569,7 +569,7 @@ toast_build_flattened_tuple(TupleDesc tupleDesc,
int num_to_free;
int i;
Datum new_values[MaxTupleAttributeNumber];
- Pointer freeable_values[MaxTupleAttributeNumber];
+ void *freeable_values[MaxTupleAttributeNumber];
/*
* We can pass the caller's isnull array directly to heap_form_tuple, but
@@ -593,7 +593,7 @@ toast_build_flattened_tuple(TupleDesc tupleDesc,
{
new_value = detoast_external_attr(new_value);
new_values[i] = PointerGetDatum(new_value);
- freeable_values[num_to_free++] = (Pointer) new_value;
+ freeable_values[num_to_free++] = new_value;
}
}
}
diff --git a/src/backend/catalog/aclchk.c b/src/backend/catalog/aclchk.c
index cd139bd65a6..58d006986b8 100644
--- a/src/backend/catalog/aclchk.c
+++ b/src/backend/catalog/aclchk.c
@@ -3125,7 +3125,7 @@ object_aclmask_ext(Oid classid, Oid objectid, Oid roleid,
result = aclmask(acl, roleid, ownerId, mask, how);
/* if we have a detoasted copy, free it */
- if (acl && (Pointer) acl != DatumGetPointer(aclDatum))
+ if (acl && acl != DatumGetPointer(aclDatum))
pfree(acl);
ReleaseSysCache(tuple);
@@ -3255,7 +3255,7 @@ pg_attribute_aclmask_ext(Oid table_oid, AttrNumber attnum, Oid roleid,
result = aclmask(acl, roleid, ownerId, mask, how);
/* if we have a detoasted copy, free it */
- if (acl && (Pointer) acl != DatumGetPointer(aclDatum))
+ if (acl && acl != DatumGetPointer(aclDatum))
pfree(acl);
ReleaseSysCache(attTuple);
@@ -3362,7 +3362,7 @@ pg_class_aclmask_ext(Oid table_oid, Oid roleid, AclMode mask,
result = aclmask(acl, roleid, ownerId, mask, how);
/* if we have a detoasted copy, free it */
- if (acl && (Pointer) acl != DatumGetPointer(aclDatum))
+ if (acl && acl != DatumGetPointer(aclDatum))
pfree(acl);
ReleaseSysCache(tuple);
@@ -3454,7 +3454,7 @@ pg_parameter_aclmask(const char *name, Oid roleid, AclMode mask, AclMaskHow how)
result = aclmask(acl, roleid, BOOTSTRAP_SUPERUSERID, mask, how);
/* if we have a detoasted copy, free it */
- if (acl && (Pointer) acl != DatumGetPointer(aclDatum))
+ if (acl && acl != DatumGetPointer(aclDatum))
pfree(acl);
ReleaseSysCache(tuple);
@@ -3509,7 +3509,7 @@ pg_parameter_acl_aclmask(Oid acl_oid, Oid roleid, AclMode mask, AclMaskHow how)
result = aclmask(acl, roleid, BOOTSTRAP_SUPERUSERID, mask, how);
/* if we have a detoasted copy, free it */
- if (acl && (Pointer) acl != DatumGetPointer(aclDatum))
+ if (acl && acl != DatumGetPointer(aclDatum))
pfree(acl);
ReleaseSysCache(tuple);
@@ -3589,7 +3589,7 @@ pg_largeobject_aclmask_snapshot(Oid lobj_oid, Oid roleid,
result = aclmask(acl, roleid, ownerId, mask, how);
/* if we have a detoasted copy, free it */
- if (acl && (Pointer) acl != DatumGetPointer(aclDatum))
+ if (acl && acl != DatumGetPointer(aclDatum))
pfree(acl);
systable_endscan(scan);
@@ -3683,7 +3683,7 @@ pg_namespace_aclmask_ext(Oid nsp_oid, Oid roleid,
result = aclmask(acl, roleid, ownerId, mask, how);
/* if we have a detoasted copy, free it */
- if (acl && (Pointer) acl != DatumGetPointer(aclDatum))
+ if (acl && acl != DatumGetPointer(aclDatum))
pfree(acl);
ReleaseSysCache(tuple);
@@ -3819,7 +3819,7 @@ pg_type_aclmask_ext(Oid type_oid, Oid roleid, AclMode mask, AclMaskHow how,
result = aclmask(acl, roleid, ownerId, mask, how);
/* if we have a detoasted copy, free it */
- if (acl && (Pointer) acl != DatumGetPointer(aclDatum))
+ if (acl && acl != DatumGetPointer(aclDatum))
pfree(acl);
ReleaseSysCache(tuple);
@@ -4003,7 +4003,7 @@ pg_attribute_aclcheck_all_ext(Oid table_oid, Oid roleid,
attmask = aclmask(acl, roleid, ownerId, mode, ACLMASK_ANY);
/* if we have a detoasted copy, free it */
- if ((Pointer) acl != DatumGetPointer(aclDatum))
+ if (acl != DatumGetPointer(aclDatum))
pfree(acl);
}
diff --git a/src/backend/catalog/pg_constraint.c b/src/backend/catalog/pg_constraint.c
index 9944e4bd2d1..5b2a8132306 100644
--- a/src/backend/catalog/pg_constraint.c
+++ b/src/backend/catalog/pg_constraint.c
@@ -1544,7 +1544,7 @@ DeconstructFkConstraintRow(HeapTuple tuple, int *numfks,
if (numkeys <= 0 || numkeys > INDEX_MAX_KEYS)
elog(ERROR, "foreign key constraint cannot have %d columns", numkeys);
memcpy(conkey, ARR_DATA_PTR(arr), numkeys * sizeof(int16));
- if ((Pointer) arr != DatumGetPointer(adatum))
+ if (arr != DatumGetPointer(adatum))
pfree(arr); /* free de-toasted copy, if any */
adatum = SysCacheGetAttrNotNull(CONSTROID, tuple,
@@ -1556,7 +1556,7 @@ DeconstructFkConstraintRow(HeapTuple tuple, int *numfks,
ARR_ELEMTYPE(arr) != INT2OID)
elog(ERROR, "confkey is not a 1-D smallint array");
memcpy(confkey, ARR_DATA_PTR(arr), numkeys * sizeof(int16));
- if ((Pointer) arr != DatumGetPointer(adatum))
+ if (arr != DatumGetPointer(adatum))
pfree(arr); /* free de-toasted copy, if any */
if (pf_eq_oprs)
@@ -1571,7 +1571,7 @@ DeconstructFkConstraintRow(HeapTuple tuple, int *numfks,
ARR_ELEMTYPE(arr) != OIDOID)
elog(ERROR, "conpfeqop is not a 1-D Oid array");
memcpy(pf_eq_oprs, ARR_DATA_PTR(arr), numkeys * sizeof(Oid));
- if ((Pointer) arr != DatumGetPointer(adatum))
+ if (arr != DatumGetPointer(adatum))
pfree(arr); /* free de-toasted copy, if any */
}
@@ -1586,7 +1586,7 @@ DeconstructFkConstraintRow(HeapTuple tuple, int *numfks,
ARR_ELEMTYPE(arr) != OIDOID)
elog(ERROR, "conppeqop is not a 1-D Oid array");
memcpy(pp_eq_oprs, ARR_DATA_PTR(arr), numkeys * sizeof(Oid));
- if ((Pointer) arr != DatumGetPointer(adatum))
+ if (arr != DatumGetPointer(adatum))
pfree(arr); /* free de-toasted copy, if any */
}
@@ -1601,7 +1601,7 @@ DeconstructFkConstraintRow(HeapTuple tuple, int *numfks,
ARR_ELEMTYPE(arr) != OIDOID)
elog(ERROR, "conffeqop is not a 1-D Oid array");
memcpy(ff_eq_oprs, ARR_DATA_PTR(arr), numkeys * sizeof(Oid));
- if ((Pointer) arr != DatumGetPointer(adatum))
+ if (arr != DatumGetPointer(adatum))
pfree(arr); /* free de-toasted copy, if any */
}
@@ -1624,7 +1624,7 @@ DeconstructFkConstraintRow(HeapTuple tuple, int *numfks,
elog(ERROR, "confdelsetcols is not a 1-D smallint array");
num_delete_cols = ARR_DIMS(arr)[0];
memcpy(fk_del_set_cols, ARR_DATA_PTR(arr), num_delete_cols * sizeof(int16));
- if ((Pointer) arr != DatumGetPointer(adatum))
+ if (arr != DatumGetPointer(adatum))
pfree(arr); /* free de-toasted copy, if any */
*num_fk_del_set_cols = num_delete_cols;
diff --git a/src/backend/utils/adt/arrayfuncs.c b/src/backend/utils/adt/arrayfuncs.c
index a464349ee33..6dc65d3d4cb 100644
--- a/src/backend/utils/adt/arrayfuncs.c
+++ b/src/backend/utils/adt/arrayfuncs.c
@@ -5687,7 +5687,7 @@ accumArrayResultArr(ArrayBuildStateArr *astate,
MemoryContextSwitchTo(oldcontext);
/* Release detoasted copy if any */
- if ((Pointer) arg != DatumGetPointer(dvalue))
+ if (arg != DatumGetPointer(dvalue))
pfree(arg);
return astate;
diff --git a/src/backend/utils/adt/datum.c b/src/backend/utils/adt/datum.c
index c2b111b829e..dabcca6f4c5 100644
--- a/src/backend/utils/adt/datum.c
+++ b/src/backend/utils/adt/datum.c
@@ -299,9 +299,9 @@ datum_image_eq(Datum value1, Datum value2, bool typByVal, int typLen)
len1 - VARHDRSZ) == 0);
/* Only free memory if it's a copy made here. */
- if ((Pointer) arg1val != DatumGetPointer(value1))
+ if (arg1val != DatumGetPointer(value1))
pfree(arg1val);
- if ((Pointer) arg2val != DatumGetPointer(value2))
+ if (arg2val != DatumGetPointer(value2))
pfree(arg2val);
}
}
@@ -355,7 +355,7 @@ datum_image_hash(Datum value, bool typByVal, int typLen)
result = hash_bytes((unsigned char *) VARDATA_ANY(val), len - VARHDRSZ);
/* Only free memory if it's a copy made here. */
- if ((Pointer) val != DatumGetPointer(value))
+ if (val != DatumGetPointer(value))
pfree(val);
}
else if (typLen == -2)
diff --git a/src/backend/utils/adt/like_support.c b/src/backend/utils/adt/like_support.c
index 999f23f86d5..dca1d9be035 100644
--- a/src/backend/utils/adt/like_support.c
+++ b/src/backend/utils/adt/like_support.c
@@ -1035,7 +1035,7 @@ like_fixed_prefix(Const *patt_const, bool case_insensitive, Oid collation,
pattlen = VARSIZE_ANY_EXHDR(bstr);
patt = (char *) palloc(pattlen);
memcpy(patt, VARDATA_ANY(bstr), pattlen);
- Assert((Pointer) bstr == DatumGetPointer(patt_const->constvalue));
+ Assert(bstr == DatumGetPointer(patt_const->constvalue));
}
match = palloc(pattlen + 1);
@@ -1577,7 +1577,7 @@ make_greater_string(const Const *str_const, FmgrInfo *ltproc, Oid collation)
len = VARSIZE_ANY_EXHDR(bstr);
workstr = (char *) palloc(len);
memcpy(workstr, VARDATA_ANY(bstr), len);
- Assert((Pointer) bstr == DatumGetPointer(str_const->constvalue));
+ Assert(bstr == DatumGetPointer(str_const->constvalue));
cmpstr = str_const->constvalue;
}
else
diff --git a/src/backend/utils/adt/numeric.c b/src/backend/utils/adt/numeric.c
index 2501007d981..1d626aecbe7 100644
--- a/src/backend/utils/adt/numeric.c
+++ b/src/backend/utils/adt/numeric.c
@@ -2194,7 +2194,7 @@ numeric_abbrev_convert(Datum original_datum, SortSupport ssup)
}
/* should happen only for external/compressed toasts */
- if ((Pointer) original_varatt != DatumGetPointer(original_datum))
+ if (original_varatt != DatumGetPointer(original_datum))
pfree(original_varatt);
return result;
@@ -2284,9 +2284,9 @@ numeric_fast_cmp(Datum x, Datum y, SortSupport ssup)
result = cmp_numerics(nx, ny);
- if ((Pointer) nx != DatumGetPointer(x))
+ if (nx != DatumGetPointer(x))
pfree(nx);
- if ((Pointer) ny != DatumGetPointer(y))
+ if (ny != DatumGetPointer(y))
pfree(ny);
return result;
diff --git a/src/backend/utils/adt/rangetypes.c b/src/backend/utils/adt/rangetypes.c
index b7e9f6dc0a8..d8e5130d642 100644
--- a/src/backend/utils/adt/rangetypes.c
+++ b/src/backend/utils/adt/rangetypes.c
@@ -1513,9 +1513,9 @@ range_fast_cmp(Datum a, Datum b, SortSupport ssup)
cmp = range_cmp_bounds(typcache, &upper1, &upper2);
}
- if ((Pointer) range_a != DatumGetPointer(a))
+ if (range_a != DatumGetPointer(a))
pfree(range_a);
- if ((Pointer) range_b != DatumGetPointer(b))
+ if (range_b != DatumGetPointer(b))
pfree(range_b);
return cmp;
diff --git a/src/backend/utils/adt/rowtypes.c b/src/backend/utils/adt/rowtypes.c
index 9e5449f17d7..38e6fe1c43a 100644
--- a/src/backend/utils/adt/rowtypes.c
+++ b/src/backend/utils/adt/rowtypes.c
@@ -1529,9 +1529,9 @@ record_image_cmp(FunctionCallInfo fcinfo)
if ((cmpresult == 0) && (len1 != len2))
cmpresult = (len1 < len2) ? -1 : 1;
- if ((Pointer) arg1val != DatumGetPointer(values1[i1]))
+ if (arg1val != DatumGetPointer(values1[i1]))
pfree(arg1val);
- if ((Pointer) arg2val != DatumGetPointer(values2[i2]))
+ if (arg2val != DatumGetPointer(values2[i2]))
pfree(arg2val);
}
else
diff --git a/src/backend/utils/cache/evtcache.c b/src/backend/utils/cache/evtcache.c
index b9d5a5998be..76ba2db5390 100644
--- a/src/backend/utils/cache/evtcache.c
+++ b/src/backend/utils/cache/evtcache.c
@@ -240,7 +240,7 @@ DecodeTextArrayToBitmapset(Datum array)
}
pfree(elems);
- if ((Pointer) arr != DatumGetPointer(array))
+ if (arr != DatumGetPointer(array))
pfree(arr);
return bms;
diff --git a/src/include/fmgr.h b/src/include/fmgr.h
index 74fe3ea0575..c0dbe85ed1c 100644
--- a/src/include/fmgr.h
+++ b/src/include/fmgr.h
@@ -259,7 +259,7 @@ extern struct varlena *pg_detoast_datum_packed(struct varlena *datum);
*/
#define PG_FREE_IF_COPY(ptr,n) \
do { \
- if ((Pointer) (ptr) != PG_GETARG_POINTER(n)) \
+ if ((ptr) != PG_GETARG_POINTER(n)) \
pfree(ptr); \
} while (0)
--
2.52.0
From 467201808f4537291513c2151ff3266723b64314 Mon Sep 17 00:00:00 2001
From: Peter Eisentraut <[email protected]>
Date: Mon, 24 Nov 2025 11:02:35 +0100
Subject: [PATCH 6/6] Remove some uses of the Pointer type
everywhere except GIN
---
contrib/amcheck/verify_heapam.c | 2 +-
src/backend/access/common/heaptuple.c | 2 +-
src/backend/access/common/toast_internals.c | 2 +-
src/backend/access/heap/heaptoast.c | 2 +-
src/backend/nodes/tidbitmap.c | 4 ++--
src/backend/replication/logical/reorderbuffer.c | 4 ++--
src/backend/utils/adt/rangetypes.c | 6 +++---
src/bin/initdb/initdb.c | 4 ++--
src/include/postgres.h | 4 ++--
9 files changed, 15 insertions(+), 15 deletions(-)
diff --git a/contrib/amcheck/verify_heapam.c b/contrib/amcheck/verify_heapam.c
index 4963e9245cb..aa9974a867b 100644
--- a/contrib/amcheck/verify_heapam.c
+++ b/contrib/amcheck/verify_heapam.c
@@ -1557,7 +1557,7 @@ check_toast_tuple(HeapTuple toasttup, HeapCheckContext *ctx,
{
int32 chunk_seq;
int32 last_chunk_seq = (extsize - 1) / TOAST_MAX_CHUNK_SIZE;
- Pointer chunk;
+ void *chunk;
bool isnull;
int32 chunksize;
int32 expected_size;
diff --git a/src/backend/access/common/heaptuple.c b/src/backend/access/common/heaptuple.c
index 74a52d87067..36b09ea5bff 100644
--- a/src/backend/access/common/heaptuple.c
+++ b/src/backend/access/common/heaptuple.c
@@ -321,7 +321,7 @@ fill_val(CompactAttribute *att,
else if (att->attlen == -1)
{
/* varlena */
- Pointer val = DatumGetPointer(datum);
+ void *val = DatumGetPointer(datum);
*infomask |= HEAP_HASVARWIDTH;
if (VARATT_IS_EXTERNAL(val))
diff --git a/src/backend/access/common/toast_internals.c b/src/backend/access/common/toast_internals.c
index 63b848473f8..ba6ef6f4e72 100644
--- a/src/backend/access/common/toast_internals.c
+++ b/src/backend/access/common/toast_internals.c
@@ -128,7 +128,7 @@ toast_save_datum(Relation rel, Datum value,
int32 chunk_seq = 0;
char *data_p;
int32 data_todo;
- Pointer dval = DatumGetPointer(value);
+ void *dval = DatumGetPointer(value);
int num_indexes;
int validIndex;
diff --git a/src/backend/access/heap/heaptoast.c b/src/backend/access/heap/heaptoast.c
index 60e765fbfce..a049d7c7e81 100644
--- a/src/backend/access/heap/heaptoast.c
+++ b/src/backend/access/heap/heaptoast.c
@@ -696,7 +696,7 @@ heap_fetch_toast_slice(Relation toastrel, Oid valueid, int32 attrsize,
while ((ttup = systable_getnext_ordered(toastscan, ForwardScanDirection)) != NULL)
{
int32 curchunk;
- Pointer chunk;
+ void *chunk;
bool isnull;
char *chunkdata;
int32 chunksize;
diff --git a/src/backend/nodes/tidbitmap.c b/src/backend/nodes/tidbitmap.c
index 23d97b3a6c8..425c1177b22 100644
--- a/src/backend/nodes/tidbitmap.c
+++ b/src/backend/nodes/tidbitmap.c
@@ -1550,11 +1550,11 @@ tbm_calculate_entries(Size maxbytes)
/*
* Estimate number of hashtable entries we can have within maxbytes. This
* estimates the hash cost as sizeof(PagetableEntry), which is good enough
- * for our purpose. Also count an extra Pointer per entry for the arrays
+ * for our purpose. Also count an extra pointer per entry for the arrays
* created during iteration readout.
*/
nbuckets = maxbytes /
- (sizeof(PagetableEntry) + sizeof(Pointer) + sizeof(Pointer));
+ (sizeof(PagetableEntry) + sizeof(void *) + sizeof(void *));
nbuckets = Min(nbuckets, INT_MAX - 1); /* safety limit */
nbuckets = Max(nbuckets, 16); /* sanity limit */
diff --git a/src/backend/replication/logical/reorderbuffer.c b/src/backend/replication/logical/reorderbuffer.c
index eb6a84554b7..a014ef72aca 100644
--- a/src/backend/replication/logical/reorderbuffer.c
+++ b/src/backend/replication/logical/reorderbuffer.c
@@ -5003,7 +5003,7 @@ ReorderBufferToastAppendChunk(ReorderBuffer *rb, ReorderBufferTXN *txn,
bool found;
int32 chunksize;
bool isnull;
- Pointer chunk;
+ void *chunk;
TupleDesc desc = RelationGetDescr(relation);
Oid chunk_id;
int32 chunk_seq;
@@ -5192,7 +5192,7 @@ ReorderBufferToastReplace(ReorderBuffer *rb, ReorderBufferTXN *txn,
bool cisnull;
ReorderBufferChange *cchange;
HeapTuple ctup;
- Pointer chunk;
+ void *chunk;
cchange = dlist_container(ReorderBufferChange, node, it.cur);
ctup = cchange->data.tp.newtuple;
diff --git a/src/backend/utils/adt/rangetypes.c b/src/backend/utils/adt/rangetypes.c
index d8e5130d642..b887f21f10e 100644
--- a/src/backend/utils/adt/rangetypes.c
+++ b/src/backend/utils/adt/rangetypes.c
@@ -1962,7 +1962,7 @@ range_serialize(TypeCacheEntry *typcache, RangeBound *lower, RangeBound *upper,
RangeType *range;
int cmp;
Size msize;
- Pointer ptr;
+ char *ptr;
int16 typlen;
bool typbyval;
char typalign;
@@ -2070,7 +2070,7 @@ range_serialize(TypeCacheEntry *typcache, RangeBound *lower, RangeBound *upper,
typstorage);
}
- *((char *) ptr) = flags;
+ *ptr = flags;
return range;
}
@@ -2953,7 +2953,7 @@ datum_write(char *ptr, Datum datum, bool typbyval, char typalign,
else if (typlen == -1)
{
/* varlena */
- Pointer val = DatumGetPointer(datum);
+ void *val = DatumGetPointer(datum);
if (VARATT_IS_EXTERNAL(val))
{
diff --git a/src/bin/initdb/initdb.c b/src/bin/initdb/initdb.c
index 92fe2f531f7..30fce0d5f37 100644
--- a/src/bin/initdb/initdb.c
+++ b/src/bin/initdb/initdb.c
@@ -1574,11 +1574,11 @@ bootstrap_template1(void)
sprintf(buf, "%d", NAMEDATALEN);
bki_lines = replace_token(bki_lines, "NAMEDATALEN", buf);
- sprintf(buf, "%d", (int) sizeof(Pointer));
+ sprintf(buf, "%d", (int) sizeof(void *));
bki_lines = replace_token(bki_lines, "SIZEOF_POINTER", buf);
bki_lines = replace_token(bki_lines, "ALIGNOF_POINTER",
- (sizeof(Pointer) == 4) ? "i" : "d");
+ (sizeof(void *) == 4) ? "i" : "d");
bki_lines = replace_token(bki_lines, "POSTGRES",
escape_quotes_bki(username));
diff --git a/src/include/postgres.h b/src/include/postgres.h
index 357cbd6fd96..5f1c6b0a79e 100644
--- a/src/include/postgres.h
+++ b/src/include/postgres.h
@@ -318,10 +318,10 @@ CommandIdGetDatum(CommandId X)
* DatumGetPointer
* Returns pointer value of a datum.
*/
-static inline Pointer
+static inline void *
DatumGetPointer(Datum X)
{
- return (Pointer) (uintptr_t) X;
+ return (void *) (uintptr_t) X;
}
/*
--
2.52.0
Attachments:
[text/plain] 0001-Remove-useless-casts-to-Pointer.patch (2.6K, ../../[email protected]/2-0001-Remove-useless-casts-to-Pointer.patch)
download | inline diff:
From d4c4d36810bbfb87d2e20d527c34025ea873de12 Mon Sep 17 00:00:00 2001
From: Peter Eisentraut <[email protected]>
Date: Mon, 24 Nov 2025 11:02:35 +0100
Subject: [PATCH 1/6] Remove useless casts to Pointer
---
contrib/bloom/blutils.c | 2 +-
contrib/bloom/blvacuum.c | 2 +-
src/backend/access/gin/ginxlog.c | 2 +-
src/backend/utils/adt/multirangetypes.c | 2 +-
4 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/contrib/bloom/blutils.c b/contrib/bloom/blutils.c
index 2c0e71eedc6..bf50037a71a 100644
--- a/contrib/bloom/blutils.c
+++ b/contrib/bloom/blutils.c
@@ -336,7 +336,7 @@ BloomPageAddItem(BloomState *state, Page page, BloomTuple *tuple)
/* Copy new tuple to the end of page */
opaque = BloomPageGetOpaque(page);
itup = BloomPageGetTuple(state, page, opaque->maxoff + 1);
- memcpy((Pointer) itup, (Pointer) tuple, state->sizeOfBloomTuple);
+ memcpy(itup, tuple, state->sizeOfBloomTuple);
/* Adjust maxoff and pd_lower */
opaque->maxoff++;
diff --git a/contrib/bloom/blvacuum.c b/contrib/bloom/blvacuum.c
index 9e5f0574fad..044fd85a32a 100644
--- a/contrib/bloom/blvacuum.c
+++ b/contrib/bloom/blvacuum.c
@@ -94,7 +94,7 @@ blbulkdelete(IndexVacuumInfo *info, IndexBulkDeleteResult *stats,
{
/* No; copy it to itupPtr++, but skip copy if not needed */
if (itupPtr != itup)
- memmove((Pointer) itupPtr, (Pointer) itup,
+ memmove(itupPtr, itup,
state.sizeOfBloomTuple);
itupPtr = BloomPageGetNextTuple(&state, itupPtr);
}
diff --git a/src/backend/access/gin/ginxlog.c b/src/backend/access/gin/ginxlog.c
index 75df3d7a680..606741fa396 100644
--- a/src/backend/access/gin/ginxlog.c
+++ b/src/backend/access/gin/ginxlog.c
@@ -212,7 +212,7 @@ ginRedoRecompress(Page page, ginxlogRecompressDataLeaf *data)
if (tailCopy)
{
Assert(writePtr + segsize < PageGetSpecialPointer(page));
- memcpy(writePtr, (Pointer) oldseg, segsize);
+ memcpy(writePtr, oldseg, segsize);
}
writePtr += segsize;
oldseg = GinNextPostingListSegment(oldseg);
diff --git a/src/backend/utils/adt/multirangetypes.c b/src/backend/utils/adt/multirangetypes.c
index 5273b97f7fe..55e0b4fdc31 100644
--- a/src/backend/utils/adt/multirangetypes.c
+++ b/src/backend/utils/adt/multirangetypes.c
@@ -629,7 +629,7 @@ write_multirange_data(MultirangeType *multirange, TypeCacheEntry *rangetyp,
}
flags[i] = *((Pointer) ranges[i] + VARSIZE(ranges[i]) - sizeof(char));
len = VARSIZE(ranges[i]) - sizeof(RangeType) - sizeof(char);
- memcpy(ptr, (Pointer) (ranges[i] + 1), len);
+ memcpy(ptr, ranges[i] + 1, len);
ptr += att_align_nominal(len, elemalign);
}
}
--
2.52.0
[text/plain] 0002-Use-better-DatumGet-function.patch (1.2K, ../../[email protected]/3-0002-Use-better-DatumGet-function.patch)
download | inline diff:
From b58263c3df6dc2eb918bde92eb04f7fd5d2a061b Mon Sep 17 00:00:00 2001
From: Peter Eisentraut <[email protected]>
Date: Mon, 24 Nov 2025 11:02:35 +0100
Subject: [PATCH 2/6] Use better DatumGet* function
Use DatumGetCString() instead of DatumGetPointer() for returning a C
string. Right now, they are the same, but that doesn't always have to
be so.
---
src/test/modules/test_resowner/test_resowner_basic.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/test/modules/test_resowner/test_resowner_basic.c b/src/test/modules/test_resowner/test_resowner_basic.c
index 8f794996371..b84ec2cb299 100644
--- a/src/test/modules/test_resowner/test_resowner_basic.c
+++ b/src/test/modules/test_resowner/test_resowner_basic.c
@@ -35,13 +35,13 @@ static const ResourceOwnerDesc string_desc = {
static void
ReleaseString(Datum res)
{
- elog(NOTICE, "releasing string: %s", DatumGetPointer(res));
+ elog(NOTICE, "releasing string: %s", DatumGetCString(res));
}
static char *
PrintString(Datum res)
{
- return psprintf("test string \"%s\"", DatumGetPointer(res));
+ return psprintf("test string \"%s\"", DatumGetCString(res));
}
/* demonstrates phases and priorities between a parent and child context */
--
2.52.0
[text/plain] 0003-Don-t-rely-on-pointer-arithmetic-with-Pointer-type.patch (14.2K, ../../[email protected]/4-0003-Don-t-rely-on-pointer-arithmetic-with-Pointer-type.patch)
download | inline diff:
From 08e6993de9f0ab2b75f023789905770b08b0f03b Mon Sep 17 00:00:00 2001
From: Peter Eisentraut <[email protected]>
Date: Mon, 24 Nov 2025 11:02:35 +0100
Subject: [PATCH 3/6] Don't rely on pointer arithmetic with Pointer type
Use char * explicitly where this is needed.
---
contrib/bloom/bloom.h | 2 +-
contrib/bloom/blutils.c | 4 +--
contrib/bloom/blvacuum.c | 2 +-
src/backend/access/gin/gindatapage.c | 18 ++++++-------
src/backend/access/gin/ginxlog.c | 20 +++++++-------
src/backend/access/rmgrdesc/genericdesc.c | 4 +--
src/backend/utils/adt/multirangetypes.c | 32 +++++++++++------------
src/backend/utils/adt/rangetypes.c | 16 ++++++------
8 files changed, 49 insertions(+), 49 deletions(-)
diff --git a/contrib/bloom/bloom.h b/contrib/bloom/bloom.h
index 648167045f4..b2966d37077 100644
--- a/contrib/bloom/bloom.h
+++ b/contrib/bloom/bloom.h
@@ -72,7 +72,7 @@ typedef BloomPageOpaqueData *BloomPageOpaque;
((BloomTuple *)(PageGetContents(page) \
+ (state)->sizeOfBloomTuple * ((offset) - 1)))
#define BloomPageGetNextTuple(state, tuple) \
- ((BloomTuple *)((Pointer)(tuple) + (state)->sizeOfBloomTuple))
+ ((BloomTuple *)((char *)(tuple) + (state)->sizeOfBloomTuple))
/* Preserved page numbers */
#define BLOOM_METAPAGE_BLKNO (0)
diff --git a/contrib/bloom/blutils.c b/contrib/bloom/blutils.c
index bf50037a71a..bbeefc3a75b 100644
--- a/contrib/bloom/blutils.c
+++ b/contrib/bloom/blutils.c
@@ -324,7 +324,7 @@ BloomPageAddItem(BloomState *state, Page page, BloomTuple *tuple)
{
BloomTuple *itup;
BloomPageOpaque opaque;
- Pointer ptr;
+ char *ptr;
/* We shouldn't be pointed to an invalid page */
Assert(!PageIsNew(page) && !BloomPageIsDeleted(page));
@@ -340,7 +340,7 @@ BloomPageAddItem(BloomState *state, Page page, BloomTuple *tuple)
/* Adjust maxoff and pd_lower */
opaque->maxoff++;
- ptr = (Pointer) BloomPageGetTuple(state, page, opaque->maxoff + 1);
+ ptr = (char *) BloomPageGetTuple(state, page, opaque->maxoff + 1);
((PageHeader) page)->pd_lower = ptr - page;
/* Assert we didn't overrun available space */
diff --git a/contrib/bloom/blvacuum.c b/contrib/bloom/blvacuum.c
index 044fd85a32a..cc0639a3ac4 100644
--- a/contrib/bloom/blvacuum.c
+++ b/contrib/bloom/blvacuum.c
@@ -122,7 +122,7 @@ blbulkdelete(IndexVacuumInfo *info, IndexBulkDeleteResult *stats,
if (BloomPageGetMaxOffset(page) == 0)
BloomPageSetDeleted(page);
/* Adjust pd_lower */
- ((PageHeader) page)->pd_lower = (Pointer) itupPtr - page;
+ ((PageHeader) page)->pd_lower = (char *) itupPtr - page;
/* Finish WAL-logging */
GenericXLogFinish(gxlogState);
}
diff --git a/src/backend/access/gin/gindatapage.c b/src/backend/access/gin/gindatapage.c
index 6c2c6194720..e677bdb2dcb 100644
--- a/src/backend/access/gin/gindatapage.c
+++ b/src/backend/access/gin/gindatapage.c
@@ -140,20 +140,20 @@ GinDataLeafPageGetItems(Page page, int *nitems, ItemPointerData advancePast)
{
GinPostingList *seg = GinDataLeafPageGetPostingList(page);
Size len = GinDataLeafPageGetPostingListSize(page);
- Pointer endptr = ((Pointer) seg) + len;
+ char *endptr = ((char *) seg) + len;
GinPostingList *next;
/* Skip to the segment containing advancePast+1 */
if (ItemPointerIsValid(&advancePast))
{
next = GinNextPostingListSegment(seg);
- while ((Pointer) next < endptr &&
+ while ((char *) next < endptr &&
ginCompareItemPointers(&next->first, &advancePast) <= 0)
{
seg = next;
next = GinNextPostingListSegment(seg);
}
- len = endptr - (Pointer) seg;
+ len = endptr - (char *) seg;
}
if (len > 0)
@@ -1371,8 +1371,8 @@ disassembleLeaf(Page page)
{
disassembledLeaf *leaf;
GinPostingList *seg;
- Pointer segbegin;
- Pointer segend;
+ char *segbegin;
+ char *segend;
leaf = palloc0(sizeof(disassembledLeaf));
dlist_init(&leaf->segments);
@@ -1383,9 +1383,9 @@ disassembleLeaf(Page page)
* Create a leafSegmentInfo entry for each segment.
*/
seg = GinDataLeafPageGetPostingList(page);
- segbegin = (Pointer) seg;
+ segbegin = (char *) seg;
segend = segbegin + GinDataLeafPageGetPostingListSize(page);
- while ((Pointer) seg < segend)
+ while ((char *) seg < segend)
{
leafSegmentInfo *seginfo = palloc(sizeof(leafSegmentInfo));
@@ -1779,7 +1779,7 @@ createPostingTree(Relation index, ItemPointerData *items, uint32 nitems,
Buffer buffer;
Page tmppage;
Page page;
- Pointer ptr;
+ char *ptr;
int nrootitems;
int rootsize;
bool is_build = (buildStats != NULL);
@@ -1795,7 +1795,7 @@ createPostingTree(Relation index, ItemPointerData *items, uint32 nitems,
*/
nrootitems = 0;
rootsize = 0;
- ptr = (Pointer) GinDataLeafPageGetPostingList(tmppage);
+ ptr = (char *) GinDataLeafPageGetPostingList(tmppage);
while (nrootitems < nitems)
{
GinPostingList *segment;
diff --git a/src/backend/access/gin/ginxlog.c b/src/backend/access/gin/ginxlog.c
index 606741fa396..34c01a01165 100644
--- a/src/backend/access/gin/ginxlog.c
+++ b/src/backend/access/gin/ginxlog.c
@@ -119,12 +119,12 @@ ginRedoRecompress(Page page, ginxlogRecompressDataLeaf *data)
int actionno;
int segno;
GinPostingList *oldseg;
- Pointer segmentend;
+ char *segmentend;
char *walbuf;
int totalsize;
- Pointer tailCopy = NULL;
- Pointer writePtr;
- Pointer segptr;
+ void *tailCopy = NULL;
+ char *writePtr;
+ char *segptr;
/*
* If the page is in pre-9.4 format, convert to new format first.
@@ -164,8 +164,8 @@ ginRedoRecompress(Page page, ginxlogRecompressDataLeaf *data)
}
oldseg = GinDataLeafPageGetPostingList(page);
- writePtr = (Pointer) oldseg;
- segmentend = (Pointer) oldseg + GinDataLeafPageGetPostingListSize(page);
+ writePtr = (char *) oldseg;
+ segmentend = (char *) oldseg + GinDataLeafPageGetPostingListSize(page);
segno = 0;
walbuf = ((char *) data) + sizeof(ginxlogRecompressDataLeaf);
@@ -243,7 +243,7 @@ ginRedoRecompress(Page page, ginxlogRecompressDataLeaf *data)
a_action = GIN_SEGMENT_REPLACE;
}
- segptr = (Pointer) oldseg;
+ segptr = (char *) oldseg;
if (segptr != segmentend)
segsize = SizeOfGinPostingList(oldseg);
else
@@ -264,7 +264,7 @@ ginRedoRecompress(Page page, ginxlogRecompressDataLeaf *data)
{
int tailSize = segmentend - segptr;
- tailCopy = (Pointer) palloc(tailSize);
+ tailCopy = palloc(tailSize);
memcpy(tailCopy, segptr, tailSize);
segptr = tailCopy;
oldseg = (GinPostingList *) segptr;
@@ -301,7 +301,7 @@ ginRedoRecompress(Page page, ginxlogRecompressDataLeaf *data)
}
/* Copy the rest of unmodified segments if any. */
- segptr = (Pointer) oldseg;
+ segptr = (char *) oldseg;
if (segptr != segmentend && tailCopy)
{
int restSize = segmentend - segptr;
@@ -311,7 +311,7 @@ ginRedoRecompress(Page page, ginxlogRecompressDataLeaf *data)
writePtr += restSize;
}
- totalsize = writePtr - (Pointer) GinDataLeafPageGetPostingList(page);
+ totalsize = writePtr - (char *) GinDataLeafPageGetPostingList(page);
GinDataPageSetDataSize(page, totalsize);
}
diff --git a/src/backend/access/rmgrdesc/genericdesc.c b/src/backend/access/rmgrdesc/genericdesc.c
index 75dc4108b9a..29a4c9e894b 100644
--- a/src/backend/access/rmgrdesc/genericdesc.c
+++ b/src/backend/access/rmgrdesc/genericdesc.c
@@ -23,8 +23,8 @@
void
generic_desc(StringInfo buf, XLogReaderState *record)
{
- Pointer ptr = XLogRecGetData(record),
- end = ptr + XLogRecGetDataLen(record);
+ const char *ptr = XLogRecGetData(record);
+ const char *end = ptr + XLogRecGetDataLen(record);
while (ptr < end)
{
diff --git a/src/backend/utils/adt/multirangetypes.c b/src/backend/utils/adt/multirangetypes.c
index 55e0b4fdc31..e259644c6ca 100644
--- a/src/backend/utils/adt/multirangetypes.c
+++ b/src/backend/utils/adt/multirangetypes.c
@@ -68,11 +68,11 @@ typedef enum
* Macros for accessing past MultirangeType parts of multirange: items, flags
* and boundaries.
*/
-#define MultirangeGetItemsPtr(mr) ((uint32 *) ((Pointer) (mr) + \
+#define MultirangeGetItemsPtr(mr) ((uint32 *) ((char *) (mr) + \
sizeof(MultirangeType)))
-#define MultirangeGetFlagsPtr(mr) ((uint8 *) ((Pointer) (mr) + \
+#define MultirangeGetFlagsPtr(mr) ((uint8 *) ((char *) (mr) + \
sizeof(MultirangeType) + ((mr)->rangeCount - 1) * sizeof(uint32)))
-#define MultirangeGetBoundariesPtr(mr, align) ((Pointer) (mr) + \
+#define MultirangeGetBoundariesPtr(mr, align) ((char *) (mr) + \
att_align_nominal(sizeof(MultirangeType) + \
((mr)->rangeCount - 1) * sizeof(uint32) + \
(mr)->rangeCount * sizeof(uint8), (align)))
@@ -602,13 +602,13 @@ write_multirange_data(MultirangeType *multirange, TypeCacheEntry *rangetyp,
uint32 prev_offset = 0;
uint8 *flags;
int32 i;
- Pointer begin,
- ptr;
+ const char *begin;
+ char *ptr;
char elemalign = rangetyp->rngelemtype->typalign;
items = MultirangeGetItemsPtr(multirange);
flags = MultirangeGetFlagsPtr(multirange);
- ptr = begin = MultirangeGetBoundariesPtr(multirange, elemalign);
+ begin = ptr = MultirangeGetBoundariesPtr(multirange, elemalign);
for (i = 0; i < range_count; i++)
{
uint32 len;
@@ -627,7 +627,7 @@ write_multirange_data(MultirangeType *multirange, TypeCacheEntry *rangetyp,
items[i - 1] |= MULTIRANGE_ITEM_OFF_BIT;
prev_offset = ptr - begin;
}
- flags[i] = *((Pointer) ranges[i] + VARSIZE(ranges[i]) - sizeof(char));
+ flags[i] = *((char *) ranges[i] + VARSIZE(ranges[i]) - sizeof(char));
len = VARSIZE(ranges[i]) - sizeof(RangeType) - sizeof(char);
memcpy(ptr, ranges[i] + 1, len);
ptr += att_align_nominal(len, elemalign);
@@ -699,8 +699,8 @@ multirange_get_range(TypeCacheEntry *rangetyp,
{
uint32 offset;
uint8 flags;
- Pointer begin,
- ptr;
+ const char *begin;
+ char *ptr;
int16 typlen = rangetyp->rngelemtype->typlen;
char typalign = rangetyp->rngelemtype->typalign;
uint32 len;
@@ -710,7 +710,7 @@ multirange_get_range(TypeCacheEntry *rangetyp,
offset = multirange_get_bounds_offset(multirange, i);
flags = MultirangeGetFlagsPtr(multirange)[i];
- ptr = begin = MultirangeGetBoundariesPtr(multirange, typalign) + offset;
+ begin = ptr = MultirangeGetBoundariesPtr(multirange, typalign) + offset;
/*
* Calculate the size of bound values. In principle, we could get offset
@@ -719,11 +719,11 @@ multirange_get_range(TypeCacheEntry *rangetyp,
* exact size.
*/
if (RANGE_HAS_LBOUND(flags))
- ptr = (Pointer) att_addlength_pointer(ptr, typlen, ptr);
+ ptr = (char *) att_addlength_pointer(ptr, typlen, ptr);
if (RANGE_HAS_UBOUND(flags))
{
- ptr = (Pointer) att_align_pointer(ptr, typalign, typlen, ptr);
- ptr = (Pointer) att_addlength_pointer(ptr, typlen, ptr);
+ ptr = (char *) att_align_pointer(ptr, typalign, typlen, ptr);
+ ptr = (char *) att_addlength_pointer(ptr, typlen, ptr);
}
len = (ptr - begin) + sizeof(RangeType) + sizeof(uint8);
@@ -749,7 +749,7 @@ multirange_get_bounds(TypeCacheEntry *rangetyp,
{
uint32 offset;
uint8 flags;
- Pointer ptr;
+ const char *ptr;
int16 typlen = rangetyp->rngelemtype->typlen;
char typalign = rangetyp->rngelemtype->typalign;
bool typbyval = rangetyp->rngelemtype->typbyval;
@@ -770,7 +770,7 @@ multirange_get_bounds(TypeCacheEntry *rangetyp,
{
/* att_align_pointer cannot be necessary here */
lbound = fetch_att(ptr, typbyval, typlen);
- ptr = (Pointer) att_addlength_pointer(ptr, typlen, ptr);
+ ptr = (char *) att_addlength_pointer(ptr, typlen, ptr);
}
else
lbound = (Datum) 0;
@@ -778,7 +778,7 @@ multirange_get_bounds(TypeCacheEntry *rangetyp,
/* fetch upper bound, if any */
if (RANGE_HAS_UBOUND(flags))
{
- ptr = (Pointer) att_align_pointer(ptr, typalign, typlen, ptr);
+ ptr = (char *) att_align_pointer(ptr, typalign, typlen, ptr);
ubound = fetch_att(ptr, typbyval, typlen);
/* no need for att_addlength_pointer */
}
diff --git a/src/backend/utils/adt/rangetypes.c b/src/backend/utils/adt/rangetypes.c
index 065a8000cf2..b7e9f6dc0a8 100644
--- a/src/backend/utils/adt/rangetypes.c
+++ b/src/backend/utils/adt/rangetypes.c
@@ -72,8 +72,8 @@ static char *range_deparse(char flags, const char *lbound_str,
static char *range_bound_escape(const char *value);
static Size datum_compute_size(Size data_length, Datum val, bool typbyval,
char typalign, int16 typlen, char typstorage);
-static Pointer datum_write(Pointer ptr, Datum datum, bool typbyval,
- char typalign, int16 typlen, char typstorage);
+static char *datum_write(char *ptr, Datum datum, bool typbyval,
+ char typalign, int16 typlen, char typstorage);
static Node *find_simplified_clause(PlannerInfo *root,
Expr *rangeExpr, Expr *elemExpr);
static Expr *build_bound_expr(Expr *elemExpr, Datum val,
@@ -2092,7 +2092,7 @@ range_deserialize(TypeCacheEntry *typcache, const RangeType *range,
int16 typlen;
bool typbyval;
char typalign;
- Pointer ptr;
+ const char *ptr;
Datum lbound;
Datum ubound;
@@ -2108,14 +2108,14 @@ range_deserialize(TypeCacheEntry *typcache, const RangeType *range,
typalign = typcache->rngelemtype->typalign;
/* initialize data pointer just after the range OID */
- ptr = (Pointer) (range + 1);
+ ptr = (char *) (range + 1);
/* fetch lower bound, if any */
if (RANGE_HAS_LBOUND(flags))
{
/* att_align_pointer cannot be necessary here */
lbound = fetch_att(ptr, typbyval, typlen);
- ptr = (Pointer) att_addlength_pointer(ptr, typlen, ptr);
+ ptr = (char *) att_addlength_pointer(ptr, typlen, ptr);
}
else
lbound = (Datum) 0;
@@ -2123,7 +2123,7 @@ range_deserialize(TypeCacheEntry *typcache, const RangeType *range,
/* fetch upper bound, if any */
if (RANGE_HAS_UBOUND(flags))
{
- ptr = (Pointer) att_align_pointer(ptr, typalign, typlen, ptr);
+ ptr = (char *) att_align_pointer(ptr, typalign, typlen, ptr);
ubound = fetch_att(ptr, typbyval, typlen);
/* no need for att_addlength_pointer */
}
@@ -2937,8 +2937,8 @@ datum_compute_size(Size data_length, Datum val, bool typbyval, char typalign,
* Write the given datum beginning at ptr (after advancing to correct
* alignment, if needed). Return the pointer incremented by space used.
*/
-static Pointer
-datum_write(Pointer ptr, Datum datum, bool typbyval, char typalign,
+static char *
+datum_write(char *ptr, Datum datum, bool typbyval, char typalign,
int16 typlen, char typstorage)
{
Size data_length;
--
2.52.0
[text/plain] 0004-Change-Pointer-to-void.patch (834B, ../../[email protected]/5-0004-Change-Pointer-to-void.patch)
download | inline diff:
From 75027ac5cbe10abc785049c7bcfddc526d5cea54 Mon Sep 17 00:00:00 2001
From: Peter Eisentraut <[email protected]>
Date: Mon, 24 Nov 2025 11:02:35 +0100
Subject: [PATCH 4/6] Change Pointer to void *
---
src/include/c.h | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/src/include/c.h b/src/include/c.h
index 729eb8a27de..fd9a89fe5f7 100644
--- a/src/include/c.h
+++ b/src/include/c.h
@@ -527,11 +527,9 @@ typedef void (*pg_funcptr_t) (void);
/*
* Pointer
* Variable holding address of any memory resident object.
- *
- * XXX Pointer arithmetic is done with this, so it can't be void *
- * under "true" ANSI compilers.
+ * (obsolescent; use void * or char *)
*/
-typedef char *Pointer;
+typedef void *Pointer;
/* Historical names for types in <stdint.h>. */
typedef int8_t int8;
--
2.52.0
[text/plain] 0005-Remove-no-longer-needed-casts-to-Pointer.patch (12.9K, ../../[email protected]/6-0005-Remove-no-longer-needed-casts-to-Pointer.patch)
download | inline diff:
From 573406a6f5deed046a88eae62becc0bae7b4b24a Mon Sep 17 00:00:00 2001
From: Peter Eisentraut <[email protected]>
Date: Mon, 24 Nov 2025 11:02:35 +0100
Subject: [PATCH 5/6] Remove no longer needed casts to (Pointer)
---
contrib/btree_gist/btree_utils_var.h | 2 +-
src/backend/access/heap/heaptoast.c | 4 ++--
src/backend/catalog/aclchk.c | 18 +++++++++---------
src/backend/catalog/pg_constraint.c | 12 ++++++------
src/backend/utils/adt/arrayfuncs.c | 2 +-
src/backend/utils/adt/datum.c | 6 +++---
src/backend/utils/adt/like_support.c | 4 ++--
src/backend/utils/adt/numeric.c | 6 +++---
src/backend/utils/adt/rangetypes.c | 4 ++--
src/backend/utils/adt/rowtypes.c | 4 ++--
src/backend/utils/cache/evtcache.c | 2 +-
src/include/fmgr.h | 2 +-
12 files changed, 33 insertions(+), 33 deletions(-)
diff --git a/contrib/btree_gist/btree_utils_var.h b/contrib/btree_gist/btree_utils_var.h
index 75ad33d24fc..6cb3aadf3c3 100644
--- a/contrib/btree_gist/btree_utils_var.h
+++ b/contrib/btree_gist/btree_utils_var.h
@@ -49,7 +49,7 @@ typedef struct
*/
#define GBT_FREE_IF_COPY(ptr1, ptr2) \
do { \
- if ((Pointer) (ptr1) != DatumGetPointer(ptr2)) \
+ if ((ptr1) != DatumGetPointer(ptr2)) \
pfree(ptr1); \
} while (0)
diff --git a/src/backend/access/heap/heaptoast.c b/src/backend/access/heap/heaptoast.c
index e148c9be482..60e765fbfce 100644
--- a/src/backend/access/heap/heaptoast.c
+++ b/src/backend/access/heap/heaptoast.c
@@ -569,7 +569,7 @@ toast_build_flattened_tuple(TupleDesc tupleDesc,
int num_to_free;
int i;
Datum new_values[MaxTupleAttributeNumber];
- Pointer freeable_values[MaxTupleAttributeNumber];
+ void *freeable_values[MaxTupleAttributeNumber];
/*
* We can pass the caller's isnull array directly to heap_form_tuple, but
@@ -593,7 +593,7 @@ toast_build_flattened_tuple(TupleDesc tupleDesc,
{
new_value = detoast_external_attr(new_value);
new_values[i] = PointerGetDatum(new_value);
- freeable_values[num_to_free++] = (Pointer) new_value;
+ freeable_values[num_to_free++] = new_value;
}
}
}
diff --git a/src/backend/catalog/aclchk.c b/src/backend/catalog/aclchk.c
index cd139bd65a6..58d006986b8 100644
--- a/src/backend/catalog/aclchk.c
+++ b/src/backend/catalog/aclchk.c
@@ -3125,7 +3125,7 @@ object_aclmask_ext(Oid classid, Oid objectid, Oid roleid,
result = aclmask(acl, roleid, ownerId, mask, how);
/* if we have a detoasted copy, free it */
- if (acl && (Pointer) acl != DatumGetPointer(aclDatum))
+ if (acl && acl != DatumGetPointer(aclDatum))
pfree(acl);
ReleaseSysCache(tuple);
@@ -3255,7 +3255,7 @@ pg_attribute_aclmask_ext(Oid table_oid, AttrNumber attnum, Oid roleid,
result = aclmask(acl, roleid, ownerId, mask, how);
/* if we have a detoasted copy, free it */
- if (acl && (Pointer) acl != DatumGetPointer(aclDatum))
+ if (acl && acl != DatumGetPointer(aclDatum))
pfree(acl);
ReleaseSysCache(attTuple);
@@ -3362,7 +3362,7 @@ pg_class_aclmask_ext(Oid table_oid, Oid roleid, AclMode mask,
result = aclmask(acl, roleid, ownerId, mask, how);
/* if we have a detoasted copy, free it */
- if (acl && (Pointer) acl != DatumGetPointer(aclDatum))
+ if (acl && acl != DatumGetPointer(aclDatum))
pfree(acl);
ReleaseSysCache(tuple);
@@ -3454,7 +3454,7 @@ pg_parameter_aclmask(const char *name, Oid roleid, AclMode mask, AclMaskHow how)
result = aclmask(acl, roleid, BOOTSTRAP_SUPERUSERID, mask, how);
/* if we have a detoasted copy, free it */
- if (acl && (Pointer) acl != DatumGetPointer(aclDatum))
+ if (acl && acl != DatumGetPointer(aclDatum))
pfree(acl);
ReleaseSysCache(tuple);
@@ -3509,7 +3509,7 @@ pg_parameter_acl_aclmask(Oid acl_oid, Oid roleid, AclMode mask, AclMaskHow how)
result = aclmask(acl, roleid, BOOTSTRAP_SUPERUSERID, mask, how);
/* if we have a detoasted copy, free it */
- if (acl && (Pointer) acl != DatumGetPointer(aclDatum))
+ if (acl && acl != DatumGetPointer(aclDatum))
pfree(acl);
ReleaseSysCache(tuple);
@@ -3589,7 +3589,7 @@ pg_largeobject_aclmask_snapshot(Oid lobj_oid, Oid roleid,
result = aclmask(acl, roleid, ownerId, mask, how);
/* if we have a detoasted copy, free it */
- if (acl && (Pointer) acl != DatumGetPointer(aclDatum))
+ if (acl && acl != DatumGetPointer(aclDatum))
pfree(acl);
systable_endscan(scan);
@@ -3683,7 +3683,7 @@ pg_namespace_aclmask_ext(Oid nsp_oid, Oid roleid,
result = aclmask(acl, roleid, ownerId, mask, how);
/* if we have a detoasted copy, free it */
- if (acl && (Pointer) acl != DatumGetPointer(aclDatum))
+ if (acl && acl != DatumGetPointer(aclDatum))
pfree(acl);
ReleaseSysCache(tuple);
@@ -3819,7 +3819,7 @@ pg_type_aclmask_ext(Oid type_oid, Oid roleid, AclMode mask, AclMaskHow how,
result = aclmask(acl, roleid, ownerId, mask, how);
/* if we have a detoasted copy, free it */
- if (acl && (Pointer) acl != DatumGetPointer(aclDatum))
+ if (acl && acl != DatumGetPointer(aclDatum))
pfree(acl);
ReleaseSysCache(tuple);
@@ -4003,7 +4003,7 @@ pg_attribute_aclcheck_all_ext(Oid table_oid, Oid roleid,
attmask = aclmask(acl, roleid, ownerId, mode, ACLMASK_ANY);
/* if we have a detoasted copy, free it */
- if ((Pointer) acl != DatumGetPointer(aclDatum))
+ if (acl != DatumGetPointer(aclDatum))
pfree(acl);
}
diff --git a/src/backend/catalog/pg_constraint.c b/src/backend/catalog/pg_constraint.c
index 9944e4bd2d1..5b2a8132306 100644
--- a/src/backend/catalog/pg_constraint.c
+++ b/src/backend/catalog/pg_constraint.c
@@ -1544,7 +1544,7 @@ DeconstructFkConstraintRow(HeapTuple tuple, int *numfks,
if (numkeys <= 0 || numkeys > INDEX_MAX_KEYS)
elog(ERROR, "foreign key constraint cannot have %d columns", numkeys);
memcpy(conkey, ARR_DATA_PTR(arr), numkeys * sizeof(int16));
- if ((Pointer) arr != DatumGetPointer(adatum))
+ if (arr != DatumGetPointer(adatum))
pfree(arr); /* free de-toasted copy, if any */
adatum = SysCacheGetAttrNotNull(CONSTROID, tuple,
@@ -1556,7 +1556,7 @@ DeconstructFkConstraintRow(HeapTuple tuple, int *numfks,
ARR_ELEMTYPE(arr) != INT2OID)
elog(ERROR, "confkey is not a 1-D smallint array");
memcpy(confkey, ARR_DATA_PTR(arr), numkeys * sizeof(int16));
- if ((Pointer) arr != DatumGetPointer(adatum))
+ if (arr != DatumGetPointer(adatum))
pfree(arr); /* free de-toasted copy, if any */
if (pf_eq_oprs)
@@ -1571,7 +1571,7 @@ DeconstructFkConstraintRow(HeapTuple tuple, int *numfks,
ARR_ELEMTYPE(arr) != OIDOID)
elog(ERROR, "conpfeqop is not a 1-D Oid array");
memcpy(pf_eq_oprs, ARR_DATA_PTR(arr), numkeys * sizeof(Oid));
- if ((Pointer) arr != DatumGetPointer(adatum))
+ if (arr != DatumGetPointer(adatum))
pfree(arr); /* free de-toasted copy, if any */
}
@@ -1586,7 +1586,7 @@ DeconstructFkConstraintRow(HeapTuple tuple, int *numfks,
ARR_ELEMTYPE(arr) != OIDOID)
elog(ERROR, "conppeqop is not a 1-D Oid array");
memcpy(pp_eq_oprs, ARR_DATA_PTR(arr), numkeys * sizeof(Oid));
- if ((Pointer) arr != DatumGetPointer(adatum))
+ if (arr != DatumGetPointer(adatum))
pfree(arr); /* free de-toasted copy, if any */
}
@@ -1601,7 +1601,7 @@ DeconstructFkConstraintRow(HeapTuple tuple, int *numfks,
ARR_ELEMTYPE(arr) != OIDOID)
elog(ERROR, "conffeqop is not a 1-D Oid array");
memcpy(ff_eq_oprs, ARR_DATA_PTR(arr), numkeys * sizeof(Oid));
- if ((Pointer) arr != DatumGetPointer(adatum))
+ if (arr != DatumGetPointer(adatum))
pfree(arr); /* free de-toasted copy, if any */
}
@@ -1624,7 +1624,7 @@ DeconstructFkConstraintRow(HeapTuple tuple, int *numfks,
elog(ERROR, "confdelsetcols is not a 1-D smallint array");
num_delete_cols = ARR_DIMS(arr)[0];
memcpy(fk_del_set_cols, ARR_DATA_PTR(arr), num_delete_cols * sizeof(int16));
- if ((Pointer) arr != DatumGetPointer(adatum))
+ if (arr != DatumGetPointer(adatum))
pfree(arr); /* free de-toasted copy, if any */
*num_fk_del_set_cols = num_delete_cols;
diff --git a/src/backend/utils/adt/arrayfuncs.c b/src/backend/utils/adt/arrayfuncs.c
index a464349ee33..6dc65d3d4cb 100644
--- a/src/backend/utils/adt/arrayfuncs.c
+++ b/src/backend/utils/adt/arrayfuncs.c
@@ -5687,7 +5687,7 @@ accumArrayResultArr(ArrayBuildStateArr *astate,
MemoryContextSwitchTo(oldcontext);
/* Release detoasted copy if any */
- if ((Pointer) arg != DatumGetPointer(dvalue))
+ if (arg != DatumGetPointer(dvalue))
pfree(arg);
return astate;
diff --git a/src/backend/utils/adt/datum.c b/src/backend/utils/adt/datum.c
index c2b111b829e..dabcca6f4c5 100644
--- a/src/backend/utils/adt/datum.c
+++ b/src/backend/utils/adt/datum.c
@@ -299,9 +299,9 @@ datum_image_eq(Datum value1, Datum value2, bool typByVal, int typLen)
len1 - VARHDRSZ) == 0);
/* Only free memory if it's a copy made here. */
- if ((Pointer) arg1val != DatumGetPointer(value1))
+ if (arg1val != DatumGetPointer(value1))
pfree(arg1val);
- if ((Pointer) arg2val != DatumGetPointer(value2))
+ if (arg2val != DatumGetPointer(value2))
pfree(arg2val);
}
}
@@ -355,7 +355,7 @@ datum_image_hash(Datum value, bool typByVal, int typLen)
result = hash_bytes((unsigned char *) VARDATA_ANY(val), len - VARHDRSZ);
/* Only free memory if it's a copy made here. */
- if ((Pointer) val != DatumGetPointer(value))
+ if (val != DatumGetPointer(value))
pfree(val);
}
else if (typLen == -2)
diff --git a/src/backend/utils/adt/like_support.c b/src/backend/utils/adt/like_support.c
index 999f23f86d5..dca1d9be035 100644
--- a/src/backend/utils/adt/like_support.c
+++ b/src/backend/utils/adt/like_support.c
@@ -1035,7 +1035,7 @@ like_fixed_prefix(Const *patt_const, bool case_insensitive, Oid collation,
pattlen = VARSIZE_ANY_EXHDR(bstr);
patt = (char *) palloc(pattlen);
memcpy(patt, VARDATA_ANY(bstr), pattlen);
- Assert((Pointer) bstr == DatumGetPointer(patt_const->constvalue));
+ Assert(bstr == DatumGetPointer(patt_const->constvalue));
}
match = palloc(pattlen + 1);
@@ -1577,7 +1577,7 @@ make_greater_string(const Const *str_const, FmgrInfo *ltproc, Oid collation)
len = VARSIZE_ANY_EXHDR(bstr);
workstr = (char *) palloc(len);
memcpy(workstr, VARDATA_ANY(bstr), len);
- Assert((Pointer) bstr == DatumGetPointer(str_const->constvalue));
+ Assert(bstr == DatumGetPointer(str_const->constvalue));
cmpstr = str_const->constvalue;
}
else
diff --git a/src/backend/utils/adt/numeric.c b/src/backend/utils/adt/numeric.c
index 2501007d981..1d626aecbe7 100644
--- a/src/backend/utils/adt/numeric.c
+++ b/src/backend/utils/adt/numeric.c
@@ -2194,7 +2194,7 @@ numeric_abbrev_convert(Datum original_datum, SortSupport ssup)
}
/* should happen only for external/compressed toasts */
- if ((Pointer) original_varatt != DatumGetPointer(original_datum))
+ if (original_varatt != DatumGetPointer(original_datum))
pfree(original_varatt);
return result;
@@ -2284,9 +2284,9 @@ numeric_fast_cmp(Datum x, Datum y, SortSupport ssup)
result = cmp_numerics(nx, ny);
- if ((Pointer) nx != DatumGetPointer(x))
+ if (nx != DatumGetPointer(x))
pfree(nx);
- if ((Pointer) ny != DatumGetPointer(y))
+ if (ny != DatumGetPointer(y))
pfree(ny);
return result;
diff --git a/src/backend/utils/adt/rangetypes.c b/src/backend/utils/adt/rangetypes.c
index b7e9f6dc0a8..d8e5130d642 100644
--- a/src/backend/utils/adt/rangetypes.c
+++ b/src/backend/utils/adt/rangetypes.c
@@ -1513,9 +1513,9 @@ range_fast_cmp(Datum a, Datum b, SortSupport ssup)
cmp = range_cmp_bounds(typcache, &upper1, &upper2);
}
- if ((Pointer) range_a != DatumGetPointer(a))
+ if (range_a != DatumGetPointer(a))
pfree(range_a);
- if ((Pointer) range_b != DatumGetPointer(b))
+ if (range_b != DatumGetPointer(b))
pfree(range_b);
return cmp;
diff --git a/src/backend/utils/adt/rowtypes.c b/src/backend/utils/adt/rowtypes.c
index 9e5449f17d7..38e6fe1c43a 100644
--- a/src/backend/utils/adt/rowtypes.c
+++ b/src/backend/utils/adt/rowtypes.c
@@ -1529,9 +1529,9 @@ record_image_cmp(FunctionCallInfo fcinfo)
if ((cmpresult == 0) && (len1 != len2))
cmpresult = (len1 < len2) ? -1 : 1;
- if ((Pointer) arg1val != DatumGetPointer(values1[i1]))
+ if (arg1val != DatumGetPointer(values1[i1]))
pfree(arg1val);
- if ((Pointer) arg2val != DatumGetPointer(values2[i2]))
+ if (arg2val != DatumGetPointer(values2[i2]))
pfree(arg2val);
}
else
diff --git a/src/backend/utils/cache/evtcache.c b/src/backend/utils/cache/evtcache.c
index b9d5a5998be..76ba2db5390 100644
--- a/src/backend/utils/cache/evtcache.c
+++ b/src/backend/utils/cache/evtcache.c
@@ -240,7 +240,7 @@ DecodeTextArrayToBitmapset(Datum array)
}
pfree(elems);
- if ((Pointer) arr != DatumGetPointer(array))
+ if (arr != DatumGetPointer(array))
pfree(arr);
return bms;
diff --git a/src/include/fmgr.h b/src/include/fmgr.h
index 74fe3ea0575..c0dbe85ed1c 100644
--- a/src/include/fmgr.h
+++ b/src/include/fmgr.h
@@ -259,7 +259,7 @@ extern struct varlena *pg_detoast_datum_packed(struct varlena *datum);
*/
#define PG_FREE_IF_COPY(ptr,n) \
do { \
- if ((Pointer) (ptr) != PG_GETARG_POINTER(n)) \
+ if ((ptr) != PG_GETARG_POINTER(n)) \
pfree(ptr); \
} while (0)
--
2.52.0
[text/plain] 0006-Remove-some-uses-of-the-Pointer-type.patch (6.3K, ../../[email protected]/7-0006-Remove-some-uses-of-the-Pointer-type.patch)
download | inline diff:
From 467201808f4537291513c2151ff3266723b64314 Mon Sep 17 00:00:00 2001
From: Peter Eisentraut <[email protected]>
Date: Mon, 24 Nov 2025 11:02:35 +0100
Subject: [PATCH 6/6] Remove some uses of the Pointer type
everywhere except GIN
---
contrib/amcheck/verify_heapam.c | 2 +-
src/backend/access/common/heaptuple.c | 2 +-
src/backend/access/common/toast_internals.c | 2 +-
src/backend/access/heap/heaptoast.c | 2 +-
src/backend/nodes/tidbitmap.c | 4 ++--
src/backend/replication/logical/reorderbuffer.c | 4 ++--
src/backend/utils/adt/rangetypes.c | 6 +++---
src/bin/initdb/initdb.c | 4 ++--
src/include/postgres.h | 4 ++--
9 files changed, 15 insertions(+), 15 deletions(-)
diff --git a/contrib/amcheck/verify_heapam.c b/contrib/amcheck/verify_heapam.c
index 4963e9245cb..aa9974a867b 100644
--- a/contrib/amcheck/verify_heapam.c
+++ b/contrib/amcheck/verify_heapam.c
@@ -1557,7 +1557,7 @@ check_toast_tuple(HeapTuple toasttup, HeapCheckContext *ctx,
{
int32 chunk_seq;
int32 last_chunk_seq = (extsize - 1) / TOAST_MAX_CHUNK_SIZE;
- Pointer chunk;
+ void *chunk;
bool isnull;
int32 chunksize;
int32 expected_size;
diff --git a/src/backend/access/common/heaptuple.c b/src/backend/access/common/heaptuple.c
index 74a52d87067..36b09ea5bff 100644
--- a/src/backend/access/common/heaptuple.c
+++ b/src/backend/access/common/heaptuple.c
@@ -321,7 +321,7 @@ fill_val(CompactAttribute *att,
else if (att->attlen == -1)
{
/* varlena */
- Pointer val = DatumGetPointer(datum);
+ void *val = DatumGetPointer(datum);
*infomask |= HEAP_HASVARWIDTH;
if (VARATT_IS_EXTERNAL(val))
diff --git a/src/backend/access/common/toast_internals.c b/src/backend/access/common/toast_internals.c
index 63b848473f8..ba6ef6f4e72 100644
--- a/src/backend/access/common/toast_internals.c
+++ b/src/backend/access/common/toast_internals.c
@@ -128,7 +128,7 @@ toast_save_datum(Relation rel, Datum value,
int32 chunk_seq = 0;
char *data_p;
int32 data_todo;
- Pointer dval = DatumGetPointer(value);
+ void *dval = DatumGetPointer(value);
int num_indexes;
int validIndex;
diff --git a/src/backend/access/heap/heaptoast.c b/src/backend/access/heap/heaptoast.c
index 60e765fbfce..a049d7c7e81 100644
--- a/src/backend/access/heap/heaptoast.c
+++ b/src/backend/access/heap/heaptoast.c
@@ -696,7 +696,7 @@ heap_fetch_toast_slice(Relation toastrel, Oid valueid, int32 attrsize,
while ((ttup = systable_getnext_ordered(toastscan, ForwardScanDirection)) != NULL)
{
int32 curchunk;
- Pointer chunk;
+ void *chunk;
bool isnull;
char *chunkdata;
int32 chunksize;
diff --git a/src/backend/nodes/tidbitmap.c b/src/backend/nodes/tidbitmap.c
index 23d97b3a6c8..425c1177b22 100644
--- a/src/backend/nodes/tidbitmap.c
+++ b/src/backend/nodes/tidbitmap.c
@@ -1550,11 +1550,11 @@ tbm_calculate_entries(Size maxbytes)
/*
* Estimate number of hashtable entries we can have within maxbytes. This
* estimates the hash cost as sizeof(PagetableEntry), which is good enough
- * for our purpose. Also count an extra Pointer per entry for the arrays
+ * for our purpose. Also count an extra pointer per entry for the arrays
* created during iteration readout.
*/
nbuckets = maxbytes /
- (sizeof(PagetableEntry) + sizeof(Pointer) + sizeof(Pointer));
+ (sizeof(PagetableEntry) + sizeof(void *) + sizeof(void *));
nbuckets = Min(nbuckets, INT_MAX - 1); /* safety limit */
nbuckets = Max(nbuckets, 16); /* sanity limit */
diff --git a/src/backend/replication/logical/reorderbuffer.c b/src/backend/replication/logical/reorderbuffer.c
index eb6a84554b7..a014ef72aca 100644
--- a/src/backend/replication/logical/reorderbuffer.c
+++ b/src/backend/replication/logical/reorderbuffer.c
@@ -5003,7 +5003,7 @@ ReorderBufferToastAppendChunk(ReorderBuffer *rb, ReorderBufferTXN *txn,
bool found;
int32 chunksize;
bool isnull;
- Pointer chunk;
+ void *chunk;
TupleDesc desc = RelationGetDescr(relation);
Oid chunk_id;
int32 chunk_seq;
@@ -5192,7 +5192,7 @@ ReorderBufferToastReplace(ReorderBuffer *rb, ReorderBufferTXN *txn,
bool cisnull;
ReorderBufferChange *cchange;
HeapTuple ctup;
- Pointer chunk;
+ void *chunk;
cchange = dlist_container(ReorderBufferChange, node, it.cur);
ctup = cchange->data.tp.newtuple;
diff --git a/src/backend/utils/adt/rangetypes.c b/src/backend/utils/adt/rangetypes.c
index d8e5130d642..b887f21f10e 100644
--- a/src/backend/utils/adt/rangetypes.c
+++ b/src/backend/utils/adt/rangetypes.c
@@ -1962,7 +1962,7 @@ range_serialize(TypeCacheEntry *typcache, RangeBound *lower, RangeBound *upper,
RangeType *range;
int cmp;
Size msize;
- Pointer ptr;
+ char *ptr;
int16 typlen;
bool typbyval;
char typalign;
@@ -2070,7 +2070,7 @@ range_serialize(TypeCacheEntry *typcache, RangeBound *lower, RangeBound *upper,
typstorage);
}
- *((char *) ptr) = flags;
+ *ptr = flags;
return range;
}
@@ -2953,7 +2953,7 @@ datum_write(char *ptr, Datum datum, bool typbyval, char typalign,
else if (typlen == -1)
{
/* varlena */
- Pointer val = DatumGetPointer(datum);
+ void *val = DatumGetPointer(datum);
if (VARATT_IS_EXTERNAL(val))
{
diff --git a/src/bin/initdb/initdb.c b/src/bin/initdb/initdb.c
index 92fe2f531f7..30fce0d5f37 100644
--- a/src/bin/initdb/initdb.c
+++ b/src/bin/initdb/initdb.c
@@ -1574,11 +1574,11 @@ bootstrap_template1(void)
sprintf(buf, "%d", NAMEDATALEN);
bki_lines = replace_token(bki_lines, "NAMEDATALEN", buf);
- sprintf(buf, "%d", (int) sizeof(Pointer));
+ sprintf(buf, "%d", (int) sizeof(void *));
bki_lines = replace_token(bki_lines, "SIZEOF_POINTER", buf);
bki_lines = replace_token(bki_lines, "ALIGNOF_POINTER",
- (sizeof(Pointer) == 4) ? "i" : "d");
+ (sizeof(void *) == 4) ? "i" : "d");
bki_lines = replace_token(bki_lines, "POSTGRES",
escape_quotes_bki(username));
diff --git a/src/include/postgres.h b/src/include/postgres.h
index 357cbd6fd96..5f1c6b0a79e 100644
--- a/src/include/postgres.h
+++ b/src/include/postgres.h
@@ -318,10 +318,10 @@ CommandIdGetDatum(CommandId X)
* DatumGetPointer
* Returns pointer value of a datum.
*/
-static inline Pointer
+static inline void *
DatumGetPointer(Datum X)
{
- return (Pointer) (uintptr_t) X;
+ return (void *) (uintptr_t) X;
}
/*
--
2.52.0
^ permalink raw reply [nested|flat] 23+ messages in thread
* Re: get rid of Pointer type, mostly
2025-11-24 10:20 get rid of Pointer type, mostly Peter Eisentraut <[email protected]>
@ 2025-11-24 12:03 ` Chao Li <[email protected]>
2 siblings, 0 replies; 23+ messages in thread
From: Chao Li @ 2025-11-24 12:03 UTC (permalink / raw)
To: Peter Eisentraut <[email protected]>; +Cc: pgsql-hackers
> On Nov 24, 2025, at 18:20, Peter Eisentraut <[email protected]> wrote:
>
> In a previous thread[0], the question was asked, 'Why do we bother with a "Pointer" type?'. So I looked into get rid of it.
>
> There are two stages to this. One is changing all code that wants to do pointer arithmetic to use char * instead of relying on Pointer being char *. Then we can change Pointer to be void * and remove a bunch of casts.
>
> The second is getting rid of uses of Pointer for variables where you might as well use void * directly. These are actually not that many.
>
> This gets rid of all uses, except in the GIN code, which is full of Pointer use, and it's part of the documented API. I'm not touching that, not least because this kind of code
>
> Pointer **extra_data = (Pointer **) PG_GETARG_POINTER(4);
>
> needs more brain-bending to understand that I'm prepared to spend. So as far as I'm concerned, the pointer type can continue to exist as a curiosity of the GIN API, but in all other places, it wasn't really doing much of anything anyway.
>
>
> [0]: https://www.postgresql.org/message-id/CA%2BhUKG%2BNFKnr%3DK4oybwDvT35dW%3DVAjAAfiuLxp%2B5JeZSOV3nBg%...;
0001 - Removed type cast from memcpy(), which should be safe, as memcpy doesn’t care about types of source and dest pointers referring to, type casting is redundant.
0002 - Changed DatumGetPointer() to DatumGetCString() for %s. Basically, DatumGetPointer() returns a void * pointer and DatumGetCString() returns a char * pointers, but they return the same addresses, thus DatumGetCString() better fits %s.
0003 - Changed type casting from Pointer to char *. Now, Pointer is a typedef of char *, so the replacement is safe. In generic_desc(), Pointer is replaced with const char *, which should be safe also.
0004 - Changed typedef of Pointer from char * to void *. I guess the purpose is to let compiler alter for missed usages of Pointer.
0005/0006 - Removed all usages of Pointer expect in Gin code.
All look good. Only things is that, as Pointer is changed from char * to void *, and Gin code are still using Pointer, so these is a change for Gin code. But I don’t think that would impact runtime, as long as build passes, that should be fine. Build passed on my MacBook M4. If there is a breakage, build farm should be able to catch the error.
Best regards,
--
Chao Li (Evan)
HighGo Software Co., Ltd.
https://www.highgo.com/
^ permalink raw reply [nested|flat] 23+ messages in thread
* Re: get rid of Pointer type, mostly
2025-11-24 10:20 get rid of Pointer type, mostly Peter Eisentraut <[email protected]>
@ 2025-11-24 14:54 ` Bertrand Drouvot <[email protected]>
2 siblings, 0 replies; 23+ messages in thread
From: Bertrand Drouvot @ 2025-11-24 14:54 UTC (permalink / raw)
To: Peter Eisentraut <[email protected]>; +Cc: pgsql-hackers
Hi,
On Mon, Nov 24, 2025 at 11:20:56AM +0100, Peter Eisentraut wrote:
> In a previous thread[0], the question was asked, 'Why do we bother with a
> "Pointer" type?'. So I looked into get rid of it.
>
> There are two stages to this. One is changing all code that wants to do
> pointer arithmetic to use char * instead of relying on Pointer being char *.
> Then we can change Pointer to be void * and remove a bunch of casts.
>
> The second is getting rid of uses of Pointer for variables where you might
> as well use void * directly. These are actually not that many.
>
> This gets rid of all uses, except in the GIN code, which is full of Pointer
> use, and it's part of the documented API. I'm not touching that, not least
> because this kind of code
>
> Pointer **extra_data = (Pointer **) PG_GETARG_POINTER(4);
>
> needs more brain-bending to understand that I'm prepared to spend. So as
> far as I'm concerned, the pointer type can continue to exist as a curiosity
> of the GIN API, but in all other places, it wasn't really doing much of
> anything anyway.
The patch series is very easy to follow, thanks! I agree with the idea: we now
use (char *) for byte(s) manipulation and (void *) for generic pointer usage.
I checked the changes and if any have been missed and that looks ok to me.
Just a nit, while at it, maybe we could get rid of those extra parentheses:
@@ -140,20 +140,20 @@ GinDataLeafPageGetItems(Page page, int *nitems, ItemPointerData advancePast)
{
GinPostingList *seg = GinDataLeafPageGetPostingList(page);
Size len = GinDataLeafPageGetPostingListSize(page);
- Pointer endptr = ((Pointer) seg) + len;
+ char *endptr = ((char *) seg) + len;
The other existing ones in some macros are good to keep.
Regards,
--
Bertrand Drouvot
PostgreSQL Contributors Team
RDS Open Source Databases
Amazon Web Services: https://aws.amazon.com
^ permalink raw reply [nested|flat] 23+ messages in thread
* Re: get rid of Pointer type, mostly
2025-11-24 10:20 get rid of Pointer type, mostly Peter Eisentraut <[email protected]>
@ 2025-11-24 16:09 ` Tom Lane <[email protected]>
2025-11-24 16:19 ` Re: get rid of Pointer type, mostly Robert Haas <[email protected]>
2 siblings, 1 reply; 23+ messages in thread
From: Tom Lane @ 2025-11-24 16:09 UTC (permalink / raw)
To: Peter Eisentraut <[email protected]>; +Cc: pgsql-hackers
Peter Eisentraut <[email protected]> writes:
> In a previous thread[0], the question was asked, 'Why do we bother with
> a "Pointer" type?'. So I looked into get rid of it.
> There are two stages to this. One is changing all code that wants to do
> pointer arithmetic to use char * instead of relying on Pointer being
> char *. Then we can change Pointer to be void * and remove a bunch of
> casts.
I'm in favor of that ...
> The second is getting rid of uses of Pointer for variables where you
> might as well use void * directly. These are actually not that many.
... but not of that. In particular, I think it's just fine if
DatumGetPointer and PointerGetDatum take and return Pointer.
regards, tom lane
^ permalink raw reply [nested|flat] 23+ messages in thread
* Re: get rid of Pointer type, mostly
2025-11-24 10:20 get rid of Pointer type, mostly Peter Eisentraut <[email protected]>
2025-11-24 16:09 ` Re: get rid of Pointer type, mostly Tom Lane <[email protected]>
@ 2025-11-24 16:19 ` Robert Haas <[email protected]>
2025-11-24 16:33 ` Re: get rid of Pointer type, mostly Tom Lane <[email protected]>
0 siblings, 1 reply; 23+ messages in thread
From: Robert Haas @ 2025-11-24 16:19 UTC (permalink / raw)
To: Tom Lane <[email protected]>; +Cc: Peter Eisentraut <[email protected]>; pgsql-hackers
On Mon, Nov 24, 2025 at 11:09 AM Tom Lane <[email protected]> wrote:
> > The second is getting rid of uses of Pointer for variables where you
> > might as well use void * directly. These are actually not that many.
>
> ... but not of that. In particular, I think it's just fine if
> DatumGetPointer and PointerGetDatum take and return Pointer.
What's your objection?
(I don't have a considered opinion on this particular point, but in
general I've found that using Pointer seems to make life worse rather
than better.)
--
Robert Haas
EDB: http://www.enterprisedb.com
^ permalink raw reply [nested|flat] 23+ messages in thread
* Re: get rid of Pointer type, mostly
2025-11-24 10:20 get rid of Pointer type, mostly Peter Eisentraut <[email protected]>
2025-11-24 16:09 ` Re: get rid of Pointer type, mostly Tom Lane <[email protected]>
2025-11-24 16:19 ` Re: get rid of Pointer type, mostly Robert Haas <[email protected]>
@ 2025-11-24 16:33 ` Tom Lane <[email protected]>
2025-11-24 17:30 ` Re: get rid of Pointer type, mostly Jelte Fennema-Nio <[email protected]>
2025-11-24 17:32 ` Re: get rid of Pointer type, mostly Robert Haas <[email protected]>
0 siblings, 2 replies; 23+ messages in thread
From: Tom Lane @ 2025-11-24 16:33 UTC (permalink / raw)
To: Robert Haas <[email protected]>; +Cc: Peter Eisentraut <[email protected]>; pgsql-hackers
Robert Haas <[email protected]> writes:
> On Mon, Nov 24, 2025 at 11:09 AM Tom Lane <[email protected]> wrote:
>>> The second is getting rid of uses of Pointer for variables where you
>>> might as well use void * directly. These are actually not that many.
>> ... but not of that. In particular, I think it's just fine if
>> DatumGetPointer and PointerGetDatum take and return Pointer.
> What's your objection?
We have lots of places where we use trivial typedefs to annotate
what something is. For instance "text *" is not really different
from "struct varlena *", but I don't think anyone would be in favor
of removing the "text" typedef. In this case we have decades of
practice using Pointer to annotate something as being a generic
pointer. I'm in favor of switching it to be "void *" to conform
more closely to modern C semantics, but not of just trying to get
rid of it. Especially so if the removal is incomplete. What have
you really accomplished then?
> (I don't have a considered opinion on this particular point, but in
> general I've found that using Pointer seems to make life worse rather
> than better.)
How much of that comes from "char *" versus "void *"?
regards, tom lane
^ permalink raw reply [nested|flat] 23+ messages in thread
* Re: get rid of Pointer type, mostly
2025-11-24 10:20 get rid of Pointer type, mostly Peter Eisentraut <[email protected]>
2025-11-24 16:09 ` Re: get rid of Pointer type, mostly Tom Lane <[email protected]>
2025-11-24 16:19 ` Re: get rid of Pointer type, mostly Robert Haas <[email protected]>
2025-11-24 16:33 ` Re: get rid of Pointer type, mostly Tom Lane <[email protected]>
@ 2025-11-24 17:30 ` Jelte Fennema-Nio <[email protected]>
2025-11-24 17:35 ` Re: get rid of Pointer type, mostly Robert Haas <[email protected]>
1 sibling, 1 reply; 23+ messages in thread
From: Jelte Fennema-Nio @ 2025-11-24 17:30 UTC (permalink / raw)
To: Tom Lane <[email protected]>; +Cc: Robert Haas <[email protected]>; Peter Eisentraut <[email protected]>; pgsql-hackers
On Mon, Nov 24, 2025, 09:34 Tom Lane <[email protected]> wrote:
> Especially so if the removal is incomplete. What have
> you really accomplished then?
>
In this case, what we would accomplish is that no new developer to the
project has to understand what some unclear typedef means, *unless* they
touch GIN related code. Just from its name it's definitely not clear to me
that Pointer means char * instead of void *. And this typedef is ven
shorter than the thing it represents.
Side annoyance: I think this is a falacy that hackers discussions end up in
a lot. Someone suggesting that the partial improvements have (almost) no
benefit and all cases need to be fixed in one go to before it should be
committed. Then the patch author thinks that's too much work and then
nothing ends up being improved at all.
^ permalink raw reply [nested|flat] 23+ messages in thread
* Re: get rid of Pointer type, mostly
2025-11-24 10:20 get rid of Pointer type, mostly Peter Eisentraut <[email protected]>
2025-11-24 16:09 ` Re: get rid of Pointer type, mostly Tom Lane <[email protected]>
2025-11-24 16:19 ` Re: get rid of Pointer type, mostly Robert Haas <[email protected]>
2025-11-24 16:33 ` Re: get rid of Pointer type, mostly Tom Lane <[email protected]>
2025-11-24 17:30 ` Re: get rid of Pointer type, mostly Jelte Fennema-Nio <[email protected]>
@ 2025-11-24 17:35 ` Robert Haas <[email protected]>
0 siblings, 0 replies; 23+ messages in thread
From: Robert Haas @ 2025-11-24 17:35 UTC (permalink / raw)
To: Jelte Fennema-Nio <[email protected]>; +Cc: Tom Lane <[email protected]>; Peter Eisentraut <[email protected]>; pgsql-hackers
On Mon, Nov 24, 2025 at 12:30 PM Jelte Fennema-Nio <[email protected]> wrote:
> In this case, what we would accomplish is that no new developer to the project has to understand what some unclear typedef means, *unless* they touch GIN related code. Just from its name it's definitely not clear to me that Pointer means char * instead of void *. And this typedef is ven shorter than the thing it represents.
+1.
> Side annoyance: I think this is a falacy that hackers discussions end up in a lot. Someone suggesting that the partial improvements have (almost) no benefit and all cases need to be fixed in one go to before it should be committed. Then the patch author thinks that's too much work and then nothing ends up being improved at all.
This is definitely a thing that happens, but what also happens pretty
often is that people claim that we'll follow up on a partial
improvement with lots more work and then we never do, and then it
creates a big mess for somebody else to untangle later. I understand
the frustration with getting a partial solution blocked, because half
a loaf is better than none, but I've also done my share of cleaning up
changes that weren't so much half a loaf as half-baked.
--
Robert Haas
EDB: http://www.enterprisedb.com
^ permalink raw reply [nested|flat] 23+ messages in thread
* Re: get rid of Pointer type, mostly
2025-11-24 10:20 get rid of Pointer type, mostly Peter Eisentraut <[email protected]>
2025-11-24 16:09 ` Re: get rid of Pointer type, mostly Tom Lane <[email protected]>
2025-11-24 16:19 ` Re: get rid of Pointer type, mostly Robert Haas <[email protected]>
2025-11-24 16:33 ` Re: get rid of Pointer type, mostly Tom Lane <[email protected]>
@ 2025-11-24 17:32 ` Robert Haas <[email protected]>
2025-11-24 18:26 ` Re: get rid of Pointer type, mostly Tom Lane <[email protected]>
1 sibling, 1 reply; 23+ messages in thread
From: Robert Haas @ 2025-11-24 17:32 UTC (permalink / raw)
To: Tom Lane <[email protected]>; +Cc: Peter Eisentraut <[email protected]>; pgsql-hackers
On Mon, Nov 24, 2025 at 11:33 AM Tom Lane <[email protected]> wrote:
> We have lots of places where we use trivial typedefs to annotate
> what something is. For instance "text *" is not really different
> from "struct varlena *", but I don't think anyone would be in favor
> of removing the "text" typedef. In this case we have decades of
> practice using Pointer to annotate something as being a generic
> pointer.
In my mind, a text * points to a varlena whose payload data is valid
in the relevant encoding, i.e. something that will be legal if you
pass it to functions that expect to work on text Datums. But I'm not
very clear on what Pointer is supposed to mean. Sometimes we use it to
indicate that a char * is a generic pointer rather than a pointer to a
C string, but sometimes we just write char * anyway, so you can't use
the fact that something is declared as char * to mean that it isn't
intended as a generic pointer. If we change Pointer to be void *, then
even that clarifying value is lost, since void * has no other meaning.
But if it were up to me, I'd rip out Pointer completely, because
reading code that uses the native C type names is easier for me than
reading code that substitutes other notation.
In my experience, there's rarely any practical confusion about whether
char * is a C string, a character array, or a generic pointer. It's
not impossible for such confusion to exist, of course, but typically
pointer arithmetic is confined to relatively brief stretches of code
to avoid breaking the author's brain, or the reader's. If you see a
pointer to a struct get cast to a char * or the other way around, you
know what's happening. It would be confusing if the char * intended as
a generic pointer were passed through multiple layers of function
calls, but for those cases it's typically convenient to use void *, so
the problem doesn't really arise, and in the rare cases where it
might, one can always write a comment to clear things up.
We have lots of data types that seem to me to have enough
documentation value to justify their existence, but IMHO, this isn't
one of them.
--
Robert Haas
EDB: http://www.enterprisedb.com
^ permalink raw reply [nested|flat] 23+ messages in thread
* Re: get rid of Pointer type, mostly
2025-11-24 10:20 get rid of Pointer type, mostly Peter Eisentraut <[email protected]>
2025-11-24 16:09 ` Re: get rid of Pointer type, mostly Tom Lane <[email protected]>
2025-11-24 16:19 ` Re: get rid of Pointer type, mostly Robert Haas <[email protected]>
2025-11-24 16:33 ` Re: get rid of Pointer type, mostly Tom Lane <[email protected]>
2025-11-24 17:32 ` Re: get rid of Pointer type, mostly Robert Haas <[email protected]>
@ 2025-11-24 18:26 ` Tom Lane <[email protected]>
2025-11-24 18:46 ` Re: get rid of Pointer type, mostly David Geier <[email protected]>
2025-11-24 19:32 ` Re: get rid of Pointer type, mostly Robert Haas <[email protected]>
0 siblings, 2 replies; 23+ messages in thread
From: Tom Lane @ 2025-11-24 18:26 UTC (permalink / raw)
To: Robert Haas <[email protected]>; +Cc: Peter Eisentraut <[email protected]>; pgsql-hackers
Robert Haas <[email protected]> writes:
> But if it were up to me, I'd rip out Pointer completely, because
> reading code that uses the native C type names is easier for me than
> reading code that substitutes other notation.
I can follow the argument that using the native type "void *" is
better, since every C programmer must know that already. But you
cannot argue for this patch on that ground unless Pointer goes away
entirely. I don't understand leaving it in place for GIN. It's
not like GIN indexes are some hoary backwater that nobody pays
attention to.
regards, tom lane
^ permalink raw reply [nested|flat] 23+ messages in thread
* Re: get rid of Pointer type, mostly
2025-11-24 10:20 get rid of Pointer type, mostly Peter Eisentraut <[email protected]>
2025-11-24 16:09 ` Re: get rid of Pointer type, mostly Tom Lane <[email protected]>
2025-11-24 16:19 ` Re: get rid of Pointer type, mostly Robert Haas <[email protected]>
2025-11-24 16:33 ` Re: get rid of Pointer type, mostly Tom Lane <[email protected]>
2025-11-24 17:32 ` Re: get rid of Pointer type, mostly Robert Haas <[email protected]>
2025-11-24 18:26 ` Re: get rid of Pointer type, mostly Tom Lane <[email protected]>
@ 2025-11-24 18:46 ` David Geier <[email protected]>
2025-11-24 19:05 ` Re: get rid of Pointer type, mostly Robert Haas <[email protected]>
1 sibling, 1 reply; 23+ messages in thread
From: David Geier @ 2025-11-24 18:46 UTC (permalink / raw)
To: Tom Lane <[email protected]>; Robert Haas <[email protected]>; +Cc: Peter Eisentraut <[email protected]>; pgsql-hackers
I'm in big favor of this change. Such types just cover up what's really
going on and make reading the code more difficult than needed,
especially for people new to the code base.
On 24.11.2025 19:26, Tom Lane wrote:
> Robert Haas <[email protected]> writes:
> I can follow the argument that using the native type "void *" is
> better, since every C programmer must know that already. But you
> cannot argue for this patch on that ground unless Pointer goes away
> entirely. I don't understand leaving it in place for GIN. It's
> not like GIN indexes are some hoary backwater that nobody pays
> attention to.
+1
The GIN code makes use of pointer but src/backend/access/gin only has 29
occurrences. If you like I can help out fixing up the GIN code and share
a page here. Let me know.
--
David Geier
^ permalink raw reply [nested|flat] 23+ messages in thread
* Re: get rid of Pointer type, mostly
2025-11-24 10:20 get rid of Pointer type, mostly Peter Eisentraut <[email protected]>
2025-11-24 16:09 ` Re: get rid of Pointer type, mostly Tom Lane <[email protected]>
2025-11-24 16:19 ` Re: get rid of Pointer type, mostly Robert Haas <[email protected]>
2025-11-24 16:33 ` Re: get rid of Pointer type, mostly Tom Lane <[email protected]>
2025-11-24 17:32 ` Re: get rid of Pointer type, mostly Robert Haas <[email protected]>
2025-11-24 18:26 ` Re: get rid of Pointer type, mostly Tom Lane <[email protected]>
2025-11-24 18:46 ` Re: get rid of Pointer type, mostly David Geier <[email protected]>
@ 2025-11-24 19:05 ` Robert Haas <[email protected]>
2025-11-24 19:15 ` Re: get rid of Pointer type, mostly Tom Lane <[email protected]>
0 siblings, 1 reply; 23+ messages in thread
From: Robert Haas @ 2025-11-24 19:05 UTC (permalink / raw)
To: David Geier <[email protected]>; +Cc: Tom Lane <[email protected]>; Peter Eisentraut <[email protected]>; pgsql-hackers
On Mon, Nov 24, 2025 at 1:46 PM David Geier <[email protected]> wrote:
> The GIN code makes use of pointer but src/backend/access/gin only has 29
> occurrences. If you like I can help out fixing up the GIN code and share
> a page here. Let me know.
I'd go for it! I mean, who knows whether your patch will be accepted?
But another pair of eyes couldn't hurt. It seems like we all agree
that a full removal of Pointer would be better than a partial removal;
it's just a question of whether we can get there without too much
other awkwardness.
--
Robert Haas
EDB: http://www.enterprisedb.com
^ permalink raw reply [nested|flat] 23+ messages in thread
* Re: get rid of Pointer type, mostly
2025-11-24 10:20 get rid of Pointer type, mostly Peter Eisentraut <[email protected]>
2025-11-24 16:09 ` Re: get rid of Pointer type, mostly Tom Lane <[email protected]>
2025-11-24 16:19 ` Re: get rid of Pointer type, mostly Robert Haas <[email protected]>
2025-11-24 16:33 ` Re: get rid of Pointer type, mostly Tom Lane <[email protected]>
2025-11-24 17:32 ` Re: get rid of Pointer type, mostly Robert Haas <[email protected]>
2025-11-24 18:26 ` Re: get rid of Pointer type, mostly Tom Lane <[email protected]>
2025-11-24 18:46 ` Re: get rid of Pointer type, mostly David Geier <[email protected]>
2025-11-24 19:05 ` Re: get rid of Pointer type, mostly Robert Haas <[email protected]>
@ 2025-11-24 19:15 ` Tom Lane <[email protected]>
2025-11-24 20:08 ` Re: get rid of Pointer type, mostly Dagfinn Ilmari Mannsåker <[email protected]>
0 siblings, 1 reply; 23+ messages in thread
From: Tom Lane @ 2025-11-24 19:15 UTC (permalink / raw)
To: Robert Haas <[email protected]>; +Cc: David Geier <[email protected]>; Peter Eisentraut <[email protected]>; pgsql-hackers
Robert Haas <[email protected]> writes:
> On Mon, Nov 24, 2025 at 1:46 PM David Geier <[email protected]> wrote:
>> The GIN code makes use of pointer but src/backend/access/gin only has 29
>> occurrences. If you like I can help out fixing up the GIN code and share
>> a page here. Let me know.
> I'd go for it! I mean, who knows whether your patch will be accepted?
> But another pair of eyes couldn't hurt. It seems like we all agree
> that a full removal of Pointer would be better than a partial removal;
> it's just a question of whether we can get there without too much
> other awkwardness.
If there are actually places in GIN where using void* would be less
readable than using Pointer, that would certainly be interesting
information. Perhaps the patch would need to spend some effort
on adding comments, not just mechanically replacing the typedef?
regards, tom lane
^ permalink raw reply [nested|flat] 23+ messages in thread
* Re: get rid of Pointer type, mostly
2025-11-24 10:20 get rid of Pointer type, mostly Peter Eisentraut <[email protected]>
2025-11-24 16:09 ` Re: get rid of Pointer type, mostly Tom Lane <[email protected]>
2025-11-24 16:19 ` Re: get rid of Pointer type, mostly Robert Haas <[email protected]>
2025-11-24 16:33 ` Re: get rid of Pointer type, mostly Tom Lane <[email protected]>
2025-11-24 17:32 ` Re: get rid of Pointer type, mostly Robert Haas <[email protected]>
2025-11-24 18:26 ` Re: get rid of Pointer type, mostly Tom Lane <[email protected]>
2025-11-24 18:46 ` Re: get rid of Pointer type, mostly David Geier <[email protected]>
2025-11-24 19:05 ` Re: get rid of Pointer type, mostly Robert Haas <[email protected]>
2025-11-24 19:15 ` Re: get rid of Pointer type, mostly Tom Lane <[email protected]>
@ 2025-11-24 20:08 ` Dagfinn Ilmari Mannsåker <[email protected]>
0 siblings, 0 replies; 23+ messages in thread
From: Dagfinn Ilmari Mannsåker @ 2025-11-24 20:08 UTC (permalink / raw)
To: Tom Lane <[email protected]>; +Cc: Robert Haas <[email protected]>; David Geier <[email protected]>; Peter Eisentraut <[email protected]>; pgsql-hackers
Tom Lane <[email protected]> writes:
> Robert Haas <[email protected]> writes:
>> On Mon, Nov 24, 2025 at 1:46 PM David Geier <[email protected]> wrote:
>>> The GIN code makes use of pointer but src/backend/access/gin only has 29
>>> occurrences. If you like I can help out fixing up the GIN code and share
>>> a page here. Let me know.
>
>> I'd go for it! I mean, who knows whether your patch will be accepted?
>> But another pair of eyes couldn't hurt. It seems like we all agree
>> that a full removal of Pointer would be better than a partial removal;
>> it's just a question of whether we can get there without too much
>> other awkwardness.
>
> If there are actually places in GIN where using void* would be less
> readable than using Pointer, that would certainly be interesting
> information. Perhaps the patch would need to spend some effort
> on adding comments, not just mechanically replacing the typedef?
I got curious and did the replacement, and IMO there's no need for any
further commentary than what's already there. I did however take the
opportunity to get rid of some pointless casts (except the return value
of PG_GETARG_POINTER(), which seems to be de rigueur to redundantly
cast), and to convert a nearby char * that's only used for memcpy() to
void *.
- ilmari
^ permalink raw reply [nested|flat] 23+ messages in thread
* Re: get rid of Pointer type, mostly
2025-11-24 10:20 get rid of Pointer type, mostly Peter Eisentraut <[email protected]>
2025-11-24 16:09 ` Re: get rid of Pointer type, mostly Tom Lane <[email protected]>
2025-11-24 16:19 ` Re: get rid of Pointer type, mostly Robert Haas <[email protected]>
2025-11-24 16:33 ` Re: get rid of Pointer type, mostly Tom Lane <[email protected]>
2025-11-24 17:32 ` Re: get rid of Pointer type, mostly Robert Haas <[email protected]>
2025-11-24 18:26 ` Re: get rid of Pointer type, mostly Tom Lane <[email protected]>
@ 2025-11-24 19:32 ` Robert Haas <[email protected]>
2025-11-24 19:38 ` Re: get rid of Pointer type, mostly Tom Lane <[email protected]>
1 sibling, 1 reply; 23+ messages in thread
From: Robert Haas @ 2025-11-24 19:32 UTC (permalink / raw)
To: Tom Lane <[email protected]>; +Cc: Peter Eisentraut <[email protected]>; pgsql-hackers
On Mon, Nov 24, 2025 at 1:26 PM Tom Lane <[email protected]> wrote:
> I don't understand leaving it in place for GIN.
I haven't tried removing it for GIN so I don't know how awkward that
would be or for what reasons, but...
> It's
> not like GIN indexes are some hoary backwater that nobody pays
> attention to.
...I almost feel like you're trolling with this comment. It is true
that we maintain that code, and I see in the commit log that there are
even some GIN-specific improvements in the recent past. But the
average PostgreSQL hacker can probably go years and years without ever
having to touch the GIN code. Hoary backwater might be overselling it,
but it's far enough in that direction that confining the need to be
aware of one specific PostgreSQL-ism just to GIN is not without value.
--
Robert Haas
EDB: http://www.enterprisedb.com
^ permalink raw reply [nested|flat] 23+ messages in thread
* Re: get rid of Pointer type, mostly
2025-11-24 10:20 get rid of Pointer type, mostly Peter Eisentraut <[email protected]>
2025-11-24 16:09 ` Re: get rid of Pointer type, mostly Tom Lane <[email protected]>
2025-11-24 16:19 ` Re: get rid of Pointer type, mostly Robert Haas <[email protected]>
2025-11-24 16:33 ` Re: get rid of Pointer type, mostly Tom Lane <[email protected]>
2025-11-24 17:32 ` Re: get rid of Pointer type, mostly Robert Haas <[email protected]>
2025-11-24 18:26 ` Re: get rid of Pointer type, mostly Tom Lane <[email protected]>
2025-11-24 19:32 ` Re: get rid of Pointer type, mostly Robert Haas <[email protected]>
@ 2025-11-24 19:38 ` Tom Lane <[email protected]>
2025-11-24 19:52 ` Re: get rid of Pointer type, mostly Robert Haas <[email protected]>
0 siblings, 1 reply; 23+ messages in thread
From: Tom Lane @ 2025-11-24 19:38 UTC (permalink / raw)
To: Robert Haas <[email protected]>; +Cc: Peter Eisentraut <[email protected]>; pgsql-hackers
Robert Haas <[email protected]> writes:
> On Mon, Nov 24, 2025 at 1:26 PM Tom Lane <[email protected]> wrote:
>> I don't understand leaving it in place for GIN.
> I haven't tried removing it for GIN so I don't know how awkward that
> would be or for what reasons, but...
Well, either Peter just ran out of energy or there is actually some
notational value in Pointer. If it's the latter, I'd like to know.
regards, tom lane
^ permalink raw reply [nested|flat] 23+ messages in thread
* Re: get rid of Pointer type, mostly
2025-11-24 10:20 get rid of Pointer type, mostly Peter Eisentraut <[email protected]>
2025-11-24 16:09 ` Re: get rid of Pointer type, mostly Tom Lane <[email protected]>
2025-11-24 16:19 ` Re: get rid of Pointer type, mostly Robert Haas <[email protected]>
2025-11-24 16:33 ` Re: get rid of Pointer type, mostly Tom Lane <[email protected]>
2025-11-24 17:32 ` Re: get rid of Pointer type, mostly Robert Haas <[email protected]>
2025-11-24 18:26 ` Re: get rid of Pointer type, mostly Tom Lane <[email protected]>
2025-11-24 19:32 ` Re: get rid of Pointer type, mostly Robert Haas <[email protected]>
2025-11-24 19:38 ` Re: get rid of Pointer type, mostly Tom Lane <[email protected]>
@ 2025-11-24 19:52 ` Robert Haas <[email protected]>
2025-11-24 20:20 ` Re: get rid of Pointer type, mostly David Geier <[email protected]>
0 siblings, 1 reply; 23+ messages in thread
From: Robert Haas @ 2025-11-24 19:52 UTC (permalink / raw)
To: Tom Lane <[email protected]>; +Cc: Peter Eisentraut <[email protected]>; pgsql-hackers
On Mon, Nov 24, 2025 at 2:38 PM Tom Lane <[email protected]> wrote:
> Well, either Peter just ran out of energy or there is actually some
> notational value in Pointer. If it's the latter, I'd like to know.
I agree that would be nice to know.
Peter's original email seemed to indicate that he was deterred by this
sort of thing:
Pointer **extra_data = (Pointer **) PG_GETARG_POINTER(4);
If Pointer is merely char *, then this is equivalent to:
char ***extra_data = (char ***) PG_GETARG_POINTER(4);
I believe this is the same extra_data that is documented thus:
extra_data is an output argument that allows extractQuery to pass
additional data to the consistent and comparePartial methods. To use
it, extractQuery must allocate an array of *nkeys pointers and store
its address at *extra_data, then store whatever it wants to into the
individual pointers. The variable is initialized to NULL before call,
so this argument can simply be ignored by operator classes that do not
require extra data. If *extra_data is set, the whole array is passed
to the consistent method, and the appropriate element to the
comparePartial method.
So in other words, it's a pointer to an array of generic pointers. In
a vacuum, I'd suggest that having three levels of indirection that are
all semantically different but all denoted by an asterisk in C is
confusing enough to be a bad idea regardless of the specifics. But
since we've already crossed that bridge, we'll just need to make the
best of it. Maybe we could use a more specific typedef here, like
GinExtraPointer. That would be a lot more greppable than just writing
Pointer, and every GinExtraPointer would be the same flavor of generic
pointer, whereas any given Pointer is not necessarily related in any
semantic way to any other.
--
Robert Haas
EDB: http://www.enterprisedb.com
^ permalink raw reply [nested|flat] 23+ messages in thread
* Re: get rid of Pointer type, mostly
2025-11-24 10:20 get rid of Pointer type, mostly Peter Eisentraut <[email protected]>
2025-11-24 16:09 ` Re: get rid of Pointer type, mostly Tom Lane <[email protected]>
2025-11-24 16:19 ` Re: get rid of Pointer type, mostly Robert Haas <[email protected]>
2025-11-24 16:33 ` Re: get rid of Pointer type, mostly Tom Lane <[email protected]>
2025-11-24 17:32 ` Re: get rid of Pointer type, mostly Robert Haas <[email protected]>
2025-11-24 18:26 ` Re: get rid of Pointer type, mostly Tom Lane <[email protected]>
2025-11-24 19:32 ` Re: get rid of Pointer type, mostly Robert Haas <[email protected]>
2025-11-24 19:38 ` Re: get rid of Pointer type, mostly Tom Lane <[email protected]>
2025-11-24 19:52 ` Re: get rid of Pointer type, mostly Robert Haas <[email protected]>
@ 2025-11-24 20:20 ` David Geier <[email protected]>
2025-12-08 10:25 ` Re: get rid of Pointer type, mostly David Geier <[email protected]>
0 siblings, 1 reply; 23+ messages in thread
From: David Geier @ 2025-11-24 20:20 UTC (permalink / raw)
To: Robert Haas <[email protected]>; Tom Lane <[email protected]>; +Cc: Peter Eisentraut <[email protected]>; pgsql-hackers
On 24.11.2025 20:52, Robert Haas wrote:
> On Mon, Nov 24, 2025 at 2:38 PM Tom Lane <[email protected]> wrote:
>> Well, either Peter just ran out of energy or there is actually some
>> notational value in Pointer. If it's the latter, I'd like to know.
>
> I agree that would be nice to know.
>
> Peter's original email seemed to indicate that he was deterred by this
> sort of thing:
>
> Pointer **extra_data = (Pointer **) PG_GETARG_POINTER(4);
>
> If Pointer is merely char *, then this is equivalent to:
>
> char ***extra_data = (char ***) PG_GETARG_POINTER(4);
>
> I believe this is the same extra_data that is documented thus:
I figured the same while doing the change.
> So in other words, it's a pointer to an array of generic pointers. In
> a vacuum, I'd suggest that having three levels of indirection that are
> all semantically different but all denoted by an asterisk in C is
> confusing enough to be a bad idea regardless of the specifics. But
> since we've already crossed that bridge, we'll just need to make the
> best of it. Maybe we could use a more specific typedef here, like
> GinExtraPointer. That would be a lot more greppable than just writing
> Pointer, and every GinExtraPointer would be the same flavor of generic
> pointer, whereas any given Pointer is not necessarily related in any
> semantic way to any other.
I went with your proposal of GinExtraPointer. See attached patch. It's
based on the series of patches from Peter's initial mail. I've included
the removal of the Pointer typedef in the same patch.
--
David Geier
Attachments:
[text/x-patch] 0001-Remove-uses-of-Pointer-in-GIN-related-code.patch (19.7K, ../../[email protected]/2-0001-Remove-uses-of-Pointer-in-GIN-related-code.patch)
download | inline diff:
From 78af974bb9b50a7a1ab52e9aa5a4108c82b23f31 Mon Sep 17 00:00:00 2001
From: David Geier <[email protected]>
Date: Mon, 24 Nov 2025 21:16:12 +0100
Subject: [PATCH] Remove uses of Pointer in GIN related code
---
contrib/amcheck/verify_gin.c | 2 +-
contrib/btree_gin/btree_gin.c | 7 ++++---
contrib/hstore/hstore_gin.c | 2 +-
contrib/intarray/_int_gin.c | 2 +-
contrib/pg_trgm/trgm_gin.c | 10 +++++-----
doc/src/sgml/gin.sgml | 8 ++++----
src/backend/access/gin/ginarrayproc.c | 6 +++---
src/backend/access/gin/ginentrypage.c | 6 +++---
src/backend/access/gin/ginscan.c | 8 ++++----
src/backend/utils/adt/jsonb_gin.c | 16 ++++++++--------
src/backend/utils/adt/selfuncs.c | 2 +-
src/backend/utils/adt/tsginidx.c | 12 ++++++------
src/include/access/gin.h | 2 ++
src/include/access/gin_private.h | 6 +++---
src/include/access/ginblock.h | 2 +-
src/include/c.h | 7 -------
16 files changed, 47 insertions(+), 51 deletions(-)
diff --git a/contrib/amcheck/verify_gin.c b/contrib/amcheck/verify_gin.c
index 5c3eb4d0fd4..4dc8af4e403 100644
--- a/contrib/amcheck/verify_gin.c
+++ b/contrib/amcheck/verify_gin.c
@@ -98,7 +98,7 @@ gin_index_check(PG_FUNCTION_ARGS)
static ItemPointer
ginReadTupleWithoutState(IndexTuple itup, int *nitems)
{
- Pointer ptr = GinGetPosting(itup);
+ void * ptr = GinGetPosting(itup);
int nipd = GinGetNPosting(itup);
ItemPointer ipd;
int ndecoded;
diff --git a/contrib/btree_gin/btree_gin.c b/contrib/btree_gin/btree_gin.c
index 8c477d17e22..4725f4c1787 100644
--- a/contrib/btree_gin/btree_gin.c
+++ b/contrib/btree_gin/btree_gin.c
@@ -5,6 +5,7 @@
#include <limits.h>
+#include "access/gin.h"
#include "access/stratnum.h"
#include "mb/pg_wchar.h"
#include "utils/builtins.h"
@@ -73,7 +74,7 @@ gin_btree_extract_query(FunctionCallInfo fcinfo,
int32 *nentries = (int32 *) PG_GETARG_POINTER(1);
StrategyNumber strategy = PG_GETARG_UINT16(2);
bool **partialmatch = (bool **) PG_GETARG_POINTER(3);
- Pointer **extra_data = (Pointer **) PG_GETARG_POINTER(4);
+ GinExtraPointer **extra_data = (GinExtraPointer **) PG_GETARG_POINTER(4);
Datum *entries = (Datum *) palloc(sizeof(Datum));
QueryInfo *data = (QueryInfo *) palloc(sizeof(QueryInfo));
bool *ptr_partialmatch = (bool *) palloc(sizeof(bool));
@@ -139,8 +140,8 @@ gin_btree_extract_query(FunctionCallInfo fcinfo,
data->orig_datum = datum;
data->entry_datum = entries[0];
data->typecmp = cmp_fns[rhs_code];
- *extra_data = (Pointer *) palloc(sizeof(Pointer));
- **extra_data = (Pointer) data;
+ *extra_data = (GinExtraPointer *) palloc(sizeof(GinExtraPointer));
+ **extra_data = (GinExtraPointer) data;
PG_RETURN_POINTER(entries);
}
diff --git a/contrib/hstore/hstore_gin.c b/contrib/hstore/hstore_gin.c
index 2e5fa115924..09ff2dd0d99 100644
--- a/contrib/hstore/hstore_gin.c
+++ b/contrib/hstore/hstore_gin.c
@@ -156,7 +156,7 @@ gin_consistent_hstore(PG_FUNCTION_ARGS)
/* HStore *query = PG_GETARG_HSTORE_P(2); */
int32 nkeys = PG_GETARG_INT32(3);
- /* Pointer *extra_data = (Pointer *) PG_GETARG_POINTER(4); */
+ /* GinExtraPointer *extra_data = (GinExtraPointer *) PG_GETARG_POINTER(4); */
bool *recheck = (bool *) PG_GETARG_POINTER(5);
bool res = true;
int32 i;
diff --git a/contrib/intarray/_int_gin.c b/contrib/intarray/_int_gin.c
index b7958d8eca5..ab15d69084e 100644
--- a/contrib/intarray/_int_gin.c
+++ b/contrib/intarray/_int_gin.c
@@ -113,7 +113,7 @@ ginint4_consistent(PG_FUNCTION_ARGS)
StrategyNumber strategy = PG_GETARG_UINT16(1);
int32 nkeys = PG_GETARG_INT32(3);
- /* Pointer *extra_data = (Pointer *) PG_GETARG_POINTER(4); */
+ /* GinExtraPointer *extra_data = (GinExtraPointer *) PG_GETARG_POINTER(4); */
bool *recheck = (bool *) PG_GETARG_POINTER(5);
bool res = false;
int32 i;
diff --git a/contrib/pg_trgm/trgm_gin.c b/contrib/pg_trgm/trgm_gin.c
index 29a52eac7af..5e45cefac26 100644
--- a/contrib/pg_trgm/trgm_gin.c
+++ b/contrib/pg_trgm/trgm_gin.c
@@ -74,7 +74,7 @@ gin_extract_query_trgm(PG_FUNCTION_ARGS)
StrategyNumber strategy = PG_GETARG_UINT16(2);
/* bool **pmatch = (bool **) PG_GETARG_POINTER(3); */
- Pointer **extra_data = (Pointer **) PG_GETARG_POINTER(4);
+ GinExtraPointer **extra_data = (GinExtraPointer **) PG_GETARG_POINTER(4);
/* bool **nullFlags = (bool **) PG_GETARG_POINTER(5); */
int32 *searchMode = (int32 *) PG_GETARG_POINTER(6);
@@ -123,9 +123,9 @@ gin_extract_query_trgm(PG_FUNCTION_ARGS)
* Pointers, but we just put the same value in each element.
*/
trglen = ARRNELEM(trg);
- *extra_data = (Pointer *) palloc(sizeof(Pointer) * trglen);
+ *extra_data = (GinExtraPointer *) palloc(sizeof(GinExtraPointer) * trglen);
for (i = 0; i < trglen; i++)
- (*extra_data)[i] = (Pointer) graph;
+ (*extra_data)[i] = (GinExtraPointer) graph;
}
else
{
@@ -174,7 +174,7 @@ gin_trgm_consistent(PG_FUNCTION_ARGS)
/* text *query = PG_GETARG_TEXT_PP(2); */
int32 nkeys = PG_GETARG_INT32(3);
- Pointer *extra_data = (Pointer *) PG_GETARG_POINTER(4);
+ GinExtraPointer *extra_data = (GinExtraPointer *) PG_GETARG_POINTER(4);
bool *recheck = (bool *) PG_GETARG_POINTER(5);
bool res;
int32 i,
@@ -273,7 +273,7 @@ gin_trgm_triconsistent(PG_FUNCTION_ARGS)
/* text *query = PG_GETARG_TEXT_PP(2); */
int32 nkeys = PG_GETARG_INT32(3);
- Pointer *extra_data = (Pointer *) PG_GETARG_POINTER(4);
+ GinExtraPointer *extra_data = (GinExtraPointer *) PG_GETARG_POINTER(4);
GinTernaryValue res = GIN_MAYBE;
int32 i,
ntrue;
diff --git a/doc/src/sgml/gin.sgml b/doc/src/sgml/gin.sgml
index 82410b1fbdf..bd392bcfdfd 100644
--- a/doc/src/sgml/gin.sgml
+++ b/doc/src/sgml/gin.sgml
@@ -184,7 +184,7 @@
<varlistentry>
<term><function>Datum *extractQuery(Datum query, int32 *nkeys,
- StrategyNumber n, bool **pmatch, Pointer **extra_data,
+ StrategyNumber n, bool **pmatch, GinExtraPointer **extra_data,
bool **nullFlags, int32 *searchMode)</function></term>
<listitem>
<para>
@@ -273,7 +273,7 @@
<variablelist>
<varlistentry>
<term><function>bool consistent(bool check[], StrategyNumber n, Datum query,
- int32 nkeys, Pointer extra_data[], bool *recheck,
+ int32 nkeys, GinExtraPointer extra_data[], bool *recheck,
Datum queryKeys[], bool nullFlags[])</function></term>
<listitem>
<para>
@@ -324,7 +324,7 @@
<varlistentry>
<term><function>GinTernaryValue triConsistent(GinTernaryValue check[], StrategyNumber n, Datum query,
- int32 nkeys, Pointer extra_data[],
+ int32 nkeys, GinExtraPointer extra_data[],
Datum queryKeys[], bool nullFlags[])</function></term>
<listitem>
<para>
@@ -391,7 +391,7 @@
<variablelist>
<varlistentry>
<term><function>int comparePartial(Datum partial_key, Datum key, StrategyNumber n,
- Pointer extra_data)</function></term>
+ GinExtraPointer extra_data)</function></term>
<listitem>
<para>
Compare a partial-match query key to an index key.
diff --git a/src/backend/access/gin/ginarrayproc.c b/src/backend/access/gin/ginarrayproc.c
index 1f821323eb0..46d9c29a08b 100644
--- a/src/backend/access/gin/ginarrayproc.c
+++ b/src/backend/access/gin/ginarrayproc.c
@@ -84,7 +84,7 @@ ginqueryarrayextract(PG_FUNCTION_ARGS)
StrategyNumber strategy = PG_GETARG_UINT16(2);
/* bool **pmatch = (bool **) PG_GETARG_POINTER(3); */
- /* Pointer *extra_data = (Pointer *) PG_GETARG_POINTER(4); */
+ /* GinExtraPointer *extra_data = (GinExtraPointer *) PG_GETARG_POINTER(4); */
bool **nullFlags = (bool **) PG_GETARG_POINTER(5);
int32 *searchMode = (int32 *) PG_GETARG_POINTER(6);
int16 elmlen;
@@ -147,7 +147,7 @@ ginarrayconsistent(PG_FUNCTION_ARGS)
/* ArrayType *query = PG_GETARG_ARRAYTYPE_P(2); */
int32 nkeys = PG_GETARG_INT32(3);
- /* Pointer *extra_data = (Pointer *) PG_GETARG_POINTER(4); */
+ /* GinExtraPointer *extra_data = (GinExtraPointer *) PG_GETARG_POINTER(4); */
bool *recheck = (bool *) PG_GETARG_POINTER(5);
/* Datum *queryKeys = (Datum *) PG_GETARG_POINTER(6); */
@@ -231,7 +231,7 @@ ginarraytriconsistent(PG_FUNCTION_ARGS)
/* ArrayType *query = PG_GETARG_ARRAYTYPE_P(2); */
int32 nkeys = PG_GETARG_INT32(3);
- /* Pointer *extra_data = (Pointer *) PG_GETARG_POINTER(4); */
+ /* GinExtraPointer *extra_data = (GinExtraPointer *) PG_GETARG_POINTER(4); */
/* Datum *queryKeys = (Datum *) PG_GETARG_POINTER(5); */
bool *nullFlags = (bool *) PG_GETARG_POINTER(6);
GinTernaryValue res;
diff --git a/src/backend/access/gin/ginentrypage.c b/src/backend/access/gin/ginentrypage.c
index c0592367700..0764da28c57 100644
--- a/src/backend/access/gin/ginentrypage.c
+++ b/src/backend/access/gin/ginentrypage.c
@@ -43,7 +43,7 @@ static void entrySplitPage(GinBtree btree, Buffer origbuf,
IndexTuple
GinFormTuple(GinState *ginstate,
OffsetNumber attnum, Datum key, GinNullCategory category,
- Pointer data, Size dataSize, int nipd,
+ const void *data, Size dataSize, int nipd,
bool errorTooBig)
{
Datum datums[2];
@@ -136,7 +136,7 @@ GinFormTuple(GinState *ginstate,
*/
if (data)
{
- char *ptr = GinGetPosting(itup);
+ void *ptr = GinGetPosting(itup);
memcpy(ptr, data, dataSize);
}
@@ -162,7 +162,7 @@ ItemPointer
ginReadTuple(GinState *ginstate, OffsetNumber attnum, IndexTuple itup,
int *nitems)
{
- Pointer ptr = GinGetPosting(itup);
+ void * ptr = GinGetPosting(itup);
int nipd = GinGetNPosting(itup);
ItemPointer ipd;
int ndecoded;
diff --git a/src/backend/access/gin/ginscan.c b/src/backend/access/gin/ginscan.c
index 26081693383..932badfd648 100644
--- a/src/backend/access/gin/ginscan.c
+++ b/src/backend/access/gin/ginscan.c
@@ -57,7 +57,7 @@ static GinScanEntry
ginFillScanEntry(GinScanOpaque so, OffsetNumber attnum,
StrategyNumber strategy, int32 searchMode,
Datum queryKey, GinNullCategory queryCategory,
- bool isPartialMatch, Pointer extra_data)
+ bool isPartialMatch, GinExtraPointer extra_data)
{
GinState *ginstate = &so->ginstate;
GinScanEntry scanEntry;
@@ -160,7 +160,7 @@ ginFillScanKey(GinScanOpaque so, OffsetNumber attnum,
StrategyNumber strategy, int32 searchMode,
Datum query, uint32 nQueryValues,
Datum *queryValues, GinNullCategory *queryCategories,
- bool *partial_matches, Pointer *extra_data)
+ bool *partial_matches, GinExtraPointer *extra_data)
{
GinScanKey key = &(so->keys[so->nkeys++]);
GinState *ginstate = &so->ginstate;
@@ -206,7 +206,7 @@ ginFillScanKey(GinScanOpaque so, OffsetNumber attnum,
Datum queryKey;
GinNullCategory queryCategory;
bool isPartialMatch;
- Pointer this_extra;
+ GinExtraPointer this_extra;
queryKey = queryValues[i];
queryCategory = queryCategories[i];
@@ -302,7 +302,7 @@ ginNewScanKey(IndexScanDesc scan)
Datum *queryValues;
int32 nQueryValues = 0;
bool *partial_matches = NULL;
- Pointer *extra_data = NULL;
+ GinExtraPointer *extra_data = NULL;
bool *nullFlags = NULL;
GinNullCategory *categories;
int32 searchMode = GIN_SEARCH_MODE_DEFAULT;
diff --git a/src/backend/utils/adt/jsonb_gin.c b/src/backend/utils/adt/jsonb_gin.c
index 9b56248cf0b..16ddccaada6 100644
--- a/src/backend/utils/adt/jsonb_gin.c
+++ b/src/backend/utils/adt/jsonb_gin.c
@@ -746,7 +746,7 @@ emit_jsp_gin_entries(JsonPathGinNode *node, GinEntries *entries)
*/
static Datum *
extract_jsp_query(JsonPath *jp, StrategyNumber strat, bool pathOps,
- int32 *nentries, Pointer **extra_data)
+ int32 *nentries, GinExtraPointer **extra_data)
{
JsonPathGinContext cxt;
JsonPathItem root;
@@ -786,7 +786,7 @@ extract_jsp_query(JsonPath *jp, StrategyNumber strat, bool pathOps,
return NULL;
*extra_data = palloc0(sizeof(**extra_data) * entries.count);
- **extra_data = (Pointer) node;
+ **extra_data = (GinExtraPointer) node;
return entries.buf;
}
@@ -909,7 +909,7 @@ gin_extract_jsonb_query(PG_FUNCTION_ARGS)
strategy == JsonbJsonpathExistsStrategyNumber)
{
JsonPath *jp = PG_GETARG_JSONPATH_P(0);
- Pointer **extra_data = (Pointer **) PG_GETARG_POINTER(4);
+ GinExtraPointer **extra_data = (GinExtraPointer **) PG_GETARG_POINTER(4);
entries = extract_jsp_query(jp, strategy, false, nentries, extra_data);
@@ -934,7 +934,7 @@ gin_consistent_jsonb(PG_FUNCTION_ARGS)
/* Jsonb *query = PG_GETARG_JSONB_P(2); */
int32 nkeys = PG_GETARG_INT32(3);
- Pointer *extra_data = (Pointer *) PG_GETARG_POINTER(4);
+ GinExtraPointer *extra_data = (GinExtraPointer *) PG_GETARG_POINTER(4);
bool *recheck = (bool *) PG_GETARG_POINTER(5);
bool res = true;
int32 i;
@@ -1017,7 +1017,7 @@ gin_triconsistent_jsonb(PG_FUNCTION_ARGS)
/* Jsonb *query = PG_GETARG_JSONB_P(2); */
int32 nkeys = PG_GETARG_INT32(3);
- Pointer *extra_data = (Pointer *) PG_GETARG_POINTER(4);
+ GinExtraPointer *extra_data = (GinExtraPointer *) PG_GETARG_POINTER(4);
GinTernaryValue res = GIN_MAYBE;
int32 i;
@@ -1200,7 +1200,7 @@ gin_extract_jsonb_query_path(PG_FUNCTION_ARGS)
strategy == JsonbJsonpathExistsStrategyNumber)
{
JsonPath *jp = PG_GETARG_JSONPATH_P(0);
- Pointer **extra_data = (Pointer **) PG_GETARG_POINTER(4);
+ GinExtraPointer **extra_data = (GinExtraPointer **) PG_GETARG_POINTER(4);
entries = extract_jsp_query(jp, strategy, true, nentries, extra_data);
@@ -1224,7 +1224,7 @@ gin_consistent_jsonb_path(PG_FUNCTION_ARGS)
/* Jsonb *query = PG_GETARG_JSONB_P(2); */
int32 nkeys = PG_GETARG_INT32(3);
- Pointer *extra_data = (Pointer *) PG_GETARG_POINTER(4);
+ GinExtraPointer *extra_data = (GinExtraPointer *) PG_GETARG_POINTER(4);
bool *recheck = (bool *) PG_GETARG_POINTER(5);
bool res = true;
int32 i;
@@ -1276,7 +1276,7 @@ gin_triconsistent_jsonb_path(PG_FUNCTION_ARGS)
/* Jsonb *query = PG_GETARG_JSONB_P(2); */
int32 nkeys = PG_GETARG_INT32(3);
- Pointer *extra_data = (Pointer *) PG_GETARG_POINTER(4);
+ GinExtraPointer *extra_data = (GinExtraPointer *) PG_GETARG_POINTER(4);
GinTernaryValue res = GIN_MAYBE;
int32 i;
diff --git a/src/backend/utils/adt/selfuncs.c b/src/backend/utils/adt/selfuncs.c
index 540aa9628d7..90531323066 100644
--- a/src/backend/utils/adt/selfuncs.c
+++ b/src/backend/utils/adt/selfuncs.c
@@ -8249,7 +8249,7 @@ gincost_pattern(IndexOptInfo *index, int indexcol,
righttype;
int32 nentries = 0;
bool *partial_matches = NULL;
- Pointer *extra_data = NULL;
+ GinExtraPointer *extra_data = NULL;
bool *nullFlags = NULL;
int32 searchMode = GIN_SEARCH_MODE_DEFAULT;
int32 i;
diff --git a/src/backend/utils/adt/tsginidx.c b/src/backend/utils/adt/tsginidx.c
index 2712fd89df0..e943f4cd968 100644
--- a/src/backend/utils/adt/tsginidx.c
+++ b/src/backend/utils/adt/tsginidx.c
@@ -44,7 +44,7 @@ gin_cmp_prefix(PG_FUNCTION_ARGS)
#ifdef NOT_USED
StrategyNumber strategy = PG_GETARG_UINT16(2);
- Pointer extra_data = PG_GETARG_POINTER(3);
+ GinExtraPointer extra_data = PG_GETARG_POINTER(3);
#endif
int cmp;
@@ -98,7 +98,7 @@ gin_extract_tsquery(PG_FUNCTION_ARGS)
/* StrategyNumber strategy = PG_GETARG_UINT16(2); */
bool **ptr_partialmatch = (bool **) PG_GETARG_POINTER(3);
- Pointer **extra_data = (Pointer **) PG_GETARG_POINTER(4);
+ GinExtraPointer **extra_data = (GinExtraPointer **) PG_GETARG_POINTER(4);
/* bool **nullFlags = (bool **) PG_GETARG_POINTER(5); */
int32 *searchMode = (int32 *) PG_GETARG_POINTER(6);
@@ -141,7 +141,7 @@ gin_extract_tsquery(PG_FUNCTION_ARGS)
* same, entry's) number. Entry's number is used in check array in
* consistent method. We use the same map for each entry.
*/
- *extra_data = (Pointer *) palloc(sizeof(Pointer) * j);
+ *extra_data = (GinExtraPointer *) palloc(sizeof(GinExtraPointer) * j);
map_item_operand = (int *) palloc0(sizeof(int) * query->size);
/* Now rescan the VAL items and fill in the arrays */
@@ -157,7 +157,7 @@ gin_extract_tsquery(PG_FUNCTION_ARGS)
val->length);
entries[j] = PointerGetDatum(txt);
partialmatch[j] = val->prefix;
- (*extra_data)[j] = (Pointer) map_item_operand;
+ (*extra_data)[j] = (GinExtraPointer) map_item_operand;
map_item_operand[i] = j;
j++;
}
@@ -219,7 +219,7 @@ gin_tsquery_consistent(PG_FUNCTION_ARGS)
TSQuery query = PG_GETARG_TSQUERY(2);
/* int32 nkeys = PG_GETARG_INT32(3); */
- Pointer *extra_data = (Pointer *) PG_GETARG_POINTER(4);
+ GinExtraPointer *extra_data = (GinExtraPointer *) PG_GETARG_POINTER(4);
bool *recheck = (bool *) PG_GETARG_POINTER(5);
bool res = false;
@@ -268,7 +268,7 @@ gin_tsquery_triconsistent(PG_FUNCTION_ARGS)
TSQuery query = PG_GETARG_TSQUERY(2);
/* int32 nkeys = PG_GETARG_INT32(3); */
- Pointer *extra_data = (Pointer *) PG_GETARG_POINTER(4);
+ GinExtraPointer *extra_data = (GinExtraPointer *) PG_GETARG_POINTER(4);
GinTernaryValue res = GIN_FALSE;
if (query->size > 0)
diff --git a/src/include/access/gin.h b/src/include/access/gin.h
index 13ea91922ef..fd26166e229 100644
--- a/src/include/access/gin.h
+++ b/src/include/access/gin.h
@@ -70,6 +70,8 @@ typedef struct GinStatsData
*/
typedef char GinTernaryValue;
+typedef void *GinExtraPointer;
+
StaticAssertDecl(sizeof(GinTernaryValue) == sizeof(bool),
"sizes of GinTernaryValue and bool are not equal");
diff --git a/src/include/access/gin_private.h b/src/include/access/gin_private.h
index db19ffd9897..d4f3c524f1f 100644
--- a/src/include/access/gin_private.h
+++ b/src/include/access/gin_private.h
@@ -214,7 +214,7 @@ extern void ginInsertValue(GinBtree btree, GinBtreeStack *stack,
/* ginentrypage.c */
extern IndexTuple GinFormTuple(GinState *ginstate,
OffsetNumber attnum, Datum key, GinNullCategory category,
- Pointer data, Size dataSize, int nipd, bool errorTooBig);
+ const void *data, Size dataSize, int nipd, bool errorTooBig);
extern void ginPrepareEntryScan(GinBtree btree, OffsetNumber attnum,
Datum key, GinNullCategory category,
GinState *ginstate);
@@ -303,7 +303,7 @@ typedef struct GinScanKeyData
/* NB: these three arrays have only nuserentries elements! */
Datum *queryValues;
GinNullCategory *queryCategories;
- Pointer *extra_data;
+ GinExtraPointer *extra_data;
StrategyNumber strategy;
int32 searchMode;
OffsetNumber attnum;
@@ -341,7 +341,7 @@ typedef struct GinScanEntryData
Datum queryKey;
GinNullCategory queryCategory;
bool isPartialMatch;
- Pointer extra_data;
+ GinExtraPointer extra_data;
StrategyNumber strategy;
int32 searchMode;
OffsetNumber attnum;
diff --git a/src/include/access/ginblock.h b/src/include/access/ginblock.h
index 4c1681068db..e7365c220cf 100644
--- a/src/include/access/ginblock.h
+++ b/src/include/access/ginblock.h
@@ -236,7 +236,7 @@ typedef signed char GinNullCategory;
#define GIN_ITUP_COMPRESSED (1U << 31)
#define GinGetPostingOffset(itup) (GinItemPointerGetBlockNumber(&(itup)->t_tid) & (~GIN_ITUP_COMPRESSED))
#define GinSetPostingOffset(itup,n) ItemPointerSetBlockNumber(&(itup)->t_tid,(n)|GIN_ITUP_COMPRESSED)
-#define GinGetPosting(itup) ((Pointer) ((char*)(itup) + GinGetPostingOffset(itup)))
+#define GinGetPosting(itup) ((void *) ((char*)(itup) + GinGetPostingOffset(itup)))
#define GinItupIsCompressed(itup) ((GinItemPointerGetBlockNumber(&(itup)->t_tid) & GIN_ITUP_COMPRESSED) != 0)
/*
diff --git a/src/include/c.h b/src/include/c.h
index ccd2b654d45..7783d07c172 100644
--- a/src/include/c.h
+++ b/src/include/c.h
@@ -524,13 +524,6 @@ typedef void (*pg_funcptr_t) (void);
* ----------------------------------------------------------------
*/
-/*
- * Pointer
- * Variable holding address of any memory resident object.
- * (obsolescent; use void * or char *)
- */
-typedef void *Pointer;
-
/* Historical names for types in <stdint.h>. */
typedef int8_t int8;
typedef int16_t int16;
--
2.51.0
^ permalink raw reply [nested|flat] 23+ messages in thread
* Re: get rid of Pointer type, mostly
2025-11-24 10:20 get rid of Pointer type, mostly Peter Eisentraut <[email protected]>
2025-11-24 16:09 ` Re: get rid of Pointer type, mostly Tom Lane <[email protected]>
2025-11-24 16:19 ` Re: get rid of Pointer type, mostly Robert Haas <[email protected]>
2025-11-24 16:33 ` Re: get rid of Pointer type, mostly Tom Lane <[email protected]>
2025-11-24 17:32 ` Re: get rid of Pointer type, mostly Robert Haas <[email protected]>
2025-11-24 18:26 ` Re: get rid of Pointer type, mostly Tom Lane <[email protected]>
2025-11-24 19:32 ` Re: get rid of Pointer type, mostly Robert Haas <[email protected]>
2025-11-24 19:38 ` Re: get rid of Pointer type, mostly Tom Lane <[email protected]>
2025-11-24 19:52 ` Re: get rid of Pointer type, mostly Robert Haas <[email protected]>
2025-11-24 20:20 ` Re: get rid of Pointer type, mostly David Geier <[email protected]>
@ 2025-12-08 10:25 ` David Geier <[email protected]>
2025-12-08 10:53 ` Re: get rid of Pointer type, mostly Chao Li <[email protected]>
0 siblings, 1 reply; 23+ messages in thread
From: David Geier @ 2025-12-08 10:25 UTC (permalink / raw)
To: Robert Haas <[email protected]>; Tom Lane <[email protected]>; +Cc: Peter Eisentraut <[email protected]>; pgsql-hackers
Hi Peter,
> I went with your proposal of GinExtraPointer. See attached patch. It's
> based on the series of patches from Peter's initial mail. I've included
> the removal of the Pointer typedef in the same patch.
It seems to me that we reached agreement. Are you planning to still
apply these patches?
--
David Geier
^ permalink raw reply [nested|flat] 23+ messages in thread
* Re: get rid of Pointer type, mostly
2025-11-24 10:20 get rid of Pointer type, mostly Peter Eisentraut <[email protected]>
2025-11-24 16:09 ` Re: get rid of Pointer type, mostly Tom Lane <[email protected]>
2025-11-24 16:19 ` Re: get rid of Pointer type, mostly Robert Haas <[email protected]>
2025-11-24 16:33 ` Re: get rid of Pointer type, mostly Tom Lane <[email protected]>
2025-11-24 17:32 ` Re: get rid of Pointer type, mostly Robert Haas <[email protected]>
2025-11-24 18:26 ` Re: get rid of Pointer type, mostly Tom Lane <[email protected]>
2025-11-24 19:32 ` Re: get rid of Pointer type, mostly Robert Haas <[email protected]>
2025-11-24 19:38 ` Re: get rid of Pointer type, mostly Tom Lane <[email protected]>
2025-11-24 19:52 ` Re: get rid of Pointer type, mostly Robert Haas <[email protected]>
2025-11-24 20:20 ` Re: get rid of Pointer type, mostly David Geier <[email protected]>
2025-12-08 10:25 ` Re: get rid of Pointer type, mostly David Geier <[email protected]>
@ 2025-12-08 10:53 ` Chao Li <[email protected]>
2025-12-08 11:14 ` Re: get rid of Pointer type, mostly Peter Eisentraut <[email protected]>
2025-12-08 11:51 ` Re: get rid of Pointer type, mostly David Geier <[email protected]>
0 siblings, 2 replies; 23+ messages in thread
From: Chao Li @ 2025-12-08 10:53 UTC (permalink / raw)
To: David Geier <[email protected]>; +Cc: Robert Haas <[email protected]>; Tom Lane <[email protected]>; Peter Eisentraut <[email protected]>; pgsql-hackers
> On Dec 8, 2025, at 18:25, David Geier <[email protected]> wrote:
>
> Hi Peter,
>> I went with your proposal of GinExtraPointer. See attached patch. It's
>> based on the series of patches from Peter's initial mail. I've included
>> the removal of the Pointer typedef in the same patch.
>
> It seems to me that we reached agreement. Are you planning to still
> apply these patches?
>
Basically I am not against this patch, as 756a43689324b473ee07549a6eb7a53a203df5ad has done similar changes.
What I want to understand is that why do we delete Pointer and add GinExtraPointer?
```
-/*
- * Pointer
- * Variable holding address of any memory resident object.
- * (obsolescent; use void * or char *)
- */
-typedef void *Pointer;
```
And
```
+typedef void *GinExtraPointer;
```
They both are underlying “void *”. Are we expecting to improve code readability? More specific maybe?
Best regards,
--
Chao Li (Evan)
HighGo Software Co., Ltd.
https://www.highgo.com/
^ permalink raw reply [nested|flat] 23+ messages in thread
* Re: get rid of Pointer type, mostly
2025-11-24 10:20 get rid of Pointer type, mostly Peter Eisentraut <[email protected]>
2025-11-24 16:09 ` Re: get rid of Pointer type, mostly Tom Lane <[email protected]>
2025-11-24 16:19 ` Re: get rid of Pointer type, mostly Robert Haas <[email protected]>
2025-11-24 16:33 ` Re: get rid of Pointer type, mostly Tom Lane <[email protected]>
2025-11-24 17:32 ` Re: get rid of Pointer type, mostly Robert Haas <[email protected]>
2025-11-24 18:26 ` Re: get rid of Pointer type, mostly Tom Lane <[email protected]>
2025-11-24 19:32 ` Re: get rid of Pointer type, mostly Robert Haas <[email protected]>
2025-11-24 19:38 ` Re: get rid of Pointer type, mostly Tom Lane <[email protected]>
2025-11-24 19:52 ` Re: get rid of Pointer type, mostly Robert Haas <[email protected]>
2025-11-24 20:20 ` Re: get rid of Pointer type, mostly David Geier <[email protected]>
2025-12-08 10:25 ` Re: get rid of Pointer type, mostly David Geier <[email protected]>
2025-12-08 10:53 ` Re: get rid of Pointer type, mostly Chao Li <[email protected]>
@ 2025-12-08 11:14 ` Peter Eisentraut <[email protected]>
2025-12-08 11:27 ` Re: get rid of Pointer type, mostly David Geier <[email protected]>
1 sibling, 1 reply; 23+ messages in thread
From: Peter Eisentraut @ 2025-12-08 11:14 UTC (permalink / raw)
To: Chao Li <[email protected]>; David Geier <[email protected]>; +Cc: Robert Haas <[email protected]>; Tom Lane <[email protected]>; pgsql-hackers
On 08.12.25 11:53, Chao Li wrote:
>
>
>> On Dec 8, 2025, at 18:25, David Geier <[email protected]> wrote:
>>
>> Hi Peter,
>>> I went with your proposal of GinExtraPointer. See attached patch. It's
>>> based on the series of patches from Peter's initial mail. I've included
>>> the removal of the Pointer typedef in the same patch.
>>
>> It seems to me that we reached agreement. Are you planning to still
>> apply these patches?
>>
>
> Basically I am not against this patch, as 756a43689324b473ee07549a6eb7a53a203df5ad has done similar changes.
>
> What I want to understand is that why do we delete Pointer and add GinExtraPointer?
>
> ```
> -/*
> - * Pointer
> - * Variable holding address of any memory resident object.
> - * (obsolescent; use void * or char *)
> - */
> -typedef void *Pointer;
> ```
>
> And
> ```
> +typedef void *GinExtraPointer;
> ```
>
> They both are underlying “void *”. Are we expecting to improve code readability? More specific maybe?
I was planning to proceed with Dagfinn's patch set. Here is what is
currently remaining of the patch series. I haven't fully processed
everyone's comments in this thread, so they might not be reflected in
these patches.
There is some interference from the changes from palloc to
palloc_object/_array/etc., and I was also trying to figure out what to
do with the commented out code, hence the delay.
From 32d2ac63d30532096467a8579f4034a63718150a Mon Sep 17 00:00:00 2001
From: Peter Eisentraut <[email protected]>
Date: Mon, 24 Nov 2025 11:02:35 +0100
Subject: [PATCH v2 1/2] Remove some uses of the Pointer type
everywhere except GIN
Reviewed-by: Chao Li <[email protected]>
Reviewed-by: Bertrand Drouvot <[email protected]>
Discussion: https://www.postgresql.org/message-id/4154950a-47ae-4223-bd01-1235cc50e933%40eisentraut.org
---
contrib/amcheck/verify_heapam.c | 2 +-
src/backend/access/common/heaptuple.c | 2 +-
src/backend/access/common/toast_internals.c | 2 +-
src/backend/access/heap/heaptoast.c | 2 +-
src/backend/nodes/tidbitmap.c | 4 ++--
src/backend/replication/logical/reorderbuffer.c | 4 ++--
src/backend/utils/adt/rangetypes.c | 6 +++---
src/bin/initdb/initdb.c | 4 ++--
src/include/postgres.h | 4 ++--
9 files changed, 15 insertions(+), 15 deletions(-)
diff --git a/contrib/amcheck/verify_heapam.c b/contrib/amcheck/verify_heapam.c
index a090e18c697..7cf58db20ef 100644
--- a/contrib/amcheck/verify_heapam.c
+++ b/contrib/amcheck/verify_heapam.c
@@ -1557,7 +1557,7 @@ check_toast_tuple(HeapTuple toasttup, HeapCheckContext *ctx,
{
int32 chunk_seq;
int32 last_chunk_seq = (extsize - 1) / TOAST_MAX_CHUNK_SIZE;
- Pointer chunk;
+ void *chunk;
bool isnull;
int32 chunksize;
int32 expected_size;
diff --git a/src/backend/access/common/heaptuple.c b/src/backend/access/common/heaptuple.c
index 1967b047020..062aadacb12 100644
--- a/src/backend/access/common/heaptuple.c
+++ b/src/backend/access/common/heaptuple.c
@@ -321,7 +321,7 @@ fill_val(CompactAttribute *att,
else if (att->attlen == -1)
{
/* varlena */
- Pointer val = DatumGetPointer(datum);
+ void *val = DatumGetPointer(datum);
*infomask |= HEAP_HASVARWIDTH;
if (VARATT_IS_EXTERNAL(val))
diff --git a/src/backend/access/common/toast_internals.c b/src/backend/access/common/toast_internals.c
index 63b848473f8..ba6ef6f4e72 100644
--- a/src/backend/access/common/toast_internals.c
+++ b/src/backend/access/common/toast_internals.c
@@ -128,7 +128,7 @@ toast_save_datum(Relation rel, Datum value,
int32 chunk_seq = 0;
char *data_p;
int32 data_todo;
- Pointer dval = DatumGetPointer(value);
+ void *dval = DatumGetPointer(value);
int num_indexes;
int validIndex;
diff --git a/src/backend/access/heap/heaptoast.c b/src/backend/access/heap/heaptoast.c
index 60e765fbfce..a049d7c7e81 100644
--- a/src/backend/access/heap/heaptoast.c
+++ b/src/backend/access/heap/heaptoast.c
@@ -696,7 +696,7 @@ heap_fetch_toast_slice(Relation toastrel, Oid valueid, int32 attrsize,
while ((ttup = systable_getnext_ordered(toastscan, ForwardScanDirection)) != NULL)
{
int32 curchunk;
- Pointer chunk;
+ void *chunk;
bool isnull;
char *chunkdata;
int32 chunksize;
diff --git a/src/backend/nodes/tidbitmap.c b/src/backend/nodes/tidbitmap.c
index 1f83d0d55f5..0d11ec001c1 100644
--- a/src/backend/nodes/tidbitmap.c
+++ b/src/backend/nodes/tidbitmap.c
@@ -1546,11 +1546,11 @@ tbm_calculate_entries(Size maxbytes)
/*
* Estimate number of hashtable entries we can have within maxbytes. This
* estimates the hash cost as sizeof(PagetableEntry), which is good enough
- * for our purpose. Also count an extra Pointer per entry for the arrays
+ * for our purpose. Also count an extra pointer per entry for the arrays
* created during iteration readout.
*/
nbuckets = maxbytes /
- (sizeof(PagetableEntry) + sizeof(Pointer) + sizeof(Pointer));
+ (sizeof(PagetableEntry) + sizeof(void *) + sizeof(void *));
nbuckets = Min(nbuckets, INT_MAX - 1); /* safety limit */
nbuckets = Max(nbuckets, 16); /* sanity limit */
diff --git a/src/backend/replication/logical/reorderbuffer.c b/src/backend/replication/logical/reorderbuffer.c
index eb6a84554b7..a014ef72aca 100644
--- a/src/backend/replication/logical/reorderbuffer.c
+++ b/src/backend/replication/logical/reorderbuffer.c
@@ -5003,7 +5003,7 @@ ReorderBufferToastAppendChunk(ReorderBuffer *rb, ReorderBufferTXN *txn,
bool found;
int32 chunksize;
bool isnull;
- Pointer chunk;
+ void *chunk;
TupleDesc desc = RelationGetDescr(relation);
Oid chunk_id;
int32 chunk_seq;
@@ -5192,7 +5192,7 @@ ReorderBufferToastReplace(ReorderBuffer *rb, ReorderBufferTXN *txn,
bool cisnull;
ReorderBufferChange *cchange;
HeapTuple ctup;
- Pointer chunk;
+ void *chunk;
cchange = dlist_container(ReorderBufferChange, node, it.cur);
ctup = cchange->data.tp.newtuple;
diff --git a/src/backend/utils/adt/rangetypes.c b/src/backend/utils/adt/rangetypes.c
index d8e5130d642..b887f21f10e 100644
--- a/src/backend/utils/adt/rangetypes.c
+++ b/src/backend/utils/adt/rangetypes.c
@@ -1962,7 +1962,7 @@ range_serialize(TypeCacheEntry *typcache, RangeBound *lower, RangeBound *upper,
RangeType *range;
int cmp;
Size msize;
- Pointer ptr;
+ char *ptr;
int16 typlen;
bool typbyval;
char typalign;
@@ -2070,7 +2070,7 @@ range_serialize(TypeCacheEntry *typcache, RangeBound *lower, RangeBound *upper,
typstorage);
}
- *((char *) ptr) = flags;
+ *ptr = flags;
return range;
}
@@ -2953,7 +2953,7 @@ datum_write(char *ptr, Datum datum, bool typbyval, char typalign,
else if (typlen == -1)
{
/* varlena */
- Pointer val = DatumGetPointer(datum);
+ void *val = DatumGetPointer(datum);
if (VARATT_IS_EXTERNAL(val))
{
diff --git a/src/bin/initdb/initdb.c b/src/bin/initdb/initdb.c
index 92fe2f531f7..30fce0d5f37 100644
--- a/src/bin/initdb/initdb.c
+++ b/src/bin/initdb/initdb.c
@@ -1574,11 +1574,11 @@ bootstrap_template1(void)
sprintf(buf, "%d", NAMEDATALEN);
bki_lines = replace_token(bki_lines, "NAMEDATALEN", buf);
- sprintf(buf, "%d", (int) sizeof(Pointer));
+ sprintf(buf, "%d", (int) sizeof(void *));
bki_lines = replace_token(bki_lines, "SIZEOF_POINTER", buf);
bki_lines = replace_token(bki_lines, "ALIGNOF_POINTER",
- (sizeof(Pointer) == 4) ? "i" : "d");
+ (sizeof(void *) == 4) ? "i" : "d");
bki_lines = replace_token(bki_lines, "POSTGRES",
escape_quotes_bki(username));
diff --git a/src/include/postgres.h b/src/include/postgres.h
index 357cbd6fd96..5f1c6b0a79e 100644
--- a/src/include/postgres.h
+++ b/src/include/postgres.h
@@ -318,10 +318,10 @@ CommandIdGetDatum(CommandId X)
* DatumGetPointer
* Returns pointer value of a datum.
*/
-static inline Pointer
+static inline void *
DatumGetPointer(Datum X)
{
- return (Pointer) (uintptr_t) X;
+ return (void *) (uintptr_t) X;
}
/*
--
2.52.0
From 343c866e127f66cad692767bfff76bef6aa9f3b0 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Dagfinn=20Ilmari=20Manns=C3=A5ker?= <[email protected]>
Date: Mon, 24 Nov 2025 20:05:38 +0000
Subject: [PATCH v2 2/2] Convert remaning uses of Pointer to void *
Also remove redundant casts of the modified variables (except
PG_GETARG_POINTER()), and change a nearby char * to void *.
---
contrib/amcheck/verify_gin.c | 2 +-
contrib/btree_gin/btree_gin.c | 6 +++---
contrib/hstore/hstore_gin.c | 2 +-
contrib/intarray/_int_gin.c | 2 +-
contrib/pg_trgm/trgm_gin.c | 12 ++++++------
src/backend/access/gin/ginarrayproc.c | 6 +++---
src/backend/access/gin/ginentrypage.c | 6 +++---
src/backend/access/gin/ginscan.c | 8 ++++----
src/backend/utils/adt/jsonb_gin.c | 16 ++++++++--------
src/backend/utils/adt/selfuncs.c | 2 +-
src/backend/utils/adt/tsginidx.c | 16 ++++++++--------
src/include/access/gin_private.h | 6 +++---
src/include/access/ginblock.h | 2 +-
13 files changed, 43 insertions(+), 43 deletions(-)
diff --git a/contrib/amcheck/verify_gin.c b/contrib/amcheck/verify_gin.c
index 253da4b1f0b..2ec941661d6 100644
--- a/contrib/amcheck/verify_gin.c
+++ b/contrib/amcheck/verify_gin.c
@@ -98,7 +98,7 @@ gin_index_check(PG_FUNCTION_ARGS)
static ItemPointer
ginReadTupleWithoutState(IndexTuple itup, int *nitems)
{
- Pointer ptr = GinGetPosting(itup);
+ void *ptr = GinGetPosting(itup);
int nipd = GinGetNPosting(itup);
ItemPointer ipd;
int ndecoded;
diff --git a/contrib/btree_gin/btree_gin.c b/contrib/btree_gin/btree_gin.c
index afb8b3820af..363202a359e 100644
--- a/contrib/btree_gin/btree_gin.c
+++ b/contrib/btree_gin/btree_gin.c
@@ -74,7 +74,7 @@ gin_btree_extract_query(FunctionCallInfo fcinfo,
int32 *nentries = (int32 *) PG_GETARG_POINTER(1);
StrategyNumber strategy = PG_GETARG_UINT16(2);
bool **partialmatch = (bool **) PG_GETARG_POINTER(3);
- Pointer **extra_data = (Pointer **) PG_GETARG_POINTER(4);
+ void ***extra_data = (void ***) PG_GETARG_POINTER(4);
Datum *entries = palloc_object(Datum);
QueryInfo *data = palloc_object(QueryInfo);
bool *ptr_partialmatch = palloc_object(bool);
@@ -140,8 +140,8 @@ gin_btree_extract_query(FunctionCallInfo fcinfo,
data->orig_datum = datum;
data->entry_datum = entries[0];
data->typecmp = cmp_fns[rhs_code];
- *extra_data = palloc_object(Pointer);
- **extra_data = (Pointer) data;
+ *extra_data = palloc_object(void *);
+ **extra_data = data;
PG_RETURN_POINTER(entries);
}
diff --git a/contrib/hstore/hstore_gin.c b/contrib/hstore/hstore_gin.c
index 2e5fa115924..4b446f4d9e3 100644
--- a/contrib/hstore/hstore_gin.c
+++ b/contrib/hstore/hstore_gin.c
@@ -156,7 +156,7 @@ gin_consistent_hstore(PG_FUNCTION_ARGS)
/* HStore *query = PG_GETARG_HSTORE_P(2); */
int32 nkeys = PG_GETARG_INT32(3);
- /* Pointer *extra_data = (Pointer *) PG_GETARG_POINTER(4); */
+ /* void **extra_data = (void **) PG_GETARG_POINTER(4); */
bool *recheck = (bool *) PG_GETARG_POINTER(5);
bool res = true;
int32 i;
diff --git a/contrib/intarray/_int_gin.c b/contrib/intarray/_int_gin.c
index c60616c3f77..dffdd3fd681 100644
--- a/contrib/intarray/_int_gin.c
+++ b/contrib/intarray/_int_gin.c
@@ -113,7 +113,7 @@ ginint4_consistent(PG_FUNCTION_ARGS)
StrategyNumber strategy = PG_GETARG_UINT16(1);
int32 nkeys = PG_GETARG_INT32(3);
- /* Pointer *extra_data = (Pointer *) PG_GETARG_POINTER(4); */
+ /* void **extra_data = (void **) PG_GETARG_POINTER(4); */
bool *recheck = (bool *) PG_GETARG_POINTER(5);
bool res = false;
int32 i;
diff --git a/contrib/pg_trgm/trgm_gin.c b/contrib/pg_trgm/trgm_gin.c
index 66ff6adde99..8eaf5d58820 100644
--- a/contrib/pg_trgm/trgm_gin.c
+++ b/contrib/pg_trgm/trgm_gin.c
@@ -74,7 +74,7 @@ gin_extract_query_trgm(PG_FUNCTION_ARGS)
StrategyNumber strategy = PG_GETARG_UINT16(2);
/* bool **pmatch = (bool **) PG_GETARG_POINTER(3); */
- Pointer **extra_data = (Pointer **) PG_GETARG_POINTER(4);
+ void ***extra_data = (void ***) PG_GETARG_POINTER(4);
/* bool **nullFlags = (bool **) PG_GETARG_POINTER(5); */
int32 *searchMode = (int32 *) PG_GETARG_POINTER(6);
@@ -120,12 +120,12 @@ gin_extract_query_trgm(PG_FUNCTION_ARGS)
/*
* Successful regex processing: store NFA-like graph as
* extra_data. GIN API requires an array of nentries
- * Pointers, but we just put the same value in each element.
+ * pointers, but we just put the same value in each element.
*/
trglen = ARRNELEM(trg);
- *extra_data = palloc_array(Pointer, trglen);
+ *extra_data = palloc_array(void *, trglen);
for (i = 0; i < trglen; i++)
- (*extra_data)[i] = (Pointer) graph;
+ (*extra_data)[i] = graph;
}
else
{
@@ -174,7 +174,7 @@ gin_trgm_consistent(PG_FUNCTION_ARGS)
/* text *query = PG_GETARG_TEXT_PP(2); */
int32 nkeys = PG_GETARG_INT32(3);
- Pointer *extra_data = (Pointer *) PG_GETARG_POINTER(4);
+ void **extra_data = (void **) PG_GETARG_POINTER(4);
bool *recheck = (bool *) PG_GETARG_POINTER(5);
bool res;
int32 i,
@@ -272,7 +272,7 @@ gin_trgm_triconsistent(PG_FUNCTION_ARGS)
/* text *query = PG_GETARG_TEXT_PP(2); */
int32 nkeys = PG_GETARG_INT32(3);
- Pointer *extra_data = (Pointer *) PG_GETARG_POINTER(4);
+ void **extra_data = (void **) PG_GETARG_POINTER(4);
GinTernaryValue res = GIN_MAYBE;
int32 i,
ntrue;
diff --git a/src/backend/access/gin/ginarrayproc.c b/src/backend/access/gin/ginarrayproc.c
index 1f821323eb0..eaeb8feb3a9 100644
--- a/src/backend/access/gin/ginarrayproc.c
+++ b/src/backend/access/gin/ginarrayproc.c
@@ -84,7 +84,7 @@ ginqueryarrayextract(PG_FUNCTION_ARGS)
StrategyNumber strategy = PG_GETARG_UINT16(2);
/* bool **pmatch = (bool **) PG_GETARG_POINTER(3); */
- /* Pointer *extra_data = (Pointer *) PG_GETARG_POINTER(4); */
+ /* void **extra_data = (void **) PG_GETARG_POINTER(4); */
bool **nullFlags = (bool **) PG_GETARG_POINTER(5);
int32 *searchMode = (int32 *) PG_GETARG_POINTER(6);
int16 elmlen;
@@ -147,7 +147,7 @@ ginarrayconsistent(PG_FUNCTION_ARGS)
/* ArrayType *query = PG_GETARG_ARRAYTYPE_P(2); */
int32 nkeys = PG_GETARG_INT32(3);
- /* Pointer *extra_data = (Pointer *) PG_GETARG_POINTER(4); */
+ /* void **extra_data = (void **) PG_GETARG_POINTER(4); */
bool *recheck = (bool *) PG_GETARG_POINTER(5);
/* Datum *queryKeys = (Datum *) PG_GETARG_POINTER(6); */
@@ -231,7 +231,7 @@ ginarraytriconsistent(PG_FUNCTION_ARGS)
/* ArrayType *query = PG_GETARG_ARRAYTYPE_P(2); */
int32 nkeys = PG_GETARG_INT32(3);
- /* Pointer *extra_data = (Pointer *) PG_GETARG_POINTER(4); */
+ /* void **extra_data = (void **) PG_GETARG_POINTER(4); */
/* Datum *queryKeys = (Datum *) PG_GETARG_POINTER(5); */
bool *nullFlags = (bool *) PG_GETARG_POINTER(6);
GinTernaryValue res;
diff --git a/src/backend/access/gin/ginentrypage.c b/src/backend/access/gin/ginentrypage.c
index 94f49d72a98..6be7b3ffcd1 100644
--- a/src/backend/access/gin/ginentrypage.c
+++ b/src/backend/access/gin/ginentrypage.c
@@ -43,7 +43,7 @@ static void entrySplitPage(GinBtree btree, Buffer origbuf,
IndexTuple
GinFormTuple(GinState *ginstate,
OffsetNumber attnum, Datum key, GinNullCategory category,
- Pointer data, Size dataSize, int nipd,
+ void *data, Size dataSize, int nipd,
bool errorTooBig)
{
Datum datums[2];
@@ -136,7 +136,7 @@ GinFormTuple(GinState *ginstate,
*/
if (data)
{
- char *ptr = GinGetPosting(itup);
+ void *ptr = GinGetPosting(itup);
memcpy(ptr, data, dataSize);
}
@@ -162,7 +162,7 @@ ItemPointer
ginReadTuple(GinState *ginstate, OffsetNumber attnum, IndexTuple itup,
int *nitems)
{
- Pointer ptr = GinGetPosting(itup);
+ void *ptr = GinGetPosting(itup);
int nipd = GinGetNPosting(itup);
ItemPointer ipd;
int ndecoded;
diff --git a/src/backend/access/gin/ginscan.c b/src/backend/access/gin/ginscan.c
index 26081693383..5aec1943ece 100644
--- a/src/backend/access/gin/ginscan.c
+++ b/src/backend/access/gin/ginscan.c
@@ -57,7 +57,7 @@ static GinScanEntry
ginFillScanEntry(GinScanOpaque so, OffsetNumber attnum,
StrategyNumber strategy, int32 searchMode,
Datum queryKey, GinNullCategory queryCategory,
- bool isPartialMatch, Pointer extra_data)
+ bool isPartialMatch, void *extra_data)
{
GinState *ginstate = &so->ginstate;
GinScanEntry scanEntry;
@@ -160,7 +160,7 @@ ginFillScanKey(GinScanOpaque so, OffsetNumber attnum,
StrategyNumber strategy, int32 searchMode,
Datum query, uint32 nQueryValues,
Datum *queryValues, GinNullCategory *queryCategories,
- bool *partial_matches, Pointer *extra_data)
+ bool *partial_matches, void **extra_data)
{
GinScanKey key = &(so->keys[so->nkeys++]);
GinState *ginstate = &so->ginstate;
@@ -206,7 +206,7 @@ ginFillScanKey(GinScanOpaque so, OffsetNumber attnum,
Datum queryKey;
GinNullCategory queryCategory;
bool isPartialMatch;
- Pointer this_extra;
+ void *this_extra;
queryKey = queryValues[i];
queryCategory = queryCategories[i];
@@ -302,7 +302,7 @@ ginNewScanKey(IndexScanDesc scan)
Datum *queryValues;
int32 nQueryValues = 0;
bool *partial_matches = NULL;
- Pointer *extra_data = NULL;
+ void **extra_data = NULL;
bool *nullFlags = NULL;
GinNullCategory *categories;
int32 searchMode = GIN_SEARCH_MODE_DEFAULT;
diff --git a/src/backend/utils/adt/jsonb_gin.c b/src/backend/utils/adt/jsonb_gin.c
index a6d3332bb42..670e1520e8e 100644
--- a/src/backend/utils/adt/jsonb_gin.c
+++ b/src/backend/utils/adt/jsonb_gin.c
@@ -746,7 +746,7 @@ emit_jsp_gin_entries(JsonPathGinNode *node, GinEntries *entries)
*/
static Datum *
extract_jsp_query(JsonPath *jp, StrategyNumber strat, bool pathOps,
- int32 *nentries, Pointer **extra_data)
+ int32 *nentries, void ***extra_data)
{
JsonPathGinContext cxt;
JsonPathItem root;
@@ -786,7 +786,7 @@ extract_jsp_query(JsonPath *jp, StrategyNumber strat, bool pathOps,
return NULL;
*extra_data = palloc0(sizeof(**extra_data) * entries.count);
- **extra_data = (Pointer) node;
+ **extra_data = node;
return entries.buf;
}
@@ -909,7 +909,7 @@ gin_extract_jsonb_query(PG_FUNCTION_ARGS)
strategy == JsonbJsonpathExistsStrategyNumber)
{
JsonPath *jp = PG_GETARG_JSONPATH_P(0);
- Pointer **extra_data = (Pointer **) PG_GETARG_POINTER(4);
+ void ***extra_data = (void ***) PG_GETARG_POINTER(4);
entries = extract_jsp_query(jp, strategy, false, nentries, extra_data);
@@ -934,7 +934,7 @@ gin_consistent_jsonb(PG_FUNCTION_ARGS)
/* Jsonb *query = PG_GETARG_JSONB_P(2); */
int32 nkeys = PG_GETARG_INT32(3);
- Pointer *extra_data = (Pointer *) PG_GETARG_POINTER(4);
+ void **extra_data = (void **) PG_GETARG_POINTER(4);
bool *recheck = (bool *) PG_GETARG_POINTER(5);
bool res = true;
int32 i;
@@ -1016,7 +1016,7 @@ gin_triconsistent_jsonb(PG_FUNCTION_ARGS)
/* Jsonb *query = PG_GETARG_JSONB_P(2); */
int32 nkeys = PG_GETARG_INT32(3);
- Pointer *extra_data = (Pointer *) PG_GETARG_POINTER(4);
+ void **extra_data = (void **) PG_GETARG_POINTER(4);
GinTernaryValue res = GIN_MAYBE;
int32 i;
@@ -1198,7 +1198,7 @@ gin_extract_jsonb_query_path(PG_FUNCTION_ARGS)
strategy == JsonbJsonpathExistsStrategyNumber)
{
JsonPath *jp = PG_GETARG_JSONPATH_P(0);
- Pointer **extra_data = (Pointer **) PG_GETARG_POINTER(4);
+ void ***extra_data = (void ***) PG_GETARG_POINTER(4);
entries = extract_jsp_query(jp, strategy, true, nentries, extra_data);
@@ -1222,7 +1222,7 @@ gin_consistent_jsonb_path(PG_FUNCTION_ARGS)
/* Jsonb *query = PG_GETARG_JSONB_P(2); */
int32 nkeys = PG_GETARG_INT32(3);
- Pointer *extra_data = (Pointer *) PG_GETARG_POINTER(4);
+ void **extra_data = (void **) PG_GETARG_POINTER(4);
bool *recheck = (bool *) PG_GETARG_POINTER(5);
bool res = true;
int32 i;
@@ -1273,7 +1273,7 @@ gin_triconsistent_jsonb_path(PG_FUNCTION_ARGS)
/* Jsonb *query = PG_GETARG_JSONB_P(2); */
int32 nkeys = PG_GETARG_INT32(3);
- Pointer *extra_data = (Pointer *) PG_GETARG_POINTER(4);
+ void **extra_data = (void **) PG_GETARG_POINTER(4);
GinTernaryValue res = GIN_MAYBE;
int32 i;
diff --git a/src/backend/utils/adt/selfuncs.c b/src/backend/utils/adt/selfuncs.c
index 540aa9628d7..f97d50641cf 100644
--- a/src/backend/utils/adt/selfuncs.c
+++ b/src/backend/utils/adt/selfuncs.c
@@ -8249,7 +8249,7 @@ gincost_pattern(IndexOptInfo *index, int indexcol,
righttype;
int32 nentries = 0;
bool *partial_matches = NULL;
- Pointer *extra_data = NULL;
+ void **extra_data = NULL;
bool *nullFlags = NULL;
int32 searchMode = GIN_SEARCH_MODE_DEFAULT;
int32 i;
diff --git a/src/backend/utils/adt/tsginidx.c b/src/backend/utils/adt/tsginidx.c
index 2712fd89df0..4fe01d5a005 100644
--- a/src/backend/utils/adt/tsginidx.c
+++ b/src/backend/utils/adt/tsginidx.c
@@ -44,7 +44,7 @@ gin_cmp_prefix(PG_FUNCTION_ARGS)
#ifdef NOT_USED
StrategyNumber strategy = PG_GETARG_UINT16(2);
- Pointer extra_data = PG_GETARG_POINTER(3);
+ void *extra_data = (void *) PG_GETARG_POINTER(3);
#endif
int cmp;
@@ -98,7 +98,7 @@ gin_extract_tsquery(PG_FUNCTION_ARGS)
/* StrategyNumber strategy = PG_GETARG_UINT16(2); */
bool **ptr_partialmatch = (bool **) PG_GETARG_POINTER(3);
- Pointer **extra_data = (Pointer **) PG_GETARG_POINTER(4);
+ void ***extra_data = (void ***) PG_GETARG_POINTER(4);
/* bool **nullFlags = (bool **) PG_GETARG_POINTER(5); */
int32 *searchMode = (int32 *) PG_GETARG_POINTER(6);
@@ -141,7 +141,7 @@ gin_extract_tsquery(PG_FUNCTION_ARGS)
* same, entry's) number. Entry's number is used in check array in
* consistent method. We use the same map for each entry.
*/
- *extra_data = (Pointer *) palloc(sizeof(Pointer) * j);
+ *extra_data = palloc(sizeof(void *) * j);
map_item_operand = (int *) palloc0(sizeof(int) * query->size);
/* Now rescan the VAL items and fill in the arrays */
@@ -157,7 +157,7 @@ gin_extract_tsquery(PG_FUNCTION_ARGS)
val->length);
entries[j] = PointerGetDatum(txt);
partialmatch[j] = val->prefix;
- (*extra_data)[j] = (Pointer) map_item_operand;
+ (*extra_data)[j] = map_item_operand;
map_item_operand[i] = j;
j++;
}
@@ -219,7 +219,7 @@ gin_tsquery_consistent(PG_FUNCTION_ARGS)
TSQuery query = PG_GETARG_TSQUERY(2);
/* int32 nkeys = PG_GETARG_INT32(3); */
- Pointer *extra_data = (Pointer *) PG_GETARG_POINTER(4);
+ void **extra_data = (void **) PG_GETARG_POINTER(4);
bool *recheck = (bool *) PG_GETARG_POINTER(5);
bool res = false;
@@ -236,7 +236,7 @@ gin_tsquery_consistent(PG_FUNCTION_ARGS)
*/
gcv.first_item = GETQUERY(query);
gcv.check = (GinTernaryValue *) check;
- gcv.map_item_operand = (int *) (extra_data[0]);
+ gcv.map_item_operand = extra_data[0];
switch (TS_execute_ternary(GETQUERY(query),
&gcv,
@@ -268,7 +268,7 @@ gin_tsquery_triconsistent(PG_FUNCTION_ARGS)
TSQuery query = PG_GETARG_TSQUERY(2);
/* int32 nkeys = PG_GETARG_INT32(3); */
- Pointer *extra_data = (Pointer *) PG_GETARG_POINTER(4);
+ void **extra_data = (void **) PG_GETARG_POINTER(4);
GinTernaryValue res = GIN_FALSE;
if (query->size > 0)
@@ -281,7 +281,7 @@ gin_tsquery_triconsistent(PG_FUNCTION_ARGS)
*/
gcv.first_item = GETQUERY(query);
gcv.check = check;
- gcv.map_item_operand = (int *) (extra_data[0]);
+ gcv.map_item_operand = extra_data[0];
res = TS_execute_ternary(GETQUERY(query),
&gcv,
diff --git a/src/include/access/gin_private.h b/src/include/access/gin_private.h
index db19ffd9897..ff42c41847c 100644
--- a/src/include/access/gin_private.h
+++ b/src/include/access/gin_private.h
@@ -214,7 +214,7 @@ extern void ginInsertValue(GinBtree btree, GinBtreeStack *stack,
/* ginentrypage.c */
extern IndexTuple GinFormTuple(GinState *ginstate,
OffsetNumber attnum, Datum key, GinNullCategory category,
- Pointer data, Size dataSize, int nipd, bool errorTooBig);
+ void *data, Size dataSize, int nipd, bool errorTooBig);
extern void ginPrepareEntryScan(GinBtree btree, OffsetNumber attnum,
Datum key, GinNullCategory category,
GinState *ginstate);
@@ -303,7 +303,7 @@ typedef struct GinScanKeyData
/* NB: these three arrays have only nuserentries elements! */
Datum *queryValues;
GinNullCategory *queryCategories;
- Pointer *extra_data;
+ void **extra_data;
StrategyNumber strategy;
int32 searchMode;
OffsetNumber attnum;
@@ -341,7 +341,7 @@ typedef struct GinScanEntryData
Datum queryKey;
GinNullCategory queryCategory;
bool isPartialMatch;
- Pointer extra_data;
+ void *extra_data;
StrategyNumber strategy;
int32 searchMode;
OffsetNumber attnum;
diff --git a/src/include/access/ginblock.h b/src/include/access/ginblock.h
index 4c1681068db..e7365c220cf 100644
--- a/src/include/access/ginblock.h
+++ b/src/include/access/ginblock.h
@@ -236,7 +236,7 @@ typedef signed char GinNullCategory;
#define GIN_ITUP_COMPRESSED (1U << 31)
#define GinGetPostingOffset(itup) (GinItemPointerGetBlockNumber(&(itup)->t_tid) & (~GIN_ITUP_COMPRESSED))
#define GinSetPostingOffset(itup,n) ItemPointerSetBlockNumber(&(itup)->t_tid,(n)|GIN_ITUP_COMPRESSED)
-#define GinGetPosting(itup) ((Pointer) ((char*)(itup) + GinGetPostingOffset(itup)))
+#define GinGetPosting(itup) ((void *) ((char*)(itup) + GinGetPostingOffset(itup)))
#define GinItupIsCompressed(itup) ((GinItemPointerGetBlockNumber(&(itup)->t_tid) & GIN_ITUP_COMPRESSED) != 0)
/*
--
2.52.0
Attachments:
[text/plain] v2-0001-Remove-some-uses-of-the-Pointer-type.patch (6.5K, ../../[email protected]/2-v2-0001-Remove-some-uses-of-the-Pointer-type.patch)
download | inline diff:
From 32d2ac63d30532096467a8579f4034a63718150a Mon Sep 17 00:00:00 2001
From: Peter Eisentraut <[email protected]>
Date: Mon, 24 Nov 2025 11:02:35 +0100
Subject: [PATCH v2 1/2] Remove some uses of the Pointer type
everywhere except GIN
Reviewed-by: Chao Li <[email protected]>
Reviewed-by: Bertrand Drouvot <[email protected]>
Discussion: https://www.postgresql.org/message-id/4154950a-47ae-4223-bd01-1235cc50e933%40eisentraut.org
---
contrib/amcheck/verify_heapam.c | 2 +-
src/backend/access/common/heaptuple.c | 2 +-
src/backend/access/common/toast_internals.c | 2 +-
src/backend/access/heap/heaptoast.c | 2 +-
src/backend/nodes/tidbitmap.c | 4 ++--
src/backend/replication/logical/reorderbuffer.c | 4 ++--
src/backend/utils/adt/rangetypes.c | 6 +++---
src/bin/initdb/initdb.c | 4 ++--
src/include/postgres.h | 4 ++--
9 files changed, 15 insertions(+), 15 deletions(-)
diff --git a/contrib/amcheck/verify_heapam.c b/contrib/amcheck/verify_heapam.c
index a090e18c697..7cf58db20ef 100644
--- a/contrib/amcheck/verify_heapam.c
+++ b/contrib/amcheck/verify_heapam.c
@@ -1557,7 +1557,7 @@ check_toast_tuple(HeapTuple toasttup, HeapCheckContext *ctx,
{
int32 chunk_seq;
int32 last_chunk_seq = (extsize - 1) / TOAST_MAX_CHUNK_SIZE;
- Pointer chunk;
+ void *chunk;
bool isnull;
int32 chunksize;
int32 expected_size;
diff --git a/src/backend/access/common/heaptuple.c b/src/backend/access/common/heaptuple.c
index 1967b047020..062aadacb12 100644
--- a/src/backend/access/common/heaptuple.c
+++ b/src/backend/access/common/heaptuple.c
@@ -321,7 +321,7 @@ fill_val(CompactAttribute *att,
else if (att->attlen == -1)
{
/* varlena */
- Pointer val = DatumGetPointer(datum);
+ void *val = DatumGetPointer(datum);
*infomask |= HEAP_HASVARWIDTH;
if (VARATT_IS_EXTERNAL(val))
diff --git a/src/backend/access/common/toast_internals.c b/src/backend/access/common/toast_internals.c
index 63b848473f8..ba6ef6f4e72 100644
--- a/src/backend/access/common/toast_internals.c
+++ b/src/backend/access/common/toast_internals.c
@@ -128,7 +128,7 @@ toast_save_datum(Relation rel, Datum value,
int32 chunk_seq = 0;
char *data_p;
int32 data_todo;
- Pointer dval = DatumGetPointer(value);
+ void *dval = DatumGetPointer(value);
int num_indexes;
int validIndex;
diff --git a/src/backend/access/heap/heaptoast.c b/src/backend/access/heap/heaptoast.c
index 60e765fbfce..a049d7c7e81 100644
--- a/src/backend/access/heap/heaptoast.c
+++ b/src/backend/access/heap/heaptoast.c
@@ -696,7 +696,7 @@ heap_fetch_toast_slice(Relation toastrel, Oid valueid, int32 attrsize,
while ((ttup = systable_getnext_ordered(toastscan, ForwardScanDirection)) != NULL)
{
int32 curchunk;
- Pointer chunk;
+ void *chunk;
bool isnull;
char *chunkdata;
int32 chunksize;
diff --git a/src/backend/nodes/tidbitmap.c b/src/backend/nodes/tidbitmap.c
index 1f83d0d55f5..0d11ec001c1 100644
--- a/src/backend/nodes/tidbitmap.c
+++ b/src/backend/nodes/tidbitmap.c
@@ -1546,11 +1546,11 @@ tbm_calculate_entries(Size maxbytes)
/*
* Estimate number of hashtable entries we can have within maxbytes. This
* estimates the hash cost as sizeof(PagetableEntry), which is good enough
- * for our purpose. Also count an extra Pointer per entry for the arrays
+ * for our purpose. Also count an extra pointer per entry for the arrays
* created during iteration readout.
*/
nbuckets = maxbytes /
- (sizeof(PagetableEntry) + sizeof(Pointer) + sizeof(Pointer));
+ (sizeof(PagetableEntry) + sizeof(void *) + sizeof(void *));
nbuckets = Min(nbuckets, INT_MAX - 1); /* safety limit */
nbuckets = Max(nbuckets, 16); /* sanity limit */
diff --git a/src/backend/replication/logical/reorderbuffer.c b/src/backend/replication/logical/reorderbuffer.c
index eb6a84554b7..a014ef72aca 100644
--- a/src/backend/replication/logical/reorderbuffer.c
+++ b/src/backend/replication/logical/reorderbuffer.c
@@ -5003,7 +5003,7 @@ ReorderBufferToastAppendChunk(ReorderBuffer *rb, ReorderBufferTXN *txn,
bool found;
int32 chunksize;
bool isnull;
- Pointer chunk;
+ void *chunk;
TupleDesc desc = RelationGetDescr(relation);
Oid chunk_id;
int32 chunk_seq;
@@ -5192,7 +5192,7 @@ ReorderBufferToastReplace(ReorderBuffer *rb, ReorderBufferTXN *txn,
bool cisnull;
ReorderBufferChange *cchange;
HeapTuple ctup;
- Pointer chunk;
+ void *chunk;
cchange = dlist_container(ReorderBufferChange, node, it.cur);
ctup = cchange->data.tp.newtuple;
diff --git a/src/backend/utils/adt/rangetypes.c b/src/backend/utils/adt/rangetypes.c
index d8e5130d642..b887f21f10e 100644
--- a/src/backend/utils/adt/rangetypes.c
+++ b/src/backend/utils/adt/rangetypes.c
@@ -1962,7 +1962,7 @@ range_serialize(TypeCacheEntry *typcache, RangeBound *lower, RangeBound *upper,
RangeType *range;
int cmp;
Size msize;
- Pointer ptr;
+ char *ptr;
int16 typlen;
bool typbyval;
char typalign;
@@ -2070,7 +2070,7 @@ range_serialize(TypeCacheEntry *typcache, RangeBound *lower, RangeBound *upper,
typstorage);
}
- *((char *) ptr) = flags;
+ *ptr = flags;
return range;
}
@@ -2953,7 +2953,7 @@ datum_write(char *ptr, Datum datum, bool typbyval, char typalign,
else if (typlen == -1)
{
/* varlena */
- Pointer val = DatumGetPointer(datum);
+ void *val = DatumGetPointer(datum);
if (VARATT_IS_EXTERNAL(val))
{
diff --git a/src/bin/initdb/initdb.c b/src/bin/initdb/initdb.c
index 92fe2f531f7..30fce0d5f37 100644
--- a/src/bin/initdb/initdb.c
+++ b/src/bin/initdb/initdb.c
@@ -1574,11 +1574,11 @@ bootstrap_template1(void)
sprintf(buf, "%d", NAMEDATALEN);
bki_lines = replace_token(bki_lines, "NAMEDATALEN", buf);
- sprintf(buf, "%d", (int) sizeof(Pointer));
+ sprintf(buf, "%d", (int) sizeof(void *));
bki_lines = replace_token(bki_lines, "SIZEOF_POINTER", buf);
bki_lines = replace_token(bki_lines, "ALIGNOF_POINTER",
- (sizeof(Pointer) == 4) ? "i" : "d");
+ (sizeof(void *) == 4) ? "i" : "d");
bki_lines = replace_token(bki_lines, "POSTGRES",
escape_quotes_bki(username));
diff --git a/src/include/postgres.h b/src/include/postgres.h
index 357cbd6fd96..5f1c6b0a79e 100644
--- a/src/include/postgres.h
+++ b/src/include/postgres.h
@@ -318,10 +318,10 @@ CommandIdGetDatum(CommandId X)
* DatumGetPointer
* Returns pointer value of a datum.
*/
-static inline Pointer
+static inline void *
DatumGetPointer(Datum X)
{
- return (Pointer) (uintptr_t) X;
+ return (void *) (uintptr_t) X;
}
/*
--
2.52.0
[text/plain] v2-0002-Convert-remaning-uses-of-Pointer-to-void.patch (17.3K, ../../[email protected]/3-v2-0002-Convert-remaning-uses-of-Pointer-to-void.patch)
download | inline diff:
From 343c866e127f66cad692767bfff76bef6aa9f3b0 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Dagfinn=20Ilmari=20Manns=C3=A5ker?= <[email protected]>
Date: Mon, 24 Nov 2025 20:05:38 +0000
Subject: [PATCH v2 2/2] Convert remaning uses of Pointer to void *
Also remove redundant casts of the modified variables (except
PG_GETARG_POINTER()), and change a nearby char * to void *.
---
contrib/amcheck/verify_gin.c | 2 +-
contrib/btree_gin/btree_gin.c | 6 +++---
contrib/hstore/hstore_gin.c | 2 +-
contrib/intarray/_int_gin.c | 2 +-
contrib/pg_trgm/trgm_gin.c | 12 ++++++------
src/backend/access/gin/ginarrayproc.c | 6 +++---
src/backend/access/gin/ginentrypage.c | 6 +++---
src/backend/access/gin/ginscan.c | 8 ++++----
src/backend/utils/adt/jsonb_gin.c | 16 ++++++++--------
src/backend/utils/adt/selfuncs.c | 2 +-
src/backend/utils/adt/tsginidx.c | 16 ++++++++--------
src/include/access/gin_private.h | 6 +++---
src/include/access/ginblock.h | 2 +-
13 files changed, 43 insertions(+), 43 deletions(-)
diff --git a/contrib/amcheck/verify_gin.c b/contrib/amcheck/verify_gin.c
index 253da4b1f0b..2ec941661d6 100644
--- a/contrib/amcheck/verify_gin.c
+++ b/contrib/amcheck/verify_gin.c
@@ -98,7 +98,7 @@ gin_index_check(PG_FUNCTION_ARGS)
static ItemPointer
ginReadTupleWithoutState(IndexTuple itup, int *nitems)
{
- Pointer ptr = GinGetPosting(itup);
+ void *ptr = GinGetPosting(itup);
int nipd = GinGetNPosting(itup);
ItemPointer ipd;
int ndecoded;
diff --git a/contrib/btree_gin/btree_gin.c b/contrib/btree_gin/btree_gin.c
index afb8b3820af..363202a359e 100644
--- a/contrib/btree_gin/btree_gin.c
+++ b/contrib/btree_gin/btree_gin.c
@@ -74,7 +74,7 @@ gin_btree_extract_query(FunctionCallInfo fcinfo,
int32 *nentries = (int32 *) PG_GETARG_POINTER(1);
StrategyNumber strategy = PG_GETARG_UINT16(2);
bool **partialmatch = (bool **) PG_GETARG_POINTER(3);
- Pointer **extra_data = (Pointer **) PG_GETARG_POINTER(4);
+ void ***extra_data = (void ***) PG_GETARG_POINTER(4);
Datum *entries = palloc_object(Datum);
QueryInfo *data = palloc_object(QueryInfo);
bool *ptr_partialmatch = palloc_object(bool);
@@ -140,8 +140,8 @@ gin_btree_extract_query(FunctionCallInfo fcinfo,
data->orig_datum = datum;
data->entry_datum = entries[0];
data->typecmp = cmp_fns[rhs_code];
- *extra_data = palloc_object(Pointer);
- **extra_data = (Pointer) data;
+ *extra_data = palloc_object(void *);
+ **extra_data = data;
PG_RETURN_POINTER(entries);
}
diff --git a/contrib/hstore/hstore_gin.c b/contrib/hstore/hstore_gin.c
index 2e5fa115924..4b446f4d9e3 100644
--- a/contrib/hstore/hstore_gin.c
+++ b/contrib/hstore/hstore_gin.c
@@ -156,7 +156,7 @@ gin_consistent_hstore(PG_FUNCTION_ARGS)
/* HStore *query = PG_GETARG_HSTORE_P(2); */
int32 nkeys = PG_GETARG_INT32(3);
- /* Pointer *extra_data = (Pointer *) PG_GETARG_POINTER(4); */
+ /* void **extra_data = (void **) PG_GETARG_POINTER(4); */
bool *recheck = (bool *) PG_GETARG_POINTER(5);
bool res = true;
int32 i;
diff --git a/contrib/intarray/_int_gin.c b/contrib/intarray/_int_gin.c
index c60616c3f77..dffdd3fd681 100644
--- a/contrib/intarray/_int_gin.c
+++ b/contrib/intarray/_int_gin.c
@@ -113,7 +113,7 @@ ginint4_consistent(PG_FUNCTION_ARGS)
StrategyNumber strategy = PG_GETARG_UINT16(1);
int32 nkeys = PG_GETARG_INT32(3);
- /* Pointer *extra_data = (Pointer *) PG_GETARG_POINTER(4); */
+ /* void **extra_data = (void **) PG_GETARG_POINTER(4); */
bool *recheck = (bool *) PG_GETARG_POINTER(5);
bool res = false;
int32 i;
diff --git a/contrib/pg_trgm/trgm_gin.c b/contrib/pg_trgm/trgm_gin.c
index 66ff6adde99..8eaf5d58820 100644
--- a/contrib/pg_trgm/trgm_gin.c
+++ b/contrib/pg_trgm/trgm_gin.c
@@ -74,7 +74,7 @@ gin_extract_query_trgm(PG_FUNCTION_ARGS)
StrategyNumber strategy = PG_GETARG_UINT16(2);
/* bool **pmatch = (bool **) PG_GETARG_POINTER(3); */
- Pointer **extra_data = (Pointer **) PG_GETARG_POINTER(4);
+ void ***extra_data = (void ***) PG_GETARG_POINTER(4);
/* bool **nullFlags = (bool **) PG_GETARG_POINTER(5); */
int32 *searchMode = (int32 *) PG_GETARG_POINTER(6);
@@ -120,12 +120,12 @@ gin_extract_query_trgm(PG_FUNCTION_ARGS)
/*
* Successful regex processing: store NFA-like graph as
* extra_data. GIN API requires an array of nentries
- * Pointers, but we just put the same value in each element.
+ * pointers, but we just put the same value in each element.
*/
trglen = ARRNELEM(trg);
- *extra_data = palloc_array(Pointer, trglen);
+ *extra_data = palloc_array(void *, trglen);
for (i = 0; i < trglen; i++)
- (*extra_data)[i] = (Pointer) graph;
+ (*extra_data)[i] = graph;
}
else
{
@@ -174,7 +174,7 @@ gin_trgm_consistent(PG_FUNCTION_ARGS)
/* text *query = PG_GETARG_TEXT_PP(2); */
int32 nkeys = PG_GETARG_INT32(3);
- Pointer *extra_data = (Pointer *) PG_GETARG_POINTER(4);
+ void **extra_data = (void **) PG_GETARG_POINTER(4);
bool *recheck = (bool *) PG_GETARG_POINTER(5);
bool res;
int32 i,
@@ -272,7 +272,7 @@ gin_trgm_triconsistent(PG_FUNCTION_ARGS)
/* text *query = PG_GETARG_TEXT_PP(2); */
int32 nkeys = PG_GETARG_INT32(3);
- Pointer *extra_data = (Pointer *) PG_GETARG_POINTER(4);
+ void **extra_data = (void **) PG_GETARG_POINTER(4);
GinTernaryValue res = GIN_MAYBE;
int32 i,
ntrue;
diff --git a/src/backend/access/gin/ginarrayproc.c b/src/backend/access/gin/ginarrayproc.c
index 1f821323eb0..eaeb8feb3a9 100644
--- a/src/backend/access/gin/ginarrayproc.c
+++ b/src/backend/access/gin/ginarrayproc.c
@@ -84,7 +84,7 @@ ginqueryarrayextract(PG_FUNCTION_ARGS)
StrategyNumber strategy = PG_GETARG_UINT16(2);
/* bool **pmatch = (bool **) PG_GETARG_POINTER(3); */
- /* Pointer *extra_data = (Pointer *) PG_GETARG_POINTER(4); */
+ /* void **extra_data = (void **) PG_GETARG_POINTER(4); */
bool **nullFlags = (bool **) PG_GETARG_POINTER(5);
int32 *searchMode = (int32 *) PG_GETARG_POINTER(6);
int16 elmlen;
@@ -147,7 +147,7 @@ ginarrayconsistent(PG_FUNCTION_ARGS)
/* ArrayType *query = PG_GETARG_ARRAYTYPE_P(2); */
int32 nkeys = PG_GETARG_INT32(3);
- /* Pointer *extra_data = (Pointer *) PG_GETARG_POINTER(4); */
+ /* void **extra_data = (void **) PG_GETARG_POINTER(4); */
bool *recheck = (bool *) PG_GETARG_POINTER(5);
/* Datum *queryKeys = (Datum *) PG_GETARG_POINTER(6); */
@@ -231,7 +231,7 @@ ginarraytriconsistent(PG_FUNCTION_ARGS)
/* ArrayType *query = PG_GETARG_ARRAYTYPE_P(2); */
int32 nkeys = PG_GETARG_INT32(3);
- /* Pointer *extra_data = (Pointer *) PG_GETARG_POINTER(4); */
+ /* void **extra_data = (void **) PG_GETARG_POINTER(4); */
/* Datum *queryKeys = (Datum *) PG_GETARG_POINTER(5); */
bool *nullFlags = (bool *) PG_GETARG_POINTER(6);
GinTernaryValue res;
diff --git a/src/backend/access/gin/ginentrypage.c b/src/backend/access/gin/ginentrypage.c
index 94f49d72a98..6be7b3ffcd1 100644
--- a/src/backend/access/gin/ginentrypage.c
+++ b/src/backend/access/gin/ginentrypage.c
@@ -43,7 +43,7 @@ static void entrySplitPage(GinBtree btree, Buffer origbuf,
IndexTuple
GinFormTuple(GinState *ginstate,
OffsetNumber attnum, Datum key, GinNullCategory category,
- Pointer data, Size dataSize, int nipd,
+ void *data, Size dataSize, int nipd,
bool errorTooBig)
{
Datum datums[2];
@@ -136,7 +136,7 @@ GinFormTuple(GinState *ginstate,
*/
if (data)
{
- char *ptr = GinGetPosting(itup);
+ void *ptr = GinGetPosting(itup);
memcpy(ptr, data, dataSize);
}
@@ -162,7 +162,7 @@ ItemPointer
ginReadTuple(GinState *ginstate, OffsetNumber attnum, IndexTuple itup,
int *nitems)
{
- Pointer ptr = GinGetPosting(itup);
+ void *ptr = GinGetPosting(itup);
int nipd = GinGetNPosting(itup);
ItemPointer ipd;
int ndecoded;
diff --git a/src/backend/access/gin/ginscan.c b/src/backend/access/gin/ginscan.c
index 26081693383..5aec1943ece 100644
--- a/src/backend/access/gin/ginscan.c
+++ b/src/backend/access/gin/ginscan.c
@@ -57,7 +57,7 @@ static GinScanEntry
ginFillScanEntry(GinScanOpaque so, OffsetNumber attnum,
StrategyNumber strategy, int32 searchMode,
Datum queryKey, GinNullCategory queryCategory,
- bool isPartialMatch, Pointer extra_data)
+ bool isPartialMatch, void *extra_data)
{
GinState *ginstate = &so->ginstate;
GinScanEntry scanEntry;
@@ -160,7 +160,7 @@ ginFillScanKey(GinScanOpaque so, OffsetNumber attnum,
StrategyNumber strategy, int32 searchMode,
Datum query, uint32 nQueryValues,
Datum *queryValues, GinNullCategory *queryCategories,
- bool *partial_matches, Pointer *extra_data)
+ bool *partial_matches, void **extra_data)
{
GinScanKey key = &(so->keys[so->nkeys++]);
GinState *ginstate = &so->ginstate;
@@ -206,7 +206,7 @@ ginFillScanKey(GinScanOpaque so, OffsetNumber attnum,
Datum queryKey;
GinNullCategory queryCategory;
bool isPartialMatch;
- Pointer this_extra;
+ void *this_extra;
queryKey = queryValues[i];
queryCategory = queryCategories[i];
@@ -302,7 +302,7 @@ ginNewScanKey(IndexScanDesc scan)
Datum *queryValues;
int32 nQueryValues = 0;
bool *partial_matches = NULL;
- Pointer *extra_data = NULL;
+ void **extra_data = NULL;
bool *nullFlags = NULL;
GinNullCategory *categories;
int32 searchMode = GIN_SEARCH_MODE_DEFAULT;
diff --git a/src/backend/utils/adt/jsonb_gin.c b/src/backend/utils/adt/jsonb_gin.c
index a6d3332bb42..670e1520e8e 100644
--- a/src/backend/utils/adt/jsonb_gin.c
+++ b/src/backend/utils/adt/jsonb_gin.c
@@ -746,7 +746,7 @@ emit_jsp_gin_entries(JsonPathGinNode *node, GinEntries *entries)
*/
static Datum *
extract_jsp_query(JsonPath *jp, StrategyNumber strat, bool pathOps,
- int32 *nentries, Pointer **extra_data)
+ int32 *nentries, void ***extra_data)
{
JsonPathGinContext cxt;
JsonPathItem root;
@@ -786,7 +786,7 @@ extract_jsp_query(JsonPath *jp, StrategyNumber strat, bool pathOps,
return NULL;
*extra_data = palloc0(sizeof(**extra_data) * entries.count);
- **extra_data = (Pointer) node;
+ **extra_data = node;
return entries.buf;
}
@@ -909,7 +909,7 @@ gin_extract_jsonb_query(PG_FUNCTION_ARGS)
strategy == JsonbJsonpathExistsStrategyNumber)
{
JsonPath *jp = PG_GETARG_JSONPATH_P(0);
- Pointer **extra_data = (Pointer **) PG_GETARG_POINTER(4);
+ void ***extra_data = (void ***) PG_GETARG_POINTER(4);
entries = extract_jsp_query(jp, strategy, false, nentries, extra_data);
@@ -934,7 +934,7 @@ gin_consistent_jsonb(PG_FUNCTION_ARGS)
/* Jsonb *query = PG_GETARG_JSONB_P(2); */
int32 nkeys = PG_GETARG_INT32(3);
- Pointer *extra_data = (Pointer *) PG_GETARG_POINTER(4);
+ void **extra_data = (void **) PG_GETARG_POINTER(4);
bool *recheck = (bool *) PG_GETARG_POINTER(5);
bool res = true;
int32 i;
@@ -1016,7 +1016,7 @@ gin_triconsistent_jsonb(PG_FUNCTION_ARGS)
/* Jsonb *query = PG_GETARG_JSONB_P(2); */
int32 nkeys = PG_GETARG_INT32(3);
- Pointer *extra_data = (Pointer *) PG_GETARG_POINTER(4);
+ void **extra_data = (void **) PG_GETARG_POINTER(4);
GinTernaryValue res = GIN_MAYBE;
int32 i;
@@ -1198,7 +1198,7 @@ gin_extract_jsonb_query_path(PG_FUNCTION_ARGS)
strategy == JsonbJsonpathExistsStrategyNumber)
{
JsonPath *jp = PG_GETARG_JSONPATH_P(0);
- Pointer **extra_data = (Pointer **) PG_GETARG_POINTER(4);
+ void ***extra_data = (void ***) PG_GETARG_POINTER(4);
entries = extract_jsp_query(jp, strategy, true, nentries, extra_data);
@@ -1222,7 +1222,7 @@ gin_consistent_jsonb_path(PG_FUNCTION_ARGS)
/* Jsonb *query = PG_GETARG_JSONB_P(2); */
int32 nkeys = PG_GETARG_INT32(3);
- Pointer *extra_data = (Pointer *) PG_GETARG_POINTER(4);
+ void **extra_data = (void **) PG_GETARG_POINTER(4);
bool *recheck = (bool *) PG_GETARG_POINTER(5);
bool res = true;
int32 i;
@@ -1273,7 +1273,7 @@ gin_triconsistent_jsonb_path(PG_FUNCTION_ARGS)
/* Jsonb *query = PG_GETARG_JSONB_P(2); */
int32 nkeys = PG_GETARG_INT32(3);
- Pointer *extra_data = (Pointer *) PG_GETARG_POINTER(4);
+ void **extra_data = (void **) PG_GETARG_POINTER(4);
GinTernaryValue res = GIN_MAYBE;
int32 i;
diff --git a/src/backend/utils/adt/selfuncs.c b/src/backend/utils/adt/selfuncs.c
index 540aa9628d7..f97d50641cf 100644
--- a/src/backend/utils/adt/selfuncs.c
+++ b/src/backend/utils/adt/selfuncs.c
@@ -8249,7 +8249,7 @@ gincost_pattern(IndexOptInfo *index, int indexcol,
righttype;
int32 nentries = 0;
bool *partial_matches = NULL;
- Pointer *extra_data = NULL;
+ void **extra_data = NULL;
bool *nullFlags = NULL;
int32 searchMode = GIN_SEARCH_MODE_DEFAULT;
int32 i;
diff --git a/src/backend/utils/adt/tsginidx.c b/src/backend/utils/adt/tsginidx.c
index 2712fd89df0..4fe01d5a005 100644
--- a/src/backend/utils/adt/tsginidx.c
+++ b/src/backend/utils/adt/tsginidx.c
@@ -44,7 +44,7 @@ gin_cmp_prefix(PG_FUNCTION_ARGS)
#ifdef NOT_USED
StrategyNumber strategy = PG_GETARG_UINT16(2);
- Pointer extra_data = PG_GETARG_POINTER(3);
+ void *extra_data = (void *) PG_GETARG_POINTER(3);
#endif
int cmp;
@@ -98,7 +98,7 @@ gin_extract_tsquery(PG_FUNCTION_ARGS)
/* StrategyNumber strategy = PG_GETARG_UINT16(2); */
bool **ptr_partialmatch = (bool **) PG_GETARG_POINTER(3);
- Pointer **extra_data = (Pointer **) PG_GETARG_POINTER(4);
+ void ***extra_data = (void ***) PG_GETARG_POINTER(4);
/* bool **nullFlags = (bool **) PG_GETARG_POINTER(5); */
int32 *searchMode = (int32 *) PG_GETARG_POINTER(6);
@@ -141,7 +141,7 @@ gin_extract_tsquery(PG_FUNCTION_ARGS)
* same, entry's) number. Entry's number is used in check array in
* consistent method. We use the same map for each entry.
*/
- *extra_data = (Pointer *) palloc(sizeof(Pointer) * j);
+ *extra_data = palloc(sizeof(void *) * j);
map_item_operand = (int *) palloc0(sizeof(int) * query->size);
/* Now rescan the VAL items and fill in the arrays */
@@ -157,7 +157,7 @@ gin_extract_tsquery(PG_FUNCTION_ARGS)
val->length);
entries[j] = PointerGetDatum(txt);
partialmatch[j] = val->prefix;
- (*extra_data)[j] = (Pointer) map_item_operand;
+ (*extra_data)[j] = map_item_operand;
map_item_operand[i] = j;
j++;
}
@@ -219,7 +219,7 @@ gin_tsquery_consistent(PG_FUNCTION_ARGS)
TSQuery query = PG_GETARG_TSQUERY(2);
/* int32 nkeys = PG_GETARG_INT32(3); */
- Pointer *extra_data = (Pointer *) PG_GETARG_POINTER(4);
+ void **extra_data = (void **) PG_GETARG_POINTER(4);
bool *recheck = (bool *) PG_GETARG_POINTER(5);
bool res = false;
@@ -236,7 +236,7 @@ gin_tsquery_consistent(PG_FUNCTION_ARGS)
*/
gcv.first_item = GETQUERY(query);
gcv.check = (GinTernaryValue *) check;
- gcv.map_item_operand = (int *) (extra_data[0]);
+ gcv.map_item_operand = extra_data[0];
switch (TS_execute_ternary(GETQUERY(query),
&gcv,
@@ -268,7 +268,7 @@ gin_tsquery_triconsistent(PG_FUNCTION_ARGS)
TSQuery query = PG_GETARG_TSQUERY(2);
/* int32 nkeys = PG_GETARG_INT32(3); */
- Pointer *extra_data = (Pointer *) PG_GETARG_POINTER(4);
+ void **extra_data = (void **) PG_GETARG_POINTER(4);
GinTernaryValue res = GIN_FALSE;
if (query->size > 0)
@@ -281,7 +281,7 @@ gin_tsquery_triconsistent(PG_FUNCTION_ARGS)
*/
gcv.first_item = GETQUERY(query);
gcv.check = check;
- gcv.map_item_operand = (int *) (extra_data[0]);
+ gcv.map_item_operand = extra_data[0];
res = TS_execute_ternary(GETQUERY(query),
&gcv,
diff --git a/src/include/access/gin_private.h b/src/include/access/gin_private.h
index db19ffd9897..ff42c41847c 100644
--- a/src/include/access/gin_private.h
+++ b/src/include/access/gin_private.h
@@ -214,7 +214,7 @@ extern void ginInsertValue(GinBtree btree, GinBtreeStack *stack,
/* ginentrypage.c */
extern IndexTuple GinFormTuple(GinState *ginstate,
OffsetNumber attnum, Datum key, GinNullCategory category,
- Pointer data, Size dataSize, int nipd, bool errorTooBig);
+ void *data, Size dataSize, int nipd, bool errorTooBig);
extern void ginPrepareEntryScan(GinBtree btree, OffsetNumber attnum,
Datum key, GinNullCategory category,
GinState *ginstate);
@@ -303,7 +303,7 @@ typedef struct GinScanKeyData
/* NB: these three arrays have only nuserentries elements! */
Datum *queryValues;
GinNullCategory *queryCategories;
- Pointer *extra_data;
+ void **extra_data;
StrategyNumber strategy;
int32 searchMode;
OffsetNumber attnum;
@@ -341,7 +341,7 @@ typedef struct GinScanEntryData
Datum queryKey;
GinNullCategory queryCategory;
bool isPartialMatch;
- Pointer extra_data;
+ void *extra_data;
StrategyNumber strategy;
int32 searchMode;
OffsetNumber attnum;
diff --git a/src/include/access/ginblock.h b/src/include/access/ginblock.h
index 4c1681068db..e7365c220cf 100644
--- a/src/include/access/ginblock.h
+++ b/src/include/access/ginblock.h
@@ -236,7 +236,7 @@ typedef signed char GinNullCategory;
#define GIN_ITUP_COMPRESSED (1U << 31)
#define GinGetPostingOffset(itup) (GinItemPointerGetBlockNumber(&(itup)->t_tid) & (~GIN_ITUP_COMPRESSED))
#define GinSetPostingOffset(itup,n) ItemPointerSetBlockNumber(&(itup)->t_tid,(n)|GIN_ITUP_COMPRESSED)
-#define GinGetPosting(itup) ((Pointer) ((char*)(itup) + GinGetPostingOffset(itup)))
+#define GinGetPosting(itup) ((void *) ((char*)(itup) + GinGetPostingOffset(itup)))
#define GinItupIsCompressed(itup) ((GinItemPointerGetBlockNumber(&(itup)->t_tid) & GIN_ITUP_COMPRESSED) != 0)
/*
--
2.52.0
^ permalink raw reply [nested|flat] 23+ messages in thread
* Re: get rid of Pointer type, mostly
2025-11-24 10:20 get rid of Pointer type, mostly Peter Eisentraut <[email protected]>
2025-11-24 16:09 ` Re: get rid of Pointer type, mostly Tom Lane <[email protected]>
2025-11-24 16:19 ` Re: get rid of Pointer type, mostly Robert Haas <[email protected]>
2025-11-24 16:33 ` Re: get rid of Pointer type, mostly Tom Lane <[email protected]>
2025-11-24 17:32 ` Re: get rid of Pointer type, mostly Robert Haas <[email protected]>
2025-11-24 18:26 ` Re: get rid of Pointer type, mostly Tom Lane <[email protected]>
2025-11-24 19:32 ` Re: get rid of Pointer type, mostly Robert Haas <[email protected]>
2025-11-24 19:38 ` Re: get rid of Pointer type, mostly Tom Lane <[email protected]>
2025-11-24 19:52 ` Re: get rid of Pointer type, mostly Robert Haas <[email protected]>
2025-11-24 20:20 ` Re: get rid of Pointer type, mostly David Geier <[email protected]>
2025-12-08 10:25 ` Re: get rid of Pointer type, mostly David Geier <[email protected]>
2025-12-08 10:53 ` Re: get rid of Pointer type, mostly Chao Li <[email protected]>
2025-12-08 11:14 ` Re: get rid of Pointer type, mostly Peter Eisentraut <[email protected]>
@ 2025-12-08 11:27 ` David Geier <[email protected]>
0 siblings, 0 replies; 23+ messages in thread
From: David Geier @ 2025-12-08 11:27 UTC (permalink / raw)
To: Peter Eisentraut <[email protected]>; Chao Li <[email protected]>; +Cc: Robert Haas <[email protected]>; Tom Lane <[email protected]>; pgsql-hackers
On 08.12.2025 12:14, Peter Eisentraut wrote:
> I was planning to proceed with Dagfinn's patch set. Here is what is
> currently remaining of the patch series. I haven't fully processed
> everyone's comments in this thread, so they might not be reflected in
> these patches.
Dagfinn's patch set turns Pointer into void *. I thought we had agreed
to use something like GinExtraPointer in the GIN code (see my patch set).
Either way is fine by me. It just seemed like the majority of commenters
where in favor of keeping some type in the GIN code for readability.
>
> There is some interference from the changes from palloc to
> palloc_object/_array/etc., and I was also trying to figure out what to
> do with the commented out code, hence the delay.
Understood.
--
David Geier
^ permalink raw reply [nested|flat] 23+ messages in thread
* Re: get rid of Pointer type, mostly
2025-11-24 10:20 get rid of Pointer type, mostly Peter Eisentraut <[email protected]>
2025-11-24 16:09 ` Re: get rid of Pointer type, mostly Tom Lane <[email protected]>
2025-11-24 16:19 ` Re: get rid of Pointer type, mostly Robert Haas <[email protected]>
2025-11-24 16:33 ` Re: get rid of Pointer type, mostly Tom Lane <[email protected]>
2025-11-24 17:32 ` Re: get rid of Pointer type, mostly Robert Haas <[email protected]>
2025-11-24 18:26 ` Re: get rid of Pointer type, mostly Tom Lane <[email protected]>
2025-11-24 19:32 ` Re: get rid of Pointer type, mostly Robert Haas <[email protected]>
2025-11-24 19:38 ` Re: get rid of Pointer type, mostly Tom Lane <[email protected]>
2025-11-24 19:52 ` Re: get rid of Pointer type, mostly Robert Haas <[email protected]>
2025-11-24 20:20 ` Re: get rid of Pointer type, mostly David Geier <[email protected]>
2025-12-08 10:25 ` Re: get rid of Pointer type, mostly David Geier <[email protected]>
2025-12-08 10:53 ` Re: get rid of Pointer type, mostly Chao Li <[email protected]>
@ 2025-12-08 11:51 ` David Geier <[email protected]>
1 sibling, 0 replies; 23+ messages in thread
From: David Geier @ 2025-12-08 11:51 UTC (permalink / raw)
To: Chao Li <[email protected]>; +Cc: Robert Haas <[email protected]>; Tom Lane <[email protected]>; Peter Eisentraut <[email protected]>; pgsql-hackers
On 08.12.2025 11:53, Chao Li wrote:
>
>
>> On Dec 8, 2025, at 18:25, David Geier <[email protected]> wrote:
>>
>> Hi Peter,
>>> I went with your proposal of GinExtraPointer. See attached patch. It's
>>> based on the series of patches from Peter's initial mail. I've included
>>> the removal of the Pointer typedef in the same patch.
>>
>> It seems to me that we reached agreement. Are you planning to still
>> apply these patches?
>>
>
> Basically I am not against this patch, as 756a43689324b473ee07549a6eb7a53a203df5ad has done similar changes.
>
> What I want to understand is that why do we delete Pointer and add GinExtraPointer?
>
> ```
> -/*
> - * Pointer
> - * Variable holding address of any memory resident object.
> - * (obsolescent; use void * or char *)
> - */
> -typedef void *Pointer;
> ```
>
> And
> ```
> +typedef void *GinExtraPointer;
> ```
>
> They both are underlying “void *”. Are we expecting to improve code readability? More specific maybe?
>
Yes, because otherwise you have void *** in the GIN code.
Please check the thread for more details.
--
David Geier
^ permalink raw reply [nested|flat] 23+ messages in thread
end of thread, other threads:[~2025-12-08 11:51 UTC | newest]
Thread overview: 23+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2025-11-24 10:20 get rid of Pointer type, mostly Peter Eisentraut <[email protected]>
2025-11-24 12:03 ` Chao Li <[email protected]>
2025-11-24 14:54 ` Bertrand Drouvot <[email protected]>
2025-11-24 16:09 ` Tom Lane <[email protected]>
2025-11-24 16:19 ` Robert Haas <[email protected]>
2025-11-24 16:33 ` Tom Lane <[email protected]>
2025-11-24 17:30 ` Jelte Fennema-Nio <[email protected]>
2025-11-24 17:35 ` Robert Haas <[email protected]>
2025-11-24 17:32 ` Robert Haas <[email protected]>
2025-11-24 18:26 ` Tom Lane <[email protected]>
2025-11-24 18:46 ` David Geier <[email protected]>
2025-11-24 19:05 ` Robert Haas <[email protected]>
2025-11-24 19:15 ` Tom Lane <[email protected]>
2025-11-24 20:08 ` Dagfinn Ilmari Mannsåker <[email protected]>
2025-11-24 19:32 ` Robert Haas <[email protected]>
2025-11-24 19:38 ` Tom Lane <[email protected]>
2025-11-24 19:52 ` Robert Haas <[email protected]>
2025-11-24 20:20 ` David Geier <[email protected]>
2025-12-08 10:25 ` David Geier <[email protected]>
2025-12-08 10:53 ` Chao Li <[email protected]>
2025-12-08 11:14 ` Peter Eisentraut <[email protected]>
2025-12-08 11:27 ` David Geier <[email protected]>
2025-12-08 11:51 ` David Geier <[email protected]>
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox