10
10
* Written by Peter Eisentraut <peter_e@gmx.net>.
11
11
*
12
12
* 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 $
14
14
*
15
15
*--------------------------------------------------------------------
16
16
*/
@@ -155,49 +155,6 @@ static char *timezone_string;
155
155
static char * XactIsoLevel_string ;
156
156
157
157
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
-
201
158
/* Macros for freeing malloc'd pointers only if appropriate to do so */
202
159
/* Some of these tests are probably redundant, but be safe ... */
203
160
#define SET_STRING_VARIABLE (rec , newval ) \
@@ -239,46 +196,126 @@ static char *GucSourceName[] =
239
196
240
197
241
198
/*
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 .
245
202
*/
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 */
247
239
gettext_noop ("Ungrouped" ),
240
+ /* CONN_AUTH */
248
241
gettext_noop ("Connections & Authentication" ),
242
+ /* CONN_AUTH_SETTINGS */
249
243
gettext_noop ("Connections & Authentication / Connection Settings" ),
244
+ /* CONN_AUTH_SECURITY */
250
245
gettext_noop ("Connections & Authentication / Security & Authentication" ),
246
+ /* RESOURCES */
251
247
gettext_noop ("Resource Usage" ),
248
+ /* RESOURCES_MEM */
252
249
gettext_noop ("Resource Usage / Memory" ),
250
+ /* RESOURCES_FSM */
253
251
gettext_noop ("Resource Usage / Free Space Map" ),
252
+ /* RESOURCES_KERNEL */
254
253
gettext_noop ("Resource Usage / Kernel Resources" ),
254
+ /* WAL */
255
255
gettext_noop ("Write Ahead Log" ),
256
+ /* WAL_SETTINGS */
256
257
gettext_noop ("Write Ahead Log / Settings" ),
258
+ /* WAL_CHECKPOINTS */
257
259
gettext_noop ("Write Ahead Log / Checkpoints" ),
260
+ /* QUERY_TUNING */
258
261
gettext_noop ("Query Tuning" ),
262
+ /* QUERY_TUNING_METHOD */
259
263
gettext_noop ("Query Tuning / Planner Method Enabling" ),
264
+ /* QUERY_TUNING_COST */
260
265
gettext_noop ("Query Tuning / Planner Cost Constants" ),
266
+ /* QUERY_TUNING_GEQO */
261
267
gettext_noop ("Query Tuning / Genetic Query Optimizer" ),
268
+ /* QUERY_TUNING_OTHER */
262
269
gettext_noop ("Query Tuning / Other Planner Options" ),
270
+ /* LOGGING */
263
271
gettext_noop ("Reporting & Logging" ),
272
+ /* LOGGING_SYSLOG */
264
273
gettext_noop ("Reporting & Logging / Syslog" ),
274
+ /* LOGGING_WHEN */
265
275
gettext_noop ("Reporting & Logging / When To Log" ),
276
+ /* LOGGING_WHAT */
266
277
gettext_noop ("Reporting & Logging / What To Log" ),
278
+ /* STATS */
267
279
gettext_noop ("Statistics" ),
280
+ /* STATS_MONITORING */
268
281
gettext_noop ("Statistics / Monitoring" ),
282
+ /* STATS_COLLECTOR */
269
283
gettext_noop ("Statistics / Query & Index Statistics Collector" ),
284
+ /* CLIENT_CONN */
270
285
gettext_noop ("Client Connection Defaults" ),
286
+ /* CLIENT_CONN_STATEMENT */
271
287
gettext_noop ("Client Connection Defaults / Statement Behavior" ),
288
+ /* CLIENT_CONN_LOCALE */
272
289
gettext_noop ("Client Connection Defaults / Locale and Formatting" ),
290
+ /* CLIENT_CONN_OTHER */
273
291
gettext_noop ("Client Connection Defaults / Other Defaults" ),
292
+ /* LOCK_MANAGEMENT */
274
293
gettext_noop ("Lock Management" ),
294
+ /* COMPAT_OPTIONS */
275
295
gettext_noop ("Version & Platform Compatibility" ),
296
+ /* COMPAT_OPTIONS_PREVIOUS */
276
297
gettext_noop ("Version & Platform Compatibility / Previous Postgres Versions" ),
298
+ /* COMPAT_OPTIONS_CLIENT */
277
299
gettext_noop ("Version & Platform Compatibility / Other Platforms & Clients" ),
300
+ /* DEVELOPER_OPTIONS */
278
301
gettext_noop ("Developer Options" ),
302
+ /* help_config wants this array to be null-terminated */
279
303
NULL
280
304
};
281
305
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
+
282
319
283
320
/*
284
321
* Contents of GUC tables
@@ -2509,9 +2546,9 @@ set_config_option(const char *name, const char *value,
2509
2546
name )));
2510
2547
return false;
2511
2548
}
2512
- /* Limit non-super user changes */
2549
+ /* Limit non-superuser changes */
2513
2550
if (record -> context == PGC_USERLIMIT &&
2514
- source > PGC_S_USERSTART &&
2551
+ source > PGC_S_UNPRIVILEGED &&
2515
2552
newval < conf -> session_val &&
2516
2553
!superuser ())
2517
2554
{
@@ -2522,10 +2559,10 @@ set_config_option(const char *name, const char *value,
2522
2559
errhint ("Must be superuser to change this value to false." )));
2523
2560
return false;
2524
2561
}
2525
- /* Allow admin to override non-super user setting */
2562
+ /* Allow admin to override non-superuser setting */
2526
2563
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 &&
2529
2566
newval > conf -> session_val &&
2530
2567
!superuser ())
2531
2568
DoIt = DoIt_orig ;
@@ -2605,9 +2642,9 @@ set_config_option(const char *name, const char *value,
2605
2642
newval , name , conf -> min , conf -> max )));
2606
2643
return false;
2607
2644
}
2608
- /* Limit non-super user changes */
2645
+ /* Limit non-superuser changes */
2609
2646
if (record -> context == PGC_USERLIMIT &&
2610
- source > PGC_S_USERSTART &&
2647
+ source > PGC_S_UNPRIVILEGED &&
2611
2648
conf -> session_val != 0 &&
2612
2649
(newval > conf -> session_val || newval == 0 ) &&
2613
2650
!superuser ())
@@ -2619,10 +2656,10 @@ set_config_option(const char *name, const char *value,
2619
2656
errhint ("Must be superuser to increase this value or set it to zero." )));
2620
2657
return false;
2621
2658
}
2622
- /* Allow admin to override non-super user setting */
2659
+ /* Allow admin to override non-superuser setting */
2623
2660
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 &&
2626
2663
newval < conf -> session_val &&
2627
2664
!superuser ())
2628
2665
DoIt = DoIt_orig ;
@@ -2702,9 +2739,9 @@ set_config_option(const char *name, const char *value,
2702
2739
newval , name , conf -> min , conf -> max )));
2703
2740
return false;
2704
2741
}
2705
- /* Limit non-super user changes */
2742
+ /* Limit non-superuser changes */
2706
2743
if (record -> context == PGC_USERLIMIT &&
2707
- source > PGC_S_USERSTART &&
2744
+ source > PGC_S_UNPRIVILEGED &&
2708
2745
newval > conf -> session_val &&
2709
2746
!superuser ())
2710
2747
{
@@ -2715,10 +2752,10 @@ set_config_option(const char *name, const char *value,
2715
2752
errhint ("Must be superuser to increase this value." )));
2716
2753
return false;
2717
2754
}
2718
- /* Allow admin to override non-super user setting */
2755
+ /* Allow admin to override non-superuser setting */
2719
2756
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 &&
2722
2759
newval < conf -> session_val &&
2723
2760
!superuser ())
2724
2761
DoIt = DoIt_orig ;
@@ -2791,15 +2828,18 @@ set_config_option(const char *name, const char *value,
2791
2828
return false;
2792
2829
}
2793
2830
2794
- if (* conf -> variable )
2831
+ if (record -> context == PGC_USERLIMIT &&
2832
+ * conf -> variable )
2795
2833
{
2796
2834
int old_int_value , new_int_value ;
2797
2835
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 &&
2803
2843
new_int_value > old_int_value &&
2804
2844
!superuser ())
2805
2845
{
@@ -2810,14 +2850,13 @@ set_config_option(const char *name, const char *value,
2810
2850
errhint ("Must be superuser to increase this value." )));
2811
2851
return false;
2812
2852
}
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 &&
2817
2856
newval < conf -> session_val &&
2818
2857
!superuser ())
2819
2858
DoIt = DoIt_orig ;
2820
- }
2859
+ }
2821
2860
}
2822
2861
else if (conf -> reset_val )
2823
2862
{
@@ -3389,13 +3428,13 @@ GetConfigOptionByNum(int varnum, const char **values, bool *noshow)
3389
3428
values [1 ] = _ShowOption (conf );
3390
3429
3391
3430
/* context */
3392
- values [2 ] = GucContextName [conf -> context ];
3431
+ values [2 ] = GucContext_Names [conf -> context ];
3393
3432
3394
3433
/* vartype */
3395
- values [3 ] = config_type_name [conf -> vartype ];
3434
+ values [3 ] = config_type_names [conf -> vartype ];
3396
3435
3397
3436
/* source */
3398
- values [4 ] = GucSourceName [conf -> source ];
3437
+ values [4 ] = GucSource_Names [conf -> source ];
3399
3438
3400
3439
/* now get the type specifc attributes */
3401
3440
switch (conf -> vartype )
0 commit comments