PostgreSQL Source Code  git master
guc.c File Reference
#include "postgres.h"
#include <ctype.h>
#include <float.h>
#include <math.h>
#include <limits.h>
#include <sys/mman.h>
#include <sys/stat.h>
#include <unistd.h>
#include "access/commit_ts.h"
#include "access/gin.h"
#include "access/rmgr.h"
#include "access/tableam.h"
#include "access/toast_compression.h"
#include "access/transam.h"
#include "access/twophase.h"
#include "access/xact.h"
#include "access/xlog_internal.h"
#include "catalog/namespace.h"
#include "catalog/pg_authid.h"
#include "catalog/storage.h"
#include "commands/async.h"
#include "commands/prepare.h"
#include "commands/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/backend_status.h"
#include "utils/builtins.h"
#include "utils/bytea.h"
#include "utils/guc_tables.h"
#include "utils/memutils.h"
#include "utils/pg_locale.h"
#include "utils/pg_lsn.h"
#include "utils/plancache.h"
#include "utils/portal.h"
#include "utils/ps_status.h"
#include "utils/queryjumble.h"
#include "utils/rls.h"
#include "utils/snapmgr.h"
#include "utils/tzparser.h"
#include "utils/inval.h"
#include "utils/varlena.h"
#include "utils/xml.h"
#include "guc-file.c"
Include dependency graph for guc.c:

Go to the source code of this file.

Data Structures

struct  unit_conversion
 

Macros

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

Functions

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

Variables

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

Macro Definition Documentation

◆ CONFIG_FILENAME

#define CONFIG_FILENAME   "postgresql.conf"

Definition at line 116 of file guc.c.

Referenced by SelectConfigFiles().

◆ HBA_FILENAME

#define HBA_FILENAME   "pg_hba.conf"

Definition at line 117 of file guc.c.

Referenced by SelectConfigFiles().

◆ IDENT_FILENAME

#define IDENT_FILENAME   "pg_ident.conf"

Definition at line 118 of file guc.c.

Referenced by SelectConfigFiles().

◆ MAX_UNIT_LEN

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

Definition at line 858 of file guc.c.

Referenced by convert_to_base_unit().

◆ newval [1/5]

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

Referenced by show_all_settings().

◆ PG_KRB_SRVTAB

#define PG_KRB_SRVTAB   ""

Definition at line 113 of file guc.c.

◆ REALTYPE_PRECISION

#define REALTYPE_PRECISION   17

Definition at line 129 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 10127 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, 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().

10128 {
10129  char buffer[256];
10130  const char *val;
10131 
10132  switch (record->vartype)
10133  {
10134  case PGC_BOOL:
10135  {
10136  struct config_bool *conf = (struct config_bool *) record;
10137 
10138  if (conf->show_hook)
10139  val = conf->show_hook();
10140  else
10141  val = *conf->variable ? "on" : "off";
10142  }
10143  break;
10144 
10145  case PGC_INT:
10146  {
10147  struct config_int *conf = (struct config_int *) record;
10148 
10149  if (conf->show_hook)
10150  val = conf->show_hook();
10151  else
10152  {
10153  /*
10154  * Use int64 arithmetic to avoid overflows in units
10155  * conversion.
10156  */
10157  int64 result = *conf->variable;
10158  const char *unit;
10159 
10160  if (use_units && result > 0 && (record->flags & GUC_UNIT))
10162  record->flags & GUC_UNIT,
10163  &result, &unit);
10164  else
10165  unit = "";
10166 
10167  snprintf(buffer, sizeof(buffer), INT64_FORMAT "%s",
10168  result, unit);
10169  val = buffer;
10170  }
10171  }
10172  break;
10173 
10174  case PGC_REAL:
10175  {
10176  struct config_real *conf = (struct config_real *) record;
10177 
10178  if (conf->show_hook)
10179  val = conf->show_hook();
10180  else
10181  {
10182  double result = *conf->variable;
10183  const char *unit;
10184 
10185  if (use_units && result > 0 && (record->flags & GUC_UNIT))
10187  record->flags & GUC_UNIT,
10188  &result, &unit);
10189  else
10190  unit = "";
10191 
10192  snprintf(buffer, sizeof(buffer), "%g%s",
10193  result, unit);
10194  val = buffer;
10195  }
10196  }
10197  break;
10198 
10199  case PGC_STRING:
10200  {
10201  struct config_string *conf = (struct config_string *) record;
10202 
10203  if (conf->show_hook)
10204  val = conf->show_hook();
10205  else if (*conf->variable && **conf->variable)
10206  val = *conf->variable;
10207  else
10208  val = "";
10209  }
10210  break;
10211 
10212  case PGC_ENUM:
10213  {
10214  struct config_enum *conf = (struct config_enum *) record;
10215 
10216  if (conf->show_hook)
10217  val = conf->show_hook();
10218  else
10219  val = config_enum_lookup_by_value(conf, *conf->variable);
10220  }
10221  break;
10222 
10223  default:
10224  /* just to keep compiler quiet */
10225  val = "???";
10226  break;
10227  }
10228 
10229  return pstrdup(val);
10230 }
char ** variable
Definition: guc_tables.h:225
char * pstrdup(const char *in)
Definition: mcxt.c:1299
bool * variable
Definition: guc_tables.h:179
const char * config_enum_lookup_by_value(struct config_enum *record, int val)
Definition: guc.c:7011
#define GUC_UNIT
Definition: guc.h:238
GucShowHook show_hook
Definition: guc_tables.h:199
int * variable
Definition: guc_tables.h:193
int * variable
Definition: guc_tables.h:239
static void convert_real_from_base_unit(double base_value, int base_unit, double *value, const char **unit)
Definition: guc.c:6759
GucShowHook show_hook
Definition: guc_tables.h:229
GucShowHook show_hook
Definition: guc_tables.h:215
double * variable
Definition: guc_tables.h:209
enum config_type vartype
Definition: guc_tables.h:148
GucShowHook show_hook
Definition: guc_tables.h:244
GucShowHook show_hook
Definition: guc_tables.h:183
#define INT64_FORMAT
Definition: c.h:483
static void convert_int_from_base_unit(int64 base_value, int base_unit, int64 *value, const char **unit)
Definition: guc.c:6717
#define snprintf
Definition: port.h:217
long val
Definition: informix.c:664

◆ add_guc_variable()

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

Definition at line 5375 of file guc.c.

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

Referenced by add_placeholder_variable(), and define_custom_variable().

5376 {
5378  {
5379  /*
5380  * Increase the vector by 25%
5381  */
5382  int size_vars = size_guc_variables + size_guc_variables / 4;
5383  struct config_generic **guc_vars;
5384 
5385  if (size_vars == 0)
5386  {
5387  size_vars = 100;
5388  guc_vars = (struct config_generic **)
5389  guc_malloc(elevel, size_vars * sizeof(struct config_generic *));
5390  }
5391  else
5392  {
5393  guc_vars = (struct config_generic **)
5394  guc_realloc(elevel, guc_variables, size_vars * sizeof(struct config_generic *));
5395  }
5396 
5397  if (guc_vars == NULL)
5398  return false; /* out of memory */
5399 
5400  guc_variables = guc_vars;
5401  size_guc_variables = size_vars;
5402  }
5405  sizeof(struct config_generic *), guc_var_compare);
5406  return true;
5407 }
static int guc_var_compare(const void *a, const void *b)
Definition: guc.c:5580
static int num_guc_variables
Definition: guc.c:5025
static void * guc_realloc(int elevel, void *old, size_t size)
Definition: guc.c:5081
static struct config_generic ** guc_variables
Definition: guc.c:5022
static int size_guc_variables
Definition: guc.c:5028
static int elevel
Definition: vacuumlazy.c:401
#define qsort(a, b, c, d)
Definition: port.h:505
static void * guc_malloc(int elevel, size_t size)
Definition: guc.c:5065

◆ add_placeholder_variable()

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

Definition at line 5453 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().

5454 {
5455  size_t sz = sizeof(struct config_string) + sizeof(char *);
5456  struct config_string *var;
5457  struct config_generic *gen;
5458 
5459  var = (struct config_string *) guc_malloc(elevel, sz);
5460  if (var == NULL)
5461  return NULL;
5462  memset(var, 0, sz);
5463  gen = &var->gen;
5464 
5465  gen->name = guc_strdup(elevel, name);
5466  if (gen->name == NULL)
5467  {
5468  free(var);
5469  return NULL;
5470  }
5471 
5472  gen->context = PGC_USERSET;
5473  gen->group = CUSTOM_OPTIONS;
5474  gen->short_desc = "GUC placeholder variable";
5476  gen->vartype = PGC_STRING;
5477 
5478  /*
5479  * The char* is allocated at the end of the struct since we have no
5480  * 'static' place to point to. Note that the current value, as well as
5481  * the boot and reset values, start out NULL.
5482  */
5483  var->variable = (char **) (var + 1);
5484 
5485  if (!add_guc_variable((struct config_generic *) var, elevel))
5486  {
5487  free(unconstify(char *, gen->name));
5488  free(var);
5489  return NULL;
5490  }
5491 
5492  return gen;
5493 }
char ** variable
Definition: guc_tables.h:225
const char * name
Definition: guc_tables.h:141
const char * short_desc
Definition: guc_tables.h:144
static char * guc_strdup(int elevel, const char *src)
Definition: guc.c:5097
#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:148
#define unconstify(underlying_type, expr)
Definition: c.h:1243
static int elevel
Definition: vacuumlazy.c:401
struct config_generic gen
Definition: guc_tables.h:223
#define free(a)
Definition: header.h:65
#define GUC_CUSTOM_PLACEHOLDER
Definition: guc.h:211
const char * name
Definition: encode.c:561
enum config_group group
Definition: guc_tables.h:143
static void * guc_malloc(int elevel, size_t size)
Definition: guc.c:5065
GucContext context
Definition: guc_tables.h:142
static bool add_guc_variable(struct config_generic *var, int elevel)
Definition: guc.c:5375

◆ AlterSystemSetConfigFile()

void AlterSystemSetConfigFile ( AlterSystemStmt altersysstmt)

Definition at line 8512 of file guc.c.

References AllocateFile(), Assert, BasicOpenFile(), close, config_generic::context, durable_rename(), elog, ereport, errcode(), errcode_for_file_access(), errmsg(), ERROR, ExtractSetVariableArgs(), find_option(), config_generic::flags, free, FreeConfigVariables(), FreeFile(), GUC_DISALLOW_IN_AUTO_FILE, GUC_DISALLOW_IN_FILE, infile(), VariableSetStmt::kind, LOG, LW_EXCLUSIVE, LWLockAcquire(), LWLockRelease(), MAXPGPATH, name, VariableSetStmt::name, 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().

