PostgreSQL Source Code  git master
guc.c File Reference
#include "postgres.h"
#include <ctype.h>
#include <float.h>
#include <math.h>
#include <limits.h>
#include <sys/mman.h>
#include <sys/stat.h>
#include <unistd.h>
#include "access/commit_ts.h"
#include "access/gin.h"
#include "access/rmgr.h"
#include "access/tableam.h"
#include "access/toast_compression.h"
#include "access/transam.h"
#include "access/twophase.h"
#include "access/xact.h"
#include "access/xlog_internal.h"
#include "catalog/namespace.h"
#include "catalog/pg_authid.h"
#include "catalog/storage.h"
#include "commands/async.h"
#include "commands/prepare.h"
#include "commands/tablespace.h"
#include "commands/trigger.h"
#include "commands/user.h"
#include "commands/vacuum.h"
#include "commands/variable.h"
#include "common/string.h"
#include "funcapi.h"
#include "jit/jit.h"
#include "libpq/auth.h"
#include "libpq/libpq.h"
#include "libpq/pqformat.h"
#include "miscadmin.h"
#include "optimizer/cost.h"
#include "optimizer/geqo.h"
#include "optimizer/optimizer.h"
#include "optimizer/paths.h"
#include "optimizer/planmain.h"
#include "parser/parse_expr.h"
#include "parser/parse_type.h"
#include "parser/parser.h"
#include "parser/scansup.h"
#include "pgstat.h"
#include "postmaster/autovacuum.h"
#include "postmaster/bgworker_internals.h"
#include "postmaster/bgwriter.h"
#include "postmaster/postmaster.h"
#include "postmaster/startup.h"
#include "postmaster/syslogger.h"
#include "postmaster/walwriter.h"
#include "replication/logicallauncher.h"
#include "replication/reorderbuffer.h"
#include "replication/slot.h"
#include "replication/syncrep.h"
#include "replication/walreceiver.h"
#include "replication/walsender.h"
#include "storage/bufmgr.h"
#include "storage/dsm_impl.h"
#include "storage/fd.h"
#include "storage/large_object.h"
#include "storage/pg_shmem.h"
#include "storage/predicate.h"
#include "storage/proc.h"
#include "storage/standby.h"
#include "tcop/tcopprot.h"
#include "tsearch/ts_cache.h"
#include "utils/acl.h"
#include "utils/backend_status.h"
#include "utils/builtins.h"
#include "utils/bytea.h"
#include "utils/guc_tables.h"
#include "utils/memutils.h"
#include "utils/pg_locale.h"
#include "utils/pg_lsn.h"
#include "utils/plancache.h"
#include "utils/portal.h"
#include "utils/ps_status.h"
#include "utils/queryjumble.h"
#include "utils/rls.h"
#include "utils/snapmgr.h"
#include "utils/tzparser.h"
#include "utils/inval.h"
#include "utils/varlena.h"
#include "utils/xml.h"
#include "guc-file.c"
Include dependency graph for guc.c:

Go to the source code of this file.

Data Structures

struct  unit_conversion
 

Macros

#define PG_KRB_SRVTAB   ""
 
#define CONFIG_FILENAME   "postgresql.conf"
 
#define HBA_FILENAME   "pg_hba.conf"
 
#define IDENT_FILENAME   "pg_ident.conf"
 
#define REALTYPE_PRECISION   17
 
#define MAX_UNIT_LEN   3 /* length of longest recognized unit string */
 
#define newval   (newval_union.boolval)
 
#define newval   (newval_union.intval)
 
#define newval   (newval_union.realval)
 
#define newval   (newval_union.stringval)
 
#define newval   (newval_union.enumval)
 
#define NUM_PG_SETTINGS_ATTS   17
 
#define NUM_PG_FILE_SETTINGS_ATTS   7
 

Functions

static void do_serialize (char **destptr, Size *maxbytes, const char *fmt,...) pg_attribute_printf(3
 
static void static void set_config_sourcefile (const char *name, char *sourcefile, int sourceline)
 
static bool call_bool_check_hook (struct config_bool *conf, bool *newval, void **extra, GucSource source, int elevel)
 
static bool call_int_check_hook (struct config_int *conf, int *newval, void **extra, GucSource source, int elevel)
 
static bool call_real_check_hook (struct config_real *conf, double *newval, void **extra, GucSource source, int elevel)
 
static bool call_string_check_hook (struct config_string *conf, char **newval, void **extra, GucSource source, int elevel)
 
static bool call_enum_check_hook (struct config_enum *conf, int *newval, void **extra, GucSource source, int elevel)
 
static bool check_log_destination (char **newval, void **extra, GucSource source)
 
static void assign_log_destination (const char *newval, void *extra)
 
static bool check_wal_consistency_checking (char **newval, void **extra, GucSource source)
 
static void assign_wal_consistency_checking (const char *newval, void *extra)
 
static void assign_syslog_facility (int newval, void *extra)
 
static void assign_syslog_ident (const char *newval, void *extra)
 
static void assign_session_replication_role (int newval, void *extra)
 
static bool check_temp_buffers (int *newval, void **extra, GucSource source)
 
static bool check_bonjour (bool *newval, void **extra, GucSource source)
 
static bool check_ssl (bool *newval, void **extra, GucSource source)
 
static bool check_stage_log_stats (bool *newval, void **extra, GucSource source)
 
static bool check_log_stats (bool *newval, void **extra, GucSource source)
 
static bool check_canonical_path (char **newval, void **extra, GucSource source)
 
static bool check_timezone_abbreviations (char **newval, void **extra, GucSource source)
 
static void assign_timezone_abbreviations (const char *newval, void *extra)
 
static void pg_timezone_abbrev_initialize (void)
 
static const char * show_archive_command (void)
 
static void assign_tcp_keepalives_idle (int newval, void *extra)
 
static void assign_tcp_keepalives_interval (int newval, void *extra)
 
static void assign_tcp_keepalives_count (int newval, void *extra)
 
static void assign_tcp_user_timeout (int newval, void *extra)
 
static const char * show_tcp_keepalives_idle (void)
 
static const char * show_tcp_keepalives_interval (void)
 
static const char * show_tcp_keepalives_count (void)
 
static const char * show_tcp_user_timeout (void)
 
static bool check_maxconnections (int *newval, void **extra, GucSource source)
 
static bool check_max_worker_processes (int *newval, void **extra, GucSource source)
 
static bool check_autovacuum_max_workers (int *newval, void **extra, GucSource source)
 
static bool check_max_wal_senders (int *newval, void **extra, GucSource source)
 
static bool check_autovacuum_work_mem (int *newval, void **extra, GucSource source)
 
static bool check_effective_io_concurrency (int *newval, void **extra, GucSource source)
 
static bool check_maintenance_io_concurrency (int *newval, void **extra, GucSource source)
 
static bool check_huge_page_size (int *newval, void **extra, GucSource source)
 
static bool check_client_connection_check_interval (int *newval, void **extra, GucSource source)
 
static void assign_pgstat_temp_directory (const char *newval, void *extra)
 
static bool check_application_name (char **newval, void **extra, GucSource source)
 
static void assign_application_name (const char *newval, void *extra)
 
static bool check_cluster_name (char **newval, void **extra, GucSource source)
 
static const char * show_unix_socket_permissions (void)
 
static const char * show_log_file_mode (void)
 
static const char * show_data_directory_mode (void)
 
static const char * show_in_hot_standby (void)
 
static bool check_backtrace_functions (char **newval, void **extra, GucSource source)
 
static void assign_backtrace_functions (const char *newval, void *extra)
 
static bool check_recovery_target_timeline (char **newval, void **extra, GucSource source)
 
static void assign_recovery_target_timeline (const char *newval, void *extra)
 
static bool check_recovery_target (char **newval, void **extra, GucSource source)
 
static void assign_recovery_target (const char *newval, void *extra)
 
static bool check_recovery_target_xid (char **newval, void **extra, GucSource source)
 
static void assign_recovery_target_xid (const char *newval, void *extra)
 
static bool check_recovery_target_time (char **newval, void **extra, GucSource source)
 
static void assign_recovery_target_time (const char *newval, void *extra)
 
static bool check_recovery_target_name (char **newval, void **extra, GucSource source)
 
static void assign_recovery_target_name (const char *newval, void *extra)
 
static bool check_recovery_target_lsn (char **newval, void **extra, GucSource source)
 
static void assign_recovery_target_lsn (const char *newval, void *extra)
 
static bool check_primary_slot_name (char **newval, void **extra, GucSource source)
 
static bool check_default_with_oids (bool *newval, void **extra, GucSource source)
 
static ConfigVariableProcessConfigFileInternal (GucContext context, bool applySettings, int elevel)
 
 StaticAssertDecl (lengthof(bytea_output_options)==(BYTEA_OUTPUT_HEX+2), "array length mismatch")
 
 StaticAssertDecl (lengthof(intervalstyle_options)==(INTSTYLE_ISO_8601+2), "array length mismatch")
 
 StaticAssertDecl (lengthof(log_error_verbosity_options)==(PGERROR_VERBOSE+2), "array length mismatch")
 
 StaticAssertDecl (lengthof(log_statement_options)==(LOGSTMT_ALL+2), "array length mismatch")
 
 StaticAssertDecl (lengthof(session_replication_role_options)==(SESSION_REPLICATION_ROLE_LOCAL+2), "array length mismatch")
 
 StaticAssertDecl (lengthof(track_function_options)==(TRACK_FUNC_ALL+2), "array length mismatch")
 
 StaticAssertDecl (lengthof(xmlbinary_options)==(XMLBINARY_HEX+2), "array length mismatch")
 
 StaticAssertDecl (lengthof(xmloption_options)==(XMLOPTION_CONTENT+2), "array length mismatch")
 
 StaticAssertDecl (lengthof(ssl_protocol_versions_info)==(PG_TLS1_3_VERSION+2), "array length mismatch")
 
 StaticAssertDecl (lengthof(GucContext_Names)==(PGC_USERSET+1), "array length mismatch")
 
 StaticAssertDecl (lengthof(GucSource_Names)==(PGC_S_SESSION+1), "array length mismatch")
 
 StaticAssertDecl (lengthof(config_group_names)==(DEVELOPER_OPTIONS+2), "array length mismatch")
 
 StaticAssertDecl (lengthof(config_type_names)==(PGC_ENUM+1), "array length mismatch")
 
static int guc_var_compare (const void *a, const void *b)
 
static int guc_name_compare (const char *namea, const char *nameb)
 
static void InitializeGUCOptionsFromEnvironment (void)
 
static void InitializeOneGUCOption (struct config_generic *gconf)
 
static void push_old_value (struct config_generic *gconf, GucAction action)
 
static void ReportGUCOption (struct config_generic *record)
 
static void reapply_stacked_values (struct config_generic *variable, struct config_string *pHolder, GucStack *stack, const char *curvalue, GucContext curscontext, GucSource cursource)
 
static void ShowGUCConfigOption (const char *name, DestReceiver *dest)
 
static void ShowAllGUCConfig (DestReceiver *dest)
 
static char * _ShowOption (struct config_generic *record, bool use_units)
 
static bool validate_option_array_item (const char *name, const char *value, bool skipIfNoPermissions)
 
static void write_auto_conf_file (int fd, const char *filename, ConfigVariable *head_p)
 
static void replace_auto_config_value (ConfigVariable **head_p, ConfigVariable **tail_p, const char *name, const char *value)
 
static void * guc_malloc (int elevel, size_t size)
 
static void * guc_realloc (int elevel, void *old, size_t size)
 
static char * guc_strdup (int elevel, const char *src)
 
static bool string_field_used (struct config_string *conf, char *strval)
 
static void set_string_field (struct config_string *conf, char **field, char *newval)
 
static bool extra_field_used (struct config_generic *gconf, void *extra)
 
static void set_extra_field (struct config_generic *gconf, void **field, void *newval)
 
static void set_stack_value (struct config_generic *gconf, config_var_value *val)
 
static void discard_stack_value (struct config_generic *gconf, config_var_value *val)
 
struct config_generic ** get_guc_variables (void)
 
void build_guc_variables (void)
 
static bool add_guc_variable (struct config_generic *var, int elevel)
 
static bool valid_custom_variable_name (const char *name)
 
static struct config_genericadd_placeholder_variable (const char *name, int elevel)
 
static struct config_genericfind_option (const char *name, bool create_placeholders, bool skip_errors, int elevel)
 
void InitializeGUCOptions (void)
 
bool SelectConfigFiles (const char *userDoption, const char *progname)
 
void ResetAllOptions (void)
 
void AtStart_GUC (void)
 
int NewGUCNestLevel (void)
 
void AtEOXact_GUC (bool isCommit, int nestLevel)
 
void BeginReportingGUCOptions (void)
 
void ReportChangedGUCOptions (void)
 
static bool convert_to_base_unit (double value, const char *unit, int base_unit, double *base_value)
 
static void convert_int_from_base_unit (int64 base_value, int base_unit, int64 *value, const char **unit)
 
static void convert_real_from_base_unit (double base_value, int base_unit, double *value, const char **unit)
 
static const char * get_config_unit_name (int flags)
 
bool parse_int (const char *value, int *result, int flags, const char **hintmsg)
 
bool parse_real (const char *value, double *result, int flags, const char **hintmsg)
 
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)
 
static char * config_enum_get_options (struct config_enum *record, const char *prefix, const char *suffix, const char *separator)
 
static bool parse_and_validate_value (struct config_generic *record, const char *name, const char *value, GucSource source, int elevel, union config_var_val *newval, void **newextra)
 
int set_config_option (const char *name, const char *value, GucContext context, GucSource source, GucAction action, bool changeVal, int elevel, bool is_reload)
 
void SetConfigOption (const char *name, const char *value, GucContext context, GucSource source)
 
const char * GetConfigOption (const char *name, bool missing_ok, bool restrict_privileged)
 
const char * GetConfigOptionResetString (const char *name)
 
int GetConfigOptionFlags (const char *name, bool missing_ok)
 
static char * flatten_set_variable_args (const char *name, List *args)
 
void AlterSystemSetConfigFile (AlterSystemStmt *altersysstmt)
 
void ExecSetVariableStmt (VariableSetStmt *stmt, bool isTopLevel)
 
char * ExtractSetVariableArgs (VariableSetStmt *stmt)
 
void SetPGVariable (const char *name, List *args, bool is_local)
 
Datum set_config_by_name (PG_FUNCTION_ARGS)
 
static struct config_genericinit_custom_variable (const char *name, const char *short_desc, const char *long_desc, GucContext context, int flags, enum config_type type, size_t sz)
 
static void define_custom_variable (struct config_generic *variable)
 
void DefineCustomBoolVariable (const char *name, const char *short_desc, const char *long_desc, bool *valueAddr, bool bootValue, GucContext context, int flags, GucBoolCheckHook check_hook, GucBoolAssignHook assign_hook, GucShowHook show_hook)
 
void DefineCustomIntVariable (const char *name, const char *short_desc, const char *long_desc, int *valueAddr, int bootValue, int minValue, int maxValue, GucContext context, int flags, GucIntCheckHook check_hook, GucIntAssignHook assign_hook, GucShowHook show_hook)
 
void DefineCustomRealVariable (const char *name, const char *short_desc, const char *long_desc, double *valueAddr, double bootValue, double minValue, double maxValue, GucContext context, int flags, GucRealCheckHook check_hook, GucRealAssignHook assign_hook, GucShowHook show_hook)
 
void DefineCustomStringVariable (const char *name, const char *short_desc, const char *long_desc, char **valueAddr, const char *bootValue, GucContext context, int flags, GucStringCheckHook check_hook, GucStringAssignHook assign_hook, GucShowHook show_hook)
 
void DefineCustomEnumVariable (const char *name, const char *short_desc, const char *long_desc, int *valueAddr, int bootValue, const struct config_enum_entry *options, GucContext context, int flags, GucEnumCheckHook check_hook, GucEnumAssignHook assign_hook, GucShowHook show_hook)
 
void EmitWarningsOnPlaceholders (const char *className)
 
void GetPGVariable (const char *name, DestReceiver *dest)
 
TupleDesc GetPGVariableResultDesc (const char *name)
 
struct config_generic ** get_explain_guc_options (int *num)
 
char * GetConfigOptionByName (const char *name, const char **varname, bool missing_ok)
 
void GetConfigOptionByNum (int varnum, const char **values, bool *noshow)
 
int GetNumConfigOptions (void)
 
Datum show_config_by_name (PG_FUNCTION_ARGS)
 
Datum show_config_by_name_missing_ok (PG_FUNCTION_ARGS)
 
Datum show_all_settings (PG_FUNCTION_ARGS)
 
Datum show_all_file_settings (PG_FUNCTION_ARGS)
 
static bool can_skip_gucvar (struct config_generic *gconf)
 
static Size estimate_variable_size (struct config_generic *gconf)
 
Size EstimateGUCStateSpace (void)
 
static void do_serialize_binary (char **destptr, Size *maxbytes, void *val, Size valsize)
 
static void serialize_variable (char **destptr, Size *maxbytes, struct config_generic *gconf)
 
void SerializeGUCState (Size maxsize, char *start_address)
 
static char * read_gucstate (char **srcptr, char *srcend)
 
static void read_gucstate_binary (char **srcptr, char *srcend, void *dest, Size size)
 
static void guc_restore_error_context_callback (void *arg)
 
void RestoreGUCState (void *gucstate)
 
void ParseLongOption (const char *string, char **name, char **value)
 
void ProcessGUCArray (ArrayType *array, GucContext context, GucSource source, GucAction action)
 
ArrayTypeGUCArrayAdd (ArrayType *array, const char *name, const char *value)
 
ArrayTypeGUCArrayDelete (ArrayType *array, const char *name)
 
ArrayTypeGUCArrayReset (ArrayType *array)
 
void GUC_check_errcode (int sqlerrcode)
 
static void pg_attribute_noreturn () error_multiple_recovery_targets(void)
 

Variables

bool Log_disconnections
 
int CommitDelay
 
int CommitSiblings
 
char * default_tablespace
 
char * temp_tablespaces
 
bool ignore_checksum_failure
 
bool ignore_invalid_pages
 
bool synchronize_seqscans
 
static int GUC_check_errcode_value
 
char * GUC_check_errmsg_string
 
char * GUC_check_errdetail_string
 
char * GUC_check_errhint_string
 
static int syslog_facility = 0
 
static const struct config_enum_entry bytea_output_options []
 
static const struct config_enum_entry client_message_level_options []
 
static const struct config_enum_entry server_message_level_options []
 
static const struct config_enum_entry intervalstyle_options []
 
static const struct config_enum_entry log_error_verbosity_options []
 
static const struct config_enum_entry log_statement_options []
 
static const struct config_enum_entry isolation_level_options []
 
static const struct config_enum_entry session_replication_role_options []
 
static const struct config_enum_entry syslog_facility_options []
 
static const struct config_enum_entry track_function_options []
 
static const struct config_enum_entry xmlbinary_options []
 
static const struct config_enum_entry xmloption_options []
 
static const struct config_enum_entry backslash_quote_options []
 
static const struct config_enum_entry compute_query_id_options []
 
static const struct config_enum_entry constraint_exclusion_options []
 
static const struct config_enum_entry synchronous_commit_options []
 
static const struct config_enum_entry huge_pages_options []
 
static const struct config_enum_entry force_parallel_mode_options []
 
static const struct config_enum_entry plan_cache_mode_options []
 
static const struct config_enum_entry password_encryption_options []
 
const struct config_enum_entry ssl_protocol_versions_info []
 
static struct config_enum_entry recovery_init_sync_method_options []
 
static struct config_enum_entry shared_memory_options []
 
static struct config_enum_entry default_toast_compression_options []
 
static const struct config_enum_entry wal_compression_options []
 
const struct config_enum_entry wal_level_options []
 
const struct config_enum_entry archive_mode_options []
 
const struct config_enum_entry recovery_target_action_options []
 
const struct config_enum_entry sync_method_options []
 
const struct config_enum_entry dynamic_shared_memory_options []
 
bool log_duration = false
 
bool Debug_print_plan = false
 
bool Debug_print_parse = false
 
bool Debug_print_rewritten = false
 
bool Debug_pretty_print = true
 
bool log_parser_stats = false
 
bool log_planner_stats = false
 
bool log_executor_stats = false
 
bool log_statement_stats = false
 
bool log_btree_build_stats = false
 
char * event_source
 
bool row_security
 
bool check_function_bodies = true
 
