mirror of
https://github.com/postgres/postgres.git
synced 2026-01-27 21:43:08 +03:00
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:
@@ -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);
|
||||
|
||||
@@ -426,9 +426,9 @@ extern char *JsonbUnquote(Jsonb *jb);
|
||||
extern bool JsonbExtractScalar(JsonbContainer *jbc, JsonbValue *res);
|
||||
extern const char *JsonbTypeName(JsonbValue *val);
|
||||
|
||||
extern Datum jsonb_set_element(Jsonb *jb, Datum *path, int path_len,
|
||||
extern Datum jsonb_set_element(Jsonb *jb, const Datum *path, int path_len,
|
||||
JsonbValue *newval);
|
||||
extern Datum jsonb_get_element(Jsonb *jb, Datum *path, int npath,
|
||||
extern Datum jsonb_get_element(Jsonb *jb, const Datum *path, int npath,
|
||||
bool *isnull, bool as_text);
|
||||
extern bool to_jsonb_is_immutable(Oid typoid);
|
||||
extern Datum jsonb_build_object_worker(int nargs, const Datum *args, const bool *nulls,
|
||||
|
||||
@@ -71,8 +71,8 @@ extern void xml_ereport(PgXmlErrorContext *errcxt, int level, int sqlcode,
|
||||
|
||||
extern xmltype *xmlconcat(List *args);
|
||||
extern xmltype *xmlelement(XmlExpr *xexpr,
|
||||
Datum *named_argvalue, bool *named_argnull,
|
||||
Datum *argvalue, bool *argnull);
|
||||
const Datum *named_argvalue, const bool *named_argnull,
|
||||
const Datum *argvalue, const bool *argnull);
|
||||
extern xmltype *xmlparse(text *data, XmlOptionType xmloption_arg, bool preserve_whitespace);
|
||||
extern xmltype *xmlpi(const char *target, text *arg, bool arg_is_null, bool *result_is_null);
|
||||
extern xmltype *xmlroot(xmltype *data, text *version, int standalone);
|
||||
|
||||
Reference in New Issue
Block a user