Make gaps array static
Looking over the recently committed work for btree tuple deletion (d168b66) should this variable not be declared static as in the attached patch? Thanks, Mark. diff --git a/src/backend/access/heap/heapam.c b/src/backend/access/heap/heapam.c index faffbb1..bbdc1ce 100644 --- a/src/backend/access/heap/heapam.c +++ b/src/backend/access/heap/heapam.c @@ -7409,7 +7409,7 @@ index_delete_sort(TM_IndexDeleteOp *delstate) * This implementation is fast with array sizes up to ~4500. This covers * all supported BLCKSZ values. */ - const int gaps[9] = {1968, 861, 336, 112, 48, 21, 7, 3, 1}; + static const int gaps[9] = {1968, 861, 336, 112, 48, 21, 7, 3, 1}; /* Think carefully before changing anything here -- keep swaps cheap */ StaticAssertStmt(sizeof(TM_IndexDelete) <= 8,
Keyword table constness in jsonpath scanner.
Hello all, While looking over the new jsonpath stuff I noticed the keyword table wasn't declared const. Shouldn't the table and the actual keyword strings both be declared const? Perhaps something like the attached (untested) patch. -Mark diff --git a/src/backend/utils/adt/jsonpath_scan.l b/src/backend/utils/adt/jsonpath_scan.l index 110ea21..5019b57 100644 --- a/src/backend/utils/adt/jsonpath_scan.l +++ b/src/backend/utils/adt/jsonpath_scan.l @@ -287,7 +287,7 @@ typedef struct keyword int16 len; bool lowercase; int val; - char *keyword; + const char *keyword; } keyword; /* @@ -295,7 +295,7 @@ typedef struct keyword * alphabetical order */ -static keyword keywords[] = { +static const keyword keywords[] = { { 2, false, IS_P, "is"}, { 2, false, TO_P, "to"}, { 3, false, ABS_P, "abs"}, @@ -324,7 +324,7 @@ checkSpecialVal() { int res = IDENT_P; int diff; - keyword *StopLow = keywords, + const keyword *StopLow = keywords, *StopHigh = keywords + lengthof(keywords), *StopMiddle;
Small const correctness patch
Hello all, Please find attached a trivial patch making a few arrays const (in addition to the data they point to). diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c index f553523857..aafc7187b0 100644 --- a/src/backend/access/transam/xlog.c +++ b/src/backend/access/transam/xlog.c @@ -769,7 +769,7 @@ typedef enum } XLogSource; /* human-readable names for XLogSources, for debugging output */ -static const char *xlogSourceNames[] = {"any", "archive", "pg_wal", "stream"}; +static const char *const xlogSourceNames[] = {"any", "archive", "pg_wal", "stream"}; /* * openLogFile is -1 or a kernel FD for an open log file segment. diff --git a/src/backend/replication/basebackup.c b/src/backend/replication/basebackup.c index d5f9b617c8..0bba32cde5 100644 --- a/src/backend/replication/basebackup.c +++ b/src/backend/replication/basebackup.c @@ -119,7 +119,7 @@ static bool noverify_checksums = false; * Note: this list should be kept in sync with the filter lists in pg_rewind's * filemap.c. */ -static const char *excludeDirContents[] = +static const char *const excludeDirContents[] = { /* * Skip temporary statistics files. PG_STAT_TMP_DIR must be skipped even @@ -160,7 +160,7 @@ static const char *excludeDirContents[] = /* * List of files excluded from backups. */ -static const char *excludeFiles[] = +static const char *const excludeFiles[] = { /* Skip auto conf temporary file. */ PG_AUTOCONF_FILENAME ".tmp",
Re: Small const correctness patch
On Thu, Aug 8, 2019 at 8:51 PM Peter Eisentraut < peter.eisentr...@2ndquadrant.com> wrote: > How did you find this? Any special compiler settings? > 16 hours stuck in a plane on an international flight. I was just eyeballing the code to kill the boredom. -Mark
Re: Small const correctness patch
On Thu, Aug 8, 2019 at 8:25 PM Ibrar Ahmed wrote: > +1 > > Patch successfully applied to the master ( > 43211c2a02f39d6568496168413dc00e0399dc2e) > That change looks like an unrelated patch for initdb. I'm still not seeing my patch there. -Mark
Missing const in DSA.
While looking at some of the recent churn in DSA I noticed that dsa_size_class_map should probably be declared const. diff --git a/src/backend/utils/mmgr/dsa.c b/src/backend/utils/mmgr/dsa.c index 33ab8d05d3..70ce7ce7da 100644 --- a/src/backend/utils/mmgr/dsa.c +++ b/src/backend/utils/mmgr/dsa.c @@ -256,7 +256,7 @@ static const uint16 dsa_size_classes[] = { * round the size of the object up to the next multiple of 8 bytes, and then * index into this array. */ -static char dsa_size_class_map[] = { +static const char dsa_size_class_map[] = { 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 14, 14, 15, 15, 15, 15, 16, 16, 16, 16, 17, 17, 17, 17, 18, 18, 18, 18, 18, 18, 18, 18, 19, 19, 19, 19, 19, 19, 19, 19,