bool default_with_oids = false
 
bool session_auth_is_superuser
 
int log_min_error_statement = ERROR
 
int log_min_messages = WARNING
 
int client_min_messages = NOTICE
 
int log_min_duration_sample = -1
 
int log_min_duration_statement = -1
 
int log_parameter_max_length = -1
 
int log_parameter_max_length_on_error = 0
 
int log_temp_files = -1
 
double log_statement_sample_rate = 1.0
 
double log_xact_sample_rate = 0
 
int trace_recovery_messages = LOG
 
char * backtrace_functions
 
char * backtrace_symbol_list
 
int temp_file_limit = -1
 
int num_temp_buffers = 1024
 
char * cluster_name = ""
 
char * ConfigFileName
 
char * HbaFileName
 
char * IdentFileName
 
char * external_pid_file
 
char * pgstat_temp_directory
 
char * application_name
 
int tcp_keepalives_idle
 
int tcp_keepalives_interval
 
int tcp_keepalives_count
 
int tcp_user_timeout
 
int ssl_renegotiation_limit
 
int huge_pages
 
int huge_page_size
 
static char * syslog_ident_str
 
static double phony_random_seed
 
static char * client_encoding_string
 
static char * datestyle_string
 
static char * locale_collate
 
static char * locale_ctype
 
static char * server_encoding_string
 
static char * server_version_string
 
static int server_version_num
 
static char * timezone_string
 
static char * log_timezone_string
 
static char * timezone_abbreviations_string
 
static char * data_directory
 
static char * session_authorization_string
 
static int max_function_args
 
static int max_index_keys
 
static int max_identifier_length
 
static int block_size
 
static int segment_size
 
static int shared_memory_size_mb
 
static int shared_memory_size_in_huge_pages
 
static int wal_block_size
 
static bool data_checksums
 
static bool integer_datetimes
 
static bool assert_enabled
 
static bool in_hot_standby
 
static char * recovery_target_timeline_string
 
static char * recovery_target_string
 
static char * recovery_target_xid_string
 
static char * recovery_target_name_string
 
static char * recovery_target_lsn_string
 
char * role_string
 
const char *const GucContext_Names []
 
const char *const GucSource_Names []
 
const char *const config_group_names []
 
const char *const config_type_names []
 
static const char * memory_units_hint = gettext_noop("Valid units for this parameter are \"B\", \"kB\", \"MB\", \"GB\", and \"TB\".")
 
static const unit_conversion memory_unit_conversion_table []
 
static const char * time_units_hint = gettext_noop("Valid units for this parameter are \"us\", \"ms\", \"s\", \"min\", \"h\", and \"d\".")
 
static const unit_conversion time_unit_conversion_table []
 
static struct config_bool ConfigureNamesBool []
 
static struct config_int ConfigureNamesInt []
 
static struct config_real ConfigureNamesReal []
 
static struct config_string ConfigureNamesString []
 
static struct config_enum ConfigureNamesEnum []
 
static const char *const map_old_guc_names []
 
static struct config_generic ** guc_variables
 
static int num_guc_variables
 
static int size_guc_variables
 
static bool guc_dirty
 
static bool reporting_enabled
 
static bool report_needed
 
static int GUCNestLevel = 0
 

Macro Definition Documentation

◆ CONFIG_FILENAME

#define CONFIG_FILENAME   "postgresql.conf"

Definition at line 118 of file guc.c.

◆ HBA_FILENAME

#define HBA_FILENAME   "pg_hba.conf"

Definition at line 119 of file guc.c.

◆ IDENT_FILENAME

#define IDENT_FILENAME   "pg_ident.conf"

Definition at line 120 of file guc.c.

◆ MAX_UNIT_LEN

#define MAX_UNIT_LEN   3 /* length of longest recognized unit string */

Definition at line 860 of file guc.c.

◆ newval [1/5]

#define newval   (newval_union.boolval)

◆ newval [2/5]

#define newval   (newval_union.intval)

◆ newval [3/5]

#define newval   (newval_union.realval)

◆ newval [4/5]

#define newval   (newval_union.stringval)

◆ newval [5/5]

#define newval   (newval_union.enumval)

◆ NUM_PG_FILE_SETTINGS_ATTS

#define NUM_PG_FILE_SETTINGS_ATTS   7

◆ NUM_PG_SETTINGS_ATTS

#define NUM_PG_SETTINGS_ATTS   17

Definition at line 9919 of file guc.c.

◆ PG_KRB_SRVTAB

#define PG_KRB_SRVTAB   ""

Definition at line 115 of file guc.c.

◆ REALTYPE_PRECISION

#define REALTYPE_PRECISION   17

Definition at line 131 of file guc.c.

Function Documentation

◆ _ShowOption()

static char * _ShowOption ( struct config_generic record,
bool  use_units 
)
static

Definition at line 10165 of file guc.c.

10166 {
10167  char buffer[256];
10168  const char *val;
10169 
10170  switch (record->vartype)
10171  {
10172  case PGC_BOOL:
10173  {
10174  struct config_bool *conf = (struct config_bool *) record;
10175 
10176  if (conf->show_hook)
10177  val = conf->show_hook();
10178  else
10179  val = *conf->variable ? "on" : "off";
10180  }
10181  break;
10182 
10183  case PGC_INT:
10184  {
10185  struct config_int *conf = (struct config_int *) record;
10186 
10187  if (conf->show_hook)
10188  val = conf->show_hook();
10189  else
10190  {
10191  /*
10192  * Use int64 arithmetic to avoid overflows in units
10193  * conversion.
10194  */
10195  int64 result = *conf->variable;
10196  const char *unit;
10197 
10198  if (use_units && result > 0 && (record->flags & GUC_UNIT))
10200  record->flags & GUC_UNIT,
10201  &result, &unit);
10202  else
10203  unit = "";
10204 
10205  snprintf(buffer, sizeof(buffer), INT64_FORMAT "%s",
10206  result, unit);
10207  val = buffer;
10208  }
10209  }
10210  break;
10211 
10212  case PGC_REAL:
10213  {
10214  struct config_real *conf = (struct config_real *) record;
10215 
10216  if (conf->show_hook)
10217  val = conf->show_hook();
10218  else
10219  {
10220  double result = *conf->variable;
10221  const char *unit;
10222 
10223  if (use_units && result > 0 && (record->flags & GUC_UNIT))
10225  record->flags & GUC_UNIT,
10226  &result, &unit);
10227  else
10228  unit = "";
10229 
10230  snprintf(buffer, sizeof(buffer), "%g%s",
10231  result, unit);
10232  val = buffer;
10233  }
10234  }
10235  break;
10236 
10237  case PGC_STRING:
10238  {
10239  struct config_string *conf = (struct config_string *) record;
10240 
10241  if (conf->show_hook)
10242  val = conf->show_hook();
10243  else if (*conf->variable && **conf->variable)
10244  val = *conf->variable;
10245  else
10246  val = "";
10247  }
10248  break;
10249 
10250  case PGC_ENUM:
10251  {
10252  struct config_enum *conf = (struct config_enum *) record;
10253 
10254  if (conf->show_hook)
10255  val = conf->show_hook();
10256  else
10257  val = config_enum_lookup_by_value(conf, *conf->variable);
10258  }
10259  break;
10260 
10261  default:
10262  /* just to keep compiler quiet */
10263  val = "???";
10264  break;
10265  }
10266 
10267  return pstrdup(val);
10268 }
#define INT64_FORMAT
Definition: c.h:483
const char * config_enum_lookup_by_value(struct config_enum *record, int val)
Definition: guc.c:7042
static void convert_int_from_base_unit(int64 base_value, int base_unit, int64 *value, const char **unit)
Definition: guc.c:6748
static void convert_real_from_base_unit(double base_value, int base_unit, double *value, const char **unit)
Definition: guc.c:6790
#define GUC_UNIT
Definition: guc.h:237
@ 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
long val
Definition: informix.c:664
char * pstrdup(const char *in)
Definition: mcxt.c:1299
#define snprintf
Definition: port.h:225
bool * variable
Definition: guc_tables.h:179
GucShowHook show_hook
Definition: guc_tables.h:183
int * variable
Definition: guc_tables.h:239
GucShowHook show_hook
Definition: guc_tables.h:244
enum config_type vartype
Definition: guc_tables.h:148
int * variable
Definition: guc_tables.h:193
GucShowHook show_hook
Definition: guc_tables.h:199
double * variable
Definition: guc_tables.h:209
GucShowHook show_hook
Definition: guc_tables.h:215
GucShowHook show_hook
Definition: guc_tables.h:229
char ** variable
Definition: guc_tables.h:225

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(), GetConfigOptionByNum(), ReportGUCOption(), and ShowAllGUCConfig().

◆ add_guc_variable()

static bool add_guc_variable ( struct config_generic var,
int  elevel 
)
static

Definition at line 5406 of file guc.c.

5407 {
5409  {
5410  /*
5411  * Increase the vector by 25%
5412  */
5413  int size_vars = size_guc_variables + size_guc_variables / 4;
5414  struct config_generic **guc_vars;
5415 
5416  if (size_vars == 0)
5417  {
5418  size_vars = 100;
5419  guc_vars = (struct config_generic **)
5420  guc_malloc(elevel, size_vars * sizeof(struct config_generic *));
5421  }
5422  else
5423  {
5424  guc_vars = (struct config_generic **)
5425  guc_realloc(elevel, guc_variables, size_vars * sizeof(struct config_generic *));
5426  }
5427 
5428  if (guc_vars == NULL)
5429  return false; /* out of memory */
5430 
5431  guc_variables = guc_vars;
5432  size_guc_variables = size_vars;
5433  }
5436  sizeof(struct config_generic *), guc_var_compare);
5437  return true;
5438 }
static struct config_generic ** guc_variables
Definition: guc.c:5053
static void * guc_malloc(int elevel, size_t size)
Definition: guc.c:5096
static int guc_var_compare(const void *a, const void *b)
Definition: guc.c:5611
static int num_guc_variables
Definition: guc.c:5056
static int size_guc_variables
Definition: guc.c:5059
static void * guc_realloc(int elevel, void *old, size_t size)
Definition: guc.c:5112
#define qsort(a, b, c, d)
Definition: port.h:495

References guc_malloc(), guc_realloc(), guc_var_compare(), guc_variables, num_guc_variables, qsort, and size_guc_variables.

Referenced by add_placeholder_variable(), and define_custom_variable().

◆ add_placeholder_variable()

static struct config_generic* add_placeholder_variable ( const char *  name,
int  elevel 
)
static

Definition at line 5484 of file guc.c.

5485 {
5486  size_t sz = sizeof(struct config_string) + sizeof(char *);
5487  struct config_string *var;
5488  struct config_generic *gen;
5489 
5490  var = (struct config_string *) guc_malloc(elevel, sz);
5491  if (var == NULL)
5492  return NULL;
5493  memset(var, 0, sz);
5494  gen = &var->gen;
5495 
5496  gen->name = guc_strdup(elevel, name);
5497  if (gen->name == NULL)
5498  {
5499  free(var);
5500  return NULL;
5501  }
5502 
5503  gen->context = PGC_USERSET;
5505  gen->short_desc = "GUC placeholder variable";
5507  gen->vartype = PGC_STRING;
5508 
5509  /*
5510  * The char* is allocated at the end of the struct since we have no
5511  * 'static' place to point to. Note that the current value, as well as
5512  * the boot and reset values, start out NULL.
5513  */
5514  var->variable = (char **) (var + 1);
5515 
5516  if (!add_guc_variable((struct config_generic *) var, elevel))
5517  {
5518  free(unconstify(char *, gen->name));
5519  free(var);
5520  return NULL;
5521  }
5522 
5523  return gen;
5524 }
#define unconstify(underlying_type, expr)
Definition: c.h:1240
const char * name
Definition: encode.c:561
static bool add_guc_variable(struct config_generic *var, int elevel)
Definition: guc.c:5406
static char * guc_strdup(int elevel, const char *src)
Definition: guc.c:5128
#define GUC_CUSTOM_PLACEHOLDER
Definition: guc.h:211
#define GUC_NO_SHOW_ALL
Definition: guc.h:206
@ PGC_USERSET
Definition: guc.h:76
#define GUC_NOT_IN_SAMPLE
Definition: guc.h:209
@ CUSTOM_OPTIONS
Definition: guc_tables.h:96
#define free(a)
Definition: header.h:65
enum config_group group
Definition: guc_tables.h:143
GucContext context
Definition: guc_tables.h:142
const char * name
Definition: guc_tables.h:141
const char * short_desc
Definition: guc_tables.h:144
struct config_generic gen
Definition: guc_tables.h:223

References add_guc_variable(), config_generic::context, CUSTOM_OPTIONS, config_generic::flags, free, config_string::gen, config_generic::group, GUC_CUSTOM_PLACEHOLDER, guc_malloc(), GUC_NO_SHOW_ALL, GUC_NOT_IN_SAMPLE, guc_strdup(), name, config_generic::name, PGC_STRING, PGC_USERSET, config_generic::short_desc, unconstify, config_string::variable, and config_generic::vartype.

Referenced by find_option().

◆ AlterSystemSetConfigFile()

void AlterSystemSetConfigFile ( AlterSystemStmt altersysstmt)

Definition at line 8543 of file guc.c.

8544 {
8545  char *name;
8546  char *value;
8547  bool resetall = false;
8548  ConfigVariable *head = NULL;
8549  ConfigVariable *tail = NULL;
8550  volatile int Tmpfd;
8551  char AutoConfFileName[MAXPGPATH];
8552  char AutoConfTmpFileName[MAXPGPATH];
8553 
8554  if (!superuser())
8555  ereport(ERROR,
8556  (errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
8557  errmsg("must be superuser to execute ALTER SYSTEM command")));
8558 
8559  /*
8560  * Extract statement arguments
8561  */
8562  name = altersysstmt->setstmt->name;
8563 
8564  switch (altersysstmt->setstmt->kind)
8565  {
8566  case VAR_SET_VALUE:
8567  value = ExtractSetVariableArgs(altersysstmt->setstmt);
8568  break;
8569 
8570  case VAR_SET_DEFAULT:
8571  case VAR_RESET:
8572  value = NULL;
8573  break;
8574 
8575  case VAR_RESET_ALL:
8576  value = NULL;
8577  resetall = true;
8578  break;
8579 
8580  default:
8581  elog(ERROR, "unrecognized alter system stmt type: %d",
8582  altersysstmt->setstmt->kind);
8583  break;
8584  }
8585 
8586  /*
8587  * Unless it's RESET_ALL, validate the target variable and value
8588  */
8589  if (!resetall)
8590  {
8591  struct config_generic *record;
8592 
8593  record = find_option(name, false, false, ERROR);
8594  Assert(record != NULL);
8595 
8596  /*
8597  * Don't allow parameters that can't be set in configuration files to
8598  * be set in PG_AUTOCONF_FILENAME file.
8599  */
8600  if ((record->context == PGC_INTERNAL) ||
8601  (record->flags & GUC_DISALLOW_IN_FILE) ||
8602  (record->flags & GUC_DISALLOW_IN_AUTO_FILE))
8603  ereport(ERROR,
8604  (errcode(ERRCODE_CANT_CHANGE_RUNTIME_PARAM),
8605  errmsg("parameter \"%s\" cannot be changed",
8606  name)));
8607 
8608  /*
8609  * If a value is specified, verify that it's sane.
8610  */
8611  if (value)
8612  {
8613  union config_var_val newval;
8614  void *newextra = NULL;
8615 
8616  /* Check that it's acceptable for the indicated parameter */
8617  if (!parse_and_validate_value(record, name, value,
8618  PGC_S_FILE, ERROR,
8619  &newval, &newextra))
8620  ereport(ERROR,
8621  (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
8622  errmsg("invalid value for parameter \"%s\": \"%s\"",
8623  name, value)));
8624 
8625  if (record->vartype == PGC_STRING && newval.stringval != NULL)
8626  free(newval.stringval);
8627  if (newextra)
8628  free(newextra);
8629 
8630  /*
8631  * We must also reject values containing newlines, because the
8632  * grammar for config files doesn't support embedded newlines in
8633  * string literals.
8634  */
8635  if (strchr(value, '\n'))
8636  ereport(ERROR,
8637  (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
8638  errmsg("parameter value for ALTER SYSTEM must not contain a newline")));
8639  }
8640  }
8641 
8642  /*
8643  * PG_AUTOCONF_FILENAME and its corresponding temporary file are always in
8644  * the data directory, so we can reference them by simple relative paths.
8645  */
8646  snprintf(AutoConfFileName, sizeof(AutoConfFileName), "%s",
8648  snprintf(AutoConfTmpFileName, sizeof(AutoConfTmpFileName), "%s.%s",
8649  AutoConfFileName,
8650  "tmp");
8651 
8652  /*
8653  * Only one backend is allowed to operate on PG_AUTOCONF_FILENAME at a
8654  * time. Use AutoFileLock to ensure that. We must hold the lock while
8655  * reading the old file contents.
8656  */
8657  LWLockAcquire(AutoFileLock, LW_EXCLUSIVE);
8658 
8659  /*
8660  * If we're going to reset everything, then no need to open or parse the
8661  * old file. We'll just write out an empty list.
8662  */
8663  if (!resetall)
8664  {
8665  struct stat st;
8666 
8667  if (stat(AutoConfFileName, &st) == 0)
8668  {
8669  /* open old file PG_AUTOCONF_FILENAME */
8670  FILE *infile;
8671 
8672  infile = AllocateFile(AutoConfFileName, "r");
8673  if (infile == NULL)
8674  ereport(ERROR,
8676  errmsg("could not open file \"%s\": %m",
8677  AutoConfFileName)));
8678 
8679  /* parse it */
8680  if (!ParseConfigFp(infile, AutoConfFileName, 0, LOG, &head, &tail))
8681  ereport(ERROR,
8682  (errcode(ERRCODE_CONFIG_FILE_ERROR),
8683  errmsg("could not parse contents of file \"%s\"",
8684  AutoConfFileName)));
8685 
8686  FreeFile(infile);
8687  }
8688 
8689  /*
8690  * Now, replace any existing entry with the new value, or add it if
8691  * not present.
8692  */
8693  replace_auto_config_value(&head, &tail, name, value);
8694  }
8695 
8696  /*
8697  * To ensure crash safety, first write the new file data to a temp file,
8698  * then atomically rename it into place.
8699  *
8700  * If there is a temp file left over due to a previous crash, it's okay to
8701  * truncate and reuse it.
8702  */
8703  Tmpfd = BasicOpenFile(AutoConfTmpFileName,
8704  O_CREAT | O_RDWR | O_TRUNC);
8705  if (Tmpfd < 0)
8706  ereport(ERROR,
8708  errmsg("could not open file \"%s\": %m",
8709  AutoConfTmpFileName)));
8710 
8711  /*
8712  * Use a TRY block to clean up the file if we fail. Since we need a TRY
8713  * block anyway, OK to use BasicOpenFile rather than OpenTransientFile.
8714  */
8715  PG_TRY();
8716  {
8717  /* Write and sync the new contents to the temporary file */
8718  write_auto_conf_file(Tmpfd, AutoConfTmpFileName, head);
8719 
8720  /* Close before renaming; may be required on some platforms */
8721  close(Tmpfd);
8722  Tmpfd = -1;
8723 
8724  /*
8725  * As the rename is atomic operation, if any problem occurs after this
8726  * at worst it can lose the parameters set by last ALTER SYSTEM
8727  * command.
8728  */
8729  durable_rename(AutoConfTmpFileName, AutoConfFileName, ERROR);
8730  }
8731  PG_CATCH();
8732  {
8733  /* Close file first, else unlink might fail on some platforms */
8734  if (Tmpfd >= 0)
8735  close(Tmpfd);
8736 
8737  /* Unlink, but ignore any error */
8738  (void) unlink(AutoConfTmpFileName);
8739 
8740  PG_RE_THROW();
8741  }
8742  PG_END_TRY();
8743 
8744  FreeConfigVariables(head);
8745 
8746  LWLockRelease(AutoFileLock);
8747 }
int errcode_for_file_access(void)
Definition: elog.c:716
int errcode(int sqlerrcode)
Definition: elog.c:693
int errmsg(const char *fmt,...)
Definition: elog.c:904
#define LOG
Definition: elog.h:25
#define PG_RE_THROW()
Definition: elog.h:340
#define PG_END_TRY()
Definition: elog.h:324
#define PG_TRY()
Definition: elog.h:299
#define ERROR
Definition: elog.h:33
#define elog(elevel,...)
Definition: elog.h:218
#define PG_CATCH()
Definition: elog.h:309
#define ereport(elevel,...)
Definition: elog.h:143
FILE * AllocateFile(const char *name, const char *mode)
Definition: fd.c:2461
int durable_rename(const char *oldfile, const char *newfile, int elevel)
Definition: fd.c:699
int BasicOpenFile(const char *fileName, int fileFlags)
Definition: fd.c:1071
int FreeFile(FILE *file)
Definition: fd.c:2660
static bool parse_and_validate_value(struct config_generic *record, const char *name, const char *value, GucSource source, int elevel, union config_var_val *newval, void **newextra)
Definition: guc.c:7149
#define newval
char * ExtractSetVariableArgs(VariableSetStmt *stmt)
Definition: guc.c:8876
static void write_auto_conf_file(int fd, const char *filename, ConfigVariable *head_p)
Definition: guc.c:8405
static struct config_generic * find_option(const char *name, bool create_placeholders, bool skip_errors, int elevel)
Definition: guc.c:5542
static void replace_auto_config_value(ConfigVariable **head_p, ConfigVariable **tail_p, const char *name, const char *value)
Definition: guc.c:8473
#define PG_AUTOCONF_FILENAME
Definition: guc.h:34
void FreeConfigVariables(ConfigVariable *list)
bool ParseConfigFp(FILE *fp, const char *config_file, int depth, int elevel, ConfigVariable **head_p, ConfigVariable **tail_p)
#define GUC_DISALLOW_IN_FILE
Definition: guc.h:210
@ PGC_S_FILE
Definition: guc.h:109
#define GUC_DISALLOW_IN_AUTO_FILE
Definition: guc.h:215
@ PGC_INTERNAL
Definition: guc.h:70
static struct @142 value
#define close(a)
Definition: win32.h:12
Assert(fmt[strlen(fmt) - 1] !='\n')
bool LWLockAcquire(LWLock *lock, LWLockMode mode)
Definition: lwlock.c:1199
void LWLockRelease(LWLock *lock)
Definition: lwlock.c:1803
@ LW_EXCLUSIVE
Definition: lwlock.h:104
@ VAR_SET_DEFAULT
Definition: parsenodes.h:2144
@ VAR_RESET
Definition: parsenodes.h:2147
@ VAR_SET_VALUE
Definition: parsenodes.h:2143
@ VAR_RESET_ALL
Definition: parsenodes.h:2148
#define MAXPGPATH
VariableSetStmt * setstmt
Definition: parsenodes.h:3334
VariableSetKind kind
Definition: parsenodes.h:2154
bool superuser(void)
Definition: superuser.c:46
#define stat
Definition: win32_port.h:283
static void infile(const char *filename)
Definition: zic.c:1241

