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

References FATAL, config_generic::flags, free, config_bool::gen, config_int::gen, config_real::gen, config_string::gen, config_enum::gen, GUC_EXPLAIN, 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().

4833 {
4834  int size_vars;
4835  int num_vars = 0;
4836  int num_explain_vars = 0;
4837  struct config_generic **guc_vars;
4838  int i;
4839 
4840  for (i = 0; ConfigureNamesBool[i].gen.name; i++)
4841  {
4842  struct config_bool *conf = &ConfigureNamesBool[i];
4843 
4844  /* Rather than requiring vartype to be filled in by hand, do this: */
4845  conf->gen.vartype = PGC_BOOL;
4846  num_vars++;
4847 
4848  if (conf->gen.flags & GUC_EXPLAIN)
4849  num_explain_vars++;
4850  }
4851 
4852  for (i = 0; ConfigureNamesInt[i].gen.name; i++)
4853  {
4854  struct config_int *conf = &ConfigureNamesInt[i];
4855 
4856  conf->gen.vartype = PGC_INT;
4857  num_vars++;
4858 
4859  if (conf->gen.flags & GUC_EXPLAIN)
4860  num_explain_vars++;
4861  }
4862 
4863  for (i = 0; ConfigureNamesReal[i].gen.name; i++)
4864  {
4865  struct config_real *conf = &ConfigureNamesReal[i];
4866 
4867  conf->gen.vartype = PGC_REAL;
4868  num_vars++;
4869 
4870  if (conf->gen.flags & GUC_EXPLAIN)
4871  num_explain_vars++;
4872  }
4873 
4874  for (i = 0; ConfigureNamesString[i].gen.name; i++)
4875  {
4876  struct config_string *conf = &ConfigureNamesString[i];
4877 
4878  conf->gen.vartype = PGC_STRING;
4879  num_vars++;
4880 
4881  if (conf->gen.flags & GUC_EXPLAIN)
4882  num_explain_vars++;
4883  }
4884 
4885  for (i = 0; ConfigureNamesEnum[i].gen.name; i++)
4886  {
4887  struct config_enum *conf = &ConfigureNamesEnum[i];
4888 
4889  conf->gen.vartype = PGC_ENUM;
4890  num_vars++;
4891 
4892  if (conf->gen.flags & GUC_EXPLAIN)
4893  num_explain_vars++;
4894  }
4895 
4896  /*
4897  * Create table with 20% slack
4898  */
4899  size_vars = num_vars + num_vars / 4;
4900 
4901  guc_vars = (struct config_generic **)
4902  guc_malloc(FATAL, size_vars * sizeof(struct config_generic *));
4903 
4904  num_vars = 0;
4905 
4906  for (i = 0; ConfigureNamesBool[i].gen.name; i++)
4907  guc_vars[num_vars++] = &ConfigureNamesBool[i].gen;
4908 
4909  for (i = 0; ConfigureNamesInt[i].gen.name; i++)
4910  guc_vars[num_vars++] = &ConfigureNamesInt[i].gen;
4911 
4912  for (i = 0; ConfigureNamesReal[i].gen.name; i++)
4913  guc_vars[num_vars++] = &ConfigureNamesReal[i].gen;
4914 
4915  for (i = 0; ConfigureNamesString[i].gen.name; i++)
4916  guc_vars[num_vars++] = &ConfigureNamesString[i].gen;
4917 
4918  for (i = 0; ConfigureNamesEnum[i].gen.name; i++)
4919  guc_vars[num_vars++] = &ConfigureNamesEnum[i].gen;
4920 
4921  if (guc_variables)
4923  guc_variables = guc_vars;
4924  num_guc_variables = num_vars;
4925  num_guc_explain_variables = num_explain_vars;
4926  size_guc_variables = size_vars;
4928  sizeof(struct config_generic *), guc_var_compare);
4929 }
static struct config_int ConfigureNamesInt[]
Definition: guc.c:1962
const char * name
Definition: guc_tables.h:149
static struct config_enum ConfigureNamesEnum[]
Definition: guc.c:4209
static struct config_bool ConfigureNamesBool[]
Definition: guc.c:881
static int guc_var_compare(const void *a, const void *b)
Definition: guc.c:5071
static int num_guc_variables
Definition: guc.c:4568
#define FATAL
Definition: elog.h:52
struct config_generic gen
Definition: guc_tables.h:182
struct config_generic gen
Definition: guc_tables.h:196
#define GUC_EXPLAIN
Definition: guc.h:230
static struct config_generic ** guc_variables
Definition: guc.c:4565
enum config_type vartype
Definition: guc_tables.h:156
static int size_guc_variables
Definition: guc.c:4574
static struct config_real ConfigureNamesReal[]
Definition: guc.c:3204
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 int num_guc_explain_variables
Definition: guc.c:4571
static struct config_string ConfigureNamesString[]
Definition: guc.c:3452
int i
#define qsort(a, b, c, d)
Definition: port.h:492
static void * guc_malloc(int elevel, size_t size)
Definition: guc.c:4609
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 6441 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().

