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 EmitWarningsOnPlaceholders(className)   MarkGUCPrefixReserved(className)
 
#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 MarkGUCPrefixReserved (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)
 
char * convert_GUC_name_for_parameter_acl (const char *name)
 
bool check_GUC_name_for_parameter_acl (const char *name)
 
void InitializeGUCOptions (void)
 
void InitializeWalConsistencyChecking (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)
 
bool check_recovery_prefetch (int *new_value, void **extra, GucSource source)
 
void assign_recovery_prefetch (int new_value, void *extra)
 

Variables

PGDLLIMPORT bool Debug_print_plan
 
PGDLLIMPORT bool Debug_print_parse
 
PGDLLIMPORT bool Debug_print_rewritten
 
PGDLLIMPORT bool Debug_pretty_print
 
PGDLLIMPORT bool log_parser_stats
 
PGDLLIMPORT bool log_planner_stats
 
PGDLLIMPORT bool log_executor_stats
 
PGDLLIMPORT bool log_statement_stats
 
PGDLLIMPORT bool log_btree_build_stats
 
PGDLLIMPORT bool check_function_bodies
 
PGDLLIMPORT bool session_auth_is_superuser
 
PGDLLIMPORT bool log_duration
 
PGDLLIMPORT int log_parameter_max_length
 
PGDLLIMPORT int log_parameter_max_length_on_error
 
PGDLLIMPORT int log_min_error_statement
 
PGDLLIMPORT int log_min_messages
 
PGDLLIMPORT int client_min_messages
 
PGDLLIMPORT int log_min_duration_sample
 
PGDLLIMPORT int log_min_duration_statement
 
PGDLLIMPORT int log_temp_files
 
PGDLLIMPORT double log_statement_sample_rate
 
PGDLLIMPORT double log_xact_sample_rate
 
PGDLLIMPORT char * backtrace_functions
 
PGDLLIMPORT char * backtrace_symbol_list
 
PGDLLIMPORT int temp_file_limit
 
PGDLLIMPORT int num_temp_buffers
 
PGDLLIMPORT char * cluster_name
 
PGDLLIMPORT char * ConfigFileName
 
PGDLLIMPORT char * HbaFileName
 
PGDLLIMPORT char * IdentFileName
 
PGDLLIMPORT char * external_pid_file
 
PGDLLIMPORT char * application_name
 
PGDLLIMPORT int tcp_keepalives_idle
 
PGDLLIMPORT int tcp_keepalives_interval
 
PGDLLIMPORT int tcp_keepalives_count
 
PGDLLIMPORT 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

◆ EmitWarningsOnPlaceholders

#define EmitWarningsOnPlaceholders (   className)    MarkGUCPrefixReserved(className)

Definition at line 359 of file guc.h.

◆ 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:1462
char * format_elog_string(const char *fmt,...)
Definition: elog.c:1471
#define TEXTDOMAIN
Definition: elog.h:146

Definition at line 427 of file guc.h.

◆ GUC_check_errhint

#define GUC_check_errhint
Value:
GUC_check_errhint_string = format_elog_string

Definition at line 431 of file guc.h.

◆ GUC_check_errmsg

#define GUC_check_errmsg
Value:
GUC_check_errmsg_string = format_elog_string

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

8773 {
8774  char *name;
8775  char *value;
8776  bool resetall = false;
8777  ConfigVariable *head = NULL;
8778  ConfigVariable *tail = NULL;
8779  volatile int Tmpfd;
8780  char AutoConfFileName[MAXPGPATH];
8781  char AutoConfTmpFileName[MAXPGPATH];
8782 
8783  /*
8784  * Extract statement arguments
8785  */
8786  name = altersysstmt->setstmt->name;
8787 
8788  switch (altersysstmt->setstmt->kind)
8789  {
8790  case VAR_SET_VALUE:
8791  value = ExtractSetVariableArgs(altersysstmt->setstmt);
8792  break;
8793 
8794  case VAR_SET_DEFAULT:
8795  case VAR_RESET:
8796  value = NULL;
8797  break;
8798 
8799  case VAR_RESET_ALL:
8800  value = NULL;
8801  resetall = true;
8802  break;
8803 
8804  default:
8805  elog(ERROR, "unrecognized alter system stmt type: %d",
8806  altersysstmt->setstmt->kind);
8807  break;
8808  }
8809 
8810  /*
8811  * Check permission to run ALTER SYSTEM on the target variable
8812  */
8813  if (!superuser())
8814  {
8815  if (resetall)
8816  ereport(ERROR,
8817  (errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
8818  errmsg("permission denied to perform ALTER SYSTEM RESET ALL")));
8819  else
8820  {
8821  AclResult aclresult;
8822 
8823  aclresult = pg_parameter_aclcheck(name, GetUserId(),
8825  if (aclresult != ACLCHECK_OK)
8826  ereport(ERROR,
8827  (errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
8828  errmsg("permission denied to set parameter \"%s\"",
8829  name)));
8830  }
8831  }
8832 
8833  /*
8834  * Unless it's RESET_ALL, validate the target variable and value
8835  */
8836  if (!resetall)
8837  {
8838  struct config_generic *record;
8839 
8840  record = find_option(name, false, false, ERROR);
8841  Assert(record != NULL);
8842 
8843  /*
8844  * Don't allow parameters that can't be set in configuration files to
8845  * be set in PG_AUTOCONF_FILENAME file.
8846  */
8847  if ((record->context == PGC_INTERNAL) ||
8848  (record->flags & GUC_DISALLOW_IN_FILE) ||
8849  (record->flags & GUC_DISALLOW_IN_AUTO_FILE))
8850  ereport(ERROR,
8851  (errcode(ERRCODE_CANT_CHANGE_RUNTIME_PARAM),
8852  errmsg("parameter \"%s\" cannot be changed",
8853  name)));
8854 
8855  /*
8856  * If a value is specified, verify that it's sane.
8857  */
8858  if (value)
8859  {
8860  union config_var_val newval;
8861  void *newextra = NULL;
8862 
8863  /* Check that it's acceptable for the indicated parameter */
8864  if (!parse_and_validate_value(record, name, value,
8865  PGC_S_FILE, ERROR,
8866  &newval, &newextra))
8867  ereport(ERROR,
8868  (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
8869  errmsg("invalid value for parameter \"%s\": \"%s\"",
8870  name, value)));
8871 
8872  if (record->vartype == PGC_STRING && newval.stringval != NULL)
8873  free(newval.stringval);
8874  if (newextra)
8875  free(newextra);
8876 
8877  /*
8878  * We must also reject values containing newlines, because the
8879  * grammar for config files doesn't support embedded newlines in
8880  * string literals.
8881  */
8882  if (strchr(value, '\n'))
8883  ereport(ERROR,
8884  (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
8885  errmsg("parameter value for ALTER SYSTEM must not contain a newline")));
8886  }
8887  }
8888 
8889  /*
8890  * PG_AUTOCONF_FILENAME and its corresponding temporary file are always in
8891  * the data directory, so we can reference them by simple relative paths.
8892  */
8893  snprintf(AutoConfFileName, sizeof(AutoConfFileName), "%s",
8895  snprintf(AutoConfTmpFileName, sizeof(AutoConfTmpFileName), "%s.%s",
8896  AutoConfFileName,
8897  "tmp");
8898 
8899  /*
8900  * Only one backend is allowed to operate on PG_AUTOCONF_FILENAME at a
8901  * time. Use AutoFileLock to ensure that. We must hold the lock while
8902  * reading the old file contents.
8903  */
8904  LWLockAcquire(AutoFileLock, LW_EXCLUSIVE);
8905 
8906  /*
8907  * If we're going to reset everything, then no need to open or parse the
8908  * old file. We'll just write out an empty list.
8909  */
8910  if (!resetall)
8911  {
8912  struct stat st;
8913 
8914  if (stat(AutoConfFileName, &st) == 0)
8915  {
8916  /* open old file PG_AUTOCONF_FILENAME */
8917  FILE *infile;
8918 
8919  infile = AllocateFile(AutoConfFileName, "r");
8920  if (infile == NULL)
8921  ereport(ERROR,
8923  errmsg("could not open file \"%s\": %m",
8924  AutoConfFileName)));
8925 
8926  /* parse it */
8927  if (!ParseConfigFp(infile, AutoConfFileName, 0, LOG, &head, &tail))
8928  ereport(ERROR,
8929  (errcode(ERRCODE_CONFIG_FILE_ERROR),
8930  errmsg("could not parse contents of file \"%s\"",
8931  AutoConfFileName)));
8932 
8933  FreeFile(infile);
8934  }
8935 
8936  /*
8937  * Now, replace any existing entry with the new value, or add it if
8938  * not present.
8939  */
8940  replace_auto_config_value(&head, &tail, name, value);
8941  }
8942 
8943  /*
8944  * Invoke the post-alter hook for setting this GUC variable. GUCs
8945  * typically do not have corresponding entries in pg_parameter_acl, so we
8946  * call the hook using the name rather than a potentially-non-existent
8947  * OID. Nonetheless, we pass ParameterAclRelationId so that this call
8948  * context can be distinguished from others. (Note that "name" will be
8949  * NULL in the RESET ALL case.)
8950  *
8951  * We do this here rather than at the end, because ALTER SYSTEM is not
8952  * transactional. If the hook aborts our transaction, it will be cleaner
8953  * to do so before we touch any files.
8954  */
8955  InvokeObjectPostAlterHookArgStr(ParameterAclRelationId, name,
8957  altersysstmt->setstmt->kind,
8958  false);
8959 
8960  /*
8961  * To ensure crash safety, first write the new file data to a temp file,
8962  * then atomically rename it into place.
8963  *
8964  * If there is a temp file left over due to a previous crash, it's okay to
8965  * truncate and reuse it.
8966  */
8967  Tmpfd = BasicOpenFile(AutoConfTmpFileName,
8968  O_CREAT | O_RDWR | O_TRUNC);
8969  if (Tmpfd < 0)
8970  ereport(ERROR,
8972  errmsg("could not open file \"%s\": %m",
8973  AutoConfTmpFileName)));
8974 
8975  /*
8976  * Use a TRY block to clean up the file if we fail. Since we need a TRY
8977  * block anyway, OK to use BasicOpenFile rather than OpenTransientFile.
8978  */
8979  PG_TRY();
8980  {
8981  /* Write and sync the new contents to the temporary file */
8982  write_auto_conf_file(Tmpfd, AutoConfTmpFileName, head);
8983 
8984  /* Close before renaming; may be required on some platforms */
8985  close(Tmpfd);
8986  Tmpfd = -1;
8987 
8988  /*
8989  * As the rename is atomic operation, if any problem occurs after this
8990  * at worst it can lose the parameters set by last ALTER SYSTEM
8991  * command.
8992  */
8993  durable_rename(AutoConfTmpFileName, AutoConfFileName, ERROR);
8994  }
8995  PG_CATCH();
8996  {
8997  /* Close file first, else unlink might fail on some platforms */
8998  if (Tmpfd >= 0)
8999  close(Tmpfd);
9000 
9001  /* Unlink, but ignore any error */
9002  (void) unlink(AutoConfTmpFileName);
9003 
9004  PG_RE_THROW();
9005  }
9006  PG_END_TRY();
9007 
9008  FreeConfigVariables(head);
9009 
9010  LWLockRelease(AutoFileLock);
9011 }
AclResult
Definition: acl.h:181
@ ACLCHECK_OK
Definition: acl.h:182
AclResult pg_parameter_aclcheck(const char *name, Oid roleid, AclMode mode)
Definition: aclchk.c:5046
int errcode_for_file_access(void)
Definition: elog.c:716
int errcode(int sqlerrcode)
Definition: elog.c:693
int errmsg(const char *fmt,...)
Definition: elog.c:904
#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:7357
#define newval
char * ExtractSetVariableArgs(VariableSetStmt *stmt)
Definition: guc.c:9144
static void write_auto_conf_file(int fd, const char *filename, ConfigVariable *head_p)
Definition: guc.c:8634
static struct config_generic * find_option(const char *name, bool create_placeholders, bool skip_errors, int elevel)
Definition: guc.c:5636
static void replace_auto_config_value(ConfigVariable **head_p, ConfigVariable **tail_p, const char *name, const char *value)
Definition: guc.c:8702
#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 @151 value
#define close(a)
Definition: win32.h:12
Assert(fmt[strlen(fmt) - 1] !='\n')
bool LWLockAcquire(LWLock *lock, LWLockMode mode)
Definition: lwlock.c:1196
void LWLockRelease(LWLock *lock)
Definition: lwlock.c:1800
@ LW_EXCLUSIVE
Definition: lwlock.h:104
Oid GetUserId(void)
Definition: miscinit.c:492
#define InvokeObjectPostAlterHookArgStr(classId, objectName, subId, auxiliaryId, is_internal)
Definition: objectaccess.h:245
@ VAR_SET_DEFAULT
Definition: parsenodes.h:2490
@ VAR_RESET
Definition: parsenodes.h:2493
@ VAR_SET_VALUE
Definition: parsenodes.h:2489
@ VAR_RESET_ALL
Definition: parsenodes.h:2494
#define ACL_ALTER_SYSTEM
Definition: parsenodes.h:95
#define MAXPGPATH
#define snprintf
Definition: port.h:225
VariableSetStmt * setstmt
Definition: parsenodes.h:3688
VariableSetKind kind
Definition: parsenodes.h:2500
GucContext context
Definition: guc_tables.h:143
enum config_type vartype
Definition: guc_tables.h:149
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 ACL_ALTER_SYSTEM, ACLCHECK_OK, 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(), GetUserId(), GUC_DISALLOW_IN_AUTO_FILE, GUC_DISALLOW_IN_FILE, infile(), InvokeObjectPostAlterHookArgStr, 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_parameter_aclcheck(), 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_recovery_prefetch()

void assign_recovery_prefetch ( int  new_value,
void *  extra 
)

Definition at line 1081 of file xlogprefetcher.c.

1082 {
1083  /* Reconfigure prefetching, because a setting it depends on changed. */
1084  recovery_prefetch = new_value;
1085  if (AmStartupProcess())
1087 }
#define AmStartupProcess()
Definition: miscadmin.h:444
int recovery_prefetch
void XLogPrefetchReconfigure(void)

References AmStartupProcess, recovery_prefetch, and XLogPrefetchReconfigure().

◆ assign_search_path()

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

Definition at line 4356 of file namespace.c.

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

References baseSearchPathValid.

◆ assign_temp_tablespaces()

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

Definition at line 1354 of file tablespace.c.

1355 {
1356  temp_tablespaces_extra *myextra = (temp_tablespaces_extra *) extra;
1357 
1358  /*
1359  * If check_temp_tablespaces was executed inside a transaction, then pass
1360  * the list it made to fd.c. Otherwise, clear fd.c's list; we must be
1361  * still outside a transaction, or else restoring during transaction exit,
1362  * and in either case we can just let the next PrepareTempTablespaces call
1363  * make things sane.
1364  */
1365  if (myextra)
1366  SetTempTablespaces(myextra->tblSpcs, myextra->numSpcs);
1367  else
1368  SetTempTablespaces(NULL, 0);
1369 }
void SetTempTablespaces(Oid *tableSpaces, int numSpaces)
Definition: fd.c:2928
Oid tblSpcs[FLEXIBLE_ARRAY_MEMBER]
Definition: tablespace.c:1241

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 7926 of file xlog.c.

