PostgreSQL Source Code  git master
guc.c File Reference
#include "postgres.h"
#include <ctype.h>
#include <float.h>
#include <math.h>
#include <limits.h>
#include <unistd.h>
#include <sys/stat.h>
#include "access/commit_ts.h"
#include "access/gin.h"
#include "access/rmgr.h"
#include "access/tableam.h"
#include "access/transam.h"
#include "access/twophase.h"
#include "access/xact.h"
#include "access/xlog_internal.h"
#include "catalog/namespace.h"
#include "catalog/pg_authid.h"
#include "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/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 void assign_effective_io_concurrency (int newval, void *extra)
 
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)
 
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 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 log_parameters_on_error = 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_temp_files = -1
 
double log_statement_sample_rate = 1.0
 
double log_xact_sample_rate = 0
 
int trace_recovery_messages = LOG
 
char * backtrace_functions
 
char * backtrace_symbol_list
 
int temp_file_limit = -1
 
int num_temp_buffers = 1024
 
char * cluster_name = ""
 
char * ConfigFileName
 
char * HbaFileName
 
char * IdentFileName
 
char * external_pid_file
 
char * pgstat_temp_directory
 
char * application_name
 
int tcp_keepalives_idle
 
int tcp_keepalives_interval
 
int tcp_keepalives_count
 
int tcp_user_timeout
 
int ssl_renegotiation_limit
 
int huge_pages
 
static char * syslog_ident_str
 
static double phony_random_seed
 
static char * client_encoding_string
 
static char * datestyle_string
 
static char * locale_collate
 
static char * locale_ctype
 
static char * server_encoding_string
 
static char * server_version_string
 
static int server_version_num
 
static char * timezone_string
 
static char * log_timezone_string
 
static char * timezone_abbreviations_string
 
static char * data_directory
 
static char * session_authorization_string
 
static int max_function_args
 
static int max_index_keys
 
static int max_identifier_length
 
static int block_size
 
static int segment_size
 
static int wal_block_size
 
static bool data_checksums
 
static bool integer_datetimes
 
static bool assert_enabled
 
static char * recovery_target_timeline_string
 
static char * recovery_target_string
 
static char * recovery_target_xid_string
 
static char * recovery_target_name_string
 
static char * recovery_target_lsn_string
 
char * role_string
 
const char *const GucContext_Names []
 
const char *const GucSource_Names []
 
const char *const config_group_names []
 
const char *const config_type_names []
 
static const char * memory_units_hint = gettext_noop("Valid units for this parameter are \"B\", \"kB\", \"MB\", \"GB\", and \"TB\".")
 
static const unit_conversion memory_unit_conversion_table []
 
static const char * time_units_hint = gettext_noop("Valid units for this parameter are \"us\", \"ms\", \"s\", \"min\", \"h\", and \"d\".")
 
static const unit_conversion time_unit_conversion_table []
 
static struct config_bool ConfigureNamesBool []
 
static struct config_int ConfigureNamesInt []
 
static struct config_real ConfigureNamesReal []
 
static struct config_string ConfigureNamesString []
 
static struct config_enum ConfigureNamesEnum []
 
static const char *const map_old_guc_names []
 
static struct config_generic ** guc_variables
 
static int num_guc_variables
 
static int num_guc_explain_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 104 of file guc.c.

Referenced by SelectConfigFiles().

◆ HBA_FILENAME

#define HBA_FILENAME   "pg_hba.conf"

Definition at line 105 of file guc.c.

Referenced by SelectConfigFiles().

◆ IDENT_FILENAME

#define IDENT_FILENAME   "pg_ident.conf"

Definition at line 106 of file guc.c.

Referenced by SelectConfigFiles().

◆ MAX_UNIT_LEN

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

Definition at line 776 of file guc.c.

Referenced by convert_to_base_unit().

◆ newval [1/5]

#define newval   (newval_union.boolval)

◆ newval [2/5]

#define newval   (newval_union.intval)

◆ newval [3/5]

#define newval   (newval_union.realval)

◆ newval [4/5]

#define newval   (newval_union.stringval)

◆ newval [5/5]

#define newval   (newval_union.enumval)

◆ NUM_PG_FILE_SETTINGS_ATTS

#define NUM_PG_FILE_SETTINGS_ATTS   7

Referenced by show_all_file_settings().

◆ NUM_PG_SETTINGS_ATTS

#define NUM_PG_SETTINGS_ATTS   17

Definition at line 9354 of file guc.c.

Referenced by show_all_settings().

◆ PG_KRB_SRVTAB

#define PG_KRB_SRVTAB   ""

Definition at line 101 of file guc.c.

◆ REALTYPE_PRECISION

#define REALTYPE_PRECISION   17

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

9602 {
9603  char buffer[256];
9604  const char *val;
9605 
9606  switch (record->vartype)
9607  {
9608  case PGC_BOOL:
9609  {
9610  struct config_bool *conf = (struct config_bool *) record;
9611 
9612  if (conf->show_hook)
9613  val = conf->show_hook();
9614  else
9615  val = *conf->variable ? "on" : "off";
9616  }
9617  break;
9618 
9619  case PGC_INT:
9620  {
9621  struct config_int *conf = (struct config_int *) record;
9622 
9623  if (conf->show_hook)
9624  val = conf->show_hook();
9625  else
9626  {
9627  /*
9628  * Use int64 arithmetic to avoid overflows in units
9629  * conversion.
9630  */
9631  int64 result = *conf->variable;
9632  const char *unit;
9633 
9634  if (use_units && result > 0 && (record->flags & GUC_UNIT))
9636  record->flags & GUC_UNIT,
9637  &result, &unit);
9638  else
9639  unit = "";
9640 
9641  snprintf(buffer, sizeof(buffer), INT64_FORMAT "%s",
9642  result, unit);
9643  val = buffer;
9644  }
9645  }
9646  break;
9647 
9648  case PGC_REAL:
9649  {
9650  struct config_real *conf = (struct config_real *) record;
9651 
9652  if (conf->show_hook)
9653  val = conf->show_hook();
9654  else
9655  {
9656  double result = *conf->variable;
9657  const char *unit;
9658 
9659  if (use_units && result > 0 && (record->flags & GUC_UNIT))
9661  record->flags & GUC_UNIT,
9662  &result, &unit);
9663  else
9664  unit = "";
9665 
9666  snprintf(buffer, sizeof(buffer), "%g%s",
9667  result, unit);
9668  val = buffer;
9669  }
9670  }
9671  break;
9672 
9673  case PGC_STRING:
9674  {
9675  struct config_string *conf = (struct config_string *) record;
9676 
9677  if (conf->show_hook)
9678  val = conf->show_hook();
9679  else if (*conf->variable && **conf->variable)
9680  val = *conf->variable;
9681  else
9682  val = "";
9683  }
9684  break;
9685 
9686  case PGC_ENUM:
9687  {
9688  struct config_enum *conf = (struct config_enum *) record;
9689 
9690  if (conf->show_hook)
9691  val = conf->show_hook();
9692  else
9693  val = config_enum_lookup_by_value(conf, *conf->variable);
9694  }
9695  break;
9696 
9697  default:
9698  /* just to keep compiler quiet */
9699  val = "???";
9700  break;
9701  }
9702 
9703  return pstrdup(val);
9704 }
char ** variable
Definition: guc_tables.h:230
char * pstrdup(const char *in)
Definition: mcxt.c:1186
bool * variable
Definition: guc_tables.h:184
const char * config_enum_lookup_by_value(struct config_enum *record, int val)
Definition: guc.c:6481
#define GUC_UNIT
Definition: guc.h:232
GucShowHook show_hook
Definition: guc_tables.h:204
int * variable
Definition: guc_tables.h:198
int * variable
Definition: guc_tables.h:244
static void convert_real_from_base_unit(double base_value, int base_unit, double *value, const char **unit)
Definition: guc.c:6229
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:401
static void convert_int_from_base_unit(int64 base_value, int base_unit, int64 *value, const char **unit)
Definition: guc.c:6187
#define snprintf
Definition: port.h:192
long val
Definition: informix.c:664

◆ add_guc_variable()

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

Definition at line 4999 of file guc.c.

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

Referenced by add_placeholder_variable(), and define_custom_variable().

5000 {
5002  {
5003  /*
5004  * Increase the vector by 25%
5005  */
5006  int size_vars = size_guc_variables + size_guc_variables / 4;
5007  struct config_generic **guc_vars;
5008 
5009  if (size_vars == 0)
5010  {
5011  size_vars = 100;
5012  guc_vars = (struct config_generic **)
5013  guc_malloc(elevel, size_vars * sizeof(struct config_generic *));
5014  }
5015  else
5016  {
5017  guc_vars = (struct config_generic **)
5018  guc_realloc(elevel, guc_variables, size_vars * sizeof(struct config_generic *));
5019  }
5020 
5021  if (guc_vars == NULL)
5022  return false; /* out of memory */
5023 
5024  guc_variables = guc_vars;
5025  size_guc_variables = size_vars;
5026  }
5029  sizeof(struct config_generic *), guc_var_compare);
5030  return true;
5031 }
static int guc_var_compare(const void *a, const void *b)
Definition: guc.c:5134
static int num_guc_variables
Definition: guc.c:4631
static void * guc_realloc(int elevel, void *old, size_t size)
Definition: guc.c:4688
static struct config_generic ** guc_variables
Definition: guc.c:4628
static int size_guc_variables
Definition: guc.c:4637
static int elevel
Definition: vacuumlazy.c:143
#define qsort(a, b, c, d)
Definition: port.h:488
static void * guc_malloc(int elevel, size_t size)
Definition: guc.c:4672

◆ add_placeholder_variable()

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

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

5038 {
5039  size_t sz = sizeof(struct config_string) + sizeof(char *);
5040  struct config_string *var;
5041  struct config_generic *gen;
5042 
5043  var = (struct config_string *) guc_malloc(elevel, sz);
5044  if (var == NULL)
5045  return NULL;
5046  memset(var, 0, sz);
5047  gen = &var->gen;
5048 
5049  gen->name = guc_strdup(elevel, name);
5050  if (gen->name == NULL)
5051  {
5052  free(var);
5053  return NULL;
5054  }
5055 
5056  gen->context = PGC_USERSET;
5057  gen->group = CUSTOM_OPTIONS;
5058  gen->short_desc = "GUC placeholder variable";
5060  gen->vartype = PGC_STRING;
5061 
5062  /*
5063  * The char* is allocated at the end of the struct since we have no
5064  * 'static' place to point to. Note that the current value, as well as
5065  * the boot and reset values, start out NULL.
5066  */
5067  var->variable = (char **) (var + 1);
5068 
5069  if (!add_guc_variable((struct config_generic *) var, elevel))
5070  {
5071  free(unconstify(char *, gen->name));
5072  free(var);
5073  return NULL;
5074  }
5075 
5076  return gen;
5077 }
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:4704
#define GUC_NO_SHOW_ALL
Definition: guc.h:206
#define GUC_NOT_IN_SAMPLE
Definition: guc.h:209
enum config_type vartype
Definition: guc_tables.h:156
#define unconstify(underlying_type, expr)
Definition: c.h:1194
static int elevel
Definition: vacuumlazy.c:143
struct config_generic gen
Definition: guc_tables.h:228
#define free(a)
Definition: header.h:65
#define GUC_CUSTOM_PLACEHOLDER
Definition: guc.h:211
const char * name
Definition: encode.c:521
enum config_group group
Definition: guc_tables.h:151
static void * guc_malloc(int elevel, size_t size)
Definition: guc.c:4672
GucContext context
Definition: guc_tables.h:150
static bool add_guc_variable(struct config_generic *var, int elevel)
Definition: guc.c:4999

◆ AlterSystemSetConfigFile()

void AlterSystemSetConfigFile ( AlterSystemStmt altersysstmt)

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

