Mark function arguments of type "Datum *" as "const Datum *" where possible

Several functions in the codebase accept "Datum *" parameters but do
not modify the pointed-to data.  These have been updated to take
"const Datum *" instead, improving type safety and making the
interfaces clearer about their intent.  This change helps the compiler
catch accidental modifications and better documents immutability of
arguments.

Most of "Datum *" parameters have a pairing "bool *isnull" parameter,
they are constified as well.

No functional behavior is changed by this patch.

Author: Chao Li <lic@highgo.com>
Discussion: https://www.postgresql.org/message-id/flat/CAEoWx2msfT0knvzUa72ZBwu9LR_RLY4on85w2a9YpE-o2By5HQ@mail.gmail.com
This commit is contained in:
Peter Eisentraut
2025-10-31 10:45:02 +01:00
parent aa4535307e
commit 8a27d418f8
34 changed files with 145 additions and 145 deletions

View File

@ -352,8 +352,8 @@ extern PGDLLIMPORT bool Array_nulls;
* prototypes for functions defined in arrayfuncs.c
*/
extern void CopyArrayEls(ArrayType *array,
Datum *values,
bool *nulls,
const Datum *values,
const bool *nulls,
int nitems,
int typlen,
bool typbyval,
@ -405,14 +405,14 @@ extern ArrayType *construct_empty_array(Oid elmtype);
extern ExpandedArrayHeader *construct_empty_expanded_array(Oid element_type,
MemoryContext parentcontext,
ArrayMetaState *metacache);
extern void deconstruct_array(ArrayType *array,
extern void deconstruct_array(const ArrayType *array,
Oid elmtype,
int elmlen, bool elmbyval, char elmalign,
Datum **elemsp, bool **nullsp, int *nelemsp);
extern void deconstruct_array_builtin(ArrayType *array,
extern void deconstruct_array_builtin(const ArrayType *array,
Oid elmtype,
Datum **elemsp, bool **nullsp, int *nelemsp);
extern bool array_contains_nulls(ArrayType *array);
extern bool array_contains_nulls(const ArrayType *array);
extern ArrayBuildState *initArrayResult(Oid element_type,
MemoryContext rcontext, bool subcontext);