PostgreSQL Source Code  git master
guc_tables.h File Reference
#include "lib/ilist.h"
#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_TCP ,
  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_genericfind_option (const char *name, bool create_placeholders, bool skip_errors, int elevel)
 
struct config_generic ** get_explain_guc_options (int *num)
 
char * ShowGUCOption (struct config_generic *record, bool use_units)
 
bool ConfigOptionIsVisible (struct config_generic *conf)
 
struct config_generic ** get_guc_variables (int *num_vars)
 
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)
 
char * config_enum_get_options (struct config_enum *record, const char *prefix, const char *suffix, const char *separator)
 

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 []
 
PGDLLIMPORT struct config_bool ConfigureNamesBool []
 
PGDLLIMPORT struct config_int ConfigureNamesInt []
 
PGDLLIMPORT struct config_real ConfigureNamesReal []
 
PGDLLIMPORT struct config_string ConfigureNamesString []
 
PGDLLIMPORT struct config_enum ConfigureNamesEnum []
 

Macro Definition Documentation

◆ GUC_IS_IN_FILE

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

Definition at line 186 of file guc_tables.h.

◆ GUC_NEEDS_REPORT

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

Definition at line 192 of file guc_tables.h.

◆ GUC_PENDING_RESTART

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

Definition at line 191 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_TCP 
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 55 of file guc_tables.h.

56 {
57  UNGROUPED, /* use for options not shown in pg_settings */
89  AUTOVACUUM,
101 };
@ RESOURCES_KERNEL
Definition: guc_tables.h:65
@ CLIENT_CONN_LOCALE
Definition: guc_tables.h:91
@ WAL_ARCHIVE_RECOVERY
Definition: guc_tables.h:73
@ STATS_CUMULATIVE
Definition: guc_tables.h:88
@ AUTOVACUUM
Definition: guc_tables.h:89
@ CLIENT_CONN_PRELOAD
Definition: guc_tables.h:92
@ QUERY_TUNING_OTHER
Definition: guc_tables.h:82
@ LOGGING_WHERE
Definition: guc_tables.h:83
@ CONN_AUTH_AUTH
Definition: guc_tables.h:61
@ ERROR_HANDLING_OPTIONS
Definition: guc_tables.h:97
@ PROCESS_TITLE
Definition: guc_tables.h:86
@ RESOURCES_DISK
Definition: guc_tables.h:64
@ REPLICATION_SENDING
Definition: guc_tables.h:75
@ LOCK_MANAGEMENT
Definition: guc_tables.h:94
@ CUSTOM_OPTIONS
Definition: guc_tables.h:99
@ REPLICATION_PRIMARY
Definition: guc_tables.h:76
@ STATS_MONITORING
Definition: guc_tables.h:87
@ WAL_RECOVERY_TARGET
Definition: guc_tables.h:74
@ WAL_RECOVERY
Definition: guc_tables.h:72
@ CONN_AUTH_SSL
Definition: guc_tables.h:62
@ RESOURCES_MEM
Definition: guc_tables.h:63
@ RESOURCES_BGWRITER
Definition: guc_tables.h:67
@ PRESET_OPTIONS
Definition: guc_tables.h:98
@ DEVELOPER_OPTIONS
Definition: guc_tables.h:100
@ RESOURCES_VACUUM_DELAY
Definition: guc_tables.h:66
@ QUERY_TUNING_METHOD
Definition: guc_tables.h:79
@ LOGGING_WHAT
Definition: guc_tables.h:85
@ RESOURCES_ASYNCHRONOUS
Definition: guc_tables.h:68
@ QUERY_TUNING_GEQO
Definition: guc_tables.h:81
@ WAL_SETTINGS
Definition: guc_tables.h:69
@ CLIENT_CONN_STATEMENT
Definition: guc_tables.h:90
@ FILE_LOCATIONS
Definition: guc_tables.h:58
@ COMPAT_OPTIONS_CLIENT
Definition: guc_tables.h:96
@ REPLICATION_STANDBY
Definition: guc_tables.h:77
@ QUERY_TUNING_COST
Definition: guc_tables.h:80
@ WAL_ARCHIVING
Definition: guc_tables.h:71
@ COMPAT_OPTIONS_PREVIOUS
Definition: guc_tables.h:95
@ WAL_CHECKPOINTS
Definition: guc_tables.h:70
@ CLIENT_CONN_OTHER
Definition: guc_tables.h:93
@ LOGGING_WHEN
Definition: guc_tables.h:84
@ CONN_AUTH_TCP
Definition: guc_tables.h:60
@ REPLICATION_SUBSCRIBERS
Definition: guc_tables.h:78
@ CONN_AUTH_SETTINGS
Definition: guc_tables.h:59
@ UNGROUPED
Definition: guc_tables.h:57

