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_generic
 
struct  config_bool
 
struct  config_int
 
struct  config_real
 
struct  config_string
 
struct  config_enum
 

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_VACUUM_DELAY , RESOURCES_BGWRITER , RESOURCES_ASYNCHRONOUS ,
  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 , AUTOVACUUM , 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 (struct config_generic *record, bool use_units)
 
bool ConfigOptionIsVisible (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 (struct config_enum *record, int val)
 
bool config_enum_lookup_by_name (struct config_enum *record, const char *value, int *retval)
 
char * config_enum_get_options (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_bool ConfigureNamesBool []
 
PGDLLIMPORT struct config_int ConfigureNamesInt []
 
PGDLLIMPORT struct config_real ConfigureNamesReal []
 
PGDLLIMPORT struct config_string ConfigureNamesString []
 
PGDLLIMPORT struct config_enum ConfigureNamesEnum []
 

Macro Definition Documentation

◆ GUC_IS_IN_FILE

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

Definition at line 187 of file guc_tables.h.

◆ GUC_NEEDS_REPORT

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

Definition at line 193 of file guc_tables.h.

◆ GUC_PENDING_RESTART

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

Definition at line 192 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_VACUUM_DELAY 
RESOURCES_BGWRITER 
RESOURCES_ASYNCHRONOUS 
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 
AUTOVACUUM 
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 */
90  AUTOVACUUM,
102 };
@ RESOURCES_KERNEL
Definition: guc_tables.h:65
@ CLIENT_CONN_LOCALE
Definition: guc_tables.h:92
@ WAL_ARCHIVE_RECOVERY
Definition: guc_tables.h:73
@ STATS_CUMULATIVE
Definition: guc_tables.h:89
@ AUTOVACUUM
Definition: guc_tables.h:90
@ CLIENT_CONN_PRELOAD
Definition: guc_tables.h:93
@ QUERY_TUNING_OTHER
Definition: guc_tables.h:83
@ LOGGING_WHERE
Definition: guc_tables.h:84
@ CONN_AUTH_AUTH
Definition: guc_tables.h:61
@ ERROR_HANDLING_OPTIONS
Definition: guc_tables.h:98
@ PROCESS_TITLE
Definition: guc_tables.h:87
@ RESOURCES_DISK
Definition: guc_tables.h:64
@ REPLICATION_SENDING
Definition: guc_tables.h:76
@ LOCK_MANAGEMENT
Definition: guc_tables.h:95
@ CUSTOM_OPTIONS
Definition: guc_tables.h:100
@ 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:67
@ PRESET_OPTIONS
Definition: guc_tables.h:99
@ DEVELOPER_OPTIONS
Definition: guc_tables.h:101
@ RESOURCES_VACUUM_DELAY
Definition: guc_tables.h:66
@ QUERY_TUNING_METHOD
Definition: guc_tables.h:80
@ LOGGING_WHAT
Definition: guc_tables.h:86
@ RESOURCES_ASYNCHRONOUS
Definition: guc_tables.h:68
@ QUERY_TUNING_GEQO
Definition: guc_tables.h:82
@ WAL_SETTINGS
Definition: guc_tables.h:69
@ COMPAT_OPTIONS_OTHER
Definition: guc_tables.h:97
@ CLIENT_CONN_STATEMENT
Definition: guc_tables.h:91
@ 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:96
@ WAL_CHECKPOINTS
Definition: guc_tables.h:70
@ CLIENT_CONN_OTHER
Definition: guc_tables.h:94
@ 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

◆ config_type

Enumerator
PGC_BOOL 
PGC_INT 
PGC_REAL 
PGC_STRING 
PGC_ENUM 

Definition at line 23 of file guc_tables.h.

24 {
25  PGC_BOOL,
26  PGC_INT,
27  PGC_REAL,
28  PGC_STRING,
29  PGC_ENUM,
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 108 of file guc_tables.h.

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

Function Documentation

◆ build_guc_variables()

void build_guc_variables ( void  )

Definition at line 902 of file guc.c.

903 {
904  int size_vars;
905  int num_vars = 0;
906  HASHCTL hash_ctl;
907  GUCHashEntry *hentry;
908  bool found;
909  int i;
910 
911  /*
912  * Create the memory context that will hold all GUC-related data.
913  */
914  Assert(GUCMemoryContext == NULL);
916  "GUCMemoryContext",
918 
919  /*
920  * Count all the built-in variables, and set their vartypes correctly.
921  */
922  for (i = 0; ConfigureNamesBool[i].gen.name; i++)
923  {
924  struct config_bool *conf = &ConfigureNamesBool[i];
925 
926  /* Rather than requiring vartype to be filled in by hand, do this: */
927  conf->gen.vartype = PGC_BOOL;
928  num_vars++;
929  }
930 
931  for (i = 0; ConfigureNamesInt[i].gen.name; i++)
932  {
933  struct config_int *conf = &ConfigureNamesInt[i];
934 
935  conf->gen.vartype = PGC_INT;
936  num_vars++;
937  }
938 
939  for (i = 0; ConfigureNamesReal[i].gen.name; i++)
940  {
941  struct config_real *conf = &ConfigureNamesReal[i];
942 
943  conf->gen.vartype = PGC_REAL;
944  num_vars++;
945  }
946 
947  for (i = 0; ConfigureNamesString[i].gen.name; i++)
948  {
949  struct config_string *conf = &ConfigureNamesString[i];
950 
951  conf->gen.vartype = PGC_STRING;
952  num_vars++;
953  }
954 
955  for (i = 0; ConfigureNamesEnum[i].gen.name; i++)
956  {
957  struct config_enum *conf = &ConfigureNamesEnum[i];
958 
959  conf->gen.vartype = PGC_ENUM;
960  num_vars++;
961  }
962 
963  /*
964  * Create hash table with 20% slack
965  */
966  size_vars = num_vars + num_vars / 4;
967 
968  hash_ctl.keysize = sizeof(char *);
969  hash_ctl.entrysize = sizeof(GUCHashEntry);
970  hash_ctl.hash = guc_name_hash;
971  hash_ctl.match = guc_name_match;
972  hash_ctl.hcxt = GUCMemoryContext;
973  guc_hashtab = hash_create("GUC hash table",
974  size_vars,
975  &hash_ctl,
977 
978  for (i = 0; ConfigureNamesBool[i].gen.name; i++)
979  {
980  struct config_generic *gucvar = &ConfigureNamesBool[i].gen;
981 
982  hentry = (GUCHashEntry *) hash_search(guc_hashtab,
983  &gucvar->name,
984  HASH_ENTER,
985  &found);
986  Assert(!found);
987  hentry->gucvar = gucvar;
988  }
989 
990  for (i = 0; ConfigureNamesInt[i].gen.name; i++)
991  {
992  struct config_generic *gucvar = &ConfigureNamesInt[i].gen;
993 
994  hentry = (GUCHashEntry *) hash_search(guc_hashtab,
995  &gucvar->name,
996  HASH_ENTER,
997  &found);
998  Assert(!found);
999  hentry->gucvar = gucvar;
1000  }
1001 
1002  for (i = 0; ConfigureNamesReal[i].gen.name; i++)
1003  {
1004  struct config_generic *gucvar = &ConfigureNamesReal[i].gen;
1005 
1006  hentry = (GUCHashEntry *) hash_search(guc_hashtab,
1007  &gucvar->name,
1008  HASH_ENTER,
1009  &found);
1010  Assert(!found);
1011  hentry->gucvar = gucvar;
1012  }
1013 
1014  for (i = 0; ConfigureNamesString[i].gen.name; i++)
1015  {
1016  struct config_generic *gucvar = &ConfigureNamesString[i].gen;
1017 
1018  hentry = (GUCHashEntry *) hash_search(guc_hashtab,
1019  &gucvar->name,
1020  HASH_ENTER,
1021  &found);
1022  Assert(!found);
1023  hentry->gucvar = gucvar;
1024  }
1025 
1026  for (i = 0; ConfigureNamesEnum[i].gen.name; i++)
1027  {
1028  struct config_generic *gucvar = &ConfigureNamesEnum[i].gen;
1029 
1030  hentry = (GUCHashEntry *) hash_search(guc_hashtab,
1031  &gucvar->name,
1032  HASH_ENTER,
1033  &found);
1034  Assert(!found);
1035  hentry->gucvar = gucvar;
1036  }
1037 
1038  Assert(num_vars == hash_get_num_entries(guc_hashtab));
1039 }
#define Assert(condition)
Definition: c.h:858
void * hash_search(HTAB *hashp, const void *keyPtr, HASHACTION action, bool *foundPtr)
Definition: dynahash.c:955
HTAB * hash_create(const char *tabname, long nelem, const HASHCTL *info, int flags)
Definition: dynahash.c:352
long hash_get_num_entries(HTAB *hashp)
Definition: dynahash.c:1341
static int guc_name_match(const void *key1, const void *key2, Size keysize)
Definition: guc.c:1353
static uint32 guc_name_hash(const void *key, Size keysize)
Definition: guc.c:1329
static HTAB * guc_hashtab
Definition: guc.c:211
static MemoryContext GUCMemoryContext
Definition: guc.c:198
struct config_string ConfigureNamesString[]
Definition: guc_tables.c:3942
struct config_int ConfigureNamesInt[]
Definition: guc_tables.c:2028
struct config_bool ConfigureNamesBool[]
Definition: guc_tables.c:763
struct config_real ConfigureNamesReal[]
Definition: guc_tables.c:3661
struct config_enum ConfigureNamesEnum[]
Definition: guc_tables.c:4719
@ 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:73
MemoryContext TopMemoryContext
Definition: mcxt.c:149
#define AllocSetContextCreate
Definition: memutils.h:129
#define ALLOCSET_DEFAULT_SIZES
Definition: memutils.h:160
struct config_generic * gucvar
Definition: guc.c:208
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
struct config_generic gen
Definition: guc_tables.h:200
struct config_generic gen
Definition: guc_tables.h:270
const char * name
Definition: guc_tables.h:156
enum config_type vartype
Definition: guc_tables.h:163
struct config_generic gen
Definition: guc_tables.h:214
struct config_generic gen
Definition: guc_tables.h:230
struct config_generic gen
Definition: guc_tables.h:256

References ALLOCSET_DEFAULT_SIZES, AllocSetContextCreate, Assert, ConfigureNamesBool, ConfigureNamesEnum, ConfigureNamesInt, ConfigureNamesReal, ConfigureNamesString, HASHCTL::entrysize, config_bool::gen, config_int::gen, config_real::gen, config_string::gen, config_enum::gen, 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, PGC_BOOL, PGC_ENUM, PGC_INT, PGC_REAL, PGC_STRING, TopMemoryContext, and config_generic::vartype.

Referenced by GucInfoMain(), and InitializeGUCOptions().

◆ config_enum_get_options()

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

Definition at line 3071 of file guc.c.

3073 {
3074  const struct config_enum_entry *entry;
3075  StringInfoData retstr;
3076  int seplen;
3077 
3078  initStringInfo(&retstr);
3079  appendStringInfoString(&retstr, prefix);
3080 
3081  seplen = strlen(separator);
3082  for (entry = record->options; entry && entry->name; entry++)
3083  {
3084  if (!entry->hidden)
3085  {
3086  appendStringInfoString(&retstr, entry->name);
3087  appendBinaryStringInfo(&retstr, separator, seplen);
3088  }
3089  }
3090 
3091  /*
3092  * All the entries may have been hidden, leaving the string empty if no
3093  * prefix was given. This indicates a broken GUC setup, since there is no
3094  * use for an enum without any values, so we just check to make sure we
3095  * don't write to invalid memory instead of actually trying to do
3096  * something smart with it.
3097  */
3098  if (retstr.len >= seplen)
3099  {
3100  /* Replace final separator */
3101  retstr.data[retstr.len - seplen] = '\0';
3102  retstr.len -= seplen;
3103  }
3104 
3105  appendStringInfoString(&retstr, suffix);
3106 
3107  return retstr.data;
3108 }
void appendBinaryStringInfo(StringInfo str, const void *data, int datalen)
Definition: stringinfo.c:233
void appendStringInfoString(StringInfo str, const char *s)
Definition: stringinfo.c:182
void initStringInfo(StringInfo str)
Definition: stringinfo.c:59
Definition: guc.h:170
const char * name
Definition: guc.h:171
bool hidden
Definition: guc.h:173
const struct config_enum_entry * options
Definition: guc_tables.h:274

References appendBinaryStringInfo(), appendStringInfoString(), StringInfoData::data, config_enum_entry::hidden, 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 ( struct config_enum record,
const char *  value,
int *  retval 
)

Definition at line 3045 of file guc.c.

3047 {
3048  const struct config_enum_entry *entry;
3049 
3050  for (entry = record->options; entry && entry->name; entry++)
3051  {
3052  if (pg_strcasecmp(value, entry->name) == 0)
3053  {
3054  *retval = entry->val;
3055  return true;
3056  }
3057  }
3058 
3059  *retval = 0;
3060  return false;
3061 }
static struct @155 value
int pg_strcasecmp(const char *s1, const char *s2)
Definition: pgstrcasecmp.c:36
int val
Definition: guc.h:172

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

Referenced by parse_and_validate_value().

◆ config_enum_lookup_by_value()

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

Definition at line 3022 of file guc.c.

3023 {
3024  const struct config_enum_entry *entry;
3025 
3026  for (entry = record->options; entry && entry->name; entry++)
3027  {
3028  if (entry->val == val)
3029  return entry->name;
3030  }
3031 
3032  elog(ERROR, "could not find enum option %d for %s",
3033  val, record->gen.name);
3034  return NULL; /* silence compiler */
3035 }
#define ERROR
Definition: elog.h:39
#define elog(elevel,...)
Definition: elog.h:224
long val
Definition: informix.c:670

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

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

◆ ConfigOptionIsVisible()

bool ConfigOptionIsVisible ( struct config_generic conf)

Definition at line 581 of file guc_funcs.c.

582 {
583  if ((conf->flags & GUC_SUPERUSER_ONLY) &&
584  !has_privs_of_role(GetUserId(), ROLE_PG_READ_ALL_SETTINGS))
585  return false;
586  else
587  return true;
588 }
bool has_privs_of_role(Oid member, Oid role)
Definition: acl.c:5134
#define GUC_SUPERUSER_ONLY
Definition: guc.h:220
Oid GetUserId(void)
Definition: miscinit.c:514

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 1234 of file guc.c.

1236 {
1237  GUCHashEntry *hentry;
1238  int i;
1239 
1240  Assert(name);
1241 
1242  /* Look it up using the hash table. */
1243  hentry = (GUCHashEntry *) hash_search(guc_hashtab,
1244  &name,
1245  HASH_FIND,
1246  NULL);
1247  if (hentry)
1248  return hentry->gucvar;
1249 
1250  /*
1251  * See if the name is an obsolete name for a variable. We assume that the
1252  * set of supported old names is short enough that a brute-force search is
1253  * the best way.
1254  */
1255  for (i = 0; map_old_guc_names[i] != NULL; i += 2)
1256  {
1258  return find_option(map_old_guc_names[i + 1], false,
1259  skip_errors, elevel);
1260  }
1261 
1262  if (create_placeholders)
1263  {
1264  /*
1265  * Check if the name is valid, and if so, add a placeholder.
1266  */
1267  if (assignable_custom_variable_name(name, skip_errors, elevel))
1268  return add_placeholder_variable(name, elevel);
1269  else
1270  return NULL; /* error message, if any, already emitted */
1271  }
1272 
1273  /* Unknown name and we're not supposed to make a placeholder */
1274  if (!skip_errors)
1275  ereport(elevel,
1276  (errcode(ERRCODE_UNDEFINED_OBJECT),
1277  errmsg("unrecognized configuration parameter \"%s\"",
1278  name)));
1279  return NULL;
1280 }
int errcode(int sqlerrcode)
Definition: elog.c:853
int errmsg(const char *fmt,...)
Definition: elog.c:1070
#define ereport(elevel,...)
Definition: elog.h:149
static const char *const map_old_guc_names[]
Definition: guc.c:190
static bool assignable_custom_variable_name(const char *name, bool skip_errors, int elevel)
Definition: guc.c:1120
struct config_generic * find_option(const char *name, bool create_placeholders, bool skip_errors, int elevel)
Definition: guc.c:1234
static struct config_generic * add_placeholder_variable(const char *name, int elevel)
Definition: guc.c:1176
int guc_name_compare(const char *namea, const char *nameb)
Definition: guc.c:1299
@ HASH_FIND
Definition: hsearch.h:113
const char * name

References add_placeholder_variable(), Assert, assignable_custom_variable_name(), ereport, errcode(), errmsg(), 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(), 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 5281 of file guc.c.

5282 {
5283  struct config_generic **result;
5284  dlist_iter iter;
5285 
5286  *num = 0;
5287 
5288  /*
5289  * While only a fraction of all the GUC variables are marked GUC_EXPLAIN,
5290  * it doesn't seem worth dynamically resizing this array.
5291  */
5292  result = palloc(sizeof(struct config_generic *) * hash_get_num_entries(guc_hashtab));
5293 
5294  /* We need only consider GUCs with source not PGC_S_DEFAULT */
5296  {
5297  struct config_generic *conf = dlist_container(struct config_generic,
5298  nondef_link, iter.cur);
5299  bool modified;
5300 
5301  /* return only parameters marked for inclusion in explain */
5302  if (!(conf->flags & GUC_EXPLAIN))
5303  continue;
5304 
5305  /* return only options visible to the current user */
5306  if (!ConfigOptionIsVisible(conf))
5307  continue;
5308 
5309  /* return only options that are different from their boot values */
5310  modified = false;
5311 
5312  switch (conf->vartype)
5313  {
5314  case PGC_BOOL:
5315  {
5316  struct config_bool *lconf = (struct config_bool *) conf;
5317 
5318  modified = (lconf->boot_val != *(lconf->variable));
5319  }
5320  break;
5321 
5322  case PGC_INT:
5323  {
5324  struct config_int *lconf = (struct config_int *) conf;
5325 
5326  modified = (lconf->boot_val != *(lconf->variable));
5327  }
5328  break;
5329 
5330  case PGC_REAL:
5331  {
5332  struct config_real *lconf = (struct config_real *) conf;
5333 
5334  modified = (lconf->boot_val != *(lconf->variable));
5335  }
5336  break;
5337 
5338  case PGC_STRING:
5339  {
5340  struct config_string *lconf = (struct config_string *) conf;
5341 
5342  if (lconf->boot_val == NULL &&
5343  *lconf->variable == NULL)
5344  modified = false;
5345  else if (lconf->boot_val == NULL ||
5346  *lconf->variable == NULL)
5347  modified = true;
5348  else
5349  modified = (strcmp(lconf->boot_val, *(lconf->variable)) != 0);
5350  }
5351  break;
5352 
5353  case PGC_ENUM:
5354  {
5355  struct config_enum *lconf = (struct config_enum *) conf;
5356 
5357  modified = (lconf->boot_val != *(lconf->variable));
5358  }
5359  break;
5360 
5361  default:
5362  elog(ERROR, "unexpected GUC type: %d", conf->vartype);
5363  }
5364 
5365  if (!modified)
5366  continue;
5367 
5368  /* OK, report it */
5369  result[*num] = conf;
5370  *num = *num + 1;
5371  }
5372 
5373  return result;
5374 }
static dlist_head guc_nondef_list
Definition: guc.c:221
#define GUC_EXPLAIN
Definition: guc.h:215
bool ConfigOptionIsVisible(struct config_generic *conf)
Definition: guc_funcs.c:581
#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:1317
bool * variable
Definition: guc_tables.h:202
bool boot_val
Definition: guc_tables.h:203
int * variable
Definition: guc_tables.h:272
dlist_node nondef_link
Definition: guc_tables.h:173
int boot_val
Definition: guc_tables.h:217
int * variable
Definition: guc_tables.h:216
double boot_val
Definition: guc_tables.h:233
double * variable
Definition: guc_tables.h:232
char ** variable
Definition: guc_tables.h:258
const char * boot_val
Definition: guc_tables.h:259
dlist_node * cur
Definition: ilist.h:179

References 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 871 of file guc.c.

872 {
873  struct config_generic **result;
875  GUCHashEntry *hentry;
876  int i;
877 
878  *num_vars = hash_get_num_entries(guc_hashtab);
879  result = palloc(sizeof(struct config_generic *) * *num_vars);
880 
881  /* Extract pointers from the hash table */
882  i = 0;
884  while ((hentry = (GUCHashEntry *) hash_seq_search(&status)) != NULL)
885  result[i++] = hentry->gucvar;
886  Assert(i == *num_vars);
887 
888  /* Sort by name */
889  qsort(result, *num_vars,
890  sizeof(struct config_generic *), guc_var_compare);
891 
892  return result;
893 }
void * hash_seq_search(HASH_SEQ_STATUS *status)
Definition: dynahash.c:1395
void hash_seq_init(HASH_SEQ_STATUS *status, HTAB *hashp)
Definition: dynahash.c:1385
static int guc_var_compare(const void *a, const void *b)
Definition: guc.c:1287
#define qsort(a, b, c, d)
Definition: port.h:453

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 ( struct config_generic record,
bool  use_units 
)

Definition at line 5415 of file guc.c.

5416 {
5417  char buffer[256];
5418  const char *val;
5419 
5420  switch (record->vartype)
5421  {
5422  case PGC_BOOL:
5423  {
5424  struct config_bool *conf = (struct config_bool *) record;
5425 
5426  if (conf->show_hook)
5427  val = conf->show_hook();
5428  else
5429  val = *conf->variable ? "on" : "off";
5430  }
5431  break;
5432 
5433  case PGC_INT:
5434  {
5435  struct config_int *conf = (struct config_int *) record;
5436 
5437  if (conf->show_hook)
5438  val = conf->show_hook();
5439  else
5440  {
5441  /*
5442  * Use int64 arithmetic to avoid overflows in units
5443  * conversion.
5444  */
5445  int64 result = *conf->variable;
5446  const char *unit;
5447 
5448  if (use_units && result > 0 && (record->flags & GUC_UNIT))
5450  record->flags & GUC_UNIT,
5451  &result, &unit);
5452  else
5453  unit = "";
5454 
5455  snprintf(buffer, sizeof(buffer), INT64_FORMAT "%s",
5456  result, unit);
5457  val = buffer;
5458  }
5459  }
5460  break;
5461 
5462  case PGC_REAL:
5463  {
5464  struct config_real *conf = (struct config_real *) record;
5465 
5466  if (conf->show_hook)
5467  val = conf->show_hook();
5468  else
5469  {
5470  double result = *conf->variable;
5471  const char *unit;
5472 
5473  if (use_units && result > 0 && (record->flags & GUC_UNIT))
5475  record->flags & GUC_UNIT,
5476  &result, &unit);
5477  else
5478  unit = "";
5479 
5480  snprintf(buffer, sizeof(buffer), "%g%s",
5481  result, unit);
5482  val = buffer;
5483  }
5484  }
5485  break;
5486 
5487  case PGC_STRING:
5488  {
5489  struct config_string *conf = (struct config_string *) record;
5490 
5491  if (conf->show_hook)
5492  val = conf->show_hook();
5493  else if (*conf->variable && **conf->variable)
5494  val = *conf->variable;
5495  else
5496  val = "";
5497  }
5498  break;
5499 
5500  case PGC_ENUM:
5501  {
5502  struct config_enum *conf = (struct config_enum *) record;
5503 
5504  if (conf->show_hook)
5505  val = conf->show_hook();
5506  else
5507  val = config_enum_lookup_by_value(conf, *conf->variable);
5508  }
5509  break;
5510 
5511  default:
5512  /* just to keep compiler quiet */
5513  val = "???";
5514  break;
5515  }
5516 
5517  return pstrdup(val);
5518 }
#define INT64_FORMAT
Definition: c.h:548
const char * config_enum_lookup_by_value(struct config_enum *record, int val)
Definition: guc.c:3022
static void convert_int_from_base_unit(int64 base_value, int base_unit, int64 *value, const char **unit)
Definition: guc.c:2728
static void convert_real_from_base_unit(double base_value, int base_unit, double *value, const char **unit)
Definition: guc.c:2770
#define GUC_UNIT
Definition: guc.h:239
char * pstrdup(const char *in)
Definition: mcxt.c:1696
#define snprintf
Definition: port.h:238
GucShowHook show_hook
Definition: guc_tables.h:206
GucShowHook show_hook
Definition: guc_tables.h:277
GucShowHook show_hook
Definition: guc_tables.h:222
GucShowHook show_hook
Definition: guc_tables.h:238
GucShowHook show_hook
Definition: guc_tables.h:262

References 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 666 of file guc_tables.c.

Referenced by GetConfigOptionValues().

◆ config_type_names

PGDLLIMPORT const char* const config_type_names[]
extern

Definition at line 723 of file guc_tables.c.

Referenced by GetConfigOptionValues().

◆ ConfigureNamesBool

PGDLLIMPORT struct config_bool ConfigureNamesBool[]
extern

Definition at line 732 of file guc_tables.c.

Referenced by build_guc_variables().

◆ ConfigureNamesEnum

PGDLLIMPORT struct config_enum ConfigureNamesEnum[]
extern

Definition at line 732 of file guc_tables.c.

Referenced by build_guc_variables().

◆ ConfigureNamesInt

PGDLLIMPORT struct config_int ConfigureNamesInt[]
extern

Definition at line 732 of file guc_tables.c.

Referenced by build_guc_variables().

◆ ConfigureNamesReal

PGDLLIMPORT struct config_real ConfigureNamesReal[]
extern

Definition at line 732 of file guc_tables.c.

Referenced by build_guc_variables().

◆ ConfigureNamesString

PGDLLIMPORT struct config_string ConfigureNamesString[]
extern

Definition at line 732 of file guc_tables.c.

Referenced by build_guc_variables().

◆ GucContext_Names

PGDLLIMPORT const char* const GucContext_Names[]
extern

Definition at line 623 of file guc_tables.c.

Referenced by GetConfigOptionValues().

◆ GucSource_Names

PGDLLIMPORT const char* const GucSource_Names[]
extern

Definition at line 642 of file guc_tables.c.

Referenced by GetConfigOptionValues().