1010 * Written by Peter Eisentraut <peter_e@gmx.net>.
1111 *
1212 * IDENTIFICATION
13- * $Header: /cvsroot/pgsql/src/backend/utils/misc/guc.c,v 1.142 2003/07/28 16:22:02 momjian Exp $
13+ * $Header: /cvsroot/pgsql/src/backend/utils/misc/guc.c,v 1.143 2003/07/28 19:31:32 tgl Exp $
1414 *
1515 *--------------------------------------------------------------------
1616 */
@@ -155,49 +155,6 @@ static char *timezone_string;
155155static char * XactIsoLevel_string ;
156156
157157
158- /*
159- * Used for pg_settings. Keep in sync with config_type enum in guc_tables.h
160- */
161- static char * config_type_name [] =
162- {
163- "bool" ,
164- "integer" ,
165- "real" ,
166- "string"
167- };
168-
169- /*
170- * Used for pg_settings. Keep in sync with GucContext enum in guc.h
171- */
172- static char * GucContextName [] =
173- {
174- "internal" ,
175- "postmaster" ,
176- "sighup" ,
177- "backend" ,
178- "super-user" ,
179- "userlimit" ,
180- "user"
181- };
182-
183- /*
184- * Used for pg_settings. Keep in sync with GucSource enum in guc.h
185- */
186- static char * GucSourceName [] =
187- {
188- "default" ,
189- "environment variable" ,
190- "configuration file" ,
191- "command line" ,
192- "userstart" ,
193- "database" ,
194- "user" ,
195- "client" ,
196- "override" ,
197- "session"
198- };
199-
200-
201158/* Macros for freeing malloc'd pointers only if appropriate to do so */
202159/* Some of these tests are probably redundant, but be safe ... */
203160#define SET_STRING_VARIABLE (rec , newval ) \
@@ -239,46 +196,126 @@ static char *GucSourceName[] =
239196
240197
241198/*
242- * The display name for each of the groupings defined in enum config_group
243- * This array needs to be kept in sync with enum config_group.
244- * This array however needs to be NULL terminated .
199+ * Displayable names for context types ( enum GucContext)
200+ *
201+ * Note: these strings are deliberately not localized .
245202 */
246- const char * const config_group_names [] = {
203+ const char * const GucContext_Names [] =
204+ {
205+ /* PGC_INTERNAL */ "internal" ,
206+ /* PGC_POSTMASTER */ "postmaster" ,
207+ /* PGC_SIGHUP */ "sighup" ,
208+ /* PGC_BACKEND */ "backend" ,
209+ /* PGC_SUSET */ "superuser" ,
210+ /* PGC_USERLIMIT */ "userlimit" ,
211+ /* PGC_USERSET */ "user"
212+ };
213+
214+ /*
215+ * Displayable names for source types (enum GucSource)
216+ *
217+ * Note: these strings are deliberately not localized.
218+ */
219+ const char * const GucSource_Names [] =
220+ {
221+ /* PGC_S_DEFAULT */ "default" ,
222+ /* PGC_S_ENV_VAR */ "environment variable" ,
223+ /* PGC_S_FILE */ "configuration file" ,
224+ /* PGC_S_ARGV */ "command line" ,
225+ /* PGC_S_UNPRIVILEGED */ "unprivileged" ,
226+ /* PGC_S_DATABASE */ "database" ,
227+ /* PGC_S_USER */ "user" ,
228+ /* PGC_S_CLIENT */ "client" ,
229+ /* PGC_S_OVERRIDE */ "override" ,
230+ /* PGC_S_SESSION */ "session"
231+ };
232+
233+ /*
234+ * Displayable names for the groupings defined in enum config_group
235+ */
236+ const char * const config_group_names [] =
237+ {
238+ /* UNGROUPED */
247239 gettext_noop ("Ungrouped" ),
240+ /* CONN_AUTH */
248241 gettext_noop ("Connections & Authentication" ),
242+ /* CONN_AUTH_SETTINGS */
249243 gettext_noop ("Connections & Authentication / Connection Settings" ),
244+ /* CONN_AUTH_SECURITY */
250245 gettext_noop ("Connections & Authentication / Security & Authentication" ),
246+ /* RESOURCES */
251247 gettext_noop ("Resource Usage" ),
248+ /* RESOURCES_MEM */
252249 gettext_noop ("Resource Usage / Memory" ),
250+ /* RESOURCES_FSM */
253251 gettext_noop ("Resource Usage / Free Space Map" ),
252+ /* RESOURCES_KERNEL */
254253 gettext_noop ("Resource Usage / Kernel Resources" ),
254+ /* WAL */
255255 gettext_noop ("Write Ahead Log" ),
256+ /* WAL_SETTINGS */
256257 gettext_noop ("Write Ahead Log / Settings" ),
258+ /* WAL_CHECKPOINTS */
257259 gettext_noop ("Write Ahead Log / Checkpoints" ),
260+ /* QUERY_TUNING */
258261 gettext_noop ("Query Tuning" ),
262+ /* QUERY_TUNING_METHOD */
259263 gettext_noop ("Query Tuning / Planner Method Enabling" ),
264+ /* QUERY_TUNING_COST */
260265 gettext_noop ("Query Tuning / Planner Cost Constants" ),
266+ /* QUERY_TUNING_GEQO */
261267 gettext_noop ("Query Tuning / Genetic Query Optimizer" ),
268+ /* QUERY_TUNING_OTHER */
262269 gettext_noop ("Query Tuning / Other Planner Options" ),
270+ /* LOGGING */
263271 gettext_noop ("Reporting & Logging" ),
272+ /* LOGGING_SYSLOG */
264273 gettext_noop ("Reporting & Logging / Syslog" ),
274+ /* LOGGING_WHEN */
265275 gettext_noop ("Reporting & Logging / When To Log" ),
276+ /* LOGGING_WHAT */
266277 gettext_noop ("Reporting & Logging / What To Log" ),
278+ /* STATS */
267279 gettext_noop ("Statistics" ),
280+ /* STATS_MONITORING */
268281 gettext_noop ("Statistics / Monitoring" ),
282+ /* STATS_COLLECTOR */
269283 gettext_noop ("Statistics / Query & Index Statistics Collector" ),
284+ /* CLIENT_CONN */
270285 gettext_noop ("Client Connection Defaults" ),
286+ /* CLIENT_CONN_STATEMENT */
271287 gettext_noop ("Client Connection Defaults / Statement Behavior" ),
288+ /* CLIENT_CONN_LOCALE */
272289 gettext_noop ("Client Connection Defaults / Locale and Formatting" ),
290+ /* CLIENT_CONN_OTHER */
273291 gettext_noop ("Client Connection Defaults / Other Defaults" ),
292+ /* LOCK_MANAGEMENT */
274293 gettext_noop ("Lock Management" ),
294+ /* COMPAT_OPTIONS */
275295 gettext_noop ("Version & Platform Compatibility" ),
296+ /* COMPAT_OPTIONS_PREVIOUS */
276297 gettext_noop ("Version & Platform Compatibility / Previous Postgres Versions" ),
298+ /* COMPAT_OPTIONS_CLIENT */
277299 gettext_noop ("Version & Platform Compatibility / Other Platforms & Clients" ),
300+ /* DEVELOPER_OPTIONS */
278301 gettext_noop ("Developer Options" ),
302+ /* help_config wants this array to be null-terminated */
279303 NULL
280304};
281305
306+ /*
307+ * Displayable names for GUC variable types (enum config_type)
308+ *
309+ * Note: these strings are deliberately not localized.
310+ */
311+ const char * const config_type_names [] =
312+ {
313+ /* PGC_BOOL */ "bool" ,
314+ /* PGC_INT */ "integer" ,
315+ /* PGC_REAL */ "real" ,
316+ /* PGC_STRING */ "string"
317+ };
318+
282319
283320/*
284321 * Contents of GUC tables
@@ -2509,9 +2546,9 @@ set_config_option(const char *name, const char *value,
25092546 name )));
25102547 return false;
25112548 }
2512- /* Limit non-super user changes */
2549+ /* Limit non-superuser changes */
25132550 if (record -> context == PGC_USERLIMIT &&
2514- source > PGC_S_USERSTART &&
2551+ source > PGC_S_UNPRIVILEGED &&
25152552 newval < conf -> session_val &&
25162553 !superuser ())
25172554 {
@@ -2522,10 +2559,10 @@ set_config_option(const char *name, const char *value,
25222559 errhint ("Must be superuser to change this value to false." )));
25232560 return false;
25242561 }
2525- /* Allow admin to override non-super user setting */
2562+ /* Allow admin to override non-superuser setting */
25262563 if (record -> context == PGC_USERLIMIT &&
2527- source < PGC_S_USERSTART &&
2528- record -> session_source > PGC_S_USERSTART &&
2564+ source < PGC_S_UNPRIVILEGED &&
2565+ record -> session_source > PGC_S_UNPRIVILEGED &&
25292566 newval > conf -> session_val &&
25302567 !superuser ())
25312568 DoIt = DoIt_orig ;
@@ -2605,9 +2642,9 @@ set_config_option(const char *name, const char *value,
26052642 newval , name , conf -> min , conf -> max )));
26062643 return false;
26072644 }
2608- /* Limit non-super user changes */
2645+ /* Limit non-superuser changes */
26092646 if (record -> context == PGC_USERLIMIT &&
2610- source > PGC_S_USERSTART &&
2647+ source > PGC_S_UNPRIVILEGED &&
26112648 conf -> session_val != 0 &&
26122649 (newval > conf -> session_val || newval == 0 ) &&
26132650 !superuser ())
@@ -2619,10 +2656,10 @@ set_config_option(const char *name, const char *value,
26192656 errhint ("Must be superuser to increase this value or set it to zero." )));
26202657 return false;
26212658 }
2622- /* Allow admin to override non-super user setting */
2659+ /* Allow admin to override non-superuser setting */
26232660 if (record -> context == PGC_USERLIMIT &&
2624- source < PGC_S_USERSTART &&
2625- record -> session_source > PGC_S_USERSTART &&
2661+ source < PGC_S_UNPRIVILEGED &&
2662+ record -> session_source > PGC_S_UNPRIVILEGED &&
26262663 newval < conf -> session_val &&
26272664 !superuser ())
26282665 DoIt = DoIt_orig ;
@@ -2702,9 +2739,9 @@ set_config_option(const char *name, const char *value,
27022739 newval , name , conf -> min , conf -> max )));
27032740 return false;
27042741 }
2705- /* Limit non-super user changes */
2742+ /* Limit non-superuser changes */
27062743 if (record -> context == PGC_USERLIMIT &&
2707- source > PGC_S_USERSTART &&
2744+ source > PGC_S_UNPRIVILEGED &&
27082745 newval > conf -> session_val &&
27092746 !superuser ())
27102747 {
@@ -2715,10 +2752,10 @@ set_config_option(const char *name, const char *value,
27152752 errhint ("Must be superuser to increase this value." )));
27162753 return false;
27172754 }
2718- /* Allow admin to override non-super user setting */
2755+ /* Allow admin to override non-superuser setting */
27192756 if (record -> context == PGC_USERLIMIT &&
2720- source < PGC_S_USERSTART &&
2721- record -> session_source > PGC_S_USERSTART &&
2757+ source < PGC_S_UNPRIVILEGED &&
2758+ record -> session_source > PGC_S_UNPRIVILEGED &&
27222759 newval < conf -> session_val &&
27232760 !superuser ())
27242761 DoIt = DoIt_orig ;
@@ -2791,15 +2828,18 @@ set_config_option(const char *name, const char *value,
27912828 return false;
27922829 }
27932830
2794- if (* conf -> variable )
2831+ if (record -> context == PGC_USERLIMIT &&
2832+ * conf -> variable )
27952833 {
27962834 int old_int_value , new_int_value ;
27972835
2798- /* Limit non-super user changes */
2799- assign_msglvl (& old_int_value , conf -> reset_val , true, interactive );
2800- assign_msglvl (& new_int_value , newval , true, interactive );
2801- if (record -> context == PGC_USERLIMIT &&
2802- source > PGC_S_USERSTART &&
2836+ /* all USERLIMIT strings are message levels */
2837+ assign_msglvl (& old_int_value , conf -> reset_val ,
2838+ true, interactive );
2839+ assign_msglvl (& new_int_value , newval ,
2840+ true, interactive );
2841+ /* Limit non-superuser changes */
2842+ if (source > PGC_S_UNPRIVILEGED &&
28032843 new_int_value > old_int_value &&
28042844 !superuser ())
28052845 {
@@ -2810,14 +2850,13 @@ set_config_option(const char *name, const char *value,
28102850 errhint ("Must be superuser to increase this value." )));
28112851 return false;
28122852 }
2813- /* Allow admin to override non-super user setting */
2814- if (record -> context == PGC_USERLIMIT &&
2815- source < PGC_S_USERSTART &&
2816- record -> session_source > PGC_S_USERSTART &&
2853+ /* Allow admin to override non-superuser setting */
2854+ if (source < PGC_S_UNPRIVILEGED &&
2855+ record -> session_source > PGC_S_UNPRIVILEGED &&
28172856 newval < conf -> session_val &&
28182857 !superuser ())
28192858 DoIt = DoIt_orig ;
2820- }
2859+ }
28212860 }
28222861 else if (conf -> reset_val )
28232862 {
@@ -3389,13 +3428,13 @@ GetConfigOptionByNum(int varnum, const char **values, bool *noshow)
33893428 values [1 ] = _ShowOption (conf );
33903429
33913430 /* context */
3392- values [2 ] = GucContextName [conf -> context ];
3431+ values [2 ] = GucContext_Names [conf -> context ];
33933432
33943433 /* vartype */
3395- values [3 ] = config_type_name [conf -> vartype ];
3434+ values [3 ] = config_type_names [conf -> vartype ];
33963435
33973436 /* source */
3398- values [4 ] = GucSourceName [conf -> source ];
3437+ values [4 ] = GucSource_Names [conf -> source ];
33993438
34003439 /* now get the type specifc attributes */
34013440 switch (conf -> vartype )
0 commit comments