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 <unistd.h>
#include <sys/stat.h>
#include "access/commit_ts.h"
#include "access/gin.h"
#include "access/rmgr.h"
#include "access/tableam.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/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/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/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/rls.h"
#include "utils/snapmgr.h"
#include "utils/tzparser.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 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 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 struct config_genericadd_placeholder_variable (const char *name, int elevel)
 
static struct config_genericfind_option (const char *name, bool create_placeholders, 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)
 
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 ()
 

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 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 shared_memory_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
 
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 wal_block_size
 
static bool data_checksums
 
static bool integer_datetimes
 
static bool assert_enabled
 
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 int GUCNestLevel = 0
 

Macro Definition Documentation

◆ CONFIG_FILENAME

#define CONFIG_FILENAME   "postgresql.conf"

Definition at line 106 of file guc.c.

Referenced by SelectConfigFiles().

◆ HBA_FILENAME

#define HBA_FILENAME   "pg_hba.conf"

Definition at line 107 of file guc.c.

Referenced by SelectConfigFiles().

◆ IDENT_FILENAME

#define IDENT_FILENAME   "pg_ident.conf"

Definition at line 108 of file guc.c.

Referenced by SelectConfigFiles().

◆ MAX_UNIT_LEN

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

Definition at line 819 of file guc.c.

Referenced by convert_to_base_unit().

◆ 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

Referenced by show_all_file_settings().

◆ NUM_PG_SETTINGS_ATTS

#define NUM_PG_SETTINGS_ATTS   17

Definition at line 9506 of file guc.c.

Referenced by show_all_settings().

◆ PG_KRB_SRVTAB

#define PG_KRB_SRVTAB   ""

Definition at line 103 of file guc.c.

◆ REALTYPE_PRECISION

#define REALTYPE_PRECISION   17

Definition at line 119 of file guc.c.

Referenced by estimate_variable_size(), and serialize_variable().

Function Documentation

◆ _ShowOption()

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

Definition at line 9752 of file guc.c.

References AllocateFile(), Assert, config_enum_lookup_by_value(), convert_int_from_base_unit(), convert_real_from_base_unit(), elevel, elog, ereport, errcode_for_file_access(), errmsg(), ERROR, FATAL, find_option(), config_generic::flags, fprintf, free, FreeFile(), GUC_ACTION_SET, guc_malloc(), guc_realloc(), GUC_UNIT, i, INT64_FORMAT, IsInitProcessingMode, LOG, config_generic::name, num_guc_variables, PGC_BOOL, PGC_ENUM, PGC_INT, PGC_POSTMASTER, PGC_REAL, PGC_S_DEFAULT, PGC_SIGHUP, PGC_STRING, pstrdup(), config_generic::scontext, set_config_option(), set_config_sourcefile(), config_bool::show_hook, config_int::show_hook, config_real::show_hook, config_string::show_hook, config_enum::show_hook, snprintf, config_generic::source, config_generic::sourcefile, config_generic::sourceline, generate_unaccent_rules::str, 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().

9753 {
9754  char buffer[256];
9755  const char *val;
9756 
9757  switch (record->vartype)
9758  {
9759  case PGC_BOOL:
9760  {
9761  struct config_bool *conf = (struct config_bool *) record;
9762 
9763  if (conf->show_hook)
9764  val = conf->show_hook();
9765  else
9766  val = *conf->variable ? "on" : "off";
9767  }
9768  break;
9769 
9770  case PGC_INT:
9771  {
9772  struct config_int *conf = (struct config_int *) record;
9773 
9774  if (conf->show_hook)
9775  val = conf->show_hook();
9776  else
9777  {
9778  /*
9779  * Use int64 arithmetic to avoid overflows in units
9780  * conversion.
9781  */
9782  int64 result = *conf->variable;
9783  const char *unit;
9784 
9785  if (use_units && result > 0 && (record->flags & GUC_UNIT))
9787  record->flags & GUC_UNIT,
9788  &result, &unit);
9789  else
9790  unit = "";
9791 
9792  snprintf(buffer, sizeof(buffer), INT64_FORMAT "%s",
9793  result, unit);
9794  val = buffer;
9795  }
9796  }
9797  break;
9798 
9799  case PGC_REAL:
9800  {
9801  struct config_real *conf = (struct config_real *) record;
9802 
9803  if (conf->show_hook)
9804  val = conf->show_hook();
9805  else
9806  {
9807  double result = *conf->variable;
9808  const char *unit;
9809 
9810  if (use_units && result > 0 && (record->flags & GUC_UNIT))
9812  record->flags & GUC_UNIT,
9813  &result, &unit);
9814  else
9815  unit = "";
9816 
9817  snprintf(buffer, sizeof(buffer), "%g%s",
9818  result, unit);
9819  val = buffer;
9820  }
9821  }
9822  break;
9823 
9824  case PGC_STRING:
9825  {
9826  struct config_string *conf = (struct config_string *) record;
9827 
9828  if (conf->show_hook)
9829  val = conf->show_hook();
9830  else if (*conf->variable && **conf->variable)
9831  val = *conf->variable;
9832  else
9833  val = "";
9834  }
9835  break;
9836 
9837  case PGC_ENUM:
9838  {
9839  struct config_enum *conf = (struct config_enum *) record;
9840 
9841  if (conf->show_hook)
9842  val = conf->show_hook();
9843  else
9844  val = config_enum_lookup_by_value(conf, *conf->variable);
9845  }
9846  break;
9847 
9848  default:
9849  /* just to keep compiler quiet */
9850  val = "???";
9851  break;
9852  }
9853 
9854  return pstrdup(val);
9855 }
char ** variable
Definition: guc_tables.h:230
char * pstrdup(const char *in)
Definition: mcxt.c:1186
bool * variable
Definition: guc_tables.h:184
const char * config_enum_lookup_by_value(struct config_enum *record, int val)
Definition: guc.c:6637
#define GUC_UNIT
Definition: guc.h:232
GucShowHook show_hook
Definition: guc_tables.h:204
int * variable
Definition: guc_tables.h:198
int * variable
Definition: guc_tables.h:244
static void convert_real_from_base_unit(double base_value, int base_unit, double *value, const char **unit)
Definition: guc.c:6385
GucShowHook show_hook
Definition: guc_tables.h:234
GucShowHook show_hook
Definition: guc_tables.h:220
double * variable
Definition: guc_tables.h:214
enum config_type vartype
Definition: guc_tables.h:156
GucShowHook show_hook
Definition: guc_tables.h:249
GucShowHook show_hook
Definition: guc_tables.h:188
#define INT64_FORMAT
Definition: c.h:409
static void convert_int_from_base_unit(int64 base_value, int base_unit, int64 *value, const char **unit)
Definition: guc.c:6343
#define snprintf
Definition: port.h:193
long val
Definition: informix.c:664

◆ add_guc_variable()

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

Definition at line 5155 of file guc.c.

References guc_malloc(), guc_realloc(), guc_var_compare(), and qsort.

Referenced by add_placeholder_variable(), and define_custom_variable().

5156 {
5158  {
5159  /*
5160  * Increase the vector by 25%
5161  */
5162  int size_vars = size_guc_variables + size_guc_variables / 4;
5163  struct config_generic **guc_vars;
5164 
5165  if (size_vars == 0)
5166  {
5167  size_vars = 100;
5168  guc_vars = (struct config_generic **)
5169  guc_malloc(elevel, size_vars * sizeof(struct config_generic *));
5170  }
5171  else
5172  {
5173  guc_vars = (struct config_generic **)
5174  guc_realloc(elevel, guc_variables, size_vars * sizeof(struct config_generic *));
5175  }
5176 
5177  if (guc_vars == NULL)
5178  return false; /* out of memory */
5179 
5180  guc_variables = guc_vars;
5181  size_guc_variables = size_vars;
5182  }
5185  sizeof(struct config_generic *), guc_var_compare);
5186  return true;
5187 }
static int guc_var_compare(const void *a, const void *b)
Definition: guc.c:5290
static int num_guc_variables
Definition: guc.c:4807
static void * guc_realloc(int elevel, void *old, size_t size)
Definition: guc.c:4861
static struct config_generic ** guc_variables
Definition: guc.c:4804
static int size_guc_variables
Definition: guc.c:4810
static int elevel
Definition: vacuumlazy.c:323
#define qsort(a, b, c, d)
Definition: port.h:479
static void * guc_malloc(int elevel, size_t size)
Definition: guc.c:4845

◆ add_placeholder_variable()

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

Definition at line 5193 of file guc.c.

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(), config_generic::name, PGC_STRING, PGC_USERSET, config_generic::short_desc, unconstify, config_string::variable, and config_generic::vartype.

Referenced by find_option().

5194 {
5195  size_t sz = sizeof(struct config_string) + sizeof(char *);
5196  struct config_string *var;
5197  struct config_generic *gen;
5198 
5199  var = (struct config_string *) guc_malloc(elevel, sz);
5200  if (var == NULL)
5201  return NULL;
5202  memset(var, 0, sz);
5203  gen = &var->gen;
5204 
5205  gen->name = guc_strdup(elevel, name);
5206  if (gen->name == NULL)
5207  {
5208  free(var);
5209  return NULL;
5210  }
5211 
5212  gen->context = PGC_USERSET;
5213  gen->group = CUSTOM_OPTIONS;
5214  gen->short_desc = "GUC placeholder variable";
5216  gen->vartype = PGC_STRING;
5217 
5218  /*
5219  * The char* is allocated at the end of the struct since we have no
5220  * 'static' place to point to. Note that the current value, as well as
5221  * the boot and reset values, start out NULL.
5222  */
5223  var->variable = (char **) (var + 1);
5224 
5225  if (!add_guc_variable((struct config_generic *) var, elevel))
5226  {
5227  free(unconstify(char *, gen->name));
5228  free(var);
5229  return NULL;
5230  }
5231 
5232  return gen;
5233 }
char ** variable
Definition: guc_tables.h:230
const char * name
Definition: guc_tables.h:149
const char * short_desc
Definition: guc_tables.h:152
static char * guc_strdup(int elevel, const char *src)
Definition: guc.c:4877
#define GUC_NO_SHOW_ALL
Definition: guc.h:206
#define GUC_NOT_IN_SAMPLE
Definition: guc.h:209
enum config_type vartype
Definition: guc_tables.h:156
#define unconstify(underlying_type, expr)
Definition: c.h:1206
static int elevel
Definition: vacuumlazy.c:323
struct config_generic gen
Definition: guc_tables.h:228
#define free(a)
Definition: header.h:65
#define GUC_CUSTOM_PLACEHOLDER
Definition: guc.h:211
const char * name
Definition: encode.c:555
enum config_group group
Definition: guc_tables.h:151
static void * guc_malloc(int elevel, size_t size)
Definition: guc.c:4845
GucContext context
Definition: guc_tables.h:150
static bool add_guc_variable(struct config_generic *var, int elevel)
Definition: guc.c:5155

◆ AlterSystemSetConfigFile()

void AlterSystemSetConfigFile ( AlterSystemStmt altersysstmt)

Definition at line 8125 of file guc.c.

References AllocateFile(), 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, 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, config_var_val::stringval, 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().