8513 {
8514  char *name;
8515  char *value;
8516  bool resetall = false;
8517  ConfigVariable *head = NULL;
8518  ConfigVariable *tail = NULL;
8519  volatile int Tmpfd;
8520  char AutoConfFileName[MAXPGPATH];
8521  char AutoConfTmpFileName[MAXPGPATH];
8522 
8523  if (!superuser())
8524  ereport(ERROR,
8525  (errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
8526  errmsg("must be superuser to execute ALTER SYSTEM command")));
8527 
8528  /*
8529  * Extract statement arguments
8530  */
8531  name = altersysstmt->setstmt->name;
8532 
8533  switch (altersysstmt->setstmt->kind)
8534  {
8535  case VAR_SET_VALUE:
8536  value = ExtractSetVariableArgs(altersysstmt->setstmt);
8537  break;
8538 
8539  case VAR_SET_DEFAULT:
8540  case VAR_RESET:
8541  value = NULL;
8542  break;
8543 
8544  case VAR_RESET_ALL:
8545  value = NULL;
8546  resetall = true;
8547  break;
8548 
8549  default:
8550  elog(ERROR, "unrecognized alter system stmt type: %d",
8551  altersysstmt->setstmt->kind);
8552  break;
8553  }
8554 
8555  /*
8556  * Unless it's RESET_ALL, validate the target variable and value
8557  */
8558  if (!resetall)
8559  {
8560  struct config_generic *record;
8561 
8562  record = find_option(name, false, false, ERROR);
8563  Assert(record != NULL);
8564 
8565  /*
8566  * Don't allow parameters that can't be set in configuration files to
8567  * be set in PG_AUTOCONF_FILENAME file.
8568  */
8569  if ((record->context == PGC_INTERNAL) ||
8570  (record->flags & GUC_DISALLOW_IN_FILE) ||
8571  (record->flags & GUC_DISALLOW_IN_AUTO_FILE))
8572  ereport(ERROR,
8573  (errcode(ERRCODE_CANT_CHANGE_RUNTIME_PARAM),
8574  errmsg("parameter \"%s\" cannot be changed",
8575  name)));
8576 
8577  /*
8578  * If a value is specified, verify that it's sane.
8579  */
8580  if (value)
8581  {
8582  union config_var_val newval;
8583  void *newextra = NULL;
8584 
8585  /* Check that it's acceptable for the indicated parameter */
8586  if (!parse_and_validate_value(record, name, value,
8587  PGC_S_FILE, ERROR,
8588  &newval, &newextra))
8589  ereport(ERROR,
8590  (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
8591  errmsg("invalid value for parameter \"%s\": \"%s\"",
8592  name, value)));
8593 
8594  if (record->vartype == PGC_STRING && newval.stringval != NULL)
8595  free(newval.stringval);
8596  if (newextra)
8597  free(newextra);
8598 
8599  /*
8600  * We must also reject values containing newlines, because the
8601  * grammar for config files doesn't support embedded newlines in
8602  * string literals.
8603  */
8604  if (strchr(value, '\n'))
8605  ereport(ERROR,
8606  (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
8607  errmsg("parameter value for ALTER SYSTEM must not contain a newline")));
8608  }
8609  }
8610 
8611  /*
8612  * PG_AUTOCONF_FILENAME and its corresponding temporary file are always in
8613  * the data directory, so we can reference them by simple relative paths.
8614  */
8615  snprintf(AutoConfFileName, sizeof(AutoConfFileName), "%s",
8617  snprintf(AutoConfTmpFileName, sizeof(AutoConfTmpFileName), "%s.%s",
8618  AutoConfFileName,
8619  "tmp");
8620 
8621  /*
8622  * Only one backend is allowed to operate on PG_AUTOCONF_FILENAME at a
8623  * time. Use AutoFileLock to ensure that. We must hold the lock while
8624  * reading the old file contents.
8625  */
8626  LWLockAcquire(AutoFileLock, LW_EXCLUSIVE);
8627 
8628  /*
8629  * If we're going to reset everything, then no need to open or parse the
8630  * old file. We'll just write out an empty list.
8631  */
8632  if (!resetall)
8633  {
8634  struct stat st;
8635 
8636  if (stat(AutoConfFileName, &st) == 0)
8637  {
8638  /* open old file PG_AUTOCONF_FILENAME */
8639  FILE *infile;
8640 
8641  infile = AllocateFile(AutoConfFileName, "r");
8642  if (infile == NULL)
8643  ereport(ERROR,
8645  errmsg("could not open file \"%s\": %m",
8646  AutoConfFileName)));
8647 
8648  /* parse it */
8649  if (!ParseConfigFp(infile, AutoConfFileName, 0, LOG, &head, &tail))
8650  ereport(ERROR,
8651  (errcode(ERRCODE_CONFIG_FILE_ERROR),
8652  errmsg("could not parse contents of file \"%s\"",
8653  AutoConfFileName)));
8654 
8655  FreeFile(infile);
8656  }
8657 
8658  /*
8659  * Now, replace any existing entry with the new value, or add it if
8660  * not present.
8661  */
8662  replace_auto_config_value(&head, &tail, name, value);
8663  }
8664 
8665  /*
8666  * To ensure crash safety, first write the new file data to a temp file,
8667  * then atomically rename it into place.
8668  *
8669  * If there is a temp file left over due to a previous crash, it's okay to
8670  * truncate and reuse it.
8671  */
8672  Tmpfd = BasicOpenFile(AutoConfTmpFileName,
8673  O_CREAT | O_RDWR | O_TRUNC);
8674  if (Tmpfd < 0)
8675  ereport(ERROR,
8677  errmsg("could not open file \"%s\": %m",
8678  AutoConfTmpFileName)));
8679 
8680  /*
8681  * Use a TRY block to clean up the file if we fail. Since we need a TRY
8682  * block anyway, OK to use BasicOpenFile rather than OpenTransientFile.
8683  */
8684  PG_TRY();
8685  {
8686  /* Write and sync the new contents to the temporary file */
8687  write_auto_conf_file(Tmpfd, AutoConfTmpFileName, head);
8688 
8689  /* Close before renaming; may be required on some platforms */
8690  close(Tmpfd);
8691  Tmpfd = -1;
8692 
8693  /*
8694  * As the rename is atomic operation, if any problem occurs after this
8695  * at worst it can lose the parameters set by last ALTER SYSTEM
8696  * command.
8697  */
8698  durable_rename(AutoConfTmpFileName, AutoConfFileName, ERROR);
8699  }
8700  PG_CATCH();
8701  {
8702  /* Close file first, else unlink might fail on some platforms */
8703  if (Tmpfd >= 0)
8704  close(Tmpfd);
8705 
8706  /* Unlink, but ignore any error */
8707  (void) unlink(AutoConfTmpFileName);
8708 
8709  PG_RE_THROW();
8710  }
8711  PG_END_TRY();
8712 
8713  FreeConfigVariables(head);
8714 
8715  LWLockRelease(AutoFileLock);
8716 }
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:7118
VariableSetKind kind
Definition: parsenodes.h:2153
int errcode(int sqlerrcode)
Definition: elog.c:698
bool superuser(void)
Definition: superuser.c:46
#define LOG
Definition: elog.h:26
void LWLockRelease(LWLock *lock)
Definition: lwlock.c:1803
#define ERROR
Definition: elog.h:46
#define MAXPGPATH
VariableSetStmt * setstmt
Definition: parsenodes.h:3332
int errcode_for_file_access(void)
Definition: elog.c:721
FILE * AllocateFile(const char *name, const char *mode)
Definition: fd.c:2459
int durable_rename(const char *oldfile, const char *newfile, int elevel)
Definition: fd.c:697
static struct config_generic * find_option(const char *name, bool create_placeholders, bool skip_errors, int elevel)
Definition: guc.c:5511
enum config_type vartype
Definition: guc_tables.h:148
#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:8374
static struct @143 value
#define ereport(elevel,...)
Definition: elog.h:157
static void infile(const char *filename)
Definition: zic.c:1241
#define free(a)
Definition: header.h:65
#define PG_CATCH()
Definition: elog.h:323
#define Assert(condition)
Definition: c.h:804
#define newval
#define PG_AUTOCONF_FILENAME
Definition: guc.h:34
bool LWLockAcquire(LWLock *lock, LWLockMode mode)
Definition: lwlock.c:1199
#define PG_RE_THROW()
Definition: elog.h:354
const char * name
Definition: encode.c:561
#define GUC_DISALLOW_IN_AUTO_FILE
Definition: guc.h:215
int BasicOpenFile(const char *fileName, int fileFlags)
Definition: fd.c:1069
int FreeFile(FILE *file)
Definition: fd.c:2658
int errmsg(const char *fmt,...)
Definition: elog.c:909
bool ParseConfigFp(FILE *fp, const char *config_file, int depth, int elevel, ConfigVariable **head_p, ConfigVariable **tail_p)
#define elog(elevel,...)
Definition: elog.h:232
static void replace_auto_config_value(ConfigVariable **head_p, ConfigVariable **tail_p, const char *name, const char *value)
Definition: guc.c:8442
void FreeConfigVariables(ConfigVariable *list)
#define close(a)
Definition: win32.h:12
#define PG_TRY()
Definition: elog.h:313
char * ExtractSetVariableArgs(VariableSetStmt *stmt)
Definition: guc.c:8845
#define snprintf
Definition: port.h:217
#define PG_END_TRY()
Definition: elog.h:338
#define stat
Definition: win32_port.h:283
GucContext context
Definition: guc_tables.h:142

◆ assign_application_name()

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

Definition at line 12156 of file guc.c.

References pgstat_report_appname().

12157 {
12158  /* Update the pg_stat_activity view */
12160 }
void pgstat_report_appname(const char *appname)
#define newval

◆ assign_backtrace_functions()

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

Definition at line 12275 of file guc.c.

12276 {
12277  backtrace_symbol_list = (char *) extra;
12278 }
char * backtrace_symbol_list
Definition: guc.c:607

◆ assign_log_destination()

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

Definition at line 11745 of file guc.c.

References Log_destination.

11746 {
11747  Log_destination = *((int *) extra);
11748 }
int Log_destination
Definition: elog.c:111

◆ assign_pgstat_temp_directory()

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

Definition at line 12118 of file guc.c.

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

12119 {
12120  /* check_canonical_path already canonicalized newval for us */
12121  char *dname;
12122  char *tname;
12123  char *fname;
12124 
12125  /* directory */
12126  dname = guc_malloc(ERROR, strlen(newval) + 1); /* runtime dir */
12127  sprintf(dname, "%s", newval);
12128 
12129  /* global stats */
12130  tname = guc_malloc(ERROR, strlen(newval) + 12); /* /global.tmp */
12131  sprintf(tname, "%s/global.tmp", newval);
12132  fname = guc_malloc(ERROR, strlen(newval) + 13); /* /global.stat */
12133  sprintf(fname, "%s/global.stat", newval);
12134 
12137  pgstat_stat_directory = dname;
12138  if (pgstat_stat_tmpname)
12140  pgstat_stat_tmpname = tname;
12143  pgstat_stat_filename = fname;
12144 }
#define sprintf
Definition: port.h:219
char * pgstat_stat_filename
Definition: pgstat.c:123
#define ERROR
Definition: elog.h:46
char * pgstat_stat_directory
Definition: pgstat.c:122
#define free(a)
Definition: header.h:65
#define newval
char * pgstat_stat_tmpname
Definition: pgstat.c:124
static void * guc_malloc(int elevel, size_t size)
Definition: guc.c:5065

◆ assign_recovery_target()

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

Definition at line 12354 of file guc.c.

References RECOVERY_TARGET_IMMEDIATE, RECOVERY_TARGET_UNSET, and recoveryTarget.

12355 {
12358  error_multiple_recovery_targets();
12359 
12360  if (newval && strcmp(newval, "") != 0)
12362  else
12364 }
#define newval
RecoveryTargetType recoveryTarget
Definition: xlog.c:275

◆ assign_recovery_target_lsn()

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

Definition at line 12522 of file guc.c.

References RECOVERY_TARGET_LSN, RECOVERY_TARGET_UNSET, recoveryTarget, and recoveryTargetLSN.

12523 {
12526  error_multiple_recovery_targets();
12527 
12528  if (newval && strcmp(newval, "") != 0)
12529  {
12531  recoveryTargetLSN = *((XLogRecPtr *) extra);
12532  }
12533  else
12535 }
XLogRecPtr recoveryTargetLSN
Definition: xlog.c:282
uint64 XLogRecPtr
Definition: xlogdefs.h:21
#define newval
RecoveryTargetType recoveryTarget
Definition: xlog.c:275

◆ assign_recovery_target_name()

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

Definition at line 12486 of file guc.c.

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

12487 {
12490  error_multiple_recovery_targets();
12491 
12492  if (newval && strcmp(newval, "") != 0)
12493  {
12496  }
12497  else
12499 }
const char * recoveryTargetName
Definition: xlog.c:281
#define newval
RecoveryTargetType recoveryTarget
Definition: xlog.c:275

◆ assign_recovery_target_time()

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

Definition at line 12460 of file guc.c.

References RECOVERY_TARGET_TIME, RECOVERY_TARGET_UNSET, and recoveryTarget.

12461 {
12464  error_multiple_recovery_targets();
12465 
12466  if (newval && strcmp(newval, "") != 0)
12468  else
12470 }
#define newval
RecoveryTargetType recoveryTarget
Definition: xlog.c:275

◆ assign_recovery_target_timeline()

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

Definition at line 12311 of file guc.c.

References RECOVERY_TARGET_TIMELINE_NUMERIC, recoveryTargetTimeLineGoal, and recoveryTargetTLIRequested.

12312 {
12315  recoveryTargetTLIRequested = (TimeLineID) strtoul(newval, NULL, 0);
12316  else
12318 }
TimeLineID recoveryTargetTLIRequested
Definition: xlog.c:332
uint32 TimeLineID
Definition: xlogdefs.h:59
RecoveryTargetTimeLineGoal
Definition: xlog.h:51
RecoveryTargetTimeLineGoal recoveryTargetTimeLineGoal
Definition: xlog.c:331
#define newval

◆ assign_recovery_target_xid()

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

Definition at line 12387 of file guc.c.

References RECOVERY_TARGET_UNSET, RECOVERY_TARGET_XID, recoveryTarget, and recoveryTargetXid.

12388 {
12391  error_multiple_recovery_targets();
12392 
12393  if (newval && strcmp(newval, "") != 0)
12394  {
12396  recoveryTargetXid = *((TransactionId *) extra);
12397  }
12398  else
12400 }
uint32 TransactionId
Definition: c.h:587
TransactionId recoveryTargetXid
Definition: xlog.c:278
#define newval
RecoveryTargetType recoveryTarget
Definition: xlog.c:275

