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/transam.h"
#include "access/twophase.h"
#include "access/xact.h"
#include "access/xlog_internal.h"
#include "catalog/namespace.h"
#include "catalog/pg_authid.h"
#include "catalog/storage.h"
#include "commands/async.h"
#include "commands/prepare.h"
#include "commands/trigger.h"
#include "commands/user.h"
#include "commands/vacuum.h"
#include "commands/variable.h"
#include "common/string.h"
#include "funcapi.h"
#include "jit/jit.h"
#include "libpq/auth.h"
#include "libpq/libpq.h"
#include "libpq/pqformat.h"
#include "miscadmin.h"
#include "optimizer/cost.h"
#include "optimizer/geqo.h"
#include "optimizer/optimizer.h"
#include "optimizer/paths.h"
#include "optimizer/planmain.h"
#include "parser/parse_expr.h"
#include "parser/parse_type.h"
#include "parser/parser.h"
#include "parser/scansup.h"
#include "pgstat.h"
#include "postmaster/autovacuum.h"
#include "postmaster/bgworker_internals.h"
#include "postmaster/bgwriter.h"
#include "postmaster/postmaster.h"
#include "postmaster/syslogger.h"
#include "postmaster/walwriter.h"
#include "replication/logicallauncher.h"
#include "replication/reorderbuffer.h"
#include "replication/slot.h"
#include "replication/syncrep.h"
#include "replication/walreceiver.h"
#include "replication/walsender.h"
#include "storage/bufmgr.h"
#include "storage/dsm_impl.h"
#include "storage/fd.h"
#include "storage/large_object.h"
#include "storage/pg_shmem.h"
#include "storage/predicate.h"
#include "storage/proc.h"
#include "storage/standby.h"
#include "tcop/tcopprot.h"
#include "tsearch/ts_cache.h"
#include "utils/acl.h"
#include "utils/builtins.h"
#include "utils/bytea.h"
#include "utils/guc_tables.h"
#include "utils/memutils.h"
#include "utils/pg_locale.h"
#include "utils/pg_lsn.h"
#include "utils/plancache.h"
#include "utils/portal.h"
#include "utils/ps_status.h"
#include "utils/rls.h"
#include "utils/snapmgr.h"
#include "utils/tzparser.h"
#include "utils/varlena.h"
#include "utils/xml.h"
#include "guc-file.c"
Include dependency graph for guc.c:

Go to the source code of this file.

Data Structures

struct  unit_conversion
 

Macros

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

Functions

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

Variables

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

Macro Definition Documentation

◆ CONFIG_FILENAME

#define CONFIG_FILENAME   "postgresql.conf"

Definition at line 109 of file guc.c.

Referenced by SelectConfigFiles().

◆ HBA_FILENAME

#define HBA_FILENAME   "pg_hba.conf"

Definition at line 110 of file guc.c.

Referenced by SelectConfigFiles().

◆ IDENT_FILENAME

#define IDENT_FILENAME   "pg_ident.conf"

Definition at line 111 of file guc.c.

Referenced by SelectConfigFiles().

◆ MAX_UNIT_LEN

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

Definition at line 815 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 9542 of file guc.c.

Referenced by show_all_settings().

◆ PG_KRB_SRVTAB

#define PG_KRB_SRVTAB   ""

Definition at line 106 of file guc.c.

◆ REALTYPE_PRECISION

#define REALTYPE_PRECISION   17

Definition at line 122 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 9788 of file guc.c.

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

Referenced by GetConfigOptionByName(), GetConfigOptionByNum(), ReportGUCOption(), and ShowAllGUCConfig().

9789 {
9790  char buffer[256];
9791  const char *val;
9792 
9793  switch (record->vartype)
9794  {
9795  case PGC_BOOL:
9796  {
9797  struct config_bool *conf = (struct config_bool *) record;
9798 
9799  if (conf->show_hook)
9800  val = conf->show_hook();
9801  else
9802  val = *conf->variable ? "on" : "off";
9803  }
9804  break;
9805 
9806  case PGC_INT:
9807  {
9808  struct config_int *conf = (struct config_int *) record;
9809 
9810  if (conf->show_hook)
9811  val = conf->show_hook();
9812  else
9813  {
9814  /*
9815  * Use int64 arithmetic to avoid overflows in units
9816  * conversion.
9817  */
9818  int64 result = *conf->variable;
9819  const char *unit;
9820 
9821  if (use_units && result > 0 && (record->flags & GUC_UNIT))
9823  record->flags & GUC_UNIT,
9824  &result, &unit);
9825  else
9826  unit = "";
9827 
9828  snprintf(buffer, sizeof(buffer), INT64_FORMAT "%s",
9829  result, unit);
9830  val = buffer;
9831  }
9832  }
9833  break;
9834 
9835  case PGC_REAL:
9836  {
9837  struct config_real *conf = (struct config_real *) record;
9838 
9839  if (conf->show_hook)
9840  val = conf->show_hook();
9841  else
9842  {
9843  double result = *conf->variable;
9844  const char *unit;
9845 
9846  if (use_units && result > 0 && (record->flags & GUC_UNIT))
9848  record->flags & GUC_UNIT,
9849  &result, &unit);
9850  else
9851  unit = "";
9852 
9853  snprintf(buffer, sizeof(buffer), "%g%s",
9854  result, unit);
9855  val = buffer;
9856  }
9857  }
9858  break;
9859 
9860  case PGC_STRING:
9861  {
9862  struct config_string *conf = (struct config_string *) record;
9863 
9864  if (conf->show_hook)
9865  val = conf->show_hook();
9866  else if (*conf->variable && **conf->variable)
9867  val = *conf->variable;
9868  else
9869  val = "";
9870  }
9871  break;
9872 
9873  case PGC_ENUM:
9874  {
9875  struct config_enum *conf = (struct config_enum *) record;
9876 
9877  if (conf->show_hook)
9878  val = conf->show_hook();
9879  else
9880  val = config_enum_lookup_by_value(conf, *conf->variable);
9881  }
9882  break;
9883 
9884  default:
9885  /* just to keep compiler quiet */
9886  val = "???";
9887  break;
9888  }
9889 
9890  return pstrdup(val);
9891 }
char ** variable
Definition: guc_tables.h:230
char * pstrdup(const char *in)
Definition: mcxt.c:1187
bool * variable
Definition: guc_tables.h:184
const char * config_enum_lookup_by_value(struct config_enum *record, int val)
Definition: guc.c:6645
#define GUC_UNIT
Definition: guc.h:233
GucShowHook show_hook
Definition: guc_tables.h:204
int * variable
Definition: guc_tables.h:198
int * variable
Definition: guc_tables.h:244
static void convert_real_from_base_unit(double base_value, int base_unit, double *value, const char **unit)
Definition: guc.c:6393
GucShowHook show_hook
Definition: guc_tables.h:234
GucShowHook show_hook
Definition: guc_tables.h:220
double * variable
Definition: guc_tables.h:214
enum config_type vartype
Definition: guc_tables.h:156
GucShowHook show_hook
Definition: guc_tables.h:249
GucShowHook show_hook
Definition: guc_tables.h:188
#define INT64_FORMAT
Definition: c.h:417
static void convert_int_from_base_unit(int64 base_value, int base_unit, int64 *value, const char **unit)
Definition: guc.c:6351
#define snprintf
Definition: port.h:215
long val
Definition: informix.c:664

◆ add_guc_variable()

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

Definition at line 5163 of file guc.c.

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

Referenced by add_placeholder_variable(), and define_custom_variable().

5164 {
5166  {
5167  /*
5168  * Increase the vector by 25%
5169  */
5170  int size_vars = size_guc_variables + size_guc_variables / 4;
5171  struct config_generic **guc_vars;
5172 
5173  if (size_vars == 0)
5174  {
5175  size_vars = 100;
5176  guc_vars = (struct config_generic **)
5177  guc_malloc(elevel, size_vars * sizeof(struct config_generic *));
5178  }
5179  else
5180  {
5181  guc_vars = (struct config_generic **)
5182  guc_realloc(elevel, guc_variables, size_vars * sizeof(struct config_generic *));
5183  }
5184 
5185  if (guc_vars == NULL)
5186  return false; /* out of memory */
5187 
5188  guc_variables = guc_vars;
5189  size_guc_variables = size_vars;
5190  }
5193  sizeof(struct config_generic *), guc_var_compare);
5194  return true;
5195 }
static int guc_var_compare(const void *a, const void *b)
Definition: guc.c:5298
static int num_guc_variables
Definition: guc.c:4815
static void * guc_realloc(int elevel, void *old, size_t size)
Definition: guc.c:4869
static struct config_generic ** guc_variables
Definition: guc.c:4812
static int size_guc_variables
Definition: guc.c:4818
static int elevel
Definition: vacuumlazy.c:333
#define qsort(a, b, c, d)
Definition: port.h:497
static void * guc_malloc(int elevel, size_t size)
Definition: guc.c:4853

◆ add_placeholder_variable()

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

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

5202 {
5203  size_t sz = sizeof(struct config_string) + sizeof(char *);
5204  struct config_string *var;
5205  struct config_generic *gen;
5206 
5207  var = (struct config_string *) guc_malloc(elevel, sz);
5208  if (var == NULL)
5209  return NULL;
5210  memset(var, 0, sz);
5211  gen = &var->gen;
5212 
5213  gen->name = guc_strdup(elevel, name);
5214  if (gen->name == NULL)
5215  {
5216  free(var);
5217  return NULL;
5218  }
5219 
5220  gen->context = PGC_USERSET;
5221  gen->group = CUSTOM_OPTIONS;
5222  gen->short_desc = "GUC placeholder variable";
5224  gen->vartype = PGC_STRING;
5225 
5226  /*
5227  * The char* is allocated at the end of the struct since we have no
5228  * 'static' place to point to. Note that the current value, as well as
5229  * the boot and reset values, start out NULL.
5230  */
5231  var->variable = (char **) (var + 1);
5232 
5233  if (!add_guc_variable((struct config_generic *) var, elevel))
5234  {
5235  free(unconstify(char *, gen->name));
5236  free(var);
5237  return NULL;
5238  }
5239 
5240  return gen;
5241 }
char ** variable
Definition: guc_tables.h:230
const char * name
Definition: guc_tables.h:149
const char * short_desc
Definition: guc_tables.h:152
static char * guc_strdup(int elevel, const char *src)
Definition: guc.c:4885
#define GUC_NO_SHOW_ALL
Definition: guc.h:207
#define GUC_NOT_IN_SAMPLE
Definition: guc.h:210
enum config_type vartype
Definition: guc_tables.h:156
#define unconstify(underlying_type, expr)
Definition: c.h:1185
static int elevel
Definition: vacuumlazy.c:333
struct config_generic gen
Definition: guc_tables.h:228
#define free(a)
Definition: header.h:65
#define GUC_CUSTOM_PLACEHOLDER
Definition: guc.h:212
const char * name
Definition: encode.c:561
enum config_group group
Definition: guc_tables.h:151
static void * guc_malloc(int elevel, size_t size)
Definition: guc.c:4853
GucContext context
Definition: guc_tables.h:150
static bool add_guc_variable(struct config_generic *var, int elevel)
Definition: guc.c:5163

