PostgreSQL Source Code  git master
guc_tables.h File Reference
#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
 

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, CONN_AUTH_SETTINGS,
  CONN_AUTH_AUTH, CONN_AUTH_SSL, RESOURCES, RESOURCES_MEM,
  RESOURCES_DISK, RESOURCES_KERNEL, RESOURCES_VACUUM_DELAY, RESOURCES_BGWRITER,
  RESOURCES_ASYNCHRONOUS, WAL, WAL_SETTINGS, WAL_CHECKPOINTS,
  WAL_ARCHIVING, WAL_ARCHIVE_RECOVERY, WAL_RECOVERY_TARGET, REPLICATION,
  REPLICATION_SENDING, REPLICATION_MASTER, REPLICATION_STANDBY, REPLICATION_SUBSCRIBERS,
  QUERY_TUNING, QUERY_TUNING_METHOD, QUERY_TUNING_COST, QUERY_TUNING_GEQO,
  QUERY_TUNING_OTHER, LOGGING, LOGGING_WHERE, LOGGING_WHEN,
  LOGGING_WHAT, PROCESS_TITLE, STATS, STATS_MONITORING,
  STATS_COLLECTOR, AUTOVACUUM, CLIENT_CONN, CLIENT_CONN_STATEMENT,
  CLIENT_CONN_LOCALE, CLIENT_CONN_PRELOAD, CLIENT_CONN_OTHER, LOCK_MANAGEMENT,
  COMPAT_OPTIONS, COMPAT_OPTIONS_PREVIOUS, COMPAT_OPTIONS_CLIENT, ERROR_HANDLING_OPTIONS,
  PRESET_OPTIONS, CUSTOM_OPTIONS, DEVELOPER_OPTIONS
}
 
enum  GucStackState { GUC_SAVE, GUC_SET, GUC_LOCAL, GUC_SET_LOCAL }
 

Functions

struct config_generic ** get_guc_variables (void)
 
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)
 
struct config_generic ** get_explain_guc_options (int *num)
 

Variables

const char *const config_group_names []
 
const char *const config_type_names []
 
const char *const GucContext_Names []
 
const char *const GucSource_Names []
 

Macro Definition Documentation

◆ GUC_IS_IN_FILE

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

Definition at line 170 of file guc_tables.h.

◆ GUC_PENDING_RESTART

#define GUC_PENDING_RESTART   0x0002

Definition at line 175 of file guc_tables.h.

Referenced by GetConfigOptionByNum(), and set_config_option().

Typedef Documentation

◆ config_var_value

◆ GucStack

typedef struct guc_stack GucStack

Enumeration Type Documentation

◆ config_group

Enumerator
UNGROUPED 
FILE_LOCATIONS 
CONN_AUTH 
CONN_AUTH_SETTINGS 
CONN_AUTH_AUTH 
CONN_AUTH_SSL 
RESOURCES 
RESOURCES_MEM 
RESOURCES_DISK 
RESOURCES_KERNEL 
RESOURCES_VACUUM_DELAY 
RESOURCES_BGWRITER 
RESOURCES_ASYNCHRONOUS 
WAL 
WAL_SETTINGS 
WAL_CHECKPOINTS 
WAL_ARCHIVING 
WAL_ARCHIVE_RECOVERY 
WAL_RECOVERY_TARGET 
REPLICATION 
REPLICATION_SENDING 
REPLICATION_MASTER 
REPLICATION_STANDBY 
REPLICATION_SUBSCRIBERS 
QUERY_TUNING 
QUERY_TUNING_METHOD 
QUERY_TUNING_COST 
QUERY_TUNING_GEQO 
QUERY_TUNING_OTHER 
LOGGING 
LOGGING_WHERE 
LOGGING_WHEN 
LOGGING_WHAT 
PROCESS_TITLE 
STATS 
STATS_MONITORING 
STATS_COLLECTOR 
AUTOVACUUM 
CLIENT_CONN 
CLIENT_CONN_STATEMENT 
CLIENT_CONN_LOCALE 
CLIENT_CONN_PRELOAD 
CLIENT_CONN_OTHER 
LOCK_MANAGEMENT 
COMPAT_OPTIONS 
COMPAT_OPTIONS_PREVIOUS 
COMPAT_OPTIONS_CLIENT 
ERROR_HANDLING_OPTIONS 
PRESET_OPTIONS 
CUSTOM_OPTIONS 
DEVELOPER_OPTIONS 

