PostgreSQL Source Code  git master
guc.h File Reference
#include "nodes/parsenodes.h"
#include "tcop/dest.h"
#include "utils/array.h"
Include dependency graph for guc.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  ConfigVariable
 
struct  config_enum_entry
 

Macros

#define MAX_KILOBYTES   (INT_MAX / 1024)
 
#define PG_AUTOCONF_FILENAME   "postgresql.auto.conf"
 
#define GUC_QUALIFIER_SEPARATOR   '.'
 
#define GUC_LIST_INPUT   0x0001 /* input can be list format */
 
#define GUC_LIST_QUOTE   0x0002 /* double-quote list elements */
 
#define GUC_NO_SHOW_ALL   0x0004 /* exclude from SHOW ALL */
 
#define GUC_NO_RESET_ALL   0x0008 /* exclude from RESET ALL */
 
#define GUC_REPORT   0x0010 /* auto-report changes to client */
 
#define GUC_NOT_IN_SAMPLE   0x0020 /* not in postgresql.conf.sample */
 
#define GUC_DISALLOW_IN_FILE   0x0040 /* can't set in postgresql.conf */
 
#define GUC_CUSTOM_PLACEHOLDER   0x0080 /* placeholder for custom variable */
 
#define GUC_SUPERUSER_ONLY   0x0100 /* show only to superusers */
 
#define GUC_IS_NAME   0x0200 /* limit string to NAMEDATALEN-1 */
 
#define GUC_NOT_WHILE_SEC_REST   0x0400 /* can't set if security restricted */
 
#define GUC_DISALLOW_IN_AUTO_FILE
 
#define GUC_UNIT_KB   0x1000 /* value is in kilobytes */
 
#define GUC_UNIT_BLOCKS   0x2000 /* value is in blocks */
 
#define GUC_UNIT_XBLOCKS   0x3000 /* value is in xlog blocks */
 
#define GUC_UNIT_MB   0x4000 /* value is in megabytes */
 
#define GUC_UNIT_BYTE   0x8000 /* value is in bytes */
 
#define GUC_UNIT_MEMORY   0xF000 /* mask for size-related units */
 
#define GUC_UNIT_MS   0x10000 /* value is in milliseconds */
 
#define GUC_UNIT_S   0x20000 /* value is in seconds */
 
#define GUC_UNIT_MIN   0x30000 /* value is in minutes */
 
#define GUC_UNIT_TIME   0xF0000 /* mask for time-related units */
 
#define GUC_EXPLAIN   0x100000 /* include in explain */
 
#define GUC_RUNTIME_COMPUTED   0x200000
 
#define GUC_UNIT   (GUC_UNIT_MEMORY | GUC_UNIT_TIME)
 
#define GUC_check_errmsg
 
#define GUC_check_errdetail
 
#define GUC_check_errhint
 

Typedefs

typedef struct ConfigVariable ConfigVariable
 
typedef bool(* GucBoolCheckHook) (bool *newval, void **extra, GucSource source)
 
typedef bool(* GucIntCheckHook) (int *newval, void **extra, GucSource source)
 
typedef bool(* GucRealCheckHook) (double *newval, void **extra, GucSource source)
 
typedef bool(* GucStringCheckHook) (char **newval, void **extra, GucSource source)
 
typedef bool(* GucEnumCheckHook) (int *newval, void **extra, GucSource source)
 
typedef void(* GucBoolAssignHook) (bool newval, void *extra)
 
typedef void(* GucIntAssignHook) (int newval, void *extra)
 
typedef void(* GucRealAssignHook) (double newval, void *extra)
 
typedef void(* GucStringAssignHook) (const char *newval, void *extra)
 
typedef void(* GucEnumAssignHook) (int newval, void *extra)
 
typedef const char *(* GucShowHook) (void)
 

Enumerations

enum  GucContext {
  PGC_INTERNAL , PGC_POSTMASTER , PGC_SIGHUP , PGC_SU_BACKEND ,
  PGC_BACKEND , PGC_SUSET , PGC_USERSET
}
 
enum  GucSource {
  PGC_S_DEFAULT , PGC_S_DYNAMIC_DEFAULT , PGC_S_ENV_VAR , PGC_S_FILE ,
  PGC_S_ARGV , PGC_S_GLOBAL , PGC_S_DATABASE , PGC_S_USER ,
  PGC_S_DATABASE_USER , PGC_S_CLIENT , PGC_S_OVERRIDE , PGC_S_INTERACTIVE ,
  PGC_S_TEST , PGC_S_SESSION
}
 
enum  GucAction { GUC_ACTION_SET , GUC_ACTION_LOCAL , GUC_ACTION_SAVE }
 

Functions

bool ParseConfigFile (const char *config_file, bool strict, const char *calling_file, int calling_lineno, int depth, int elevel, ConfigVariable **head_p, ConfigVariable **tail_p)
 
bool ParseConfigFp (FILE *fp, const char *config_file, int depth, int elevel, ConfigVariable **head_p, ConfigVariable **tail_p)
 
bool ParseConfigDirectory (const char *includedir, const char *calling_file, int calling_lineno, int depth, int elevel, ConfigVariable **head_p, ConfigVariable **tail_p)
 
void FreeConfigVariables (ConfigVariable *list)
 
char * DeescapeQuotedString (const char *s)
 
void SetConfigOption (const char *name, const char *value, GucContext context, GucSource source)
 
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)
 
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)
 
void ProcessConfigFile (GucContext context)
 
void InitializeGUCOptions (void)
 
bool SelectConfigFiles (const char *userDoption, const char *progname)
 
void ResetAllOptions (void)
 
void AtStart_GUC (void)
 
int NewGUCNestLevel (void)
 
void AtEOXact_GUC (bool isCommit, int nestLevel)
 
void BeginReportingGUCOptions (void)
 
void ReportChangedGUCOptions (void)
 
void ParseLongOption (const char *string, char **name, char **value)
 
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)
 
int set_config_option (const char *name, const char *value, GucContext context, GucSource source, GucAction action, bool changeVal, int elevel, bool is_reload)
 
void AlterSystemSetConfigFile (AlterSystemStmt *altersysstmt)
 
char * GetConfigOptionByName (const char *name, const char **varname, bool missing_ok)
 
void GetConfigOptionByNum (int varnum, const char **values, bool *noshow)
 
int GetNumConfigOptions (void)
 
void SetPGVariable (const char *name, List *args, bool is_local)
 
void GetPGVariable (const char *name, DestReceiver *dest)
 
TupleDesc GetPGVariableResultDesc (const char *name)
 
void ExecSetVariableStmt (VariableSetStmt *stmt, bool isTopLevel)
 
char * ExtractSetVariableArgs (VariableSetStmt *stmt)
 
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)
 
Size EstimateGUCStateSpace (void)
 
void SerializeGUCState (Size maxsize, char *start_address)
 
void RestoreGUCState (void *gucstate)
 
void GUC_check_errcode (int sqlerrcode)
 
bool check_default_tablespace (char **newval, void **extra, GucSource source)
 
bool check_temp_tablespaces (char **newval, void **extra, GucSource source)
 
void assign_temp_tablespaces (const char *newval, void *extra)
 
bool check_search_path (char **newval, void **extra, GucSource source)
 
void assign_search_path (const char *newval, void *extra)
 
bool check_wal_buffers (int *newval, void **extra, GucSource source)
 
void assign_xlog_sync_method (int new_sync_method, void *extra)
 

Variables

bool Debug_print_plan
 
bool Debug_print_parse
 
bool Debug_print_rewritten
 
bool Debug_pretty_print
 
bool log_parser_stats
 
bool log_planner_stats
 
bool log_executor_stats
 
bool log_statement_stats
 
bool log_btree_build_stats
 
PGDLLIMPORT bool check_function_bodies
 
bool session_auth_is_superuser
 
bool log_duration
 
int log_parameter_max_length
 
int log_parameter_max_length_on_error
 
int log_min_error_statement
 
PGDLLIMPORT int log_min_messages
 
PGDLLIMPORT int client_min_messages
 
int log_min_duration_sample
 
int log_min_duration_statement
 
int log_temp_files
 
double log_statement_sample_rate
 
double log_xact_sample_rate
 
char * backtrace_functions
 
char * backtrace_symbol_list
 
int temp_file_limit
 
int num_temp_buffers
 
char * cluster_name
 
PGDLLIMPORT char * ConfigFileName
 
char * HbaFileName
 
char * IdentFileName
 
char * external_pid_file
 
PGDLLIMPORT char * application_name
 
int tcp_keepalives_idle
 
int tcp_keepalives_interval
 
int tcp_keepalives_count
 
int tcp_user_timeout
 
PGDLLIMPORT char * GUC_check_errmsg_string
 
PGDLLIMPORT char * GUC_check_errdetail_string
 
PGDLLIMPORT char * GUC_check_errhint_string
 

Macro Definition Documentation

◆ GUC_check_errdetail

#define GUC_check_errdetail
Value:
GUC_check_errdetail_string = format_elog_string
void pre_format_elog_string(int errnumber, const char *domain)
Definition: elog.c:1467
char * format_elog_string(const char *fmt,...)
Definition: elog.c:1476
#define TEXTDOMAIN
Definition: elog.h:146

Definition at line 421 of file guc.h.

◆ GUC_check_errhint

#define GUC_check_errhint
Value:
GUC_check_errhint_string = format_elog_string

Definition at line 425 of file guc.h.

◆ GUC_check_errmsg

#define GUC_check_errmsg
Value:
GUC_check_errmsg_string = format_elog_string

Definition at line 417 of file guc.h.

◆ GUC_CUSTOM_PLACEHOLDER

#define GUC_CUSTOM_PLACEHOLDER   0x0080 /* placeholder for custom variable */

Definition at line 211 of file guc.h.

◆ GUC_DISALLOW_IN_AUTO_FILE

#define GUC_DISALLOW_IN_AUTO_FILE
Value:
0x0800 /* can't set in
* PG_AUTOCONF_FILENAME */

Definition at line 215 of file guc.h.

◆ GUC_DISALLOW_IN_FILE

#define GUC_DISALLOW_IN_FILE   0x0040 /* can't set in postgresql.conf */

Definition at line 210 of file guc.h.

◆ GUC_EXPLAIN

#define GUC_EXPLAIN   0x100000 /* include in explain */

Definition at line 229 of file guc.h.

◆ GUC_IS_NAME

#define GUC_IS_NAME   0x0200 /* limit string to NAMEDATALEN-1 */

Definition at line 213 of file guc.h.

◆ GUC_LIST_INPUT

#define GUC_LIST_INPUT   0x0001 /* input can be list format */

Definition at line 204 of file guc.h.

◆ GUC_LIST_QUOTE

#define GUC_LIST_QUOTE   0x0002 /* double-quote list elements */

Definition at line 205 of file guc.h.

◆ GUC_NO_RESET_ALL

#define GUC_NO_RESET_ALL   0x0008 /* exclude from RESET ALL */

Definition at line 207 of file guc.h.

◆ GUC_NO_SHOW_ALL

#define GUC_NO_SHOW_ALL   0x0004 /* exclude from SHOW ALL */

Definition at line 206 of file guc.h.

◆ GUC_NOT_IN_SAMPLE

#define GUC_NOT_IN_SAMPLE   0x0020 /* not in postgresql.conf.sample */

Definition at line 209 of file guc.h.

◆ GUC_NOT_WHILE_SEC_REST

#define GUC_NOT_WHILE_SEC_REST   0x0400 /* can't set if security restricted */

Definition at line 214 of file guc.h.

◆ GUC_QUALIFIER_SEPARATOR

#define GUC_QUALIFIER_SEPARATOR   '.'

Definition at line 199 of file guc.h.

◆ GUC_REPORT

#define GUC_REPORT   0x0010 /* auto-report changes to client */

Definition at line 208 of file guc.h.

◆ GUC_RUNTIME_COMPUTED

#define GUC_RUNTIME_COMPUTED   0x200000

Definition at line 235 of file guc.h.

◆ GUC_SUPERUSER_ONLY

#define GUC_SUPERUSER_ONLY   0x0100 /* show only to superusers */

Definition at line 212 of file guc.h.

◆ GUC_UNIT

#define GUC_UNIT   (GUC_UNIT_MEMORY | GUC_UNIT_TIME)

Definition at line 237 of file guc.h.

◆ GUC_UNIT_BLOCKS

#define GUC_UNIT_BLOCKS   0x2000 /* value is in blocks */

Definition at line 218 of file guc.h.

◆ GUC_UNIT_BYTE

#define GUC_UNIT_BYTE   0x8000 /* value is in bytes */

Definition at line 221 of file guc.h.

◆ GUC_UNIT_KB

#define GUC_UNIT_KB   0x1000 /* value is in kilobytes */

Definition at line 217 of file guc.h.

◆ GUC_UNIT_MB

#define GUC_UNIT_MB   0x4000 /* value is in megabytes */

Definition at line 220 of file guc.h.

◆ GUC_UNIT_MEMORY

#define GUC_UNIT_MEMORY   0xF000 /* mask for size-related units */

Definition at line 222 of file guc.h.

◆ GUC_UNIT_MIN

#define GUC_UNIT_MIN   0x30000 /* value is in minutes */

Definition at line 226 of file guc.h.

◆ GUC_UNIT_MS

#define GUC_UNIT_MS   0x10000 /* value is in milliseconds */

Definition at line 224 of file guc.h.

◆ GUC_UNIT_S

#define GUC_UNIT_S   0x20000 /* value is in seconds */

Definition at line 225 of file guc.h.

◆ GUC_UNIT_TIME

#define GUC_UNIT_TIME   0xF0000 /* mask for time-related units */

Definition at line 227 of file guc.h.

◆ GUC_UNIT_XBLOCKS

#define GUC_UNIT_XBLOCKS   0x3000 /* value is in xlog blocks */

Definition at line 219 of file guc.h.

◆ MAX_KILOBYTES

#define MAX_KILOBYTES   (INT_MAX / 1024)

Definition at line 26 of file guc.h.

◆ PG_AUTOCONF_FILENAME

#define PG_AUTOCONF_FILENAME   "postgresql.auto.conf"

Definition at line 34 of file guc.h.

Typedef Documentation

◆ ConfigVariable

◆ GucBoolAssignHook

typedef void(* GucBoolAssignHook) (bool newval, void *extra)

Definition at line 180 of file guc.h.

◆ GucBoolCheckHook

typedef bool(* GucBoolCheckHook) (bool *newval, void **extra, GucSource source)

Definition at line 174 of file guc.h.

◆ GucEnumAssignHook

typedef void(* GucEnumAssignHook) (int newval, void *extra)

Definition at line 184 of file guc.h.

◆ GucEnumCheckHook

typedef bool(* GucEnumCheckHook) (int *newval, void **extra, GucSource source)

Definition at line 178 of file guc.h.

◆ GucIntAssignHook

typedef void(* GucIntAssignHook) (int newval, void *extra)

Definition at line 181 of file guc.h.

◆ GucIntCheckHook

typedef bool(* GucIntCheckHook) (int *newval, void **extra, GucSource source)

Definition at line 175 of file guc.h.

◆ GucRealAssignHook

typedef void(* GucRealAssignHook) (double newval, void *extra)

Definition at line 182 of file guc.h.

◆ GucRealCheckHook

typedef bool(* GucRealCheckHook) (double *newval, void **extra, GucSource source)

Definition at line 176 of file guc.h.

◆ GucShowHook

typedef const char*(* GucShowHook) (void)

Definition at line 186 of file guc.h.

◆ GucStringAssignHook

typedef void(* GucStringAssignHook) (const char *newval, void *extra)

Definition at line 183 of file guc.h.

◆ GucStringCheckHook

typedef bool(* GucStringCheckHook) (char **newval, void **extra, GucSource source)

Definition at line 177 of file guc.h.

Enumeration Type Documentation

◆ GucAction

enum GucAction
Enumerator
GUC_ACTION_SET 
GUC_ACTION_LOCAL 
GUC_ACTION_SAVE 

Definition at line 191 of file guc.h.

192 {
193  /* Types of set_config_option actions */
194  GUC_ACTION_SET, /* regular SET command */
195  GUC_ACTION_LOCAL, /* SET LOCAL command */
196  GUC_ACTION_SAVE /* function SET option, or temp assignment */
197 } GucAction;
GucAction
Definition: guc.h:192
@ GUC_ACTION_SAVE
Definition: guc.h:196
@ GUC_ACTION_SET
Definition: guc.h:194
@ GUC_ACTION_LOCAL
Definition: guc.h:195

◆ GucContext

enum GucContext
Enumerator
PGC_INTERNAL 
PGC_POSTMASTER 
PGC_SIGHUP 
PGC_SU_BACKEND 
PGC_BACKEND 
PGC_SUSET 
PGC_USERSET 

Definition at line 68 of file guc.h.

69 {
72  PGC_SIGHUP,
75  PGC_SUSET,
77 } GucContext;
GucContext
Definition: guc.h:69
@ PGC_SUSET
Definition: guc.h:75
@ PGC_INTERNAL
Definition: guc.h:70
@ PGC_USERSET
Definition: guc.h:76
@ PGC_SU_BACKEND
Definition: guc.h:73
@ PGC_POSTMASTER
Definition: guc.h:71
@ PGC_SIGHUP
Definition: guc.h:72
@ PGC_BACKEND
Definition: guc.h:74

◆ GucSource

enum GucSource
Enumerator
PGC_S_DEFAULT 
PGC_S_DYNAMIC_DEFAULT 
PGC_S_ENV_VAR 
PGC_S_FILE 
PGC_S_ARGV 
PGC_S_GLOBAL 
PGC_S_DATABASE 
PGC_S_USER 
PGC_S_DATABASE_USER 
PGC_S_CLIENT 
PGC_S_OVERRIDE 
PGC_S_INTERACTIVE 
PGC_S_TEST 
PGC_S_SESSION 

Definition at line 104 of file guc.h.