References AllocateFile(), Assert(), BasicOpenFile(), close, config_generic::context, durable_rename(), elog, ereport, errcode(), errcode_for_file_access(), errmsg(), ERROR, ExtractSetVariableArgs(), find_option(), config_generic::flags, free, FreeConfigVariables(), FreeFile(), GUC_DISALLOW_IN_AUTO_FILE, GUC_DISALLOW_IN_FILE, infile(), VariableSetStmt::kind, LOG, LW_EXCLUSIVE, LWLockAcquire(), LWLockRelease(), MAXPGPATH, name, VariableSetStmt::name, newval, parse_and_validate_value(), ParseConfigFp(), PG_AUTOCONF_FILENAME, PG_CATCH, PG_END_TRY, PG_RE_THROW, PG_TRY, PGC_INTERNAL, PGC_S_FILE, PGC_STRING, replace_auto_config_value(), AlterSystemStmt::setstmt, snprintf, stat, superuser(), value, VAR_RESET, VAR_RESET_ALL, VAR_SET_DEFAULT, VAR_SET_VALUE, config_generic::vartype, and write_auto_conf_file().

Referenced by standard_ProcessUtility().

◆ assign_application_name()

static void assign_application_name ( const char *  newval,
void *  extra 
)
static

Definition at line 12196 of file guc.c.

12197 {
12198  /* Update the pg_stat_activity view */
12200 }
void pgstat_report_appname(const char *appname)

References newval, and pgstat_report_appname().

◆ assign_backtrace_functions()

static void assign_backtrace_functions ( const char *  newval,
void *  extra 
)
static

Definition at line 12315 of file guc.c.

12316 {
12317  backtrace_symbol_list = (char *) extra;
12318 }
char * backtrace_symbol_list
Definition: guc.c:609

References backtrace_symbol_list, and config_generic::extra.

◆ assign_log_destination()

static void assign_log_destination ( const char *  newval,
void *  extra 
)
static

Definition at line 11785 of file guc.c.

11786 {
11787  Log_destination = *((int *) extra);
11788 }
int Log_destination
Definition: elog.c:111

References config_generic::extra, and Log_destination.

◆ assign_pgstat_temp_directory()

static void assign_pgstat_temp_directory ( const char *  newval,
void *  extra 
)
static

Definition at line 12158 of file guc.c.

12159 {
12160  /* check_canonical_path already canonicalized newval for us */
12161  char *dname;
12162  char *tname;
12163  char *fname;
12164 
12165  /* directory */
12166  dname = guc_malloc(ERROR, strlen(newval) + 1); /* runtime dir */
12167  sprintf(dname, "%s", newval);
12168 
12169  /* global stats */
12170  tname = guc_malloc(ERROR, strlen(newval) + 12); /* /global.tmp */
12171  sprintf(tname, "%s/global.tmp", newval);
12172  fname = guc_malloc(ERROR, strlen(newval) + 13); /* /global.stat */
12173  sprintf(fname, "%s/global.stat", newval);
12174 
12177  pgstat_stat_directory = dname;
12178  if (pgstat_stat_tmpname)
12180  pgstat_stat_tmpname = tname;
12183  pgstat_stat_filename = fname;
12184 }
char * pgstat_stat_directory
Definition: pgstat.c:118
char * pgstat_stat_filename
Definition: pgstat.c:119
char * pgstat_stat_tmpname
Definition: pgstat.c:120
#define sprintf
Definition: port.h:227

References ERROR, free, guc_malloc(), newval, pgstat_stat_directory, pgstat_stat_filename, pgstat_stat_tmpname, and sprintf.

◆ assign_recovery_target()

static void assign_recovery_target ( const char *  newval,
void *  extra 
)
static

Definition at line 12394 of file guc.c.

12395 {
12398  error_multiple_recovery_targets();
12399 
12400  if (newval && strcmp(newval, "") != 0)
12402  else
12404 }
RecoveryTargetType recoveryTarget
Definition: xlog.c:271
@ RECOVERY_TARGET_IMMEDIATE
Definition: xlog.h:43
@ RECOVERY_TARGET_UNSET
Definition: xlog.h:38

References newval, RECOVERY_TARGET_IMMEDIATE, RECOVERY_TARGET_UNSET, and recoveryTarget.

◆ assign_recovery_target_lsn()

static void assign_recovery_target_lsn ( const char *  newval,
void *  extra 
)
static

Definition at line 12562 of file guc.c.

12563 {
12566  error_multiple_recovery_targets();
12567 
12568  if (newval && strcmp(newval, "") != 0)
12569  {
12571  recoveryTargetLSN = *((XLogRecPtr *) extra);
12572  }
12573  else
12575 }
XLogRecPtr recoveryTargetLSN
Definition: xlog.c:278
@ RECOVERY_TARGET_LSN
Definition: xlog.h:42
uint64 XLogRecPtr
Definition: xlogdefs.h:21

References newval, RECOVERY_TARGET_LSN, RECOVERY_TARGET_UNSET, recoveryTarget, and recoveryTargetLSN.

◆ assign_recovery_target_name()

static void assign_recovery_target_name ( const char *  newval,
void *  extra 
)
static

Definition at line 12526 of file guc.c.

12527 {
12530  error_multiple_recovery_targets();
12531 
12532  if (newval && strcmp(newval, "") != 0)
12533  {
12536  }
12537  else
12539 }
const char * recoveryTargetName
Definition: xlog.c:277
@ RECOVERY_TARGET_NAME
Definition: xlog.h:41

References newval, RECOVERY_TARGET_NAME, RECOVERY_TARGET_UNSET, recoveryTarget, and recoveryTargetName.

◆ assign_recovery_target_time()

static void assign_recovery_target_time ( const char *  newval,
void *  extra 
)
static

Definition at line 12500 of file guc.c.

12501 {
12504  error_multiple_recovery_targets();
12505 
12506  if (newval && strcmp(newval, "") != 0)
12508  else
12510 }
@ RECOVERY_TARGET_TIME
Definition: xlog.h:40

References newval, RECOVERY_TARGET_TIME, RECOVERY_TARGET_UNSET, and recoveryTarget.

◆ assign_recovery_target_timeline()

static void assign_recovery_target_timeline ( const char *  newval,
void *  extra 
)
static

Definition at line 12351 of file guc.c.

12352 {
12355  recoveryTargetTLIRequested = (TimeLineID) strtoul(newval, NULL, 0);
12356  else
12358 }
RecoveryTargetTimeLineGoal recoveryTargetTimeLineGoal
Definition: xlog.c:321
TimeLineID recoveryTargetTLIRequested
Definition: xlog.c:322
RecoveryTargetTimeLineGoal
Definition: xlog.h:50
@ RECOVERY_TARGET_TIMELINE_NUMERIC
Definition: xlog.h:53
uint32 TimeLineID
Definition: xlogdefs.h:59

References config_generic::extra, newval, RECOVERY_TARGET_TIMELINE_NUMERIC, recoveryTargetTimeLineGoal, and recoveryTargetTLIRequested.

◆ assign_recovery_target_xid()

static void assign_recovery_target_xid ( const char *  newval,
void *  extra 
)
static

Definition at line 12427 of file guc.c.

12428 {
12431  error_multiple_recovery_targets();
12432 
12433  if (newval && strcmp(newval, "") != 0)
12434  {
12436  recoveryTargetXid = *((TransactionId *) extra);
12437  }
12438  else
12440 }
uint32 TransactionId
Definition: c.h:587
TransactionId recoveryTargetXid
Definition: xlog.c:274
@ RECOVERY_TARGET_XID
Definition: xlog.h:39

References config_generic::extra, newval, RECOVERY_TARGET_UNSET, RECOVERY_TARGET_XID, recoveryTarget, and recoveryTargetXid.

◆ assign_session_replication_role()

static void assign_session_replication_role ( int  newval,
void *  extra 
)
static

Definition at line 11811 of file guc.c.

11812 {
11813  /*
11814  * Must flush the plan cache when changing replication role; but don't
11815  * flush unnecessarily.
11816  */
11818  ResetPlanCache();
11819 }
void ResetPlanCache(void)
Definition: plancache.c:2149
int SessionReplicationRole
Definition: trigger.c:68

References newval, ResetPlanCache(), and SessionReplicationRole.

◆ assign_syslog_facility()

static void assign_syslog_facility ( int  newval,
void *  extra 
)
static

Definition at line 11791 of file guc.c.

11792 {
11793 #ifdef HAVE_SYSLOG
11794  set_syslog_parameters(syslog_ident_str ? syslog_ident_str : "postgres",
11795  newval);
11796 #endif
11797  /* Without syslog support, just ignore it */
11798 }
static char * syslog_ident_str
Definition: guc.c:650

References newval, and syslog_ident_str.

◆ assign_syslog_ident()

static void assign_syslog_ident ( const char *  newval,
void *  extra 
)
static

Definition at line 11801 of file guc.c.

11802 {
11803 #ifdef HAVE_SYSLOG
11804  set_syslog_parameters(newval, syslog_facility);
11805 #endif
11806  /* Without syslog support, it will always be set to "none", so ignore */
11807 }
static int syslog_facility
Definition: guc.c:182

References newval, and syslog_facility.

◆ assign_tcp_keepalives_count()

static void assign_tcp_keepalives_count ( int  newval,
void *  extra 
)
static

Definition at line 12011 of file guc.c.

12012 {
12013  /* See comments in assign_tcp_keepalives_idle */
12015 }
struct Port * MyProcPort
Definition: globals.c:46
int pq_setkeepalivescount(int count, Port *port)
Definition: pqcomm.c:1837

References MyProcPort, newval, and pq_setkeepalivescount().

◆ assign_tcp_keepalives_idle()

static void assign_tcp_keepalives_idle ( int  newval,
void *  extra 
)
static

Definition at line 11967 of file guc.c.

11968 {
11969  /*
11970  * The kernel API provides no way to test a value without setting it; and
11971  * once we set it we might fail to unset it. So there seems little point
11972  * in fully implementing the check-then-assign GUC API for these
11973  * variables. Instead we just do the assignment on demand. pqcomm.c
11974  * reports any problems via ereport(LOG).
11975  *
11976  * This approach means that the GUC value might have little to do with the
11977  * actual kernel value, so we use a show_hook that retrieves the kernel
11978  * value rather than trusting GUC's copy.
11979  */
11981 }
int pq_setkeepalivesidle(int idle, Port *port)
Definition: pqcomm.c:1673

References MyProcPort, newval, and pq_setkeepalivesidle().

◆ assign_tcp_keepalives_interval()

static void assign_tcp_keepalives_interval ( int  newval,
void *  extra 
)
static

Definition at line 11994 of file guc.c.

11995 {
11996  /* See comments in assign_tcp_keepalives_idle */
11998 }
int pq_setkeepalivesinterval(int interval, Port *port)
Definition: pqcomm.c:1758

References MyProcPort, newval, and pq_setkeepalivesinterval().

◆ assign_tcp_user_timeout()

static void assign_tcp_user_timeout ( int  newval,
void *  extra 
)
static

Definition at line 12028 of file guc.c.

12029 {
12030  /* See comments in assign_tcp_keepalives_idle */
12032 }
int pq_settcpusertimeout(int timeout, Port *port)
Definition: pqcomm.c:1912

References MyProcPort, newval, and pq_settcpusertimeout().

◆ assign_timezone_abbreviations()

static void assign_timezone_abbreviations ( const char *  newval,
void *  extra 
)
static

Definition at line 11931 of file guc.c.

11932 {
11933  /* Do nothing for the boot_val default of NULL */
11934  if (!extra)
11935  return;
11936 
11938 }
void InstallTimeZoneAbbrevs(TimeZoneAbbrevTable *tbl)
Definition: datetime.c:4611

References config_generic::extra, and InstallTimeZoneAbbrevs().

◆ assign_wal_consistency_checking()

static void assign_wal_consistency_checking ( const char *  newval,
void *  extra 
)
static

Definition at line 11720 of file guc.c.

11721 {
11722  wal_consistency_checking = (bool *) extra;
11723 }
bool * wal_consistency_checking
Definition: xlog.c:107

References config_generic::extra, and wal_consistency_checking.

◆ AtEOXact_GUC()

void AtEOXact_GUC ( bool  isCommit,
int  nestLevel 
)

Definition at line 6273 of file guc.c.

