Make various variables const (read-only).
authorTom Lane <tgl@sss.pgh.pa.us>
Sat, 18 Jan 2014 21:04:11 +0000 (16:04 -0500)
committerTom Lane <tgl@sss.pgh.pa.us>
Sat, 18 Jan 2014 21:04:32 +0000 (16:04 -0500)
commit0d79c0a8cc20dbaa39112d78a9abb821c4ca3554
treefbf44e5fc488b94c056aead354111d4e32167318
parent7d7eee8bb702d7796a0d7c5886c1f4685f2e2806
Make various variables const (read-only).

These changes should generally improve correctness/maintainability.
A nice side benefit is that several kilobytes move from initialized
data to text segment, allowing them to be shared across processes and
probably reducing copy-on-write overhead while forking a new backend.
Unfortunately this doesn't seem to help libpq in the same way (at least
not when it's compiled with -fpic on x86_64), but we can hope the linker
at least collects all nominally-const data together even if it's not
actually part of the text segment.

Also, make pg_encname_tbl[] static in encnames.c, since there seems
no very good reason for any other code to use it; per a suggestion
from Wim Lewis, who independently submitted a patch that was mostly
a subset of this one.

Oskari Saarenmaa, with some editorialization by me
16 files changed:
src/backend/catalog/objectaddress.c
src/backend/commands/conversioncmds.c
src/backend/regex/regc_lex.c
src/backend/regex/regcomp.c
src/backend/regex/regerror.c
src/backend/tsearch/wparser_def.c
src/backend/utils/adt/datetime.c
src/backend/utils/adt/formatting.c
src/backend/utils/adt/tsrank.c
src/backend/utils/mb/encnames.c
src/backend/utils/mb/mbutils.c
src/backend/utils/mb/wchar.c
src/common/relpath.c
src/include/common/relpath.h
src/include/mb/pg_wchar.h
src/include/utils/datetime.h