8126 {
8127  char *name;
8128  char *value;
8129  bool resetall = false;
8130  ConfigVariable *head = NULL;
8131  ConfigVariable *tail = NULL;
8132  volatile int Tmpfd;
8133  char AutoConfFileName[MAXPGPATH];
8134  char AutoConfTmpFileName[MAXPGPATH];
8135 
8136  if (!superuser())
8137  ereport(ERROR,
8138  (errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
8139  errmsg("must be superuser to execute ALTER SYSTEM command")));
8140 
8141  /*
8142  * Extract statement arguments
8143  */
8144  name = altersysstmt->setstmt->name;
8145 
8146  switch (altersysstmt->setstmt->kind)
8147  {
8148  case VAR_SET_VALUE:
8149  value = ExtractSetVariableArgs(altersysstmt->setstmt);
8150  break;
8151 
8152  case VAR_SET_DEFAULT:
8153  case VAR_RESET:
8154  value = NULL;
8155  break;
8156 
8157  case VAR_RESET_ALL:
8158  value = NULL;
8159  resetall = true;
8160  break;
8161 
8162  default:
8163  elog(ERROR, "unrecognized alter system stmt type: %d",
8164  altersysstmt->setstmt->kind);
8165  break;
8166  }
8167 
8168  /*
8169  * Unless it's RESET_ALL, validate the target variable and value
8170  */
8171  if (!resetall)
8172  {
8173  struct config_generic *record;
8174 
8175  record = find_option(name, false, ERROR);
8176  if (record == NULL)
8177  ereport(ERROR,
8178  (errcode(ERRCODE_UNDEFINED_OBJECT),
8179  errmsg("unrecognized configuration parameter \"%s\"",
8180  name)));
8181 
8182  /*
8183  * Don't allow parameters that can't be set in configuration files to
8184  * be set in PG_AUTOCONF_FILENAME file.
8185  */
8186  if ((record->context == PGC_INTERNAL) ||
8187  (record->flags & GUC_DISALLOW_IN_FILE) ||
8188  (record->flags & GUC_DISALLOW_IN_AUTO_FILE))
8189  ereport(ERROR,
8190  (errcode(ERRCODE_CANT_CHANGE_RUNTIME_PARAM),
8191  errmsg("parameter \"%s\" cannot be changed",
8192  name)));
8193 
8194  /*
8195  * If a value is specified, verify that it's sane.
8196  */
8197  if (value)
8198  {
8199  union config_var_val newval;
8200  void *newextra = NULL;
8201 
8202  /* Check that it's acceptable for the indicated parameter */
8203  if (!parse_and_validate_value(record, name, value,
8204  PGC_S_FILE, ERROR,
8205  &newval, &newextra))
8206  ereport(ERROR,
8207  (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
8208  errmsg("invalid value for parameter \"%s\": \"%s\"",
8209  name, value)));
8210 
8211  if (record->vartype == PGC_STRING && newval.stringval != NULL)
8212  free(newval.stringval);
8213  if (newextra)
8214  free(newextra);
8215 
8216  /*
8217  * We must also reject values containing newlines, because the
8218  * grammar for config files doesn't support embedded newlines in
8219  * string literals.
8220  */
8221  if (strchr(value, '\n'))
8222  ereport(ERROR,
8223  (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
8224  errmsg("parameter value for ALTER SYSTEM must not contain a newline")));
8225  }
8226  }
8227 
8228  /*
8229  * PG_AUTOCONF_FILENAME and its corresponding temporary file are always in
8230  * the data directory, so we can reference them by simple relative paths.
8231  */
8232  snprintf(AutoConfFileName, sizeof(AutoConfFileName), "%s",
8234  snprintf(AutoConfTmpFileName, sizeof(AutoConfTmpFileName), "%s.%s",
8235  AutoConfFileName,
8236  "tmp");
8237 
8238  /*
8239  * Only one backend is allowed to operate on PG_AUTOCONF_FILENAME at a
8240  * time. Use AutoFileLock to ensure that. We must hold the lock while
8241  * reading the old file contents.
8242  */
8243  LWLockAcquire(AutoFileLock, LW_EXCLUSIVE);
8244 
8245  /*
8246  * If we're going to reset everything, then no need to open or parse the
8247  * old file. We'll just write out an empty list.
8248  */
8249  if (!resetall)
8250  {
8251  struct stat st;
8252 
8253  if (stat(AutoConfFileName, &st) == 0)
8254  {
8255  /* open old file PG_AUTOCONF_FILENAME */
8256  FILE *infile;
8257 
8258  infile = AllocateFile(AutoConfFileName, "r");
8259  if (infile == NULL)
8260  ereport(ERROR,
8262  errmsg("could not open file \"%s\": %m",
8263  AutoConfFileName)));
8264 
8265  /* parse it */
8266  if (!ParseConfigFp(infile, AutoConfFileName, 0, LOG, &head, &tail))
8267  ereport(ERROR,
8268  (errcode(ERRCODE_CONFIG_FILE_ERROR),
8269  errmsg("could not parse contents of file \"%s\"",
8270  AutoConfFileName)));
8271 
8272  FreeFile(infile);
8273  }
8274 
8275  /*
8276  * Now, replace any existing entry with the new value, or add it if
8277  * not present.
8278  */
8279  replace_auto_config_value(&head, &tail, name, value);
8280  }
8281 
8282  /*
8283  * To ensure crash safety, first write the new file data to a temp file,
8284  * then atomically rename it into place.
8285  *
8286  * If there is a temp file left over due to a previous crash, it's okay to
8287  * truncate and reuse it.
8288  */
8289  Tmpfd = BasicOpenFile(AutoConfTmpFileName,
8290  O_CREAT | O_RDWR | O_TRUNC);
8291  if (Tmpfd < 0)
8292  ereport(ERROR,
8294  errmsg("could not open file \"%s\": %m",
8295  AutoConfTmpFileName)));
8296 
8297  /*
8298  * Use a TRY block to clean up the file if we fail. Since we need a TRY
8299  * block anyway, OK to use BasicOpenFile rather than OpenTransientFile.
8300  */
8301  PG_TRY();
8302  {
8303  /* Write and sync the new contents to the temporary file */
8304  write_auto_conf_file(Tmpfd, AutoConfTmpFileName, head);
8305 
8306  /* Close before renaming; may be required on some platforms */
8307  close(Tmpfd);
8308  Tmpfd = -1;
8309 
8310  /*
8311  * As the rename is atomic operation, if any problem occurs after this
8312  * at worst it can lose the parameters set by last ALTER SYSTEM
8313  * command.
8314  */
8315  durable_rename(AutoConfTmpFileName, AutoConfFileName, ERROR);
8316  }
8317  PG_CATCH();
8318  {
8319  /* Close file first, else unlink might fail on some platforms */
8320  if (Tmpfd >= 0)
8321  close(Tmpfd);
8322 
8323  /* Unlink, but ignore any error */
8324  (void) unlink(AutoConfTmpFileName);
8325 
8326  PG_RE_THROW();
8327  }
8328  PG_END_TRY();
8329 
8330  FreeConfigVariables(head);
8331 
8332  LWLockRelease(AutoFileLock);
8333 }
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:6744
VariableSetKind kind
Definition: parsenodes.h:2042
int errcode(int sqlerrcode)
Definition: elog.c:610
bool superuser(void)
Definition: superuser.c:46
#define LOG
Definition: elog.h:26
void LWLockRelease(LWLock *lock)
Definition: lwlock.c:1812
#define ERROR
Definition: elog.h:43
#define MAXPGPATH
VariableSetStmt * setstmt
Definition: parsenodes.h:3194
int errcode_for_file_access(void)
Definition: elog.c:633
FILE * AllocateFile(const char *name, const char *mode)
Definition: fd.c:2320
int durable_rename(const char *oldfile, const char *newfile, int elevel)
Definition: fd.c:656
enum config_type vartype
Definition: guc_tables.h:156
#define stat(a, b)
Definition: win32_port.h:255
#define GUC_DISALLOW_IN_FILE
Definition: guc.h:210
static void write_auto_conf_file(int fd, const char *filename, ConfigVariable *head_p)
Definition: guc.c:7987
static struct @143 value
#define ereport(elevel,...)
Definition: elog.h:144
static void infile(const char *filename)
Definition: zic.c:1233
#define free(a)
Definition: header.h:65
static struct config_generic * find_option(const char *name, bool create_placeholders, int elevel)
Definition: guc.c:5241
#define PG_CATCH()
Definition: elog.h:305
#define newval
#define PG_AUTOCONF_FILENAME
Definition: guc.h:34
bool LWLockAcquire(LWLock *lock, LWLockMode mode)
Definition: lwlock.c:1208
#define PG_RE_THROW()
Definition: elog.h:336
const char * name
Definition: encode.c:555
#define GUC_DISALLOW_IN_AUTO_FILE
Definition: guc.h:215
int BasicOpenFile(const char *fileName, int fileFlags)
Definition: fd.c:983
int FreeFile(FILE *file)
Definition: fd.c:2519
int errmsg(const char *fmt,...)
Definition: elog.c:824
bool ParseConfigFp(FILE *fp, const char *config_file, int depth, int elevel, ConfigVariable **head_p, ConfigVariable **tail_p)
#define elog(elevel,...)
Definition: elog.h:214
static void replace_auto_config_value(ConfigVariable **head_p, ConfigVariable **tail_p, const char *name, const char *value)
Definition: guc.c:8055
void FreeConfigVariables(ConfigVariable *list)
#define close(a)
Definition: win32.h:12
#define PG_TRY()
Definition: elog.h:295
char * ExtractSetVariableArgs(VariableSetStmt *stmt)
Definition: guc.c:8463
#define snprintf
Definition: port.h:193
#define PG_END_TRY()
Definition: elog.h:320
GucContext context
Definition: guc_tables.h:150

◆ assign_application_name()

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

Definition at line 11628 of file guc.c.

References pgstat_report_appname().

11629 {
11630  /* Update the pg_stat_activity view */
11632 }
void pgstat_report_appname(const char *appname)
Definition: pgstat.c:3309
#define newval

◆ assign_backtrace_functions()

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

Definition at line 11735 of file guc.c.

11736 {
11737  backtrace_symbol_list = (char *) extra;
11738 }
char * backtrace_symbol_list
Definition: guc.c:554

◆ assign_log_destination()

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

Definition at line 11246 of file guc.c.

References Log_destination.

11247 {
11248  Log_destination = *((int *) extra);
11249 }
int Log_destination
Definition: elog.c:110

◆ assign_pgstat_temp_directory()

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

Definition at line 11590 of file guc.c.

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

11591 {
11592  /* check_canonical_path already canonicalized newval for us */
11593  char *dname;
11594  char *tname;
11595  char *fname;
11596 
11597  /* directory */
11598  dname = guc_malloc(ERROR, strlen(newval) + 1); /* runtime dir */
11599  sprintf(dname, "%s", newval);
11600 
11601  /* global stats */
11602  tname = guc_malloc(ERROR, strlen(newval) + 12); /* /global.tmp */
11603  sprintf(tname, "%s/global.tmp", newval);
11604  fname = guc_malloc(ERROR, strlen(newval) + 13); /* /global.stat */
11605  sprintf(fname, "%s/global.stat", newval);
11606 
11609  pgstat_stat_directory = dname;
11610  if (pgstat_stat_tmpname)
11612  pgstat_stat_tmpname = tname;
11615  pgstat_stat_filename = fname;
11616 }
#define sprintf
Definition: port.h:195
char * pgstat_stat_filename
Definition: pgstat.c:134
#define ERROR
Definition: elog.h:43
char * pgstat_stat_directory
Definition: pgstat.c:133
#define free(a)
Definition: header.h:65
#define newval
char * pgstat_stat_tmpname
Definition: pgstat.c:135
static void * guc_malloc(int elevel, size_t size)
Definition: guc.c:4845

◆ assign_recovery_target()

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

Definition at line 11814 of file guc.c.

References RECOVERY_TARGET_IMMEDIATE, RECOVERY_TARGET_UNSET, and recoveryTarget.

11815 {
11818  error_multiple_recovery_targets();
11819 
11820  if (newval && strcmp(newval, "") != 0)
11822  else
11824 }
#define newval
RecoveryTargetType recoveryTarget
Definition: xlog.c:282

◆ assign_recovery_target_lsn()

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

Definition at line 11982 of file guc.c.

References RECOVERY_TARGET_LSN, RECOVERY_TARGET_UNSET, recoveryTarget, and recoveryTargetLSN.

11983 {
11986  error_multiple_recovery_targets();
11987 
11988  if (newval && strcmp(newval, "") != 0)
11989  {
11991  recoveryTargetLSN = *((XLogRecPtr *) extra);
11992  }
11993  else
11995 }
XLogRecPtr recoveryTargetLSN
Definition: xlog.c:289
uint64 XLogRecPtr
Definition: xlogdefs.h:21
#define newval
RecoveryTargetType recoveryTarget
Definition: xlog.c:282

◆ assign_recovery_target_name()

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

Definition at line 11946 of file guc.c.

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

11947 {
11950  error_multiple_recovery_targets();
11951 
11952  if (newval && strcmp(newval, "") != 0)
11953  {
11956  }
11957  else
11959 }
const char * recoveryTargetName
Definition: xlog.c:288
#define newval
RecoveryTargetType recoveryTarget
Definition: xlog.c:282

◆ assign_recovery_target_time()

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

Definition at line 11920 of file guc.c.

References RECOVERY_TARGET_TIME, RECOVERY_TARGET_UNSET, and recoveryTarget.

11921 {
11924  error_multiple_recovery_targets();
11925 
11926  if (newval && strcmp(newval, "") != 0)
11928  else
11930 }
#define newval
RecoveryTargetType recoveryTarget
Definition: xlog.c:282

◆ assign_recovery_target_timeline()

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

Definition at line 11771 of file guc.c.

References RECOVERY_TARGET_TIMELINE_NUMERIC, recoveryTargetTimeLineGoal, and recoveryTargetTLIRequested.

11772 {
11775  recoveryTargetTLIRequested = (TimeLineID) strtoul(newval, NULL, 0);
11776  else
11778 }
TimeLineID recoveryTargetTLIRequested
Definition: xlog.c:342
uint32 TimeLineID
Definition: xlogdefs.h:52
RecoveryTargetTimeLineGoal
Definition: xlog.h:93
RecoveryTargetTimeLineGoal recoveryTargetTimeLineGoal
Definition: xlog.c:341
#define newval

◆ assign_recovery_target_xid()

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

Definition at line 11847 of file guc.c.

References RECOVERY_TARGET_UNSET, RECOVERY_TARGET_XID, recoveryTarget, and recoveryTargetXid.

11848 {
11851  error_multiple_recovery_targets();
11852 
11853  if (newval && strcmp(newval, "") != 0)
11854  {
11856  recoveryTargetXid = *((TransactionId *) extra);
11857  }
11858  else
11860 }
uint32 TransactionId
Definition: c.h:513
TransactionId recoveryTargetXid
Definition: xlog.c:285
#define newval
RecoveryTargetType recoveryTarget
Definition: xlog.c:282

◆ assign_session_replication_role()

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

Definition at line 11272 of file guc.c.

References ResetPlanCache(), and SessionReplicationRole.

11273 {
11274  /*
11275  * Must flush the plan cache when changing replication role; but don't
11276  * flush unnecessarily.
11277  */
11279  ResetPlanCache();
11280 }
int SessionReplicationRole
Definition: trigger.c:67
void ResetPlanCache(void)
Definition: plancache.c:2144
#define newval

◆ assign_syslog_facility()

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

Definition at line 11252 of file guc.c.

11253 {
11254 #ifdef HAVE_SYSLOG
11255  set_syslog_parameters(syslog_ident_str ? syslog_ident_str : "postgres",
11256  newval);
11257 #endif
11258  /* Without syslog support, just ignore it */
11259 }
static char * syslog_ident_str
Definition: guc.c:594
#define newval

◆ assign_syslog_ident()

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

Definition at line 11262 of file guc.c.

11263 {
11264 #ifdef HAVE_SYSLOG
11265  set_syslog_parameters(newval, syslog_facility);
11266 #endif
11267  /* Without syslog support, it will always be set to "none", so ignore */
11268 }
static int syslog_facility
Definition: guc.c:170
#define newval

◆ assign_tcp_keepalives_count()

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

Definition at line 11471 of file guc.c.

References MyProcPort, and pq_setkeepalivescount().

11472 {
11473  /* See comments in assign_tcp_keepalives_idle */
11475 }
struct Port * MyProcPort
Definition: globals.c:43
int pq_setkeepalivescount(int count, Port *port)
Definition: pqcomm.c:1875
#define newval

◆ assign_tcp_keepalives_idle()

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

Definition at line 11427 of file guc.c.

References MyProcPort, and pq_setkeepalivesidle().

11428 {
11429  /*
11430  * The kernel API provides no way to test a value without setting it; and
11431  * once we set it we might fail to unset it. So there seems little point
11432  * in fully implementing the check-then-assign GUC API for these
11433  * variables. Instead we just do the assignment on demand. pqcomm.c
11434  * reports any problems via elog(LOG).
11435  *
11436  * This approach means that the GUC value might have little to do with the
11437  * actual kernel value, so we use a show_hook that retrieves the kernel
11438  * value rather than trusting GUC's copy.
11439  */
11441 }
struct Port * MyProcPort
Definition: globals.c:43
int pq_setkeepalivesidle(int idle, Port *port)
Definition: pqcomm.c:1717
#define newval

◆ assign_tcp_keepalives_interval()

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

Definition at line 11454 of file guc.c.

References MyProcPort, and pq_setkeepalivesinterval().

11455 {
11456  /* See comments in assign_tcp_keepalives_idle */
11458 }
struct Port * MyProcPort
Definition: globals.c:43
int pq_setkeepalivesinterval(int interval, Port *port)
Definition: pqcomm.c:1799
#define newval

◆ assign_tcp_user_timeout()

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

Definition at line 11488 of file guc.c.

References MyProcPort, and pq_settcpusertimeout().

11489 {
11490  /* See comments in assign_tcp_keepalives_idle */
11492 }
struct Port * MyProcPort
Definition: globals.c:43
#define newval
int pq_settcpusertimeout(int timeout, Port *port)
Definition: pqcomm.c:1947

◆ assign_timezone_abbreviations()

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

Definition at line 11391 of file guc.c.

References InstallTimeZoneAbbrevs().

