Here is a patch set with some straightforward code cleanup in index.c and indexcmds.c and some adjacent places.

First, I have added const qualifiers to all the function prototypes as appropriate. This didn't require any additional casts or tricks.

Then, I have renamed some function arguments for clarity. For example, several functions had an argument like

    Oid *classObjectId

This is confusing in more than one way: The "class" is actually the operator class, not the pg_class entry, and the argument is actually an array, not a single value as the name would suggest. The amended version

    const Oid *opclassIds

should be much clearer.

Also, about half the code in these files already used the better naming system, so this change also makes everything within these files more consistent.

Third, I removed some line breaks around the places that I touched anyway. In some cases, with the renaming, the lines didn't seem that long anymore to warrant a line break.
From dfa595a003ea237a7431603824b9e5f28c5b20fa Mon Sep 17 00:00:00 2001
From: Peter Eisentraut <pe...@eisentraut.org>
Date: Wed, 16 Aug 2023 07:45:28 +0200
Subject: [PATCH 1/3] Add const decorations

in index.c and indexcmds.c and some adjacent places.  This especially
makes it easier to understand for some complicated function signatures
which are the input and the output arguments.
---
 src/backend/bootstrap/bootstrap.c |  2 +-
 src/backend/catalog/heap.c        |  2 +-
 src/backend/catalog/index.c       | 66 +++++++++++++++----------------
 src/backend/catalog/namespace.c   | 10 ++---
 src/backend/commands/indexcmds.c  | 58 +++++++++++++--------------
 src/include/bootstrap/bootstrap.h |  2 +-
 src/include/catalog/heap.h        |  2 +-
 src/include/catalog/index.h       | 28 ++++++-------
 src/include/catalog/namespace.h   | 10 ++---
 src/include/commands/defrem.h     |  8 ++--
 10 files changed, 94 insertions(+), 94 deletions(-)

