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_CUMULATIVE , 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

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 []
 

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 */

Definition at line 171 of file guc_tables.h.

◆ GUC_PENDING_RESTART

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

Definition at line 170 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_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_CUMULATIVE 
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 };
@ RESOURCES_KERNEL
Definition: guc_tables.h:63
@ CLIENT_CONN_LOCALE
Definition: guc_tables.h:89
@ WAL_ARCHIVE_RECOVERY
Definition: guc_tables.h:71
@ STATS_CUMULATIVE
Definition: guc_tables.h:86
@ AUTOVACUUM
Definition: guc_tables.h:87
@ CLIENT_CONN_PRELOAD
Definition: guc_tables.h:90
@ QUERY_TUNING_OTHER
Definition: guc_tables.h:80
@ LOGGING_WHERE
Definition: guc_tables.h:81
@ CONN_AUTH_AUTH
Definition: guc_tables.h:59
@ ERROR_HANDLING_OPTIONS
Definition: guc_tables.h:95
@ PROCESS_TITLE
Definition: guc_tables.h:84
@ RESOURCES_DISK
Definition: guc_tables.h:62
@ REPLICATION_SENDING
Definition: guc_tables.h:73
@ LOCK_MANAGEMENT
Definition: guc_tables.h:92
@ CUSTOM_OPTIONS
Definition: guc_tables.h:97
@ REPLICATION_PRIMARY
Definition: guc_tables.h:74
@ STATS_MONITORING
Definition: guc_tables.h:85
@ WAL_RECOVERY_TARGET
Definition: guc_tables.h:72
@ WAL_RECOVERY
Definition: guc_tables.h:70
@ CONN_AUTH_SSL
Definition: guc_tables.h:60
@ RESOURCES_MEM
Definition: guc_tables.h:61
@ RESOURCES_BGWRITER
Definition: guc_tables.h:65
@ PRESET_OPTIONS
Definition: guc_tables.h:96
@ DEVELOPER_OPTIONS
Definition: guc_tables.h:98
@ RESOURCES_VACUUM_DELAY
Definition: guc_tables.h:64
@ QUERY_TUNING_METHOD
Definition: guc_tables.h:77
@ LOGGING_WHAT
Definition: guc_tables.h:83
@ RESOURCES_ASYNCHRONOUS
Definition: guc_tables.h:66
@ QUERY_TUNING_GEQO
Definition: guc_tables.h:79
@ WAL_SETTINGS
Definition: guc_tables.h:67
@ CLIENT_CONN_STATEMENT
Definition: guc_tables.h:88
@ FILE_LOCATIONS
Definition: guc_tables.h:57
@ COMPAT_OPTIONS_CLIENT
Definition: guc_tables.h:94
@ REPLICATION_STANDBY
Definition: guc_tables.h:75
@ QUERY_TUNING_COST
Definition: guc_tables.h:78
@ WAL_ARCHIVING
Definition: guc_tables.h:69
@ COMPAT_OPTIONS_PREVIOUS
Definition: guc_tables.h:93
@ WAL_CHECKPOINTS
Definition: guc_tables.h:68
@ CLIENT_CONN_OTHER
Definition: guc_tables.h:91
@ LOGGING_WHEN
Definition: guc_tables.h:82
@ REPLICATION_SUBSCRIBERS
Definition: guc_tables.h:76
@ CONN_AUTH_SETTINGS
Definition: guc_tables.h:58
@ UNGROUPED
Definition: guc_tables.h:56

◆ 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 };
@ PGC_BOOL
Definition: guc_tables.h:24
@ PGC_STRING
Definition: guc_tables.h:27
@ PGC_ENUM
Definition: guc_tables.h:28
@ PGC_REAL
Definition: guc_tables.h:26
@ PGC_INT
Definition: guc_tables.h:25

◆ 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:106
@ GUC_SET_LOCAL
Definition: guc_tables.h:111
@ GUC_SET
Definition: guc_tables.h:109
@ GUC_SAVE
Definition: guc_tables.h:108
@ GUC_LOCAL
Definition: guc_tables.h:110

Function Documentation

◆ build_guc_variables()

void build_guc_variables ( void  )

Definition at line 5413 of file guc.c.