6274 {
6275  bool still_dirty;
6276  int i;
6277 
6278  /*
6279  * Note: it's possible to get here with GUCNestLevel == nestLevel-1 during
6280  * abort, if there is a failure during transaction start before
6281  * AtStart_GUC is called.
6282  */
6283  Assert(nestLevel > 0 &&
6284  (nestLevel <= GUCNestLevel ||
6285  (nestLevel == GUCNestLevel + 1 && !isCommit)));
6286 
6287  /* Quick exit if nothing's changed in this transaction */
6288  if (!guc_dirty)
6289  {
6290  GUCNestLevel = nestLevel - 1;
6291  return;
6292  }
6293 
6294  still_dirty = false;
6295  for (i = 0; i < num_guc_variables; i++)
6296  {
6297  struct config_generic *gconf = guc_variables[i];
6298  GucStack *stack;
6299 
6300  /*
6301  * Process and pop each stack entry within the nest level. To simplify
6302  * fmgr_security_definer() and other places that use GUC_ACTION_SAVE,
6303  * we allow failure exit from code that uses a local nest level to be
6304  * recovered at the surrounding transaction or subtransaction abort;
6305  * so there could be more than one stack entry to pop.
6306  */
6307  while ((stack = gconf->stack) != NULL &&
6308  stack->nest_level >= nestLevel)
6309  {
6310  GucStack *prev = stack->prev;
6311  bool restorePrior = false;
6312  bool restoreMasked = false;
6313  bool changed;
6314 
6315  /*
6316  * In this next bit, if we don't set either restorePrior or
6317  * restoreMasked, we must "discard" any unwanted fields of the
6318  * stack entries to avoid leaking memory. If we do set one of
6319  * those flags, unused fields will be cleaned up after restoring.
6320  */
6321  if (!isCommit) /* if abort, always restore prior value */
6322  restorePrior = true;
6323  else if (stack->state == GUC_SAVE)
6324  restorePrior = true;
6325  else if (stack->nest_level == 1)
6326  {
6327  /* transaction commit */
6328  if (stack->state == GUC_SET_LOCAL)
6329  restoreMasked = true;
6330  else if (stack->state == GUC_SET)
6331  {
6332  /* we keep the current active value */
6333  discard_stack_value(gconf, &stack->prior);
6334  }
6335  else /* must be GUC_LOCAL */
6336  restorePrior = true;
6337  }
6338  else if (prev == NULL ||
6339  prev->nest_level < stack->nest_level - 1)
6340  {
6341  /* decrement entry's level and do not pop it */
6342  stack->nest_level--;
6343  continue;
6344  }
6345  else
6346  {
6347  /*
6348  * We have to merge this stack entry into prev. See README for
6349  * discussion of this bit.
6350  */
6351  switch (stack->state)
6352  {
6353  case GUC_SAVE:
6354  Assert(false); /* can't get here */
6355  break;
6356 
6357  case GUC_SET:
6358  /* next level always becomes SET */
6359  discard_stack_value(gconf, &stack->prior);
6360  if (prev->state == GUC_SET_LOCAL)
6361  discard_stack_value(gconf, &prev->masked);
6362  prev->state = GUC_SET;
6363  break;
6364 
6365  case GUC_LOCAL:
6366  if (prev->state == GUC_SET)
6367  {
6368  /* LOCAL migrates down */
6369  prev->masked_scontext = stack->scontext;
6370  prev->masked = stack->prior;
6371  prev->state = GUC_SET_LOCAL;
6372  }
6373  else
6374  {
6375  /* else just forget this stack level */
6376  discard_stack_value(gconf, &stack->prior);
6377  }
6378  break;
6379 
6380  case GUC_SET_LOCAL:
6381  /* prior state at this level no longer wanted */
6382  discard_stack_value(gconf, &stack->prior);
6383  /* copy down the masked state */
6385  if (prev->state == GUC_SET_LOCAL)
6386  discard_stack_value(gconf, &prev->masked);
6387  prev->masked = stack->masked;
6388  prev->state = GUC_SET_LOCAL;
6389  break;
6390  }
6391  }
6392 
6393  changed = false;
6394 
6395  if (restorePrior || restoreMasked)
6396  {
6397  /* Perform appropriate restoration of the stacked value */
6398  config_var_value newvalue;
6399  GucSource newsource;
6400  GucContext newscontext;
6401 
6402  if (restoreMasked)
6403  {
6404  newvalue = stack->masked;
6405  newsource = PGC_S_SESSION;
6406  newscontext = stack->masked_scontext;
6407  }
6408  else
6409  {
6410  newvalue = stack->prior;
6411  newsource = stack->source;
6412  newscontext = stack->scontext;
6413  }
6414 
6415  switch (gconf->vartype)
6416  {
6417  case PGC_BOOL:
6418  {
6419  struct config_bool *conf = (struct config_bool *) gconf;
6420  bool newval = newvalue.val.boolval;
6421  void *newextra = newvalue.extra;
6422 
6423  if (*conf->variable != newval ||
6424  conf->gen.extra != newextra)
6425  {
6426  if (conf->assign_hook)
6427  conf->assign_hook(newval, newextra);
6428  *conf->variable = newval;
6429  set_extra_field(&conf->gen, &conf->gen.extra,
6430  newextra);
6431  changed = true;
6432  }
6433  break;
6434  }
6435  case PGC_INT:
6436  {
6437  struct config_int *conf = (struct config_int *) gconf;
6438  int newval = newvalue.val.intval;
6439  void *newextra = newvalue.extra;
6440 
6441  if (*conf->variable != newval ||
6442  conf->gen.extra != newextra)
6443  {
6444  if (conf->assign_hook)
6445  conf->assign_hook(newval, newextra);
6446  *conf->variable = newval;
6447  set_extra_field(&conf->gen, &conf->gen.extra,
6448  newextra);
6449  changed = true;
6450  }
6451  break;
6452  }
6453  case PGC_REAL:
6454  {
6455  struct config_real *conf = (struct config_real *) gconf;
6456  double newval = newvalue.val.realval;
6457  void *newextra = newvalue.extra;
6458 
6459  if (*conf->variable != newval ||
6460  conf->gen.extra != newextra)
6461  {
6462  if (conf->assign_hook)
6463  conf->assign_hook(newval, newextra);
6464  *conf->variable = newval;
6465  set_extra_field(&conf->gen, &conf->gen.extra,
6466  newextra);
6467  changed = true;
6468  }
6469  break;
6470  }
6471  case PGC_STRING:
6472  {
6473  struct config_string *conf = (struct config_string *) gconf;
6474  char *newval = newvalue.val.stringval;
6475  void *newextra = newvalue.extra;
6476 
6477  if (*conf->variable != newval ||
6478  conf->gen.extra != newextra)
6479  {
6480  if (conf->assign_hook)
6481  conf->assign_hook(newval, newextra);
6482  set_string_field(conf, conf->variable, newval);
6483  set_extra_field(&conf->gen, &conf->gen.extra,
6484  newextra);
6485  changed = true;
6486  }
6487 
6488  /*
6489  * Release stacked values if not used anymore. We
6490  * could use discard_stack_value() here, but since
6491  * we have type-specific code anyway, might as
6492  * well inline it.
6493  */
6494  set_string_field(conf, &stack->prior.val.stringval, NULL);
6495  set_string_field(conf, &stack->masked.val.stringval, NULL);
6496  break;
6497  }
6498  case PGC_ENUM:
6499  {
6500  struct config_enum *conf = (struct config_enum *) gconf;
6501  int newval = newvalue.val.enumval;
6502  void *newextra = newvalue.extra;
6503 
6504  if (*conf->variable != newval ||
6505  conf->gen.extra != newextra)
6506  {
6507  if (conf->assign_hook)
6508  conf->assign_hook(newval, newextra);
6509  *conf->variable = newval;
6510  set_extra_field(&conf->gen, &conf->gen.extra,
6511  newextra);
6512  changed = true;
6513  }
6514  break;
6515  }
6516  }
6517 
6518  /*
6519  * Release stacked extra values if not used anymore.
6520  */
6521  set_extra_field(gconf, &(stack->prior.extra), NULL);
6522  set_extra_field(gconf, &(stack->masked.extra), NULL);
6523 
6524  /* And restore source information */
6525  gconf->source = newsource;
6526  gconf->scontext = newscontext;
6527  }
6528 
6529  /* Finish popping the state stack */
6530  gconf->stack = prev;
6531  pfree(stack);
6532 
6533  /* Report new value if we changed it */
6534  if (changed && (gconf->flags & GUC_REPORT))
6535  {
6536  gconf->status |= GUC_NEEDS_REPORT;
6537  report_needed = true;
6538  }
6539  } /* end of stack-popping loop */
6540 
6541  if (stack != NULL)
6542  still_dirty = true;
6543  }
6544 
6545  /* If there are no remaining stack entries, we can reset guc_dirty */
6546  guc_dirty = still_dirty;
6547 
6548  /* Update nesting level */
6549  GUCNestLevel = nestLevel - 1;
6550 }
static void set_string_field(struct config_string *conf, char **field, char *newval)
Definition: guc.c:5168
static bool report_needed
Definition: guc.c:5066
static int GUCNestLevel
Definition: guc.c:5068
static void discard_stack_value(struct config_generic *gconf, config_var_value *val)
Definition: guc.c:5283
static bool guc_dirty
Definition: guc.c:5062
static void set_extra_field(struct config_generic *gconf, void **field, void *newval)
Definition: guc.c:5229
GucSource
Definition: guc.h:105
@ PGC_S_SESSION
Definition: guc.h:119
GucContext
Definition: guc.h:69
#define GUC_REPORT
Definition: guc.h:208
@ GUC_SET_LOCAL
Definition: guc_tables.h:110
@ GUC_SET
Definition: guc_tables.h:108
@ GUC_SAVE
Definition: guc_tables.h:107
@ GUC_LOCAL
Definition: guc_tables.h:109
#define GUC_NEEDS_REPORT
Definition: guc_tables.h:170
int i
Definition: isn.c:73
void pfree(void *pointer)
Definition: mcxt.c:1169
struct config_generic gen
Definition: guc_tables.h:177
GucBoolAssignHook assign_hook
Definition: guc_tables.h:182
GucEnumAssignHook assign_hook
Definition: guc_tables.h:243
struct config_generic gen
Definition: guc_tables.h:237
GucContext scontext
Definition: guc_tables.h:152
GucStack * stack
Definition: guc_tables.h:154
GucSource source
Definition: guc_tables.h:150
GucIntAssignHook assign_hook
Definition: guc_tables.h:198
struct config_generic gen
Definition: guc_tables.h:191
GucRealAssignHook assign_hook
Definition: guc_tables.h:214
struct config_generic gen
Definition: guc_tables.h:207
GucStringAssignHook assign_hook
Definition: guc_tables.h:228
union config_var_val val
Definition: guc_tables.h:46
struct guc_stack * prev
Definition: guc_tables.h:115
int nest_level
Definition: guc_tables.h:116
config_var_value masked
Definition: guc_tables.h:123
config_var_value prior
Definition: guc_tables.h:122
GucContext scontext
Definition: guc_tables.h:120
GucStackState state
Definition: guc_tables.h:117
GucSource source
Definition: guc_tables.h:118
GucContext masked_scontext
Definition: guc_tables.h:121
double realval
Definition: guc_tables.h:35
char * stringval
Definition: guc_tables.h:36

References Assert(), config_bool::assign_hook, config_int::assign_hook, config_real::assign_hook, config_string::assign_hook, config_enum::assign_hook, config_var_val::boolval, discard_stack_value(), config_var_val::enumval, config_var_value::extra, config_generic::extra, config_generic::flags, config_bool::gen, config_int::gen, config_real::gen, config_string::gen, config_enum::gen, guc_dirty, GUC_LOCAL, GUC_NEEDS_REPORT, GUC_REPORT, GUC_SAVE, GUC_SET, GUC_SET_LOCAL, guc_variables, GUCNestLevel, i, config_var_val::intval, guc_stack::masked, guc_stack::masked_scontext, guc_stack::nest_level, newval, num_guc_variables, pfree(), PGC_BOOL, PGC_ENUM, PGC_INT, PGC_REAL, PGC_S_SESSION, PGC_STRING, guc_stack::prev, guc_stack::prior, config_var_val::realval, report_needed, guc_stack::scontext, config_generic::scontext, set_extra_field(), set_string_field(), guc_stack::source, config_generic::source, config_generic::stack, guc_stack::state, config_generic::status, config_var_val::stringval, config_var_value::val, config_bool::variable, config_int::variable, config_real::variable, config_string::variable, config_enum::variable, and config_generic::vartype.

Referenced by AbortSubTransaction(), AbortTransaction(), CommitSubTransaction(), CommitTransaction(), DefineIndex(), do_analyze_rel(), ExecCreateTableAs(), ExecRefreshMatView(), execute_extension_script(), fmgr_security_definer(), index_build(), PrepareTransaction(), ProcedureCreate(), reset_transmission_modes(), restoreLocalGucs(), RI_Initial_Check(), RI_PartitionRemove_Check(), vacuum_rel(), and validate_index().

◆ AtStart_GUC()

void AtStart_GUC ( void  )

Definition at line 6239 of file guc.c.

6240 {
6241  /*
6242  * The nest level should be 0 between transactions; if it isn't, somebody
6243  * didn't call AtEOXact_GUC, or called it with the wrong nestLevel. We
6244  * throw a warning but make no other effort to clean up.
6245  */
6246  if (GUCNestLevel != 0)
6247  elog(WARNING, "GUC nest level = %d at transaction start",
6248  GUCNestLevel);
6249  GUCNestLevel = 1;
6250 }
#define WARNING
Definition: elog.h:30

References elog, GUCNestLevel, and WARNING.

Referenced by StartTransaction().

◆ BeginReportingGUCOptions()

void BeginReportingGUCOptions ( void  )

Definition at line 6558 of file guc.c.

6559 {
6560  int i;
6561 
6562  /*
6563  * Don't do anything unless talking to an interactive frontend.
6564  */
6566  return;
6567 
6568  reporting_enabled = true;
6569 
6570  /*
6571  * Hack for in_hot_standby: initialize with the value we're about to send.
6572  * (This could be out of date by the time we actually send it, in which
6573  * case the next ReportChangedGUCOptions call will send a duplicate
6574  * report.)
6575  */
6577 
6578  /* Transmit initial values of interesting variables */
6579  for (i = 0; i < num_guc_variables; i++)
6580  {
6581  struct config_generic *conf = guc_variables[i];
6582 
6583  if (conf->flags & GUC_REPORT)
6584  ReportGUCOption(conf);
6585  }
6586 
6587  report_needed = false;
6588 }
@ DestRemote
Definition: dest.h:91
static void ReportGUCOption(struct config_generic *record)
Definition: guc.c:6650
static bool in_hot_standby
Definition: guc.c:675
static bool reporting_enabled
Definition: guc.c:5064
CommandDest whereToSendOutput
Definition: postgres.c:93
bool RecoveryInProgress(void)
Definition: xlog.c:8404

References DestRemote, config_generic::flags, GUC_REPORT, guc_variables, i, in_hot_standby, num_guc_variables, RecoveryInProgress(), report_needed, ReportGUCOption(), reporting_enabled, and whereToSendOutput.

Referenced by PostgresMain().

◆ build_guc_variables()

void build_guc_variables ( void  )

Definition at line 5319 of file guc.c.

5320 {
5321  int size_vars;
5322  int num_vars = 0;
5323  struct config_generic **guc_vars;
5324  int i;
5325 
5326  for (i = 0; ConfigureNamesBool[i].gen.name; i++)
5327  {
5328  struct config_bool *conf = &ConfigureNamesBool[i];
5329 
5330  /* Rather than requiring vartype to be filled in by hand, do this: */
5331  conf->gen.vartype = PGC_BOOL;
5332  num_vars++;
5333  }
5334 
5335  for (i = 0; ConfigureNamesInt[i].gen.name; i++)
5336  {
5337  struct config_int *conf = &ConfigureNamesInt[i];
5338 
5339  conf->gen.vartype = PGC_INT;
5340  num_vars++;
5341  }
5342 
5343  for (i = 0; ConfigureNamesReal[i].gen.name; i++)
5344  {
5345  struct config_real *conf = &ConfigureNamesReal[i];
5346 
5347  conf->gen.vartype = PGC_REAL;
5348  num_vars++;
5349  }
5350 
5351  for (i = 0; ConfigureNamesString[i].gen.name; i++)
5352  {
5353  struct config_string *conf = &ConfigureNamesString[i];
5354 
5355  conf->gen.vartype = PGC_STRING;
5356  num_vars++;
5357  }
5358 
5359  for (i = 0; ConfigureNamesEnum[i].gen.name; i++)
5360  {
5361  struct config_enum *conf = &ConfigureNamesEnum[i];
5362 
5363  conf->gen.vartype = PGC_ENUM;
5364  num_vars++;
5365  }
5366 
5367  /*
5368  * Create table with 20% slack
5369  */
5370  size_vars = num_vars + num_vars / 4;
5371 
5372  guc_vars = (struct config_generic **)
5373  guc_malloc(FATAL, size_vars * sizeof(struct config_generic *));
5374 
5375  num_vars = 0;
5376 
5377  for (i = 0; ConfigureNamesBool[i].gen.name; i++)
5378  guc_vars[num_vars++] = &ConfigureNamesBool[i].gen;
5379 
5380  for (i = 0; ConfigureNamesInt[i].gen.name; i++)
5381  guc_vars[num_vars++] = &ConfigureNamesInt[i].gen;
5382 
5383  for (i = 0; ConfigureNamesReal[i].gen.name; i++)
5384  guc_vars[num_vars++] = &ConfigureNamesReal[i].gen;
5385 
5386  for (i = 0; ConfigureNamesString[i].gen.name; i++)
5387  guc_vars[num_vars++] = &ConfigureNamesString[i].gen;
5388 
5389  for (i = 0; ConfigureNamesEnum[i].gen.name; i++)
5390  guc_vars[num_vars++] = &ConfigureNamesEnum[i].gen;
5391 
5392  if (guc_variables)
5394  guc_variables = guc_vars;
5395  num_guc_variables = num_vars;
5396  size_guc_variables = size_vars;
5398  sizeof(struct config_generic *), guc_var_compare);
5399 }
#define FATAL
Definition: elog.h:35
static struct config_string ConfigureNamesString[]
Definition: guc.c:3879
static struct config_int ConfigureNamesInt[]
Definition: guc.c:2142
static struct config_bool ConfigureNamesBool[]
Definition: guc.c:973
static struct config_real ConfigureNamesReal[]
Definition: guc.c:3610
static struct config_enum ConfigureNamesEnum[]
Definition: guc.c:4658

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

◆ call_bool_check_hook()

static bool call_bool_check_hook ( struct config_bool conf,
bool newval,
void **  extra,
GucSource  source,
int  elevel 
)
static

Definition at line 11454 of file guc.c.

11456 {
11457  /* Quick success if no hook */
11458  if (!conf->check_hook)
11459  return true;
11460 
11461  /* Reset variables that might be set by hook */
11462  GUC_check_errcode_value = ERRCODE_INVALID_PARAMETER_VALUE;
11463  GUC_check_errmsg_string = NULL;
11465  GUC_check_errhint_string = NULL;
11466 
11467  if (!conf->check_hook(newval, extra, source))
11468  {
11469  ereport(elevel,
11473  errmsg("invalid value for parameter \"%s\": %d",
11474  conf->gen.name, (int) *newval),
11478  errhint("%s", GUC_check_errhint_string) : 0));
11479  /* Flush any strings created in ErrorContext */
11480  FlushErrorState();
11481  return false;
11482  }
11483 
11484  return true;
11485 }
int errmsg_internal(const char *fmt,...)
Definition: elog.c:991
int errdetail_internal(const char *fmt,...)
Definition: elog.c:1064
void FlushErrorState(void)
Definition: elog.c:1649
int errhint(const char *fmt,...)
Definition: elog.c:1151
char * GUC_check_errhint_string
Definition: guc.c:155
char * GUC_check_errmsg_string
Definition: guc.c:153
static int GUC_check_errcode_value
Definition: guc.c:150
char * GUC_check_errdetail_string
Definition: guc.c:154
static rewind_source * source
Definition: pg_rewind.c:79
GucBoolCheckHook check_hook
Definition: guc_tables.h:181

References config_bool::check_hook, ereport, errcode(), errdetail_internal(), errhint(), errmsg(), errmsg_internal(), config_generic::extra, FlushErrorState(), config_bool::gen, GUC_check_errcode_value, GUC_check_errdetail_string, GUC_check_errhint_string, GUC_check_errmsg_string, config_generic::name, newval, and source.

Referenced by InitializeOneGUCOption(), parse_and_validate_value(), and set_config_option().

◆ call_enum_check_hook()

static bool call_enum_check_hook ( struct config_enum conf,
int *  newval,
void **  extra,
GucSource  source,
int  elevel 
)
static

Definition at line 11606 of file guc.c.

11608 {
11609  /* Quick success if no hook */
11610  if (!conf->check_hook)
11611  return true;
11612 
11613  /* Reset variables that might be set by hook */
11614  GUC_check_errcode_value = ERRCODE_INVALID_PARAMETER_VALUE;
11615  GUC_check_errmsg_string = NULL;
11617  GUC_check_errhint_string = NULL;
11618 
11619  if (!conf->check_hook(newval, extra, source))
11620  {
11621  ereport(elevel,
11625  errmsg("invalid value for parameter \"%s\": \"%s\"",
11626  conf->gen.name,
11631  errhint("%s", GUC_check_errhint_string) : 0));
11632  /* Flush any strings created in ErrorContext */
11633  FlushErrorState();
11634  return false;
11635  }
11636 
11637  return true;
11638 }
GucEnumCheckHook check_hook
Definition: guc_tables.h:242

References config_enum::check_hook, config_enum_lookup_by_value(), ereport, errcode(), errdetail_internal(), errhint(), errmsg(), errmsg_internal(), config_generic::extra, FlushErrorState(), config_enum::gen, GUC_check_errcode_value, GUC_check_errdetail_string, GUC_check_errhint_string, GUC_check_errmsg_string, config_generic::name, newval, and source.

Referenced by InitializeOneGUCOption(), parse_and_validate_value(), and set_config_option().

◆ call_int_check_hook()

static bool call_int_check_hook ( struct config_int conf,
int *  newval,
void **  extra,
GucSource  source,
int  elevel 
)
static

Definition at line 11488 of file guc.c.

11490 {
11491  /* Quick success if no hook */
11492  if (!conf->check_hook)
11493  return true;
11494 
11495  /* Reset variables that might be set by hook */
11496  GUC_check_errcode_value = ERRCODE_INVALID_PARAMETER_VALUE;
11497  GUC_check_errmsg_string = NULL;
11499  GUC_check_errhint_string = NULL;
11500 
11501  if (!conf->check_hook(newval, extra, source))
11502  {
11503  ereport(elevel,
11507  errmsg("invalid value for parameter \"%s\": %d",
11508  conf->gen.name, *newval),
11512  errhint("%s", GUC_check_errhint_string) : 0));
11513  /* Flush any strings created in ErrorContext */
11514  FlushErrorState();
11515  return false;
11516  }
11517 
11518  return true;
11519 }
GucIntCheckHook check_hook
Definition: guc_tables.h:197

References config_int::check_hook, ereport, errcode(), errdetail_internal(), errhint(), errmsg(), errmsg_internal(), config_generic::extra, FlushErrorState(), config_int::gen, GUC_check_errcode_value, GUC_check_errdetail_string, GUC_check_errhint_string, GUC_check_errmsg_string, config_generic::name, newval, and source.

Referenced by InitializeOneGUCOption(), parse_and_validate_value(), and set_config_option().

◆ call_real_check_hook()

static bool call_real_check_hook ( struct config_real conf,
double *  newval,
void **  extra,
GucSource  source,
int  elevel 
)
static

Definition at line 11522 of file guc.c.

11524 {
11525  /* Quick success if no hook */
11526  if (!conf->check_hook)
11527  return true;
11528 
11529  /* Reset variables that might be set by hook */
11530  GUC_check_errcode_value = ERRCODE_INVALID_PARAMETER_VALUE;
11531  GUC_check_errmsg_string = NULL;
11533  GUC_check_errhint_string = NULL;
11534 
11535  if (!conf->check_hook(newval, extra, source))
11536  {
11537  ereport(elevel,
11541  errmsg("invalid value for parameter \"%s\": %g",
11542  conf->gen.name, *newval),
11546  errhint("%s", GUC_check_errhint_string) : 0));
11547  /* Flush any strings created in ErrorContext */
11548  FlushErrorState();
11549  return false;
11550  }
11551 
11552  return true;
11553 }
GucRealCheckHook check_hook
Definition: guc_tables.h:213

References config_real::check_hook, ereport, errcode(), errdetail_internal(), errhint(), errmsg(), errmsg_internal(), config_generic::extra, FlushErrorState(), config_real::gen, GUC_check_errcode_value, GUC_check_errdetail_string, GUC_check_errhint_string, GUC_check_errmsg_string, config_generic::name, newval, and source.

Referenced by InitializeOneGUCOption(), parse_and_validate_value(), and set_config_option().

◆ call_string_check_hook()

static bool call_string_check_hook ( struct config_string conf,
char **  newval,
void **  extra,
GucSource  source,
int  elevel 
)
static

Definition at line 11556 of file guc.c.

