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 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 856 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 9858 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 10104 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().

10105 {
10106  char buffer[256];
10107  const char *val;
10108 
10109  switch (record->vartype)
10110  {
10111  case PGC_BOOL:
10112  {
10113  struct config_bool *conf = (struct config_bool *) record;
10114 
10115  if (conf->show_hook)
10116  val = conf->show_hook();
10117  else
10118  val = *conf->variable ? "on" : "off";
10119  }
10120  break;
10121 
10122  case PGC_INT:
10123  {
10124  struct config_int *conf = (struct config_int *) record;
10125 
10126  if (conf->show_hook)
10127  val = conf->show_hook();
10128  else
10129  {
10130  /*
10131  * Use int64 arithmetic to avoid overflows in units
10132  * conversion.
10133  */
10134  int64 result = *conf->variable;
10135  const char *unit;
10136 
10137  if (use_units && result > 0 && (record->flags & GUC_UNIT))
10139  record->flags & GUC_UNIT,
10140  &result, &unit);
10141  else
10142  unit = "";
10143 
10144  snprintf(buffer, sizeof(buffer), INT64_FORMAT "%s",
10145  result, unit);
10146  val = buffer;
10147  }
10148  }
10149  break;
10150 
10151  case PGC_REAL:
10152  {
10153  struct config_real *conf = (struct config_real *) record;
10154 
10155  if (conf->show_hook)
10156  val = conf->show_hook();
10157  else
10158  {
10159  double result = *conf->variable;
10160  const char *unit;
10161 
10162  if (use_units && result > 0 && (record->flags & GUC_UNIT))
10164  record->flags & GUC_UNIT,
10165  &result, &unit);
10166  else
10167  unit = "";
10168 
10169  snprintf(buffer, sizeof(buffer), "%g%s",
10170  result, unit);
10171  val = buffer;
10172  }
10173  }
10174  break;
10175 
10176  case PGC_STRING:
10177  {
10178  struct config_string *conf = (struct config_string *) record;
10179 
10180  if (conf->show_hook)
10181  val = conf->show_hook();
10182  else if (*conf->variable && **conf->variable)
10183  val = *conf->variable;
10184  else
10185  val = "";
10186  }
10187  break;
10188 
10189  case PGC_ENUM:
10190  {
10191  struct config_enum *conf = (struct config_enum *) record;
10192 
10193  if (conf->show_hook)
10194  val = conf->show_hook();
10195  else
10196  val = config_enum_lookup_by_value(conf, *conf->variable);
10197  }
10198  break;
10199 
10200  default:
10201  /* just to keep compiler quiet */
10202  val = "???";
10203  break;
10204  }
10205 
10206  return pstrdup(val);
10207 }
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:6987
#define GUC_UNIT
Definition: guc.h:232
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:6735
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:6693
#define snprintf
Definition: port.h:216
long val
Definition: informix.c:664

◆ add_guc_variable()

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

Definition at line 5351 of file guc.c.

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

Referenced by add_placeholder_variable(), and define_custom_variable().

5352 {
5354  {
5355  /*
5356  * Increase the vector by 25%
5357  */
5358  int size_vars = size_guc_variables + size_guc_variables / 4;
5359  struct config_generic **guc_vars;
5360 
5361  if (size_vars == 0)
5362  {
5363  size_vars = 100;
5364  guc_vars = (struct config_generic **)
5365  guc_malloc(elevel, size_vars * sizeof(struct config_generic *));
5366  }
5367  else
5368  {
5369  guc_vars = (struct config_generic **)
5370  guc_realloc(elevel, guc_variables, size_vars * sizeof(struct config_generic *));
5371  }
5372 
5373  if (guc_vars == NULL)
5374  return false; /* out of memory */
5375 
5376  guc_variables = guc_vars;
5377  size_guc_variables = size_vars;
5378  }
5381  sizeof(struct config_generic *), guc_var_compare);
5382  return true;
5383 }
static int guc_var_compare(const void *a, const void *b)
Definition: guc.c:5556
static int num_guc_variables
Definition: guc.c:5001
static void * guc_realloc(int elevel, void *old, size_t size)
Definition: guc.c:5057
static struct config_generic ** guc_variables
Definition: guc.c:4998
static int size_guc_variables
Definition: guc.c:5004
static int elevel
Definition: vacuumlazy.c:403
#define qsort(a, b, c, d)
Definition: port.h:504
static void * guc_malloc(int elevel, size_t size)
Definition: guc.c:5041

◆ add_placeholder_variable()

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

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

5430 {
5431  size_t sz = sizeof(struct config_string) + sizeof(char *);
5432  struct config_string *var;
5433  struct config_generic *gen;
5434 
5435  var = (struct config_string *) guc_malloc(elevel, sz);
5436  if (var == NULL)
5437  return NULL;
5438  memset(var, 0, sz);
5439  gen = &var->gen;
5440 
5441  gen->name = guc_strdup(elevel, name);
5442  if (gen->name == NULL)
5443  {
5444  free(var);
5445  return NULL;
5446  }
5447 
5448  gen->context = PGC_USERSET;
5449  gen->group = CUSTOM_OPTIONS;
5450  gen->short_desc = "GUC placeholder variable";
5452  gen->vartype = PGC_STRING;
5453 
5454  /*
5455  * The char* is allocated at the end of the struct since we have no
5456  * 'static' place to point to. Note that the current value, as well as
5457  * the boot and reset values, start out NULL.
5458  */
5459  var->variable = (char **) (var + 1);
5460 
5461  if (!add_guc_variable((struct config_generic *) var, elevel))
5462  {
5463  free(unconstify(char *, gen->name));
5464  free(var);
5465  return NULL;
5466  }
5467 
5468  return gen;
5469 }
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:5073
#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:403
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:515
enum config_group group
Definition: guc_tables.h:143
static void * guc_malloc(int elevel, size_t size)
Definition: guc.c:5041
GucContext context
Definition: guc_tables.h:142
static bool add_guc_variable(struct config_generic *var, int elevel)
Definition: guc.c:5351

◆ AlterSystemSetConfigFile()

void AlterSystemSetConfigFile ( AlterSystemStmt altersysstmt)

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

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

◆ assign_application_name()

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

Definition at line 12133 of file guc.c.

References pgstat_report_appname().

12134 {
12135  /* Update the pg_stat_activity view */
12137 }
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 12252 of file guc.c.

12253 {
12254  backtrace_symbol_list = (char *) extra;
12255 }
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 11722 of file guc.c.

References Log_destination.

11723 {
11724  Log_destination = *((int *) extra);
11725 }
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 12095 of file guc.c.

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

12096 {
12097  /* check_canonical_path already canonicalized newval for us */
12098  char *dname;
12099  char *tname;
12100  char *fname;
12101 
12102  /* directory */
12103  dname = guc_malloc(ERROR, strlen(newval) + 1); /* runtime dir */
12104  sprintf(dname, "%s", newval);
12105 
12106  /* global stats */
12107  tname = guc_malloc(ERROR, strlen(newval) + 12); /* /global.tmp */
12108  sprintf(tname, "%s/global.tmp", newval);
12109  fname = guc_malloc(ERROR, strlen(newval) + 13); /* /global.stat */
12110  sprintf(fname, "%s/global.stat", newval);
12111 
12114  pgstat_stat_directory = dname;
12115  if (pgstat_stat_tmpname)
12117  pgstat_stat_tmpname = tname;
12120  pgstat_stat_filename = fname;
12121 }
#define sprintf
Definition: port.h:218
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:5041

◆ assign_recovery_target()

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

Definition at line 12331 of file guc.c.

References RECOVERY_TARGET_IMMEDIATE, RECOVERY_TARGET_UNSET, and recoveryTarget.

12332 {
12335  error_multiple_recovery_targets();
12336 
12337  if (newval && strcmp(newval, "") != 0)
12339  else
12341 }
#define newval
RecoveryTargetType recoveryTarget
Definition: xlog.c:285

◆ assign_recovery_target_lsn()

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

Definition at line 12499 of file guc.c.

References RECOVERY_TARGET_LSN, RECOVERY_TARGET_UNSET, recoveryTarget, and recoveryTargetLSN.

12500 {
12503  error_multiple_recovery_targets();
12504 
12505  if (newval && strcmp(newval, "") != 0)
12506  {
12508  recoveryTargetLSN = *((XLogRecPtr *) extra);
12509  }
12510  else
12512 }
XLogRecPtr recoveryTargetLSN
Definition: xlog.c:292
uint64 XLogRecPtr
Definition: xlogdefs.h:21
#define newval
RecoveryTargetType recoveryTarget
Definition: xlog.c:285

◆ assign_recovery_target_name()

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

Definition at line 12463 of file guc.c.

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

