Add some const qualifiers
authorPeter Eisentraut <peter@eisentraut.org>
Tue, 26 Sep 2023 10:28:57 +0000 (11:28 +0100)
committerPeter Eisentraut <peter@eisentraut.org>
Tue, 26 Sep 2023 10:28:57 +0000 (11:28 +0100)
There was a mismatch between the const qualifiers for
excludeDirContents in src/backend/backup/basebackup.c and
src/bin/pg_rewind/filemap.c, which led to a quick search for similar
cases.  We should make excludeDirContents match, but the rest of the
changes seem like a good idea as well.

Author: David Steele <david@pgmasters.net>
Discussion: https://www.postgresql.org/message-id/flat/669a035c-d23d-2f38-7ff0-0cb93e01d610@pgmasters.net

contrib/fuzzystrmatch/fuzzystrmatch.c
contrib/pgcrypto/pgp-armor.c
src/backend/catalog/heap.c
src/backend/utils/adt/ruleutils.c
src/backend/utils/misc/guc.c
src/bin/initdb/initdb.c
src/bin/pg_amcheck/pg_amcheck.c
src/bin/pg_rewind/filemap.c
src/bin/pg_rewind/parsexlog.c
src/bin/pgbench/pgbench.c
src/interfaces/libpq/pqexpbuffer.c

index 56864979832ce6b4b4c740208bf4a46f3709e6eb..fc9cfbeda4b1410009ec964ff55cecf95935daf9 100644 (file)
@@ -55,7 +55,7 @@ static void _soundex(const char *instr, char *outstr);
 #define SOUNDEX_LEN 4
 
 /*                                 ABCDEFGHIJKLMNOPQRSTUVWXYZ */
-static const char *soundex_table = "01230120022455012623010202";
+static const char *const soundex_table = "01230120022455012623010202";
 
 static char
 soundex_code(char letter)
index 9128756647c559db33eb388b8238794001fd2495..bfc90af063d513eb02fc2ef8c48c3b2cec692dd6 100644 (file)
@@ -178,8 +178,8 @@ pg_base64_dec_len(unsigned srclen)
  * PGP armor
  */
 
-static const char *armor_header = "-----BEGIN PGP MESSAGE-----\n";
-static const char *armor_footer = "\n-----END PGP MESSAGE-----\n";
+static const char *const armor_header = "-----BEGIN PGP MESSAGE-----\n";
+static const char *const armor_footer = "\n-----END PGP MESSAGE-----\n";
 
 /* CRC24 implementation from rfc2440 */
 #define CRC24_INIT 0x00b704ceL
index b42711f574467a1516812aeca8cf14f53339b25c..d03c9616786dd65b19c8ca727b9827dfc833ffbb 100644 (file)
@@ -228,7 +228,7 @@ static const FormData_pg_attribute a6 = {
    .attislocal = true,
 };
 
-static const FormData_pg_attribute *SysAtt[] = {&a1, &a2, &a3, &a4, &a5, &a6};
+static const FormData_pg_attribute *const SysAtt[] = {&a1, &a2, &a3, &a4, &a5, &a6};
 
 /*
  * This function returns a Form_pg_attribute pointer for a system attribute.
index 68f301484e38a720504ee003f58e7b3b58bcb8cc..8d5eac47916112d011406518abcb2aecba97001c 100644 (file)
@@ -316,9 +316,9 @@ typedef void (*rsv_callback) (Node *node, deparse_context *context,
  * ----------
  */
 static SPIPlanPtr plan_getrulebyoid = NULL;
-static const char *query_getrulebyoid = "SELECT * FROM pg_catalog.pg_rewrite WHERE oid = $1";
+static const char *const query_getrulebyoid = "SELECT * FROM pg_catalog.pg_rewrite WHERE oid = $1";
 static SPIPlanPtr plan_getviewrule = NULL;
-static const char *query_getviewrule = "SELECT * FROM pg_catalog.pg_rewrite WHERE ev_class = $1 AND rulename = $2";
+static const char *const query_getviewrule = "SELECT * FROM pg_catalog.pg_rewrite WHERE ev_class = $1 AND rulename = $2";
 
 /* GUC parameters */
 bool       quote_all_identifiers = false;
index 84e7ad4d9072aebd07a954575af771fad6b67c53..c25c697a0691e4f580811f5b591f287dabe14621 100644 (file)
@@ -112,7 +112,7 @@ typedef struct
 #error XLOG_BLCKSZ must be between 1KB and 1MB
 #endif
 