7927 {
7928  if (sync_method != new_sync_method)
7929  {
7930  /*
7931  * To ensure that no blocks escape unsynced, force an fsync on the
7932  * currently open log segment (if any). Also, if the open flag is
7933  * changing, close the log file so it will be reopened (with new flag
7934  * bit) at next use.
7935  */
7936  if (openLogFile >= 0)
7937  {
7939  if (pg_fsync(openLogFile) != 0)
7940  {
7941  char xlogfname[MAXFNAMELEN];
7942  int save_errno;
7943 
7944  save_errno = errno;
7945  XLogFileName(xlogfname, openLogTLI, openLogSegNo,
7947  errno = save_errno;
7948  ereport(PANIC,
7950  errmsg("could not fsync file \"%s\": %m", xlogfname)));
7951  }
7952 
7954  if (get_sync_bit(sync_method) != get_sync_bit(new_sync_method))
7955  XLogFileClose();
7956  }
7957  }
7958 }
#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:231
static void pgstat_report_wait_start(uint32 wait_event_info)
Definition: wait_event.h:266
static void pgstat_report_wait_end(void)
Definition: wait_event.h:282
static int openLogFile
Definition: xlog.c:614
int wal_segment_size
Definition: xlog.c:144
static int get_sync_bit(int method)
Definition: xlog.c:7870
static TimeLineID openLogTLI
Definition: xlog.c:616
static void XLogFileClose(void)
Definition: xlog.c:3366
static XLogSegNo openLogSegNo
Definition: xlog.c:615
int sync_method
Definition: xlog.c:131
#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 6481 of file guc.c.

6482 {
6483  bool still_dirty;
6484  int i;
6485 
6486  /*
6487  * Note: it's possible to get here with GUCNestLevel == nestLevel-1 during
6488  * abort, if there is a failure during transaction start before
6489  * AtStart_GUC is called.
6490  */
6491  Assert(nestLevel > 0 &&
6492  (nestLevel <= GUCNestLevel ||
6493  (nestLevel == GUCNestLevel + 1 && !isCommit)));
6494 
6495  /* Quick exit if nothing's changed in this transaction */
6496  if (!guc_dirty)
6497  {
6498  GUCNestLevel = nestLevel - 1;
6499  return;
6500  }
6501 
6502  still_dirty = false;
6503  for (i = 0; i < num_guc_variables; i++)
6504  {
6505  struct config_generic *gconf = guc_variables[i];
6506  GucStack *stack;
6507 
6508  /*
6509  * Process and pop each stack entry within the nest level. To simplify
6510  * fmgr_security_definer() and other places that use GUC_ACTION_SAVE,
6511  * we allow failure exit from code that uses a local nest level to be
6512  * recovered at the surrounding transaction or subtransaction abort;
6513  * so there could be more than one stack entry to pop.
6514  */
6515  while ((stack = gconf->stack) != NULL &&
6516  stack->nest_level >= nestLevel)
6517  {
6518  GucStack *prev = stack->prev;
6519  bool restorePrior = false;
6520  bool restoreMasked = false;
6521  bool changed;
6522 
6523  /*
6524  * In this next bit, if we don't set either restorePrior or
6525  * restoreMasked, we must "discard" any unwanted fields of the
6526  * stack entries to avoid leaking memory. If we do set one of
6527  * those flags, unused fields will be cleaned up after restoring.
6528  */
6529  if (!isCommit) /* if abort, always restore prior value */
6530  restorePrior = true;
6531  else if (stack->state == GUC_SAVE)
6532  restorePrior = true;
6533  else if (stack->nest_level == 1)
6534  {
6535  /* transaction commit */
6536  if (stack->state == GUC_SET_LOCAL)
6537  restoreMasked = true;
6538  else if (stack->state == GUC_SET)
6539  {
6540  /* we keep the current active value */
6541  discard_stack_value(gconf, &stack->prior);
6542  }
6543  else /* must be GUC_LOCAL */
6544  restorePrior = true;
6545  }
6546  else if (prev == NULL ||
6547  prev->nest_level < stack->nest_level - 1)
6548  {
6549  /* decrement entry's level and do not pop it */
6550  stack->nest_level--;
6551  continue;
6552  }
6553  else
6554  {
6555  /*
6556  * We have to merge this stack entry into prev. See README for
6557  * discussion of this bit.
6558  */
6559  switch (stack->state)
6560  {
6561  case GUC_SAVE:
6562  Assert(false); /* can't get here */
6563  break;
6564 
6565  case GUC_SET:
6566  /* next level always becomes SET */
6567  discard_stack_value(gconf, &stack->prior);
6568  if (prev->state == GUC_SET_LOCAL)
6569  discard_stack_value(gconf, &prev->masked);
6570  prev->state = GUC_SET;
6571  break;
6572 
6573  case GUC_LOCAL:
6574  if (prev->state == GUC_SET)
6575  {
6576  /* LOCAL migrates down */
6577  prev->masked_scontext = stack->scontext;
6578  prev->masked = stack->prior;
6579  prev->state = GUC_SET_LOCAL;
6580  }
6581  else
6582  {
6583  /* else just forget this stack level */
6584  discard_stack_value(gconf, &stack->prior);
6585  }
6586  break;
6587 
6588  case GUC_SET_LOCAL:
6589  /* prior state at this level no longer wanted */
6590  discard_stack_value(gconf, &stack->prior);
6591  /* copy down the masked state */
6593  if (prev->state == GUC_SET_LOCAL)
6594  discard_stack_value(gconf, &prev->masked);
6595  prev->masked = stack->masked;
6596  prev->state = GUC_SET_LOCAL;
6597  break;
6598  }
6599  }
6600 
6601  changed = false;
6602 
6603  if (restorePrior || restoreMasked)
6604  {
6605  /* Perform appropriate restoration of the stacked value */
6606  config_var_value newvalue;
6607  GucSource newsource;
6608  GucContext newscontext;
6609 
6610  if (restoreMasked)
6611  {
6612  newvalue = stack->masked;
6613  newsource = PGC_S_SESSION;
6614  newscontext = stack->masked_scontext;
6615  }
6616  else
6617  {
6618  newvalue = stack->prior;
6619  newsource = stack->source;
6620  newscontext = stack->scontext;
6621  }
6622 
6623  switch (gconf->vartype)
6624  {
6625  case PGC_BOOL:
6626  {
6627  struct config_bool *conf = (struct config_bool *) gconf;
6628  bool newval = newvalue.val.boolval;
6629  void *newextra = newvalue.extra;
6630 
6631  if (*conf->variable != newval ||
6632  conf->gen.extra != newextra)
6633  {
6634  if (conf->assign_hook)
6635  conf->assign_hook(newval, newextra);
6636  *conf->variable = newval;
6637  set_extra_field(&conf->gen, &conf->gen.extra,
6638  newextra);
6639  changed = true;
6640  }
6641  break;
6642  }
6643  case PGC_INT:
6644  {
6645  struct config_int *conf = (struct config_int *) gconf;
6646  int newval = newvalue.val.intval;
6647  void *newextra = newvalue.extra;
6648 
6649  if (*conf->variable != newval ||
6650  conf->gen.extra != newextra)
6651  {
6652  if (conf->assign_hook)
6653  conf->assign_hook(newval, newextra);
6654  *conf->variable = newval;
6655  set_extra_field(&conf->gen, &conf->gen.extra,
6656  newextra);
6657  changed = true;
6658  }
6659  break;
6660  }
6661  case PGC_REAL:
6662  {
6663  struct config_real *conf = (struct config_real *) gconf;
6664  double newval = newvalue.val.realval;
6665  void *newextra = newvalue.extra;
6666 
6667  if (*conf->variable != newval ||
6668  conf->gen.extra != newextra)
6669  {
6670  if (conf->assign_hook)
6671  conf->assign_hook(newval, newextra);
6672  *conf->variable = newval;
6673  set_extra_field(&conf->gen, &conf->gen.extra,
6674  newextra);
6675  changed = true;
6676  }
6677  break;
6678  }
6679  case PGC_STRING:
6680  {
6681  struct config_string *conf = (struct config_string *) gconf;
6682  char *newval = newvalue.val.stringval;
6683  void *newextra = newvalue.extra;
6684 
6685  if (*conf->variable != newval ||
6686  conf->gen.extra != newextra)
6687  {
6688  if (conf->assign_hook)
6689  conf->assign_hook(newval, newextra);
6690  set_string_field(conf, conf->variable, newval);
6691  set_extra_field(&conf->gen, &conf->gen.extra,
6692  newextra);
6693  changed = true;
6694  }
6695 
6696  /*
6697  * Release stacked values if not used anymore. We
6698  * could use discard_stack_value() here, but since
6699  * we have type-specific code anyway, might as
6700  * well inline it.
6701  */
6702  set_string_field(conf, &stack->prior.val.stringval, NULL);
6703  set_string_field(conf, &stack->masked.val.stringval, NULL);
6704  break;
6705  }
6706  case PGC_ENUM:
6707  {
6708  struct config_enum *conf = (struct config_enum *) gconf;
6709  int newval = newvalue.val.enumval;
6710  void *newextra = newvalue.extra;
6711 
6712  if (*conf->variable != newval ||
6713  conf->gen.extra != newextra)
6714  {
6715  if (conf->assign_hook)
6716  conf->assign_hook(newval, newextra);
6717  *conf->variable = newval;
6718  set_extra_field(&conf->gen, &conf->gen.extra,
6719  newextra);
6720  changed = true;
6721  }
6722  break;
6723  }
6724  }
6725 
6726  /*
6727  * Release stacked extra values if not used anymore.
6728  */
6729  set_extra_field(gconf, &(stack->prior.extra), NULL);
6730  set_extra_field(gconf, &(stack->masked.extra), NULL);
6731 
6732  /* And restore source information */
6733  gconf->source = newsource;
6734  gconf->scontext = newscontext;
6735  }
6736 
6737  /* Finish popping the state stack */
6738  gconf->stack = prev;
6739  pfree(stack);
6740 
6741  /* Report new value if we changed it */
6742  if (changed && (gconf->flags & GUC_REPORT))
6743  {
6744  gconf->status |= GUC_NEEDS_REPORT;
6745  report_needed = true;
6746  }
6747  } /* end of stack-popping loop */
6748 
6749  if (stack != NULL)
6750  still_dirty = true;
6751  }
6752 
6753  /* If there are no remaining stack entries, we can reset guc_dirty */
6754  guc_dirty = still_dirty;
6755 
6756  /* Update nesting level */
6757  GUCNestLevel = nestLevel - 1;
6758 }
static struct config_generic ** guc_variables
Definition: guc.c:5147
static void set_string_field(struct config_string *conf, char **field, char *newval)
Definition: guc.c:5262
static int num_guc_variables
Definition: guc.c:5150
static bool report_needed
Definition: guc.c:5160
static int GUCNestLevel
Definition: guc.c:5162
static void discard_stack_value(struct config_generic *gconf, config_var_value *val)
Definition: guc.c:5377
static bool guc_dirty
Definition: guc.c:5156
static void set_extra_field(struct config_generic *gconf, void **field, void *newval)
Definition: guc.c:5323
#define GUC_REPORT
Definition: guc.h:208
@ GUC_SET_LOCAL
Definition: guc_tables.h:111
@ GUC_SET
Definition: guc_tables.h:109
@ GUC_SAVE
Definition: guc_tables.h:108
@ GUC_LOCAL
Definition: guc_tables.h:110
#define GUC_NEEDS_REPORT
Definition: guc_tables.h:171
@ 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:1175
struct config_generic gen
Definition: guc_tables.h:178
bool * variable
Definition: guc_tables.h:180
GucBoolAssignHook assign_hook
Definition: guc_tables.h:183
int * variable
Definition: guc_tables.h:240
GucEnumAssignHook assign_hook
Definition: guc_tables.h:244
struct config_generic gen
Definition: guc_tables.h:238
GucContext scontext
Definition: guc_tables.h:153
GucStack * stack
Definition: guc_tables.h:155
GucSource source
Definition: guc_tables.h:151
GucIntAssignHook assign_hook
Definition: guc_tables.h:199
int * variable
Definition: guc_tables.h:194
struct config_generic gen
Definition: guc_tables.h:192
GucRealAssignHook assign_hook
Definition: guc_tables.h:215
double * variable
Definition: guc_tables.h:210
struct config_generic gen
Definition: guc_tables.h:208
struct config_generic gen
Definition: guc_tables.h:224
GucStringAssignHook assign_hook
Definition: guc_tables.h:229
char ** variable
Definition: guc_tables.h:226
union config_var_val val
Definition: guc_tables.h:46
struct guc_stack * prev
Definition: guc_tables.h:116
int nest_level
Definition: guc_tables.h:117
config_var_value masked
Definition: guc_tables.h:124
config_var_value prior
Definition: guc_tables.h:123
GucContext scontext
Definition: guc_tables.h:121
GucStackState state
Definition: guc_tables.h:118
GucSource source
Definition: guc_tables.h:119
GucContext masked_scontext
Definition: guc_tables.h:122
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(), brin_summarize_range(), bt_index_check_internal(), cluster_rel(), CommitSubTransaction(), CommitTransaction(), DefineIndex(), do_analyze_rel(), ExecCreateTableAs(), ExecRefreshMatView(), execute_extension_script(), fmgr_security_definer(), index_build(), index_concurrently_build(), PrepareTransaction(), ProcedureCreate(), reindex_index(), ReindexRelationConcurrently(), reset_transmission_modes(), restoreLocalGucs(), RI_Initial_Check(), RI_PartitionRemove_Check(), vacuum_rel(), and validate_index().

◆ AtStart_GUC()

void AtStart_GUC ( void  )

Definition at line 6447 of file guc.c.

6448 {
6449  /*
6450  * The nest level should be 0 between transactions; if it isn't, somebody
6451  * didn't call AtEOXact_GUC, or called it with the wrong nestLevel. We
6452  * throw a warning but make no other effort to clean up.
6453  */
6454  if (GUCNestLevel != 0)
6455  elog(WARNING, "GUC nest level = %d at transaction start",
6456  GUCNestLevel);
6457  GUCNestLevel = 1;
6458 }
#define WARNING
Definition: elog.h:30

References elog, GUCNestLevel, and WARNING.

Referenced by StartTransaction().

◆ BeginReportingGUCOptions()

void BeginReportingGUCOptions ( void  )

Definition at line 6766 of file guc.c.

6767 {
6768  int i;
6769 
6770  /*
6771  * Don't do anything unless talking to an interactive frontend.
6772  */
6774  return;
6775 
6776  reporting_enabled = true;
6777 
6778  /*
6779  * Hack for in_hot_standby: initialize with the value we're about to send.
6780  * (This could be out of date by the time we actually send it, in which
6781  * case the next ReportChangedGUCOptions call will send a duplicate
6782  * report.)
6783  */
6785 
6786  /* Transmit initial values of interesting variables */
6787  for (i = 0; i < num_guc_variables; i++)
6788  {
6789  struct config_generic *conf = guc_variables[i];
6790 
6791  if (conf->flags & GUC_REPORT)
6792  ReportGUCOption(conf);
6793  }
6794 
6795  report_needed = false;
6796 }
@ DestRemote
Definition: dest.h:91
static void ReportGUCOption(struct config_generic *record)
Definition: guc.c:6858
static bool in_hot_standby
Definition: guc.c:713
static bool reporting_enabled
Definition: guc.c:5158
CommandDest whereToSendOutput
Definition: postgres.c:92
bool RecoveryInProgress(void)
Definition: xlog.c:5753

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 1139 of file tablespace.c.