7970 {
7971  char *name;
7972  char *value;
7973  bool resetall = false;
7974  ConfigVariable *head = NULL;
7975  ConfigVariable *tail = NULL;
7976  volatile int Tmpfd;
7977  char AutoConfFileName[MAXPGPATH];
7978  char AutoConfTmpFileName[MAXPGPATH];
7979 
7980  if (!superuser())
7981  ereport(ERROR,
7982  (errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
7983  (errmsg("must be superuser to execute ALTER SYSTEM command"))));
7984 
7985  /*
7986  * Extract statement arguments
7987  */
7988  name = altersysstmt->setstmt->name;
7989 
7990  switch (altersysstmt->setstmt->kind)
7991  {
7992  case VAR_SET_VALUE:
7993  value = ExtractSetVariableArgs(altersysstmt->setstmt);
7994  break;
7995 
7996  case VAR_SET_DEFAULT:
7997  case VAR_RESET:
7998  value = NULL;
7999  break;
8000 
8001  case VAR_RESET_ALL:
8002  value = NULL;
8003  resetall = true;
8004  break;
8005 
8006  default:
8007  elog(ERROR, "unrecognized alter system stmt type: %d",
8008  altersysstmt->setstmt->kind);
8009  break;
8010  }
8011 
8012  /*
8013  * Unless it's RESET_ALL, validate the target variable and value
8014  */
8015  if (!resetall)
8016  {
8017  struct config_generic *record;
8018 
8019  record = find_option(name, false, ERROR);
8020  if (record == NULL)
8021  ereport(ERROR,
8022  (errcode(ERRCODE_UNDEFINED_OBJECT),
8023  errmsg("unrecognized configuration parameter \"%s\"",
8024  name)));
8025 
8026  /*
8027  * Don't allow parameters that can't be set in configuration files to
8028  * be set in PG_AUTOCONF_FILENAME file.
8029  */
8030  if ((record->context == PGC_INTERNAL) ||
8031  (record->flags & GUC_DISALLOW_IN_FILE) ||
8032  (record->flags & GUC_DISALLOW_IN_AUTO_FILE))
8033  ereport(ERROR,
8034  (errcode(ERRCODE_CANT_CHANGE_RUNTIME_PARAM),
8035  errmsg("parameter \"%s\" cannot be changed",
8036  name)));
8037 
8038  /*
8039  * If a value is specified, verify that it's sane.
8040  */
8041  if (value)
8042  {
8043  union config_var_val newval;
8044  void *newextra = NULL;
8045 
8046  /* Check that it's acceptable for the indicated parameter */
8047  if (!parse_and_validate_value(record, name, value,
8048  PGC_S_FILE, ERROR,
8049  &newval, &newextra))
8050  ereport(ERROR,
8051  (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
8052  errmsg("invalid value for parameter \"%s\": \"%s\"",
8053  name, value)));
8054 
8055  if (record->vartype == PGC_STRING && newval.stringval != NULL)
8056  free(newval.stringval);
8057  if (newextra)
8058  free(newextra);
8059 
8060  /*
8061  * We must also reject values containing newlines, because the
8062  * grammar for config files doesn't support embedded newlines in
8063  * string literals.
8064  */
8065  if (strchr(value, '\n'))
8066  ereport(ERROR,
8067  (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
8068  errmsg("parameter value for ALTER SYSTEM must not contain a newline")));
8069  }
8070  }
8071 
8072  /*
8073  * PG_AUTOCONF_FILENAME and its corresponding temporary file are always in
8074  * the data directory, so we can reference them by simple relative paths.
8075  */
8076  snprintf(AutoConfFileName, sizeof(AutoConfFileName), "%s",
8078  snprintf(AutoConfTmpFileName, sizeof(AutoConfTmpFileName), "%s.%s",
8079  AutoConfFileName,
8080  "tmp");
8081 
8082  /*
8083  * Only one backend is allowed to operate on PG_AUTOCONF_FILENAME at a
8084  * time. Use AutoFileLock to ensure that. We must hold the lock while
8085  * reading the old file contents.
8086  */
8087  LWLockAcquire(AutoFileLock, LW_EXCLUSIVE);
8088 
8089  /*
8090  * If we're going to reset everything, then no need to open or parse the
8091  * old file. We'll just write out an empty list.
8092  */
8093  if (!resetall)
8094  {
8095  struct stat st;
8096 
8097  if (stat(AutoConfFileName, &st) == 0)
8098  {
8099  /* open old file PG_AUTOCONF_FILENAME */
8100  FILE *infile;
8101 
8102  infile = AllocateFile(AutoConfFileName, "r");
8103  if (infile == NULL)
8104  ereport(ERROR,
8106  errmsg("could not open file \"%s\": %m",
8107  AutoConfFileName)));
8108 
8109  /* parse it */
8110  if (!ParseConfigFp(infile, AutoConfFileName, 0, LOG, &head, &tail))
8111  ereport(ERROR,
8112  (errcode(ERRCODE_CONFIG_FILE_ERROR),
8113  errmsg("could not parse contents of file \"%s\"",
8114  AutoConfFileName)));
8115 
8116  FreeFile(infile);
8117  }
8118 
8119  /*
8120  * Now, replace any existing entry with the new value, or add it if
8121  * not present.
8122  */
8123  replace_auto_config_value(&head, &tail, name, value);
8124  }
8125 
8126  /*
8127  * To ensure crash safety, first write the new file data to a temp file,
8128  * then atomically rename it into place.
8129  *
8130  * If there is a temp file left over due to a previous crash, it's okay to
8131  * truncate and reuse it.
8132  */
8133  Tmpfd = BasicOpenFile(AutoConfTmpFileName,
8134  O_CREAT | O_RDWR | O_TRUNC);
8135  if (Tmpfd < 0)
8136  ereport(ERROR,
8138  errmsg("could not open file \"%s\": %m",
8139  AutoConfTmpFileName)));
8140 
8141  /*
8142  * Use a TRY block to clean up the file if we fail. Since we need a TRY
8143  * block anyway, OK to use BasicOpenFile rather than OpenTransientFile.
8144  */
8145  PG_TRY();
8146  {
8147  /* Write and sync the new contents to the temporary file */
8148  write_auto_conf_file(Tmpfd, AutoConfTmpFileName, head);
8149 
8150  /* Close before renaming; may be required on some platforms */
8151  close(Tmpfd);
8152  Tmpfd = -1;
8153 
8154  /*
8155  * As the rename is atomic operation, if any problem occurs after this
8156  * at worst it can lose the parameters set by last ALTER SYSTEM
8157  * command.
8158  */
8159  durable_rename(AutoConfTmpFileName, AutoConfFileName, ERROR);
8160  }
8161  PG_CATCH();
8162  {
8163  /* Close file first, else unlink might fail on some platforms */
8164  if (Tmpfd >= 0)
8165  close(Tmpfd);
8166 
8167  /* Unlink, but ignore any error */
8168  (void) unlink(AutoConfTmpFileName);
8169 
8170  PG_RE_THROW();
8171  }
8172  PG_END_TRY();
8173 
8174  FreeConfigVariables(head);
8175 
8176  LWLockRelease(AutoFileLock);
8177 }
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:6588
VariableSetKind kind
Definition: parsenodes.h:2019
static struct @145 value
int errcode(int sqlerrcode)
Definition: elog.c:608
bool superuser(void)
Definition: superuser.c:46
#define LOG
Definition: elog.h:26
void LWLockRelease(LWLock *lock)
Definition: lwlock.c:1726
#define ERROR
Definition: elog.h:43
#define MAXPGPATH
VariableSetStmt * setstmt
Definition: parsenodes.h:3158
int errcode_for_file_access(void)
Definition: elog.c:631
FILE * AllocateFile(const char *name, const char *mode)
Definition: fd.c:2242
#define ereport(elevel, rest)
Definition: elog.h:141
int durable_rename(const char *oldfile, const char *newfile, int elevel)
Definition: fd.c:643
enum config_type vartype
Definition: guc_tables.h:156
#define stat(a, b)
Definition: win32_port.h:255
#define GUC_DISALLOW_IN_FILE
Definition: guc.h:210
static void write_auto_conf_file(int fd, const char *filename, ConfigVariable *head_p)
Definition: guc.c:7831
static void infile(const char *filename)
Definition: zic.c:1233
#define free(a)
Definition: header.h:65
static struct config_generic * find_option(const char *name, bool create_placeholders, int elevel)
Definition: guc.c:5085
#define PG_CATCH()
Definition: elog.h:332
#define newval
#define PG_AUTOCONF_FILENAME
Definition: guc.h:34
bool LWLockAcquire(LWLock *lock, LWLockMode mode)
Definition: lwlock.c:1122
#define PG_RE_THROW()
Definition: elog.h:363
const char * name
Definition: encode.c:521
#define GUC_DISALLOW_IN_AUTO_FILE
Definition: guc.h:215
int BasicOpenFile(const char *fileName, int fileFlags)
Definition: fd.c:981
int FreeFile(FILE *file)
Definition: fd.c:2441
int errmsg(const char *fmt,...)
Definition: elog.c:822
bool ParseConfigFp(FILE *fp, const char *config_file, int depth, int elevel, ConfigVariable **head_p, ConfigVariable **tail_p)
#define elog(elevel,...)
Definition: elog.h:228
static void replace_auto_config_value(ConfigVariable **head_p, ConfigVariable **tail_p, const char *name, const char *value)
Definition: guc.c:7899
void FreeConfigVariables(ConfigVariable *list)
#define close(a)
Definition: win32.h:12
#define PG_TRY()
Definition: elog.h:322
char * ExtractSetVariableArgs(VariableSetStmt *stmt)
Definition: guc.c:8307
#define snprintf
Definition: port.h:192
#define PG_END_TRY()
Definition: elog.h:347
GucContext context
Definition: guc_tables.h:150

◆ assign_application_name()

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

Definition at line 11486 of file guc.c.

References pgstat_report_appname().

11487 {
11488  /* Update the pg_stat_activity view */
11490 }
void pgstat_report_appname(const char *appname)
Definition: pgstat.c:3292
#define newval

◆ assign_backtrace_functions()

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

Definition at line 11593 of file guc.c.

11594 {
11595  backtrace_symbol_list = (char *) extra;
11596 }
char * backtrace_symbol_list
Definition: guc.c:523

◆ assign_effective_io_concurrency()

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

Definition at line 11440 of file guc.c.

References target_prefetch_pages.

11441 {
11442 #ifdef USE_PREFETCH
11443  target_prefetch_pages = *((int *) extra);
11444 #endif /* USE_PREFETCH */
11445 }
int target_prefetch_pages
Definition: bufmgr.c:130

◆ assign_log_destination()

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

Definition at line 11095 of file guc.c.

References Log_destination.

11096 {
11097  Log_destination = *((int *) extra);
11098 }
int Log_destination
Definition: elog.c:109

◆ assign_pgstat_temp_directory()

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

Definition at line 11448 of file guc.c.

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

11449 {
11450  /* check_canonical_path already canonicalized newval for us */
11451  char *dname;
11452  char *tname;
11453  char *fname;
11454 
11455  /* directory */
11456  dname = guc_malloc(ERROR, strlen(newval) + 1); /* runtime dir */
11457  sprintf(dname, "%s", newval);
11458 
11459  /* global stats */
11460  tname = guc_malloc(ERROR, strlen(newval) + 12); /* /global.tmp */
11461  sprintf(tname, "%s/global.tmp", newval);
11462  fname = guc_malloc(ERROR, strlen(newval) + 13); /* /global.stat */
11463  sprintf(fname, "%s/global.stat", newval);
11464 
11467  pgstat_stat_directory = dname;
11468  if (pgstat_stat_tmpname)
11470  pgstat_stat_tmpname = tname;
11473  pgstat_stat_filename = fname;
11474 }
#define sprintf
Definition: port.h:194
char * pgstat_stat_filename
Definition: pgstat.c:133
#define ERROR
Definition: elog.h:43
char * pgstat_stat_directory
Definition: pgstat.c:132
#define free(a)
Definition: header.h:65
#define newval
char * pgstat_stat_tmpname
Definition: pgstat.c:134
static void * guc_malloc(int elevel, size_t size)
Definition: guc.c:4672

◆ assign_recovery_target()

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

Definition at line 11672 of file guc.c.

References RECOVERY_TARGET_IMMEDIATE, RECOVERY_TARGET_UNSET, and recoveryTarget.

11673 {
11676  error_multiple_recovery_targets();
11677 
11678  if (newval && strcmp(newval, "") != 0)
11680  else
11682 }
#define newval
RecoveryTargetType recoveryTarget
Definition: xlog.c:271

◆ assign_recovery_target_lsn()

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

Definition at line 11840 of file guc.c.

References RECOVERY_TARGET_LSN, RECOVERY_TARGET_UNSET, recoveryTarget, and recoveryTargetLSN.

11841 {
11844  error_multiple_recovery_targets();
11845 
11846  if (newval && strcmp(newval, "") != 0)
11847  {
11849  recoveryTargetLSN = *((XLogRecPtr *) extra);
11850  }
11851  else
11853 }
XLogRecPtr recoveryTargetLSN
Definition: xlog.c:278
uint64 XLogRecPtr
Definition: xlogdefs.h:21
#define newval
RecoveryTargetType recoveryTarget
Definition: xlog.c:271

◆ assign_recovery_target_name()

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

Definition at line 11804 of file guc.c.

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

11805 {
11808  error_multiple_recovery_targets();
11809 
11810  if (newval && strcmp(newval, "") != 0)
11811  {
11814  }
11815  else
11817 }
const char * recoveryTargetName
Definition: xlog.c:277
#define newval
RecoveryTargetType recoveryTarget
Definition: xlog.c:271

◆ assign_recovery_target_time()

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

Definition at line 11778 of file guc.c.

References RECOVERY_TARGET_TIME, RECOVERY_TARGET_UNSET, and recoveryTarget.

11779 {
11782  error_multiple_recovery_targets();
11783 
11784  if (newval && strcmp(newval, "") != 0)
11786  else
11788 }
#define newval
RecoveryTargetType recoveryTarget
Definition: xlog.c:271

◆ assign_recovery_target_timeline()

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

Definition at line 11629 of file guc.c.

References RECOVERY_TARGET_TIMELINE_NUMERIC, recoveryTargetTimeLineGoal, and recoveryTargetTLIRequested.

11630 {
11633  recoveryTargetTLIRequested = (TimeLineID) strtoul(newval, NULL, 0);
11634  else
11636 }
TimeLineID recoveryTargetTLIRequested
Definition: xlog.c:331
uint32 TimeLineID
Definition: xlogdefs.h:52
RecoveryTargetTimeLineGoal
Definition: xlog.h:93
RecoveryTargetTimeLineGoal recoveryTargetTimeLineGoal
Definition: xlog.c:330
#define newval

◆ assign_recovery_target_xid()

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

Definition at line 11705 of file guc.c.

References RECOVERY_TARGET_UNSET, RECOVERY_TARGET_XID, recoveryTarget, and recoveryTargetXid.

11706 {
11709  error_multiple_recovery_targets();
11710 
11711  if (newval && strcmp(newval, "") != 0)
11712  {
11714  recoveryTargetXid = *((TransactionId *) extra);
11715  }
11716  else
11718 }
uint32 TransactionId
Definition: c.h:514
TransactionId recoveryTargetXid
Definition: xlog.c:274
#define newval
RecoveryTargetType recoveryTarget
Definition: xlog.c:271

◆ assign_session_replication_role()

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

Definition at line 11121 of file guc.c.

References ResetPlanCache(), and SessionReplicationRole.

11122 {
11123  /*
11124  * Must flush the plan cache when changing replication role; but don't
11125  * flush unnecessarily.
11126  */
11128  ResetPlanCache();
11129 }
int SessionReplicationRole
Definition: trigger.c:67
void ResetPlanCache(void)
Definition: plancache.c:1966
#define newval

◆ assign_syslog_facility()

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

Definition at line 11101 of file guc.c.

11102 {
11103 #ifdef HAVE_SYSLOG
11104  set_syslog_parameters(syslog_ident_str ? syslog_ident_str : "postgres",
11105  newval);
11106 #endif
11107  /* Without syslog support, just ignore it */
11108 }
static char * syslog_ident_str
Definition: guc.c:563
#define newval

◆ assign_syslog_ident()

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

Definition at line 11111 of file guc.c.