◆ config_type

Enumerator
PGC_BOOL 
PGC_INT 
PGC_REAL 
PGC_STRING 
PGC_ENUM 

Definition at line 23 of file guc_tables.h.

24 {
25  PGC_BOOL,
26  PGC_INT,
27  PGC_REAL,
28  PGC_STRING,
29  PGC_ENUM
30 };
@ PGC_BOOL
Definition: guc_tables.h:25
@ PGC_STRING
Definition: guc_tables.h:28
@ PGC_ENUM
Definition: guc_tables.h:29
@ PGC_REAL
Definition: guc_tables.h:27
@ PGC_INT
Definition: guc_tables.h:26

◆ GucStackState

Enumerator
GUC_SAVE 
GUC_SET 
GUC_LOCAL 
GUC_SET_LOCAL 

Definition at line 107 of file guc_tables.h.

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

Function Documentation

◆ build_guc_variables()

void build_guc_variables ( void  )

Definition at line 895 of file guc.c.

896 {
897  int size_vars;
898  int num_vars = 0;
899  HASHCTL hash_ctl;
900  GUCHashEntry *hentry;
901  bool found;
902  int i;
903 
904  /*
905  * Create the memory context that will hold all GUC-related data.
906  */
907  Assert(GUCMemoryContext == NULL);
909  "GUCMemoryContext",
911 
912  /*
913  * Count all the built-in variables, and set their vartypes correctly.
914  */
915  for (i = 0; ConfigureNamesBool[i].gen.name; i++)
916  {
917  struct config_bool *conf = &ConfigureNamesBool[i];
918 
919  /* Rather than requiring vartype to be filled in by hand, do this: */
920  conf->gen.vartype = PGC_BOOL;
921  num_vars++;
922  }
923 
924  for (i = 0; ConfigureNamesInt[i].gen.name; i++)
925  {
926  struct config_int *conf = &ConfigureNamesInt[i];
927 
928  conf->gen.vartype = PGC_INT;
929  num_vars++;
930  }
931 
932  for (i = 0; ConfigureNamesReal[i].gen.name; i++)
933  {
934  struct config_real *conf = &ConfigureNamesReal[i];
935 
936  conf->gen.vartype = PGC_REAL;
937  num_vars++;
938  }
939 
940  for (i = 0; ConfigureNamesString[i].gen.name; i++)
941  {
942  struct config_string *conf = &ConfigureNamesString[i];
943 
944  conf->gen.vartype = PGC_STRING;
945  num_vars++;
946  }
947 
948  for (i = 0; ConfigureNamesEnum[i].gen.name; i++)
949  {
950  struct config_enum *conf = &ConfigureNamesEnum[i];
951 
952  conf->gen.vartype = PGC_ENUM;
953  num_vars++;
954  }
955 
956  /*
957  * Create hash table with 20% slack
958  */
959  size_vars = num_vars + num_vars / 4;
960 
961  hash_ctl.keysize = sizeof(char *);
962  hash_ctl.entrysize = sizeof(GUCHashEntry);
963  hash_ctl.hash = guc_name_hash;
964  hash_ctl.match = guc_name_match;
965  hash_ctl.hcxt = GUCMemoryContext;
966  guc_hashtab = hash_create("GUC hash table",
967  size_vars,
968  &hash_ctl,
970 
971  for (i = 0; ConfigureNamesBool[i].gen.name; i++)
972  {
973  struct config_generic *gucvar = &ConfigureNamesBool[i].gen;
974 
975  hentry = (GUCHashEntry *) hash_search(guc_hashtab,
976  &gucvar->name,
977  HASH_ENTER,
978  &found);
979  Assert(!found);
980  hentry->gucvar = gucvar;
981  }
982 
983  for (i = 0; ConfigureNamesInt[i].gen.name; i++)
984  {
985  struct config_generic *gucvar = &ConfigureNamesInt[i].gen;
986 
987  hentry = (GUCHashEntry *) hash_search(guc_hashtab,
988  &gucvar->name,
989  HASH_ENTER,
990  &found);
991  Assert(!found);
992  hentry->gucvar = gucvar;
993  }
994 
995  for (i = 0; ConfigureNamesReal[i].gen.name; i++)
996  {
997  struct config_generic *gucvar = &ConfigureNamesReal[i].gen;
998 
999  hentry = (GUCHashEntry *) hash_search(guc_hashtab,
1000  &gucvar->name,
1001  HASH_ENTER,
1002  &found);
1003  Assert(!found);
1004  hentry->gucvar = gucvar;
1005  }
1006 
1007  for (i = 0; ConfigureNamesString[i].gen.name; i++)
1008  {
1009  struct config_generic *gucvar = &ConfigureNamesString[i].gen;
1010 
1011  hentry = (GUCHashEntry *) hash_search(guc_hashtab,
1012  &gucvar->name,
1013  HASH_ENTER,
1014  &found);
1015  Assert(!found);
1016  hentry->gucvar = gucvar;
1017  }
1018 
1019  for (i = 0; ConfigureNamesEnum[i].gen.name; i++)
1020  {
1021  struct config_generic *gucvar = &ConfigureNamesEnum[i].gen;
1022 
1023  hentry = (GUCHashEntry *) hash_search(guc_hashtab,
1024  &gucvar->name,
1025  HASH_ENTER,
1026  &found);
1027  Assert(!found);
1028  hentry->gucvar = gucvar;
1029  }
1030 
1031  Assert(num_vars == hash_get_num_entries(guc_hashtab));
1032 }
void * hash_search(HTAB *hashp, const void *keyPtr, HASHACTION action, bool *foundPtr)
Definition: dynahash.c:953
HTAB * hash_create(const char *tabname, long nelem, const HASHCTL *info, int flags)
Definition: dynahash.c:350
long hash_get_num_entries(HTAB *hashp)
Definition: dynahash.c:1377
static int guc_name_match(const void *key1, const void *key2, Size keysize)
Definition: guc.c:1318
static uint32 guc_name_hash(const void *key, Size keysize)
Definition: guc.c:1294
static HTAB * guc_hashtab
Definition: guc.c:207
static MemoryContext GUCMemoryContext
Definition: guc.c:194
struct config_string ConfigureNamesString[]
Definition: guc_tables.c:3758
struct config_int ConfigureNamesInt[]
Definition: guc_tables.c:1982
struct config_bool ConfigureNamesBool[]
Definition: guc_tables.c:786
struct config_real ConfigureNamesReal[]
Definition: guc_tables.c:3477
struct config_enum ConfigureNamesEnum[]
Definition: guc_tables.c:4534
@ HASH_ENTER
Definition: hsearch.h:114
#define HASH_CONTEXT
Definition: hsearch.h:102
#define HASH_ELEM
Definition: hsearch.h:95
#define HASH_COMPARE
Definition: hsearch.h:99
#define HASH_FUNCTION
Definition: hsearch.h:98
int i
Definition: isn.c:73
Assert(fmt[strlen(fmt) - 1] !='\n')
MemoryContext TopMemoryContext
Definition: mcxt.c:141
#define AllocSetContextCreate
Definition: memutils.h:129
#define ALLOCSET_DEFAULT_SIZES
Definition: memutils.h:153
struct config_generic * gucvar
Definition: guc.c:204
Size keysize
Definition: hsearch.h:75
HashValueFunc hash
Definition: hsearch.h:78
Size entrysize
Definition: hsearch.h:76
HashCompareFunc match
Definition: hsearch.h:80
MemoryContext hcxt
Definition: hsearch.h:86
struct config_generic gen
Definition: guc_tables.h:199
struct config_generic gen
Definition: guc_tables.h:259
const char * name
Definition: guc_tables.h:155
enum config_type vartype
Definition: guc_tables.h:162
struct config_generic gen
Definition: guc_tables.h:213
struct config_generic gen
Definition: guc_tables.h:229
struct config_generic gen
Definition: guc_tables.h:245

References ALLOCSET_DEFAULT_SIZES, AllocSetContextCreate, Assert(), ConfigureNamesBool, ConfigureNamesEnum, ConfigureNamesInt, ConfigureNamesReal, ConfigureNamesString, HASHCTL::entrysize, config_bool::gen, config_int::gen, config_real::gen, config_string::gen, config_enum::gen, guc_hashtab, guc_name_hash(), guc_name_match(), GUCMemoryContext, GUCHashEntry::gucvar, HASHCTL::hash, HASH_COMPARE, HASH_CONTEXT, hash_create(), HASH_ELEM, HASH_ENTER, HASH_FUNCTION, hash_get_num_entries(), hash_search(), HASHCTL::hcxt, i, HASHCTL::keysize, HASHCTL::match, config_generic::name, PGC_BOOL, PGC_ENUM, PGC_INT, PGC_REAL, PGC_STRING, TopMemoryContext, and config_generic::vartype.

Referenced by GucInfoMain(), and InitializeGUCOptions().

◆ config_enum_get_options()

char* config_enum_get_options ( struct config_enum record,
const char *  prefix,
const char *  suffix,
const char *  separator 
)

Definition at line 3024 of file guc.c.

3026 {
3027  const struct config_enum_entry *entry;
3028  StringInfoData retstr;
3029  int seplen;
3030 
3031  initStringInfo(&retstr);
3032  appendStringInfoString(&retstr, prefix);
3033 
3034  seplen = strlen(separator);
3035  for (entry = record->options; entry && entry->name; entry++)
3036  {
3037  if (!entry->hidden)
3038  {
3039  appendStringInfoString(&retstr, entry->name);
3040  appendBinaryStringInfo(&retstr, separator, seplen);
3041  }
3042  }
3043 
3044  /*
3045  * All the entries may have been hidden, leaving the string empty if no
3046  * prefix was given. This indicates a broken GUC setup, since there is no
3047  * use for an enum without any values, so we just check to make sure we
3048  * don't write to invalid memory instead of actually trying to do
3049  * something smart with it.
3050  */
3051  if (retstr.len >= seplen)
3052  {
3053  /* Replace final separator */
3054  retstr.data[retstr.len - seplen] = '\0';
3055  retstr.len -= seplen;
3056  }
3057 
3058  appendStringInfoString(&retstr, suffix);
3059 
3060  return retstr.data;
3061 }
void appendBinaryStringInfo(StringInfo str, const void *data, int datalen)
Definition: stringinfo.c:227
void appendStringInfoString(StringInfo str, const char *s)
Definition: stringinfo.c:176
void initStringInfo(StringInfo str)
Definition: stringinfo.c:59
Definition: guc.h:168
const char * name
Definition: guc.h:169
bool hidden
Definition: guc.h:171
const struct config_enum_entry * options
Definition: guc_tables.h:263

References appendBinaryStringInfo(), appendStringInfoString(), StringInfoData::data, config_enum_entry::hidden, initStringInfo(), StringInfoData::len, config_enum_entry::name, and config_enum::options.

Referenced by GetConfigOptionValues(), and parse_and_validate_value().

◆ config_enum_lookup_by_name()

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

Definition at line 2998 of file guc.c.

3000 {
3001  const struct config_enum_entry *entry;
3002 
3003  for (entry = record->options; entry && entry->name; entry++)
3004  {
3005  if (pg_strcasecmp(value, entry->name) == 0)
3006  {
3007  *retval = entry->val;
3008  return true;
3009  }
3010  }
3011 
3012  *retval = 0;
3013  return false;
3014 }
static struct @143 value
int pg_strcasecmp(const char *s1, const char *s2)
Definition: pgstrcasecmp.c:36
int val
Definition: guc.h:170

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

2976 {
2977  const struct config_enum_entry *entry;
2978 
2979  for (entry = record->options; entry && entry->name; entry++)
2980  {
2981  if (entry->val == val)
2982  return entry->name;
2983  }
2984 
2985  elog(ERROR, "could not find enum option %d for %s",
2986  val, record->gen.name);
2987  return NULL; /* silence compiler */
2988 }
#define ERROR
Definition: elog.h:39
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 call_enum_check_hook(), estimate_variable_size(), GetConfigOption(), GetConfigOptionResetString(), GetConfigOptionValues(), serialize_variable(), and ShowGUCOption().

◆ ConfigOptionIsVisible()

bool ConfigOptionIsVisible ( struct config_generic conf)

Definition at line 591 of file guc_funcs.c.

592 {
593  if ((conf->flags & GUC_SUPERUSER_ONLY) &&
594  !has_privs_of_role(GetUserId(), ROLE_PG_READ_ALL_SETTINGS))
595  return false;
596  else
597  return true;
598 }
bool has_privs_of_role(Oid member, Oid role)
Definition: acl.c:4969
#define GUC_SUPERUSER_ONLY
Definition: guc.h:218
Oid GetUserId(void)
Definition: miscinit.c:502

References config_generic::flags, GetUserId(), GUC_SUPERUSER_ONLY, and has_privs_of_role().

Referenced by get_explain_guc_options(), GetConfigOption(), GetConfigOptionByName(), GetConfigOptionResetString(), show_all_settings(), and ShowAllGUCConfig().

◆ find_option()

struct config_generic* find_option ( const char *  name,
bool  create_placeholders,
bool  skip_errors,
int  elevel 
)

Definition at line 1162 of file guc.c.

1164 {
1165  GUCHashEntry *hentry;
1166  int i;
1167 
1168  Assert(name);
1169 
1170  /* Look it up using the hash table. */
1171  hentry = (GUCHashEntry *) hash_search(guc_hashtab,
1172  &name,
1173  HASH_FIND,
1174  NULL);
1175  if (hentry)
1176  return hentry->gucvar;
1177 
1178  /*
1179  * See if the name is an obsolete name for a variable. We assume that the
1180  * set of supported old names is short enough that a brute-force search is
1181  * the best way.
1182  */
1183  for (i = 0; map_old_guc_names[i] != NULL; i += 2)
1184  {
1186  return find_option(map_old_guc_names[i + 1], false,
1187  skip_errors, elevel);
1188  }
1189 
1190  if (create_placeholders)
1191  {
1192  /*
1193  * Check if the name is valid, and if so, add a placeholder. If it
1194  * doesn't contain a separator, don't assume that it was meant to be a
1195  * placeholder.
1196  */
1197  const char *sep = strchr(name, GUC_QUALIFIER_SEPARATOR);
1198 
1199  if (sep != NULL)
1200  {
1201  size_t classLen = sep - name;
1202  ListCell *lc;
1203 
1204  /* The name must be syntactically acceptable ... */
1206  {
1207  if (!skip_errors)
1208  ereport(elevel,
1209  (errcode(ERRCODE_INVALID_NAME),
1210  errmsg("invalid configuration parameter name \"%s\"",
1211  name),
1212  errdetail("Custom parameter names must be two or more simple identifiers separated by dots.")));
1213  return NULL;
1214  }
1215  /* ... and it must not match any previously-reserved prefix */
1216  foreach(lc, reserved_class_prefix)
1217  {
1218  const char *rcprefix = lfirst(lc);
1219 
1220  if (strlen(rcprefix) == classLen &&
1221  strncmp(name, rcprefix, classLen) == 0)
1222  {
1223  if (!skip_errors)
1224  ereport(elevel,
1225  (errcode(ERRCODE_INVALID_NAME),
1226  errmsg("invalid configuration parameter name \"%s\"",
1227  name),
1228  errdetail("\"%s\" is a reserved prefix.",
1229  rcprefix)));
1230  return NULL;
1231  }
1232  }
1233  /* OK, create it */
1234  return add_placeholder_variable(name, elevel);
1235  }
1236  }
1237 
1238  /* Unknown name */
1239  if (!skip_errors)
1240  ereport(elevel,
1241  (errcode(ERRCODE_UNDEFINED_OBJECT),
1242  errmsg("unrecognized configuration parameter \"%s\"",
1243  name)));
1244  return NULL;
1245 }
int errdetail(const char *fmt,...)
Definition: elog.c:1202
int errcode(int sqlerrcode)
Definition: elog.c:858
int errmsg(const char *fmt,...)
Definition: elog.c:1069
#define ereport(elevel,...)
Definition: elog.h:149
const char * name
Definition: encode.c:571
static const char *const map_old_guc_names[]
Definition: guc.c:186
struct config_generic * find_option(const char *name, bool create_placeholders, bool skip_errors, int elevel)
Definition: guc.c:1162
static bool valid_custom_variable_name(const char *name)
Definition: guc.c:1068
static List * reserved_class_prefix
Definition: guc.c:71
static struct config_generic * add_placeholder_variable(const char *name, int elevel)
Definition: guc.c:1104
int guc_name_compare(const char *namea, const char *nameb)
Definition: guc.c:1264
#define GUC_QUALIFIER_SEPARATOR
Definition: guc.h:202
@ HASH_FIND
Definition: hsearch.h:113
#define lfirst(lc)
Definition: pg_list.h:172

References add_placeholder_variable(), Assert(), ereport, errcode(), errdetail(), errmsg(), guc_hashtab, guc_name_compare(), GUC_QUALIFIER_SEPARATOR, GUCHashEntry::gucvar, HASH_FIND, hash_search(), i, lfirst, map_old_guc_names, name, reserved_class_prefix, and valid_custom_variable_name().

Referenced by AlterSystemSetConfigFile(), check_GUC_name_for_parameter_acl(), ExtractSetVariableArgs(), flatten_set_variable_args(), GetConfigOption(), GetConfigOptionByName(), GetConfigOptionFlags(), GetConfigOptionResetString(), GUCArrayAdd(), GUCArrayDelete(), InitializeWalConsistencyChecking(), pg_settings_get_flags(), ProcessConfigFileInternal(), SelectConfigFiles(), set_config_option_ext(), set_config_sourcefile(), and validate_option_array_item().

◆ get_explain_guc_options()

struct config_generic** get_explain_guc_options ( int *  num)

Definition at line 5154 of file guc.c.

5155 {
5156  struct config_generic **result;
5157  dlist_iter iter;
5158 
5159  *num = 0;
5160 
5161  /*
5162  * While only a fraction of all the GUC variables are marked GUC_EXPLAIN,
5163  * it doesn't seem worth dynamically resizing this array.
5164  */
5165  result = palloc(sizeof(struct config_generic *) * hash_get_num_entries(guc_hashtab));
5166 
5167  /* We need only consider GUCs with source not PGC_S_DEFAULT */
5169  {
5170  struct config_generic *conf = dlist_container(struct config_generic,
5171  nondef_link, iter.cur);
5172  bool modified;
5173 
5174  /* return only parameters marked for inclusion in explain */
5175  if (!(conf->flags & GUC_EXPLAIN))
5176  continue;
5177 
5178  /* return only options visible to the current user */
5179  if (!ConfigOptionIsVisible(conf))
5180  continue;
5181 
5182  /* return only options that are different from their boot values */
5183  modified = false;
5184 
5185  switch (conf->vartype)
5186  {
5187  case PGC_BOOL:
5188  {
5189  struct config_bool *lconf = (struct config_bool *) conf;
5190 
5191  modified = (lconf->boot_val != *(lconf->variable));
5192  }
5193  break;
5194 
5195  case PGC_INT:
5196  {
5197  struct config_int *lconf = (struct config_int *) conf;
5198 
5199  modified = (lconf->boot_val != *(lconf->variable));
5200  }
5201  break;
5202 
5203  case PGC_REAL:
5204  {
5205  struct config_real *lconf = (struct config_real *) conf;
5206 
5207  modified = (lconf->boot_val != *(lconf->variable));
5208  }
5209  break;
5210 
5211  case PGC_STRING:
5212  {
5213  struct config_string *lconf = (struct config_string *) conf;
5214 
5215  modified = (strcmp(lconf->boot_val, *(lconf->variable)) != 0);
5216  }
5217  break;
5218 
5219  case PGC_ENUM:
5220  {
5221  struct config_enum *lconf = (struct config_enum *) conf;
5222 
5223  modified = (lconf->boot_val != *(lconf->variable));
5224  }
5225  break;
5226 
5227  default:
5228  elog(ERROR, "unexpected GUC type: %d", conf->vartype);
5229  }
5230 
5231  if (!modified)
5232  continue;
5233 
5234  /* OK, report it */
5235  result[*num] = conf;
5236  *num = *num + 1;
5237  }
5238 
5239  return result;
5240 }
static dlist_head guc_nondef_list
Definition: guc.c:217
#define GUC_EXPLAIN
Definition: guc.h:213
bool ConfigOptionIsVisible(struct config_generic *conf)
Definition: guc_funcs.c:591
#define dlist_foreach(iter, lhead)
Definition: ilist.h:623
#define dlist_container(type, membername, ptr)
Definition: ilist.h:593
void * palloc(Size size)
Definition: mcxt.c:1210
bool * variable
Definition: guc_tables.h:201
bool boot_val
Definition: guc_tables.h:202
int * variable
Definition: guc_tables.h:261
dlist_node nondef_link
Definition: guc_tables.h:172
int boot_val
Definition: guc_tables.h:216
int * variable
Definition: guc_tables.h:215
double boot_val
Definition: guc_tables.h:232
double * variable
Definition: guc_tables.h:231
char ** variable
Definition: guc_tables.h:247
const char * boot_val
Definition: guc_tables.h:248
dlist_node * cur
Definition: ilist.h:179

References config_bool::boot_val, config_int::boot_val, config_real::boot_val, config_string::boot_val, config_enum::boot_val, ConfigOptionIsVisible(), dlist_iter::cur, dlist_container, dlist_foreach, elog(), ERROR, config_generic::flags, GUC_EXPLAIN, guc_hashtab, guc_nondef_list, hash_get_num_entries(), config_generic::nondef_link, 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 ( int *  num_vars)

Definition at line 864 of file guc.c.

865 {
866  struct config_generic **result;
868  GUCHashEntry *hentry;
869  int i;
870 
871  *num_vars = hash_get_num_entries(guc_hashtab);
872  result = palloc(sizeof(struct config_generic *) * *num_vars);
873 
874  /* Extract pointers from the hash table */
875  i = 0;
877  while ((hentry = (GUCHashEntry *) hash_seq_search(&status)) != NULL)
878  result[i++] = hentry->gucvar;
879  Assert(i == *num_vars);
880 
881  /* Sort by name */
882  qsort(result, *num_vars,
883  sizeof(struct config_generic *), guc_var_compare);
884 
885  return result;
886 }
void * hash_seq_search(HASH_SEQ_STATUS *status)
Definition: dynahash.c:1431
void hash_seq_init(HASH_SEQ_STATUS *status, HTAB *hashp)
Definition: dynahash.c:1421
static int guc_var_compare(const void *a, const void *b)
Definition: guc.c:1252
static void static void status(const char *fmt,...) pg_attribute_printf(1
Definition: pg_regress.c:224
#define qsort(a, b, c, d)
Definition: port.h:445

References Assert(), guc_hashtab, guc_var_compare(), GUCHashEntry::gucvar, hash_get_num_entries(), hash_seq_init(), hash_seq_search(), i, palloc(), qsort, and status().

Referenced by GucInfoMain(), show_all_settings(), and ShowAllGUCConfig().

◆ ShowGUCOption()

char* ShowGUCOption ( struct config_generic record,
bool  use_units 
)

Definition at line 5280 of file guc.c.

5281 {
5282  char buffer[256];
5283  const char *val;
5284 
5285  switch (record->vartype)
5286  {
5287  case PGC_BOOL:
5288  {
5289  struct config_bool *conf = (struct config_bool *) record;
5290 
5291  if (conf->show_hook)
5292  val = conf->show_hook();
5293  else
5294  val = *conf->variable ? "on" : "off";
5295  }
5296  break;
5297 
5298  case PGC_INT:
5299  {
5300  struct config_int *conf = (struct config_int *) record;
5301 
5302  if (conf->show_hook)
5303  val = conf->show_hook();
5304  else
5305  {
5306  /*
5307  * Use int64 arithmetic to avoid overflows in units
5308  * conversion.
5309  */
5310  int64 result = *conf->variable;
5311  const char *unit;
5312 
5313  if (use_units && result > 0 && (record->flags & GUC_UNIT))
5315  record->flags & GUC_UNIT,
5316  &result, &unit);
5317  else
5318  unit = "";
5319 
5320  snprintf(buffer, sizeof(buffer), INT64_FORMAT "%s",
5321  result, unit);
5322  val = buffer;
5323  }
5324  }
5325  break;
5326 
5327  case PGC_REAL:
5328  {
5329  struct config_real *conf = (struct config_real *) record;
5330 
5331  if (conf->show_hook)
5332  val = conf->show_hook();
5333  else
5334  {
5335  double result = *conf->variable;
5336  const char *unit;
5337 
5338  if (use_units && result > 0 && (record->flags & GUC_UNIT))
5340  record->flags & GUC_UNIT,
5341  &result, &unit);
5342  else
5343  unit = "";
5344 
5345  snprintf(buffer, sizeof(buffer), "%g%s",
5346  result, unit);
5347  val = buffer;
5348  }
5349  }
5350  break;
5351 
5352  case PGC_STRING:
5353  {
5354  struct config_string *conf = (struct config_string *) record;
5355 
5356  if (conf->show_hook)
5357  val = conf->show_hook();
5358  else if (*conf->variable && **conf->variable)
5359  val = *conf->variable;
5360  else
5361  val = "";
5362  }
5363  break;
5364 
5365  case PGC_ENUM:
5366  {
5367  struct config_enum *conf = (struct config_enum *) record;
5368 
5369  if (conf->show_hook)
5370  val = conf->show_hook();
5371  else
5372  val = config_enum_lookup_by_value(conf, *conf->variable);
5373  }
5374  break;
5375 
5376  default:
5377  /* just to keep compiler quiet */
5378  val = "???";
5379  break;
5380  }
5381 
5382  return pstrdup(val);
5383 }
#define INT64_FORMAT
Definition: c.h:532
const char * config_enum_lookup_by_value(struct config_enum *record, int val)
Definition: guc.c:2975
static void convert_int_from_base_unit(int64 base_value, int base_unit, int64 *value, const char **unit)
Definition: guc.c:2681
static void convert_real_from_base_unit(double base_value, int base_unit, double *value, const char **unit)
Definition: guc.c:2723
#define GUC_UNIT
Definition: guc.h:237
char * pstrdup(const char *in)
Definition: mcxt.c:1624
#define snprintf
Definition: port.h:238
GucShowHook show_hook
Definition: guc_tables.h:205
GucShowHook show_hook
Definition: guc_tables.h:266
GucShowHook show_hook
Definition: guc_tables.h:221
GucShowHook show_hook
Definition: guc_tables.h:237
GucShowHook show_hook
Definition: guc_tables.h:251

