PostgreSQL Source Code git master
Data Structures | Macros | Typedefs | Enumerations | Functions | Variables
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 guc_stack  GucStack
 

Enumerations

 
 
 

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

Macro Definition Documentation

GUC_IS_IN_FILE

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

Definition at line 205 of file guc_tables.h.

GUC_NEEDS_REPORT

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

Definition at line 211 of file guc_tables.h.

GUC_PENDING_RESTART

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

Definition at line 210 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_BGWRITER 
RESOURCES_IO 
RESOURCES_WORKER_PROCESSES 
WAL_SETTINGS 
WAL_CHECKPOINTS 
WAL_ARCHIVING 
WAL_RECOVERY 
WAL_ARCHIVE_RECOVERY 
WAL_RECOVERY_TARGET 
WAL_SUMMARIZATION 
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 
VACUUM_AUTOVACUUM 
VACUUM_COST_DELAY 
VACUUM_DEFAULT 
VACUUM_FREEZING 
CLIENT_CONN_STATEMENT 
CLIENT_CONN_LOCALE 
CLIENT_CONN_PRELOAD 
CLIENT_CONN_OTHER 
LOCK_MANAGEMENT 
COMPAT_OPTIONS_PREVIOUS 
COMPAT_OPTIONS_OTHER 
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 */
105};
@ RESOURCES_KERNEL
Definition: guc_tables.h:65
@ CLIENT_CONN_LOCALE
Definition: guc_tables.h:95
@ WAL_ARCHIVE_RECOVERY
Definition: guc_tables.h:73
@ STATS_CUMULATIVE
Definition: guc_tables.h:89
@ CLIENT_CONN_PRELOAD
Definition: guc_tables.h:96
@ VACUUM_COST_DELAY
Definition: guc_tables.h:91
@ QUERY_TUNING_OTHER
Definition: guc_tables.h:83
@ LOGGING_WHERE
Definition: guc_tables.h:84
@ CONN_AUTH_AUTH
Definition: guc_tables.h:61
@ RESOURCES_WORKER_PROCESSES
Definition: guc_tables.h:68
@ VACUUM_FREEZING
Definition: guc_tables.h:93
@ ERROR_HANDLING_OPTIONS
Definition: guc_tables.h:101
@ PROCESS_TITLE
Definition: guc_tables.h:87
@ RESOURCES_DISK
Definition: guc_tables.h:64
@ REPLICATION_SENDING
Definition: guc_tables.h:76
@ RESOURCES_IO
Definition: guc_tables.h:67
@ LOCK_MANAGEMENT
Definition: guc_tables.h:98
@ CUSTOM_OPTIONS
Definition: guc_tables.h:103
@ REPLICATION_PRIMARY
Definition: guc_tables.h:77
@ STATS_MONITORING
Definition: guc_tables.h:88
@ 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:66
@ PRESET_OPTIONS
Definition: guc_tables.h:102
@ DEVELOPER_OPTIONS
Definition: guc_tables.h:104
@ QUERY_TUNING_METHOD
Definition: guc_tables.h:80
@ LOGGING_WHAT
Definition: guc_tables.h:86
@ VACUUM_DEFAULT
Definition: guc_tables.h:92
@ QUERY_TUNING_GEQO
Definition: guc_tables.h:82
@ WAL_SETTINGS
Definition: guc_tables.h:69
@ COMPAT_OPTIONS_OTHER
Definition: guc_tables.h:100
@ CLIENT_CONN_STATEMENT
Definition: guc_tables.h:94
@ FILE_LOCATIONS
Definition: guc_tables.h:58
@ REPLICATION_STANDBY
Definition: guc_tables.h:78
@ QUERY_TUNING_COST
Definition: guc_tables.h:81
@ WAL_ARCHIVING
Definition: guc_tables.h:71
@ COMPAT_OPTIONS_PREVIOUS
Definition: guc_tables.h:99
@ WAL_CHECKPOINTS
Definition: guc_tables.h:70
@ CLIENT_CONN_OTHER
Definition: guc_tables.h:97
@ LOGGING_WHEN
Definition: guc_tables.h:85
@ CONN_AUTH_TCP
Definition: guc_tables.h:60
@ REPLICATION_SUBSCRIBERS
Definition: guc_tables.h:79
@ WAL_SUMMARIZATION
Definition: guc_tables.h:75
@ CONN_AUTH_SETTINGS
Definition: guc_tables.h:59
@ UNGROUPED
Definition: guc_tables.h:57
@ VACUUM_AUTOVACUUM
Definition: guc_tables.h:90

