1 /*-------------------------------------------------------------------------
4 * Displays available options under grand unified configuration scheme
6 * Options whose flag bits are set to GUC_NO_SHOW_ALL, GUC_NOT_IN_SAMPLE,
7 * or GUC_DISALLOW_IN_FILE are not displayed, unless the user specifically
8 * requests that variable by name
10 * Portions Copyright (c) 1996-2024, PostgreSQL Global Development Group
13 * src/backend/utils/misc/help_config.c
15 *-------------------------------------------------------------------------
22 #include "utils/guc_tables.h"
23 #include "utils/help_config.h"
27 * This union allows us to mix the numerous different types of structs
28 * that we are organizing.
32 struct config_generic generic
;
33 struct config_bool _bool
;
34 struct config_real real
;
35 struct config_int integer
;
36 struct config_string string
;
37 struct config_enum _enum
;
41 static void printMixedStruct(mixedStruct
*structToPrint
);
42 static bool displayStruct(mixedStruct
*structToDisplay
);
48 struct config_generic
**guc_vars
;
52 /* Initialize the GUC hash table */
53 build_guc_variables();
55 guc_vars
= get_guc_variables(&numOpts
);
57 for (i
= 0; i
< numOpts
; i
++)
59 mixedStruct
*var
= (mixedStruct
*) guc_vars
[i
];
61 if (displayStruct(var
))
62 printMixedStruct(var
);
70 * This function will return true if the struct passed to it
71 * should be displayed to the user.
74 displayStruct(mixedStruct
*structToDisplay
)
76 return !(structToDisplay
->generic
.flags
& (GUC_NO_SHOW_ALL
|
78 GUC_DISALLOW_IN_FILE
));
83 * This function prints out the generic struct passed to it. It will print out
84 * a different format, depending on what the user wants to see.
87 printMixedStruct(mixedStruct
*structToPrint
)
89 printf("%s\t%s\t%s\t",
90 structToPrint
->generic
.name
,
91 GucContext_Names
[structToPrint
->generic
.context
],
92 _(config_group_names
[structToPrint
->generic
.group
]));
94 switch (structToPrint
->generic
.vartype
)
98 printf("BOOLEAN\t%s\t\t\t",
99 (structToPrint
->_bool
.reset_val
== 0) ?
104 printf("INTEGER\t%d\t%d\t%d\t",
105 structToPrint
->integer
.reset_val
,
106 structToPrint
->integer
.min
,
107 structToPrint
->integer
.max
);
111 printf("REAL\t%g\t%g\t%g\t",
112 structToPrint
->real
.reset_val
,
113 structToPrint
->real
.min
,
114 structToPrint
->real
.max
);
118 printf("STRING\t%s\t\t\t",
119 structToPrint
->string
.boot_val
? structToPrint
->string
.boot_val
: "");
123 printf("ENUM\t%s\t\t\t",
124 config_enum_lookup_by_value(&structToPrint
->_enum
,
125 structToPrint
->_enum
.boot_val
));
129 write_stderr("internal error: unrecognized run-time parameter type\n");
134 (structToPrint
->generic
.short_desc
== NULL
) ? "" : _(structToPrint
->generic
.short_desc
),
135 (structToPrint
->generic
.long_desc
== NULL
) ? "" : _(structToPrint
->generic
.long_desc
));