Currently, when the argument of copyObject() is const-qualified, the return type is also, because the use of typeof carries over all the qualifiers. This is incorrect, since the point of copyObject() is to make a copy to mutate. But apparently no code ran into it.

The new implementation uses typeof_unqual, which drops the qualifiers, making this work correctly.

typeof_unqual is standardized in C23, but all recent versions of all the usual compilers support it even in non-C23 mode, at least as __typeof_unqual__. We add a configure/meson test for typeof_unqual and __typeof_unqual__ and use it if it's available, else we use the existing fallback of just returning void *.

(Even MSVC supports it, if we use a slightly newer version than is on CI. For example, the new buildfarm member unicorn would support it.)

The second patch make some changes to take advantage of this improved qualifier handling. EventTriggerCollectSimpleCommand() is a good example: It takes a node tree and makes a copy that it keeps around for its internal purposes, but it can't communicate via its function signature that it promises not scribble on the passed node tree. That is now fixed.

The obvious drawback is that if you use an older compiler that supports typeof but not typeof_unqual, this change will make you lose that check. Currently, on the Cirrus CI system, only the NetBSD and OpenBSD tasks are affected by this.

Anyway, the reason I'm posting this now instead of, say, waiting another year, is that over in the thread "Make copyObject work in C++"[0], we're discussing, well, making copyObject() work in (standard) C++ (typeof and typeof_unqual are not in C++). Assuming we want to make the typeof_unqual change in principle, I figured it would be worth considering doing that change first and then developing a C++ equivalent of that, instead of making a C++ equivalent of the current logic and then having to find another C++ solution when changing to typeof_unqual.


[0]: https://www.postgresql.org/message-id/flat/cageczqr21onnkizo_1rlwo0-16kg1jbxnvq-wymyw0-_1cu...@mail.gmail.com
From b136e702351ad50b3f96b8289f01f9e265000412 Mon Sep 17 00:00:00 2001
From: Peter Eisentraut <[email protected]>
Date: Tue, 20 Jan 2026 10:01:46 +0100
Subject: [PATCH 1/2] Change copyObject() to use typeof_unqual

Currently, when the argument of copyObject() is const-qualified, the
return type is also, because the use of typeof carries over all the
qualifiers.  This is incorrect, since the point of copyObject() is to
make a copy to mutate.  But apparently no code ran into it.

The new implementation uses typeof_unqual, which drops the qualifiers,
making this work correctly.

typeof_unqual is standardized in C23, but all recent versions of all
the usual compilers support it even in non-C23 mode, at least as
__typeof_unqual__.  We add a configure/meson test for typeof_unqual
and __typeof_unqual__ and use it if it's available, else we use the
existing fallback of just returning void *.
---
 config/c-compiler.m4       | 25 +++++++++++++++++++++++
 configure                  | 42 ++++++++++++++++++++++++++++++++++++++
 configure.ac               |  1 +
 meson.build                | 24 ++++++++++++++++++++++
 src/include/nodes/nodes.h  |  4 ++--
 src/include/pg_config.h.in |  7 +++++++
 6 files changed, 101 insertions(+), 2 deletions(-)

diff --git a/config/c-compiler.m4 b/config/c-compiler.m4
index 1509dbfa2ab..7179a73bd2c 100644
--- a/config/c-compiler.m4
+++ b/config/c-compiler.m4
@@ -192,6 +192,31 @@ if test "$pgac_cv_c_typeof" != no; then
 fi])# PGAC_C_TYPEOF
 
 
