PostgreSQL Source Code git master
guc_tables.h File Reference
#include "lib/ilist.h"
#include "utils/guc.h"
Include dependency graph for guc_tables.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

union  config_var_val
 
struct  config_var_value
 
struct  guc_stack
 
struct  config_bool
 
struct  config_int
 
struct  config_real
 
struct  config_string
 
struct  config_enum
 
struct  config_generic
 

Macros

#define GUC_IS_IN_FILE   0x0001 /* found it in config file */
 
#define GUC_PENDING_RESTART   0x0002 /* changed value cannot be applied yet */
 
#define GUC_NEEDS_REPORT   0x0004 /* new value must be reported to client */
 

Typedefs

typedef struct config_var_value config_var_value
 
typedef struct guc_stack GucStack
 

Enumerations

enum  config_type {
  PGC_BOOL , PGC_INT , PGC_REAL , PGC_STRING ,
  PGC_ENUM
}
 
enum  config_group {
  UNGROUPED , FILE_LOCATIONS , CONN_AUTH_SETTINGS , CONN_AUTH_TCP ,
  CONN_AUTH_AUTH , CONN_AUTH_SSL , RESOURCES_MEM , RESOURCES_DISK ,
  RESOURCES_KERNEL , RESOURCES_BGWRITER , RESOURCES_IO , RESOURCES_WORKER_PROCESSES ,
  WAL_SETTINGS , WAL_CHECKPOINTS , WAL_ARCHIVING , WAL_RECOVERY ,
  WAL_ARCHIVE_RECOVERY , WAL_RECOVERY_TARGET , WAL_SUMMARIZATION , REPLICATION_SENDING ,
  REPLICATION_PRIMARY , REPLICATION_STANDBY , REPLICATION_SUBSCRIBERS , QUERY_TUNING_METHOD ,
  QUERY_TUNING_COST , QUERY_TUNING_GEQO , QUERY_TUNING_OTHER , LOGGING_WHERE ,
  LOGGING_WHEN , LOGGING_WHAT , PROCESS_TITLE , STATS_MONITORING ,
  STATS_CUMULATIVE , VACUUM_AUTOVACUUM , VACUUM_COST_DELAY , VACUUM_DEFAULT ,
  VACUUM_FREEZING , CLIENT_CONN_STATEMENT , CLIENT_CONN_LOCALE , CLIENT_CONN_PRELOAD ,
  CLIENT_CONN_OTHER , LOCK_MANAGEMENT , COMPAT_OPTIONS_PREVIOUS , COMPAT_OPTIONS_OTHER ,
  ERROR_HANDLING_OPTIONS , PRESET_OPTIONS , CUSTOM_OPTIONS , DEVELOPER_OPTIONS
}
 
enum  GucStackState { GUC_SAVE , GUC_SET , GUC_LOCAL , GUC_SET_LOCAL }
 

Functions

struct config_genericfind_option (const char *name, bool create_placeholders, bool skip_errors, int elevel)
 
struct config_generic ** get_explain_guc_options (int *num)
 
char * ShowGUCOption (const struct config_generic *record, bool use_units)
 
bool ConfigOptionIsVisible (const struct config_generic *conf)
 
struct config_generic ** get_guc_variables (int *num_vars)
 
void build_guc_variables (void)
 
const char * config_enum_lookup_by_value (const struct config_generic *record, int val)
 
bool config_enum_lookup_by_name (const struct config_enum *record, const char *value, int *retval)
 
char * config_enum_get_options (const struct config_enum *record, const char *prefix, const char *suffix, const char *separator)
 

Variables

PGDLLIMPORT const char *const config_group_names []
 
PGDLLIMPORT const char *const config_type_names []
 
PGDLLIMPORT const char *const GucContext_Names []
 
PGDLLIMPORT const char *const GucSource_Names []
 
PGDLLIMPORT struct config_generic ConfigureNames []
 

Macro Definition Documentation

◆ GUC_IS_IN_FILE

#define GUC_IS_IN_FILE   0x0001 /* found it in config file */

Definition at line 294 of file guc_tables.h.

◆ GUC_NEEDS_REPORT

#define GUC_NEEDS_REPORT   0x0004 /* new value must be reported to client */

Definition at line 300 of file guc_tables.h.

◆ GUC_PENDING_RESTART

