4
4
* Displays available options under grand unified configuration scheme
5
5
*
6
6
* The purpose of this option is to list, sort, and make searchable, all
7
- * runtime options available to Postgresql, by their description and grouping.
8
- *
9
- * Valid command-line options to this program:
10
- *
11
- * none : All available variables are sorted by group and name
12
- * and formatted nicely. ( for human consumption )
13
- * <string> : list all the variables whose name matches this string
14
- * -g <string> : list all the variables whose group matches this string
15
- * -l : lists all currently defined groups and terminates
16
- * -G : no sort by groups (you get strict name order, instead)
17
- * -m : output the list in Machine friendly format, with a header row
18
- * -M : same as m, except no header
19
- * -h : help
7
+ * runtime options available to PostgreSQL, by their description and grouping.
20
8
*
21
9
* Options whose flag bits are set to GUC_NO_SHOW_ALL, GUC_NOT_IN_SAMPLE,
22
10
* or GUC_DISALLOW_IN_FILE are not displayed, unless the user specifically
25
13
* Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
26
14
*
27
15
* IDENTIFICATION
28
- * $Header: /cvsroot/pgsql/src/backend/utils/misc/help_config.c,v 1.6 2003/09/25 06:58:06 petere Exp $
16
+ * $Header: /cvsroot/pgsql/src/backend/utils/misc/help_config.c,v 1.7 2003/09/27 09:29:31 petere Exp $
29
17
*
30
18
*-------------------------------------------------------------------------
31
19
*/
@@ -52,40 +40,33 @@ extern char *optarg;
52
40
* The following char constructs provide the different formats the variables
53
41
* can be outputted in.
54
42
*/
55
- enum outputFormat
56
- {
57
- HUMAN_OUTPUT ,
58
- MACHINE_OUTPUT
59
- };
43
+ #define HUMAN_OUTPUT 0
44
+ #define MACHINE_OUTPUT 1
60
45
61
46
static const char * const GENERIC_FORMAT [] = {
62
- gettext_noop ("Name: %-20s\nContext: %-20s\nGroup: %-20s\n" ),
47
+ gettext_noop ("Name: %-20s\nContext: %-20s\nGroup: %-20s\n" ),
63
48
"%s\t%s\t%s\t"
64
49
};
65
50
static const char * const GENERIC_DESC [] = {
66
- gettext_noop ("Description: %s\n%s\n" ),
51
+ gettext_noop ("Description: %s\n%s\n" ),
67
52
"%s\t%s\n"
68
53
};
69
54
static const char * const BOOL_FORMAT [] = {
70
- gettext_noop ("Type: Boolean\nReset value: %-s\n" ),
55
+ gettext_noop ("Type: Boolean\nDefault value: %-s\n" ),
71
56
"BOOL\t%s\t\t\t"
72
57
};
73
58
static const char * const INT_FORMAT [] = {
74
- gettext_noop ("Type: integer\nReset value: %-20d\nMin value: %-20d\nMax value: %-20d\n" ),
59
+ gettext_noop ("Type: integer\nDefault value: %-20d\nMin value: %-20d\nMax value: %-20d\n" ),
75
60
"INT\t%d\t%d\t%d\t"
76
61
};
77
62
static const char * const REAL_FORMAT [] = {
78
- gettext_noop ("Type: real\nReset value: %-20g\nMin value: %-20g\nMax value: %-20g\n" ),
63
+ gettext_noop ("Type: real\nDefault value: %-20g\nMin value: %-20g\nMax value: %-20g\n" ),
79
64
"REAL\t%g\t%g\t%g\t"
80
65
};
81
66
static const char * const STRING_FORMAT [] = {
82
- gettext_noop ("Type: string\nReset value: %-s\n" ),
67
+ gettext_noop ("Type: string\nDefault value: %-s\n" ),
83
68
"STRING\t%s\t\t\t"
84
69
};
85
- static const char * const COLUMN_HEADER [] = {
86
- "" ,
87
- gettext_noop ("NAME\tCONTEXT\tGROUP\tTYPE\tRESET_VALUE\tMIN\tMAX\tSHORT_DESCRIPTION\tLONG_DESCRIPTION\n" )
88
- };
89
70
static const char * const ROW_SEPARATOR [] = {
90
71
"------------------------------------------------------------\n" ,
91
72
""
@@ -95,12 +76,8 @@ static const char *const ROW_SEPARATOR[] = {
95
76
* Variables loaded from the command line
96
77
*/
97
78
static char * nameString = NULL ; /* The var name pattern to match */
98
- static bool nameRegexBool = false; /* Match the name pattern as a
99
- * regex */
100
79
static char * groupString = NULL ; /* The var group pattern to match */
101
- static bool groupRegexBool = false; /* Match the group pattern as a
102
- * regex */
103
- static enum outputFormat outFormat = HUMAN_OUTPUT ;
80
+ static int outFormat = HUMAN_OUTPUT ;
104
81
static bool suppressAllHeaders = false; /* MACHINE_OUTPUT output, no
105
82
* column headers */
106
83
static bool groupResults = true; /* sort result list by groups */
@@ -124,8 +101,7 @@ typedef union
124
101
static bool varMatches (mixedStruct * structToTest );
125
102
static int compareMixedStructs (const void * , const void * );
126
103
static mixedStruct * * varsToDisplay (int * resultListSize );
127
- static const char * usageErrMsg (void );
128
- static void helpMessage (void );
104
+ static void helpMessage (const char * progname );
129
105
static void listAllGroups (void );
130
106
static void printGenericHead (struct config_generic structToPrint );
131
107
static void printGenericFoot (struct config_generic structToPrint );
@@ -145,16 +121,13 @@ GucInfoMain(int argc, char *argv[])
145
121
int c ;
146
122
int i ;
147
123
148
- while ((c = getopt (argc , argv , "g:rGmMlh " )) != -1 )
124
+ while ((c = getopt (argc - 1 , argv + 1 , "g:GmMlh " )) != -1 )
149
125
{
150
126
switch (c )
151
127
{
152
128
case 'g' :
153
129
groupString = optarg ;
154
130
break ;
155
- case 'r' : /* not actually implemented yet */
156
- nameRegexBool = true;
157
- break ;
158
131
case 'G' :
159
132
groupResults = false;
160
133
break ;
@@ -169,17 +142,17 @@ GucInfoMain(int argc, char *argv[])
169
142
listAllGroups ();
170
143
exit (0 );
171
144
case 'h' :
172
- helpMessage ();
145
+ helpMessage (argv [ 0 ] );
173
146
exit (0 );
174
147
175
148
default :
176
- fprintf (stderr , gettext ("%s \n Try -h for further details \n" ), usageErrMsg () );
149
+ fprintf (stderr , gettext ("Try \" %s --help-config -h\" for more information. \n" ), argv [ 0 ] );
177
150
exit (1 );
178
151
}
179
152
}
180
153
181
- if (optind < argc )
182
- nameString = argv [optind ];
154
+ if (optind < argc - 1 )
155
+ nameString = argv [optind + 1 ];
183
156
184
157
/* get the list of variables that match the user's specs. */
185
158
varList = varsToDisplay (& resultListSize );
@@ -191,12 +164,12 @@ GucInfoMain(int argc, char *argv[])
191
164
sizeof (mixedStruct * ), compareMixedStructs );
192
165
193
166
/* output the results */
194
- if (!suppressAllHeaders )
195
- printf (gettext ( COLUMN_HEADER [ outFormat ]) );
167
+ if (outFormat == MACHINE_OUTPUT && !suppressAllHeaders )
168
+ printf ("NAME\tCONTEXT\tGROUP\tTYPE\tDEFAULT_VALUE\tMIN\tMAX\tSHORT_DESCRIPTION\tLONG_DESCRIPTION\n" );
196
169
197
170
for (i = 0 ; varList [i ] != NULL ; i ++ )
198
171
{
199
- printf (gettext ( ROW_SEPARATOR [outFormat ]) );
172
+ printf (ROW_SEPARATOR [outFormat ]);
200
173
printMixedStruct (varList [i ]);
201
174
}
202
175
@@ -299,7 +272,7 @@ varMatches(mixedStruct *structToTest)
299
272
* searched for a variable in
300
273
* particular. */
301
274
302
- if (nameString != NULL && ! nameRegexBool )
275
+ if (nameString != NULL )
303
276
{
304
277
if (strstr (structToTest -> generic .name , nameString ) != NULL )
305
278
{
@@ -308,12 +281,7 @@ varMatches(mixedStruct *structToTest)
308
281
}
309
282
}
310
283
311
- if (nameString != NULL && nameRegexBool )
312
- {
313
- /* We do not support this option yet */
314
- }
315
-
316
- if (groupString != NULL && !groupRegexBool )
284
+ if (groupString != NULL )
317
285
{
318
286
if (strstr (config_group_names [structToTest -> generic .group ], groupString ) != NULL )
319
287
{
@@ -326,11 +294,6 @@ varMatches(mixedStruct *structToTest)
326
294
matches = false;
327
295
}
328
296
329
- if (groupString != NULL && groupRegexBool )
330
- {
331
- /* We do not support this option yet */
332
- }
333
-
334
297
/* return all variables */
335
298
if (nameString == NULL && groupString == NULL )
336
299
matches = true;
@@ -355,9 +318,14 @@ printMixedStruct(mixedStruct *structToPrint)
355
318
{
356
319
357
320
case PGC_BOOL :
358
- printf (gettext (BOOL_FORMAT [outFormat ]),
359
- (structToPrint -> bool .reset_val == 0 ) ?
360
- gettext ("FALSE" ) : gettext ("TRUE" ));
321
+ if (outFormat == HUMAN_OUTPUT )
322
+ printf (gettext (BOOL_FORMAT [outFormat ]),
323
+ (structToPrint -> bool .reset_val == 0 ) ?
324
+ gettext ("false" ) : gettext ("true" ));
325
+ else
326
+ printf (gettext (BOOL_FORMAT [outFormat ]),
327
+ (structToPrint -> bool .reset_val == 0 ) ?
328
+ "FALSE" : "TRUE" );
361
329
break ;
362
330
363
331
case PGC_INT :
@@ -380,7 +348,7 @@ printMixedStruct(mixedStruct *structToPrint)
380
348
break ;
381
349
382
350
default :
383
- printf (gettext ( "Unrecognized variable type! \n") );
351
+ printf ("Internal error: unrecognized run-time parameter type\n" );
384
352
break ;
385
353
}
386
354
@@ -409,40 +377,29 @@ listAllGroups(void)
409
377
{
410
378
int i ;
411
379
412
- printf (gettext ("All currently defined groups\n" ));
413
- printf (gettext ("----------------------------\n" ));
414
380
for (i = 0 ; config_group_names [i ] != NULL ; i ++ )
415
- printf (gettext ("%s\n" ), gettext (config_group_names [i ]));
416
- }
417
-
418
- static const char *
419
- usageErrMsg (void )
420
- {
421
- return gettext ("Usage for --help-config option: [-h] [-g <group>] [-l] [-G] [-m] [-M] [string]\n" );
381
+ printf ("%s\n" , gettext (config_group_names [i ]));
422
382
}
423
383
424
384
static void
425
- helpMessage (void )
385
+ helpMessage (const char * progname )
426
386
{
427
- printf (gettext ("Description:\n"
428
- "--help-config displays all the runtime options available in PostgreSQL.\n"
429
- "It groups them by category and sorts them by name. If available, it will\n"
430
- "present a short description, default, max and min values as well as other\n"
431
- "information about each option.\n\n"
432
- "With no options specified, it will output all available runtime options\n"
433
- "in human friendly format, grouped by category and sorted by name.\n\n"
434
-
435
- "%s\n"
436
-
437
- "General Options:\n"
438
- " [string] All options with names that match this string\n"
439
- " -g GROUP All options in categories that match GROUP\n"
440
- " -l Prints list of all groups / subgroups\n"
441
- " -h Prints this help message\n"
442
- "\nOutput Options:\n"
443
- " -G Do not group by category\n"
444
- " -m Machine friendly format: tab separated fields\n"
445
- " -M Same as m, except header with column names is suppressed\n" ),
446
- usageErrMsg ()
447
- );
387
+ printf (gettext ("%s --help-config displays information about the\n"
388
+ "run-time configuration parameters available in the PostgreSQL server.\n\n" ),
389
+ progname );
390
+ printf (gettext ("Usage:\n %s --help-config [OPTION]... [NAME]\n\n" ), progname );
391
+ printf (gettext ("General Options:\n" ));
392
+ printf (gettext (" NAME output information about parameters matching this name\n" ));
393
+ printf (gettext (" -g GROUP output information about parameters matching this group\n" ));
394
+ printf (gettext (" -l list available parameter groups\n" ));
395
+ printf (gettext (" -h show this help, then exit\n" ));
396
+ printf (gettext ("\nOutput Options:\n" ));
397
+ printf (gettext (" -G do not group by category\n" ));
398
+ printf (gettext (" -m machine-friendly format: tab separated fields\n" ));
399
+ printf (gettext (" -M same as -m, but header with column names is suppressed\n" ));
400
+ printf (gettext ("\n"
401
+ "If no parameter name is specified, all parameters are shown. By default,\n"
402
+ "parameters are grouped by category, sorted by name, and output in a human-\n"
403
+ "friendly format. Available information about run-time parameters includes\n"
404
+ "a short description, default value, maximum and minimum values.\n" ));
448
405
}
0 commit comments