6443 {
6444  const struct config_enum_entry *entry;
6445 
6446  for (entry = record->options; entry && entry->name; entry++)
6447  {
6448  if (pg_strcasecmp(value, entry->name) == 0)
6449  {
6450  *retval = entry->val;
6451  return true;
6452  }
6453  }
6454 
6455  *retval = 0;
6456  return false;
6457 }
Definition: guc.h:164
static struct @145 value
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
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 6418 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().

6419 {
6420  const struct config_enum_entry *entry;
6421 
6422  for (entry = record->options; entry && entry->name; entry++)
6423  {
6424  if (entry->val == val)
6425  return entry->name;
6426  }
6427 
6428  elog(ERROR, "could not find enum option %d for %s",
6429  val, record->gen.name);
6430  return NULL; /* silence compiler */
6431 }
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:226
long val
Definition: informix.c:684

◆ get_explain_guc_options()

struct config_generic** get_explain_guc_options ( int *  num)

Definition at line 8879 of file guc.c.

References Assert, 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().

8880 {
8881  int i;
8882  struct config_generic **result;
8883 
8884  *num = 0;
8885 
8886  /*
8887  * Allocate enough space to fit all GUC_EXPLAIN options. We may not need
8888  * all the space, but there are fairly few such options so we don't waste
8889  * a lot of memory.
8890  */
8891  result = palloc(sizeof(struct config_generic *) * num_guc_explain_variables);
8892 
8893  for (i = 0; i < num_guc_variables; i++)
8894  {
8895  bool modified;
8896  struct config_generic *conf = guc_variables[i];
8897 
8898  /* return only options visible to the user */
8899  if ((conf->flags & GUC_NO_SHOW_ALL) ||
8900  ((conf->flags & GUC_SUPERUSER_ONLY) &&
8901  !is_member_of_role(GetUserId(), DEFAULT_ROLE_READ_ALL_SETTINGS)))
8902  continue;
8903 
8904  /* only parameters explicitly marked for inclusion in explain */
8905  if (!(conf->flags & GUC_EXPLAIN))
8906  continue;
8907 
8908  /* return only options that were modified (w.r.t. config file) */
8909  modified = false;
8910 
8911  switch (conf->vartype)
8912  {
8913  case PGC_BOOL:
8914  {
8915  struct config_bool *lconf = (struct config_bool *) conf;
8916 
8917  modified = (lconf->boot_val != *(lconf->variable));
8918  }
8919  break;
8920 
8921  case PGC_INT:
8922  {
8923  struct config_int *lconf = (struct config_int *) conf;
8924 
8925  modified = (lconf->boot_val != *(lconf->variable));
8926  }
8927  break;
8928 
8929  case PGC_REAL:
8930  {
8931  struct config_real *lconf = (struct config_real *) conf;
8932 
8933  modified = (lconf->boot_val != *(lconf->variable));
8934  }
8935  break;
8936 
8937  case PGC_STRING:
8938  {
8939  struct config_string *lconf = (struct config_string *) conf;
8940 
8941  modified = (strcmp(lconf->boot_val, *(lconf->variable)) != 0);
8942  }
8943  break;
8944 
8945  case PGC_ENUM:
8946  {
8947  struct config_enum *lconf = (struct config_enum *) conf;
8948 
8949  modified = (lconf->boot_val != *(lconf->variable));
8950  }
8951  break;
8952 
8953  default:
8954  elog(ERROR, "unexpected GUC type: %d", conf->vartype);
8955  }
8956 
8957  /* skip GUC variables that match the built-in default */
8958  if (!modified)
8959  continue;
8960 
8961  /* assign to the values array */
8962  result[*num] = conf;
8963  *num = *num + 1;
8964 
8966  }
8967 
8968  return result;
8969 }
Oid GetUserId(void)
Definition: miscinit.c:380
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:4568
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:4565
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:4932
double boot_val
Definition: guc_tables.h:215
#define Assert(condition)
Definition: c.h:732
static int num_guc_explain_variables
Definition: guc.c:4571
void * palloc(Size size)
Definition: mcxt.c:949
#define elog(elevel,...)
Definition: elog.h:226
int i

◆ get_guc_variables()

struct config_generic** get_guc_variables ( void  )

Definition at line 4820 of file guc.c.

References guc_variables.

Referenced by GucInfoMain().

4821 {
4822  return guc_variables;
4823 }
static struct config_generic ** guc_variables
Definition: guc.c:4565

Variable Documentation

◆ config_group_names

const char* const config_group_names[]

Definition at line 631 of file guc.c.

Referenced by printMixedStruct().

◆ config_type_names

const char* const config_type_names[]

Definition at line 744 of file guc.c.

◆ GucContext_Names

const char* const GucContext_Names[]

Definition at line 594 of file guc.c.

Referenced by printMixedStruct().

◆ GucSource_Names

const char* const GucSource_Names[]

Definition at line 610 of file guc.c.