11112 {
11113 #ifdef HAVE_SYSLOG
11114  set_syslog_parameters(newval, syslog_facility);
11115 #endif
11116  /* Without syslog support, it will always be set to "none", so ignore */
11117 }
static int syslog_facility
Definition: guc.c:167
#define newval

◆ assign_tcp_keepalives_count()

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

Definition at line 11320 of file guc.c.

References MyProcPort, and pq_setkeepalivescount().

11321 {
11322  /* See comments in assign_tcp_keepalives_idle */
11324 }
struct Port * MyProcPort
Definition: globals.c:43
int pq_setkeepalivescount(int count, Port *port)
Definition: pqcomm.c:1889
#define newval

◆ assign_tcp_keepalives_idle()

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

Definition at line 11276 of file guc.c.

References MyProcPort, and pq_setkeepalivesidle().

11277 {
11278  /*
11279  * The kernel API provides no way to test a value without setting it; and
11280  * once we set it we might fail to unset it. So there seems little point
11281  * in fully implementing the check-then-assign GUC API for these
11282  * variables. Instead we just do the assignment on demand. pqcomm.c
11283  * reports any problems via elog(LOG).
11284  *
11285  * This approach means that the GUC value might have little to do with the
11286  * actual kernel value, so we use a show_hook that retrieves the kernel
11287  * value rather than trusting GUC's copy.
11288  */
11290 }
struct Port * MyProcPort
Definition: globals.c:43
int pq_setkeepalivesidle(int idle, Port *port)
Definition: pqcomm.c:1731
#define newval

◆ assign_tcp_keepalives_interval()

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

Definition at line 11303 of file guc.c.

References MyProcPort, and pq_setkeepalivesinterval().

11304 {
11305  /* See comments in assign_tcp_keepalives_idle */
11307 }
struct Port * MyProcPort
Definition: globals.c:43
int pq_setkeepalivesinterval(int interval, Port *port)
Definition: pqcomm.c:1813
#define newval

◆ assign_tcp_user_timeout()

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

Definition at line 11337 of file guc.c.

References MyProcPort, and pq_settcpusertimeout().

11338 {
11339  /* See comments in assign_tcp_keepalives_idle */
11341 }
struct Port * MyProcPort
Definition: globals.c:43
#define newval
int pq_settcpusertimeout(int timeout, Port *port)
Definition: pqcomm.c:1961

◆ assign_timezone_abbreviations()

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

Definition at line 11240 of file guc.c.

References InstallTimeZoneAbbrevs().

11241 {
11242  /* Do nothing for the boot_val default of NULL */
11243  if (!extra)
11244  return;
11245 
11247 }
void InstallTimeZoneAbbrevs(TimeZoneAbbrevTable *tbl)
Definition: datetime.c:4581

◆ assign_wal_consistency_checking()

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

Definition at line 11032 of file guc.c.

References wal_consistency_checking.

11033 {
11034  wal_consistency_checking = (bool *) extra;
11035 }
bool * wal_consistency_checking
Definition: xlog.c:98

◆ AtEOXact_GUC()

void AtEOXact_GUC ( bool  isCommit,
int  nestLevel 
)

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

5793 {
5794  bool still_dirty;
5795  int i;
5796 
5797  /*
5798  * Note: it's possible to get here with GUCNestLevel == nestLevel-1 during
5799  * abort, if there is a failure during transaction start before
5800  * AtStart_GUC is called.
5801  */
5802  Assert(nestLevel > 0 &&
5803  (nestLevel <= GUCNestLevel ||
5804  (nestLevel == GUCNestLevel + 1 && !isCommit)));
5805 
5806  /* Quick exit if nothing's changed in this transaction */
5807  if (!guc_dirty)
5808  {
5809  GUCNestLevel = nestLevel - 1;
5810  return;
5811  }
5812 
5813  still_dirty = false;
5814  for (i = 0; i < num_guc_variables; i++)
5815  {
5816  struct config_generic *gconf = guc_variables[i];
5817  GucStack *stack;
5818 
5819  /*
5820  * Process and pop each stack entry within the nest level. To simplify
5821  * fmgr_security_definer() and other places that use GUC_ACTION_SAVE,
5822  * we allow failure exit from code that uses a local nest level to be
5823  * recovered at the surrounding transaction or subtransaction abort;
5824  * so there could be more than one stack entry to pop.
5825  */
5826  while ((stack = gconf->stack) != NULL &&
5827  stack->nest_level >= nestLevel)
5828  {
5829  GucStack *prev = stack->prev;
5830  bool restorePrior = false;
5831  bool restoreMasked = false;
5832  bool changed;
5833 
5834  /*
5835  * In this next bit, if we don't set either restorePrior or
5836  * restoreMasked, we must "discard" any unwanted fields of the
5837  * stack entries to avoid leaking memory. If we do set one of
5838  * those flags, unused fields will be cleaned up after restoring.
5839  */
5840  if (!isCommit) /* if abort, always restore prior value */
5841  restorePrior = true;
5842  else if (stack->state == GUC_SAVE)
5843  restorePrior = true;
5844  else if (stack->nest_level == 1)
5845  {
5846  /* transaction commit */
5847  if (stack->state == GUC_SET_LOCAL)
5848  restoreMasked = true;
5849  else if (stack->state == GUC_SET)
5850  {
5851  /* we keep the current active value */
5852  discard_stack_value(gconf, &stack->prior);
5853  }
5854  else /* must be GUC_LOCAL */
5855  restorePrior = true;
5856  }
5857  else if (prev == NULL ||
5858  prev->nest_level < stack->nest_level - 1)
5859  {
5860  /* decrement entry's level and do not pop it */
5861  stack->nest_level--;
5862  continue;
5863  }
5864  else
5865  {
5866  /*
5867  * We have to merge this stack entry into prev. See README for
5868  * discussion of this bit.
5869  */
5870  switch (stack->state)
5871  {
5872  case GUC_SAVE:
5873  Assert(false); /* can't get here */
5874  break;
5875 
5876  case GUC_SET:
5877  /* next level always becomes SET */
5878  discard_stack_value(gconf, &stack->prior);
5879  if (prev->state == GUC_SET_LOCAL)
5880  discard_stack_value(gconf, &prev->masked);
5881  prev->state = GUC_SET;
5882  break;
5883 
5884  case GUC_LOCAL:
5885  if (prev->state == GUC_SET)
5886  {
5887  /* LOCAL migrates down */
5888  prev->masked_scontext = stack->scontext;
5889  prev->masked = stack->prior;
5890  prev->state = GUC_SET_LOCAL;
5891  }
5892  else
5893  {
5894  /* else just forget this stack level */
5895  discard_stack_value(gconf, &stack->prior);
5896  }
5897  break;
5898 
5899  case GUC_SET_LOCAL:
5900  /* prior state at this level no longer wanted */
5901  discard_stack_value(gconf, &stack->prior);
5902  /* copy down the masked state */
5903  prev->masked_scontext = stack->masked_scontext;
5904  if (prev->state == GUC_SET_LOCAL)
5905  discard_stack_value(gconf, &prev->masked);
5906  prev->masked = stack->masked;
5907  prev->state = GUC_SET_LOCAL;
5908  break;
5909  }
5910  }
5911 
5912  changed = false;
5913 
5914  if (restorePrior || restoreMasked)
5915  {
5916  /* Perform appropriate restoration of the stacked value */
5917  config_var_value newvalue;
5918  GucSource newsource;
5919  GucContext newscontext;
5920 
5921  if (restoreMasked)
5922  {
5923  newvalue = stack->masked;
5924  newsource = PGC_S_SESSION;
5925  newscontext = stack->masked_scontext;
5926  }
5927  else
5928  {
5929  newvalue = stack->prior;
5930  newsource = stack->source;
5931  newscontext = stack->scontext;
5932  }
5933 
5934  switch (gconf->vartype)
5935  {
5936  case PGC_BOOL:
5937  {
5938  struct config_bool *conf = (struct config_bool *) gconf;
5939  bool newval = newvalue.val.boolval;
5940  void *newextra = newvalue.extra;
5941 
5942  if (*conf->variable != newval ||
5943  conf->gen.extra != newextra)
5944  {
5945  if (conf->assign_hook)
5946  conf->assign_hook(newval, newextra);
5947  *conf->variable = newval;
5948  set_extra_field(&conf->gen, &conf->gen.extra,
5949  newextra);
5950  changed = true;
5951  }
5952  break;
5953  }
5954  case PGC_INT:
5955  {
5956  struct config_int *conf = (struct config_int *) gconf;
5957  int newval = newvalue.val.intval;
5958  void *newextra = newvalue.extra;
5959 
5960  if (*conf->variable != newval ||
5961  conf->gen.extra != newextra)
5962  {
5963  if (conf->assign_hook)
5964  conf->assign_hook(newval, newextra);
5965  *conf->variable = newval;
5966  set_extra_field(&conf->gen, &conf->gen.extra,
5967  newextra);
5968  changed = true;
5969  }
5970  break;
5971  }
5972  case PGC_REAL:
5973  {
5974  struct config_real *conf = (struct config_real *) gconf;
5975  double newval = newvalue.val.realval;
5976  void *newextra = newvalue.extra;
5977 
5978  if (*conf->variable != newval ||
5979  conf->gen.extra != newextra)
5980  {
5981  if (conf->assign_hook)
5982  conf->assign_hook(newval, newextra);
5983  *conf->variable = newval;
5984  set_extra_field(&conf->gen, &conf->gen.extra,
5985  newextra);
5986  changed = true;
5987  }
5988  break;
5989  }
5990  case PGC_STRING:
5991  {
5992  struct config_string *conf = (struct config_string *) gconf;
5993  char *newval = newvalue.val.stringval;
5994  void *newextra = newvalue.extra;
5995 
5996  if (*conf->variable != newval ||
5997  conf->gen.extra != newextra)
5998  {
5999  if (conf->assign_hook)
6000  conf->assign_hook(newval, newextra);
6001  set_string_field(conf, conf->variable, newval);
6002  set_extra_field(&conf->gen, &conf->gen.extra,
6003  newextra);
6004  changed = true;
6005  }
6006 
6007  /*
6008  * Release stacked values if not used anymore. We
6009  * could use discard_stack_value() here, but since
6010  * we have type-specific code anyway, might as
6011  * well inline it.
6012  */
6013  set_string_field(conf, &stack->prior.val.stringval, NULL);
6014  set_string_field(conf, &stack->masked.val.stringval, NULL);
6015  break;
6016  }
6017  case PGC_ENUM:
6018  {
6019  struct config_enum *conf = (struct config_enum *) gconf;
6020  int newval = newvalue.val.enumval;
6021  void *newextra = newvalue.extra;
6022 
6023  if (*conf->variable != newval ||
6024  conf->gen.extra != newextra)
6025  {
6026  if (conf->assign_hook)
6027  conf->assign_hook(newval, newextra);
6028  *conf->variable = newval;
6029  set_extra_field(&conf->gen, &conf->gen.extra,
6030  newextra);
6031  changed = true;
6032  }
6033  break;
6034  }
6035  }
6036 
6037  /*
6038  * Release stacked extra values if not used anymore.
6039  */
6040  set_extra_field(gconf, &(stack->prior.extra), NULL);
6041  set_extra_field(gconf, &(stack->masked.extra), NULL);
6042 
6043  /* And restore source information */
6044  gconf->source = newsource;
6045  gconf->scontext = newscontext;
6046  }
6047 
6048  /* Finish popping the state stack */
6049  gconf->stack = prev;
6050  pfree(stack);
6051 
6052  /* Report new value if we changed it */
6053  if (changed && (gconf->flags & GUC_REPORT))
6054  ReportGUCOption(gconf);
6055  } /* end of stack-popping loop */
6056 
6057  if (stack != NULL)
6058  still_dirty = true;
6059  }
6060 
6061  /* If there are no remaining stack entries, we can reset guc_dirty */
6062  guc_dirty = still_dirty;
6063 
6064  /* Update nesting level */
6065  GUCNestLevel = nestLevel - 1;
6066 }
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:4644
bool * variable
Definition: guc_tables.h:184
GucEnumAssignHook assign_hook
Definition: guc_tables.h:248
GucBoolAssignHook assign_hook
Definition: guc_tables.h:187
config_var_value masked
Definition: guc_tables.h:131
GucContext scontext
Definition: guc_tables.h:160
GucIntAssignHook assign_hook
Definition: guc_tables.h:203
GucSource
Definition: guc.h:105
int * variable
Definition: guc_tables.h:198
int * variable
Definition: guc_tables.h:244
void pfree(void *pointer)
Definition: mcxt.c:1056
static int num_guc_variables
Definition: guc.c:4631
static void discard_stack_value(struct config_generic *gconf, config_var_value *val)
Definition: guc.c:4859
GucSource source
Definition: guc_tables.h:126
static void set_extra_field(struct config_generic *gconf, void **field, void *newval)
Definition: guc.c:4805
struct config_generic gen
Definition: guc_tables.h:182
struct config_generic gen
Definition: guc_tables.h:196
GucContext masked_scontext
Definition: guc_tables.h:129
#define GUC_REPORT
Definition: guc.h:208
double * variable
Definition: guc_tables.h:214
static void set_string_field(struct config_string *conf, char **field, char *newval)
Definition: guc.c:4744
static struct config_generic ** guc_variables
Definition: guc.c:4628
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:739
#define newval
char * stringval
Definition: guc_tables.h:36
int i
static void ReportGUCOption(struct config_generic *record)
Definition: guc.c:6102
GucStack * stack
Definition: guc_tables.h:162
double realval
Definition: guc_tables.h:35
static bool guc_dirty
Definition: guc.c:4640
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 5758 of file guc.c.

References elog, and WARNING.

Referenced by StartTransaction().

5759 {
5760  /*
5761  * The nest level should be 0 between transactions; if it isn't, somebody
5762  * didn't call AtEOXact_GUC, or called it with the wrong nestLevel. We
5763  * throw a warning but make no other effort to clean up.
5764  */
5765  if (GUCNestLevel != 0)
5766  elog(WARNING, "GUC nest level = %d at transaction start",
5767  GUCNestLevel);
5768  GUCNestLevel = 1;
5769 }
static int GUCNestLevel
Definition: guc.c:4644
#define WARNING
Definition: elog.h:40
#define elog(elevel,...)
Definition: elog.h:228