Definition at line 53 of file guc_tables.h.

54 {
55  UNGROUPED,
57  CONN_AUTH,
61  RESOURCES,
68  WAL,
84  LOGGING,
89  STATS,
92  AUTOVACUUM,
106 };
Definition: guc_tables.h:68

◆ config_type

Enumerator
PGC_BOOL 
PGC_INT 
PGC_REAL 
PGC_STRING 
PGC_ENUM 

Definition at line 22 of file guc_tables.h.

23 {
24  PGC_BOOL,
25  PGC_INT,
26  PGC_REAL,
27  PGC_STRING,
28  PGC_ENUM
29 };

◆ GucStackState

Enumerator
GUC_SAVE 
GUC_SET 
GUC_LOCAL 
GUC_SET_LOCAL 

Definition at line 112 of file guc_tables.h.

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

Function Documentation

◆ build_guc_variables()

void build_guc_variables ( void  )

Definition at line 5068 of file guc.c.

References FATAL, free, config_bool::gen, config_int::gen, config_real::gen, config_string::gen, config_enum::gen, guc_malloc(), guc_var_compare(), i, config_generic::name, PGC_BOOL, PGC_ENUM, PGC_INT, PGC_REAL, PGC_STRING, qsort, and config_generic::vartype.

Referenced by GucInfoMain(), and InitializeGUCOptions().

5069 {
5070  int size_vars;
5071  int num_vars = 0;
5072  struct config_generic **guc_vars;
5073  int i;
5074 
5075  for (i = 0; ConfigureNamesBool[i].gen.name; i++)
5076  {
5077  struct config_bool *conf = &ConfigureNamesBool[i];
5078 
5079  /* Rather than requiring vartype to be filled in by hand, do this: */
5080  conf->gen.vartype = PGC_BOOL;
5081  num_vars++;
5082  }
5083 
5084  for (i = 0; ConfigureNamesInt[i].gen.name; i++)
5085  {
5086  struct config_int *conf = &ConfigureNamesInt[i];
5087 
5088  conf->gen.vartype = PGC_INT;
5089  num_vars++;
5090  }
5091 
5092  for (i = 0; ConfigureNamesReal[i].gen.name; i++)
5093  {
5094  struct config_real *conf = &ConfigureNamesReal[i];
5095 
5096  conf->gen.vartype = PGC_REAL;
5097  num_vars++;
5098  }
5099 
5100  for (i = 0; ConfigureNamesString[i].gen.name; i++)
5101  {
5102  struct config_string *conf = &ConfigureNamesString[i];
5103 
5104  conf->gen.vartype = PGC_STRING;
5105  num_vars++;
5106  }
5107 
5108  for (i = 0; ConfigureNamesEnum[i].gen.name; i++)
5109  {
5110  struct config_enum *conf = &ConfigureNamesEnum[i];
5111 
5112  conf->gen.vartype = PGC_ENUM;
5113  num_vars++;
5114  }
5115 
5116  /*
5117  * Create table with 20% slack
5118  */
5119  size_vars = num_vars + num_vars / 4;
5120 
5121  guc_vars = (struct config_generic **)
5122  guc_malloc(FATAL, size_vars * sizeof(struct config_generic *));
5123 
5124  num_vars = 0;
5125 
5126  for (i = 0; ConfigureNamesBool[i].gen.name; i++)
5127  guc_vars[num_vars++] = &ConfigureNamesBool[i].gen;
5128 
5129  for (i = 0; ConfigureNamesInt[i].gen.name; i++)
5130  guc_vars[num_vars++] = &ConfigureNamesInt[i].gen;
5131 
5132  for (i = 0; ConfigureNamesReal[i].gen.name; i++)
5133  guc_vars[num_vars++] = &ConfigureNamesReal[i].gen;
5134 
5135  for (i = 0; ConfigureNamesString[i].gen.name; i++)
5136  guc_vars[num_vars++] = &ConfigureNamesString[i].gen;
5137 
5138  for (i = 0; ConfigureNamesEnum[i].gen.name; i++)
5139  guc_vars[num_vars++] = &ConfigureNamesEnum[i].gen;
5140 
5141  if (guc_variables)
5143  guc_variables = guc_vars;
5144  num_guc_variables = num_vars;
5145  size_guc_variables = size_vars;
5147  sizeof(struct config_generic *), guc_var_compare);
5148 }
static struct config_int ConfigureNamesInt[]
Definition: guc.c:2070
const char * name
Definition: guc_tables.h:149
static struct config_enum ConfigureNamesEnum[]
Definition: guc.c:4448
static struct config_bool ConfigureNamesBool[]
Definition: guc.c:932
static int guc_var_compare(const void *a, const void *b)
Definition: guc.c:5290
static int num_guc_variables
Definition: guc.c:4807
#define FATAL
Definition: elog.h:52
struct config_generic gen
Definition: guc_tables.h:182
struct config_generic gen
Definition: guc_tables.h:196
static struct config_generic ** guc_variables
Definition: guc.c:4804
enum config_type vartype
Definition: guc_tables.h:156
static int size_guc_variables
Definition: guc.c:4810
static struct config_real ConfigureNamesReal[]
Definition: guc.c:3410
struct config_generic gen
Definition: guc_tables.h:242
struct config_generic gen
Definition: guc_tables.h:228
#define free(a)
Definition: header.h:65
static struct config_string ConfigureNamesString[]
Definition: guc.c:3679
int i
#define qsort(a, b, c, d)
Definition: port.h:479
static void * guc_malloc(int elevel, size_t size)
Definition: guc.c:4845
struct config_generic gen
Definition: guc_tables.h:212