1140 {
1141  /*
1142  * If we aren't inside a transaction, or connected to a database, we
1143  * cannot do the catalog accesses necessary to verify the name. Must
1144  * accept the value on faith.
1145  */
1147  {
1148  if (**newval != '\0' &&
1150  {
1151  /*
1152  * When source == PGC_S_TEST, don't throw a hard error for a
1153  * nonexistent tablespace, only a NOTICE. See comments in guc.h.
1154  */
1155  if (source == PGC_S_TEST)
1156  {
1157  ereport(NOTICE,
1158  (errcode(ERRCODE_UNDEFINED_OBJECT),
1159  errmsg("tablespace \"%s\" does not exist",
1160  *newval)));
1161  }
1162  else
1163  {
1164  GUC_check_errdetail("Tablespace \"%s\" does not exist.",
1165  *newval);
1166  return false;
1167  }
1168  }
1169  }
1170 
1171  return true;
1172 }
Oid get_tablespace_oid(const char *tablespacename, bool missing_ok)
Definition: tablespace.c:1474
#define OidIsValid(objectId)
Definition: c.h:710
#define NOTICE
Definition: elog.h:29
Oid MyDatabaseId
Definition: globals.c:89
#define GUC_check_errdetail
Definition: guc.h:427
static rewind_source * source
Definition: pg_rewind.c:81
#define InvalidOid
Definition: postgres_ext.h:36
bool IsTransactionState(void)
Definition: xact.c:374

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

◆ check_GUC_name_for_parameter_acl()

bool check_GUC_name_for_parameter_acl ( const char *  name)

Definition at line 5817 of file guc.c.

5818 {
5819  /* OK if the GUC exists. */
5820  if (find_option(name, false, true, DEBUG1) != NULL)
5821  return true;
5822  /* Otherwise, it'd better be a valid custom GUC name. */
5824  return true;
5825  return false;
5826 }
#define DEBUG1
Definition: elog.h:24
static bool valid_custom_variable_name(const char *name)
Definition: guc.c:5542

References DEBUG1, find_option(), name, and valid_custom_variable_name().

Referenced by ParameterAclCreate().

◆ check_recovery_prefetch()

bool check_recovery_prefetch ( int *  new_value,
void **  extra,
GucSource  source 
)

Definition at line 1067 of file xlogprefetcher.c.

1068 {
1069 #ifndef USE_PREFETCH
1070  if (*new_value == RECOVERY_PREFETCH_ON)
1071  {
1072  GUC_check_errdetail("recovery_prefetch not supported on platforms that lack posix_fadvise().");
1073  return false;
1074  }
1075 #endif
1076 
1077  return true;
1078 }
@ RECOVERY_PREFETCH_ON

References GUC_check_errdetail, and RECOVERY_PREFETCH_ON.

◆ check_search_path()

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

Definition at line 4322 of file namespace.c.

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

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 1246 of file tablespace.c.

1247 {
1248  char *rawname;
1249  List *namelist;
1250 
1251  /* Need a modifiable copy of string */
1252  rawname = pstrdup(*newval);
1253 
1254  /* Parse string into list of identifiers */
1255  if (!SplitIdentifierString(rawname, ',', &namelist))
1256  {
1257  /* syntax error in name list */
1258  GUC_check_errdetail("List syntax is invalid.");
1259  pfree(rawname);
1260  list_free(namelist);
1261  return false;
1262  }
1263 
1264  /*
1265  * If we aren't inside a transaction, or connected to a database, we
1266  * cannot do the catalog accesses necessary to verify the name. Must
1267  * accept the value on faith. Fortunately, there's then also no need to
1268  * pass the data to fd.c.
1269  */
1271  {
1272  temp_tablespaces_extra *myextra;
1273  Oid *tblSpcs;
1274  int numSpcs;
1275  ListCell *l;
1276 
1277  /* temporary workspace until we are done verifying the list */
1278  tblSpcs = (Oid *) palloc(list_length(namelist) * sizeof(Oid));
1279  numSpcs = 0;
1280  foreach(l, namelist)
1281  {
1282  char *curname = (char *) lfirst(l);
1283  Oid curoid;
1284  AclResult aclresult;
1285 
1286  /* Allow an empty string (signifying database default) */
1287  if (curname[0] == '\0')
1288  {
1289  /* InvalidOid signifies database's default tablespace */
1290  tblSpcs[numSpcs++] = InvalidOid;
1291  continue;
1292  }
1293 
1294  /*
1295  * In an interactive SET command, we ereport for bad info. When
1296  * source == PGC_S_TEST, don't throw a hard error for a
1297  * nonexistent tablespace, only a NOTICE. See comments in guc.h.
1298  */
1299  curoid = get_tablespace_oid(curname, source <= PGC_S_TEST);
1300  if (curoid == InvalidOid)
1301  {
1302  if (source == PGC_S_TEST)
1303  ereport(NOTICE,
1304  (errcode(ERRCODE_UNDEFINED_OBJECT),
1305  errmsg("tablespace \"%s\" does not exist",
1306  curname)));
1307  continue;
1308  }
1309 
1310  /*
1311  * Allow explicit specification of database's default tablespace
1312  * in temp_tablespaces without triggering permissions checks.
1313  */
1314  if (curoid == MyDatabaseTableSpace)
1315  {
1316  /* InvalidOid signifies database's default tablespace */
1317  tblSpcs[numSpcs++] = InvalidOid;
1318  continue;
1319  }
1320 
1321  /* Check permissions, similarly complaining only if interactive */
1322  aclresult = pg_tablespace_aclcheck(curoid, GetUserId(),
1323  ACL_CREATE);
1324  if (aclresult != ACLCHECK_OK)
1325  {
1326  if (source >= PGC_S_INTERACTIVE)
1327  aclcheck_error(aclresult, OBJECT_TABLESPACE, curname);
1328  continue;
1329  }
1330 
1331  tblSpcs[numSpcs++] = curoid;
1332  }
1333 
1334  /* Now prepare an "extra" struct for assign_temp_tablespaces */
1335  myextra = malloc(offsetof(temp_tablespaces_extra, tblSpcs) +
1336  numSpcs * sizeof(Oid));
1337  if (!myextra)
1338  return false;
1339  myextra->numSpcs = numSpcs;
1340  memcpy(myextra->tblSpcs, tblSpcs, numSpcs * sizeof(Oid));
1341  *extra = (void *) myextra;
1342 
1343  pfree(tblSpcs);
1344  }
1345 
1346  pfree(rawname);
1347  list_free(namelist);
1348 
1349  return true;
1350 }
AclResult pg_tablespace_aclcheck(Oid spc_oid, Oid roleid, AclMode mode)
Definition: aclchk.c:5121
void aclcheck_error(AclResult aclerr, ObjectType objtype, const char *objectname)
Definition: aclchk.c:3512
#define offsetof(type, field)
Definition: c.h:727
Oid MyDatabaseTableSpace
Definition: globals.c:91
#define malloc(a)
Definition: header.h:50
void * palloc(Size size)
Definition: mcxt.c:1068
@ OBJECT_TABLESPACE
Definition: parsenodes.h:2176
#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 4282 of file xlog.c.

4283 {
4284  /*
4285  * -1 indicates a request for auto-tune.
4286  */
4287  if (*newval == -1)
4288  {
4289  /*
4290  * If we haven't yet changed the boot_val default of -1, just let it
4291  * be. We'll fix it when XLOGShmemSize is called.
4292  */
4293  if (XLOGbuffers == -1)
4294  return true;
4295 
4296  /* Otherwise, substitute the auto-tune value */
4298  }
4299 
4300  /*
4301  * We clamp manually-set values to at least 4 blocks. Prior to PostgreSQL
4302  * 9.1, a minimum of 4 was enforced by guc.c, but since that is no longer
4303  * the case, we just silently treat such values as a request for the
4304  * minimum. (We could throw an error instead, but that doesn't seem very
4305  * helpful.)
4306  */
4307  if (*newval < 4)
4308  *newval = 4;
4309 
4310  return true;
4311 }
static int XLOGChooseNumBuffers(void)
Definition: xlog.c:4266
int XLOGbuffers
Definition: xlog.c:118

References newval, XLOGbuffers, and XLOGChooseNumBuffers().

◆ convert_GUC_name_for_parameter_acl()

char* convert_GUC_name_for_parameter_acl ( const char *  name)

Definition at line 5781 of file guc.c.

5782 {
5783  char *result;
5784 
5785  /* Apply old-GUC-name mapping. */
5786  for (int i = 0; map_old_guc_names[i] != NULL; i += 2)
5787  {
5789  {
5790  name = map_old_guc_names[i + 1];
5791  break;
5792  }
5793  }
5794 
5795  /* Apply case-folding that matches guc_name_compare(). */
5796  result = pstrdup(name);
5797  for (char *ptr = result; *ptr != '\0'; ptr++)
5798  {
5799  char ch = *ptr;
5800 
5801  if (ch >= 'A' && ch <= 'Z')
5802  {
5803  ch += 'a' - 'A';
5804  *ptr = ch;
5805  }
5806  }
5807 
5808  return result;
5809 }
static const char *const map_old_guc_names[]
Definition: guc.c:5137
static int guc_name_compare(const char *namea, const char *nameb)
Definition: guc.c:5743

References guc_name_compare(), i, map_old_guc_names, name, and pstrdup().

Referenced by ParameterAclCreate(), ParameterAclLookup(), and pg_parameter_aclmask().

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

9486 {
9487  struct config_bool *var;
9488 
9489  var = (struct config_bool *)
9490  init_custom_variable(name, short_desc, long_desc, context, flags,
9491  PGC_BOOL, sizeof(struct config_bool));
9492  var->variable = valueAddr;
9493  var->boot_val = bootValue;
9494  var->reset_val = bootValue;
9495  var->check_hook = check_hook;
9496  var->assign_hook = assign_hook;
9497  var->show_hook = show_hook;
9498  define_custom_variable(&var->gen);
9499 }
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:9232
static void define_custom_variable(struct config_generic *variable)
Definition: guc.c:9292
GucBoolCheckHook check_hook
Definition: guc_tables.h:182
bool reset_val
Definition: guc_tables.h:186
bool boot_val
Definition: guc_tables.h:181
GucShowHook show_hook
Definition: guc_tables.h:184

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

9598 {
9599  struct config_enum *var;
9600 
9601  var = (struct config_enum *)
9602  init_custom_variable(name, short_desc, long_desc, context, flags,
9603  PGC_ENUM, sizeof(struct config_enum));
9604  var->variable = valueAddr;
9605  var->boot_val = bootValue;
9606  var->reset_val = bootValue;
9607  var->options = options;
9608  var->check_hook = check_hook;
9609  var->assign_hook = assign_hook;
9610  var->show_hook = show_hook;
9611  define_custom_variable(&var->gen);
9612 }
static char ** options
const struct config_enum_entry * options
Definition: guc_tables.h:242
GucEnumCheckHook check_hook
Definition: guc_tables.h:243
GucShowHook show_hook
Definition: guc_tables.h:245

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

9514 {
9515  struct config_int *var;
9516 
9517  var = (struct config_int *)
9518  init_custom_variable(name, short_desc, long_desc, context, flags,
9519  PGC_INT, sizeof(struct config_int));
9520  var->variable = valueAddr;
9521  var->boot_val = bootValue;
9522  var->reset_val = bootValue;
9523  var->min = minValue;
9524  var->max = maxValue;
9525  var->check_hook = check_hook;
9526  var->assign_hook = assign_hook;
9527  var->show_hook = show_hook;
9528  define_custom_variable(&var->gen);
9529 }
int reset_val
Definition: guc_tables.h:202
int boot_val
Definition: guc_tables.h:195
GucIntCheckHook check_hook
Definition: guc_tables.h:198
GucShowHook show_hook
Definition: guc_tables.h:200

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

9544 {
9545  struct config_real *var;
9546 
9547  var = (struct config_real *)
9548  init_custom_variable(name, short_desc, long_desc, context, flags,
9549  PGC_REAL, sizeof(struct config_real));
9550  var->variable = valueAddr;
9551  var->boot_val = bootValue;
9552  var->reset_val = bootValue;
9553  var->min = minValue;
9554  var->max = maxValue;
9555  var->check_hook = check_hook;
9556  var->assign_hook = assign_hook;
9557  var->show_hook = show_hook;
9558  define_custom_variable(&var->gen);
9559 }
double boot_val
Definition: guc_tables.h:211
double reset_val
Definition: guc_tables.h:218
double min
Definition: guc_tables.h:212
double max
Definition: guc_tables.h:213
GucShowHook show_hook
Definition: guc_tables.h:216
GucRealCheckHook check_hook
Definition: guc_tables.h:214

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

9572 {
9573  struct config_string *var;
9574 
9575  var = (struct config_string *)
9576  init_custom_variable(name, short_desc, long_desc, context, flags,
9577  PGC_STRING, sizeof(struct config_string));
9578  var->variable = valueAddr;
9579  var->boot_val = bootValue;
9580  var->check_hook = check_hook;
9581  var->assign_hook = assign_hook;
9582  var->show_hook = show_hook;
9583  define_custom_variable(&var->gen);
9584 }
GucStringCheckHook check_hook
Definition: guc_tables.h:228
GucShowHook show_hook
Definition: guc_tables.h:230
const char * boot_val
Definition: guc_tables.h:227

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

◆ EstimateGUCStateSpace()

Size EstimateGUCStateSpace ( void  )

Definition at line 10931 of file guc.c.

10932 {
10933  Size size;
10934  int i;
10935 
10936  /* Add space reqd for saving the data size of the guc state */
10937  size = sizeof(Size);
10938 
10939  /* Add up the space needed for each GUC variable */
10940  for (i = 0; i < num_guc_variables; i++)
10941  size = add_size(size,
10943 
10944  return size;
10945 }
size_t Size
Definition: c.h:540
static Size estimate_variable_size(struct config_generic *gconf)
Definition: guc.c:10832
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 9017 of file guc.c.

9018 {
9020 
9021  /*
9022  * Workers synchronize these parameters at the start of the parallel
9023  * operation; then, we block SET during the operation.
9024  */
9025  if (IsInParallelMode())
9026  ereport(ERROR,
9027  (errcode(ERRCODE_INVALID_TRANSACTION_STATE),
9028  errmsg("cannot set parameters during a parallel operation")));
9029 
9030  switch (stmt->kind)
9031  {
9032  case VAR_SET_VALUE:
9033  case VAR_SET_CURRENT:
9034  if (stmt->is_local)
9035  WarnNoTransactionBlock(isTopLevel, "SET LOCAL");
9036  (void) set_config_option(stmt->name,
9037  ExtractSetVariableArgs(stmt),
9039  PGC_S_SESSION,
9040  action, true, 0, false);
9041  break;
9042  case VAR_SET_MULTI:
9043 
9044  /*
9045  * Special-case SQL syntaxes. The TRANSACTION and SESSION
9046  * CHARACTERISTICS cases effectively set more than one variable
9047  * per statement. TRANSACTION SNAPSHOT only takes one argument,
9048  * but we put it here anyway since it's a special case and not
9049  * related to any GUC variable.
9050  */
9051  if (strcmp(stmt->name, "TRANSACTION") == 0)
9052  {
9053  ListCell *head;
9054 
9055  WarnNoTransactionBlock(isTopLevel, "SET TRANSACTION");
9056 
9057  foreach(head, stmt->args)
9058  {
9059  DefElem *item = (DefElem *) lfirst(head);
9060 
9061  if (strcmp(item->defname, "transaction_isolation") == 0)
9062  SetPGVariable("transaction_isolation",
9063  list_make1(item->arg), stmt->is_local);
9064  else if (strcmp(item->defname, "transaction_read_only") == 0)
9065  SetPGVariable("transaction_read_only",
9066  list_make1(item->arg), stmt->is_local);
9067  else if (strcmp(item->defname, "transaction_deferrable") == 0)
9068  SetPGVariable("transaction_deferrable",
9069  list_make1(item->arg), stmt->is_local);
9070  else
9071  elog(ERROR, "unexpected SET TRANSACTION element: %s",
9072  item->defname);
9073  }
9074  }
9075  else if (strcmp(stmt->name, "SESSION CHARACTERISTICS") == 0)
9076  {
9077  ListCell *head;
9078 
9079  foreach(head, stmt->args)
9080  {
9081  DefElem *item = (DefElem *) lfirst(head);
9082 
9083  if (strcmp(item->defname, "transaction_isolation") == 0)
9084  SetPGVariable("default_transaction_isolation",
9085  list_make1(item->arg), stmt->is_local);
9086  else if (strcmp(item->defname, "transaction_read_only") == 0)
9087  SetPGVariable("default_transaction_read_only",
9088  list_make1(item->arg), stmt->is_local);
9089  else if (strcmp(item->defname, "transaction_deferrable") == 0)
9090  SetPGVariable("default_transaction_deferrable",
9091  list_make1(item->arg), stmt->is_local);
9092  else
9093  elog(ERROR, "unexpected SET SESSION element: %s",
9094  item->defname);
9095  }
9096  }
9097  else if (strcmp(stmt->name, "TRANSACTION SNAPSHOT") == 0)
9098  {
9099  A_Const *con = linitial_node(A_Const, stmt->args);
9100 
9101  if (stmt->is_local)
9102  ereport(ERROR,
9103  (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
9104  errmsg("SET LOCAL TRANSACTION SNAPSHOT is not implemented")));
9105 
9106  WarnNoTransactionBlock(isTopLevel, "SET TRANSACTION");
9107  ImportSnapshot(strVal(&con->val));
9108  }
9109  else
9110  elog(ERROR, "unexpected SET MULTI element: %s",
9111  stmt->name);
9112  break;
9113  case VAR_SET_DEFAULT:
9114  if (stmt->is_local)
9115  WarnNoTransactionBlock(isTopLevel, "SET LOCAL");
9116  /* fall through */
9117  case VAR_RESET:
9118  if (strcmp(stmt->name, "transaction_isolation") == 0)
9119  WarnNoTransactionBlock(isTopLevel, "RESET TRANSACTION");
9120 
9121  (void) set_config_option(stmt->name,
9122  NULL,
9124  PGC_S_SESSION,
9125  action, true, 0, false);
9126  break;
9127  case VAR_RESET_ALL:
9128  ResetAllOptions();
9129  break;
9130  }
9131 
9132  /* Invoke the post-alter hook for setting this GUC variable, by name. */
9133  InvokeObjectPostAlterHookArgStr(ParameterAclRelationId, stmt->name,
9134  ACL_SET, stmt->kind, false);
9135 }
void ResetAllOptions(void)
Definition: guc.c:6263
void SetPGVariable(const char *name, List *args, bool is_local)
Definition: guc.c:9164
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:7558
#define ACL_SET
Definition: parsenodes.h:94
@ VAR_SET_MULTI
Definition: parsenodes.h:2492
@ VAR_SET_CURRENT
Definition: parsenodes.h:2491
#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:1394
union A_Const::ValUnion val
char * defname
Definition: parsenodes.h:765
Node * arg
Definition: parsenodes.h:766
#define strVal(v)
Definition: value.h:72
void WarnNoTransactionBlock(bool isTopLevel, const char *stmtType)
Definition: xact.c:3522
bool IsInParallelMode(void)
Definition: xact.c:1065

References ACL_SET, generate_unaccent_rules::action, DefElem::arg, VariableSetStmt::args, DefElem::defname, elog, ereport, errcode(), errmsg(), ERROR, ExtractSetVariableArgs(), GUC_ACTION_LOCAL, GUC_ACTION_SET, ImportSnapshot(), InvokeObjectPostAlterHookArgStr, 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 9144 of file guc.c.

9145 {
9146  switch (stmt->kind)
9147  {
9148  case VAR_SET_VALUE:
9149  return flatten_set_variable_args(stmt->name, stmt->args);
9150  case VAR_SET_CURRENT:
9151  return GetConfigOptionByName(stmt->name, NULL, false);
9152  default:
9153  return NULL;
9154  }
9155 }
static char * flatten_set_variable_args(const char *name, List *args)
Definition: guc.c:8512
char * GetConfigOptionByName(const char *name, const char **varname, bool missing_ok)
Definition: guc.c:9901

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

8395 {
8396  struct config_generic *record;
8397  static char buffer[256];
8398 
8399  record = find_option(name, false, missing_ok, ERROR);
8400  if (record == NULL)
8401  return NULL;
8402  if (restrict_privileged &&
8403  (record->flags & GUC_SUPERUSER_ONLY) &&
8404  !has_privs_of_role(GetUserId(), ROLE_PG_READ_ALL_SETTINGS))
8405  ereport(ERROR,
8406  (errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
8407  errmsg("must be superuser or have privileges of pg_read_all_settings to examine \"%s\"",
8408  name)));
8409 
8410  switch (record->vartype)
8411  {
8412  case PGC_BOOL:
8413  return *((struct config_bool *) record)->variable ? "on" : "off";
8414 
8415  case PGC_INT:
8416  snprintf(buffer, sizeof(buffer), "%d",
8417  *((struct config_int *) record)->variable);
8418  return buffer;
8419 
8420  case PGC_REAL:
8421  snprintf(buffer, sizeof(buffer), "%g",
8422  *((struct config_real *) record)->variable);
8423  return buffer;
8424 
8425  case PGC_STRING:
8426  return *((struct config_string *) record)->variable;
8427 
8428  case PGC_ENUM:
8429  return config_enum_lookup_by_value((struct config_enum *) record,
8430  *((struct config_enum *) record)->variable);
8431  }
8432  return NULL;
8433 }
bool has_privs_of_role(Oid member, Oid role)
Definition: acl.c:4951
const char * config_enum_lookup_by_value(struct config_enum *record, int val)
Definition: guc.c:7250
#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, has_privs_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 9901 of file guc.c.

9902 {
9903  struct config_generic *record;
9904 
9905  record = find_option(name, false, missing_ok, ERROR);
9906  if (record == NULL)
9907  {
9908  if (varname)
9909  *varname = NULL;
9910  return NULL;
9911  }
9912 
9913  if ((record->flags & GUC_SUPERUSER_ONLY) &&
9914  !has_privs_of_role(GetUserId(), ROLE_PG_READ_ALL_SETTINGS))
9915  ereport(ERROR,
9916  (errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
9917  errmsg("must be superuser or have privileges of pg_read_all_settings to examine \"%s\"",
9918  name)));
9919 
9920  if (varname)
9921  *varname = record->name;
9922 
9923  return _ShowOption(record, true);
9924 }
static char * _ShowOption(struct config_generic *record, bool use_units)
Definition: guc.c:10450
const char * name
Definition: guc_tables.h:142

References _ShowOption(), ereport, errcode(), errmsg(), ERROR, find_option(), config_generic::flags, GetUserId(), GUC_SUPERUSER_ONLY, has_privs_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 9970 of file guc.c.

9971 {
9972  char buffer[256];
9973  struct config_generic *conf;
9974 
9975  /* check requested variable number valid */
9976  Assert((varnum >= 0) && (varnum < num_guc_variables));
9977 
9978  conf = guc_variables[varnum];
9979 
9980  if (noshow)
9981  {
9982  if ((conf->flags & GUC_NO_SHOW_ALL) ||
9983  ((conf->flags & GUC_SUPERUSER_ONLY) &&
9984  !has_privs_of_role(GetUserId(), ROLE_PG_READ_ALL_SETTINGS)))
9985  *noshow = true;
9986  else
9987  *noshow = false;
9988  }
9989 
9990  /* first get the generic attributes */
9991 
9992  /* name */
9993  values[0] = conf->name;
9994 
9995  /* setting: use _ShowOption in order to avoid duplicating the logic */
9996  values[1] = _ShowOption(conf, false);
9997 
9998  /* unit, if any (NULL is fine) */
9999  values[2] = get_config_unit_name(conf->flags);
10000 
10001  /* group */
10002  values[3] = _(config_group_names[conf->group]);
10003 
10004  /* short_desc */
10005  values[4] = _(conf->short_desc);
10006 
10007  /* extra_desc */
10008  values[5] = conf->long_desc != NULL ? _(conf->long_desc) : NULL;
10009 
10010  /* context */
10011  values[6] = GucContext_Names[conf->context];
10012 
10013  /* vartype */
10014  values[7] = config_type_names[conf->vartype];
10015 
10016  /* source */
10017  values[8] = GucSource_Names[conf->source];
10018 
10019  /* now get the type specific attributes */
10020  switch (conf->vartype)
10021  {
10022  case PGC_BOOL:
10023  {
10024  struct config_bool *lconf = (struct config_bool *) conf;
10025 
10026  /* min_val */
10027  values[9] = NULL;
10028 
10029  /* max_val */
10030  values[10] = NULL;
10031 
10032  /* enumvals */
10033  values[11] = NULL;
10034 
10035  /* boot_val */
10036  values[12] = pstrdup(lconf->boot_val ? "on" : "off");
10037 
10038  /* reset_val */
10039  values[13] = pstrdup(lconf->reset_val ? "on" : "off");
10040  }
10041  break;
10042 
10043  case PGC_INT:
10044  {
10045  struct config_int *lconf = (struct config_int *) conf;
10046 
10047  /* min_val */
10048  snprintf(buffer, sizeof(buffer), "%d", lconf->min);
10049  values[9] = pstrdup(buffer);
10050 
10051  /* max_val */
10052  snprintf(buffer, sizeof(buffer), "%d", lconf->max);
10053  values[10] = pstrdup(buffer);
10054 
10055  /* enumvals */
10056  values[11] = NULL;
10057 
10058  /* boot_val */
10059  snprintf(buffer, sizeof(buffer), "%d", lconf->boot_val);
10060  values[12] = pstrdup(buffer);
10061 
10062  /* reset_val */
10063  snprintf(buffer, sizeof(buffer), "%d", lconf->reset_val);
10064  values[13] = pstrdup(buffer);
10065  }
10066  break;
10067 
10068  case PGC_REAL:
10069  {
10070  struct config_real *lconf = (struct config_real *) conf;
10071 
10072  /* min_val */
10073  snprintf(buffer, sizeof(buffer), "%g", lconf->min);
10074  values[9] = pstrdup(buffer);
10075 
10076  /* max_val */
10077  snprintf(buffer, sizeof(buffer), "%g", lconf->max);
10078  values[10] = pstrdup(buffer);
10079 
10080  /* enumvals */
10081  values[11] = NULL;
10082 
10083  /* boot_val */
10084  snprintf(buffer, sizeof(buffer), "%g", lconf->boot_val);
10085  values[12] = pstrdup(buffer);
10086 
10087  /* reset_val */
10088  snprintf(buffer, sizeof(buffer), "%g", lconf->reset_val);
10089  values[13] = pstrdup(buffer);
10090  }
10091  break;
10092 
10093  case PGC_STRING:
10094  {
10095  struct config_string *lconf = (struct config_string *) conf;
10096 
10097  /* min_val */
10098  values[9] = NULL;
10099 
10100  /* max_val */
10101  values[10] = NULL;
10102 
10103  /* enumvals */
10104  values[11] = NULL;
10105 
10106  /* boot_val */
10107  if (lconf->boot_val == NULL)
10108  values[12] = NULL;
10109  else
10110  values[12] = pstrdup(lconf->boot_val);
10111 
10112  /* reset_val */
10113  if (lconf->reset_val == NULL)
10114  values[13] = NULL;
10115  else
10116  values[13] = pstrdup(lconf->reset_val);
10117  }
10118  break;
10119 
10120  case PGC_ENUM:
10121  {
10122  struct config_enum *lconf = (struct config_enum *) conf;
10123 
10124  /* min_val */
10125  values[9] = NULL;
10126 
10127  /* max_val */
10128  values[10] = NULL;
10129 
10130  /* enumvals */
10131 
10132  /*
10133  * NOTE! enumvals with double quotes in them are not
10134  * supported!
10135  */
10136  values[11] = config_enum_get_options((struct config_enum *) conf,
10137  "{\"", "\"}", "\",\"");
10138 
10139  /* boot_val */
10141  lconf->boot_val));
10142 
10143  /* reset_val */
10145  lconf->reset_val));
10146  }
10147  break;
10148 
10149  default:
10150  {
10151  /*
10152  * should never get here, but in case we do, set 'em to NULL
10153  */
10154 
10155  /* min_val */
10156  values[9] = NULL;
10157 
10158  /* max_val */
10159  values[10] = NULL;
10160 
10161  /* enumvals */
10162  values[11] = NULL;
10163 
10164  /* boot_val */
10165  values[12] = NULL;
10166 
10167  /* reset_val */
10168  values[13] = NULL;
10169  }
10170  break;
10171  }
10172 
10173  /*
10174  * If the setting came from a config file, set the source location. For
10175  * security reasons, we don't show source file/line number for
10176  * insufficiently-privileged users.
10177  */
10178  if (conf->source == PGC_S_FILE &&
10179  has_privs_of_role(GetUserId(), ROLE_PG_READ_ALL_SETTINGS))
10180  {
10181  values[14] = conf->sourcefile;
10182  snprintf(buffer, sizeof(buffer), "%d", conf->sourceline);
10183  values[15] = pstrdup(buffer);
10184  }
10185  else
10186  {
10187  values[14] = NULL;
10188  values[15] = NULL;
10189  }
10190 
10191  values[16] = (conf->status & GUC_PENDING_RESTART) ? "t" : "f";
10192 }
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:7041
const char *const GucContext_Names[]
Definition: guc.c:730
const char *const GucSource_Names[]
Definition: guc.c:749
const char *const config_type_names[]
Definition: guc.c:873
static char * config_enum_get_options(struct config_enum *record, const char *prefix, const char *suffix, const char *separator)
Definition: guc.c:7299
const char *const config_group_names[]
Definition: guc.c:773
#define GUC_NO_SHOW_ALL
Definition: guc.h:206
#define GUC_PENDING_RESTART
Definition: guc_tables.h:170
enum config_group group
Definition: guc_tables.h:144
const char * long_desc
Definition: guc_tables.h:146
const char * short_desc
Definition: guc_tables.h:145
char * sourcefile
Definition: guc_tables.h:159
char * reset_val
Definition: guc_tables.h:232

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, has_privs_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 8489 of file guc.c.