#define GUC_PENDING_RESTART   0x0002 /* changed value cannot be applied yet */

Definition at line 299 of file guc_tables.h.

Typedef Documentation

◆ config_var_value

◆ GucStack

typedef struct guc_stack GucStack

Enumeration Type Documentation

◆ config_group

Enumerator
UNGROUPED 
FILE_LOCATIONS 
CONN_AUTH_SETTINGS 
CONN_AUTH_TCP 
CONN_AUTH_AUTH 
CONN_AUTH_SSL 
RESOURCES_MEM 
RESOURCES_DISK 
RESOURCES_KERNEL 
RESOURCES_BGWRITER 
RESOURCES_IO 
RESOURCES_WORKER_PROCESSES 
WAL_SETTINGS 
WAL_CHECKPOINTS 
WAL_ARCHIVING 
WAL_RECOVERY 
WAL_ARCHIVE_RECOVERY 
WAL_RECOVERY_TARGET 
WAL_SUMMARIZATION 
REPLICATION_SENDING 
REPLICATION_PRIMARY 
REPLICATION_STANDBY 
REPLICATION_SUBSCRIBERS 
QUERY_TUNING_METHOD 
QUERY_TUNING_COST 
QUERY_TUNING_GEQO 
QUERY_TUNING_OTHER 
LOGGING_WHERE 
LOGGING_WHEN 
LOGGING_WHAT 
PROCESS_TITLE 
STATS_MONITORING 
STATS_CUMULATIVE 
VACUUM_AUTOVACUUM 
VACUUM_COST_DELAY 
VACUUM_DEFAULT 
VACUUM_FREEZING 
CLIENT_CONN_STATEMENT 
CLIENT_CONN_LOCALE 
CLIENT_CONN_PRELOAD 
CLIENT_CONN_OTHER 
LOCK_MANAGEMENT 
COMPAT_OPTIONS_PREVIOUS 
COMPAT_OPTIONS_OTHER 
ERROR_HANDLING_OPTIONS 
PRESET_OPTIONS 
CUSTOM_OPTIONS 
DEVELOPER_OPTIONS 

Definition at line 55 of file guc_tables.h.

56{
57 UNGROUPED, /* use for options not shown in pg_settings */
105};
@ RESOURCES_KERNEL
Definition: guc_tables.h:65
@ CLIENT_CONN_LOCALE
Definition: guc_tables.h:95
@ WAL_ARCHIVE_RECOVERY
Definition: guc_tables.h:73
@ STATS_CUMULATIVE
Definition: guc_tables.h:89
@ CLIENT_CONN_PRELOAD
Definition: guc_tables.h:96
@ VACUUM_COST_DELAY
Definition: guc_tables.h:91
@ QUERY_TUNING_OTHER
Definition: guc_tables.h:83
@ LOGGING_WHERE
Definition: guc_tables.h:84
@ CONN_AUTH_AUTH
Definition: guc_tables.h:61
@ RESOURCES_WORKER_PROCESSES
Definition: guc_tables.h:68
@ VACUUM_FREEZING
Definition: guc_tables.h:93
@ ERROR_HANDLING_OPTIONS
Definition: guc_tables.h:101
@ PROCESS_TITLE
Definition: guc_tables.h:87
@ RESOURCES_DISK
Definition: guc_tables.h:64
@ REPLICATION_SENDING
Definition: guc_tables.h:76
@ RESOURCES_IO
Definition: guc_tables.h:67
@ LOCK_MANAGEMENT
Definition: guc_tables.h:98
@ CUSTOM_OPTIONS
Definition: guc_tables.h:103
@ REPLICATION_PRIMARY
Definition: guc_tables.h:77
@ STATS_MONITORING
Definition: guc_tables.h:88
@ WAL_RECOVERY_TARGET
Definition: guc_tables.h:74
@ WAL_RECOVERY
Definition: guc_tables.h:72
@ CONN_AUTH_SSL
Definition: guc_tables.h:62
@ RESOURCES_MEM
Definition: guc_tables.h:63
@ RESOURCES_BGWRITER
Definition: guc_tables.h:66
@ PRESET_OPTIONS
Definition: guc_tables.h:102
@ DEVELOPER_OPTIONS
Definition: guc_tables.h:104
@ QUERY_TUNING_METHOD
Definition: guc_tables.h:80
@ LOGGING_WHAT
Definition: guc_tables.h:86
@ VACUUM_DEFAULT
Definition: guc_tables.h:92
@ QUERY_TUNING_GEQO
Definition: guc_tables.h:82
@ WAL_SETTINGS
Definition: guc_tables.h:69
@ COMPAT_OPTIONS_OTHER
Definition: guc_tables.h:100
@ CLIENT_CONN_STATEMENT
Definition: guc_tables.h:94
@ FILE_LOCATIONS
Definition: guc_tables.h:58
@ REPLICATION_STANDBY
Definition: guc_tables.h:78
@ QUERY_TUNING_COST
Definition: guc_tables.h:81
@ WAL_ARCHIVING
Definition: guc_tables.h:71
@ COMPAT_OPTIONS_PREVIOUS
Definition: guc_tables.h:99
@ WAL_CHECKPOINTS
Definition: guc_tables.h:70
@ CLIENT_CONN_OTHER
Definition: guc_tables.h:97
@ LOGGING_WHEN
Definition: guc_tables.h:85
@ CONN_AUTH_TCP
Definition: guc_tables.h:60
@ REPLICATION_SUBSCRIBERS
Definition: guc_tables.h:79
@ WAL_SUMMARIZATION
Definition: guc_tables.h:75
@ CONN_AUTH_SETTINGS
Definition: guc_tables.h:59
@ UNGROUPED
Definition: guc_tables.h:57
@ VACUUM_AUTOVACUUM
Definition: guc_tables.h:90