config_type

Enumerator
PGC_BOOL 
PGC_INT 
PGC_REAL 
PGC_STRING 
PGC_ENUM 

Definition at line 23 of file guc_tables.h.

24{
26 PGC_INT,
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 111 of file guc_tables.h.

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

Function Documentation

build_guc_variables()

void build_guc_variables ( void  )

Definition at line 905 of file guc.c.

906{
907 int size_vars;
908 int num_vars = 0;
909 HASHCTL hash_ctl;
910 GUCHashEntry *hentry;
911 bool found;
912 int i;
913
914 /*
915 * Create the memory context that will hold all GUC-related data.
916 */
917 Assert(GUCMemoryContext == NULL);
919 "GUCMemoryContext",
921
922 /*
923 * Count all the built-in variables, and set their vartypes correctly.
924 */
925 for (i = 0; ConfigureNamesBool[i].gen.name; i++)
926 {
927 struct config_bool *conf = &ConfigureNamesBool[i];
928
929 /* Rather than requiring vartype to be filled in by hand, do this: */
930 conf->gen.vartype = PGC_BOOL;
931 num_vars++;
932 }
933
934 for (i = 0; ConfigureNamesInt[i].gen.name; i++)
935 {
936 struct config_int *conf = &ConfigureNamesInt[i];
937
938 conf->gen.vartype = PGC_INT;
939 num_vars++;
940 }
941
942 for (i = 0; ConfigureNamesReal[i].gen.name; i++)
943 {
944 struct config_real *conf = &ConfigureNamesReal[i];
945
946 conf->gen.vartype = PGC_REAL;
947 num_vars++;
948 }
949
950 for (i = 0; ConfigureNamesString[i].gen.name; i++)
951 {
952 struct config_string *conf = &ConfigureNamesString[i];
953
954 conf->gen.vartype = PGC_STRING;
955 num_vars++;
956 }
957
958 for (i = 0; ConfigureNamesEnum[i].gen.name; i++)
959 {
960 struct config_enum *conf = &ConfigureNamesEnum[i];
961
962 conf->gen.vartype = PGC_ENUM;
963 num_vars++;
964 }
965
966 /*
967 * Create hash table with 20% slack
968 */
969 size_vars = num_vars + num_vars / 4;
970
971 hash_ctl.keysize = sizeof(char *);
972 hash_ctl.entrysize = sizeof(GUCHashEntry);
973 hash_ctl.hash = guc_name_hash;
974 hash_ctl.match = guc_name_match;
975 hash_ctl.hcxt = GUCMemoryContext;
976 guc_hashtab = hash_create("GUC hash table",
977 size_vars,
978 &hash_ctl,
980
981 for (i = 0; ConfigureNamesBool[i].gen.name; i++)
982 {
983 struct config_generic *gucvar = &ConfigureNamesBool[i].gen;
984
986 &gucvar->name,
988 &found);
989 Assert(!found);
990 hentry->gucvar = gucvar;
991 }
992
993 for (i = 0; ConfigureNamesInt[i].gen.name; i++)
994 {
995 struct config_generic *gucvar = &ConfigureNamesInt[i].gen;
996
998 &gucvar->name,
1000 &found);
1001 Assert(!found);
1002 hentry->gucvar = gucvar;
1003 }
1004
1005 for (i = 0; ConfigureNamesReal[i].gen.name; i++)
1006 {
1007 struct config_generic *gucvar = &ConfigureNamesReal[i].gen;
1008
1010 &gucvar->name,
1011 HASH_ENTER,
1012 &found);
1013 Assert(!found);
1014 hentry->gucvar = gucvar;
1015 }
1016
1017 for (i = 0; ConfigureNamesString[i].gen.name; i++)
1018 {
1019 struct config_generic *gucvar = &ConfigureNamesString[i].gen;
1020
1022 &gucvar->name,
1023 HASH_ENTER,
1024 &found);
1025 Assert(!found);
1026 hentry->gucvar = gucvar;
1027 }
1028
1029 for (i = 0; ConfigureNamesEnum[i].gen.name; i++)
1030 {
1031 struct config_generic *gucvar = &ConfigureNamesEnum[i].gen;
1032
1034 &gucvar->name,
1035 HASH_ENTER,
1036 &found);
1037 Assert(!found);
1038 hentry->gucvar = gucvar;
1039 }
1040
1042}
void * hash_search(HTAB *hashp, const void *keyPtr, HASHACTION action, bool *foundPtr)
Definition: dynahash.c:952
HTAB * hash_create(const char *tabname, int64 nelem, const HASHCTL *info, int flags)
Definition: dynahash.c:358
int64 hash_get_num_entries(HTAB *hashp)
Definition: dynahash.c:1336
static int guc_name_match(const void *key1, const void *key2, Size keysize)
Definition: guc.c:1356
static uint32 guc_name_hash(const void *key, Size keysize)
Definition: guc.c:1332
static HTAB * guc_hashtab
Definition: guc.c:213
static MemoryContext GUCMemoryContext
Definition: guc.c:200
PGDLLIMPORT struct config_int ConfigureNamesInt[]
PGDLLIMPORT struct config_real ConfigureNamesReal[]
PGDLLIMPORT struct config_string ConfigureNamesString[]
PGDLLIMPORT struct config_enum ConfigureNamesEnum[]
PGDLLIMPORT struct config_bool ConfigureNamesBool[]
Assert(PointerIsAligned(start, uint64))
@ 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
i
int i
Definition: isn.c:77
MemoryContext TopMemoryContext
Definition: mcxt.c:166
#define AllocSetContextCreate
Definition: memutils.h:129
#define ALLOCSET_DEFAULT_SIZES
Definition: memutils.h:160
Definition: guc.c:208
struct config_generic * gucvar
Definition: guc.c:210
Definition: hsearch.h:66
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:218
struct config_generic gen
Definition: guc_tables.h:288
const char * name
Definition: guc_tables.h:174
enum config_type vartype
Definition: guc_tables.h:181
struct config_generic gen
Definition: guc_tables.h:232
struct config_generic gen
Definition: guc_tables.h:248
struct config_generic gen
Definition: guc_tables.h:274

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_enumrecord,
const char *  prefix,
const char *  suffix,
const char *  separator 
)

