The attached patches fix more cases where qualifiers (const, volatile) are cast away either accidentally, or unnecessarily, or where it can be worked around easily.

I split these into tiny bits to simplify review and to show that they are all independent. But they could perhaps be committed all together.
(See also similar commit 3f988629805.)

I have a local WIP branch that fixes all remaining -Wcast-qual warnings. The attached patches are the "easy" half of that. I plan to propose addressing the other half separately later.
From 3ca7f0e18ee608e96a1ad4d37e9dcac53dbeda90 Mon Sep 17 00:00:00 2001
From: Peter Eisentraut <[email protected]>
Date: Tue, 18 Aug 2026 10:52:24 +0200
Subject: [PATCH 01/11] Fix some -Wcast-qual warnings [fe_utils/print.c]

fixup for commit c83a133f2bb
---
 src/fe_utils/print.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/fe_utils/print.c b/src/fe_utils/print.c
index 06039ca1499..b0dd9d54371 100644
--- a/src/fe_utils/print.c
+++ b/src/fe_utils/print.c
@@ -3269,7 +3269,7 @@ printTableAddHeader(printTableContent *content, const 
char *header,
         * are provided by ourselves, so they had better be ok.  And if they 
were
         * not, running mbvalidate on them could overwrite gettext-owned memory.
         */
-       if (!translate && !mb_is_valid((unsigned char *) header, 
content->opt->encoding))
+       if (!translate && !mb_is_valid((const unsigned char *) header, 
content->opt->encoding))
        {
                char       *header2;
 
@@ -3327,7 +3327,7 @@ printTableAddCell(printTableContent *content, const char 
*cell,
         * are provided by ourselves, so they had better be ok.  And if they 
were
         * not, running mbvalidate on them could overwrite gettext-owned memory.
         */
-       if (!translate && !mb_is_valid((unsigned char *) cell, 
content->opt->encoding))
+       if (!translate && !mb_is_valid((const unsigned char *) cell, 
content->opt->encoding))
        {
                char       *cell2;
 
-- 
2.55.0

From 218c5c861f0dfdd17c8aa34a405ebd6b0b8fb712 Mon Sep 17 00:00:00 2001
From: Peter Eisentraut <[email protected]>
Date: Tue, 18 Aug 2026 10:52:24 +0200
Subject: [PATCH 02/11] Fix some -Wcast-qual warnings [rangetypes]

Drop unnecessary casts, which inadvertently cast away const
qualifiers.
---
 src/backend/utils/adt/multirangetypes.c | 6 +++---
 src/backend/utils/adt/rangetypes.c      | 2 +-
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/src/backend/utils/adt/multirangetypes.c 
b/src/backend/utils/adt/multirangetypes.c
index e72a2efadcd..14a71fe534f 100644
--- a/src/backend/utils/adt/multirangetypes.c
+++ b/src/backend/utils/adt/multirangetypes.c
@@ -722,11 +722,11 @@ multirange_get_range(TypeCacheEntry *rangetyp,
         * exact size.
         */
        if (RANGE_HAS_LBOUND(flags))
-               ptr = (char *) att_addlength_pointer(ptr, typlen, ptr);
+               ptr = att_addlength_pointer(ptr, typlen, ptr);
        if (RANGE_HAS_UBOUND(flags))
        {
                ptr = (char *) att_align_pointer(ptr, typalign, typlen, ptr);
-               ptr = (char *) att_addlength_pointer(ptr, typlen, ptr);
+               ptr = att_addlength_pointer(ptr, typlen, ptr);
        }
        len = (ptr - begin) + sizeof(RangeType) + sizeof(uint8);
 
@@ -773,7 +773,7 @@ multirange_get_bounds(TypeCacheEntry *rangetyp,
        {
                /* att_align_pointer cannot be necessary here */
                lbound = fetch_att(ptr, typbyval, typlen);
-               ptr = (char *) att_addlength_pointer(ptr, typlen, ptr);
+               ptr = att_addlength_pointer(ptr, typlen, ptr);
        }
        else
                lbound = (Datum) 0;
diff --git a/src/backend/utils/adt/rangetypes.c 
b/src/backend/utils/adt/rangetypes.c
index 92dacd73dec..84d71761c1b 100644
--- a/src/backend/utils/adt/rangetypes.c
+++ b/src/backend/utils/adt/rangetypes.c
@@ -2117,7 +2117,7 @@ range_deserialize(TypeCacheEntry *typcache, const 
RangeType *range,
        {
                /* att_align_pointer cannot be necessary here */
                lbound = fetch_att(ptr, typbyval, typlen);
-               ptr = (char *) att_addlength_pointer(ptr, typlen, ptr);
+               ptr = att_addlength_pointer(ptr, typlen, ptr);
        }
        else
                lbound = (Datum) 0;
-- 
2.55.0

From 9e97f2da6a9ad17db52c74451cbda83b714ae52f Mon Sep 17 00:00:00 2001
From: Peter Eisentraut <[email protected]>
Date: Tue, 18 Aug 2026 10:52:24 +0200
Subject: [PATCH 03/11] Fix some -Wcast-qual warnings [varlena]

Small cleanup to avoid having to cast away const qualifiers.
---
 src/backend/utils/adt/varlena.c | 24 ++++++++++++------------
 1 file changed, 12 insertions(+), 12 deletions(-)

diff --git a/src/backend/utils/adt/varlena.c b/src/backend/utils/adt/varlena.c
index a09a9e5d5bb..fa2ab02b262 100644
--- a/src/backend/utils/adt/varlena.c
+++ b/src/backend/utils/adt/varlena.c
@@ -1153,9 +1153,9 @@ text_position_next_internal(char *start_ptr, 
TextPositionState *state)
        int                     needle_len = state->len2;
        int                     skiptablemask = state->skiptablemask;
        const char *haystack = state->str1;
-       const char *needle = state->str2;
+       char       *needle = state->str2;
        const char *haystack_end = &haystack[haystack_len];
-       const char *hptr;
+       char       *hptr;
 
        Assert(start_ptr >= haystack && start_ptr <= haystack_end);
        Assert(needle_len > 0);
@@ -1184,7 +1184,7 @@ text_position_next_internal(char *start_ptr, 
TextPositionState *state)
                 * collation would accept an empty match, returning one would 
send
                 * callers that search for successive matches into an infinite 
loop.)
                 */
-               const char *result_hptr = NULL;
+               char       *result_hptr = NULL;
 
                hptr = start_ptr;
                while (hptr < haystack_end)
@@ -1198,7 +1198,7 @@ text_position_next_internal(char *start_ptr, 
TextPositionState *state)
                        if (!state->greedy &&
                                haystack_end - hptr >= needle_len &&
                                pg_strncoll(hptr, needle_len, needle, 
needle_len, state->locale) == 0)
-                               return (char *) hptr;
+                               return hptr;
 
                        /*
                         * Else check if any of the non-empty substrings 
starting at hptr
@@ -1223,7 +1223,7 @@ text_position_next_internal(char *start_ptr, 
TextPositionState *state)
                        hptr += pg_mblen_range(hptr, haystack_end);
                }
 
-               return (char *) result_hptr;
+               return result_hptr;
        }
        else if (needle_len == 1)
        {
@@ -1234,21 +1234,21 @@ text_position_next_internal(char *start_ptr, 
TextPositionState *state)
                while (hptr < haystack_end)
                {
                        if (*hptr == nchar)
-                               return (char *) hptr;
+                               return hptr;
                        hptr++;
                }
        }
        else
        {
-               const char *needle_last = &needle[needle_len - 1];
+               char       *needle_last = &needle[needle_len - 1];
 
                /* Start at startpos plus the length of the needle */
                hptr = start_ptr + needle_len - 1;
                while (hptr < haystack_end)
                {
                        /* Match the needle scanning *backward* */
-                       const char *nptr;
-                       const char *p;
+                       char       *nptr;
+                       char       *p;
 
                        nptr = needle_last;
                        p = hptr;
@@ -1256,7 +1256,7 @@ text_position_next_internal(char *start_ptr, 
TextPositionState *state)
                        {
                                /* Matched it all?      If so, return 1-based 
position */
                                if (nptr == needle)
-                                       return (char *) p;
+                                       return p;
                                nptr--, p--;
                        }
 
@@ -4470,7 +4470,7 @@ string_agg_deserialize(PG_FUNCTION_ARGS)
        bytea      *sstate;
        StringInfo      result;
        StringInfoData buf;
-       char       *data;
+       const char *data;
        int                     datalen;
 
        /* cannot be called directly because of internal-type argument */
@@ -4492,7 +4492,7 @@ string_agg_deserialize(PG_FUNCTION_ARGS)
 
        /* data */
        datalen = VARSIZE_ANY_EXHDR(sstate) - 4;
-       data = (char *) pq_getmsgbytes(&buf, datalen);
+       data = pq_getmsgbytes(&buf, datalen);
        appendBinaryStringInfo(result, data, datalen);
 
        pq_getmsgend(&buf);
-- 
2.55.0

From 5a3b7453cb0a881d6a46a520295ec17df3bcc48c Mon Sep 17 00:00:00 2001
From: Peter Eisentraut <[email protected]>
Date: Tue, 18 Aug 2026 10:52:24 +0200
Subject: [PATCH 04/11] Fix some -Wcast-qual warnings [contrib/xml2]

Small rearrangement to avoid having to cast away a volatile qualifier.
---
 contrib/xml2/xslt_proc.c | 15 ++++++++-------
 1 file changed, 8 insertions(+), 7 deletions(-)

diff --git a/contrib/xml2/xslt_proc.c b/contrib/xml2/xslt_proc.c
index a1e18671ce8..c8ae52498e0 100644
--- a/contrib/xml2/xslt_proc.c
+++ b/contrib/xml2/xslt_proc.c
@@ -60,7 +60,7 @@ xslt_process(PG_FUNCTION_ARGS)
        volatile xsltSecurityPrefsPtr xslt_sec_prefs = NULL;
        volatile xsltTransformContextPtr xslt_ctxt = NULL;
        volatile int resstat = -1;
-       xmlChar    *volatile resstr = NULL;
+       xmlChar    *volatile resstrv = NULL;
 
        if (fcinfo->nargs == 3)
        {
@@ -80,6 +80,7 @@ xslt_process(PG_FUNCTION_ARGS)
        PG_TRY();
        {
                bool            xslt_sec_prefs_error;
+               xmlChar    *resstr = NULL;
                int                     reslen = 0;
 
                /* Parse document */
@@ -147,8 +148,8 @@ xslt_process(PG_FUNCTION_ARGS)
                        xml_ereport(xmlerrcxt, ERROR, 
ERRCODE_INVALID_ARGUMENT_FOR_XQUERY,
                                                "failed to apply stylesheet");
 
-               resstat = xsltSaveResultToString((xmlChar **) &resstr, &reslen,
-                                                                               
 restree, stylesheet);
+               resstat = xsltSaveResultToString(&resstr, &reslen, restree, 
stylesheet);
+               resstrv = resstr;
 
                if (resstat >= 0)
                {
@@ -176,8 +177,8 @@ xslt_process(PG_FUNCTION_ARGS)
                        xmlFreeDoc(ssdoc);
                if (doctree != NULL)
                        xmlFreeDoc(doctree);
-               if (resstr != NULL)
-                       xmlFree(resstr);
+               if (resstrv != NULL)
+                       xmlFree(resstrv);
                xsltCleanupGlobals();
 
                pg_xml_done(xmlerrcxt, true);
@@ -193,8 +194,8 @@ xslt_process(PG_FUNCTION_ARGS)
        xmlFreeDoc(doctree);
        xsltCleanupGlobals();
 
-       if (resstr)
-               xmlFree(resstr);
+       if (resstrv)
+               xmlFree(resstrv);
 
        pg_xml_done(xmlerrcxt, false);
 
-- 
2.55.0

From 3efc4bac5da22ba27b41e94e10854ee9a87f93b6 Mon Sep 17 00:00:00 2001
From: Peter Eisentraut <[email protected]>
Date: Tue, 18 Aug 2026 10:52:24 +0200
Subject: [PATCH 05/11] Fix some -Wcast-qual warnings [postgres_fdw]

Small rearrangement to avoid having to cast away const qualifiers.
---
 contrib/postgres_fdw/connection.c | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/contrib/postgres_fdw/connection.c 
b/contrib/postgres_fdw/connection.c
index fc9583f369f..b5d4cf3dccc 100644
--- a/contrib/postgres_fdw/connection.c
+++ b/contrib/postgres_fdw/connection.c
@@ -580,28 +580,31 @@ construct_connection_params(ForeignServer *server, 
UserMapping *user,
        if (MyProcPort != NULL && MyProcPort->has_scram_keys && 
UseScramPassthrough(server, user))
        {
                int                     len;
+               char       *encoded;
                int                     encoded_len;
 
                keywords[n] = "scram_client_key";
                len = pg_b64_enc_len(sizeof(MyProcPort->scram_ClientKey));
                /* don't forget the zero-terminator */
-               values[n] = palloc0(len + 1);
+               encoded = palloc0(len + 1);
                encoded_len = pg_b64_encode(MyProcPort->scram_ClientKey,
                                                                        
sizeof(MyProcPort->scram_ClientKey),
-                                                                       (char 
*) values[n], len);
+                                                                       
encoded, len);
                if (encoded_len < 0)
                        elog(ERROR, "could not encode SCRAM client key");
+               values[n] = encoded;
                n++;
 
                keywords[n] = "scram_server_key";
                len = pg_b64_enc_len(sizeof(MyProcPort->scram_ServerKey));
                /* don't forget the zero-terminator */
-               values[n] = palloc0(len + 1);
+               encoded = palloc0(len + 1);
                encoded_len = pg_b64_encode(MyProcPort->scram_ServerKey,
                                                                        
sizeof(MyProcPort->scram_ServerKey),
-                                                                       (char 
*) values[n], len);
+                                                                       
encoded, len);
                if (encoded_len < 0)
                        elog(ERROR, "could not encode SCRAM server key");
+               values[n] = encoded;
                n++;
 
                /*
-- 
2.55.0

From cec624866019246f7c14a8110eac76de6906b4d6 Mon Sep 17 00:00:00 2001
From: Peter Eisentraut <[email protected]>
Date: Tue, 18 Aug 2026 10:52:24 +0200
Subject: [PATCH 06/11] Fix some -Wcast-qual warnings [btree_gist]

Some small adjustments to avoid having to cast away const qualifiers.
---
 contrib/btree_gist/btree_bit.c       | 4 ++--
 contrib/btree_gist/btree_utils_var.c | 4 ++--
 contrib/btree_gist/btree_utils_var.h | 2 +-
 3 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/contrib/btree_gist/btree_bit.c b/contrib/btree_gist/btree_bit.c
index 5fb8c8b82f0..434a5f7e430 100644
--- a/contrib/btree_gist/btree_bit.c
+++ b/contrib/btree_gist/btree_bit.c
@@ -98,7 +98,7 @@ gbt_bitcmp(const void *a, const void *b, Oid collation, 
FmgrInfo *flinfo)
  * descend to that leaf page.
  */
 static bytea *
-gbt_bit_xfrm(VarBit *leaf)
+gbt_bit_xfrm(const VarBit *leaf)
 {
        bytea      *out;
        int                     sz = VARBITBYTES(leaf) + VARHDRSZ;
@@ -125,7 +125,7 @@ gbt_bit_l2n(GBT_VARKEY *leaf, FmgrInfo *flinfo)
        GBT_VARKEY_R r = gbt_var_key_readable(leaf);
        bytea      *o;
 
-       o = gbt_bit_xfrm((VarBit *) r.lower);
+       o = gbt_bit_xfrm((const VarBit *) r.lower);
        r.upper = r.lower = o;
        out = gbt_var_key_copy(&r);
        pfree(o);
diff --git a/contrib/btree_gist/btree_utils_var.c 
b/contrib/btree_gist/btree_utils_var.c
index 3eeaee6bc35..efa6e09aa53 100644
--- a/contrib/btree_gist/btree_utils_var.c
+++ b/contrib/btree_gist/btree_utils_var.c
@@ -62,9 +62,9 @@ gbt_var_key_readable(const GBT_VARKEY *k)
 {
        GBT_VARKEY_R r;
 
-       r.lower = (bytea *) &(((char *) k)[VARHDRSZ]);
+       r.lower = (const bytea *) &(((const char *) k)[VARHDRSZ]);
        if (VARSIZE(k) > (VARHDRSZ + (VARSIZE(r.lower))))
-               r.upper = (bytea *) &(((char *) k)[VARHDRSZ + 
INTALIGN(VARSIZE(r.lower))]);
+               r.upper = (const bytea *) &(((const char *) k)[VARHDRSZ + 
INTALIGN(VARSIZE(r.lower))]);
        else
                r.upper = r.lower;
        return r;
diff --git a/contrib/btree_gist/btree_utils_var.h 
b/contrib/btree_gist/btree_utils_var.h
index 2ed7eaa86b2..a12485b3098 100644
--- a/contrib/btree_gist/btree_utils_var.h
+++ b/contrib/btree_gist/btree_utils_var.h
@@ -26,7 +26,7 @@ typedef bytea GBT_VARKEY;
  */
 typedef struct
 {
-       bytea      *lower,
+       const bytea *lower,
                           *upper;
 } GBT_VARKEY_R;
 
-- 
2.55.0

From 8af9e75a43a06ea56199ae7418aba15086eb4e29 Mon Sep 17 00:00:00 2001
From: Peter Eisentraut <[email protected]>
Date: Tue, 18 Aug 2026 10:52:24 +0200
Subject: [PATCH 07/11] Fix some -Wcast-qual warnings [guc_funcs]

Some rearrangements to avoid having to cast away const qualifiers.
---
 src/backend/utils/misc/guc_funcs.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/src/backend/utils/misc/guc_funcs.c 
b/src/backend/utils/misc/guc_funcs.c
index e2c2919484e..defaa796a0c 100644
--- a/src/backend/utils/misc/guc_funcs.c
+++ b/src/backend/utils/misc/guc_funcs.c
@@ -971,6 +971,7 @@ show_all_settings(PG_FUNCTION_ARGS)
        while (call_cntr < max_calls)   /* do when there is more left to send */
        {
                struct config_generic *conf = guc_vars[call_cntr];
+               const char *cvalues[NUM_PG_SETTINGS_ATTS];
                char       *values[NUM_PG_SETTINGS_ATTS];
                HeapTuple       tuple;
                Datum           result;
@@ -984,7 +985,14 @@ show_all_settings(PG_FUNCTION_ARGS)
                }
 
                /* extract values for the current variable */
-               GetConfigOptionValues(conf, (const char **) values);
+               GetConfigOptionValues(conf, cvalues);
+
+               /*
+                * This is so that both GetConfigOptionValues() and
+                * BuildTupleFromCStrings() are satisfied about the const-ness 
without
+                * triggering warnings.
+                */
+               memcpy(values, cvalues, sizeof(cvalues));
 
                /* build a tuple */
                tuple = BuildTupleFromCStrings(attinmeta, values);
-- 
2.55.0

From 4653cd967eed3dcb77dce06c6dfebf708479dea1 Mon Sep 17 00:00:00 2001
From: Peter Eisentraut <[email protected]>
Date: Tue, 18 Aug 2026 10:52:24 +0200
Subject: [PATCH 08/11] Fix some -Wcast-qual warnings [bufpage]

Adding a const qualifier inside the macro avoids possible warnings
about casting away const.  The result type of the macro is not
affected.

Currently, PageGetTempPageCopySpecial() is the only caller affected by
this.
---
 src/include/storage/bufpage.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/include/storage/bufpage.h b/src/include/storage/bufpage.h
index 634e1e49ee5..713b6222286 100644
--- a/src/include/storage/bufpage.h
+++ b/src/include/storage/bufpage.h
@@ -364,7 +364,7 @@ PageValidateSpecialPointer(const PageData *page)
 #define PageGetSpecialPointer(page) \
 ( \
        PageValidateSpecialPointer(page), \
-       ((page) + ((PageHeader) (page))->pd_special) \
+       ((page) + ((const PageHeaderData *) (page))->pd_special) \
 )
 
 /*
-- 
2.55.0

From 632016f418c4e9ba598bb4812eee818d150460b4 Mon Sep 17 00:00:00 2001
From: Peter Eisentraut <[email protected]>
Date: Tue, 18 Aug 2026 10:52:24 +0200
Subject: [PATCH 09/11] Fix some -Wcast-qual warnings [test_custom_stats]

This just removes an unnecessary cast.
---
 src/test/modules/test_custom_stats/test_custom_var_stats.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/test/modules/test_custom_stats/test_custom_var_stats.c 
b/src/test/modules/test_custom_stats/test_custom_var_stats.c
index a39ada0b67c..ec06d5e1fdb 100644
--- a/src/test/modules/test_custom_stats/test_custom_var_stats.c
+++ b/src/test/modules/test_custom_stats/test_custom_var_stats.c
@@ -237,7 +237,7 @@ test_custom_stats_var_to_serialized_data(const 
PgStat_HashKey *key,
         * be cross-checked with the key read from main stats file at loading
         * time.
         */
-       if (!write_chunk_s(fd_description, (PgStat_HashKey *) key))
+       if (!write_chunk_s(fd_description, key))
                return false;
        fd_description_offset += sizeof(PgStat_HashKey);
 
-- 
2.55.0

From dc95ee6606fec5ba003d4f2374b57f0715c2f8d1 Mon Sep 17 00:00:00 2001
From: Peter Eisentraut <[email protected]>
Date: Tue, 18 Aug 2026 10:52:24 +0200
Subject: [PATCH 10/11] Fix some -Wcast-qual warnings [readline]

The casting away of const is no longer needed.

rl_readline_name has been const since readline-4.2 (2001), libedit
since
2018 
(https://cvsweb.netbsd.org/bsdweb.cgi/src/lib/libedit/readline/readline.h?sortby=date,
rev 1.44)

see also commit 8666cf65ea6
---
 src/bin/psql/tab-complete.in.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/bin/psql/tab-complete.in.c b/src/bin/psql/tab-complete.in.c
index 190fff7ea0e..809ed1c22d7 100644
--- a/src/bin/psql/tab-complete.in.c
+++ b/src/bin/psql/tab-complete.in.c
@@ -1522,7 +1522,7 @@ static char *dequote_file_name(char *fname, int 
quote_char);
 void
 initialize_readline(void)
 {
-       rl_readline_name = (char *) pset.progname;
+       rl_readline_name = pset.progname;
        rl_attempted_completion_function = psql_completion;
 
 #ifdef USE_FILENAME_QUOTING_FUNCTIONS
-- 
2.55.0

From 853f8471b7ae5f14779d2fe715c74bae0d0de575 Mon Sep 17 00:00:00 2001
From: Peter Eisentraut <[email protected]>
Date: Tue, 18 Aug 2026 10:52:24 +0200
Subject: [PATCH 11/11] Change InputFunctionCall* to take a const char *str

It's reasonable to specify that the input string passed to these
functions isn't modified.

In each case, the input string is passed down to CStringGetDatum(),
which already takes a const char *, so this change just pushes that
API specification one level up.

A couple of callers benefit from this by no longer having to cast away
a const qualifier.

A few more functions that call input functions internally are changed
so that they can now offer a const qualified input string to their
callers.
---
 contrib/postgres_fdw/postgres_fdw.c           | 4 ++--
 src/backend/bootstrap/bootstrap.c             | 6 +++---
 src/backend/parser/parse_type.c               | 2 +-
 src/backend/statistics/extended_stats_funcs.c | 2 +-
 src/backend/utils/adt/domains.c               | 2 +-
 src/backend/utils/adt/rowtypes.c              | 2 +-
 src/backend/utils/fmgr/fmgr.c                 | 8 ++++----
 src/include/bootstrap/bootstrap.h             | 2 +-
 src/include/fmgr.h                            | 8 ++++----
 src/include/parser/parse_type.h               | 2 +-
 10 files changed, 19 insertions(+), 19 deletions(-)

diff --git a/contrib/postgres_fdw/postgres_fdw.c 
b/contrib/postgres_fdw/postgres_fdw.c
index 479a40719bd..6bb6f736c55 100644
--- a/contrib/postgres_fdw/postgres_fdw.c
+++ b/contrib/postgres_fdw/postgres_fdw.c
@@ -6228,7 +6228,7 @@ set_floatarr_arg(NullableDatum *arg, const char *s)
                Datum           val;
 
                fmgr_info(F_ARRAY_IN, &flinfo);
-               val = InputFunctionCall(&flinfo, (char *) s, FLOAT4OID, -1);
+               val = InputFunctionCall(&flinfo, s, FLOAT4OID, -1);
 
                arg->value = val;
                arg->isnull = false;
@@ -8425,7 +8425,7 @@ make_tuple_from_result_row(PGresult *res,
        foreach(lc, retrieved_attrs)
        {
                int                     i = lfirst_int(lc);
-               char       *valstr;
+               const char *valstr;
 
                /* fetch next column's textual value */
                if (PQgetisnull(res, row, j))
diff --git a/src/backend/bootstrap/bootstrap.c 
b/src/backend/bootstrap/bootstrap.c
index a678f345230..63e4d71b96b 100644
--- a/src/backend/bootstrap/bootstrap.c
+++ b/src/backend/bootstrap/bootstrap.c
@@ -51,7 +51,7 @@
 static void CheckerModeMain(void);
 static void bootstrap_signals(void);
 static Form_pg_attribute AllocateAttribute(void);
-static void InsertOneProargdefaultsValue(char *value);
+static void InsertOneProargdefaultsValue(const char *value);
 static void populate_typ_list(void);
 static Oid     gettype(char *type);
 static void cleanup(void);
@@ -698,7 +698,7 @@ InsertOneTuple(void)
  * ----------------
  */
 void
-InsertOneValue(char *value, int i)
+InsertOneValue(const char *value, int i)
 {
        Form_pg_attribute attr;
        Oid                     typoid;
@@ -765,7 +765,7 @@ InsertOneValue(char *value, int i)
  * ----------------
  */
 static void
-InsertOneProargdefaultsValue(char *value)
+InsertOneProargdefaultsValue(const char *value)
 {
        int                     pronargs;
        oidvector  *proargtypes;
diff --git a/src/backend/parser/parse_type.c b/src/backend/parser/parse_type.c
index bb7eccde9fd..262f2742b02 100644
--- a/src/backend/parser/parse_type.c
+++ b/src/backend/parser/parse_type.c
@@ -651,7 +651,7 @@ typeTypeCollation(Type typ)
  * (which might result in failure, if the input function rejects NULLs).
  */
 Datum
-stringTypeDatum(Type tp, char *string, int32 atttypmod)
+stringTypeDatum(Type tp, const char *string, int32 atttypmod)
 {
        Form_pg_type typform = (Form_pg_type) GETSTRUCT(tp);
        Oid                     typinput = typform->typinput;
diff --git a/src/backend/statistics/extended_stats_funcs.c 
b/src/backend/statistics/extended_stats_funcs.c
index a3e56933b91..988f81c6be4 100644
--- a/src/backend/statistics/extended_stats_funcs.c
+++ b/src/backend/statistics/extended_stats_funcs.c
@@ -1059,7 +1059,7 @@ array_in_safe(FmgrInfo *array_in, const char *s, Oid 
typid, int32 typmod,
         * Overwriting the existing hint (if any) is not ideal, and an error
         * context would only work for level >= ERROR.
         */
-       if (!InputFunctionCallSafe(array_in, (char *) s, typid, typmod,
+       if (!InputFunctionCallSafe(array_in, s, typid, typmod,
                                                           (Node *) &escontext, 
&result))
        {
                StringInfoData hint_str;
diff --git a/src/backend/utils/adt/domains.c b/src/backend/utils/adt/domains.c
index 50cd257e0bf..331439046a8 100644
--- a/src/backend/utils/adt/domains.c
+++ b/src/backend/utils/adt/domains.c
@@ -226,7 +226,7 @@ domain_check_input(Datum value, bool isnull, DomainIOData 
*my_extra,
 Datum
 domain_in(PG_FUNCTION_ARGS)
 {
-       char       *string;
+       const char *string;
        Oid                     domainType;
        Node       *escontext = fcinfo->context;
        DomainIOData *my_extra;
diff --git a/src/backend/utils/adt/rowtypes.c b/src/backend/utils/adt/rowtypes.c
index d94989ad116..0da0f10c2a0 100644
--- a/src/backend/utils/adt/rowtypes.c
+++ b/src/backend/utils/adt/rowtypes.c
@@ -167,7 +167,7 @@ record_in(PG_FUNCTION_ARGS)
                Form_pg_attribute att = TupleDescAttr(tupdesc, i);
                ColumnIOData *column_info = &my_extra->columns[i];
                Oid                     column_type = att->atttypid;
-               char       *column_data;
+               const char *column_data;
 
                /* Ignore dropped columns in datatype, but fill with nulls */
                if (att->attisdropped)
diff --git a/src/backend/utils/fmgr/fmgr.c b/src/backend/utils/fmgr/fmgr.c
index bfeceb7a92f..b2fd6dbb73d 100644
--- a/src/backend/utils/fmgr/fmgr.c
+++ b/src/backend/utils/fmgr/fmgr.c
@@ -1529,7 +1529,7 @@ OidFunctionCall9Coll(Oid functionId, Oid collation, Datum 
arg1, Datum arg2,
  * the same as FunctionCall3.
  */
 Datum
-InputFunctionCall(FmgrInfo *flinfo, char *str, Oid typioparam, int32 typmod)
+InputFunctionCall(FmgrInfo *flinfo, const char *str, Oid typioparam, int32 
typmod)
 {
        LOCAL_FCINFO(fcinfo, 3);
        Datum           result;
@@ -1583,7 +1583,7 @@ InputFunctionCall(FmgrInfo *flinfo, char *str, Oid 
typioparam, int32 typmod)
  * InputFunctionCall; the result will always be true if control returns.
  */
 bool
-InputFunctionCallSafe(FmgrInfo *flinfo, char *str,
+InputFunctionCallSafe(FmgrInfo *flinfo, const char *str,
                                          Oid typioparam, int32 typmod,
                                          Node *escontext,
                                          Datum *result)
@@ -1638,7 +1638,7 @@ InputFunctionCallSafe(FmgrInfo *flinfo, char *str,
  * look at FmgrInfo, since there won't be any.
  */
 bool
-DirectInputFunctionCallSafe(PGFunction func, char *str,
+DirectInputFunctionCallSafe(PGFunction func, const char *str,
                                                        Oid typioparam, int32 
typmod,
                                                        Node *escontext,
                                                        Datum *result)
@@ -1752,7 +1752,7 @@ SendFunctionCall(FmgrInfo *flinfo, Datum val)
  * in seldom-executed code paths.  They are not only slow but leak memory.
  */
 Datum
-OidInputFunctionCall(Oid functionId, char *str, Oid typioparam, int32 typmod)
+OidInputFunctionCall(Oid functionId, const char *str, Oid typioparam, int32 
typmod)
 {
        FmgrInfo        flinfo;
 
diff --git a/src/include/bootstrap/bootstrap.h 
b/src/include/bootstrap/bootstrap.h
index c0bba03a5ee..165eb03de2e 100644
--- a/src/include/bootstrap/bootstrap.h
+++ b/src/include/bootstrap/bootstrap.h
@@ -41,7 +41,7 @@ extern void boot_openrel(char *relname);
 
 extern void DefineAttr(char *name, char *type, int attnum, int nullness);
 extern void InsertOneTuple(void);
-extern void InsertOneValue(char *value, int i);
+extern void InsertOneValue(const char *value, int i);
 extern void InsertOneNull(int i);
 
 extern void index_register(Oid heap, Oid ind, const IndexInfo *indexInfo);
diff --git a/src/include/fmgr.h b/src/include/fmgr.h
index 38e143ac670..04b7914095f 100644
--- a/src/include/fmgr.h
+++ b/src/include/fmgr.h
@@ -744,17 +744,17 @@ extern Datum OidFunctionCall9Coll(Oid functionId, Oid 
collation,
 
 
 /* Special cases for convenient invocation of datatype I/O functions. */
-extern Datum InputFunctionCall(FmgrInfo *flinfo, char *str,
+extern Datum InputFunctionCall(FmgrInfo *flinfo, const char *str,
                                                           Oid typioparam, 
int32 typmod);
-extern bool InputFunctionCallSafe(FmgrInfo *flinfo, char *str,
+extern bool InputFunctionCallSafe(FmgrInfo *flinfo, const char *str,
                                                                  Oid 
typioparam, int32 typmod,
                                                                  Node 
*escontext,
                                                                  Datum 
*result);
-extern bool DirectInputFunctionCallSafe(PGFunction func, char *str,
+extern bool DirectInputFunctionCallSafe(PGFunction func, const char *str,
                                                                                
Oid typioparam, int32 typmod,
                                                                                
Node *escontext,
                                                                                
Datum *result);
-extern Datum OidInputFunctionCall(Oid functionId, char *str,
+extern Datum OidInputFunctionCall(Oid functionId, const char *str,
                                                                  Oid 
typioparam, int32 typmod);
 extern char *OutputFunctionCall(FmgrInfo *flinfo, Datum val);
 extern char *OidOutputFunctionCall(Oid functionId, Datum val);
diff --git a/src/include/parser/parse_type.h b/src/include/parser/parse_type.h
index a335807b0b0..79f10b5b5b2 100644
--- a/src/include/parser/parse_type.h
+++ b/src/include/parser/parse_type.h
@@ -46,7 +46,7 @@ extern bool typeByVal(Type t);
 extern char *typeTypeName(Type t);
 extern Oid     typeTypeRelid(Type typ);
 extern Oid     typeTypeCollation(Type typ);
-extern Datum stringTypeDatum(Type tp, char *string, int32 atttypmod);
+extern Datum stringTypeDatum(Type tp, const char *string, int32 atttypmod);
 
 extern Oid     typeidTypeRelid(Oid type_id);
 extern Oid     typeOrDomainTypeRelid(Oid type_id);
-- 
2.55.0

Reply via email to