8490 {
8491  struct config_generic *record;
8492 
8493  record = find_option(name, false, missing_ok, ERROR);
8494  if (record == NULL)
8495  return 0;
8496  return record->flags;
8497 }

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

8444 {
8445  struct config_generic *record;
8446  static char buffer[256];
8447 
8448  record = find_option(name, false, false, ERROR);
8449  Assert(record != NULL);
8450  if ((record->flags & GUC_SUPERUSER_ONLY) &&
8451  !has_privs_of_role(GetUserId(), ROLE_PG_READ_ALL_SETTINGS))
8452  ereport(ERROR,
8453  (errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
8454  errmsg("must be superuser or have privileges of pg_read_all_settings to examine \"%s\"",
8455  name)));
8456 
8457  switch (record->vartype)
8458  {
8459  case PGC_BOOL:
8460  return ((struct config_bool *) record)->reset_val ? "on" : "off";
8461 
8462  case PGC_INT:
8463  snprintf(buffer, sizeof(buffer), "%d",
8464  ((struct config_int *) record)->reset_val);
8465  return buffer;
8466 
8467  case PGC_REAL:
8468  snprintf(buffer, sizeof(buffer), "%g",
8469  ((struct config_real *) record)->reset_val);
8470  return buffer;
8471 
8472  case PGC_STRING:
8473  return ((struct config_string *) record)->reset_val;
8474 
8475  case PGC_ENUM:
8476  return config_enum_lookup_by_value((struct config_enum *) record,
8477  ((struct config_enum *) record)->reset_val);
8478  }
8479  return NULL;
8480 }

References Assert(), config_enum_lookup_by_value(), ereport, errcode(), errmsg(), ERROR, find_option(), config_generic::flags, GetUserId(), GUC_SUPERUSER_ONLY, has_privs_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 10198 of file guc.c.

10199 {
10200  return num_guc_variables;
10201 }

References num_guc_variables.

Referenced by GucInfoMain(), and show_all_settings().

◆ GetPGVariable()

void GetPGVariable ( const char *  name,
DestReceiver dest 
)

Definition at line 9666 of file guc.c.