◆ config_type

Enumerator
PGC_BOOL 
PGC_INT 
PGC_REAL 
PGC_STRING 
PGC_ENUM 

Definition at line 23 of file guc_tables.h.

24{
26 PGC_INT,
30};
@ 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

◆ GucStackState

Enumerator
GUC_SAVE 
GUC_SET 
GUC_LOCAL 
GUC_SET_LOCAL 

Definition at line 111 of file guc_tables.h.

112{
113 /* This is almost GucAction, but we need a fourth state for SET+LOCAL */
114 GUC_SAVE, /* entry caused by function SET option */
115 GUC_SET, /* entry caused by plain SET command */
116 GUC_LOCAL, /* entry caused by SET LOCAL command */
117 GUC_SET_LOCAL, /* entry caused by SET then SET LOCAL */
GucStackState
Definition: guc_tables.h:112
@ GUC_SET_LOCAL
Definition: guc_tables.h:117
@ GUC_SET
Definition: guc_tables.h:115
@ GUC_SAVE
Definition: guc_tables.h:114
@ GUC_LOCAL
Definition: guc_tables.h:116

Function Documentation

◆ build_guc_variables()

void build_guc_variables ( void  )

Definition at line 870 of file guc.c.

871{
872 int size_vars;
873 int num_vars = 0;
874 HASHCTL hash_ctl;
875 GUCHashEntry *hentry;
876 bool found;
877
878 /*
879 * Create the memory context that will hold all GUC-related data.
880 */
881 Assert(GUCMemoryContext == NULL);
883 "GUCMemoryContext",
885
886 /*
887 * Count all the built-in variables.
888 */
889 for (int i = 0; ConfigureNames[i].name; i++)
890 num_vars++;
891
892 /*
893 * Create hash table with 20% slack
894 */
895 size_vars = num_vars + num_vars / 4;
896
897 hash_ctl.keysize = sizeof(char *);
898 hash_ctl.entrysize = sizeof(GUCHashEntry);
899 hash_ctl.hash = guc_name_hash;
900 hash_ctl.match = guc_name_match;
901 hash_ctl.hcxt = GUCMemoryContext;
902 guc_hashtab = hash_create("GUC hash table",
903 size_vars,
904 &hash_ctl,
906
907 for (int i = 0; ConfigureNames[i].name; i++)
908 {
909 struct config_generic *gucvar = &ConfigureNames[i];
910
912 &gucvar->name,
914 &found);
915 Assert(!found);
916 hentry->gucvar = gucvar;
917 }
918
920}
void * hash_search(HTAB *hashp, const void *keyPtr, HASHACTION action, bool *foundPtr)
Definition: dynahash.c:952
HTAB * hash_create(const char *tabname, int64 nelem, const HASHCTL *info, int flags)
Definition: dynahash.c:358
int64 hash_get_num_entries(HTAB *hashp)
Definition: dynahash.c:1336
static int guc_name_match(const void *key1, const void *key2, Size keysize)
Definition: guc.c:1231
static uint32 guc_name_hash(const void *key, Size keysize)
Definition: guc.c:1207
static HTAB * guc_hashtab
Definition: guc.c:213
static MemoryContext GUCMemoryContext
Definition: guc.c:200
PGDLLIMPORT struct config_generic ConfigureNames[]
Assert(PointerIsAligned(start, uint64))
@ HASH_ENTER
Definition: hsearch.h:114
#define HASH_CONTEXT
Definition: hsearch.h:102
#define HASH_ELEM
Definition: hsearch.h:95
#define HASH_COMPARE
Definition: hsearch.h:99
#define HASH_FUNCTION
Definition: hsearch.h:98
int i
Definition: isn.c:77
MemoryContext TopMemoryContext
Definition: mcxt.c:166
#define AllocSetContextCreate
Definition: memutils.h:129
#define ALLOCSET_DEFAULT_SIZES
Definition: memutils.h:160
struct config_generic * gucvar
Definition: guc.c:210
Size keysize
Definition: hsearch.h:75
HashValueFunc hash
Definition: hsearch.h:78
Size entrysize
Definition: hsearch.h:76
HashCompareFunc match
Definition: hsearch.h:80
MemoryContext hcxt
Definition: hsearch.h:86
const char * name
Definition: guc_tables.h:252

References ALLOCSET_DEFAULT_SIZES, AllocSetContextCreate, Assert(), ConfigureNames, HASHCTL::entrysize, guc_hashtab, guc_name_hash(), guc_name_match(), GUCMemoryContext, GUCHashEntry::gucvar, HASHCTL::hash, HASH_COMPARE, HASH_CONTEXT, hash_create(), HASH_ELEM, HASH_ENTER, HASH_FUNCTION, hash_get_num_entries(), hash_search(), HASHCTL::hcxt, i, HASHCTL::keysize, HASHCTL::match, config_generic::name, and TopMemoryContext.

Referenced by GucInfoMain(), and InitializeGUCOptions().

◆ config_enum_get_options()

char * config_enum_get_options ( const struct config_enum record,
const char *  prefix,
const char *  suffix,
const char *  separator 
)

Definition at line 2940 of file guc.c.

2942{
2943 StringInfoData retstr;
2944 int seplen;
2945
2946 initStringInfo(&retstr);
2947 appendStringInfoString(&retstr, prefix);
2948
2949 seplen = strlen(separator);
2950 for (const struct config_enum_entry *entry = record->options; entry && entry->name; entry++)
2951 {
2952 if (!entry->hidden)
2953 {
2954 appendStringInfoString(&retstr, entry->name);
2955 appendBinaryStringInfo(&retstr, separator, seplen);
2956 }
2957 }
2958
2959 /*
2960 * All the entries may have been hidden, leaving the string empty if no
2961 * prefix was given. This indicates a broken GUC setup, since there is no
2962 * use for an enum without any values, so we just check to make sure we
2963 * don't write to invalid memory instead of actually trying to do
2964 * something smart with it.
2965 */
2966 if (retstr.len >= seplen)
2967 {
2968 /* Replace final separator */
2969 retstr.data[retstr.len - seplen] = '\0';
2970 retstr.len -= seplen;
2971 }
2972
2973 appendStringInfoString(&retstr, suffix);
2974
2975 return retstr.data;
2976}
void appendBinaryStringInfo(StringInfo str, const void *data, int datalen)
Definition: stringinfo.c:281
void appendStringInfoString(StringInfo str, const char *s)
Definition: stringinfo.c:230
void initStringInfo(StringInfo str)
Definition: stringinfo.c:97
Definition: guc.h:174
const char * name
Definition: guc.h:175
const struct config_enum_entry * options
Definition: guc_tables.h:205

References appendBinaryStringInfo(), appendStringInfoString(), StringInfoData::data, initStringInfo(), StringInfoData::len, config_enum_entry::name, and config_enum::options.

Referenced by GetConfigOptionValues(), and parse_and_validate_value().

◆ config_enum_lookup_by_name()

bool config_enum_lookup_by_name ( const struct config_enum record,
const char *  value,
int *  retval 
)

Definition at line 2916 of file guc.c.

2918{
2919 for (const struct config_enum_entry *entry = record->options; entry && entry->name; entry++)
2920 {
2921 if (pg_strcasecmp(value, entry->name) == 0)
2922 {
2923 *retval = entry->val;
2924 return true;
2925 }
2926 }
2927
2928 *retval = 0;
2929 return false;
2930}
static struct @171 value
int pg_strcasecmp(const char *s1, const char *s2)
Definition: pgstrcasecmp.c:32

References config_enum_entry::name, config_enum::options, pg_strcasecmp(), and value.

Referenced by parse_and_validate_value().

◆ config_enum_lookup_by_value()

const char * config_enum_lookup_by_value ( const struct config_generic record,
int  val 
)

Definition at line 2895 of file guc.c.

2896{
2897 for (const struct config_enum_entry *entry = record->_enum.options; entry && entry->name; entry++)
2898 {
2899 if (entry->val == val)
2900 return entry->name;
2901 }
2902
2903 elog(ERROR, "could not find enum option %d for %s",
2904 val, record->name);
2905 return NULL; /* silence compiler */
2906}
#define ERROR
Definition: elog.h:39
#define elog(elevel,...)
Definition: elog.h:226
long val
Definition: informix.c:689
struct config_enum _enum
Definition: guc_tables.h:289

References config_generic::_enum, elog, ERROR, config_enum_entry::name, config_generic::name, config_enum::options, and val.

Referenced by call_enum_check_hook(), estimate_variable_size(), GetConfigOption(), GetConfigOptionResetString(), GetConfigOptionValues(), printMixedStruct(), serialize_variable(), and ShowGUCOption().

◆ ConfigOptionIsVisible()

bool ConfigOptionIsVisible ( const struct config_generic conf)

Definition at line 607 of file guc_funcs.c.

608{
609 if ((conf->flags & GUC_SUPERUSER_ONLY) &&
610 !has_privs_of_role(GetUserId(), ROLE_PG_READ_ALL_SETTINGS))
611 return false;
612 else
613 return true;
614}
bool has_privs_of_role(Oid member, Oid role)
Definition: acl.c:5284
#define GUC_SUPERUSER_ONLY
Definition: guc.h:224
Oid GetUserId(void)
Definition: miscinit.c:469

References config_generic::flags, GetUserId(), GUC_SUPERUSER_ONLY, and has_privs_of_role().

Referenced by get_explain_guc_options(), GetConfigOption(), GetConfigOptionByName(), GetConfigOptionResetString(), show_all_settings(), and ShowAllGUCConfig().

◆ find_option()

struct config_generic * find_option ( const char *  name,
bool  create_placeholders,
bool  skip_errors,
int  elevel 
)

Definition at line 1113 of file guc.c.

1115{
1116 GUCHashEntry *hentry;
1117
1118 Assert(name);
1119
1120 /* Look it up using the hash table. */
1122 &name,
1123 HASH_FIND,
1124 NULL);
1125 if (hentry)
1126 return hentry->gucvar;
1127
1128 /*
1129 * See if the name is an obsolete name for a variable. We assume that the
1130 * set of supported old names is short enough that a brute-force search is
1131 * the best way.
1132 */
1133 for (int i = 0; map_old_guc_names[i] != NULL; i += 2)
1134 {
1136 return find_option(map_old_guc_names[i + 1], false,
1137 skip_errors, elevel);
1138 }
1139
1140 if (create_placeholders)
1141 {
1142 /*
1143 * Check if the name is valid, and if so, add a placeholder.
1144 */
1145 if (assignable_custom_variable_name(name, skip_errors, elevel))
1146 return add_placeholder_variable(name, elevel);
1147 else
1148 return NULL; /* error message, if any, already emitted */
1149 }
1150
1151 /* Unknown name and we're not supposed to make a placeholder */
1152 if (!skip_errors)
1153 ereport(elevel,
1154 (errcode(ERRCODE_UNDEFINED_OBJECT),
1155 errmsg("unrecognized configuration parameter \"%s\"",
1156 name)));
1157 return NULL;
1158}
int errcode(int sqlerrcode)
Definition: elog.c:863
int errmsg(const char *fmt,...)
Definition: elog.c:1080
#define ereport(elevel,...)
Definition: elog.h:150
static const char *const map_old_guc_names[]
Definition: guc.c:191
static bool assignable_custom_variable_name(const char *name, bool skip_errors, int elevel)
Definition: guc.c:1001
struct config_generic * find_option(const char *name, bool create_placeholders, bool skip_errors, int elevel)
Definition: guc.c:1113
static struct config_generic * add_placeholder_variable(const char *name, int elevel)
Definition: guc.c:1057
int guc_name_compare(const char *namea, const char *nameb)
Definition: guc.c:1177
@ HASH_FIND
Definition: hsearch.h:113
const char * name