12464 {
12467  error_multiple_recovery_targets();
12468 
12469  if (newval && strcmp(newval, "") != 0)
12470  {
12473  }
12474  else
12476 }
const char * recoveryTargetName
Definition: xlog.c:291
#define newval
RecoveryTargetType recoveryTarget
Definition: xlog.c:285

◆ assign_recovery_target_time()

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

Definition at line 12437 of file guc.c.

References RECOVERY_TARGET_TIME, RECOVERY_TARGET_UNSET, and recoveryTarget.

12438 {
12441  error_multiple_recovery_targets();
12442 
12443  if (newval && strcmp(newval, "") != 0)
12445  else
12447 }
#define newval
RecoveryTargetType recoveryTarget
Definition: xlog.c:285

◆ assign_recovery_target_timeline()

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

Definition at line 12288 of file guc.c.

References RECOVERY_TARGET_TIMELINE_NUMERIC, recoveryTargetTimeLineGoal, and recoveryTargetTLIRequested.

12289 {
12292  recoveryTargetTLIRequested = (TimeLineID) strtoul(newval, NULL, 0);
12293  else
12295 }
TimeLineID recoveryTargetTLIRequested
Definition: xlog.c:342
uint32 TimeLineID
Definition: xlogdefs.h:59
RecoveryTargetTimeLineGoal
Definition: xlog.h:93
RecoveryTargetTimeLineGoal recoveryTargetTimeLineGoal
Definition: xlog.c:341
#define newval

◆ assign_recovery_target_xid()

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

Definition at line 12364 of file guc.c.

References RECOVERY_TARGET_UNSET, RECOVERY_TARGET_XID, recoveryTarget, and recoveryTargetXid.

12365 {
12368  error_multiple_recovery_targets();
12369 
12370  if (newval && strcmp(newval, "") != 0)
12371  {
12373  recoveryTargetXid = *((TransactionId *) extra);
12374  }
12375  else
12377 }
uint32 TransactionId
Definition: c.h:587
TransactionId recoveryTargetXid
Definition: xlog.c:288
#define newval
RecoveryTargetType recoveryTarget
Definition: xlog.c:285

◆ assign_session_replication_role()

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

Definition at line 11748 of file guc.c.

References ResetPlanCache(), and SessionReplicationRole.

11749 {
11750  /*
11751  * Must flush the plan cache when changing replication role; but don't
11752  * flush unnecessarily.
11753  */
11755  ResetPlanCache();
11756 }
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 11728 of file guc.c.

11729 {
11730 #ifdef HAVE_SYSLOG
11731  set_syslog_parameters(syslog_ident_str ? syslog_ident_str : "postgres",
11732  newval);
11733 #endif
11734  /* Without syslog support, just ignore it */
11735 }
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 11738 of file guc.c.

11739 {
11740 #ifdef HAVE_SYSLOG
11741  set_syslog_parameters(newval, syslog_facility);
11742 #endif
11743  /* Without syslog support, it will always be set to "none", so ignore */
11744 }
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 11948 of file guc.c.

References MyProcPort, and pq_setkeepalivescount().

11949 {
11950  /* See comments in assign_tcp_keepalives_idle */
11952 }
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 11904 of file guc.c.

References MyProcPort, and pq_setkeepalivesidle().

11905 {
11906  /*
11907  * The kernel API provides no way to test a value without setting it; and
11908  * once we set it we might fail to unset it. So there seems little point
11909  * in fully implementing the check-then-assign GUC API for these
11910  * variables. Instead we just do the assignment on demand. pqcomm.c
11911  * reports any problems via ereport(LOG).
11912  *
11913  * This approach means that the GUC value might have little to do with the
11914  * actual kernel value, so we use a show_hook that retrieves the kernel
11915  * value rather than trusting GUC's copy.
11916  */
11918 }
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 11931 of file guc.c.

References MyProcPort, and pq_setkeepalivesinterval().

11932 {
11933  /* See comments in assign_tcp_keepalives_idle */
11935 }
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 11965 of file guc.c.

References MyProcPort, and pq_settcpusertimeout().

11966 {
11967  /* See comments in assign_tcp_keepalives_idle */
11969 }
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 11868 of file guc.c.

References InstallTimeZoneAbbrevs().

11869 {
11870  /* Do nothing for the boot_val default of NULL */
11871  if (!extra)
11872  return;
11873 
11875 }
void InstallTimeZoneAbbrevs(TimeZoneAbbrevTable *tbl)
Definition: datetime.c:4615

◆ assign_wal_consistency_checking()

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

Definition at line 11659 of file guc.c.

References wal_consistency_checking.

11660 {
11661  wal_consistency_checking = (bool *) extra;
11662 }
bool * wal_consistency_checking
Definition: xlog.c:103

◆ AtEOXact_GUC()

void AtEOXact_GUC ( bool  isCommit,
int  nestLevel 
)

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

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

References elog, and WARNING.

Referenced by StartTransaction().

6185 {
6186  /*
6187  * The nest level should be 0 between transactions; if it isn't, somebody
6188  * didn't call AtEOXact_GUC, or called it with the wrong nestLevel. We
6189  * throw a warning but make no other effort to clean up.
6190  */
6191  if (GUCNestLevel != 0)
6192  elog(WARNING, "GUC nest level = %d at transaction start",
6193  GUCNestLevel);
6194  GUCNestLevel = 1;
6195 }
static int GUCNestLevel
Definition: guc.c:5013
#define WARNING
Definition: elog.h:40
#define elog(elevel,...)
Definition: elog.h:232

◆ BeginReportingGUCOptions()

void BeginReportingGUCOptions ( void  )

Definition at line 6503 of file guc.c.

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

Referenced by PostgresMain().

6504 {
6505  int i;
6506 
6507  /*
6508  * Don't do anything unless talking to an interactive frontend.
6509  */
6511  return;
6512 
6513  reporting_enabled = true;
6514 
6515  /*
6516  * Hack for in_hot_standby: initialize with the value we're about to send.
6517  * (This could be out of date by the time we actually send it, in which
6518  * case the next ReportChangedGUCOptions call will send a duplicate
6519  * report.)
6520  */
6522 
6523  /* Transmit initial values of interesting variables */
6524  for (i = 0; i < num_guc_variables; i++)
6525  {
6526  struct config_generic *conf = guc_variables[i];
6527 
6528  if (conf->flags & GUC_REPORT)
6529  ReportGUCOption(conf);
6530  }
6531 
6532  report_needed = false;
6533 }
static bool report_needed
Definition: guc.c:5011
static bool in_hot_standby
Definition: guc.c:671
bool RecoveryInProgress(void)
Definition: xlog.c:8248
static int num_guc_variables
Definition: guc.c:5001
#define GUC_REPORT
Definition: guc.h:208
static struct config_generic ** guc_variables
Definition: guc.c:4998
int i
static void ReportGUCOption(struct config_generic *record)
Definition: guc.c:6595
CommandDest whereToSendOutput
Definition: postgres.c:92
static bool reporting_enabled
Definition: guc.c:5009

◆ build_guc_variables()

void build_guc_variables ( void  )

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

5265 {
5266  int size_vars;
5267  int num_vars = 0;
5268  struct config_generic **guc_vars;
5269  int i;
5270 
5271  for (i = 0; ConfigureNamesBool[i].gen.name; i++)
5272  {
5273  struct config_bool *conf = &ConfigureNamesBool[i];
5274 
5275  /* Rather than requiring vartype to be filled in by hand, do this: */
5276  conf->gen.vartype = PGC_BOOL;
5277  num_vars++;
5278  }
5279 
5280  for (i = 0; ConfigureNamesInt[i].gen.name; i++)
5281  {
5282  struct config_int *conf = &ConfigureNamesInt[i];
5283 
5284  conf->gen.vartype = PGC_INT;
5285  num_vars++;
5286  }
5287 
5288  for (i = 0; ConfigureNamesReal[i].gen.name; i++)
5289  {
5290  struct config_real *conf = &ConfigureNamesReal[i];
5291 
5292  conf->gen.vartype = PGC_REAL;
5293  num_vars++;
5294  }
5295 
5296  for (i = 0; ConfigureNamesString[i].gen.name; i++)
5297  {
5298  struct config_string *conf = &ConfigureNamesString[i];
5299 
5300  conf->gen.vartype = PGC_STRING;
5301  num_vars++;
5302  }
5303 
5304  for (i = 0; ConfigureNamesEnum[i].gen.name; i++)
5305  {
5306  struct config_enum *conf = &ConfigureNamesEnum[i];
5307 
5308  conf->gen.vartype = PGC_ENUM;
5309  num_vars++;
5310  }
5311 
5312  /*
5313  * Create table with 20% slack
5314  */
5315  size_vars = num_vars + num_vars / 4;
5316 
5317  guc_vars = (struct config_generic **)
5318  guc_malloc(FATAL, size_vars * sizeof(struct config_generic *));
5319 
5320  num_vars = 0;
5321 
5322  for (i = 0; ConfigureNamesBool[i].gen.name; i++)
5323  guc_vars[num_vars++] = &ConfigureNamesBool[i].gen;
5324 
5325  for (i = 0; ConfigureNamesInt[i].gen.name; i++)
5326  guc_vars[num_vars++] = &ConfigureNamesInt[i].gen;
5327 
5328  for (i = 0; ConfigureNamesReal[i].gen.name; i++)
5329  guc_vars[num_vars++] = &ConfigureNamesReal[i].gen;
5330 
5331  for (i = 0; ConfigureNamesString[i].gen.name; i++)
5332  guc_vars[num_vars++] = &ConfigureNamesString[i].gen;
5333 
5334  for (i = 0; ConfigureNamesEnum[i].gen.name; i++)
5335  guc_vars[num_vars++] = &ConfigureNamesEnum[i].gen;
5336 
5337  if (guc_variables)
5339  guc_variables = guc_vars;
5340  num_guc_variables = num_vars;
5341  size_guc_variables = size_vars;
5343  sizeof(struct config_generic *), guc_var_compare);
5344 }
static struct config_int ConfigureNamesInt[]
Definition: guc.c:2126
const char * name
Definition: guc_tables.h:141
static struct config_enum ConfigureNamesEnum[]
Definition: guc.c:4604
static struct config_bool ConfigureNamesBool[]
Definition: guc.c:969
static int guc_var_compare(const void *a, const void *b)
Definition: guc.c:5556
static int num_guc_variables
Definition: guc.c:5001
#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:4998
enum config_type vartype
Definition: guc_tables.h:148
static int size_guc_variables
Definition: guc.c:5004
static struct config_real ConfigureNamesReal[]
Definition: guc.c:3556
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:3825
int i
#define qsort(a, b, c, d)
Definition: port.h:504
static void * guc_malloc(int elevel, size_t size)
Definition: guc.c:5041
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 11393 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().