◆ config_enum_lookup_by_name()

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

Definition at line 6660 of file guc.c.

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

Referenced by parse_and_validate_value().

6662 {
6663  const struct config_enum_entry *entry;
6664 
6665  for (entry = record->options; entry && entry->name; entry++)
6666  {
6667  if (pg_strcasecmp(value, entry->name) == 0)
6668  {
6669  *retval = entry->val;
6670  return true;
6671  }
6672  }
6673 
6674  *retval = 0;
6675  return false;
6676 }
Definition: guc.h:164
int pg_strcasecmp(const char *s1, const char *s2)
Definition: pgstrcasecmp.c:36
const struct config_enum_entry * options
Definition: guc_tables.h:246
int val
Definition: guc.h:167
static struct @143 value
const char * name
Definition: guc.h:166

◆ config_enum_lookup_by_value()

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

Definition at line 6637 of file guc.c.

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

Referenced by _ShowOption(), call_enum_check_hook(), estimate_variable_size(), GetConfigOption(), GetConfigOptionByNum(), GetConfigOptionResetString(), printMixedStruct(), and serialize_variable().

6638 {
6639  const struct config_enum_entry *entry;
6640 
6641  for (entry = record->options; entry && entry->name; entry++)
6642  {
6643  if (entry->val == val)
6644  return entry->name;
6645  }
6646 
6647  elog(ERROR, "could not find enum option %d for %s",
6648  val, record->gen.name);
6649  return NULL; /* silence compiler */
6650 }
Definition: guc.h:164
const char * name
Definition: guc_tables.h:149
#define ERROR
Definition: elog.h:43
const struct config_enum_entry * options
Definition: guc_tables.h:246
int val
Definition: guc.h:167
struct config_generic gen
Definition: guc_tables.h:242
const char * name
Definition: guc.h:166
#define elog(elevel,...)
Definition: elog.h:214
long val
Definition: informix.c:664

◆ get_explain_guc_options()

struct config_generic** get_explain_guc_options ( int *  num)

Definition at line 9099 of file guc.c.

References config_bool::boot_val, config_int::boot_val, config_real::boot_val, config_string::boot_val, config_enum::boot_val, elog, ERROR, config_generic::flags, GetUserId(), GUC_EXPLAIN, GUC_NO_SHOW_ALL, GUC_SUPERUSER_ONLY, i, is_member_of_role(), num_guc_variables, 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().

