PostgreSQL Source Code git master
help_config.c
Go to the documentation of this file.
1/*-------------------------------------------------------------------------
2 * help_config.c
3 *
4 * Displays available options under grand unified configuration scheme
5 *
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
9 *
10 * Portions Copyright (c) 1996-2025, PostgreSQL Global Development Group
11 *
12 * IDENTIFICATION
13 * src/backend/utils/misc/help_config.c
14 *
15 *-------------------------------------------------------------------------
16 */
17#include "postgres.h"
18
19#include <limits.h>
20#include <unistd.h>
21
22#include "utils/guc_tables.h"
23#include "utils/help_config.h"
24
25
26static void printMixedStruct(const struct config_generic *structToPrint);
27static bool displayStruct(const struct config_generic *structToDisplay);
28
29
30void
32{
33 struct config_generic **guc_vars;
34 int numOpts;
35
36 /* Initialize the GUC hash table */
38
39 guc_vars = get_guc_variables(&numOpts);
40
41 for (int i = 0; i < numOpts; i++)
42 {
43 const struct config_generic *var = guc_vars[i];
44
45 if (displayStruct(var))
47 }
48
49 exit(0);
50}
51
52
53/*
54 * This function will return true if the struct passed to it
55 * should be displayed to the user.
56 */
57static bool
58displayStruct(const struct config_generic *structToDisplay)
59{
60 return !(structToDisplay->flags & (GUC_NO_SHOW_ALL |
63}
64
65
66/*
67 * This function prints out the generic struct passed to it. It will print out
68 * a different format, depending on what the user wants to see.
69 */
70static void
71printMixedStruct(const struct config_generic *structToPrint)
72{
73 printf("%s\t%s\t%s\t",
74 structToPrint->name,
75 GucContext_Names[structToPrint->context],
76 _(config_group_names[structToPrint->group]));
77
78 switch (structToPrint->vartype)
79 {
80
81 case PGC_BOOL:
82 printf("BOOLEAN\t%s\t\t\t",
83 (structToPrint->_bool.reset_val == 0) ?
84 "FALSE" : "TRUE");
85 break;
86
87 case PGC_INT:
88 printf("INTEGER\t%d\t%d\t%d\t",
89 structToPrint->_int.reset_val,
90 structToPrint->_int.min,
91 structToPrint->_int.max);
92 break;
93
94 case PGC_REAL:
95 printf("REAL\t%g\t%g\t%g\t",
96 structToPrint->_real.reset_val,
97 structToPrint->_real.min,
98 structToPrint->_real.max);
99 break;
100
101 case PGC_STRING:
102 printf("STRING\t%s\t\t\t",
103 structToPrint->_string.boot_val ? structToPrint->_string.boot_val : "");
104 break;
105
106 case PGC_ENUM:
107 printf("ENUM\t%s\t\t\t",
108 config_enum_lookup_by_value(structToPrint,
109 structToPrint->_enum.boot_val));
110 break;
111
112 default:
113 write_stderr("internal error: unrecognized run-time parameter type\n");
114 break;
115 }
116
117 printf("%s\t%s\n",
118 (structToPrint->short_desc == NULL) ? "" : _(structToPrint->short_desc),
119 (structToPrint->long_desc == NULL) ? "" : _(structToPrint->long_desc));
120}
#define write_stderr(str)
Definition: parallel.c:186
#define _(x)
Definition: elog.c:91
const char * config_enum_lookup_by_value(const struct config_generic *record, int val)
Definition: guc.c:2895
struct config_generic ** get_guc_variables(int *num_vars)
Definition: guc.c:839
void build_guc_variables(void)
Definition: guc.c:870
#define GUC_DISALLOW_IN_FILE
Definition: guc.h:222
#define GUC_NO_SHOW_ALL
Definition: guc.h:216
#define GUC_NOT_IN_SAMPLE
Definition: guc.h:221
const char *const GucContext_Names[]
Definition: guc_tables.c:655
const char *const config_group_names[]
Definition: guc_tables.c:698
@ PGC_BOOL
Definition: guc_tables.h:25
@ PGC_STRING
Definition: guc_tables.h:28
@ PGC_ENUM
Definition: guc_tables.h:29
@ PGC_REAL
Definition: guc_tables.h:27
@ PGC_INT
Definition: guc_tables.h:26
void GucInfoMain(void)
Definition: help_config.c:31
static void printMixedStruct(const struct config_generic *structToPrint)
Definition: help_config.c:71
static bool displayStruct(const struct config_generic *structToDisplay)
Definition: help_config.c:58
int i
Definition: isn.c:77
#define printf(...)
Definition: port.h:266
bool reset_val
Definition: guc_tables.h:147
enum config_group group
Definition: guc_tables.h:254
GucContext context
Definition: guc_tables.h:253
const char * long_desc
Definition: guc_tables.h:256
struct config_bool _bool
Definition: guc_tables.h:285
struct config_string _string
Definition: guc_tables.h:288
const char * name
Definition: guc_tables.h:252
struct config_real _real
Definition: guc_tables.h:287
const char * short_desc
Definition: guc_tables.h:255
struct config_int _int
Definition: guc_tables.h:286
enum config_type vartype
Definition: guc_tables.h:258
struct config_enum _enum
Definition: guc_tables.h:289
int reset_val
Definition: guc_tables.h:161
double reset_val
Definition: guc_tables.h:175
double min
Definition: guc_tables.h:169
double max
Definition: guc_tables.h:170
const char * boot_val
Definition: guc_tables.h:192