diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2014-01-18 16:04:11 -0500 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2014-01-18 16:04:32 -0500 |
commit | 0d79c0a8cc20dbaa39112d78a9abb821c4ca3554 (patch) | |
tree | fbf44e5fc488b94c056aead354111d4e32167318 /src/backend/utils/adt/datetime.c | |
parent | 7d7eee8bb702d7796a0d7c5886c1f4685f2e2806 (diff) | |
download | postgresql-0d79c0a8cc20dbaa39112d78a9abb821c4ca3554.tar.gz postgresql-0d79c0a8cc20dbaa39112d78a9abb821c4ca3554.zip |
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
Diffstat (limited to 'src/backend/utils/adt/datetime.c')
-rw-r--r-- | src/backend/utils/adt/datetime.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/src/backend/utils/adt/datetime.c b/src/backend/utils/adt/datetime.c index 9e4c9829ad9..a61b40e17f9 100644 --- a/src/backend/utils/adt/datetime.c +++ b/src/backend/utils/adt/datetime.c @@ -59,10 +59,10 @@ const int day_tab[2][13] = {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31, 0} }; -char *months[] = {"Jan", "Feb", "Mar", "Apr", "May", "Jun", +const char *const months[] = {"Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec", NULL}; -char *days[] = {"Sunday", "Monday", "Tuesday", "Wednesday", +const char *const days[] = {"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", NULL}; @@ -186,7 +186,7 @@ static const datetkn datetktbl[] = { static int szdatetktbl = sizeof datetktbl / sizeof datetktbl[0]; -static datetkn deltatktbl[] = { +static const datetkn deltatktbl[] = { /* text, token, lexval */ {"@", IGNORE_DTF, 0}, /* postgres relative prefix */ {DAGO, AGO, 0}, /* "ago" indicates negative time offset */ |