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 /* 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_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, 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_COLLECTOR, AUTOVACUUM,
  CLIENT_CONN_STATEMENT, CLIENT_CONN_LOCALE, CLIENT_CONN_PRELOAD, CLIENT_CONN_OTHER,
  LOCK_MANAGEMENT, 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 165 of file guc_tables.h.

◆ GUC_NEEDS_REPORT

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

◆ GUC_PENDING_RESTART

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

Definition at line 170 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_SETTINGS 
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 
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_COLLECTOR 
AUTOVACUUM 
CLIENT_CONN_STATEMENT 
CLIENT_CONN_LOCALE 
CLIENT_CONN_PRELOAD 
CLIENT_CONN_OTHER 
LOCK_MANAGEMENT 
COMPAT_OPTIONS_PREVIOUS 
COMPAT_OPTIONS_CLIENT 
ERROR_HANDLING_OPTIONS 
PRESET_OPTIONS 
CUSTOM_OPTIONS 
DEVELOPER_OPTIONS 

Definition at line 54 of file guc_tables.h.

55 {
56  UNGROUPED, /* use for options not shown in pg_settings */
87  AUTOVACUUM,
99 };

◆ 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 105 of file guc_tables.h.

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

Function Documentation

◆ build_guc_variables()

void build_guc_variables ( void  )

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

5266 {
5267  int size_vars;
5268  int num_vars = 0;
5269  struct config_generic **guc_vars;
5270  int i;
5271 
5272  for (i = 0; ConfigureNamesBool[i].gen.name; i++)
5273  {
5274  struct config_bool *conf = &ConfigureNamesBool[i];
5275 
5276  /* Rather than requiring vartype to be filled in by hand, do this: */
5277  conf->gen.vartype = PGC_BOOL;
5278  num_vars++;
5279  }
5280 
5281  for (i = 0; ConfigureNamesInt[i].gen.name; i++)
5282  {
5283  struct config_int *conf = &ConfigureNamesInt[i];
5284 
5285  conf->gen.vartype = PGC_INT;
5286  num_vars++;
5287  }
5288 
5289  for (i = 0; ConfigureNamesReal[i].gen.name; i++)
5290  {
5291  struct config_real *conf = &ConfigureNamesReal[i];
5292 
5293  conf->gen.vartype = PGC_REAL;
5294  num_vars++;
5295  }
5296 
5297  for (i = 0; ConfigureNamesString[i].gen.name; i++)
5298  {
5299  struct config_string *conf = &ConfigureNamesString[i];
5300 
5301  conf->gen.vartype = PGC_STRING;
5302  num_vars++;
5303  }
5304 
5305  for (i = 0; ConfigureNamesEnum[i].gen.name; i++)
5306  {
5307  struct config_enum *conf = &ConfigureNamesEnum[i];
5308 
5309  conf->gen.vartype = PGC_ENUM;
5310  num_vars++;
5311  }
5312 
5313  /*
5314  * Create table with 20% slack
5315  */
5316  size_vars = num_vars + num_vars / 4;
5317 
5318  guc_vars = (struct config_generic **)
5319  guc_malloc(FATAL, size_vars * sizeof(struct config_generic *));
5320 
5321  num_vars = 0;
5322 
5323  for (i = 0; ConfigureNamesBool[i].gen.name; i++)
5324  guc_vars[num_vars++] = &ConfigureNamesBool[i].gen;
5325 
5326  for (i = 0; ConfigureNamesInt[i].gen.name; i++)
5327  guc_vars[num_vars++] = &ConfigureNamesInt[i].gen;
5328 
5329  for (i = 0; ConfigureNamesReal[i].gen.name; i++)
5330  guc_vars[num_vars++] = &ConfigureNamesReal[i].gen;
5331 
5332  for (i = 0; ConfigureNamesString[i].gen.name; i++)
5333  guc_vars[num_vars++] = &ConfigureNamesString[i].gen;
5334 
5335  for (i = 0; ConfigureNamesEnum[i].gen.name; i++)
5336  guc_vars[num_vars++] = &ConfigureNamesEnum[i].gen;
5337 
5338  if (guc_variables)
5340  guc_variables = guc_vars;
5341  num_guc_variables = num_vars;
5342  size_guc_variables = size_vars;
5344  sizeof(struct config_generic *), guc_var_compare);
5345 }
static struct config_int ConfigureNamesInt[]
Definition: guc.c:2136
const char * name
Definition: guc_tables.h:142
static struct config_enum ConfigureNamesEnum[]
Definition: guc.c:4625
static struct config_bool ConfigureNamesBool[]
Definition: guc.c:940
static int guc_var_compare(const void *a, const void *b)
Definition: guc.c:5556
static int num_guc_variables
Definition: guc.c:5002
#define FATAL
Definition: elog.h:49
struct config_generic gen
Definition: guc_tables.h:178
struct config_generic gen
Definition: guc_tables.h:192
static struct config_generic ** guc_variables
Definition: guc.c:4999
enum config_type vartype
Definition: guc_tables.h:149
static int size_guc_variables
Definition: guc.c:5005
static struct config_real ConfigureNamesReal[]
Definition: guc.c:3577
struct config_generic gen
Definition: guc_tables.h:238
struct config_generic gen
Definition: guc_tables.h:224
#define free(a)
Definition: header.h:65
static struct config_string ConfigureNamesString[]
Definition: guc.c:3846
int i
#define qsort(a, b, c, d)
Definition: port.h:504
static void * guc_malloc(int elevel, size_t size)
Definition: guc.c:5042
struct config_generic gen
Definition: guc_tables.h:208

◆ config_enum_lookup_by_name()

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

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