Definition at line 3078 of file guc.c.

3080{
3081 const struct config_enum_entry *entry;
3082 StringInfoData retstr;
3083 int seplen;
3084
3085 initStringInfo(&retstr);
3086 appendStringInfoString(&retstr, prefix);
3087
3088 seplen = strlen(separator);
3089 for (entry = record->options; entry && entry->name; entry++)
3090 {
3091 if (!entry->hidden)
3092 {
3093 appendStringInfoString(&retstr, entry->name);
3094 appendBinaryStringInfo(&retstr, separator, seplen);
3095 }
3096 }
3097
3098 /*
3099 * All the entries may have been hidden, leaving the string empty if no
3100 * prefix was given. This indicates a broken GUC setup, since there is no
3101 * use for an enum without any values, so we just check to make sure we
3102 * don't write to invalid memory instead of actually trying to do
3103 * something smart with it.
3104 */
3105 if (retstr.len >= seplen)
3106 {
3107 /* Replace final separator */
3108 retstr.data[retstr.len - seplen] = '0円';
3109 retstr.len -= seplen;
3110 }
3111
3112 appendStringInfoString(&retstr, suffix);
3113
3114 return retstr.data;
3115}
void appendBinaryStringInfo(StringInfo str, const void *data, int datalen)
Definition: stringinfo.c:281
void appendStringInfoString(StringInfo str, const char *s)
Definition: stringinfo.c:230
void initStringInfo(StringInfo str)
Definition: stringinfo.c:97
char * data
Definition: stringinfo.h:48
Definition: guc.h:174
const char * name
Definition: guc.h:175
bool hidden
Definition: guc.h:177
const struct config_enum_entry * options
Definition: guc_tables.h:292
Definition: print.h:106

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_enumrecord,
const char *  value,
int *  retval 
)

Definition at line 3052 of file guc.c.

3054{
3055 const struct config_enum_entry *entry;
3056
3057 for (entry = record->options; entry && entry->name; entry++)
3058 {
3059 if (pg_strcasecmp(value, entry->name) == 0)
3060 {
3061 *retval = entry->val;
3062 return true;
3063 }
3064 }
3065
3066 *retval = 0;
3067 return false;
3068}
static struct @169 value
int pg_strcasecmp(const char *s1, const char *s2)
Definition: pgstrcasecmp.c:36
int val
Definition: guc.h:176

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_enumrecord,
int  val 
)

Definition at line 3029 of file guc.c.