-static const char *memory_units_hint = gettext_noop("Valid units for this parameter are \"B\", \"kB\", \"MB\", \"GB\", and \"TB\".");
+static const char *const memory_units_hint = gettext_noop("Valid units for this parameter are \"B\", \"kB\", \"MB\", \"GB\", and \"TB\".");
 
 static const unit_conversion memory_unit_conversion_table[] =
 {
@@ -149,7 +149,7 @@ static const unit_conversion memory_unit_conversion_table[] =
    {""}                        /* end of table marker */
 };
 
-static const char *time_units_hint = gettext_noop("Valid units for this parameter are \"us\", \"ms\", \"s\", \"min\", \"h\", and \"d\".");
+static const char *const time_units_hint = gettext_noop("Valid units for this parameter are \"us\", \"ms\", \"s\", \"min\", \"h\", and \"d\".");
 
 static const unit_conversion time_unit_conversion_table[] =
 {
index bddb30d766cb2170a70d3a807e9568a20122bd48..0c6f5ceb0acdd9885eea0315a2526027e020ad56 100644 (file)
@@ -218,8 +218,8 @@ static bool authwarning = false;
  * but here it is more convenient to pass it as an environment variable
  * (no quoting to worry about).
  */
-static const char *boot_options = "-F -c log_checkpoints=false";
-static const char *backend_options = "--single -F -O -j -c search_path=pg_catalog -c exit_on_error=true -c log_checkpoints=false";
+static const char *const boot_options = "-F -c log_checkpoints=false";
+static const char *const backend_options = "--single -F -O -j -c search_path=pg_catalog -c exit_on_error=true -c log_checkpoints=false";
 
 /* Additional switches to pass to backend (either boot or standalone) */
 static char *extra_options = "";
index 57df14bc1e033691bd6b6424e0641d7ced7ddd76..8ac7051ff4daa85307b9ab184703699054729633 100644 (file)
@@ -166,7 +166,7 @@ typedef struct RelationInfo
  * Query for determining if contrib's amcheck is installed.  If so, selects the
  * namespace name where amcheck's functions can be found.
  */
-static const char *amcheck_sql =
+static const char *const amcheck_sql =
 "SELECT n.nspname, x.extversion FROM pg_catalog.pg_extension x"
 "\nJOIN pg_catalog.pg_namespace n ON x.extnamespace = n.oid"
 "\nWHERE x.extname = 'amcheck'";
index 58280d9abceac8280b8d3875a3012f6a956746b0..ecadd69dc5397a68269b890f6f53c3b2bc771230 100644 (file)
@@ -85,7 +85,7 @@ struct exclude_list_item
  * they are defined in backend-only headers.  So this list is maintained
  * with a best effort in mind.
  */
-static const char *excludeDirContents[] =
+static const char *const excludeDirContents[] =
 {
    /*
     * Skip temporary statistics files. PG_STAT_TMP_DIR must be skipped
index 27782237d0577960e9e844124821b45a0682760f..0233ece88be8551ed35f816be57ef6efdfee80b8 100644 (file)
@@ -31,7 +31,7 @@
 #define PG_RMGR(symname,name,redo,desc,identify,startup,cleanup,mask,decode) \
   name,
 
-static const char *RmgrNames[RM_MAX_ID + 1] = {
+static const char *const RmgrNames[RM_MAX_ID + 1] = {
 #include "access/rmgrlist.h"
 };
 
index 713e8a06bb5d3b4647d697f9ae3682f20172f153..7a42fd00ee4007d49e7996f6525b26dbdf99c923 100644 (file)
@@ -231,7 +231,7 @@ typedef enum
 } partition_method_t;
 
 static partition_method_t partition_method = PART_NONE;
-static const char *PARTITION_METHOD[] = {"none", "range", "hash"};
+static const char *const PARTITION_METHOD[] = {"none", "range", "hash"};
 
 /* random seed used to initialize base_random_sequence */
 int64      random_seed = -1;
@@ -709,7 +709,7 @@ typedef enum QueryMode
 } QueryMode;
 
 static QueryMode querymode = QUERY_SIMPLE;
-static const char *QUERYMODE[] = {"simple", "extended", "prepared"};
+static const char *const QUERYMODE[] = {"simple", "extended", "prepared"};
 
 /*
  * struct Command represents one command in a script.
index de7e0328dbb1a57d5b38f36f2b222e55d0f38d5a..6d83014aab650cb71d0f546874905e882b98b265 100644 (file)
@@ -38,7 +38,7 @@
 static const char oom_buffer[1] = "";
 
 /* Need a char * for unconstify() compatibility */
-static const char *oom_buffer_ptr = oom_buffer;
+static const char *const oom_buffer_ptr = oom_buffer;
 
 
 /*