References add_placeholder_variable(), Assert(), assignable_custom_variable_name(), ereport, errcode(), errmsg(), find_option(), guc_hashtab, guc_name_compare(), GUCHashEntry::gucvar, HASH_FIND, hash_search(), i, map_old_guc_names, and name.

Referenced by AlterSystemSetConfigFile(), check_GUC_name_for_parameter_acl(), find_option(), flatten_set_variable_args(), get_config_handle(), GetConfigOption(), GetConfigOptionByName(), GetConfigOptionFlags(), GetConfigOptionResetString(), GUCArrayAdd(), GUCArrayDelete(), InitializeWalConsistencyChecking(), pg_settings_get_flags(), ProcessConfigFileInternal(), SelectConfigFiles(), set_config_sourcefile(), set_config_with_handle(), and validate_option_array_item().

◆ get_explain_guc_options()

struct config_generic ** get_explain_guc_options ( int *  num)

Definition at line 5200 of file guc.c.

5201{
5202 struct config_generic **result;
5203 dlist_iter iter;
5204
5205 *num = 0;
5206
5207 /*
5208 * While only a fraction of all the GUC variables are marked GUC_EXPLAIN,
5209 * it doesn't seem worth dynamically resizing this array.
5210 */
5211 result = palloc(sizeof(struct config_generic *) * hash_get_num_entries(guc_hashtab));
5212
5213 /* We need only consider GUCs with source not PGC_S_DEFAULT */
5215 {
5216 struct config_generic *conf = dlist_container(struct config_generic,
5217 nondef_link, iter.cur);
5218 bool modified;
5219
5220 /* return only parameters marked for inclusion in explain */
5221 if (!(conf->flags & GUC_EXPLAIN))
5222 continue;
5223
5224 /* return only options visible to the current user */
5225 if (!ConfigOptionIsVisible(conf))
5226 continue;
5227
5228 /* return only options that are different from their boot values */
5229 modified = false;
5230
5231 switch (conf->vartype)
5232 {
5233 case PGC_BOOL:
5234 {
5235 struct config_bool *lconf = &conf->_bool;
5236
5237 modified = (lconf->boot_val != *(lconf->variable));
5238 }
5239 break;
5240
5241 case PGC_INT:
5242 {
5243 struct config_int *lconf = &conf->_int;
5244
5245 modified = (lconf->boot_val != *(lconf->variable));
5246 }
5247 break;
5248
5249 case PGC_REAL:
5250 {
5251 struct config_real *lconf = &conf->_real;
5252
5253 modified = (lconf->boot_val != *(lconf->variable));
5254 }
5255 break;
5256
5257 case PGC_STRING:
5258 {
5259 struct config_string *lconf = &conf->_string;
5260
5261 if (lconf->boot_val == NULL &&
5262 *lconf->variable == NULL)
5263 modified = false;
5264 else if (lconf->boot_val == NULL ||
5265 *lconf->variable == NULL)
5266 modified = true;
5267 else
5268 modified = (strcmp(lconf->boot_val, *(lconf->variable)) != 0);
5269 }
5270 break;
5271
5272 case PGC_ENUM:
5273 {
5274 struct config_enum *lconf = &conf->_enum;
5275
5276 modified = (lconf->boot_val != *(lconf->variable));
5277 }
5278 break;
5279
5280 default:
5281 elog(ERROR, "unexpected GUC type: %d", conf->vartype);
5282 }
5283
5284 if (!modified)
5285 continue;
5286
5287 /* OK, report it */
5288 result[*num] = conf;
5289 *num = *num + 1;
5290 }
5291
5292 return result;
5293}
static dlist_head guc_nondef_list
Definition: guc.c:223
#define GUC_EXPLAIN
Definition: guc.h:219
bool ConfigOptionIsVisible(const struct config_generic *conf)
Definition: guc_funcs.c:607
#define dlist_foreach(iter, lhead)
Definition: ilist.h:623
#define dlist_container(type, membername, ptr)
Definition: ilist.h:593
void * palloc(Size size)
Definition: mcxt.c:1365
bool * variable
Definition: guc_tables.h:141
bool boot_val
Definition: guc_tables.h:142
int * variable
Definition: guc_tables.h:203
dlist_node nondef_link
Definition: guc_tables.h:270
struct config_bool _bool
Definition: guc_tables.h:285
struct config_string _string
Definition: guc_tables.h:288
struct config_real _real
Definition: guc_tables.h:287
struct config_int _int
Definition: guc_tables.h:286
enum config_type vartype
Definition: guc_tables.h:258
int boot_val
Definition: guc_tables.h:154
int * variable
Definition: guc_tables.h:153
double boot_val
Definition: guc_tables.h:168
double * variable
Definition: guc_tables.h:167
char ** variable
Definition: guc_tables.h:191
const char * boot_val
Definition: guc_tables.h:192
dlist_node * cur
Definition: ilist.h:179