References config_enum_lookup_by_value(), convert_int_from_base_unit(), convert_real_from_base_unit(), config_generic::flags, GUC_UNIT, INT64_FORMAT, PGC_BOOL, PGC_ENUM, PGC_INT, PGC_REAL, PGC_STRING, pstrdup(), config_bool::show_hook, config_int::show_hook, config_real::show_hook, config_string::show_hook, config_enum::show_hook, snprintf, val, config_bool::variable, config_int::variable, config_real::variable, config_string::variable, config_enum::variable, and config_generic::vartype.

Referenced by GetConfigOptionByName(), GetConfigOptionValues(), ReportGUCOption(), and ShowAllGUCConfig().

Variable Documentation

◆ config_group_names

PGDLLIMPORT const char* const config_group_names[]
extern

Definition at line 644 of file guc_tables.c.

Referenced by GetConfigOptionValues().

◆ config_type_names

PGDLLIMPORT const char* const config_type_names[]
extern

Definition at line 746 of file guc_tables.c.

Referenced by GetConfigOptionValues().

◆ ConfigureNamesBool

PGDLLIMPORT struct config_bool ConfigureNamesBool[]
extern

Definition at line 755 of file guc_tables.c.

Referenced by build_guc_variables().

◆ ConfigureNamesEnum

PGDLLIMPORT struct config_enum ConfigureNamesEnum[]
extern

Definition at line 755 of file guc_tables.c.

Referenced by build_guc_variables().

◆ ConfigureNamesInt

PGDLLIMPORT struct config_int ConfigureNamesInt[]
extern

Definition at line 755 of file guc_tables.c.

Referenced by build_guc_variables().

◆ ConfigureNamesReal

PGDLLIMPORT struct config_real ConfigureNamesReal[]
extern

Definition at line 755 of file guc_tables.c.

Referenced by build_guc_variables().

◆ ConfigureNamesString

PGDLLIMPORT struct config_string ConfigureNamesString[]
extern

Definition at line 755 of file guc_tables.c.

Referenced by build_guc_variables().

◆ GucContext_Names

PGDLLIMPORT const char* const GucContext_Names[]
extern

Definition at line 601 of file guc_tables.c.

Referenced by GetConfigOptionValues().

◆ GucSource_Names

PGDLLIMPORT const char* const GucSource_Names[]
extern

Definition at line 620 of file guc_tables.c.

Referenced by GetConfigOptionValues().