◆ AlterSystemSetConfigFile()

void AlterSystemSetConfigFile ( AlterSystemStmt altersysstmt)

Definition at line 8161 of file guc.c.

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

Referenced by standard_ProcessUtility().

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

◆ assign_application_name()

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

Definition at line 11678 of file guc.c.

References pgstat_report_appname().

11679 {
11680  /* Update the pg_stat_activity view */
11682 }
void pgstat_report_appname(const char *appname)
Definition: pgstat.c:3448
#define newval

◆ assign_backtrace_functions()

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

Definition at line 11785 of file guc.c.

11786 {
11787  backtrace_symbol_list = (char *) extra;
11788 }
char * backtrace_symbol_list
Definition: guc.c:549

◆ assign_log_destination()

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

Definition at line 11282 of file guc.c.

References Log_destination.

11283 {
11284  Log_destination = *((int *) extra);
11285 }
int Log_destination
Definition: elog.c:110

◆ assign_pgstat_temp_directory()

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

Definition at line 11640 of file guc.c.

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

11641 {
11642  /* check_canonical_path already canonicalized newval for us */
11643  char *dname;
11644  char *tname;
11645  char *fname;
11646 
11647  /* directory */
11648  dname = guc_malloc(ERROR, strlen(newval) + 1); /* runtime dir */
11649  sprintf(dname, "%s", newval);
11650 
11651  /* global stats */
11652  tname = guc_malloc(ERROR, strlen(newval) + 12); /* /global.tmp */
11653  sprintf(tname, "%s/global.tmp", newval);
11654  fname = guc_malloc(ERROR, strlen(newval) + 13); /* /global.stat */
11655  sprintf(fname, "%s/global.stat", newval);
11656 
11659  pgstat_stat_directory = dname;
11660  if (pgstat_stat_tmpname)
11662  pgstat_stat_tmpname = tname;
11665  pgstat_stat_filename = fname;
11666 }
#define sprintf
Definition: port.h:217
char * pgstat_stat_filename
Definition: pgstat.c:135
#define ERROR
Definition: elog.h:43
char * pgstat_stat_directory
Definition: pgstat.c:134
#define free(a)
Definition: header.h:65
#define newval
char * pgstat_stat_tmpname
Definition: pgstat.c:136
static void * guc_malloc(int elevel, size_t size)
Definition: guc.c:4853

◆ assign_recovery_target()

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

Definition at line 11864 of file guc.c.

References RECOVERY_TARGET_IMMEDIATE, RECOVERY_TARGET_UNSET, and recoveryTarget.

11865 {
11868  error_multiple_recovery_targets();
11869 
11870  if (newval && strcmp(newval, "") != 0)
11872  else
11874 }
#define newval
RecoveryTargetType recoveryTarget
Definition: xlog.c:283

◆ assign_recovery_target_lsn()

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

Definition at line 12032 of file guc.c.

References RECOVERY_TARGET_LSN, RECOVERY_TARGET_UNSET, recoveryTarget, and recoveryTargetLSN.

12033 {
12036  error_multiple_recovery_targets();
12037 
12038  if (newval && strcmp(newval, "") != 0)
12039  {
12041  recoveryTargetLSN = *((XLogRecPtr *) extra);
12042  }
12043  else
12045 }
XLogRecPtr recoveryTargetLSN
Definition: xlog.c:290
uint64 XLogRecPtr
Definition: xlogdefs.h:21
#define newval
RecoveryTargetType recoveryTarget
Definition: xlog.c:283

◆ assign_recovery_target_name()

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

Definition at line 11996 of file guc.c.

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

11997 {
12000  error_multiple_recovery_targets();
12001 
12002  if (newval && strcmp(newval, "") != 0)
12003  {
12006  }
12007  else
12009 }
const char * recoveryTargetName
Definition: xlog.c:289
#define newval
RecoveryTargetType recoveryTarget
Definition: xlog.c:283

◆ assign_recovery_target_time()

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

Definition at line 11970 of file guc.c.

References RECOVERY_TARGET_TIME, RECOVERY_TARGET_UNSET, and recoveryTarget.

11971 {
11974  error_multiple_recovery_targets();
11975 
11976  if (newval && strcmp(newval, "") != 0)
11978  else
11980 }
#define newval
RecoveryTargetType recoveryTarget
Definition: xlog.c:283

◆ assign_recovery_target_timeline()

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

Definition at line 11821 of file guc.c.

References RECOVERY_TARGET_TIMELINE_NUMERIC, recoveryTargetTimeLineGoal, and recoveryTargetTLIRequested.

11822 {
11825  recoveryTargetTLIRequested = (TimeLineID) strtoul(newval, NULL, 0);
11826  else
11828 }
TimeLineID recoveryTargetTLIRequested
Definition: xlog.c:340
uint32 TimeLineID
Definition: xlogdefs.h:52
RecoveryTargetTimeLineGoal
Definition: xlog.h:93
RecoveryTargetTimeLineGoal recoveryTargetTimeLineGoal
Definition: xlog.c:339
#define newval

◆ assign_recovery_target_xid()

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

Definition at line 11897 of file guc.c.

References RECOVERY_TARGET_UNSET, RECOVERY_TARGET_XID, recoveryTarget, and recoveryTargetXid.

11898 {
11901  error_multiple_recovery_targets();
11902 
11903  if (newval && strcmp(newval, "") != 0)
11904  {
11906  recoveryTargetXid = *((TransactionId *) extra);
11907  }
11908  else
11910 }
uint32 TransactionId
Definition: c.h:521
TransactionId recoveryTargetXid
Definition: xlog.c:286
#define newval
RecoveryTargetType recoveryTarget
Definition: xlog.c:283

◆ assign_session_replication_role()

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

Definition at line 11308 of file guc.c.

References ResetPlanCache(), and SessionReplicationRole.

11309 {
11310  /*
11311  * Must flush the plan cache when changing replication role; but don't
11312  * flush unnecessarily.
11313  */
11315  ResetPlanCache();
11316 }
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 11288 of file guc.c.

11289 {
11290 #ifdef HAVE_SYSLOG
11291  set_syslog_parameters(syslog_ident_str ? syslog_ident_str : "postgres",
11292  newval);
11293 #endif
11294  /* Without syslog support, just ignore it */
11295 }
static char * syslog_ident_str
Definition: guc.c:590
#define newval

◆ assign_syslog_ident()

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

Definition at line 11298 of file guc.c.

11299 {
11300 #ifdef HAVE_SYSLOG
11301  set_syslog_parameters(newval, syslog_facility);
11302 #endif
11303  /* Without syslog support, it will always be set to "none", so ignore */
11304 }
static int syslog_facility
Definition: guc.c:173
#define newval

◆ assign_tcp_keepalives_count()

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

Definition at line 11507 of file guc.c.

References MyProcPort, and pq_setkeepalivescount().

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

◆ assign_tcp_keepalives_idle()

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

Definition at line 11463 of file guc.c.

References MyProcPort, and pq_setkeepalivesidle().

11464 {
11465  /*
11466  * The kernel API provides no way to test a value without setting it; and
11467  * once we set it we might fail to unset it. So there seems little point
11468  * in fully implementing the check-then-assign GUC API for these
11469  * variables. Instead we just do the assignment on demand. pqcomm.c
11470  * reports any problems via elog(LOG).
11471  *
11472  * This approach means that the GUC value might have little to do with the
11473  * actual kernel value, so we use a show_hook that retrieves the kernel
11474  * value rather than trusting GUC's copy.
11475  */
11477 }
struct Port * MyProcPort
Definition: globals.c:43
int pq_setkeepalivesidle(int idle, Port *port)
Definition: pqcomm.c:1717
#define newval

◆ assign_tcp_keepalives_interval()

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

Definition at line 11490 of file guc.c.

References MyProcPort, and pq_setkeepalivesinterval().

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

◆ assign_tcp_user_timeout()

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

Definition at line 11524 of file guc.c.

References MyProcPort, and pq_settcpusertimeout().

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

◆ assign_timezone_abbreviations()

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

Definition at line 11427 of file guc.c.

References InstallTimeZoneAbbrevs().

11428 {
11429  /* Do nothing for the boot_val default of NULL */
11430  if (!extra)
11431  return;
11432 
11434 }
void InstallTimeZoneAbbrevs(TimeZoneAbbrevTable *tbl)
Definition: datetime.c:4614

◆ assign_wal_consistency_checking()

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

Definition at line 11219 of file guc.c.

References wal_consistency_checking.

11220 {
11221  wal_consistency_checking = (bool *) extra;
11222 }
bool * wal_consistency_checking
Definition: xlog.c:102

◆ AtEOXact_GUC()

void AtEOXact_GUC ( bool  isCommit,
int  nestLevel 
)

Definition at line 5956 of file guc.c.

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

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

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

◆ AtStart_GUC()

void AtStart_GUC ( void  )

Definition at line 5922 of file guc.c.

References elog, and WARNING.

Referenced by StartTransaction().

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

◆ BeginReportingGUCOptions()

void BeginReportingGUCOptions ( void  )

Definition at line 6238 of file guc.c.

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

Referenced by PostgresMain().