◆ assign_session_replication_role()

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

Definition at line 11771 of file guc.c.

References ResetPlanCache(), and SessionReplicationRole.

11772 {
11773  /*
11774  * Must flush the plan cache when changing replication role; but don't
11775  * flush unnecessarily.
11776  */
11778  ResetPlanCache();
11779 }
int SessionReplicationRole
Definition: trigger.c:68
void ResetPlanCache(void)
Definition: plancache.c:2149
#define newval

◆ assign_syslog_facility()

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

Definition at line 11751 of file guc.c.

11752 {
11753 #ifdef HAVE_SYSLOG
11754  set_syslog_parameters(syslog_ident_str ? syslog_ident_str : "postgres",
11755  newval);
11756 #endif
11757  /* Without syslog support, just ignore it */
11758 }
static char * syslog_ident_str
Definition: guc.c:648
#define newval

◆ assign_syslog_ident()

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

Definition at line 11761 of file guc.c.

11762 {
11763 #ifdef HAVE_SYSLOG
11764  set_syslog_parameters(newval, syslog_facility);
11765 #endif
11766  /* Without syslog support, it will always be set to "none", so ignore */
11767 }
static int syslog_facility
Definition: guc.c:180
#define newval

◆ assign_tcp_keepalives_count()

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

Definition at line 11971 of file guc.c.

References MyProcPort, and pq_setkeepalivescount().

11972 {
11973  /* See comments in assign_tcp_keepalives_idle */
11975 }
struct Port * MyProcPort
Definition: globals.c:46
int pq_setkeepalivescount(int count, Port *port)
Definition: pqcomm.c:1810
#define newval

◆ assign_tcp_keepalives_idle()

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

Definition at line 11927 of file guc.c.

References MyProcPort, and pq_setkeepalivesidle().

11928 {
11929  /*
11930  * The kernel API provides no way to test a value without setting it; and
11931  * once we set it we might fail to unset it. So there seems little point
11932  * in fully implementing the check-then-assign GUC API for these
11933  * variables. Instead we just do the assignment on demand. pqcomm.c
11934  * reports any problems via ereport(LOG).
11935  *
11936  * This approach means that the GUC value might have little to do with the
11937  * actual kernel value, so we use a show_hook that retrieves the kernel
11938  * value rather than trusting GUC's copy.
11939  */
11941 }
struct Port * MyProcPort
Definition: globals.c:46
int pq_setkeepalivesidle(int idle, Port *port)
Definition: pqcomm.c:1646
#define newval

◆ assign_tcp_keepalives_interval()

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

Definition at line 11954 of file guc.c.

References MyProcPort, and pq_setkeepalivesinterval().

11955 {
11956  /* See comments in assign_tcp_keepalives_idle */
11958 }
struct Port * MyProcPort
Definition: globals.c:46
int pq_setkeepalivesinterval(int interval, Port *port)
Definition: pqcomm.c:1731
#define newval

◆ assign_tcp_user_timeout()

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

Definition at line 11988 of file guc.c.

References MyProcPort, and pq_settcpusertimeout().

11989 {
11990  /* See comments in assign_tcp_keepalives_idle */
11992 }
struct Port * MyProcPort
Definition: globals.c:46
#define newval
int pq_settcpusertimeout(int timeout, Port *port)
Definition: pqcomm.c:1885

◆ assign_timezone_abbreviations()

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

Definition at line 11891 of file guc.c.

References InstallTimeZoneAbbrevs().

11892 {
11893  /* Do nothing for the boot_val default of NULL */
11894  if (!extra)
11895  return;
11896 
11898 }
void InstallTimeZoneAbbrevs(TimeZoneAbbrevTable *tbl)
Definition: datetime.c:4611

◆ assign_wal_consistency_checking()

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

Definition at line 11682 of file guc.c.

References wal_consistency_checking.

11683 {
11684  wal_consistency_checking = (bool *) extra;
11685 }
bool * wal_consistency_checking
Definition: xlog.c:103

◆ AtEOXact_GUC()

void AtEOXact_GUC ( bool  isCommit,
int  nestLevel 
)

Definition at line 6242 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_NEEDS_REPORT, 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, guc_stack::scontext, config_generic::scontext, set_extra_field(), set_string_field(), guc_stack::source, config_generic::source, config_generic::stack, guc_stack::state, config_generic::status, config_var_val::stringval, config_var_value::val, config_bool::variable, config_int::variable, config_real::variable, config_string::variable, config_enum::variable, and config_generic::vartype.

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

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

◆ AtStart_GUC()

void AtStart_GUC ( void  )

Definition at line 6208 of file guc.c.

References elog, and WARNING.

Referenced by StartTransaction().

6209 {
6210  /*
6211  * The nest level should be 0 between transactions; if it isn't, somebody
6212  * didn't call AtEOXact_GUC, or called it with the wrong nestLevel. We
6213  * throw a warning but make no other effort to clean up.
6214  */
6215  if (GUCNestLevel != 0)
6216  elog(WARNING, "GUC nest level = %d at transaction start",
6217  GUCNestLevel);
6218  GUCNestLevel = 1;
6219 }
static int GUCNestLevel
Definition: guc.c:5037
#define WARNING
Definition: elog.h:40
#define elog(elevel,...)
Definition: elog.h:232

◆ BeginReportingGUCOptions()

void BeginReportingGUCOptions ( void  )

Definition at line 6527 of file guc.c.

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

Referenced by PostgresMain().

6528 {
6529  int i;
6530 
6531  /*
6532  * Don't do anything unless talking to an interactive frontend.
6533  */
6535  return;
6536 
6537  reporting_enabled = true;
6538 
6539  /*
6540  * Hack for in_hot_standby: initialize with the value we're about to send.
6541  * (This could be out of date by the time we actually send it, in which
6542  * case the next ReportChangedGUCOptions call will send a duplicate
6543  * report.)
6544  */
6546 
6547  /* Transmit initial values of interesting variables */
6548  for (i = 0; i < num_guc_variables; i++)
6549  {
6550  struct config_generic *conf = guc_variables[i];
6551 
6552  if (conf->flags & GUC_REPORT)
6553  ReportGUCOption(conf);
6554  }
6555 
6556  report_needed = false;
6557 }
static bool report_needed
Definition: guc.c:5035
static bool in_hot_standby
Definition: guc.c:673
bool RecoveryInProgress(void)
Definition: xlog.c:8328
static int num_guc_variables
Definition: guc.c:5025
#define GUC_REPORT
Definition: guc.h:208
static struct config_generic ** guc_variables
Definition: guc.c:5022
int i
static void ReportGUCOption(struct config_generic *record)
Definition: guc.c:6619
CommandDest whereToSendOutput
Definition: postgres.c:92
static bool reporting_enabled
Definition: guc.c:5033

◆ build_guc_variables()

void build_guc_variables ( void  )

Definition at line 5288 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().

5289 {
5290  int size_vars;
5291  int num_vars = 0;
5292  struct config_generic **guc_vars;
5293  int i;
5294 
5295  for (i = 0; ConfigureNamesBool[i].gen.name; i++)
5296  {
5297  struct config_bool *conf = &ConfigureNamesBool[i];
5298 
5299  /* Rather than requiring vartype to be filled in by hand, do this: */
5300  conf->gen.vartype = PGC_BOOL;
5301  num_vars++;
5302  }
5303 
5304  for (i = 0; ConfigureNamesInt[i].gen.name; i++)
5305  {
5306  struct config_int *conf = &ConfigureNamesInt[i];
5307 
5308  conf->gen.vartype = PGC_INT;
5309  num_vars++;
5310  }
5311 
5312  for (i = 0; ConfigureNamesReal[i].gen.name; i++)
5313  {
5314  struct config_real *conf = &ConfigureNamesReal[i];
5315 
5316  conf->gen.vartype = PGC_REAL;
5317  num_vars++;
5318  }
5319 
5320  for (i = 0; ConfigureNamesString[i].gen.name; i++)
5321  {
5322  struct config_string *conf = &ConfigureNamesString[i];
5323 
5324  conf->gen.vartype = PGC_STRING;
5325  num_vars++;
5326  }
5327 
5328  for (i = 0; ConfigureNamesEnum[i].gen.name; i++)
5329  {
5330  struct config_enum *conf = &ConfigureNamesEnum[i];
5331 
5332  conf->gen.vartype = PGC_ENUM;
5333  num_vars++;
5334  }
5335 
5336  /*
5337  * Create table with 20% slack
5338  */
5339  size_vars = num_vars + num_vars / 4;
5340 
5341  guc_vars = (struct config_generic **)
5342  guc_malloc(FATAL, size_vars * sizeof(struct config_generic *));
5343 
5344  num_vars = 0;
5345 
5346  for (i = 0; ConfigureNamesBool[i].gen.name; i++)
5347  guc_vars[num_vars++] = &ConfigureNamesBool[i].gen;
5348 
5349  for (i = 0; ConfigureNamesInt[i].gen.name; i++)
5350  guc_vars[num_vars++] = &ConfigureNamesInt[i].gen;
5351 
5352  for (i = 0; ConfigureNamesReal[i].gen.name; i++)
5353  guc_vars[num_vars++] = &ConfigureNamesReal[i].gen;
5354 
5355  for (i = 0; ConfigureNamesString[i].gen.name; i++)
5356  guc_vars[num_vars++] = &ConfigureNamesString[i].gen;
5357 
5358  for (i = 0; ConfigureNamesEnum[i].gen.name; i++)
5359  guc_vars[num_vars++] = &ConfigureNamesEnum[i].gen;
5360 
5361  if (guc_variables)
5363  guc_variables = guc_vars;
5364  num_guc_variables = num_vars;
5365  size_guc_variables = size_vars;
5367  sizeof(struct config_generic *), guc_var_compare);
5368 }
static struct config_int ConfigureNamesInt[]
Definition: guc.c:2128
const char * name
Definition: guc_tables.h:141
static struct config_enum ConfigureNamesEnum[]
Definition: guc.c:4628
static struct config_bool ConfigureNamesBool[]
Definition: guc.c:971
static int guc_var_compare(const void *a, const void *b)
Definition: guc.c:5580
static int num_guc_variables
Definition: guc.c:5025
#define FATAL
Definition: elog.h:49
struct config_generic gen
Definition: guc_tables.h:177
struct config_generic gen
Definition: guc_tables.h:191
static struct config_generic ** guc_variables
Definition: guc.c:5022
enum config_type vartype
Definition: guc_tables.h:148
static int size_guc_variables
Definition: guc.c:5028
static struct config_real ConfigureNamesReal[]
Definition: guc.c:3580
struct config_generic gen
Definition: guc_tables.h:237
struct config_generic gen
Definition: guc_tables.h:223
#define free(a)
Definition: header.h:65
static struct config_string ConfigureNamesString[]
Definition: guc.c:3849
int i
#define qsort(a, b, c, d)
Definition: port.h:505
static void * guc_malloc(int elevel, size_t size)
Definition: guc.c:5065
struct config_generic gen
Definition: guc_tables.h:207

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

11418 {
11419  /* Quick success if no hook */
11420  if (!conf->check_hook)
11421  return true;
11422 
11423  /* Reset variables that might be set by hook */
11424  GUC_check_errcode_value = ERRCODE_INVALID_PARAMETER_VALUE;
11425  GUC_check_errmsg_string = NULL;
11427  GUC_check_errhint_string = NULL;
11428 
11429  if (!conf->check_hook(newval, extra, source))
11430  {
11431  ereport(elevel,
11435  errmsg("invalid value for parameter \"%s\": %d",
11436  conf->gen.name, (int) *newval),
11440  errhint("%s", GUC_check_errhint_string) : 0));
11441  /* Flush any strings created in ErrorContext */
11442  FlushErrorState();
11443  return false;
11444  }
11445 
11446  return true;
11447 }
char * GUC_check_errhint_string
Definition: guc.c:153
int errhint(const char *fmt,...)
Definition: elog.c:1156
const char * name
Definition: guc_tables.h:141
int errcode(int sqlerrcode)
Definition: elog.c:698
static int GUC_check_errcode_value
Definition: guc.c:148
void FlushErrorState(void)
Definition: elog.c:1654
int errdetail_internal(const char *fmt,...)
Definition: elog.c:1069
struct config_generic gen
Definition: guc_tables.h:177
char * GUC_check_errdetail_string
Definition: guc.c:152
static int elevel
Definition: vacuumlazy.c:401
GucBoolCheckHook check_hook
Definition: guc_tables.h:181
#define ereport(elevel,...)
Definition: elog.h:157
int errmsg_internal(const char *fmt,...)
Definition: elog.c:996
static rewind_source * source
Definition: pg_rewind.c:79
#define newval
char * GUC_check_errmsg_string
Definition: guc.c:151
int errmsg(const char *fmt,...)
Definition: elog.c:909

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