3030{
3031 const struct config_enum_entry *entry;
3032
3033 for (entry = record->options; entry && entry->name; entry++)
3034 {
3035 if (entry->val == val)
3036 return entry->name;
3037 }
3038
3039 elog(ERROR, "could not find enum option %d for %s",
3040 val, record->gen.name);
3041 return NULL; /* silence compiler */
3042}
#define ERROR
Definition: elog.h:39
#define elog(elevel,...)
Definition: elog.h:226
long val
Definition: informix.c:689

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(), printMixedStruct(), serialize_variable(), and ShowGUCOption().

ConfigOptionIsVisible()

bool ConfigOptionIsVisible ( struct config_genericconf )

Definition at line 581 of file guc_funcs.c.

582{
583 if ((conf->flags & GUC_SUPERUSER_ONLY) &&
584 !has_privs_of_role(GetUserId(), ROLE_PG_READ_ALL_SETTINGS))
585 return false;
586 else
587 return true;
588}
bool has_privs_of_role(Oid member, Oid role)
Definition: acl.c:5284
#define GUC_SUPERUSER_ONLY
Definition: guc.h:224
Oid GetUserId(void)
Definition: miscinit.c:469

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

1239{
1240 GUCHashEntry *hentry;
1241 int i;
1242
1243 Assert(name);
1244
1245 /* Look it up using the hash table. */
1247 &name,
1248 HASH_FIND,
1249 NULL);
1250 if (hentry)
1251 return hentry->gucvar;
1252
1253 /*
1254 * See if the name is an obsolete name for a variable. We assume that the
1255 * set of supported old names is short enough that a brute-force search is
1256 * the best way.
1257 */
1258 for (i = 0; map_old_guc_names[i] != NULL; i += 2)
1259 {
1261 return find_option(map_old_guc_names[i + 1], false,
1262 skip_errors, elevel);
1263 }
1264
1265 if (create_placeholders)
1266 {
1267 /*
1268 * Check if the name is valid, and if so, add a placeholder.
1269 */
1270 if (assignable_custom_variable_name(name, skip_errors, elevel))
1271 return add_placeholder_variable(name, elevel);
1272 else
1273 return NULL; /* error message, if any, already emitted */
1274 }
1275
1276 /* Unknown name and we're not supposed to make a placeholder */
1277 if (!skip_errors)
1278 ereport(elevel,
1279 (errcode(ERRCODE_UNDEFINED_OBJECT),
1280 errmsg("unrecognized configuration parameter \"%s\"",
1281 name)));
1282 return NULL;
1283}
int errcode(int sqlerrcode)
Definition: elog.c:854
int errmsg(const char *fmt,...)
Definition: elog.c:1071
#define ereport(elevel,...)
Definition: elog.h:150
static const char *const map_old_guc_names[]
Definition: guc.c:191
static bool assignable_custom_variable_name(const char *name, bool skip_errors, int elevel)
Definition: guc.c:1123
struct config_generic * find_option(const char *name, bool create_placeholders, bool skip_errors, int elevel)
Definition: guc.c:1237
static struct config_generic * add_placeholder_variable(const char *name, int elevel)
Definition: guc.c:1179
int guc_name_compare(const char *namea, const char *nameb)
Definition: guc.c:1302
@ HASH_FIND
Definition: hsearch.h:113
const char * name

References add_placeholder_variable(), Assert(), assignable_custom_variable_name(), ereport, errcode(), errmsg(), find_option(), guc_hashtab, guc_name_compare(), GUCHashEntry::gucvar, HASH_FIND, hash_search(), i, map_old_guc_names, and name.

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

get_explain_guc_options()

struct config_generic ** get_explain_guc_options ( int *  num )

Definition at line 5354 of file guc.c.

