v2-0002-Convert-remaning-uses-of-Pointer-to-void.patch
text/plain
Filename: v2-0002-Convert-remaning-uses-of-Pointer-to-void.patch
Type: text/plain
Part: 1
Message:
Re: get rid of Pointer type, mostly
Patch
Same data as JSON:
GET /api/v1/attachments/:id/patch
the parsed metadata as JSON — format, series position, per-file stats; never the diff bytes.
API reference →
Format: format-patch
Series: patch v2-0002
Subject: Convert remaning uses of Pointer to void *
| File | + | − |
|---|---|---|
| contrib/amcheck/verify_gin.c | 1 | 1 |
| contrib/btree_gin/btree_gin.c | 3 | 3 |
| contrib/hstore/hstore_gin.c | 1 | 1 |
| contrib/intarray/_int_gin.c | 1 | 1 |
| contrib/pg_trgm/trgm_gin.c | 6 | 6 |
| src/backend/access/gin/ginarrayproc.c | 3 | 3 |
| src/backend/access/gin/ginentrypage.c | 3 | 3 |
| src/backend/access/gin/ginscan.c | 4 | 4 |
| src/backend/utils/adt/jsonb_gin.c | 8 | 8 |
| src/backend/utils/adt/selfuncs.c | 1 | 1 |
| src/backend/utils/adt/tsginidx.c | 8 | 8 |
| src/include/access/ginblock.h | 1 | 1 |
| src/include/access/gin_private.h | 3 | 3 |
From 343c866e127f66cad692767bfff76bef6aa9f3b0 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Dagfinn=20Ilmari=20Manns=C3=A5ker?= <ilmari@ilmari.org>
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