105 {
106  PGC_S_DEFAULT, /* hard-wired default ("boot_val") */
107  PGC_S_DYNAMIC_DEFAULT, /* default computed during initialization */
108  PGC_S_ENV_VAR, /* postmaster environment variable */
109  PGC_S_FILE, /* postgresql.conf */
110  PGC_S_ARGV, /* postmaster command line */
111  PGC_S_GLOBAL, /* global in-database setting */
112  PGC_S_DATABASE, /* per-database setting */
113  PGC_S_USER, /* per-user setting */
114  PGC_S_DATABASE_USER, /* per-user-and-database setting */
115  PGC_S_CLIENT, /* from client connection request */
116  PGC_S_OVERRIDE, /* special case to forcibly set default */
117  PGC_S_INTERACTIVE, /* dividing line for error reporting */
118  PGC_S_TEST, /* test per-database or per-user setting */
119  PGC_S_SESSION /* SET command */
120 } GucSource;
GucSource
Definition: guc.h:105
@ PGC_S_DEFAULT
Definition: guc.h:106
@ PGC_S_DYNAMIC_DEFAULT
Definition: guc.h:107
@ PGC_S_FILE
Definition: guc.h:109
@ PGC_S_GLOBAL
Definition: guc.h:111
@ PGC_S_DATABASE
Definition: guc.h:112
@ PGC_S_OVERRIDE
Definition: guc.h:116
@ PGC_S_ARGV
Definition: guc.h:110
@ PGC_S_SESSION
Definition: guc.h:119
@ PGC_S_CLIENT
Definition: guc.h:115
@ PGC_S_DATABASE_USER
Definition: guc.h:114
@ PGC_S_ENV_VAR
Definition: guc.h:108
@ PGC_S_USER
Definition: guc.h:113
@ PGC_S_TEST
Definition: guc.h:118
@ PGC_S_INTERACTIVE
Definition: guc.h:117

Function Documentation

◆ AlterSystemSetConfigFile()

void AlterSystemSetConfigFile ( AlterSystemStmt altersysstmt)

Definition at line 8533 of file guc.c.

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

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

◆ assign_search_path()

void assign_search_path ( const char *  newval,
void *  extra 
)

Definition at line 4353 of file namespace.c.

4354 {
4355  /*
4356  * We mark the path as needing recomputation, but don't do anything until
4357  * it's needed. This avoids trying to do database access during GUC
4358  * initialization, or outside a transaction.
4359  */
4360  baseSearchPathValid = false;
4361 }
static bool baseSearchPathValid
Definition: namespace.c:160

References baseSearchPathValid.

◆ assign_temp_tablespaces()

void assign_temp_tablespaces ( const char *  newval,
void *  extra 
)

Definition at line 1307 of file tablespace.c.

1308 {
1309  temp_tablespaces_extra *myextra = (temp_tablespaces_extra *) extra;
1310 
1311  /*
1312  * If check_temp_tablespaces was executed inside a transaction, then pass
1313  * the list it made to fd.c. Otherwise, clear fd.c's list; we must be
1314  * still outside a transaction, or else restoring during transaction exit,
1315  * and in either case we can just let the next PrepareTempTablespaces call
1316  * make things sane.
1317  */
1318  if (myextra)
1319  SetTempTablespaces(myextra->tblSpcs, myextra->numSpcs);
1320  else
1321  SetTempTablespaces(NULL, 0);
1322 }
void SetTempTablespaces(Oid *tableSpaces, int numSpaces)
Definition: fd.c:2928
Oid tblSpcs[FLEXIBLE_ARRAY_MEMBER]
Definition: tablespace.c:1194

References temp_tablespaces_extra::numSpcs, SetTempTablespaces(), and temp_tablespaces_extra::tblSpcs.

◆ assign_xlog_sync_method()

void assign_xlog_sync_method ( int  new_sync_method,
void *  extra 
)

Definition at line 10849 of file xlog.c.

10850 {
10851  if (sync_method != new_sync_method)
10852  {
10853  /*
10854  * To ensure that no blocks escape unsynced, force an fsync on the
10855  * currently open log segment (if any). Also, if the open flag is
10856  * changing, close the log file so it will be reopened (with new flag
10857  * bit) at next use.
10858  */
10859  if (openLogFile >= 0)
10860  {
10862  if (pg_fsync(openLogFile) != 0)
10863  {
10864  char xlogfname[MAXFNAMELEN];
10865  int save_errno;
10866 
10867  save_errno = errno;
10868  XLogFileName(xlogfname, openLogTLI, openLogSegNo,
10870  errno = save_errno;
10871  ereport(PANIC,
10873  errmsg("could not fsync file \"%s\": %m", xlogfname)));
10874  }
10875 
10877  if (get_sync_bit(sync_method) != get_sync_bit(new_sync_method))
10878  XLogFileClose();
10879  }
10880  }
10881 }
#define PANIC
Definition: elog.h:36
int pg_fsync(int fd)
Definition: fd.c:359
@ WAIT_EVENT_WAL_SYNC_METHOD_ASSIGN
Definition: wait_event.h:227
static void pgstat_report_wait_start(uint32 wait_event_info)
Definition: wait_event.h:262
static void pgstat_report_wait_end(void)
Definition: wait_event.h:278
static int openLogFile
Definition: xlog.c:801
int wal_segment_size
Definition: xlog.c:123
static int get_sync_bit(int method)
Definition: xlog.c:10793
static TimeLineID openLogTLI
Definition: xlog.c:803
static void XLogFileClose(void)
Definition: xlog.c:3955
static XLogSegNo openLogSegNo
Definition: xlog.c:802
int sync_method
Definition: xlog.c:111
#define XLogFileName(fname, tli, logSegNo, wal_segsz_bytes)
#define MAXFNAMELEN

References ereport, errcode_for_file_access(), errmsg(), get_sync_bit(), MAXFNAMELEN, openLogFile, openLogSegNo, openLogTLI, PANIC, pg_fsync(), pgstat_report_wait_end(), pgstat_report_wait_start(), sync_method, WAIT_EVENT_WAL_SYNC_METHOD_ASSIGN, wal_segment_size, XLogFileClose(), and XLogFileName.

◆ AtEOXact_GUC()

void AtEOXact_GUC ( bool  isCommit,
int  nestLevel 
)

Definition at line 6263 of file guc.c.

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

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_dirty, GUC_LOCAL, GUC_NEEDS_REPORT, GUC_REPORT, GUC_SAVE, GUC_SET, GUC_SET_LOCAL, guc_variables, GUCNestLevel, 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, report_needed, guc_stack::scontext, config_generic::scontext, set_extra_field(), set_string_field(), guc_stack::source, config_generic::source, config_generic::stack, guc_stack::state, config_generic::status, config_var_val::stringval, config_var_value::val, config_bool::variable, config_int::variable, config_real::variable, config_string::variable, config_enum::variable, and config_generic::vartype.

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

◆ AtStart_GUC()

void AtStart_GUC ( void  )

Definition at line 6229 of file guc.c.

6230 {
6231  /*
6232  * The nest level should be 0 between transactions; if it isn't, somebody
6233  * didn't call AtEOXact_GUC, or called it with the wrong nestLevel. We
6234  * throw a warning but make no other effort to clean up.
6235  */
6236  if (GUCNestLevel != 0)
6237  elog(WARNING, "GUC nest level = %d at transaction start",
6238  GUCNestLevel);
6239  GUCNestLevel = 1;
6240 }
#define WARNING
Definition: elog.h:30

References elog, GUCNestLevel, and WARNING.

Referenced by StartTransaction().

◆ BeginReportingGUCOptions()

void BeginReportingGUCOptions ( void  )

Definition at line 6548 of file guc.c.

6549 {
6550  int i;
6551 
6552  /*
6553  * Don't do anything unless talking to an interactive frontend.
6554  */
6556  return;
6557 
6558  reporting_enabled = true;
6559 
6560  /*
6561  * Hack for in_hot_standby: initialize with the value we're about to send.
6562  * (This could be out of date by the time we actually send it, in which
6563  * case the next ReportChangedGUCOptions call will send a duplicate
6564  * report.)
6565  */
6567 
6568  /* Transmit initial values of interesting variables */
6569  for (i = 0; i < num_guc_variables; i++)
6570  {
6571  struct config_generic *conf = guc_variables[i];
6572 
6573  if (conf->flags & GUC_REPORT)
6574  ReportGUCOption(conf);
6575  }
6576 
6577  report_needed = false;
6578 }
@ DestRemote
Definition: dest.h:91
static void ReportGUCOption(struct config_generic *record)
Definition: guc.c:6640
static bool in_hot_standby
Definition: guc.c:676
static bool reporting_enabled
Definition: guc.c:5054
CommandDest whereToSendOutput
Definition: postgres.c:93
bool RecoveryInProgress(void)
Definition: xlog.c:8398

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

Referenced by PostgresMain().

◆ check_default_tablespace()

bool check_default_tablespace ( char **  newval,
void **  extra,
GucSource  source 
)

Definition at line 1092 of file tablespace.c.

