summaryrefslogtreecommitdiff
path: root/src/backend
diff options
context:
space:
mode:
authorPeter Eisentraut <peter@eisentraut.org>2025-10-30 10:44:36 +0100
committerPeter Eisentraut <peter@eisentraut.org>2025-10-30 11:20:04 +0100
commit8ce795fcb70df7a8fdf3303eec0cfcd703b0d122 (patch)
treed931e44077408d6229c432a01e2b4a23746d7766 /src/backend
parent9fcd4874ed50ee6c60dadd0f1146d8fea9ff0055 (diff)
Fix some confusing uses of const
There are a few places where we have typedef struct FooData { ... } FooData; typedef FooData *Foo; and then function declarations with bar(const Foo x) which isn't incorrect but probably meant bar(const FooData *x) meaning that the thing x points to is immutable, not x itself. This patch makes those changes where appropriate. In one case (execGrouping.c), the thing being pointed to was not immutable, so in that case remove the const altogether, to avoid further confusion. Co-authored-by: Chao Li <li.evan.chao@gmail.com> Discussion: https://www.postgresql.org/message-id/CAEoWx2m2E0xE8Kvbkv31ULh_E%2B5zph-WA_bEdv3UR9CLhw%2B3vg%40mail.gmail.com Discussion: https://www.postgresql.org/message-id/CAEoWx2kTDz%3Db6T2xHX78vy_B_osDeCC5dcTCi9eG0vXHp5QpdQ%40mail.gmail.com
Diffstat (limited to 'src/backend')
-rw-r--r--src/backend/access/gin/ginget.c2
-rw-r--r--src/backend/access/gin/ginpostinglist.c4
-rw-r--r--src/backend/executor/execGrouping.c8
-rw-r--r--src/backend/nodes/tidbitmap.c2
-rw-r--r--src/backend/utils/adt/tsvector_op.c12
5 files changed, 14 insertions, 14 deletions
diff --git a/src/backend/access/gin/ginget.c b/src/backend/access/gin/ginget.c
index 656299b1b52..0d4108d05a3 100644
--- a/src/backend/access/gin/ginget.c
+++ b/src/backend/access/gin/ginget.c
@@ -489,7 +489,7 @@ restartScanEntry:
static int
entryIndexByFrequencyCmp(const void *a1, const void *a2, void *arg)
{
- const GinScanKey key = (const GinScanKey) arg;
+ const GinScanKeyData *key = arg;
int i1 = *(const int *) a1;
int i2 = *(const int *) a2;
uint32 n1 = key->scanEntry[i1]->predictNumberResult;
diff --git a/src/backend/access/gin/ginpostinglist.c b/src/backend/access/gin/ginpostinglist.c
index 48eadec87b0..1bf061803da 100644
--- a/src/backend/access/gin/ginpostinglist.c
+++ b/src/backend/access/gin/ginpostinglist.c
@@ -84,7 +84,7 @@
#define MaxBytesPerInteger 7
static inline uint64
-itemptr_to_uint64(const ItemPointer iptr)
+itemptr_to_uint64(const ItemPointerData *iptr)
{
uint64 val;
@@ -194,7 +194,7 @@ decode_varbyte(unsigned char **ptr)
* byte at the end, if any, is zero.
*/
GinPostingList *
-ginCompressPostingList(const ItemPointer ipd, int nipd, int maxsize,
+ginCompressPostingList(const ItemPointerData *ipd, int nipd, int maxsize,
int *nwritten)
{
uint64 prev;
diff --git a/src/backend/executor/execGrouping.c b/src/backend/executor/execGrouping.c
index 75087204f0c..f34530fdacf 100644
--- a/src/backend/executor/execGrouping.c
+++ b/src/backend/executor/execGrouping.c
@@ -20,9 +20,9 @@
#include "miscadmin.h"
#include "utils/lsyscache.h"
-static int TupleHashTableMatch(struct tuplehash_hash *tb, const MinimalTuple tuple1, const MinimalTuple tuple2);
+static int TupleHashTableMatch(struct tuplehash_hash *tb, MinimalTuple tuple1, MinimalTuple tuple2);
static inline uint32 TupleHashTableHash_internal(struct tuplehash_hash *tb,
- const MinimalTuple tuple);
+ MinimalTuple tuple);
static inline TupleHashEntry LookupTupleHashEntry_internal(TupleHashTable hashtable,
TupleTableSlot *slot,
bool *isnew, uint32 hash);
@@ -419,7 +419,7 @@ FindTupleHashEntry(TupleHashTable hashtable, TupleTableSlot *slot,
*/
static uint32
TupleHashTableHash_internal(struct tuplehash_hash *tb,
- const MinimalTuple tuple)
+ MinimalTuple tuple)
{
TupleHashTable hashtable = (TupleHashTable) tb->private_data;
uint32 hashkey;
@@ -517,7 +517,7 @@ LookupTupleHashEntry_internal(TupleHashTable hashtable, TupleTableSlot *slot,
* See whether two tuples (presumably of the same hash value) match
*/
static int
-TupleHashTableMatch(struct tuplehash_hash *tb, const MinimalTuple tuple1, const MinimalTuple tuple2)
+TupleHashTableMatch(struct tuplehash_hash *tb, MinimalTuple tuple1, MinimalTuple tuple2)
{
TupleTableSlot *slot1;
TupleTableSlot *slot2;
diff --git a/src/backend/nodes/tidbitmap.c b/src/backend/nodes/tidbitmap.c
index fac2ba5d0ca..23d97b3a6c8 100644
--- a/src/backend/nodes/tidbitmap.c
+++ b/src/backend/nodes/tidbitmap.c
@@ -364,7 +364,7 @@ tbm_free_shared_area(dsa_area *dsa, dsa_pointer dp)
* TBMIterateResult when any of these tuples are reported out.
*/
void
-tbm_add_tuples(TIDBitmap *tbm, const ItemPointer tids, int ntids,
+tbm_add_tuples(TIDBitmap *tbm, const ItemPointerData *tids, int ntids,
bool recheck)
{
BlockNumber currblk = InvalidBlockNumber;
diff --git a/src/backend/utils/adt/tsvector_op.c b/src/backend/utils/adt/tsvector_op.c
index 0625da9532f..c752cbe5463 100644
--- a/src/backend/utils/adt/tsvector_op.c
+++ b/src/backend/utils/adt/tsvector_op.c
@@ -75,7 +75,7 @@ static bool TS_execute_locations_recurse(QueryItem *curitem,
void *arg,
TSExecuteCallback chkcond,
List **locations);
-static int tsvector_bsearch(const TSVector tsv, char *lexeme, int lexeme_len);
+static int tsvector_bsearch(const TSVectorData *tsv, char *lexeme, int lexeme_len);
static Datum tsvector_update_trigger(PG_FUNCTION_ARGS, bool config_column);
@@ -83,7 +83,7 @@ static Datum tsvector_update_trigger(PG_FUNCTION_ARGS, bool config_column);
* Order: haspos, len, word, for all positions (pos, weight)
*/
static int
-silly_cmp_tsvector(const TSVector a, const TSVector b)
+silly_cmp_tsvector(const TSVectorData *a, const TSVectorData *b)
{
if (VARSIZE(a) < VARSIZE(b))
return -1;
@@ -95,8 +95,8 @@ silly_cmp_tsvector(const TSVector a, const TSVector b)
return 1;
else
{
- WordEntry *aptr = ARRPTR(a);
- WordEntry *bptr = ARRPTR(b);
+ const WordEntry *aptr = ARRPTR(a);
+ const WordEntry *bptr = ARRPTR(b);
int i = 0;
int res;
@@ -397,9 +397,9 @@ add_pos(TSVector src, WordEntry *srcptr,
* found.
*/
static int
-tsvector_bsearch(const TSVector tsv, char *lexeme, int lexeme_len)
+tsvector_bsearch(const TSVectorData *tsv, char *lexeme, int lexeme_len)
{
- WordEntry *arrin = ARRPTR(tsv);
+ const WordEntry *arrin = ARRPTR(tsv);
int StopLow = 0,
StopHigh = tsv->size,
StopMiddle,