11392 {
11393  /* Do nothing for the boot_val default of NULL */
11394  if (!extra)
11395  return;
11396 
11398 }
void InstallTimeZoneAbbrevs(TimeZoneAbbrevTable *tbl)
Definition: datetime.c:4568

◆ assign_wal_consistency_checking()

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

Definition at line 11183 of file guc.c.

References wal_consistency_checking.

11184 {
11185  wal_consistency_checking = (bool *) extra;
11186 }
bool * wal_consistency_checking
Definition: xlog.c:101

◆ AtEOXact_GUC()

void AtEOXact_GUC ( bool  isCommit,
int  nestLevel 
)

Definition at line 5948 of file guc.c.

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_LOCAL, GUC_REPORT, GUC_SAVE, GUC_SET, GUC_SET_LOCAL, 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, ReportGUCOption(), 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_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().

5949 {
5950  bool still_dirty;
5951  int i;
5952 
5953  /*
5954  * Note: it's possible to get here with GUCNestLevel == nestLevel-1 during
5955  * abort, if there is a failure during transaction start before
5956  * AtStart_GUC is called.
5957  */
5958  Assert(nestLevel > 0 &&
5959  (nestLevel <= GUCNestLevel ||
5960  (nestLevel == GUCNestLevel + 1 && !isCommit)));
5961 
5962  /* Quick exit if nothing's changed in this transaction */
5963  if (!guc_dirty)
5964  {
5965  GUCNestLevel = nestLevel - 1;
5966  return;
5967  }
5968 
5969  still_dirty = false;
5970  for (i = 0; i < num_guc_variables; i++)
5971  {
5972  struct config_generic *gconf = guc_variables[i];
5973  GucStack *stack;
5974 
5975  /*
5976  * Process and pop each stack entry within the nest level. To simplify
5977  * fmgr_security_definer() and other places that use GUC_ACTION_SAVE,
5978  * we allow failure exit from code that uses a local nest level to be
5979  * recovered at the surrounding transaction or subtransaction abort;
5980  * so there could be more than one stack entry to pop.
5981  */
5982  while ((stack = gconf->stack) != NULL &&
5983  stack->nest_level >= nestLevel)
5984  {
5985  GucStack *prev = stack->prev;
5986  bool restorePrior = false;
5987  bool restoreMasked = false;
5988  bool changed;
5989 
5990  /*
5991  * In this next bit, if we don't set either restorePrior or
5992  * restoreMasked, we must "discard" any unwanted fields of the
5993  * stack entries to avoid leaking memory. If we do set one of
5994  * those flags, unused fields will be cleaned up after restoring.
5995  */
5996  if (!isCommit) /* if abort, always restore prior value */
5997  restorePrior = true;
5998  else if (stack->state == GUC_SAVE)
5999  restorePrior = true;
6000  else if (stack->nest_level == 1)
6001  {
6002  /* transaction commit */
6003  if (stack->state == GUC_SET_LOCAL)
6004  restoreMasked = true;
6005  else if (stack->state == GUC_SET)
6006  {
6007  /* we keep the current active value */
6008  discard_stack_value(gconf, &stack->prior);
6009  }
6010  else /* must be GUC_LOCAL */
6011  restorePrior = true;
6012  }
6013  else if (prev == NULL ||
6014  prev->nest_level < stack->nest_level - 1)
6015  {
6016  /* decrement entry's level and do not pop it */
6017  stack->nest_level--;
6018  continue;
6019  }
6020  else
6021  {
6022  /*
6023  * We have to merge this stack entry into prev. See README for
6024  * discussion of this bit.
6025  */
6026  switch (stack->state)
6027  {
6028  case GUC_SAVE:
6029  Assert(false); /* can't get here */
6030  break;
6031 
6032  case GUC_SET:
6033  /* next level always becomes SET */
6034  discard_stack_value(gconf, &stack->prior);
6035  if (prev->state == GUC_SET_LOCAL)
6036  discard_stack_value(gconf, &prev->masked);
6037  prev->state = GUC_SET;
6038  break;
6039 
6040  case GUC_LOCAL:
6041  if (prev->state == GUC_SET)
6042  {
6043  /* LOCAL migrates down */
6044  prev->masked_scontext = stack->scontext;
6045  prev->masked = stack->prior;
6046  prev->state = GUC_SET_LOCAL;
6047  }
6048  else
6049  {
6050  /* else just forget this stack level */
6051  discard_stack_value(gconf, &stack->prior);
6052  }
6053  break;
6054 
6055  case GUC_SET_LOCAL:
6056  /* prior state at this level no longer wanted */
6057  discard_stack_value(gconf, &stack->prior);
6058  /* copy down the masked state */
6059  prev->masked_scontext = stack->masked_scontext;
6060  if (prev->state == GUC_SET_LOCAL)
6061  discard_stack_value(gconf, &prev->masked);
6062  prev->masked = stack->masked;
6063  prev->state = GUC_SET_LOCAL;
6064  break;
6065  }
6066  }
6067 
6068  changed = false;
6069 
6070  if (restorePrior || restoreMasked)
6071  {
6072  /* Perform appropriate restoration of the stacked value */
6073  config_var_value newvalue;
6074  GucSource newsource;
6075  GucContext newscontext;
6076 
6077  if (restoreMasked)
6078  {
6079  newvalue = stack->masked;
6080  newsource = PGC_S_SESSION;
6081  newscontext = stack->masked_scontext;
6082  }
6083  else
6084  {
6085  newvalue = stack->prior;
6086  newsource = stack->source;
6087  newscontext = stack->scontext;
6088  }
6089 
6090  switch (gconf->vartype)
6091  {
6092  case PGC_BOOL:
6093  {
6094  struct config_bool *conf = (struct config_bool *) gconf;
6095  bool newval = newvalue.val.boolval;
6096  void *newextra = newvalue.extra;
6097 
6098  if (*conf->variable != newval ||
6099  conf->gen.extra != newextra)
6100  {
6101  if (conf->assign_hook)
6102  conf->assign_hook(newval, newextra);
6103  *conf->variable = newval;
6104  set_extra_field(&conf->gen, &conf->gen.extra,
6105  newextra);
6106  changed = true;
6107  }
6108  break;
6109  }
6110  case PGC_INT:
6111  {
6112  struct config_int *conf = (struct config_int *) gconf;
6113  int newval = newvalue.val.intval;
6114  void *newextra = newvalue.extra;
6115 
6116  if (*conf->variable != newval ||
6117  conf->gen.extra != newextra)
6118  {
6119  if (conf->assign_hook)
6120  conf->assign_hook(newval, newextra);
6121  *conf->variable = newval;
6122  set_extra_field(&conf->gen, &conf->gen.extra,
6123  newextra);
6124  changed = true;
6125  }
6126  break;
6127  }
6128  case PGC_REAL:
6129  {
6130  struct config_real *conf = (struct config_real *) gconf;
6131  double newval = newvalue.val.realval;
6132  void *newextra = newvalue.extra;
6133 
6134  if (*conf->variable != newval ||
6135  conf->gen.extra != newextra)
6136  {
6137  if (conf->assign_hook)
6138  conf->assign_hook(newval, newextra);
6139  *conf->variable = newval;
6140  set_extra_field(&conf->gen, &conf->gen.extra,
6141  newextra);
6142  changed = true;
6143  }
6144  break;
6145  }
6146  case PGC_STRING:
6147  {
6148  struct config_string *conf = (struct config_string *) gconf;
6149  char *newval = newvalue.val.stringval;
6150  void *newextra = newvalue.extra;
6151 
6152  if (*conf->variable != newval ||
6153  conf->gen.extra != newextra)
6154  {
6155  if (conf->assign_hook)
6156  conf->assign_hook(newval, newextra);
6157  set_string_field(conf, conf->variable, newval);
6158  set_extra_field(&conf->gen, &conf->gen.extra,
6159  newextra);
6160  changed = true;
6161  }
6162 
6163  /*
6164  * Release stacked values if not used anymore. We
6165  * could use discard_stack_value() here, but since
6166  * we have type-specific code anyway, might as
6167  * well inline it.
6168  */
6169  set_string_field(conf, &stack->prior.val.stringval, NULL);
6170  set_string_field(conf, &stack->masked.val.stringval, NULL);
6171  break;
6172  }
6173  case PGC_ENUM:
6174  {
6175  struct config_enum *conf = (struct config_enum *) gconf;
6176  int newval = newvalue.val.enumval;
6177  void *newextra = newvalue.extra;
6178 
6179  if (*conf->variable != newval ||
6180  conf->gen.extra != newextra)
6181  {
6182  if (conf->assign_hook)
6183  conf->assign_hook(newval, newextra);
6184  *conf->variable = newval;
6185  set_extra_field(&conf->gen, &conf->gen.extra,
6186  newextra);
6187  changed = true;
6188  }
6189  break;
6190  }
6191  }
6192 
6193  /*
6194  * Release stacked extra values if not used anymore.
6195  */
6196  set_extra_field(gconf, &(stack->prior.extra), NULL);
6197  set_extra_field(gconf, &(stack->masked.extra), NULL);
6198 
6199  /* And restore source information */
6200  gconf->source = newsource;
6201  gconf->scontext = newscontext;
6202  }
6203 
6204  /* Finish popping the state stack */
6205  gconf->stack = prev;
6206  pfree(stack);
6207 
6208  /* Report new value if we changed it */
6209  if (changed && (gconf->flags & GUC_REPORT))
6210  ReportGUCOption(gconf);
6211  } /* end of stack-popping loop */
6212 
6213  if (stack != NULL)
6214  still_dirty = true;
6215  }
6216 
6217  /* If there are no remaining stack entries, we can reset guc_dirty */
6218  guc_dirty = still_dirty;
6219 
6220  /* Update nesting level */
6221  GUCNestLevel = nestLevel - 1;
6222 }
struct guc_stack * prev
Definition: guc_tables.h:123
GucSource source
Definition: guc_tables.h:158
GucContext
Definition: guc.h:68
union config_var_val val
Definition: guc_tables.h:46
int nest_level
Definition: guc_tables.h:124
GucRealAssignHook assign_hook
Definition: guc_tables.h:219
char ** variable
Definition: guc_tables.h:230
static int GUCNestLevel
Definition: guc.c:4817
bool * variable
Definition: guc_tables.h:184
GucEnumAssignHook assign_hook
Definition: guc_tables.h:248
GucBoolAssignHook assign_hook
Definition: guc_tables.h:187
config_var_value masked
Definition: guc_tables.h:131
GucContext scontext
Definition: guc_tables.h:160
GucIntAssignHook assign_hook
Definition: guc_tables.h:203
GucSource
Definition: guc.h:105
int * variable
Definition: guc_tables.h:198
int * variable
Definition: guc_tables.h:244
void pfree(void *pointer)
Definition: mcxt.c:1056
static int num_guc_variables
Definition: guc.c:4807
static void discard_stack_value(struct config_generic *gconf, config_var_value *val)
Definition: guc.c:5032
GucSource source
Definition: guc_tables.h:126
static void set_extra_field(struct config_generic *gconf, void **field, void *newval)
Definition: guc.c:4978
struct config_generic gen
Definition: guc_tables.h:182
struct config_generic gen
Definition: guc_tables.h:196
GucContext masked_scontext
Definition: guc_tables.h:129
#define GUC_REPORT
Definition: guc.h:208
double * variable
Definition: guc_tables.h:214
static void set_string_field(struct config_string *conf, char **field, char *newval)
Definition: guc.c:4917
static struct config_generic ** guc_variables
Definition: guc.c:4804
enum config_type vartype
Definition: guc_tables.h:156
GucContext scontext
Definition: guc_tables.h:128
struct config_generic gen
Definition: guc_tables.h:242
struct config_generic gen
Definition: guc_tables.h:228
GucStackState state
Definition: guc_tables.h:125
GucStringAssignHook assign_hook
Definition: guc_tables.h:233
#define Assert(condition)
Definition: c.h:738
#define newval
char * stringval
Definition: guc_tables.h:36
int i
static void ReportGUCOption(struct config_generic *record)
Definition: guc.c:6258
GucStack * stack
Definition: guc_tables.h:162
double realval
Definition: guc_tables.h:35
static bool guc_dirty
Definition: guc.c:4813
config_var_value prior
Definition: guc_tables.h:130
struct config_generic gen
Definition: guc_tables.h:212

◆ AtStart_GUC()

void AtStart_GUC ( void  )

Definition at line 5914 of file guc.c.

References elog, and WARNING.

Referenced by StartTransaction().

5915 {
5916  /*
5917  * The nest level should be 0 between transactions; if it isn't, somebody
5918  * didn't call AtEOXact_GUC, or called it with the wrong nestLevel. We
5919  * throw a warning but make no other effort to clean up.
5920  */
5921  if (GUCNestLevel != 0)
5922  elog(WARNING, "GUC nest level = %d at transaction start",
5923  GUCNestLevel);
5924  GUCNestLevel = 1;
5925 }
static int GUCNestLevel
Definition: guc.c:4817
#define WARNING
Definition: elog.h:40
#define elog(elevel,...)
Definition: elog.h:214

◆ BeginReportingGUCOptions()

void BeginReportingGUCOptions ( void  )

Definition at line 6230 of file guc.c.

References DestRemote, config_generic::flags, FrontendProtocol, GUC_REPORT, i, num_guc_variables, PG_PROTOCOL_MAJOR, ReportGUCOption(), and whereToSendOutput.

Referenced by PostgresMain().