References config_generic::_bool, config_generic::_enum, config_generic::_int, config_generic::_real, config_generic::_string, config_bool::boot_val, config_int::boot_val, config_real::boot_val, config_string::boot_val, config_enum::boot_val, ConfigOptionIsVisible(), dlist_iter::cur, dlist_container, dlist_foreach, elog, ERROR, config_generic::flags, GUC_EXPLAIN, guc_hashtab, guc_nondef_list, hash_get_num_entries(), config_generic::nondef_link, palloc(), PGC_BOOL, PGC_ENUM, PGC_INT, PGC_REAL, PGC_STRING, config_bool::variable, config_int::variable, config_real::variable, config_string::variable, config_enum::variable, and config_generic::vartype.

Referenced by ExplainPrintSettings().

◆ get_guc_variables()

struct config_generic ** get_guc_variables ( int *  num_vars)

Definition at line 839 of file guc.c.

840{
841 struct config_generic **result;
843 GUCHashEntry *hentry;
844 int i;
845
847 result = palloc(sizeof(struct config_generic *) * *num_vars);
848
849 /* Extract pointers from the hash table */
850 i = 0;
852 while ((hentry = (GUCHashEntry *) hash_seq_search(&status)) != NULL)
853 result[i++] = hentry->gucvar;
854 Assert(i == *num_vars);
855
856 /* Sort by name */
857 qsort(result, *num_vars,
858 sizeof(struct config_generic *), guc_var_compare);
859
860 return result;
861}
void * hash_seq_search(HASH_SEQ_STATUS *status)
Definition: dynahash.c:1415
void hash_seq_init(HASH_SEQ_STATUS *status, HTAB *hashp)
Definition: dynahash.c:1380
static int guc_var_compare(const void *a, const void *b)
Definition: guc.c:1165
#define qsort(a, b, c, d)
Definition: port.h:500