1093 {
1094  /*
1095  * If we aren't inside a transaction, or connected to a database, we
1096  * cannot do the catalog accesses necessary to verify the name. Must
1097  * accept the value on faith.
1098  */
1100  {
1101  if (**newval != '\0' &&
1103  {
1104  /*
1105  * When source == PGC_S_TEST, don't throw a hard error for a
1106  * nonexistent tablespace, only a NOTICE. See comments in guc.h.
1107  */
1108  if (source == PGC_S_TEST)
1109  {
1110  ereport(NOTICE,
1111  (errcode(ERRCODE_UNDEFINED_OBJECT),
1112  errmsg("tablespace \"%s\" does not exist",
1113  *newval)));
1114  }
1115  else
1116  {
1117  GUC_check_errdetail("Tablespace \"%s\" does not exist.",
1118  *newval);
1119  return false;
1120  }
1121  }
1122  }
1123 
1124  return true;
1125 }
Oid get_tablespace_oid(const char *tablespacename, bool missing_ok)
Definition: tablespace.c:1427
#define OidIsValid(objectId)
Definition: c.h:710
#define NOTICE
Definition: elog.h:29
Oid MyDatabaseId
Definition: globals.c:88
#define GUC_check_errdetail
Definition: guc.h:421
static rewind_source * source
Definition: pg_rewind.c:79
#define InvalidOid
Definition: postgres_ext.h:36
bool IsTransactionState(void)
Definition: xact.c:373

References ereport, errcode(), errmsg(), get_tablespace_oid(), GUC_check_errdetail, InvalidOid, IsTransactionState(), MyDatabaseId, newval, NOTICE, OidIsValid, PGC_S_TEST, and source.

◆ check_search_path()

bool check_search_path ( char **  newval,
void **  extra,
GucSource  source 
)

Definition at line 4319 of file namespace.c.

4320 {
4321  char *rawname;
4322  List *namelist;
4323 
4324  /* Need a modifiable copy of string */
4325  rawname = pstrdup(*newval);
4326 
4327  /* Parse string into list of identifiers */
4328  if (!SplitIdentifierString(rawname, ',', &namelist))
4329  {
4330  /* syntax error in name list */
4331  GUC_check_errdetail("List syntax is invalid.");
4332  pfree(rawname);
4333  list_free(namelist);
4334  return false;
4335  }
4336 
4337  /*
4338  * We used to try to check that the named schemas exist, but there are
4339  * many valid use-cases for having search_path settings that include
4340  * schemas that don't exist; and often, we are not inside a transaction
4341  * here and so can't consult the system catalogs anyway. So now, the only
4342  * requirement is syntactic validity of the identifier list.
4343  */
4344 
4345  pfree(rawname);
4346  list_free(namelist);
4347 
4348  return true;
4349 }
void list_free(List *list)
Definition: list.c:1505
char * pstrdup(const char *in)
Definition: mcxt.c:1299
Definition: pg_list.h:51
bool SplitIdentifierString(char *rawstring, char separator, List **namelist)
Definition: varlena.c:3746

References GUC_check_errdetail, list_free(), newval, pfree(), pstrdup(), and SplitIdentifierString().

◆ check_temp_tablespaces()

bool check_temp_tablespaces ( char **  newval,
void **  extra,
GucSource  source 
)

Definition at line 1199 of file tablespace.c.

1200 {
1201  char *rawname;
1202  List *namelist;
1203 
1204  /* Need a modifiable copy of string */
1205  rawname = pstrdup(*newval);
1206 
1207  /* Parse string into list of identifiers */
1208  if (!SplitIdentifierString(rawname, ',', &namelist))
1209  {
1210  /* syntax error in name list */
1211  GUC_check_errdetail("List syntax is invalid.");
1212  pfree(rawname);
1213  list_free(namelist);
1214  return false;
1215  }
1216 
1217  /*
1218  * If we aren't inside a transaction, or connected to a database, we
1219  * cannot do the catalog accesses necessary to verify the name. Must
1220  * accept the value on faith. Fortunately, there's then also no need to
1221  * pass the data to fd.c.
1222  */
1224  {
1225  temp_tablespaces_extra *myextra;
1226  Oid *tblSpcs;
1227  int numSpcs;
1228  ListCell *l;
1229 
1230  /* temporary workspace until we are done verifying the list */
1231  tblSpcs = (Oid *) palloc(list_length(namelist) * sizeof(Oid));
1232  numSpcs = 0;
1233  foreach(l, namelist)
1234  {
1235  char *curname = (char *) lfirst(l);
1236  Oid curoid;
1237  AclResult aclresult;
1238 
1239  /* Allow an empty string (signifying database default) */
1240  if (curname[0] == '\0')
1241  {
1242  /* InvalidOid signifies database's default tablespace */
1243  tblSpcs[numSpcs++] = InvalidOid;
1244  continue;
1245  }
1246 
1247  /*
1248  * In an interactive SET command, we ereport for bad info. When
1249  * source == PGC_S_TEST, don't throw a hard error for a
1250  * nonexistent tablespace, only a NOTICE. See comments in guc.h.
1251  */
1252  curoid = get_tablespace_oid(curname, source <= PGC_S_TEST);
1253  if (curoid == InvalidOid)
1254  {
1255  if (source == PGC_S_TEST)
1256  ereport(NOTICE,
1257  (errcode(ERRCODE_UNDEFINED_OBJECT),
1258  errmsg("tablespace \"%s\" does not exist",
1259  curname)));
1260  continue;
1261  }
1262 
1263  /*
1264  * Allow explicit specification of database's default tablespace
1265  * in temp_tablespaces without triggering permissions checks.
1266  */
1267  if (curoid == MyDatabaseTableSpace)
1268  {
1269  /* InvalidOid signifies database's default tablespace */
1270  tblSpcs[numSpcs++] = InvalidOid;
1271  continue;
1272  }
1273 
1274  /* Check permissions, similarly complaining only if interactive */
1275  aclresult = pg_tablespace_aclcheck(curoid, GetUserId(),
1276  ACL_CREATE);
1277  if (aclresult != ACLCHECK_OK)
1278  {
1279  if (source >= PGC_S_INTERACTIVE)
1280  aclcheck_error(aclresult, OBJECT_TABLESPACE, curname);
1281  continue;
1282  }
1283 
1284  tblSpcs[numSpcs++] = curoid;
1285  }
1286 
1287  /* Now prepare an "extra" struct for assign_temp_tablespaces */
1288  myextra = malloc(offsetof(temp_tablespaces_extra, tblSpcs) +
1289  numSpcs * sizeof(Oid));
1290  if (!myextra)
1291  return false;
1292  myextra->numSpcs = numSpcs;
1293  memcpy(myextra->tblSpcs, tblSpcs, numSpcs * sizeof(Oid));
1294  *extra = (void *) myextra;
1295 
1296  pfree(tblSpcs);
1297  }
1298 
1299  pfree(rawname);
1300  list_free(namelist);
1301 
1302  return true;
1303 }
AclResult
Definition: acl.h:178
@ ACLCHECK_OK
Definition: acl.h:179
AclResult pg_tablespace_aclcheck(Oid spc_oid, Oid roleid, AclMode mode)
Definition: aclchk.c:4770
void aclcheck_error(AclResult aclerr, ObjectType objtype, const char *objectname)
Definition: aclchk.c:3308
#define offsetof(type, field)
Definition: c.h:727
Oid MyDatabaseTableSpace
Definition: globals.c:90
#define malloc(a)
Definition: header.h:50
void * palloc(Size size)
Definition: mcxt.c:1062
Oid GetUserId(void)
Definition: miscinit.c:495
@ OBJECT_TABLESPACE
Definition: parsenodes.h:1829
#define ACL_CREATE
Definition: parsenodes.h:91
#define lfirst(lc)
Definition: pg_list.h:169
static int list_length(const List *l)
Definition: pg_list.h:149
unsigned int Oid
Definition: postgres_ext.h:31

References ACL_CREATE, aclcheck_error(), ACLCHECK_OK, ereport, errcode(), errmsg(), get_tablespace_oid(), GetUserId(), GUC_check_errdetail, InvalidOid, IsTransactionState(), lfirst, list_free(), list_length(), malloc, MyDatabaseId, MyDatabaseTableSpace, newval, NOTICE, temp_tablespaces_extra::numSpcs, OBJECT_TABLESPACE, offsetof, palloc(), pfree(), pg_tablespace_aclcheck(), PGC_S_INTERACTIVE, PGC_S_TEST, pstrdup(), source, SplitIdentifierString(), and temp_tablespaces_extra::tblSpcs.

◆ check_wal_buffers()

bool check_wal_buffers ( int *  newval,
void **  extra,
GucSource  source 
)

Definition at line 5126 of file xlog.c.

5127 {
5128  /*
5129  * -1 indicates a request for auto-tune.
5130  */
5131  if (*newval == -1)
5132  {
5133  /*
5134  * If we haven't yet changed the boot_val default of -1, just let it
5135  * be. We'll fix it when XLOGShmemSize is called.
5136  */
5137  if (XLOGbuffers == -1)
5138  return true;
5139 
5140  /* Otherwise, substitute the auto-tune value */
5142  }
5143 
5144  /*
5145  * We clamp manually-set values to at least 4 blocks. Prior to PostgreSQL
5146  * 9.1, a minimum of 4 was enforced by guc.c, but since that is no longer
5147  * the case, we just silently treat such values as a request for the
5148  * minimum. (We could throw an error instead, but that doesn't seem very
5149  * helpful.)
5150  */
5151  if (*newval < 4)
5152  *newval = 4;
5153 
5154  return true;
5155 }
static int XLOGChooseNumBuffers(void)
Definition: xlog.c:5110
int XLOGbuffers
Definition: xlog.c:98

References newval, XLOGbuffers, and XLOGChooseNumBuffers().

◆ DeescapeQuotedString()

char* DeescapeQuotedString ( const char *  s)

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

9208 {
9209  struct config_bool *var;
9210 
9211  var = (struct config_bool *)
9212  init_custom_variable(name, short_desc, long_desc, context, flags,
9213  PGC_BOOL, sizeof(struct config_bool));
9214  var->variable = valueAddr;
9215  var->boot_val = bootValue;
9216  var->reset_val = bootValue;
9217  var->check_hook = check_hook;
9218  var->assign_hook = assign_hook;
9219  var->show_hook = show_hook;
9220  define_custom_variable(&var->gen);
9221 }
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:8957
static void define_custom_variable(struct config_generic *variable)
Definition: guc.c:9017
GucBoolCheckHook check_hook
Definition: guc_tables.h:181
bool reset_val
Definition: guc_tables.h:185
bool boot_val
Definition: guc_tables.h:180
GucShowHook show_hook
Definition: guc_tables.h:183

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

Referenced by _PG_init().

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

9320 {
9321  struct config_enum *var;
9322 
9323  var = (struct config_enum *)
9324  init_custom_variable(name, short_desc, long_desc, context, flags,
9325  PGC_ENUM, sizeof(struct config_enum));
9326  var->variable = valueAddr;
9327  var->boot_val = bootValue;
9328  var->reset_val = bootValue;
9329  var->options = options;
9330  var->check_hook = check_hook;
9331  var->assign_hook = assign_hook;
9332  var->show_hook = show_hook;
9333  define_custom_variable(&var->gen);
9334 }
static char ** options
const struct config_enum_entry * options
Definition: guc_tables.h:241
GucEnumCheckHook check_hook
Definition: guc_tables.h:242
GucShowHook show_hook
Definition: guc_tables.h:244

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

Referenced by _PG_init().

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

9236 {
9237  struct config_int *var;
9238 
9239  var = (struct config_int *)
9240  init_custom_variable(name, short_desc, long_desc, context, flags,
9241  PGC_INT, sizeof(struct config_int));
9242  var->variable = valueAddr;
9243  var->boot_val = bootValue;
9244  var->reset_val = bootValue;
9245  var->min = minValue;
9246  var->max = maxValue;
9247  var->check_hook = check_hook;
9248  var->assign_hook = assign_hook;
9249  var->show_hook = show_hook;
9250  define_custom_variable(&var->gen);
9251 }
int reset_val
Definition: guc_tables.h:201
int boot_val
Definition: guc_tables.h:194
GucIntCheckHook check_hook
Definition: guc_tables.h:197
GucShowHook show_hook
Definition: guc_tables.h:199

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

Referenced by _PG_init().

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

9266 {
9267  struct config_real *var;
9268 
9269  var = (struct config_real *)
9270  init_custom_variable(name, short_desc, long_desc, context, flags,
9271  PGC_REAL, sizeof(struct config_real));
9272  var->variable = valueAddr;
9273  var->boot_val = bootValue;
9274  var->reset_val = bootValue;
9275  var->min = minValue;
9276  var->max = maxValue;
9277  var->check_hook = check_hook;
9278  var->assign_hook = assign_hook;
9279  var->show_hook = show_hook;
9280  define_custom_variable(&var->gen);
9281 }
double boot_val
Definition: guc_tables.h:210
double reset_val
Definition: guc_tables.h:217
double min
Definition: guc_tables.h:211
double max
Definition: guc_tables.h:212
GucShowHook show_hook
Definition: guc_tables.h:215
GucRealCheckHook check_hook
Definition: guc_tables.h:213

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

Referenced by _PG_init().

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

9294 {
9295  struct config_string *var;
9296 
9297  var = (struct config_string *)
9298  init_custom_variable(name, short_desc, long_desc, context, flags,
9299  PGC_STRING, sizeof(struct config_string));
9300  var->variable = valueAddr;
9301  var->boot_val = bootValue;
9302  var->check_hook = check_hook;
9303  var->assign_hook = assign_hook;
9304  var->show_hook = show_hook;
9305  define_custom_variable(&var->gen);
9306 }
GucStringCheckHook check_hook
Definition: guc_tables.h:227
GucShowHook show_hook
Definition: guc_tables.h:229
const char * boot_val
Definition: guc_tables.h:226

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

Referenced by _PG_init().

◆ EmitWarningsOnPlaceholders()

void EmitWarningsOnPlaceholders ( const char *  className)

Definition at line 9337 of file guc.c.

9338 {
9339  int classLen = strlen(className);
9340  int i;
9341  MemoryContext oldcontext;
9342 
9343  for (i = 0; i < num_guc_variables; i++)
9344  {
9345  struct config_generic *var = guc_variables[i];
9346 
9347  if ((var->flags & GUC_CUSTOM_PLACEHOLDER) != 0 &&
9348  strncmp(className, var->name, classLen) == 0 &&
9349  var->name[classLen] == GUC_QUALIFIER_SEPARATOR)
9350  {
9351  ereport(WARNING,
9352  (errcode(ERRCODE_UNDEFINED_OBJECT),
9353  errmsg("unrecognized configuration parameter \"%s\"",
9354  var->name)));
9355  }
9356  }
9357 
9360  MemoryContextSwitchTo(oldcontext);
9361 }
static List * reserved_class_prefix
Definition: guc.c:239
#define GUC_CUSTOM_PLACEHOLDER
Definition: guc.h:211
#define GUC_QUALIFIER_SEPARATOR
Definition: guc.h:199
List * lappend(List *list, void *datum)
Definition: list.c:336
MemoryContext TopMemoryContext
Definition: mcxt.c:48
static MemoryContext MemoryContextSwitchTo(MemoryContext context)
Definition: palloc.h:109
const char * name
Definition: guc_tables.h:141

References ereport, errcode(), errmsg(), config_generic::flags, GUC_CUSTOM_PLACEHOLDER, GUC_QUALIFIER_SEPARATOR, guc_variables, i, lappend(), MemoryContextSwitchTo(), config_generic::name, num_guc_variables, pstrdup(), reserved_class_prefix, TopMemoryContext, and WARNING.

Referenced by _PG_init().

◆ EstimateGUCStateSpace()

Size EstimateGUCStateSpace ( void  )

Definition at line 10674 of file guc.c.

10675 {
10676  Size size;
10677  int i;
10678 
10679  /* Add space reqd for saving the data size of the guc state */
10680  size = sizeof(Size);
10681 
10682  /* Add up the space needed for each GUC variable */
10683  for (i = 0; i < num_guc_variables; i++)
10684  size = add_size(size,
10686 
10687  return size;
10688 }
size_t Size
Definition: c.h:540
static Size estimate_variable_size(struct config_generic *gconf)
Definition: guc.c:10575
Size add_size(Size s1, Size s2)
Definition: shmem.c:502

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

Referenced by InitializeParallelDSM().

◆ ExecSetVariableStmt()

void ExecSetVariableStmt ( VariableSetStmt stmt,
bool  isTopLevel 
)

Definition at line 8743 of file guc.c.

8744 {
8746 
8747  /*
8748  * Workers synchronize these parameters at the start of the parallel
8749  * operation; then, we block SET during the operation.
8750  */
8751  if (IsInParallelMode())
8752  ereport(ERROR,
8753  (errcode(ERRCODE_INVALID_TRANSACTION_STATE),
8754  errmsg("cannot set parameters during a parallel operation")));
8755 
8756  switch (stmt->kind)
8757  {
8758  case VAR_SET_VALUE:
8759  case VAR_SET_CURRENT:
8760  if (stmt->is_local)
8761  WarnNoTransactionBlock(isTopLevel, "SET LOCAL");
8762  (void) set_config_option(stmt->name,
8763  ExtractSetVariableArgs(stmt),
8765  PGC_S_SESSION,
8766  action, true, 0, false);
8768  break;
8769  case VAR_SET_MULTI:
8770 
8771  /*
8772  * Special-case SQL syntaxes. The TRANSACTION and SESSION
8773  * CHARACTERISTICS cases effectively set more than one variable
8774  * per statement. TRANSACTION SNAPSHOT only takes one argument,
8775  * but we put it here anyway since it's a special case and not
8776  * related to any GUC variable.
8777  */
8778  if (strcmp(stmt->name, "TRANSACTION") == 0)
8779  {
8780  ListCell *head;
8781 
8782  WarnNoTransactionBlock(isTopLevel, "SET TRANSACTION");
8783 
8784  foreach(head, stmt->args)
8785  {
8786  DefElem *item = (DefElem *) lfirst(head);
8787 
8788  if (strcmp(item->defname, "transaction_isolation") == 0)
8789  SetPGVariable("transaction_isolation",
8790  list_make1(item->arg), stmt->is_local);
8791  else if (strcmp(item->defname, "transaction_read_only") == 0)
8792  SetPGVariable("transaction_read_only",
8793  list_make1(item->arg), stmt->is_local);
8794  else if (strcmp(item->defname, "transaction_deferrable") == 0)
8795  SetPGVariable("transaction_deferrable",
8796  list_make1(item->arg), stmt->is_local);
8797  else
8798  elog(ERROR, "unexpected SET TRANSACTION element: %s",
8799  item->defname);
8800  }
8801  }
8802  else if (strcmp(stmt->name, "SESSION CHARACTERISTICS") == 0)
8803  {
8804  ListCell *head;
8805 
8806  foreach(head, stmt->args)
8807  {
8808  DefElem *item = (DefElem *) lfirst(head);
8809 
8810  if (strcmp(item->defname, "transaction_isolation") == 0)
8811  SetPGVariable("default_transaction_isolation",
8812  list_make1(item->arg), stmt->is_local);
8813  else if (strcmp(item->defname, "transaction_read_only") == 0)
8814  SetPGVariable("default_transaction_read_only",
8815  list_make1(item->arg), stmt->is_local);
8816  else if (strcmp(item->defname, "transaction_deferrable") == 0)
8817  SetPGVariable("default_transaction_deferrable",
8818  list_make1(item->arg), stmt->is_local);
8819  else
8820  elog(ERROR, "unexpected SET SESSION element: %s",
8821  item->defname);
8822  }
8823  }
8824  else if (strcmp(stmt->name, "TRANSACTION SNAPSHOT") == 0)
8825  {
8826  A_Const *con = linitial_node(A_Const, stmt->args);
8827 
8828  if (stmt->is_local)
8829  ereport(ERROR,
8830  (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
8831  errmsg("SET LOCAL TRANSACTION SNAPSHOT is not implemented")));
8832 
8833  WarnNoTransactionBlock(isTopLevel, "SET TRANSACTION");
8834  ImportSnapshot(strVal(&con->val));
8835  }
8836  else
8837  elog(ERROR, "unexpected SET MULTI element: %s",
8838  stmt->name);
8839  break;
8840  case VAR_SET_DEFAULT:
8841  if (stmt->is_local)
8842  WarnNoTransactionBlock(isTopLevel, "SET LOCAL");
8843  /* fall through */
8844  case VAR_RESET:
8845  if (strcmp(stmt->name, "transaction_isolation") == 0)
8846  WarnNoTransactionBlock(isTopLevel, "RESET TRANSACTION");
8847 
8848  (void) set_config_option(stmt->name,
8849  NULL,
8851  PGC_S_SESSION,
8852  action, true, 0, false);
8853 
8855  break;
8856  case VAR_RESET_ALL:
8857  ResetAllOptions();
8858  break;
8859  }
8860 }
void ResetAllOptions(void)
Definition: guc.c:6045
void SetPGVariable(const char *name, List *args, bool is_local)
Definition: guc.c:8889
static void check_reserved_prefixes(const char *varName)
Definition: guc.c:9368
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:7340
@ VAR_SET_MULTI
Definition: parsenodes.h:2145
@ VAR_SET_CURRENT
Definition: parsenodes.h:2144
#define linitial_node(type, l)
Definition: pg_list.h:177
#define list_make1(x1)
Definition: pg_list.h:206
void ImportSnapshot(const char *idstr)
Definition: snapmgr.c:1392
union A_Const::ValUnion val
char * defname
Definition: parsenodes.h:757
Node * arg
Definition: parsenodes.h:758
#define strVal(v)
Definition: value.h:65
void WarnNoTransactionBlock(bool isTopLevel, const char *stmtType)
Definition: xact.c:3510
bool IsInParallelMode(void)
Definition: xact.c:1064

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

Referenced by standard_ProcessUtility().

◆ ExtractSetVariableArgs()

char* ExtractSetVariableArgs ( VariableSetStmt stmt)

Definition at line 8869 of file guc.c.

8870 {
8871  switch (stmt->kind)
8872  {
8873  case VAR_SET_VALUE:
8874  return flatten_set_variable_args(stmt->name, stmt->args);
8875  case VAR_SET_CURRENT:
8876  return GetConfigOptionByName(stmt->name, NULL, false);
8877  default:
8878  return NULL;
8879  }
8880 }
static char * flatten_set_variable_args(const char *name, List *args)
Definition: guc.c:8273
char * GetConfigOptionByName(const char *name, const char **varname, bool missing_ok)
Definition: guc.c:9640

References VariableSetStmt::args, flatten_set_variable_args(), GetConfigOptionByName(), VariableSetStmt::kind, VariableSetStmt::name, VAR_SET_CURRENT, and VAR_SET_VALUE.

Referenced by AlterSetting(), AlterSystemSetConfigFile(), ExecSetVariableStmt(), and update_proconfig_value().

◆ FreeConfigVariables()

void FreeConfigVariables ( ConfigVariable list)

◆ GetConfigOption()

const char* GetConfigOption ( const char *  name,
bool  missing_ok,
bool  restrict_privileged 
)

Definition at line 8155 of file guc.c.

8156 {
8157  struct config_generic *record;
8158  static char buffer[256];
8159 
8160  record = find_option(name, false, missing_ok, ERROR);
8161  if (record == NULL)
8162  return NULL;
8163  if (restrict_privileged &&
8164  (record->flags & GUC_SUPERUSER_ONLY) &&
8165  !is_member_of_role(GetUserId(), ROLE_PG_READ_ALL_SETTINGS))
8166  ereport(ERROR,
8167  (errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
8168  errmsg("must be superuser or a member of pg_read_all_settings to examine \"%s\"",
8169  name)));
8170 
8171  switch (record->vartype)
8172  {
8173  case PGC_BOOL:
8174  return *((struct config_bool *) record)->variable ? "on" : "off";
8175 
8176  case PGC_INT:
8177  snprintf(buffer, sizeof(buffer), "%d",
8178  *((struct config_int *) record)->variable);
8179  return buffer;
8180 
8181  case PGC_REAL:
8182  snprintf(buffer, sizeof(buffer), "%g",
8183  *((struct config_real *) record)->variable);
8184  return buffer;
8185 
8186  case PGC_STRING:
8187  return *((struct config_string *) record)->variable;
8188 
8189  case PGC_ENUM:
8190  return config_enum_lookup_by_value((struct config_enum *) record,
8191  *((struct config_enum *) record)->variable);
8192  }
8193  return NULL;
8194 }
bool is_member_of_role(Oid member, Oid role)
Definition: acl.c:4869
const char * config_enum_lookup_by_value(struct config_enum *record, int val)
Definition: guc.c:7032
#define GUC_SUPERUSER_ONLY
Definition: guc.h:212

References config_enum_lookup_by_value(), ereport, errcode(), errmsg(), ERROR, find_option(), config_generic::flags, GetUserId(), GUC_SUPERUSER_ONLY, is_member_of_role(), name, PGC_BOOL, PGC_ENUM, PGC_INT, PGC_REAL, PGC_STRING, snprintf, and config_generic::vartype.

Referenced by applyRemoteGucs(), be_tls_init(), and PostmasterMain().

◆ GetConfigOptionByName()

char* GetConfigOptionByName ( const char *  name,
const char **  varname,
bool  missing_ok 
)

Definition at line 9640 of file guc.c.

9641 {
9642  struct config_generic *record;
9643 
9644  record = find_option(name, false, missing_ok, ERROR);
9645  if (record == NULL)
9646  {
9647  if (varname)
9648  *varname = NULL;
9649  return NULL;
9650  }
9651 
9652  if ((record->flags & GUC_SUPERUSER_ONLY) &&
9653  !is_member_of_role(GetUserId(), ROLE_PG_READ_ALL_SETTINGS))
9654  ereport(ERROR,
9655  (errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
9656  errmsg("must be superuser or a member of pg_read_all_settings to examine \"%s\"",
9657  name)));
9658 
9659  if (varname)
9660  *varname = record->name;
9661 
9662  return _ShowOption(record, true);
9663 }
static char * _ShowOption(struct config_generic *record, bool use_units)
Definition: guc.c:10193

References _ShowOption(), ereport, errcode(), errmsg(), ERROR, find_option(), config_generic::flags, GetUserId(), GUC_SUPERUSER_ONLY, is_member_of_role(), name, and config_generic::name.

Referenced by ExplainPrintSettings(), ExtractSetVariableArgs(), GetPGVariableResultDesc(), set_config_by_name(), show_config_by_name(), show_config_by_name_missing_ok(), and ShowGUCConfigOption().

◆ GetConfigOptionByNum()

void GetConfigOptionByNum ( int  varnum,
const char **  values,
bool noshow 
)

Definition at line 9670 of file guc.c.

9671 {
9672  char buffer[256];
9673  struct config_generic *conf;
9674 
9675  /* check requested variable number valid */
9676  Assert((varnum >= 0) && (varnum < num_guc_variables));
9677 
9678  conf = guc_variables[varnum];
9679 
9680  if (noshow)
9681  {
9682  if ((conf->flags & GUC_NO_SHOW_ALL) ||
9683  ((conf->flags & GUC_SUPERUSER_ONLY) &&
9684  !is_member_of_role(GetUserId(), ROLE_PG_READ_ALL_SETTINGS)))
9685  *noshow = true;
9686  else
9687  *noshow = false;
9688  }
9689 
9690  /* first get the generic attributes */
9691 
9692  /* name */
9693  values[0] = conf->name;
9694 
9695  /* setting: use _ShowOption in order to avoid duplicating the logic */
9696  values[1] = _ShowOption(conf, false);
9697 
9698  /* unit, if any (NULL is fine) */
9699  values[2] = get_config_unit_name(conf->flags);
9700 
9701  /* group */
9702  values[3] = _(config_group_names[conf->group]);
9703 
9704  /* short_desc */
9705  values[4] = _(conf->short_desc);
9706 
9707  /* extra_desc */
9708  values[5] = _(conf->long_desc);
9709 
9710  /* context */
9711  values[6] = GucContext_Names[conf->context];
9712 
9713  /* vartype */
9714  values[7] = config_type_names[conf->vartype];
9715 
9716  /* source */
9717  values[8] = GucSource_Names[conf->source];
9718 
9719  /* now get the type specific attributes */
9720  switch (conf->vartype)
9721  {
9722  case PGC_BOOL:
9723  {
9724  struct config_bool *lconf = (struct config_bool *) conf;
9725 
9726  /* min_val */
9727  values[9] = NULL;
9728 
9729  /* max_val */
9730  values[10] = NULL;
9731 
9732  /* enumvals */
9733  values[11] = NULL;
9734 
9735  /* boot_val */
9736  values[12] = pstrdup(lconf->boot_val ? "on" : "off");
9737 
9738  /* reset_val */
9739  values[13] = pstrdup(lconf->reset_val ? "on" : "off");
9740  }
9741  break;
9742 
9743  case PGC_INT:
9744  {
9745  struct config_int *lconf = (struct config_int *) conf;
9746 
9747  /* min_val */
9748  snprintf(buffer, sizeof(buffer), "%d", lconf->min);
9749  values[9] = pstrdup(buffer);
9750 
9751  /* max_val */
9752  snprintf(buffer, sizeof(buffer), "%d", lconf->max);
9753  values[10] = pstrdup(buffer);
9754 
9755  /* enumvals */
9756  values[11] = NULL;
9757 
9758  /* boot_val */
9759  snprintf(buffer, sizeof(buffer), "%d", lconf->boot_val);
9760  values[12] = pstrdup(buffer);
9761 
9762  /* reset_val */
9763  snprintf(buffer, sizeof(buffer), "%d", lconf->reset_val);
9764  values[13] = pstrdup(buffer);
9765  }
9766  break;
9767 
9768  case PGC_REAL:
9769  {
9770  struct config_real *lconf = (struct config_real *) conf;
9771 
9772  /* min_val */
9773  snprintf(buffer, sizeof(buffer), "%g", lconf->min);
9774  values[9] = pstrdup(buffer);
9775 
9776  /* max_val */
9777  snprintf(buffer, sizeof(buffer), "%g", lconf->max);
9778  values[10] = pstrdup(buffer);
9779 
9780  /* enumvals */
9781  values[11] = NULL;
9782 
9783  /* boot_val */
9784  snprintf(buffer, sizeof(buffer), "%g", lconf->boot_val);
9785  values[12] = pstrdup(buffer);
9786 
9787  /* reset_val */
9788  snprintf(buffer, sizeof(buffer), "%g", lconf->reset_val);
9789  values[13] = pstrdup(buffer);
9790  }
9791  break;
9792 
9793  case PGC_STRING:
9794  {
9795  struct config_string *lconf = (struct config_string *) conf;
9796 
9797  /* min_val */
9798  values[9] = NULL;
9799 
9800  /* max_val */
9801  values[10] = NULL;
9802 
9803  /* enumvals */
9804  values[11] = NULL;
9805 
9806  /* boot_val */
9807  if (lconf->boot_val == NULL)
9808  values[12] = NULL;
9809  else
9810  values[12] = pstrdup(lconf->boot_val);
9811 
9812  /* reset_val */
9813  if (lconf->reset_val == NULL)
9814  values[13] = NULL;
9815  else
9816  values[13] = pstrdup(lconf->reset_val);
9817  }
9818  break;
9819 
9820  case PGC_ENUM:
9821  {
9822  struct config_enum *lconf = (struct config_enum *) conf;
9823 
9824  /* min_val */
9825  values[9] = NULL;
9826 
9827  /* max_val */
9828  values[10] = NULL;
9829 
9830  /* enumvals */
9831 
9832  /*
9833  * NOTE! enumvals with double quotes in them are not
9834  * supported!
9835  */
9836  values[11] = config_enum_get_options((struct config_enum *) conf,
9837  "{\"", "\"}", "\",\"");
9838 
9839  /* boot_val */
9841  lconf->boot_val));
9842 
9843  /* reset_val */
9845  lconf->reset_val));
9846  }
9847  break;
9848 
9849  default:
9850  {
9851  /*
9852  * should never get here, but in case we do, set 'em to NULL
9853  */
9854 
9855  /* min_val */
9856  values[9] = NULL;
9857 
9858  /* max_val */
9859  values[10] = NULL;
9860 
9861  /* enumvals */
9862  values[11] = NULL;
9863 
9864  /* boot_val */
9865  values[12] = NULL;
9866 
9867  /* reset_val */
9868  values[13] = NULL;
9869  }
9870  break;
9871  }
9872 
9873  /*
9874  * If the setting came from a config file, set the source location. For
9875  * security reasons, we don't show source file/line number for
9876  * insufficiently-privileged users.
9877  */
9878  if (conf->source == PGC_S_FILE &&
9879  is_member_of_role(GetUserId(), ROLE_PG_READ_ALL_SETTINGS))
9880  {
9881  values[14] = conf->sourcefile;
9882  snprintf(buffer, sizeof(buffer), "%d", conf->sourceline);
9883  values[15] = pstrdup(buffer);
9884  }
9885  else
9886  {
9887  values[14] = NULL;
9888  values[15] = NULL;
9889  }
9890 
9891  values[16] = (conf->status & GUC_PENDING_RESTART) ? "t" : "f";
9892 }
static Datum values[MAXATTR]
Definition: bootstrap.c:156
#define _(x)
Definition: elog.c:89
static const char * get_config_unit_name(int flags)
Definition: guc.c:6823
const char *const GucContext_Names[]
Definition: guc.c:693
const char *const GucSource_Names[]
Definition: guc.c:712
const char *const config_type_names[]
Definition: guc.c:834
static char * config_enum_get_options(struct config_enum *record, const char *prefix, const char *suffix, const char *separator)
Definition: guc.c:7081
const char *const config_group_names[]
Definition: guc.c:736
#define GUC_NO_SHOW_ALL
Definition: guc.h:206
#define GUC_PENDING_RESTART
Definition: guc_tables.h:169
enum config_group group
Definition: guc_tables.h:143
const char * long_desc
Definition: guc_tables.h:145
const char * short_desc
Definition: guc_tables.h:144
char * sourcefile
Definition: guc_tables.h:158
char * reset_val
Definition: guc_tables.h:231