+# PGAC_C_TYPEOF_UNQUAL
+# --------------------
+# Check if the C compiler understands typeof_unqual or a variant.  Define
+# HAVE_TYPEOF_UNQUAL if so, and define 'typeof_unqual' to the actual key word.
+#
+AC_DEFUN([PGAC_C_TYPEOF_UNQUAL],
+[AC_CACHE_CHECK(for typeof_unqual, pgac_cv_c_typeof_unqual,
+[pgac_cv_c_typeof_unqual=no
+for pgac_kw in typeof_unqual __typeof_unqual__; do
+  AC_COMPILE_IFELSE([AC_LANG_PROGRAM([],
+[int x = 0;
+$pgac_kw(x) y;
+y = x;
+return y;])],
+[pgac_cv_c_typeof_unqual=$pgac_kw])
+  test "$pgac_cv_c_typeof_unqual" != no && break
+done])
+if test "$pgac_cv_c_typeof_unqual" != no; then
+  AC_DEFINE(HAVE_TYPEOF_UNQUAL, 1,
+            [Define to 1 if your compiler understands `typeof_unqual' or 
something similar.])
+  if test "$pgac_cv_c_typeof_unqual" != typeof_unqual; then
+    AC_DEFINE_UNQUOTED(typeof_unqual, $pgac_cv_c_typeof_unqual, [Define to how 
the compiler spells `typeof_unqual'.])
+  fi
+fi])# PGAC_C_TYPEOF_UNQUAL
+
 
 # PGAC_C_TYPES_COMPATIBLE
 # -----------------------
diff --git a/configure b/configure
index fb6a4914b06..b72123635c5 100755
--- a/configure
+++ b/configure
@@ -14919,6 +14919,48 @@ _ACEOF
 
   fi
 fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for typeof_unqual" >&5
+$as_echo_n "checking for typeof_unqual... " >&6; }
+if ${pgac_cv_c_typeof_unqual+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  pgac_cv_c_typeof_unqual=no
+for pgac_kw in typeof_unqual __typeof_unqual__; do
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+int
+main ()
+{
+int x = 0;
+$pgac_kw(x) y;
+y = x;
+return y;
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+  pgac_cv_c_typeof_unqual=$pgac_kw
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+  test "$pgac_cv_c_typeof_unqual" != no && break
+done
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $pgac_cv_c_typeof_unqual" >&5
+$as_echo "$pgac_cv_c_typeof_unqual" >&6; }
+if test "$pgac_cv_c_typeof_unqual" != no; then
+
+$as_echo "#define HAVE_TYPEOF_UNQUAL 1" >>confdefs.h
+
+  if test "$pgac_cv_c_typeof_unqual" != typeof_unqual; then
+
+cat >>confdefs.h <<_ACEOF
+#define typeof_unqual $pgac_cv_c_typeof_unqual
+_ACEOF
+
+  fi
+fi
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for 
__builtin_types_compatible_p" >&5
 $as_echo_n "checking for __builtin_types_compatible_p... " >&6; }
 if ${pgac_cv__types_compatible+:} false; then :
diff --git a/configure.ac b/configure.ac
index d3febfe58f1..42f48fc8d19 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1677,6 +1677,7 @@ PGAC_PRINTF_ARCHETYPE
 PGAC_CXX_PRINTF_ARCHETYPE
 PGAC_C_STATEMENT_EXPRESSIONS
 PGAC_C_TYPEOF
+PGAC_C_TYPEOF_UNQUAL
 PGAC_C_TYPES_COMPATIBLE
 PGAC_C_BUILTIN_CONSTANT_P
 PGAC_C_BUILTIN_OP_OVERFLOW
diff --git a/meson.build b/meson.build
index 6d304f32fb0..9b916878207 100644
--- a/meson.build
+++ b/meson.build
@@ -2851,6 +2851,30 @@ int main(void)
   endif
 endforeach
 
+# Check if the C compiler understands typeof_unqual or a variant.  Define
+# HAVE_TYPEOF_UNQUAL if so, and define 'typeof_unqual' to the actual key word.
+foreach kw : ['typeof_unqual', '__typeof_unqual__']
+  if cc.compiles('''
+int main(void)
+{
+    int x = 0;
+    @0@(x) y;
+    y = x;
+    return y;
+}
+'''.format(kw),
+    name: kw,
+    args: test_c_args, include_directories: postgres_inc)
+
+    cdata.set('HAVE_TYPEOF_UNQUAL', 1)
+    if kw != 'typeof_unqual'
+      cdata.set('typeof_unqual', kw)
+    endif
+
+    break
+  endif
+endforeach
+
 
 # MSVC doesn't cope well with defining restrict to __restrict, the
 # spelling it understands, because it conflicts with
diff --git a/src/include/nodes/nodes.h b/src/include/nodes/nodes.h
index b6ad28618ab..ba6dd7f3899 100644
--- a/src/include/nodes/nodes.h
+++ b/src/include/nodes/nodes.h
@@ -226,8 +226,8 @@ extern int16 *readAttrNumberCols(int numCols);
 extern void *copyObjectImpl(const void *from);
 
 /* cast result back to argument type, if supported by compiler */
-#ifdef HAVE_TYPEOF
-#define copyObject(obj) ((typeof(obj)) copyObjectImpl(obj))
+#ifdef HAVE_TYPEOF_UNQUAL
+#define copyObject(obj) ((typeof_unqual(*(obj)) *) copyObjectImpl(obj))
 #else
 #define copyObject(obj) copyObjectImpl(obj)
 #endif
diff --git a/src/include/pg_config.h.in b/src/include/pg_config.h.in
index 339268dc8ef..c089f2252c3 100644
--- a/src/include/pg_config.h.in
+++ b/src/include/pg_config.h.in
@@ -454,6 +454,10 @@
 /* Define to 1 if your compiler understands `typeof' or something similar. */
 #undef HAVE_TYPEOF
 
+/* Define to 1 if your compiler understands `typeof_unqual' or something
+   similar. */
+#undef HAVE_TYPEOF_UNQUAL
+
 /* Define to 1 if you have the <uchar.h> header file. */
 #undef HAVE_UCHAR_H
 
@@ -806,3 +810,6 @@
 
 /* Define to how the compiler spells `typeof'. */
 #undef typeof
+
+/* Define to how the compiler spells `typeof_unqual'. */
+#undef typeof_unqual

base-commit: 7ebb64c557570647e3fcf6f5f1549e882ed26489
-- 
2.52.0

From a394ca6303c7c88da1430b6ab66d65e6efc695ae Mon Sep 17 00:00:00 2001
From: Peter Eisentraut <[email protected]>
Date: Tue, 20 Jan 2026 10:01:46 +0100
Subject: [PATCH 2/2] Add some const qualifiers enabled by typeof_unqual change
 on copyObject

---
 src/backend/catalog/index.c               |  2 +-
 src/backend/commands/event_trigger.c      | 14 +++++++-------
 src/backend/commands/indexcmds.c          |  4 ++--
 src/backend/commands/trigger.c            |  4 ++--
 src/backend/optimizer/prep/prepjointree.c |  4 ++--
 src/backend/partitioning/partprune.c      | 12 ++++++------
 src/backend/rewrite/rewriteManip.c        | 17 ++++++++++-------
 src/backend/utils/cache/plancache.c       |  2 +-
 src/include/commands/defrem.h             |  2 +-
 src/include/commands/event_trigger.h      | 14 +++++++-------
 src/include/commands/trigger.h            |  4 ++--
 src/include/rewrite/rewriteManip.h        |  4 ++--
 src/include/utils/plancache.h             |  2 +-
 13 files changed, 44 insertions(+), 41 deletions(-)

diff --git a/src/backend/catalog/index.c b/src/backend/catalog/index.c
index 43de42ce39e..d4ca965df19 100644
--- a/src/backend/catalog/index.c
+++ b/src/backend/catalog/index.c
@@ -3705,7 +3705,7 @@ reindex_index(const ReindexStmt *stmt, Oid indexId,
                ObjectAddressSet(address, RelationRelationId, indexId);
                EventTriggerCollectSimpleCommand(address,
                                                                                
 InvalidObjectAddress,
-                                                                               
 (Node *) stmt);
+                                                                               
 (const Node *) stmt);
        }
 
        /*
diff --git a/src/backend/commands/event_trigger.c 
b/src/backend/commands/event_trigger.c
index 028f9e2de90..ab331eb3ccb 100644
--- a/src/backend/commands/event_trigger.c
+++ b/src/backend/commands/event_trigger.c
@@ -1714,7 +1714,7 @@ EventTriggerUndoInhibitCommandCollection(void)
 void
 EventTriggerCollectSimpleCommand(ObjectAddress address,
                                                                 ObjectAddress 
secondaryObject,
-                                                                Node 
*parsetree)
+                                                                const Node 
*parsetree)
 {
        MemoryContext oldcxt;
        CollectedCommand *command;
@@ -1750,7 +1750,7 @@ EventTriggerCollectSimpleCommand(ObjectAddress address,
  * add it to the command list.
  */
 void