11570 {
11571  /* Quick success if no hook */
11572  if (!conf->check_hook)
11573  return true;
11574 
11575  /* Reset variables that might be set by hook */
11576  GUC_check_errcode_value = ERRCODE_INVALID_PARAMETER_VALUE;
11577  GUC_check_errmsg_string = NULL;
11579  GUC_check_errhint_string = NULL;
11580 
11581  if (!conf->check_hook(newval, extra, source))
11582  {
11583  ereport(elevel,
11587  errmsg("invalid value for parameter \"%s\": \"%s\"",
11588  conf->gen.name,
11593  errhint("%s", GUC_check_errhint_string) : 0));
11594  /* Flush any strings created in ErrorContext */
11595  FlushErrorState();
11596  return false;
11597  }
11598 
11599  return true;
11600 }
char * GUC_check_errhint_string
Definition: guc.c:153
GucEnumCheckHook check_hook
Definition: guc_tables.h:242
int errhint(const char *fmt,...)
Definition: elog.c:1156
const char * name
Definition: guc_tables.h:141
int errcode(int sqlerrcode)
Definition: elog.c:698
const char * config_enum_lookup_by_value(struct config_enum *record, int val)
Definition: guc.c:7011
static int GUC_check_errcode_value
Definition: guc.c:148
void FlushErrorState(void)
Definition: elog.c:1654
int errdetail_internal(const char *fmt,...)
Definition: elog.c:1069
char * GUC_check_errdetail_string
Definition: guc.c:152
static int elevel
Definition: vacuumlazy.c:401
struct config_generic gen
Definition: guc_tables.h:237
#define ereport(elevel,...)
Definition: elog.h:157
int errmsg_internal(const char *fmt,...)
Definition: elog.c:996
static rewind_source * source
Definition: pg_rewind.c:79
#define newval
char * GUC_check_errmsg_string
Definition: guc.c:151
int errmsg(const char *fmt,...)
Definition: elog.c:909

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

11452 {
11453  /* Quick success if no hook */
11454  if (!conf->check_hook)
11455  return true;
11456 
11457  /* Reset variables that might be set by hook */
11458  GUC_check_errcode_value = ERRCODE_INVALID_PARAMETER_VALUE;
11459  GUC_check_errmsg_string = NULL;
11461  GUC_check_errhint_string = NULL;
11462 
11463  if (!conf->check_hook(newval, extra, source))
11464  {
11465  ereport(elevel,
11469  errmsg("invalid value for parameter \"%s\": %d",
11470  conf->gen.name, *newval),
11474  errhint("%s", GUC_check_errhint_string) : 0));
11475  /* Flush any strings created in ErrorContext */
11476  FlushErrorState();
11477  return false;
11478  }
11479 
11480  return true;
11481 }
char * GUC_check_errhint_string
Definition: guc.c:153
int errhint(const char *fmt,...)
Definition: elog.c:1156
const char * name
Definition: guc_tables.h:141
int errcode(int sqlerrcode)
Definition: elog.c:698
static int GUC_check_errcode_value
Definition: guc.c:148
GucIntCheckHook check_hook
Definition: guc_tables.h:197
void FlushErrorState(void)
Definition: elog.c:1654
int errdetail_internal(const char *fmt,...)
Definition: elog.c:1069
struct config_generic gen
Definition: guc_tables.h:191
char * GUC_check_errdetail_string
Definition: guc.c:152
static int elevel
Definition: vacuumlazy.c:401
#define ereport(elevel,...)
Definition: elog.h:157
int errmsg_internal(const char *fmt,...)
Definition: elog.c:996
static rewind_source * source
Definition: pg_rewind.c:79
#define newval
char * GUC_check_errmsg_string
Definition: guc.c:151
int errmsg(const char *fmt,...)
Definition: elog.c:909

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

11486 {
11487  /* Quick success if no hook */
11488  if (!conf->check_hook)
11489  return true;
11490 
11491  /* Reset variables that might be set by hook */
11492  GUC_check_errcode_value = ERRCODE_INVALID_PARAMETER_VALUE;
11493  GUC_check_errmsg_string = NULL;
11495  GUC_check_errhint_string = NULL;
11496 
11497  if (!conf->check_hook(newval, extra, source))
11498  {
11499  ereport(elevel,
11503  errmsg("invalid value for parameter \"%s\": %g",
11504  conf->gen.name, *newval),
11508  errhint("%s", GUC_check_errhint_string) : 0));
11509  /* Flush any strings created in ErrorContext */
11510  FlushErrorState();
11511  return false;
11512  }
11513 
11514  return true;
11515 }
char * GUC_check_errhint_string
Definition: guc.c:153
int errhint(const char *fmt,...)
Definition: elog.c:1156
const char * name
Definition: guc_tables.h:141
int errcode(int sqlerrcode)
Definition: elog.c:698
static int GUC_check_errcode_value
Definition: guc.c:148
GucRealCheckHook check_hook
Definition: guc_tables.h:213
void FlushErrorState(void)
Definition: elog.c:1654
int errdetail_internal(const char *fmt,...)
Definition: elog.c:1069
char * GUC_check_errdetail_string
Definition: guc.c:152
static int elevel
Definition: vacuumlazy.c:401
#define ereport(elevel,...)
Definition: elog.h:157
int errmsg_internal(const char *fmt,...)
Definition: elog.c:996
static rewind_source * source
Definition: pg_rewind.c:79
#define newval
char * GUC_check_errmsg_string
Definition: guc.c:151
int errmsg(const char *fmt,...)
Definition: elog.c:909
struct config_generic gen
Definition: guc_tables.h:207

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

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

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

11520 {
11521  volatile bool result = true;
11522 
11523  /* Quick success if no hook */
11524  if (!conf->check_hook)
11525  return true;
11526 
11527  /*
11528  * If elevel is ERROR, or if the check_hook itself throws an elog
11529  * (undesirable, but not always avoidable), make sure we don't leak the
11530  * already-malloc'd newval string.
11531  */
11532  PG_TRY();
11533  {
11534  /* Reset variables that might be set by hook */
11535  GUC_check_errcode_value = ERRCODE_INVALID_PARAMETER_VALUE;
11536  GUC_check_errmsg_string = NULL;
11538  GUC_check_errhint_string = NULL;
11539 
11540  if (!conf->check_hook(newval, extra, source))
11541  {
11542  ereport(elevel,
11546  errmsg("invalid value for parameter \"%s\": \"%s\"",
11547  conf->gen.name, *newval ? *newval : ""),
11551  errhint("%s", GUC_check_errhint_string) : 0));
11552  /* Flush any strings created in ErrorContext */
11553  FlushErrorState();
11554  result = false;
11555  }
11556  }
11557  PG_CATCH();
11558  {
11559  free(*newval);
11560  PG_RE_THROW();
11561  }
11562  PG_END_TRY();
11563 
11564  return result;
11565 }
char * GUC_check_errhint_string
Definition: guc.c:153
int errhint(const char *fmt,...)
Definition: elog.c:1156
const char * name
Definition: guc_tables.h:141
GucStringCheckHook check_hook
Definition: guc_tables.h:227
int errcode(int sqlerrcode)
Definition: elog.c:698
static int GUC_check_errcode_value
Definition: guc.c:148
void FlushErrorState(void)
Definition: elog.c:1654
int errdetail_internal(const char *fmt,...)
Definition: elog.c:1069
char * GUC_check_errdetail_string
Definition: guc.c:152
static int elevel
Definition: vacuumlazy.c:401
#define ereport(elevel,...)
Definition: elog.h:157
struct config_generic gen
Definition: guc_tables.h:223
#define free(a)
Definition: header.h:65
int errmsg_internal(const char *fmt,...)
Definition: elog.c:996
#define PG_CATCH()
Definition: elog.h:323
static rewind_source * source
Definition: pg_rewind.c:79
#define newval
#define PG_RE_THROW()
Definition: elog.h:354
char * GUC_check_errmsg_string
Definition: guc.c:151
int errmsg(const char *fmt,...)
Definition: elog.c:909
#define PG_TRY()
Definition: elog.h:313
#define PG_END_TRY()
Definition: elog.h:338

◆ can_skip_gucvar()

static bool can_skip_gucvar ( struct config_generic gconf)
static

Definition at line 10469 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().

10470 {
10471  /*
10472  * We can skip GUCs that are guaranteed to have the same values in leaders
10473  * and workers. (Note it is critical that the leader and worker have the
10474  * same idea of which GUCs fall into this category. It's okay to consider
10475  * context and name for this purpose, since those are unchanging
10476  * properties of a GUC.)
10477  *
10478  * PGC_POSTMASTER variables always have the same value in every child of a
10479  * particular postmaster, so the worker will certainly have the right
10480  * value already. Likewise, PGC_INTERNAL variables are set by special
10481  * mechanisms (if indeed they aren't compile-time constants). So we may
10482  * always skip these.
10483  *
10484  * Role must be handled specially because its current value can be an
10485  * invalid value (for instance, if someone dropped the role since we set
10486  * it). So if we tried to serialize it normally, we might get a failure.
10487  * We skip it here, and use another mechanism to ensure the worker has the
10488  * right value.
10489  *
10490  * For all other GUCs, we skip if the GUC has its compiled-in default
10491  * value (i.e., source == PGC_S_DEFAULT). On the leader side, this means
10492  * we don't send GUCs that have their default values, which typically
10493  * saves lots of work. On the worker side, this means we don't need to
10494  * reset the GUC to default because it already has that value. See
10495  * comments in RestoreGUCState for more info.
10496  */
10497  return gconf->context == PGC_POSTMASTER ||
10498  gconf->context == PGC_INTERNAL || gconf->source == PGC_S_DEFAULT ||
10499  strcmp(gconf->name, "role") == 0;
10500 }
GucSource source
Definition: guc_tables.h:150
const char * name
Definition: guc_tables.h:141
GucContext context
Definition: guc_tables.h:142

◆ check_application_name()

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

Definition at line 12147 of file guc.c.

References pg_clean_ascii().

12148 {
12149  /* Only allow clean ASCII chars in the application name */
12151 
12152  return true;
12153 }
#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 12014 of file guc.c.

References MAX_BACKENDS, max_wal_senders, max_worker_processes, and MaxConnections.