6231 {
6232  int i;
6233 
6234  /*
6235  * Don't do anything unless talking to an interactive frontend of protocol
6236  * 3.0 or later.
6237  */
6238  if (whereToSendOutput != DestRemote ||
6240  return;
6241 
6242  reporting_enabled = true;
6243 
6244  /* Transmit initial values of interesting variables */
6245  for (i = 0; i < num_guc_variables; i++)
6246  {
6247  struct config_generic *conf = guc_variables[i];
6248 
6249  if (conf->flags & GUC_REPORT)
6250  ReportGUCOption(conf);
6251  }
6252 }
#define PG_PROTOCOL_MAJOR(v)
Definition: pqcomm.h:104
static int num_guc_variables
Definition: guc.c:4807
#define GUC_REPORT
Definition: guc.h:208
static struct config_generic ** guc_variables
Definition: guc.c:4804
int i
static void ReportGUCOption(struct config_generic *record)
Definition: guc.c:6258
CommandDest whereToSendOutput
Definition: postgres.c:91
static bool reporting_enabled
Definition: guc.c:4815
ProtocolVersion FrontendProtocol
Definition: globals.c:28

◆ build_guc_variables()

void build_guc_variables ( void  )

Definition at line 5068 of file guc.c.

References FATAL, free, config_bool::gen, config_int::gen, config_real::gen, config_string::gen, config_enum::gen, guc_malloc(), guc_var_compare(), i, config_generic::name, PGC_BOOL, PGC_ENUM, PGC_INT, PGC_REAL, PGC_STRING, qsort, and config_generic::vartype.

Referenced by GucInfoMain(), and InitializeGUCOptions().

5069 {
5070  int size_vars;
5071  int num_vars = 0;
5072  struct config_generic **guc_vars;
5073  int i;
5074 
5075  for (i = 0; ConfigureNamesBool[i].gen.name; i++)
5076  {
5077  struct config_bool *conf = &ConfigureNamesBool[i];
5078 
5079  /* Rather than requiring vartype to be filled in by hand, do this: */
5080  conf->gen.vartype = PGC_BOOL;
5081  num_vars++;
5082  }
5083 
5084  for (i = 0; ConfigureNamesInt[i].gen.name; i++)
5085  {
5086  struct config_int *conf = &ConfigureNamesInt[i];
5087 
5088  conf->gen.vartype = PGC_INT;
5089  num_vars++;
5090  }
5091 
5092  for (i = 0; ConfigureNamesReal[i].gen.name; i++)
5093  {
5094  struct config_real *conf = &ConfigureNamesReal[i];
5095 
5096  conf->gen.vartype = PGC_REAL;
5097  num_vars++;
5098  }
5099 
5100  for (i = 0; ConfigureNamesString[i].gen.name; i++)
5101  {
5102  struct config_string *conf = &ConfigureNamesString[i];
5103 
5104  conf->gen.vartype = PGC_STRING;
5105  num_vars++;
5106  }
5107 
5108  for (i = 0; ConfigureNamesEnum[i].gen.name; i++)
5109  {
5110  struct config_enum *conf = &ConfigureNamesEnum[i];
5111 
5112  conf->gen.vartype = PGC_ENUM;
5113  num_vars++;
5114  }
5115 
5116  /*
5117  * Create table with 20% slack
5118  */
5119  size_vars = num_vars + num_vars / 4;
5120 
5121  guc_vars = (struct config_generic **)
5122  guc_malloc(FATAL, size_vars * sizeof(struct config_generic *));
5123 
5124  num_vars = 0;
5125 
5126  for (i = 0; ConfigureNamesBool[i].gen.name; i++)
5127  guc_vars[num_vars++] = &ConfigureNamesBool[i].gen;
5128 
5129  for (i = 0; ConfigureNamesInt[i].gen.name; i++)
5130  guc_vars[num_vars++] = &ConfigureNamesInt[i].gen;
5131 
5132  for (i = 0; ConfigureNamesReal[i].gen.name; i++)
5133  guc_vars[num_vars++] = &ConfigureNamesReal[i].gen;
5134 
5135  for (i = 0; ConfigureNamesString[i].gen.name; i++)
5136  guc_vars[num_vars++] = &ConfigureNamesString[i].gen;
5137 
5138  for (i = 0; ConfigureNamesEnum[i].gen.name; i++)
5139  guc_vars[num_vars++] = &ConfigureNamesEnum[i].gen;
5140 
5141  if (guc_variables)
5143  guc_variables = guc_vars;
5144  num_guc_variables = num_vars;
5145  size_guc_variables = size_vars;
5147  sizeof(struct config_generic *), guc_var_compare);
5148 }
static struct config_int ConfigureNamesInt[]
Definition: guc.c:2070
const char * name
Definition: guc_tables.h:149
static struct config_enum ConfigureNamesEnum[]
Definition: guc.c:4448
static struct config_bool ConfigureNamesBool[]
Definition: guc.c:932
static int guc_var_compare(const void *a, const void *b)
Definition: guc.c:5290
static int num_guc_variables
Definition: guc.c:4807
#define FATAL
Definition: elog.h:52
struct config_generic gen
Definition: guc_tables.h:182
struct config_generic gen
Definition: guc_tables.h:196
static struct config_generic ** guc_variables
Definition: guc.c:4804
enum config_type vartype
Definition: guc_tables.h:156
static int size_guc_variables
Definition: guc.c:4810
static struct config_real ConfigureNamesReal[]
Definition: guc.c:3410
struct config_generic gen
Definition: guc_tables.h:242
struct config_generic gen
Definition: guc_tables.h:228
#define free(a)
Definition: header.h:65
static struct config_string ConfigureNamesString[]
Definition: guc.c:3679
int i
#define qsort(a, b, c, d)
Definition: port.h:479
static void * guc_malloc(int elevel, size_t size)
Definition: guc.c:4845
struct config_generic gen
Definition: guc_tables.h:212

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

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

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

10935 {
10936  /* Quick success if no hook */
10937  if (!conf->check_hook)
10938  return true;
10939 
10940  /* Reset variables that might be set by hook */
10941  GUC_check_errcode_value = ERRCODE_INVALID_PARAMETER_VALUE;
10942  GUC_check_errmsg_string = NULL;
10944  GUC_check_errhint_string = NULL;
10945 
10946  if (!conf->check_hook(newval, extra, source))
10947  {
10948  ereport(elevel,
10952  errmsg("invalid value for parameter \"%s\": %d",
10953  conf->gen.name, (int) *newval),
10957  errhint("%s", GUC_check_errhint_string) : 0));
10958  /* Flush any strings created in ErrorContext */
10959  FlushErrorState();
10960  return false;
10961  }
10962 
10963  return true;
10964 }
char * GUC_check_errhint_string
Definition: guc.c:143
GucSource source
Definition: guc_tables.h:158
int errhint(const char *fmt,...)
Definition: elog.c:1071
const char * name
Definition: guc_tables.h:149
int errcode(int sqlerrcode)
Definition: elog.c:610
static int GUC_check_errcode_value
Definition: guc.c:138
void FlushErrorState(void)
Definition: elog.c:1568
int errdetail_internal(const char *fmt,...)
Definition: elog.c:984
struct config_generic gen
Definition: guc_tables.h:182
char * GUC_check_errdetail_string
Definition: guc.c:142
static int elevel
Definition: vacuumlazy.c:323
GucBoolCheckHook check_hook
Definition: guc_tables.h:186
#define ereport(elevel,...)
Definition: elog.h:144
int errmsg_internal(const char *fmt,...)
Definition: elog.c:911
#define newval
char * GUC_check_errmsg_string
Definition: guc.c:141
int errmsg(const char *fmt,...)
Definition: elog.c:824

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

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

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

11071 {
11072  /* Quick success if no hook */
11073  if (!conf->check_hook)
11074  return true;
11075 
11076  /* Reset variables that might be set by hook */
11077  GUC_check_errcode_value = ERRCODE_INVALID_PARAMETER_VALUE;
11078  GUC_check_errmsg_string = NULL;
11080  GUC_check_errhint_string = NULL;
11081 
11082  if (!conf->check_hook(newval, extra, source))
11083  {
11084  ereport(elevel,
11088  errmsg("invalid value for parameter \"%s\": \"%s\"",
11089  conf->gen.name,
11094  errhint("%s", GUC_check_errhint_string) : 0));
11095  /* Flush any strings created in ErrorContext */
11096  FlushErrorState();
11097  return false;
11098  }
11099 
11100  return true;
11101 }
char * GUC_check_errhint_string
Definition: guc.c:143
GucSource source
Definition: guc_tables.h:158
GucEnumCheckHook check_hook
Definition: guc_tables.h:247
int errhint(const char *fmt,...)
Definition: elog.c:1071
const char * name
Definition: guc_tables.h:149
int errcode(int sqlerrcode)
Definition: elog.c:610
const char * config_enum_lookup_by_value(struct config_enum *record, int val)
Definition: guc.c:6637
static int GUC_check_errcode_value
Definition: guc.c:138
void FlushErrorState(void)
Definition: elog.c:1568
int errdetail_internal(const char *fmt,...)
Definition: elog.c:984
char * GUC_check_errdetail_string
Definition: guc.c:142
static int elevel
Definition: vacuumlazy.c:323
struct config_generic gen
Definition: guc_tables.h:242
#define ereport(elevel,...)
Definition: elog.h:144
int errmsg_internal(const char *fmt,...)
Definition: elog.c:911
#define newval
char * GUC_check_errmsg_string
Definition: guc.c:141
int errmsg(const char *fmt,...)
Definition: elog.c:824

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

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

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

10969 {
10970  /* Quick success if no hook */
10971  if (!conf->check_hook)
10972  return true;
10973 
10974  /* Reset variables that might be set by hook */
10975  GUC_check_errcode_value = ERRCODE_INVALID_PARAMETER_VALUE;
10976  GUC_check_errmsg_string = NULL;
10978  GUC_check_errhint_string = NULL;
10979 
10980  if (!conf->check_hook(newval, extra, source))
10981  {
10982  ereport(elevel,
10986  errmsg("invalid value for parameter \"%s\": %d",
10987  conf->gen.name, *newval),
10991  errhint("%s", GUC_check_errhint_string) : 0));
10992  /* Flush any strings created in ErrorContext */
10993  FlushErrorState();
10994  return false;
10995  }
10996 
10997  return true;
10998 }
char * GUC_check_errhint_string
Definition: guc.c:143
GucSource source
Definition: guc_tables.h:158
int errhint(const char *fmt,...)
Definition: elog.c:1071
const char * name
Definition: guc_tables.h:149
int errcode(int sqlerrcode)
Definition: elog.c:610
static int GUC_check_errcode_value
Definition: guc.c:138
GucIntCheckHook check_hook
Definition: guc_tables.h:202
void FlushErrorState(void)
Definition: elog.c:1568
int errdetail_internal(const char *fmt,...)
Definition: elog.c:984
struct config_generic gen
Definition: guc_tables.h:196
char * GUC_check_errdetail_string
Definition: guc.c:142
static int elevel
Definition: vacuumlazy.c:323
#define ereport(elevel,...)
Definition: elog.h:144
int errmsg_internal(const char *fmt,...)
Definition: elog.c:911
#define newval
char * GUC_check_errmsg_string
Definition: guc.c:141
int errmsg(const char *fmt,...)
Definition: elog.c:824

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

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

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

11003 {
11004  /* Quick success if no hook */
11005  if (!conf->check_hook)
11006  return true;
11007 
11008  /* Reset variables that might be set by hook */
11009  GUC_check_errcode_value = ERRCODE_INVALID_PARAMETER_VALUE;
11010  GUC_check_errmsg_string = NULL;
11012  GUC_check_errhint_string = NULL;
11013 
11014  if (!conf->check_hook(newval, extra, source))
11015  {
11016  ereport(elevel,
11020  errmsg("invalid value for parameter \"%s\": %g",
11021  conf->gen.name, *newval),
11025  errhint("%s", GUC_check_errhint_string) : 0));
11026  /* Flush any strings created in ErrorContext */
11027  FlushErrorState();
11028  return false;
11029  }
11030 
11031  return true;
11032 }
char * GUC_check_errhint_string
Definition: guc.c:143
GucSource source
Definition: guc_tables.h:158
int errhint(const char *fmt,...)
Definition: elog.c:1071
const char * name
Definition: guc_tables.h:149
int errcode(int sqlerrcode)
Definition: elog.c:610
static int GUC_check_errcode_value
Definition: guc.c:138
GucRealCheckHook check_hook
Definition: guc_tables.h:218
void FlushErrorState(void)
Definition: elog.c:1568
int errdetail_internal(const char *fmt,...)
Definition: elog.c:984
char * GUC_check_errdetail_string
Definition: guc.c:142
static int elevel
Definition: vacuumlazy.c:323
#define ereport(elevel,...)
Definition: elog.h:144
int errmsg_internal(const char *fmt,...)
Definition: elog.c:911
#define newval
char * GUC_check_errmsg_string
Definition: guc.c:141
int errmsg(const char *fmt,...)
Definition: elog.c:824
struct config_generic gen
Definition: guc_tables.h:212

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

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

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

11037 {
11038  /* Quick success if no hook */
11039  if (!conf->check_hook)
11040  return true;
11041 
11042  /* Reset variables that might be set by hook */
11043  GUC_check_errcode_value = ERRCODE_INVALID_PARAMETER_VALUE;
11044  GUC_check_errmsg_string = NULL;
11046  GUC_check_errhint_string = NULL;
11047 
11048  if (!conf->check_hook(newval, extra, source))
11049  {
11050  ereport(elevel,
11054  errmsg("invalid value for parameter \"%s\": \"%s\"",
11055  conf->gen.name, *newval ? *newval : ""),
11059  errhint("%s", GUC_check_errhint_string) : 0));
11060  /* Flush any strings created in ErrorContext */
11061  FlushErrorState();
11062  return false;
11063  }
11064 
11065  return true;
11066 }
char * GUC_check_errhint_string
Definition: guc.c:143
GucSource source
Definition: guc_tables.h:158
int errhint(const char *fmt,...)
Definition: elog.c:1071
const char * name
Definition: guc_tables.h:149
GucStringCheckHook check_hook
Definition: guc_tables.h:232
int errcode(int sqlerrcode)
Definition: elog.c:610
static int GUC_check_errcode_value
Definition: guc.c:138
void FlushErrorState(void)
Definition: elog.c:1568
int errdetail_internal(const char *fmt,...)
Definition: elog.c:984
char * GUC_check_errdetail_string
Definition: guc.c:142
static int elevel
Definition: vacuumlazy.c:323
#define ereport(elevel,...)
Definition: elog.h:144
struct config_generic gen
Definition: guc_tables.h:228
int errmsg_internal(const char *fmt,...)
Definition: elog.c:911
#define newval
char * GUC_check_errmsg_string
Definition: guc.c:141
int errmsg(const char *fmt,...)
Definition: elog.c:824

◆ can_skip_gucvar()

static bool can_skip_gucvar ( struct config_generic gconf)
static

Definition at line 10113 of file guc.c.

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

10114 {
10115  return gconf->context == PGC_POSTMASTER ||
10116  gconf->context == PGC_INTERNAL || gconf->source == PGC_S_DEFAULT ||
10117  strcmp(gconf->name, "role") == 0;
10118 }
GucSource source
Definition: guc_tables.h:158
const char * name
Definition: guc_tables.h:149
GucContext context
Definition: guc_tables.h:150

◆ check_application_name()

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

Definition at line 11619 of file guc.c.

References pg_clean_ascii().

11620 {
11621  /* Only allow clean ASCII chars in the application name */
11623 
11624  return true;
11625 }
#define newval
void pg_clean_ascii(char *str)
Definition: string.c:82

◆ check_autovacuum_max_workers()

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

Definition at line 11514 of file guc.c.

References MAX_BACKENDS, max_wal_senders, max_worker_processes, and MaxConnections.