References Assert(), guc_hashtab, guc_var_compare(), GUCHashEntry::gucvar, hash_get_num_entries(), hash_seq_init(), hash_seq_search(), i, palloc(), qsort, and config_generic::status.

Referenced by GucInfoMain(), show_all_settings(), and ShowAllGUCConfig().

◆ ShowGUCOption()

char * ShowGUCOption ( const struct config_generic record,
bool  use_units 
)

Definition at line 5334 of file guc.c.

5335{
5336 char buffer[256];
5337 const char *val;
5338
5339 switch (record->vartype)
5340 {
5341 case PGC_BOOL:
5342 {
5343 const struct config_bool *conf = &record->_bool;
5344
5345 if (conf->show_hook)
5346 val = conf->show_hook();
5347 else
5348 val = *conf->variable ? "on" : "off";
5349 }
5350 break;
5351
5352 case PGC_INT:
5353 {
5354 const struct config_int *conf = &record->_int;
5355
5356 if (conf->show_hook)
5357 val = conf->show_hook();
5358 else
5359 {
5360 /*
5361 * Use int64 arithmetic to avoid overflows in units
5362 * conversion.
5363 */
5364 int64 result = *conf->variable;
5365 const char *unit;
5366
5367 if (use_units && result > 0 && (record->flags & GUC_UNIT))
5369 record->flags & GUC_UNIT,
5370 &result, &unit);
5371 else
5372 unit = "";
5373
5374 snprintf(buffer, sizeof(buffer), INT64_FORMAT "%s",
5375 result, unit);
5376 val = buffer;
5377 }
5378 }
5379 break;
5380
5381 case PGC_REAL:
5382 {
5383 const struct config_real *conf = &record->_real;
5384
5385 if (conf->show_hook)
5386 val = conf->show_hook();
5387 else
5388 {
5389 double result = *conf->variable;
5390 const char *unit;
5391
5392 if (use_units && result > 0 && (record->flags & GUC_UNIT))
5394 record->flags & GUC_UNIT,
5395 &result, &unit);
5396 else
5397 unit = "";
5398
5399 snprintf(buffer, sizeof(buffer), "%g%s",
5400 result, unit);
5401 val = buffer;
5402 }
5403 }
5404 break;
5405
5406 case PGC_STRING:
5407 {
5408 const struct config_string *conf = &record->_string;
5409
5410 if (conf->show_hook)
5411 val = conf->show_hook();
5412 else if (*conf->variable && **conf->variable)
5413 val = *conf->variable;
5414 else
5415 val = "";
5416 }
5417 break;
5418
5419 case PGC_ENUM:
5420 {
5421 const struct config_enum *conf = &record->_enum;
5422
5423 if (conf->show_hook)
5424 val = conf->show_hook();
5425 else
5426 val = config_enum_lookup_by_value(record, *conf->variable);
5427 }
5428 break;
5429
5430 default:
5431 /* just to keep compiler quiet */
5432 val = "???";
5433 break;
5434 }
5435
5436 return pstrdup(val);
5437}
#define INT64_FORMAT
Definition: c.h:559
int64_t int64
Definition: c.h:538
const char * config_enum_lookup_by_value(const struct config_generic *record, int val)
Definition: guc.c:2895
static void convert_int_from_base_unit(int64 base_value, int base_unit, int64 *value, const char **unit)
Definition: guc.c:2603
static void convert_real_from_base_unit(double base_value, int base_unit, double *value, const char **unit)
Definition: guc.c:2644
#define GUC_UNIT
Definition: guc.h:244
char * pstrdup(const char *in)
Definition: mcxt.c:1759
#define snprintf
Definition: port.h:260
GucShowHook show_hook
Definition: guc_tables.h:145
GucShowHook show_hook
Definition: guc_tables.h:208
GucShowHook show_hook
Definition: guc_tables.h:159
GucShowHook show_hook
Definition: guc_tables.h:173
GucShowHook show_hook
Definition: guc_tables.h:195

