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 4885 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().

4886 {
4887  int size_vars;
4888  int num_vars = 0;
4889  int num_explain_vars = 0;
4890  struct config_generic **guc_vars;
4891  int i;
4892 
4893  for (i = 0; ConfigureNamesBool[i].gen.name; i++)
4894  {
4895  struct config_bool *conf = &ConfigureNamesBool[i];
4896 
4897  /* Rather than requiring vartype to be filled in by hand, do this: */
4898  conf->gen.vartype = PGC_BOOL;
4899  num_vars++;
4900 
4901  if (conf->gen.flags & GUC_EXPLAIN)
4902  num_explain_vars++;
4903  }
4904 
4905  for (i = 0; ConfigureNamesInt[i].gen.name; i++)
4906  {
4907  struct config_int *conf = &ConfigureNamesInt[i];
4908 
4909  conf->gen.vartype = PGC_INT;
4910  num_vars++;
4911 
4912  if (conf->gen.flags & GUC_EXPLAIN)
4913  num_explain_vars++;
4914  }
4915 
4916  for (i = 0; ConfigureNamesReal[i].gen.name; i++)
4917  {
4918  struct config_real *conf = &ConfigureNamesReal[i];
4919 
4920  conf->gen.vartype = PGC_REAL;
4921  num_vars++;
4922 
4923  if (conf->gen.flags & GUC_EXPLAIN)
4924  num_explain_vars++;
4925  }
4926 
4927  for (i = 0; ConfigureNamesString[i].gen.name; i++)
4928  {
4929  struct config_string *conf = &ConfigureNamesString[i];
4930 
4931  conf->gen.vartype = PGC_STRING;
4932  num_vars++;
4933 
4934  if (conf->gen.flags & GUC_EXPLAIN)
4935  num_explain_vars++;
4936  }
4937 
4938  for (i = 0; ConfigureNamesEnum[i].gen.name; i++)
4939  {
4940  struct config_enum *conf = &ConfigureNamesEnum[i];
4941 
4942  conf->gen.vartype = PGC_ENUM;
4943  num_vars++;
4944 
4945  if (conf->gen.flags & GUC_EXPLAIN)
4946  num_explain_vars++;
4947  }
4948 
4949  /*
4950  * Create table with 20% slack
4951  */
4952  size_vars = num_vars + num_vars / 4;
4953 
4954  guc_vars = (struct config_generic **)
4955  guc_malloc(FATAL, size_vars * sizeof(struct config_generic *));
4956 
4957  num_vars = 0;
4958 
4959  for (i = 0; ConfigureNamesBool[i].gen.name; i++)
4960  guc_vars[num_vars++] = &ConfigureNamesBool[i].gen;
4961 
4962  for (i = 0; ConfigureNamesInt[i].gen.name; i++)
4963  guc_vars[num_vars++] = &ConfigureNamesInt[i].gen;
4964 
4965  for (i = 0; ConfigureNamesReal[i].gen.name; i++)
4966  guc_vars[num_vars++] = &ConfigureNamesReal[i].gen;
4967 
4968  for (i = 0; ConfigureNamesString[i].gen.name; i++)
4969  guc_vars[num_vars++] = &ConfigureNamesString[i].gen;
4970 
4971  for (i = 0; ConfigureNamesEnum[i].gen.name; i++)
4972  guc_vars[num_vars++] = &ConfigureNamesEnum[i].gen;
4973 
4974  if (guc_variables)
4976  guc_variables = guc_vars;
4977  num_guc_variables = num_vars;
4978  num_guc_explain_variables = num_explain_vars;
4979  size_guc_variables = size_vars;
4981  sizeof(struct config_generic *), guc_var_compare);
4982 }
static struct config_int ConfigureNamesInt[]
Definition: guc.c:1969
const char * name
Definition: guc_tables.h:149
static struct config_enum ConfigureNamesEnum[]
Definition: guc.c:4262
static struct config_bool ConfigureNamesBool[]
Definition: guc.c:888
static int guc_var_compare(const void *a, const void *b)
Definition: guc.c:5124
static int num_guc_variables
Definition: guc.c:4621
#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:4618
enum config_type vartype
Definition: guc_tables.h:156
static int size_guc_variables
Definition: guc.c:4627
static struct config_real ConfigureNamesReal[]
Definition: guc.c:3236
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:4624
static struct config_string ConfigureNamesString[]
Definition: guc.c:3494
int i
#define qsort(a, b, c, d)
Definition: port.h:488
static void * guc_malloc(int elevel, size_t size)
Definition: guc.c:4662
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 6494 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().