9667 {
9668  if (guc_name_compare(name, "all") == 0)
9670  else
9672 }
static void ShowGUCConfigOption(const char *name, DestReceiver *dest)
Definition: guc.c:9710
static void ShowAllGUCConfig(DestReceiver *dest)
Definition: guc.c:9738

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

9676 {
9677  TupleDesc tupdesc;
9678 
9679  if (guc_name_compare(name, "all") == 0)
9680  {
9681  /* need a tuple descriptor representing three TEXT columns */
9682  tupdesc = CreateTemplateTupleDesc(3);
9683  TupleDescInitEntry(tupdesc, (AttrNumber) 1, "name",
9684  TEXTOID, -1, 0);
9685  TupleDescInitEntry(tupdesc, (AttrNumber) 2, "setting",
9686  TEXTOID, -1, 0);
9687  TupleDescInitEntry(tupdesc, (AttrNumber) 3, "description",
9688  TEXTOID, -1, 0);
9689  }
9690  else
9691  {
9692  const char *varname;
9693 
9694  /* Get the canonical spelling of name */
9695  (void) GetConfigOptionByName(name, &varname, false);
9696 
9697  /* need a tuple descriptor representing a single TEXT column */
9698  tupdesc = CreateTemplateTupleDesc(1);
9699  TupleDescInitEntry(tupdesc, (AttrNumber) 1, varname,
9700  TEXTOID, -1, 0);
9701  }
9702  return tupdesc;
9703 }
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 11428 of file guc.c.

11429 {
11430  struct config_generic *record;
11431  Datum datum;
11432  char *newval;
11433  ArrayType *a;
11434 
11435  Assert(name);
11436  Assert(value);
11437 
11438  /* test if the option is valid and we're allowed to set it */
11439  (void) validate_option_array_item(name, value, false);
11440 
11441  /* normalize name (converts obsolete GUC names to modern spellings) */
11442  record = find_option(name, false, true, WARNING);
11443  if (record)
11444  name = record->name;
11445 
11446  /* build new item for array */
11447  newval = psprintf("%s=%s", name, value);
11448  datum = CStringGetTextDatum(newval);
11449 
11450  if (array)
11451  {
11452  int index;
11453  bool isnull;
11454  int i;
11455 
11456  Assert(ARR_ELEMTYPE(array) == TEXTOID);
11457  Assert(ARR_NDIM(array) == 1);
11458  Assert(ARR_LBOUND(array)[0] == 1);
11459 
11460  index = ARR_DIMS(array)[0] + 1; /* add after end */
11461 
11462  for (i = 1; i <= ARR_DIMS(array)[0]; i++)
11463  {
11464  Datum d;
11465  char *current;
11466 
11467  d = array_ref(array, 1, &i,
11468  -1 /* varlenarray */ ,
11469  -1 /* TEXT's typlen */ ,
11470  false /* TEXT's typbyval */ ,
11471  TYPALIGN_INT /* TEXT's typalign */ ,
11472  &isnull);
11473  if (isnull)
11474  continue;
11475  current = TextDatumGetCString(d);
11476 
11477  /* check for match up through and including '=' */
11478  if (strncmp(current, newval, strlen(name) + 1) == 0)
11479  {
11480  index = i;
11481  break;
11482  }
11483  }
11484 
11485  a = array_set(array, 1, &index,
11486  datum,
11487  false,
11488  -1 /* varlena array */ ,
11489  -1 /* TEXT's typlen */ ,
11490  false /* TEXT's typbyval */ ,
11491  TYPALIGN_INT /* TEXT's typalign */ );
11492  }
11493  else
11494  a = construct_array(&datum, 1,
11495  TEXTOID,
11496  -1, false, TYPALIGN_INT);
11497 
11498  return a;
11499 }
#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:85
#define TextDatumGetCString(d)
Definition: builtins.h:86
static bool validate_option_array_item(const char *name, const char *value, bool skipIfNoPermissions)
Definition: guc.c:11654
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 11508 of file guc.c.

11509 {
11510  struct config_generic *record;
11511  ArrayType *newarray;
11512  int i;
11513  int index;
11514 
11515  Assert(name);
11516 
11517  /* test if the option is valid and we're allowed to set it */
11518  (void) validate_option_array_item(name, NULL, false);
11519 
11520  /* normalize name (converts obsolete GUC names to modern spellings) */
11521  record = find_option(name, false, true, WARNING);
11522  if (record)
11523  name = record->name;
11524 
11525  /* if array is currently null, then surely nothing to delete */
11526  if (!array)
11527  return NULL;
11528 
11529  newarray = NULL;
11530  index = 1;
11531 
11532  for (i = 1; i <= ARR_DIMS(array)[0]; i++)
11533  {
11534  Datum d;
11535  char *val;
11536  bool isnull;
11537 
11538  d = array_ref(array, 1, &i,
11539  -1 /* varlenarray */ ,
11540  -1 /* TEXT's typlen */ ,
11541  false /* TEXT's typbyval */ ,
11542  TYPALIGN_INT /* TEXT's typalign */ ,
11543  &isnull);
11544  if (isnull)
11545  continue;
11546  val = TextDatumGetCString(d);
11547 
11548  /* ignore entry if it's what we want to delete */
11549  if (strncmp(val, name, strlen(name)) == 0
11550  && val[strlen(name)] == '=')
11551  continue;
11552 
11553  /* else add it to the output array */
11554  if (newarray)
11555  newarray = array_set(newarray, 1, &index,
11556  d,
11557  false,
11558  -1 /* varlenarray */ ,
11559  -1 /* TEXT's typlen */ ,
11560  false /* TEXT's typbyval */ ,
11561  TYPALIGN_INT /* TEXT's typalign */ );
11562  else
11563  newarray = construct_array(&d, 1,
11564  TEXTOID,
11565  -1, false, TYPALIGN_INT);
11566 
11567  index++;
11568  }
11569 
11570  return newarray;
11571 }
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 11580 of file guc.c.

11581 {
11582  ArrayType *newarray;
11583  int i;
11584  int index;
11585 
11586  /* if array is currently null, nothing to do */
11587  if (!array)
11588  return NULL;
11589 
11590  /* if we're superuser, we can delete everything, so just do it */
11591  if (superuser())
11592  return NULL;
11593 
11594  newarray = NULL;
11595  index = 1;
11596 
11597  for (i = 1; i <= ARR_DIMS(array)[0]; i++)
11598  {
11599  Datum d;
11600  char *val;
11601  char *eqsgn;
11602  bool isnull;
11603 
11604  d = array_ref(array, 1, &i,
11605  -1 /* varlenarray */ ,
11606  -1 /* TEXT's typlen */ ,
11607  false /* TEXT's typbyval */ ,
11608  TYPALIGN_INT /* TEXT's typalign */ ,
11609  &isnull);
11610  if (isnull)
11611  continue;
11612  val = TextDatumGetCString(d);
11613 
11614  eqsgn = strchr(val, '=');
11615  *eqsgn = '\0';
11616 
11617  /* skip if we have permission to delete it */
11618  if (validate_option_array_item(val, NULL, true))
11619  continue;
11620 
11621  /* else add it to the output array */
11622  if (newarray)
11623  newarray = array_set(newarray, 1, &index,
11624  d,
11625  false,
11626  -1 /* varlenarray */ ,
11627  -1 /* TEXT's typlen */ ,
11628  false /* TEXT's typbyval */ ,
11629  TYPALIGN_INT /* TEXT's typalign */ );
11630  else
11631  newarray = construct_array(&d, 1,
11632  TEXTOID,
11633  -1, false, TYPALIGN_INT);
11634 
11635  index++;
11636  pfree(val);
11637  }
11638 
11639  return newarray;
11640 }

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

5837 {
5838  int i;
5839 
5840  /*
5841  * Before log_line_prefix could possibly receive a nonempty setting, make
5842  * sure that timezone processing is minimally alive (see elog.c).
5843  */
5845 
5846  /*
5847  * Build sorted array of all GUC variables.
5848  */
5850 
5851  /*
5852  * Load all variables with their compiled-in defaults, and initialize
5853  * status fields as needed.
5854  */
5855  for (i = 0; i < num_guc_variables; i++)
5856  {
5858  }
5859 
5860  guc_dirty = false;
5861 
5862  reporting_enabled = false;
5863 
5864  /*
5865  * Prevent any attempt to override the transaction modes from
5866  * non-interactive sources.
5867  */
5868  SetConfigOption("transaction_isolation", "read committed",
5870  SetConfigOption("transaction_read_only", "no",
5872  SetConfigOption("transaction_deferrable", "no",
5874 
5875  /*
5876  * For historical reasons, some GUC parameters can receive defaults from
5877  * environment variables. Process those settings.
5878  */
5880 }
void SetConfigOption(const char *name, const char *value, GucContext context, GucSource source)
Definition: guc.c:8370
static void InitializeOneGUCOption(struct config_generic *gconf)
Definition: guc.c:5967
void build_guc_variables(void)
Definition: guc.c:5413
static void InitializeGUCOptionsFromEnvironment(void)
Definition: guc.c:5921
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().

◆ InitializeWalConsistencyChecking()

void InitializeWalConsistencyChecking ( void  )

Definition at line 5889 of file guc.c.

5890 {
5892 
5894  {
5895  struct config_generic *guc;
5896 
5897  guc = find_option("wal_consistency_checking", false, false, ERROR);
5898 
5900 
5901  set_config_option("wal_consistency_checking",
5903  PGC_POSTMASTER, guc->source,
5904  GUC_ACTION_SET, true, ERROR, false);
5905 
5906  /* checking should not be deferred again */
5908  }
5909 }
static bool check_wal_consistency_checking_deferred
Definition: guc.c:254
bool process_shared_preload_libraries_done
Definition: miscinit.c:1619
char * wal_consistency_checking_string
Definition: xlog.c:126

References Assert(), check_wal_consistency_checking_deferred, ERROR, find_option(), GUC_ACTION_SET, PGC_POSTMASTER, process_shared_preload_libraries_done, set_config_option(), config_generic::source, and wal_consistency_checking_string.

Referenced by PostmasterMain().

◆ MarkGUCPrefixReserved()

void MarkGUCPrefixReserved ( const char *  className)

Definition at line 9623 of file guc.c.

9624 {
9625  int classLen = strlen(className);
9626  int i;
9627  MemoryContext oldcontext;
9628 
9629  /*
9630  * Check for existing placeholders. We must actually remove invalid
9631  * placeholders, else future parallel worker startups will fail. (We
9632  * don't bother trying to free associated memory, since this shouldn't
9633  * happen often.)
9634  */
9635  for (i = 0; i < num_guc_variables; i++)
9636  {
9637  struct config_generic *var = guc_variables[i];
9638 
9639  if ((var->flags & GUC_CUSTOM_PLACEHOLDER) != 0 &&
9640  strncmp(className, var->name, classLen) == 0 &&
9641  var->name[classLen] == GUC_QUALIFIER_SEPARATOR)
9642  {
9643  ereport(WARNING,
9644  (errcode(ERRCODE_INVALID_NAME),
9645  errmsg("invalid configuration parameter name \"%s\", removing it",
9646  var->name),
9647  errdetail("\"%s\" is now a reserved prefix.",
9648  className)));
9650  memmove(&guc_variables[i], &guc_variables[i + 1],
9651  (num_guc_variables - i) * sizeof(struct config_generic *));
9652  }
9653  }
9654 
9655  /* And remember the name so we can prevent future mistakes. */
9658  MemoryContextSwitchTo(oldcontext);
9659 }
int errdetail(const char *fmt,...)
Definition: elog.c:1037
static List * reserved_class_prefix
Definition: guc.c:156
#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

References ereport, errcode(), errdetail(), 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().

◆ NewGUCNestLevel()

◆ parse_int()

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

Definition at line 7098 of file guc.c.

7099 {
7100  /*
7101  * We assume here that double is wide enough to represent any integer
7102  * value with adequate precision.
7103  */
7104  double val;
7105  char *endptr;
7106 
7107  /* To suppress compiler warnings, always set output params */
7108  if (result)
7109  *result = 0;
7110  if (hintmsg)
7111  *hintmsg = NULL;
7112 
7113  /*
7114  * Try to parse as an integer (allowing octal or hex input). If the
7115  * conversion stops at a decimal point or 'e', or overflows, re-parse as
7116  * float. This should work fine as long as we have no unit names starting
7117  * with 'e'. If we ever do, the test could be extended to check for a
7118  * sign or digit after 'e', but for now that's unnecessary.
7119  */
7120  errno = 0;
7121  val = strtol(value, &endptr, 0);
7122  if (*endptr == '.' || *endptr == 'e' || *endptr == 'E' ||
7123  errno == ERANGE)
7124  {
7125  errno = 0;
7126  val = strtod(value, &endptr);
7127  }
7128 
7129  if (endptr == value || errno == ERANGE)
7130  return false; /* no HINT for these cases */
7131 
7132  /* reject NaN (infinities will fail range check below) */
7133  if (isnan(val))
7134  return false; /* treat same as syntax error; no HINT */
7135 
7136  /* allow whitespace between number and unit */
7137  while (isspace((unsigned char) *endptr))
7138  endptr++;
7139 
7140  /* Handle possible unit */
7141  if (*endptr != '\0')
7142  {
7143  if ((flags & GUC_UNIT) == 0)
7144  return false; /* this setting does not accept a unit */
7145 
7147  endptr, (flags & GUC_UNIT),
7148  &val))
7149  {
7150  /* invalid unit, or garbage after the unit; set hint and fail. */
7151  if (hintmsg)
7152  {
7153  if (flags & GUC_UNIT_MEMORY)
7154  *hintmsg = memory_units_hint;
7155  else
7156  *hintmsg = time_units_hint;
7157  }
7158  return false;
7159  }
7160  }
7161 
7162  /* Round to int, then check for overflow */
7163  val = rint(val);
7164 
7165  if (val > INT_MAX || val < INT_MIN)
7166  {
7167  if (hintmsg)
7168  *hintmsg = gettext_noop("Value exceeds integer range.");
7169  return false;
7170  }
7171 
7172  if (result)
7173  *result = (int) val;
7174  return true;
7175 }
#define gettext_noop(x)
Definition: c.h:1194
static const char * memory_units_hint
Definition: guc.c:918
static bool convert_to_base_unit(double value, const char *unit, int base_unit, double *base_value)
Definition: guc.c:6898
static const char * time_units_hint
Definition: guc.c:955
#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 7188 of file guc.c.

7189 {
7190  double val;
7191  char *endptr;
7192 
7193  /* To suppress compiler warnings, always set output params */
7194  if (result)
7195  *result = 0;
7196  if (hintmsg)
7197  *hintmsg = NULL;
7198 
7199  errno = 0;
7200  val = strtod(value, &endptr);
7201 
7202  if (endptr == value || errno == ERANGE)
7203  return false; /* no HINT for these cases */
7204 
7205  /* reject NaN (infinities will fail range checks later) */
7206  if (isnan(val))
7207  return false; /* treat same as syntax error; no HINT */
7208 
7209  /* allow whitespace between number and unit */
7210  while (isspace((unsigned char) *endptr))
7211  endptr++;
7212 
7213  /* Handle possible unit */
7214  if (*endptr != '\0')
7215  {
7216  if ((flags & GUC_UNIT) == 0)
7217  return false; /* this setting does not accept a unit */
7218 
7220  endptr, (flags & GUC_UNIT),
7221  &val))
7222  {
7223  /* invalid unit, or garbage after the unit; set hint and fail. */
7224  if (hintmsg)
7225  {
7226  if (flags & GUC_UNIT_MEMORY)
7227  *hintmsg = memory_units_hint;
7228  else
7229  *hintmsg = time_units_hint;
7230  }
7231  return false;
7232  }
7233  }
7234 
7235  if (result)
7236  *result = val;
7237  return true;
7238 }

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

