Line data Source code
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 : 26 : static void printMixedStruct(const struct config_generic *structToPrint); 27 : static bool displayStruct(const struct config_generic *structToDisplay); 28 : 29 : 30 : void 31 0 : GucInfoMain(void) 32 : { 33 : struct config_generic **guc_vars; 34 : int numOpts; 35 : 36 : /* Initialize the GUC hash table */ 37 0 : build_guc_variables(); 38 : 39 0 : guc_vars = get_guc_variables(&numOpts); 40 : 41 0 : for (int i = 0; i < numOpts; i++) 42 : { 43 0 : const struct config_generic *var = guc_vars[i]; 44 : 45 0 : if (displayStruct(var)) 46 0 : printMixedStruct(var); 47 : } 48 : 49 0 : 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 : */ 57 : static bool 58 0 : displayStruct(const struct config_generic *structToDisplay) 59 : { 60 0 : return !(structToDisplay->flags & (GUC_NO_SHOW_ALL | 61 : GUC_NOT_IN_SAMPLE | 62 : GUC_DISALLOW_IN_FILE)); 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 : */ 70 : static void 71 0 : printMixedStruct(const struct config_generic *structToPrint) 72 : { 73 0 : printf("%s\t%s\t%s\t", 74 : structToPrint->name, 75 : GucContext_Names[structToPrint->context], 76 : _(config_group_names[structToPrint->group])); 77 : 78 0 : switch (structToPrint->vartype) 79 : { 80 : 81 0 : case PGC_BOOL: 82 0 : printf("BOOLEAN\t%s\t\t\t", 83 : (structToPrint->_bool.reset_val == 0) ? 84 : "FALSE" : "TRUE"); 85 0 : break; 86 : 87 0 : case PGC_INT: 88 0 : printf("INTEGER\t%d\t%d\t%d\t", 89 : structToPrint->_int.reset_val, 90 : structToPrint->_int.min, 91 : structToPrint->_int.max); 92 0 : break; 93 : 94 0 : case PGC_REAL: 95 0 : printf("REAL\t%g\t%g\t%g\t", 96 : structToPrint->_real.reset_val, 97 : structToPrint->_real.min, 98 : structToPrint->_real.max); 99 0 : break; 100 : 101 0 : case PGC_STRING: 102 0 : printf("STRING\t%s\t\t\t", 103 : structToPrint->_string.boot_val ? structToPrint->_string.boot_val : ""); 104 0 : break; 105 : 106 0 : case PGC_ENUM: 107 0 : printf("ENUM\t%s\t\t\t", 108 : config_enum_lookup_by_value(structToPrint, 109 : structToPrint->_enum.boot_val)); 110 0 : break; 111 : 112 0 : default: 113 0 : write_stderr("internal error: unrecognized run-time parameter type\n"); 114 0 : break; 115 : } 116 : 117 0 : printf("%s\t%s\n", 118 : (structToPrint->short_desc == NULL) ? "" : _(structToPrint->short_desc), 119 : (structToPrint->long_desc == NULL) ? "" : _(structToPrint->long_desc)); 120 0 : }