Skip to content

Commit 1e35951

Browse files
committed
Turn a few 'validnsps' static variables into locals
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
1 parent a890ad2 commit 1e35951

File tree

5 files changed

+6
-6
lines changed

5 files changed

+6
-6
lines changed

src/backend/access/common/reloptions.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1154,7 +1154,7 @@ add_local_string_reloption(local_relopts *relopts, const char *name,
11541154
*/
11551155
Datum
11561156
transformRelOptions(Datum oldOptions, List *defList, const char *namspace,
1157-
char *validnsps[], bool acceptOidsOff, bool isReset)
1157+
const char *const validnsps[], bool acceptOidsOff, bool isReset)
11581158
{
11591159
Datum result;
11601160
ArrayBuildState *astate;

src/backend/commands/createas.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ create_ctas_internal(List *attrList, IntoClause *into)
8383
bool is_matview;
8484
char relkind;
8585
Datum toast_options;
86-
static char *validnsps[] = HEAP_RELOPT_NAMESPACES;
86+
const char *const validnsps[] = HEAP_RELOPT_NAMESPACES;
8787
ObjectAddress intoRelationAddr;
8888

8989
/* This code supports both CREATE TABLE AS and CREATE MATERIALIZED VIEW */

src/backend/commands/tablecmds.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -700,7 +700,7 @@ DefineRelation(CreateStmt *stmt, char relkind, Oid ownerId,
700700
ListCell *listptr;
701701
AttrNumber attnum;
702702
bool partitioned;
703-
static char *validnsps[] = HEAP_RELOPT_NAMESPACES;
703+
const char *const validnsps[] = HEAP_RELOPT_NAMESPACES;
704704
Oid ofTypeId;
705705
ObjectAddress address;
706706
LOCKMODE parentLockmode;
@@ -14897,7 +14897,7 @@ ATExecSetRelOptions(Relation rel, List *defList, AlterTableType operation,
1489714897
Datum repl_val[Natts_pg_class];
1489814898
bool repl_null[Natts_pg_class];
1489914899
bool repl_repl[Natts_pg_class];
14900-
static char *validnsps[] = HEAP_RELOPT_NAMESPACES;
14900+
const char *const validnsps[] = HEAP_RELOPT_NAMESPACES;
1490114901

1490214902
if (defList == NIL && operation != AT_ReplaceRelOptions)
1490314903
return; /* nothing to do */

src/backend/tcop/utility.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1155,7 +1155,7 @@ ProcessUtilitySlow(ParseState *pstate,
11551155
{
11561156
CreateStmt *cstmt = (CreateStmt *) stmt;
11571157
Datum toast_options;
1158-
static char *validnsps[] = HEAP_RELOPT_NAMESPACES;
1158+
const char *const validnsps[] = HEAP_RELOPT_NAMESPACES;
11591159

11601160
/* Remember transformed RangeVar for LIKE */
11611161
table_rv = cstmt->relation;

src/include/access/reloptions.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ extern void add_local_string_reloption(local_relopts *relopts, const char *name,
220220
fill_string_relopt filler, int offset);
221221

222222
extern Datum transformRelOptions(Datum oldOptions, List *defList,
223-
const char *namspace, char *validnsps[],
223+
const char *namspace, const char *const validnsps[],
224224
bool acceptOidsOff, bool isReset);
225225
extern List *untransformRelOptions(Datum options);
226226
extern bytea *extractRelOptions(HeapTuple tuple, TupleDesc tupdesc,

0 commit comments

Comments
 (0)