pgsql: Make various variables const (read-only).

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: pgsql-committers(at)postgresql(dot)org
Subject: pgsql: Make various variables const (read-only).
Date: 2014-01-18 21:04:45
Message-ID: E1W4d4P-0007kz-G4@gemulon.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers

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

Branch
------
master

Details
-------
http://git.postgresql.org/pg/commitdiff/0d79c0a8cc20dbaa39112d78a9abb821c4ca3554

Modified Files
--------------
src/backend/catalog/objectaddress.c | 28 +++++++-------
src/backend/commands/conversioncmds.c | 2 +-
src/backend/regex/regc_lex.c | 4 +-
src/backend/regex/regcomp.c | 2 +-
src/backend/regex/regerror.c | 6 +--
src/backend/tsearch/wparser_def.c | 4 +-
src/backend/utils/adt/datetime.c | 6 +--
src/backend/utils/adt/formatting.c | 67 +++++++++++++++------------------
src/backend/utils/adt/tsrank.c | 16 ++++----
src/backend/utils/mb/encnames.c | 55 +++++++++++----------------
src/backend/utils/mb/mbutils.c | 6 +--
src/backend/utils/mb/wchar.c | 2 +-
src/common/relpath.c | 2 +-
src/include/common/relpath.h | 3 +-
src/include/mb/pg_wchar.h | 26 ++++---------
src/include/utils/datetime.h | 2 +
16 files changed, 101 insertions(+), 130 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Stephen Frost 2014-01-18 23:51:11 pgsql: Allow SET TABLESPACE to database default
Previous Message Andrew Dunstan 2014-01-18 20:31:04 pgsql: Export a few more symbols required for test_shm_mq module.