5355{
5356 struct config_generic **result;
5357 dlist_iter iter;
5358
5359 *num = 0;
5360
5361 /*
5362 * While only a fraction of all the GUC variables are marked GUC_EXPLAIN,
5363 * it doesn't seem worth dynamically resizing this array.
5364 */
5365 result = palloc(sizeof(struct config_generic *) * hash_get_num_entries(guc_hashtab));
5366
5367 /* We need only consider GUCs with source not PGC_S_DEFAULT */
5369 {
5370 struct config_generic *conf = dlist_container(struct config_generic,
5371 nondef_link, iter.cur);
5372 bool modified;
5373
5374 /* return only parameters marked for inclusion in explain */
5375 if (!(conf->flags & GUC_EXPLAIN))
5376 continue;
5377
5378 /* return only options visible to the current user */
5379 if (!ConfigOptionIsVisible(conf))
5380 continue;
5381
5382 /* return only options that are different from their boot values */
5383 modified = false;
5384
5385 switch (conf->vartype)
5386 {
5387 case PGC_BOOL:
5388 {
5389 struct config_bool *lconf = (struct config_bool *) conf;
5390
5391 modified = (lconf->boot_val != *(lconf->variable));
5392 }
5393 break;
5394
5395 case PGC_INT:
5396 {
5397 struct config_int *lconf = (struct config_int *) conf;
5398
5399 modified = (lconf->boot_val != *(lconf->variable));
5400 }
5401 break;
5402
5403 case PGC_REAL:
5404 {
5405 struct config_real *lconf = (struct config_real *) conf;
5406
5407 modified = (lconf->boot_val != *(lconf->variable));
5408 }
5409 break;
5410
5411 case PGC_STRING:
5412 {
5413 struct config_string *lconf = (struct config_string *) conf;
5414
5415 if (lconf->boot_val == NULL &&
5416 *lconf->variable == NULL)
5417 modified = false;
5418 else if (lconf->boot_val == NULL ||
5419 *lconf->variable == NULL)
5420 modified = true;
5421 else
5422 modified = (strcmp(lconf->boot_val, *(lconf->variable)) != 0);
5423 }
5424 break;
5425
5426 case PGC_ENUM:
5427 {
5428 struct config_enum *lconf = (struct config_enum *) conf;
5429
5430 modified = (lconf->boot_val != *(lconf->variable));
5431 }
5432 break;
5433
5434 default:
5435 elog(ERROR, "unexpected GUC type: %d", conf->vartype);
5436 }
5437
5438 if (!modified)
5439 continue;
5440
5441 /* OK, report it */
5442 result[*num] = conf;
5443 *num = *num + 1;
5444 }
5445
5446 return result;
5447}
static dlist_head guc_nondef_list
Definition: guc.c:223
#define GUC_EXPLAIN
Definition: guc.h:219
bool ConfigOptionIsVisible(struct config_generic *conf)
Definition: guc_funcs.c:581
#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:1365
bool * variable
Definition: guc_tables.h:220
bool boot_val
Definition: guc_tables.h:221
int * variable
Definition: guc_tables.h:290
int boot_val
Definition: guc_tables.h:291
dlist_node nondef_link
Definition: guc_tables.h:191
int boot_val
Definition: guc_tables.h:235
int * variable
Definition: guc_tables.h:234
double boot_val
Definition: guc_tables.h:251
double * variable
Definition: guc_tables.h:250
char ** variable
Definition: guc_tables.h:276
const char * boot_val
Definition: guc_tables.h:277
Definition: ilist.h:178
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 874 of file guc.c.

875{
876 struct config_generic **result;
878 GUCHashEntry *hentry;
879 int i;
880
882 result = palloc(sizeof(struct config_generic *) * *num_vars);
883
884 /* Extract pointers from the hash table */
885 i = 0;
887 while ((hentry = (GUCHashEntry *) hash_seq_search(&status)) != NULL)
888 result[i++] = hentry->gucvar;
889 Assert(i == *num_vars);
890
891 /* Sort by name */
892 qsort(result, *num_vars,
893 sizeof(struct config_generic *), guc_var_compare);
894
895 return result;
896}
void * hash_seq_search(HASH_SEQ_STATUS *status)
Definition: dynahash.c:1415
void hash_seq_init(HASH_SEQ_STATUS *status, HTAB *hashp)
Definition: dynahash.c:1380
static int guc_var_compare(const void *a, const void *b)
Definition: guc.c:1290
#define qsort(a, b, c, d)
Definition: port.h:479

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

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

ShowGUCOption()

char * ShowGUCOption ( struct config_genericrecord,
bool  use_units 
)

Definition at line 5488 of file guc.c.

