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-2006, PostgreSQL Global Development Group
13 * $PostgreSQL: pgsql/src/backend/utils/misc/help_config.c,v 1.17 2006/07/14 14:52:25 momjian Exp $
15 *-------------------------------------------------------------------------
23 #include "utils/guc_tables.h"
24 #include "utils/help_config.h"
28 * This union allows us to mix the numerous different types of structs
29 * that we are organizing.
33 struct config_generic generic;
34 struct config_bool bool;
35 struct config_real real;
36 struct config_int integer;
37 struct config_string string;
41 static void printMixedStruct(mixedStruct *structToPrint);
42 static bool displayStruct(mixedStruct *structToDisplay);
48 struct config_generic **guc_vars;
52 /* Initialize the guc_variables[] array */
53 build_guc_variables();
55 guc_vars = get_guc_variables();
56 numOpts = GetNumConfigOptions();
58 for (i = 0; i < numOpts; i++)
60 mixedStruct *var = (mixedStruct *) guc_vars[i];
62 if (displayStruct(var))
63 printMixedStruct(var);
71 * This function will return true if the struct passed to it
72 * should be displayed to the user.
75 displayStruct(mixedStruct *structToDisplay)
77 return !(structToDisplay->generic.flags & (GUC_NO_SHOW_ALL |
79 GUC_DISALLOW_IN_FILE));
84 * This function prints out the generic struct passed to it. It will print out
85 * a different format, depending on what the user wants to see.
88 printMixedStruct(mixedStruct *structToPrint)
90 printf("%s\t%s\t%s\t",
91 structToPrint->generic.name,
92 GucContext_Names[structToPrint->generic.context],
93 _(config_group_names[structToPrint->generic.group]));
95 switch (structToPrint->generic.vartype)
99 printf("BOOLEAN\t%s\t\t\t",
100 (structToPrint->bool.reset_val == 0) ?
105 printf("INTEGER\t%d\t%d\t%d\t",
106 structToPrint->integer.reset_val,
107 structToPrint->integer.min,
108 structToPrint->integer.max);
112 printf("REAL\t%g\t%g\t%g\t",
113 structToPrint->real.reset_val,
114 structToPrint->real.min,
115 structToPrint->real.max);
119 printf("STRING\t%s\t\t\t",
120 structToPrint->string.boot_val);
124 write_stderr("internal error: unrecognized run-time parameter type\n");
129 (structToPrint->generic.short_desc == NULL) ? "" : _(structToPrint->generic.short_desc),
130 (structToPrint->generic.long_desc == NULL) ? "" : _(structToPrint->generic.long_desc));