diff --git a/src/backend/bootstrap/bootstrap.c 
b/src/backend/bootstrap/bootstrap.c
index 49e956b2c5..4cc2efa95c 100644
--- a/src/backend/bootstrap/bootstrap.c
+++ b/src/backend/bootstrap/bootstrap.c
@@ -914,7 +914,7 @@ AllocateAttribute(void)
 void
 index_register(Oid heap,
                           Oid ind,
-                          IndexInfo *indexInfo)
+                          const IndexInfo *indexInfo)
 {
        IndexList  *newind;
        MemoryContext oldcxt;
diff --git a/src/backend/catalog/heap.c b/src/backend/catalog/heap.c
index 4c30c7d461..c89b0bfa75 100644
--- a/src/backend/catalog/heap.c
+++ b/src/backend/catalog/heap.c
@@ -697,7 +697,7 @@ void
 InsertPgAttributeTuples(Relation pg_attribute_rel,
                                                TupleDesc tupdesc,
                                                Oid new_rel_oid,
-                                               Datum *attoptions,
+                                               const Datum *attoptions,
                                                CatalogIndexState indstate)
 {
        TupleTableSlot **slot;
diff --git a/src/backend/catalog/index.c b/src/backend/catalog/index.c
index eb2b8d84c3..2a30eb3a32 100644
--- a/src/backend/catalog/index.c
+++ b/src/backend/catalog/index.c
@@ -106,20 +106,20 @@ typedef struct
 /* non-export function prototypes */
 static bool relationHasPrimaryKey(Relation rel);
 static TupleDesc ConstructTupleDescriptor(Relation heapRelation,
-                                                                               
  IndexInfo *indexInfo,
-                                                                               
  List *indexColNames,
+                                                                               
  const IndexInfo *indexInfo,
+                                                                               
  const List *indexColNames,
                                                                                
  Oid accessMethodObjectId,
-                                                                               
  Oid *collationObjectId,
-                                                                               
  Oid *classObjectId);
+                                                                               
  const Oid *collationObjectId,
+                                                                               
  const Oid *classObjectId);
 static void InitializeAttributeOids(Relation indexRelation,
                                                                        int 
numatts, Oid indexoid);
-static void AppendAttributeTuples(Relation indexRelation, Datum *attopts);
+static void AppendAttributeTuples(Relation indexRelation, const Datum 
*attopts);
 static void UpdateIndexRelation(Oid indexoid, Oid heapoid,
                                                                Oid 
parentIndexId,
-                                                               IndexInfo 
*indexInfo,
-                                                               Oid 
*collationOids,
-                                                               Oid *classOids,
-                                                               int16 
*coloptions,
+                                                               const IndexInfo 
*indexInfo,
+                                                               const Oid 
*collationOids,
+                                                               const Oid 
*classOids,
+                                                               const int16 
*coloptions,
                                                                bool primary,
                                                                bool 
isexclusion,
                                                                bool immediate,
@@ -205,9 +205,9 @@ relationHasPrimaryKey(Relation rel)
  */
 void
 index_check_primary_key(Relation heapRel,
-                                               IndexInfo *indexInfo,
+                                               const IndexInfo *indexInfo,
                                                bool is_alter_table,
-                                               IndexStmt *stmt)
+                                               const IndexStmt *stmt)
 {
        int                     i;
 
@@ -284,11 +284,11 @@ index_check_primary_key(Relation heapRel,
  */
 static TupleDesc
 ConstructTupleDescriptor(Relation heapRelation,
-                                                IndexInfo *indexInfo,
-                                                List *indexColNames,
+                                                const IndexInfo *indexInfo,
+                                                const List *indexColNames,
                                                 Oid accessMethodObjectId,
-                                                Oid *collationObjectId,
-                                                Oid *classObjectId)
+                                                const Oid *collationObjectId,
+                                                const Oid *classObjectId)
 {
        int                     numatts = indexInfo->ii_NumIndexAttrs;
        int                     numkeyatts = indexInfo->ii_NumIndexKeyAttrs;
@@ -516,7 +516,7 @@ InitializeAttributeOids(Relation indexRelation,
  * ----------------------------------------------------------------
  */
 static void
-AppendAttributeTuples(Relation indexRelation, Datum *attopts)
+AppendAttributeTuples(Relation indexRelation, const Datum *attopts)
 {
        Relation        pg_attribute;
        CatalogIndexState indstate;
@@ -551,10 +551,10 @@ static void
 UpdateIndexRelation(Oid indexoid,
                                        Oid heapoid,
                                        Oid parentIndexId,
-                                       IndexInfo *indexInfo,
-                                       Oid *collationOids,
-                                       Oid *classOids,
-                                       int16 *coloptions,
+                                       const IndexInfo *indexInfo,
+                                       const Oid *collationOids,
+                                       const Oid *classOids,
+                                       const int16 *coloptions,
                                        bool primary,
                                        bool isexclusion,
                                        bool immediate,
@@ -718,12 +718,12 @@ index_create(Relation heapRelation,
                         Oid parentConstraintId,
                         RelFileNumber relFileNumber,
                         IndexInfo *indexInfo,
-                        List *indexColNames,
+                        const List *indexColNames,
                         Oid accessMethodObjectId,
                         Oid tableSpaceId,
-                        Oid *collationObjectId,
-                        Oid *classObjectId,
-                        int16 *coloptions,
+                        const Oid *collationObjectId,
+                        const Oid *classObjectId,
+                        const int16 *coloptions,
                         Datum reloptions,
                         bits16 flags,
                         bits16 constr_flags,
@@ -1908,7 +1908,7 @@ ObjectAddress
 index_constraint_create(Relation heapRelation,
                                                Oid indexRelationId,
                                                Oid parentConstraintId,
-                                               IndexInfo *indexInfo,
+                                               const IndexInfo *indexInfo,
                                                const char *constraintName,
                                                char constraintType,
                                                bits16 constr_flags,
@@ -2537,10 +2537,10 @@ BuildDummyIndexInfo(Relation index)
  * Use build_attrmap_by_name(index2, index1) to build the attmap.
  */
 bool
-CompareIndexInfo(IndexInfo *info1, IndexInfo *info2,
-                                Oid *collations1, Oid *collations2,
-                                Oid *opfamilies1, Oid *opfamilies2,
-                                AttrMap *attmap)
+CompareIndexInfo(const IndexInfo *info1, const IndexInfo *info2,
+                                const Oid *collations1, const Oid *collations2,
+                                const Oid *opfamilies1, const Oid *opfamilies2,
+                                const AttrMap *attmap)
 {
        int                     i;
 
@@ -3559,7 +3559,7 @@ IndexGetRelation(Oid indexId, bool missing_ok)
  */
 void
 reindex_index(Oid indexId, bool skip_constraint_checks, char persistence,
-                         ReindexParams *params)
+                         const ReindexParams *params)
 {
        Relation        iRel,
                                heapRelation;
@@ -3872,7 +3872,7 @@ reindex_index(Oid indexId, bool skip_constraint_checks, 
char persistence,
  * index rebuild.
  */
 bool
-reindex_relation(Oid relid, int flags, ReindexParams *params)
+reindex_relation(Oid relid, int flags, const ReindexParams *params)
 {
        Relation        rel;
        Oid                     toast_relid;
@@ -4177,9 +4177,9 @@ SerializeReindexState(Size maxsize, char *start_address)
  *             Restore reindex state in a parallel worker.
  */
 void
-RestoreReindexState(void *reindexstate)
+RestoreReindexState(const void *reindexstate)
 {
-       SerializedReindexState *sistate = (SerializedReindexState *) 
reindexstate;
+       const SerializedReindexState *sistate = (const SerializedReindexState 
*) reindexstate;
        int                     c = 0;
        MemoryContext oldcontext;
 
diff --git a/src/backend/catalog/namespace.c b/src/backend/catalog/namespace.c
index 0c679fbf94..4ceae038ec 100644
--- a/src/backend/catalog/namespace.c
+++ b/src/backend/catalog/namespace.c
@@ -2831,7 +2831,7 @@ TSConfigIsVisible(Oid cfgid)
  * *nspname_p is set to NULL if there is no explicit schema name.
  */
 void
-DeconstructQualifiedName(List *names,
+DeconstructQualifiedName(const List *names,
                                                 char **nspname_p,
                                                 char **objname_p)
 {
@@ -3017,7 +3017,7 @@ CheckSetNamespace(Oid oldNspOid, Oid nspOid)
  * if we have to create or clean out the temp namespace.
  */
 Oid
-QualifiedNameGetCreationNamespace(List *names, char **objname_p)
+QualifiedNameGetCreationNamespace(const List *names, char **objname_p)
 {
        char       *schemaname;
        Oid                     namespaceId;
@@ -3084,7 +3084,7 @@ get_namespace_oid(const char *nspname, bool missing_ok)
  *             Utility routine to convert a qualified-name list into RangeVar 
form.
  */
 RangeVar *
-makeRangeVarFromNameList(List *names)
+makeRangeVarFromNameList(const List *names)
 {
        RangeVar   *rel = makeRangeVar(NULL, NULL, -1);
 
@@ -3124,7 +3124,7 @@ makeRangeVarFromNameList(List *names)
  * but we also allow A_Star for the convenience of ColumnRef processing.
  */
 char *
-NameListToString(List *names)
+NameListToString(const List *names)
 {
        StringInfoData string;
        ListCell   *l;
@@ -3158,7 +3158,7 @@ NameListToString(List *names)
  * so the string could be re-parsed (eg, by textToQualifiedNameList).
  */
 char *
-NameListToQuotedString(List *names)
+NameListToQuotedString(const List *names)
 {
        StringInfoData string;
        ListCell   *l;
diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c
index baf3e6e57a..8e707d4ad9 100644
--- a/src/backend/commands/indexcmds.c
+++ b/src/backend/commands/indexcmds.c
@@ -71,15 +71,15 @@
 
 
 /* non-export function prototypes */
-static bool CompareOpclassOptions(Datum *opts1, Datum *opts2, int natts);
+static bool CompareOpclassOptions(const Datum *opts1, const Datum *opts2, int 
natts);
 static void CheckPredicate(Expr *predicate);
 static void ComputeIndexAttrs(IndexInfo *indexInfo,
                                                          Oid *typeOidP,
                                                          Oid *collationOidP,
                                                          Oid *classOidP,
                                                          int16 *colOptionP,
-                                                         List *attList,
-                                                         List 
*exclusionOpNames,
+                                                         const List *attList,
+                                                         const List 
*exclusionOpNames,
                                                          Oid relId,
                                                          const char 
*accessMethodName, Oid accessMethodId,
                                                          bool amcanorder,
@@ -88,25 +88,25 @@ static void ComputeIndexAttrs(IndexInfo *indexInfo,
                                                          int ddl_sec_context,
                                                          int 
*ddl_save_nestlevel);
 static char *ChooseIndexName(const char *tabname, Oid namespaceId,
-                                                        List *colnames, List 
*exclusionOpNames,
+                                                        const List *colnames, 
const List *exclusionOpNames,
                                                         bool primary, bool 
isconstraint);
-static char *ChooseIndexNameAddition(List *colnames);
-static List *ChooseIndexColumnNames(List *indexElems);
-static void ReindexIndex(RangeVar *indexRelation, ReindexParams *params,
+static char *ChooseIndexNameAddition(const List *colnames);
+static List *ChooseIndexColumnNames(const List *indexElems);
+static void ReindexIndex(const RangeVar *indexRelation, const ReindexParams 
*params,
                                                 bool isTopLevel);
 static void RangeVarCallbackForReindexIndex(const RangeVar *relation,
                                                                                
        Oid relId, Oid oldRelId, void *arg);
-static Oid     ReindexTable(RangeVar *relation, ReindexParams *params,
+static Oid     ReindexTable(const RangeVar *relation, const ReindexParams 
*params,
                                                 bool isTopLevel);
 static void ReindexMultipleTables(const char *objectName,
-                                                                 
ReindexObjectType objectKind, ReindexParams *params);
+                                                                 
ReindexObjectType objectKind, const ReindexParams *params);
 static void reindex_error_callback(void *arg);
-static void ReindexPartitions(Oid relid, ReindexParams *params,
+static void ReindexPartitions(Oid relid, const ReindexParams *params,
                                                          bool isTopLevel);
-static void ReindexMultipleInternal(List *relids,
-                                                                       
ReindexParams *params);
+static void ReindexMultipleInternal(const List *relids,
+                                                                       const 
ReindexParams *params);
 static bool ReindexRelationConcurrently(Oid relationOid,
-                                                                               
ReindexParams *params);
+                                                                               
const ReindexParams *params);
 static void update_relispartition(Oid relationId, bool newval);
 static inline void set_indexsafe_procflags(void);
 
@@ -169,8 +169,8 @@ typedef struct ReindexErrorInfo
 bool
 CheckIndexCompatible(Oid oldId,
                                         const char *accessMethodName,
-                                        List *attributeList,
-                                        List *exclusionOpNames)
+                                        const List *attributeList,
+                                        const List *exclusionOpNames)
 {
        bool            isconstraint;
        Oid                *typeObjectId;
@@ -349,7 +349,7 @@ CheckIndexCompatible(Oid oldId,
  * datums.  Both elements of arrays and array themselves can be NULL.
  */
 static bool
-CompareOpclassOptions(Datum *opts1, Datum *opts2, int natts)
+CompareOpclassOptions(const Datum *opts1, const Datum *opts2, int natts)
 {
        int                     i;
 
@@ -1859,8 +1859,8 @@ ComputeIndexAttrs(IndexInfo *indexInfo,
                                  Oid *collationOidP,
                                  Oid *classOidP,
                                  int16 *colOptionP,
-                                 List *attList,        /* list of IndexElem's 
*/
-                                 List *exclusionOpNames,
+                                 const List *attList,  /* list of IndexElem's 
*/
+                                 const List *exclusionOpNames,
                                  Oid relId,
                                  const char *accessMethodName,
                                  Oid accessMethodId,
@@ -2225,7 +2225,7 @@ ComputeIndexAttrs(IndexInfo *indexInfo,
  * partition key definitions.
  */
 Oid
-ResolveOpClass(List *opclass, Oid attrType,
+ResolveOpClass(const List *opclass, Oid attrType,
                           const char *accessMethodName, Oid accessMethodId)
 {
        char       *schemaname;
@@ -2542,7 +2542,7 @@ ChooseRelationName(const char *name1, const char *name2,
  */
 static char *
 ChooseIndexName(const char *tabname, Oid namespaceId,
-                               List *colnames, List *exclusionOpNames,
+                               const List *colnames, const List 
*exclusionOpNames,
                                bool primary, bool isconstraint)
 {
        char       *indexname;
@@ -2596,7 +2596,7 @@ ChooseIndexName(const char *tabname, Oid namespaceId,
  * ChooseExtendedStatisticNameAddition.
  */
 static char *
-ChooseIndexNameAddition(List *colnames)
+ChooseIndexNameAddition(const List *colnames)
 {
        char            buf[NAMEDATALEN * 2];
        int                     buflen = 0;
@@ -2630,7 +2630,7 @@ ChooseIndexNameAddition(List *colnames)
  * Returns a List of plain strings (char *, not String nodes).
  */
 static List *
-ChooseIndexColumnNames(List *indexElems)
+ChooseIndexColumnNames(const List *indexElems)
 {
        List       *result = NIL;
        ListCell   *lc;
@@ -2691,7 +2691,7 @@ ChooseIndexColumnNames(List *indexElems)
  * each subroutine of REINDEX.
  */
 void
-ExecReindex(ParseState *pstate, ReindexStmt *stmt, bool isTopLevel)
+ExecReindex(ParseState *pstate, const ReindexStmt *stmt, bool isTopLevel)
 {
        ReindexParams params = {0};
        ListCell   *lc;
@@ -2786,7 +2786,7 @@ ExecReindex(ParseState *pstate, ReindexStmt *stmt, bool 
isTopLevel)
  *             Recreate a specific index.
  */
 static void
-ReindexIndex(RangeVar *indexRelation, ReindexParams *params, bool isTopLevel)
+ReindexIndex(const RangeVar *indexRelation, const ReindexParams *params, bool 
isTopLevel)
 {
        struct ReindexIndexCallbackState state;
        Oid                     indOid;
@@ -2909,7 +2909,7 @@ RangeVarCallbackForReindexIndex(const RangeVar *relation,
  *             Recreate all indexes of a table (and of its toast table, if any)
  */
 static Oid
-ReindexTable(RangeVar *relation, ReindexParams *params, bool isTopLevel)
+ReindexTable(const RangeVar *relation, const ReindexParams *params, bool 
isTopLevel)
 {
        Oid                     heapOid;
        bool            result;
@@ -2968,7 +2968,7 @@ ReindexTable(RangeVar *relation, ReindexParams *params, 
bool isTopLevel)
  */
 static void
 ReindexMultipleTables(const char *objectName, ReindexObjectType objectKind,
-                                         ReindexParams *params)
+                                         const ReindexParams *params)
 {
        Oid                     objectOid;
        Relation        relationRelation;
@@ -3206,7 +3206,7 @@ reindex_error_callback(void *arg)
  * by the caller.
  */
 static void
-ReindexPartitions(Oid relid, ReindexParams *params, bool isTopLevel)
+ReindexPartitions(Oid relid, const ReindexParams *params, bool isTopLevel)
 {
        List       *partitions = NIL;
        char            relkind = get_rel_relkind(relid);
@@ -3300,7 +3300,7 @@ ReindexPartitions(Oid relid, ReindexParams *params, bool 
isTopLevel)
  * and starts a new transaction when finished.
  */
 static void
-ReindexMultipleInternal(List *relids, ReindexParams *params)
+ReindexMultipleInternal(const List *relids, const ReindexParams *params)
 {
        ListCell   *l;
 
@@ -3424,7 +3424,7 @@ ReindexMultipleInternal(List *relids, ReindexParams 
*params)
  * anyway, and a non-concurrent reindex is more efficient.
  */
 static bool
-ReindexRelationConcurrently(Oid relationOid, ReindexParams *params)
+ReindexRelationConcurrently(Oid relationOid, const ReindexParams *params)
 {
        typedef struct ReindexIndexInfo
        {
diff --git a/src/include/bootstrap/bootstrap.h 
b/src/include/bootstrap/bootstrap.h
index 2c28a52ce7..e1cb73c5f2 100644
--- a/src/include/bootstrap/bootstrap.h
+++ b/src/include/bootstrap/bootstrap.h
@@ -42,7 +42,7 @@ extern void InsertOneTuple(void);
 extern void InsertOneValue(char *value, int i);
 extern void InsertOneNull(int i);
 
-extern void index_register(Oid heap, Oid ind, IndexInfo *indexInfo);
+extern void index_register(Oid heap, Oid ind, const IndexInfo *indexInfo);
 extern void build_indices(void);
 
 extern void boot_get_type_io_data(Oid typid,
diff --git a/src/include/catalog/heap.h b/src/include/catalog/heap.h
index d01ab504b6..c472ee1365 100644
--- a/src/include/catalog/heap.h
+++ b/src/include/catalog/heap.h
@@ -97,7 +97,7 @@ extern List *heap_truncate_find_FKs(List *relationIds);
 extern void InsertPgAttributeTuples(Relation pg_attribute_rel,
                                                                        
TupleDesc tupdesc,
                                                                        Oid 
new_rel_oid,
-                                                                       Datum 
*attoptions,
+                                                                       const 
Datum *attoptions,
                                                                        
CatalogIndexState indstate);
 
 extern void InsertPgClassTuple(Relation pg_class_desc,
diff --git a/src/include/catalog/index.h b/src/include/catalog/index.h
index c8532fb97c..72ac2dc1b1 100644
--- a/src/include/catalog/index.h
+++ b/src/include/catalog/index.h
@@ -54,9 +54,9 @@ typedef struct ValidateIndexState
 } ValidateIndexState;
 
 extern void index_check_primary_key(Relation heapRel,
-                                                                       
IndexInfo *indexInfo,
+                                                                       const 
IndexInfo *indexInfo,
                                                                        bool 
is_alter_table,
-                                                                       
IndexStmt *stmt);
+                                                                       const 
IndexStmt *stmt);
 
 #define        INDEX_CREATE_IS_PRIMARY                         (1 << 0)
 #define        INDEX_CREATE_ADD_CONSTRAINT                     (1 << 1)
@@ -73,12 +73,12 @@ extern Oid  index_create(Relation heapRelation,
                                                 Oid parentConstraintId,
                                                 RelFileNumber relFileNumber,
                                                 IndexInfo *indexInfo,
-                                                List *indexColNames,
+                                                const List *indexColNames,
                                                 Oid accessMethodObjectId,
                                                 Oid tableSpaceId,
-                                                Oid *collationObjectId,
-                                                Oid *classObjectId,
-                                                int16 *coloptions,
+                                                const Oid *collationObjectId,
+                                                const Oid *classObjectId,
+                                                const int16 *coloptions,
                                                 Datum reloptions,
                                                 bits16 flags,
                                                 bits16 constr_flags,
@@ -110,7 +110,7 @@ extern void index_concurrently_set_dead(Oid heapId,
 extern ObjectAddress index_constraint_create(Relation heapRelation,
                                                                                
         Oid indexRelationId,
                                                                                
         Oid parentConstraintId,
-                                                                               
         IndexInfo *indexInfo,
+                                                                               
         const IndexInfo *indexInfo,
                                                                                
         const char *constraintName,
                                                                                
         char constraintType,
                                                                                
         bits16 constr_flags,
@@ -123,10 +123,10 @@ extern IndexInfo *BuildIndexInfo(Relation index);
 
 extern IndexInfo *BuildDummyIndexInfo(Relation index);
 
-extern bool CompareIndexInfo(IndexInfo *info1, IndexInfo *info2,
-                                                        Oid *collations1, Oid 
*collations2,
-                                                        Oid *opfamilies1, Oid 
*opfamilies2,
-                                                        AttrMap *attmap);
+extern bool CompareIndexInfo(const IndexInfo *info1, const IndexInfo *info2,
+                                                        const Oid 
*collations1, const Oid *collations2,
+                                                        const Oid 
*opfamilies1, const Oid *opfamilies2,
+                                                        const AttrMap *attmap);
 
 extern void BuildSpeculativeIndexInfo(Relation index, IndexInfo *ii);
 
@@ -149,7 +149,7 @@ extern void index_set_state_flags(Oid indexId, 
IndexStateFlagsAction action);
 extern Oid     IndexGetRelation(Oid indexId, bool missing_ok);
 
 extern void reindex_index(Oid indexId, bool skip_constraint_checks,
-                                                 char persistence, 
ReindexParams *params);
+                                                 char persistence, const 
ReindexParams *params);
 
 /* Flag bits for reindex_relation(): */
 #define REINDEX_REL_PROCESS_TOAST                      0x01
@@ -158,7 +158,7 @@ extern void reindex_index(Oid indexId, bool 
skip_constraint_checks,
 #define REINDEX_REL_FORCE_INDEXES_UNLOGGED     0x08
 #define REINDEX_REL_FORCE_INDEXES_PERMANENT 0x10
 
-extern bool reindex_relation(Oid relid, int flags, ReindexParams *params);
+extern bool reindex_relation(Oid relid, int flags, const ReindexParams 
*params);
 
 extern bool ReindexIsProcessingHeap(Oid heapOid);
 extern bool ReindexIsProcessingIndex(Oid indexOid);
@@ -166,7 +166,7 @@ extern bool ReindexIsProcessingIndex(Oid indexOid);
 extern void ResetReindexState(int nestLevel);
 extern Size EstimateReindexStateSpace(void);
 extern void SerializeReindexState(Size maxsize, char *start_address);
-extern void RestoreReindexState(void *reindexstate);
+extern void RestoreReindexState(const void *reindexstate);
 
 extern void IndexSetParentIndex(Relation partitionIdx, Oid parentOid);
 
diff --git a/src/include/catalog/namespace.h b/src/include/catalog/namespace.h
index 49ef619e4b..e027940430 100644
--- a/src/include/catalog/namespace.h
+++ b/src/include/catalog/namespace.h
@@ -136,7 +136,7 @@ extern bool TSTemplateIsVisible(Oid tmplId);
 extern Oid     get_ts_config_oid(List *names, bool missing_ok);
 extern bool TSConfigIsVisible(Oid cfgid);
 
-extern void DeconstructQualifiedName(List *names,
+extern void DeconstructQualifiedName(const List *names,
                                                                         char 
**nspname_p,
                                                                         char 
**objname_p);
 extern Oid     LookupNamespaceNoError(const char *nspname);
@@ -145,10 +145,10 @@ extern Oid        get_namespace_oid(const char *nspname, 
bool missing_ok);
 
 extern Oid     LookupCreationNamespace(const char *nspname);
 extern void CheckSetNamespace(Oid oldNspOid, Oid nspOid);
-extern Oid     QualifiedNameGetCreationNamespace(List *names, char 
**objname_p);
-extern RangeVar *makeRangeVarFromNameList(List *names);
-extern char *NameListToString(List *names);
-extern char *NameListToQuotedString(List *names);
+extern Oid     QualifiedNameGetCreationNamespace(const List *names, char 
**objname_p);
+extern RangeVar *makeRangeVarFromNameList(const List *names);
+extern char *NameListToString(const List *names);
+extern char *NameListToQuotedString(const List *names);
 
 extern bool isTempNamespace(Oid namespaceId);
 extern bool isTempToastNamespace(Oid namespaceId);
diff --git a/src/include/commands/defrem.h b/src/include/commands/defrem.h
index 478203ed4c..190040d463 100644
--- a/src/include/commands/defrem.h
+++ b/src/include/commands/defrem.h
@@ -35,7 +35,7 @@ extern ObjectAddress DefineIndex(Oid relationId,
                                                                 bool 
check_not_in_use,
                                                                 bool 
skip_build,
                                                                 bool quiet);
-extern void ExecReindex(ParseState *pstate, ReindexStmt *stmt, bool 
isTopLevel);
+extern void ExecReindex(ParseState *pstate, const ReindexStmt *stmt, bool 
isTopLevel);
 extern char *makeObjectName(const char *name1, const char *name2,
                                                        const char *label);
 extern char *ChooseRelationName(const char *name1, const char *name2,
@@ -43,10 +43,10 @@ extern char *ChooseRelationName(const char *name1, const 
char *name2,
                                                                bool 
isconstraint);
 extern bool CheckIndexCompatible(Oid oldId,
                                                                 const char 
*accessMethodName,
-                                                                List 
*attributeList,
-                                                                List 
*exclusionOpNames);
+                                                                const List 
*attributeList,
+                                                                const List 
*exclusionOpNames);
 extern Oid     GetDefaultOpClass(Oid type_id, Oid am_id);
-extern Oid     ResolveOpClass(List *opclass, Oid attrType,
+extern Oid     ResolveOpClass(const List *opclass, Oid attrType,
                                                   const char 
*accessMethodName, Oid accessMethodId);
 
 /* commands/functioncmds.c */
-- 
2.41.0

From de6b80e54b05a2821adcea6bc3ef2b996eb2bfd2 Mon Sep 17 00:00:00 2001
From: Peter Eisentraut <pe...@eisentraut.org>
Date: Wed, 16 Aug 2023 07:45:28 +0200
Subject: [PATCH 2/3] Rename some function arguments for better clarity

Especially make sure that array arguments have plural names.
---
 src/backend/catalog/index.c      |  62 +++++++++----------
 src/backend/catalog/toasting.c   |  14 ++---
 src/backend/commands/indexcmds.c | 100 +++++++++++++++----------------
 src/include/catalog/index.h      |   6 +-
 src/include/commands/defrem.h    |   2 +-
 5 files changed, 92 insertions(+), 92 deletions(-)

diff --git a/src/backend/catalog/index.c b/src/backend/catalog/index.c
index 2a30eb3a32..05b6f9ca1a 100644
--- a/src/backend/catalog/index.c
+++ b/src/backend/catalog/index.c
@@ -108,9 +108,9 @@ static bool relationHasPrimaryKey(Relation rel);
 static TupleDesc ConstructTupleDescriptor(Relation heapRelation,
                                                                                
  const IndexInfo *indexInfo,
                                                                                
  const List *indexColNames,
-                                                                               
  Oid accessMethodObjectId,
-                                                                               
  const Oid *collationObjectId,
-                                                                               
  const Oid *classObjectId);
+                                                                               
  Oid accessMethodId,
+                                                                               
  const Oid *collationIds,
+                                                                               
  const Oid *opclassIds);
 static void InitializeAttributeOids(Relation indexRelation,
                                                                        int 
numatts, Oid indexoid);
 static void AppendAttributeTuples(Relation indexRelation, const Datum 
*attopts);
@@ -118,7 +118,7 @@ static void UpdateIndexRelation(Oid indexoid, Oid heapoid,
                                                                Oid 
parentIndexId,
                                                                const IndexInfo 
*indexInfo,
                                                                const Oid 
*collationOids,
-                                                               const Oid 
*classOids,
+                                                               const Oid 
*opclassOids,
                                                                const int16 
*coloptions,
                                                                bool primary,
                                                                bool 
isexclusion,
@@ -286,9 +286,9 @@ static TupleDesc
 ConstructTupleDescriptor(Relation heapRelation,
                                                 const IndexInfo *indexInfo,
                                                 const List *indexColNames,
-                                                Oid accessMethodObjectId,
-                                                const Oid *collationObjectId,
-                                                const Oid *classObjectId)
+                                                Oid accessMethodId,
+                                                const Oid *collationIds,
+                                                const Oid *opclassIds)
 {
        int                     numatts = indexInfo->ii_NumIndexAttrs;
        int                     numkeyatts = indexInfo->ii_NumIndexKeyAttrs;
@@ -301,7 +301,7 @@ ConstructTupleDescriptor(Relation heapRelation,
        int                     i;
 
        /* We need access to the index AM's API struct */
-       amroutine = GetIndexAmRoutineByAmId(accessMethodObjectId, false);
+       amroutine = GetIndexAmRoutineByAmId(accessMethodId, false);
 
        /* ... and to the table's tuple descriptor */
        heapTupDesc = RelationGetDescr(heapRelation);
@@ -330,7 +330,7 @@ ConstructTupleDescriptor(Relation heapRelation,
                to->attcacheoff = -1;
                to->attislocal = true;
                to->attcollation = (i < numkeyatts) ?
-                       collationObjectId[i] : InvalidOid;
+                       collationIds[i] : InvalidOid;
 
                /*
                 * Set the attribute name as specified by caller.
@@ -436,10 +436,10 @@ ConstructTupleDescriptor(Relation heapRelation,
 
                if (i < indexInfo->ii_NumIndexKeyAttrs)
                {
-                       tuple = SearchSysCache1(CLAOID, 
ObjectIdGetDatum(classObjectId[i]));
+                       tuple = SearchSysCache1(CLAOID, 
ObjectIdGetDatum(opclassIds[i]));
                        if (!HeapTupleIsValid(tuple))
                                elog(ERROR, "cache lookup failed for opclass 
%u",
-                                        classObjectId[i]);
+                                        opclassIds[i]);
                        opclassTup = (Form_pg_opclass) GETSTRUCT(tuple);
                        if (OidIsValid(opclassTup->opckeytype))
                                keyType = opclassTup->opckeytype;
@@ -553,7 +553,7 @@ UpdateIndexRelation(Oid indexoid,
                                        Oid parentIndexId,
                                        const IndexInfo *indexInfo,
                                        const Oid *collationOids,
-                                       const Oid *classOids,
+                                       const Oid *opclassOids,
                                        const int16 *coloptions,
                                        bool primary,
                                        bool isexclusion,
@@ -581,7 +581,7 @@ UpdateIndexRelation(Oid indexoid,
        for (i = 0; i < indexInfo->ii_NumIndexAttrs; i++)
                indkey->values[i] = indexInfo->ii_IndexAttrNumbers[i];
        indcollation = buildoidvector(collationOids, 
indexInfo->ii_NumIndexKeyAttrs);
-       indclass = buildoidvector(classOids, indexInfo->ii_NumIndexKeyAttrs);
+       indclass = buildoidvector(opclassOids, indexInfo->ii_NumIndexKeyAttrs);
        indoption = buildint2vector(coloptions, indexInfo->ii_NumIndexKeyAttrs);
 
        /*
@@ -679,10 +679,10 @@ UpdateIndexRelation(Oid indexoid,
  *             May be nonzero to attach an existing valid build.
  * indexInfo: same info executor uses to insert into the index
  * indexColNames: column names to use for index (List of char *)
- * accessMethodObjectId: OID of index AM to use
+ * accessMethodId: OID of index AM to use
  * tableSpaceId: OID of tablespace to use
- * collationObjectId: array of collation OIDs, one per index column
- * classObjectId: array of index opclass OIDs, one per index column
+ * collationIds: array of collation OIDs, one per index column
+ * opclassIds: array of index opclass OIDs, one per index column
  * coloptions: array of per-index-column indoption settings
  * reloptions: AM-specific options
  * flags: bitmask that can include any combination of these bits:
@@ -719,10 +719,10 @@ index_create(Relation heapRelation,
                         RelFileNumber relFileNumber,
                         IndexInfo *indexInfo,
                         const List *indexColNames,
-                        Oid accessMethodObjectId,
+                        Oid accessMethodId,
                         Oid tableSpaceId,
-                        const Oid *collationObjectId,
-                        const Oid *classObjectId,
+                        const Oid *collationIds,
+                        const Oid *opclassIds,
                         const int16 *coloptions,
                         Datum reloptions,
                         bits16 flags,
@@ -806,8 +806,8 @@ index_create(Relation heapRelation,
         */
        for (i = 0; i < indexInfo->ii_NumIndexKeyAttrs; i++)
        {
-               Oid                     collation = collationObjectId[i];
-               Oid                     opclass = classObjectId[i];
+               Oid                     collation = collationIds[i];
+               Oid                     opclass = opclassIds[i];
 
                if (collation)
                {
@@ -908,9 +908,9 @@ index_create(Relation heapRelation,
        indexTupDesc = ConstructTupleDescriptor(heapRelation,
                                                                                
        indexInfo,
                                                                                
        indexColNames,
-                                                                               
        accessMethodObjectId,
-                                                                               
        collationObjectId,
-                                                                               
        classObjectId);
+                                                                               
        accessMethodId,
+                                                                               
        collationIds,
+                                                                               
        opclassIds);
 
        /*
         * Allocate an OID for the index, unless we were told what to use.
@@ -964,7 +964,7 @@ index_create(Relation heapRelation,
                                                                tableSpaceId,
                                                                indexRelationId,
                                                                relFileNumber,
-                                                               
accessMethodObjectId,
+                                                               accessMethodId,
                                                                indexTupDesc,
                                                                relkind,
                                                                relpersistence,
@@ -993,7 +993,7 @@ index_create(Relation heapRelation,
         * XXX should have a cleaner way to create cataloged indexes
         */
        indexRelation->rd_rel->relowner = heapRelation->rd_rel->relowner;
-       indexRelation->rd_rel->relam = accessMethodObjectId;
+       indexRelation->rd_rel->relam = accessMethodId;
        indexRelation->rd_rel->relispartition = OidIsValid(parentIndexRelid);
 
        /*
@@ -1030,7 +1030,7 @@ index_create(Relation heapRelation,
         */
        UpdateIndexRelation(indexRelationId, heapRelationId, parentIndexRelid,
                                                indexInfo,
-                                               collationObjectId, 
classObjectId, coloptions,
+                                               collationIds, opclassIds, 
coloptions,
                                                isprimary, is_exclusion,
                                                (constr_flags & 
INDEX_CONSTR_CREATE_DEFERRABLE) == 0,
                                                !concurrent && !invalid,
@@ -1159,11 +1159,11 @@ index_create(Relation heapRelation,
                /* The default collation is pinned, so don't bother recording 
it */
                for (i = 0; i < indexInfo->ii_NumIndexKeyAttrs; i++)
                {
-                       if (OidIsValid(collationObjectId[i]) &&
-                               collationObjectId[i] != DEFAULT_COLLATION_OID)
+                       if (OidIsValid(collationIds[i]) &&
+                               collationIds[i] != DEFAULT_COLLATION_OID)
                        {
                                ObjectAddressSet(referenced, 
CollationRelationId,
-                                                                
collationObjectId[i]);
+                                                                
collationIds[i]);
                                add_exact_object_address(&referenced, addrs);
                        }
                }
@@ -1171,7 +1171,7 @@ index_create(Relation heapRelation,
                /* Store dependency on operator classes */
                for (i = 0; i < indexInfo->ii_NumIndexKeyAttrs; i++)
                {
-                       ObjectAddressSet(referenced, OperatorClassRelationId, 
classObjectId[i]);
+                       ObjectAddressSet(referenced, OperatorClassRelationId, 
opclassIds[i]);
                        add_exact_object_address(&referenced, addrs);
                }
 
diff --git a/src/backend/catalog/toasting.c b/src/backend/catalog/toasting.c
index ab12b0b9de..3fef593bf1 100644
--- a/src/backend/catalog/toasting.c
+++ b/src/backend/catalog/toasting.c
@@ -142,8 +142,8 @@ create_toast_table(Relation rel, Oid toastOid, Oid 
toastIndexOid,
        char            toast_relname[NAMEDATALEN];
        char            toast_idxname[NAMEDATALEN];
        IndexInfo  *indexInfo;
-       Oid                     collationObjectId[2];
-       Oid                     classObjectId[2];
+       Oid                     collationIds[2];
+       Oid                     opclassIds[2];
        int16           coloptions[2];
        ObjectAddress baseobject,
                                toastobject;
@@ -312,11 +312,11 @@ create_toast_table(Relation rel, Oid toastOid, Oid 
toastIndexOid,
        indexInfo->ii_AmCache = NULL;
        indexInfo->ii_Context = CurrentMemoryContext;
 
-       collationObjectId[0] = InvalidOid;
-       collationObjectId[1] = InvalidOid;
+       collationIds[0] = InvalidOid;
+       collationIds[1] = InvalidOid;
 
-       classObjectId[0] = OID_BTREE_OPS_OID;
-       classObjectId[1] = INT4_BTREE_OPS_OID;
+       opclassIds[0] = OID_BTREE_OPS_OID;
+       opclassIds[1] = INT4_BTREE_OPS_OID;
 
        coloptions[0] = 0;
        coloptions[1] = 0;
@@ -327,7 +327,7 @@ create_toast_table(Relation rel, Oid toastOid, Oid 
toastIndexOid,
                                 list_make2("chunk_id", "chunk_seq"),
                                 BTREE_AM_OID,
                                 rel->rd_rel->reltablespace,
-                                collationObjectId, classObjectId, coloptions, 
(Datum) 0,
+                                collationIds, opclassIds, coloptions, (Datum) 
0,
                                 INDEX_CREATE_IS_PRIMARY, 0, true, true, NULL);
 
        table_close(toast_rel, NoLock);
diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c
index 8e707d4ad9..0ed620ef65 100644
--- a/src/backend/commands/indexcmds.c
+++ b/src/backend/commands/indexcmds.c
@@ -74,10 +74,10 @@
 static bool CompareOpclassOptions(const Datum *opts1, const Datum *opts2, int 
natts);
 static void CheckPredicate(Expr *predicate);
 static void ComputeIndexAttrs(IndexInfo *indexInfo,
-                                                         Oid *typeOidP,
-                                                         Oid *collationOidP,
-                                                         Oid *classOidP,
-                                                         int16 *colOptionP,
+                                                         Oid *typeOids,
+                                                         Oid *collationOids,
+                                                         Oid *opclassOids,
+                                                         int16 *colOptions,
                                                          const List *attList,
                                                          const List 
*exclusionOpNames,
                                                          Oid relId,
@@ -173,9 +173,9 @@ CheckIndexCompatible(Oid oldId,
                                         const List *exclusionOpNames)
 {
        bool            isconstraint;
-       Oid                *typeObjectId;
-       Oid                *collationObjectId;
-       Oid                *classObjectId;
+       Oid                *typeIds;
+       Oid                *collationIds;
+       Oid                *opclassIds;
        Oid                     accessMethodId;
        Oid                     relationId;
        HeapTuple       tuple;
@@ -234,12 +234,12 @@ CheckIndexCompatible(Oid oldId,
        indexInfo = makeIndexInfo(numberOfAttributes, numberOfAttributes,
                                                          accessMethodId, NIL, 
NIL, false, false,
                                                          false, false, 
amsummarizing);
-       typeObjectId = palloc_array(Oid, numberOfAttributes);
-       collationObjectId = palloc_array(Oid, numberOfAttributes);
-       classObjectId = palloc_array(Oid, numberOfAttributes);
+       typeIds = palloc_array(Oid, numberOfAttributes);
+       collationIds = palloc_array(Oid, numberOfAttributes);
+       opclassIds = palloc_array(Oid, numberOfAttributes);
        coloptions = palloc_array(int16, numberOfAttributes);
        ComputeIndexAttrs(indexInfo,
-                                         typeObjectId, collationObjectId, 
classObjectId,
+                                         typeIds, collationIds, opclassIds,
                                          coloptions, attributeList,
                                          exclusionOpNames, relationId,
                                          accessMethodName, accessMethodId,
@@ -274,9 +274,9 @@ CheckIndexCompatible(Oid oldId,
        d = SysCacheGetAttrNotNull(INDEXRELID, tuple, Anum_pg_index_indclass);
        old_indclass = (oidvector *) DatumGetPointer(d);
 
-       ret = (memcmp(old_indclass->values, classObjectId,
+       ret = (memcmp(old_indclass->values, opclassIds,
                                  old_natts * sizeof(Oid)) == 0 &&
-                  memcmp(old_indcollation->values, collationObjectId,
+                  memcmp(old_indcollation->values, collationIds,
                                  old_natts * sizeof(Oid)) == 0);
 
        ReleaseSysCache(tuple);
@@ -288,8 +288,8 @@ CheckIndexCompatible(Oid oldId,
        irel = index_open(oldId, AccessShareLock);      /* caller probably has 
a lock */
        for (i = 0; i < old_natts; i++)
        {
-               if (IsPolymorphicType(get_opclass_input_type(classObjectId[i])) 
&&
-                       TupleDescAttr(irel->rd_att, i)->atttypid != 
typeObjectId[i])
+               if (IsPolymorphicType(get_opclass_input_type(opclassIds[i])) &&
+                       TupleDescAttr(irel->rd_att, i)->atttypid != typeIds[i])
                {
                        ret = false;
                        break;
@@ -329,7 +329,7 @@ CheckIndexCompatible(Oid oldId,
 
                                op_input_types(indexInfo->ii_ExclusionOps[i], 
&left, &right);
                                if ((IsPolymorphicType(left) || 
IsPolymorphicType(right)) &&
-                                       TupleDescAttr(irel->rd_att, 
i)->atttypid != typeObjectId[i])
+                                       TupleDescAttr(irel->rd_att, 
i)->atttypid != typeIds[i])
                                {
                                        ret = false;
                                        break;
@@ -500,7 +500,7 @@ WaitForOlderSnapshots(TransactionId limitXmin, bool 
progress)
  * consider offering one DDL command for catalog setup and a separate DDL
  * command for steps that run opaque expressions.
  *
- * 'relationId': the OID of the heap relation on which the index is to be
+ * 'tableId': the OID of the table relation on which the index is to be
  *             created
  * 'stmt': IndexStmt describing the properties of the new index.
  * 'indexRelationId': normally InvalidOid, but during bootstrap can be
@@ -523,7 +523,7 @@ WaitForOlderSnapshots(TransactionId limitXmin, bool 
progress)
  * Returns the object address of the created index.
  */
 ObjectAddress
-DefineIndex(Oid relationId,
+DefineIndex(Oid tableId,
                        IndexStmt *stmt,
                        Oid indexRelationId,
                        Oid parentIndexId,
@@ -538,9 +538,9 @@ DefineIndex(Oid relationId,
        bool            concurrent;
        char       *indexRelationName;
        char       *accessMethodName;
-       Oid                *typeObjectId;
-       Oid                *collationObjectId;
-       Oid                *classObjectId;
+       Oid                *typeIds;
+       Oid                *collationIds;
+       Oid                *opclassIds;
        Oid                     accessMethodId;
        Oid                     namespaceId;
        Oid                     tablespaceId;
@@ -592,7 +592,7 @@ DefineIndex(Oid relationId,
         * is more efficient.  Do this before any use of the concurrent option 
is
         * done.
         */
-       if (stmt->concurrent && get_rel_persistence(relationId) != 
RELPERSISTENCE_TEMP)
+       if (stmt->concurrent && get_rel_persistence(tableId) != 
RELPERSISTENCE_TEMP)
                concurrent = true;
        else
                concurrent = false;
@@ -604,7 +604,7 @@ DefineIndex(Oid relationId,
        if (!OidIsValid(parentIndexId))
        {
                pgstat_progress_start_command(PROGRESS_COMMAND_CREATE_INDEX,
-                                                                         
relationId);
+                                                                         
tableId);
                pgstat_progress_update_param(PROGRESS_CREATEIDX_COMMAND,
                                                                         
concurrent ?
                                                                         
PROGRESS_CREATEIDX_COMMAND_CREATE_CONCURRENTLY :
@@ -649,7 +649,7 @@ DefineIndex(Oid relationId,
         * index build; but for concurrent builds we allow INSERT/UPDATE/DELETE
         * (but not VACUUM).
         *
-        * NB: Caller is responsible for making sure that relationId refers to 
the
+        * NB: Caller is responsible for making sure that tableId refers to the
         * relation on which the index should be built; except in bootstrap 
mode,
         * this will typically require the caller to have already locked the
         * relation.  To avoid lock upgrade hazards, that lock should be at 
least
@@ -660,7 +660,7 @@ DefineIndex(Oid relationId,
         * functions will need to be updated, too.
         */
        lockmode = concurrent ? ShareUpdateExclusiveLock : ShareLock;
-       rel = table_open(relationId, lockmode);
+       rel = table_open(tableId, lockmode);
 
        /*
         * Switch to the table owner's userid, so that any index functions are 
run
@@ -899,14 +899,14 @@ DefineIndex(Oid relationId,
                                                          concurrent,
                                                          amissummarizing);
 
-       typeObjectId = palloc_array(Oid, numberOfAttributes);
-       collationObjectId = palloc_array(Oid, numberOfAttributes);
-       classObjectId = palloc_array(Oid, numberOfAttributes);
+       typeIds = palloc_array(Oid, numberOfAttributes);
+       collationIds = palloc_array(Oid, numberOfAttributes);
+       opclassIds = palloc_array(Oid, numberOfAttributes);
        coloptions = palloc_array(int16, numberOfAttributes);
        ComputeIndexAttrs(indexInfo,
-                                         typeObjectId, collationObjectId, 
classObjectId,
+                                         typeIds, collationIds, opclassIds,
                                          coloptions, allIndexParams,
-                                         stmt->excludeOpNames, relationId,
+                                         stmt->excludeOpNames, tableId,
                                          accessMethodName, accessMethodId,
                                          amcanorder, stmt->isconstraint, 
root_save_userid,
                                          root_save_sec_context, 
&root_save_nestlevel);
@@ -1011,7 +1011,7 @@ DefineIndex(Oid relationId,
                                        Oid                     idx_opfamily;
                                        Oid                     idx_opcintype;
 
-                                       if 
(get_opclass_opfamily_and_input_type(classObjectId[j],
+                                       if 
(get_opclass_opfamily_and_input_type(opclassIds[j],
                                                                                
                                        &idx_opfamily,
                                                                                
                                        &idx_opcintype))
                                        {
@@ -1181,7 +1181,7 @@ DefineIndex(Oid relationId,
                                         parentConstraintId,
                                         stmt->oldNumber, indexInfo, 
indexColNames,
                                         accessMethodId, tablespaceId,
-                                        collationObjectId, classObjectId,
+                                        collationIds, opclassIds,
                                         coloptions, reloptions,
                                         flags, constr_flags,
                                         allowSystemTableMods, !check_rights,
@@ -1262,7 +1262,7 @@ DefineIndex(Oid relationId,
                                 */
                                if (total_parts < 0)
                                {
-                                       List       *children = 
find_all_inheritors(relationId,
+                                       List       *children = 
find_all_inheritors(tableId,
                                                                                
                                           NoLock, NULL);
 
                                        total_parts = list_length(children) - 1;
@@ -1674,7 +1674,7 @@ DefineIndex(Oid relationId,
        PushActiveSnapshot(GetTransactionSnapshot());
 
        /* Perform concurrent build of index */
-       index_concurrently_build(relationId, indexRelationId);
+       index_concurrently_build(tableId, indexRelationId);
 
        /* we can do away with our snapshot */
        PopActiveSnapshot();
@@ -1720,7 +1720,7 @@ DefineIndex(Oid relationId,
        /*
         * Scan the index and the heap, insert any missing index entries.
         */
-       validate_index(relationId, indexRelationId, snapshot);
+       validate_index(tableId, indexRelationId, snapshot);
 
        /*
         * Drop the reference snapshot.  We must do this before waiting out 
other
@@ -1855,10 +1855,10 @@ CheckPredicate(Expr *predicate)
  */
 static void
 ComputeIndexAttrs(IndexInfo *indexInfo,
-                                 Oid *typeOidP,
-                                 Oid *collationOidP,
-                                 Oid *classOidP,
-                                 int16 *colOptionP,
+                                 Oid *typeOids,
+                                 Oid *collationOids,
+                                 Oid *opclassOids,
+                                 int16 *colOptions,
                                  const List *attList,  /* list of IndexElem's 
*/
                                  const List *exclusionOpNames,
                                  Oid relId,
@@ -1988,7 +1988,7 @@ ComputeIndexAttrs(IndexInfo *indexInfo,
                        }
                }
 
-               typeOidP[attn] = atttype;
+               typeOids[attn] = atttype;
 
                /*
                 * Included columns have no collation, no opclass and no 
ordering
@@ -2013,9 +2013,9 @@ ComputeIndexAttrs(IndexInfo *indexInfo,
                                                
(errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
                                                 errmsg("including column does 
not support NULLS FIRST/LAST options")));
 
-                       classOidP[attn] = InvalidOid;
-                       colOptionP[attn] = 0;
-                       collationOidP[attn] = InvalidOid;
+                       opclassOids[attn] = InvalidOid;
+                       colOptions[attn] = 0;
+                       collationOids[attn] = InvalidOid;
                        attn++;
 
                        continue;
@@ -2064,7 +2064,7 @@ ComputeIndexAttrs(IndexInfo *indexInfo,
                                                                
format_type_be(atttype))));
                }
 
-               collationOidP[attn] = attcollation;
+               collationOids[attn] = attcollation;
 
                /*
                 * Identify the opclass to use.  Use of ddl_userid is necessary 
due to
@@ -2077,7 +2077,7 @@ ComputeIndexAttrs(IndexInfo *indexInfo,
                        AtEOXact_GUC(false, *ddl_save_nestlevel);
                        SetUserIdAndSecContext(ddl_userid, ddl_sec_context);
                }
-               classOidP[attn] = ResolveOpClass(attribute->opclass,
+               opclassOids[attn] = ResolveOpClass(attribute->opclass,
                                                                                
 atttype,
                                                                                
 accessMethodName,
                                                                                
 accessMethodId);
@@ -2132,7 +2132,7 @@ ComputeIndexAttrs(IndexInfo *indexInfo,
                        /*
                         * Operator must be a member of the right opfamily, too
                         */
-                       opfamily = get_opclass_family(classOidP[attn]);
+                       opfamily = get_opclass_family(opclassOids[attn]);
                        strat = get_op_opfamily_strategy(opid, opfamily);
                        if (strat == 0)
                        {
@@ -2170,20 +2170,20 @@ ComputeIndexAttrs(IndexInfo *indexInfo,
                 * zero for any un-ordered index, while ordered indexes have 
DESC and
                 * NULLS FIRST/LAST options.
                 */
-               colOptionP[attn] = 0;
+               colOptions[attn] = 0;
                if (amcanorder)
                {
                        /* default ordering is ASC */
                        if (attribute->ordering == SORTBY_DESC)
-                               colOptionP[attn] |= INDOPTION_DESC;
+                               colOptions[attn] |= INDOPTION_DESC;
                        /* default null ordering is LAST for ASC, FIRST for 
DESC */
                        if (attribute->nulls_ordering == SORTBY_NULLS_DEFAULT)
                        {
                                if (attribute->ordering == SORTBY_DESC)
-                                       colOptionP[attn] |= 
INDOPTION_NULLS_FIRST;
+                                       colOptions[attn] |= 
INDOPTION_NULLS_FIRST;
                        }
                        else if (attribute->nulls_ordering == 
SORTBY_NULLS_FIRST)
-                               colOptionP[attn] |= INDOPTION_NULLS_FIRST;
+                               colOptions[attn] |= INDOPTION_NULLS_FIRST;
                }
                else
                {
diff --git a/src/include/catalog/index.h b/src/include/catalog/index.h
index 72ac2dc1b1..4d8ba81f90 100644
--- a/src/include/catalog/index.h
+++ b/src/include/catalog/index.h
@@ -74,10 +74,10 @@ extern Oid  index_create(Relation heapRelation,
                                                 RelFileNumber relFileNumber,
                                                 IndexInfo *indexInfo,
                                                 const List *indexColNames,
-                                                Oid accessMethodObjectId,
+                                                Oid accessMethodId,
                                                 Oid tableSpaceId,
-                                                const Oid *collationObjectId,
-                                                const Oid *classObjectId,
+                                                const Oid *collationIds,
+                                                const Oid *opclassIds,
                                                 const int16 *coloptions,
                                                 Datum reloptions,
                                                 bits16 flags,
diff --git a/src/include/commands/defrem.h b/src/include/commands/defrem.h
index 190040d463..179eb9901f 100644
--- a/src/include/commands/defrem.h
+++ b/src/include/commands/defrem.h
@@ -24,7 +24,7 @@
 extern void RemoveObjects(DropStmt *stmt);
 
 /* commands/indexcmds.c */
-extern ObjectAddress DefineIndex(Oid relationId,
+extern ObjectAddress DefineIndex(Oid tableId,
                                                                 IndexStmt 
*stmt,
                                                                 Oid 
indexRelationId,
                                                                 Oid 
parentIndexId,
-- 
2.41.0

From e5260923d204707172928c4dc9389042177677b9 Mon Sep 17 00:00:00 2001
From: Peter Eisentraut <pe...@eisentraut.org>
Date: Wed, 16 Aug 2023 07:45:28 +0200
Subject: [PATCH 3/3] Some vertical reformatting

Remove some line breaks that have become unnecessary after some
variable renaming.
---
 src/backend/catalog/index.c      | 12 ++++--------
 src/backend/commands/indexcmds.c | 21 ++++++++-------------
 2 files changed, 12 insertions(+), 21 deletions(-)

diff --git a/src/backend/catalog/index.c b/src/backend/catalog/index.c
index 05b6f9ca1a..fd09378848 100644
--- a/src/backend/catalog/index.c
+++ b/src/backend/catalog/index.c
@@ -329,8 +329,7 @@ ConstructTupleDescriptor(Relation heapRelation,
                to->attstattarget = -1;
                to->attcacheoff = -1;
                to->attislocal = true;
-               to->attcollation = (i < numkeyatts) ?
-                       collationIds[i] : InvalidOid;
+               to->attcollation = (i < numkeyatts) ? collationIds[i] : 
InvalidOid;
 
                /*
                 * Set the attribute name as specified by caller.
@@ -438,8 +437,7 @@ ConstructTupleDescriptor(Relation heapRelation,
                {
                        tuple = SearchSysCache1(CLAOID, 
ObjectIdGetDatum(opclassIds[i]));
                        if (!HeapTupleIsValid(tuple))
-                               elog(ERROR, "cache lookup failed for opclass 
%u",
-                                        opclassIds[i]);
+                               elog(ERROR, "cache lookup failed for opclass 
%u", opclassIds[i]);
                        opclassTup = (Form_pg_opclass) GETSTRUCT(tuple);
                        if (OidIsValid(opclassTup->opckeytype))
                                keyType = opclassTup->opckeytype;
@@ -1159,11 +1157,9 @@ index_create(Relation heapRelation,
                /* The default collation is pinned, so don't bother recording 
it */
                for (i = 0; i < indexInfo->ii_NumIndexKeyAttrs; i++)
                {
-                       if (OidIsValid(collationIds[i]) &&
-                               collationIds[i] != DEFAULT_COLLATION_OID)
+                       if (OidIsValid(collationIds[i]) && collationIds[i] != 
DEFAULT_COLLATION_OID)
                        {
-                               ObjectAddressSet(referenced, 
CollationRelationId,
-                                                                
collationIds[i]);
+                               ObjectAddressSet(referenced, 
CollationRelationId, collationIds[i]);
                                add_exact_object_address(&referenced, addrs);
                        }
                }
diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c
index 0ed620ef65..483b868785 100644
--- a/src/backend/commands/indexcmds.c
+++ b/src/backend/commands/indexcmds.c
@@ -81,7 +81,8 @@ static void ComputeIndexAttrs(IndexInfo *indexInfo,
                                                          const List *attList,
                                                          const List 
*exclusionOpNames,
                                                          Oid relId,
-                                                         const char 
*accessMethodName, Oid accessMethodId,
+                                                         const char 
*accessMethodName,
+                                                         Oid accessMethodId,
                                                          bool amcanorder,
                                                          bool isconstraint,
                                                          Oid ddl_userid,
@@ -274,10 +275,8 @@ CheckIndexCompatible(Oid oldId,
        d = SysCacheGetAttrNotNull(INDEXRELID, tuple, Anum_pg_index_indclass);
        old_indclass = (oidvector *) DatumGetPointer(d);
 
-       ret = (memcmp(old_indclass->values, opclassIds,
-                                 old_natts * sizeof(Oid)) == 0 &&
-                  memcmp(old_indcollation->values, collationIds,
-                                 old_natts * sizeof(Oid)) == 0);
+       ret = (memcmp(old_indclass->values, opclassIds, old_natts * 
sizeof(Oid)) == 0 &&
+                  memcmp(old_indcollation->values, collationIds, old_natts * 
sizeof(Oid)) == 0);
 
        ReleaseSysCache(tuple);
 
@@ -603,8 +602,7 @@ DefineIndex(Oid tableId,
         */
        if (!OidIsValid(parentIndexId))
        {
-               pgstat_progress_start_command(PROGRESS_COMMAND_CREATE_INDEX,
-                                                                         
tableId);
+               pgstat_progress_start_command(PROGRESS_COMMAND_CREATE_INDEX, 
tableId);
                pgstat_progress_update_param(PROGRESS_CREATEIDX_COMMAND,
                                                                         
concurrent ?
                                                                         
PROGRESS_CREATEIDX_COMMAND_CREATE_CONCURRENTLY :
@@ -1262,8 +1260,7 @@ DefineIndex(Oid tableId,
                                 */
                                if (total_parts < 0)
                                {
-                                       List       *children = 
find_all_inheritors(tableId,
-                                                                               
                                           NoLock, NULL);
+                                       List       *children = 
find_all_inheritors(tableId, NoLock, NULL);
 
                                        total_parts = list_length(children) - 1;
                                        list_free(children);
@@ -3789,8 +3786,7 @@ ReindexRelationConcurrently(Oid relationOid, const 
ReindexParams *params)
                if (indexRel->rd_rel->relpersistence == RELPERSISTENCE_TEMP)
                        elog(ERROR, "cannot reindex a temporary table 
concurrently");
 
-               pgstat_progress_start_command(PROGRESS_COMMAND_CREATE_INDEX,
-                                                                         
idx->tableId);
+               pgstat_progress_start_command(PROGRESS_COMMAND_CREATE_INDEX, 
idx->tableId);
 
                progress_vals[0] = 
PROGRESS_CREATEIDX_COMMAND_REINDEX_CONCURRENTLY;
                progress_vals[1] = 0;   /* initializing */
@@ -4015,8 +4011,7 @@ ReindexRelationConcurrently(Oid relationOid, const 
ReindexParams *params)
                 * Update progress for the index to build, with the correct 
parent
                 * table involved.
                 */
-               pgstat_progress_start_command(PROGRESS_COMMAND_CREATE_INDEX,
-                                                                         
newidx->tableId);
+               pgstat_progress_start_command(PROGRESS_COMMAND_CREATE_INDEX, 
newidx->tableId);
                progress_vals[0] = 
PROGRESS_CREATEIDX_COMMAND_REINDEX_CONCURRENTLY;
                progress_vals[1] = PROGRESS_CREATEIDX_PHASE_VALIDATE_IDXSCAN;
                progress_vals[2] = newidx->indexId;
-- 
2.41.0

Reply via email to