References _, _ShowOption(), Assert(), config_bool::boot_val, config_int::boot_val, config_real::boot_val, config_string::boot_val, config_enum::boot_val, config_enum_get_options(), config_enum_lookup_by_value(), config_group_names, config_type_names, config_generic::context, config_generic::flags, get_config_unit_name(), GetUserId(), config_generic::group, GUC_NO_SHOW_ALL, GUC_PENDING_RESTART, GUC_SUPERUSER_ONLY, guc_variables, GucContext_Names, GucSource_Names, is_member_of_role(), config_generic::long_desc, config_int::max, config_real::max, config_int::min, config_real::min, config_generic::name, num_guc_variables, PGC_BOOL, PGC_ENUM, PGC_INT, PGC_REAL, PGC_S_FILE, PGC_STRING, pstrdup(), config_bool::reset_val, config_int::reset_val, config_real::reset_val, config_string::reset_val, config_enum::reset_val, config_generic::short_desc, snprintf, config_generic::source, config_generic::sourcefile, config_generic::sourceline, config_generic::status, values, and config_generic::vartype.

Referenced by show_all_settings().

◆ GetConfigOptionFlags()

int GetConfigOptionFlags ( const char *  name,
bool  missing_ok 
)

Definition at line 8250 of file guc.c.

8251 {
8252  struct config_generic *record;
8253 
8254  record = find_option(name, false, missing_ok, ERROR);
8255  if (record == NULL)
8256  return 0;
8257  return record->flags;
8258 }

References ERROR, find_option(), config_generic::flags, and name.

Referenced by pg_get_functiondef(), and PostmasterMain().

◆ GetConfigOptionResetString()

const char* GetConfigOptionResetString ( const char *  name)

Definition at line 8204 of file guc.c.

8205 {
8206  struct config_generic *record;
8207  static char buffer[256];
8208 
8209  record = find_option(name, false, false, ERROR);
8210  Assert(record != NULL);
8211  if ((record->flags & GUC_SUPERUSER_ONLY) &&
8212  !is_member_of_role(GetUserId(), ROLE_PG_READ_ALL_SETTINGS))
8213  ereport(ERROR,
8214  (errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
8215  errmsg("must be superuser or a member of pg_read_all_settings to examine \"%s\"",
8216  name)));
8217 
8218  switch (record->vartype)
8219  {
8220  case PGC_BOOL:
8221  return ((struct config_bool *) record)->reset_val ? "on" : "off";
8222 
8223  case PGC_INT:
8224  snprintf(buffer, sizeof(buffer), "%d",
8225  ((struct config_int *) record)->reset_val);
8226  return buffer;
8227 
8228  case PGC_REAL:
8229  snprintf(buffer, sizeof(buffer), "%g",
8230  ((struct config_real *) record)->reset_val);
8231  return buffer;
8232 
8233  case PGC_STRING:
8234  return ((struct config_string *) record)->reset_val;
8235 
8236  case PGC_ENUM:
8237  return config_enum_lookup_by_value((struct config_enum *) record,
8238  ((struct config_enum *) record)->reset_val);
8239  }
8240  return NULL;
8241 }

References Assert(), config_enum_lookup_by_value(), ereport, errcode(), errmsg(), ERROR, find_option(), config_generic::flags, GetUserId(), GUC_SUPERUSER_ONLY, is_member_of_role(), name, PGC_BOOL, PGC_ENUM, PGC_INT, PGC_REAL, PGC_STRING, snprintf, and config_generic::vartype.

Referenced by check_datestyle().

◆ GetNumConfigOptions()

int GetNumConfigOptions ( void  )

Definition at line 9898 of file guc.c.

9899 {
9900  return num_guc_variables;
9901 }

References num_guc_variables.

Referenced by GucInfoMain(), and show_all_settings().

◆ GetPGVariable()

void GetPGVariable ( const char *  name,
DestReceiver dest 
)

Definition at line 9405 of file guc.c.

9406 {
9407  if (guc_name_compare(name, "all") == 0)
9409  else
9411 }
static void ShowGUCConfigOption(const char *name, DestReceiver *dest)
Definition: guc.c:9449
static int guc_name_compare(const char *namea, const char *nameb)
Definition: guc.c:5613
static void ShowAllGUCConfig(DestReceiver *dest)
Definition: guc.c:9477

References generate_unaccent_rules::dest, guc_name_compare(), name, ShowAllGUCConfig(), and ShowGUCConfigOption().

Referenced by exec_replication_command(), and standard_ProcessUtility().

◆ GetPGVariableResultDesc()

TupleDesc GetPGVariableResultDesc ( const char *  name)

Definition at line 9414 of file guc.c.

9415 {
9416  TupleDesc tupdesc;
9417 
9418  if (guc_name_compare(name, "all") == 0)
9419  {
9420  /* need a tuple descriptor representing three TEXT columns */
9421  tupdesc = CreateTemplateTupleDesc(3);
9422  TupleDescInitEntry(tupdesc, (AttrNumber) 1, "name",
9423  TEXTOID, -1, 0);
9424  TupleDescInitEntry(tupdesc, (AttrNumber) 2, "setting",
9425  TEXTOID, -1, 0);
9426  TupleDescInitEntry(tupdesc, (AttrNumber) 3, "description",
9427  TEXTOID, -1, 0);
9428  }
9429  else
9430  {
9431  const char *varname;
9432 
9433  /* Get the canonical spelling of name */
9434  (void) GetConfigOptionByName(name, &varname, false);
9435 
9436  /* need a tuple descriptor representing a single TEXT column */
9437  tupdesc = CreateTemplateTupleDesc(1);
9438  TupleDescInitEntry(tupdesc, (AttrNumber) 1, varname,
9439  TEXTOID, -1, 0);
9440  }
9441  return tupdesc;
9442 }
int16 AttrNumber
Definition: attnum.h:21
TupleDesc CreateTemplateTupleDesc(int natts)
Definition: tupdesc.c:45
void TupleDescInitEntry(TupleDesc desc, AttrNumber attributeNumber, const char *attributeName, Oid oidtypeid, int32 typmod, int attdim)
Definition: tupdesc.c:583

References CreateTemplateTupleDesc(), GetConfigOptionByName(), guc_name_compare(), name, and TupleDescInitEntry().

Referenced by UtilityTupleDescriptor().

◆ GUC_check_errcode()

void GUC_check_errcode ( int  sqlerrcode)

◆ GUCArrayAdd()

ArrayType* GUCArrayAdd ( ArrayType array,
const char *  name,
const char *  value 
)

Definition at line 11171 of file guc.c.

11172 {
11173  struct config_generic *record;
11174  Datum datum;
11175  char *newval;
11176  ArrayType *a;
11177 
11178  Assert(name);
11179  Assert(value);
11180 
11181  /* test if the option is valid and we're allowed to set it */
11182  (void) validate_option_array_item(name, value, false);
11183 
11184  /* normalize name (converts obsolete GUC names to modern spellings) */
11185  record = find_option(name, false, true, WARNING);
11186  if (record)
11187  name = record->name;
11188 
11189  /* build new item for array */
11190  newval = psprintf("%s=%s", name, value);
11191  datum = CStringGetTextDatum(newval);
11192 
11193  if (array)
11194  {
11195  int index;
11196  bool isnull;
11197  int i;
11198 
11199  Assert(ARR_ELEMTYPE(array) == TEXTOID);
11200  Assert(ARR_NDIM(array) == 1);
11201  Assert(ARR_LBOUND(array)[0] == 1);
11202 
11203  index = ARR_DIMS(array)[0] + 1; /* add after end */
11204 
11205  for (i = 1; i <= ARR_DIMS(array)[0]; i++)
11206  {
11207  Datum d;
11208  char *current;
11209 
11210  d = array_ref(array, 1, &i,
11211  -1 /* varlenarray */ ,
11212  -1 /* TEXT's typlen */ ,
11213  false /* TEXT's typbyval */ ,
11214  TYPALIGN_INT /* TEXT's typalign */ ,
11215  &isnull);
11216  if (isnull)
11217  continue;
11218  current = TextDatumGetCString(d);
11219 
11220  /* check for match up through and including '=' */
11221  if (strncmp(current, newval, strlen(name) + 1) == 0)
11222  {
11223  index = i;
11224  break;
11225  }
11226  }
11227 
11228  a = array_set(array, 1, &index,
11229  datum,
11230  false,
11231  -1 /* varlena array */ ,
11232  -1 /* TEXT's typlen */ ,
11233  false /* TEXT's typbyval */ ,
11234  TYPALIGN_INT /* TEXT's typalign */ );
11235  }
11236  else
11237  a = construct_array(&datum, 1,
11238  TEXTOID,
11239  -1, false, TYPALIGN_INT);
11240 
11241  return a;
11242 }
#define ARR_NDIM(a)
Definition: array.h:283
#define ARR_ELEMTYPE(a)
Definition: array.h:285
#define ARR_DIMS(a)
Definition: array.h:287
#define ARR_LBOUND(a)
Definition: array.h:289
ArrayType * array_set(ArrayType *array, int nSubscripts, int *indx, Datum dataValue, bool isNull, int arraytyplen, int elmlen, bool elmbyval, char elmalign)
Definition: arrayfuncs.c:3121
ArrayType * construct_array(Datum *elems, int nelems, Oid elmtype, int elmlen, bool elmbyval, char elmalign)
Definition: arrayfuncs.c:3319
Datum array_ref(ArrayType *array, int nSubscripts, int *indx, int arraytyplen, int elmlen, bool elmbyval, char elmalign, bool *isNull)
Definition: arrayfuncs.c:3104
#define CStringGetTextDatum(s)
Definition: builtins.h:86
#define TextDatumGetCString(d)
Definition: builtins.h:87
static bool validate_option_array_item(const char *name, const char *value, bool skipIfNoPermissions)
Definition: guc.c:11397
int a
Definition: isn.c:69
uintptr_t Datum
Definition: postgres.h:411
char * psprintf(const char *fmt,...)
Definition: psprintf.c:46
Definition: type.h:90

References a, ARR_DIMS, ARR_ELEMTYPE, ARR_LBOUND, ARR_NDIM, array_ref(), array_set(), Assert(), construct_array(), CStringGetTextDatum, find_option(), i, name, config_generic::name, newval, psprintf(), TextDatumGetCString, validate_option_array_item(), value, and WARNING.

Referenced by AlterSetting(), and update_proconfig_value().

◆ GUCArrayDelete()

ArrayType* GUCArrayDelete ( ArrayType array,
const char *  name 
)

Definition at line 11251 of file guc.c.