9100 {
9101  struct config_generic **result;
9102 
9103  *num = 0;
9104 
9105  /*
9106  * While only a fraction of all the GUC variables are marked GUC_EXPLAIN,
9107  * it doesn't seem worth dynamically resizing this array.
9108  */
9109  result = palloc(sizeof(struct config_generic *) * num_guc_variables);
9110 
9111  for (int i = 0; i < num_guc_variables; i++)
9112  {
9113  bool modified;
9114  struct config_generic *conf = guc_variables[i];
9115 
9116  /* return only parameters marked for inclusion in explain */
9117  if (!(conf->flags & GUC_EXPLAIN))
9118  continue;
9119 
9120  /* return only options visible to the current user */
9121  if ((conf->flags & GUC_NO_SHOW_ALL) ||
9122  ((conf->flags & GUC_SUPERUSER_ONLY) &&
9123  !is_member_of_role(GetUserId(), DEFAULT_ROLE_READ_ALL_SETTINGS)))
9124  continue;
9125 
9126  /* return only options that are different from their boot values */
9127  modified = false;
9128 
9129  switch (conf->vartype)
9130  {
9131  case PGC_BOOL:
9132  {
9133  struct config_bool *lconf = (struct config_bool *) conf;
9134 
9135  modified = (lconf->boot_val != *(lconf->variable));
9136  }
9137  break;
9138 
9139  case PGC_INT:
9140  {
9141  struct config_int *lconf = (struct config_int *) conf;
9142 
9143  modified = (lconf->boot_val != *(lconf->variable));
9144  }
9145  break;
9146 
9147  case PGC_REAL:
9148  {
9149  struct config_real *lconf = (struct config_real *) conf;
9150 
9151  modified = (lconf->boot_val != *(lconf->variable));
9152  }
9153  break;
9154 
9155  case PGC_STRING:
9156  {
9157  struct config_string *lconf = (struct config_string *) conf;
9158 
9159  modified = (strcmp(lconf->boot_val, *(lconf->variable)) != 0);
9160  }
9161  break;
9162 
9163  case PGC_ENUM:
9164  {
9165  struct config_enum *lconf = (struct config_enum *) conf;
9166 
9167  modified = (lconf->boot_val != *(lconf->variable));
9168  }
9169  break;
9170 
9171  default:
9172  elog(ERROR, "unexpected GUC type: %d", conf->vartype);
9173  }
9174 
9175  if (!modified)
9176  continue;
9177 
9178  /* OK, report it */
9179  result[*num] = conf;
9180  *num = *num + 1;
9181  }
9182 
9183  return result;
9184 }
Oid GetUserId(void)
Definition: miscinit.c:448
char ** variable
Definition: guc_tables.h:230
bool * variable
Definition: guc_tables.h:184
int boot_val
Definition: guc_tables.h:199
const char * boot_val
Definition: guc_tables.h:231
#define GUC_NO_SHOW_ALL
Definition: guc.h:206
int * variable
Definition: guc_tables.h:198
int * variable
Definition: guc_tables.h:244
#define ERROR
Definition: elog.h:43
static int num_guc_variables
Definition: guc.c:4807
bool boot_val
Definition: guc_tables.h:185
#define GUC_EXPLAIN
Definition: guc.h:230
double * variable
Definition: guc_tables.h:214
static struct config_generic ** guc_variables
Definition: guc.c:4804
enum config_type vartype
Definition: guc_tables.h:156
#define GUC_SUPERUSER_ONLY
Definition: guc.h:212
bool is_member_of_role(Oid member, Oid role)
Definition: acl.c:4916
double boot_val
Definition: guc_tables.h:215
void * palloc(Size size)
Definition: mcxt.c:949
#define elog(elevel,...)
Definition: elog.h:214
int i

◆ get_guc_variables()

struct config_generic** get_guc_variables ( void  )

Definition at line 5056 of file guc.c.

References guc_variables.

Referenced by GucInfoMain().

5057 {
5058  return guc_variables;
5059 }
static struct config_generic ** guc_variables
Definition: guc.c:4804

Variable Documentation

◆ config_group_names

const char* const config_group_names[]

Definition at line 676 of file guc.c.

Referenced by printMixedStruct().

◆ config_type_names

const char* const config_type_names[]

Definition at line 792 of file guc.c.

◆ GucContext_Names

const char* const GucContext_Names[]

Definition at line 633 of file guc.c.

Referenced by printMixedStruct().

◆ GucSource_Names

const char* const GucSource_Names[]

Definition at line 652 of file guc.c.