6239 {
6240  int i;
6241 
6242  /*
6243  * Don't do anything unless talking to an interactive frontend of protocol
6244  * 3.0 or later.
6245  */
6246  if (whereToSendOutput != DestRemote ||
6248  return;
6249 
6250  reporting_enabled = true;
6251 
6252  /* Transmit initial values of interesting variables */
6253  for (i = 0; i < num_guc_variables; i++)
6254  {
6255  struct config_generic *conf = guc_variables[i];
6256 
6257  if (conf->flags & GUC_REPORT)
6258  ReportGUCOption(conf);
6259  }
6260 }
#define PG_PROTOCOL_MAJOR(v)
Definition: pqcomm.h:104
static int num_guc_variables
Definition: guc.c:4815
#define GUC_REPORT
Definition: guc.h:209
static struct config_generic ** guc_variables
Definition: guc.c:4812
int i
static void ReportGUCOption(struct config_generic *record)
Definition: guc.c:6266
CommandDest whereToSendOutput
Definition: postgres.c:91
static bool reporting_enabled
Definition: guc.c:4823
ProtocolVersion FrontendProtocol
Definition: globals.c:28

◆ build_guc_variables()

void build_guc_variables ( void  )

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

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

◆ call_bool_check_hook()

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

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

10971 {
10972  /* Quick success if no hook */
10973  if (!conf->check_hook)
10974  return true;
10975 
10976  /* Reset variables that might be set by hook */
10977  GUC_check_errcode_value = ERRCODE_INVALID_PARAMETER_VALUE;
10978  GUC_check_errmsg_string = NULL;
10980  GUC_check_errhint_string = NULL;
10981 
10982  if (!conf->check_hook(newval, extra, source))
10983  {
10984  ereport(elevel,
10988  errmsg("invalid value for parameter \"%s\": %d",
10989  conf->gen.name, (int) *newval),
10993  errhint("%s", GUC_check_errhint_string) : 0));
10994  /* Flush any strings created in ErrorContext */
10995  FlushErrorState();
10996  return false;
10997  }
10998 
10999  return true;
11000 }
char * GUC_check_errhint_string
Definition: guc.c:146
GucSource source
Definition: guc_tables.h:158
int errhint(const char *fmt,...)
Definition: elog.c:1068
const char * name
Definition: guc_tables.h:149
int errcode(int sqlerrcode)
Definition: elog.c:610
static int GUC_check_errcode_value
Definition: guc.c:141
void FlushErrorState(void)
Definition: elog.c:1565
int errdetail_internal(const char *fmt,...)
Definition: elog.c:981
struct config_generic gen
Definition: guc_tables.h:182
char * GUC_check_errdetail_string
Definition: guc.c:145
static int elevel
Definition: vacuumlazy.c:333
GucBoolCheckHook check_hook
Definition: guc_tables.h:186
#define ereport(elevel,...)
Definition: elog.h:144
int errmsg_internal(const char *fmt,...)
Definition: elog.c:908
#define newval
char * GUC_check_errmsg_string
Definition: guc.c:144
int errmsg(const char *fmt,...)
Definition: elog.c:821

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

11107 {
11108  /* Quick success if no hook */
11109  if (!conf->check_hook)
11110  return true;
11111 
11112  /* Reset variables that might be set by hook */
11113  GUC_check_errcode_value = ERRCODE_INVALID_PARAMETER_VALUE;
11114  GUC_check_errmsg_string = NULL;
11116  GUC_check_errhint_string = NULL;
11117 
11118  if (!conf->check_hook(newval, extra, source))
11119  {
11120  ereport(elevel,
11124  errmsg("invalid value for parameter \"%s\": \"%s\"",
11125  conf->gen.name,
11130  errhint("%s", GUC_check_errhint_string) : 0));
11131  /* Flush any strings created in ErrorContext */
11132  FlushErrorState();
11133  return false;
11134  }
11135 
11136  return true;
11137 }
char * GUC_check_errhint_string
Definition: guc.c:146
GucSource source
Definition: guc_tables.h:158
GucEnumCheckHook check_hook
Definition: guc_tables.h:247
int errhint(const char *fmt,...)
Definition: elog.c:1068
const char * name
Definition: guc_tables.h:149
int errcode(int sqlerrcode)
Definition: elog.c:610
const char * config_enum_lookup_by_value(struct config_enum *record, int val)
Definition: guc.c:6645
static int GUC_check_errcode_value
Definition: guc.c:141
void FlushErrorState(void)
Definition: elog.c:1565
int errdetail_internal(const char *fmt,...)
Definition: elog.c:981
char * GUC_check_errdetail_string
Definition: guc.c:145
static int elevel
Definition: vacuumlazy.c:333
struct config_generic gen
Definition: guc_tables.h:242
#define ereport(elevel,...)
Definition: elog.h:144
int errmsg_internal(const char *fmt,...)
Definition: elog.c:908
#define newval
char * GUC_check_errmsg_string
Definition: guc.c:144
int errmsg(const char *fmt,...)
Definition: elog.c:821

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

11005 {
11006  /* Quick success if no hook */
11007  if (!conf->check_hook)
11008  return true;
11009 
11010  /* Reset variables that might be set by hook */
11011  GUC_check_errcode_value = ERRCODE_INVALID_PARAMETER_VALUE;
11012  GUC_check_errmsg_string = NULL;
11014  GUC_check_errhint_string = NULL;
11015 
11016  if (!conf->check_hook(newval, extra, source))
11017  {
11018  ereport(elevel,
11022  errmsg("invalid value for parameter \"%s\": %d",
11023  conf->gen.name, *newval),
11027  errhint("%s", GUC_check_errhint_string) : 0));
11028  /* Flush any strings created in ErrorContext */
11029  FlushErrorState();
11030  return false;
11031  }
11032 
11033  return true;
11034 }
char * GUC_check_errhint_string
Definition: guc.c:146
GucSource source
Definition: guc_tables.h:158
int errhint(const char *fmt,...)
Definition: elog.c:1068
const char * name
Definition: guc_tables.h:149
int errcode(int sqlerrcode)
Definition: elog.c:610
static int GUC_check_errcode_value
Definition: guc.c:141
GucIntCheckHook check_hook
Definition: guc_tables.h:202
void FlushErrorState(void)
Definition: elog.c:1565
int errdetail_internal(const char *fmt,...)
Definition: elog.c:981
struct config_generic gen
Definition: guc_tables.h:196
char * GUC_check_errdetail_string
Definition: guc.c:145
static int elevel
Definition: vacuumlazy.c:333
#define ereport(elevel,...)
Definition: elog.h:144
int errmsg_internal(const char *fmt,...)
Definition: elog.c:908
#define newval
char * GUC_check_errmsg_string
Definition: guc.c:144
int errmsg(const char *fmt,...)
Definition: elog.c:821

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

11039 {
11040  /* Quick success if no hook */
11041  if (!conf->check_hook)
11042  return true;
11043 
11044  /* Reset variables that might be set by hook */
11045  GUC_check_errcode_value = ERRCODE_INVALID_PARAMETER_VALUE;
11046  GUC_check_errmsg_string = NULL;
11048  GUC_check_errhint_string = NULL;
11049 
11050  if (!conf->check_hook(newval, extra, source))
11051  {
11052  ereport(elevel,
11056  errmsg("invalid value for parameter \"%s\": %g",
11057  conf->gen.name, *newval),
11061  errhint("%s", GUC_check_errhint_string) : 0));
11062  /* Flush any strings created in ErrorContext */
11063  FlushErrorState();
11064  return false;
11065  }
11066 
11067  return true;
11068 }
char * GUC_check_errhint_string
Definition: guc.c:146
GucSource source
Definition: guc_tables.h:158
int errhint(const char *fmt,...)
Definition: elog.c:1068
const char * name
Definition: guc_tables.h:149
int errcode(int sqlerrcode)
Definition: elog.c:610
static int GUC_check_errcode_value
Definition: guc.c:141
GucRealCheckHook check_hook
Definition: guc_tables.h:218
void FlushErrorState(void)
Definition: elog.c:1565
int errdetail_internal(const char *fmt,...)
Definition: elog.c:981
char * GUC_check_errdetail_string
Definition: guc.c:145
static int elevel
Definition: vacuumlazy.c:333
#define ereport(elevel,...)
Definition: elog.h:144
int errmsg_internal(const char *fmt,...)
Definition: elog.c:908
#define newval
char * GUC_check_errmsg_string
Definition: guc.c:144
int errmsg(const char *fmt,...)
Definition: elog.c:821
struct config_generic gen
Definition: guc_tables.h:212

◆ call_string_check_hook()

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

Definition at line 11071 of file guc.c.

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

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

11073 {
11074  /* Quick success if no hook */
11075  if (!conf->check_hook)
11076  return true;
11077 
11078  /* Reset variables that might be set by hook */
11079  GUC_check_errcode_value = ERRCODE_INVALID_PARAMETER_VALUE;
11080  GUC_check_errmsg_string = NULL;
11082  GUC_check_errhint_string = NULL;
11083 
11084  if (!conf->check_hook(newval, extra, source))
11085  {
11086  ereport(elevel,
11090  errmsg("invalid value for parameter \"%s\": \"%s\"",
11091  conf->gen.name, *newval ? *newval : ""),
11095  errhint("%s", GUC_check_errhint_string) : 0));
11096  /* Flush any strings created in ErrorContext */
11097  FlushErrorState();
11098  return false;
11099  }
11100 
11101  return true;
11102 }
char * GUC_check_errhint_string
Definition: guc.c:146
GucSource source
Definition: guc_tables.h:158
int errhint(const char *fmt,...)
Definition: elog.c:1068
const char * name
Definition: guc_tables.h:149
GucStringCheckHook check_hook
Definition: guc_tables.h:232
int errcode(int sqlerrcode)
Definition: elog.c:610
static int GUC_check_errcode_value
Definition: guc.c:141
void FlushErrorState(void)
Definition: elog.c:1565
int errdetail_internal(const char *fmt,...)
Definition: elog.c:981
char * GUC_check_errdetail_string
Definition: guc.c:145
static int elevel
Definition: vacuumlazy.c:333
#define ereport(elevel,...)
Definition: elog.h:144
struct config_generic gen
Definition: guc_tables.h:228
int errmsg_internal(const char *fmt,...)
Definition: elog.c:908
#define newval
char * GUC_check_errmsg_string
Definition: guc.c:144
int errmsg(const char *fmt,...)
Definition: elog.c:821

◆ can_skip_gucvar()

static bool can_skip_gucvar ( struct config_generic gconf)
static

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

10150 {
10151  return gconf->context == PGC_POSTMASTER ||
10152  gconf->context == PGC_INTERNAL || gconf->source == PGC_S_DEFAULT ||
10153  strcmp(gconf->name, "role") == 0;
10154 }
GucSource source
Definition: guc_tables.h:158
const char * name
Definition: guc_tables.h:149
GucContext context
Definition: guc_tables.h:150