11395 {
11396  /* Quick success if no hook */
11397  if (!conf->check_hook)
11398  return true;
11399 
11400  /* Reset variables that might be set by hook */
11401  GUC_check_errcode_value = ERRCODE_INVALID_PARAMETER_VALUE;
11402  GUC_check_errmsg_string = NULL;
11404  GUC_check_errhint_string = NULL;
11405 
11406  if (!conf->check_hook(newval, extra, source))
11407  {
11408  ereport(elevel,
11412  errmsg("invalid value for parameter \"%s\": %d",
11413  conf->gen.name, (int) *newval),
11417  errhint("%s", GUC_check_errhint_string) : 0));
11418  /* Flush any strings created in ErrorContext */
11419  FlushErrorState();
11420  return false;
11421  }
11422 
11423  return true;
11424 }
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:403
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 11545 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().

11547 {
11548  /* Quick success if no hook */
11549  if (!conf->check_hook)
11550  return true;
11551 
11552  /* Reset variables that might be set by hook */
11553  GUC_check_errcode_value = ERRCODE_INVALID_PARAMETER_VALUE;
11554  GUC_check_errmsg_string = NULL;
11556  GUC_check_errhint_string = NULL;
11557 
11558  if (!conf->check_hook(newval, extra, source))
11559  {
11560  ereport(elevel,
11564  errmsg("invalid value for parameter \"%s\": \"%s\"",
11565  conf->gen.name,
11570  errhint("%s", GUC_check_errhint_string) : 0));
11571  /* Flush any strings created in ErrorContext */
11572  FlushErrorState();
11573  return false;
11574  }
11575 
11576  return true;
11577 }
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:6987
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:403
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 11427 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().

11429 {
11430  /* Quick success if no hook */
11431  if (!conf->check_hook)
11432  return true;
11433 
11434  /* Reset variables that might be set by hook */
11435  GUC_check_errcode_value = ERRCODE_INVALID_PARAMETER_VALUE;
11436  GUC_check_errmsg_string = NULL;
11438  GUC_check_errhint_string = NULL;
11439 
11440  if (!conf->check_hook(newval, extra, source))
11441  {
11442  ereport(elevel,
11446  errmsg("invalid value for parameter \"%s\": %d",
11447  conf->gen.name, *newval),
11451  errhint("%s", GUC_check_errhint_string) : 0));
11452  /* Flush any strings created in ErrorContext */
11453  FlushErrorState();
11454  return false;
11455  }
11456 
11457  return true;
11458 }
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:403
#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 11461 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().

11463 {
11464  /* Quick success if no hook */
11465  if (!conf->check_hook)
11466  return true;
11467 
11468  /* Reset variables that might be set by hook */
11469  GUC_check_errcode_value = ERRCODE_INVALID_PARAMETER_VALUE;
11470  GUC_check_errmsg_string = NULL;
11472  GUC_check_errhint_string = NULL;
11473 
11474  if (!conf->check_hook(newval, extra, source))
11475  {
11476  ereport(elevel,
11480  errmsg("invalid value for parameter \"%s\": %g",
11481  conf->gen.name, *newval),
11485  errhint("%s", GUC_check_errhint_string) : 0));
11486  /* Flush any strings created in ErrorContext */
11487  FlushErrorState();
11488  return false;
11489  }
11490 
11491  return true;
11492 }
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:403
#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 11495 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().

11497 {
11498  volatile bool result = true;
11499 
11500  /* Quick success if no hook */
11501  if (!conf->check_hook)
11502  return true;
11503 
11504  /*
11505  * If elevel is ERROR, or if the check_hook itself throws an elog
11506  * (undesirable, but not always avoidable), make sure we don't leak the
11507  * already-malloc'd newval string.
11508  */
11509  PG_TRY();
11510  {
11511  /* Reset variables that might be set by hook */
11512  GUC_check_errcode_value = ERRCODE_INVALID_PARAMETER_VALUE;
11513  GUC_check_errmsg_string = NULL;
11515  GUC_check_errhint_string = NULL;
11516 
11517  if (!conf->check_hook(newval, extra, source))
11518  {
11519  ereport(elevel,
11523  errmsg("invalid value for parameter \"%s\": \"%s\"",
11524  conf->gen.name, *newval ? *newval : ""),
11528  errhint("%s", GUC_check_errhint_string) : 0));
11529  /* Flush any strings created in ErrorContext */
11530  FlushErrorState();
11531  result = false;
11532  }
11533  }
11534  PG_CATCH();
11535  {
11536  free(*newval);
11537  PG_RE_THROW();
11538  }
11539  PG_END_TRY();
11540 
11541  return result;
11542 }
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:403
#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 10446 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().

10447 {
10448  /*
10449  * We can skip GUCs that are guaranteed to have the same values in leaders
10450  * and workers. (Note it is critical that the leader and worker have the
10451  * same idea of which GUCs fall into this category. It's okay to consider
10452  * context and name for this purpose, since those are unchanging
10453  * properties of a GUC.)
10454  *
10455  * PGC_POSTMASTER variables always have the same value in every child of a
10456  * particular postmaster, so the worker will certainly have the right
10457  * value already. Likewise, PGC_INTERNAL variables are set by special
10458  * mechanisms (if indeed they aren't compile-time constants). So we may
10459  * always skip these.
10460  *
10461  * Role must be handled specially because its current value can be an
10462  * invalid value (for instance, if someone dropped the role since we set
10463  * it). So if we tried to serialize it normally, we might get a failure.
10464  * We skip it here, and use another mechanism to ensure the worker has the
10465  * right value.
10466  *
10467  * For all other GUCs, we skip if the GUC has its compiled-in default
10468  * value (i.e., source == PGC_S_DEFAULT). On the leader side, this means
10469  * we don't send GUCs that have their default values, which typically
10470  * saves lots of work. On the worker side, this means we don't need to
10471  * reset the GUC to default because it already has that value. See
10472  * comments in RestoreGUCState for more info.
10473  */
10474  return gconf->context == PGC_POSTMASTER ||
10475  gconf->context == PGC_INTERNAL || gconf->source == PGC_S_DEFAULT ||
10476  strcmp(gconf->name, "role") == 0;
10477 }
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 12124 of file guc.c.

References pg_clean_ascii().

12125 {
12126  /* Only allow clean ASCII chars in the application name */
12128 
12129  return true;
12130 }
#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 11991 of file guc.c.

References MAX_BACKENDS, max_wal_senders, max_worker_processes, and MaxConnections.