11252 {
11253  struct config_generic *record;
11254  ArrayType *newarray;
11255  int i;
11256  int index;
11257 
11258  Assert(name);
11259 
11260  /* test if the option is valid and we're allowed to set it */
11261  (void) validate_option_array_item(name, NULL, false);
11262 
11263  /* normalize name (converts obsolete GUC names to modern spellings) */
11264  record = find_option(name, false, true, WARNING);
11265  if (record)
11266  name = record->name;
11267 
11268  /* if array is currently null, then surely nothing to delete */
11269  if (!array)
11270  return NULL;
11271 
11272  newarray = NULL;
11273  index = 1;
11274 
11275  for (i = 1; i <= ARR_DIMS(array)[0]; i++)
11276  {
11277  Datum d;
11278  char *val;
11279  bool isnull;
11280 
11281  d = array_ref(array, 1, &i,
11282  -1 /* varlenarray */ ,
11283  -1 /* TEXT's typlen */ ,
11284  false /* TEXT's typbyval */ ,
11285  TYPALIGN_INT /* TEXT's typalign */ ,
11286  &isnull);
11287  if (isnull)
11288  continue;
11289  val = TextDatumGetCString(d);
11290 
11291  /* ignore entry if it's what we want to delete */
11292  if (strncmp(val, name, strlen(name)) == 0
11293  && val[strlen(name)] == '=')
11294  continue;
11295 
11296  /* else add it to the output array */
11297  if (newarray)
11298  newarray = array_set(newarray, 1, &index,
11299  d,
11300  false,
11301  -1 /* varlenarray */ ,
11302  -1 /* TEXT's typlen */ ,
11303  false /* TEXT's typbyval */ ,
11304  TYPALIGN_INT /* TEXT's typalign */ );
11305  else
11306  newarray = construct_array(&d, 1,
11307  TEXTOID,
11308  -1, false, TYPALIGN_INT);
11309 
11310  index++;
11311  }
11312 
11313  return newarray;
11314 }
long val
Definition: informix.c:664

References ARR_DIMS, array_ref(), array_set(), Assert(), construct_array(), find_option(), i, name, config_generic::name, TextDatumGetCString, val, validate_option_array_item(), and WARNING.

Referenced by AlterSetting(), and update_proconfig_value().

◆ GUCArrayReset()

ArrayType* GUCArrayReset ( ArrayType array)

Definition at line 11323 of file guc.c.

11324 {
11325  ArrayType *newarray;
11326  int i;
11327  int index;
11328 
11329  /* if array is currently null, nothing to do */
11330  if (!array)
11331  return NULL;
11332 
11333  /* if we're superuser, we can delete everything, so just do it */
11334  if (superuser())
11335  return NULL;
11336 
11337  newarray = NULL;
11338  index = 1;
11339 
11340  for (i = 1; i <= ARR_DIMS(array)[0]; i++)
11341  {
11342  Datum d;
11343  char *val;
11344  char *eqsgn;
11345  bool isnull;
11346 
11347  d = array_ref(array, 1, &i,
11348  -1 /* varlenarray */ ,
11349  -1 /* TEXT's typlen */ ,
11350  false /* TEXT's typbyval */ ,
11351  TYPALIGN_INT /* TEXT's typalign */ ,
11352  &isnull);
11353  if (isnull)
11354  continue;
11355  val = TextDatumGetCString(d);
11356 
11357  eqsgn = strchr(val, '=');
11358  *eqsgn = '\0';
11359 
11360  /* skip if we have permission to delete it */
11361  if (validate_option_array_item(val, NULL, true))
11362  continue;
11363 
11364  /* else add it to the output array */
11365  if (newarray)
11366  newarray = array_set(newarray, 1, &index,
11367  d,
11368  false,
11369  -1 /* varlenarray */ ,
11370  -1 /* TEXT's typlen */ ,
11371  false /* TEXT's typbyval */ ,
11372  TYPALIGN_INT /* TEXT's typalign */ );
11373  else
11374  newarray = construct_array(&d, 1,
11375  TEXTOID,
11376  -1, false, TYPALIGN_INT);
11377 
11378  index++;
11379  pfree(val);
11380  }
11381 
11382  return newarray;
11383 }

References ARR_DIMS, array_ref(), array_set(), construct_array(), i, pfree(), superuser(), TextDatumGetCString, val, and validate_option_array_item().

Referenced by AlterSetting().

◆ InitializeGUCOptions()

void InitializeGUCOptions ( void  )

Definition at line 5647 of file guc.c.

5648 {
5649  int i;
5650 
5651  /*
5652  * Before log_line_prefix could possibly receive a nonempty setting, make
5653  * sure that timezone processing is minimally alive (see elog.c).
5654  */
5656 
5657  /*
5658  * Build sorted array of all GUC variables.
5659  */
5661 
5662  /*
5663  * Load all variables with their compiled-in defaults, and initialize
5664  * status fields as needed.
5665  */
5666  for (i = 0; i < num_guc_variables; i++)
5667  {
5669  }
5670 
5671  guc_dirty = false;
5672 
5673  reporting_enabled = false;
5674 
5675  /*
5676  * Prevent any attempt to override the transaction modes from
5677  * non-interactive sources.
5678  */
5679  SetConfigOption("transaction_isolation", "read committed",
5681  SetConfigOption("transaction_read_only", "no",
5683  SetConfigOption("transaction_deferrable", "no",
5685 
5686  /*
5687  * For historical reasons, some GUC parameters can receive defaults from
5688  * environment variables. Process those settings.
5689  */
5691 }
void SetConfigOption(const char *name, const char *value, GucContext context, GucSource source)
Definition: guc.c:8131
static void InitializeOneGUCOption(struct config_generic *gconf)
Definition: guc.c:5749
void build_guc_variables(void)
Definition: guc.c:5309
static void InitializeGUCOptionsFromEnvironment(void)
Definition: guc.c:5703
void pg_timezone_initialize(void)
Definition: pgtz.c:361

References build_guc_variables(), guc_dirty, guc_variables, i, InitializeGUCOptionsFromEnvironment(), InitializeOneGUCOption(), num_guc_variables, pg_timezone_initialize(), PGC_POSTMASTER, PGC_S_OVERRIDE, reporting_enabled, and SetConfigOption().

Referenced by BootstrapModeMain(), PostgresSingleUserMain(), and PostmasterMain().

◆ NewGUCNestLevel()

◆ parse_int()

bool parse_int ( const char *  value,
int *  result,
int  flags,
const char **  hintmsg 
)

Definition at line 6880 of file guc.c.

6881 {
6882  /*
6883  * We assume here that double is wide enough to represent any integer
6884  * value with adequate precision.
6885  */
6886  double val;
6887  char *endptr;
6888 
6889  /* To suppress compiler warnings, always set output params */
6890  if (result)
6891  *result = 0;
6892  if (hintmsg)
6893  *hintmsg = NULL;
6894 
6895  /*
6896  * Try to parse as an integer (allowing octal or hex input). If the
6897  * conversion stops at a decimal point or 'e', or overflows, re-parse as
6898  * float. This should work fine as long as we have no unit names starting
6899  * with 'e'. If we ever do, the test could be extended to check for a
6900  * sign or digit after 'e', but for now that's unnecessary.
6901  */
6902  errno = 0;
6903  val = strtol(value, &endptr, 0);
6904  if (*endptr == '.' || *endptr == 'e' || *endptr == 'E' ||
6905  errno == ERANGE)
6906  {
6907  errno = 0;
6908  val = strtod(value, &endptr);
6909  }
6910 
6911  if (endptr == value || errno == ERANGE)
6912  return false; /* no HINT for these cases */
6913 
6914  /* reject NaN (infinities will fail range check below) */
6915  if (isnan(val))
6916  return false; /* treat same as syntax error; no HINT */
6917 
6918  /* allow whitespace between number and unit */
6919  while (isspace((unsigned char) *endptr))
6920  endptr++;
6921 
6922  /* Handle possible unit */
6923  if (*endptr != '\0')
6924  {
6925  if ((flags & GUC_UNIT) == 0)
6926  return false; /* this setting does not accept a unit */
6927 
6929  endptr, (flags & GUC_UNIT),
6930  &val))
6931  {
6932  /* invalid unit, or garbage after the unit; set hint and fail. */
6933  if (hintmsg)
6934  {
6935  if (flags & GUC_UNIT_MEMORY)
6936  *hintmsg = memory_units_hint;
6937  else
6938  *hintmsg = time_units_hint;
6939  }
6940  return false;
6941  }
6942  }
6943 
6944  /* Round to int, then check for overflow */
6945  val = rint(val);
6946 
6947  if (val > INT_MAX || val < INT_MIN)
6948  {
6949  if (hintmsg)
6950  *hintmsg = gettext_noop("Value exceeds integer range.");
6951  return false;
6952  }
6953 
6954  if (result)
6955  *result = (int) val;
6956  return true;
6957 }
#define gettext_noop(x)
Definition: c.h:1194
static const char * memory_units_hint
Definition: guc.c:879
static bool convert_to_base_unit(double value, const char *unit, int base_unit, double *base_value)
Definition: guc.c:6680
static const char * time_units_hint
Definition: guc.c:916
#define GUC_UNIT
Definition: guc.h:237
#define GUC_UNIT_MEMORY
Definition: guc.h:222

References convert_to_base_unit(), config_generic::flags, gettext_noop, GUC_UNIT, GUC_UNIT_MEMORY, memory_units_hint, time_units_hint, val, and value.

Referenced by apply_server_options(), apply_table_options(), get_batch_size_option(), parse_and_validate_value(), parse_one_reloption(), postgres_fdw_validator(), and postgresAcquireSampleRowsFunc().

◆ parse_real()

bool parse_real ( const char *  value,
double *  result,
int  flags,
const char **  hintmsg 
)

Definition at line 6970 of file guc.c.

6971 {
6972  double val;
6973  char *endptr;
6974 
6975  /* To suppress compiler warnings, always set output params */
6976  if (result)
6977  *result = 0;
6978  if (hintmsg)
6979  *hintmsg = NULL;
6980 
6981  errno = 0;
6982  val = strtod(value, &endptr);
6983 
6984  if (endptr == value || errno == ERANGE)
6985  return false; /* no HINT for these cases */
6986 
6987  /* reject NaN (infinities will fail range checks later) */
6988  if (isnan(val))
6989  return false; /* treat same as syntax error; no HINT */
6990 
6991  /* allow whitespace between number and unit */
6992  while (isspace((unsigned char) *endptr))
6993  endptr++;
6994 
6995  /* Handle possible unit */
6996  if (*endptr != '\0')
6997  {
6998  if ((flags & GUC_UNIT) == 0)
6999  return false; /* this setting does not accept a unit */
7000 
7002  endptr, (flags & GUC_UNIT),
7003  &val))
7004  {
7005  /* invalid unit, or garbage after the unit; set hint and fail. */
7006  if (hintmsg)
7007  {
7008  if (flags & GUC_UNIT_MEMORY)
7009  *hintmsg = memory_units_hint;
7010  else
7011  *hintmsg = time_units_hint;
7012  }
7013  return false;
7014  }
7015  }
7016 
7017  if (result)
7018  *result = val;
7019  return true;
7020 }

References convert_to_base_unit(), config_generic::flags, GUC_UNIT, GUC_UNIT_MEMORY, memory_units_hint, time_units_hint, val, and value.

Referenced by apply_server_options(), parse_and_validate_value(), parse_one_reloption(), and postgres_fdw_validator().

◆ ParseConfigDirectory()

bool ParseConfigDirectory ( const char *  includedir,
const char *  calling_file,
int  calling_lineno,
int  depth,
int  elevel,
ConfigVariable **  head_p,
ConfigVariable **  tail_p 
)

◆ ParseConfigFile()

bool ParseConfigFile ( const char *  config_file,
bool  strict,
const char *  calling_file,
int  calling_lineno,
int  depth,
int  elevel,
ConfigVariable **  head_p,
ConfigVariable **  tail_p 
)

◆ ParseConfigFp()

bool ParseConfigFp ( FILE *  fp,
const char *  config_file,
int  depth,
int  elevel,
ConfigVariable **  head_p,
ConfigVariable **  tail_p 
)

◆ ParseLongOption()

void ParseLongOption ( const char *  string,
char **  name,
char **  value 
)

Definition at line 11068 of file guc.c.

11069 {
11070  size_t equal_pos;
11071  char *cp;
11072 
11073  AssertArg(string);
11074  AssertArg(name);
11075  AssertArg(value);
11076 
11077  equal_pos = strcspn(string, "=");
11078 
11079  if (string[equal_pos] == '=')
11080  {
11081  *name = guc_malloc(FATAL, equal_pos + 1);
11082  strlcpy(*name, string, equal_pos + 1);
11083 
11084  *value = guc_strdup(FATAL, &string[equal_pos + 1]);
11085  }
11086  else
11087  {
11088  /* no equal sign in string */
11089  *name = guc_strdup(FATAL, string);
11090  *value = NULL;
11091  }
11092 
11093  for (cp = *name; *cp; cp++)
11094  if (*cp == '-')
11095  *cp = '_';
11096 }
#define AssertArg(condition)
Definition: c.h:806
#define FATAL
Definition: elog.h:35
static void * guc_malloc(int elevel, size_t size)
Definition: guc.c:5086
static char * guc_strdup(int elevel, const char *src)
Definition: guc.c:5118
size_t strlcpy(char *dst, const char *src, size_t siz)
Definition: strlcpy.c:45

References AssertArg, FATAL, guc_malloc(), guc_strdup(), name, strlcpy(), and value.

Referenced by BootstrapModeMain(), PostmasterMain(), process_postgres_switches(), and ProcessGUCArray().

◆ ProcessConfigFile()

◆ ProcessGUCArray()

void ProcessGUCArray ( ArrayType array,
GucContext  context,
GucSource  source,
GucAction  action 
)

Definition at line 11106 of file guc.c.

11108 {
11109  int i;
11110 
11111  Assert(array != NULL);
11112  Assert(ARR_ELEMTYPE(array) == TEXTOID);
11113  Assert(ARR_NDIM(array) == 1);
11114  Assert(ARR_LBOUND(array)[0] == 1);
11115 
11116  for (i = 1; i <= ARR_DIMS(array)[0]; i++)
11117  {
11118  Datum d;
11119  bool isnull;
11120  char *s;
11121  char *name;
11122  char *value;
11123  char *namecopy;
11124  char *valuecopy;
11125 
11126  d = array_ref(array, 1, &i,
11127  -1 /* varlenarray */ ,
11128  -1 /* TEXT's typlen */ ,
11129  false /* TEXT's typbyval */ ,
11130  TYPALIGN_INT /* TEXT's typalign */ ,
11131  &isnull);
11132 
11133  if (isnull)
11134  continue;
11135 
11136  s = TextDatumGetCString(d);
11137 
11138  ParseLongOption(s, &name, &value);
11139  if (!value)
11140  {
11141  ereport(WARNING,
11142  (errcode(ERRCODE_SYNTAX_ERROR),
11143  errmsg("could not parse setting for parameter \"%s\"",
11144  name)));
11145  free(name);
11146  continue;
11147  }
11148 
11149  /* free malloc'd strings immediately to avoid leak upon error */
11150  namecopy = pstrdup(name);
11151  free(name);
11152  valuecopy = pstrdup(value);
11153  free(value);
11154 
11155  (void) set_config_option(namecopy, valuecopy,
11156  context, source,
11157  action, true, 0, false);
11158 
11159  pfree(namecopy);
11160  pfree(valuecopy);
11161  pfree(s);
11162  }
11163 }
void ParseLongOption(const char *string, char **name, char **value)
Definition: guc.c:11068

References generate_unaccent_rules::action, ARR_DIMS, ARR_ELEMTYPE, ARR_LBOUND, ARR_NDIM, array_ref(), Assert(), ereport, errcode(), errmsg(), free, i, name, ParseLongOption(), pfree(), pstrdup(), set_config_option(), source, TextDatumGetCString, value, and WARNING.

Referenced by ApplySetting(), fmgr_security_definer(), and ProcedureCreate().

◆ ReportChangedGUCOptions()

void ReportChangedGUCOptions ( void  )

Definition at line 6594 of file guc.c.

6595 {
6596  /* Quick exit if not (yet) enabled */
6597  if (!reporting_enabled)
6598  return;
6599 
6600  /*
6601  * Since in_hot_standby isn't actually changed by normal GUC actions, we
6602  * need a hack to check whether a new value needs to be reported to the
6603  * client. For speed, we rely on the assumption that it can never
6604  * transition from false to true.
6605  */
6607  {
6608  struct config_generic *record;
6609 
6610  record = find_option("in_hot_standby", false, false, ERROR);
6611  Assert(record != NULL);
6612  record->status |= GUC_NEEDS_REPORT;
6613  report_needed = true;
6614  in_hot_standby = false;
6615  }
6616 
6617  /* Quick exit if no values have been changed */
6618  if (!report_needed)
6619  return;
6620 
6621  /* Transmit new values of interesting variables */
6622  for (int i = 0; i < num_guc_variables; i++)
6623  {
6624  struct config_generic *conf = guc_variables[i];
6625 
6626  if ((conf->flags & GUC_REPORT) && (conf->status & GUC_NEEDS_REPORT))
6627  ReportGUCOption(conf);
6628  }
6629 
6630  report_needed = false;
6631 }

References Assert(), ERROR, find_option(), config_generic::flags, GUC_NEEDS_REPORT, GUC_REPORT, guc_variables, i, in_hot_standby, num_guc_variables, RecoveryInProgress(), report_needed, ReportGUCOption(), reporting_enabled, and config_generic::status.

Referenced by PostgresMain().

◆ ResetAllOptions()

void ResetAllOptions ( void  )

Definition at line 6045 of file guc.c.

