Hackers,
I noticed that there was a mismatch between the const qualifiers for
excludeDirContents in src/backend/backup/backup/basebackup.c and
src/bin/pg_rewind/file_map.c and that led me to use ^static const.*\*.*=
to do a quick search for similar cases.
I think at the least we should make excludeDirContents match, but the
rest of the changes seem like a good idea as well.
Regards,
-David
diff --git a/contrib/fuzzystrmatch/fuzzystrmatch.c
b/contrib/fuzzystrmatch/fuzzystrmatch.c
index 5686497983..fc9cfbeda4 100644
--- a/contrib/fuzzystrmatch/fuzzystrmatch.c
+++ b/contrib/fuzzystrmatch/fuzzystrmatch.c
@@ -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)
diff --git a/contrib/pgcrypto/pgp-armor.c b/contrib/pgcrypto/pgp-armor.c
index 9128756647..bfc90af063 100644
--- a/contrib/pgcrypto/pgp-armor.c
+++ b/contrib/pgcrypto/pgp-armor.c
@@ -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
diff --git a/src/backend/catalog/heap.c b/src/backend/catalog/heap.c
index b42711f574..d03c961678 100644
--- a/src/backend/catalog/heap.c
+++ b/src/backend/catalog/heap.c
@@ -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.
diff --git a/src/backend/utils/adt/ruleutils.c
b/src/backend/utils/adt/ruleutils.c
index 97b0ef22ac..4fae852666 100644
--- a/src/backend/utils/adt/ruleutils.c
+++ b/src/backend/utils/adt/ruleutils.c
@@ -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;
diff --git a/src/backend/utils/misc/guc.c b/src/backend/utils/misc/guc.c
index 84e7ad4d90..c25c697a06 100644
--- a/src/backend/utils/misc/guc.c
+++ b/src/backend/utils/misc/guc.c
@@ -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[] =
{
diff --git a/src/bin/initdb/initdb.c b/src/bin/initdb/initdb.c
index 905b979947..79548ba06e 100644
--- a/src/bin/initdb/initdb.c
+++ b/src/bin/initdb/initdb.c
@@ -217,8 +217,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 = "";
diff --git a/src/bin/pg_amcheck/pg_amcheck.c b/src/bin/pg_amcheck/pg_amcheck.c
index 57df14bc1e..8ac7051ff4 100644
--- a/src/bin/pg_amcheck/pg_amcheck.c
+++ b/src/bin/pg_amcheck/pg_amcheck.c
@@ -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'";
diff --git a/src/bin/pg_rewind/filemap.c b/src/bin/pg_rewind/filemap.c
index bd5c598e20..bdef6b8c6a 100644
--- a/src/bin/pg_rewind/filemap.c
+++ b/src/bin/pg_rewind/filemap.c
@@ -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
diff --git a/src/bin/pg_rewind/parsexlog.c b/src/bin/pg_rewind/parsexlog.c
index 27782237d0..0233ece88b 100644
--- a/src/bin/pg_rewind/parsexlog.c
+++ b/src/bin/pg_rewind/parsexlog.c
@@ -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"
};
diff --git a/src/bin/pgbench/pgbench.c b/src/bin/pgbench/pgbench.c
index 713e8a06bb..7a42fd00ee 100644
--- a/src/bin/pgbench/pgbench.c
+++ b/src/bin/pgbench/pgbench.c
@@ -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.
diff --git a/src/interfaces/libpq/pqexpbuffer.c
b/src/interfaces/libpq/pqexpbuffer.c
index de7e0328db..6d83014aab 100644
--- a/src/interfaces/libpq/pqexpbuffer.c
+++ b/src/interfaces/libpq/pqexpbuffer.c
@@ -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;
/*