11558 {
11559  volatile bool result = true;
11560 
11561  /* Quick success if no hook */
11562  if (!conf->check_hook)
11563  return true;
11564 
11565  /*
11566  * If elevel is ERROR, or if the check_hook itself throws an elog
11567  * (undesirable, but not always avoidable), make sure we don't leak the
11568  * already-malloc'd newval string.
11569  */
11570  PG_TRY();
11571  {
11572  /* Reset variables that might be set by hook */
11573  GUC_check_errcode_value = ERRCODE_INVALID_PARAMETER_VALUE;
11574  GUC_check_errmsg_string = NULL;
11576  GUC_check_errhint_string = NULL;
11577 
11578  if (!conf->check_hook(newval, extra, source))
11579  {
11580  ereport(elevel,
11584  errmsg("invalid value for parameter \"%s\": \"%s\"",
11585  conf->gen.name, *newval ? *newval : ""),
11589  errhint("%s", GUC_check_errhint_string) : 0));
11590  /* Flush any strings created in ErrorContext */
11591  FlushErrorState();
11592  result = false;
11593  }
11594  }
11595  PG_CATCH();
11596  {
11597  free(*newval);
11598  PG_RE_THROW();
11599  }
11600  PG_END_TRY();
11601 
11602  return result;
11603 }
GucStringCheckHook check_hook
Definition: guc_tables.h:227

References config_string::check_hook, ereport, errcode(), errdetail_internal(), errhint(), errmsg(), errmsg_internal(), config_generic::extra, FlushErrorState(), free, config_string::gen, GUC_check_errcode_value, GUC_check_errdetail_string, GUC_check_errhint_string, GUC_check_errmsg_string, config_generic::name, newval, PG_CATCH, PG_END_TRY, PG_RE_THROW, PG_TRY, and source.

Referenced by InitializeOneGUCOption(), parse_and_validate_value(), and set_config_option().

◆ can_skip_gucvar()

static bool can_skip_gucvar ( struct config_generic gconf)
static

Definition at line 10507 of file guc.c.

10508 {
10509  /*
10510  * We can skip GUCs that are guaranteed to have the same values in leaders
10511  * and workers. (Note it is critical that the leader and worker have the
10512  * same idea of which GUCs fall into this category. It's okay to consider
10513  * context and name for this purpose, since those are unchanging
10514  * properties of a GUC.)
10515  *
10516  * PGC_POSTMASTER variables always have the same value in every child of a
10517  * particular postmaster, so the worker will certainly have the right
10518  * value already. Likewise, PGC_INTERNAL variables are set by special
10519  * mechanisms (if indeed they aren't compile-time constants). So we may
10520  * always skip these.
10521  *
10522  * Role must be handled specially because its current value can be an
10523  * invalid value (for instance, if someone dropped the role since we set
10524  * it). So if we tried to serialize it normally, we might get a failure.
10525  * We skip it here, and use another mechanism to ensure the worker has the
10526  * right value.
10527  *
10528  * For all other GUCs, we skip if the GUC has its compiled-in default
10529  * value (i.e., source == PGC_S_DEFAULT). On the leader side, this means
10530  * we don't send GUCs that have their default values, which typically
10531  * saves lots of work. On the worker side, this means we don't need to
10532  * reset the GUC to default because it already has that value. See
10533  * comments in RestoreGUCState for more info.
10534  */
10535  return gconf->context == PGC_POSTMASTER ||
10536  gconf->context == PGC_INTERNAL || gconf->source == PGC_S_DEFAULT ||
10537  strcmp(gconf->name, "role") == 0;
10538 }
@ PGC_S_DEFAULT
Definition: guc.h:106
@ PGC_POSTMASTER
Definition: guc.h:71

References config_generic::context, config_generic::name, PGC_INTERNAL, PGC_POSTMASTER, PGC_S_DEFAULT, and config_generic::source.

Referenced by estimate_variable_size(), RestoreGUCState(), and serialize_variable().

◆ check_application_name()

static bool check_application_name ( char **  newval,
void **  extra,
GucSource  source 
)
static

Definition at line 12187 of file guc.c.

12188 {
12189  /* Only allow clean ASCII chars in the application name */
12191 
12192  return true;
12193 }
void pg_clean_ascii(char *str)
Definition: string.c:82

References newval, and pg_clean_ascii().

◆ check_autovacuum_max_workers()

static bool check_autovacuum_max_workers ( int *  newval,
void **  extra,
GucSource  source 
)
static

Definition at line 12054 of file guc.c.