-EventTriggerAlterTableStart(Node *parsetree)
+EventTriggerAlterTableStart(const Node *parsetree)
 {
        MemoryContext oldcxt;
        CollectedCommand *command;
@@ -1802,7 +1802,7 @@ EventTriggerAlterTableRelid(Oid objectId)
  * internally, so that's all that this code needs to handle at the moment.
  */
 void
-EventTriggerCollectAlterTableSubcmd(Node *subcmd, ObjectAddress address)
+EventTriggerCollectAlterTableSubcmd(const Node *subcmd, ObjectAddress address)
 {
        MemoryContext oldcxt;
        CollectedATSubcmd *newsub;
@@ -1919,7 +1919,7 @@ EventTriggerCollectGrant(InternalGrant *istmt)
  *             executed
  */
 void
-EventTriggerCollectAlterOpFam(AlterOpFamilyStmt *stmt, Oid opfamoid,
+EventTriggerCollectAlterOpFam(const AlterOpFamilyStmt *stmt, Oid opfamoid,
                                                          List *operators, List 
*procedures)
 {
        MemoryContext oldcxt;
@@ -1952,7 +1952,7 @@ EventTriggerCollectAlterOpFam(AlterOpFamilyStmt *stmt, 
Oid opfamoid,
  *             Save data about a CREATE OPERATOR CLASS command being executed
  */
 void
-EventTriggerCollectCreateOpClass(CreateOpClassStmt *stmt, Oid opcoid,
+EventTriggerCollectCreateOpClass(const CreateOpClassStmt *stmt, Oid opcoid,
                                                                 List 
*operators, List *procedures)
 {
        MemoryContext oldcxt;
@@ -1986,7 +1986,7 @@ EventTriggerCollectCreateOpClass(CreateOpClassStmt *stmt, 
Oid opcoid,
  *             executed
  */
 void
-EventTriggerCollectAlterTSConfig(AlterTSConfigurationStmt *stmt, Oid cfgId,
+EventTriggerCollectAlterTSConfig(const AlterTSConfigurationStmt *stmt, Oid 
cfgId,
                                                                 Oid *dictIds, 
int ndicts)
 {
        MemoryContext oldcxt;
@@ -2021,7 +2021,7 @@ EventTriggerCollectAlterTSConfig(AlterTSConfigurationStmt 
*stmt, Oid cfgId,
  *             executed
  */
 void
-EventTriggerCollectAlterDefPrivs(AlterDefaultPrivilegesStmt *stmt)
+EventTriggerCollectAlterDefPrivs(const AlterDefaultPrivilegesStmt *stmt)
 {
        MemoryContext oldcxt;
        CollectedCommand *command;
diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c
index 635679cc1f2..6c7f8180bc2 100644
--- a/src/backend/commands/indexcmds.c
+++ b/src/backend/commands/indexcmds.c
@@ -543,7 +543,7 @@ WaitForOlderSnapshots(TransactionId limitXmin, bool 
progress)
 ObjectAddress
 DefineIndex(ParseState *pstate,
                        Oid tableId,
-                       IndexStmt *stmt,
+                       const IndexStmt *stmt,
                        Oid indexRelationId,
                        Oid parentIndexId,
                        Oid parentConstraintId,
@@ -4047,7 +4047,7 @@ ReindexRelationConcurrently(const ReindexStmt *stmt, Oid 
relationOid, const Rein
                        ObjectAddressSet(address, RelationRelationId, 
newIndexId);
                        EventTriggerCollectSimpleCommand(address,
                                                                                
         InvalidObjectAddress,
-                                                                               
         (Node *) stmt);
+                                                                               
         (const Node *) stmt);
                }
        }
 
diff --git a/src/backend/commands/trigger.c b/src/backend/commands/trigger.c
index d30fda660eb..76ecdec34c7 100644
--- a/src/backend/commands/trigger.c
+++ b/src/backend/commands/trigger.c
@@ -157,7 +157,7 @@ static HeapTuple check_modified_virtual_generated(TupleDesc 
tupdesc, HeapTuple t
  * (but see CloneRowTriggersToPartition).
  */
 ObjectAddress
-CreateTrigger(CreateTrigStmt *stmt, const char *queryString,
+CreateTrigger(const CreateTrigStmt *stmt, const char *queryString,
                          Oid relOid, Oid refRelOid, Oid constraintOid, Oid 
indexOid,
                          Oid funcoid, Oid parentTriggerOid, Node *whenClause,
                          bool isInternal, bool in_partition)
@@ -174,7 +174,7 @@ CreateTrigger(CreateTrigStmt *stmt, const char *queryString,
  * (always/origin/replica/disabled) can be specified.
  */
 ObjectAddress
-CreateTriggerFiringOn(CreateTrigStmt *stmt, const char *queryString,
+CreateTriggerFiringOn(const CreateTrigStmt *stmt, const char *queryString,
                                          Oid relOid, Oid refRelOid, Oid 
constraintOid,
                                          Oid indexOid, Oid funcoid, Oid 
parentTriggerOid,
                                          Node *whenClause, bool isInternal, 
bool in_partition,
diff --git a/src/backend/optimizer/prep/prepjointree.c 
b/src/backend/optimizer/prep/prepjointree.c
index c80bfc88d82..9e439bd1522 100644
--- a/src/backend/optimizer/prep/prepjointree.c
+++ b/src/backend/optimizer/prep/prepjointree.c
@@ -148,7 +148,7 @@ static void replace_vars_in_jointree(Node *jtnode,
                                                                         
pullup_replace_vars_context *context);
 static Node *pullup_replace_vars(Node *expr,
                                                                 
pullup_replace_vars_context *context);
-static Node *pullup_replace_vars_callback(Var *var,
+static Node *pullup_replace_vars_callback(const Var *var,
                                                                                
  replace_rte_variables_context *context);
 static Query *pullup_replace_vars_subquery(Query *query,
                                                                                
   pullup_replace_vars_context *context);
@@ -2694,7 +2694,7 @@ pullup_replace_vars(Node *expr, 
pullup_replace_vars_context *context)
 }
 
 static Node *
-pullup_replace_vars_callback(Var *var,
+pullup_replace_vars_callback(const Var *var,
                                                         
replace_rte_variables_context *context)
 {
        pullup_replace_vars_context *rcon = (pullup_replace_vars_context *) 
context->callback_arg;
diff --git a/src/backend/partitioning/partprune.c 
b/src/backend/partitioning/partprune.c
index a4bbb10a3b7..9dfdf315dd1 100644
--- a/src/backend/partitioning/partprune.c
+++ b/src/backend/partitioning/partprune.c
@@ -158,7 +158,7 @@ static PartitionPruneStep 
*gen_prune_step_combine(GeneratePruningStepsContext *c
 static List *gen_prune_steps_from_opexps(GeneratePruningStepsContext *context,
                                                                                
 List **keyclauses, Bitmapset *nullkeys);
 static PartClauseMatchStatus 
match_clause_to_partition_key(GeneratePruningStepsContext *context,
-                                                                               
                                   Expr *clause, Expr *partkey, int partkeyidx,
+                                                                               
                                   const Expr *clause, const Expr *partkey, int 
partkeyidx,
                                                                                
                                   bool *clause_is_not_null,
                                                                                
                                   PartClauseInfo **pc, List **clause_steps);
 static List *get_steps_using_prefix(GeneratePruningStepsContext *context,
@@ -196,8 +196,8 @@ static PruneStepResult 
*perform_pruning_combine_step(PartitionPruneContext *cont
                                                                                
                         PartitionPruneStepCombine *cstep,
                                                                                
                         PruneStepResult **step_results);
 static PartClauseMatchStatus match_boolean_partition_clause(Oid partopfamily,
-                                                                               
                                        Expr *clause,
-                                                                               
                                        Expr *partkey,
+                                                                               
                                        const Expr *clause,
+                                                                               
                                        const Expr *partkey,
                                                                                
                                        Expr **outconst,
                                                                                
                                        bool *notclause);
 static void partkey_datum_from_expr(PartitionPruneContext *context,
@@ -1816,7 +1816,7 @@ gen_prune_steps_from_opexps(GeneratePruningStepsContext 
*context,
  */
 static PartClauseMatchStatus
 match_clause_to_partition_key(GeneratePruningStepsContext *context,
-                                                         Expr *clause, Expr 
*partkey, int partkeyidx,
+                                                         const Expr *clause, 
const Expr *partkey, int partkeyidx,
                                                          bool 
*clause_is_not_null, PartClauseInfo **pc,
                                                          List **clause_steps)
 {
@@ -3697,10 +3697,10 @@ perform_pruning_combine_step(PartitionPruneContext 
*context,
  * 'partkey'.
  */
 static PartClauseMatchStatus
-match_boolean_partition_clause(Oid partopfamily, Expr *clause, Expr *partkey,
+match_boolean_partition_clause(Oid partopfamily, const Expr *clause, const 
Expr *partkey,
                                                           Expr **outconst, 
bool *notclause)
 {
-       Expr       *leftop;
+       const Expr *leftop;
 
        *outconst = NULL;
        *notclause = false;
diff --git a/src/backend/rewrite/rewriteManip.c 
b/src/backend/rewrite/rewriteManip.c
index 6fa174412f2..acd20f61f5a 100644
--- a/src/backend/rewrite/rewriteManip.c
+++ b/src/backend/rewrite/rewriteManip.c
@@ -1768,7 +1768,7 @@ typedef struct
 } ReplaceVarsFromTargetList_context;
 
 static Node *
-ReplaceVarsFromTargetList_callback(Var *var,
+ReplaceVarsFromTargetList_callback(const Var *var,
                                                                   
replace_rte_variables_context *context)
 {
        ReplaceVarsFromTargetList_context *rcon = 
(ReplaceVarsFromTargetList_context *) context->callback_arg;
@@ -1789,7 +1789,7 @@ ReplaceVarsFromTargetList_callback(Var *var,
 }
 
 Node *
-ReplaceVarFromTargetList(Var *var,
+ReplaceVarFromTargetList(const Var *var,
                                                 RangeTblEntry *target_rte,
                                                 List *targetlist,
                                                 int result_relation,
@@ -1875,11 +1875,14 @@ ReplaceVarFromTargetList(Var *var,
                                break;
 
                        case REPLACEVARS_CHANGE_VARNO:
-                               var = copyObject(var);
-                               var->varno = nomatch_varno;
-                               var->varlevelsup = 0;
-                               /* we leave the syntactic referent alone */
-                               return (Node *) var;
+                               {
+                                       Var                *newvar = 
copyObject(var);
+
+                                       newvar->varno = nomatch_varno;
+                                       newvar->varlevelsup = 0;
+                                       /* we leave the syntactic referent 
alone */
+                                       return (Node *) newvar;
+                               }
 
                        case REPLACEVARS_SUBSTITUTE_NULL:
                                {
diff --git a/src/backend/utils/cache/plancache.c 
b/src/backend/utils/cache/plancache.c
index 37d5d73b7fb..fbb11812d5a 100644
--- a/src/backend/utils/cache/plancache.c
+++ b/src/backend/utils/cache/plancache.c
@@ -180,7 +180,7 @@ InitPlanCache(void)
  * commandTag: command tag for query, or UNKNOWN if empty query
  */
 CachedPlanSource *
-CreateCachedPlan(RawStmt *raw_parse_tree,
+CreateCachedPlan(const RawStmt *raw_parse_tree,
                                 const char *query_string,
                                 CommandTag commandTag)
 {
diff --git a/src/include/commands/defrem.h b/src/include/commands/defrem.h
index 8f4a2d9bbc1..d080ad59b71 100644
--- a/src/include/commands/defrem.h
+++ b/src/include/commands/defrem.h
@@ -27,7 +27,7 @@ extern void RemoveObjects(DropStmt *stmt);
 /* commands/indexcmds.c */
 extern ObjectAddress DefineIndex(ParseState *pstate,
                                                                 Oid tableId,
-                                                                IndexStmt 
*stmt,
+                                                                const 
IndexStmt *stmt,
                                                                 Oid 
indexRelationId,
                                                                 Oid 
parentIndexId,
                                                                 Oid 
parentConstraintId,
diff --git a/src/include/commands/event_trigger.h 
b/src/include/commands/event_trigger.h
index c662782bb1e..27340655061 100644
--- a/src/include/commands/event_trigger.h
+++ b/src/include/commands/event_trigger.h
@@ -75,23 +75,23 @@ extern void EventTriggerUndoInhibitCommandCollection(void);
 
 extern void EventTriggerCollectSimpleCommand(ObjectAddress address,
                                                                                
         ObjectAddress secondaryObject,
-                                                                               
         Node *parsetree);
+                                                                               
         const Node *parsetree);
 
-extern void EventTriggerAlterTableStart(Node *parsetree);
+extern void EventTriggerAlterTableStart(const Node *parsetree);
 extern void EventTriggerAlterTableRelid(Oid objectId);
-extern void EventTriggerCollectAlterTableSubcmd(Node *subcmd,
+extern void EventTriggerCollectAlterTableSubcmd(const Node *subcmd,
                                                                                
                ObjectAddress address);
 extern void EventTriggerAlterTableEnd(void);
 
 extern void EventTriggerCollectGrant(InternalGrant *istmt);
-extern void EventTriggerCollectAlterOpFam(AlterOpFamilyStmt *stmt,
+extern void EventTriggerCollectAlterOpFam(const AlterOpFamilyStmt *stmt,
                                                                                
  Oid opfamoid, List *operators,
                                                                                
  List *procedures);
-extern void EventTriggerCollectCreateOpClass(CreateOpClassStmt *stmt,
+extern void EventTriggerCollectCreateOpClass(const CreateOpClassStmt *stmt,
                                                                                
         Oid opcoid, List *operators,
                                                                                
         List *procedures);
-extern void EventTriggerCollectAlterTSConfig(AlterTSConfigurationStmt *stmt,
+extern void EventTriggerCollectAlterTSConfig(const AlterTSConfigurationStmt 
*stmt,
                                                                                
         Oid cfgId, Oid *dictIds, int ndicts);
-extern void EventTriggerCollectAlterDefPrivs(AlterDefaultPrivilegesStmt *stmt);
+extern void EventTriggerCollectAlterDefPrivs(const AlterDefaultPrivilegesStmt 
*stmt);
 
 #endif                                                 /* EVENT_TRIGGER_H */
diff --git a/src/include/commands/trigger.h b/src/include/commands/trigger.h
index b60317c7a75..209b806a2db 100644
--- a/src/include/commands/trigger.h
+++ b/src/include/commands/trigger.h
@@ -151,11 +151,11 @@ extern PGDLLIMPORT int SessionReplicationRole;
 #define TRIGGER_FIRES_ON_REPLICA                       'R'
 #define TRIGGER_DISABLED                                       'D'
 
-extern ObjectAddress CreateTrigger(CreateTrigStmt *stmt, const char 
*queryString,
+extern ObjectAddress CreateTrigger(const CreateTrigStmt *stmt, const char 
*queryString,
                                                                   Oid relOid, 
Oid refRelOid, Oid constraintOid, Oid indexOid,
                                                                   Oid funcoid, 
Oid parentTriggerOid, Node *whenClause,
                                                                   bool 
isInternal, bool in_partition);
-extern ObjectAddress CreateTriggerFiringOn(CreateTrigStmt *stmt, const char 
*queryString,
+extern ObjectAddress CreateTriggerFiringOn(const CreateTrigStmt *stmt, const 
char *queryString,
                                                                                
   Oid relOid, Oid refRelOid, Oid constraintOid,
                                                                                
   Oid indexOid, Oid funcoid, Oid parentTriggerOid,
                                                                                
   Node *whenClause, bool isInternal, bool in_partition,
diff --git a/src/include/rewrite/rewriteManip.h 
b/src/include/rewrite/rewriteManip.h
index f8216c22fb7..a6d4e888e06 100644
--- a/src/include/rewrite/rewriteManip.h
+++ b/src/include/rewrite/rewriteManip.h
@@ -22,7 +22,7 @@ typedef struct AttrMap AttrMap; /* avoid including attmap.h 
here */
 
 typedef struct replace_rte_variables_context replace_rte_variables_context;
 
-typedef Node *(*replace_rte_variables_callback) (Var *var,
+typedef Node *(*replace_rte_variables_callback) (const Var *var,
                                                                                
                 replace_rte_variables_context *context);
 
 struct replace_rte_variables_context
@@ -104,7 +104,7 @@ extern Node *map_variable_attnos(Node *node,
                                                                 const AttrMap 
*attno_map,
                                                                 Oid 
to_rowtype, bool *found_whole_row);
 
-extern Node *ReplaceVarFromTargetList(Var *var,
+extern Node *ReplaceVarFromTargetList(const Var *var,
                                                                          
RangeTblEntry *target_rte,
                                                                          List 
*targetlist,
                                                                          int 
result_relation,
diff --git a/src/include/utils/plancache.h b/src/include/utils/plancache.h
index 984c51515c6..7a4a85c8038 100644
--- a/src/include/utils/plancache.h
+++ b/src/include/utils/plancache.h
@@ -202,7 +202,7 @@ extern void ResetPlanCache(void);
 
 extern void ReleaseAllPlanCacheRefsInOwner(ResourceOwner owner);
 
-extern CachedPlanSource *CreateCachedPlan(RawStmt *raw_parse_tree,
+extern CachedPlanSource *CreateCachedPlan(const RawStmt *raw_parse_tree,
                                                                                
  const char *query_string,
                                                                                
  CommandTag commandTag);
 extern CachedPlanSource *CreateCachedPlanForQuery(Query *analyzed_parse_tree,
-- 
2.52.0

Reply via email to