6046 {
6047  int i;
6048 
6049  for (i = 0; i < num_guc_variables; i++)
6050  {
6051  struct config_generic *gconf = guc_variables[i];
6052 
6053  /* Don't reset non-SET-able values */
6054  if (gconf->context != PGC_SUSET &&
6055  gconf->context != PGC_USERSET)
6056  continue;
6057  /* Don't reset if special exclusion from RESET ALL */
6058  if (gconf->flags & GUC_NO_RESET_ALL)
6059  continue;
6060  /* No need to reset if wasn't SET */
6061  if (gconf->source <= PGC_S_OVERRIDE)
6062  continue;
6063 
6064  /* Save old value to support transaction abort */
6066 
6067  switch (gconf->vartype)
6068  {
6069  case PGC_BOOL:
6070  {
6071  struct config_bool *conf = (struct config_bool *) gconf;
6072 
6073  if (conf->assign_hook)
6074  conf->assign_hook(conf->reset_val,
6075  conf->reset_extra);
6076  *conf->variable = conf->reset_val;
6077  set_extra_field(&conf->gen, &conf->gen.extra,
6078  conf->reset_extra);
6079  break;
6080  }
6081  case PGC_INT:
6082  {
6083  struct config_int *conf = (struct config_int *) gconf;
6084 
6085  if (conf->assign_hook)
6086  conf->assign_hook(conf->reset_val,
6087  conf->reset_extra);
6088  *conf->variable = conf->reset_val;
6089  set_extra_field(&conf->gen, &conf->gen.extra,
6090  conf->reset_extra);
6091  break;
6092  }
6093  case PGC_REAL:
6094  {
6095  struct config_real *conf = (struct config_real *) gconf;
6096 
6097  if (conf->assign_hook)
6098  conf->assign_hook(conf->reset_val,
6099  conf->reset_extra);
6100  *conf->variable = conf->reset_val;
6101  set_extra_field(&conf->gen, &conf->gen.extra,
6102  conf->reset_extra);
6103  break;
6104  }
6105  case PGC_STRING:
6106  {
6107  struct config_string *conf = (struct config_string *) gconf;
6108 
6109  if (conf->assign_hook)
6110  conf->assign_hook(conf->reset_val,
6111  conf->reset_extra);
6112  set_string_field(conf, conf->variable, conf->reset_val);
6113  set_extra_field(&conf->gen, &conf->gen.extra,
6114  conf->reset_extra);
6115  break;
6116  }
6117  case PGC_ENUM:
6118  {
6119  struct config_enum *conf = (struct config_enum *) gconf;
6120 
6121  if (conf->assign_hook)
6122  conf->assign_hook(conf->reset_val,
6123  conf->reset_extra);
6124  *conf->variable = conf->reset_val;
6125  set_extra_field(&conf->gen, &conf->gen.extra,
6126  conf->reset_extra);
6127  break;
6128  }
6129  }
6130 
6131  gconf->source = gconf->reset_source;
6132  gconf->scontext = gconf->reset_scontext;
6133 
6134  if (gconf->flags & GUC_REPORT)
6135  {
6136  gconf->status |= GUC_NEEDS_REPORT;
6137  report_needed = true;
6138  }
6139  }
6140 }
static void push_old_value(struct config_generic *gconf, GucAction action)
Definition: guc.c:6148
#define GUC_NO_RESET_ALL
Definition: guc.h:207
void * reset_extra
Definition: guc_tables.h:186
void * reset_extra
Definition: guc_tables.h:247
GucContext reset_scontext
Definition: guc_tables.h:153
GucSource reset_source
Definition: guc_tables.h:151
void * reset_extra
Definition: guc_tables.h:202
void * reset_extra
Definition: guc_tables.h:218
void * reset_extra
Definition: guc_tables.h:232

References config_bool::assign_hook, config_int::assign_hook, config_real::assign_hook, config_string::assign_hook, config_enum::assign_hook, config_generic::context, config_generic::extra, config_generic::flags, config_bool::gen, config_int::gen, config_real::gen, config_string::gen, config_enum::gen, GUC_ACTION_SET, GUC_NEEDS_REPORT, GUC_NO_RESET_ALL, GUC_REPORT, guc_variables, i, num_guc_variables, PGC_BOOL, PGC_ENUM, PGC_INT, PGC_REAL, PGC_S_OVERRIDE, PGC_STRING, PGC_SUSET, PGC_USERSET, push_old_value(), report_needed, config_bool::reset_extra, config_int::reset_extra, config_real::reset_extra, config_string::reset_extra, config_enum::reset_extra, config_generic::reset_scontext, config_generic::reset_source, config_bool::reset_val, config_int::reset_val, config_real::reset_val, config_string::reset_val, config_enum::reset_val, config_generic::scontext, set_extra_field(), set_string_field(), config_generic::source, config_generic::status, config_bool::variable, config_int::variable, config_real::variable, config_string::variable, config_enum::variable, and config_generic::vartype.

Referenced by DiscardAll(), and ExecSetVariableStmt().

◆ RestoreGUCState()

void RestoreGUCState ( void *  gucstate)

Definition at line 10903 of file guc.c.

10904 {
10905  char *varname,
10906  *varvalue,
10907  *varsourcefile;
10908  int varsourceline;
10909  GucSource varsource;
10910  GucContext varscontext;
10911  char *srcptr = (char *) gucstate;
10912  char *srcend;
10913  Size len;
10914  int i;
10915  ErrorContextCallback error_context_callback;
10916 
10917  /*
10918  * First, ensure that all potentially-shippable GUCs are reset to their
10919  * default values. We must not touch those GUCs that the leader will
10920  * never ship, while there is no need to touch those that are shippable
10921  * but already have their default values. Thus, this ends up being the
10922  * same test that SerializeGUCState uses, even though the sets of
10923  * variables involved may well be different since the leader's set of
10924  * variables-not-at-default-values can differ from the set that are
10925  * not-default in this freshly started worker.
10926  *
10927  * Once we have set all the potentially-shippable GUCs to default values,
10928  * restoring the GUCs that the leader sent (because they had non-default
10929  * values over there) leads us to exactly the set of GUC values that the
10930  * leader has. This is true even though the worker may have initially
10931  * absorbed postgresql.conf settings that the leader hasn't yet seen, or
10932  * ALTER USER/DATABASE SET settings that were established after the leader
10933  * started.
10934  *
10935  * Note that ensuring all the potential target GUCs are at PGC_S_DEFAULT
10936  * also ensures that set_config_option won't refuse to set them because of
10937  * source-priority comparisons.
10938  */
10939  for (i = 0; i < num_guc_variables; i++)
10940  {
10941  struct config_generic *gconf = guc_variables[i];
10942 
10943  /* Do nothing if non-shippable or if already at PGC_S_DEFAULT. */
10944  if (can_skip_gucvar(gconf))
10945  continue;
10946 
10947  /*
10948  * We can use InitializeOneGUCOption to reset the GUC to default, but
10949  * first we must free any existing subsidiary data to avoid leaking
10950  * memory. The stack must be empty, but we have to clean up all other
10951  * fields. Beware that there might be duplicate value or "extra"
10952  * pointers.
10953  */
10954  Assert(gconf->stack == NULL);
10955  if (gconf->extra)
10956  free(gconf->extra);
10957  if (gconf->last_reported) /* probably can't happen */
10958  free(gconf->last_reported);
10959  if (gconf->sourcefile)
10960  free(gconf->sourcefile);
10961  switch (gconf->vartype)
10962  {
10963  case PGC_BOOL:
10964  {
10965  struct config_bool *conf = (struct config_bool *) gconf;
10966 
10967  if (conf->reset_extra && conf->reset_extra != gconf->extra)
10968  free(conf->reset_extra);
10969  break;
10970  }
10971  case PGC_INT:
10972  {
10973  struct config_int *conf = (struct config_int *) gconf;
10974 
10975  if (conf->reset_extra && conf->reset_extra != gconf->extra)
10976  free(conf->reset_extra);
10977  break;
10978  }
10979  case PGC_REAL:
10980  {
10981  struct config_real *conf = (struct config_real *) gconf;
10982 
10983  if (conf->reset_extra && conf->reset_extra != gconf->extra)
10984  free(conf->reset_extra);
10985  break;
10986  }
10987  case PGC_STRING:
10988  {
10989  struct config_string *conf = (struct config_string *) gconf;
10990 
10991  if (*conf->variable)
10992  free(*conf->variable);
10993  if (conf->reset_val && conf->reset_val != *conf->variable)
10994  free(conf->reset_val);
10995  if (conf->reset_extra && conf->reset_extra != gconf->extra)
10996  free(conf->reset_extra);
10997  break;
10998  }
10999  case PGC_ENUM:
11000  {
11001  struct config_enum *conf = (struct config_enum *) gconf;
11002 
11003  if (conf->reset_extra && conf->reset_extra != gconf->extra)
11004  free(conf->reset_extra);
11005  break;
11006  }
11007  }
11008  /* Now we can reset the struct to PGS_S_DEFAULT state. */
11009  InitializeOneGUCOption(gconf);
11010  }
11011 
11012  /* First item is the length of the subsequent data */
11013  memcpy(&len, gucstate, sizeof(len));
11014 
11015  srcptr += sizeof(len);
11016  srcend = srcptr + len;
11017 
11018  /* If the GUC value check fails, we want errors to show useful context. */
11019  error_context_callback.callback = guc_restore_error_context_callback;
11020  error_context_callback.previous = error_context_stack;
11021  error_context_callback.arg = NULL;
11022  error_context_stack = &error_context_callback;
11023 
11024  /* Restore all the listed GUCs. */
11025  while (srcptr < srcend)
11026  {
11027  int result;
11028  char *error_context_name_and_value[2];
11029 
11030  varname = read_gucstate(&srcptr, srcend);
11031  varvalue = read_gucstate(&srcptr, srcend);
11032  varsourcefile = read_gucstate(&srcptr, srcend);
11033  if (varsourcefile[0])
11034  read_gucstate_binary(&srcptr, srcend,
11035  &varsourceline, sizeof(varsourceline));
11036  else
11037  varsourceline = 0;
11038  read_gucstate_binary(&srcptr, srcend,
11039  &varsource, sizeof(varsource));
11040  read_gucstate_binary(&srcptr, srcend,
11041  &varscontext, sizeof(varscontext));
11042 
11043  error_context_name_and_value[0] = varname;
11044  error_context_name_and_value[1] = varvalue;
11045  error_context_callback.arg = &error_context_name_and_value[0];
11046  result = set_config_option(varname, varvalue, varscontext, varsource,
11047  GUC_ACTION_SET, true, ERROR, true);
11048  if (result <= 0)
11049  ereport(ERROR,
11050  (errcode(ERRCODE_INTERNAL_ERROR),
11051  errmsg("parameter \"%s\" could not be set", varname)));
11052  if (varsourcefile[0])
11053  set_config_sourcefile(varname, varsourcefile, varsourceline);
11054  error_context_callback.arg = NULL;
11055  }
11056 
11057  error_context_stack = error_context_callback.previous;
11058 }
ErrorContextCallback * error_context_stack
Definition: elog.c:93
static void guc_restore_error_context_callback(void *arg)
Definition: guc.c:10881
static void static void set_config_sourcefile(const char *name, char *sourcefile, int sourceline)
Definition: guc.c:8097
static char * read_gucstate(char **srcptr, char *srcend)
Definition: guc.c:10844
static bool can_skip_gucvar(struct config_generic *gconf)
Definition: guc.c:10535
static void read_gucstate_binary(char **srcptr, char *srcend, void *dest, Size size)
Definition: guc.c:10867
const void size_t len
struct ErrorContextCallback * previous
Definition: elog.h:232
void(* callback)(void *arg)
Definition: elog.h:233
char * last_reported
Definition: guc_tables.h:156

References ErrorContextCallback::arg, Assert(), ErrorContextCallback::callback, can_skip_gucvar(), ereport, errcode(), errmsg(), ERROR, error_context_stack, config_generic::extra, free, GUC_ACTION_SET, guc_restore_error_context_callback(), guc_variables, i, InitializeOneGUCOption(), config_generic::last_reported, len, num_guc_variables, PGC_BOOL, PGC_ENUM, PGC_INT, PGC_REAL, PGC_STRING, ErrorContextCallback::previous, read_gucstate(), read_gucstate_binary(), config_bool::reset_extra, config_int::reset_extra, config_real::reset_extra, config_string::reset_extra, config_enum::reset_extra, config_string::reset_val, set_config_option(), set_config_sourcefile(), config_generic::sourcefile, config_generic::stack, config_string::variable, and config_generic::vartype.

Referenced by ParallelWorkerMain().

◆ SelectConfigFiles()

bool SelectConfigFiles ( const char *  userDoption,
const char *  progname 
)

Definition at line 5870 of file guc.c.