12055 {
12056  if (MaxConnections + *newval + 1 +
12058  return false;
12059  return true;
12060 }
int MaxConnections
Definition: globals.c:136
int max_worker_processes
Definition: globals.c:137
#define MAX_BACKENDS
Definition: postmaster.h:75
int max_wal_senders
Definition: walsender.c:121

References MAX_BACKENDS, max_wal_senders, max_worker_processes, MaxConnections, and newval.

◆ check_autovacuum_work_mem()

static bool check_autovacuum_work_mem ( int *  newval,
void **  extra,
GucSource  source 
)
static

Definition at line 12072 of file guc.c.

12073 {
12074  /*
12075  * -1 indicates fallback.
12076  *
12077  * If we haven't yet changed the boot_val default of -1, just let it be.
12078  * Autovacuum will look to maintenance_work_mem instead.
12079  */
12080  if (*newval == -1)
12081  return true;
12082 
12083  /*
12084  * We clamp manually-set values to at least 1MB. Since
12085  * maintenance_work_mem is always set to at least this value, do the same
12086  * here.
12087  */
12088  if (*newval < 1024)
12089  *newval = 1024;
12090 
12091  return true;
12092 }

References newval.

◆ check_backtrace_functions()

static bool check_backtrace_functions ( char **  newval,
void **  extra,
GucSource  source 
)
static

Definition at line 12259 of file guc.c.

12260 {
12261  int newvallen = strlen(*newval);
12262  char *someval;
12263  int validlen;
12264  int i;
12265  int j;
12266 
12267  /*
12268  * Allow characters that can be C identifiers and commas as separators, as
12269  * well as some whitespace for readability.
12270  */
12271  validlen = strspn(*newval,
12272  "0123456789_"
12273  "abcdefghijklmnopqrstuvwxyz"
12274  "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
12275  ", \n\t");
12276  if (validlen != newvallen)
12277  {
12278  GUC_check_errdetail("invalid character");
12279  return false;
12280  }
12281 
12282  if (*newval[0] == '\0')
12283  {
12284  *extra = NULL;
12285  return true;
12286  }
12287 
12288  /*
12289  * Allocate space for the output and create the copy. We could discount
12290  * whitespace chars to save some memory, but it doesn't seem worth the
12291  * trouble.
12292  */
12293  someval = guc_malloc(ERROR, newvallen + 1 + 1);
12294  for (i = 0, j = 0; i < newvallen; i++)
12295  {
12296  if ((*newval)[i] == ',')
12297  someval[j++] = '\0'; /* next item */
12298  else if ((*newval)[i] == ' ' ||
12299  (*newval)[i] == '\n' ||
12300  (*newval)[i] == '\t')
12301  ; /* ignore these */
12302  else
12303  someval[j++] = (*newval)[i]; /* copy anything else */
12304  }
12305 
12306  /* two \0s end the setting */
12307  someval[j] = '\0';
12308  someval[j + 1] = '\0';
12309 
12310  *extra = someval;
12311  return true;
12312 }
#define GUC_check_errdetail
Definition: guc.h:421
int j
Definition: isn.c:74

References ERROR, config_generic::extra, GUC_check_errdetail, guc_malloc(), i, j, and newval.

◆ check_bonjour()

static bool check_bonjour ( bool newval,
void **  extra,
GucSource  source 
)
static

Definition at line 11837 of file guc.c.

11838 {
11839 #ifndef USE_BONJOUR
11840  if (*newval)
11841  {
11842  GUC_check_errmsg("Bonjour is not supported by this build");
11843  return false;
11844  }
11845 #endif
11846  return true;
11847 }
#define GUC_check_errmsg
Definition: guc.h:417

References GUC_check_errmsg, and newval.

◆ check_canonical_path()

static bool check_canonical_path ( char **  newval,
void **  extra,
GucSource  source 
)
static

Definition at line 11888 of file guc.c.

11889 {
11890  /*
11891  * Since canonicalize_path never enlarges the string, we can just modify
11892  * newval in-place. But watch out for NULL, which is the default value
11893  * for external_pid_file.
11894  */
11895  if (*newval)
11897  return true;
11898 }
void canonicalize_path(char *path)
Definition: path.c:254

References canonicalize_path(), and newval.

◆ check_client_connection_check_interval()

static bool check_client_connection_check_interval ( int *  newval,
void **  extra,
GucSource  source 
)
static

Definition at line 12144 of file guc.c.

12145 {
12146 #ifndef POLLRDHUP
12147  /* Linux only, for now. See pq_check_connection(). */
12148  if (*newval != 0)
12149  {
12150  GUC_check_errdetail("client_connection_check_interval must be set to 0 on platforms that lack POLLRDHUP.");
12151  return false;
12152  }
12153 #endif
12154  return true;
12155 }

References GUC_check_errdetail, and newval.

◆ check_cluster_name()

static bool check_cluster_name ( char **  newval,
void **  extra,
GucSource  source 
)
static

Definition at line 12203 of file guc.c.

12204 {
12205  /* Only allow clean ASCII chars in the cluster name */
12207 
12208  return true;
12209 }

References newval, and pg_clean_ascii().

◆ check_default_with_oids()

static bool check_default_with_oids ( bool newval,
void **  extra,
GucSource  source 
)
static

Definition at line 12588 of file guc.c.

12589 {
12590  if (*newval)
12591  {
12592  /* check the GUC's definition for an explanation */
12593  GUC_check_errcode(ERRCODE_FEATURE_NOT_SUPPORTED);
12594  GUC_check_errmsg("tables declared WITH OIDS are not supported");
12595 
12596  return false;
12597  }
12598 
12599  return true;
12600 }
void GUC_check_errcode(int sqlerrcode)
Definition: guc.c:11441

References GUC_check_errcode(), GUC_check_errmsg, and newval.

◆ check_effective_io_concurrency()

static bool check_effective_io_concurrency ( int *  newval,
void **  extra,
GucSource  source 
)
static

Definition at line 12104 of file guc.c.

12105 {
12106 #ifndef USE_PREFETCH
12107  if (*newval != 0)
12108  {
12109  GUC_check_errdetail("effective_io_concurrency must be set to 0 on platforms that lack posix_fadvise().");
12110  return false;
12111  }
12112 #endif /* USE_PREFETCH */
12113  return true;
12114 }

References GUC_check_errdetail, and newval.

◆ check_huge_page_size()

static bool check_huge_page_size ( int *  newval,
void **  extra,
GucSource  source 
)
static

Definition at line 12130 of file guc.c.

12131 {
12132 #if !(defined(MAP_HUGE_MASK) && defined(MAP_HUGE_SHIFT))
12133  /* Recent enough Linux only, for now. See GetHugePageSize(). */
12134  if (*newval != 0)
12135  {
12136  GUC_check_errdetail("huge_page_size must be 0 on this platform.");
12137  return false;
12138  }
12139 #endif
12140  return true;
12141 }

References GUC_check_errdetail, and newval.

◆ check_log_destination()

static bool check_log_destination ( char **  newval,
void **  extra,
GucSource  source 
)
static

Definition at line 11726 of file guc.c.

11727 {
11728  char *rawstring;
11729  List *elemlist;
11730  ListCell *l;
11731  int newlogdest = 0;
11732  int *myextra;
11733 
11734  /* Need a modifiable copy of string */
11735  rawstring = pstrdup(*newval);
11736 
11737  /* Parse string into list of identifiers */
11738  if (!SplitIdentifierString(rawstring, ',', &elemlist))
11739  {
11740  /* syntax error in list */
11741  GUC_check_errdetail("List syntax is invalid.");
11742  pfree(rawstring);
11743  list_free(elemlist);
11744  return false;
11745  }
11746 
11747  foreach(l, elemlist)
11748  {
11749  char *tok = (char *) lfirst(l);
11750 
11751  if (pg_strcasecmp(tok, "stderr") == 0)
11752  newlogdest |= LOG_DESTINATION_STDERR;
11753  else if (pg_strcasecmp(tok, "csvlog") == 0)
11754  newlogdest |= LOG_DESTINATION_CSVLOG;
11755  else if (pg_strcasecmp(tok, "jsonlog") == 0)
11756  newlogdest |= LOG_DESTINATION_JSONLOG;
11757 #ifdef HAVE_SYSLOG
11758  else if (pg_strcasecmp(tok, "syslog") == 0)
11759  newlogdest |= LOG_DESTINATION_SYSLOG;
11760 #endif
11761 #ifdef WIN32
11762  else if (pg_strcasecmp(tok, "eventlog") == 0)
11763  newlogdest |= LOG_DESTINATION_EVENTLOG;
11764 #endif
11765  else
11766  {
11767  GUC_check_errdetail("Unrecognized key word: \"%s\".", tok);
11768  pfree(rawstring);
11769  list_free(elemlist);
11770  return false;
11771  }
11772  }
11773 
11774  pfree(rawstring);
11775  list_free(elemlist);
11776 
11777  myextra = (int *) guc_malloc(ERROR, sizeof(int));
11778  *myextra = newlogdest;
11779  *extra = (void *) myextra;
11780 
11781  return true;
11782 }
#define LOG_DESTINATION_JSONLOG
Definition: elog.h:425
#define LOG_DESTINATION_SYSLOG
Definition: elog.h:422
#define LOG_DESTINATION_STDERR
Definition: elog.h:421
#define LOG_DESTINATION_EVENTLOG
Definition: elog.h:423
#define LOG_DESTINATION_CSVLOG
Definition: elog.h:424
void list_free(List *list)
Definition: list.c:1505
#define lfirst(lc)
Definition: pg_list.h:169
int pg_strcasecmp(const char *s1, const char *s2)
Definition: pgstrcasecmp.c:36
Definition: pg_list.h:51
bool SplitIdentifierString(char *rawstring, char separator, List **namelist)
Definition: varlena.c:3746

References ERROR, config_generic::extra, GUC_check_errdetail, guc_malloc(), lfirst, list_free(), LOG_DESTINATION_CSVLOG, LOG_DESTINATION_EVENTLOG, LOG_DESTINATION_JSONLOG, LOG_DESTINATION_STDERR, LOG_DESTINATION_SYSLOG, newval, pfree(), pg_strcasecmp(), pstrdup(), and SplitIdentifierString().

◆ check_log_stats()

static bool check_log_stats ( bool newval,
void **  extra,
GucSource  source 
)
static

Definition at line 11874 of file guc.c.

11875 {
11876  if (*newval &&
11878  {
11879  GUC_check_errdetail("Cannot enable \"log_statement_stats\" when "
11880  "\"log_parser_stats\", \"log_planner_stats\", "
11881  "or \"log_executor_stats\" is true.");
11882  return false;
11883  }
11884  return true;
11885 }
bool log_parser_stats
Definition: guc.c:579
bool log_planner_stats
Definition: guc.c:580
bool log_executor_stats
Definition: guc.c:581

References GUC_check_errdetail, log_executor_stats, log_parser_stats, log_planner_stats, and newval.

◆ check_maintenance_io_concurrency()

static bool check_maintenance_io_concurrency ( int *  newval,
void **  extra,
GucSource  source 
)
static

Definition at line 12117 of file guc.c.

12118 {
12119 #ifndef USE_PREFETCH
12120  if (*newval != 0)
12121  {
12122  GUC_check_errdetail("maintenance_io_concurrency must be set to 0 on platforms that lack posix_fadvise().");
12123  return false;
12124  }
12125 #endif /* USE_PREFETCH */
12126  return true;
12127 }

References GUC_check_errdetail, and newval.

◆ check_max_wal_senders()

static bool check_max_wal_senders ( int *  newval,
void **  extra,
GucSource  source 
)
static

Definition at line 12063 of file guc.c.

12064 {
12067  return false;
12068  return true;
12069 }
int autovacuum_max_workers
Definition: autovacuum.c:115

References autovacuum_max_workers, MAX_BACKENDS, max_worker_processes, MaxConnections, and newval.

◆ check_max_worker_processes()

static bool check_max_worker_processes ( int *  newval,
void **  extra,
GucSource  source 
)
static

Definition at line 12095 of file guc.c.

12096 {
12099  return false;
12100  return true;
12101 }

References autovacuum_max_workers, MAX_BACKENDS, max_wal_senders, MaxConnections, and newval.

◆ check_maxconnections()

static bool check_maxconnections ( int *  newval,
void **  extra,
GucSource  source 
)
static

Definition at line 12045 of file guc.c.

12046 {
12047  if (*newval + autovacuum_max_workers + 1 +
12049  return false;
12050  return true;
12051 }

References autovacuum_max_workers, MAX_BACKENDS, max_wal_senders, max_worker_processes, and newval.

◆ check_primary_slot_name()

static bool check_primary_slot_name ( char **  newval,
void **  extra,
GucSource  source 
)
static

Definition at line 12578 of file guc.c.

12579 {
12580  if (*newval && strcmp(*newval, "") != 0 &&
12582  return false;
12583 
12584  return true;
12585 }
bool ReplicationSlotValidateName(const char *name, int elevel)
Definition: slot.c:172

References newval, ReplicationSlotValidateName(), and WARNING.

◆ check_recovery_target()

static bool check_recovery_target ( char **  newval,
void **  extra,
GucSource  source 
)
static

Definition at line 12383 of file guc.c.

12384 {
12385  if (strcmp(*newval, "immediate") != 0 && strcmp(*newval, "") != 0)
12386  {
12387  GUC_check_errdetail("The only allowed value is \"immediate\".");
12388  return false;
12389  }
12390  return true;
12391 }

References GUC_check_errdetail, and newval.

◆ check_recovery_target_lsn()

static bool check_recovery_target_lsn ( char **  newval,
void **  extra,
GucSource  source 
)
static

Definition at line 12542 of file guc.c.

12543 {
12544  if (strcmp(*newval, "") != 0)
12545  {
12546  XLogRecPtr lsn;
12547  XLogRecPtr *myextra;
12548  bool have_error = false;
12549 
12550  lsn = pg_lsn_in_internal(*newval, &have_error);
12551  if (have_error)
12552  return false;
12553 
12554  myextra = (XLogRecPtr *) guc_malloc(ERROR, sizeof(XLogRecPtr));
12555  *myextra = lsn;
12556  *extra = (void *) myextra;
12557  }
12558  return true;
12559 }
XLogRecPtr pg_lsn_in_internal(const char *str, bool *have_error)
Definition: pg_lsn.c:30

References ERROR, guc_malloc(), newval, and pg_lsn_in_internal().

◆ check_recovery_target_name()

static bool check_recovery_target_name ( char **  newval,
void **  extra,
GucSource  source 
)
static

Definition at line 12513 of file guc.c.

12514 {
12515  /* Use the value of newval directly */
12516  if (strlen(*newval) >= MAXFNAMELEN)
12517  {
12518  GUC_check_errdetail("%s is too long (maximum %d characters).",
12519  "recovery_target_name", MAXFNAMELEN - 1);
12520  return false;
12521  }
12522  return true;
12523 }
#define MAXFNAMELEN

References GUC_check_errdetail, MAXFNAMELEN, and newval.

◆ check_recovery_target_time()

static bool check_recovery_target_time ( char **  newval,
void **  extra,
GucSource  source 
)
static

Definition at line 12450 of file guc.c.

12451 {
12452  if (strcmp(*newval, "") != 0)
12453  {
12454  /* reject some special values */
12455  if (strcmp(*newval, "now") == 0 ||
12456  strcmp(*newval, "today") == 0 ||
12457  strcmp(*newval, "tomorrow") == 0 ||
12458  strcmp(*newval, "yesterday") == 0)
12459  {
12460  return false;
12461  }
12462 
12463  /*
12464  * parse timestamp value (see also timestamptz_in())
12465  */
12466  {
12467  char *str = *newval;
12468  fsec_t fsec;
12469  struct pg_tm tt,
12470  *tm = &tt;
12471  int tz;
12472  int dtype;
12473  int nf;
12474  int dterr;
12475  char *field[MAXDATEFIELDS];
12476  int ftype[MAXDATEFIELDS];
12477  char workbuf[MAXDATELEN + MAXDATEFIELDS];
12479 
12480  dterr = ParseDateTime(str, workbuf, sizeof(workbuf),
12481  field, ftype, MAXDATEFIELDS, &nf);
12482  if (dterr == 0)
12483  dterr = DecodeDateTime(field, ftype, nf, &dtype, tm, &fsec, &tz);
12484  if (dterr != 0)
12485  return false;
12486  if (dtype != DTK_DATE)
12487  return false;
12488 
12489  if (tm2timestamp(tm, fsec, &tz, &timestamp) != 0)
12490  {
12491  GUC_check_errdetail("timestamp out of range: \"%s\"", str);
12492  return false;
12493  }
12494  }
12495  }
12496  return true;
12497 }
int ParseDateTime(const char *timestr, char *workbuf, size_t buflen, char **field, int *ftype, int maxfields, int *numfields)
Definition: datetime.c:582
int DecodeDateTime(char **field, int *ftype, int nf, int *dtype, struct pg_tm *tm, fsec_t *fsec, int *tzp)
Definition: datetime.c:803
int tm2timestamp(struct pg_tm *tm, fsec_t fsec, int *tzp, Timestamp *result)
Definition: timestamp.c:1918
int64 TimestampTz
Definition: timestamp.h:39
int32 fsec_t
Definition: timestamp.h:41
#define MAXDATEFIELDS
Definition: datetime.h:203
#define DTK_DATE
Definition: datetime.h:145
#define MAXDATELEN
Definition: datetime.h:201
static struct pg_tm tm
Definition: localtime.c:102
int64 timestamp
Definition: pgtime.h:33

References DecodeDateTime(), DTK_DATE, GUC_check_errdetail, MAXDATEFIELDS, MAXDATELEN, newval, ParseDateTime(), generate_unaccent_rules::str, tm, and tm2timestamp().

◆ check_recovery_target_timeline()

static bool check_recovery_target_timeline ( char **  newval,
void **  extra,
GucSource  source 
)
static

Definition at line 12321 of file guc.c.

12322 {
12324  RecoveryTargetTimeLineGoal *myextra;
12325 
12326  if (strcmp(*newval, "current") == 0)
12328  else if (strcmp(*newval, "latest") == 0)
12330  else
12331  {
12333 
12334  errno = 0;
12335  strtoul(*newval, NULL, 0);
12336  if (errno == EINVAL || errno == ERANGE)
12337  {
12338  GUC_check_errdetail("recovery_target_timeline is not a valid number.");
12339  return false;
12340  }
12341  }
12342 
12344  *myextra = rttg;
12345  *extra = (void *) myextra;
12346 
12347  return true;
12348 }
@ RECOVERY_TARGET_TIMELINE_CONTROLFILE
Definition: xlog.h:51
@ RECOVERY_TARGET_TIMELINE_LATEST
Definition: xlog.h:52

References ERROR, config_generic::extra, GUC_check_errdetail, guc_malloc(), newval, RECOVERY_TARGET_TIMELINE_CONTROLFILE, RECOVERY_TARGET_TIMELINE_LATEST, and RECOVERY_TARGET_TIMELINE_NUMERIC.

◆ check_recovery_target_xid()

static bool check_recovery_target_xid ( char **  newval,
void **  extra,
GucSource  source 
)
static

Definition at line 12407 of file guc.c.

12408 {
12409  if (strcmp(*newval, "") != 0)
12410  {
12411  TransactionId xid;
12412  TransactionId *myextra;
12413 
12414  errno = 0;
12415  xid = (TransactionId) strtou64(*newval, NULL, 0);
12416  if (errno == EINVAL || errno == ERANGE)
12417  return false;
12418 
12419  myextra = (TransactionId *) guc_malloc(ERROR, sizeof(TransactionId));
12420  *myextra = xid;
12421  *extra = (void *) myextra;
12422  }
12423  return true;
12424 }
#define strtou64(str, endptr, base)
Definition: c.h:1322

References ERROR, config_generic::extra, guc_malloc(), newval, and strtou64.

◆ check_ssl()

static bool check_ssl ( bool newval,
void **  extra,
GucSource  source 
)
static

Definition at line 11850 of file guc.c.

11851 {
11852 #ifndef USE_SSL
11853  if (*newval)
11854  {
11855  GUC_check_errmsg("SSL is not supported by this build");
11856  return false;
11857  }
11858 #endif
11859  return true;
11860 }

References GUC_check_errmsg, and newval.

◆ check_stage_log_stats()

static bool check_stage_log_stats ( bool newval,
void **  extra,
GucSource  source 
)
static

Definition at line 11863 of file guc.c.

11864 {
11865  if (*newval && log_statement_stats)
11866  {
11867  GUC_check_errdetail("Cannot enable parameter when \"log_statement_stats\" is true.");
11868  return false;
11869  }
11870  return true;
11871 }
bool log_statement_stats
Definition: guc.c:582

References GUC_check_errdetail, log_statement_stats, and newval.

◆ check_temp_buffers()

static bool check_temp_buffers ( int *  newval,
void **  extra,
GucSource  source 
)
static

Definition at line 11822 of file guc.c.

11823 {
11824  /*
11825  * Once local buffers have been initialized, it's too late to change this.
11826  * However, if this is only a test call, allow it.
11827  */
11828  if (source != PGC_S_TEST && NLocBuffer && NLocBuffer != *newval)
11829  {
11830  GUC_check_errdetail("\"temp_buffers\" cannot be changed after any temporary tables have been accessed in the session.");
11831  return false;
11832  }
11833  return true;
11834 }
@ PGC_S_TEST
Definition: guc.h:118
int NLocBuffer
Definition: localbuf.c:41

References GUC_check_errdetail, newval, NLocBuffer, PGC_S_TEST, and source.

◆ check_timezone_abbreviations()

static bool check_timezone_abbreviations ( char **  newval,
void **  extra,
GucSource  source 
)
static

Definition at line 11901 of file guc.c.

11902 {
11903  /*
11904  * The boot_val given above for timezone_abbreviations is NULL. When we
11905  * see this we just do nothing. If this value isn't overridden from the
11906  * config file then pg_timezone_abbrev_initialize() will eventually
11907  * replace it with "Default". This hack has two purposes: to avoid
11908  * wasting cycles loading values that might soon be overridden from the
11909  * config file, and to avoid trying to read the timezone abbrev files
11910  * during InitializeGUCOptions(). The latter doesn't work in an
11911  * EXEC_BACKEND subprocess because my_exec_path hasn't been set yet and so
11912  * we can't locate PGSHAREDIR.
11913  */
11914  if (*newval == NULL)
11915  {
11917  return true;
11918  }
11919 
11920  /* OK, load the file and produce a malloc'd TimeZoneAbbrevTable */
11921  *extra = load_tzoffsets(*newval);
11922 
11923  /* tzparser.c returns NULL on failure, reporting via GUC_check_errmsg */
11924  if (!*extra)
11925  return false;
11926 
11927  return true;
11928 }
TimeZoneAbbrevTable * load_tzoffsets(const char *filename)
Definition: tzparser.c:437

References Assert(), config_generic::extra, load_tzoffsets(), newval, PGC_S_DEFAULT, and source.

◆ check_wal_consistency_checking()

static bool check_wal_consistency_checking ( char **  newval,
void **  extra,
GucSource  source 
)
static

Definition at line 11646 of file guc.c.

11647 {
11648  char *rawstring;
11649  List *elemlist;
11650  ListCell *l;
11651  bool newwalconsistency[RM_MAX_ID + 1];
11652 
11653  /* Initialize the array */
11654  MemSet(newwalconsistency, 0, (RM_MAX_ID + 1) * sizeof(bool));
11655 
11656  /* Need a modifiable copy of string */
11657  rawstring = pstrdup(*newval);
11658 
11659  /* Parse string into list of identifiers */
11660  if (!SplitIdentifierString(rawstring, ',', &elemlist))
11661  {
11662  /* syntax error in list */
11663  GUC_check_errdetail("List syntax is invalid.");
11664  pfree(rawstring);
11665  list_free(elemlist);
11666  return false;
11667  }
11668 
11669  foreach(l, elemlist)
11670  {
11671  char *tok = (char *) lfirst(l);
11672  bool found = false;
11673  RmgrId rmid;
11674 
11675  /* Check for 'all'. */
11676  if (pg_strcasecmp(tok, "all") == 0)
11677  {
11678  for (rmid = 0; rmid <= RM_MAX_ID; rmid++)
11679  if (RmgrTable[rmid].rm_mask != NULL)
11680  newwalconsistency[rmid] = true;
11681  found = true;
11682  }
11683  else
11684  {
11685  /*
11686  * Check if the token matches with any individual resource
11687  * manager.
11688  */
11689  for (rmid = 0; rmid <= RM_MAX_ID; rmid++)
11690  {
11691  if (pg_strcasecmp(tok, RmgrTable[rmid].rm_name) == 0 &&
11692  RmgrTable[rmid].rm_mask != NULL)
11693  {
11694  newwalconsistency[rmid] = true;
11695  found = true;
11696  }
11697  }
11698  }
11699 
11700  /* If a valid resource manager is found, check for the next one. */
11701  if (!found)
11702  {
11703  GUC_check_errdetail("Unrecognized key word: \"%s\".", tok);
11704  pfree(rawstring);
11705  list_free(elemlist);
11706  return false;
11707  }
11708  }
11709 
11710  pfree(rawstring);
11711  list_free(elemlist);
11712 
11713  /* assign new value */
11714  *extra = guc_malloc(ERROR, (RM_MAX_ID + 1) * sizeof(bool));
11715  memcpy(*extra, newwalconsistency, (RM_MAX_ID + 1) * sizeof(bool));
11716  return true;
11717 }
#define MemSet(start, val, len)
Definition: c.h:1008
const RmgrData RmgrTable[RM_MAX_ID+1]
Definition: rmgr.c:36
#define RM_MAX_ID
Definition: rmgr.h:33
uint8 RmgrId
Definition: rmgr.h:11
void(* rm_mask)(char *pagedata, BlockNumber blkno)

References ERROR, config_generic::extra, GUC_check_errdetail, guc_malloc(), lfirst, list_free(), MemSet, newval, pfree(), pg_strcasecmp(), pstrdup(), RmgrData::rm_mask, RM_MAX_ID, RmgrTable, and SplitIdentifierString().

◆ config_enum_get_options()

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

Definition at line 7091 of file guc.c.

7093 {
7094  const struct config_enum_entry *entry;
7095  StringInfoData retstr;
7096  int seplen;
7097 
7098  initStringInfo(&retstr);
7099  appendStringInfoString(&retstr, prefix);
7100 
7101  seplen = strlen(separator);
7102  for (entry = record->options; entry && entry->name; entry++)
7103  {
7104  if (!entry->hidden)
7105  {
7106  appendStringInfoString(&retstr, entry->name);
7107  appendBinaryStringInfo(&retstr, separator, seplen);
7108  }
7109  }
7110 
7111  /*
7112  * All the entries may have been hidden, leaving the string empty if no
7113  * prefix was given. This indicates a broken GUC setup, since there is no
7114  * use for an enum without any values, so we just check to make sure we
7115  * don't write to invalid memory instead of actually trying to do
7116  * something smart with it.
7117  */
7118  if (retstr.len >= seplen)
7119  {
7120  /* Replace final separator */
7121  retstr.data[retstr.len - seplen] = '\0';
7122  retstr.len -= seplen;
7123  }
7124 
7125  appendStringInfoString(&retstr, suffix);
7126 
7127  return retstr.data;
7128 }
void appendBinaryStringInfo(StringInfo str, const char *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:165
const char * name
Definition: guc.h:166
bool hidden
Definition: guc.h:168
const struct config_enum_entry * options
Definition: guc_tables.h:241

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

Referenced by GetConfigOptionByNum(), 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 7065 of file guc.c.

7067 {
7068  const struct config_enum_entry *entry;
7069 
7070  for (entry = record->options; entry && entry->name; entry++)
7071  {
7072  if (pg_strcasecmp(value, entry->name) == 0)
7073  {
7074  *retval = entry->val;
7075  return true;
7076  }
7077  }
7078 
7079  *retval = 0;
7080  return false;
7081 }
int val
Definition: guc.h:167

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

7043 {
7044  const struct config_enum_entry *entry;
7045 
7046  for (entry = record->options; entry && entry->name; entry++)
7047  {
7048  if (entry->val == val)
7049  return entry->name;
7050  }
7051 
7052  elog(ERROR, "could not find enum option %d for %s",
7053  val, record->gen.name);
7054  return NULL; /* silence compiler */
7055 }

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

◆ convert_int_from_base_unit()

static void convert_int_from_base_unit ( int64  base_value,
int  base_unit,
int64 *  value,
const char **  unit 
)
static

Definition at line 6748 of file guc.c.

6750 {
6751  const unit_conversion *table;
6752  int i;
6753 
6754  *unit = NULL;
6755 
6756  if (base_unit & GUC_UNIT_MEMORY)
6758  else
6760 
6761  for (i = 0; *table[i].unit; i++)
6762  {
6763  if (base_unit == table[i].base_unit)
6764  {
6765  /*
6766  * Accept the first conversion that divides the value evenly. We
6767  * assume that the conversions for each base unit are ordered from
6768  * greatest unit to the smallest!
6769  */
6770  if (table[i].multiplier <= 1.0 ||
6771  base_value % (int64) table[i].multiplier == 0)
6772  {
6773  *value = (int64) rint(base_value / table[i].multiplier);
6774  *unit = table[i].unit;
6775  break;
6776  }
6777  }
6778  }
6779 
6780  Assert(*unit != NULL);
6781 }
static const unit_conversion memory_unit_conversion_table[]
Definition: guc.c:880
static const unit_conversion time_unit_conversion_table[]
Definition: guc.c:917
#define GUC_UNIT_MEMORY
Definition: guc.h:222
char unit[MAX_UNIT_LEN+1]
Definition: guc.c:864

References Assert(), GUC_UNIT_MEMORY, i, memory_unit_conversion_table, time_unit_conversion_table, unit_conversion::unit, and value.

Referenced by _ShowOption().

◆ convert_real_from_base_unit()

static void convert_real_from_base_unit ( double  base_value,
int  base_unit,
double *  value,
const char **  unit 
)
static

Definition at line 6790 of file guc.c.

6792 {
6793  const unit_conversion *table;
6794  int i;
6795 
6796  *unit = NULL;
6797 
6798  if (base_unit & GUC_UNIT_MEMORY)
6800  else
6802 
6803  for (i = 0; *table[i].unit; i++)
6804  {
6805  if (base_unit == table[i].base_unit)
6806  {
6807  /*
6808  * Accept the first conversion that divides the value evenly; or
6809  * if there is none, use the smallest (last) target unit.
6810  *
6811  * What we actually care about here is whether snprintf with "%g"
6812  * will print the value as an integer, so the obvious test of
6813  * "*value == rint(*value)" is too strict; roundoff error might
6814  * make us choose an unreasonably small unit. As a compromise,
6815  * accept a divisor that is within 1e-8 of producing an integer.
6816  */
6817  *value = base_value / table[i].multiplier;
6818  *unit = table[i].unit;
6819  if (*value > 0 &&
6820  fabs((rint(*value) / *value) - 1.0) <= 1e-8)
6821  break;
6822  }
6823  }
6824 
6825  Assert(*unit != NULL);
6826 }
e
Definition: preproc-init.c:82
double multiplier
Definition: guc.c:867

References Assert(), GUC_UNIT_MEMORY, i, memory_unit_conversion_table, unit_conversion::multiplier, time_unit_conversion_table, unit_conversion::unit, and value.

Referenced by _ShowOption().

◆ convert_to_base_unit()

static bool convert_to_base_unit ( double  value,
const char *  unit,
int  base_unit,
double *  base_value 
)
static

Definition at line 6690 of file guc.c.

6692 {
6693  char unitstr[MAX_UNIT_LEN + 1];
6694  int unitlen;
6695  const unit_conversion *table;
6696  int i;
6697 
6698  /* extract unit string to compare to table entries */
6699  unitlen = 0;
6700  while (*unit != '\0' && !isspace((unsigned char) *unit) &&
6701  unitlen < MAX_UNIT_LEN)
6702  unitstr[unitlen++] = *(unit++);
6703  unitstr[unitlen] = '\0';
6704  /* allow whitespace after unit */
6705  while (isspace((unsigned char) *unit))
6706  unit++;
6707  if (*unit != '\0')
6708  return false; /* unit too long, or garbage after it */
6709 
6710  /* now search the appropriate table */
6711  if (base_unit & GUC_UNIT_MEMORY)
6713  else
6715 
6716  for (i = 0; *table[i].unit; i++)
6717  {
6718  if (base_unit == table[i].base_unit &&
6719  strcmp(unitstr, table[i].unit) == 0)
6720  {
6721  double cvalue = value * table[i].multiplier;
6722 
6723  /*
6724  * If the user gave a fractional value such as "30.1GB", round it
6725  * off to the nearest multiple of the next smaller unit, if there
6726  * is one.
6727  */
6728  if (*table[i + 1].unit &&
6729  base_unit == table[i + 1].base_unit)
6730  cvalue = rint(cvalue / table[i + 1].multiplier) *
6731  table[i + 1].multiplier;
6732 
6733  *base_value = cvalue;
6734  return true;
6735  }
6736  }
6737  return false;
6738 }
#define MAX_UNIT_LEN
Definition: guc.c:860

References GUC_UNIT_MEMORY, i, MAX_UNIT_LEN, memory_unit_conversion_table, unit_conversion::multiplier, time_unit_conversion_table, unit_conversion::unit, and value.

Referenced by parse_int(), and parse_real().

◆ define_custom_variable()

static void define_custom_variable ( struct config_generic variable)
static

Definition at line 9024 of file guc.c.

9025 {
9026  const char *name = variable->name;
9027  const char **nameAddr = &name;
9028  struct config_string *pHolder;
9029  struct config_generic **res;
9030 
9031  /*
9032  * See if there's a placeholder by the same name.
9033  */
9034  res = (struct config_generic **) bsearch((void *) &nameAddr,
9035  (void *) guc_variables,
9037  sizeof(struct config_generic *),
9038  guc_var_compare);
9039  if (res == NULL)
9040  {
9041  /*
9042  * No placeholder to replace, so we can just add it ... but first,
9043  * make sure it's initialized to its default value.
9044  */
9047  return;
9048  }
9049 
9050  /*
9051  * This better be a placeholder
9052  */
9053  if (((*res)->flags & GUC_CUSTOM_PLACEHOLDER) == 0)
9054  ereport(ERROR,
9055  (errcode(ERRCODE_INTERNAL_ERROR),
9056  errmsg("attempt to redefine parameter \"%s\"", name)));
9057 
9058  Assert((*res)->vartype == PGC_STRING);
9059  pHolder = (struct config_string *) (*res);
9060 
9061  /*
9062  * First, set the variable to its default value. We must do this even
9063  * though we intend to immediately apply a new value, since it's possible
9064  * that the new value is invalid.
9065  */
9067 
9068  /*
9069  * Replace the placeholder. We aren't changing the name, so no re-sorting
9070  * is necessary
9071  */
9072  *res = variable;
9073 
9074  /*
9075  * Assign the string value(s) stored in the placeholder to the real
9076  * variable. Essentially, we need to duplicate all the active and stacked
9077  * values, but with appropriate validation and datatype adjustment.
9078  *
9079  * If an assignment fails, we report a WARNING and keep going. We don't
9080  * want to throw ERROR for bad values, because it'd bollix the add-on
9081  * module that's presumably halfway through getting loaded. In such cases
9082  * the default or previous state will become active instead.
9083  */
9084 
9085  /* First, apply the reset value if any */
9086  if (pHolder->reset_val)
9087  (void) set_config_option(name, pHolder->reset_val,
9088  pHolder->gen.reset_scontext,
9089  pHolder->gen.reset_source,
9090  GUC_ACTION_SET, true, WARNING, false);
9091  /* That should not have resulted in stacking anything */
9092  Assert(variable->stack == NULL);
9093 
9094  /* Now, apply current and stacked values, in the order they were stacked */
9095  reapply_stacked_values(variable, pHolder, pHolder->gen.stack,
9096  *(pHolder->variable),
9097  pHolder->gen.scontext, pHolder->gen.source);
9098 
9099  /* Also copy over any saved source-location information */
9100  if (pHolder->gen.sourcefile)
9102  pHolder->gen.sourceline);
9103 
9104  /*
9105  * Free up as much as we conveniently can of the placeholder structure.
9106  * (This neglects any stack items, so it's possible for some memory to be
9107  * leaked. Since this can only happen once per session per variable, it
9108  * doesn't seem worth spending much code on.)
9109  */
9110  set_string_field(pHolder, pHolder->variable, NULL);
9111  set_string_field(pHolder, &pHolder->reset_val, NULL);
9112 
9113  free(pHolder);
9114 }
static void static void set_config_sourcefile(const char *name, char *sourcefile, int sourceline)
Definition: guc.c:8107
static void InitializeOneGUCOption(struct config_generic *gconf)
Definition: guc.c:5759
static void reapply_stacked_values(struct config_generic *variable, struct config_string *pHolder, GucStack *stack, const char *curvalue, GucContext curscontext, GucSource cursource)
Definition: guc.c:9124
int set_config_option(const char *name, const char *value, GucContext context, GucSource source, GucAction action, bool changeVal, int elevel, bool is_reload)
Definition: guc.c:7350
@ GUC_ACTION_SET
Definition: guc.h:194
char * sourcefile
Definition: guc_tables.h:158
GucContext reset_scontext
Definition: guc_tables.h:153
GucSource reset_source
Definition: guc_tables.h:151
char * reset_val
Definition: guc_tables.h:231
char * name
Definition: type.h:172

References add_guc_variable(), Assert(), ereport, errcode(), errmsg(), ERROR, free, config_string::gen, GUC_ACTION_SET, GUC_CUSTOM_PLACEHOLDER, guc_var_compare(), guc_variables, InitializeOneGUCOption(), name, variable::name, num_guc_variables, PGC_STRING, reapply_stacked_values(), res, config_generic::reset_scontext, config_generic::reset_source, config_string::reset_val, config_generic::scontext, set_config_option(), set_config_sourcefile(), set_string_field(), config_generic::source, config_generic::sourcefile, config_generic::sourceline, config_generic::stack, config_string::variable, and WARNING.

Referenced by DefineCustomBoolVariable(), DefineCustomEnumVariable(), DefineCustomIntVariable(), DefineCustomRealVariable(), and DefineCustomStringVariable().

◆ DefineCustomBoolVariable()

void DefineCustomBoolVariable ( const char *  name,
const char *  short_desc,
const char *  long_desc,
bool valueAddr,
bool  bootValue,
GucContext  context,
int  flags,
GucBoolCheckHook  check_hook,
GucBoolAssignHook  assign_hook,
GucShowHook  show_hook 
)

Definition at line 9208 of file guc.c.

9218 {
9219  struct config_bool *var;
9220 
9221  var = (struct config_bool *)
9222  init_custom_variable(name, short_desc, long_desc, context, flags,
9223  PGC_BOOL, sizeof(struct config_bool));
9224  var->variable = valueAddr;
9225  var->boot_val = bootValue;
9226  var->reset_val = bootValue;
9227  var->check_hook = check_hook;
9228  var->assign_hook = assign_hook;
9229  var->show_hook = show_hook;
9230  define_custom_variable(&var->gen);
9231 }
static struct config_generic * init_custom_variable(const char *name, const char *short_desc, const char *long_desc, GucContext context, int flags, enum config_type type, size_t sz)
Definition: guc.c:8964
static void define_custom_variable(struct config_generic *variable)
Definition: guc.c:9024
bool reset_val
Definition: guc_tables.h:185
bool boot_val
Definition: guc_tables.h:180

References config_bool::assign_hook, config_bool::boot_val, config_bool::check_hook, define_custom_variable(), config_bool::gen, init_custom_variable(), name, PGC_BOOL, config_bool::reset_val, config_bool::show_hook, and config_bool::variable.

Referenced by _PG_init().

◆ DefineCustomEnumVariable()

void DefineCustomEnumVariable ( const char *  name,
const char *  short_desc,
const char *  long_desc,
int *  valueAddr,
int  bootValue,
const struct config_enum_entry options,
GucContext  context,
int  flags,
GucEnumCheckHook  check_hook,
GucEnumAssignHook  assign_hook,
GucShowHook  show_hook 
)

Definition at line 9319 of file guc.c.

9330 {
9331  struct config_enum *var;
9332 
9333  var = (struct config_enum *)
9334  init_custom_variable(name, short_desc, long_desc, context, flags,
9335  PGC_ENUM, sizeof(struct config_enum));
9336  var->variable = valueAddr;
9337  var->boot_val = bootValue;
9338  var->reset_val = bootValue;
9339  var->options = options;
9340  var->check_hook = check_hook;
9341  var->assign_hook = assign_hook;
9342  var->show_hook = show_hook;
9343  define_custom_variable(&var->gen);
9344 }
static char ** options

References config_enum::assign_hook, config_enum::boot_val, config_enum::check_hook, define_custom_variable(), config_enum::gen, init_custom_variable(), name, options, config_enum::options, PGC_ENUM, config_enum::reset_val, config_enum::show_hook, and config_enum::variable.

Referenced by _PG_init().

◆ DefineCustomIntVariable()

void DefineCustomIntVariable ( const char *  name,
const char *  short_desc,
const char *  long_desc,
int *  valueAddr,
int  bootValue,
int  minValue,
int  maxValue,
GucContext  context,
int  flags,
GucIntCheckHook  check_hook,
GucIntAssignHook  assign_hook,
GucShowHook  show_hook 
)

Definition at line 9234 of file guc.c.

9246 {
9247  struct config_int *var;
9248 
9249  var = (struct config_int *)
9250  init_custom_variable(name, short_desc, long_desc, context, flags,
9251  PGC_INT, sizeof(struct config_int));
9252  var->variable = valueAddr;
9253  var->boot_val = bootValue;
9254  var->reset_val = bootValue;
9255  var->min = minValue;
9256  var->max = maxValue;
9257  var->check_hook = check_hook;
9258  var->assign_hook = assign_hook;
9259  var->show_hook = show_hook;
9260  define_custom_variable(&var->gen);
9261 }
int reset_val
Definition: guc_tables.h:201
int boot_val
Definition: guc_tables.h:194

References config_int::assign_hook, config_int::boot_val, config_int::check_hook, define_custom_variable(), config_int::gen, init_custom_variable(), config_int::max, config_int::min, name, PGC_INT, config_int::reset_val, config_int::show_hook, and config_int::variable.

Referenced by _PG_init().

◆ DefineCustomRealVariable()

void DefineCustomRealVariable ( const char *  name,
const char *  short_desc,
const char *  long_desc,
double *  valueAddr,
double  bootValue,
double  minValue,
double  maxValue,
GucContext  context,
int  flags,
GucRealCheckHook  check_hook,
GucRealAssignHook  assign_hook,
GucShowHook  show_hook 
)

Definition at line 9264 of file guc.c.

9276 {
9277  struct config_real *var;
9278 
9279  var = (struct config_real *)
9280  init_custom_variable(name, short_desc, long_desc, context, flags,
9281  PGC_REAL, sizeof(struct config_real));
9282  var->variable = valueAddr;
9283  var->boot_val = bootValue;
9284  var->reset_val = bootValue;
9285  var->min = minValue;
9286  var->max = maxValue;
9287  var->check_hook = check_hook;
9288  var->assign_hook = assign_hook;
9289  var->show_hook = show_hook;
9290  define_custom_variable(&var->gen);
9291 }
double boot_val
Definition: guc_tables.h:210
double reset_val
Definition: guc_tables.h:217
double min
Definition: guc_tables.h:211
double max
Definition: guc_tables.h:212

References config_real::assign_hook, config_real::boot_val, config_real::check_hook, define_custom_variable(), config_real::gen, init_custom_variable(), config_real::max, config_real::min, name, PGC_REAL, config_real::reset_val, config_real::show_hook, and config_real::variable.

Referenced by _PG_init().

◆ DefineCustomStringVariable()

void DefineCustomStringVariable ( const char *  name,
const char *  short_desc,
const char *  long_desc,
char **  valueAddr,
const char *  bootValue,
GucContext  context,
int  flags,
GucStringCheckHook  check_hook,
GucStringAssignHook  assign_hook,
GucShowHook  show_hook 
)

Definition at line 9294 of file guc.c.

9304 {
9305  struct config_string *var;
9306 
9307  var = (struct config_string *)
9308  init_custom_variable(name, short_desc, long_desc, context, flags,
9309  PGC_STRING, sizeof(struct config_string));
9310  var->variable = valueAddr;
9311  var->boot_val = bootValue;
9312  var->check_hook = check_hook;
9313  var->assign_hook = assign_hook;
9314  var->show_hook = show_hook;
9315  define_custom_variable(&var->gen);
9316 }
const char * boot_val
Definition: guc_tables.h:226

References config_string::assign_hook, config_string::boot_val, config_string::check_hook, define_custom_variable(), config_string::gen, init_custom_variable(), name, PGC_STRING, config_string::show_hook, and config_string::variable.

Referenced by _PG_init().

◆ discard_stack_value()

static void discard_stack_value ( struct config_generic gconf,
config_var_value val 
)
static

Definition at line 5283 of file guc.c.

5284 {
5285  switch (gconf->vartype)
5286  {
5287  case PGC_BOOL:
5288  case PGC_INT:
5289  case PGC_REAL:
5290  case PGC_ENUM:
5291  /* no need to do anything */
5292  break;
5293  case PGC_STRING:
5294  set_string_field((struct config_string *) gconf,
5295  &(val->val.stringval),
5296  NULL);
5297  break;
5298  }
5299  set_extra_field(gconf, &(val->extra), NULL);
5300 }

References PGC_BOOL, PGC_ENUM, PGC_INT, PGC_REAL, PGC_STRING, set_extra_field(), set_string_field(), val, and config_generic::vartype.

Referenced by AtEOXact_GUC(), and push_old_value().

◆ do_serialize()

static void do_serialize ( char **  destptr,
Size maxbytes,
const char *  fmt,
  ... 
)
static

Definition at line 10669 of file guc.c.

10670 {
10671  va_list vargs;
10672  int n;
10673 
10674  if (*maxbytes <= 0)
10675  elog(ERROR, "not enough space to serialize GUC state");
10676 
10677  va_start(vargs, fmt);
10678  n = vsnprintf(*destptr, *maxbytes, fmt, vargs);
10679  va_end(vargs);
10680 
10681  if (n < 0)
10682  {
10683  /* Shouldn't happen. Better show errno description. */
10684  elog(ERROR, "vsnprintf failed: %m with format string \"%s\"", fmt);
10685  }
10686  if (n >= *maxbytes)
10687  {
10688  /* This shouldn't happen either, really. */
10689  elog(ERROR, "not enough space to serialize GUC state");
10690  }
10691 
10692  /* Shift the destptr ahead of the null terminator */
10693  *destptr += n + 1;
10694  *maxbytes -= n + 1;
10695 }
va_end(args)
static void const char * fmt
va_start(args, fmt)
#define vsnprintf
Definition: port.h:224

References elog, ERROR, fmt, va_end(), va_start(), and vsnprintf.

Referenced by serialize_variable().

◆ do_serialize_binary()

static void do_serialize_binary ( char **  destptr,
Size maxbytes,
void *  val,
Size  valsize 
)
static

Definition at line 10699 of file guc.c.

10700 {
10701  if (valsize > *maxbytes)
10702  elog(ERROR, "not enough space to serialize GUC state");
10703 
10704  memcpy(*destptr, val, valsize);
10705  *destptr += valsize;
10706  *maxbytes -= valsize;
10707 }

References elog, ERROR, and val.

Referenced by serialize_variable().

◆ EmitWarningsOnPlaceholders()

void EmitWarningsOnPlaceholders ( const char *  className)

Definition at line 9351 of file guc.c.

9352 {
9353  int classLen = strlen(className);
9354  int i;
9355 
9356  for (i = 0; i < num_guc_variables; i++)
9357  {
9358  struct config_generic *var = guc_variables[i];
9359 
9360  if ((var->flags & GUC_CUSTOM_PLACEHOLDER) != 0 &&
9361  strncmp(className, var->name, classLen) == 0 &&
9362  var->name[classLen] == GUC_QUALIFIER_SEPARATOR)
9363  {
9364  ereport(WARNING,
9365  (errcode(ERRCODE_UNDEFINED_OBJECT),
9366  errmsg("unrecognized configuration parameter \"%s\"",
9367  var->name)));
9368  }
9369  }
9370 }
#define GUC_QUALIFIER_SEPARATOR
Definition: guc.h:199

References ereport, errcode(), errmsg(), config_generic::flags, GUC_CUSTOM_PLACEHOLDER, GUC_QUALIFIER_SEPARATOR, guc_variables, i, config_generic::name, num_guc_variables, and WARNING.

Referenced by _PG_init().

◆ estimate_variable_size()

static Size estimate_variable_size ( struct config_generic gconf)
static

Definition at line 10547 of file guc.c.

10548 {
10549  Size size;
10550  Size valsize = 0;
10551 
10552  /* Skippable GUCs consume zero space. */
10553  if (can_skip_gucvar(gconf))
10554  return 0;
10555 
10556  /* Name, plus trailing zero byte. */
10557  size = strlen(gconf->name) + 1;
10558 
10559  /* Get the maximum display length of the GUC value. */
10560  switch (gconf->vartype)
10561  {
10562  case PGC_BOOL:
10563  {
10564  valsize = 5; /* max(strlen('true'), strlen('false')) */
10565  }
10566  break;
10567 
10568  case PGC_INT:
10569  {
10570  struct config_int *conf = (struct config_int *) gconf;
10571 
10572  /*
10573  * Instead of getting the exact display length, use max
10574  * length. Also reduce the max length for typical ranges of
10575  * small values. Maximum value is 2147483647, i.e. 10 chars.
10576  * Include one byte for sign.
10577  */
10578  if (Abs(*conf->variable) < 1000)
10579  valsize = 3 + 1;
10580  else
10581  valsize = 10 + 1;
10582  }
10583  break;
10584 
10585  case PGC_REAL:
10586  {
10587  /*
10588  * We are going to print it with %e with REALTYPE_PRECISION
10589  * fractional digits. Account for sign, leading digit,
10590  * decimal point, and exponent with up to 3 digits. E.g.
10591  * -3.99329042340000021e+110
10592  */
10593  valsize = 1 + 1 + 1 + REALTYPE_PRECISION + 5;
10594  }
10595  break;
10596 
10597  case PGC_STRING:
10598  {
10599  struct config_string *conf = (struct config_string *) gconf;
10600 
10601  /*
10602  * If the value is NULL, we transmit it as an empty string.
10603  * Although this is not physically the same value, GUC
10604  * generally treats a NULL the same as empty string.
10605  */
10606  if (*conf->variable)
10607  valsize = strlen(*conf->variable);
10608  else
10609  valsize = 0;
10610  }
10611  break;
10612 
10613  case PGC_ENUM:
10614  {
10615  struct config_enum *conf = (struct config_enum *) gconf;
10616 
10617  valsize = strlen(config_enum_lookup_by_value(conf, *conf->variable));
10618  }
10619  break;
10620  }
10621 
10622  /* Allow space for terminating zero-byte for value */
10623  size = add_size(size, valsize + 1);
10624 
10625  if (gconf->sourcefile)
10626  size = add_size(size, strlen(gconf->sourcefile));
10627 
10628  /* Allow space for terminating zero-byte for sourcefile */
10629  size = add_size(size, 1);
10630 
10631  /* Include line whenever file is nonempty. */
10632  if (gconf->sourcefile && gconf->sourcefile[0])
10633  size = add_size(size, sizeof(gconf->sourceline));
10634 
10635  size = add_size(size, sizeof(gconf->source));
10636  size = add_size(size, sizeof(gconf->scontext));
10637 
10638  return size;
10639 }
#define Abs(x)
Definition: c.h:992
size_t Size
Definition: c.h:540
static bool can_skip_gucvar(struct config_generic *gconf)
Definition: guc.c:10507
#define REALTYPE_PRECISION
Definition: guc.c:131
Size add_size(Size s1, Size s2)
Definition: shmem.c:502

References Abs, add_size(), can_skip_gucvar(), config_enum_lookup_by_value(), config_generic::name, PGC_BOOL, PGC_ENUM, PGC_INT, PGC_REAL, PGC_STRING, REALTYPE_PRECISION, config_generic::scontext, config_generic::source, config_generic::sourcefile, config_generic::sourceline, config_int::variable, config_string::variable, config_enum::variable, and config_generic::vartype.

Referenced by EstimateGUCStateSpace().

◆ EstimateGUCStateSpace()

Size EstimateGUCStateSpace ( void  )

Definition at line 10646 of file guc.c.

10647 {
10648  Size size;
10649  int i;
10650 
10651  /* Add space reqd for saving the data size of the guc state */
10652  size = sizeof(Size);
10653 
10654  /* Add up the space needed for each GUC variable */
10655  for (i = 0; i < num_guc_variables; i++)
10656  size = add_size(size,
10658 
10659  return size;
10660 }
static Size estimate_variable_size(struct config_generic *gconf)
Definition: guc.c:10547

References add_size(), estimate_variable_size(), guc_variables, i, and num_guc_variables.

Referenced by InitializeParallelDSM().

◆ ExecSetVariableStmt()

void ExecSetVariableStmt ( VariableSetStmt stmt,
bool  isTopLevel 
)

Definition at line 8753 of file guc.c.

8754 {
8756 
8757  /*
8758  * Workers synchronize these parameters at the start of the parallel
8759  * operation; then, we block SET during the operation.
8760  */
8761  if (IsInParallelMode())
8762  ereport(ERROR,
8763  (errcode(ERRCODE_INVALID_TRANSACTION_STATE),
8764  errmsg("cannot set parameters during a parallel operation")));
8765 
8766  switch (stmt->kind)
8767  {
8768  case VAR_SET_VALUE:
8769  case VAR_SET_CURRENT:
8770  if (stmt->is_local)
8771  WarnNoTransactionBlock(isTopLevel, "SET LOCAL");
8772  (void) set_config_option(stmt->name,
8773  ExtractSetVariableArgs(stmt),
8775  PGC_S_SESSION,
8776  action, true, 0, false);
8777  break;
8778  case VAR_SET_MULTI:
8779 
8780  /*
8781  * Special-case SQL syntaxes. The TRANSACTION and SESSION
8782  * CHARACTERISTICS cases effectively set more than one variable
8783  * per statement. TRANSACTION SNAPSHOT only takes one argument,
8784  * but we put it here anyway since it's a special case and not
8785  * related to any GUC variable.
8786  */
8787  if (strcmp(stmt->name, "TRANSACTION") == 0)
8788  {
8789  ListCell *head;
8790 
8791  WarnNoTransactionBlock(isTopLevel, "SET TRANSACTION");
8792 
8793  foreach(head, stmt->args)
8794  {
8795  DefElem *item = (DefElem *) lfirst(head);
8796 
8797  if (strcmp(item->defname, "transaction_isolation") == 0)
8798  SetPGVariable("transaction_isolation",
8799  list_make1(item->arg), stmt->is_local);
8800  else if (strcmp(item->defname, "transaction_read_only") == 0)
8801  SetPGVariable("transaction_read_only",
8802  list_make1(item->arg), stmt->is_local);
8803  else if (strcmp(item->defname, "transaction_deferrable") == 0)
8804  SetPGVariable("transaction_deferrable",
8805  list_make1(item->arg), stmt->is_local);
8806  else
8807  elog(ERROR, "unexpected SET TRANSACTION element: %s",
8808  item->defname);
8809  }
8810  }
8811  else if (strcmp(stmt->name, "SESSION CHARACTERISTICS") == 0)
8812  {
8813  ListCell *head;
8814 
8815  foreach(head, stmt->args)
8816  {
8817  DefElem *item = (DefElem *) lfirst(head);
8818 
8819  if (strcmp(item->defname, "transaction_isolation") == 0)
8820  SetPGVariable("default_transaction_isolation",
8821  list_make1(item->arg), stmt->is_local);
8822  else if (strcmp(item->defname, "transaction_read_only") == 0)
8823  SetPGVariable("default_transaction_read_only",
8824  list_make1(item->arg), stmt->is_local);
8825  else if (strcmp(item->defname, "transaction_deferrable") == 0)
8826  SetPGVariable("default_transaction_deferrable",
8827  list_make1(item->arg), stmt->is_local);
8828  else
8829  elog(ERROR, "unexpected SET SESSION element: %s",
8830  item->defname);
8831  }
8832  }
8833  else if (strcmp(stmt->name, "TRANSACTION SNAPSHOT") == 0)
8834  {
8835  A_Const *con = linitial_node(A_Const, stmt->args);
8836 
8837  if (stmt->is_local)
8838  ereport(ERROR,
8839  (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
8840  errmsg("SET LOCAL TRANSACTION SNAPSHOT is not implemented")));
8841 
8842  WarnNoTransactionBlock(isTopLevel, "SET TRANSACTION");
8843  ImportSnapshot(strVal(&con->val));
8844  }
8845  else
8846  elog(ERROR, "unexpected SET MULTI element: %s",
8847  stmt->name);
8848  break;
8849  case VAR_SET_DEFAULT:
8850  if (stmt->is_local)
8851  WarnNoTransactionBlock(isTopLevel, "SET LOCAL");
8852  /* fall through */
8853  case VAR_RESET:
8854  if (strcmp(stmt->name, "transaction_isolation") == 0)
8855  WarnNoTransactionBlock(isTopLevel, "RESET TRANSACTION");
8856 
8857  (void) set_config_option(stmt->name,
8858  NULL,
8860  PGC_S_SESSION,
8861  action, true, 0, false);
8862  break;
8863  case VAR_RESET_ALL:
8864  ResetAllOptions();
8865  break;
8866  }
8867 }
void ResetAllOptions(void)
Definition: guc.c:6055
void SetPGVariable(const char *name, List *args, bool is_local)
Definition: guc.c:8896
GucAction
Definition: guc.h:192
@ GUC_ACTION_LOCAL
Definition: guc.h:195
@ PGC_SUSET
Definition: guc.h:75
@ VAR_SET_MULTI
Definition: parsenodes.h:2146
@ VAR_SET_CURRENT
Definition: parsenodes.h:2145
#define linitial_node(type, l)
Definition: pg_list.h:177
#define list_make1(x1)
Definition: pg_list.h:206
void ImportSnapshot(const char *idstr)
Definition: snapmgr.c:1392
union A_Const::ValUnion val
char * defname
Definition: parsenodes.h:758
Node * arg
Definition: parsenodes.h:759
#define strVal(v)
Definition: value.h:72
void WarnNoTransactionBlock(bool isTopLevel, const char *stmtType)
Definition: xact.c:3510
bool IsInParallelMode(void)
Definition: xact.c:1064

References generate_unaccent_rules::action, DefElem::arg, VariableSetStmt::args, DefElem::defname, elog, ereport, errcode(), errmsg(), ERROR, ExtractSetVariableArgs(), GUC_ACTION_LOCAL, GUC_ACTION_SET, ImportSnapshot(), VariableSetStmt::is_local, IsInParallelMode(), VariableSetStmt::kind, lfirst, linitial_node, list_make1, VariableSetStmt::name, PGC_S_SESSION, PGC_SUSET, PGC_USERSET, ResetAllOptions(), set_config_option(), SetPGVariable(), strVal, superuser(), A_Const::val, VAR_RESET, VAR_RESET_ALL, VAR_SET_CURRENT, VAR_SET_DEFAULT, VAR_SET_MULTI, VAR_SET_VALUE, and WarnNoTransactionBlock().

Referenced by standard_ProcessUtility().

◆ extra_field_used()

static bool extra_field_used ( struct config_generic gconf,
void *  extra 
)
static

Definition at line 5184 of file guc.c.

5185 {
5186  GucStack *stack;
5187 
5188  if (extra == gconf->extra)
5189  return true;
5190  switch (gconf->vartype)
5191  {
5192  case PGC_BOOL:
5193  if (extra == ((struct config_bool *) gconf)->reset_extra)
5194  return true;
5195  break;
5196  case PGC_INT:
5197  if (extra == ((struct config_int *) gconf)->reset_extra)
5198  return true;
5199  break;
5200  case PGC_REAL:
5201  if (extra == ((struct config_real *) gconf)->reset_extra)
5202  return true;
5203  break;
5204  case PGC_STRING:
5205  if (extra == ((struct config_string *) gconf)->reset_extra)
5206  return true;
5207  break;
5208  case PGC_ENUM:
5209  if (extra == ((struct config_enum *) gconf)->reset_extra)
5210  return true;
5211  break;
5212  }
5213  for (stack = gconf->stack; stack; stack = stack->prev)
5214  {
5215  if (extra == stack->prior.extra ||
5216  extra == stack->masked.extra)
5217  return true;
5218  }
5219 
5220  return false;
5221 }

References config_var_value::extra, config_generic::extra, guc_stack::masked, PGC_BOOL, PGC_ENUM, PGC_INT, PGC_REAL, PGC_STRING, guc_stack::prev, guc_stack::prior, config_generic::stack, and config_generic::vartype.

Referenced by set_config_option(), and set_extra_field().

◆ ExtractSetVariableArgs()

char* ExtractSetVariableArgs ( VariableSetStmt stmt)

Definition at line 8876 of file guc.c.

8877 {
8878  switch (stmt->kind)
8879  {
8880  case VAR_SET_VALUE:
8881  return flatten_set_variable_args(stmt->name, stmt->args);
8882  case VAR_SET_CURRENT:
8883  return GetConfigOptionByName(stmt->name, NULL, false);
8884  default:
8885  return NULL;
8886  }
8887 }
static char * flatten_set_variable_args(const char *name, List *args)
Definition: guc.c:8283
char * GetConfigOptionByName(const char *name, const char **varname, bool missing_ok)
Definition: guc.c:9612

References VariableSetStmt::args, flatten_set_variable_args(), GetConfigOptionByName(), VariableSetStmt::kind, VariableSetStmt::name, VAR_SET_CURRENT, and VAR_SET_VALUE.

Referenced by AlterSetting(), AlterSystemSetConfigFile(), ExecSetVariableStmt(), and update_proconfig_value().

◆ find_option()

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

Definition at line 5542 of file guc.c.

5544 {
5545  const char **key = &name;
5546  struct config_generic **res;
5547  int i;
5548 
5549  Assert(name);
5550 
5551  /*
5552  * By equating const char ** with struct config_generic *, we are assuming
5553  * the name field is first in config_generic.
5554  */
5555  res = (struct config_generic **) bsearch((void *) &key,
5556  (void *) guc_variables,
5558  sizeof(struct config_generic *),
5559  guc_var_compare);
5560  if (res)
5561  return *res;
5562 
5563  /*
5564  * See if the name is an obsolete name for a variable. We assume that the
5565  * set of supported old names is short enough that a brute-force search is
5566  * the best way.
5567  */
5568  for (i = 0; map_old_guc_names[i] != NULL; i += 2)
5569  {
5571  return find_option(map_old_guc_names[i + 1], false,
5572  skip_errors, elevel);
5573  }
5574 
5575  if (create_placeholders)
5576  {
5577  /*
5578  * Check if the name is valid, and if so, add a placeholder. If it
5579  * doesn't contain a separator, don't assume that it was meant to be a
5580  * placeholder.
5581  */
5582  if (strchr(name, GUC_QUALIFIER_SEPARATOR) != NULL)
5583  {
5585  return add_placeholder_variable(name, elevel);
5586  /* A special error message seems desirable here */
5587  if (!skip_errors)
5588  ereport(elevel,
5589  (errcode(ERRCODE_INVALID_NAME),
5590  errmsg("invalid configuration parameter name \"%s\"",
5591  name),
5592  errdetail("Custom parameter names must be two or more simple identifiers separated by dots.")));
5593  return NULL;
5594  }
5595  }
5596 
5597  /* Unknown name */
5598  if (!skip_errors)
5599  ereport(elevel,
5600  (errcode(ERRCODE_UNDEFINED_OBJECT),
5601  errmsg("unrecognized configuration parameter \"%s\"",
5602  name)));
5603  return NULL;
5604 }
int errdetail(const char *fmt,...)
Definition: elog.c:1037
static const char *const map_old_guc_names[]
Definition: guc.c:5043
static bool valid_custom_variable_name(const char *name)
Definition: guc.c:5448
static int guc_name_compare(const char *namea, const char *nameb)
Definition: guc.c:5623
static struct config_generic * add_placeholder_variable(const char *name, int elevel)
Definition: guc.c:5484

References add_placeholder_variable(), Assert(), ereport, errcode(), errdetail(), errmsg(), guc_name_compare(), GUC_QUALIFIER_SEPARATOR, guc_var_compare(), guc_variables, i, sort-test::key, map_old_guc_names, name, num_guc_variables, res, and valid_custom_variable_name().

Referenced by AlterSystemSetConfigFile(), flatten_set_variable_args(), GetConfigOption(), GetConfigOptionByName(), GetConfigOptionFlags(), GetConfigOptionResetString(), GUCArrayAdd(), GUCArrayDelete(), ReportChangedGUCOptions(), set_config_option(), set_config_sourcefile(), and validate_option_array_item().

◆ flatten_set_variable_args()

static char* flatten_set_variable_args ( const char *  name,
List args 
)
static

Definition at line 8283 of file guc.c.

8284 {
8285  struct config_generic *record;
8286  int flags;
8288  ListCell *l;
8289 
8290  /* Fast path if just DEFAULT */
8291  if (args == NIL)
8292  return NULL;
8293 
8294  /*
8295  * Get flags for the variable; if it's not known, use default flags.
8296  * (Caller might throw error later, but not our business to do so here.)
8297  */
8298  record = find_option(name, false, true, WARNING);
8299  if (record)
8300  flags = record->flags;
8301  else
8302  flags = 0;
8303 
8304  /* Complain if list input and non-list variable */
8305  if ((flags & GUC_LIST_INPUT) == 0 &&
8306  list_length(args) != 1)
8307  ereport(ERROR,
8308  (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
8309  errmsg("SET %s takes only one argument", name)));
8310 
8311  initStringInfo(&buf);
8312 
8313  /*
8314  * Each list member may be a plain A_Const node, or an A_Const within a
8315  * TypeCast; the latter case is supported only for ConstInterval arguments
8316  * (for SET TIME ZONE).
8317  */
8318  foreach(l, args)
8319  {
8320  Node *arg = (Node *) lfirst(l);
8321  char *val;
8322  TypeName *typeName = NULL;
8323  A_Const *con;
8324 
8325  if (l != list_head(args))
8326  appendStringInfoString(&buf, ", ");
8327 
8328  if (IsA(arg, TypeCast))
8329  {
8330  TypeCast *tc = (TypeCast *) arg;
8331 
8332  arg = tc->arg;
8333  typeName = tc->typeName;
8334  }
8335 
8336  if (!IsA(arg, A_Const))
8337  elog(ERROR, "unrecognized node type: %d", (int) nodeTag(arg));
8338  con = (A_Const *) arg;
8339 
8340  switch (nodeTag(&con->val))
8341  {
8342  case T_Integer:
8343  appendStringInfo(&buf, "%d", intVal(&con->val));
8344  break;
8345  case T_Float:
8346  /* represented as a string, so just copy it */
8347  appendStringInfoString(&buf, castNode(Float, &con->val)->fval);
8348  break;
8349  case T_String:
8350  val = strVal(&con->val);
8351  if (typeName != NULL)
8352  {
8353  /*
8354  * Must be a ConstInterval argument for TIME ZONE. Coerce
8355  * to interval and back to normalize the value and account
8356  * for any typmod.
8357  */
8358  Oid typoid;
8359  int32 typmod;
8360  Datum interval;
8361  char *intervalout;
8362 
8363  typenameTypeIdAndMod(NULL, typeName, &typoid, &typmod);
8364  Assert(typoid == INTERVALOID);
8365 
8366  interval =
8370  Int32GetDatum(typmod));
8371 
8372  intervalout =
8374  interval));
8375  appendStringInfo(&buf, "INTERVAL '%s'", intervalout);
8376  }
8377  else
8378  {
8379  /*
8380  * Plain string literal or identifier. For quote mode,
8381  * quote it if it's not a vanilla identifier.
8382  */
8383  if (flags & GUC_LIST_QUOTE)
8385  else
8387  }
8388  break;
8389  default:
8390  elog(ERROR, "unrecognized node type: %d",
8391  (int) nodeTag(&con->val));
8392  break;
8393  }
8394  }
8395 
8396  return buf.data;
8397 }
Datum interval_out(PG_FUNCTION_ARGS)
Definition: timestamp.c:958
Datum interval_in(PG_FUNCTION_ARGS)
Definition: timestamp.c:882
signed int int32
Definition: c.h:429
#define DirectFunctionCall1(func, arg1)
Definition: fmgr.h:631
#define DirectFunctionCall3(func, arg1, arg2, arg3)
Definition: fmgr.h:635
#define GUC_LIST_QUOTE
Definition: guc.h:205
#define GUC_LIST_INPUT
Definition: guc.h:204
#define IsA(nodeptr, _type_)
Definition: nodes.h:590
#define nodeTag(nodeptr)
Definition: nodes.h:544
@ T_Float
Definition: nodes.h:294
@ T_String
Definition: nodes.h:296
@ T_Integer
Definition: nodes.h:293
#define castNode(_type_, nodeptr)
Definition: nodes.h:608
void typenameTypeIdAndMod(ParseState *pstate, const TypeName *typeName, Oid *typeid_p, int32 *typmod_p)
Definition: parse_type.c:310
void * arg
static int list_length(const List *l)
Definition: pg_list.h:149
#define NIL
Definition: pg_list.h:65
static ListCell * list_head(const List *l)
Definition: pg_list.h:125
static char * buf
Definition: pg_test_fsync.c:70
#define CStringGetDatum(X)
Definition: postgres.h:622
uintptr_t Datum
Definition: postgres.h:411
#define ObjectIdGetDatum(X)
Definition: postgres.h:551
#define Int32GetDatum(X)
Definition: postgres.h:523
#define DatumGetCString(X)
Definition: postgres.h:610
#define InvalidOid
Definition: postgres_ext.h:36
unsigned int Oid
Definition: postgres_ext.h:31
const char * quote_identifier(const char *ident)
Definition: ruleutils.c:11440
void appendStringInfo(StringInfo str, const char *fmt,...)
Definition: stringinfo.c:91
Definition: value.h:46
Definition: nodes.h:540
TypeName * typeName
Definition: parsenodes.h:321
Node * arg
Definition: parsenodes.h:320
#define intVal(v)
Definition: value.h:69

References appendStringInfo(), appendStringInfoString(), arg, TypeCast::arg, generate_unaccent_rules::args, Assert(), buf, castNode, CStringGetDatum, DatumGetCString, DirectFunctionCall1, DirectFunctionCall3, elog, ereport, errcode(), errmsg(), ERROR, find_option(), config_generic::flags, GUC_LIST_INPUT, GUC_LIST_QUOTE, initStringInfo(), Int32GetDatum, interval_in(), interval_out(), intVal, InvalidOid, IsA, lfirst, list_head(), list_length(), name, NIL, nodeTag, ObjectIdGetDatum, quote_identifier(), strVal, T_Float, T_Integer, T_String, TypeCast::typeName, typenameTypeIdAndMod(), A_Const::val, val, and WARNING.

Referenced by ExtractSetVariableArgs(), and SetPGVariable().

◆ get_config_unit_name()

static const char* get_config_unit_name ( int  flags)
static

Definition at line 6833 of file guc.c.

6834 {
6835  switch (flags & (GUC_UNIT_MEMORY | GUC_UNIT_TIME))
6836  {
6837  case 0:
6838  return NULL; /* GUC has no units */
6839  case GUC_UNIT_BYTE:
6840  return "B";
6841  case GUC_UNIT_KB:
6842  return "kB";
6843  case GUC_UNIT_MB:
6844  return "MB";
6845  case GUC_UNIT_BLOCKS:
6846  {
6847  static char bbuf[8];
6848 
6849  /* initialize if first time through */
6850  if (bbuf[0] == '\0')
6851  snprintf(bbuf, sizeof(bbuf), "%dkB", BLCKSZ / 1024);
6852  return bbuf;
6853  }
6854  case GUC_UNIT_XBLOCKS:
6855  {
6856  static char xbuf[8];
6857 
6858  /* initialize if first time through */
6859  if (xbuf[0] == '\0')
6860  snprintf(xbuf, sizeof(xbuf), "%dkB", XLOG_BLCKSZ / 1024);
6861  return xbuf;
6862  }
6863  case GUC_UNIT_MS:
6864  return "ms";
6865  case GUC_UNIT_S:
6866  return "s";
6867  case GUC_UNIT_MIN:
6868  return "min";
6869  default:
6870  elog(ERROR, "unrecognized GUC units value: %d",
6871  flags & (GUC_UNIT_MEMORY | GUC_UNIT_TIME));
6872  return NULL;
6873  }
6874 }
#define GUC_UNIT_MB
Definition: guc.h:220
#define GUC_UNIT_TIME
Definition: guc.h:227
#define GUC_UNIT_MS
Definition: guc.h:224
#define GUC_UNIT_BLOCKS
Definition: guc.h:218
#define GUC_UNIT_XBLOCKS
Definition: guc.h:219
#define GUC_UNIT_BYTE
Definition: guc.h:221
#define GUC_UNIT_S
Definition: guc.h:225
#define GUC_UNIT_KB
Definition: guc.h:217
#define GUC_UNIT_MIN
Definition: guc.h:226

References elog, ERROR, config_generic::flags, GUC_UNIT_BLOCKS, GUC_UNIT_BYTE, GUC_UNIT_KB, GUC_UNIT_MB, GUC_UNIT_MEMORY, GUC_UNIT_MIN, GUC_UNIT_MS, GUC_UNIT_S, GUC_UNIT_TIME, GUC_UNIT_XBLOCKS, and snprintf.

Referenced by GetConfigOptionByNum(), and parse_and_validate_value().

◆ get_explain_guc_options()

struct config_generic** get_explain_guc_options ( int *  num)

Definition at line 9519 of file guc.c.

9520 {
9521  struct config_generic **result;
9522 
9523  *num = 0;
9524 
9525  /*
9526  * While only a fraction of all the GUC variables are marked GUC_EXPLAIN,
9527  * it doesn't seem worth dynamically resizing this array.
9528  */
9529  result = palloc(sizeof(struct config_generic *) * num_guc_variables);
9530 
9531  for (int i = 0; i < num_guc_variables; i++)
9532  {
9533  bool modified;
9534  struct config_generic *conf = guc_variables[i];
9535 
9536  /* return only parameters marked for inclusion in explain */
9537  if (!(conf->flags & GUC_EXPLAIN))
9538  continue;
9539 
9540  /* return only options visible to the current user */
9541  if ((conf->flags & GUC_NO_SHOW_ALL) ||
9542  ((conf->flags & GUC_SUPERUSER_ONLY) &&
9543  !is_member_of_role(GetUserId(), ROLE_PG_READ_ALL_SETTINGS)))
9544  continue;
9545 
9546  /* return only options that are different from their boot values */
9547  modified = false;
9548 
9549  switch (conf->vartype)
9550  {
9551  case PGC_BOOL:
9552  {
9553  struct config_bool *lconf = (struct config_bool *) conf;
9554 
9555  modified = (lconf->boot_val != *(lconf->variable));
9556  }
9557  break;
9558 
9559  case PGC_INT:
9560  {
9561  struct config_int *lconf = (struct config_int *) conf;
9562 
9563  modified = (lconf->boot_val != *(lconf->variable));
9564  }
9565  break;
9566 
9567  case PGC_REAL:
9568  {
9569  struct config_real *lconf = (struct config_real *) conf;
9570 
9571  modified = (lconf->boot_val != *(lconf->variable));
9572  }
9573  break;
9574 
9575  case PGC_STRING:
9576  {
9577  struct config_string *lconf = (struct config_string *) conf;
9578 
9579  modified = (strcmp(lconf->boot_val, *(lconf->variable)) != 0);
9580  }
9581  break;
9582 
9583  case PGC_ENUM:
9584  {
9585  struct config_enum *lconf = (struct config_enum *) conf;
9586 
9587  modified = (lconf->boot_val != *(lconf->variable));
9588  }
9589  break;
9590 
9591  default:
9592  elog(ERROR, "unexpected GUC type: %d", conf->vartype);
9593  }
9594 
9595  if (!modified)
9596  continue;
9597 
9598  /* OK, report it */
9599  result[*num] = conf;
9600  *num = *num + 1;
9601  }
9602 
9603  return result;
9604 }
bool is_member_of_role(Oid member, Oid role)
Definition: acl.c:4869
#define GUC_EXPLAIN
Definition: guc.h:229
#define GUC_SUPERUSER_ONLY
Definition: guc.h:212
void * palloc(Size size)
Definition: mcxt.c:1062
Oid GetUserId(void)
Definition: miscinit.c:495

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

◆ get_guc_variables()

struct config_generic** get_guc_variables ( void  )

Definition at line 5307 of file guc.c.

5308 {
5309  return guc_variables;
5310 }

References guc_variables.

Referenced by GucInfoMain().

◆ GetConfigOption()

const char* GetConfigOption ( const char *  name,