◆ BeginReportingGUCOptions()

void BeginReportingGUCOptions ( void  )

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

6075 {
6076  int i;
6077 
6078  /*
6079  * Don't do anything unless talking to an interactive frontend of protocol
6080  * 3.0 or later.
6081  */
6082  if (whereToSendOutput != DestRemote ||
6084  return;
6085 
6086  reporting_enabled = true;
6087 
6088  /* Transmit initial values of interesting variables */
6089  for (i = 0; i < num_guc_variables; i++)
6090  {
6091  struct config_generic *conf = guc_variables[i];
6092 
6093  if (conf->flags & GUC_REPORT)
6094  ReportGUCOption(conf);
6095  }
6096 }
#define PG_PROTOCOL_MAJOR(v)
Definition: pqcomm.h:104
static int num_guc_variables
Definition: guc.c:4631
#define GUC_REPORT
Definition: guc.h:208
static struct config_generic ** guc_variables
Definition: guc.c:4628
int i
static void ReportGUCOption(struct config_generic *record)
Definition: guc.c:6102
CommandDest whereToSendOutput
Definition: postgres.c:90
static bool reporting_enabled
Definition: guc.c:4642
ProtocolVersion FrontendProtocol
Definition: globals.c:28

◆ build_guc_variables()

void build_guc_variables ( void  )

Definition at line 4895 of file guc.c.

References FATAL, config_generic::flags, free, config_bool::gen, config_int::gen, config_real::gen, config_string::gen, config_enum::gen, GUC_EXPLAIN, 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().

4896 {
4897  int size_vars;
4898  int num_vars = 0;
4899  int num_explain_vars = 0;
4900  struct config_generic **guc_vars;
4901  int i;
4902 
4903  for (i = 0; ConfigureNamesBool[i].gen.name; i++)
4904  {
4905  struct config_bool *conf = &ConfigureNamesBool[i];
4906 
4907  /* Rather than requiring vartype to be filled in by hand, do this: */
4908  conf->gen.vartype = PGC_BOOL;
4909  num_vars++;
4910 
4911  if (conf->gen.flags & GUC_EXPLAIN)
4912  num_explain_vars++;
4913  }
4914 
4915  for (i = 0; ConfigureNamesInt[i].gen.name; i++)
4916  {
4917  struct config_int *conf = &ConfigureNamesInt[i];
4918 
4919  conf->gen.vartype = PGC_INT;
4920  num_vars++;
4921 
4922  if (conf->gen.flags & GUC_EXPLAIN)
4923  num_explain_vars++;
4924  }
4925 
4926  for (i = 0; ConfigureNamesReal[i].gen.name; i++)
4927  {
4928  struct config_real *conf = &ConfigureNamesReal[i];
4929 
4930  conf->gen.vartype = PGC_REAL;
4931  num_vars++;
4932 
4933  if (conf->gen.flags & GUC_EXPLAIN)
4934  num_explain_vars++;
4935  }
4936 
4937  for (i = 0; ConfigureNamesString[i].gen.name; i++)
4938  {
4939  struct config_string *conf = &ConfigureNamesString[i];
4940 
4941  conf->gen.vartype = PGC_STRING;
4942  num_vars++;
4943 
4944  if (conf->gen.flags & GUC_EXPLAIN)
4945  num_explain_vars++;
4946  }
4947 
4948  for (i = 0; ConfigureNamesEnum[i].gen.name; i++)
4949  {
4950  struct config_enum *conf = &ConfigureNamesEnum[i];
4951 
4952  conf->gen.vartype = PGC_ENUM;
4953  num_vars++;
4954 
4955  if (conf->gen.flags & GUC_EXPLAIN)
4956  num_explain_vars++;
4957  }
4958 
4959  /*
4960  * Create table with 20% slack
4961  */
4962  size_vars = num_vars + num_vars / 4;
4963 
4964  guc_vars = (struct config_generic **)
4965  guc_malloc(FATAL, size_vars * sizeof(struct config_generic *));
4966 
4967  num_vars = 0;
4968 
4969  for (i = 0; ConfigureNamesBool[i].gen.name; i++)
4970  guc_vars[num_vars++] = &ConfigureNamesBool[i].gen;
4971 
4972  for (i = 0; ConfigureNamesInt[i].gen.name; i++)
4973  guc_vars[num_vars++] = &ConfigureNamesInt[i].gen;
4974 
4975  for (i = 0; ConfigureNamesReal[i].gen.name; i++)
4976  guc_vars[num_vars++] = &ConfigureNamesReal[i].gen;
4977 
4978  for (i = 0; ConfigureNamesString[i].gen.name; i++)
4979  guc_vars[num_vars++] = &ConfigureNamesString[i].gen;
4980 
4981  for (i = 0; ConfigureNamesEnum[i].gen.name; i++)
4982  guc_vars[num_vars++] = &ConfigureNamesEnum[i].gen;
4983 
4984  if (guc_variables)
4986  guc_variables = guc_vars;
4987  num_guc_variables = num_vars;
4988  num_guc_explain_variables = num_explain_vars;
4989  size_guc_variables = size_vars;
4991  sizeof(struct config_generic *), guc_var_compare);
4992 }
static struct config_int ConfigureNamesInt[]
Definition: guc.c:1979
const char * name
Definition: guc_tables.h:149
static struct config_enum ConfigureNamesEnum[]
Definition: guc.c:4272
static struct config_bool ConfigureNamesBool[]
Definition: guc.c:889
static int guc_var_compare(const void *a, const void *b)
Definition: guc.c:5134
static int num_guc_variables
Definition: guc.c:4631
#define FATAL
Definition: elog.h:52
struct config_generic gen
Definition: guc_tables.h:182
struct config_generic gen
Definition: guc_tables.h:196
#define GUC_EXPLAIN
Definition: guc.h:230
static struct config_generic ** guc_variables
Definition: guc.c:4628
enum config_type vartype
Definition: guc_tables.h:156
static int size_guc_variables
Definition: guc.c:4637
static struct config_real ConfigureNamesReal[]
Definition: guc.c:3246
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 int num_guc_explain_variables
Definition: guc.c:4634
static struct config_string ConfigureNamesString[]
Definition: guc.c:3504
int i
#define qsort(a, b, c, d)
Definition: port.h:488
static void * guc_malloc(int elevel, size_t size)
Definition: guc.c:4672
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 10782 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().

10784 {
10785  /* Quick success if no hook */
10786  if (!conf->check_hook)
10787  return true;
10788 
10789  /* Reset variables that might be set by hook */
10790  GUC_check_errcode_value = ERRCODE_INVALID_PARAMETER_VALUE;
10791  GUC_check_errmsg_string = NULL;
10793  GUC_check_errhint_string = NULL;
10794 
10795  if (!conf->check_hook(newval, extra, source))
10796  {
10797  ereport(elevel,
10801  errmsg("invalid value for parameter \"%s\": %d",
10802  conf->gen.name, (int) *newval),
10806  errhint("%s", GUC_check_errhint_string) : 0));
10807  /* Flush any strings created in ErrorContext */
10808  FlushErrorState();
10809  return false;
10810  }
10811 
10812  return true;
10813 }
char * GUC_check_errhint_string
Definition: guc.c:140
GucSource source
Definition: guc_tables.h:158
int errhint(const char *fmt,...)
Definition: elog.c:1069
const char * name
Definition: guc_tables.h:149
int errcode(int sqlerrcode)
Definition: elog.c:608
static int GUC_check_errcode_value
Definition: guc.c:135
void FlushErrorState(void)
Definition: elog.c:1678
int errdetail_internal(const char *fmt,...)
Definition: elog.c:982
struct config_generic gen
Definition: guc_tables.h:182
char * GUC_check_errdetail_string
Definition: guc.c:139
#define ereport(elevel, rest)
Definition: elog.h:141
static int elevel
Definition: vacuumlazy.c:143
GucBoolCheckHook check_hook
Definition: guc_tables.h:186
int errmsg_internal(const char *fmt,...)
Definition: elog.c:909
#define newval
char * GUC_check_errmsg_string
Definition: guc.c:138
int errmsg(const char *fmt,...)
Definition: elog.c:822

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

10920 {
10921  /* Quick success if no hook */
10922  if (!conf->check_hook)
10923  return true;
10924 
10925  /* Reset variables that might be set by hook */
10926  GUC_check_errcode_value = ERRCODE_INVALID_PARAMETER_VALUE;
10927  GUC_check_errmsg_string = NULL;
10929  GUC_check_errhint_string = NULL;
10930 
10931  if (!conf->check_hook(newval, extra, source))
10932  {
10933  ereport(elevel,
10937  errmsg("invalid value for parameter \"%s\": \"%s\"",
10938  conf->gen.name,
10943  errhint("%s", GUC_check_errhint_string) : 0));
10944  /* Flush any strings created in ErrorContext */
10945  FlushErrorState();
10946  return false;
10947  }
10948 
10949  return true;
10950 }
char * GUC_check_errhint_string
Definition: guc.c:140
GucSource source
Definition: guc_tables.h:158
GucEnumCheckHook check_hook
Definition: guc_tables.h:247
int errhint(const char *fmt,...)
Definition: elog.c:1069
const char * name
Definition: guc_tables.h:149
int errcode(int sqlerrcode)
Definition: elog.c:608
const char * config_enum_lookup_by_value(struct config_enum *record, int val)
Definition: guc.c:6481
static int GUC_check_errcode_value
Definition: guc.c:135
void FlushErrorState(void)
Definition: elog.c:1678
int errdetail_internal(const char *fmt,...)
Definition: elog.c:982
char * GUC_check_errdetail_string
Definition: guc.c:139
#define ereport(elevel, rest)
Definition: elog.h:141
static int elevel
Definition: vacuumlazy.c:143
struct config_generic gen
Definition: guc_tables.h:242
int errmsg_internal(const char *fmt,...)
Definition: elog.c:909
#define newval
char * GUC_check_errmsg_string
Definition: guc.c:138
int errmsg(const char *fmt,...)
Definition: elog.c:822

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

10818 {
10819  /* Quick success if no hook */
10820  if (!conf->check_hook)
10821  return true;
10822 
10823  /* Reset variables that might be set by hook */
10824  GUC_check_errcode_value = ERRCODE_INVALID_PARAMETER_VALUE;
10825  GUC_check_errmsg_string = NULL;
10827  GUC_check_errhint_string = NULL;
10828 
10829  if (!conf->check_hook(newval, extra, source))
10830  {
10831  ereport(elevel,
10835  errmsg("invalid value for parameter \"%s\": %d",
10836  conf->gen.name, *newval),
10840  errhint("%s", GUC_check_errhint_string) : 0));
10841  /* Flush any strings created in ErrorContext */
10842  FlushErrorState();
10843  return false;
10844  }
10845 
10846  return true;
10847 }
char * GUC_check_errhint_string
Definition: guc.c:140
GucSource source
Definition: guc_tables.h:158
int errhint(const char *fmt,...)
Definition: elog.c:1069
const char * name
Definition: guc_tables.h:149
int errcode(int sqlerrcode)
Definition: elog.c:608
static int GUC_check_errcode_value
Definition: guc.c:135
GucIntCheckHook check_hook
Definition: guc_tables.h:202
void FlushErrorState(void)
Definition: elog.c:1678
int errdetail_internal(const char *fmt,...)
Definition: elog.c:982
struct config_generic gen
Definition: guc_tables.h:196
char * GUC_check_errdetail_string
Definition: guc.c:139
#define ereport(elevel, rest)
Definition: elog.h:141
static int elevel
Definition: vacuumlazy.c:143
int errmsg_internal(const char *fmt,...)
Definition: elog.c:909
#define newval
char * GUC_check_errmsg_string
Definition: guc.c:138
int errmsg(const char *fmt,...)
Definition: elog.c:822

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

10852 {
10853  /* Quick success if no hook */
10854  if (!conf->check_hook)
10855  return true;
10856 
10857  /* Reset variables that might be set by hook */
10858  GUC_check_errcode_value = ERRCODE_INVALID_PARAMETER_VALUE;
10859  GUC_check_errmsg_string = NULL;
10861  GUC_check_errhint_string = NULL;
10862 
10863  if (!conf->check_hook(newval, extra, source))
10864  {
10865  ereport(elevel,
10869  errmsg("invalid value for parameter \"%s\": %g",
10870  conf->gen.name, *newval),
10874  errhint("%s", GUC_check_errhint_string) : 0));
10875  /* Flush any strings created in ErrorContext */
10876  FlushErrorState();
10877  return false;
10878  }
10879 
10880  return true;
10881 }
char * GUC_check_errhint_string
Definition: guc.c:140
GucSource source
Definition: guc_tables.h:158
int errhint(const char *fmt,...)
Definition: elog.c:1069
const char * name
Definition: guc_tables.h:149
int errcode(int sqlerrcode)
Definition: elog.c:608
static int GUC_check_errcode_value
Definition: guc.c:135
GucRealCheckHook check_hook
Definition: guc_tables.h:218
void FlushErrorState(void)
Definition: elog.c:1678
int errdetail_internal(const char *fmt,...)
Definition: elog.c:982
char * GUC_check_errdetail_string
Definition: guc.c:139
#define ereport(elevel, rest)
Definition: elog.h:141
static int elevel
Definition: vacuumlazy.c:143
int errmsg_internal(const char *fmt,...)
Definition: elog.c:909
#define newval
char * GUC_check_errmsg_string
Definition: guc.c:138
int errmsg(const char *fmt,...)
Definition: elog.c:822
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 10884 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().