5489{
5490 char buffer[256];
5491 const char *val;
5492
5493 switch (record->vartype)
5494 {
5495 case PGC_BOOL:
5496 {
5497 struct config_bool *conf = (struct config_bool *) record;
5498
5499 if (conf->show_hook)
5500 val = conf->show_hook();
5501 else
5502 val = *conf->variable ? "on" : "off";
5503 }
5504 break;
5505
5506 case PGC_INT:
5507 {
5508 struct config_int *conf = (struct config_int *) record;
5509
5510 if (conf->show_hook)
5511 val = conf->show_hook();
5512 else
5513 {
5514 /*
5515 * Use int64 arithmetic to avoid overflows in units
5516 * conversion.
5517 */
5518 int64 result = *conf->variable;
5519 const char *unit;
5520
5521 if (use_units && result > 0 && (record->flags & GUC_UNIT))
5523 record->flags & GUC_UNIT,
5524 &result, &unit);
5525 else
5526 unit = "";
5527
5528 snprintf(buffer, sizeof(buffer), INT64_FORMAT "%s",
5529 result, unit);
5530 val = buffer;
5531 }
5532 }
5533 break;
5534
5535 case PGC_REAL:
5536 {
5537 struct config_real *conf = (struct config_real *) record;
5538
5539 if (conf->show_hook)
5540 val = conf->show_hook();
5541 else
5542 {
5543 double result = *conf->variable;
5544 const char *unit;
5545
5546 if (use_units && result > 0 && (record->flags & GUC_UNIT))
5548 record->flags & GUC_UNIT,
5549 &result, &unit);
5550 else
5551 unit = "";
5552
5553 snprintf(buffer, sizeof(buffer), "%g%s",
5554 result, unit);
5555 val = buffer;
5556 }
5557 }
5558 break;
5559
5560 case PGC_STRING:
5561 {
5562 struct config_string *conf = (struct config_string *) record;
5563
5564 if (conf->show_hook)
5565 val = conf->show_hook();
5566 else if (*conf->variable && **conf->variable)
5567 val = *conf->variable;
5568 else
5569 val = "";
5570 }
5571 break;
5572
5573 case PGC_ENUM:
5574 {
5575 struct config_enum *conf = (struct config_enum *) record;
5576
5577 if (conf->show_hook)
5578 val = conf->show_hook();
5579 else
5581 }
5582 break;
5583
5584 default:
5585 /* just to keep compiler quiet */
5586 val = "???";
5587 break;
5588 }
5589
5590 return pstrdup(val);
5591}
#define INT64_FORMAT
Definition: c.h:556
int64_t int64
Definition: c.h:535
static void convert_int_from_base_unit(int64 base_value, int base_unit, int64 *value, const char **unit)
Definition: guc.c:2735
const char * config_enum_lookup_by_value(struct config_enum *record, int val)
Definition: guc.c:3029
static void convert_real_from_base_unit(double base_value, int base_unit, double *value, const char **unit)
Definition: guc.c:2777
#define GUC_UNIT
Definition: guc.h:244
char * pstrdup(const char *in)
Definition: mcxt.c:1759
#define snprintf
Definition: port.h:239
GucShowHook show_hook
Definition: guc_tables.h:224
GucShowHook show_hook
Definition: guc_tables.h:295
GucShowHook show_hook
Definition: guc_tables.h:240
GucShowHook show_hook
Definition: guc_tables.h:256
GucShowHook show_hook
Definition: guc_tables.h:280

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 691 of file guc_tables.c.

Referenced by GetConfigOptionValues(), and printMixedStruct().

config_type_names

PGDLLIMPORT const char* const config_type_names[]
extern

Definition at line 751 of file guc_tables.c.

Referenced by GetConfigOptionValues().

ConfigureNamesBool

PGDLLIMPORT struct config_bool ConfigureNamesBool[]
extern

Referenced by build_guc_variables().

ConfigureNamesEnum

PGDLLIMPORT struct config_enum ConfigureNamesEnum[]
extern

Referenced by build_guc_variables().

ConfigureNamesInt

PGDLLIMPORT struct config_int ConfigureNamesInt[]
extern

Referenced by build_guc_variables().

ConfigureNamesReal

PGDLLIMPORT struct config_real ConfigureNamesReal[]
extern

Referenced by build_guc_variables().

ConfigureNamesString

PGDLLIMPORT struct config_string ConfigureNamesString[]
extern

Referenced by build_guc_variables().

GucContext_Names

PGDLLIMPORT const char* const GucContext_Names[]
extern

Definition at line 648 of file guc_tables.c.

Referenced by GetConfigOptionValues(), and printMixedStruct().

GucSource_Names

PGDLLIMPORT const char* const GucSource_Names[]
extern

Definition at line 667 of file guc_tables.c.

Referenced by GetConfigOptionValues().

AltStyle によって変換されたページ (->オリジナル) /