11326 {
11327  size_t equal_pos;
11328  char *cp;
11329 
11330  AssertArg(string);
11331  AssertArg(name);
11332  AssertArg(value);
11333 
11334  equal_pos = strcspn(string, "=");
11335 
11336  if (string[equal_pos] == '=')
11337  {
11338  *name = guc_malloc(FATAL, equal_pos + 1);
11339  strlcpy(*name, string, equal_pos + 1);
11340 
11341  *value = guc_strdup(FATAL, &string[equal_pos + 1]);
11342  }
11343  else
11344  {
11345  /* no equal sign in string */
11346  *name = guc_strdup(FATAL, string);
11347  *value = NULL;
11348  }
11349 
11350  for (cp = *name; *cp; cp++)
11351  if (*cp == '-')
11352  *cp = '_';
11353 }
#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:5190
static char * guc_strdup(int elevel, const char *src)
Definition: guc.c:5222
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 11363 of file guc.c.

11365 {
11366  int i;
11367 
11368  Assert(array != NULL);
11369  Assert(ARR_ELEMTYPE(array) == TEXTOID);
11370  Assert(ARR_NDIM(array) == 1);
11371  Assert(ARR_LBOUND(array)[0] == 1);
11372 
11373  for (i = 1; i <= ARR_DIMS(array)[0]; i++)
11374  {
11375  Datum d;
11376  bool isnull;
11377  char *s;
11378  char *name;
11379  char *value;
11380  char *namecopy;
11381  char *valuecopy;
11382 
11383  d = array_ref(array, 1, &i,
11384  -1 /* varlenarray */ ,
11385  -1 /* TEXT's typlen */ ,
11386  false /* TEXT's typbyval */ ,
11387  TYPALIGN_INT /* TEXT's typalign */ ,
11388  &isnull);
11389 
11390  if (isnull)
11391  continue;
11392 
11393  s = TextDatumGetCString(d);
11394 
11395  ParseLongOption(s, &name, &value);
11396  if (!value)
11397  {
11398  ereport(WARNING,
11399  (errcode(ERRCODE_SYNTAX_ERROR),
11400  errmsg("could not parse setting for parameter \"%s\"",
11401  name)));
11402  free(name);
11403  continue;
11404  }
11405 
11406  /* free malloc'd strings immediately to avoid leak upon error */
11407  namecopy = pstrdup(name);
11408  free(name);
11409  valuecopy = pstrdup(value);
11410  free(value);
11411 
11412  (void) set_config_option(namecopy, valuecopy,
11413  context, source,
11414  action, true, 0, false);
11415 
11416  pfree(namecopy);
11417  pfree(valuecopy);
11418  pfree(s);
11419  }
11420 }
void ParseLongOption(const char *string, char **name, char **value)
Definition: guc.c:11325

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

6813 {
6814  /* Quick exit if not (yet) enabled */
6815  if (!reporting_enabled)
6816  return;
6817 
6818  /*
6819  * Since in_hot_standby isn't actually changed by normal GUC actions, we
6820  * need a hack to check whether a new value needs to be reported to the
6821  * client. For speed, we rely on the assumption that it can never
6822  * transition from false to true.
6823  */
6825  {
6826  struct config_generic *record;
6827 
6828  record = find_option("in_hot_standby", false, false, ERROR);
6829  Assert(record != NULL);
6830  record->status |= GUC_NEEDS_REPORT;
6831  report_needed = true;
6832  in_hot_standby = false;
6833  }
6834 
6835  /* Quick exit if no values have been changed */
6836  if (!report_needed)
6837  return;
6838 
6839  /* Transmit new values of interesting variables */
6840  for (int i = 0; i < num_guc_variables; i++)
6841  {
6842  struct config_generic *conf = guc_variables[i];
6843 
6844  if ((conf->flags & GUC_REPORT) && (conf->status & GUC_NEEDS_REPORT))
6845  ReportGUCOption(conf);
6846  }
6847 
6848  report_needed = false;
6849 }

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

6264 {
6265  int i;
6266 
6267  for (i = 0; i < num_guc_variables; i++)
6268  {
6269  struct config_generic *gconf = guc_variables[i];
6270 
6271  /* Don't reset non-SET-able values */
6272  if (gconf->context != PGC_SUSET &&
6273  gconf->context != PGC_USERSET)
6274  continue;
6275  /* Don't reset if special exclusion from RESET ALL */
6276  if (gconf->flags & GUC_NO_RESET_ALL)
6277  continue;
6278  /* No need to reset if wasn't SET */
6279  if (gconf->source <= PGC_S_OVERRIDE)
6280  continue;
6281 
6282  /* Save old value to support transaction abort */
6284 
6285  switch (gconf->vartype)
6286  {
6287  case PGC_BOOL:
6288  {
6289  struct config_bool *conf = (struct config_bool *) gconf;
6290 
6291  if (conf->assign_hook)
6292  conf->assign_hook(conf->reset_val,
6293  conf->reset_extra);
6294  *conf->variable = conf->reset_val;
6295  set_extra_field(&conf->gen, &conf->gen.extra,
6296  conf->reset_extra);
6297  break;
6298  }
6299  case PGC_INT:
6300  {
6301  struct config_int *conf = (struct config_int *) gconf;
6302 
6303  if (conf->assign_hook)
6304  conf->assign_hook(conf->reset_val,
6305  conf->reset_extra);
6306  *conf->variable = conf->reset_val;
6307  set_extra_field(&conf->gen, &conf->gen.extra,
6308  conf->reset_extra);
6309  break;
6310  }
6311  case PGC_REAL:
6312  {
6313  struct config_real *conf = (struct config_real *) gconf;
6314 
6315  if (conf->assign_hook)
6316  conf->assign_hook(conf->reset_val,
6317  conf->reset_extra);
6318  *conf->variable = conf->reset_val;
6319  set_extra_field(&conf->gen, &conf->gen.extra,
6320  conf->reset_extra);
6321  break;
6322  }
6323  case PGC_STRING:
6324  {
6325  struct config_string *conf = (struct config_string *) gconf;
6326 
6327  if (conf->assign_hook)
6328  conf->assign_hook(conf->reset_val,
6329  conf->reset_extra);
6330  set_string_field(conf, conf->variable, conf->reset_val);
6331  set_extra_field(&conf->gen, &conf->gen.extra,
6332  conf->reset_extra);
6333  break;
6334  }
6335  case PGC_ENUM:
6336  {
6337  struct config_enum *conf = (struct config_enum *) gconf;
6338 
6339  if (conf->assign_hook)
6340  conf->assign_hook(conf->reset_val,
6341  conf->reset_extra);
6342  *conf->variable = conf->reset_val;
6343  set_extra_field(&conf->gen, &conf->gen.extra,
6344  conf->reset_extra);
6345  break;
6346  }
6347  }
6348 
6349  gconf->source = gconf->reset_source;
6350  gconf->scontext = gconf->reset_scontext;
6351 
6352  if (gconf->flags & GUC_REPORT)
6353  {
6354  gconf->status |= GUC_NEEDS_REPORT;
6355  report_needed = true;
6356  }
6357  }
6358 }
static void push_old_value(struct config_generic *gconf, GucAction action)
Definition: guc.c:6366
#define GUC_NO_RESET_ALL
Definition: guc.h:207
void * reset_extra
Definition: guc_tables.h:187
void * reset_extra
Definition: guc_tables.h:248
GucContext reset_scontext
Definition: guc_tables.h:154
GucSource reset_source
Definition: guc_tables.h:152
void * reset_extra
Definition: guc_tables.h:203
void * reset_extra
Definition: guc_tables.h:219
void * reset_extra
Definition: guc_tables.h:233

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

11161 {
11162  char *varname,
11163  *varvalue,
11164  *varsourcefile;
11165  int varsourceline;
11166  GucSource varsource;
11167  GucContext varscontext;
11168  char *srcptr = (char *) gucstate;
11169  char *srcend;
11170  Size len;
11171  int i;
11172  ErrorContextCallback error_context_callback;
11173 
11174  /*
11175  * First, ensure that all potentially-shippable GUCs are reset to their
11176  * default values. We must not touch those GUCs that the leader will
11177  * never ship, while there is no need to touch those that are shippable
11178  * but already have their default values. Thus, this ends up being the
11179  * same test that SerializeGUCState uses, even though the sets of
11180  * variables involved may well be different since the leader's set of
11181  * variables-not-at-default-values can differ from the set that are
11182  * not-default in this freshly started worker.
11183  *
11184  * Once we have set all the potentially-shippable GUCs to default values,
11185  * restoring the GUCs that the leader sent (because they had non-default
11186  * values over there) leads us to exactly the set of GUC values that the
11187  * leader has. This is true even though the worker may have initially
11188  * absorbed postgresql.conf settings that the leader hasn't yet seen, or
11189  * ALTER USER/DATABASE SET settings that were established after the leader
11190  * started.
11191  *
11192  * Note that ensuring all the potential target GUCs are at PGC_S_DEFAULT
11193  * also ensures that set_config_option won't refuse to set them because of
11194  * source-priority comparisons.
11195  */
11196  for (i = 0; i < num_guc_variables; i++)
11197  {
11198  struct config_generic *gconf = guc_variables[i];
11199 
11200  /* Do nothing if non-shippable or if already at PGC_S_DEFAULT. */
11201  if (can_skip_gucvar(gconf))
11202  continue;
11203 
11204  /*
11205  * We can use InitializeOneGUCOption to reset the GUC to default, but
11206  * first we must free any existing subsidiary data to avoid leaking
11207  * memory. The stack must be empty, but we have to clean up all other
11208  * fields. Beware that there might be duplicate value or "extra"
11209  * pointers.
11210  */
11211  Assert(gconf->stack == NULL);
11212  if (gconf->extra)
11213  free(gconf->extra);
11214  if (gconf->last_reported) /* probably can't happen */
11215  free(gconf->last_reported);
11216  if (gconf->sourcefile)
11217  free(gconf->sourcefile);
11218  switch (gconf->vartype)
11219  {
11220  case PGC_BOOL:
11221  {
11222  struct config_bool *conf = (struct config_bool *) gconf;
11223 
11224  if (conf->reset_extra && conf->reset_extra != gconf->extra)
11225  free(conf->reset_extra);
11226  break;
11227  }
11228  case PGC_INT:
11229  {
11230  struct config_int *conf = (struct config_int *) gconf;
11231 
11232  if (conf->reset_extra && conf->reset_extra != gconf->extra)
11233  free(conf->reset_extra);
11234  break;
11235  }
11236  case PGC_REAL:
11237  {
11238  struct config_real *conf = (struct config_real *) gconf;
11239 
11240  if (conf->reset_extra && conf->reset_extra != gconf->extra)
11241  free(conf->reset_extra);
11242  break;
11243  }
11244  case PGC_STRING:
11245  {
11246  struct config_string *conf = (struct config_string *) gconf;
11247 
11248  if (*conf->variable)
11249  free(*conf->variable);
11250  if (conf->reset_val && conf->reset_val != *conf->variable)
11251  free(conf->reset_val);
11252  if (conf->reset_extra && conf->reset_extra != gconf->extra)
11253  free(conf->reset_extra);
11254  break;
11255  }
11256  case PGC_ENUM:
11257  {
11258  struct config_enum *conf = (struct config_enum *) gconf;
11259 
11260  if (conf->reset_extra && conf->reset_extra != gconf->extra)
11261  free(conf->reset_extra);
11262  break;
11263  }
11264  }
11265  /* Now we can reset the struct to PGS_S_DEFAULT state. */
11266  InitializeOneGUCOption(gconf);
11267  }
11268 
11269  /* First item is the length of the subsequent data */
11270  memcpy(&len, gucstate, sizeof(len));
11271 
11272  srcptr += sizeof(len);
11273  srcend = srcptr + len;
11274 
11275  /* If the GUC value check fails, we want errors to show useful context. */
11276  error_context_callback.callback = guc_restore_error_context_callback;
11277  error_context_callback.previous = error_context_stack;
11278  error_context_callback.arg = NULL;
11279  error_context_stack = &error_context_callback;
11280 
11281  /* Restore all the listed GUCs. */
11282  while (srcptr < srcend)
11283  {
11284  int result;
11285  char *error_context_name_and_value[2];
11286 
11287  varname = read_gucstate(&srcptr, srcend);
11288  varvalue = read_gucstate(&srcptr, srcend);
11289  varsourcefile = read_gucstate(&srcptr, srcend);
11290  if (varsourcefile[0])
11291  read_gucstate_binary(&srcptr, srcend,
11292  &varsourceline, sizeof(varsourceline));
11293  else
11294  varsourceline = 0;
11295  read_gucstate_binary(&srcptr, srcend,
11296  &varsource, sizeof(varsource));
11297  read_gucstate_binary(&srcptr, srcend,
11298  &varscontext, sizeof(varscontext));
11299 
11300  error_context_name_and_value[0] = varname;
11301  error_context_name_and_value[1] = varvalue;
11302  error_context_callback.arg = &error_context_name_and_value[0];
11303  result = set_config_option(varname, varvalue, varscontext, varsource,
11304  GUC_ACTION_SET, true, ERROR, true);
11305  if (result <= 0)
11306  ereport(ERROR,
11307  (errcode(ERRCODE_INTERNAL_ERROR),
11308  errmsg("parameter \"%s\" could not be set", varname)));
11309  if (varsourcefile[0])
11310  set_config_sourcefile(varname, varsourcefile, varsourceline);
11311  error_context_callback.arg = NULL;
11312  }
11313 
11314  error_context_stack = error_context_callback.previous;
11315 }
ErrorContextCallback * error_context_stack
Definition: elog.c:93
static void guc_restore_error_context_callback(void *arg)
Definition: guc.c:11138
static void static void set_config_sourcefile(const char *name, char *sourcefile, int sourceline)
Definition: guc.c:8336
static char * read_gucstate(char **srcptr, char *srcend)
Definition: guc.c:11101
static bool can_skip_gucvar(struct config_generic *gconf)
Definition: guc.c:10792
static void read_gucstate_binary(char **srcptr, char *srcend, void *dest, Size size)
Definition: guc.c:11124
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:157

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

