Turn a few 'validnsps' static variables into locals
authorHeikki Linnakangas <[email protected]>
Tue, 6 Aug 2024 20:03:43 +0000 (23:03 +0300)
committerHeikki Linnakangas <[email protected]>
Tue, 6 Aug 2024 20:03:43 +0000 (23:03 +0300)
There was no need for these to be static buffers, local variables work
just as well. I think they were marked as 'static' to imply that they
are read-only, but 'const' is more appropriate for that, so change
them to const.

To make it possible to mark the variables as 'const', also add 'const'
decorations to the transformRelOptions() signature.

Reviewed-by: Andres Freund
Discussion: https://www.postgresql.org/message-id/54c29fb0-edf2-48ea-9814-44e918bbd6e8@iki.fi

src/backend/access/common/reloptions.c
src/backend/commands/createas.c
src/backend/commands/tablecmds.c
src/backend/tcop/utility.c
src/include/access/reloptions.h

index d6eb5d8559939fef263e9cab96c9a98d13cbc45f..49fd35bfc55302b462fc8ca710ee691eaadf47cc 100644 (file)
@@ -1154,7 +1154,7 @@ add_local_string_reloption(local_relopts *relopts, const char *name,
  */
 Datum
 transformRelOptions(Datum oldOptions, List *defList, const char *namspace,
-                   char *validnsps[], bool acceptOidsOff, bool isReset)
+                   const char *const validnsps[], bool acceptOidsOff, bool isReset)
 {
    Datum       result;
    ArrayBuildState *astate;
index c71ff80188878ddae18a12dbdc5e85aacbf41e89..0b629b1f79ca5820bd3fbbdbbc20e33981caf4c8 100644 (file)
@@ -83,7 +83,7 @@ create_ctas_internal(List *attrList, IntoClause *into)
    bool        is_matview;
    char        relkind;
    Datum       toast_options;
-   static char *validnsps[] = HEAP_RELOPT_NAMESPACES;
+   const char *const validnsps[] = HEAP_RELOPT_NAMESPACES;
    ObjectAddress intoRelationAddr;
 
    /* This code supports both CREATE TABLE AS and CREATE MATERIALIZED VIEW */
index 0b2a52463f16b91da2d0ecaea05d04d629fa2d13..1f94f4fdbbc32353e92337ae734f65e7305d44d9 100644 (file)
@@ -700,7 +700,7 @@ DefineRelation(CreateStmt *stmt, char relkind, Oid ownerId,
    ListCell   *listptr;
    AttrNumber  attnum;
    bool        partitioned;
-   static char *validnsps[] = HEAP_RELOPT_NAMESPACES;
+   const char *const validnsps[] = HEAP_RELOPT_NAMESPACES;
    Oid         ofTypeId;
    ObjectAddress address;
    LOCKMODE    parentLockmode;
@@ -14897,7 +14897,7 @@ ATExecSetRelOptions(Relation rel, List *defList, AlterTableType operation,
    Datum       repl_val[Natts_pg_class];
    bool        repl_null[Natts_pg_class];
    bool        repl_repl[Natts_pg_class];
-   static char *validnsps[] = HEAP_RELOPT_NAMESPACES;
+   const char *const validnsps[] = HEAP_RELOPT_NAMESPACES;
 
    if (defList == NIL && operation != AT_ReplaceRelOptions)
        return;                 /* nothing to do */
index 702a6c3a0b075929a4b7111ebbc6f394dc5f2d84..b2ea8125c92423ecfc0529208b8dc7e701428dbc 100644 (file)
@@ -1155,7 +1155,7 @@ ProcessUtilitySlow(ParseState *pstate,
                        {
                            CreateStmt *cstmt = (CreateStmt *) stmt;
                            Datum       toast_options;
-                           static char *validnsps[] = HEAP_RELOPT_NAMESPACES;
+                           const char *const validnsps[] = HEAP_RELOPT_NAMESPACES;
 
                            /* Remember transformed RangeVar for LIKE */
                            table_rv = cstmt->relation;
index 81829b8270a79b9788a855d9242b45054559c601..df6923c9d50eda6a6e84a6a3820bca6ae5a74234 100644 (file)
@@ -220,7 +220,7 @@ extern void add_local_string_reloption(local_relopts *relopts, const char *name,
                                       fill_string_relopt filler, int offset);
 
 extern Datum transformRelOptions(Datum oldOptions, List *defList,
-                                const char *namspace, char *validnsps[],
+                                const char *namspace, const char *const validnsps[],
                                 bool acceptOidsOff, bool isReset);
 extern List *untransformRelOptions(Datum options);
 extern bytea *extractRelOptions(HeapTuple tuple, TupleDesc tupdesc,