11992 {
11993  if (MaxConnections + *newval + 1 +
11995  return false;
11996  return true;
11997 }
#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 12009 of file guc.c.

12010 {
12011  /*
12012  * -1 indicates fallback.
12013  *
12014  * If we haven't yet changed the boot_val default of -1, just let it be.
12015  * Autovacuum will look to maintenance_work_mem instead.
12016  */
12017  if (*newval == -1)
12018  return true;
12019 
12020  /*
12021  * We clamp manually-set values to at least 1MB. Since
12022  * maintenance_work_mem is always set to at least this value, do the same
12023  * here.
12024  */
12025  if (*newval < 1024)
12026  *newval = 1024;
12027 
12028  return true;
12029 }
#define newval

◆ check_backtrace_functions()

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

Definition at line 12196 of file guc.c.

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

12197 {
12198  int newvallen = strlen(*newval);
12199  char *someval;
12200  int validlen;
12201  int i;
12202  int j;
12203 
12204  /*
12205  * Allow characters that can be C identifiers and commas as separators, as
12206  * well as some whitespace for readability.
12207  */
12208  validlen = strspn(*newval,
12209  "0123456789_"
12210  "abcdefghijklmnopqrstuvwxyz"
12211  "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
12212  ", \n\t");
12213  if (validlen != newvallen)
12214  {
12215  GUC_check_errdetail("invalid character");
12216  return false;
12217  }
12218 
12219  if (*newval[0] == '\0')
12220  {
12221  *extra = NULL;
12222  return true;
12223  }
12224 
12225  /*
12226  * Allocate space for the output and create the copy. We could discount
12227  * whitespace chars to save some memory, but it doesn't seem worth the
12228  * trouble.
12229  */
12230  someval = guc_malloc(ERROR, newvallen + 1 + 1);
12231  for (i = 0, j = 0; i < newvallen; i++)
12232  {
12233  if ((*newval)[i] == ',')
12234  someval[j++] = '\0'; /* next item */
12235  else if ((*newval)[i] == ' ' ||
12236  (*newval)[i] == '\n' ||
12237  (*newval)[i] == '\t')
12238  ; /* ignore these */
12239  else
12240  someval[j++] = (*newval)[i]; /* copy anything else */
12241  }
12242 
12243  /* two \0s end the setting */
12244  someval[j] = '\0';
12245  someval[j + 1] = '\0';
12246 
12247  *extra = someval;
12248  return true;
12249 }
#define GUC_check_errdetail
Definition: guc.h:416
#define ERROR
Definition: elog.h:46
#define newval
int i
static void * guc_malloc(int elevel, size_t size)
Definition: guc.c:5041

◆ check_bonjour()

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

Definition at line 11774 of file guc.c.

References GUC_check_errmsg.

11775 {
11776 #ifndef USE_BONJOUR
11777  if (*newval)
11778  {
11779  GUC_check_errmsg("Bonjour is not supported by this build");
11780  return false;
11781  }
11782 #endif
11783  return true;
11784 }
#define GUC_check_errmsg
Definition: guc.h:412
#define newval

◆ check_canonical_path()

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

Definition at line 11825 of file guc.c.

References canonicalize_path().

11826 {
11827  /*
11828  * Since canonicalize_path never enlarges the string, we can just modify
11829  * newval in-place. But watch out for NULL, which is the default value
11830  * for external_pid_file.
11831  */
11832  if (*newval)
11834  return true;
11835 }
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 12081 of file guc.c.

References GUC_check_errdetail.

12082 {
12083 #ifndef POLLRDHUP
12084  /* Linux only, for now. See pq_check_connection(). */
12085  if (*newval != 0)
12086  {
12087  GUC_check_errdetail("client_connection_check_interval must be set to 0 on platforms that lack POLLRDHUP.");
12088  return false;
12089  }
12090 #endif
12091  return true;
12092 }
#define GUC_check_errdetail
Definition: guc.h:416
#define newval

◆ check_cluster_name()

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

Definition at line 12140 of file guc.c.

References pg_clean_ascii().

12141 {
12142  /* Only allow clean ASCII chars in the cluster name */
12144 
12145  return true;
12146 }
#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 12525 of file guc.c.

References GUC_check_errcode(), and GUC_check_errmsg.

12526 {
12527  if (*newval)
12528  {
12529  /* check the GUC's definition for an explanation */
12530  GUC_check_errcode(ERRCODE_FEATURE_NOT_SUPPORTED);
12531  GUC_check_errmsg("tables declared WITH OIDS are not supported");
12532 
12533  return false;
12534  }
12535 
12536  return true;
12537 }
#define GUC_check_errmsg
Definition: guc.h:412
void GUC_check_errcode(int sqlerrcode)
Definition: guc.c:11380
#define newval

◆ check_effective_io_concurrency()

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

Definition at line 12041 of file guc.c.

References GUC_check_errdetail.

12042 {
12043 #ifndef USE_PREFETCH
12044  if (*newval != 0)
12045  {
12046  GUC_check_errdetail("effective_io_concurrency must be set to 0 on platforms that lack posix_fadvise().");
12047  return false;
12048  }
12049 #endif /* USE_PREFETCH */
12050  return true;
12051 }
#define GUC_check_errdetail
Definition: guc.h:416
#define newval

◆ check_huge_page_size()

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

Definition at line 12067 of file guc.c.

References GUC_check_errdetail.

12068 {
12069 #if !(defined(MAP_HUGE_MASK) && defined(MAP_HUGE_SHIFT))
12070  /* Recent enough Linux only, for now. See GetHugePageSize(). */
12071  if (*newval != 0)
12072  {
12073  GUC_check_errdetail("huge_page_size must be 0 on this platform.");
12074  return false;
12075  }
12076 #endif
12077  return true;
12078 }
#define GUC_check_errdetail
Definition: guc.h:416
#define newval

◆ check_log_destination()

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

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

11666 {
11667  char *rawstring;
11668  List *elemlist;
11669  ListCell *l;
11670  int newlogdest = 0;
11671  int *myextra;
11672 
11673  /* Need a modifiable copy of string */
11674  rawstring = pstrdup(*newval);
11675 
11676  /* Parse string into list of identifiers */
11677  if (!SplitIdentifierString(rawstring, ',', &elemlist))
11678  {
11679  /* syntax error in list */
11680  GUC_check_errdetail("List syntax is invalid.");
11681  pfree(rawstring);
11682  list_free(elemlist);
11683  return false;
11684  }
11685 
11686  foreach(l, elemlist)
11687  {
11688  char *tok = (char *) lfirst(l);
11689 
11690  if (pg_strcasecmp(tok, "stderr") == 0)
11691  newlogdest |= LOG_DESTINATION_STDERR;
11692  else if (pg_strcasecmp(tok, "csvlog") == 0)
11693  newlogdest |= LOG_DESTINATION_CSVLOG;
11694 #ifdef HAVE_SYSLOG
11695  else if (pg_strcasecmp(tok, "syslog") == 0)
11696  newlogdest |= LOG_DESTINATION_SYSLOG;
11697 #endif
11698 #ifdef WIN32
11699  else if (pg_strcasecmp(tok, "eventlog") == 0)
11700  newlogdest |= LOG_DESTINATION_EVENTLOG;
11701 #endif
11702  else
11703  {
11704  GUC_check_errdetail("Unrecognized key word: \"%s\".", tok);
11705  pfree(rawstring);
11706  list_free(elemlist);
11707  return false;
11708  }
11709  }
11710 
11711  pfree(rawstring);
11712  list_free(elemlist);
11713 
11714  myextra = (int *) guc_malloc(ERROR, sizeof(int));
11715  *myextra = newlogdest;
11716  *extra = (void *) myextra;
11717 
11718  return true;
11719 }
#define LOG_DESTINATION_EVENTLOG
Definition: elog.h:437
#define GUC_check_errdetail
Definition: guc.h:416
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:3753
#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:5041
Definition: pg_list.h:50

◆ check_log_stats()

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

Definition at line 11811 of file guc.c.

References GUC_check_errdetail.

11812 {
11813  if (*newval &&
11815  {
11816  GUC_check_errdetail("Cannot enable \"log_statement_stats\" when "
11817  "\"log_parser_stats\", \"log_planner_stats\", "
11818  "or \"log_executor_stats\" is true.");
11819  return false;
11820  }
11821  return true;
11822 }
bool log_parser_stats
Definition: guc.c:577
#define GUC_check_errdetail
Definition: guc.h:416
#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 12054 of file guc.c.

References GUC_check_errdetail.

12055 {
12056 #ifndef USE_PREFETCH
12057  if (*newval != 0)
12058  {
12059  GUC_check_errdetail("maintenance_io_concurrency must be set to 0 on platforms that lack posix_fadvise().");
12060  return false;
12061  }
12062 #endif /* USE_PREFETCH */
12063  return true;
12064 }
#define GUC_check_errdetail
Definition: guc.h:416
#define newval

◆ check_max_wal_senders()

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

Definition at line 12000 of file guc.c.

References autovacuum_max_workers, MAX_BACKENDS, max_worker_processes, and MaxConnections.

12001 {
12004  return false;
12005  return true;
12006 }
#define MAX_BACKENDS
Definition: postmaster.h:76
int MaxConnections
Definition: globals.c:136
int autovacuum_max_workers
Definition: autovacuum.c:116
#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 12032 of file guc.c.

References autovacuum_max_workers, MAX_BACKENDS, max_wal_senders, and MaxConnections.

12033 {
12036  return false;
12037  return true;
12038 }
#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:116
#define newval

◆ check_maxconnections()

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

Definition at line 11982 of file guc.c.

References autovacuum_max_workers, MAX_BACKENDS, max_wal_senders, and max_worker_processes.

11983 {
11984  if (*newval + autovacuum_max_workers + 1 +
11986  return false;
11987  return true;
11988 }
#define MAX_BACKENDS
Definition: postmaster.h:76
int max_wal_senders
Definition: walsender.c:121
int autovacuum_max_workers
Definition: autovacuum.c:116
#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 12515 of file guc.c.

References ReplicationSlotValidateName(), and WARNING.

12516 {
12517  if (*newval && strcmp(*newval, "") != 0 &&
12519  return false;
12520 
12521  return true;
12522 }
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 12320 of file guc.c.

References GUC_check_errdetail.

12321 {
12322  if (strcmp(*newval, "immediate") != 0 && strcmp(*newval, "") != 0)
12323  {
12324  GUC_check_errdetail("The only allowed value is \"immediate\".");
12325  return false;
12326  }
12327  return true;
12328 }
#define GUC_check_errdetail
Definition: guc.h:416
#define newval

◆ check_recovery_target_lsn()

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

Definition at line 12479 of file guc.c.

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

12480 {
12481  if (strcmp(*newval, "") != 0)
12482  {
12483  XLogRecPtr lsn;
12484  XLogRecPtr *myextra;
12485  bool have_error = false;
12486 
12487  lsn = pg_lsn_in_internal(*newval, &have_error);
12488  if (have_error)
12489  return false;
12490 
12491  myextra = (XLogRecPtr *) guc_malloc(ERROR, sizeof(XLogRecPtr));
12492  *myextra = lsn;
12493  *extra = (void *) myextra;
12494  }
12495  return true;
12496 }
#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:5041

◆ check_recovery_target_name()

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

Definition at line 12450 of file guc.c.

References GUC_check_errdetail, and MAXFNAMELEN.

12451 {
12452  /* Use the value of newval directly */
12453  if (strlen(*newval) >= MAXFNAMELEN)
12454  {
12455  GUC_check_errdetail("%s is too long (maximum %d characters).",
12456  "recovery_target_name", MAXFNAMELEN - 1);
12457  return false;
12458  }
12459  return true;
12460 }
#define GUC_check_errdetail
Definition: guc.h:416
#define MAXFNAMELEN
#define newval

◆ check_recovery_target_time()

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

Definition at line 12387 of file guc.c.

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

12388 {
12389  if (strcmp(*newval, "") != 0)
12390  {
12391  /* reject some special values */
12392  if (strcmp(*newval, "now") == 0 ||
12393  strcmp(*newval, "today") == 0 ||
12394  strcmp(*newval, "tomorrow") == 0 ||
12395  strcmp(*newval, "yesterday") == 0)
12396  {
12397  return false;
12398  }
12399 
12400  /*
12401  * parse timestamp value (see also timestamptz_in())
12402  */
12403  {
12404  char *str = *newval;
12405  fsec_t fsec;
12406  struct pg_tm tt,
12407  *tm = &tt;
12408  int tz;
12409  int dtype;
12410  int nf;
12411  int dterr;
12412  char *field[MAXDATEFIELDS];
12413  int ftype[MAXDATEFIELDS];
12414  char workbuf[MAXDATELEN + MAXDATEFIELDS];
12416 
12417  dterr = ParseDateTime(str, workbuf, sizeof(workbuf),
12418  field, ftype, MAXDATEFIELDS, &nf);
12419  if (dterr == 0)
12420  dterr = DecodeDateTime(field, ftype, nf, &dtype, tm, &fsec, &tz);
12421  if (dterr != 0)
12422  return false;
12423  if (dtype != DTK_DATE)
12424  return false;
12425 
12426  if (tm2timestamp(tm, fsec, &tz, &timestamp) != 0)
12427  {
12428  GUC_check_errdetail("timestamp out of range: \"%s\"", str);
12429  return false;
12430  }
12431  }
12432  }
12433  return true;
12434 }
#define MAXDATELEN
Definition: datetime.h:201
#define GUC_check_errdetail
Definition: guc.h:416
int64 timestamp
int64 TimestampTz
Definition: timestamp.h:39
Definition: pgtime.h:25
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 12258 of file guc.c.

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

12259 {
12261  RecoveryTargetTimeLineGoal *myextra;
12262 
12263  if (strcmp(*newval, "current") == 0)
12265  else if (strcmp(*newval, "latest") == 0)
12267  else
12268  {
12270 
12271  errno = 0;
12272  strtoul(*newval, NULL, 0);
12273  if (errno == EINVAL || errno == ERANGE)
12274  {
12275  GUC_check_errdetail("recovery_target_timeline is not a valid number.");
12276  return false;
12277  }
12278  }
12279 
12281  *myextra = rttg;
12282  *extra = (void *) myextra;
12283 
12284  return true;
12285 }
#define GUC_check_errdetail
Definition: guc.h:416
RecoveryTargetTimeLineGoal
Definition: xlog.h:93
#define ERROR
Definition: elog.h:46
#define newval
static void * guc_malloc(int elevel, size_t size)
Definition: guc.c:5041

◆ check_recovery_target_xid()

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

Definition at line 12344 of file guc.c.

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

12345 {
12346  if (strcmp(*newval, "") != 0)
12347  {
12348  TransactionId xid;
12349  TransactionId *myextra;
12350 
12351  errno = 0;
12352  xid = (TransactionId) pg_strtouint64(*newval, NULL, 0);
12353  if (errno == EINVAL || errno == ERANGE)
12354  return false;
12355 
12356  myextra = (TransactionId *) guc_malloc(ERROR, sizeof(TransactionId));
12357  *myextra = xid;
12358  *extra = (void *) myextra;
12359  }
12360  return true;
12361 }
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:5041

◆ check_ssl()

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

Definition at line 11787 of file guc.c.

References GUC_check_errmsg.

11788 {
11789 #ifndef USE_SSL
11790  if (*newval)
11791  {
11792  GUC_check_errmsg("SSL is not supported by this build");
11793  return false;
11794  }
11795 #endif
11796  return true;
11797 }
#define GUC_check_errmsg
Definition: guc.h:412
#define newval

◆ check_stage_log_stats()

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

Definition at line 11800 of file guc.c.

References GUC_check_errdetail.

11801 {
11802  if (*newval && log_statement_stats)
11803  {
11804  GUC_check_errdetail("Cannot enable parameter when \"log_statement_stats\" is true.");
11805  return false;
11806  }
11807  return true;
11808 }
bool log_statement_stats
Definition: guc.c:580
#define GUC_check_errdetail
Definition: guc.h:416
#define newval

◆ check_temp_buffers()

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

Definition at line 11759 of file guc.c.

References GUC_check_errdetail, NLocBuffer, and PGC_S_TEST.

11760 {
11761  /*
11762  * Once local buffers have been initialized, it's too late to change this.
11763  * However, if this is only a test call, allow it.
11764  */
11765  if (source != PGC_S_TEST && NLocBuffer && NLocBuffer != *newval)
11766  {
11767  GUC_check_errdetail("\"temp_buffers\" cannot be changed after any temporary tables have been accessed in the session.");
11768  return false;
11769  }
11770  return true;
11771 }
#define GUC_check_errdetail
Definition: guc.h:416
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 11838 of file guc.c.

References Assert, load_tzoffsets(), and PGC_S_DEFAULT.

11839 {
11840  /*
11841  * The boot_val given above for timezone_abbreviations is NULL. When we
11842  * see this we just do nothing. If this value isn't overridden from the
11843  * config file then pg_timezone_abbrev_initialize() will eventually
11844  * replace it with "Default". This hack has two purposes: to avoid
11845  * wasting cycles loading values that might soon be overridden from the
11846  * config file, and to avoid trying to read the timezone abbrev files
11847  * during InitializeGUCOptions(). The latter doesn't work in an
11848  * EXEC_BACKEND subprocess because my_exec_path hasn't been set yet and so
11849  * we can't locate PGSHAREDIR.
11850  */
11851  if (*newval == NULL)
11852  {
11854  return true;
11855  }
11856 
11857  /* OK, load the file and produce a malloc'd TimeZoneAbbrevTable */
11858  *extra = load_tzoffsets(*newval);
11859 
11860  /* tzparser.c returns NULL on failure, reporting via GUC_check_errmsg */
11861  if (!*extra)
11862  return false;
11863 
11864  return true;
11865 }
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 11585 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().

11586 {
11587  char *rawstring;
11588  List *elemlist;
11589  ListCell *l;
11590  bool newwalconsistency[RM_MAX_ID + 1];
11591 
11592  /* Initialize the array */
11593  MemSet(newwalconsistency, 0, (RM_MAX_ID + 1) * sizeof(bool));
11594 
11595  /* Need a modifiable copy of string */
11596  rawstring = pstrdup(*newval);
11597 
11598  /* Parse string into list of identifiers */
11599  if (!SplitIdentifierString(rawstring, ',', &elemlist))
11600  {
11601  /* syntax error in list */
11602  GUC_check_errdetail("List syntax is invalid.");
11603  pfree(rawstring);
11604  list_free(elemlist);
11605  return false;
11606  }
11607 
11608  foreach(l, elemlist)
11609  {
11610  char *tok = (char *) lfirst(l);
11611  bool found = false;
11612  RmgrId rmid;
11613 
11614  /* Check for 'all'. */
11615  if (pg_strcasecmp(tok, "all") == 0)
11616  {
11617  for (rmid = 0; rmid <= RM_MAX_ID; rmid++)
11618  if (RmgrTable[rmid].rm_mask != NULL)
11619  newwalconsistency[rmid] = true;
11620  found = true;
11621  }
11622  else
11623  {
11624  /*
11625  * Check if the token matches with any individual resource
11626  * manager.
11627  */
11628  for (rmid = 0; rmid <= RM_MAX_ID; rmid++)
11629  {
11630  if (pg_strcasecmp(tok, RmgrTable[rmid].rm_name) == 0 &&
11631  RmgrTable[rmid].rm_mask != NULL)
11632  {
11633  newwalconsistency[rmid] = true;
11634  found = true;
11635  }
11636  }
11637  }
11638 
11639  /* If a valid resource manager is found, check for the next one. */
11640  if (!found)
11641  {
11642  GUC_check_errdetail("Unrecognized key word: \"%s\".", tok);
11643  pfree(rawstring);
11644  list_free(elemlist);
11645  return false;
11646  }
11647  }
11648 
11649  pfree(rawstring);
11650  list_free(elemlist);
11651 
11652  /* assign new value */
11653  *extra = guc_malloc(ERROR, (RM_MAX_ID + 1) * sizeof(bool));
11654  memcpy(*extra, newwalconsistency, (RM_MAX_ID + 1) * sizeof(bool));
11655  return true;
11656 }
#define GUC_check_errdetail
Definition: guc.h:416
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:3753
#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:5041
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 7036 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().

7038 {
7039  const struct config_enum_entry *entry;
7040  StringInfoData retstr;
7041  int seplen;
7042 
7043  initStringInfo(&retstr);
7044  appendStringInfoString(&retstr, prefix);
7045 
7046  seplen = strlen(separator);
7047  for (entry = record->options; entry && entry->name; entry++)
7048  {
7049  if (!entry->hidden)
7050  {
7051  appendStringInfoString(&retstr, entry->name);
7052  appendBinaryStringInfo(&retstr, separator, seplen);
7053  }
7054  }
7055 
7056  /*
7057  * All the entries may have been hidden, leaving the string empty if no
7058  * prefix was given. This indicates a broken GUC setup, since there is no
7059  * use for an enum without any values, so we just check to make sure we
7060  * don't write to invalid memory instead of actually trying to do
7061  * something smart with it.
7062  */
7063  if (retstr.len >= seplen)
7064  {
7065  /* Replace final separator */
7066  retstr.data[retstr.len - seplen] = '\0';
7067  retstr.len -= seplen;
7068  }
7069 
7070  appendStringInfoString(&retstr, suffix);
7071 
7072  return retstr.data;
7073 }
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 7010 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().

7012 {
7013  const struct config_enum_entry *entry;
7014 
7015  for (entry = record->options; entry && entry->name; entry++)
7016  {
7017  if (pg_strcasecmp(value, entry->name) == 0)
7018  {
7019  *retval = entry->val;
7020  return true;
7021  }
7022  }
7023 
7024  *retval = 0;
7025  return false;
7026 }
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 6987 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().

6988 {
6989  const struct config_enum_entry *entry;
6990 
6991  for (entry = record->options; entry && entry->name; entry++)
6992  {
6993  if (entry->val == val)
6994  return entry->name;
6995  }
6996 
6997  elog(ERROR, "could not find enum option %d for %s",
6998  val, record->gen.name);
6999  return NULL; /* silence compiler */
7000 }
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 6693 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().

6695 {
6696  const unit_conversion *table;
6697  int i;
6698 
6699  *unit = NULL;
6700 
6701  if (base_unit & GUC_UNIT_MEMORY)
6703  else
6705 
6706  for (i = 0; *table[i].unit; i++)
6707  {
6708  if (base_unit == table[i].base_unit)
6709  {
6710  /*
6711  * Accept the first conversion that divides the value evenly. We
6712  * assume that the conversions for each base unit are ordered from
6713  * greatest unit to the smallest!
6714  */
6715  if (table[i].multiplier <= 1.0 ||
6716  base_value % (int64) table[i].multiplier == 0)
6717  {
6718  *value = (int64) rint(base_value / table[i].multiplier);
6719  *unit = table[i].unit;
6720  break;
6721  }
6722  }
6723  }
6724 
6725  Assert(*unit != NULL);
6726 }
static const unit_conversion time_unit_conversion_table[]
Definition: guc.c:913
static const unit_conversion memory_unit_conversion_table[]
Definition: guc.c:876
static struct @143 value
#define Assert(condition)
Definition: c.h:804
int i
char unit[MAX_UNIT_LEN+1]
Definition: guc.c:860
#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 6735 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().

6737 {
6738  const unit_conversion *table;
6739  int i;
6740 
6741  *unit = NULL;
6742 
6743  if (base_unit & GUC_UNIT_MEMORY)
6745  else
6747 
6748  for (i = 0; *table[i].unit; i++)
6749  {
6750  if (base_unit == table[i].base_unit)
6751  {
6752  /*
6753  * Accept the first conversion that divides the value evenly; or
6754  * if there is none, use the smallest (last) target unit.
6755  *
6756  * What we actually care about here is whether snprintf with "%g"
6757  * will print the value as an integer, so the obvious test of
6758  * "*value == rint(*value)" is too strict; roundoff error might
6759  * make us choose an unreasonably small unit. As a compromise,
6760  * accept a divisor that is within 1e-8 of producing an integer.
6761  */
6762  *value = base_value / table[i].multiplier;
6763  *unit = table[i].unit;
6764  if (*value > 0 &&
6765  fabs((rint(*value) / *value) - 1.0) <= 1e-8)
6766  break;
6767  }
6768  }
6769 
6770  Assert(*unit != NULL);
6771 }
static const unit_conversion time_unit_conversion_table[]
Definition: guc.c:913
static const unit_conversion memory_unit_conversion_table[]
Definition: guc.c:876
static struct @143 value
#define Assert(condition)
Definition: c.h:804
double multiplier
Definition: guc.c:863
e
Definition: preproc-init.c:82
int i
char unit[MAX_UNIT_LEN+1]
Definition: guc.c:860
#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 6635 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().

6637 {
6638  char unitstr[MAX_UNIT_LEN + 1];
6639  int unitlen;
6640  const unit_conversion *table;
6641  int i;
6642 
6643  /* extract unit string to compare to table entries */
6644  unitlen = 0;
6645  while (*unit != '\0' && !isspace((unsigned char) *unit) &&
6646  unitlen < MAX_UNIT_LEN)
6647  unitstr[unitlen++] = *(unit++);
6648  unitstr[unitlen] = '\0';
6649  /* allow whitespace after unit */
6650  while (isspace((unsigned char) *unit))
6651  unit++;
6652  if (*unit != '\0')
6653  return false; /* unit too long, or garbage after it */
6654 
6655  /* now search the appropriate table */
6656  if (base_unit & GUC_UNIT_MEMORY)
6658  else
6660 
6661  for (i = 0; *table[i].unit; i++)
6662  {
6663  if (base_unit == table[i].base_unit &&
6664  strcmp(unitstr, table[i].unit) == 0)
6665  {
6666  double cvalue = value * table[i].multiplier;
6667 
6668  /*
6669  * If the user gave a fractional value such as "30.1GB", round it
6670  * off to the nearest multiple of the next smaller unit, if there
6671  * is one.
6672  */
6673  if (*table[i + 1].unit &&
6674  base_unit == table[i + 1].base_unit)
6675  cvalue = rint(cvalue / table[i + 1].multiplier) *
6676  table[i + 1].multiplier;
6677 
6678  *base_value = cvalue;
6679  return true;
6680  }
6681  }
6682  return false;
6683 }
static const unit_conversion time_unit_conversion_table[]
Definition: guc.c:913
static const unit_conversion memory_unit_conversion_table[]
Definition: guc.c:876
#define MAX_UNIT_LEN
Definition: guc.c:856
static struct @143 value
double multiplier
Definition: guc.c:863
int i
char unit[MAX_UNIT_LEN+1]
Definition: guc.c:860
#define GUC_UNIT_MEMORY
Definition: guc.h:223

◆ define_custom_variable()

static void define_custom_variable ( struct config_generic variable)
static

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

8971 {
8972  const char *name = variable->name;
8973  const char **nameAddr = &name;
8974  struct config_string *pHolder;
8975  struct config_generic **res;
8976 
8977  /*
8978  * See if there's a placeholder by the same name.
8979  */
8980  res = (struct config_generic **) bsearch((void *) &nameAddr,
8981  (void *) guc_variables,
8983  sizeof(struct config_generic *),
8984  guc_var_compare);
8985  if (res == NULL)
8986  {
8987  /*
8988  * No placeholder to replace, so we can just add it ... but first,
8989  * make sure it's initialized to its default value.
8990  */
8991  InitializeOneGUCOption(variable);
8992  add_guc_variable(variable, ERROR);
8993  return;
8994  }
8995 
8996  /*
8997  * This better be a placeholder
8998  */
8999  if (((*res)->flags & GUC_CUSTOM_PLACEHOLDER) == 0)
9000  ereport(ERROR,
9001  (errcode(ERRCODE_INTERNAL_ERROR),
9002  errmsg("attempt to redefine parameter \"%s\"", name)));
9003 
9004  Assert((*res)->vartype == PGC_STRING);
9005  pHolder = (struct config_string *) (*res);
9006 
9007  /*
9008  * First, set the variable to its default value. We must do this even
9009  * though we intend to immediately apply a new value, since it's possible
9010  * that the new value is invalid.
9011  */
9012  InitializeOneGUCOption(variable);
9013 
9014  /*
9015  * Replace the placeholder. We aren't changing the name, so no re-sorting
9016  * is necessary
9017  */
9018  *res = variable;
9019 
9020  /*
9021  * Assign the string value(s) stored in the placeholder to the real
9022  * variable. Essentially, we need to duplicate all the active and stacked
9023  * values, but with appropriate validation and datatype adjustment.
9024  *
9025  * If an assignment fails, we report a WARNING and keep going. We don't
9026  * want to throw ERROR for bad values, because it'd bollix the add-on
9027  * module that's presumably halfway through getting loaded. In such cases
9028  * the default or previous state will become active instead.
9029  */
9030 
9031  /* First, apply the reset value if any */
9032  if (pHolder->reset_val)
9033  (void) set_config_option(name, pHolder->reset_val,
9034  pHolder->gen.reset_scontext,
9035  pHolder->gen.reset_source,
9036  GUC_ACTION_SET, true, WARNING, false);
9037  /* That should not have resulted in stacking anything */
9038  Assert(variable->stack == NULL);
9039 
9040  /* Now, apply current and stacked values, in the order they were stacked */
9041  reapply_stacked_values(variable, pHolder, pHolder->gen.stack,
9042  *(pHolder->variable),
9043  pHolder->gen.scontext, pHolder->gen.source);
9044 
9045  /* Also copy over any saved source-location information */
9046  if (pHolder->gen.sourcefile)
9047  set_config_sourcefile(name, pHolder->gen.sourcefile,
9048  pHolder->gen.sourceline);
9049 
9050  /*
9051  * Free up as much as we conveniently can of the placeholder structure.
9052  * (This neglects any stack items, so it's possible for some memory to be
9053  * leaked. Since this can only happen once per session per variable, it
9054  * doesn't seem worth spending much code on.)
9055  */
9056  set_string_field(pHolder, pHolder->variable, NULL);
9057  set_string_field(pHolder, &pHolder->reset_val, NULL);
9058 
9059  free(pHolder);
9060 }
GucSource source
Definition: guc_tables.h:150
static void static void set_config_sourcefile(const char *name, char *sourcefile, int sourceline)
Definition: guc.c:8052
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:9070
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:5556
#define ERROR
Definition: elog.h:46
static int num_guc_variables
Definition: guc.c:5001
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:5704
static void set_string_field(struct config_string *conf, char **field, char *newval)
Definition: guc.c:5113
static struct config_generic ** guc_variables
Definition: guc.c:4998
#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:515
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:7295
static bool add_guc_variable(struct config_generic *var, int elevel)
Definition: guc.c:5351
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 9151 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().

9161 {
9162  struct config_bool *var;
9163 
9164  var = (struct config_bool *)
9165  init_custom_variable(name, short_desc, long_desc, context, flags,
9166  PGC_BOOL, sizeof(struct config_bool));
9167  var->variable = valueAddr;
9168  var->boot_val = bootValue;
9169  var->reset_val = bootValue;
9170  var->check_hook = check_hook;
9171  var->assign_hook = assign_hook;
9172  var->show_hook = show_hook;
9173  define_custom_variable(&var->gen);
9174 }
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:8910
GucBoolCheckHook check_hook
Definition: guc_tables.h:181
GucShowHook show_hook
Definition: guc_tables.h:183
const char * name
Definition: encode.c:515
bool reset_val
Definition: guc_tables.h:185
static void define_custom_variable(struct config_generic *variable)
Definition: guc.c:8970

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

9273 {
9274  struct config_enum *var;
9275 
9276  var = (struct config_enum *)
9277  init_custom_variable(name, short_desc, long_desc, context, flags,
9278  PGC_ENUM, sizeof(struct config_enum));
9279  var->variable = valueAddr;
9280  var->boot_val = bootValue;
9281  var->reset_val = bootValue;
9282  var->options = options;
9283  var->check_hook = check_hook;
9284  var->assign_hook = assign_hook;
9285  var->show_hook = show_hook;
9286  define_custom_variable(&var->gen);
9287 }
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:8910
GucShowHook show_hook
Definition: guc_tables.h:244
struct config_generic gen
Definition: guc_tables.h:237
const char * name
Definition: encode.c:515
static void define_custom_variable(struct config_generic *variable)
Definition: guc.c:8970

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

9189 {
9190  struct config_int *var;
9191 
9192  var = (struct config_int *)
9193  init_custom_variable(name, short_desc, long_desc, context, flags,
9194  PGC_INT, sizeof(struct config_int));
9195  var->variable = valueAddr;
9196  var->boot_val = bootValue;
9197  var->reset_val = bootValue;
9198  var->min = minValue;
9199  var->max = maxValue;
9200  var->check_hook = check_hook;
9201  var->assign_hook = assign_hook;
9202  var->show_hook = show_hook;
9203  define_custom_variable(&var->gen);
9204 }
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:8910
const char * name
Definition: encode.c:515
static void define_custom_variable(struct config_generic *variable)
Definition: guc.c:8970
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 9207 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().

9219 {
9220  struct config_real *var;
9221 
9222  var = (struct config_real *)
9223  init_custom_variable(name, short_desc, long_desc, context, flags,
9224  PGC_REAL, sizeof(struct config_real));
9225  var->variable = valueAddr;
9226  var->boot_val = bootValue;
9227  var->reset_val = bootValue;
9228  var->min = minValue;
9229  var->max = maxValue;
9230  var->check_hook = check_hook;
9231  var->assign_hook = assign_hook;
9232  var->show_hook = show_hook;
9233  define_custom_variable(&var->gen);
9234 }
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:8910
double max
Definition: guc_tables.h:212
double boot_val
Definition: guc_tables.h:210
const char * name
Definition: encode.c:515
double min
Definition: guc_tables.h:211
static void define_custom_variable(struct config_generic *variable)
Definition: guc.c:8970
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 9237 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().

9247 {
9248  struct config_string *var;
9249 
9250  var = (struct config_string *)
9251  init_custom_variable(name, short_desc, long_desc, context, flags,
9252  PGC_STRING, sizeof(struct config_string));
9253  var->variable = valueAddr;
9254  var->boot_val = bootValue;
9255  var->check_hook = check_hook;
9256  var->assign_hook = assign_hook;
9257  var->show_hook = show_hook;
9258  define_custom_variable(&var->gen);
9259 }
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:8910
struct config_generic gen
Definition: guc_tables.h:223
GucStringAssignHook assign_hook
Definition: guc_tables.h:228
const char * name
Definition: encode.c:515
static void define_custom_variable(struct config_generic *variable)
Definition: guc.c:8970

◆ discard_stack_value()

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

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

5229 {
5230  switch (gconf->vartype)
5231  {
5232  case PGC_BOOL:
5233  case PGC_INT:
5234  case PGC_REAL:
5235  case PGC_ENUM:
5236  /* no need to do anything */
5237  break;
5238  case PGC_STRING:
5239  set_string_field((struct config_string *) gconf,
5240  &(val->val.stringval),
5241  NULL);
5242  break;
5243  }
5244  set_extra_field(gconf, &(val->extra), NULL);
5245 }
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:5174
static void set_string_field(struct config_string *conf, char **field, char *newval)
Definition: guc.c:5113
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 10608 of file guc.c.

References elog, ERROR, and vsnprintf.

Referenced by serialize_variable().

10609 {
10610  va_list vargs;
10611  int n;
10612 
10613  if (*maxbytes <= 0)
10614  elog(ERROR, "not enough space to serialize GUC state");
10615 
10616  va_start(vargs, fmt);
10617  n = vsnprintf(*destptr, *maxbytes, fmt, vargs);
10618  va_end(vargs);
10619 
10620  if (n < 0)
10621  {
10622  /* Shouldn't happen. Better show errno description. */
10623  elog(ERROR, "vsnprintf failed: %m with format string \"%s\"", fmt);
10624  }
10625  if (n >= *maxbytes)
10626  {
10627  /* This shouldn't happen either, really. */
10628  elog(ERROR, "not enough space to serialize GUC state");
10629  }
10630 
10631  /* Shift the destptr ahead of the null terminator */
10632  *destptr += n + 1;
10633  *maxbytes -= n + 1;
10634 }
#define ERROR
Definition: elog.h:46
#define vsnprintf
Definition: port.h:215
#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 10638 of file guc.c.

References elog, and ERROR.

Referenced by serialize_variable().

10639 {
10640  if (valsize > *maxbytes)
10641  elog(ERROR, "not enough space to serialize GUC state");
10642 
10643  memcpy(*destptr, val, valsize);
10644  *destptr += valsize;
10645  *maxbytes -= valsize;
10646 }
#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 9290 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().

9291 {
9292  int classLen = strlen(className);
9293  int i;
9294 
9295  for (i = 0; i < num_guc_variables; i++)
9296  {
9297  struct config_generic *var = guc_variables[i];
9298 
9299  if ((var->flags & GUC_CUSTOM_PLACEHOLDER) != 0 &&
9300  strncmp(className, var->name, classLen) == 0 &&
9301  var->name[classLen] == GUC_QUALIFIER_SEPARATOR)
9302  {
9303  ereport(WARNING,
9304  (errcode(ERRCODE_UNDEFINED_OBJECT),
9305  errmsg("unrecognized configuration parameter \"%s\"",
9306  var->name)));
9307  }
9308  }
9309 }
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:5001
static struct config_generic ** guc_variables
Definition: guc.c:4998
#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 10486 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().

10487 {
10488  Size size;
10489  Size valsize = 0;
10490 
10491  /* Skippable GUCs consume zero space. */
10492  if (can_skip_gucvar(gconf))
10493  return 0;
10494 
10495  /* Name, plus trailing zero byte. */
10496  size = strlen(gconf->name) + 1;
10497 
10498  /* Get the maximum display length of the GUC value. */
10499  switch (gconf->vartype)
10500  {
10501  case PGC_BOOL:
10502  {
10503  valsize = 5; /* max(strlen('true'), strlen('false')) */
10504  }
10505  break;
10506 
10507  case PGC_INT:
10508  {
10509  struct config_int *conf = (struct config_int *) gconf;
10510 
10511  /*
10512  * Instead of getting the exact display length, use max
10513  * length. Also reduce the max length for typical ranges of
10514  * small values. Maximum value is 2147483647, i.e. 10 chars.
10515  * Include one byte for sign.
10516  */
10517  if (Abs(*conf->variable) < 1000)
10518  valsize = 3 + 1;
10519  else
10520  valsize = 10 + 1;
10521  }
10522  break;
10523 
10524  case PGC_REAL:
10525  {
10526  /*
10527  * We are going to print it with %e with REALTYPE_PRECISION
10528  * fractional digits. Account for sign, leading digit,
10529  * decimal point, and exponent with up to 3 digits. E.g.
10530  * -3.99329042340000021e+110
10531  */
10532  valsize = 1 + 1 + 1 + REALTYPE_PRECISION + 5;
10533  }
10534  break;
10535 
10536  case PGC_STRING:
10537  {
10538  struct config_string *conf = (struct config_string *) gconf;
10539 
10540  /*
10541  * If the value is NULL, we transmit it as an empty string.
10542  * Although this is not physically the same value, GUC
10543  * generally treats a NULL the same as empty string.
10544  */
10545  if (*conf->variable)
10546  valsize = strlen(*conf->variable);
10547  else
10548  valsize = 0;
10549  }
10550  break;
10551 
10552  case PGC_ENUM:
10553  {
10554  struct config_enum *conf = (struct config_enum *) gconf;
10555 
10556  valsize = strlen(config_enum_lookup_by_value(conf, *conf->variable));
10557  }
10558  break;
10559  }
10560 
10561  /* Allow space for terminating zero-byte for value */
10562  size = add_size(size, valsize + 1);
10563 
10564  if (gconf->sourcefile)
10565  size = add_size(size, strlen(gconf->sourcefile));
10566 
10567  /* Allow space for terminating zero-byte for sourcefile */
10568  size = add_size(size, 1);
10569 
10570  /* Include line whenever file is nonempty. */
10571  if (gconf->sourcefile && gconf->sourcefile[0])
10572  size = add_size(size, sizeof(gconf->sourceline));
10573 
10574  size = add_size(size, sizeof(gconf->source));
10575  size = add_size(size, sizeof(gconf->scontext));
10576 
10577  return size;
10578 }
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:6987
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:10446
#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 10585 of file guc.c.

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

Referenced by InitializeParallelDSM().

10586 {
10587  Size size;
10588  int i;
10589 
10590  /* Add space reqd for saving the data size of the guc state */
10591  size = sizeof(Size);
10592 
10593  /* Add up the space needed for each GUC variable */
10594  for (i = 0; i < num_guc_variables; i++)
10595  size = add_size(size,
10597 
10598  return size;
10599 }
static int num_guc_variables
Definition: guc.c:5001
static struct config_generic ** guc_variables
Definition: guc.c:4998
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:10486
int i

◆ ExecSetVariableStmt()

void ExecSetVariableStmt ( VariableSetStmt stmt,
bool  isTopLevel 
)

Definition at line 8698 of file guc.c.

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

Referenced by standard_ProcessUtility().

8699 {
8701 
8702  /*
8703  * Workers synchronize these parameters at the start of the parallel
8704  * operation; then, we block SET during the operation.
8705  */
8706  if (IsInParallelMode())
8707  ereport(ERROR,
8708  (errcode(ERRCODE_INVALID_TRANSACTION_STATE),
8709  errmsg("cannot set parameters during a parallel operation")));
8710 
8711  switch (stmt->kind)
8712  {
8713  case VAR_SET_VALUE:
8714  case VAR_SET_CURRENT:
8715  if (stmt->is_local)
8716  WarnNoTransactionBlock(isTopLevel, "SET LOCAL");
8717  (void) set_config_option(stmt->name,
8718  ExtractSetVariableArgs(stmt),
8720  PGC_S_SESSION,
8721  action, true, 0, false);
8722  break;
8723  case VAR_SET_MULTI:
8724 
8725  /*
8726  * Special-case SQL syntaxes. The TRANSACTION and SESSION
8727  * CHARACTERISTICS cases effectively set more than one variable
8728  * per statement. TRANSACTION SNAPSHOT only takes one argument,
8729  * but we put it here anyway since it's a special case and not
8730  * related to any GUC variable.
8731  */
8732  if (strcmp(stmt->name, "TRANSACTION") == 0)
8733  {
8734  ListCell *head;
8735 
8736  WarnNoTransactionBlock(isTopLevel, "SET TRANSACTION");
8737 
8738  foreach(head, stmt->args)
8739  {
8740  DefElem *item = (DefElem *) lfirst(head);
8741 
8742  if (strcmp(item->defname, "transaction_isolation") == 0)
8743  SetPGVariable("transaction_isolation",
8744  list_make1(item->arg), stmt->is_local);
8745  else if (strcmp(item->defname, "transaction_read_only") == 0)
8746  SetPGVariable("transaction_read_only",
8747  list_make1(item->arg), stmt->is_local);
8748  else if (strcmp(item->defname, "transaction_deferrable") == 0)
8749  SetPGVariable("transaction_deferrable",
8750  list_make1(item->arg), stmt->is_local);
8751  else
8752  elog(ERROR, "unexpected SET TRANSACTION element: %s",
8753  item->defname);
8754  }
8755  }
8756  else if (strcmp(stmt->name, "SESSION CHARACTERISTICS") == 0)
8757  {
8758  ListCell *head;
8759 
8760  foreach(head, stmt->args)
8761  {
8762  DefElem *item = (DefElem *) lfirst(head);
8763 
8764  if (strcmp(item->defname, "transaction_isolation") == 0)
8765  SetPGVariable("default_transaction_isolation",
8766  list_make1(item->arg), stmt->is_local);
8767  else if (strcmp(item->defname, "transaction_read_only") == 0)
8768  SetPGVariable("default_transaction_read_only",
8769  list_make1(item->arg), stmt->is_local);
8770  else