11515 {
11516  if (MaxConnections + *newval + 1 +
11518  return false;
11519  return true;
11520 }
#define MAX_BACKENDS
Definition: postmaster.h:75
int max_wal_senders
Definition: walsender.c:121
int MaxConnections
Definition: globals.c:132
#define newval
int max_worker_processes
Definition: globals.c:133

◆ check_autovacuum_work_mem()

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

Definition at line 11532 of file guc.c.

11533 {
11534  /*
11535  * -1 indicates fallback.
11536  *
11537  * If we haven't yet changed the boot_val default of -1, just let it be.
11538  * Autovacuum will look to maintenance_work_mem instead.
11539  */
11540  if (*newval == -1)
11541  return true;
11542 
11543  /*
11544  * We clamp manually-set values to at least 1MB. Since
11545  * maintenance_work_mem is always set to at least this value, do the same
11546  * here.
11547  */
11548  if (*newval < 1024)
11549  *newval = 1024;
11550 
11551  return true;
11552 }
#define newval

◆ check_backtrace_functions()

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

Definition at line 11679 of file guc.c.

References ERROR, GUC_check_errdetail, guc_malloc(), and i.

11680 {
11681  int newvallen = strlen(*newval);
11682  char *someval;
11683  int validlen;
11684  int i;
11685  int j;
11686 
11687  /*
11688  * Allow characters that can be C identifiers and commas as separators, as
11689  * well as some whitespace for readability.
11690  */
11691  validlen = strspn(*newval,
11692  "0123456789_"
11693  "abcdefghijklmnopqrstuvwxyz"
11694  "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
11695  ", \n\t");
11696  if (validlen != newvallen)
11697  {
11698  GUC_check_errdetail("invalid character");
11699  return false;
11700  }
11701 
11702  if (*newval[0] == '\0')
11703  {
11704  *extra = NULL;
11705  return true;
11706  }
11707 
11708  /*
11709  * Allocate space for the output and create the copy. We could discount
11710  * whitespace chars to save some memory, but it doesn't seem worth the
11711  * trouble.
11712  */
11713  someval = guc_malloc(ERROR, newvallen + 1 + 1);
11714  for (i = 0, j = 0; i < newvallen; i++)
11715  {
11716  if ((*newval)[i] == ',')
11717  someval[j++] = '\0'; /* next item */
11718  else if ((*newval)[i] == ' ' ||
11719  (*newval)[i] == '\n' ||
11720  (*newval)[i] == '\t')
11721  ; /* ignore these */
11722  else
11723  someval[j++] = (*newval)[i]; /* copy anything else */
11724  }
11725 
11726  /* two \0s end the setting */
11727  someval[j] = '\0';
11728  someval[j + 1] = '\0';
11729 
11730  *extra = someval;
11731  return true;
11732 }
#define GUC_check_errdetail
Definition: guc.h:415
#define ERROR
Definition: elog.h:43
#define newval
int i
static void * guc_malloc(int elevel, size_t size)
Definition: guc.c:4845

◆ check_bonjour()

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

Definition at line 11297 of file guc.c.

References GUC_check_errmsg.

11298 {
11299 #ifndef USE_BONJOUR
11300  if (*newval)
11301  {
11302  GUC_check_errmsg("Bonjour is not supported by this build");
11303  return false;
11304  }
11305 #endif
11306  return true;
11307 }
#define GUC_check_errmsg
Definition: guc.h:411
#define newval

◆ check_canonical_path()

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

Definition at line 11348 of file guc.c.

References canonicalize_path().

11349 {
11350  /*
11351  * Since canonicalize_path never enlarges the string, we can just modify
11352  * newval in-place. But watch out for NULL, which is the default value
11353  * for external_pid_file.
11354  */
11355  if (*newval)
11357  return true;
11358 }
void canonicalize_path(char *path)
Definition: path.c:254
#define newval

◆ check_cluster_name()

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

Definition at line 11635 of file guc.c.

References pg_clean_ascii().

11636 {
11637  /* Only allow clean ASCII chars in the cluster name */
11639 
11640  return true;
11641 }
#define newval
void pg_clean_ascii(char *str)
Definition: string.c:82

◆ check_default_with_oids()

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

Definition at line 12008 of file guc.c.

References GUC_check_errcode(), and GUC_check_errmsg.

12009 {
12010  if (*newval)
12011  {
12012  /* check the GUC's definition for an explanation */
12013  GUC_check_errcode(ERRCODE_FEATURE_NOT_SUPPORTED);
12014  GUC_check_errmsg("tables declared WITH OIDS are not supported");
12015 
12016  return false;
12017  }
12018 
12019  return true;
12020 }
#define GUC_check_errmsg
Definition: guc.h:411
void GUC_check_errcode(int sqlerrcode)
Definition: guc.c:10920
#define newval

◆ check_effective_io_concurrency()

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

Definition at line 11564 of file guc.c.

References GUC_check_errdetail.

11565 {
11566 #ifndef USE_PREFETCH
11567  if (*newval != 0)
11568  {
11569  GUC_check_errdetail("effective_io_concurrency must be set to 0 on platforms that lack posix_fadvise().");
11570  return false;
11571  }
11572 #endif /* USE_PREFETCH */
11573  return true;
11574 }
#define GUC_check_errdetail
Definition: guc.h:415
#define newval

◆ check_log_destination()

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

Definition at line 11189 of file guc.c.

References ERROR, GUC_check_errdetail, guc_malloc(), lfirst, list_free(), LOG_DESTINATION_CSVLOG, LOG_DESTINATION_EVENTLOG, LOG_DESTINATION_STDERR, LOG_DESTINATION_SYSLOG, pfree(), pg_strcasecmp(), pstrdup(), and SplitIdentifierString().

11190 {
11191  char *rawstring;
11192  List *elemlist;
11193  ListCell *l;
11194  int newlogdest = 0;
11195  int *myextra;
11196 
11197  /* Need a modifiable copy of string */
11198  rawstring = pstrdup(*newval);
11199 
11200  /* Parse string into list of identifiers */
11201  if (!SplitIdentifierString(rawstring, ',', &elemlist))
11202  {
11203  /* syntax error in list */
11204  GUC_check_errdetail("List syntax is invalid.");
11205  pfree(rawstring);
11206  list_free(elemlist);
11207  return false;
11208  }
11209 
11210  foreach(l, elemlist)
11211  {
11212  char *tok = (char *) lfirst(l);
11213 
11214  if (pg_strcasecmp(tok, "stderr") == 0)
11215  newlogdest |= LOG_DESTINATION_STDERR;
11216  else if (pg_strcasecmp(tok, "csvlog") == 0)
11217  newlogdest |= LOG_DESTINATION_CSVLOG;
11218 #ifdef HAVE_SYSLOG
11219  else if (pg_strcasecmp(tok, "syslog") == 0)
11220  newlogdest |= LOG_DESTINATION_SYSLOG;
11221 #endif
11222 #ifdef WIN32
11223  else if (pg_strcasecmp(tok, "eventlog") == 0)
11224  newlogdest |= LOG_DESTINATION_EVENTLOG;
11225 #endif
11226  else
11227  {
11228  GUC_check_errdetail("Unrecognized key word: \"%s\".", tok);
11229  pfree(rawstring);
11230  list_free(elemlist);
11231  return false;
11232  }
11233  }
11234 
11235  pfree(rawstring);
11236  list_free(elemlist);
11237 
11238  myextra = (int *) guc_malloc(ERROR, sizeof(int));
11239  *myextra = newlogdest;
11240  *extra = (void *) myextra;
11241 
11242  return true;
11243 }
#define LOG_DESTINATION_EVENTLOG
Definition: elog.h:420
#define GUC_check_errdetail
Definition: guc.h:415
char * pstrdup(const char *in)
Definition: mcxt.c:1186
#define LOG_DESTINATION_SYSLOG
Definition: elog.h:419
int pg_strcasecmp(const char *s1, const char *s2)
Definition: pgstrcasecmp.c:36
void pfree(void *pointer)
Definition: mcxt.c:1056
#define ERROR
Definition: elog.h:43
bool SplitIdentifierString(char *rawstring, char separator, List **namelist)
Definition: varlena.c:3686
#define LOG_DESTINATION_CSVLOG
Definition: elog.h:421
#define LOG_DESTINATION_STDERR
Definition: elog.h:418
#define lfirst(lc)
Definition: pg_list.h:190
#define newval
void list_free(List *list)
Definition: list.c:1376
static void * guc_malloc(int elevel, size_t size)
Definition: guc.c:4845
Definition: pg_list.h:50

◆ check_log_stats()

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

Definition at line 11334 of file guc.c.

References GUC_check_errdetail.

11335 {
11336  if (*newval &&
11338  {
11339  GUC_check_errdetail("Cannot enable \"log_statement_stats\" when "
11340  "\"log_parser_stats\", \"log_planner_stats\", "
11341  "or \"log_executor_stats\" is true.");
11342  return false;
11343  }
11344  return true;
11345 }
bool log_parser_stats
Definition: guc.c:524
#define GUC_check_errdetail
Definition: guc.h:415
#define newval
bool log_executor_stats
Definition: guc.c:526
bool log_planner_stats
Definition: guc.c:525

◆ check_maintenance_io_concurrency()

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

Definition at line 11577 of file guc.c.

References GUC_check_errdetail.

11578 {
11579 #ifndef USE_PREFETCH
11580  if (*newval != 0)
11581  {
11582  GUC_check_errdetail("maintenance_io_concurrency must be set to 0 on platforms that lack posix_fadvise().");
11583  return false;
11584  }
11585 #endif /* USE_PREFETCH */
11586  return true;
11587 }
#define GUC_check_errdetail
Definition: guc.h:415
#define newval

◆ check_max_wal_senders()

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

Definition at line 11523 of file guc.c.

References autovacuum_max_workers, MAX_BACKENDS, max_worker_processes, and MaxConnections.

11524 {
11527  return false;
11528  return true;
11529 }
#define MAX_BACKENDS
Definition: postmaster.h:75
int MaxConnections
Definition: globals.c:132
int autovacuum_max_workers
Definition: autovacuum.c:115
#define newval
int max_worker_processes
Definition: globals.c:133

◆ check_max_worker_processes()

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

Definition at line 11555 of file guc.c.

References autovacuum_max_workers, MAX_BACKENDS, max_wal_senders, and MaxConnections.

11556 {
11559  return false;
11560  return true;
11561 }
#define MAX_BACKENDS
Definition: postmaster.h:75
int max_wal_senders
Definition: walsender.c:121
int MaxConnections
Definition: globals.c:132
int autovacuum_max_workers
Definition: autovacuum.c:115
#define newval

◆ check_maxconnections()

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

Definition at line 11505 of file guc.c.

References autovacuum_max_workers, MAX_BACKENDS, max_wal_senders, and max_worker_processes.

11506 {
11507  if (*newval + autovacuum_max_workers + 1 +
11509  return false;
11510  return true;
11511 }
#define MAX_BACKENDS
Definition: postmaster.h:75
int max_wal_senders
Definition: walsender.c:121
int autovacuum_max_workers
Definition: autovacuum.c:115
#define newval
int max_worker_processes
Definition: globals.c:133

◆ check_primary_slot_name()

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

Definition at line 11998 of file guc.c.

References ReplicationSlotValidateName(), and WARNING.

11999 {
12000  if (*newval && strcmp(*newval, "") != 0 &&
12002  return false;
12003 
12004  return true;
12005 }
bool ReplicationSlotValidateName(const char *name, int elevel)
Definition: slot.c:172
#define WARNING
Definition: elog.h:40
#define newval

◆ check_recovery_target()

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

Definition at line 11803 of file guc.c.

References GUC_check_errdetail.

11804 {
11805  if (strcmp(*newval, "immediate") != 0 && strcmp(*newval, "") != 0)
11806  {
11807  GUC_check_errdetail("The only allowed value is \"immediate\".");
11808  return false;
11809  }
11810  return true;
11811 }
#define GUC_check_errdetail
Definition: guc.h:415
#define newval

◆ check_recovery_target_lsn()

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

Definition at line 11962 of file guc.c.

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

11963 {
11964  if (strcmp(*newval, "") != 0)
11965  {
11966  XLogRecPtr lsn;
11967  XLogRecPtr *myextra;
11968  bool have_error = false;
11969 
11970  lsn = pg_lsn_in_internal(*newval, &have_error);
11971  if (have_error)
11972  return false;
11973 
11974  myextra = (XLogRecPtr *) guc_malloc(ERROR, sizeof(XLogRecPtr));
11975  *myextra = lsn;
11976  *extra = (void *) myextra;
11977  }
11978  return true;
11979 }
#define ERROR
Definition: elog.h:43
XLogRecPtr pg_lsn_in_internal(const char *str, bool *have_error)
Definition: pg_lsn.c:29
uint64 XLogRecPtr
Definition: xlogdefs.h:21
#define newval
static void * guc_malloc(int elevel, size_t size)
Definition: guc.c:4845

◆ check_recovery_target_name()

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

Definition at line 11933 of file guc.c.

References GUC_check_errdetail, and MAXFNAMELEN.

11934 {
11935  /* Use the value of newval directly */
11936  if (strlen(*newval) >= MAXFNAMELEN)
11937  {
11938  GUC_check_errdetail("%s is too long (maximum %d characters).",
11939  "recovery_target_name", MAXFNAMELEN - 1);
11940  return false;
11941  }
11942  return true;
11943 }
#define GUC_check_errdetail
Definition: guc.h:415
#define MAXFNAMELEN
#define newval

◆ check_recovery_target_time()

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

Definition at line 11870 of file guc.c.

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

11871 {
11872  if (strcmp(*newval, "") != 0)
11873  {
11874  /* reject some special values */
11875  if (strcmp(*newval, "now") == 0 ||
11876  strcmp(*newval, "today") == 0 ||
11877  strcmp(*newval, "tomorrow") == 0 ||
11878  strcmp(*newval, "yesterday") == 0)
11879  {
11880  return false;
11881  }
11882 
11883  /*
11884  * parse timestamp value (see also timestamptz_in())
11885  */
11886  {
11887  char *str = *newval;
11888  fsec_t fsec;
11889  struct pg_tm tt,
11890  *tm = &tt;
11891  int tz;
11892  int dtype;
11893  int nf;
11894  int dterr;
11895  char *field[MAXDATEFIELDS];
11896  int ftype[MAXDATEFIELDS];
11897  char workbuf[MAXDATELEN + MAXDATEFIELDS];
11899 
11900  dterr = ParseDateTime(str, workbuf, sizeof(workbuf),
11901  field, ftype, MAXDATEFIELDS, &nf);
11902  if (dterr == 0)
11903  dterr = DecodeDateTime(field, ftype, nf, &dtype, tm, &fsec, &tz);
11904  if (dterr != 0)
11905  return false;
11906  if (dtype != DTK_DATE)
11907  return false;
11908 
11909  if (tm2timestamp(tm, fsec, &tz, &timestamp) != 0)
11910  {
11911  GUC_check_errdetail("timestamp out of range: \"%s\"", str);
11912  return false;
11913  }
11914  }
11915  }
11916  return true;
11917 }
#define MAXDATELEN
Definition: datetime.h:201
#define GUC_check_errdetail
Definition: guc.h:415
int64 timestamp
int64 TimestampTz
Definition: timestamp.h:39
Definition: pgtime.h:25
static struct pg_tm tm
Definition: localtime.c:108
int DecodeDateTime(char **field, int *ftype, int nf, int *dtype, struct pg_tm *tm, fsec_t *fsec, int *tzp)
Definition: datetime.c:758
int32 fsec_t
Definition: timestamp.h:41
int tm2timestamp(struct pg_tm *tm, fsec_t fsec, int *tzp, Timestamp *result)
Definition: timestamp.c:1880
#define MAXDATEFIELDS
Definition: datetime.h:203
#define newval
int ParseDateTime(const char *timestr, char *workbuf, size_t buflen, char **field, int *ftype, int maxfields, int *numfields)
Definition: datetime.c:537
#define DTK_DATE
Definition: datetime.h:145

◆ check_recovery_target_timeline()

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

Definition at line 11741 of file guc.c.

References ERROR, GUC_check_errdetail, guc_malloc(), RECOVERY_TARGET_TIMELINE_CONTROLFILE, RECOVERY_TARGET_TIMELINE_LATEST, and RECOVERY_TARGET_TIMELINE_NUMERIC.

11742 {
11744  RecoveryTargetTimeLineGoal *myextra;
11745 
11746  if (strcmp(*newval, "current") == 0)
11748  else if (strcmp(*newval, "latest") == 0)
11750  else
11751  {
11753 
11754  errno = 0;
11755  strtoul(*newval, NULL, 0);
11756  if (errno == EINVAL || errno == ERANGE)
11757  {
11758  GUC_check_errdetail("recovery_target_timeline is not a valid number.");
11759  return false;
11760  }
11761  }
11762 
11764  *myextra = rttg;
11765  *extra = (void *) myextra;
11766 
11767  return true;
11768 }
#define GUC_check_errdetail
Definition: guc.h:415
RecoveryTargetTimeLineGoal
Definition: xlog.h:93
#define ERROR
Definition: elog.h:43
#define newval
static void * guc_malloc(int elevel, size_t size)
Definition: guc.c:4845

◆ check_recovery_target_xid()

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

Definition at line 11827 of file guc.c.

References ERROR, and guc_malloc().

11828 {
11829  if (strcmp(*newval, "") != 0)
11830  {
11831  TransactionId xid;
11832  TransactionId *myextra;
11833 
11834  errno = 0;
11835  xid = (TransactionId) strtoul(*newval, NULL, 0);
11836  if (errno == EINVAL || errno == ERANGE)
11837  return false;
11838 
11839  myextra = (TransactionId *) guc_malloc(ERROR, sizeof(TransactionId));
11840  *myextra = xid;
11841  *extra = (void *) myextra;
11842  }
11843  return true;
11844 }
uint32 TransactionId
Definition: c.h:513
#define ERROR
Definition: elog.h:43
#define newval
static void * guc_malloc(int elevel, size_t size)
Definition: guc.c:4845

◆ check_ssl()

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

Definition at line 11310 of file guc.c.

References GUC_check_errmsg.

11311 {
11312 #ifndef USE_SSL
11313  if (*newval)
11314  {
11315  GUC_check_errmsg("SSL is not supported by this build");
11316  return false;
11317  }
11318 #endif
11319  return true;
11320 }
#define GUC_check_errmsg
Definition: guc.h:411
#define newval

◆ check_stage_log_stats()

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

Definition at line 11323 of file guc.c.

References GUC_check_errdetail.

11324 {
11325  if (*newval && log_statement_stats)
11326  {
11327  GUC_check_errdetail("Cannot enable parameter when \"log_statement_stats\" is true.");
11328  return false;
11329  }
11330  return true;
11331 }
bool log_statement_stats
Definition: guc.c:527
#define GUC_check_errdetail
Definition: guc.h:415
#define newval

◆ check_temp_buffers()

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

Definition at line 11283 of file guc.c.

References GUC_check_errdetail, and NLocBuffer.

11284 {
11285  /*
11286  * Once local buffers have been initialized, it's too late to change this.
11287  */
11288  if (NLocBuffer && NLocBuffer != *newval)
11289  {
11290  GUC_check_errdetail("\"temp_buffers\" cannot be changed after any temporary tables have been accessed in the session.");
11291  return false;
11292  }
11293  return true;
11294 }
#define GUC_check_errdetail
Definition: guc.h:415
int NLocBuffer
Definition: localbuf.c:41
#define newval

◆ check_timezone_abbreviations()

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

Definition at line 11361 of file guc.c.

References Assert, load_tzoffsets(), and PGC_S_DEFAULT.

11362 {
11363  /*
11364  * The boot_val given above for timezone_abbreviations is NULL. When we
11365  * see this we just do nothing. If this value isn't overridden from the
11366  * config file then pg_timezone_abbrev_initialize() will eventually
11367  * replace it with "Default". This hack has two purposes: to avoid
11368  * wasting cycles loading values that might soon be overridden from the
11369  * config file, and to avoid trying to read the timezone abbrev files
11370  * during InitializeGUCOptions(). The latter doesn't work in an
11371  * EXEC_BACKEND subprocess because my_exec_path hasn't been set yet and so
11372  * we can't locate PGSHAREDIR.
11373  */
11374  if (*newval == NULL)
11375  {
11376  Assert(source == PGC_S_DEFAULT);
11377  return true;
11378  }
11379 
11380  /* OK, load the file and produce a malloc'd TimeZoneAbbrevTable */
11381  *extra = load_tzoffsets(*newval);
11382 
11383  /* tzparser.c returns NULL on failure, reporting via GUC_check_errmsg */
11384  if (!*extra)
11385  return false;
11386 
11387  return true;
11388 }
TimeZoneAbbrevTable * load_tzoffsets(const char *filename)
Definition: tzparser.c:437
#define Assert(condition)
Definition: c.h:738
#define newval

◆ check_wal_consistency_checking()

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

Definition at line 11109 of file guc.c.

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

11110 {
11111  char *rawstring;
11112  List *elemlist;
11113  ListCell *l;
11114  bool newwalconsistency[RM_MAX_ID + 1];
11115 
11116  /* Initialize the array */
11117  MemSet(newwalconsistency, 0, (RM_MAX_ID + 1) * sizeof(bool));
11118 
11119  /* Need a modifiable copy of string */
11120  rawstring = pstrdup(*newval);
11121 
11122  /* Parse string into list of identifiers */
11123  if (!SplitIdentifierString(rawstring, ',', &elemlist))
11124  {
11125  /* syntax error in list */
11126  GUC_check_errdetail("List syntax is invalid.");
11127  pfree(rawstring);
11128  list_free(elemlist);
11129  return false;
11130  }
11131 
11132  foreach(l, elemlist)
11133  {
11134  char *tok = (char *) lfirst(l);
11135  bool found = false;
11136  RmgrId rmid;
11137 
11138  /* Check for 'all'. */
11139  if (pg_strcasecmp(tok, "all") == 0)
11140  {
11141  for (rmid = 0; rmid <= RM_MAX_ID; rmid++)
11142  if (RmgrTable[rmid].rm_mask != NULL)
11143  newwalconsistency[rmid] = true;
11144  found = true;
11145  }
11146  else
11147  {
11148  /*
11149  * Check if the token matches with any individual resource
11150  * manager.
11151  */
11152  for (rmid = 0; rmid <= RM_MAX_ID; rmid++)
11153  {
11154  if (pg_strcasecmp(tok, RmgrTable[rmid].rm_name) == 0 &&
11155  RmgrTable[rmid].rm_mask != NULL)
11156  {
11157  newwalconsistency[rmid] = true;
11158  found = true;
11159  }
11160  }
11161  }
11162 
11163  /* If a valid resource manager is found, check for the next one. */
11164  if (!found)
11165  {
11166  GUC_check_errdetail("Unrecognized key word: \"%s\".", tok);
11167  pfree(rawstring);
11168  list_free(elemlist);
11169  return false;
11170  }
11171  }
11172 
11173  pfree(rawstring);
11174  list_free(elemlist);
11175 
11176  /* assign new value */
11177  *extra = guc_malloc(ERROR, (RM_MAX_ID + 1) * sizeof(bool));
11178  memcpy(*extra, newwalconsistency, (RM_MAX_ID + 1) * sizeof(bool));
11179  return true;
11180 }
#define GUC_check_errdetail
Definition: guc.h:415
char * pstrdup(const char *in)
Definition: mcxt.c:1186
const RmgrData RmgrTable[RM_MAX_ID+1]
Definition: rmgr.c:36
#define MemSet(start, val, len)
Definition: c.h:971
int pg_strcasecmp(const char *s1, const char *s2)
Definition: pgstrcasecmp.c:36
void pfree(void *pointer)
Definition: mcxt.c:1056
#define ERROR
Definition: elog.h:43
bool SplitIdentifierString(char *rawstring, char separator, List **namelist)
Definition: varlena.c:3686
#define RM_MAX_ID
Definition: rmgr.h:33
void(* rm_mask)(char *pagedata, BlockNumber blkno)
uint8 RmgrId
Definition: rmgr.h:11
#define lfirst(lc)
Definition: pg_list.h:190
#define newval
void list_free(List *list)
Definition: list.c:1376
static void * guc_malloc(int elevel, size_t size)
Definition: guc.c:4845
Definition: pg_list.h:50

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

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

6688 {
6689  const struct config_enum_entry *entry;
6690  StringInfoData retstr;
6691  int seplen;
6692 
6693  initStringInfo(&retstr);
6694  appendStringInfoString(&retstr, prefix);
6695 
6696  seplen = strlen(separator);
6697  for (entry = record->options; entry && entry->name; entry++)
6698  {
6699  if (!entry->hidden)
6700  {
6701  appendStringInfoString(&retstr, entry->name);
6702  appendBinaryStringInfo(&retstr, separator, seplen);
6703  }
6704  }
6705 
6706  /*
6707  * All the entries may have been hidden, leaving the string empty if no
6708  * prefix was given. This indicates a broken GUC setup, since there is no
6709  * use for an enum without any values, so we just check to make sure we
6710  * don't write to invalid memory instead of actually trying to do
6711  * something smart with it.
6712  */
6713  if (retstr.len >= seplen)
6714  {
6715  /* Replace final separator */
6716  retstr.data[retstr.len - seplen] = '\0';
6717  retstr.len -= seplen;
6718  }
6719 
6720  appendStringInfoString(&retstr, suffix);
6721 
6722  return retstr.data;
6723 }
Definition: guc.h:164
const struct config_enum_entry * options
Definition: guc_tables.h:246
void appendStringInfoString(StringInfo str, const char *s)
Definition: stringinfo.c:176
void initStringInfo(StringInfo str)
Definition: stringinfo.c:59
const char * name
Definition: guc.h:166
void appendBinaryStringInfo(StringInfo str, const char *data, int datalen)
Definition: stringinfo.c:227
bool hidden
Definition: guc.h:168

◆ config_enum_lookup_by_name()

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

Definition at line 6660 of file guc.c.

References config_enum_entry::name, config_enum::options, pg_strcasecmp(), and config_enum_entry::val.

Referenced by parse_and_validate_value().

6662 {
6663  const struct config_enum_entry *entry;
6664 
6665  for (entry = record->options; entry && entry->name; entry++)
6666  {
6667  if (pg_strcasecmp(value, entry->name) == 0)
6668  {
6669  *retval = entry->val;
6670  return true;
6671  }
6672  }
6673 
6674  *retval = 0;
6675  return false;
6676 }
Definition: guc.h:164
int pg_strcasecmp(const char *s1, const char *s2)
Definition: pgstrcasecmp.c:36
const struct config_enum_entry * options
Definition: guc_tables.h:246
int val
Definition: guc.h:167
static struct @143 value
const char * name
Definition: guc.h:166

◆ config_enum_lookup_by_value()

const char* config_enum_lookup_by_value ( struct config_enum record,
int  val 
)

Definition at line 6637 of file guc.c.

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

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

6638 {
6639  const struct config_enum_entry *entry;
6640 
6641  for (entry = record->options; entry && entry->name; entry++)
6642  {
6643  if (entry->val == val)
6644  return entry->name;
6645  }
6646 
6647  elog(ERROR, "could not find enum option %d for %s",
6648  val, record->gen.name);
6649  return NULL; /* silence compiler */
6650 }
Definition: guc.h:164
const char * name
Definition: guc_tables.h:149
#define ERROR
Definition: elog.h:43
const struct config_enum_entry * options
Definition: guc_tables.h:246
int val
Definition: guc.h:167
struct config_generic gen
Definition: guc_tables.h:242
const char * name
Definition: guc.h:166
#define elog(elevel,...)
Definition: elog.h:214
long val
Definition: informix.c:664

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

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

Referenced by _ShowOption().

6345 {
6346  const unit_conversion *table;
6347  int i;
6348 
6349  *unit = NULL;
6350 
6351  if (base_unit & GUC_UNIT_MEMORY)
6353  else
6355 
6356  for (i = 0; *table[i].unit; i++)
6357  {
6358  if (base_unit == table[i].base_unit)
6359  {
6360  /*
6361  * Accept the first conversion that divides the value evenly. We
6362  * assume that the conversions for each base unit are ordered from
6363  * greatest unit to the smallest!
6364  */
6365  if (table[i].multiplier <= 1.0 ||
6366  base_value % (int64) table[i].multiplier == 0)
6367  {
6368  *value = (int64) rint(base_value / table[i].multiplier);
6369  *unit = table[i].unit;
6370  break;
6371  }
6372  }
6373  }
6374 
6375  Assert(*unit != NULL);
6376 }
static const unit_conversion time_unit_conversion_table[]
Definition: guc.c:876
static const unit_conversion memory_unit_conversion_table[]
Definition: guc.c:839
static struct @143 value
#define Assert(condition)
Definition: c.h:738
int i
char unit[MAX_UNIT_LEN+1]
Definition: guc.c:823
#define GUC_UNIT_MEMORY
Definition: guc.h:223

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

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

Referenced by _ShowOption().

6387 {
6388  const unit_conversion *table;
6389  int i;
6390 
6391  *unit = NULL;
6392 
6393  if (base_unit & GUC_UNIT_MEMORY)
6395  else
6397 
6398  for (i = 0; *table[i].unit; i++)
6399  {
6400  if (base_unit == table[i].base_unit)
6401  {
6402  /*
6403  * Accept the first conversion that divides the value evenly; or
6404  * if there is none, use the smallest (last) target unit.
6405  *
6406  * What we actually care about here is whether snprintf with "%g"
6407  * will print the value as an integer, so the obvious test of
6408  * "*value == rint(*value)" is too strict; roundoff error might
6409  * make us choose an unreasonably small unit. As a compromise,
6410  * accept a divisor that is within 1e-8 of producing an integer.
6411  */
6412  *value = base_value / table[i].multiplier;
6413  *unit = table[i].unit;
6414  if (*value > 0 &&
6415  fabs((rint(*value) / *value) - 1.0) <= 1e-8)
6416  break;
6417  }
6418  }
6419 
6420  Assert(*unit != NULL);
6421 }
static const unit_conversion time_unit_conversion_table[]
Definition: guc.c:876
static const unit_conversion memory_unit_conversion_table[]
Definition: guc.c:839
static struct @143 value
#define Assert(condition)
Definition: c.h:738
double multiplier
Definition: guc.c:826
e
Definition: preproc-init.c:82
int i
char unit[MAX_UNIT_LEN+1]
Definition: guc.c:823
#define GUC_UNIT_MEMORY
Definition: guc.h:223

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

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

Referenced by parse_int(), and parse_real().

6287 {
6288  char unitstr[MAX_UNIT_LEN + 1];
6289  int unitlen;
6290  const unit_conversion *table;
6291  int i;
6292 
6293  /* extract unit string to compare to table entries */
6294  unitlen = 0;
6295  while (*unit != '\0' && !isspace((unsigned char) *unit) &&
6296  unitlen < MAX_UNIT_LEN)
6297  unitstr[unitlen++] = *(unit++);
6298  unitstr[unitlen] = '\0';
6299  /* allow whitespace after unit */
6300  while (isspace((unsigned char) *unit))
6301  unit++;
6302  if (*unit != '\0')
6303  return false; /* unit too long, or garbage after it */
6304 
6305  /* now search the appropriate table */
6306  if (base_unit & GUC_UNIT_MEMORY)
6308  else
6310 
6311  for (i = 0; *table[i].unit; i++)
6312  {
6313  if (base_unit == table[i].base_unit &&
6314  strcmp(unitstr, table[i].unit) == 0)
6315  {
6316  double cvalue = value * table[i].multiplier;
6317 
6318  /*
6319  * If the user gave a fractional value such as "30.1GB", round it
6320  * off to the nearest multiple of the next smaller unit, if there
6321  * is one.
6322  */
6323  if (*table[i + 1].unit &&
6324  base_unit == table[i + 1].base_unit)
6325  cvalue = rint(cvalue / table[i + 1].multiplier) *
6326  table[i + 1].multiplier;
6327 
6328  *base_value = cvalue;
6329  return true;
6330  }
6331  }
6332  return false;
6333 }
static const unit_conversion time_unit_conversion_table[]
Definition: guc.c:876
static const unit_conversion memory_unit_conversion_table[]
Definition: guc.c:839
#define MAX_UNIT_LEN
Definition: guc.c:819
static struct @143 value
double multiplier
Definition: guc.c:826
int i
char unit[MAX_UNIT_LEN+1]
Definition: guc.c:823
#define GUC_UNIT_MEMORY
Definition: guc.h:223

◆ define_custom_variable()

static void define_custom_variable ( struct config_generic variable)
static

Definition at line 8611 of file guc.c.

References add_guc_variable(), Assert, ereport, errcode(), errmsg(), ERROR, free, config_string::gen, GUC_ACTION_SET, GUC_CUSTOM_PLACEHOLDER, guc_var_compare(), InitializeOneGUCOption(), config_generic::name, name, PGC_STRING, reapply_stacked_values(), 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().

8612 {
8613  const char *name = variable->name;
8614  const char **nameAddr = &name;
8615  struct config_string *pHolder;
8616  struct config_generic **res;
8617 
8618  /*
8619  * See if there's a placeholder by the same name.
8620  */
8621  res = (struct config_generic **) bsearch((void *) &nameAddr,
8622  (void *) guc_variables,
8624  sizeof(struct config_generic *),
8625  guc_var_compare);
8626  if (res == NULL)
8627  {
8628  /*
8629  * No placeholder to replace, so we can just add it ... but first,
8630  * make sure it's initialized to its default value.
8631  */
8632  InitializeOneGUCOption(variable);
8633  add_guc_variable(variable, ERROR);
8634  return;
8635  }
8636 
8637  /*
8638  * This better be a placeholder
8639  */
8640  if (((*res)->flags & GUC_CUSTOM_PLACEHOLDER) == 0)
8641  ereport(ERROR,
8642  (errcode(ERRCODE_INTERNAL_ERROR),
8643  errmsg("attempt to redefine parameter \"%s\"", name)));
8644 
8645  Assert((*res)->vartype == PGC_STRING);
8646  pHolder = (struct config_string *) (*res);
8647 
8648  /*
8649  * First, set the variable to its default value. We must do this even
8650  * though we intend to immediately apply a new value, since it's possible
8651  * that the new value is invalid.
8652  */
8653  InitializeOneGUCOption(variable);
8654 
8655  /*
8656  * Replace the placeholder. We aren't changing the name, so no re-sorting
8657  * is necessary
8658  */
8659  *res = variable;
8660 
8661  /*
8662  * Assign the string value(s) stored in the placeholder to the real
8663  * variable. Essentially, we need to duplicate all the active and stacked
8664  * values, but with appropriate validation and datatype adjustment.
8665  *
8666  * If an assignment fails, we report a WARNING and keep going. We don't
8667  * want to throw ERROR for bad values, because it'd bollix the add-on
8668  * module that's presumably halfway through getting loaded. In such cases
8669  * the default or previous state will become active instead.
8670  */
8671 
8672  /* First, apply the reset value if any */
8673  if (pHolder->reset_val)
8674  (void) set_config_option(name, pHolder->reset_val,
8675  pHolder->gen.reset_scontext,
8676  pHolder->gen.reset_source,
8677  GUC_ACTION_SET, true, WARNING, false);
8678  /* That should not have resulted in stacking anything */
8679  Assert(variable->stack == NULL);
8680 
8681  /* Now, apply current and stacked values, in the order they were stacked */
8682  reapply_stacked_values(variable, pHolder, pHolder->gen.stack,
8683  *(pHolder->variable),
8684  pHolder->gen.scontext, pHolder->gen.source);
8685 
8686  /* Also copy over any saved source-location information */
8687  if (pHolder->gen.sourcefile)
8688  set_config_sourcefile(name, pHolder->gen.sourcefile,
8689  pHolder->gen.sourceline);
8690 
8691  /*
8692  * Free up as much as we conveniently can of the placeholder structure.
8693  * (This neglects any stack items, so it's possible for some memory to be
8694  * leaked. Since this can only happen once per session per variable, it
8695  * doesn't seem worth spending much code on.)
8696  */
8697  set_string_field(pHolder, pHolder->variable, NULL);
8698  set_string_field(pHolder, &pHolder->reset_val, NULL);
8699 
8700  free(pHolder);
8701 }
GucSource source
Definition: guc_tables.h:158
static void static void set_config_sourcefile(const char *name, char *sourcefile, int sourceline)
Definition: guc.c:7672
char ** variable
Definition: guc_tables.h:230
const char * name
Definition: guc_tables.h:149
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:8711
int errcode(int sqlerrcode)
Definition: elog.c:610
GucContext scontext
Definition: guc_tables.h:160
static int guc_var_compare(const void *a, const void *b)
Definition: guc.c:5290
#define ERROR
Definition: elog.h:43
static int num_guc_variables
Definition: guc.c:4807
char * sourcefile
Definition: guc_tables.h:164
GucSource reset_source
Definition: guc_tables.h:159
static void InitializeOneGUCOption(struct config_generic *gconf)
Definition: guc.c:5438
static void set_string_field(struct config_string *conf, char **field, char *newval)
Definition: guc.c:4917
static struct config_generic ** guc_variables
Definition: guc.c:4804
#define WARNING
Definition: elog.h:40
#define ereport(elevel,...)
Definition: elog.h:144
struct config_generic gen
Definition: guc_tables.h:228
#define free(a)
Definition: header.h:65
char * reset_val
Definition: guc_tables.h:236
#define Assert(condition)
Definition: c.h:738
#define GUC_CUSTOM_PLACEHOLDER
Definition: guc.h:211
const char * name
Definition: encode.c:555
int errmsg(const char *fmt,...)
Definition: elog.c:824
GucStack * stack
Definition: guc_tables.h:162
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:6941
static bool add_guc_variable(struct config_generic *var, int elevel)
Definition: guc.c:5155
GucContext reset_scontext
Definition: guc_tables.h:161

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

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

Referenced by _PG_init().

8802 {
8803  struct config_bool *var;
8804 
8805  var = (struct config_bool *)
8806  init_custom_variable(name, short_desc, long_desc, context, flags,
8807  PGC_BOOL, sizeof(struct config_bool));
8808  var->variable = valueAddr;
8809  var->boot_val = bootValue;
8810  var->reset_val = bootValue;
8811  var->check_hook = check_hook;
8812  var->assign_hook = assign_hook;
8813  var->show_hook = show_hook;
8814  define_custom_variable(&var->gen);
8815 }
bool * variable
Definition: guc_tables.h:184
GucBoolAssignHook assign_hook
Definition: guc_tables.h:187
bool boot_val
Definition: guc_tables.h:185
struct config_generic gen
Definition: guc_tables.h:182
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:8551
GucBoolCheckHook check_hook
Definition: guc_tables.h:186
GucShowHook show_hook
Definition: guc_tables.h:188
const char * name
Definition: encode.c:555
bool reset_val
Definition: guc_tables.h:190
static void define_custom_variable(struct config_generic *variable)
Definition: guc.c:8611

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

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

Referenced by _PG_init().

8914 {
8915  struct config_enum *var;
8916 
8917  var = (struct config_enum *)
8918  init_custom_variable(name, short_desc, long_desc, context, flags,
8919  PGC_ENUM, sizeof(struct config_enum));
8920  var->variable = valueAddr;
8921  var->boot_val = bootValue;
8922  var->reset_val = bootValue;
8923  var->options = options;
8924  var->check_hook = check_hook;
8925  var->assign_hook = assign_hook;
8926  var->show_hook = show_hook;
8927  define_custom_variable(&var->gen);
8928 }
GucEnumCheckHook check_hook
Definition: guc_tables.h:247
GucEnumAssignHook assign_hook
Definition: guc_tables.h:248
int * variable
Definition: guc_tables.h:244
const struct config_enum_entry * options
Definition: guc_tables.h:246
static char ** options
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:8551
GucShowHook show_hook
Definition: guc_tables.h:249
struct config_generic gen
Definition: guc_tables.h:242
const char * name
Definition: encode.c:555
static void define_custom_variable(struct config_generic *variable)
Definition: guc.c:8611

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

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, PGC_INT, config_int::reset_val, config_int::show_hook, and config_int::variable.

Referenced by _PG_init().

8830 {
8831  struct config_int *var;
8832 
8833  var = (struct config_int *)
8834  init_custom_variable(name, short_desc, long_desc, context, flags,
8835  PGC_INT, sizeof(struct config_int));
8836  var->variable = valueAddr;
8837  var->boot_val = bootValue;
8838  var->reset_val = bootValue;
8839  var->min = minValue;
8840  var->max = maxValue;
8841  var->check_hook = check_hook;
8842  var->assign_hook = assign_hook;
8843  var->show_hook = show_hook;
8844  define_custom_variable(&var->gen);
8845 }
int boot_val
Definition: guc_tables.h:199
GucIntAssignHook assign_hook
Definition: guc_tables.h:203
GucIntCheckHook check_hook
Definition: guc_tables.h:202
GucShowHook show_hook
Definition: guc_tables.h:204
int * variable
Definition: guc_tables.h:198
struct config_generic gen
Definition: guc_tables.h:196
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:8551
const char * name
Definition: encode.c:555
static void define_custom_variable(struct config_generic *variable)
Definition: guc.c:8611
int reset_val
Definition: guc_tables.h:206

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

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, PGC_REAL, config_real::reset_val, config_real::show_hook, and config_real::variable.

Referenced by _PG_init().

8860 {
8861  struct config_real *var;
8862 
8863  var = (struct config_real *)
8864  init_custom_variable(name, short_desc, long_desc, context, flags,
8865  PGC_REAL, sizeof(struct config_real));
8866  var->variable = valueAddr;
8867  var->boot_val = bootValue;
8868  var->reset_val = bootValue;
8869  var->min = minValue;
8870  var->max = maxValue;
8871  var->check_hook = check_hook;
8872  var->assign_hook = assign_hook;
8873  var->show_hook = show_hook;
8874  define_custom_variable(&var->gen);
8875 }
GucRealAssignHook assign_hook
Definition: guc_tables.h:219
double reset_val
Definition: guc_tables.h:222
GucRealCheckHook check_hook
Definition: guc_tables.h:218
GucShowHook show_hook
Definition: guc_tables.h:220
double * variable
Definition: guc_tables.h:214
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:8551
double max
Definition: guc_tables.h:217
double boot_val
Definition: guc_tables.h:215
const char * name
Definition: encode.c:555
double min
Definition: guc_tables.h:216
static void define_custom_variable(struct config_generic *variable)
Definition: guc.c:8611
struct config_generic gen
Definition: guc_tables.h:212

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

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

Referenced by _PG_init().

8888 {
8889  struct config_string *var;
8890 
8891  var = (struct config_string *)
8892  init_custom_variable(name, short_desc, long_desc, context, flags,
8893  PGC_STRING, sizeof(struct config_string));
8894  var->variable = valueAddr;
8895  var->boot_val = bootValue;
8896  var->check_hook = check_hook;
8897  var->assign_hook = assign_hook;
8898  var->show_hook = show_hook;
8899  define_custom_variable(&var->gen);
8900 }
char ** variable
Definition: guc_tables.h:230
GucStringCheckHook check_hook
Definition: guc_tables.h:232
const char * boot_val
Definition: guc_tables.h:231
GucShowHook show_hook
Definition: guc_tables.h:234
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:8551
struct config_generic gen
Definition: guc_tables.h:228
GucStringAssignHook assign_hook
Definition: guc_tables.h:233
const char * name
Definition: encode.c:555
static void define_custom_variable(struct config_generic *variable)
Definition: guc.c:8611

◆ discard_stack_value()

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

Definition at line 5032 of file guc.c.

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

Referenced by AtEOXact_GUC(), and push_old_value().

5033 {
5034  switch (gconf->vartype)
5035  {
5036  case PGC_BOOL:
5037  case PGC_INT:
5038  case PGC_REAL:
5039  case PGC_ENUM:
5040  /* no need to do anything */
5041  break;
5042  case PGC_STRING:
5043  set_string_field((struct config_string *) gconf,
5044  &(val->val.stringval),
5045  NULL);
5046  break;
5047  }
5048  set_extra_field(gconf, &(val->extra), NULL);
5049 }
union config_var_val val
Definition: guc_tables.h:46
static void set_extra_field(struct config_generic *gconf, void **field, void *newval)
Definition: guc.c:4978
static void set_string_field(struct config_string *conf, char **field, char *newval)
Definition: guc.c:4917
enum config_type vartype
Definition: guc_tables.h:156
char * stringval
Definition: guc_tables.h:36

◆ do_serialize()

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

Definition at line 10248 of file guc.c.

References elog, ERROR, and vsnprintf.

Referenced by serialize_variable().

10249 {
10250  va_list vargs;
10251  int n;
10252 
10253  if (*maxbytes <= 0)
10254  elog(ERROR, "not enough space to serialize GUC state");
10255 
10256  va_start(vargs, fmt);
10257  n = vsnprintf(*destptr, *maxbytes, fmt, vargs);
10258  va_end(vargs);
10259 
10260  if (n < 0)
10261  {
10262  /* Shouldn't happen. Better show errno description. */
10263  elog(ERROR, "vsnprintf failed: %m with format string \"%s\"", fmt);
10264  }
10265  if (n >= *maxbytes)
10266  {
10267  /* This shouldn't happen either, really. */
10268  elog(ERROR, "not enough space to serialize GUC state");
10269  }
10270 
10271  /* Shift the destptr ahead of the null terminator */
10272  *destptr += n + 1;
10273  *maxbytes -= n + 1;
10274 }
#define ERROR
Definition: elog.h:43
#define vsnprintf
Definition: port.h:192
#define elog(elevel,...)
Definition: elog.h:214

◆ do_serialize_binary()

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

Definition at line 10278 of file guc.c.

References elog, and ERROR.

Referenced by serialize_variable().

10279 {
10280  if (valsize > *maxbytes)
10281  elog(ERROR, "not enough space to serialize GUC state");
10282 
10283  memcpy(*destptr, val, valsize);
10284  *destptr += valsize;
10285  *maxbytes -= valsize;
10286 }
#define ERROR
Definition: elog.h:43
#define elog(elevel,...)
Definition: elog.h:214
long val
Definition: informix.c:664

◆ EmitWarningsOnPlaceholders()

void EmitWarningsOnPlaceholders ( const char *  className)

Definition at line 8931 of file guc.c.

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

Referenced by _PG_init().

8932 {
8933  int classLen = strlen(className);
8934  int i;
8935 
8936  for (i = 0; i < num_guc_variables; i++)
8937  {
8938  struct config_generic *var = guc_variables[i];
8939 
8940  if ((var->flags & GUC_CUSTOM_PLACEHOLDER) != 0 &&
8941  strncmp(className, var->name, classLen) == 0 &&
8942  var->name[classLen] == GUC_QUALIFIER_SEPARATOR)
8943  {
8944  ereport(WARNING,
8945  (errcode(ERRCODE_UNDEFINED_OBJECT),
8946  errmsg("unrecognized configuration parameter \"%s\"",
8947  var->name)));
8948  }
8949  }
8950 }
const char * name
Definition: guc_tables.h:149
int errcode(int sqlerrcode)
Definition: elog.c:610
#define GUC_QUALIFIER_SEPARATOR
Definition: guc.h:199
static int num_guc_variables
Definition: guc.c:4807
static struct config_generic ** guc_variables
Definition: guc.c:4804
#define WARNING
Definition: elog.h:40
#define ereport(elevel,...)
Definition: elog.h:144
#define GUC_CUSTOM_PLACEHOLDER
Definition: guc.h:211
int errmsg(const char *fmt,...)
Definition: elog.c:824
int i

◆ estimate_variable_size()

static Size estimate_variable_size ( struct config_generic gconf)
static

Definition at line 10127 of file guc.c.

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

10128 {
10129  Size size;
10130  Size valsize = 0;
10131 
10132  if (can_skip_gucvar(gconf))
10133  return 0;
10134 
10135  /* Name, plus trailing zero byte. */
10136  size = strlen(gconf->name) + 1;
10137 
10138  /* Get the maximum display length of the GUC value. */
10139  switch (gconf->vartype)
10140  {
10141  case PGC_BOOL:
10142  {
10143  valsize = 5; /* max(strlen('true'), strlen('false')) */
10144  }
10145  break;
10146 
10147  case PGC_INT:
10148  {
10149  struct config_int *conf = (struct config_int *) gconf;
10150 
10151  /*
10152  * Instead of getting the exact display length, use max
10153  * length. Also reduce the max length for typical ranges of
10154  * small values. Maximum value is 2147483647, i.e. 10 chars.
10155  * Include one byte for sign.
10156  */
10157  if (Abs(*conf->variable) < 1000)
10158  valsize = 3 + 1;
10159  else
10160  valsize = 10 + 1;
10161  }
10162  break;
10163 
10164  case PGC_REAL:
10165  {
10166  /*
10167  * We are going to print it with %e with REALTYPE_PRECISION
10168  * fractional digits. Account for sign, leading digit,
10169  * decimal point, and exponent with up to 3 digits. E.g.
10170  * -3.99329042340000021e+110
10171  */
10172  valsize = 1 + 1 + 1 + REALTYPE_PRECISION + 5;
10173  }
10174  break;
10175 
10176  case PGC_STRING:
10177  {
10178  struct config_string *conf = (struct config_string *) gconf;
10179 
10180  /*
10181  * If the value is NULL, we transmit it as an empty string.
10182  * Although this is not physically the same value, GUC
10183  * generally treats a NULL the same as empty string.
10184  */
10185  if (*conf->variable)
10186  valsize = strlen(*conf->variable);
10187  else
10188  valsize = 0;
10189  }
10190  break;
10191 
10192  case PGC_ENUM:
10193  {
10194  struct config_enum *conf = (struct config_enum *) gconf;
10195 
10196  valsize = strlen(config_enum_lookup_by_value(conf, *conf->variable));
10197  }
10198  break;
10199  }
10200 
10201  /* Allow space for terminating zero-byte for value */
10202  size = add_size(size, valsize + 1);
10203 
10204  if (gconf->sourcefile)
10205  size = add_size(size, strlen(gconf->sourcefile));
10206 
10207  /* Allow space for terminating zero-byte for sourcefile */
10208  size = add_size(size, 1);
10209 
10210  /* Include line whenever file is nonempty. */
10211  if (gconf->sourcefile && gconf->sourcefile[0])
10212  size = add_size(size, sizeof(gconf->sourceline));
10213 
10214  size = add_size(size, sizeof(gconf->source));
10215  size = add_size(size, sizeof(gconf->scontext));
10216 
10217  return size;
10218 }
GucSource source
Definition: guc_tables.h:158
char ** variable
Definition: guc_tables.h:230
const char * name
Definition: guc_tables.h:149
const char * config_enum_lookup_by_value(struct config_enum *record, int val)
Definition: guc.c:6637
GucContext scontext
Definition: guc_tables.h:160
#define Abs(x)
Definition: c.h:926
int * variable
Definition: guc_tables.h:198
int * variable
Definition: guc_tables.h:244
char * sourcefile
Definition: guc_tables.h:164
static bool can_skip_gucvar(struct config_generic *gconf)
Definition: guc.c:10113
#define REALTYPE_PRECISION
Definition: guc.c:119
enum config_type vartype
Definition: guc_tables.h:156
Size add_size(Size s1, Size s2)
Definition: shmem.c:498
size_t Size
Definition: c.h:466

◆ EstimateGUCStateSpace()

Size EstimateGUCStateSpace ( void  )

Definition at line 10225 of file guc.c.

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

Referenced by InitializeParallelDSM().

10226 {
10227  Size size;
10228  int i;
10229 
10230  /* Add space reqd for saving the data size of the guc state */
10231  size = sizeof(Size);
10232 
10233  /* Add up the space needed for each GUC variable */
10234  for (i = 0; i < num_guc_variables; i++)
10235  size = add_size(size,
10237 
10238  return size;
10239 }
static int num_guc_variables
Definition: guc.c:4807
static struct config_generic ** guc_variables
Definition: guc.c:4804
Size add_size(Size s1, Size s2)
Definition: shmem.c:498
size_t Size
Definition: c.h:466
static Size estimate_variable_size(struct config_generic *gconf)
Definition: guc.c:10127
int i

◆ ExecSetVariableStmt()

void ExecSetVariableStmt ( VariableSetStmt stmt,
bool  isTopLevel 
)

Definition at line 8339 of file guc.c.

References generate_unaccent_rules::action, DefElem::arg, VariableSetStmt::args, Assert, 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, nodeTag, PGC_S_SESSION, PGC_SUSET, PGC_USERSET, ResetAllOptions(), set_config_option(), SetPGVariable(), strVal, superuser(), T_String, 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().

8340 {
8342 
8343  /*
8344  * Workers synchronize these parameters at the start of the parallel
8345  * operation; then, we block SET during the operation.
8346  */
8347  if (IsInParallelMode())
8348  ereport(ERROR,
8349  (errcode(ERRCODE_INVALID_TRANSACTION_STATE),
8350  errmsg("cannot set parameters during a parallel operation")));
8351 
8352  switch (stmt->kind)
8353  {
8354  case VAR_SET_VALUE:
8355  case VAR_SET_CURRENT:
8356  if (stmt->is_local)
8357  WarnNoTransactionBlock(isTopLevel, "SET LOCAL");
8358  (void) set_config_option(stmt->name,
8359  ExtractSetVariableArgs(stmt),
8361  PGC_S_SESSION,
8362  action, true, 0, false);
8363  break;
8364  case VAR_SET_MULTI:
8365 
8366  /*
8367  * Special-case SQL syntaxes. The TRANSACTION and SESSION
8368  * CHARACTERISTICS cases effectively set more than one variable
8369  * per statement. TRANSACTION SNAPSHOT only takes one argument,
8370  * but we put it here anyway since it's a special case and not
8371  * related to any GUC variable.
8372  */
8373  if (strcmp(stmt->name, "TRANSACTION") == 0)
8374  {
8375  ListCell *head;
8376 
8377  WarnNoTransactionBlock(isTopLevel, "SET TRANSACTION");
8378 
8379  foreach(head, stmt->args)
8380  {
8381  DefElem *item = (DefElem *) lfirst(head);
8382 
8383  if (strcmp(item->defname, "transaction_isolation") == 0)
8384  SetPGVariable("transaction_isolation",
8385  list_make1(item->arg), stmt->is_local);
8386  else if (strcmp(item->defname, "transaction_read_only") == 0)
8387  SetPGVariable("transaction_read_only",
8388  list_make1(item->arg), stmt->is_local);
8389  else if (strcmp(item->defname, "transaction_deferrable") == 0)
8390  SetPGVariable("transaction_deferrable",
8391  list_make1(item->arg), stmt->is_local);
8392  else
8393  elog(ERROR, "unexpected SET TRANSACTION element: %s",
8394  item->defname);
8395  }
8396  }
8397  else if (strcmp(stmt->name, "SESSION CHARACTERISTICS") == 0)
8398  {
8399  ListCell *head;
8400 
8401  foreach(head, stmt->args)
8402  {
8403  DefElem *item = (DefElem *) lfirst(head);
8404 
8405  if (strcmp(item->defname, "transaction_isolation") == 0)
8406  SetPGVariable("default_transaction_isolation",
8407  list_make1(item->arg), stmt->is_local);
8408  else if (strcmp(item->defname, "transaction_read_only") == 0)
8409  SetPGVariable("default_transaction_read_only",
8410  list_make1(item->arg), stmt->is_local);
8411  else if (strcmp(item->defname, "transaction_deferrable") == 0)
8412  SetPGVariable("default_transaction_deferrable",
8413  list_make1(item->arg), stmt->is_local);
8414  else
8415  elog(ERROR, "unexpected SET SESSION element: %s",
8416  item->defname);
8417  }
8418  }
8419  else if (strcmp(stmt->name, "TRANSACTION SNAPSHOT") == 0)
8420  {
8421  A_Const *con = linitial_node(A_Const, stmt->args);
8422 
8423  if (stmt->is_local)
8424  ereport(ERROR,
8425  (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
8426  errmsg("SET LOCAL TRANSACTION SNAPSHOT is not implemented")));
8427 
8428  WarnNoTransactionBlock(isTopLevel, "SET TRANSACTION");
8429  Assert(nodeTag(&con->val) == T_String);
8430  ImportSnapshot(strVal(&con->val));
8431  }
8432  else
8433  elog(ERROR, "unexpected SET MULTI element: %s",
8434  stmt->name);
8435  break;
8436  case VAR_SET_DEFAULT:
8437  if (stmt->is_local)
8438  WarnNoTransactionBlock(isTopLevel, "SET LOCAL");
8439  /* fall through */
8440  case VAR_RESET:
8441  if (strcmp(stmt->name, "transaction_isolation") == 0)
8442  WarnNoTransactionBlock(isTopLevel, "RESET TRANSACTION");
8443 
8444  (void) set_config_option(stmt->name,
8445  NULL,
8447  PGC_S_SESSION,
8448  action, true, 0, false);
8449  break;
8450  case VAR_RESET_ALL:
8451  ResetAllOptions();
8452  break;
8453  }
8454 }
void ImportSnapshot(const char *idstr)
Definition: snapmgr.c:1462
VariableSetKind kind
Definition: parsenodes.h:2042
void WarnNoTransactionBlock(bool isTopLevel, const char *stmtType)
Definition: xact.c:3410
#define strVal(v)
Definition: value.h:54
int errcode(int sqlerrcode)
Definition: elog.c:610
bool superuser(void)
Definition: superuser.c:46
#define linitial_node(type, l)
Definition: pg_list.h:198
GucAction
Definition: guc.h:191
#define list_make1(x1)
Definition: pg_list.h:227
bool IsInParallelMode(void)
Definition: xact.c:997
#define ERROR
Definition: elog.h:43
Definition: guc.h:75
void ResetAllOptions(void)
Definition: guc.c:5733
Node * arg
Definition: parsenodes.h:733
#define ereport(elevel,...)
Definition: elog.h:144
#define Assert(condition)
Definition: c.h:738
#define lfirst(lc)
Definition: pg_list.h:190
#define nodeTag(nodeptr)
Definition: nodes.h:534
int errmsg(const char *fmt,...)
Definition: elog.c:824
#define elog(elevel,...)
Definition: elog.h:214
char * defname
Definition: parsenodes.h:732
char * ExtractSetVariableArgs(VariableSetStmt *stmt)
Definition: guc.c:8463
Value val
Definition: parsenodes.h:289
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:6941
void SetPGVariable(const char *name, List *args, bool is_local)
Definition: guc.c:8483

◆ extra_field_used()

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

Definition at line 4933 of file guc.c.

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

4934 {
4935  GucStack *stack;
4936 
4937  if (extra == gconf->extra)
4938  return true;
4939  switch (gconf->vartype)
4940  {
4941  case PGC_BOOL:
4942  if (extra == ((struct config_bool *) gconf)->reset_extra)
4943  return true;
4944  break;
4945  case PGC_INT:
4946  if (extra == ((struct config_int *) gconf)->reset_extra)
4947  return true;
4948  break;
4949  case PGC_REAL