7012 {
7013  const struct config_enum_entry *entry;
7014 
7015  for (entry = record->options; entry && entry->name; entry++)
7016  {
7017  if (pg_strcasecmp(value, entry->name) == 0)
7018  {
7019  *retval = entry->val;
7020  return true;
7021  }
7022  }
7023 
7024  *retval = 0;
7025  return false;
7026 }
static struct @142 value
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:242
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 6987 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().

6988 {
6989  const struct config_enum_entry *entry;
6990 
6991  for (entry = record->options; entry && entry->name; entry++)
6992  {
6993  if (entry->val == val)
6994  return entry->name;
6995  }
6996 
6997  elog(ERROR, "could not find enum option %d for %s",
6998  val, record->gen.name);
6999  return NULL; /* silence compiler */
7000 }
Definition: guc.h:164
const char * name
Definition: guc_tables.h:142
#define ERROR
Definition: elog.h:46
const struct config_enum_entry * options
Definition: guc_tables.h:242
int val
Definition: guc.h:167
struct config_generic gen
Definition: guc_tables.h:238
const char * name
Definition: guc.h:166
#define elog(elevel,...)
Definition: elog.h:232
long val
Definition: informix.c:664

◆ get_explain_guc_options()

struct config_generic** get_explain_guc_options ( int *  num)

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

9459 {
9460  struct config_generic **result;
9461 
9462  *num = 0;
9463 
9464  /*
9465  * While only a fraction of all the GUC variables are marked GUC_EXPLAIN,
9466  * it doesn't seem worth dynamically resizing this array.
9467  */
9468  result = palloc(sizeof(struct config_generic *) * num_guc_variables);
9469 
9470  for (int i = 0; i < num_guc_variables; i++)
9471  {
9472  bool modified;
9473  struct config_generic *conf = guc_variables[i];
9474 
9475  /* return only parameters marked for inclusion in explain */
9476  if (!(conf->flags & GUC_EXPLAIN))
9477  continue;
9478 
9479  /* return only options visible to the current user */
9480  if ((conf->flags & GUC_NO_SHOW_ALL) ||
9481  ((conf->flags & GUC_SUPERUSER_ONLY) &&
9482  !is_member_of_role(GetUserId(), ROLE_PG_READ_ALL_SETTINGS)))
9483  continue;
9484 
9485  /* return only options that are different from their boot values */
9486  modified = false;
9487 
9488  switch (conf->vartype)
9489  {
9490  case PGC_BOOL:
9491  {
9492  struct config_bool *lconf = (struct config_bool *) conf;
9493 
9494  modified = (lconf->boot_val != *(lconf->variable));
9495  }
9496  break;
9497 
9498  case PGC_INT:
9499  {
9500  struct config_int *lconf = (struct config_int *) conf;
9501 
9502  modified = (lconf->boot_val != *(lconf->variable));
9503  }
9504  break;
9505 
9506  case PGC_REAL:
9507  {
9508  struct config_real *lconf = (struct config_real *) conf;
9509 
9510  modified = (lconf->boot_val != *(lconf->variable));
9511  }
9512  break;
9513 
9514  case PGC_STRING:
9515  {
9516  struct config_string *lconf = (struct config_string *) conf;
9517 
9518  modified = (strcmp(lconf->boot_val, *(lconf->variable)) != 0);
9519  }
9520  break;
9521 
9522  case PGC_ENUM:
9523  {
9524  struct config_enum *lconf = (struct config_enum *) conf;
9525 
9526  modified = (lconf->boot_val != *(lconf->variable));
9527  }
9528  break;
9529 
9530  default:
9531  elog(ERROR, "unexpected GUC type: %d", conf->vartype);
9532  }
9533 
9534  if (!modified)
9535  continue;
9536 
9537  /* OK, report it */
9538  result[*num] = conf;
9539  *num = *num + 1;
9540  }
9541 
9542  return result;
9543 }
Oid GetUserId(void)
Definition: miscinit.c:478
char ** variable
Definition: guc_tables.h:226
bool * variable
Definition: guc_tables.h:180
int boot_val
Definition: guc_tables.h:195
const char * boot_val
Definition: guc_tables.h:227
#define GUC_NO_SHOW_ALL
Definition: guc.h:206
int * variable
Definition: guc_tables.h:194
int * variable
Definition: guc_tables.h:240
#define ERROR
Definition: elog.h:46
static int num_guc_variables
Definition: guc.c:5002
bool boot_val
Definition: guc_tables.h:181
#define GUC_EXPLAIN
Definition: guc.h:230
double * variable
Definition: guc_tables.h:210
static struct config_generic ** guc_variables
Definition: guc.c:4999
enum config_type vartype
Definition: guc_tables.h:149
#define GUC_SUPERUSER_ONLY
Definition: guc.h:212
bool is_member_of_role(Oid member, Oid role)
Definition: acl.c:4869
double boot_val
Definition: guc_tables.h:211
void * palloc(Size size)
Definition: mcxt.c:1062
#define elog(elevel,...)
Definition: elog.h:232
int i

◆ get_guc_variables()

struct config_generic** get_guc_variables ( void  )

Definition at line 5253 of file guc.c.

References guc_variables.

Referenced by GucInfoMain().

5254 {
5255  return guc_variables;
5256 }
static struct config_generic ** guc_variables
Definition: guc.c:4999

Variable Documentation

◆ config_group_names

const char* const config_group_names[]

Definition at line 700 of file guc.c.

Referenced by printMixedStruct().

◆ config_type_names

const char* const config_type_names[]

Definition at line 800 of file guc.c.

◆ GucContext_Names

const char* const GucContext_Names[]

Definition at line 657 of file guc.c.

Referenced by printMixedStruct().

◆ GucSource_Names

const char* const GucSource_Names[]

Definition at line 676 of file guc.c.