5414 {
5415  int size_vars;
5416  int num_vars = 0;
5417  struct config_generic **guc_vars;
5418  int i;
5419 
5420  for (i = 0; ConfigureNamesBool[i].gen.name; i++)
5421  {
5422  struct config_bool *conf = &ConfigureNamesBool[i];
5423 
5424  /* Rather than requiring vartype to be filled in by hand, do this: */
5425  conf->gen.vartype = PGC_BOOL;
5426  num_vars++;
5427  }
5428 
5429  for (i = 0; ConfigureNamesInt[i].gen.name; i++)
5430  {
5431  struct config_int *conf = &ConfigureNamesInt[i];
5432 
5433  conf->gen.vartype = PGC_INT;
5434  num_vars++;
5435  }
5436 
5437  for (i = 0; ConfigureNamesReal[i].gen.name; i++)
5438  {
5439  struct config_real *conf = &ConfigureNamesReal[i];
5440 
5441  conf->gen.vartype = PGC_REAL;
5442  num_vars++;
5443  }
5444 
5445  for (i = 0; ConfigureNamesString[i].gen.name; i++)
5446  {
5447  struct config_string *conf = &ConfigureNamesString[i];
5448 
5449  conf->gen.vartype = PGC_STRING;
5450  num_vars++;
5451  }
5452 
5453  for (i = 0; ConfigureNamesEnum[i].gen.name; i++)
5454  {
5455  struct config_enum *conf = &ConfigureNamesEnum[i];
5456 
5457  conf->gen.vartype = PGC_ENUM;
5458  num_vars++;
5459  }
5460 
5461  /*
5462  * Create table with 20% slack
5463  */
5464  size_vars = num_vars + num_vars / 4;
5465 
5466  guc_vars = (struct config_generic **)
5467  guc_malloc(FATAL, size_vars * sizeof(struct config_generic *));
5468 
5469  num_vars = 0;
5470 
5471  for (i = 0; ConfigureNamesBool[i].gen.name; i++)
5472  guc_vars[num_vars++] = &ConfigureNamesBool[i].gen;
5473 
5474  for (i = 0; ConfigureNamesInt[i].gen.name; i++)
5475  guc_vars[num_vars++] = &ConfigureNamesInt[i].gen;
5476 
5477  for (i = 0; ConfigureNamesReal[i].gen.name; i++)
5478  guc_vars[num_vars++] = &ConfigureNamesReal[i].gen;
5479 
5480  for (i = 0; ConfigureNamesString[i].gen.name; i++)
5481  guc_vars[num_vars++] = &ConfigureNamesString[i].gen;
5482 
5483  for (i = 0; ConfigureNamesEnum[i].gen.name; i++)
5484  guc_vars[num_vars++] = &ConfigureNamesEnum[i].gen;
5485 
5486  if (guc_variables)
5488  guc_variables = guc_vars;
5489  num_guc_variables = num_vars;
5490  size_guc_variables = size_vars;
5492  sizeof(struct config_generic *), guc_var_compare);
5493 }
#define FATAL
Definition: elog.h:35
static struct config_generic ** guc_variables
Definition: guc.c:5147
static void * guc_malloc(int elevel, size_t size)
Definition: guc.c:5190
static struct config_string ConfigureNamesString[]
Definition: guc.c:3953
static int guc_var_compare(const void *a, const void *b)
Definition: guc.c:5731
static int num_guc_variables
Definition: guc.c:5150
static int size_guc_variables
Definition: guc.c:5153
static struct config_int ConfigureNamesInt[]
Definition: guc.c:2192
static struct config_bool ConfigureNamesBool[]
Definition: guc.c:1013
static struct config_real ConfigureNamesReal[]
Definition: guc.c:3672
static struct config_enum ConfigureNamesEnum[]
Definition: guc.c:4731
#define free(a)
Definition: header.h:65
int i
Definition: isn.c:73
#define qsort(a, b, c, d)
Definition: port.h:495
struct config_generic gen
Definition: guc_tables.h:178
struct config_generic gen
Definition: guc_tables.h:238
const char * name
Definition: guc_tables.h:142
enum config_type vartype
Definition: guc_tables.h:149
struct config_generic gen
Definition: guc_tables.h:192
struct config_generic gen
Definition: guc_tables.h:208
struct config_generic gen
Definition: guc_tables.h:224

References ConfigureNamesBool, ConfigureNamesEnum, ConfigureNamesInt, ConfigureNamesReal, ConfigureNamesString, FATAL, free, config_bool::gen, config_int::gen, config_real::gen, config_string::gen, config_enum::gen, guc_malloc(), guc_var_compare(), guc_variables, i, config_generic::name, num_guc_variables, PGC_BOOL, PGC_ENUM, PGC_INT, PGC_REAL, PGC_STRING, qsort, size_guc_variables, and config_generic::vartype.

Referenced by GucInfoMain(), and InitializeGUCOptions().

◆ config_enum_lookup_by_name()

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

Definition at line 7279 of file guc.c.

7281 {
7282  const struct config_enum_entry *entry;
7283 
7284  for (entry = record->options; entry && entry->name; entry++)
7285  {
7286  if (pg_strcasecmp(value, entry->name) == 0)
7287  {
7288  *retval = entry->val;
7289  return true;
7290  }
7291  }
7292 
7293  *retval = 0;
7294  return false;
7295 }
static struct @151 value
int pg_strcasecmp(const char *s1, const char *s2)
Definition: pgstrcasecmp.c:36
Definition: guc.h:169
const char * name
Definition: guc.h:170
int val
Definition: guc.h:171
const struct config_enum_entry * options
Definition: guc_tables.h:242

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