10886 {
10887  /* Quick success if no hook */
10888  if (!conf->check_hook)
10889  return true;
10890 
10891  /* Reset variables that might be set by hook */
10892  GUC_check_errcode_value = ERRCODE_INVALID_PARAMETER_VALUE;
10893  GUC_check_errmsg_string = NULL;
10895  GUC_check_errhint_string = NULL;
10896 
10897  if (!conf->check_hook(newval, extra, source))
10898  {
10899  ereport(elevel,
10903  errmsg("invalid value for parameter \"%s\": \"%s\"",
10904  conf->gen.name, *newval ? *newval : ""),
10908  errhint("%s", GUC_check_errhint_string) : 0));
10909  /* Flush any strings created in ErrorContext */
10910  FlushErrorState();
10911  return false;
10912  }
10913 
10914  return true;
10915 }
char * GUC_check_errhint_string
Definition: guc.c:140
GucSource source
Definition: guc_tables.h:158
int errhint(const char *fmt,...)
Definition: elog.c:1069
const char * name
Definition: guc_tables.h:149
GucStringCheckHook check_hook
Definition: guc_tables.h:232
int errcode(int sqlerrcode)
Definition: elog.c:608
static int GUC_check_errcode_value
Definition: guc.c:135
void FlushErrorState(void)
Definition: elog.c:1678
int errdetail_internal(const char *fmt,...)
Definition: elog.c:982
char * GUC_check_errdetail_string
Definition: guc.c:139
#define ereport(elevel, rest)
Definition: elog.h:141
static int elevel
Definition: vacuumlazy.c:143
struct config_generic gen
Definition: guc_tables.h:228
int errmsg_internal(const char *fmt,...)
Definition: elog.c:909
#define newval
char * GUC_check_errmsg_string
Definition: guc.c:138
int errmsg(const char *fmt,...)
Definition: elog.c:822

◆ can_skip_gucvar()

static bool can_skip_gucvar ( struct config_generic gconf)
static

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

9963 {
9964  return gconf->context == PGC_POSTMASTER ||
9965  gconf->context == PGC_INTERNAL || gconf->source == PGC_S_DEFAULT ||
9966  strcmp(gconf->name, "role") == 0;
9967 }
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 11477 of file guc.c.

References pg_clean_ascii().

11478 {
11479  /* Only allow clean ASCII chars in the application name */
11481 
11482  return true;
11483 }
#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 11363 of file guc.c.

References MAX_BACKENDS, max_wal_senders, max_worker_processes, and MaxConnections.