12015 {
12016  if (MaxConnections + *newval + 1 +
12018  return false;
12019  return true;
12020 }
#define MAX_BACKENDS
Definition: postmaster.h:76
int max_wal_senders
Definition: walsender.c:121
int MaxConnections
Definition: globals.c:136
#define newval
int max_worker_processes
Definition: globals.c:137

◆ check_autovacuum_work_mem()

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

Definition at line 12032 of file guc.c.

12033 {
12034  /*
12035  * -1 indicates fallback.
12036  *
12037  * If we haven't yet changed the boot_val default of -1, just let it be.
12038  * Autovacuum will look to maintenance_work_mem instead.
12039  */
12040  if (*newval == -1)
12041  return true;
12042 
12043  /*
12044  * We clamp manually-set values to at least 1MB. Since
12045  * maintenance_work_mem is always set to at least this value, do the same
12046  * here.
12047  */
12048  if (*newval < 1024)
12049  *newval = 1024;
12050 
12051  return true;
12052 }
#define newval

◆ check_backtrace_functions()

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

Definition at line 12219 of file guc.c.

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

12220 {
12221  int newvallen = strlen(*newval);
12222  char *someval;
12223  int validlen;
12224  int i;
12225  int j;
12226 
12227  /*
12228  * Allow characters that can be C identifiers and commas as separators, as
12229  * well as some whitespace for readability.
12230  */
12231  validlen = strspn(*newval,
12232  "0123456789_"
12233  "abcdefghijklmnopqrstuvwxyz"
12234  "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
12235  ", \n\t");
12236  if (validlen != newvallen)
12237  {
12238  GUC_check_errdetail("invalid character");
12239  return false;
12240  }
12241 
12242  if (*newval[0] == '\0')
12243  {
12244  *extra = NULL;
12245  return true;
12246  }
12247 
12248  /*
12249  * Allocate space for the output and create the copy. We could discount
12250  * whitespace chars to save some memory, but it doesn't seem worth the
12251  * trouble.
12252  */
12253  someval = guc_malloc(ERROR, newvallen + 1 + 1);
12254  for (i = 0, j = 0; i < newvallen; i++)
12255  {
12256  if ((*newval)[i] == ',')
12257  someval[j++] = '\0'; /* next item */
12258  else if ((*newval)[i] == ' ' ||
12259  (*newval)[i] == '\n' ||
12260  (*newval)[i] == '\t')
12261  ; /* ignore these */
12262  else
12263  someval[j++] = (*newval)[i]; /* copy anything else */
12264  }
12265 
12266  /* two \0s end the setting */
12267  someval[j] = '\0';
12268  someval[j + 1] = '\0';
12269 
12270  *extra = someval;
12271  return true;
12272 }
#define GUC_check_errdetail
Definition: guc.h:422
#define ERROR
Definition: elog.h:46
#define newval
int i
static void * guc_malloc(int elevel, size_t size)
Definition: guc.c:5065

◆ check_bonjour()

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

Definition at line 11797 of file guc.c.

References GUC_check_errmsg.

11798 {
11799 #ifndef USE_BONJOUR
11800  if (*newval)
11801  {
11802  GUC_check_errmsg("Bonjour is not supported by this build");
11803  return false;
11804  }
11805 #endif
11806  return true;
11807 }
#define GUC_check_errmsg
Definition: guc.h:418
#define newval

◆ check_canonical_path()

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

Definition at line 11848 of file guc.c.

References canonicalize_path().

11849 {
11850  /*
11851  * Since canonicalize_path never enlarges the string, we can just modify
11852  * newval in-place. But watch out for NULL, which is the default value
11853  * for external_pid_file.
11854  */
11855  if (*newval)
11857  return true;
11858 }
void canonicalize_path(char *path)
Definition: path.c:254
#define newval

◆ check_client_connection_check_interval()

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

Definition at line 12104 of file guc.c.

References GUC_check_errdetail.

12105 {
12106 #ifndef POLLRDHUP
12107  /* Linux only, for now. See pq_check_connection(). */
12108  if (*newval != 0)
12109  {
12110  GUC_check_errdetail("client_connection_check_interval must be set to 0 on platforms that lack POLLRDHUP.");
12111  return false;
12112  }
12113 #endif
12114  return true;
12115 }
#define GUC_check_errdetail
Definition: guc.h:422
#define newval

◆ check_cluster_name()

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

Definition at line 12163 of file guc.c.

References pg_clean_ascii().

12164 {
12165  /* Only allow clean ASCII chars in the cluster name */
12167 
12168  return true;
12169 }
#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 12548 of file guc.c.

References GUC_check_errcode(), and GUC_check_errmsg.

12549 {
12550  if (*newval)
12551  {
12552  /* check the GUC's definition for an explanation */
12553  GUC_check_errcode(ERRCODE_FEATURE_NOT_SUPPORTED);
12554  GUC_check_errmsg("tables declared WITH OIDS are not supported");
12555 
12556  return false;
12557  }
12558 
12559  return true;
12560 }
#define GUC_check_errmsg
Definition: guc.h:418
void GUC_check_errcode(int sqlerrcode)
Definition: guc.c:11403
#define newval

◆ check_effective_io_concurrency()

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

Definition at line 12064 of file guc.c.

References GUC_check_errdetail.

12065 {
12066 #ifndef USE_PREFETCH
12067  if (*newval != 0)
12068  {
12069  GUC_check_errdetail("effective_io_concurrency must be set to 0 on platforms that lack posix_fadvise().");
12070  return false;
12071  }
12072 #endif /* USE_PREFETCH */
12073  return true;
12074 }
#define GUC_check_errdetail
Definition: guc.h:422
#define newval

◆ check_huge_page_size()

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

Definition at line 12090 of file guc.c.

References GUC_check_errdetail.

12091 {
12092 #if !(defined(MAP_HUGE_MASK) && defined(MAP_HUGE_SHIFT))
12093  /* Recent enough Linux only, for now. See GetHugePageSize(). */
12094  if (*newval != 0)
12095  {
12096  GUC_check_errdetail("huge_page_size must be 0 on this platform.");
12097  return false;
12098  }
12099 #endif
12100  return true;
12101 }
#define GUC_check_errdetail
Definition: guc.h:422
#define newval

◆ check_log_destination()

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

Definition at line 11688 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().

11689 {
11690  char *rawstring;
11691  List *elemlist;
11692  ListCell *l;
11693  int newlogdest = 0;
11694  int *myextra;
11695 
11696  /* Need a modifiable copy of string */
11697  rawstring = pstrdup(*newval);
11698 
11699  /* Parse string into list of identifiers */
11700  if (!SplitIdentifierString(rawstring, ',', &elemlist))
11701  {
11702  /* syntax error in list */
11703  GUC_check_errdetail("List syntax is invalid.");
11704  pfree(rawstring);
11705  list_free(elemlist);
11706  return false;
11707  }
11708 
11709  foreach(l, elemlist)
11710  {
11711  char *tok = (char *) lfirst(l);
11712 
11713  if (pg_strcasecmp(tok, "stderr") == 0)
11714  newlogdest |= LOG_DESTINATION_STDERR;
11715  else if (pg_strcasecmp(tok, "csvlog") == 0)
11716  newlogdest |= LOG_DESTINATION_CSVLOG;
11717 #ifdef HAVE_SYSLOG
11718  else if (pg_strcasecmp(tok, "syslog") == 0)
11719  newlogdest |= LOG_DESTINATION_SYSLOG;
11720 #endif
11721 #ifdef WIN32
11722  else if (pg_strcasecmp(tok, "eventlog") == 0)
11723  newlogdest |= LOG_DESTINATION_EVENTLOG;
11724 #endif
11725  else
11726  {
11727  GUC_check_errdetail("Unrecognized key word: \"%s\".", tok);
11728  pfree(rawstring);
11729  list_free(elemlist);
11730  return false;
11731  }
11732  }
11733 
11734  pfree(rawstring);
11735  list_free(elemlist);
11736 
11737  myextra = (int *) guc_malloc(ERROR, sizeof(int));
11738  *myextra = newlogdest;
11739  *extra = (void *) myextra;
11740 
11741  return true;
11742 }
#define LOG_DESTINATION_EVENTLOG
Definition: elog.h:437
#define GUC_check_errdetail
Definition: guc.h:422
char * pstrdup(const char *in)
Definition: mcxt.c:1299
#define LOG_DESTINATION_SYSLOG
Definition: elog.h:436
int pg_strcasecmp(const char *s1, const char *s2)
Definition: pgstrcasecmp.c:36
void pfree(void *pointer)
Definition: mcxt.c:1169
#define ERROR
Definition: elog.h:46
bool SplitIdentifierString(char *rawstring, char separator, List **namelist)
Definition: varlena.c:3746
#define LOG_DESTINATION_CSVLOG
Definition: elog.h:438
#define LOG_DESTINATION_STDERR
Definition: elog.h:435
#define lfirst(lc)
Definition: pg_list.h:169
#define newval
void list_free(List *list)
Definition: list.c:1391
static void * guc_malloc(int elevel, size_t size)
Definition: guc.c:5065
Definition: pg_list.h:50

◆ check_log_stats()

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

Definition at line 11834 of file guc.c.

References GUC_check_errdetail.

11835 {
11836  if (*newval &&
11838  {
11839  GUC_check_errdetail("Cannot enable \"log_statement_stats\" when "
11840  "\"log_parser_stats\", \"log_planner_stats\", "
11841  "or \"log_executor_stats\" is true.");
11842  return false;
11843  }
11844  return true;
11845 }
bool log_parser_stats
Definition: guc.c:577
#define GUC_check_errdetail
Definition: guc.h:422
#define newval
bool log_executor_stats
Definition: guc.c:579
bool log_planner_stats
Definition: guc.c:578

◆ check_maintenance_io_concurrency()

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

Definition at line 12077 of file guc.c.

References GUC_check_errdetail.

12078 {
12079 #ifndef USE_PREFETCH
12080  if (*newval != 0)
12081  {
12082  GUC_check_errdetail("maintenance_io_concurrency must be set to 0 on platforms that lack posix_fadvise().");
12083  return false;
12084  }
12085 #endif /* USE_PREFETCH */
12086  return true;
12087 }
#define GUC_check_errdetail
Definition: guc.h:422
#define newval

◆ check_max_wal_senders()

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

Definition at line 12023 of file guc.c.

References autovacuum_max_workers, MAX_BACKENDS, max_worker_processes, and MaxConnections.

12024 {
12027  return false;
12028  return true;
12029 }
#define MAX_BACKENDS
Definition: postmaster.h:76
int MaxConnections
Definition: globals.c:136
int autovacuum_max_workers
Definition: autovacuum.c:115
#define newval
int max_worker_processes
Definition: globals.c:137

◆ check_max_worker_processes()

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

Definition at line 12055 of file guc.c.

References autovacuum_max_workers, MAX_BACKENDS, max_wal_senders, and MaxConnections.

12056 {
12059  return false;
12060  return true;
12061 }
#define MAX_BACKENDS
Definition: postmaster.h:76
int max_wal_senders
Definition: walsender.c:121
int MaxConnections
Definition: globals.c:136
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 12005 of file guc.c.

References autovacuum_max_workers, MAX_BACKENDS, max_wal_senders, and max_worker_processes.

12006 {
12007  if (*newval + autovacuum_max_workers + 1 +
12009  return false;
12010  return true;
12011 }
#define MAX_BACKENDS
Definition: postmaster.h:76
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:137

◆ check_primary_slot_name()

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

Definition at line 12538 of file guc.c.

References ReplicationSlotValidateName(), and WARNING.

12539 {
12540  if (*newval && strcmp(*newval, "") != 0 &&
12542  return false;
12543 
12544  return true;
12545 }
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 12343 of file guc.c.

References GUC_check_errdetail.

12344 {
12345  if (strcmp(*newval, "immediate") != 0 && strcmp(*newval, "") != 0)
12346  {
12347  GUC_check_errdetail("The only allowed value is \"immediate\".");
12348  return false;
12349  }
12350  return true;
12351 }
#define GUC_check_errdetail
Definition: guc.h:422
#define newval

◆ check_recovery_target_lsn()

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

Definition at line 12502 of file guc.c.

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

12503 {
12504  if (strcmp(*newval, "") != 0)
12505  {
12506  XLogRecPtr lsn;
12507  XLogRecPtr *myextra;
12508  bool have_error = false;
12509 
12510  lsn = pg_lsn_in_internal(*newval, &have_error);
12511  if (have_error)
12512  return false;
12513 
12514  myextra = (XLogRecPtr *) guc_malloc(ERROR, sizeof(XLogRecPtr));
12515  *myextra = lsn;
12516  *extra = (void *) myextra;
12517  }
12518  return true;
12519 }
#define ERROR
Definition: elog.h:46
XLogRecPtr pg_lsn_in_internal(const char *str, bool *have_error)
Definition: pg_lsn.c:30
uint64 XLogRecPtr
Definition: xlogdefs.h:21
#define newval
static void * guc_malloc(int elevel, size_t size)
Definition: guc.c:5065

◆ check_recovery_target_name()

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

Definition at line 12473 of file guc.c.

References GUC_check_errdetail, and MAXFNAMELEN.

12474 {
12475  /* Use the value of newval directly */
12476  if (strlen(*newval) >= MAXFNAMELEN)
12477  {
12478  GUC_check_errdetail("%s is too long (maximum %d characters).",
12479  "recovery_target_name", MAXFNAMELEN - 1);
12480  return false;
12481  }
12482  return true;
12483 }
#define GUC_check_errdetail
Definition: guc.h:422
#define MAXFNAMELEN
#define newval

◆ check_recovery_target_time()

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

Definition at line 12410 of file guc.c.

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

12411 {
12412  if (strcmp(*newval, "") != 0)
12413  {
12414  /* reject some special values */
12415  if (strcmp(*newval, "now") == 0 ||
12416  strcmp(*newval, "today") == 0 ||
12417  strcmp(*newval, "tomorrow") == 0 ||
12418  strcmp(*newval, "yesterday") == 0)
12419  {
12420  return false;
12421  }
12422 
12423  /*
12424  * parse timestamp value (see also timestamptz_in())
12425  */
12426  {
12427  char *str = *newval;
12428  fsec_t fsec;
12429  struct pg_tm tt,
12430  *tm = &tt;
12431  int tz;
12432  int dtype;
12433  int nf;
12434  int dterr;
12435  char *field[MAXDATEFIELDS];
12436  int ftype[MAXDATEFIELDS];
12437  char workbuf[MAXDATELEN + MAXDATEFIELDS];
12439 
12440  dterr = ParseDateTime(str, workbuf, sizeof(workbuf),
12441  field, ftype, MAXDATEFIELDS, &nf);
12442  if (dterr == 0)
12443  dterr = DecodeDateTime(field, ftype, nf, &dtype, tm, &fsec, &tz);
12444  if (dterr != 0)
12445  return false;
12446  if (dtype != DTK_DATE)
12447  return false;
12448 
12449  if (tm2timestamp(tm, fsec, &tz, &timestamp) != 0)
12450  {
12451  GUC_check_errdetail("timestamp out of range: \"%s\"", str);
12452  return false;
12453  }
12454  }
12455  }
12456  return true;
12457 }
#define MAXDATELEN
Definition: datetime.h:201
#define GUC_check_errdetail
Definition: guc.h:422
int64 timestamp
int64 TimestampTz
Definition: timestamp.h:39
Definition: pgtime.h:32
static struct pg_tm tm
Definition: localtime.c:102
int DecodeDateTime(char **field, int *ftype, int nf, int *dtype, struct pg_tm *tm, fsec_t *fsec, int *tzp)
Definition: datetime.c:803
int32 fsec_t
Definition: timestamp.h:41
int tm2timestamp(struct pg_tm *tm, fsec_t fsec, int *tzp, Timestamp *result)
Definition: timestamp.c:1918
#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:582
#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 12281 of file guc.c.

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

12282 {
12284  RecoveryTargetTimeLineGoal *myextra;
12285 
12286  if (strcmp(*newval, "current") == 0)
12288  else if (strcmp(*newval, "latest") == 0)
12290  else
12291  {
12293 
12294  errno = 0;
12295  strtoul(*newval, NULL, 0);
12296  if (errno == EINVAL || errno == ERANGE)
12297  {
12298  GUC_check_errdetail("recovery_target_timeline is not a valid number.");
12299  return false;
12300  }
12301  }
12302 
12304  *myextra = rttg;
12305  *extra = (void *) myextra;
12306 
12307  return true;
12308 }
#define GUC_check_errdetail
Definition: guc.h:422
RecoveryTargetTimeLineGoal
Definition: xlog.h:51
#define ERROR
Definition: elog.h:46
#define newval
static void * guc_malloc(int elevel, size_t size)
Definition: guc.c:5065

◆ check_recovery_target_xid()

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

Definition at line 12367 of file guc.c.

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

12368 {
12369  if (strcmp(*newval, "") != 0)
12370  {
12371  TransactionId xid;
12372  TransactionId *myextra;
12373 
12374  errno = 0;
12375  xid = (TransactionId) pg_strtouint64(*newval, NULL, 0);
12376  if (errno == EINVAL || errno == ERANGE)
12377  return false;
12378 
12379  myextra = (TransactionId *) guc_malloc(ERROR, sizeof(TransactionId));
12380  *myextra = xid;
12381  *extra = (void *) myextra;
12382  }
12383  return true;
12384 }
uint32 TransactionId
Definition: c.h:587
#define ERROR
Definition: elog.h:46
uint64 pg_strtouint64(const char *str, char **endptr, int base)
Definition: numutils.c:621
#define newval
static void * guc_malloc(int elevel, size_t size)
Definition: guc.c:5065

◆ check_ssl()

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

Definition at line 11810 of file guc.c.

References GUC_check_errmsg.

11811 {
11812 #ifndef USE_SSL
11813  if (*newval)
11814  {
11815  GUC_check_errmsg("SSL is not supported by this build");
11816  return false;
11817  }
11818 #endif
11819  return true;
11820 }
#define GUC_check_errmsg
Definition: guc.h:418
#define newval

◆ check_stage_log_stats()

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

Definition at line 11823 of file guc.c.

References GUC_check_errdetail.

11824 {
11825  if (*newval && log_statement_stats)
11826  {
11827  GUC_check_errdetail("Cannot enable parameter when \"log_statement_stats\" is true.");
11828  return false;
11829  }
11830  return true;
11831 }
bool log_statement_stats
Definition: guc.c:580
#define GUC_check_errdetail
Definition: guc.h:422
#define newval

◆ check_temp_buffers()

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

Definition at line 11782 of file guc.c.

References GUC_check_errdetail, NLocBuffer, and PGC_S_TEST.

11783 {
11784  /*
11785  * Once local buffers have been initialized, it's too late to change this.
11786  * However, if this is only a test call, allow it.
11787  */
11788  if (source != PGC_S_TEST && NLocBuffer && NLocBuffer != *newval)
11789  {
11790  GUC_check_errdetail("\"temp_buffers\" cannot be changed after any temporary tables have been accessed in the session.");
11791  return false;
11792  }
11793  return true;
11794 }
#define GUC_check_errdetail
Definition: guc.h:422
int NLocBuffer
Definition: localbuf.c:41
static rewind_source * source
Definition: pg_rewind.c:79
#define newval

◆ check_timezone_abbreviations()

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

Definition at line 11861 of file guc.c.

References Assert, load_tzoffsets(), and PGC_S_DEFAULT.

11862 {
11863  /*
11864  * The boot_val given above for timezone_abbreviations is NULL. When we
11865  * see this we just do nothing. If this value isn't overridden from the
11866  * config file then pg_timezone_abbrev_initialize() will eventually
11867  * replace it with "Default". This hack has two purposes: to avoid
11868  * wasting cycles loading values that might soon be overridden from the
11869  * config file, and to avoid trying to read the timezone abbrev files
11870  * during InitializeGUCOptions(). The latter doesn't work in an
11871  * EXEC_BACKEND subprocess because my_exec_path hasn't been set yet and so
11872  * we can't locate PGSHAREDIR.
11873  */
11874  if (*newval == NULL)
11875  {
11877  return true;
11878  }
11879 
11880  /* OK, load the file and produce a malloc'd TimeZoneAbbrevTable */
11881  *extra = load_tzoffsets(*newval);
11882 
11883  /* tzparser.c returns NULL on failure, reporting via GUC_check_errmsg */
11884  if (!*extra)
11885  return false;
11886 
11887  return true;
11888 }
TimeZoneAbbrevTable * load_tzoffsets(const char *filename)
Definition: tzparser.c:437
#define Assert(condition)
Definition: c.h:804
static rewind_source * source
Definition: pg_rewind.c:79
#define newval

◆ check_wal_consistency_checking()

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

Definition at line 11608 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().

11609 {
11610  char *rawstring;
11611  List *elemlist;
11612  ListCell *l;
11613  bool newwalconsistency[RM_MAX_ID + 1];
11614 
11615  /* Initialize the array */
11616  MemSet(newwalconsistency, 0, (RM_MAX_ID + 1) * sizeof(bool));
11617 
11618  /* Need a modifiable copy of string */
11619  rawstring = pstrdup(*newval);
11620 
11621  /* Parse string into list of identifiers */
11622  if (!SplitIdentifierString(rawstring, ',', &elemlist))
11623  {
11624  /* syntax error in list */
11625  GUC_check_errdetail("List syntax is invalid.");
11626  pfree(rawstring);
11627  list_free(elemlist);
11628  return false;
11629  }
11630 
11631  foreach(l, elemlist)
11632  {
11633  char *tok = (char *) lfirst(l);
11634  bool found = false;
11635  RmgrId rmid;
11636 
11637  /* Check for 'all'. */
11638  if (pg_strcasecmp(tok, "all") == 0)
11639  {
11640  for (rmid = 0; rmid <= RM_MAX_ID; rmid++)
11641  if (RmgrTable[rmid].rm_mask != NULL)
11642  newwalconsistency[rmid] = true;
11643  found = true;
11644  }
11645  else
11646  {
11647  /*
11648  * Check if the token matches with any individual resource
11649  * manager.
11650  */
11651  for (rmid = 0; rmid <= RM_MAX_ID; rmid++)
11652  {
11653  if (pg_strcasecmp(tok, RmgrTable[rmid].rm_name) == 0 &&
11654  RmgrTable[rmid].rm_mask != NULL)
11655  {
11656  newwalconsistency[rmid] = true;
11657  found = true;
11658  }
11659  }
11660  }
11661 
11662  /* If a valid resource manager is found, check for the next one. */
11663  if (!found)
11664  {
11665  GUC_check_errdetail("Unrecognized key word: \"%s\".", tok);
11666  pfree(rawstring);
11667  list_free(elemlist);
11668  return false;
11669  }
11670  }
11671 
11672  pfree(rawstring);
11673  list_free(elemlist);
11674 
11675  /* assign new value */
11676  *extra = guc_malloc(ERROR, (RM_MAX_ID + 1) * sizeof(bool));
11677  memcpy(*extra, newwalconsistency, (RM_MAX_ID + 1) * sizeof(bool));
11678  return true;
11679 }
#define GUC_check_errdetail
Definition: guc.h:422
char * pstrdup(const char *in)
Definition: mcxt.c:1299
const RmgrData RmgrTable[RM_MAX_ID+1]
Definition: rmgr.c:36
#define MemSet(start, val, len)
Definition: c.h:1008
int pg_strcasecmp(const char *s1, const char *s2)
Definition: pgstrcasecmp.c:36
void pfree(void *pointer)
Definition: mcxt.c:1169
#define ERROR
Definition: elog.h:46
bool SplitIdentifierString(char *rawstring, char separator, List **namelist)
Definition: varlena.c:3746
#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:169
#define newval
void list_free(List *list)
Definition: list.c:1391
static void * guc_malloc(int elevel, size_t size)
Definition: guc.c:5065
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 7060 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().

7062 {
7063  const struct config_enum_entry *entry;
7064  StringInfoData retstr;
7065  int seplen;
7066 
7067  initStringInfo(&retstr);
7068  appendStringInfoString(&retstr, prefix);
7069 
7070  seplen = strlen(separator);
7071  for (entry = record->options; entry && entry->name; entry++)
7072  {
7073  if (!entry->hidden)
7074  {
7075  appendStringInfoString(&retstr, entry->name);
7076  appendBinaryStringInfo(&retstr, separator, seplen);
7077  }
7078  }
7079 
7080  /*
7081  * All the entries may have been hidden, leaving the string empty if no
7082  * prefix was given. This indicates a broken GUC setup, since there is no
7083  * use for an enum without any values, so we just check to make sure we
7084  * don't write to invalid memory instead of actually trying to do
7085  * something smart with it.
7086  */
7087  if (retstr.len >= seplen)
7088  {
7089  /* Replace final separator */
7090  retstr.data[retstr.len - seplen] = '\0';
7091  retstr.len -= seplen;
7092  }
7093 
7094  appendStringInfoString(&retstr, suffix);
7095 
7096  return retstr.data;
7097 }
Definition: guc.h:164
const struct config_enum_entry * options
Definition: guc_tables.h:241
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 7034 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().

7036 {
7037  const struct config_enum_entry *entry;
7038 
7039  for (entry = record->options; entry && entry->name; entry++)
7040  {
7041  if (pg_strcasecmp(value, entry->name) == 0)
7042  {
7043  *retval = entry->val;
7044  return true;
7045  }
7046  }
7047 
7048  *retval = 0;
7049  return false;
7050 }
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:241
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 7011 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().

7012 {
7013  const struct config_enum_entry *entry;
7014 
7015  for (entry = record->options; entry && entry->name; entry++)
7016  {
7017  if (entry->val == val)
7018  return entry->name;
7019  }
7020 
7021  elog(ERROR, "could not find enum option %d for %s",
7022  val, record->gen.name);
7023  return NULL; /* silence compiler */
7024 }
Definition: guc.h:164
const char * name
Definition: guc_tables.h:141
#define ERROR
Definition: elog.h:46
const struct config_enum_entry * options
Definition: guc_tables.h:241
int val
Definition: guc.h:167
struct config_generic gen
Definition: guc_tables.h:237
const char * name
Definition: guc.h:166
#define elog(elevel,...)
Definition: elog.h:232
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 6717 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().

6719 {
6720  const unit_conversion *table;
6721  int i;
6722 
6723  *unit = NULL;
6724 
6725  if (base_unit & GUC_UNIT_MEMORY)
6727  else
6729 
6730  for (i = 0; *table[i].unit; i++)
6731  {
6732  if (base_unit == table[i].base_unit)
6733  {
6734  /*
6735  * Accept the first conversion that divides the value evenly. We
6736  * assume that the conversions for each base unit are ordered from
6737  * greatest unit to the smallest!
6738  */
6739  if (table[i].multiplier <= 1.0 ||
6740  base_value % (int64) table[i].multiplier == 0)
6741  {
6742  *value = (int64) rint(base_value / table[i].multiplier);
6743  *unit = table[i].unit;
6744  break;
6745  }
6746  }
6747  }
6748 
6749  Assert(*unit != NULL);
6750 }
static const unit_conversion time_unit_conversion_table[]
Definition: guc.c:915
static const unit_conversion memory_unit_conversion_table[]
Definition: guc.c:878
static struct @143 value
#define Assert(condition)
Definition: c.h:804
int i
char unit[MAX_UNIT_LEN+1]
Definition: guc.c:862
#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 6759 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().

6761 {
6762  const unit_conversion *table;
6763  int i;
6764 
6765  *unit = NULL;
6766 
6767  if (base_unit & GUC_UNIT_MEMORY)
6769  else
6771 
6772  for (i = 0; *table[i].unit; i++)
6773  {
6774  if (base_unit == table[i].base_unit)
6775  {
6776  /*
6777  * Accept the first conversion that divides the value evenly; or
6778  * if there is none, use the smallest (last) target unit.
6779  *
6780  * What we actually care about here is whether snprintf with "%g"
6781  * will print the value as an integer, so the obvious test of
6782  * "*value == rint(*value)" is too strict; roundoff error might
6783  * make us choose an unreasonably small unit. As a compromise,
6784  * accept a divisor that is within 1e-8 of producing an integer.
6785  */
6786  *value = base_value / table[i].multiplier;
6787  *unit = table[i].unit;
6788  if (*value > 0 &&
6789  fabs((rint(*value) / *value) - 1.0) <= 1e-8)
6790  break;
6791  }
6792  }
6793 
6794  Assert(*unit != NULL);
6795 }
static const unit_conversion time_unit_conversion_table[]
Definition: guc.c:915
static const unit_conversion memory_unit_conversion_table[]
Definition: guc.c:878
static struct @143 value
#define Assert(condition)
Definition: c.h:804
double multiplier
Definition: guc.c:865
e
Definition: preproc-init.c:82
int i
char unit[MAX_UNIT_LEN+1]
Definition: guc.c:862
#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 6659 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().

6661 {
6662  char unitstr[MAX_UNIT_LEN + 1];
6663  int unitlen;
6664  const unit_conversion *table;
6665  int i;
6666 
6667  /* extract unit string to compare to table entries */
6668  unitlen = 0;
6669  while (*unit != '\0' && !isspace((unsigned char) *unit) &&
6670  unitlen < MAX_UNIT_LEN)
6671  unitstr[unitlen++] = *(unit++);
6672  unitstr[unitlen] = '\0';
6673  /* allow whitespace after unit */
6674  while (isspace((unsigned char) *unit))
6675  unit++;
6676  if (*unit != '\0')
6677  return false; /* unit too long, or garbage after it */
6678 
6679  /* now search the appropriate table */
6680  if (base_unit & GUC_UNIT_MEMORY)
6682  else
6684 
6685  for (i = 0; *table[i].unit; i++)
6686  {
6687  if (base_unit == table[i].base_unit &&
6688  strcmp(unitstr, table[i].unit) == 0)
6689  {
6690  double cvalue = value * table[i].multiplier;
6691 
6692  /*
6693  * If the user gave a fractional value such as "30.1GB", round it
6694  * off to the nearest multiple of the next smaller unit, if there
6695  * is one.
6696  */
6697  if (*table[i + 1].unit &&
6698  base_unit == table[i + 1].base_unit)
6699  cvalue = rint(cvalue / table[i + 1].multiplier) *
6700  table[i + 1].multiplier;
6701 
6702  *base_value = cvalue;
6703  return true;
6704  }
6705  }
6706  return false;
6707 }
static const unit_conversion time_unit_conversion_table[]
Definition: guc.c:915
static const unit_conversion memory_unit_conversion_table[]
Definition: guc.c:878
#define MAX_UNIT_LEN
Definition: guc.c:858
static struct @143 value
double multiplier
Definition: guc.c:865
int i
char unit[MAX_UNIT_LEN+1]
Definition: guc.c:862
#define GUC_UNIT_MEMORY
Definition: guc.h:223

◆ define_custom_variable()

static void define_custom_variable ( struct config_generic variable)
static

Definition at line 8993 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().

8994 {
8995  const char *name = variable->name;
8996  const char **nameAddr = &name;
8997  struct config_string *pHolder;
8998  struct config_generic **res;
8999 
9000  /*
9001  * See if there's a placeholder by the same name.
9002  */
9003  res = (struct config_generic **) bsearch((void *) &nameAddr,
9004  (void *) guc_variables,
9006  sizeof(struct config_generic *),
9007  guc_var_compare);
9008  if (res == NULL)
9009  {
9010  /*
9011  * No placeholder to replace, so we can just add it ... but first,
9012  * make sure it's initialized to its default value.
9013  */
9014  InitializeOneGUCOption(variable);
9015  add_guc_variable(variable, ERROR);
9016  return;
9017  }
9018 
9019  /*
9020  * This better be a placeholder
9021  */
9022  if (((*res)->flags & GUC_CUSTOM_PLACEHOLDER) == 0)
9023  ereport(ERROR,
9024  (errcode(ERRCODE_INTERNAL_ERROR),
9025  errmsg("attempt to redefine parameter \"%s\"", name)));
9026 
9027  Assert((*res)->vartype == PGC_STRING);
9028  pHolder = (struct config_string *) (*res);
9029 
9030  /*
9031  * First, set the variable to its default value. We must do this even
9032  * though we intend to immediately apply a new value, since it's possible
9033  * that the new value is invalid.
9034  */
9035  InitializeOneGUCOption(variable);
9036 
9037  /*
9038  * Replace the placeholder. We aren't changing the name, so no re-sorting
9039  * is necessary
9040  */
9041  *res = variable;
9042 
9043  /*
9044  * Assign the string value(s) stored in the placeholder to the real
9045  * variable. Essentially, we need to duplicate all the active and stacked
9046  * values, but with appropriate validation and datatype adjustment.
9047  *
9048  * If an assignment fails, we report a WARNING and keep going. We don't
9049  * want to throw ERROR for bad values, because it'd bollix the add-on
9050  * module that's presumably halfway through getting loaded. In such cases
9051  * the default or previous state will become active instead.
9052  */
9053 
9054  /* First, apply the reset value if any */
9055  if (pHolder->reset_val)
9056  (void) set_config_option(name, pHolder->reset_val,
9057  pHolder->gen.reset_scontext,
9058  pHolder->gen.reset_source,
9059  GUC_ACTION_SET, true, WARNING, false);
9060  /* That should not have resulted in stacking anything */
9061  Assert(variable->stack == NULL);
9062 
9063  /* Now, apply current and stacked values, in the order they were stacked */
9064  reapply_stacked_values(variable, pHolder, pHolder->gen.stack,
9065  *(pHolder->variable),
9066  pHolder->gen.scontext, pHolder->gen.source);
9067 
9068  /* Also copy over any saved source-location information */
9069  if (pHolder->gen.sourcefile)
9070  set_config_sourcefile(name, pHolder->gen.sourcefile,
9071  pHolder->gen.sourceline);
9072 
9073  /*
9074  * Free up as much as we conveniently can of the placeholder structure.
9075  * (This neglects any stack items, so it's possible for some memory to be
9076  * leaked. Since this can only happen once per session per variable, it
9077  * doesn't seem worth spending much code on.)
9078  */
9079  set_string_field(pHolder, pHolder->variable, NULL);
9080  set_string_field(pHolder, &pHolder->reset_val, NULL);
9081 
9082  free(pHolder);
9083 }
GucSource source
Definition: guc_tables.h:150
static void static void set_config_sourcefile(const char *name, char *sourcefile, int sourceline)
Definition: guc.c:8076
char ** variable
Definition: guc_tables.h:225
const char * name
Definition: guc_tables.h:141
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:9093
int errcode(int sqlerrcode)
Definition: elog.c:698
GucContext scontext
Definition: guc_tables.h:152
static int guc_var_compare(const void *a, const void *b)
Definition: guc.c:5580
#define ERROR
Definition: elog.h:46
static int num_guc_variables
Definition: guc.c:5025
char * sourcefile
Definition: guc_tables.h:158
GucSource reset_source
Definition: guc_tables.h:151
static void InitializeOneGUCOption(struct config_generic *gconf)
Definition: guc.c:5728
static void set_string_field(struct config_string *conf, char **field, char *newval)
Definition: guc.c:5137
static struct config_generic ** guc_variables
Definition: guc.c:5022
#define WARNING
Definition: elog.h:40
#define ereport(elevel,...)
Definition: elog.h:157
struct config_generic gen
Definition: guc_tables.h:223
#define free(a)
Definition: header.h:65
char * reset_val
Definition: guc_tables.h:231
#define Assert(condition)
Definition: c.h:804
#define GUC_CUSTOM_PLACEHOLDER
Definition: guc.h:211
const char * name
Definition: encode.c:561
int errmsg(const char *fmt,...)
Definition: elog.c:909
GucStack * stack
Definition: guc_tables.h:154
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:7319
static bool add_guc_variable(struct config_generic *var, int elevel)
Definition: guc.c:5375
GucContext reset_scontext
Definition: guc_tables.h:153

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

9184 {
9185  struct config_bool *var;
9186 
9187  var = (struct config_bool *)
9188  init_custom_variable(name, short_desc, long_desc, context, flags,
9189  PGC_BOOL, sizeof(struct config_bool));
9190  var->variable = valueAddr;
9191  var->boot_val = bootValue;
9192  var->reset_val = bootValue;
9193  var->check_hook = check_hook;
9194  var->assign_hook = assign_hook;
9195  var->show_hook = show_hook;
9196  define_custom_variable(&var->gen);
9197 }
bool * variable
Definition: guc_tables.h:179
GucBoolAssignHook assign_hook
Definition: guc_tables.h:182
bool boot_val
Definition: guc_tables.h:180
struct config_generic gen
Definition: guc_tables.h:177
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:8933
GucBoolCheckHook check_hook
Definition: guc_tables.h:181
GucShowHook show_hook
Definition: guc_tables.h:183
const char * name
Definition: encode.c:561
bool reset_val
Definition: guc_tables.h:185
static void define_custom_variable(struct config_generic *variable)
Definition: guc.c:8993

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

9296 {
9297  struct config_enum *var;
9298 
9299  var = (struct config_enum *)
9300  init_custom_variable(name, short_desc, long_desc, context, flags,
9301  PGC_ENUM, sizeof(struct config_enum));
9302  var->variable = valueAddr;
9303  var->boot_val = bootValue;
9304  var->reset_val = bootValue;
9305  var->options = options;
9306  var->check_hook = check_hook;
9307  var->assign_hook = assign_hook;
9308  var->show_hook = show_hook;
9309  define_custom_variable(&var->gen);
9310 }
GucEnumCheckHook check_hook
Definition: guc_tables.h:242
GucEnumAssignHook assign_hook
Definition: guc_tables.h:243
int * variable
Definition: guc_tables.h:239
const struct config_enum_entry * options
Definition: guc_tables.h:241
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:8933
GucShowHook show_hook
Definition: guc_tables.h:244
struct config_generic gen
Definition: guc_tables.h:237
const char * name
Definition: encode.c:561
static void define_custom_variable(struct config_generic *variable)
Definition: guc.c:8993

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

9212 {
9213  struct config_int *var;
9214 
9215  var = (struct config_int *)
9216  init_custom_variable(name, short_desc, long_desc, context, flags,
9217  PGC_INT, sizeof(struct config_int));
9218  var->variable = valueAddr;
9219  var->boot_val = bootValue;
9220  var->reset_val = bootValue;
9221  var->min = minValue;
9222  var->max = maxValue;
9223  var->check_hook = check_hook;
9224  var->assign_hook = assign_hook;
9225  var->show_hook = show_hook;
9226  define_custom_variable(&var->gen);
9227 }
int boot_val
Definition: guc_tables.h:194
GucIntAssignHook assign_hook
Definition: guc_tables.h:198
GucIntCheckHook check_hook
Definition: guc_tables.h:197
GucShowHook show_hook
Definition: guc_tables.h:199
int * variable
Definition: guc_tables.h:193
struct config_generic gen
Definition: guc_tables.h:191
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:8933
const char * name
Definition: encode.c:561
static void define_custom_variable(struct config_generic *variable)
Definition: guc.c:8993
int reset_val
Definition: guc_tables.h:201

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

9242 {
9243  struct config_real *var;
9244 
9245  var = (struct config_real *)
9246  init_custom_variable(name, short_desc, long_desc, context, flags,
9247  PGC_REAL, sizeof(struct config_real));
9248  var->variable = valueAddr;
9249  var->boot_val = bootValue;
9250  var->reset_val = bootValue;
9251  var->min = minValue;
9252  var->max = maxValue;
9253  var->check_hook = check_hook;
9254  var->assign_hook = assign_hook;
9255  var->show_hook = show_hook;
9256  define_custom_variable(&var->gen);
9257 }
GucRealAssignHook assign_hook
Definition: guc_tables.h:214
double reset_val
Definition: guc_tables.h:217
GucRealCheckHook check_hook
Definition: guc_tables.h:213
GucShowHook show_hook
Definition: guc_tables.h:215
double * variable
Definition: guc_tables.h:209
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:8933
double max
Definition: guc_tables.h:212
double boot_val
Definition: guc_tables.h:210
const char * name
Definition: encode.c:561
double min
Definition: guc_tables.h:211
static void define_custom_variable(struct config_generic *variable)
Definition: guc.c:8993
struct config_generic gen
Definition: guc_tables.h:207

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

9270 {
9271  struct config_string *var;
9272 
9273  var = (struct config_string *)
9274  init_custom_variable(name, short_desc, long_desc, context, flags,
9275  PGC_STRING, sizeof(struct config_string));
9276  var->variable = valueAddr;
9277  var->boot_val = bootValue;
9278  var->check_hook = check_hook;
9279  var->assign_hook = assign_hook;
9280  var->show_hook = show_hook;
9281  define_custom_variable(&var->gen);
9282 }
char ** variable
Definition: guc_tables.h:225
GucStringCheckHook check_hook
Definition: guc_tables.h:227
const char * boot_val
Definition: guc_tables.h:226
GucShowHook show_hook
Definition: guc_tables.h:229
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:8933
struct config_generic gen
Definition: guc_tables.h:223
GucStringAssignHook assign_hook
Definition: guc_tables.h:228
const char * name
Definition: encode.c:561
static void define_custom_variable(struct config_generic *variable)
Definition: guc.c:8993

◆ discard_stack_value()

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

Definition at line 5252 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().

5253 {
5254  switch (gconf->vartype)
5255  {
5256  case PGC_BOOL:
5257  case PGC_INT:
5258  case PGC_REAL:
5259  case PGC_ENUM:
5260  /* no need to do anything */
5261  break;
5262  case PGC_STRING:
5263  set_string_field((struct config_string *) gconf,
5264  &(val->val.stringval),
5265  NULL);
5266  break;
5267  }
5268  set_extra_field(gconf, &(val->extra), NULL);
5269 }
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:5198
static void set_string_field(struct config_string *conf, char **field, char *newval)
Definition: guc.c:5137
enum config_type vartype
Definition: guc_tables.h:148
char * stringval
Definition: guc_tables.h:36

◆ do_serialize()

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

Definition at line 10631 of file guc.c.

References elog, ERROR, and vsnprintf.

Referenced by serialize_variable().

10632 {
10633  va_list vargs;
10634  int n;
10635 
10636  if (*maxbytes <= 0)
10637  elog(ERROR, "not enough space to serialize GUC state");
10638 
10639  va_start(vargs, fmt);
10640  n = vsnprintf(*destptr, *maxbytes, fmt, vargs);
10641  va_end(vargs);
10642 
10643  if (n < 0)
10644  {
10645  /* Shouldn't happen. Better show errno description. */
10646  elog(ERROR, "vsnprintf failed: %m with format string \"%s\"", fmt);
10647  }
10648  if (n >= *maxbytes)
10649  {
10650  /* This shouldn't happen either, really. */
10651  elog(ERROR, "not enough space to serialize GUC state");
10652  }
10653 
10654  /* Shift the destptr ahead of the null terminator */
10655  *destptr += n + 1;
10656  *maxbytes -= n + 1;
10657 }
#define ERROR
Definition: elog.h:46
#define vsnprintf
Definition: port.h:216
#define elog(elevel,...)
Definition: elog.h:232

◆ do_serialize_binary()

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

Definition at line 10661 of file guc.c.

References elog, and ERROR.

Referenced by serialize_variable().

10662 {
10663  if (valsize > *maxbytes)
10664  elog(ERROR, "not enough space to serialize GUC state");
10665 
10666  memcpy(*destptr, val, valsize);
10667  *destptr += valsize;
10668  *maxbytes -= valsize;
10669 }
#define ERROR
Definition: elog.h:46
#define elog(elevel,...)
Definition: elog.h:232
long val
Definition: informix.c:664

◆ EmitWarningsOnPlaceholders()

void EmitWarningsOnPlaceholders ( const char *  className)

Definition at line 9313 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().

9314 {
9315  int classLen = strlen(className);
9316  int i;
9317 
9318  for (i = 0; i < num_guc_variables; i++)
9319  {
9320  struct config_generic *var = guc_variables[i];
9321 
9322  if ((var->flags & GUC_CUSTOM_PLACEHOLDER) != 0 &&
9323  strncmp(className, var->name, classLen) == 0 &&
9324  var->name[classLen] == GUC_QUALIFIER_SEPARATOR)
9325  {
9326  ereport(WARNING,
9327  (errcode(ERRCODE_UNDEFINED_OBJECT),
9328  errmsg("unrecognized configuration parameter \"%s\"",
9329  var->name)));
9330  }
9331  }
9332 }
const char * name
Definition: guc_tables.h:141
int errcode(int sqlerrcode)
Definition: elog.c:698
#define GUC_QUALIFIER_SEPARATOR
Definition: guc.h:199
static int num_guc_variables
Definition: guc.c:5025
static struct config_generic ** guc_variables
Definition: guc.c:5022
#define WARNING
Definition: elog.h:40
#define ereport(elevel,...)
Definition: elog.h:157
#define GUC_CUSTOM_PLACEHOLDER
Definition: guc.h:211
int errmsg(const char *fmt,...)
Definition: elog.c:909
int i

◆ estimate_variable_size()

static Size estimate_variable_size ( struct config_generic gconf)
static

Definition at line 10509 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().

10510 {
10511  Size size;
10512  Size valsize = 0;
10513 
10514  /* Skippable GUCs consume zero space. */
10515  if (can_skip_gucvar(gconf))
10516  return 0;
10517 
10518  /* Name, plus trailing zero byte. */
10519  size = strlen(gconf->name) + 1;
10520 
10521  /* Get the maximum display length of the GUC value. */
10522  switch (gconf->vartype)
10523  {
10524  case PGC_BOOL:
10525  {
10526  valsize = 5; /* max(strlen('true'), strlen('false')) */
10527  }
10528  break;
10529 
10530  case PGC_INT:
10531  {
10532  struct config_int *conf = (struct config_int *) gconf;
10533 
10534  /*
10535  * Instead of getting the exact display length, use max
10536  * length. Also reduce the max length for typical ranges of
10537  * small values. Maximum value is 2147483647, i.e. 10 chars.
10538  * Include one byte for sign.
10539  */
10540  if (Abs(*conf->variable) < 1000)
10541  valsize = 3 + 1;
10542  else
10543  valsize = 10 + 1;
10544  }
10545  break;
10546 
10547  case PGC_REAL:
10548  {
10549  /*
10550  * We are going to print it with %e with REALTYPE_PRECISION
10551  * fractional digits. Account for sign, leading digit,
10552  * decimal point, and exponent with up to 3 digits. E.g.
10553  * -3.99329042340000021e+110
10554  */
10555  valsize = 1 + 1 + 1 + REALTYPE_PRECISION + 5;
10556  }
10557  break;
10558 
10559  case PGC_STRING:
10560  {
10561  struct config_string *conf = (struct config_string *) gconf;
10562 
10563  /*
10564  * If the value is NULL, we transmit it as an empty string.
10565  * Although this is not physically the same value, GUC
10566  * generally treats a NULL the same as empty string.
10567  */
10568  if (*conf->variable)
10569  valsize = strlen(*conf->variable);
10570  else
10571  valsize = 0;
10572  }
10573  break;
10574 
10575  case PGC_ENUM:
10576  {
10577  struct config_enum *conf = (struct config_enum *) gconf;
10578 
10579  valsize = strlen(config_enum_lookup_by_value(conf, *conf->variable));
10580  }
10581  break;
10582  }
10583 
10584  /* Allow space for terminating zero-byte for value */
10585  size = add_size(size, valsize + 1);
10586 
10587  if (gconf->sourcefile)
10588  size = add_size(size, strlen(gconf->sourcefile));
10589 
10590  /* Allow space for terminating zero-byte for sourcefile */
10591  size = add_size(size, 1);
10592 
10593  /* Include line whenever file is nonempty. */
10594  if (gconf->sourcefile && gconf->sourcefile[0])
10595  size = add_size(size, sizeof(gconf->sourceline));
10596 
10597  size = add_size(size, sizeof(gconf->source));
10598  size = add_size(size, sizeof(gconf->scontext));
10599 
10600  return size;
10601 }
GucSource source
Definition: guc_tables.h:150
char ** variable
Definition: guc_tables.h:225
const char * name
Definition: guc_tables.h:141
const char * config_enum_lookup_by_value(struct config_enum *record, int val)
Definition: guc.c:7011
GucContext scontext
Definition: guc_tables.h:152
#define Abs(x)
Definition: c.h:992
int * variable
Definition: guc_tables.h:193
int * variable
Definition: guc_tables.h:239
char * sourcefile
Definition: guc_tables.h:158
static bool can_skip_gucvar(struct config_generic *gconf)
Definition: guc.c:10469
#define REALTYPE_PRECISION
Definition: guc.c:129
enum config_type vartype
Definition: guc_tables.h:148
Size add_size(Size s1, Size s2)
Definition: shmem.c:502
size_t Size
Definition: c.h:540

◆ EstimateGUCStateSpace()

Size EstimateGUCStateSpace ( void  )

Definition at line 10608 of file guc.c.

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

Referenced by InitializeParallelDSM().

10609 {
10610  Size size;
10611  int i;
10612 
10613  /* Add space reqd for saving the data size of the guc state */
10614  size = sizeof(Size);
10615 
10616  /* Add up the space needed for each GUC variable */
10617  for (i = 0; i < num_guc_variables; i++)
10618  size = add_size(size,
10620 
10621  return size;
10622 }
static int num_guc_variables
Definition: guc.c:5025
static struct config_generic ** guc_variables
Definition: guc.c:5022
Size add_size(Size s1, Size s2)
Definition: shmem.c:502
size_t Size
Definition: c.h:540
static Size estimate_variable_size(struct config_generic *gconf)
Definition: guc.c:10509
int i

◆ ExecSetVariableStmt()

void ExecSetVariableStmt ( VariableSetStmt stmt,
bool  isTopLevel 
)

Definition at line 8722 of file guc.c.

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

Referenced by standard_ProcessUtility().

8723 {
8725 
8726  /*
8727  * Workers synchronize these parameters at the start of the parallel
8728  * operation; then, we block SET during the operation.
8729  */
8730  if (IsInParallelMode())
8731  ereport(ERROR,
8732  (errcode(ERRCODE_INVALID_TRANSACTION_STATE),
8733  errmsg("cannot set parameters during a parallel operation")));
8734 
8735  switch (stmt->kind)
8736  {
8737  case VAR_SET_VALUE:
8738  case VAR_SET_CURRENT:
8739  if (stmt->is_local)
8740  WarnNoTransactionBlock(isTopLevel, "SET LOCAL");
8741  (void) set_config_option(stmt->name,
8742  ExtractSetVariableArgs(stmt),
8744  PGC_S_SESSION,
8745  action, true, 0, false);
8746  break;
8747  case VAR_SET_MULTI:
8748 
8749  /*
8750  * Special-case SQL syntaxes. The TRANSACTION and SESSION
8751  * CHARACTERISTICS cases effectively set more than one variable
8752  * per statement. TRANSACTION SNAPSHOT only takes one argument,
8753  * but we put it here anyway since it's a special case and not
8754  * related to any GUC variable.
8755  */
8756  if (strcmp(stmt->name, "TRANSACTION") == 0)
8757  {
8758  ListCell *head;
8759 
8760  WarnNoTransactionBlock(isTopLevel, "SET TRANSACTION");
8761 
8762  foreach(head, stmt->args)
8763  {
8764  DefElem *item = (DefElem *) lfirst(head);
8765 
8766  if (strcmp(item->defname, "transaction_isolation") == 0)
8767  SetPGVariable("transaction_isolation",
8768  list_make1(item->arg), stmt->is_local);
8769  else if (strcmp(item->defname, "transaction_read_only") == 0)
8770  SetPGVariable("transaction_read_only",
8771  list_make1(item->arg), stmt->is_local);
8772  else if (strcmp(item->defname, "transaction_deferrable") == 0)
8773  SetPGVariable("transaction_deferrable",
8774  list_make1(item->arg), stmt->is_local);
8775  else
8776  elog(ERROR, "unexpected SET TRANSACTION element: %s",
8777  item->defname);
8778  }
8779  }
8780  else if (strcmp(stmt->name, "SESSION CHARACTERISTICS") == 0)
8781  {
8782  ListCell *head;
8783 
8784  foreach(head, stmt->args)
8785  {
8786  DefElem *item = (DefElem *) lfirst(head);
8787 
8788  if (strcmp(item->defname, "transaction_isolation") == 0)
8789  SetPGVariable("default_transaction_isolation",
8790  list_make1(item->arg), stmt->is_local);
8791  else if (strcmp(item->defname, "transaction_read_only") == 0)
8792