7257 {
7258  const struct config_enum_entry *entry;
7259 
7260  for (entry = record->options; entry && entry->name; entry++)
7261  {
7262  if (entry->val == val)
7263  return entry->name;
7264  }
7265 
7266  elog(ERROR, "could not find enum option %d for %s",
7267  val, record->gen.name);
7268  return NULL; /* silence compiler */
7269 }
#define ERROR
Definition: elog.h:33
#define elog(elevel,...)
Definition: elog.h:218
long val
Definition: informix.c:664

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

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

◆ get_explain_guc_options()

struct config_generic** get_explain_guc_options ( int *  num)

Definition at line 9824 of file guc.c.

9825 {
9826  struct config_generic **result;
9827 
9828  *num = 0;
9829 
9830  /*
9831  * While only a fraction of all the GUC variables are marked GUC_EXPLAIN,
9832  * it doesn't seem worth dynamically resizing this array.
9833  */
9834  result = palloc(sizeof(struct config_generic *) * num_guc_variables);
9835 
9836  for (int i = 0; i < num_guc_variables; i++)
9837  {
9838  bool modified;
9839  struct config_generic *conf = guc_variables[i];
9840 
9841  /* return only parameters marked for inclusion in explain */
9842  if (!(conf->flags & GUC_EXPLAIN))
9843  continue;
9844 
9845  /* return only options visible to the current user */
9846  if ((conf->flags & GUC_NO_SHOW_ALL) ||
9847  ((conf->flags & GUC_SUPERUSER_ONLY) &&
9848  !has_privs_of_role(GetUserId(), ROLE_PG_READ_ALL_SETTINGS)))
9849  continue;
9850 
9851  /* return only options that are different from their boot values */
9852  modified = false;
9853 
9854  switch (conf->vartype)
9855  {
9856  case PGC_BOOL:
9857  {
9858  struct config_bool *lconf = (struct config_bool *) conf;
9859 
9860  modified = (lconf->boot_val != *(lconf->variable));
9861  }
9862  break;
9863 
9864  case PGC_INT:
9865  {
9866  struct config_int *lconf = (struct config_int *) conf;
9867 
9868  modified = (lconf->boot_val != *(lconf->variable));
9869  }
9870  break;
9871 
9872  case PGC_REAL:
9873  {
9874  struct config_real *lconf = (struct config_real *) conf;
9875 
9876  modified = (lconf->boot_val != *(lconf->variable));
9877  }
9878  break;
9879 
9880  case PGC_STRING:
9881  {
9882  struct config_string *lconf = (struct config_string *) conf;
9883 
9884  modified = (strcmp(lconf->boot_val, *(lconf->variable)) != 0);
9885  }
9886  break;
9887 
9888  case PGC_ENUM:
9889  {
9890  struct config_enum *lconf = (struct config_enum *) conf;
9891 
9892  modified = (lconf->boot_val != *(lconf->variable));
9893  }
9894  break;
9895 
9896  default:
9897  elog(ERROR, "unexpected GUC type: %d", conf->vartype);
9898  }
9899 
9900  if (!modified)
9901  continue;
9902 
9903  /* OK, report it */
9904  result[*num] = conf;
9905  *num = *num + 1;
9906  }
9907 
9908  return result;
9909 }
bool has_privs_of_role(Oid member, Oid role)
Definition: acl.c:4951
#define GUC_EXPLAIN
Definition: guc.h:233
#define GUC_SUPERUSER_ONLY
Definition: guc.h:216
#define GUC_NO_SHOW_ALL
Definition: guc.h:210
void * palloc(Size size)
Definition: mcxt.c:1068
Oid GetUserId(void)
Definition: miscinit.c:492
bool * variable
Definition: guc_tables.h:180
bool boot_val
Definition: guc_tables.h:181
int * variable
Definition: guc_tables.h:240
int boot_val
Definition: guc_tables.h:195
int * variable
Definition: guc_tables.h:194
double boot_val
Definition: guc_tables.h:211
double * variable
Definition: guc_tables.h:210
char ** variable
Definition: guc_tables.h:226
const char * boot_val
Definition: guc_tables.h:227

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, guc_variables, has_privs_of_role(), i, 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().

◆ get_guc_variables()

struct config_generic** get_guc_variables ( void  )

Definition at line 5401 of file guc.c.

5402 {
5403  return guc_variables;
5404 }

References guc_variables.

Referenced by GucInfoMain().

Variable Documentation

◆ config_group_names

PGDLLIMPORT const char* const config_group_names[]
extern

Definition at line 773 of file guc.c.

Referenced by GetConfigOptionByNum().

◆ config_type_names

PGDLLIMPORT const char* const config_type_names[]
extern

Definition at line 873 of file guc.c.

Referenced by GetConfigOptionByNum().

◆ GucContext_Names

PGDLLIMPORT const char* const GucContext_Names[]
extern

Definition at line 730 of file guc.c.

Referenced by GetConfigOptionByNum().

◆ GucSource_Names

PGDLLIMPORT const char* const GucSource_Names[]
extern

Definition at line 749 of file guc.c.

Referenced by GetConfigOptionByNum().