◆ check_application_name()

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

Definition at line 11669 of file guc.c.

References pg_clean_ascii().

11670 {
11671  /* Only allow clean ASCII chars in the application name */
11673 
11674  return true;
11675 }
#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 11550 of file guc.c.

References MAX_BACKENDS, max_wal_senders, max_worker_processes, and MaxConnections.

11551 {
11552  if (MaxConnections + *newval + 1 +
11554  return false;
11555  return true;
11556 }
#define MAX_BACKENDS
Definition: postmaster.h:75
int max_wal_senders
Definition: walsender.c:121
int MaxConnections
Definition: globals.c:133
#define newval
int max_worker_processes
Definition: globals.c:134

◆ check_autovacuum_work_mem()

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

Definition at line 11568 of file guc.c.

11569 {
11570  /*
11571  * -1 indicates fallback.
11572  *
11573  * If we haven't yet changed the boot_val default of -1, just let it be.
11574  * Autovacuum will look to maintenance_work_mem instead.
11575  */
11576  if (*newval == -1)
11577  return true;
11578 
11579  /*
11580  * We clamp manually-set values to at least 1MB. Since
11581  * maintenance_work_mem is always set to at least this value, do the same
11582  * here.
11583  */
11584  if (*newval < 1024)
11585  *newval = 1024;
11586 
11587  return true;
11588 }
#define newval

◆ check_backtrace_functions()

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

Definition at line 11729 of file guc.c.

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

11730 {
11731  int newvallen = strlen(*newval);
11732  char *someval;
11733  int validlen;
11734  int i;
11735  int j;
11736 
11737  /*
11738  * Allow characters that can be C identifiers and commas as separators, as
11739  * well as some whitespace for readability.
11740  */
11741  validlen = strspn(*newval,
11742  "0123456789_"
11743  "abcdefghijklmnopqrstuvwxyz"
11744  "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
11745  ", \n\t");
11746  if (validlen != newvallen)
11747  {
11748  GUC_check_errdetail("invalid character");
11749  return false;
11750  }
11751 
11752  if (*newval[0] == '\0')
11753  {
11754  *extra = NULL;
11755  return true;
11756  }
11757 
11758  /*
11759  * Allocate space for the output and create the copy. We could discount
11760  * whitespace chars to save some memory, but it doesn't seem worth the
11761  * trouble.
11762  */
11763  someval = guc_malloc(ERROR, newvallen + 1 + 1);
11764  for (i = 0, j = 0; i < newvallen; i++)
11765  {
11766  if ((*newval)[i] == ',')
11767  someval[j++] = '\0'; /* next item */
11768  else if ((*newval)[i] == ' ' ||
11769  (*newval)[i] == '\n' ||
11770  (*newval)[i] == '\t')
11771  ; /* ignore these */
11772  else
11773  someval[j++] = (*newval)[i]; /* copy anything else */
11774  }
11775 
11776  /* two \0s end the setting */
11777  someval[j] = '\0';
11778  someval[j + 1] = '\0';
11779 
11780  *extra = someval;
11781  return true;
11782 }
#define GUC_check_errdetail
Definition: guc.h:416
#define ERROR
Definition: elog.h:43
#define newval
int i
static void * guc_malloc(int elevel, size_t size)
Definition: guc.c:4853

◆ check_bonjour()

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

Definition at line 11333 of file guc.c.

References GUC_check_errmsg.

11334 {
11335 #ifndef USE_BONJOUR
11336  if (*newval)
11337  {
11338  GUC_check_errmsg("Bonjour is not supported by this build");
11339  return false;
11340  }
11341 #endif
11342  return true;
11343 }
#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 11384 of file guc.c.

References canonicalize_path().

11385 {
11386  /*
11387  * Since canonicalize_path never enlarges the string, we can just modify
11388  * newval in-place. But watch out for NULL, which is the default value
11389  * for external_pid_file.
11390  */
11391  if (*newval)
11393  return true;
11394 }
void canonicalize_path(char *path)
Definition: path.c:254
#define newval

◆ check_cluster_name()

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

Definition at line 11685 of file guc.c.

References pg_clean_ascii().

11686 {
11687  /* Only allow clean ASCII chars in the cluster name */
11689 
11690  return true;
11691 }
#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 12058 of file guc.c.

References GUC_check_errcode(), and GUC_check_errmsg.

12059 {
12060  if (*newval)
12061  {
12062  /* check the GUC's definition for an explanation */
12063  GUC_check_errcode(ERRCODE_FEATURE_NOT_SUPPORTED);
12064  GUC_check_errmsg("tables declared WITH OIDS are not supported");
12065 
12066  return false;
12067  }
12068 
12069  return true;
12070 }
#define GUC_check_errmsg
Definition: guc.h:412
void GUC_check_errcode(int sqlerrcode)
Definition: guc.c:10956
#define newval

◆ check_effective_io_concurrency()

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

Definition at line 11600 of file guc.c.

References GUC_check_errdetail.

11601 {
11602 #ifndef USE_PREFETCH
11603  if (*newval != 0)
11604  {
11605  GUC_check_errdetail("effective_io_concurrency must be set to 0 on platforms that lack posix_fadvise().");
11606  return false;
11607  }
11608 #endif /* USE_PREFETCH */
11609  return true;
11610 }
#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 11626 of file guc.c.

References GUC_check_errdetail.

11627 {
11628 #if !(defined(MAP_HUGE_MASK) && defined(MAP_HUGE_SHIFT))
11629  /* Recent enough Linux only, for now. See GetHugePageSize(). */
11630  if (*newval != 0)
11631  {
11632  GUC_check_errdetail("huge_page_size must be 0 on this platform.");
11633  return false;
11634  }
11635 #endif
11636  return true;
11637 }
#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 11225 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().

11226 {
11227  char *rawstring;
11228  List *elemlist;
11229  ListCell *l;
11230  int newlogdest = 0;
11231  int *myextra;
11232 
11233  /* Need a modifiable copy of string */
11234  rawstring = pstrdup(*newval);
11235 
11236  /* Parse string into list of identifiers */
11237  if (!SplitIdentifierString(rawstring, ',', &elemlist))
11238  {
11239  /* syntax error in list */
11240  GUC_check_errdetail("List syntax is invalid.");
11241  pfree(rawstring);
11242  list_free(elemlist);
11243  return false;
11244  }
11245 
11246  foreach(l, elemlist)
11247  {
11248  char *tok = (char *) lfirst(l);
11249 
11250  if (pg_strcasecmp(tok, "stderr") == 0)
11251  newlogdest |= LOG_DESTINATION_STDERR;
11252  else if (pg_strcasecmp(tok, "csvlog") == 0)
11253  newlogdest |= LOG_DESTINATION_CSVLOG;
11254 #ifdef HAVE_SYSLOG
11255  else if (pg_strcasecmp(tok, "syslog") == 0)
11256  newlogdest |= LOG_DESTINATION_SYSLOG;
11257 #endif
11258 #ifdef WIN32
11259  else if (pg_strcasecmp(tok, "eventlog") == 0)
11260  newlogdest |= LOG_DESTINATION_EVENTLOG;
11261 #endif
11262  else
11263  {
11264  GUC_check_errdetail("Unrecognized key word: \"%s\".", tok);
11265  pfree(rawstring);
11266  list_free(elemlist);
11267  return false;
11268  }
11269  }
11270 
11271  pfree(rawstring);
11272  list_free(elemlist);
11273 
11274  myextra = (int *) guc_malloc(ERROR, sizeof(int));
11275  *myextra = newlogdest;
11276  *extra = (void *) myextra;
11277 
11278  return true;
11279 }
#define LOG_DESTINATION_EVENTLOG
Definition: elog.h:420
#define GUC_check_errdetail
Definition: guc.h:416
char * pstrdup(const char *in)
Definition: mcxt.c:1187
#define LOG_DESTINATION_SYSLOG
Definition: elog.h:419
int pg_strcasecmp(const char *s1, const char *s2)
Definition: pgstrcasecmp.c:36
void pfree(void *pointer)
Definition: mcxt.c:1057
#define ERROR
Definition: elog.h:43
bool SplitIdentifierString(char *rawstring, char separator, List **namelist)
Definition: varlena.c:3702
#define LOG_DESTINATION_CSVLOG
Definition: elog.h:421
#define LOG_DESTINATION_STDERR
Definition: elog.h:418
#define lfirst(lc)
Definition: pg_list.h:169
#define newval
void list_free(List *list)
Definition: list.c:1376
static void * guc_malloc(int elevel, size_t size)
Definition: guc.c:4853
Definition: pg_list.h:50

◆ check_log_stats()

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

Definition at line 11370 of file guc.c.

References GUC_check_errdetail.

11371 {
11372  if (*newval &&
11374  {
11375  GUC_check_errdetail("Cannot enable \"log_statement_stats\" when "
11376  "\"log_parser_stats\", \"log_planner_stats\", "
11377  "or \"log_executor_stats\" is true.");
11378  return false;
11379  }
11380  return true;
11381 }
bool log_parser_stats
Definition: guc.c:519
#define GUC_check_errdetail
Definition: guc.h:416
#define newval
bool log_executor_stats
Definition: guc.c:521
bool log_planner_stats
Definition: guc.c:520

◆ check_maintenance_io_concurrency()

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

Definition at line 11613 of file guc.c.

References GUC_check_errdetail.

11614 {
11615 #ifndef USE_PREFETCH
11616  if (*newval != 0)
11617  {
11618  GUC_check_errdetail("maintenance_io_concurrency must be set to 0 on platforms that lack posix_fadvise().");
11619  return false;
11620  }
11621 #endif /* USE_PREFETCH */
11622  return true;
11623 }
#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 11559 of file guc.c.

References autovacuum_max_workers, MAX_BACKENDS, max_worker_processes, and MaxConnections.

11560 {
11563  return false;
11564  return true;
11565 }
#define MAX_BACKENDS
Definition: postmaster.h:75
int MaxConnections
Definition: globals.c:133
int autovacuum_max_workers
Definition: autovacuum.c:115
#define newval
int max_worker_processes
Definition: globals.c:134

◆ check_max_worker_processes()

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

Definition at line 11591 of file guc.c.

References autovacuum_max_workers, MAX_BACKENDS, max_wal_senders, and MaxConnections.

11592 {
11595  return false;
11596  return true;
11597 }
#define MAX_BACKENDS
Definition: postmaster.h:75
int max_wal_senders
Definition: walsender.c:121
int MaxConnections
Definition: globals.c:133
int autovacuum_max_workers
Definition: autovacuum.c:115
#define newval

◆ check_maxconnections()

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

Definition at line 11541 of file guc.c.

References autovacuum_max_workers, MAX_BACKENDS, max_wal_senders, and max_worker_processes.

11542 {
11543  if (*newval + autovacuum_max_workers + 1 +
11545  return false;
11546  return true;
11547 }
#define MAX_BACKENDS
Definition: postmaster.h:75
int max_wal_senders
Definition: walsender.c:121
int autovacuum_max_workers
Definition: autovacuum.c:115
#define newval
int max_worker_processes
Definition: globals.c:134

◆ check_primary_slot_name()

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

Definition at line 12048 of file guc.c.

References ReplicationSlotValidateName(), and WARNING.

12049 {
12050  if (*newval && strcmp(*newval, "") != 0 &&
12052  return false;
12053 
12054  return true;
12055 }
bool ReplicationSlotValidateName(const char *name, int elevel)
Definition: slot.c:174
#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 11853 of file guc.c.

References GUC_check_errdetail.

11854 {
11855  if (strcmp(*newval, "immediate") != 0 && strcmp(*newval, "") != 0)
11856  {
11857  GUC_check_errdetail("The only allowed value is \"immediate\".");
11858  return false;
11859  }
11860  return true;
11861 }
#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 12012 of file guc.c.

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

12013 {
12014  if (strcmp(*newval, "") != 0)
12015  {
12016  XLogRecPtr lsn;
12017  XLogRecPtr *myextra;
12018  bool have_error = false;
12019 
12020  lsn = pg_lsn_in_internal(*newval, &have_error);
12021  if (have_error)
12022  return false;
12023 
12024  myextra = (XLogRecPtr *) guc_malloc(ERROR, sizeof(XLogRecPtr));
12025  *myextra = lsn;
12026  *extra = (void *) myextra;
12027  }
12028  return true;
12029 }
#define ERROR
Definition: elog.h:43
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:4853

◆ check_recovery_target_name()

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

Definition at line 11983 of file guc.c.

References GUC_check_errdetail, and MAXFNAMELEN.

11984 {
11985  /* Use the value of newval directly */
11986  if (strlen(*newval) >= MAXFNAMELEN)
11987  {
11988  GUC_check_errdetail("%s is too long (maximum %d characters).",
11989  "recovery_target_name", MAXFNAMELEN - 1);
11990  return false;
11991  }
11992  return true;
11993 }
#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 11920 of file guc.c.

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

11921 {
11922  if (strcmp(*newval, "") != 0)
11923  {
11924  /* reject some special values */
11925  if (strcmp(*newval, "now") == 0 ||
11926  strcmp(*newval, "today") == 0 ||
11927  strcmp(*newval, "tomorrow") == 0 ||
11928  strcmp(*newval, "yesterday") == 0)
11929  {
11930  return false;
11931  }
11932 
11933  /*
11934  * parse timestamp value (see also timestamptz_in())
11935  */
11936  {
11937  char *str = *newval;
11938  fsec_t fsec;
11939  struct pg_tm tt,
11940  *tm = &tt;
11941  int tz;
11942  int dtype;
11943  int nf;
11944  int dterr;
11945  char *field[MAXDATEFIELDS];
11946  int ftype[MAXDATEFIELDS];
11947  char workbuf[MAXDATELEN + MAXDATEFIELDS];
11949 
11950  dterr = ParseDateTime(str, workbuf, sizeof(workbuf),
11951  field, ftype, MAXDATEFIELDS, &nf);
11952  if (dterr == 0)
11953  dterr = DecodeDateTime(field, ftype, nf, &dtype, tm, &fsec, &tz);
11954  if (dterr != 0)
11955  return false;
11956  if (dtype != DTK_DATE)
11957  return false;
11958 
11959  if (tm2timestamp(tm, fsec, &tz, &timestamp) != 0)
11960  {
11961  GUC_check_errdetail("timestamp out of range: \"%s\"", str);
11962  return false;
11963  }
11964  }
11965  }
11966  return true;
11967 }
#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:1884
#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 11791 of file guc.c.

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

11792 {
11794  RecoveryTargetTimeLineGoal *myextra;
11795 
11796  if (strcmp(*newval, "current") == 0)
11798  else if (strcmp(*newval, "latest") == 0)
11800  else
11801  {
11803 
11804  errno = 0;
11805  strtoul(*newval, NULL, 0);
11806  if (errno == EINVAL || errno == ERANGE)
11807  {
11808  GUC_check_errdetail("recovery_target_timeline is not a valid number.");
11809  return false;
11810  }
11811  }
11812 
11814  *myextra = rttg;
11815  *extra = (void *) myextra;
11816 
11817  return true;
11818 }
#define GUC_check_errdetail
Definition: guc.h:416
RecoveryTargetTimeLineGoal
Definition: xlog.h:93
#define ERROR
Definition: elog.h:43
#define newval
static void * guc_malloc(int elevel, size_t size)
Definition: guc.c:4853

◆ check_recovery_target_xid()

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

Definition at line 11877 of file guc.c.

References ERROR, and guc_malloc().

11878 {
11879  if (strcmp(*newval, "") != 0)
11880  {
11881  TransactionId xid;
11882  TransactionId *myextra;
11883 
11884  errno = 0;
11885  xid = (TransactionId) strtoul(*newval, NULL, 0);
11886  if (errno == EINVAL || errno == ERANGE)
11887  return false;
11888 
11889  myextra = (TransactionId *) guc_malloc(ERROR, sizeof(TransactionId));
11890  *myextra = xid;
11891  *extra = (void *) myextra;
11892  }
11893  return true;
11894 }
uint32 TransactionId
Definition: c.h:521
#define ERROR
Definition: elog.h:43
#define newval
static void * guc_malloc(int elevel, size_t size)
Definition: guc.c:4853

◆ check_ssl()

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

Definition at line 11346 of file guc.c.

References GUC_check_errmsg.

11347 {
11348 #ifndef USE_SSL
11349  if (*newval)
11350  {
11351  GUC_check_errmsg("SSL is not supported by this build");
11352  return false;
11353  }
11354 #endif
11355  return true;
11356 }
#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 11359 of file guc.c.

References GUC_check_errdetail.

11360 {
11361  if (*newval && log_statement_stats)
11362  {
11363  GUC_check_errdetail("Cannot enable parameter when \"log_statement_stats\" is true.");
11364  return false;
11365  }
11366  return true;
11367 }
bool log_statement_stats
Definition: guc.c:522
#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 11319 of file guc.c.

References GUC_check_errdetail, and NLocBuffer.

11320 {
11321  /*
11322  * Once local buffers have been initialized, it's too late to change this.
11323  */
11324  if (NLocBuffer && NLocBuffer != *newval)
11325  {
11326  GUC_check_errdetail("\"temp_buffers\" cannot be changed after any temporary tables have been accessed in the session.");
11327  return false;
11328  }
11329  return true;
11330 }
#define GUC_check_errdetail
Definition: guc.h:416
int NLocBuffer
Definition: localbuf.c:41
#define newval

◆ check_timezone_abbreviations()

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

Definition at line 11397 of file guc.c.

References Assert, load_tzoffsets(), and PGC_S_DEFAULT.

11398 {
11399  /*
11400  * The boot_val given above for timezone_abbreviations is NULL. When we
11401  * see this we just do nothing. If this value isn't overridden from the
11402  * config file then pg_timezone_abbrev_initialize() will eventually
11403  * replace it with "Default". This hack has two purposes: to avoid
11404  * wasting cycles loading values that might soon be overridden from the
11405  * config file, and to avoid trying to read the timezone abbrev files
11406  * during InitializeGUCOptions(). The latter doesn't work in an
11407  * EXEC_BACKEND subprocess because my_exec_path hasn't been set yet and so
11408  * we can't locate PGSHAREDIR.
11409  */
11410  if (*newval == NULL)
11411  {
11412  Assert(source == PGC_S_DEFAULT);
11413  return true;
11414  }
11415 
11416  /* OK, load the file and produce a malloc'd TimeZoneAbbrevTable */
11417  *extra = load_tzoffsets(*newval);
11418 
11419  /* tzparser.c returns NULL on failure, reporting via GUC_check_errmsg */
11420  if (!*extra)
11421  return false;
11422 
11423  return true;
11424 }
TimeZoneAbbrevTable * load_tzoffsets(const char *filename)
Definition: tzparser.c:437
#define Assert(condition)
Definition: c.h:746
#define newval

◆ check_wal_consistency_checking()

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

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

11146 {
11147  char *rawstring;
11148  List *elemlist;
11149  ListCell *l;
11150  bool newwalconsistency[RM_MAX_ID + 1];
11151 
11152  /* Initialize the array */
11153  MemSet(newwalconsistency, 0, (RM_MAX_ID + 1) * sizeof(bool));
11154 
11155  /* Need a modifiable copy of string */
11156  rawstring = pstrdup(*newval);
11157 
11158  /* Parse string into list of identifiers */
11159  if (!SplitIdentifierString(rawstring, ',', &elemlist))
11160  {
11161  /* syntax error in list */
11162  GUC_check_errdetail("List syntax is invalid.");
11163  pfree(rawstring);
11164  list_free(elemlist);
11165  return false;
11166  }
11167 
11168  foreach(l, elemlist)
11169  {
11170  char *tok = (char *) lfirst(l);
11171  bool found = false;
11172  RmgrId rmid;
11173 
11174  /* Check for 'all'. */
11175  if (pg_strcasecmp(tok, "all") == 0)
11176  {
11177  for (rmid = 0; rmid <= RM_MAX_ID; rmid++)
11178  if (RmgrTable[rmid].rm_mask != NULL)
11179  newwalconsistency[rmid] = true;
11180  found = true;
11181  }
11182  else
11183  {
11184  /*
11185  * Check if the token matches with any individual resource
11186  * manager.
11187  */
11188  for (rmid = 0; rmid <= RM_MAX_ID; rmid++)
11189  {
11190  if (pg_strcasecmp(tok, RmgrTable[rmid].rm_name) == 0 &&
11191  RmgrTable[rmid].rm_mask != NULL)
11192  {
11193  newwalconsistency[rmid] = true;
11194  found = true;
11195  }
11196  }
11197  }
11198 
11199  /* If a valid resource manager is found, check for the next one. */
11200  if (!found)
11201  {
11202  GUC_check_errdetail("Unrecognized key word: \"%s\".", tok);
11203  pfree(rawstring);
11204  list_free(elemlist);
11205  return false;
11206  }
11207  }
11208 
11209  pfree(rawstring);
11210  list_free(elemlist);
11211 
11212  /* assign new value */
11213  *extra = guc_malloc(ERROR, (RM_MAX_ID + 1) * sizeof(bool));
11214  memcpy(*extra, newwalconsistency, (RM_MAX_ID + 1) * sizeof(bool));
11215  return true;
11216 }
#define GUC_check_errdetail
Definition: guc.h:416
char * pstrdup(const char *in)
Definition: mcxt.c:1187
const RmgrData RmgrTable[RM_MAX_ID+1]
Definition: rmgr.c:36
#define MemSet(start, val, len)
Definition: c.h:950
int pg_strcasecmp(const char *s1, const char *s2)
Definition: pgstrcasecmp.c:36
void pfree(void *pointer)
Definition: mcxt.c:1057
#define ERROR
Definition: elog.h:43
bool SplitIdentifierString(char *rawstring, char separator, List **namelist)
Definition: varlena.c:3702
#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:1376
static void * guc_malloc(int elevel, size_t size)
Definition: guc.c:4853
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 6694 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().

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

◆ config_enum_lookup_by_name()

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

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

6670 {
6671  const struct config_enum_entry *entry;
6672 
6673  for (entry = record->options; entry && entry->name; entry++)
6674  {
6675  if (pg_strcasecmp(value, entry->name) == 0)
6676  {
6677  *retval = entry->val;
6678  return true;
6679  }
6680  }
6681 
6682  *retval = 0;
6683  return false;
6684 }
Definition: guc.h:165
int pg_strcasecmp(const char *s1, const char *s2)
Definition: pgstrcasecmp.c:36
const struct config_enum_entry * options
Definition: guc_tables.h:246
int val
Definition: guc.h:168
static struct @143 value
const char * name
Definition: guc.h:167

◆ config_enum_lookup_by_value()

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

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

6646 {
6647  const struct config_enum_entry *entry;
6648 
6649  for (entry = record->options; entry && entry->name; entry++)
6650  {
6651  if (entry->val == val)
6652  return entry->name;
6653  }
6654 
6655  elog(ERROR, "could not find enum option %d for %s",
6656  val, record->gen.name);
6657  return NULL; /* silence compiler */
6658 }
Definition: guc.h:165
const char * name
Definition: guc_tables.h:149
#define ERROR
Definition: elog.h:43
const struct config_enum_entry * options
Definition: guc_tables.h:246
int val
Definition: guc.h:168
struct config_generic gen
Definition: guc_tables.h:242
const char * name
Definition: guc.h:167
#define elog(elevel,...)
Definition: elog.h:214
long val
Definition: informix.c:664

◆ convert_int_from_base_unit()

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

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

6353 {
6354  const unit_conversion *table;
6355  int i;
6356 
6357  *unit = NULL;
6358 
6359  if (base_unit & GUC_UNIT_MEMORY)
6361  else
6363 
6364  for (i = 0; *table[i].unit; i++)
6365  {
6366  if (base_unit == table[i].base_unit)
6367  {
6368  /*
6369  * Accept the first conversion that divides the value evenly. We
6370  * assume that the conversions for each base unit are ordered from
6371  * greatest unit to the smallest!
6372  */
6373  if (table[i].multiplier <= 1.0 ||
6374  base_value % (int64) table[i].multiplier == 0)
6375  {
6376  *value = (int64) rint(base_value / table[i].multiplier);
6377  *unit = table[i].unit;
6378  break;
6379  }
6380  }
6381  }
6382 
6383  Assert(*unit != NULL);
6384 }
static const unit_conversion time_unit_conversion_table[]
Definition: guc.c:872
static const unit_conversion memory_unit_conversion_table[]
Definition: guc.c:835
static struct @143 value
#define Assert(condition)
Definition: c.h:746
int i
char unit[MAX_UNIT_LEN+1]
Definition: guc.c:819
#define GUC_UNIT_MEMORY
Definition: guc.h:224

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

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

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

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

◆ define_custom_variable()

static void define_custom_variable ( struct config_generic variable)
static

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

8648 {
8649  const char *name = variable->name;
8650  const char **nameAddr = &name;
8651  struct config_string *pHolder;
8652  struct config_generic **res;
8653 
8654  /*
8655  * See if there's a placeholder by the same name.
8656  */
8657  res = (struct config_generic **) bsearch((void *) &nameAddr,
8658  (void *) guc_variables,
8660  sizeof(struct config_generic *),
8661  guc_var_compare);
8662  if (res == NULL)
8663  {
8664  /*
8665  * No placeholder to replace, so we can just add it ... but first,
8666  * make sure it's initialized to its default value.
8667  */
8668  InitializeOneGUCOption(variable);
8669  add_guc_variable(variable, ERROR);
8670  return;
8671  }
8672 
8673  /*
8674  * This better be a placeholder
8675  */
8676  if (((*res)->flags & GUC_CUSTOM_PLACEHOLDER) == 0)
8677  ereport(ERROR,
8678  (errcode(ERRCODE_INTERNAL_ERROR),
8679  errmsg("attempt to redefine parameter \"%s\"", name)));
8680 
8681  Assert((*res)->vartype == PGC_STRING);
8682  pHolder = (struct config_string *) (*res);
8683 
8684  /*
8685  * First, set the variable to its default value. We must do this even
8686  * though we intend to immediately apply a new value, since it's possible
8687  * that the new value is invalid.
8688  */
8689  InitializeOneGUCOption(variable);
8690 
8691  /*
8692  * Replace the placeholder. We aren't changing the name, so no re-sorting
8693  * is necessary
8694  */
8695  *res = variable;
8696 
8697  /*
8698  * Assign the string value(s) stored in the placeholder to the real
8699  * variable. Essentially, we need to duplicate all the active and stacked
8700  * values, but with appropriate validation and datatype adjustment.
8701  *
8702  * If an assignment fails, we report a WARNING and keep going. We don't
8703  * want to throw ERROR for bad values, because it'd bollix the add-on
8704  * module that's presumably halfway through getting loaded. In such cases
8705  * the default or previous state will become active instead.
8706  */
8707 
8708  /* First, apply the reset value if any */
8709  if (pHolder->reset_val)
8710  (void) set_config_option(name, pHolder->reset_val,
8711  pHolder->gen.reset_scontext,
8712  pHolder->gen.reset_source,
8713  GUC_ACTION_SET, true, WARNING, false);
8714  /* That should not have resulted in stacking anything */
8715  Assert(variable->stack == NULL);
8716 
8717  /* Now, apply current and stacked values, in the order they were stacked */
8718  reapply_stacked_values(variable, pHolder, pHolder->gen.stack,
8719  *(pHolder->variable),
8720  pHolder->gen.scontext, pHolder->gen.source);
8721 
8722  /* Also copy over any saved source-location information */
8723  if (pHolder->gen.sourcefile)
8724  set_config_sourcefile(name, pHolder->gen.sourcefile,
8725  pHolder->gen.sourceline);
8726 
8727  /*
8728  * Free up as much as we conveniently can of the placeholder structure.
8729  * (This neglects any stack items, so it's possible for some memory to be
8730  * leaked. Since this can only happen once per session per variable, it
8731  * doesn't seem worth spending much code on.)
8732  */
8733  set_string_field(pHolder, pHolder->variable, NULL);
8734  set_string_field(pHolder, &pHolder->reset_val, NULL);
8735 
8736  free(pHolder);
8737 }
GucSource source
Definition: guc_tables.h:158
static void static void set_config_sourcefile(const char *name, char *sourcefile, int sourceline)
Definition: guc.c:7708
char ** variable
Definition: guc_tables.h:230
const char * name
Definition: guc_tables.h:149
static void reapply_stacked_values(struct config_generic *variable, struct config_string *pHolder, GucStack *stack, const char *curvalue, GucContext curscontext, GucSource cursource)
Definition: guc.c:8747
int errcode(int sqlerrcode)
Definition: elog.c:610
GucContext scontext
Definition: guc_tables.h:160
static int guc_var_compare(const void *a, const void *b)
Definition: guc.c:5298
#define ERROR
Definition: elog.h:43
static int num_guc_variables
Definition: guc.c:4815
char * sourcefile
Definition: guc_tables.h:164
GucSource reset_source
Definition: guc_tables.h:159
static void InitializeOneGUCOption(struct config_generic *gconf)
Definition: guc.c:5446
static void set_string_field(struct config_string *conf, char **field, char *newval)
Definition: guc.c:4925
static struct config_generic ** guc_variables
Definition: guc.c:4812
#define WARNING
Definition: elog.h:40
#define ereport(elevel,...)
Definition: elog.h:144
struct config_generic gen
Definition: guc_tables.h:228
#define free(a)
Definition: header.h:65
char * reset_val
Definition: guc_tables.h:236
#define Assert(condition)
Definition: c.h:746
#define GUC_CUSTOM_PLACEHOLDER
Definition: guc.h:212
const char * name
Definition: encode.c:561
int errmsg(const char *fmt,...)
Definition: elog.c:821
GucStack * stack
Definition: guc_tables.h:162
int set_config_option(const char *name, const char *value, GucContext context, GucSource source, GucAction action, bool changeVal, int elevel, bool is_reload)
Definition: guc.c:6949
static bool add_guc_variable(struct config_generic *var, int elevel)
Definition: guc.c:5163
GucContext reset_scontext
Definition: guc_tables.h:161

◆ DefineCustomBoolVariable()

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

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

8838 {
8839  struct config_bool *var;
8840 
8841  var = (struct config_bool *)
8842  init_custom_variable(name, short_desc, long_desc, context, flags,
8843  PGC_BOOL, sizeof(struct config_bool));
8844  var->variable = valueAddr;
8845  var->boot_val = bootValue;
8846  var->reset_val = bootValue;
8847  var->check_hook = check_hook;
8848  var->assign_hook = assign_hook;
8849  var->show_hook = show_hook;
8850  define_custom_variable(&var->gen);
8851 }
bool * variable
Definition: guc_tables.h:184
GucBoolAssignHook assign_hook
Definition: guc_tables.h:187
bool boot_val
Definition: guc_tables.h:185
struct config_generic gen
Definition: guc_tables.h:182
static struct config_generic * init_custom_variable(const char *name, const char *short_desc, const char *long_desc, GucContext context, int flags, enum config_type type, size_t sz)
Definition: guc.c:8587
GucBoolCheckHook check_hook
Definition: guc_tables.h:186
GucShowHook show_hook
Definition: guc_tables.h:188
const char * name
Definition: encode.c:561
bool reset_val
Definition: guc_tables.h:190
static void define_custom_variable(struct config_generic *variable)
Definition: guc.c:8647

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

8950 {
8951  struct config_enum *var;
8952 
8953  var = (struct config_enum *)
8954  init_custom_variable(name, short_desc, long_desc, context, flags,
8955  PGC_ENUM, sizeof(struct config_enum));
8956  var->variable = valueAddr;
8957  var->boot_val = bootValue;
8958  var->reset_val = bootValue;
8959  var->options = options;
8960  var->check_hook = check_hook;
8961  var->assign_hook = assign_hook;
8962  var->show_hook = show_hook;
8963  define_custom_variable(&var->gen);
8964 }
GucEnumCheckHook check_hook
Definition: guc_tables.h:247
GucEnumAssignHook assign_hook
Definition: guc_tables.h:248
int * variable
Definition: guc_tables.h:244
const struct config_enum_entry * options
Definition: guc_tables.h:246
static char ** options
static struct config_generic * init_custom_variable(const char *name, const char *short_desc, const char *long_desc, GucContext context, int flags, enum config_type type, size_t sz)
Definition: guc.c:8587
GucShowHook show_hook
Definition: guc_tables.h:249
struct config_generic gen
Definition: guc_tables.h:242
const char * name
Definition: encode.c:561
static void define_custom_variable(struct config_generic *variable)
Definition: guc.c:8647

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

8866 {
8867  struct config_int *var;
8868 
8869  var = (struct config_int *)
8870  init_custom_variable(name, short_desc, long_desc, context, flags,
8871  PGC_INT, sizeof(struct config_int));
8872  var->variable = valueAddr;
8873  var->boot_val = bootValue;
8874  var->reset_val = bootValue;
8875  var->min = minValue;
8876  var->max = maxValue;
8877  var->check_hook = check_hook;
8878  var->assign_hook = assign_hook;
8879  var->show_hook = show_hook;
8880  define_custom_variable(&var->gen);
8881 }
int boot_val
Definition: guc_tables.h:199
GucIntAssignHook assign_hook
Definition: guc_tables.h:203
GucIntCheckHook check_hook
Definition: guc_tables.h:202
GucShowHook show_hook
Definition: guc_tables.h:204
int * variable
Definition: guc_tables.h:198
struct config_generic gen
Definition: guc_tables.h:196
static struct config_generic * init_custom_variable(const char *name, const char *short_desc, const char *long_desc, GucContext context, int flags, enum config_type type, size_t sz)
Definition: guc.c:8587
const char * name
Definition: encode.c:561
static void define_custom_variable(struct config_generic *variable)
Definition: guc.c:8647
int reset_val
Definition: guc_tables.h:206

◆ DefineCustomRealVariable()

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

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

8896 {
8897  struct config_real *var;
8898 
8899  var = (struct config_real *)
8900  init_custom_variable(name, short_desc, long_desc, context, flags,
8901  PGC_REAL, sizeof(struct config_real));
8902  var->variable = valueAddr;
8903  var->boot_val = bootValue;
8904  var->reset_val = bootValue;
8905  var->min = minValue;
8906  var->max = maxValue;
8907  var->check_hook = check_hook;
8908  var->assign_hook = assign_hook;
8909  var->show_hook = show_hook;
8910  define_custom_variable(&var->gen);
8911 }
GucRealAssignHook assign_hook
Definition: guc_tables.h:219
double reset_val
Definition: guc_tables.h:222
GucRealCheckHook check_hook
Definition: guc_tables.h:218
GucShowHook show_hook
Definition: guc_tables.h:220
double * variable
Definition: guc_tables.h:214
static struct config_generic * init_custom_variable(const char *name, const char *short_desc, const char *long_desc, GucContext context, int flags, enum config_type type, size_t sz)
Definition: guc.c:8587
double max
Definition: guc_tables.h:217
double boot_val
Definition: guc_tables.h:215
const char * name
Definition: encode.c:561
double min
Definition: guc_tables.h:216
static void define_custom_variable(struct config_generic *variable)
Definition: guc.c:8647
struct config_generic gen
Definition: guc_tables.h:212

◆ DefineCustomStringVariable()

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

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

8924 {
8925  struct config_string *var;
8926 
8927  var = (struct config_string *)
8928  init_custom_variable(name, short_desc, long_desc, context, flags,
8929  PGC_STRING, sizeof(struct config_string));
8930  var->variable = valueAddr;
8931  var->boot_val = bootValue;
8932  var->check_hook = check_hook;
8933  var->assign_hook = assign_hook;
8934  var->show_hook = show_hook;
8935  define_custom_variable(&var->gen);
8936 }
char ** variable
Definition: guc_tables.h:230
GucStringCheckHook check_hook
Definition: guc_tables.h:232
const char * boot_val
Definition: guc_tables.h:231
GucShowHook show_hook
Definition: guc_tables.h:234
static struct config_generic * init_custom_variable(const char *name, const char *short_desc, const char *long_desc, GucContext context, int flags, enum config_type type, size_t sz)
Definition: guc.c:8587
struct config_generic gen
Definition: guc_tables.h:228
GucStringAssignHook assign_hook
Definition: guc_tables.h:233
const char * name
Definition: encode.c:561
static void define_custom_variable(struct config_generic *variable)
Definition: guc.c:8647

◆ discard_stack_value()

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

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

5041 {
5042  switch (gconf->vartype)
5043  {
5044  case PGC_BOOL:
5045  case PGC_INT:
5046  case PGC_REAL:
5047  case PGC_ENUM:
5048  /* no need to do anything */
5049  break;
5050  case PGC_STRING:
5051  set_string_field((struct config_string *) gconf,
5052  &(val->val.stringval),
5053  NULL);
5054  break;
5055  }
5056  set_extra_field(gconf, &(val->extra), NULL);
5057 }
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:4986
static void set_string_field(struct config_string *conf, char **field, char *newval)
Definition: guc.c:4925
enum config_type vartype
Definition: guc_tables.h:156
char * stringval
Definition: guc_tables.h:36

◆ do_serialize()

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

Definition at line 10284 of file guc.c.

References elog, ERROR, and vsnprintf.

Referenced by serialize_variable().

10285 {
10286  va_list vargs;
10287  int n;
10288 
10289  if (*maxbytes <= 0)
10290  elog(ERROR, "not enough space to serialize GUC state");
10291 
10292  va_start(vargs, fmt);
10293  n = vsnprintf(*destptr, *maxbytes, fmt, vargs);
10294  va_end(vargs);
10295 
10296  if (n < 0)
10297  {
10298  /* Shouldn't happen. Better show errno description. */
10299  elog(ERROR, "vsnprintf failed: %m with format string \"%s\"", fmt);
10300  }
10301  if (n >= *maxbytes)
10302  {
10303  /* This shouldn't happen either, really. */
10304  elog(ERROR, "not enough space to serialize GUC state");
10305  }
10306 
10307  /* Shift the destptr ahead of the null terminator */
10308  *destptr += n + 1;
10309  *maxbytes -= n + 1;
10310 }
#define ERROR
Definition: elog.h:43
#define vsnprintf
Definition: port.h:214
#define elog(elevel,...)
Definition: elog.h:214

◆ do_serialize_binary()

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

Definition at line 10314 of file guc.c.

References elog, and ERROR.

Referenced by serialize_variable().

10315 {
10316  if (valsize > *maxbytes)
10317  elog(ERROR, "not enough space to serialize GUC state");
10318 
10319  memcpy(*destptr, val, valsize);
10320  *destptr += valsize;
10321  *maxbytes -= valsize;
10322 }
#define ERROR
Definition: elog.h:43
#define elog(elevel,...)
Definition: elog.h:214
long val
Definition: informix.c:664

◆ EmitWarningsOnPlaceholders()

void EmitWarningsOnPlaceholders ( const char *  className)

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

8968 {
8969  int classLen = strlen(className);
8970  int i;
8971 
8972  for (i = 0; i < num_guc_variables; i++)
8973  {
8974  struct config_generic *var = guc_variables[i];
8975 
8976  if ((var->flags & GUC_CUSTOM_PLACEHOLDER) != 0 &&
8977  strncmp(className, var->name, classLen) == 0 &&
8978  var->name[classLen] == GUC_QUALIFIER_SEPARATOR)
8979  {
8980  ereport(WARNING,
8981  (errcode(ERRCODE_UNDEFINED_OBJECT),
8982  errmsg("unrecognized configuration parameter \"%s\"",
8983  var->name)));
8984  }
8985  }
8986 }
const char * name
Definition: guc_tables.h:149
int errcode(int sqlerrcode)
Definition: elog.c:610
#define GUC_QUALIFIER_SEPARATOR
Definition: guc.h:200
static int num_guc_variables
Definition: guc.c:4815
static struct config_generic ** guc_variables
Definition: guc.c:4812
#define WARNING
Definition: elog.h:40
#define ereport(elevel,...)
Definition: elog.h:144
#define GUC_CUSTOM_PLACEHOLDER
Definition: guc.h:212
int errmsg(const char *fmt,...)
Definition: elog.c:821
int i

◆ estimate_variable_size()

static Size estimate_variable_size ( struct config_generic gconf)
static

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

10164 {
10165  Size size;
10166  Size valsize = 0;
10167 
10168  if (can_skip_gucvar(gconf))
10169  return 0;
10170 
10171  /* Name, plus trailing zero byte. */
10172  size = strlen(gconf->name) + 1;
10173 
10174  /* Get the maximum display length of the GUC value. */
10175  switch (gconf->vartype)
10176  {
10177  case PGC_BOOL:
10178  {
10179  valsize = 5; /* max(strlen('true'), strlen('false')) */
10180  }
10181  break;
10182 
10183  case PGC_INT:
10184  {
10185  struct config_int *conf = (struct config_int *) gconf;
10186 
10187  /*
10188  * Instead of getting the exact display length, use max
10189  * length. Also reduce the max length for typical ranges of
10190  * small values. Maximum value is 2147483647, i.e. 10 chars.
10191  * Include one byte for sign.
10192  */
10193  if (Abs(*conf->variable) < 1000)
10194  valsize = 3 + 1;
10195  else
10196  valsize = 10 + 1;
10197  }
10198  break;
10199 
10200  case PGC_REAL:
10201  {
10202  /*
10203  * We are going to print it with %e with REALTYPE_PRECISION
10204  * fractional digits. Account for sign, leading digit,
10205  * decimal point, and exponent with up to 3 digits. E.g.
10206  * -3.99329042340000021e+110
10207  */
10208  valsize = 1 + 1 + 1 + REALTYPE_PRECISION + 5;
10209  }
10210  break;
10211 
10212  case PGC_STRING:
10213  {
10214  struct config_string *conf = (struct config_string *) gconf;
10215 
10216  /*
10217  * If the value is NULL, we transmit it as an empty string.
10218  * Although this is not physically the same value, GUC
10219  * generally treats a NULL the same as empty string.
10220  */
10221  if (*conf->variable)
10222  valsize = strlen(*conf->variable);
10223  else
10224  valsize = 0;
10225  }
10226  break;
10227 
10228  case PGC_ENUM:
10229  {
10230  struct config_enum *conf = (struct config_enum *) gconf;
10231 
10232  valsize = strlen(config_enum_lookup_by_value(conf, *conf->variable));
10233  }
10234  break;
10235  }
10236 
10237  /* Allow space for terminating zero-byte for value */
10238  size = add_size(size, valsize + 1);
10239 
10240  if (gconf->sourcefile)
10241  size = add_size(size, strlen(gconf->sourcefile));
10242 
10243  /* Allow space for terminating zero-byte for sourcefile */
10244  size = add_size(size, 1);
10245 
10246  /* Include line whenever file is nonempty. */
10247  if (gconf->sourcefile && gconf->sourcefile[0])
10248  size = add_size(size, sizeof(gconf->sourceline));
10249 
10250  size = add_size(size, sizeof(gconf->source));
10251  size = add_size(size, sizeof(gconf->scontext));
10252 
10253  return size;
10254 }
GucSource source
Definition: guc_tables.h:158
char ** variable
Definition: guc_tables.h:230
const char * name
Definition: guc_tables.h:149
const char * config_enum_lookup_by_value(struct config_enum *record, int val)
Definition: guc.c:6645
GucContext scontext
Definition: guc_tables.h:160
#define Abs(x)
Definition: c.h:934
int * variable
Definition: guc_tables.h:198
int * variable
Definition: guc_tables.h:244
char * sourcefile
Definition: guc_tables.h:164
static bool can_skip_gucvar(struct config_generic *gconf)
Definition: guc.c:10149
#define REALTYPE_PRECISION
Definition: guc.c:122
enum config_type vartype
Definition: guc_tables.h:156
Size add_size(Size s1, Size s2)
Definition: shmem.c:498
size_t Size
Definition: c.h:474

◆ EstimateGUCStateSpace()

Size EstimateGUCStateSpace ( void  )

Definition at line 10261 of file guc.c.

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

Referenced by InitializeParallelDSM().

10262 {
10263  Size size;
10264  int i;
10265 
10266  /* Add space reqd for saving the data size of the guc state */
10267  size = sizeof(Size);
10268 
10269  /* Add up the space needed for each GUC variable */
10270  for (i = 0; i < num_guc_variables; i++)
10271  size = add_size(size,
10273 
10274  return size;
10275 }
static int num_guc_variables
Definition: guc.c:4815
static struct config_generic ** guc_variables
Definition: guc.c:4812
Size add_size(Size s1, Size s2)
Definition: shmem.c:498
size_t Size
Definition: c.h:474
static Size estimate_variable_size(struct config_generic *gconf)
Definition: guc.c:10163
int i

◆ ExecSetVariableStmt()

void ExecSetVariableStmt ( VariableSetStmt stmt,
bool  isTopLevel 
)

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

8376 {
8378 
8379  /*
8380  * Workers synchronize these parameters at the start of the parallel
8381  * operation; then, we block SET during the operation.
8382  */
8383  if (IsInParallelMode())
8384  ereport(ERROR,
8385  (errcode(ERRCODE_INVALID_TRANSACTION_STATE),
8386  errmsg("cannot set parameters during a parallel operation")));
8387 
8388  switch (stmt->kind)
8389  {
8390  case VAR_SET_VALUE:
8391  case VAR_SET_CURRENT:
8392  if (stmt->is_local)
8393  WarnNoTransactionBlock(isTopLevel, "SET LOCAL");
8394  (void) set_config_option(stmt->name,
8395  ExtractSetVariableArgs(stmt),
8397  PGC_S_SESSION,
8398  action, true, 0, false);
8399  break;
8400  case VAR_SET_MULTI:
8401 
8402  /*
8403  * Special-case SQL syntaxes. The TRANSACTION and SESSION
8404  * CHARACTERISTICS cases effectively set more than one variable
8405  * per statement. TRANSACTION SNAPSHOT only takes one argument,
8406  * but we put it here anyway since it's a special case and not
8407  * related to any GUC variable.
8408  */
8409  if (strcmp(stmt->name, "TRANSACTION") == 0)
8410  {
8411  ListCell *head;
8412 
8413  WarnNoTransactionBlock(isTopLevel, "SET TRANSACTION");
8414 
8415  foreach(head, stmt->args)
8416  {
8417  DefElem *item = (DefElem *) lfirst(head);
8418 
8419  if (strcmp(item->defname, "transaction_isolation") == 0)
8420  SetPGVariable("transaction_isolation",
8421  list_make1(item->arg), stmt->is_local);
8422  else if (strcmp(item->defname, "transaction_read_only") == 0)
8423  SetPGVariable("transaction_read_only",
8424  list_make1(item->arg), stmt->is_local);
8425  else if (strcmp(item->defname, "transaction_deferrable") == 0)
8426  SetPGVariable("transaction_deferrable",
8427  list_make1(item->arg), stmt->is_local);
8428  else
8429  elog(ERROR, "unexpected SET TRANSACTION element: %s",
8430  item->defname);
8431  }
8432  }
8433  else if (strcmp(stmt->name, "SESSION CHARACTERISTICS") == 0)
8434  {
8435  ListCell *head;
8436 
8437  foreach(head, stmt->args)
8438  {
8439  DefElem *item = (DefElem *) lfirst(head);
8440 
8441  if (strcmp(item->defname, "transaction_isolation") == 0)
8442  SetPGVariable("default_transaction_isolation",
8443  list_make1(item->arg), stmt->is_local);
8444  else if (strcmp(item->defname, "transaction_read_only") == 0)
8445  SetPGVariable("default_transaction_read_only",
8446  list_make1(item->arg), stmt->is_local);
8447  else if (strcmp(item->defname, "transaction_deferrable") == 0)
8448  SetPGVariable("default_transaction_deferrable",
8449  list_make1(item->arg), stmt->is_local);
8450  else
8451  elog(ERROR, "unexpected SET SESSION element: %s",
8452  item->defname);
8453  }
8454  }
8455  else if (strcmp(stmt->name, "TRANSACTION SNAPSHOT") == 0)
8456  {
8457  A_Const *con = linitial_node(A_Const, stmt->args);
8458 
8459  if (stmt->is_local)
8460  ereport(ERROR,
8461  (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
8462  errmsg("SET LOCAL TRANSACTION SNAPSHOT is not implemented")));
8463 
8464  WarnNoTransactionBlock(isTopLevel, "SET TRANSACTION");
8465  Assert(nodeTag(&con->val) == T_String);
8466  ImportSnapshot(strVal(&con->val));
8467  }
8468  else
8469  elog(ERROR, "unexpected SET MULTI element: %s",
8470  stmt->name);
8471  break;
8472  case VAR_SET_DEFAULT:
8473  if (stmt->is_local)
8474  WarnNoTransactionBlock(isTopLevel, "SET LOCAL");
8475  /* fall through */
8476  case VAR_RESET:
8477  if (strcmp(stmt->name, "transaction_isolation") == 0)
8478  WarnNoTransactionBlock(isTopLevel, "RESET TRANSACTION");
8479 
8480  (void) set_config_option(stmt->name,
8481  NULL,
8483  PGC_S_SESSION,
8484  action, true, 0, false);
8485  break;
8486  case VAR_RESET_ALL:
8487  ResetAllOptions();
8488  break;
8489  }
8490 }
void ImportSnapshot(const char *idstr)
Definition: snapmgr.c:1377
VariableSetKind kind
Definition: parsenodes.h:2044
void WarnNoTransactionBlock(bool isTopLevel, const char *stmtType)
Definition: xact.c:3440
#define strVal(v)
Definition: value.h:54
int errcode(int sqlerrcode)
Definition: elog.c:610
bool superuser(void)
Definition: superuser.c:46
#define linitial_node(type, l)
Definition: pg_list.h:177
GucAction
Definition: guc.h:192
#define list_make1(x1)
Definition: pg_list.h:206
bool IsInParallelMode(void)
Definition: xact.c:1012
#define ERROR
Definition: elog.h:43
Definition: guc.h:75
void ResetAllOptions(void)
Definition: guc.c:5741
Node * arg
Definition: parsenodes.h:734
#define ereport(elevel,...)
Definition: elog.h:144
#define Assert(condition)
Definition: c.h:746
#define lfirst(lc)
Definition: pg_list.h:169
#define nodeTag(nodeptr)
Definition: nodes.h:533
int errmsg(const char *fmt,...)
Definition: elog.c:821
#define elog(elevel,...)
Definition: elog.h:214
char * defname
Definition: parsenodes.h:733
char * ExtractSetVariableArgs(VariableSetStmt *stmt)
Definition: guc.c:8499
Value val
Definition: parsenodes.h:289
int set_config_option(const char *name, const char *value, GucContext context, GucSource source, GucAction action, bool changeVal, int elevel, bool is_reload)
Definition: guc.c:6949
void SetPGVariable(const char *name, List *args, bool is_local)
Definition: guc.c:8519

◆ extra_field_used()

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

Definition at line 4941 of file guc.c.

References