From 0d79c0a8cc20dbaa39112d78a9abb821c4ca3554 Mon Sep 17 00:00:00 2001 From: Tom Lane Date: Sat, 18 Jan 2014 16:04:11 -0500 Subject: 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 --- src/backend/utils/mb/mbutils.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/backend/utils/mb/mbutils.c') diff --git a/src/backend/utils/mb/mbutils.c b/src/backend/utils/mb/mbutils.c index 6d1cd8e8759..08440e9fe9d 100644 --- a/src/backend/utils/mb/mbutils.c +++ b/src/backend/utils/mb/mbutils.c @@ -55,9 +55,9 @@ static FmgrInfo *ToClientConvProc = NULL; /* * These variables track the currently-selected encodings. */ -static pg_enc2name *ClientEncoding = &pg_enc2name_tbl[PG_SQL_ASCII]; -static pg_enc2name *DatabaseEncoding = &pg_enc2name_tbl[PG_SQL_ASCII]; -static pg_enc2name *MessageEncoding = &pg_enc2name_tbl[PG_SQL_ASCII]; +static const pg_enc2name *ClientEncoding = &pg_enc2name_tbl[PG_SQL_ASCII]; +static const pg_enc2name *DatabaseEncoding = &pg_enc2name_tbl[PG_SQL_ASCII]; +static const pg_enc2name *MessageEncoding = &pg_enc2name_tbl[PG_SQL_ASCII]; /* * During backend startup we can't set client encoding because we (a) -- cgit v1.2.3