11364 {
11365  if (MaxConnections + *newval + 1 +
11367  return false;
11368  return true;
11369 }
#define MAX_BACKENDS
Definition: postmaster.h:75
int max_wal_senders
Definition: walsender.c:120
int MaxConnections
Definition: globals.c:132
#define newval
int max_worker_processes
Definition: globals.c:133

◆ check_autovacuum_work_mem()

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

Definition at line 11381 of file guc.c.

11382 {
11383  /*
11384  * -1 indicates fallback.
11385  *
11386  * If we haven't yet changed the boot_val default of -1, just let it be.
11387  * Autovacuum will look to maintenance_work_mem instead.
11388  */
11389  if (*newval == -1)
11390  return true;
11391 
11392  /*
11393  * We clamp manually-set values to at least 1MB. Since
11394  * maintenance_work_mem is always set to at least this value, do the same
11395  * here.
11396  */
11397  if (*newval < 1024)
11398  *newval = 1024;
11399 
11400  return true;
11401 }
#define newval

◆ check_backtrace_functions()

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

Definition at line 11537 of file guc.c.

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

11538 {
11539  int newvallen = strlen(*newval);
11540  char *someval;
11541  int validlen;
11542  int i;
11543  int j;
11544 
11545  /*
11546  * Allow characters that can be C identifiers and commas as separators, as
11547  * well as some whitespace for readability.
11548  */
11549  validlen = strspn(*newval,
11550  "0123456789_"
11551  "abcdefghijklmnopqrstuvwxyz"
11552  "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
11553  ", \n\t");
11554  if (validlen != newvallen)
11555  {
11556  GUC_check_errdetail("invalid character");
11557  return false;
11558  }
11559 
11560  if (*newval[0] == '\0')
11561  {
11562  *extra = NULL;
11563  return true;
11564  }
11565 
11566  /*
11567  * Allocate space for the output and create the copy. We could discount
11568  * whitespace chars to save some memory, but it doesn't seem worth the
11569  * trouble.
11570  */
11571  someval = guc_malloc(ERROR, newvallen + 1 + 1);
11572  for (i = 0, j = 0; i < newvallen; i++)
11573  {
11574  if ((*newval)[i] == ',')
11575  someval[j++] = '\0'; /* next item */
11576  else if ((*newval)[i] == ' ' ||
11577  (*newval)[i] == '\n' ||
11578  (*newval)[i] == '\t')
11579  ; /* ignore these */
11580  else
11581  someval[j++] = (*newval)[i]; /* copy anything else */
11582  }
11583 
11584  /* two \0s end the setting */
11585  someval[j] = '\0';
11586  someval[j + 1] = '\0';
11587 
11588  *extra = someval;
11589  return true;
11590 }
#define GUC_check_errdetail
Definition: guc.h:414
#define ERROR
Definition: elog.h:43
#define newval
int i
static void * guc_malloc(int elevel, size_t size)
Definition: guc.c:4672

◆ check_bonjour()

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

Definition at line 11146 of file guc.c.

References GUC_check_errmsg.

11147 {
11148 #ifndef USE_BONJOUR
11149  if (*newval)
11150  {
11151  GUC_check_errmsg("Bonjour is not supported by this build");
11152  return false;
11153  }
11154 #endif
11155  return true;
11156 }
#define GUC_check_errmsg
Definition: guc.h:410
#define newval

◆ check_canonical_path()

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

Definition at line 11197 of file guc.c.

References canonicalize_path().

11198 {
11199  /*
11200  * Since canonicalize_path never enlarges the string, we can just modify
11201  * newval in-place. But watch out for NULL, which is the default value
11202  * for external_pid_file.
11203  */
11204  if (*newval)
11206  return true;
11207 }
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 11493 of file guc.c.

References pg_clean_ascii().

11494 {
11495  /* Only allow clean ASCII chars in the cluster name */
11497 
11498  return true;
11499 }
#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 11866 of file guc.c.

References GUC_check_errcode(), and GUC_check_errmsg.

11867 {
11868  if (*newval)
11869  {
11870  /* check the GUC's definition for an explanation */
11871  GUC_check_errcode(ERRCODE_FEATURE_NOT_SUPPORTED);
11872  GUC_check_errmsg("tables declared WITH OIDS are not supported");
11873 
11874  return false;
11875  }
11876 
11877  return true;
11878 }
#define GUC_check_errmsg
Definition: guc.h:410
void GUC_check_errcode(int sqlerrcode)
Definition: guc.c:10769
#define newval

◆ check_effective_io_concurrency()

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

Definition at line 11413 of file guc.c.

References ComputeIoConcurrency(), ERROR, GUC_check_errdetail, guc_malloc(), and rint().

11414 {
11415 #ifdef USE_PREFETCH
11416  double new_prefetch_pages;
11417 
11418  if (ComputeIoConcurrency(*newval, &new_prefetch_pages))
11419  {
11420  int *myextra = (int *) guc_malloc(ERROR, sizeof(int));
11421 
11422  *myextra = (int) rint(new_prefetch_pages);
11423  *extra = (void *) myextra;
11424 
11425  return true;
11426  }
11427  else
11428  return false;
11429 #else
11430  if (*newval != 0)
11431  {
11432  GUC_check_errdetail("effective_io_concurrency must be set to 0 on platforms that lack posix_fadvise().");
11433  return false;
11434  }
11435  return true;
11436 #endif /* USE_PREFETCH */
11437 }
#define GUC_check_errdetail
Definition: guc.h:414
bool ComputeIoConcurrency(int io_concurrency, double *target)
Definition: bufmgr.c:469
#define ERROR
Definition: elog.h:43
double rint(double x)
Definition: rint.c:21
#define newval
static void * guc_malloc(int elevel, size_t size)
Definition: guc.c:4672

◆ check_log_destination()

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

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

11039 {
11040  char *rawstring;
11041  List *elemlist;
11042  ListCell *l;
11043  int newlogdest = 0;
11044  int *myextra;
11045 
11046  /* Need a modifiable copy of string */
11047  rawstring = pstrdup(*newval);
11048 
11049  /* Parse string into list of identifiers */
11050  if (!SplitIdentifierString(rawstring, ',', &elemlist))
11051  {
11052  /* syntax error in list */
11053  GUC_check_errdetail("List syntax is invalid.");
11054  pfree(rawstring);
11055  list_free(elemlist);
11056  return false;
11057  }
11058 
11059  foreach(l, elemlist)
11060  {
11061  char *tok = (char *) lfirst(l);
11062 
11063  if (pg_strcasecmp(tok, "stderr") == 0)
11064  newlogdest |= LOG_DESTINATION_STDERR;
11065  else if (pg_strcasecmp(tok, "csvlog") == 0)
11066  newlogdest |= LOG_DESTINATION_CSVLOG;
11067 #ifdef HAVE_SYSLOG
11068  else if (pg_strcasecmp(tok, "syslog") == 0)
11069  newlogdest |= LOG_DESTINATION_SYSLOG;
11070 #endif
11071 #ifdef WIN32
11072  else if (pg_strcasecmp(tok, "eventlog") == 0)
11073  newlogdest |= LOG_DESTINATION_EVENTLOG;
11074 #endif
11075  else
11076  {
11077  GUC_check_errdetail("Unrecognized key word: \"%s\".", tok);
11078  pfree(rawstring);
11079  list_free(elemlist);
11080  return false;
11081  }
11082  }
11083 
11084  pfree(rawstring);
11085  list_free(elemlist);
11086 
11087  myextra = (int *) guc_malloc(ERROR, sizeof(int));
11088  *myextra = newlogdest;
11089  *extra = (void *) myextra;
11090 
11091  return true;
11092 }
#define LOG_DESTINATION_EVENTLOG
Definition: elog.h:447
#define GUC_check_errdetail
Definition: guc.h:414
char * pstrdup(const char *in)
Definition: mcxt.c:1186
#define LOG_DESTINATION_SYSLOG
Definition: elog.h:446
int pg_strcasecmp(const char *s1, const char *s2)
Definition: pgstrcasecmp.c:36
void pfree(void *pointer)
Definition: mcxt.c:1056
#define ERROR
Definition: elog.h:43
bool SplitIdentifierString(char *rawstring, char separator, List **namelist)
Definition: varlena.c:3652
#define LOG_DESTINATION_CSVLOG
Definition: elog.h:448
#define LOG_DESTINATION_STDERR
Definition: elog.h:445
#define lfirst(lc)
Definition: pg_list.h:190
#define newval
void list_free(List *list)
Definition: list.c:1377
static void * guc_malloc(int elevel, size_t size)
Definition: guc.c:4672
Definition: pg_list.h:50

◆ check_log_stats()

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

Definition at line 11183 of file guc.c.

References GUC_check_errdetail.

11184 {
11185  if (*newval &&
11187  {
11188  GUC_check_errdetail("Cannot enable \"log_statement_stats\" when "
11189  "\"log_parser_stats\", \"log_planner_stats\", "
11190  "or \"log_executor_stats\" is true.");
11191  return false;
11192  }
11193  return true;
11194 }
bool log_parser_stats
Definition: guc.c:495
#define GUC_check_errdetail
Definition: guc.h:414
#define newval
bool log_executor_stats
Definition: guc.c:497
bool log_planner_stats
Definition: guc.c:496

◆ check_max_wal_senders()

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

Definition at line 11372 of file guc.c.

References autovacuum_max_workers, MAX_BACKENDS, max_worker_processes, and MaxConnections.

11373 {
11376  return false;
11377  return true;
11378 }
#define MAX_BACKENDS
Definition: postmaster.h:75
int MaxConnections
Definition: globals.c:132
int autovacuum_max_workers
Definition: autovacuum.c:114
#define newval
int max_worker_processes
Definition: globals.c:133

◆ check_max_worker_processes()

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

Definition at line 11404 of file guc.c.

References autovacuum_max_workers, MAX_BACKENDS, max_wal_senders, and MaxConnections.

11405 {
11408  return false;
11409  return true;
11410 }
#define MAX_BACKENDS
Definition: postmaster.h:75
int max_wal_senders
Definition: walsender.c:120
int MaxConnections
Definition: globals.c:132
int autovacuum_max_workers
Definition: autovacuum.c:114
#define newval

◆ check_maxconnections()

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

Definition at line 11354 of file guc.c.

References autovacuum_max_workers, MAX_BACKENDS, max_wal_senders, and max_worker_processes.

11355 {
11356  if (*newval + autovacuum_max_workers + 1 +
11358  return false;
11359  return true;
11360 }
#define MAX_BACKENDS
Definition: postmaster.h:75
int max_wal_senders
Definition: walsender.c:120
int autovacuum_max_workers
Definition: autovacuum.c:114
#define newval
int max_worker_processes
Definition: globals.c:133

◆ check_primary_slot_name()

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

Definition at line 11856 of file guc.c.

References ReplicationSlotValidateName(), and WARNING.

11857 {
11858  if (*newval && strcmp(*newval, "") != 0 &&
11860  return false;
11861 
11862  return true;
11863 }
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 11661 of file guc.c.

References GUC_check_errdetail.

11662 {
11663  if (strcmp(*newval, "immediate") != 0 && strcmp(*newval, "") != 0)
11664  {
11665  GUC_check_errdetail("The only allowed value is \"immediate\".");
11666  return false;
11667  }
11668  return true;
11669 }
#define GUC_check_errdetail
Definition: guc.h:414
#define newval

◆ check_recovery_target_lsn()

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

Definition at line 11820 of file guc.c.

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

11821 {
11822  if (strcmp(*newval, "") != 0)
11823  {
11824  XLogRecPtr lsn;
11825  XLogRecPtr *myextra;
11826  bool have_error = false;
11827 
11828  lsn = pg_lsn_in_internal(*newval, &have_error);
11829  if (have_error)
11830  return false;
11831 
11832  myextra = (XLogRecPtr *) guc_malloc(ERROR, sizeof(XLogRecPtr));
11833  *myextra = lsn;
11834  *extra = (void *) myextra;
11835  }
11836  return true;
11837 }
#define ERROR
Definition: elog.h:43
XLogRecPtr pg_lsn_in_internal(const char *str, bool *have_error)
Definition: pg_lsn.c:29
uint64 XLogRecPtr
Definition: xlogdefs.h:21
#define newval
static void * guc_malloc(int elevel, size_t size)
Definition: guc.c:4672

◆ check_recovery_target_name()

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

Definition at line 11791 of file guc.c.

References GUC_check_errdetail, and MAXFNAMELEN.

11792 {
11793  /* Use the value of newval directly */
11794  if (strlen(*newval) >= MAXFNAMELEN)
11795  {
11796  GUC_check_errdetail("%s is too long (maximum %d characters).",
11797  "recovery_target_name", MAXFNAMELEN - 1);
11798  return false;
11799  }
11800  return true;
11801 }
#define GUC_check_errdetail
Definition: guc.h:414
#define MAXFNAMELEN
#define newval

◆ check_recovery_target_time()

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

Definition at line 11728 of file guc.c.

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

11729 {
11730  if (strcmp(*newval, "") != 0)
11731  {
11732  /* reject some special values */
11733  if (strcmp(*newval, "now") == 0 ||
11734  strcmp(*newval, "today") == 0 ||
11735  strcmp(*newval, "tomorrow") == 0 ||
11736  strcmp(*newval, "yesterday") == 0)
11737  {
11738  return false;
11739  }
11740 
11741  /*
11742  * parse timestamp value (see also timestamptz_in())
11743  */
11744  {
11745  char *str = *newval;
11746  fsec_t fsec;
11747  struct pg_tm tt,
11748  *tm = &tt;
11749  int tz;
11750  int dtype;
11751  int nf;
11752  int dterr;
11753  char *field[MAXDATEFIELDS];
11754  int ftype[MAXDATEFIELDS];
11755  char workbuf[MAXDATELEN + MAXDATEFIELDS];
11757 
11758  dterr = ParseDateTime(str, workbuf, sizeof(workbuf),
11759  field, ftype, MAXDATEFIELDS, &nf);
11760  if (dterr == 0)
11761  dterr = DecodeDateTime(field, ftype, nf, &dtype, tm, &fsec, &tz);
11762  if (dterr != 0)
11763  return false;
11764  if (dtype != DTK_DATE)
11765  return false;
11766 
11767  if (tm2timestamp(tm, fsec, &tz, &timestamp) != 0)
11768  {
11769  GUC_check_errdetail("timestamp out of range: \"%s\"", str);
11770  return false;
11771  }
11772  }
11773  }
11774  return true;
11775 }
#define MAXDATELEN
Definition: datetime.h:201
#define GUC_check_errdetail
Definition: guc.h:414
int64 timestamp
int64 TimestampTz
Definition: timestamp.h:39
Definition: pgtime.h:25
static struct pg_tm tm
Definition: localtime.c:108
int DecodeDateTime(char **field, int *ftype, int nf, int *dtype, struct pg_tm *tm, fsec_t *fsec, int *tzp)
Definition: datetime.c:758
int32 fsec_t
Definition: timestamp.h:41
int tm2timestamp(struct pg_tm *tm, fsec_t fsec, int *tzp, Timestamp *result)
Definition: timestamp.c:1887
#define MAXDATEFIELDS
Definition: datetime.h:203
#define newval
int ParseDateTime(const char *timestr, char *workbuf, size_t buflen, char **field, int *ftype, int maxfields, int *numfields)
Definition: datetime.c:537
#define DTK_DATE
Definition: datetime.h:145

◆ check_recovery_target_timeline()

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

Definition at line 11599 of file guc.c.

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

11600 {
11602  RecoveryTargetTimeLineGoal *myextra;
11603 
11604  if (strcmp(*newval, "current") == 0)
11606  else if (strcmp(*newval, "latest") == 0)
11608  else
11609  {
11611 
11612  errno = 0;
11613  strtoul(*newval, NULL, 0);
11614  if (errno == EINVAL || errno == ERANGE)
11615  {
11616  GUC_check_errdetail("recovery_target_timeline is not a valid number.");
11617  return false;
11618  }
11619  }
11620 
11622  *myextra = rttg;
11623  *extra = (void *) myextra;
11624 
11625  return true;
11626 }
#define GUC_check_errdetail
Definition: guc.h:414
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:4672

◆ check_recovery_target_xid()

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

Definition at line 11685 of file guc.c.

References ERROR, and guc_malloc().

11686 {
11687  if (strcmp(*newval, "") != 0)
11688  {
11689  TransactionId xid;
11690  TransactionId *myextra;
11691 
11692  errno = 0;
11693  xid = (TransactionId) strtoul(*newval, NULL, 0);
11694  if (errno == EINVAL || errno == ERANGE)
11695  return false;
11696 
11697  myextra = (TransactionId *) guc_malloc(ERROR, sizeof(TransactionId));
11698  *myextra = xid;
11699  *extra = (void *) myextra;
11700  }
11701  return true;
11702 }
uint32 TransactionId
Definition: c.h:514
#define ERROR
Definition: elog.h:43
#define newval
static void * guc_malloc(int elevel, size_t size)
Definition: guc.c:4672

◆ check_ssl()

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

Definition at line 11159 of file guc.c.

References GUC_check_errmsg.

11160 {
11161 #ifndef USE_SSL
11162  if (*newval)
11163  {
11164  GUC_check_errmsg("SSL is not supported by this build");
11165  return false;
11166  }
11167 #endif
11168  return true;
11169 }
#define GUC_check_errmsg
Definition: guc.h:410
#define newval

◆ check_stage_log_stats()

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

Definition at line 11172 of file guc.c.

References GUC_check_errdetail.

11173 {
11174  if (*newval && log_statement_stats)
11175  {
11176  GUC_check_errdetail("Cannot enable parameter when \"log_statement_stats\" is true.");
11177  return false;
11178  }
11179  return true;
11180 }
bool log_statement_stats
Definition: guc.c:498
#define GUC_check_errdetail
Definition: guc.h:414
#define newval

◆ check_temp_buffers()

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

Definition at line 11132 of file guc.c.

References GUC_check_errdetail, and NLocBuffer.

11133 {
11134  /*
11135  * Once local buffers have been initialized, it's too late to change this.
11136  */
11137  if (NLocBuffer && NLocBuffer != *newval)
11138  {
11139  GUC_check_errdetail("\"temp_buffers\" cannot be changed after any temporary tables have been accessed in the session.");
11140  return false;
11141  }
11142  return true;
11143 }
#define GUC_check_errdetail
Definition: guc.h:414
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 11210 of file guc.c.

References Assert, load_tzoffsets(), and PGC_S_DEFAULT.

11211 {
11212  /*
11213  * The boot_val given above for timezone_abbreviations is NULL. When we
11214  * see this we just do nothing. If this value isn't overridden from the
11215  * config file then pg_timezone_abbrev_initialize() will eventually
11216  * replace it with "Default". This hack has two purposes: to avoid
11217  * wasting cycles loading values that might soon be overridden from the
11218  * config file, and to avoid trying to read the timezone abbrev files
11219  * during InitializeGUCOptions(). The latter doesn't work in an
11220  * EXEC_BACKEND subprocess because my_exec_path hasn't been set yet and so
11221  * we can't locate PGSHAREDIR.
11222  */
11223  if (*newval == NULL)
11224  {
11225  Assert(source == PGC_S_DEFAULT);
11226  return true;
11227  }
11228 
11229  /* OK, load the file and produce a malloc'd TimeZoneAbbrevTable */
11230  *extra = load_tzoffsets(*newval);
11231 
11232  /* tzparser.c returns NULL on failure, reporting via GUC_check_errmsg */
11233  if (!*extra)
11234  return false;
11235 
11236  return true;
11237 }
TimeZoneAbbrevTable * load_tzoffsets(const char *filename)
Definition: tzparser.c:437
#define Assert(condition)
Definition: c.h:739
#define newval

◆ check_wal_consistency_checking()

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

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

10959 {
10960  char *rawstring;
10961  List *elemlist;
10962  ListCell *l;
10963  bool newwalconsistency[RM_MAX_ID + 1];
10964 
10965  /* Initialize the array */
10966  MemSet(newwalconsistency, 0, (RM_MAX_ID + 1) * sizeof(bool));
10967 
10968  /* Need a modifiable copy of string */
10969  rawstring = pstrdup(*newval);
10970 
10971  /* Parse string into list of identifiers */
10972  if (!SplitIdentifierString(rawstring, ',', &elemlist))
10973  {
10974  /* syntax error in list */
10975  GUC_check_errdetail("List syntax is invalid.");
10976  pfree(rawstring);
10977  list_free(elemlist);
10978  return false;
10979  }
10980 
10981  foreach(l, elemlist)
10982  {
10983  char *tok = (char *) lfirst(l);
10984  bool found = false;
10985  RmgrId rmid;
10986 
10987  /* Check for 'all'. */
10988  if (pg_strcasecmp(tok, "all") == 0)
10989  {
10990  for (rmid = 0; rmid <= RM_MAX_ID; rmid++)
10991  if (RmgrTable[rmid].rm_mask != NULL)
10992  newwalconsistency[rmid] = true;
10993  found = true;
10994  }
10995  else
10996  {
10997  /*
10998  * Check if the token matches with any individual resource
10999  * manager.
11000  */
11001  for (rmid = 0; rmid <= RM_MAX_ID; rmid++)
11002  {
11003  if (pg_strcasecmp(tok, RmgrTable[rmid].rm_name) == 0 &&
11004  RmgrTable[rmid].rm_mask != NULL)
11005  {
11006  newwalconsistency[rmid] = true;
11007  found = true;
11008  }
11009  }
11010  }
11011 
11012  /* If a valid resource manager is found, check for the next one. */
11013  if (!found)
11014  {
11015  GUC_check_errdetail("Unrecognized key word: \"%s\".", tok);
11016  pfree(rawstring);
11017  list_free(elemlist);
11018  return false;
11019  }
11020  }
11021 
11022  pfree(rawstring);
11023  list_free(elemlist);
11024 
11025  /* assign new value */
11026  *extra = guc_malloc(ERROR, (RM_MAX_ID + 1) * sizeof(bool));
11027  memcpy(*extra, newwalconsistency, (RM_MAX_ID + 1) * sizeof(bool));
11028  return true;
11029 }
#define GUC_check_errdetail
Definition: guc.h:414
char * pstrdup(const char *in)
Definition: mcxt.c:1186
const RmgrData RmgrTable[RM_MAX_ID+1]
Definition: rmgr.c:36
#define MemSet(start, val, len)
Definition: c.h:962
int pg_strcasecmp(const char *s1, const char *s2)
Definition: pgstrcasecmp.c:36
void pfree(void *pointer)
Definition: mcxt.c:1056
#define ERROR
Definition: elog.h:43
bool SplitIdentifierString(char *rawstring, char separator, List **namelist)
Definition: varlena.c:3652
#define RM_MAX_ID
Definition: rmgr.h:33
void(* rm_mask)(char *pagedata, BlockNumber blkno)
uint8 RmgrId
Definition: rmgr.h:11
#define lfirst(lc)
Definition: pg_list.h:190
#define newval
void list_free(List *list)
Definition: list.c:1377
static void * guc_malloc(int elevel, size_t size)
Definition: guc.c:4672
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 6530 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().

6532 {
6533  const struct config_enum_entry *entry;
6534  StringInfoData retstr;
6535  int seplen;
6536 
6537  initStringInfo(&retstr);
6538  appendStringInfoString(&retstr, prefix);
6539 
6540  seplen = strlen(separator);
6541  for (entry = record->options; entry && entry->name; entry++)
6542  {
6543  if (!entry->hidden)
6544  {
6545  appendStringInfoString(&retstr, entry->name);
6546  appendBinaryStringInfo(&retstr, separator, seplen);
6547  }
6548  }
6549 
6550  /*
6551  * All the entries may have been hidden, leaving the string empty if no
6552  * prefix was given. This indicates a broken GUC setup, since there is no
6553  * use for an enum without any values, so we just check to make sure we
6554  * don't write to invalid memory instead of actually trying to do
6555  * something smart with it.
6556  */
6557  if (retstr.len >= seplen)
6558  {
6559  /* Replace final separator */
6560  retstr.data[retstr.len - seplen] = '\0';
6561  retstr.len -= seplen;
6562  }
6563 
6564  appendStringInfoString(&retstr, suffix);
6565 
6566  return retstr.data;
6567 }
Definition: guc.h:164
const struct config_enum_entry * options
Definition: guc_tables.h:246
void appendStringInfoString(StringInfo str, const char *s)
Definition: stringinfo.c:176
void initStringInfo(StringInfo str)
Definition: stringinfo.c:59
const char * name
Definition: guc.h:166
void appendBinaryStringInfo(StringInfo str, const char *data, int datalen)
Definition: stringinfo.c:227
bool hidden
Definition: guc.h:168

◆ config_enum_lookup_by_name()

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

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

6506 {
6507  const struct config_enum_entry *entry;
6508 
6509  for (entry = record->options; entry && entry->name; entry++)
6510  {
6511  if (pg_strcasecmp(value, entry->name) == 0)
6512  {
6513  *retval = entry->val;
6514  return true;
6515  }
6516  }
6517 
6518  *retval = 0;
6519  return false;
6520 }
Definition: guc.h:164
static struct @145 value
int pg_strcasecmp(const char *s1, const char *s2)
Definition: pgstrcasecmp.c:36
const struct config_enum_entry * options
Definition: guc_tables.h:246
int val
Definition: guc.h:167
const char * name
Definition: guc.h:166

◆ config_enum_lookup_by_value()

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

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

6482 {
6483  const struct config_enum_entry *entry;
6484 
6485  for (entry = record->options; entry && entry->name; entry++)
6486  {
6487  if (entry->val == val)
6488  return entry->name;
6489  }
6490 
6491  elog(ERROR, "could not find enum option %d for %s",
6492  val, record->gen.name);
6493  return NULL; /* silence compiler */
6494 }
Definition: guc.h:164
const char * name
Definition: guc_tables.h:149
#define ERROR
Definition: elog.h:43
const struct config_enum_entry * options
Definition: guc_tables.h:246
int val
Definition: guc.h:167
struct config_generic gen
Definition: guc_tables.h:242
const char * name
Definition: guc.h:166
#define elog(elevel,...)
Definition: elog.h:228
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 6187 of file guc.c.

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

Referenced by _ShowOption().

6189 {
6190  const unit_conversion *table;
6191  int i;
6192 
6193  *unit = NULL;
6194 
6195  if (base_unit & GUC_UNIT_MEMORY)
6197  else
6199 
6200  for (i = 0; *table[i].unit; i++)
6201  {
6202  if (base_unit == table[i].base_unit)
6203  {
6204  /*
6205  * Accept the first conversion that divides the value evenly. We
6206  * assume that the conversions for each base unit are ordered from
6207  * greatest unit to the smallest!
6208  */
6209  if (table[i].multiplier <= 1.0 ||
6210  base_value % (int64) table[i].multiplier == 0)
6211  {
6212  *value = (int64) rint(base_value / table[i].multiplier);
6213  *unit = table[i].unit;
6214  break;
6215  }
6216  }
6217  }
6218 
6219  Assert(*unit != NULL);
6220 }
static const unit_conversion time_unit_conversion_table[]
Definition: guc.c:833
static const unit_conversion memory_unit_conversion_table[]
Definition: guc.c:796
static struct @145 value
double rint(double x)
Definition: rint.c:21
#define Assert(condition)
Definition: c.h:739
int i
char unit[MAX_UNIT_LEN+1]
Definition: guc.c:780
#define GUC_UNIT_MEMORY
Definition: guc.h:223

◆ convert_real_from_base_unit()

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

Definition at line 6229 of file guc.c.

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

Referenced by _ShowOption().

6231 {
6232  const unit_conversion *table;
6233  int i;
6234 
6235  *unit = NULL;
6236 
6237  if (base_unit & GUC_UNIT_MEMORY)
6239  else
6241 
6242  for (i = 0; *table[i].unit; i++)
6243  {
6244  if (base_unit == table[i].base_unit)
6245  {
6246  /*
6247  * Accept the first conversion that divides the value evenly; or
6248  * if there is none, use the smallest (last) target unit.
6249  *
6250  * What we actually care about here is whether snprintf with "%g"
6251  * will print the value as an integer, so the obvious test of
6252  * "*value == rint(*value)" is too strict; roundoff error might
6253  * make us choose an unreasonably small unit. As a compromise,
6254  * accept a divisor that is within 1e-8 of producing an integer.
6255  */
6256  *value = base_value / table[i].multiplier;
6257  *unit = table[i].unit;
6258  if (*value > 0 &&
6259  fabs((rint(*value) / *value) - 1.0) <= 1e-8)
6260  break;
6261  }
6262  }
6263 
6264  Assert(*unit != NULL);
6265 }
static const unit_conversion time_unit_conversion_table[]
Definition: guc.c:833
static const unit_conversion memory_unit_conversion_table[]
Definition: guc.c:796
static struct @145 value
double rint(double x)
Definition: rint.c:21
#define Assert(condition)
Definition: c.h:739
double multiplier
Definition: guc.c:783
e
Definition: preproc-init.c:82
int i
char unit[MAX_UNIT_LEN+1]
Definition: guc.c:780
#define GUC_UNIT_MEMORY
Definition: guc.h:223

◆ convert_to_base_unit()

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

Definition at line 6129 of file guc.c.

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

Referenced by parse_int(), and parse_real().

6131 {
6132  char unitstr[MAX_UNIT_LEN + 1];
6133  int unitlen;
6134  const unit_conversion *table;
6135  int i;
6136 
6137  /* extract unit string to compare to table entries */
6138  unitlen = 0;
6139  while (*unit != '\0' && !isspace((unsigned char) *unit) &&
6140  unitlen < MAX_UNIT_LEN)
6141  unitstr[unitlen++] = *(unit++);
6142  unitstr[unitlen] = '\0';
6143  /* allow whitespace after unit */
6144  while (isspace((unsigned char) *unit))
6145  unit++;
6146  if (*unit != '\0')
6147  return false; /* unit too long, or garbage after it */
6148 
6149  /* now search the appropriate table */
6150  if (base_unit & GUC_UNIT_MEMORY)
6152  else
6154 
6155  for (i = 0; *table[i].unit; i++)
6156  {
6157  if (base_unit == table[i].base_unit &&
6158  strcmp(unitstr, table[i].unit) == 0)
6159  {
6160  double cvalue = value * table[i].multiplier;
6161 
6162  /*
6163  * If the user gave a fractional value such as "30.1GB", round it
6164  * off to the nearest multiple of the next smaller unit, if there
6165  * is one.
6166  */
6167  if (*table[i + 1].unit &&
6168  base_unit == table[i + 1].base_unit)
6169  cvalue = rint(cvalue / table[i + 1].multiplier) *
6170  table[i + 1].multiplier;
6171 
6172  *base_value = cvalue;
6173  return true;
6174  }
6175  }
6176  return false;
6177 }
static const unit_conversion time_unit_conversion_table[]
Definition: guc.c:833
static const unit_conversion memory_unit_conversion_table[]
Definition: guc.c:796
#define MAX_UNIT_LEN
Definition: guc.c:776
static struct @145 value
double rint(double x)
Definition: rint.c:21
double multiplier
Definition: guc.c:783
int i
char unit[MAX_UNIT_LEN+1]
Definition: guc.c:780
#define GUC_UNIT_MEMORY
Definition: guc.h:223

◆ define_custom_variable()

static void define_custom_variable ( struct config_generic variable)
static

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

8456 {
8457  const char *name = variable->name;
8458  const char **nameAddr = &name;
8459  struct config_string *pHolder;
8460  struct config_generic **res;
8461 
8462  /*
8463  * See if there's a placeholder by the same name.
8464  */
8465  res = (struct config_generic **) bsearch((void *) &nameAddr,
8466  (void *) guc_variables,
8468  sizeof(struct config_generic *),
8469  guc_var_compare);
8470  if (res == NULL)
8471  {
8472  /*
8473  * No placeholder to replace, so we can just add it ... but first,
8474  * make sure it's initialized to its default value.
8475  */
8476  InitializeOneGUCOption(variable);
8477  add_guc_variable(variable, ERROR);
8478  return;
8479  }
8480 
8481  /*
8482  * This better be a placeholder
8483  */
8484  if (((*res)->flags & GUC_CUSTOM_PLACEHOLDER) == 0)
8485  ereport(ERROR,
8486  (errcode(ERRCODE_INTERNAL_ERROR),
8487  errmsg("attempt to redefine parameter \"%s\"", name)));
8488 
8489  Assert((*res)->vartype == PGC_STRING);
8490  pHolder = (struct config_string *) (*res);
8491 
8492  /*
8493  * First, set the variable to its default value. We must do this even
8494  * though we intend to immediately apply a new value, since it's possible
8495  * that the new value is invalid.
8496  */
8497  InitializeOneGUCOption(variable);
8498 
8499  /*
8500  * Replace the placeholder. We aren't changing the name, so no re-sorting
8501  * is necessary
8502  */
8503  *res = variable;
8504 
8505  /*
8506  * Assign the string value(s) stored in the placeholder to the real
8507  * variable. Essentially, we need to duplicate all the active and stacked
8508  * values, but with appropriate validation and datatype adjustment.
8509  *
8510  * If an assignment fails, we report a WARNING and keep going. We don't
8511  * want to throw ERROR for bad values, because it'd bollix the add-on
8512  * module that's presumably halfway through getting loaded. In such cases
8513  * the default or previous state will become active instead.
8514  */
8515 
8516  /* First, apply the reset value if any */
8517  if (pHolder->reset_val)
8518  (void) set_config_option(name, pHolder->reset_val,
8519  pHolder->gen.reset_scontext,
8520  pHolder->gen.reset_source,
8521  GUC_ACTION_SET, true, WARNING, false);
8522  /* That should not have resulted in stacking anything */
8523  Assert(variable->stack == NULL);
8524 
8525  /* Now, apply current and stacked values, in the order they were stacked */
8526  reapply_stacked_values(variable, pHolder, pHolder->gen.stack,
8527  *(pHolder->variable),
8528  pHolder->gen.scontext, pHolder->gen.source);
8529 
8530  /* Also copy over any saved source-location information */
8531  if (pHolder->gen.sourcefile)
8532  set_config_sourcefile(name, pHolder->gen.sourcefile,
8533  pHolder->gen.sourceline);
8534 
8535  /*
8536  * Free up as much as we conveniently can of the placeholder structure.
8537  * (This neglects any stack items, so it's possible for some memory to be
8538  * leaked. Since this can only happen once per session per variable, it
8539  * doesn't seem worth spending much code on.)
8540  */
8541  set_string_field(pHolder, pHolder->variable, NULL);
8542  set_string_field(pHolder, &pHolder->reset_val, NULL);
8543 
8544  free(pHolder);
8545 }
GucSource source
Definition: guc_tables.h:158
static void static void set_config_sourcefile(const char *name, char *sourcefile, int sourceline)
Definition: guc.c:7516
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:8555
int errcode(int sqlerrcode)
Definition: elog.c:608
GucContext scontext
Definition: guc_tables.h:160
static int guc_var_compare(const void *a, const void *b)
Definition: guc.c:5134
#define ERROR
Definition: elog.h:43
static int num_guc_variables
Definition: guc.c:4631
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:5282
static void set_string_field(struct config_string *conf, char **field, char *newval)
Definition: guc.c:4744
#define ereport(elevel, rest)
Definition: elog.h:141
static struct config_generic ** guc_variables
Definition: guc.c:4628
#define WARNING
Definition: elog.h:40
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:739
#define GUC_CUSTOM_PLACEHOLDER
Definition: guc.h:211
const char * name
Definition: encode.c:521
int errmsg(const char *fmt,...)
Definition: elog.c:822
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:6785
static bool add_guc_variable(struct config_generic *var, int elevel)
Definition: guc.c:4999
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 8636 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().

8646 {
8647  struct config_bool *var;
8648 
8649  var = (struct config_bool *)
8650  init_custom_variable(name, short_desc, long_desc, context, flags,
8651  PGC_BOOL, sizeof(struct config_bool));
8652  var->variable = valueAddr;
8653  var->boot_val = bootValue;
8654  var->reset_val = bootValue;
8655  var->check_hook = check_hook;
8656  var->assign_hook = assign_hook;
8657  var->show_hook = show_hook;
8658  define_custom_variable(&var->gen);
8659 }
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:8395
GucBoolCheckHook check_hook
Definition: guc_tables.h:186
GucShowHook show_hook
Definition: guc_tables.h:188
const char * name
Definition: encode.c:521
bool reset_val
Definition: guc_tables.h:190
static void define_custom_variable(struct config_generic *variable)
Definition: guc.c:8455

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

8758 {
8759  struct config_enum *var;
8760 
8761  var = (struct config_enum *)
8762  init_custom_variable(name, short_desc, long_desc, context, flags,
8763  PGC_ENUM, sizeof(struct config_enum));
8764  var->variable = valueAddr;
8765  var->boot_val = bootValue;
8766  var->reset_val = bootValue;
8767  var->options = options;
8768  var->check_hook = check_hook;
8769  var->assign_hook = assign_hook;
8770  var->show_hook = show_hook;
8771  define_custom_variable(&var->gen);
8772 }
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:8395
GucShowHook show_hook
Definition: guc_tables.h:249
struct config_generic gen
Definition: guc_tables.h:242
const char * name
Definition: encode.c:521
static void define_custom_variable(struct config_generic *variable)
Definition: guc.c:8455

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

8674 {
8675  struct config_int *var;
8676 
8677  var = (struct config_int *)
8678  init_custom_variable(name, short_desc, long_desc, context, flags,
8679  PGC_INT, sizeof(struct config_int));
8680  var->variable = valueAddr;
8681  var->boot_val = bootValue;
8682  var->reset_val = bootValue;
8683  var->min = minValue;
8684  var->max = maxValue;
8685  var->check_hook = check_hook;
8686  var->assign_hook = assign_hook;
8687  var->show_hook = show_hook;
8688  define_custom_variable(&var->gen);
8689 }
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:8395
const char * name
Definition: encode.c:521
static void define_custom_variable(struct config_generic *variable)
Definition: guc.c:8455
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 8692 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().

8704 {
8705  struct config_real *var;
8706 
8707  var = (struct config_real *)
8708  init_custom_variable(name, short_desc, long_desc, context, flags,
8709  PGC_REAL, sizeof(struct config_real));
8710  var->variable = valueAddr;
8711  var->boot_val = bootValue;
8712  var->reset_val = bootValue;
8713  var->min = minValue;
8714  var->max = maxValue;
8715  var->check_hook = check_hook;
8716  var->assign_hook = assign_hook;
8717  var->show_hook = show_hook;
8718  define_custom_variable(&var->gen);
8719 }
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:8395
double max
Definition: guc_tables.h:217
double boot_val
Definition: guc_tables.h:215
const char * name
Definition: encode.c:521
double min
Definition: guc_tables.h:216
static void define_custom_variable(struct config_generic *variable)
Definition: guc.c:8455
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 8722 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().

8732 {
8733  struct config_string *var;
8734 
8735  var = (struct config_string *)
8736  init_custom_variable(name, short_desc, long_desc, context, flags,
8737  PGC_STRING, sizeof(struct config_string));
8738  var->variable = valueAddr;
8739  var->boot_val = bootValue;
8740  var->check_hook = check_hook;
8741  var->assign_hook = assign_hook;
8742  var->show_hook = show_hook;
8743  define_custom_variable(&var->gen);
8744 }
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:8395
struct config_generic gen
Definition: guc_tables.h:228
GucStringAssignHook assign_hook
Definition: guc_tables.h:233
const char * name
Definition: encode.c:521
static void define_custom_variable(struct config_generic *variable)
Definition: guc.c:8455

◆ discard_stack_value()

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

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

4860 {
4861  switch (gconf->vartype)
4862  {
4863  case PGC_BOOL:
4864  case PGC_INT:
4865  case PGC_REAL:
4866  case PGC_ENUM:
4867  /* no need to do anything */
4868  break;
4869  case PGC_STRING:
4870  set_string_field((struct config_string *) gconf,
4871  &(val->val.stringval),
4872  NULL);
4873  break;
4874  }
4875  set_extra_field(gconf, &(val->extra), NULL);
4876 }
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:4805
static void set_string_field(struct config_string *conf, char **field, char *newval)
Definition: guc.c:4744
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 10097 of file guc.c.

References elog, ERROR, and vsnprintf.

Referenced by serialize_variable().

10098 {
10099  va_list vargs;
10100  int n;
10101 
10102  if (*maxbytes <= 0)
10103  elog(ERROR, "not enough space to serialize GUC state");
10104 
10105  va_start(vargs, fmt);
10106  n = vsnprintf(*destptr, *maxbytes, fmt, vargs);
10107  va_end(vargs);
10108 
10109  if (n < 0)
10110  {
10111  /* Shouldn't happen. Better show errno description. */
10112  elog(ERROR, "vsnprintf failed: %m with format string \"%s\"", fmt);
10113  }
10114  if (n >= *maxbytes)
10115  {
10116  /* This shouldn't happen either, really. */
10117  elog(ERROR, "not enough space to serialize GUC state");
10118  }
10119 
10120  /* Shift the destptr ahead of the null terminator */
10121  *destptr += n + 1;
10122  *maxbytes -= n + 1;
10123 }
#define ERROR
Definition: elog.h:43
#define vsnprintf
Definition: port.h:191
#define elog(elevel,...)
Definition: elog.h:228

◆ do_serialize_binary()

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

Definition at line 10127 of file guc.c.

References elog, and ERROR.

Referenced by serialize_variable().

10128 {
10129  if (valsize > *maxbytes)
10130  elog(ERROR, "not enough space to serialize GUC state");
10131 
10132  memcpy(*destptr, val, valsize);
10133  *destptr += valsize;
10134  *maxbytes -= valsize;
10135 }
#define ERROR
Definition: elog.h:43
#define elog(elevel,...)
Definition: elog.h:228
long val
Definition: informix.c:664

◆ EmitWarningsOnPlaceholders()

void EmitWarningsOnPlaceholders ( const char *  className)

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

8776 {
8777  int classLen = strlen(className);
8778  int i;
8779 
8780  for (i = 0; i < num_guc_variables; i++)
8781  {
8782  struct config_generic *var = guc_variables[i];
8783 
8784  if ((var->flags & GUC_CUSTOM_PLACEHOLDER) != 0 &&
8785  strncmp(className, var->name, classLen) == 0 &&
8786  var->name[classLen] == GUC_QUALIFIER_SEPARATOR)
8787  {
8788  ereport(WARNING,
8789  (errcode(ERRCODE_UNDEFINED_OBJECT),
8790  errmsg("unrecognized configuration parameter \"%s\"",
8791  var->name)));
8792  }
8793  }
8794 }
const char * name
Definition: guc_tables.h:149
int errcode(int sqlerrcode)
Definition: elog.c:608
#define GUC_QUALIFIER_SEPARATOR
Definition: guc.h:199
static int num_guc_variables
Definition: guc.c:4631
#define ereport(elevel, rest)
Definition: elog.h:141
static struct config_generic ** guc_variables
Definition: guc.c:4628
#define WARNING
Definition: elog.h:40
#define GUC_CUSTOM_PLACEHOLDER
Definition: guc.h:211
int errmsg(const char *fmt,...)
Definition: elog.c:822
int i

◆ estimate_variable_size()

static Size estimate_variable_size ( struct config_generic gconf)
static

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

9977 {
9978  Size size;
9979  Size valsize = 0;
9980 
9981  if (can_skip_gucvar(gconf))
9982  return 0;
9983 
9984  /* Name, plus trailing zero byte. */
9985  size = strlen(gconf->name) + 1;
9986 
9987  /* Get the maximum display length of the GUC value. */
9988  switch (gconf->vartype)
9989  {
9990  case PGC_BOOL:
9991  {
9992  valsize = 5; /* max(strlen('true'), strlen('false')) */
9993  }
9994  break;
9995 
9996  case PGC_INT:
9997  {
9998  struct config_int *conf = (struct config_int *) gconf;
9999 
10000  /*
10001  * Instead of getting the exact display length, use max
10002  * length. Also reduce the max length for typical ranges of
10003  * small values. Maximum value is 2147483647, i.e. 10 chars.
10004  * Include one byte for sign.
10005  */
10006  if (Abs(*conf->variable) < 1000)
10007  valsize = 3 + 1;
10008  else
10009  valsize = 10 + 1;
10010  }
10011  break;
10012 
10013  case PGC_REAL:
10014  {
10015  /*
10016  * We are going to print it with %e with REALTYPE_PRECISION
10017  * fractional digits. Account for sign, leading digit,
10018  * decimal point, and exponent with up to 3 digits. E.g.
10019  * -3.99329042340000021e+110
10020  */
10021  valsize = 1 + 1 + 1 + REALTYPE_PRECISION + 5;
10022  }
10023  break;
10024 
10025  case PGC_STRING:
10026  {
10027  struct config_string *conf = (struct config_string *) gconf;
10028 
10029  /*
10030  * If the value is NULL, we transmit it as an empty string.
10031  * Although this is not physically the same value, GUC
10032  * generally treats a NULL the same as empty string.
10033  */
10034  if (*conf->variable)
10035  valsize = strlen(*conf->variable);
10036  else
10037  valsize = 0;
10038  }
10039  break;
10040 
10041  case PGC_ENUM:
10042  {
10043  struct config_enum *conf = (struct config_enum *) gconf;
10044 
10045  valsize = strlen(config_enum_lookup_by_value(conf, *conf->variable));
10046  }
10047  break;
10048  }
10049 
10050  /* Allow space for terminating zero-byte for value */
10051  size = add_size(size, valsize + 1);
10052 
10053  if (gconf->sourcefile)
10054  size = add_size(size, strlen(gconf->sourcefile));
10055 
10056  /* Allow space for terminating zero-byte for sourcefile */
10057  size = add_size(size, 1);
10058 
10059  /* Include line whenever file is nonempty. */
10060  if (gconf->sourcefile && gconf->sourcefile[0])
10061  size = add_size(size, sizeof(gconf->sourceline));
10062 
10063  size = add_size(size, sizeof(gconf->source));
10064  size = add_size(size, sizeof(gconf->scontext));
10065 
10066  return size;
10067 }
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:6481
GucContext scontext
Definition: guc_tables.h:160
#define Abs(x)
Definition: c.h:917
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:9962
#define REALTYPE_PRECISION
Definition: guc.c:117
enum config_type vartype
Definition: guc_tables.h:156
Size add_size(Size s1, Size s2)
Definition: shmem.c:475
size_t Size
Definition: c.h:467

◆ EstimateGUCStateSpace()

Size EstimateGUCStateSpace ( void  )

Definition at line 10074 of file guc.c.

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

Referenced by InitializeParallelDSM().

10075 {
10076  Size size;
10077  int i;
10078 
10079  /* Add space reqd for saving the data size of the guc state */
10080  size = sizeof(Size);
10081 
10082  /* Add up the space needed for each GUC variable */
10083  for (i = 0; i < num_guc_variables; i++)
10084  size = add_size(size,
10086 
10087  return size;
10088 }
static int num_guc_variables
Definition: guc.c:4631
static struct config_generic ** guc_variables
Definition: guc.c:4628
Size add_size(Size s1, Size s2)
Definition: shmem.c:475
size_t Size
Definition: c.h:467
static Size estimate_variable_size(struct config_generic *gconf)
Definition: guc.c:9976
int i

◆ ExecSetVariableStmt()

void ExecSetVariableStmt ( VariableSetStmt stmt,
bool  isTopLevel 
)

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

8184 {
8186 
8187  /*
8188  * Workers synchronize these parameters at the start of the parallel
8189  * operation; then, we block SET during the operation.
8190  */
8191  if (IsInParallelMode())
8192  ereport(ERROR,
8193  (errcode(ERRCODE_INVALID_TRANSACTION_STATE),
8194  errmsg("cannot set parameters during a parallel operation")));
8195 
8196  switch (stmt->kind)
8197  {
8198  case VAR_SET_VALUE:
8199  case VAR_SET_CURRENT:
8200  if (stmt->is_local)
8201  WarnNoTransactionBlock(isTopLevel, "SET LOCAL");
8202  (void) set_config_option(stmt->name,
8203  ExtractSetVariableArgs(stmt),
8205  PGC_S_SESSION,
8206  action, true, 0, false);
8207  break;
8208  case VAR_SET_MULTI:
8209 
8210  /*
8211  * Special-case SQL syntaxes. The TRANSACTION and SESSION
8212  * CHARACTERISTICS cases effectively set more than one variable
8213  * per statement. TRANSACTION SNAPSHOT only takes one argument,
8214  * but we put it here anyway since it's a special case and not
8215  * related to any GUC variable.
8216  */
8217  if (strcmp(stmt->name, "TRANSACTION") == 0)
8218  {
8219  ListCell *head;
8220 
8221  WarnNoTransactionBlock(isTopLevel, "SET TRANSACTION");
8222 
8223  foreach(head, stmt->args)
8224  {
8225  DefElem *item = (DefElem *) lfirst(head);
8226 
8227  if (strcmp(item->defname, "transaction_isolation") == 0)
8228  SetPGVariable("transaction_isolation",
8229  list_make1(item->arg), stmt->is_local);
8230  else if (strcmp(item->defname, "transaction_read_only") == 0)
8231  SetPGVariable("transaction_read_only",
8232  list_make1(item->arg), stmt->is_local);
8233  else if (strcmp(item->defname, "transaction_deferrable") == 0)
8234  SetPGVariable("transaction_deferrable",
8235  list_make1(item->arg), stmt->is_local);
8236  else
8237  elog(ERROR, "unexpected SET TRANSACTION element: %s",
8238  item->defname);
8239  }
8240  }
8241  else if (strcmp(stmt->name, "SESSION CHARACTERISTICS") == 0)
8242  {
8243  ListCell *head;
8244 
8245  foreach(head, stmt->args)
8246  {
8247  DefElem *item = (DefElem *) lfirst(head);
8248 
8249  if (strcmp(item->defname, "transaction_isolation") == 0)
8250  SetPGVariable("default_transaction_isolation",
8251  list_make1(item->arg), stmt->is_local);
8252  else if (strcmp(item->defname, "transaction_read_only") == 0)
8253  SetPGVariable("default_transaction_read_only",
8254  list_make1(item->arg), stmt->is_local);
8255  else if (strcmp(item->defname, "transaction_deferrable") == 0)
8256  SetPGVariable("default_transaction_deferrable",
8257  list_make1(item->arg), stmt->is_local);
8258  else
8259  elog(ERROR, "unexpected SET SESSION element: %s",
8260  item->defname);
8261  }
8262  }
8263  else if (strcmp(stmt->name, "TRANSACTION SNAPSHOT") == 0)
8264  {
8265  A_Const *con = linitial_node(A_Const, stmt->args);
8266 
8267  if (stmt->is_local)
8268  ereport(ERROR,
8269  (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
8270  errmsg("SET LOCAL TRANSACTION SNAPSHOT is not implemented")));
8271 
8272  WarnNoTransactionBlock(isTopLevel, "SET TRANSACTION");
8273  Assert(nodeTag(&con->val) == T_String);
8274  ImportSnapshot(strVal(&con->val));
8275  }
8276  else
8277  elog(ERROR, "unexpected SET MULTI element: %s",
8278  stmt->name);
8279  break;
8280  case VAR_SET_DEFAULT:
8281  if (stmt->is_local)
8282  WarnNoTransactionBlock(isTopLevel, "SET LOCAL");
8283  /* fall through */
8284  case VAR_RESET:
8285  if (strcmp(stmt->name, "transaction_isolation") == 0)
8286  WarnNoTransactionBlock(isTopLevel, "RESET TRANSACTION");
8287 
8288  (void) set_config_option(stmt->name,
8289  NULL,
8291  PGC_S_SESSION,
8292  action, true, 0, false);
8293  break;
8294  case VAR_RESET_ALL:
8295  ResetAllOptions();
8296  break;
8297  }
8298 }
void ImportSnapshot(const char *idstr)
Definition: snapmgr.c:1462
VariableSetKind kind
Definition: parsenodes.h:2019
void WarnNoTransactionBlock(bool isTopLevel, const char *stmtType)
Definition: xact.c:3391
#define strVal(v)
Definition: value.h:54
int errcode(int sqlerrcode)
Definition: elog.c:608
bool superuser(void)
Definition: superuser.c:46
#define linitial_node(type, l)
Definition: pg_list.h:198
GucAction
Definition: guc.h:191
#define list_make1(x1)
Definition: pg_list.h:227
bool IsInParallelMode(void)
Definition: xact.c:996
#define ERROR
Definition: elog.h:43
Definition: guc.h:75
void ResetAllOptions(void)
Definition: guc.c:5577
#define ereport(elevel, rest)
Definition: elog.h:141
Node * arg
Definition: parsenodes.h:731
#define Assert(condition)
Definition: c.h:739
#define lfirst(lc)
Definition: pg_list.h:190
#define nodeTag(nodeptr)
Definition: nodes.h:530
int errmsg(const char *fmt,...)
Definition: elog.c:822
#define elog(elevel,...)
Definition: elog.h:228
char * defname
Definition: parsenodes.h:730
char * ExtractSetVariableArgs(VariableSetStmt *stmt)
Definition: guc.c:8307
Value val
Definition: parsenodes.h:288
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:6785
void SetPGVariable(const char *name, List *args, bool is_local)
Definition: guc.c:8327

◆ extra_field_used()

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

Definition at line 4760 of file guc.c.

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

Referenced by set_config_option(), and set_extra_field().

4761 {
4762  GucStack *stack;
4763 
4764  if (extra == gconf->extra)
4765  return true;
4766  switch (gconf->vartype)
4767  {
4768  case PGC_BOOL:
4769  if (extra == ((struct config_bool *) gconf)->reset_extra)
4770  return true;
4771  break;
4772  case PGC_INT:
4773  if (extra == ((struct config_int *) gconf)->reset_extra)
4774  return true;
4775  break;
4776  case PGC_REAL:
4777  if (extra == ((struct config_real *) gconf)->reset_extra)
4778  return true;
4779  break;
4780  case PGC_STRING:
4781  if (extra == ((struct config_string *) gconf)->reset_extra)
4782  return true;
4783