5871 {
5872  char *configdir;
5873  char *fname;
5874  struct stat stat_buf;
5875 
5876  /* configdir is -D option, or $PGDATA if no -D */
5877  if (userDoption)
5878  configdir = make_absolute_path(userDoption);
5879  else
5880  configdir = make_absolute_path(getenv("PGDATA"));
5881 
5882  if (configdir && stat(configdir, &stat_buf) != 0)
5883  {
5884  write_stderr("%s: could not access directory \"%s\": %s\n",
5885  progname,
5886  configdir,
5887  strerror(errno));
5888  if (errno == ENOENT)
5889  write_stderr("Run initdb or pg_basebackup to initialize a PostgreSQL data directory.\n");
5890  return false;
5891  }
5892 
5893  /*
5894  * Find the configuration file: if config_file was specified on the
5895  * command line, use it, else use configdir/postgresql.conf. In any case
5896  * ensure the result is an absolute path, so that it will be interpreted
5897  * the same way by future backends.
5898  */
5899  if (ConfigFileName)
5901  else if (configdir)
5902  {
5903  fname = guc_malloc(FATAL,
5904  strlen(configdir) + strlen(CONFIG_FILENAME) + 2);
5905  sprintf(fname, "%s/%s", configdir, CONFIG_FILENAME);
5906  }
5907  else
5908  {
5909  write_stderr("%s does not know where to find the server configuration file.\n"
5910  "You must specify the --config-file or -D invocation "
5911  "option or set the PGDATA environment variable.\n",
5912  progname);
5913  return false;
5914  }
5915 
5916  /*
5917  * Set the ConfigFileName GUC variable to its final value, ensuring that
5918  * it can't be overridden later.
5919  */
5920  SetConfigOption("config_file", fname, PGC_POSTMASTER, PGC_S_OVERRIDE);
5921  free(fname);
5922 
5923  /*
5924  * Now read the config file for the first time.
5925  */
5926  if (stat(ConfigFileName, &stat_buf) != 0)
5927  {
5928  write_stderr("%s: could not access the server configuration file \"%s\": %s\n",
5929  progname, ConfigFileName, strerror(errno));
5930  free(configdir);
5931  return false;
5932  }
5933 
5934  /*
5935  * Read the configuration file for the first time. This time only the
5936  * data_directory parameter is picked up to determine the data directory,
5937  * so that we can read the PG_AUTOCONF_FILENAME file next time.
5938  */
5940 
5941  /*
5942  * If the data_directory GUC variable has been set, use that as DataDir;
5943  * otherwise use configdir if set; else punt.
5944  *
5945  * Note: SetDataDir will copy and absolute-ize its argument, so we don't
5946  * have to.
5947  */
5948  if (data_directory)
5950  else if (configdir)
5951  SetDataDir(configdir);
5952  else
5953  {
5954  write_stderr("%s does not know where to find the database system data.\n"
5955  "This can be specified as \"data_directory\" in \"%s\", "
5956  "or by the -D invocation option, or by the "
5957  "PGDATA environment variable.\n",
5959  return false;
5960  }
5961 
5962  /*
5963  * Reflect the final DataDir value back into the data_directory GUC var.
5964  * (If you are wondering why we don't just make them a single variable,
5965  * it's because the EXEC_BACKEND case needs DataDir to be transmitted to
5966  * child backends specially. XXX is that still true? Given that we now
5967  * chdir to DataDir, EXEC_BACKEND can read the config file without knowing
5968  * DataDir in advance.)
5969  */
5971 
5972  /*
5973  * Now read the config file a second time, allowing any settings in the
5974  * PG_AUTOCONF_FILENAME file to take effect. (This is pretty ugly, but
5975  * since we have to determine the DataDir before we can find the autoconf
5976  * file, the alternatives seem worse.)
5977  */
5979 
5980  /*
5981  * If timezone_abbreviations wasn't set in the configuration file, install
5982  * the default value. We do it this way because we can't safely install a
5983  * "real" value until my_exec_path is set, which may not have happened
5984  * when InitializeGUCOptions runs, so the bootstrap default value cannot
5985  * be the real desired default.
5986  */
5988 
5989  /*
5990  * Figure out where pg_hba.conf is, and make sure the path is absolute.
5991  */
5992  if (HbaFileName)
5994  else if (configdir)
5995  {
5996  fname = guc_malloc(FATAL,
5997  strlen(configdir) + strlen(HBA_FILENAME) + 2);
5998  sprintf(fname, "%s/%s", configdir, HBA_FILENAME);
5999  }
6000  else
6001  {
6002  write_stderr("%s does not know where to find the \"hba\" configuration file.\n"
6003  "This can be specified as \"hba_file\" in \"%s\", "
6004  "or by the -D invocation option, or by the "
6005  "PGDATA environment variable.\n",
6007  return false;
6008  }
6009  SetConfigOption("hba_file", fname, PGC_POSTMASTER, PGC_S_OVERRIDE);
6010  free(fname);
6011 
6012  /*
6013  * Likewise for pg_ident.conf.
6014  */
6015  if (IdentFileName)
6017  else if (configdir)
6018  {
6019  fname = guc_malloc(FATAL,
6020  strlen(configdir) + strlen(IDENT_FILENAME) + 2);
6021  sprintf(fname, "%s/%s", configdir, IDENT_FILENAME);
6022  }
6023  else
6024  {
6025  write_stderr("%s does not know where to find the \"ident\" configuration file.\n"
6026  "This can be specified as \"ident_file\" in \"%s\", "
6027  "or by the -D invocation option, or by the "
6028  "PGDATA environment variable.\n",
6030  return false;
6031  }
6032  SetConfigOption("ident_file", fname, PGC_POSTMASTER, PGC_S_OVERRIDE);
6033  free(fname);
6034 
6035  free(configdir);
6036 
6037  return true;
6038 }
#define write_stderr(str)
Definition: parallel.c:186
char * DataDir
Definition: globals.c:65
char * HbaFileName
Definition: guc.c:618
static void pg_timezone_abbrev_initialize(void)
Definition: guc.c:11977
char * ConfigFileName
Definition: guc.c:617
#define IDENT_FILENAME
Definition: guc.c:119
#define HBA_FILENAME
Definition: guc.c:118
char * IdentFileName
Definition: guc.c:619
static char * data_directory
Definition: guc.c:663
#define CONFIG_FILENAME
Definition: guc.c:117
void ProcessConfigFile(GucContext context)
const char * progname
Definition: main.c:46
void SetDataDir(const char *dir)
Definition: miscinit.c:414
char * make_absolute_path(const char *path)
Definition: path.c:608
#define sprintf
Definition: port.h:224
#define strerror
Definition: port.h:235
static const char * userDoption
Definition: postgres.c:173

References CONFIG_FILENAME, ConfigFileName, data_directory, DataDir, FATAL, free, guc_malloc(), HBA_FILENAME, HbaFileName, IDENT_FILENAME, IdentFileName, make_absolute_path(), pg_timezone_abbrev_initialize(), PGC_POSTMASTER, PGC_S_OVERRIDE, ProcessConfigFile(), progname, SetConfigOption(), SetDataDir(), sprintf, stat, strerror, userDoption, and write_stderr.

Referenced by BootstrapModeMain(), PostgresSingleUserMain(), and PostmasterMain().

◆ SerializeGUCState()

void SerializeGUCState ( Size  maxsize,
char *  start_address 
)

Definition at line 10817 of file guc.c.

10818 {
10819  char *curptr;
10820  Size actual_size;
10821  Size bytes_left;
10822  int i;
10823 
10824  /* Reserve space for saving the actual size of the guc state */
10825  Assert(maxsize > sizeof(actual_size));
10826  curptr = start_address + sizeof(actual_size);
10827  bytes_left = maxsize - sizeof(actual_size);
10828 
10829  for (i = 0; i < num_guc_variables; i++)
10830  serialize_variable(&curptr, &bytes_left, guc_variables[i]);
10831 
10832  /* Store actual size without assuming alignment of start_address. */
10833  actual_size = maxsize - bytes_left - sizeof(actual_size);
10834  memcpy(start_address, &actual_size, sizeof(actual_size));
10835 }
static void serialize_variable(char **destptr, Size *maxbytes, struct config_generic *gconf)
Definition: guc.c:10742

References Assert(), guc_variables, i, num_guc_variables, and serialize_variable().

Referenced by InitializeParallelDSM().

◆ set_config_option()

int set_config_option ( const char *  name,
const char *  value,
GucContext  context,
GucSource  source,
GucAction  action,
bool  changeVal,
int  elevel,
bool  is_reload 
)

Definition at line 7340 of file guc.c.

7344 {
7345  struct config_generic *record;
7346  union config_var_val newval_union;
7347  void *newextra = NULL;
7348  bool prohibitValueChange = false;
7349  bool makeDefault;
7350 
7351  if (elevel == 0)
7352  {
7353  if (source == PGC_S_DEFAULT || source == PGC_S_FILE)
7354  {
7355  /*
7356  * To avoid cluttering the log, only the postmaster bleats loudly
7357  * about problems with the config file.
7358  */
7360  }
7361  else if (source == PGC_S_GLOBAL ||
7362  source == PGC_S_DATABASE ||
7363  source == PGC_S_USER ||
7365  elevel = WARNING;
7366  else
7367  elevel = ERROR;
7368  }
7369 
7370  /*
7371  * GUC_ACTION_SAVE changes are acceptable during a parallel operation,
7372  * because the current worker will also pop the change. We're probably
7373  * dealing with a function having a proconfig entry. Only the function's
7374  * body should observe the change, and peer workers do not share in the
7375  * execution of a function call started by this worker.
7376  *
7377  * Other changes might need to affect other workers, so forbid them.
7378  */
7379  if (IsInParallelMode() && changeVal && action != GUC_ACTION_SAVE)
7380  ereport(elevel,
7381  (errcode(ERRCODE_INVALID_TRANSACTION_STATE),
7382  errmsg("cannot set parameters during a parallel operation")));
7383 
7384  record = find_option(name, true, false, elevel);
7385  if (record == NULL)
7386  return 0;
7387 
7388  /*
7389  * Check if the option can be set at this time. See guc.h for the precise
7390  * rules.
7391  */
7392  switch (record->context)
7393  {
7394  case PGC_INTERNAL:
7395  if (context != PGC_INTERNAL)
7396  {
7397  ereport(elevel,
7398  (errcode(ERRCODE_CANT_CHANGE_RUNTIME_PARAM),
7399  errmsg("parameter \"%s\" cannot be changed",
7400  name)));
7401  return 0;
7402  }
7403  break;
7404  case PGC_POSTMASTER:
7405  if (context == PGC_SIGHUP)
7406  {
7407  /*
7408  * We are re-reading a PGC_POSTMASTER variable from
7409  * postgresql.conf. We can't change the setting, so we should
7410  * give a warning if the DBA tries to change it. However,
7411  * because of variant formats, canonicalization by check
7412  * hooks, etc, we can't just compare the given string directly
7413  * to what's stored. Set a flag to check below after we have
7414  * the final storable value.
7415  */
7416  prohibitValueChange = true;
7417  }
7418  else if (context != PGC_POSTMASTER)
7419  {
7420  ereport(elevel,
7421  (errcode(ERRCODE_CANT_CHANGE_RUNTIME_PARAM),
7422  errmsg("parameter \"%s\" cannot be changed without restarting the server",
7423  name)));
7424  return 0;
7425  }
7426  break;
7427  case PGC_SIGHUP:
7428  if (context != PGC_SIGHUP && context != PGC_POSTMASTER)
7429  {
7430  ereport(elevel,
7431  (errcode(ERRCODE_CANT_CHANGE_RUNTIME_PARAM),
7432  errmsg("parameter \"%s\" cannot be changed now",
7433  name)));
7434  return 0;
7435  }
7436 
7437  /*
7438  * Hmm, the idea of the SIGHUP context is "ought to be global, but
7439  * can be changed after postmaster start". But there's nothing
7440  * that prevents a crafty administrator from sending SIGHUP
7441  * signals to individual backends only.
7442  */
7443  break;
7444  case PGC_SU_BACKEND:
7445  /* Reject if we're connecting but user is not superuser */
7446  if (context == PGC_BACKEND)
7447  {
7448  ereport(elevel,
7449  (errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
7450  errmsg("permission denied to set parameter \"%s\"",
7451  name)));
7452  return 0;
7453  }
7454  /* fall through to process the same as PGC_BACKEND */
7455  /* FALLTHROUGH */
7456  case PGC_BACKEND:
7457  if (context == PGC_SIGHUP)
7458  {
7459  /*
7460  * If a PGC_BACKEND or PGC_SU_BACKEND parameter is changed in
7461  * the config file, we want to accept the new value in the
7462  * postmaster (whence it will propagate to
7463  * subsequently-started backends), but ignore it in existing
7464  * backends. This is a tad klugy, but necessary because we
7465  * don't re-read the config file during backend start.
7466  *
7467  * In EXEC_BACKEND builds, this works differently: we load all
7468  * non-default settings from the CONFIG_EXEC_PARAMS file
7469  * during backend start. In that case we must accept
7470  * PGC_SIGHUP settings, so as to have the same value as if
7471  * we'd forked from the postmaster. This can also happen when
7472  * using RestoreGUCState() within a background worker that
7473  * needs to have the same settings as the user backend that
7474  * started it. is_reload will be true when either situation
7475  * applies.
7476  */
7477  if (IsUnderPostmaster && !is_reload)
7478  return -1;
7479  }
7480  else if (context != PGC_POSTMASTER &&
7481  context != PGC_BACKEND &&
7482  context != PGC_SU_BACKEND &&
7483  source != PGC_S_CLIENT)
7484  {
7485  ereport(elevel,
7486  (errcode(ERRCODE_CANT_CHANGE_RUNTIME_PARAM),
7487  errmsg("parameter \"%s\" cannot be set after connection start",
7488  name)));
7489  return 0;
7490  }
7491  break;
7492  case PGC_SUSET:
7493  if (context == PGC_USERSET || context == PGC_BACKEND)
7494  {
7495  ereport(elevel,
7496  (errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
7497  errmsg("permission denied to set parameter \"%s\"",
7498  name)));
7499  return 0;
7500  }
7501  break;
7502  case PGC_USERSET:
7503  /* always okay */
7504  break;
7505  }
7506 
7507  /*
7508  * Disallow changing GUC_NOT_WHILE_SEC_REST values if we are inside a
7509  * security restriction context. We can reject this regardless of the GUC
7510  * context or source, mainly because sources that it might be reasonable
7511  * to override for won't be seen while inside a function.
7512  *
7513  * Note: variables marked GUC_NOT_WHILE_SEC_REST should usually be marked
7514  * GUC_NO_RESET_ALL as well, because ResetAllOptions() doesn't check this.
7515  * An exception might be made if the reset value is assumed to be "safe".
7516  *
7517  * Note: this flag is currently used for "session_authorization" and
7518  * "role". We need to prohibit changing these inside a local userid
7519  * context because when we exit it, GUC won't be notified, leaving things
7520  * out of sync. (This could be fixed by forcing a new GUC nesting level,
7521  * but that would change behavior in possibly-undesirable ways.) Also, we
7522  * prohibit changing these in a security-restricted operation because
7523  * otherwise RESET could be used to regain the session user's privileges.
7524  */
7525  if (record->flags & GUC_NOT_WHILE_SEC_REST)
7526  {
7527  if (InLocalUserIdChange())
7528  {
7529  /*
7530  * Phrasing of this error message is historical, but it's the most
7531  * common case.
7532  */
7533  ereport(elevel,
7534  (errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
7535  errmsg("cannot set parameter \"%s\" within security-definer function",
7536  name)));
7537  return 0;
7538  }
7540  {
7541  ereport(elevel,
7542  (errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
7543  errmsg("cannot set parameter \"%s\" within security-restricted operation",
7544  name)));
7545  return 0;
7546  }
7547  }
7548 
7549  /*
7550  * Should we set reset/stacked values? (If so, the behavior is not
7551  * transactional.) This is done either when we get a default value from
7552  * the database's/user's/client's default settings or when we reset a
7553  * value to its default.
7554  */
7555  makeDefault = changeVal && (source <= PGC_S_OVERRIDE) &&
7556  ((value != NULL) || source == PGC_S_DEFAULT);
7557 
7558  /*
7559  * Ignore attempted set if overridden by previously processed setting.
7560  * However, if changeVal is false then plow ahead anyway since we are
7561  * trying to find out if the value is potentially good, not actually use
7562  * it. Also keep going if makeDefault is true, since we may want to set
7563  * the reset/stacked values even if we can't set the variable itself.
7564  */
7565  if (record->source > source)
7566  {
7567  if (changeVal && !makeDefault)
7568  {
7569  elog(DEBUG3, "\"%s\": setting ignored because previous source is higher priority",
7570  name);
7571  return -1;
7572  }
7573  changeVal = false;
7574  }
7575 
7576  /*
7577  * Evaluate value and set variable.
7578  */
7579  switch (record->vartype)
7580  {
7581  case PGC_BOOL:
7582  {
7583  struct config_bool *conf = (struct config_bool *) record;
7584 
7585 #define newval (newval_union.boolval)
7586 
7587  if (value)
7588  {
7589  if (!parse_and_validate_value(record, name, value,
7590  source, elevel,
7591  &newval_union, &newextra))
7592  return 0;
7593  }
7594  else if (source == PGC_S_DEFAULT)
7595  {
7596  newval = conf->boot_val;
7597  if (!call_bool_check_hook(conf, &newval, &newextra,
7598  source, elevel))
7599  return 0;
7600  }
7601  else
7602  {
7603  newval = conf->reset_val;
7604  newextra = conf->reset_extra;
7605  source = conf->gen.reset_source;
7606  context = conf->gen.reset_scontext;
7607  }
7608 
7609  if (prohibitValueChange)
7610  {
7611  /* Release newextra, unless it's reset_extra */
7612  if (newextra && !extra_field_used(&conf->gen, newextra))
7613  free(newextra);
7614 
7615  if (*conf->variable != newval)
7616  {
7617  record->status |= GUC_PENDING_RESTART;
7618  ereport(elevel,
7619  (errcode(ERRCODE_CANT_CHANGE_RUNTIME_PARAM),
7620  errmsg("parameter \"%s\" cannot be changed without restarting the server",
7621  name)));
7622  return 0;
7623  }
7624  record->status &= ~GUC_PENDING_RESTART;
7625  return -1;
7626  }
7627 
7628  if (changeVal)
7629  {
7630  /* Save old value to support transaction abort */
7631  if (!makeDefault)
7632  push_old_value(&conf->gen, action);
7633 
7634  if (conf->assign_hook)
7635  conf->assign_hook(newval, newextra);
7636  *conf->variable = newval;
7637  set_extra_field(&conf->gen, &conf->gen.extra,
7638  newextra);
7639  conf->gen.source = source;
7640  conf->gen.scontext = context;
7641  }
7642  if (makeDefault)
7643  {
7644  GucStack *stack;
7645 
7646  if (conf->gen.reset_source <= source)
7647  {
7648  conf->reset_val = newval;
7649  set_extra_field(&conf->gen, &conf->reset_extra,
7650  newextra);
7651  conf->gen.reset_source = source;
7652  conf->gen.reset_scontext = context;
7653  }
7654  for (stack = conf->gen.stack; stack; stack = stack->prev)
7655  {
7656  if (stack->source <= source)
7657  {
7658  stack->prior.val.boolval = newval;
7659  set_extra_field(&conf->gen, &stack->prior.extra,
7660  newextra);
7661  stack->source = source;
7662  stack->scontext = context;
7663  }
7664  }
7665  }
7666 
7667  /* Perhaps we didn't install newextra anywhere */
7668  if (newextra && !extra_field_used(&conf->gen, newextra))
7669  free(newextra);
7670  break;
7671 
7672 #undef newval
7673  }
7674 
7675  case PGC_INT:
7676  {
7677  struct config_int *conf = (struct config_int *) record;
7678 
7679 #define newval (newval_union.intval)
7680 
7681  if (value)
7682  {
7683  if (!parse_and_validate_value(record, name, value,
7684  source, elevel,
7685  &newval_union, &newextra))
7686  return 0;
7687  }
7688  else if (source == PGC_S_DEFAULT)
7689  {
7690  newval = conf->boot_val;
7691  if (!call_int_check_hook(conf, &newval, &newextra,
7692  source, elevel))
7693  return 0;
7694  }
7695  else
7696  {
7697  newval = conf->reset_val;
7698  newextra = conf->reset_extra;
7699  source = conf->gen.reset_source;
7700  context = conf->gen.reset_scontext;
7701  }
7702 
7703  if (prohibitValueChange)
7704  {
7705  /* Release newextra, unless it's reset_extra */
7706  if (newextra && !extra_field_used(&conf->gen, newextra))
7707  free(newextra);
7708 
7709  if (*conf->variable != newval)
7710  {
7711  record->status |= GUC_PENDING_RESTART;
7712  ereport(elevel,
7713  (errcode(ERRCODE_CANT_CHANGE_RUNTIME_PARAM),
7714  errmsg("parameter \"%s\" cannot be changed without restarting the server",
7715  name)));
7716  return 0;
7717  }
7718  record->status &= ~GUC_PENDING_RESTART;
7719  return -1;
7720  }
7721 
7722  if (changeVal)
7723  {
7724  /* Save old value to support transaction abort */
7725  if (!makeDefault)
7726  push_old_value(&conf->gen, action);
7727 
7728  if (conf->assign_hook)
7729  conf->assign_hook(newval, newextra);
7730  *conf->variable = newval;
7731  set_extra_field(&conf->gen, &conf->gen.extra,
7732  newextra);
7733  conf->gen.source = source;
7734  conf->gen.scontext = context;
7735  }
7736  if (makeDefault)
7737  {
7738  GucStack *stack;
7739 
7740  if (conf->gen.reset_source <= source)
7741  {
7742  conf->reset_val = newval;
7743  set_extra_field(&conf->gen, &conf->reset_extra,
7744  newextra);
7745  conf->gen.reset_source = source;
7746  conf->gen.reset_scontext = context;
7747  }
7748  for (stack = conf->gen.stack; stack; stack = stack->prev)
7749  {
7750  if (stack->source <= source)
7751  {
7752  stack->prior.val.intval = newval;
7753  set_extra_field(&conf->gen, &stack->prior.extra,
7754  newextra);
7755  stack->source = source;
7756  stack->scontext = context;
7757  }
7758  }
7759  }
7760 
7761  /* Perhaps we didn't install newextra anywhere */
7762  if (newextra && !extra_field_used(&conf->gen, newextra))
7763  free(newextra);
7764  break;
7765 
7766 #undef newval
7767  }
7768 
7769  case PGC_REAL:
7770  {
7771  struct config_real *conf = (struct config_real *) record;
7772 
7773 #define newval (newval_union.realval)
7774 
7775  if (value)
7776  {
7777  if (!parse_and_validate_value(record, name, value,
7778  source, elevel,
7779  &newval_union, &newextra))
7780  return 0;
7781  }
7782  else if (source == PGC_S_DEFAULT)
7783  {
7784  newval = conf->boot_val;
7785  if (!call_real_check_hook(conf, &newval, &newextra,
7786  source, elevel))
7787  return 0;
7788  }
7789  else
7790  {
7791  newval = conf->reset_val;
7792  newextra = conf->reset_extra;
7793  source = conf->gen.reset_source;
7794  context = conf->gen.reset_scontext;
7795  }
7796 
7797  if (prohibitValueChange)
7798  {
7799  /* Release newextra, unless it's reset_extra */
7800  if (newextra && !extra_field_used(&conf->gen, newextra))
7801  free(newextra);
7802 
7803  if (*conf->variable != newval)
7804  {
7805  record->status |= GUC_PENDING_RESTART;
7806  ereport(elevel,
7807  (errcode(ERRCODE_CANT_CHANGE_RUNTIME_PARAM),
7808  errmsg("parameter \"%s\" cannot be changed without restarting the server",
7809  name)));
7810  return 0;
7811  }
7812  record->status &= ~GUC_PENDING_RESTART;
7813  return -1;
7814  }
7815 
7816  if (changeVal)
7817  {
7818  /* Save old value to support transaction abort */
7819  if (!makeDefault)
7820  push_old_value(&conf->gen, action);
7821 
7822  if (conf->assign_hook)
7823  conf->assign_hook(newval, newextra);
7824  *conf->variable = newval;
7825  set_extra_field(&conf->gen, &conf->gen.extra,
7826  newextra);
7827  conf->gen.source = source;
7828  conf->gen.scontext = context;
7829  }
7830  if (makeDefault)
7831  {
7832  GucStack *stack;
7833 
7834  if (conf->gen.reset_source <= source)
7835  {
7836  conf->reset_val = newval;
7837  set_extra_field(&conf->gen, &conf->reset_extra,
7838  newextra);
7839  conf->gen.reset_source = source;
7840  conf->gen.reset_scontext = context;
7841  }
7842  for (stack = conf->gen.stack; stack; stack = stack->prev)
7843  {
7844  if (stack->source <= source)
7845  {
7846  stack->prior.val.realval = newval;
7847  set_extra_field(&conf->gen, &stack->prior.extra,
7848  newextra);
7849  stack->source = source;
7850  stack->scontext = context;
7851  }
7852  }
7853  }
7854 
7855  /* Perhaps we didn't install newextra anywhere */
7856  if (newextra && !extra_field_used(&conf->gen, newextra))
7857  free(newextra);
7858  break;
7859 
7860 #undef newval
7861  }
7862 
7863  case PGC_STRING:
7864  {
7865  struct config_string *conf = (struct config_string *) record;
7866 
7867 #define newval (newval_union.stringval)
7868 
7869  if (value)
7870  {
7871  if (!parse_and_validate_value(record, name, value,
7872  source, elevel,
7873  &newval_union, &newextra))
7874  return 0;
7875  }
7876  else if (source == PGC_S_DEFAULT)
7877  {
7878  /* non-NULL boot_val must always get strdup'd */
7879  if (conf->boot_val != NULL)
7880  {
7881  newval = guc_strdup(elevel, conf->boot_val);
7882  if (newval == NULL)
7883  return 0;
7884  }
7885  else
7886  newval = NULL;
7887 
7888  if (!call_string_check_hook(conf, &newval, &newextra,
7889  source, elevel))
7890  {
7891  free(newval);
7892  return 0;
7893  }
7894  }
7895  else
7896  {
7897  /*
7898  * strdup not needed, since reset_val is already under
7899  * guc.c's control
7900  */
7901  newval = conf->reset_val;
7902  newextra = conf->reset_extra;
7903  source = conf->gen.reset_source;
7904  context = conf->gen.reset_scontext;
7905  }
7906 
7907  if (prohibitValueChange)
7908  {
7909  bool newval_different;
7910 
7911  /* newval shouldn't be NULL, so we're a bit sloppy here */
7912  newval_different = (*conf->variable == NULL ||
7913  newval == NULL ||
7914  strcmp(*conf->variable, newval) != 0);
7915 
7916  /* Release newval, unless it's reset_val */
7917  if (newval && !string_field_used(conf, newval))
7918  free(newval);
7919  /* Release newextra, unless it's reset_extra */
7920  if (newextra && !extra_field_used(&conf->gen, newextra))
7921  free(newextra);
7922 
7923  if (newval_different)
7924  {
7925  record->status |= GUC_PENDING_RESTART;
7926  ereport(elevel,
7927  (errcode(ERRCODE_CANT_CHANGE_RUNTIME_PARAM),
7928  errmsg("parameter \"%s\" cannot be changed without restarting the server",
7929  name)));
7930  return 0;
7931  }
7932  record->status &= ~GUC_PENDING_RESTART;
7933  return -1;
7934  }
7935 
7936  if (changeVal)
7937  {
7938  /* Save old value to support transaction abort */
7939  if (!makeDefault)
7940  push_old_value(&conf->gen, action);
7941 
7942  if (conf->assign_hook)
7943  conf->assign_hook(newval, newextra);
7944  set_string_field(conf, conf->variable, newval);
7945  set_extra_field(&conf->gen, &conf->gen.extra,
7946  newextra);
7947  conf->gen.source = source;
7948  conf->gen.scontext = context;
7949  }
7950 
7951  if (makeDefault)
7952  {
7953  GucStack *stack;
7954 
7955  if (conf->gen.reset_source <= source)
7956  {
7957  set_string_field(conf, &conf->reset_val, newval);
7958  set_extra_field(&conf->gen, &conf->reset_extra,
7959  newextra);
7960  conf->gen.reset_source = source;
7961  conf->gen.reset_scontext = context;
7962  }
7963  for (stack = conf->gen.stack; stack; stack = stack->prev)
7964  {
7965  if (stack->source <= source)
7966  {
7967  set_string_field(conf, &stack->prior.val.stringval,
7968  newval);
7969  set_extra_field(&conf->gen, &stack->prior.extra,
7970  newextra);
7971  stack->source = source;
7972  stack->scontext = context;
7973  }
7974  }
7975  }
7976 
7977  /* Perhaps we didn't install newval anywhere */
7978  if (newval && !string_field_used(conf, newval))
7979  free(newval);
7980  /* Perhaps we didn't install newextra anywhere */
7981  if (newextra && !extra_field_used(&conf->gen, newextra))
7982  free(newextra);
7983  break;
7984 
7985 #undef newval
7986  }
7987 
7988  case PGC_ENUM:
7989  {
7990  struct config_enum *conf = (struct config_enum *) record;
7991 
7992 #define newval (newval_union.enumval)
7993 
7994  if (value)
7995  {
7996  if (!parse_and_validate_value(record, name, value,
7997  source, elevel,
7998  &newval_union, &newextra))
7999  return 0;
8000  }
8001  else if (source == PGC_S_DEFAULT)
8002  {
8003  newval = conf->boot_val;
8004  if (!call_enum_check_hook(conf, &newval, &newextra,
8005  source, elevel))
8006  return 0;
8007  }
8008  else
8009  {
8010  newval = conf->reset_val;
8011  newextra = conf->reset_extra;
8012  source = conf->gen.reset_source;
8013  context = conf->gen.reset_scontext;
8014  }
8015 
8016  if (prohibitValueChange)
8017  {
8018  /* Release newextra, unless it's reset_extra */
8019  if (newextra && !extra_field_used(&conf->gen, newextra))
8020  free(newextra);
8021 
8022  if (*conf->variable != newval)
8023  {
8024  record->status |= GUC_PENDING_RESTART;
8025  ereport(elevel,
8026  (errcode(ERRCODE_CANT_CHANGE_RUNTIME_PARAM),
8027  errmsg("parameter \"%s\" cannot be changed without restarting the server",
8028  name)));
8029  return 0;
8030  }
8031  record->status &= ~GUC_PENDING_RESTART;
8032  return -1;
8033  }
8034 
8035  if (changeVal)
8036  {
8037  /* Save old value to support transaction abort */
8038  if (!makeDefault)
8039  push_old_value(&conf->gen, action);
8040 
8041  if (conf->assign_hook)
8042  conf->assign_hook(newval, newextra);
8043  *conf->variable = newval;
8044  set_extra_field(&conf->gen, &conf->gen.extra,
8045  newextra);
8046  conf->gen.source = source;
8047  conf->gen.scontext = context;
8048  }
8049  if (makeDefault)
8050  {
8051  GucStack *stack;
8052 
8053  if (conf->gen.reset_source <= source)
8054  {
8055  conf->reset_val = newval;
8056  set_extra_field(&conf->gen, &conf->reset_extra,
8057  newextra);
8058  conf->gen.reset_source = source;
8059  conf->gen.reset_scontext = context;
8060  }
8061  for (stack = conf->gen.stack; stack; stack = stack->prev)
8062  {
8063  if (stack->source <= source)
8064  {
8065  stack->prior.val.enumval = newval;
8066  set_extra_field(&conf->gen, &stack->prior.extra,
8067  newextra);
8068  stack->source = source;
8069  stack->scontext = context;
8070  }
8071  }
8072  }
8073 
8074  /* Perhaps we didn't install newextra anywhere */
8075  if (newextra && !extra_field_used(&conf->gen, newextra))
8076  free(newextra);
8077  break;
8078 
8079 #undef newval
8080  }
8081  }
8082 
8083  if (changeVal && (record->flags & GUC_REPORT))
8084  {
8085  record->status |= GUC_NEEDS_REPORT;
8086  report_needed = true;
8087  }
8088 
8089  return changeVal ? 1 : -1;
8090 }
#define DEBUG3
Definition: elog.h:22
bool IsUnderPostmaster
Definition: globals.c:112
static bool call_string_check_hook(struct config_string *conf, char **newval, void **extra, GucSource source, int elevel)
Definition: guc.c:11584
static bool extra_field_used(struct config_generic *gconf, void *extra)
Definition: guc.c:5174
static bool call_bool_check_hook(struct config_bool *conf, bool *newval, void **extra, GucSource source, int elevel)
Definition: guc.c:11482
static bool call_int_check_hook(struct config_int *conf, int *newval, void **extra, GucSource source, int elevel)
Definition: guc.c:11516
static bool string_field_used(struct config_string *conf, char *strval)
Definition: guc.c:5135
static bool call_real_check_hook(struct config_real *conf, double *newval, void **extra, GucSource source, int elevel)
Definition: guc.c:11550
static bool call_enum_check_hook(struct config_enum *conf, int *newval, void **extra, GucSource source, int elevel)
Definition: guc.c:11634
#define GUC_NOT_WHILE_SEC_REST
Definition: guc.h:214
bool InSecurityRestrictedOperation(void)
Definition: miscinit.c:627
bool InLocalUserIdChange(void)
Definition: miscinit.c:618
static int elevel
Definition: vacuumlazy.c:376

References generate_unaccent_rules::action, config_bool::assign_hook, config_int::assign_hook, config_real::assign_hook, config_string::assign_hook, config_enum::assign_hook, config_var_val::boolval, config_bool::boot_val, config_int::boot_val, config_real::boot_val, config_string::boot_val, config_enum::boot_val, call_bool_check_hook(), call_enum_check_hook(), call_int_check_hook(), call_real_check_hook(), call_string_check_hook(), config_generic::context, DEBUG3, elevel, elog, config_var_val::enumval, ereport, errcode(), errmsg(), ERROR, config_var_value::extra, config_generic::extra, extra_field_used(), find_option(), config_generic::flags, free, config_bool::gen, config_int::gen, config_real::gen, config_string::gen, config_enum::gen, GUC_ACTION_SAVE, GUC_NEEDS_REPORT, GUC_NOT_WHILE_SEC_REST, GUC_PENDING_RESTART, GUC_REPORT, guc_strdup(), InLocalUserIdChange(), InSecurityRestrictedOperation(), config_var_val::intval, IsInParallelMode(), IsUnderPostmaster, LOG, name, newval, parse_and_validate_value(), PGC_BACKEND, PGC_BOOL, PGC_ENUM, PGC_INT, PGC_INTERNAL, PGC_POSTMASTER, PGC_REAL, PGC_S_CLIENT, PGC_S_DATABASE, PGC_S_DATABASE_USER, PGC_S_DEFAULT, PGC_S_FILE, PGC_S_GLOBAL, PGC_S_OVERRIDE, PGC_S_USER, PGC_SIGHUP, PGC_STRING, PGC_SU_BACKEND, PGC_SUSET, PGC_USERSET, guc_stack::prev, guc_stack::prior, push_old_value(), config_var_val::realval, report_needed, config_bool::reset_extra, config_int::reset_extra, config_real::reset_extra, config_string::reset_extra, config_enum::reset_extra, config_generic::reset_scontext, config_generic::reset_source, config_bool::reset_val, config_int::reset_val, config_real::reset_val, config_string::reset_val, config_enum::reset_val, guc_stack::scontext, config_generic::scontext, set_extra_field(), set_string_field(), source, guc_stack::source, config_generic::source, config_generic::stack, config_generic::status, string_field_used(), config_var_val::stringval, config_var_value::val, value, config_bool::variable, config_int::variable, config_real::variable, config_string::variable, config_enum::variable, config_generic::vartype, and WARNING.

Referenced by applyRemoteGucs(), define_custom_variable(), DefineIndex(), ExecSetVariableStmt(), execute_extension_script(), parse_subscription_options(), ProcessGUCArray(), reapply_stacked_values(), RestoreGUCState(), RI_Initial_Check(), RI_PartitionRemove_Check(), set_config_by_name(), set_transmission_modes(), SetConfigOption(), SetPGVariable(), and validate_option_array_item().

◆ SetConfigOption()

◆ SetPGVariable()

void SetPGVariable ( const char *  name,
List args,
bool  is_local 
)

Definition at line 8889 of file guc.c.

8890 {
8891  char *argstring = flatten_set_variable_args(name, args);
8892 
8893  /* Note SET DEFAULT (argstring == NULL) is equivalent to RESET */
8894  (void) set_config_option(name,
8895  argstring,
8897  PGC_S_SESSION,
8898  is_local ? GUC_ACTION_LOCAL : GUC_ACTION_SET,
8899  true, 0, false);
8900 }

References generate_unaccent_rules::args, flatten_set_variable_args(), GUC_ACTION_LOCAL, GUC_ACTION_SET, name, PGC_S_SESSION, PGC_SUSET, PGC_USERSET, set_config_option(), and superuser().

Referenced by DiscardAll(), ExecSetVariableStmt(), and standard_ProcessUtility().

Variable Documentation

◆ application_name

◆ backtrace_functions

char* backtrace_functions
extern

Definition at line 609 of file guc.c.

Referenced by errfinish().

◆ backtrace_symbol_list

char* backtrace_symbol_list
extern

Definition at line 610 of file guc.c.

Referenced by assign_backtrace_functions(), and matches_backtrace_functions().

◆ check_function_bodies

◆ client_min_messages

PGDLLIMPORT int client_min_messages
extern

Definition at line 600 of file guc.c.

Referenced by execute_extension_script(), and should_output_to_client().

◆ cluster_name

char* cluster_name
extern

Definition at line 616 of file guc.c.

Referenced by init_ps_display(), and WalReceiverMain().

◆ ConfigFileName

PGDLLIMPORT char* ConfigFileName
extern

Definition at line 617 of file guc.c.

Referenced by SelectConfigFiles().

◆ Debug_pretty_print

bool Debug_pretty_print
extern

Definition at line 578 of file guc.c.

Referenced by pg_plan_query(), and pg_rewrite_query().

◆ Debug_print_parse

bool Debug_print_parse
extern

Definition at line 576 of file guc.c.

Referenced by pg_rewrite_query().

◆ Debug_print_plan

bool Debug_print_plan
extern

Definition at line 575 of file guc.c.

Referenced by pg_plan_query().

◆ Debug_print_rewritten

bool Debug_print_rewritten
extern

Definition at line 577 of file guc.c.

Referenced by pg_rewrite_query().

◆ external_pid_file

char* external_pid_file
extern

Definition at line 620 of file guc.c.

Referenced by PostmasterMain(), and unlink_external_pid_file().

◆ GUC_check_errdetail_string

PGDLLIMPORT char* GUC_check_errdetail_string
extern

◆ GUC_check_errhint_string

PGDLLIMPORT char* GUC_check_errhint_string
extern

◆ GUC_check_errmsg_string

PGDLLIMPORT char* GUC_check_errmsg_string
extern

◆ HbaFileName

char* HbaFileName
extern

◆ IdentFileName

char* IdentFileName
extern

Definition at line 619 of file guc.c.

Referenced by load_ident(), and SelectConfigFiles().

◆ log_btree_build_stats

bool log_btree_build_stats
extern

◆ log_duration

bool log_duration
extern

Definition at line 574 of file guc.c.

Referenced by check_log_duration().

◆ log_executor_stats

bool log_executor_stats
extern

Definition at line 582 of file guc.c.

Referenced by check_log_stats(), PortalRun(), and PortalRunMulti().

◆ log_min_duration_sample

int log_min_duration_sample
extern

Definition at line 601 of file guc.c.

Referenced by check_log_duration().

◆ log_min_duration_statement

int log_min_duration_statement
extern

Definition at line 602 of file guc.c.

Referenced by check_log_duration().

◆ log_min_error_statement

int log_min_error_statement
extern

Definition at line 598 of file guc.c.

Referenced by send_message_to_server_log(), and write_csvlog().

◆ log_min_messages

PGDLLIMPORT int log_min_messages
extern

Definition at line 599 of file guc.c.

Referenced by execute_extension_script(), and should_output_to_server().

◆ log_parameter_max_length

int log_parameter_max_length
extern

Definition at line 603 of file guc.c.

Referenced by errdetail_params().

◆ log_parameter_max_length_on_error

int log_parameter_max_length_on_error
extern

Definition at line 604 of file guc.c.

Referenced by bind_param_error_callback(), and exec_bind_message().

◆ log_parser_stats

◆ log_planner_stats

bool log_planner_stats
extern

Definition at line 581 of file guc.c.

Referenced by check_log_stats(), and pg_plan_query().

◆ log_statement_sample_rate

double log_statement_sample_rate
extern

Definition at line 606 of file guc.c.

Referenced by check_log_duration().

◆ log_statement_stats

bool log_statement_stats
extern

◆ log_temp_files

int log_temp_files
extern

Definition at line 605 of file guc.c.

Referenced by ReportTemporaryFileUsage().

◆ log_xact_sample_rate

double log_xact_sample_rate
extern

Definition at line 607 of file guc.c.

Referenced by StartTransaction().