References config_generic::_bool, config_generic::_enum, config_generic::_int, config_generic::_real, config_generic::_string, config_enum_lookup_by_value(), convert_int_from_base_unit(), convert_real_from_base_unit(), config_generic::flags, GUC_UNIT, INT64_FORMAT, PGC_BOOL, PGC_ENUM, PGC_INT, PGC_REAL, PGC_STRING, pstrdup(), config_bool::show_hook, config_int::show_hook, config_real::show_hook, config_string::show_hook, config_enum::show_hook, snprintf, val, config_bool::variable, config_int::variable, config_real::variable, config_string::variable, config_enum::variable, and config_generic::vartype.

Referenced by GetConfigOptionByName(), GetConfigOptionValues(), ReportGUCOption(), and ShowAllGUCConfig().

Variable Documentation

◆ config_group_names

PGDLLIMPORT const char* const config_group_names[]
extern

Definition at line 698 of file guc_tables.c.

Referenced by GetConfigOptionValues(), and printMixedStruct().

◆ config_type_names

PGDLLIMPORT const char* const config_type_names[]
extern

Definition at line 758 of file guc_tables.c.

Referenced by GetConfigOptionValues().

◆ ConfigureNames

PGDLLIMPORT struct config_generic ConfigureNames[]
extern

Referenced by build_guc_variables().

◆ GucContext_Names

PGDLLIMPORT const char* const GucContext_Names[]
extern

Definition at line 655 of file guc_tables.c.

Referenced by GetConfigOptionValues(), and printMixedStruct().

◆ GucSource_Names

PGDLLIMPORT const char* const GucSource_Names[]
extern

Definition at line 674 of file guc_tables.c.

Referenced by GetConfigOptionValues().