6089 {
6090  char *configdir;
6091  char *fname;
6092  struct stat stat_buf;
6093 
6094  /* configdir is -D option, or $PGDATA if no -D */
6095  if (userDoption)
6096  configdir = make_absolute_path(userDoption);
6097  else
6098  configdir = make_absolute_path(getenv("PGDATA"));
6099 
6100  if (configdir && stat(configdir, &stat_buf) != 0)
6101  {
6102  write_stderr("%s: could not access directory \"%s\": %s\n",
6103  progname,
6104  configdir,
6105  strerror(errno));
6106  if (errno == ENOENT)
6107  write_stderr("Run initdb or pg_basebackup to initialize a PostgreSQL data directory.\n");
6108  return false;
6109  }
6110 
6111  /*
6112  * Find the configuration file: if config_file was specified on the
6113  * command line, use it, else use configdir/postgresql.conf. In any case
6114  * ensure the result is an absolute path, so that it will be interpreted
6115  * the same way by future backends.
6116  */
6117  if (ConfigFileName)
6119  else if (configdir)
6120  {
6121  fname = guc_malloc(FATAL,
6122  strlen(configdir) + strlen(CONFIG_FILENAME) + 2);
6123  sprintf(fname, "%s/%s", configdir, CONFIG_FILENAME);
6124  }
6125  else
6126  {
6127  write_stderr("%s does not know where to find the server configuration file.\n"
6128  "You must specify the --config-file or -D invocation "
6129  "option or set the PGDATA environment variable.\n",
6130  progname);
6131  return false;
6132  }
6133 
6134  /*
6135  * Set the ConfigFileName GUC variable to its final value, ensuring that
6136  * it can't be overridden later.
6137  */
6138  SetConfigOption("config_file", fname, PGC_POSTMASTER, PGC_S_OVERRIDE);
6139  free(fname);
6140 
6141  /*
6142  * Now read the config file for the first time.
6143  */
6144  if (stat(ConfigFileName, &stat_buf) != 0)
6145  {
6146  write_stderr("%s: could not access the server configuration file \"%s\": %s\n",
6147  progname, ConfigFileName, strerror(errno));
6148  free(configdir);
6149  return false;
6150  }
6151 
6152  /*
6153  * Read the configuration file for the first time. This time only the
6154  * data_directory parameter is picked up to determine the data directory,
6155  * so that we can read the PG_AUTOCONF_FILENAME file next time.
6156  */
6158 
6159  /*
6160  * If the data_directory GUC variable has been set, use that as DataDir;
6161  * otherwise use configdir if set; else punt.
6162  *
6163  * Note: SetDataDir will copy and absolute-ize its argument, so we don't
6164  * have to.
6165  */
6166  if (data_directory)
6168  else if (configdir)
6169  SetDataDir(configdir);
6170  else
6171  {
6172  write_stderr("%s does not know where to find the database system data.\n"
6173  "This can be specified as \"data_directory\" in \"%s\", "
6174  "or by the -D invocation option, or by the "
6175  "PGDATA environment variable.\n",
6177  return false;
6178  }
6179 
6180  /*
6181  * Reflect the final DataDir value back into the data_directory GUC var.
6182  * (If you are wondering why we don't just make them a single variable,
6183  * it's because the EXEC_BACKEND case needs DataDir to be transmitted to
6184  * child backends specially. XXX is that still true? Given that we now
6185  * chdir to DataDir, EXEC_BACKEND can read the config file without knowing
6186  * DataDir in advance.)
6187  */
6189 
6190  /*
6191  * Now read the config file a second time, allowing any settings in the
6192  * PG_AUTOCONF_FILENAME file to take effect. (This is pretty ugly, but
6193  * since we have to determine the DataDir before we can find the autoconf
6194  * file, the alternatives seem worse.)
6195  */
6197 
6198  /*
6199  * If timezone_abbreviations wasn't set in the configuration file, install
6200  * the default value. We do it this way because we can't safely install a
6201  * "real" value until my_exec_path is set, which may not have happened
6202  * when InitializeGUCOptions runs, so the bootstrap default value cannot
6203  * be the real desired default.
6204  */
6206 
6207  /*
6208  * Figure out where pg_hba.conf is, and make sure the path is absolute.
6209  */
6210  if (HbaFileName)
6212  else if (configdir)
6213  {
6214  fname = guc_malloc(FATAL,
6215  strlen(configdir) + strlen(HBA_FILENAME) + 2);
6216  sprintf(fname, "%s/%s", configdir, HBA_FILENAME);
6217  }
6218  else
6219  {
6220  write_stderr("%s does not know where to find the \"hba\" configuration file.\n"
6221  "This can be specified as \"hba_file\" in \"%s\", "
6222  "or by the -D invocation option, or by the "
6223  "PGDATA environment variable.\n",
6225  return false;
6226  }
6227  SetConfigOption("hba_file", fname, PGC_POSTMASTER, PGC_S_OVERRIDE);
6228  free(fname);
6229 
6230  /*
6231  * Likewise for pg_ident.conf.
6232  */
6233  if (IdentFileName)
6235  else if (configdir)
6236  {
6237  fname = guc_malloc(FATAL,
6238  strlen(configdir) + strlen(IDENT_FILENAME) + 2);
6239  sprintf(fname, "%s/%s", configdir, IDENT_FILENAME);
6240  }
6241  else
6242  {
6243  write_stderr("%s does not know where to find the \"ident\" configuration file.\n"
6244  "This can be specified as \"ident_file\" in \"%s\", "
6245  "or by the -D invocation option, or by the "
6246  "PGDATA environment variable.\n",
6248  return false;
6249  }
6250  SetConfigOption("ident_file", fname, PGC_POSTMASTER, PGC_S_OVERRIDE);
6251  free(fname);
6252 
6253  free(configdir);
6254 
6255  return true;
6256 }
#define write_stderr(str)
Definition: parallel.c:186
char * DataDir
Definition: globals.c:66
char * HbaFileName
Definition: guc.c:655
static void pg_timezone_abbrev_initialize(void)
Definition: guc.c:12260
char * ConfigFileName
Definition: guc.c:654
#define IDENT_FILENAME
Definition: guc.c:124
#define HBA_FILENAME
Definition: guc.c:123
char * IdentFileName
Definition: guc.c:656
static char * data_directory
Definition: guc.c:700
#define CONFIG_FILENAME
Definition: guc.c:122
void ProcessConfigFile(GucContext context)
const char * progname
Definition: main.c:50
void SetDataDir(const char *dir)
Definition: miscinit.c:411
char * make_absolute_path(const char *path)
Definition: path.c:729
#define sprintf
Definition: port.h:227
#define strerror
Definition: port.h:238
static const char * userDoption
Definition: postgres.c:170

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

11075 {
11076  char *curptr;
11077  Size actual_size;
11078  Size bytes_left;
11079  int i;
11080 
11081  /* Reserve space for saving the actual size of the guc state */
11082  Assert(maxsize > sizeof(actual_size));
11083  curptr = start_address + sizeof(actual_size);
11084  bytes_left = maxsize - sizeof(actual_size);
11085 
11086  for (i = 0; i < num_guc_variables; i++)
11087  serialize_variable(&curptr, &bytes_left, guc_variables[i]);
11088 
11089  /* Store actual size without assuming alignment of start_address. */
11090  actual_size = maxsize - bytes_left - sizeof(actual_size);
11091  memcpy(start_address, &actual_size, sizeof(actual_size));
11092 }
static void serialize_variable(char **destptr, Size *maxbytes, struct config_generic *gconf)
Definition: guc.c:10999

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

7562 {
7563  struct config_generic *record;
7564  union config_var_val newval_union;
7565  void *newextra = NULL;
7566  bool prohibitValueChange = false;
7567  bool makeDefault;
7568 
7569  if (elevel == 0)
7570  {
7571  if (source == PGC_S_DEFAULT || source == PGC_S_FILE)
7572  {
7573  /*
7574  * To avoid cluttering the log, only the postmaster bleats loudly
7575  * about problems with the config file.
7576  */
7577  elevel = IsUnderPostmaster ? DEBUG3 : LOG;
7578  }
7579  else if (source == PGC_S_GLOBAL ||
7580  source == PGC_S_DATABASE ||
7581  source == PGC_S_USER ||
7583  elevel = WARNING;
7584  else
7585  elevel = ERROR;
7586  }
7587 
7588  /*
7589  * GUC_ACTION_SAVE changes are acceptable during a parallel operation,
7590  * because the current worker will also pop the change. We're probably
7591  * dealing with a function having a proconfig entry. Only the function's
7592  * body should observe the change, and peer workers do not share in the
7593  * execution of a function call started by this worker.
7594  *
7595  * Other changes might need to affect other workers, so forbid them.
7596  */
7597  if (IsInParallelMode() && changeVal && action != GUC_ACTION_SAVE)
7598  ereport(elevel,
7599  (errcode(ERRCODE_INVALID_TRANSACTION_STATE),
7600  errmsg("cannot set parameters during a parallel operation")));
7601 
7602  record = find_option(name, true, false, elevel);
7603  if (record == NULL)
7604  return 0;
7605 
7606  /*
7607  * Check if the option can be set at this time. See guc.h for the precise
7608  * rules.
7609  */
7610  switch (record->context)
7611  {
7612  case PGC_INTERNAL:
7613  if (context != PGC_INTERNAL)
7614  {
7615  ereport(elevel,
7616  (errcode(ERRCODE_CANT_CHANGE_RUNTIME_PARAM),
7617  errmsg("parameter \"%s\" cannot be changed",
7618  name)));
7619  return 0;
7620  }
7621  break;
7622  case PGC_POSTMASTER:
7623  if (context == PGC_SIGHUP)
7624  {
7625  /*
7626  * We are re-reading a PGC_POSTMASTER variable from
7627  * postgresql.conf. We can't change the setting, so we should
7628  * give a warning if the DBA tries to change it. However,
7629  * because of variant formats, canonicalization by check
7630  * hooks, etc, we can't just compare the given string directly
7631  * to what's stored. Set a flag to check below after we have
7632  * the final storable value.
7633  */
7634  prohibitValueChange = true;
7635  }
7636  else if (context != PGC_POSTMASTER)
7637  {
7638  ereport(elevel,
7639  (errcode(ERRCODE_CANT_CHANGE_RUNTIME_PARAM),
7640  errmsg("parameter \"%s\" cannot be changed without restarting the server",
7641  name)));
7642  return 0;
7643  }
7644  break;
7645  case PGC_SIGHUP:
7646  if (context != PGC_SIGHUP && context != PGC_POSTMASTER)
7647  {
7648  ereport(elevel,
7649  (errcode(ERRCODE_CANT_CHANGE_RUNTIME_PARAM),
7650  errmsg("parameter \"%s\" cannot be changed now",
7651  name)));
7652  return 0;
7653  }
7654 
7655  /*
7656  * Hmm, the idea of the SIGHUP context is "ought to be global, but
7657  * can be changed after postmaster start". But there's nothing
7658  * that prevents a crafty administrator from sending SIGHUP
7659  * signals to individual backends only.
7660  */
7661  break;
7662  case PGC_SU_BACKEND:
7663  if (context == PGC_BACKEND)
7664  {
7665  /*
7666  * Check whether the current user has been granted privilege
7667  * to set this GUC.
7668  */
7669  AclResult aclresult;
7670 
7671  aclresult = pg_parameter_aclcheck(name, GetUserId(), ACL_SET);
7672  if (aclresult != ACLCHECK_OK)
7673  {
7674  /* No granted privilege */
7675  ereport(elevel,
7676  (errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
7677  errmsg("permission denied to set parameter \"%s\"",
7678  name)));
7679  return 0;
7680  }
7681  }
7682  /* fall through to process the same as PGC_BACKEND */
7683  /* FALLTHROUGH */
7684  case PGC_BACKEND:
7685  if (context == PGC_SIGHUP)
7686  {
7687  /*
7688  * If a PGC_BACKEND or PGC_SU_BACKEND parameter is changed in
7689  * the config file, we want to accept the new value in the
7690  * postmaster (whence it will propagate to
7691  * subsequently-started backends), but ignore it in existing
7692  * backends. This is a tad klugy, but necessary because we
7693  * don't re-read the config file during backend start.
7694  *
7695  * In EXEC_BACKEND builds, this works differently: we load all
7696  * non-default settings from the CONFIG_EXEC_PARAMS file
7697  * during backend start. In that case we must accept
7698  * PGC_SIGHUP settings, so as to have the same value as if
7699  * we'd forked from the postmaster. This can also happen when
7700  * using RestoreGUCState() within a background worker that
7701  * needs to have the same settings as the user backend that
7702  * started it. is_reload will be true when either situation
7703  * applies.
7704  */
7705  if (IsUnderPostmaster && !is_reload)
7706  return -1;
7707  }
7708  else if (context != PGC_POSTMASTER &&
7709  context != PGC_BACKEND &&
7710  context != PGC_SU_BACKEND &&
7711  source != PGC_S_CLIENT)
7712  {
7713  ereport(elevel,
7714  (errcode(ERRCODE_CANT_CHANGE_RUNTIME_PARAM),
7715  errmsg("parameter \"%s\" cannot be set after connection start",
7716  name)));
7717  return 0;
7718  }
7719  break;
7720  case PGC_SUSET:
7721  if (context == PGC_USERSET || context == PGC_BACKEND)
7722  {
7723  /*
7724  * Check whether the current user has been granted privilege
7725  * to set this GUC.
7726  */
7727  AclResult aclresult;
7728 
7729  aclresult = pg_parameter_aclcheck(name, GetUserId(), ACL_SET);
7730  if (aclresult != ACLCHECK_OK)
7731  {
7732  /* No granted privilege */
7733  ereport(elevel,
7734  (errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
7735  errmsg("permission denied to set parameter \"%s\"",
7736  name)));
7737  return 0;
7738  }
7739  }
7740  break;
7741  case PGC_USERSET:
7742  /* always okay */
7743  break;
7744  }
7745 
7746  /*
7747  * Disallow changing GUC_NOT_WHILE_SEC_REST values if we are inside a
7748  * security restriction context. We can reject this regardless of the GUC
7749  * context or source, mainly because sources that it might be reasonable
7750  * to override for won't be seen while inside a function.
7751  *
7752  * Note: variables marked GUC_NOT_WHILE_SEC_REST should usually be marked
7753  * GUC_NO_RESET_ALL as well, because ResetAllOptions() doesn't check this.
7754  * An exception might be made if the reset value is assumed to be "safe".
7755  *
7756  * Note: this flag is currently used for "session_authorization" and
7757  * "role". We need to prohibit changing these inside a local userid
7758  * context because when we exit it, GUC won't be notified, leaving things
7759  * out of sync. (This could be fixed by forcing a new GUC nesting level,
7760  * but that would change behavior in possibly-undesirable ways.) Also, we
7761  * prohibit changing these in a security-restricted operation because
7762  * otherwise RESET could be used to regain the session user's privileges.
7763  */
7764  if (record->flags & GUC_NOT_WHILE_SEC_REST)
7765  {
7766  if (InLocalUserIdChange())
7767  {
7768  /*
7769  * Phrasing of this error message is historical, but it's the most
7770  * common case.
7771  */
7772  ereport(elevel,
7773  (errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
7774  errmsg("cannot set parameter \"%s\" within security-definer function",
7775  name)));
7776  return 0;
7777  }
7779  {
7780  ereport(elevel,
7781  (errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
7782  errmsg("cannot set parameter \"%s\" within security-restricted operation",
7783  name)));
7784  return 0;
7785  }
7786  }
7787 
7788  /*
7789  * Should we set reset/stacked values? (If so, the behavior is not
7790  * transactional.) This is done either when we get a default value from
7791  * the database's/user's/client's default settings or when we reset a
7792  * value to its default.
7793  */
7794  makeDefault = changeVal && (source <= PGC_S_OVERRIDE) &&
7795  ((value != NULL) || source == PGC_S_DEFAULT);
7796 
7797  /*
7798  * Ignore attempted set if overridden by previously processed setting.
7799  * However, if changeVal is false then plow ahead anyway since we are
7800  * trying to find out if the value is potentially good, not actually use
7801  * it. Also keep going if makeDefault is true, since we may want to set
7802  * the reset/stacked values even if we can't set the variable itself.
7803  */
7804  if (record->source > source)
7805  {
7806  if (changeVal && !makeDefault)
7807  {
7808  elog(DEBUG3, "\"%s\": setting ignored because previous source is higher priority",
7809  name);
7810  return -1;
7811  }
7812  changeVal = false;
7813  }
7814 
7815  /*
7816  * Evaluate value and set variable.
7817  */
7818  switch (record->vartype)
7819  {
7820  case PGC_BOOL:
7821  {
7822  struct config_bool *conf = (struct config_bool *) record;
7823 
7824 #define newval (newval_union.boolval)
7825 
7826  if (value)
7827  {
7828  if (!parse_and_validate_value(record, name, value,
7829  source, elevel,
7830  &newval_union, &newextra))
7831  return 0;
7832  }
7833  else if (source == PGC_S_DEFAULT)
7834  {
7835  newval = conf->boot_val;
7836  if (!call_bool_check_hook(conf, &newval, &newextra,
7837  source, elevel))
7838  return 0;
7839  }
7840  else
7841  {
7842  newval = conf->reset_val;
7843  newextra = conf->reset_extra;
7844  source = conf->gen.reset_source;
7845  context = conf->gen.reset_scontext;
7846  }
7847 
7848  if (prohibitValueChange)
7849  {
7850  /* Release newextra, unless it's reset_extra */
7851  if (newextra && !extra_field_used(&conf->gen, newextra))
7852  free(newextra);
7853 
7854  if (*conf->variable != newval)
7855  {
7856  record->status |= GUC_PENDING_RESTART;
7857  ereport(elevel,
7858  (errcode(ERRCODE_CANT_CHANGE_RUNTIME_PARAM),
7859  errmsg("parameter \"%s\" cannot be changed without restarting the server",
7860  name)));
7861  return 0;
7862  }
7863  record->status &= ~GUC_PENDING_RESTART;
7864  return -1;
7865  }
7866 
7867  if (changeVal)
7868  {
7869  /* Save old value to support transaction abort */
7870  if (!makeDefault)
7871  push_old_value(&conf->gen, action);
7872 
7873  if (conf->assign_hook)
7874  conf->assign_hook(newval, newextra);
7875  *conf->variable = newval;
7876  set_extra_field(&conf->gen, &conf->gen.extra,
7877  newextra);
7878  conf->gen.source = source;
7879  conf->gen.scontext = context;
7880  }
7881  if (makeDefault)
7882  {
7883  GucStack *stack;
7884 
7885  if (conf->gen.reset_source <= source)
7886  {
7887  conf->reset_val = newval;
7888  set_extra_field(&conf->gen, &conf->reset_extra,
7889  newextra);
7890  conf->gen.reset_source = source;
7891  conf->gen.reset_scontext = context;
7892  }
7893  for (stack = conf->gen.stack; stack; stack = stack->prev)
7894  {
7895  if (stack->source <= source)
7896  {
7897  stack->prior.val.boolval = newval;
7898  set_extra_field(&conf->gen, &stack->prior.extra,
7899  newextra);
7900  stack->source = source;
7901  stack->scontext = context;
7902  }
7903  }
7904  }
7905 
7906  /* Perhaps we didn't install newextra anywhere */
7907  if (newextra && !extra_field_used(&conf->gen, newextra))
7908  free(newextra);
7909  break;
7910 
7911 #undef newval
7912  }
7913 
7914  case PGC_INT:
7915  {
7916  struct config_int *conf = (struct config_int *) record;
7917 
7918 #define newval (newval_union.intval)
7919 
7920  if (value)
7921  {
7922  if (!parse_and_validate_value(record, name, value,
7923  source, elevel,
7924  &newval_union, &newextra))
7925  return 0;
7926  }
7927  else if (source == PGC_S_DEFAULT)
7928  {
7929  newval = conf->boot_val;
7930  if (!call_int_check_hook(conf, &newval, &newextra,
7931  source, elevel))
7932  return 0;
7933  }
7934  else
7935  {
7936  newval = conf->reset_val;
7937  newextra = conf->reset_extra;
7938  source = conf->gen.reset_source;
7939  context = conf->gen.reset_scontext;
7940  }
7941 
7942  if (prohibitValueChange)
7943  {
7944  /* Release newextra, unless it's reset_extra */
7945  if (newextra && !extra_field_used(&conf->gen, newextra))
7946  free(newextra);
7947 
7948  if (*conf->variable != newval)
7949  {
7950  record->status |= GUC_PENDING_RESTART;
7951  ereport(elevel,
7952  (errcode(ERRCODE_CANT_CHANGE_RUNTIME_PARAM),
7953  errmsg("parameter \"%s\" cannot be changed without restarting the server",
7954  name)));
7955  return 0;
7956  }
7957  record->status &= ~GUC_PENDING_RESTART;
7958  return -1;
7959  }
7960 
7961  if (changeVal)
7962  {
7963  /* Save old value to support transaction abort */
7964  if (!makeDefault)
7965  push_old_value(&conf->gen, action);
7966 
7967  if (conf->assign_hook)
7968  conf->assign_hook(newval, newextra);
7969  *conf->variable = newval;
7970  set_extra_field(&conf->gen, &conf->gen.extra,
7971  newextra);
7972  conf->gen.source = source;
7973  conf->gen.scontext = context;
7974  }
7975  if (makeDefault)
7976  {
7977  GucStack *stack;
7978 
7979  if (conf->gen.reset_source <= source)
7980  {
7981  conf->reset_val = newval;
7982  set_extra_field(&conf->gen, &conf->reset_extra,
7983  newextra);
7984  conf->gen.reset_source = source;
7985  conf->gen.reset_scontext = context;
7986  }
7987  for (stack = conf->gen.stack; stack; stack = stack->prev)
7988  {
7989  if (stack->source <= source)
7990  {
7991  stack->prior.val.intval = newval;
7992  set_extra_field(&conf->gen, &stack->prior.extra,
7993  newextra);
7994  stack->source = source;
7995  stack->scontext = context;
7996  }
7997  }
7998  }
7999 
8000  /* Perhaps we didn't install newextra anywhere */
8001  if (newextra && !extra_field_used(&conf->gen, newextra))
8002  free(newextra);
8003  break;
8004 
8005 #undef newval
8006  }
8007 
8008  case PGC_REAL:
8009  {
8010  struct config_real *conf = (struct config_real *) record;
8011 
8012 #define newval (newval_union.realval)
8013 
8014  if (value)
8015  {
8016  if (!parse_and_validate_value(record, name, value,
8017  source, elevel,
8018  &newval_union, &newextra))
8019  return 0;
8020  }
8021  else if (source == PGC_S_DEFAULT)
8022  {
8023  newval = conf->boot_val;
8024  if (!call_real_check_hook(conf, &newval, &newextra,
8025  source, elevel))
8026  return 0;
8027  }
8028  else
8029  {
8030  newval = conf->reset_val;
8031  newextra = conf->reset_extra;
8032  source = conf->gen.reset_source;
8033  context = conf->gen.reset_scontext;
8034  }
8035 
8036  if (prohibitValueChange)
8037  {
8038  /* Release newextra, unless it's reset_extra */
8039  if (newextra && !extra_field_used(&conf->gen, newextra))
8040  free(newextra);
8041 
8042  if (*conf->variable != newval)
8043  {
8044  record->status |= GUC_PENDING_RESTART;
8045  ereport(elevel,
8046  (errcode(ERRCODE_CANT_CHANGE_RUNTIME_PARAM),
8047  errmsg("parameter \"%s\" cannot be changed without restarting the server",
8048  name)));
8049  return 0;
8050  }
8051  record->status &= ~GUC_PENDING_RESTART;
8052  return -1;
8053  }
8054 
8055  if (changeVal)
8056  {
8057  /* Save old value to support transaction abort */
8058  if (!makeDefault)
8059  push_old_value(&conf->gen, action);
8060 
8061  if (conf->assign_hook)
8062  conf->assign_hook(newval, newextra);
8063  *conf->variable = newval;
8064  set_extra_field(&conf->gen, &conf->gen.extra,
8065  newextra);
8066  conf->gen.source = source;
8067  conf->gen.scontext = context;
8068  }
8069  if (makeDefault)
8070  {
8071  GucStack *stack;
8072 
8073  if (conf->gen.reset_source <= source)
8074  {
8075  conf->reset_val = newval;
8076  set_extra_field(&conf->gen, &conf->reset_extra,
8077  newextra);
8078  conf->gen.reset_source = source;
8079  conf->gen.reset_scontext = context;
8080  }
8081  for (stack = conf->gen.stack; stack; stack = stack->prev)
8082  {
8083  if (stack->source <= source)
8084  {
8085  stack->prior.val.realval = newval;
8086  set_extra_field(&conf->gen, &stack->prior.extra,
8087  newextra);
8088  stack->source = source;
8089  stack->scontext = context;
8090  }
8091  }
8092  }
8093 
8094  /* Perhaps we didn't install newextra anywhere */
8095  if (newextra && !extra_field_used(&conf->gen, newextra))
8096  free(newextra);
8097  break;
8098 
8099 #undef newval
8100  }
8101 
8102  case PGC_STRING:
8103  {
8104  struct config_string *conf = (struct config_string *) record;
8105 
8106 #define newval (newval_union.stringval)
8107 
8108  if (value)
8109  {
8110  if (!parse_and_validate_value(record, name, value,
8111  source, elevel,
8112  &newval_union, &newextra))
8113  return 0;
8114  }
8115  else if (source == PGC_S_DEFAULT)
8116  {
8117  /* non-NULL boot_val must always get strdup'd */
8118  if (conf->boot_val != NULL)
8119  {
8120  newval = guc_strdup(elevel, conf->boot_val);
8121  if (newval == NULL)
8122  return 0;
8123  }
8124  else
8125  newval = NULL;
8126 
8127  if (!call_string_check_hook(conf, &newval, &newextra,
8128  source, elevel))
8129  {
8130  free(newval);
8131  return 0;
8132  }
8133  }
8134  else
8135  {
8136  /*
8137  * strdup not needed, since reset_val is already under
8138  * guc.c's control
8139  */
8140  newval = conf->reset_val;
8141  newextra = conf->reset_extra;
8142  source = conf->gen.reset_source;
8143  context = conf->gen.reset_scontext;
8144  }
8145 
8146  if (prohibitValueChange)
8147  {
8148  bool newval_different;
8149 
8150  /* newval shouldn't be NULL, so we're a bit sloppy here */
8151  newval_different = (*conf->variable == NULL ||
8152  newval == NULL ||
8153  strcmp(*conf->variable, newval) != 0);
8154 
8155  /* Release newval, unless it's reset_val */
8156  if (newval && !string_field_used(conf, newval))
8157  free(newval);
8158  /* Release newextra, unless it's reset_extra */
8159  if (newextra && !extra_field_used(&conf->gen, newextra))
8160  free(newextra);
8161 
8162  if (newval_different)
8163  {
8164  record->status |= GUC_PENDING_RESTART;
8165  ereport(elevel,
8166  (errcode(ERRCODE_CANT_CHANGE_RUNTIME_PARAM),
8167  errmsg("parameter \"%s\" cannot be changed without restarting the server",
8168  name)));
8169  return 0;
8170  }
8171  record->status &= ~GUC_PENDING_RESTART;
8172  return -1;
8173  }
8174 
8175  if (changeVal)
8176  {
8177  /* Save old value to support transaction abort */
8178  if (!makeDefault)
8179  push_old_value(&conf->gen, action);
8180 
8181  if (conf->assign_hook)
8182  conf->assign_hook(newval, newextra);
8183  set_string_field(conf, conf->variable, newval);
8184  set_extra_field(&conf->gen, &conf->gen.extra,
8185  newextra);
8186  conf->gen.source = source;
8187  conf->gen.scontext = context;
8188  }
8189 
8190  if (makeDefault)
8191  {
8192  GucStack *stack;
8193 
8194  if (conf->gen.reset_source <= source)
8195  {
8196  set_string_field(conf, &conf->reset_val, newval);
8197  set_extra_field(&conf->gen, &conf->reset_extra,
8198  newextra);
8199  conf->gen.reset_source = source;
8200  conf->gen.reset_scontext = context;
8201  }
8202  for (stack = conf->gen.stack; stack; stack = stack->prev)
8203  {
8204  if (stack->source <= source)
8205  {
8206  set_string_field(conf, &stack->prior.val.stringval,
8207  newval);
8208  set_extra_field(&conf->gen, &stack->prior.extra,
8209  newextra);
8210  stack->source = source;
8211  stack->scontext = context;
8212  }
8213  }
8214  }
8215 
8216  /* Perhaps we didn't install newval anywhere */
8217  if (newval && !string_field_used(conf, newval))
8218  free(newval);
8219  /* Perhaps we didn't install newextra anywhere */
8220  if (newextra && !extra_field_used(&conf->gen, newextra))
8221  free(newextra);
8222  break;
8223 
8224 #undef newval
8225  }
8226 
8227  case PGC_ENUM:
8228  {
8229  struct config_enum *conf = (struct config_enum *) record;
8230 
8231 #define newval (newval_union.enumval)
8232 
8233  if (value)
8234  {
8235  if (!parse_and_validate_value(record, name, value,
8236  source, elevel,
8237  &newval_union, &newextra))
8238  return 0;
8239  }
8240  else if (source == PGC_S_DEFAULT)
8241  {
8242  newval = conf->boot_val;
8243  if (!call_enum_check_hook(conf, &newval, &newextra,
8244  source, elevel))
8245  return 0;
8246  }
8247  else
8248  {
8249  newval = conf->reset_val;
8250  newextra = conf->reset_extra;
8251  source = conf->gen.reset_source;
8252  context = conf->gen.reset_scontext;
8253  }
8254 
8255  if (prohibitValueChange)
8256  {
8257  /* Release newextra, unless it's reset_extra */
8258  if (newextra && !extra_field_used(&conf->gen, newextra))
8259  free(newextra);
8260 
8261  if (*conf->variable != newval)
8262  {
8263  record->status |= GUC_PENDING_RESTART;
8264  ereport(elevel,
8265  (errcode(ERRCODE_CANT_CHANGE_RUNTIME_PARAM),
8266  errmsg("parameter \"%s\" cannot be changed without restarting the server",
8267  name)));
8268  return 0;
8269  }
8270  record->status &= ~GUC_PENDING_RESTART;
8271  return -1;
8272  }
8273 
8274  if (changeVal)
8275  {
8276  /* Save old value to support transaction abort */
8277  if (!makeDefault)
8278  push_old_value(&conf->gen, action);
8279 
8280  if (conf->assign_hook)
8281  conf->assign_hook(newval, newextra);
8282  *conf->variable = newval;
8283  set_extra_field(&conf->gen, &conf->gen.extra,
8284  newextra);
8285  conf->gen.source = source;
8286  conf->gen.scontext = context;
8287  }
8288  if (makeDefault)
8289  {
8290  GucStack *stack;
8291 
8292  if (conf->gen.reset_source <= source)
8293  {
8294  conf->reset_val = newval;
8295  set_extra_field(&conf->gen, &conf->reset_extra,
8296  newextra);
8297  conf->gen.reset_source = source;
8298  conf->gen.reset_scontext = context;
8299  }
8300  for (stack = conf->gen.stack; stack; stack = stack->prev)
8301  {
8302  if (stack->source <= source)
8303  {
8304  stack->prior.val.enumval = newval;
8305  set_extra_field(&conf->gen, &stack->prior.extra,
8306  newextra);
8307  stack->source = source;
8308  stack->scontext = context;
8309  }
8310  }
8311  }
8312 
8313  /* Perhaps we didn't install newextra anywhere */
8314  if (newextra && !extra_field_used(&conf->gen, newextra))
8315  free(newextra);
8316  break;
8317 
8318 #undef newval
8319  }
8320  }
8321 
8322  if (changeVal && (record->flags & GUC_REPORT))
8323  {
8324  record->status |= GUC_NEEDS_REPORT;
8325  report_needed = true;
8326  }
8327 
8328  return changeVal ? 1 : -1;
8329 }
#define DEBUG3
Definition: elog.h:22
bool IsUnderPostmaster
Definition: globals.c:113
static bool call_string_check_hook(struct config_string *conf, char **newval, void **extra, GucSource source, int elevel)
Definition: guc.c:11841
static bool extra_field_used(struct config_generic *gconf, void *extra)
Definition: guc.c:5278
static bool call_bool_check_hook(struct config_bool *conf, bool *newval, void **extra, GucSource source, int elevel)
Definition: guc.c:11739
static bool call_int_check_hook(struct config_int *conf, int *newval, void **extra, GucSource source, int elevel)
Definition: guc.c:11773
static bool string_field_used(struct config_string *conf, char *strval)
Definition: guc.c:5239
static bool call_real_check_hook(struct config_real *conf, double *newval, void **extra, GucSource source, int elevel)
Definition: guc.c:11807
static bool call_enum_check_hook(struct config_enum *conf, int *newval, void **extra, GucSource source, int elevel)
Definition: guc.c:11891
#define GUC_NOT_WHILE_SEC_REST
Definition: guc.h:214
bool InSecurityRestrictedOperation(void)
Definition: miscinit.c:630
bool InLocalUserIdChange(void)
Definition: miscinit.c:621

References ACL_SET, ACLCHECK_OK, 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, 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, GetUserId(), 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(), pg_parameter_aclcheck(), 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,