6496 {
6497  const struct config_enum_entry *entry;
6498 
6499  for (entry = record->options; entry && entry->name; entry++)
6500  {
6501  if (pg_strcasecmp(value, entry->name) == 0)
6502  {
6503  *retval = entry->val;
6504  return true;
6505  }
6506  }
6507 
6508  *retval = 0;
6509  return false;
6510 }
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 6471 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().

6472 {
6473  const struct config_enum_entry *entry;
6474 
6475  for (entry = record->options; entry && entry->name; entry++)
6476  {
6477  if (entry->val == val)
6478  return entry->name;
6479  }
6480 
6481  elog(ERROR, "could not find enum option %d for %s",
6482  val, record->gen.name);
6483  return NULL; /* silence compiler */
6484 }
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:228
long val
Definition: informix.c:664

◆ get_explain_guc_options()

struct config_generic** get_explain_guc_options ( int *  num)

Definition at line 8932 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().

8933 {
8934  int i;
8935  struct config_generic **result;
8936 
8937  *num = 0;
8938 
8939  /*
8940  * Allocate enough space to fit all GUC_EXPLAIN options. We may not need
8941  * all the space, but there are fairly few such options so we don't waste
8942  * a lot of memory.
8943  */
8944  result = palloc(sizeof(struct config_generic *) * num_guc_explain_variables);
8945 
8946  for (i = 0; i < num_guc_variables; i++)
8947  {
8948  bool modified;
8949  struct config_generic *conf = guc_variables[i];
8950 
8951  /* return only options visible to the user */
8952  if ((conf->flags & GUC_NO_SHOW_ALL) ||
8953  ((conf->flags & GUC_SUPERUSER_ONLY) &&
8954  !is_member_of_role(GetUserId(), DEFAULT_ROLE_READ_ALL_SETTINGS)))
8955  continue;
8956 
8957  /* only parameters explicitly marked for inclusion in explain */
8958  if (!(conf->flags & GUC_EXPLAIN))
8959  continue;
8960 
8961  /* return only options that were modified (w.r.t. config file) */
8962  modified = false;
8963 
8964  switch (conf->vartype)
8965  {
8966  case PGC_BOOL:
8967  {
8968  struct config_bool *lconf = (struct config_bool *) conf;
8969 
8970  modified = (lconf->boot_val != *(lconf->variable));
8971  }
8972  break;
8973 
8974  case PGC_INT:
8975  {
8976  struct config_int *lconf = (struct config_int *) conf;
8977 
8978  modified = (lconf->boot_val != *(lconf->variable));
8979  }
8980  break;
8981 
8982  case PGC_REAL:
8983  {
8984  struct config_real *lconf = (struct config_real *) conf;
8985 
8986  modified = (lconf->boot_val != *(lconf->variable));
8987  }
8988  break;
8989 
8990  case PGC_STRING:
8991  {
8992  struct config_string *lconf = (struct config_string *) conf;
8993 
8994  modified = (strcmp(lconf->boot_val, *(lconf->variable)) != 0);
8995  }
8996  break;
8997 
8998  case PGC_ENUM:
8999  {
9000  struct config_enum *lconf = (struct config_enum *) conf;
9001 
9002  modified = (lconf->boot_val != *(lconf->variable));
9003  }
9004  break;
9005 
9006  default:
9007  elog(ERROR, "unexpected GUC type: %d", conf->vartype);
9008  }
9009 
9010  /* skip GUC variables that match the built-in default */
9011  if (!modified)
9012  continue;
9013 
9014  /* assign to the values array */
9015  result[*num] = conf;
9016  *num = *num + 1;
9017 
9019  }
9020 
9021  return result;
9022 }
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:4621
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:4618
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:4924
double boot_val
Definition: guc_tables.h:215
#define Assert(condition)
Definition: c.h:739
static int num_guc_explain_variables
Definition: guc.c:4624
void * palloc(Size size)
Definition: mcxt.c:949
#define elog(elevel,...)
Definition: elog.h:228
int i

◆ get_guc_variables()

struct config_generic** get_guc_variables ( void  )

Definition at line 4873 of file guc.c.

References guc_variables.

Referenced by GucInfoMain().

4874 {
4875  return guc_variables;
4876 }
static struct config_generic ** guc_variables
Definition: guc.c:4618

Variable Documentation

◆ config_group_names

const char* const config_group_names[]

Definition at line 638 of file guc.c.

Referenced by printMixedStruct().

◆ config_type_names

const char* const config_type_names[]

Definition at line 751 of file guc.c.

◆ GucContext_Names

const char* const GucContext_Names[]

Definition at line 601 of file guc.c.

Referenced by printMixedStruct().

◆ GucSource_Names

const char* const GucSource_Names[]

Definition at line 617 of file guc.c.