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

Go to the source code of this file.

Functions

bool check_application_name (char **newval, void **extra, GucSource source)
 
void assign_application_name (const char *newval, void *extra)
 
const char * show_archive_command (void)
 
bool check_autovacuum_max_workers (int *newval, void **extra, GucSource source)
 
bool check_autovacuum_work_mem (int *newval, void **extra, GucSource source)
 
bool check_vacuum_buffer_usage_limit (int *newval, void **extra, GucSource source)
 
bool check_backtrace_functions (char **newval, void **extra, GucSource source)
 
void assign_backtrace_functions (const char *newval, void *extra)
 
bool check_bonjour (bool *newval, void **extra, GucSource source)
 
bool check_canonical_path (char **newval, void **extra, GucSource source)
 
void assign_checkpoint_completion_target (double newval, void *extra)
 
bool check_client_connection_check_interval (int *newval, void **extra, GucSource source)
 
bool check_client_encoding (char **newval, void **extra, GucSource source)
 
void assign_client_encoding (const char *newval, void *extra)
 
bool check_cluster_name (char **newval, void **extra, GucSource source)
 
const char * show_data_directory_mode (void)
 
bool check_datestyle (char **newval, void **extra, GucSource source)
 
void assign_datestyle (const char *newval, void *extra)
 
bool check_debug_io_direct (char **newval, void **extra, GucSource source)
 
void assign_debug_io_direct (const char *newval, void *extra)
 
bool check_default_table_access_method (char **newval, void **extra, GucSource source)
 
bool check_default_tablespace (char **newval, void **extra, GucSource source)
 
bool check_default_text_search_config (char **newval, void **extra, GucSource source)
 
void assign_default_text_search_config (const char *newval, void *extra)
 
bool check_default_with_oids (bool *newval, void **extra, GucSource source)
 
bool check_effective_io_concurrency (int *newval, void **extra, GucSource source)
 
bool check_huge_page_size (int *newval, void **extra, GucSource source)
 
const char * show_in_hot_standby (void)
 
bool check_locale_messages (char **newval, void **extra, GucSource source)
 
void assign_locale_messages (const char *newval, void *extra)
 
bool check_locale_monetary (char **newval, void **extra, GucSource source)
 
void assign_locale_monetary (const char *newval, void *extra)
 
bool check_locale_numeric (char **newval, void **extra, GucSource source)
 
void assign_locale_numeric (const char *newval, void *extra)
 
bool check_locale_time (char **newval, void **extra, GucSource source)
 
void assign_locale_time (const char *newval, void *extra)
 
bool check_log_destination (char **newval, void **extra, GucSource source)
 
void assign_log_destination (const char *newval, void *extra)
 
const char * show_log_file_mode (void)
 
bool check_log_stats (bool *newval, void **extra, GucSource source)
 
bool check_log_timezone (char **newval, void **extra, GucSource source)
 
void assign_log_timezone (const char *newval, void *extra)
 
const char * show_log_timezone (void)
 
bool check_maintenance_io_concurrency (int *newval, void **extra, GucSource source)
 
void assign_maintenance_io_concurrency (int newval, void *extra)
 
bool check_max_connections (int *newval, void **extra, GucSource source)
 
bool check_max_wal_senders (int *newval, void **extra, GucSource source)
 
void assign_max_wal_size (int newval, void *extra)
 
bool check_max_worker_processes (int *newval, void **extra, GucSource source)
 
bool check_max_stack_depth (int *newval, void **extra, GucSource source)
 
void assign_max_stack_depth (int newval, void *extra)
 
bool check_primary_slot_name (char **newval, void **extra, GucSource source)
 
bool check_random_seed (double *newval, void **extra, GucSource source)
 
void assign_random_seed (double newval, void *extra)
 
const char * show_random_seed (void)
 
bool check_recovery_prefetch (int *new_value, void **extra, GucSource source)
 
void assign_recovery_prefetch (int new_value, void *extra)
 
bool check_recovery_target (char **newval, void **extra, GucSource source)
 
void assign_recovery_target (const char *newval, void *extra)
 
bool check_recovery_target_lsn (char **newval, void **extra, GucSource source)
 
void assign_recovery_target_lsn (const char *newval, void *extra)
 
bool check_recovery_target_name (char **newval, void **extra, GucSource source)
 
void assign_recovery_target_name (const char *newval, void *extra)
 
bool check_recovery_target_time (char **newval, void **extra, GucSource source)
 
void assign_recovery_target_time (const char *newval, void *extra)
 
bool check_recovery_target_timeline (char **newval, void **extra, GucSource source)
 
void assign_recovery_target_timeline (const char *newval, void *extra)
 
bool check_recovery_target_xid (char **newval, void **extra, GucSource source)
 
void assign_recovery_target_xid (const char *newval, void *extra)
 
bool check_role (char **newval, void **extra, GucSource source)
 
void assign_role (const char *newval, void *extra)
 
const char * show_role (void)
 
bool check_search_path (char **newval, void **extra, GucSource source)
 
void assign_search_path (const char *newval, void *extra)
 
bool check_session_authorization (char **newval, void **extra, GucSource source)
 
void assign_session_authorization (const char *newval, void *extra)
 
void assign_session_replication_role (int newval, void *extra)
 
void assign_stats_fetch_consistency (int newval, void *extra)
 
bool check_ssl (bool *newval, void **extra, GucSource source)
 
bool check_stage_log_stats (bool *newval, void **extra, GucSource source)
 
bool check_synchronous_standby_names (char **newval, void **extra, GucSource source)
 
void assign_synchronous_standby_names (const char *newval, void *extra)
 
void assign_synchronous_commit (int newval, void *extra)
 
void assign_syslog_facility (int newval, void *extra)
 
void assign_syslog_ident (const char *newval, void *extra)
 
void assign_tcp_keepalives_count (int newval, void *extra)
 
const char * show_tcp_keepalives_count (void)
 
void assign_tcp_keepalives_idle (int newval, void *extra)
 
const char * show_tcp_keepalives_idle (void)
 
void assign_tcp_keepalives_interval (int newval, void *extra)
 
const char * show_tcp_keepalives_interval (void)
 
void assign_tcp_user_timeout (int newval, void *extra)
 
const char * show_tcp_user_timeout (void)
 
bool check_temp_buffers (int *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_timezone (char **newval, void **extra, GucSource source)
 
void assign_timezone (const char *newval, void *extra)
 
const char * show_timezone (void)
 
bool check_timezone_abbreviations (char **newval, void **extra, GucSource source)
 
void assign_timezone_abbreviations (const char *newval, void *extra)
 
bool check_transaction_deferrable (bool *newval, void **extra, GucSource source)
 
bool check_transaction_isolation (int *newval, void **extra, GucSource source)
 
bool check_transaction_read_only (bool *newval, void **extra, GucSource source)
 
const char * show_unix_socket_permissions (void)
 
bool check_wal_buffers (int *newval, void **extra, GucSource source)
 
bool check_wal_consistency_checking (char **newval, void **extra, GucSource source)
 
void assign_wal_consistency_checking (const char *newval, void *extra)
 
bool check_wal_segment_size (int *newval, void **extra, GucSource source)
 
void assign_xlog_sync_method (int new_sync_method, void *extra)
 

Function Documentation

◆ assign_application_name()

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

Definition at line 1075 of file variable.c.

1076 {
1077  /* Update the pg_stat_activity view */
1079 }
void pgstat_report_appname(const char *appname)
#define newval

References newval, and pgstat_report_appname().

◆ assign_backtrace_functions()

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

Definition at line 2181 of file elog.c.

2182 {
2183  backtrace_symbol_list = (char *) extra;
2184 }
static char * backtrace_symbol_list
Definition: elog.c:119

References backtrace_symbol_list.

◆ assign_checkpoint_completion_target()

void assign_checkpoint_completion_target ( double  newval,
void *  extra 
)

Definition at line 1992 of file xlog.c.

1993 {
1996 }
double CheckPointCompletionTarget
Definition: checkpointer.c:146
static void CalculateCheckpointSegments(void)
Definition: xlog.c:1956

References CalculateCheckpointSegments(), CheckPointCompletionTarget, and newval.

◆ assign_client_encoding()

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

Definition at line 756 of file variable.c.

757 {
758  int encoding = *((int *) extra);
759 
760  /*
761  * Parallel workers send data to the leader, not the client. They always
762  * send data using the database encoding.
763  */
764  if (IsParallelWorker())
765  {
766  /*
767  * During parallel worker startup, we want to accept the leader's
768  * client_encoding setting so that anyone who looks at the value in
769  * the worker sees the same value that they would see in the leader.
770  */
772  return;
773 
774  /*
775  * A change other than during startup, for example due to a SET clause
776  * attached to a function definition, should be rejected, as there is
777  * nothing we can do inside the worker to make it take effect.
778  */
779  ereport(ERROR,
780  (errcode(ERRCODE_INVALID_TRANSACTION_STATE),
781  errmsg("cannot change client_encoding during a parallel operation")));
782  }
783 
784  /* We do not expect an error if PrepareClientEncoding succeeded */
785  if (SetClientEncoding(encoding) < 0)
786  elog(LOG, "SetClientEncoding(%d) failed", encoding);
787 }
bool InitializingParallelWorker
Definition: parallel.c:120
int errcode(int sqlerrcode)
Definition: elog.c:858
int errmsg(const char *fmt,...)
Definition: elog.c:1069
#define LOG
Definition: elog.h:31
#define ERROR
Definition: elog.h:39
#define ereport(elevel,...)
Definition: elog.h:149
#define IsParallelWorker()
Definition: parallel.h:61
int SetClientEncoding(int encoding)
Definition: mbutils.c:209
int32 encoding
Definition: pg_database.h:41

References elog(), encoding, ereport, errcode(), errmsg(), ERROR, InitializingParallelWorker, IsParallelWorker, LOG, and SetClientEncoding().

◆ assign_datestyle()

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

Definition at line 244 of file variable.c.

245 {
246  int *myextra = (int *) extra;
247 
248  DateStyle = myextra[0];
249  DateOrder = myextra[1];
250 }
int DateStyle
Definition: globals.c:119
int DateOrder
Definition: globals.c:120

References DateOrder, and DateStyle.

◆ assign_debug_io_direct()

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

Definition at line 3969 of file fd.c.

3970 {
3971  int *flags = (int *) extra;
3972 
3973  io_direct_flags = *flags;
3974 }
int io_direct_flags
Definition: fd.c:168

References io_direct_flags.

◆ assign_default_text_search_config()

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

Definition at line 670 of file ts_cache.c.

671 {
672  /* Just reset the cache to force a lookup on first use */
674 }
#define InvalidOid
Definition: postgres_ext.h:36
static Oid TSCurrentConfigCache
Definition: ts_cache.c:78

References InvalidOid, and TSCurrentConfigCache.

◆ assign_locale_messages()

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

Definition at line 428 of file pg_locale.c.

429 {
430  /*
431  * LC_MESSAGES category does not exist everywhere, but accept it anyway.
432  * We ignore failure, as per comment above.
433  */
434 #ifdef LC_MESSAGES
435  (void) pg_perm_setlocale(LC_MESSAGES, newval);
436 #endif
437 }
char * pg_perm_setlocale(int category, const char *locale)
Definition: pg_locale.c:213

References newval, and pg_perm_setlocale().

◆ assign_locale_monetary()

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

Definition at line 365 of file pg_locale.c.

366 {
367  CurrentLocaleConvValid = false;
368 }
static bool CurrentLocaleConvValid
Definition: pg_locale.c:121

References CurrentLocaleConvValid.

◆ assign_locale_numeric()

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

Definition at line 377 of file pg_locale.c.

378 {
379  CurrentLocaleConvValid = false;
380 }

References CurrentLocaleConvValid.

◆ assign_locale_time()

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

Definition at line 389 of file pg_locale.c.

390 {
391  CurrentLCTimeValid = false;
392 }
static bool CurrentLCTimeValid
Definition: pg_locale.c:122

References CurrentLCTimeValid.

◆ assign_log_destination()

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

Definition at line 2252 of file elog.c.

2253 {
2254  Log_destination = *((int *) extra);
2255 }
int Log_destination
Definition: elog.c:113

References Log_destination.

◆ assign_log_timezone()

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

Definition at line 454 of file variable.c.

455 {
456  log_timezone = *((pg_tz **) extra);
457 }
PGDLLIMPORT pg_tz * log_timezone
Definition: pgtz.c:31
Definition: pgtz.h:66

References log_timezone.

◆ assign_maintenance_io_concurrency()

void assign_maintenance_io_concurrency ( int  newval,
void *  extra 
)

Definition at line 1111 of file variable.c.

1112 {
1113 #ifdef USE_PREFETCH
1114  /*
1115  * Reconfigure recovery prefetching, because a setting it depends on
1116  * changed.
1117  */
1119  if (AmStartupProcess())
1121 #endif
1122 }
int maintenance_io_concurrency
Definition: bufmgr.c:153
#define AmStartupProcess()
Definition: miscadmin.h:452
void XLogPrefetchReconfigure(void)

References AmStartupProcess, maintenance_io_concurrency, newval, and XLogPrefetchReconfigure().

◆ assign_max_stack_depth()

void assign_max_stack_depth ( int  newval,
void *  extra 
)

Definition at line 3587 of file postgres.c.

3588 {
3589  long newval_bytes = newval * 1024L;
3590 
3591  max_stack_depth_bytes = newval_bytes;
3592 }
static long max_stack_depth_bytes
Definition: postgres.c:123

References max_stack_depth_bytes, and newval.

◆ assign_max_wal_size()

void assign_max_wal_size ( int  newval,
void *  extra 
)

Definition at line 1985 of file xlog.c.

1986 {
1989 }
int max_wal_size_mb
Definition: xlog.c:117

References CalculateCheckpointSegments(), max_wal_size_mb, and newval.

◆ assign_random_seed()

void assign_random_seed ( double  newval,
void *  extra 
)

Definition at line 660 of file variable.c.

661 {
662  /* We'll do this at most once for any setting of the GUC variable */
663  if (*((int *) extra))
665  *((int *) extra) = 0;
666 }
Datum setseed(PG_FUNCTION_ARGS)
Definition: float.c:2860
Datum Float8GetDatum(float8 X)
Definition: fmgr.c:1799
#define DirectFunctionCall1(func, arg1)
Definition: fmgr.h:642

References DirectFunctionCall1, Float8GetDatum(), newval, and setseed().

◆ assign_recovery_prefetch()

void assign_recovery_prefetch ( int  new_value,
void *  extra 
)

Definition at line 1101 of file xlogprefetcher.c.

1102 {
1103  /* Reconfigure prefetching, because a setting it depends on changed. */
1104  recovery_prefetch = new_value;
1105  if (AmStartupProcess())
1107 }
int recovery_prefetch

References AmStartupProcess, recovery_prefetch, and XLogPrefetchReconfigure().

◆ assign_recovery_target()

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

Definition at line 4711 of file xlogrecovery.c.

4712 {
4715  error_multiple_recovery_targets();
4716 
4717  if (newval && strcmp(newval, "") != 0)
4719  else
4721 }
RecoveryTargetType recoveryTarget
Definition: xlogrecovery.c:85
@ RECOVERY_TARGET_IMMEDIATE
Definition: xlogrecovery.h:30
@ RECOVERY_TARGET_UNSET
Definition: xlogrecovery.h:25

References newval, RECOVERY_TARGET_IMMEDIATE, RECOVERY_TARGET_UNSET, and recoveryTarget.

◆ assign_recovery_target_lsn()

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

Definition at line 4750 of file xlogrecovery.c.

4751 {
4754  error_multiple_recovery_targets();
4755 
4756  if (newval && strcmp(newval, "") != 0)
4757  {
4759  recoveryTargetLSN = *((XLogRecPtr *) extra);
4760  }
4761  else
4763 }
uint64 XLogRecPtr
Definition: xlogdefs.h:21
XLogRecPtr recoveryTargetLSN
Definition: xlogrecovery.c:92
@ RECOVERY_TARGET_LSN
Definition: xlogrecovery.h:29

References newval, RECOVERY_TARGET_LSN, RECOVERY_TARGET_UNSET, recoveryTarget, and recoveryTargetLSN.

◆ assign_recovery_target_name()

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

Definition at line 4785 of file xlogrecovery.c.

4786 {
4789  error_multiple_recovery_targets();
4790 
4791  if (newval && strcmp(newval, "") != 0)
4792  {
4795  }
4796  else
4798 }
const char * recoveryTargetName
Definition: xlogrecovery.c:91
@ RECOVERY_TARGET_NAME
Definition: xlogrecovery.h:28

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

◆ assign_recovery_target_time()

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

Definition at line 4865 of file xlogrecovery.c.

4866 {
4869  error_multiple_recovery_targets();
4870 
4871  if (newval && strcmp(newval, "") != 0)
4873  else
4875 }
@ RECOVERY_TARGET_TIME
Definition: xlogrecovery.h:27

References newval, RECOVERY_TARGET_TIME, RECOVERY_TARGET_UNSET, and recoveryTarget.

◆ assign_recovery_target_timeline()

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

Definition at line 4914 of file xlogrecovery.c.

4915 {
4918  recoveryTargetTLIRequested = (TimeLineID) strtoul(newval, NULL, 0);
4919  else
4921 }
uint32 TimeLineID
Definition: xlogdefs.h:59
RecoveryTargetTimeLineGoal recoveryTargetTimeLineGoal
Definition: xlogrecovery.c:120
TimeLineID recoveryTargetTLIRequested
Definition: xlogrecovery.c:121
RecoveryTargetTimeLineGoal
Definition: xlogrecovery.h:37
@ RECOVERY_TARGET_TIMELINE_NUMERIC
Definition: xlogrecovery.h:40

References newval, RECOVERY_TARGET_TIMELINE_NUMERIC, recoveryTargetTimeLineGoal, and recoveryTargetTLIRequested.

◆ assign_recovery_target_xid()

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

Definition at line 4950 of file xlogrecovery.c.

4951 {
4954  error_multiple_recovery_targets();
4955 
4956  if (newval && strcmp(newval, "") != 0)
4957  {
4959  recoveryTargetXid = *((TransactionId *) extra);
4960  }
4961  else
4963 }
uint32 TransactionId
Definition: c.h:641
TransactionId recoveryTargetXid
Definition: xlogrecovery.c:88
@ RECOVERY_TARGET_XID
Definition: xlogrecovery.h:26

References newval, RECOVERY_TARGET_UNSET, RECOVERY_TARGET_XID, recoveryTarget, and recoveryTargetXid.

◆ assign_role()

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

Definition at line 995 of file variable.c.

996 {
997  role_auth_extra *myextra = (role_auth_extra *) extra;
998 
999  SetCurrentRoleId(myextra->roleid, myextra->is_superuser);
1000 }
void SetCurrentRoleId(Oid roleid, bool is_superuser)
Definition: miscinit.c:931
bool is_superuser
Definition: variable.c:798

References role_auth_extra::is_superuser, role_auth_extra::roleid, and SetCurrentRoleId().

◆ assign_search_path()

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

Definition at line 4136 of file namespace.c.

4137 {
4138  /*
4139  * We mark the path as needing recomputation, but don't do anything until
4140  * it's needed. This avoids trying to do database access during GUC
4141  * initialization, or outside a transaction.
4142  */
4143  baseSearchPathValid = false;
4144 }
static bool baseSearchPathValid
Definition: namespace.c:155

References baseSearchPathValid.

◆ assign_session_authorization()

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

Definition at line 885 of file variable.c.

886 {
887  role_auth_extra *myextra = (role_auth_extra *) extra;
888 
889  /* Do nothing for the boot_val default of NULL */
890  if (!myextra)
891  return;
892 
893  SetSessionAuthorization(myextra->roleid, myextra->is_superuser);
894 }
void SetSessionAuthorization(Oid userid, bool is_superuser)
Definition: miscinit.c:894

References role_auth_extra::is_superuser, role_auth_extra::roleid, and SetSessionAuthorization().

◆ assign_session_replication_role()

void assign_session_replication_role ( int  newval,
void *  extra 
)

Definition at line 6567 of file trigger.c.

6568 {
6569  /*
6570  * Must flush the plan cache when changing replication role; but don't
6571  * flush unnecessarily.
6572  */
6574  ResetPlanCache();
6575 }
void ResetPlanCache(void)
Definition: plancache.c:2164
int SessionReplicationRole
Definition: trigger.c:70

References newval, ResetPlanCache(), and SessionReplicationRole.

◆ assign_stats_fetch_consistency()

void assign_stats_fetch_consistency ( int  newval,
void *  extra 
)

Definition at line 1707 of file pgstat.c.

1708 {
1709  /*
1710  * Changing this value in a transaction may cause snapshot state
1711  * inconsistencies, so force a clear of the current snapshot on the next
1712  * snapshot build attempt.
1713  */
1716 }
int pgstat_fetch_consistency
Definition: pgstat.c:188
static bool force_stats_snapshot_clear
Definition: pgstat.c:234

References force_stats_snapshot_clear, newval, and pgstat_fetch_consistency.

◆ assign_synchronous_commit()

void assign_synchronous_commit ( int  newval,
void *  extra 
)

Definition at line 1060 of file syncrep.c.

1061 {
1062  switch (newval)
1063  {
1066  break;
1069  break;
1072  break;
1073  default:
1075  break;
1076  }
1077 }
static int SyncRepWaitMode
Definition: syncrep.c:99
#define SYNC_REP_NO_WAIT
Definition: syncrep.h:22
#define SYNC_REP_WAIT_WRITE
Definition: syncrep.h:23
#define SYNC_REP_WAIT_FLUSH
Definition: syncrep.h:24
#define SYNC_REP_WAIT_APPLY
Definition: syncrep.h:25
@ SYNCHRONOUS_COMMIT_REMOTE_WRITE
Definition: xact.h:72
@ SYNCHRONOUS_COMMIT_REMOTE_APPLY
Definition: xact.h:75
@ SYNCHRONOUS_COMMIT_REMOTE_FLUSH
Definition: xact.h:74

References newval, SYNC_REP_NO_WAIT, SYNC_REP_WAIT_APPLY, SYNC_REP_WAIT_FLUSH, SYNC_REP_WAIT_WRITE, SYNCHRONOUS_COMMIT_REMOTE_APPLY, SYNCHRONOUS_COMMIT_REMOTE_FLUSH, SYNCHRONOUS_COMMIT_REMOTE_WRITE, and SyncRepWaitMode.

◆ assign_synchronous_standby_names()

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

Definition at line 1054 of file syncrep.c.

1055 {
1056  SyncRepConfig = (SyncRepConfigData *) extra;
1057 }
SyncRepConfigData * SyncRepConfig
Definition: syncrep.c:98

References SyncRepConfig.

◆ assign_syslog_facility()

void assign_syslog_facility ( int  newval,
void *  extra 
)

Definition at line 2293 of file elog.c.

2294 {
2295 #ifdef HAVE_SYSLOG
2296  /*
2297  * As above, don't thrash the syslog connection unnecessarily.
2298  */
2299  if (syslog_facility != newval)
2300  {
2301  if (openlog_done)
2302  {
2303  closelog();
2304  openlog_done = false;
2305  }
2307  }
2308 #endif
2309  /* Without syslog support, just ignore it */
2310 }
static int syslog_facility
Definition: guc_tables.c:583

References newval, and syslog_facility.

◆ assign_syslog_ident()

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

Definition at line 2261 of file elog.c.

2262 {
2263 #ifdef HAVE_SYSLOG
2264  /*
2265  * guc.c is likely to call us repeatedly with same parameters, so don't
2266  * thrash the syslog connection unnecessarily. Also, we do not re-open
2267  * the connection until needed, since this routine will get called whether
2268  * or not Log_destination actually mentions syslog.
2269  *
2270  * Note that we make our own copy of the ident string rather than relying
2271  * on guc.c's. This may be overly paranoid, but it ensures that we cannot
2272  * accidentally free a string that syslog is still using.
2273  */
2274  if (syslog_ident == NULL || strcmp(syslog_ident, newval) != 0)
2275  {
2276  if (openlog_done)
2277  {
2278  closelog();
2279  openlog_done = false;
2280  }
2281  free(syslog_ident);
2282  syslog_ident = strdup(newval);
2283  /* if the strdup fails, we will cope in write_syslog() */
2284  }
2285 #endif
2286  /* Without syslog support, just ignore it */
2287 }
#define free(a)
Definition: header.h:65

References free, and newval.

◆ assign_tcp_keepalives_count()

void assign_tcp_keepalives_count ( int  newval,
void *  extra 
)

Definition at line 1987 of file pqcomm.c.

1988 {
1989  /* See comments in assign_tcp_keepalives_idle */
1991 }
struct Port * MyProcPort
Definition: globals.c:47
int pq_setkeepalivescount(int count, Port *port)
Definition: pqcomm.c:1808

References MyProcPort, newval, and pq_setkeepalivescount().

◆ assign_tcp_keepalives_idle()

void assign_tcp_keepalives_idle ( int  newval,
void *  extra 
)

Definition at line 1931 of file pqcomm.c.

1932 {
1933  /*
1934  * The kernel API provides no way to test a value without setting it; and
1935  * once we set it we might fail to unset it. So there seems little point
1936  * in fully implementing the check-then-assign GUC API for these
1937  * variables. Instead we just do the assignment on demand.
1938  * pq_setkeepalivesidle reports any problems via ereport(LOG).
1939  *
1940  * This approach means that the GUC value might have little to do with the
1941  * actual kernel value, so we use a show_hook that retrieves the kernel
1942  * value rather than trusting GUC's copy.
1943  */
1945 }
int pq_setkeepalivesidle(int idle, Port *port)
Definition: pqcomm.c:1644

References MyProcPort, newval, and pq_setkeepalivesidle().

◆ assign_tcp_keepalives_interval()

void assign_tcp_keepalives_interval ( int  newval,
void *  extra 
)

Definition at line 1964 of file pqcomm.c.

1965 {
1966  /* See comments in assign_tcp_keepalives_idle */
1968 }
int pq_setkeepalivesinterval(int interval, Port *port)
Definition: pqcomm.c:1729

References MyProcPort, newval, and pq_setkeepalivesinterval().

◆ assign_tcp_user_timeout()

void assign_tcp_user_timeout ( int  newval,
void *  extra 
)

Definition at line 2010 of file pqcomm.c.

2011 {
2012  /* See comments in assign_tcp_keepalives_idle */
2014 }
int pq_settcpusertimeout(int timeout, Port *port)
Definition: pqcomm.c:1883

References MyProcPort, newval, and pq_settcpusertimeout().

◆ assign_temp_tablespaces()

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

Definition at line 1312 of file tablespace.c.

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

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

◆ assign_timezone()

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

Definition at line 381 of file variable.c.

382 {
383  session_timezone = *((pg_tz **) extra);
384 }
PGDLLIMPORT pg_tz * session_timezone
Definition: pgtz.c:28

References session_timezone.

◆ assign_timezone_abbreviations()

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

Definition at line 517 of file variable.c.

518 {
519  /* Do nothing for the boot_val default of NULL */
520  if (!extra)
521  return;
522 
524 }
void InstallTimeZoneAbbrevs(TimeZoneAbbrevTable *tbl)
Definition: datetime.c:4846

References InstallTimeZoneAbbrevs().

◆ assign_wal_consistency_checking()

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

Definition at line 4399 of file xlog.c.

4400 {
4401  /*
4402  * If some checks were deferred, it's possible that the checks will fail
4403  * later during InitializeWalConsistencyChecking(). But in that case, the
4404  * postmaster will exit anyway, so it's safe to proceed with the
4405  * assignment.
4406  *
4407  * Any built-in resource managers specified are assigned immediately,
4408  * which affects WAL created before shared_preload_libraries are
4409  * processed. Any custom resource managers specified won't be assigned
4410  * until after shared_preload_libraries are processed, but that's OK
4411  * because WAL for a custom resource manager can't be written before the
4412  * module is loaded anyway.
4413  */
4414  wal_consistency_checking = extra;
4415 }
bool * wal_consistency_checking
Definition: xlog.c:129

References wal_consistency_checking.

◆ assign_xlog_sync_method()

void assign_xlog_sync_method ( int  new_sync_method,
void *  extra 
)

Definition at line 8144 of file xlog.c.

8145 {
8146  if (sync_method != new_sync_method)
8147  {
8148  /*
8149  * To ensure that no blocks escape unsynced, force an fsync on the
8150  * currently open log segment (if any). Also, if the open flag is
8151  * changing, close the log file so it will be reopened (with new flag
8152  * bit) at next use.
8153  */
8154  if (openLogFile >= 0)
8155  {
8156  pgstat_report_wait_start(WAIT_EVENT_WAL_SYNC_METHOD_ASSIGN);
8157  if (pg_fsync(openLogFile) != 0)
8158  {
8159  char xlogfname[MAXFNAMELEN];
8160  int save_errno;
8161 
8162  save_errno = errno;
8163  XLogFileName(xlogfname, openLogTLI, openLogSegNo,
8165  errno = save_errno;
8166  ereport(PANIC,
8168  errmsg("could not fsync file \"%s\": %m", xlogfname)));
8169  }
8170 
8172  if (get_sync_bit(sync_method) != get_sync_bit(new_sync_method))
8173  XLogFileClose();
8174  }
8175  }
8176 }
int errcode_for_file_access(void)
Definition: elog.c:881
#define PANIC
Definition: elog.h:42
int pg_fsync(int fd)
Definition: fd.c:361
static void pgstat_report_wait_start(uint32 wait_event_info)
Definition: wait_event.h:88
static void pgstat_report_wait_end(void)
Definition: wait_event.h:104
static int openLogFile
Definition: xlog.c:618
int wal_segment_size
Definition: xlog.c:146
static int get_sync_bit(int method)
Definition: xlog.c:8096
static TimeLineID openLogTLI
Definition: xlog.c:620
static void XLogFileClose(void)
Definition: xlog.c:3372
static XLogSegNo openLogSegNo
Definition: xlog.c:619
int sync_method
Definition: xlog.c:133
#define MAXFNAMELEN
static void XLogFileName(char *fname, TimeLineID tli, XLogSegNo logSegNo, int wal_segsz_bytes)

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, wal_segment_size, XLogFileClose(), and XLogFileName().

◆ check_application_name()

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

Definition at line 1049 of file variable.c.

1050 {
1051  char *clean;
1052  char *ret;
1053 
1054  /* Only allow clean ASCII chars in the application name */
1056  if (!clean)
1057  return false;
1058 
1059  ret = guc_strdup(WARNING, clean);
1060  if (!ret)
1061  {
1062  pfree(clean);
1063  return false;
1064  }
1065 
1066  pfree(clean);
1067  *newval = ret;
1068  return true;
1069 }
#define WARNING
Definition: elog.h:36
#define MCXT_ALLOC_NO_OOM
Definition: fe_memutils.h:17
char * guc_strdup(int elevel, const char *src)
Definition: guc.c:670
void pfree(void *pointer)
Definition: mcxt.c:1456
char * pg_clean_ascii(const char *str, int alloc_flags)
Definition: string.c:86

References guc_strdup(), MCXT_ALLOC_NO_OOM, newval, pfree(), pg_clean_ascii(), and WARNING.

◆ check_autovacuum_max_workers()

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

Definition at line 588 of file postinit.c.

589 {
590  if (MaxConnections + *newval + 1 +
592  return false;
593  return true;
594 }
int MaxConnections
Definition: globals.c:137
int max_worker_processes
Definition: globals.c:138
#define MAX_BACKENDS
Definition: postmaster.h:78
int max_wal_senders
Definition: walsender.c:122

References MAX_BACKENDS, max_wal_senders, max_worker_processes, MaxConnections, and newval.

◆ check_autovacuum_work_mem()

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

Definition at line 3472 of file autovacuum.c.

3473 {
3474  /*
3475  * -1 indicates fallback.
3476  *
3477  * If we haven't yet changed the boot_val default of -1, just let it be.
3478  * Autovacuum will look to maintenance_work_mem instead.
3479  */
3480  if (*newval == -1)
3481  return true;
3482 
3483  /*
3484  * We clamp manually-set values to at least 1MB. Since
3485  * maintenance_work_mem is always set to at least this value, do the same
3486  * here.
3487  */
3488  if (*newval < 1024)
3489  *newval = 1024;
3490 
3491  return true;
3492 }

References newval.

◆ check_backtrace_functions()

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

Definition at line 2122 of file elog.c.

2123 {
2124  int newvallen = strlen(*newval);
2125  char *someval;
2126  int validlen;
2127  int i;
2128  int j;
2129 
2130  /*
2131  * Allow characters that can be C identifiers and commas as separators, as
2132  * well as some whitespace for readability.
2133  */
2134  validlen = strspn(*newval,
2135  "0123456789_"
2136  "abcdefghijklmnopqrstuvwxyz"
2137  "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
2138  ", \n\t");
2139  if (validlen != newvallen)
2140  {
2141  GUC_check_errdetail("invalid character");
2142  return false;
2143  }
2144 
2145  if (*newval[0] == '\0')
2146  {
2147  *extra = NULL;
2148  return true;
2149  }
2150 
2151  /*
2152  * Allocate space for the output and create the copy. We could discount
2153  * whitespace chars to save some memory, but it doesn't seem worth the
2154  * trouble.
2155  */
2156  someval = guc_malloc(ERROR, newvallen + 1 + 1);
2157  for (i = 0, j = 0; i < newvallen; i++)
2158  {
2159  if ((*newval)[i] == ',')
2160  someval[j++] = '\0'; /* next item */
2161  else if ((*newval)[i] == ' ' ||
2162  (*newval)[i] == '\n' ||
2163  (*newval)[i] == '\t')
2164  ; /* ignore these */
2165  else
2166  someval[j++] = (*newval)[i]; /* copy anything else */
2167  }
2168 
2169  /* two \0s end the setting */
2170  someval[j] = '\0';
2171  someval[j + 1] = '\0';
2172 
2173  *extra = someval;
2174  return true;
2175 }
void * guc_malloc(int elevel, size_t size)
Definition: guc.c:631
#define GUC_check_errdetail
Definition: guc.h:436
int j
Definition: isn.c:74
int i
Definition: isn.c:73

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

◆ check_bonjour()

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

Definition at line 1172 of file variable.c.

1173 {
1174 #ifndef USE_BONJOUR
1175  if (*newval)
1176  {
1177  GUC_check_errmsg("Bonjour is not supported by this build");
1178  return false;
1179  }
1180 #endif
1181  return true;
1182 }
#define GUC_check_errmsg
Definition: guc.h:432

References GUC_check_errmsg, and newval.

◆ check_canonical_path()

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

Definition at line 1028 of file variable.c.

1029 {
1030  /*
1031  * Since canonicalize_path never enlarges the string, we can just modify
1032  * newval in-place. But watch out for NULL, which is the default value
1033  * for external_pid_file.
1034  */
1035  if (*newval)
1037  return true;
1038 }
void canonicalize_path(char *path)
Definition: path.c:264

References canonicalize_path(), and newval.

◆ check_client_connection_check_interval()

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

Definition at line 3598 of file postgres.c.

3599 {
3600  if (!WaitEventSetCanReportClosed() && *newval != 0)
3601  {
3602  GUC_check_errdetail("client_connection_check_interval must be set to 0 on this platform.");
3603  return false;
3604  }
3605  return true;
3606 }
bool WaitEventSetCanReportClosed(void)
Definition: latch.c:2172

References GUC_check_errdetail, newval, and WaitEventSetCanReportClosed().

◆ check_client_encoding()

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

Definition at line 680 of file variable.c.

681 {
682  int encoding;
683  const char *canonical_name;
684 
685  /* Look up the encoding by name */
687  if (encoding < 0)
688  return false;
689 
690  /* Get the canonical name (no aliases, uniform case) */
691  canonical_name = pg_encoding_to_char(encoding);
692 
693  /*
694  * If we are not within a transaction then PrepareClientEncoding will not
695  * be able to look up the necessary conversion procs. If we are still
696  * starting up, it will return "OK" anyway, and InitializeClientEncoding
697  * will fix things once initialization is far enough along. After
698  * startup, we'll fail. This would only happen if someone tries to change
699  * client_encoding in postgresql.conf and then SIGHUP existing sessions.
700  * It seems like a bad idea for client_encoding to change that way anyhow,
701  * so we don't go out of our way to support it.
702  *
703  * Note: in the postmaster, or any other process that never calls
704  * InitializeClientEncoding, PrepareClientEncoding will always succeed,
705  * and so will SetClientEncoding; but they won't do anything, which is OK.
706  */
708  {
709  if (IsTransactionState())
710  {
711  /* Must be a genuine no-such-conversion problem */
712  GUC_check_errcode(ERRCODE_FEATURE_NOT_SUPPORTED);
713  GUC_check_errdetail("Conversion between %s and %s is not supported.",
714  canonical_name,
716  }
717  else
718  {
719  /* Provide a useful complaint */
720  GUC_check_errdetail("Cannot change \"client_encoding\" now.");
721  }
722  return false;
723  }
724 
725  /*
726  * Replace the user-supplied string with the encoding's canonical name.
727  * This gets rid of aliases and case-folding variations.
728  *
729  * XXX Although canonicalizing seems like a good idea in the abstract, it
730  * breaks pre-9.1 JDBC drivers, which expect that if they send "UNICODE"
731  * as the client_encoding setting then it will read back the same way. As
732  * a workaround, don't replace the string if it's "UNICODE". Remove that
733  * hack when pre-9.1 JDBC drivers are no longer in use.
734  */
735  if (strcmp(*newval, canonical_name) != 0 &&
736  strcmp(*newval, "UNICODE") != 0)
737  {
738  guc_free(*newval);
739  *newval = guc_strdup(LOG, canonical_name);
740  if (!*newval)
741  return false;
742  }
743 
744  /*
745  * Save the encoding's ID in *extra, for use by assign_client_encoding.
746  */
747  *extra = guc_malloc(LOG, sizeof(int));
748  if (!*extra)
749  return false;
750  *((int *) *extra) = encoding;
751 
752  return true;
753 }
int pg_valid_client_encoding(const char *name)
Definition: encnames.c:486
const char * pg_encoding_to_char(int encoding)
Definition: encnames.c:588
void GUC_check_errcode(int sqlerrcode)
Definition: guc.c:6609
void guc_free(void *ptr)
Definition: guc.c:682
int PrepareClientEncoding(int encoding)
Definition: mbutils.c:111
const char * GetDatabaseEncodingName(void)
Definition: mbutils.c:1274
bool IsTransactionState(void)
Definition: xact.c:378

References encoding, GetDatabaseEncodingName(), GUC_check_errcode(), GUC_check_errdetail, guc_free(), guc_malloc(), guc_strdup(), IsTransactionState(), LOG, newval, pg_encoding_to_char(), pg_valid_client_encoding(), and PrepareClientEncoding().

◆ check_cluster_name()

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

Definition at line 1085 of file variable.c.

1086 {
1087  char *clean;
1088  char *ret;
1089 
1090  /* Only allow clean ASCII chars in the cluster name */
1092  if (!clean)
1093  return false;
1094 
1095  ret = guc_strdup(WARNING, clean);
1096  if (!ret)
1097  {
1098  pfree(clean);
1099  return false;
1100  }
1101 
1102  pfree(clean);
1103  *newval = ret;
1104  return true;
1105 }

References guc_strdup(), MCXT_ALLOC_NO_OOM, newval, pfree(), pg_clean_ascii(), and WARNING.

◆ check_datestyle()

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

Definition at line 52 of file variable.c.

53 {
54  int newDateStyle = DateStyle;
55  int newDateOrder = DateOrder;
56  bool have_style = false;
57  bool have_order = false;
58  bool ok = true;
59  char *rawstring;
60  int *myextra;
61  char *result;
62  List *elemlist;
63  ListCell *l;
64 
65  /* Need a modifiable copy of string */
66  rawstring = pstrdup(*newval);
67 
68  /* Parse string into list of identifiers */
69  if (!SplitIdentifierString(rawstring, ',', &elemlist))
70  {
71  /* syntax error in list */
72  GUC_check_errdetail("List syntax is invalid.");
73  pfree(rawstring);
74  list_free(elemlist);
75  return false;
76  }
77 
78  foreach(l, elemlist)
79  {
80  char *tok = (char *) lfirst(l);
81 
82  /* Ugh. Somebody ought to write a table driven version -- mjl */
83 
84  if (pg_strcasecmp(tok, "ISO") == 0)
85  {
86  if (have_style && newDateStyle != USE_ISO_DATES)
87  ok = false; /* conflicting styles */
88  newDateStyle = USE_ISO_DATES;
89  have_style = true;
90  }
91  else if (pg_strcasecmp(tok, "SQL") == 0)
92  {
93  if (have_style && newDateStyle != USE_SQL_DATES)
94  ok = false; /* conflicting styles */
95  newDateStyle = USE_SQL_DATES;
96  have_style = true;
97  }
98  else if (pg_strncasecmp(tok, "POSTGRES", 8) == 0)
99  {
100  if (have_style && newDateStyle != USE_POSTGRES_DATES)
101  ok = false; /* conflicting styles */
102  newDateStyle = USE_POSTGRES_DATES;
103  have_style = true;
104  }
105  else if (pg_strcasecmp(tok, "GERMAN") == 0)
106  {
107  if (have_style && newDateStyle != USE_GERMAN_DATES)
108  ok = false; /* conflicting styles */
109  newDateStyle = USE_GERMAN_DATES;
110  have_style = true;
111  /* GERMAN also sets DMY, unless explicitly overridden */
112  if (!have_order)
113  newDateOrder = DATEORDER_DMY;
114  }
115  else if (pg_strcasecmp(tok, "YMD") == 0)
116  {
117  if (have_order && newDateOrder != DATEORDER_YMD)
118  ok = false; /* conflicting orders */
119  newDateOrder = DATEORDER_YMD;
120  have_order = true;
121  }
122  else if (pg_strcasecmp(tok, "DMY") == 0 ||
123  pg_strncasecmp(tok, "EURO", 4) == 0)
124  {
125  if (have_order && newDateOrder != DATEORDER_DMY)
126  ok = false; /* conflicting orders */
127  newDateOrder = DATEORDER_DMY;
128  have_order = true;
129  }
130  else if (pg_strcasecmp(tok, "MDY") == 0 ||
131  pg_strcasecmp(tok, "US") == 0 ||
132  pg_strncasecmp(tok, "NONEURO", 7) == 0)
133  {
134  if (have_order && newDateOrder != DATEORDER_MDY)
135  ok = false; /* conflicting orders */
136  newDateOrder = DATEORDER_MDY;
137  have_order = true;
138  }
139  else if (pg_strcasecmp(tok, "DEFAULT") == 0)
140  {
141  /*
142  * Easiest way to get the current DEFAULT state is to fetch the
143  * DEFAULT string from guc.c and recursively parse it.
144  *
145  * We can't simply "return check_datestyle(...)" because we need
146  * to handle constructs like "DEFAULT, ISO".
147  */
148  char *subval;
149  void *subextra = NULL;
150 
151  subval = guc_strdup(LOG, GetConfigOptionResetString("datestyle"));
152  if (!subval)
153  {
154  ok = false;
155  break;
156  }
157  if (!check_datestyle(&subval, &subextra, source))
158  {
159  guc_free(subval);
160  ok = false;
161  break;
162  }
163  myextra = (int *) subextra;
164  if (!have_style)
165  newDateStyle = myextra[0];
166  if (!have_order)
167  newDateOrder = myextra[1];
168  guc_free(subval);
169  guc_free(subextra);
170  }
171  else
172  {
173  GUC_check_errdetail("Unrecognized key word: \"%s\".", tok);
174  pfree(rawstring);
175  list_free(elemlist);
176  return false;
177  }
178  }
179 
180  pfree(rawstring);
181  list_free(elemlist);
182 
183  if (!ok)
184  {
185  GUC_check_errdetail("Conflicting \"datestyle\" specifications.");
186  return false;
187  }
188 
189  /*
190  * Prepare the canonical string to return. GUC wants it guc_malloc'd.
191  */
192  result = (char *) guc_malloc(LOG, 32);
193  if (!result)
194  return false;
195 
196  switch (newDateStyle)
197  {
198  case USE_ISO_DATES:
199  strcpy(result, "ISO");
200  break;
201  case USE_SQL_DATES:
202  strcpy(result, "SQL");
203  break;
204  case USE_GERMAN_DATES:
205  strcpy(result, "German");
206  break;
207  default:
208  strcpy(result, "Postgres");
209  break;
210  }
211  switch (newDateOrder)
212  {
213  case DATEORDER_YMD:
214  strcat(result, ", YMD");
215  break;
216  case DATEORDER_DMY:
217  strcat(result, ", DMY");
218  break;
219  default:
220  strcat(result, ", MDY");
221  break;
222  }
223 
224  guc_free(*newval);
225  *newval = result;
226 
227  /*
228  * Set up the "extra" struct actually used by assign_datestyle.
229  */
230  myextra = (int *) guc_malloc(LOG, 2 * sizeof(int));
231  if (!myextra)
232  return false;
233  myextra[0] = newDateStyle;
234  myextra[1] = newDateOrder;
235  *extra = (void *) myextra;
236 
237  return true;
238 }
bool check_datestyle(char **newval, void **extra, GucSource source)
Definition: variable.c:52
const char * GetConfigOptionResetString(const char *name)
Definition: guc.c:4249
void list_free(List *list)
Definition: list.c:1545
char * pstrdup(const char *in)
Definition: mcxt.c:1644
#define USE_SQL_DATES
Definition: miscadmin.h:231
#define USE_POSTGRES_DATES
Definition: miscadmin.h:229
#define USE_ISO_DATES
Definition: miscadmin.h:230
#define DATEORDER_DMY
Definition: miscadmin.h:237
#define DATEORDER_MDY
Definition: miscadmin.h:238
#define DATEORDER_YMD
Definition: miscadmin.h:236
#define USE_GERMAN_DATES
Definition: miscadmin.h:232
#define lfirst(lc)
Definition: pg_list.h:172
static rewind_source * source
Definition: pg_rewind.c:89
int pg_strcasecmp(const char *s1, const char *s2)
Definition: pgstrcasecmp.c:36
int pg_strncasecmp(const char *s1, const char *s2, size_t n)
Definition: pgstrcasecmp.c:69
Definition: pg_list.h:54
bool SplitIdentifierString(char *rawstring, char separator, List **namelist)
Definition: varlena.c:3454

References DateOrder, DATEORDER_DMY, DATEORDER_MDY, DATEORDER_YMD, DateStyle, GetConfigOptionResetString(), GUC_check_errdetail, guc_free(), guc_malloc(), guc_strdup(), lfirst, list_free(), LOG, newval, pfree(), pg_strcasecmp(), pg_strncasecmp(), pstrdup(), source, SplitIdentifierString(), USE_GERMAN_DATES, USE_ISO_DATES, USE_POSTGRES_DATES, and USE_SQL_DATES.

◆ check_debug_io_direct()

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

Definition at line 3887 of file fd.c.

3888 {
3889  bool result = true;
3890  int flags;
3891 
3892 #if PG_O_DIRECT == 0
3893  if (strcmp(*newval, "") != 0)
3894  {
3895  GUC_check_errdetail("debug_io_direct is not supported on this platform.");
3896  result = false;
3897  }
3898  flags = 0;
3899 #else
3900  List *elemlist;
3901  ListCell *l;
3902  char *rawstring;
3903 
3904  /* Need a modifiable copy of string */
3905  rawstring = pstrdup(*newval);
3906 
3907  if (!SplitGUCList(rawstring, ',', &elemlist))
3908  {
3909  GUC_check_errdetail("invalid list syntax in parameter \"%s\"",
3910  "debug_io_direct");
3911  pfree(rawstring);
3912  list_free(elemlist);
3913  return false;
3914  }
3915 
3916  flags = 0;
3917  foreach(l, elemlist)
3918  {
3919  char *item = (char *) lfirst(l);
3920 
3921  if (pg_strcasecmp(item, "data") == 0)
3922  flags |= IO_DIRECT_DATA;
3923  else if (pg_strcasecmp(item, "wal") == 0)
3924  flags |= IO_DIRECT_WAL;
3925  else if (pg_strcasecmp(item, "wal_init") == 0)
3926  flags |= IO_DIRECT_WAL_INIT;
3927  else
3928  {
3929  GUC_check_errdetail("invalid option \"%s\"", item);
3930  result = false;
3931  break;
3932  }
3933  }
3934 
3935  /*
3936  * It's possible to configure block sizes smaller than our assumed I/O
3937  * alignment size, which could result in invalid I/O requests.
3938  */
3939 #if XLOG_BLCKSZ < PG_IO_ALIGN_SIZE
3940  if (result && (flags & (IO_DIRECT_WAL | IO_DIRECT_WAL_INIT)))
3941  {
3942  GUC_check_errdetail("debug_io_direct is not supported for WAL because XLOG_BLCKSZ is too small");
3943  result = false;
3944  }
3945 #endif
3946 #if BLCKSZ < PG_IO_ALIGN_SIZE
3947  if (result && (flags & IO_DIRECT_DATA))
3948  {
3949  GUC_check_errdetail("debug_io_direct is not supported for data because BLCKSZ is too small");
3950  result = false;
3951  }
3952 #endif
3953 
3954  pfree(rawstring);
3955  list_free(elemlist);
3956 #endif
3957 
3958  if (!result)
3959  return result;
3960 
3961  /* Save the flags in *extra, for use by assign_debug_io_direct */
3962  *extra = guc_malloc(ERROR, sizeof(int));
3963  *((int *) *extra) = flags;
3964 
3965  return result;
3966 }
#define IO_DIRECT_WAL
Definition: fd.h:53
#define IO_DIRECT_DATA
Definition: fd.h:52
#define IO_DIRECT_WAL_INIT
Definition: fd.h:54
bool SplitGUCList(char *rawstring, char separator, List **namelist)
Definition: varlena.c:3702

References ERROR, GUC_check_errdetail, guc_malloc(), IO_DIRECT_DATA, IO_DIRECT_WAL, IO_DIRECT_WAL_INIT, lfirst, list_free(), newval, pfree(), pg_strcasecmp(), pstrdup(), and SplitGUCList().

◆ check_default_table_access_method()

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

Definition at line 112 of file tableamapi.c.

113 {
114  if (**newval == '\0')
115  {
116  GUC_check_errdetail("%s cannot be empty.",
117  "default_table_access_method");
118  return false;
119  }
120 
121  if (strlen(*newval) >= NAMEDATALEN)
122  {
123  GUC_check_errdetail("%s is too long (maximum %d characters).",
124  "default_table_access_method", NAMEDATALEN - 1);
125  return false;
126  }
127 
128  /*
129  * If we aren't inside a transaction, or not connected to a database, we
130  * cannot do the catalog access necessary to verify the method. Must
131  * accept the value on faith.
132  */
134  {
135  if (!OidIsValid(get_table_am_oid(*newval, true)))
136  {
137  /*
138  * When source == PGC_S_TEST, don't throw a hard error for a
139  * nonexistent table access method, only a NOTICE. See comments in
140  * guc.h.
141  */
142  if (source == PGC_S_TEST)
143  {
144  ereport(NOTICE,
145  (errcode(ERRCODE_UNDEFINED_OBJECT),
146  errmsg("table access method \"%s\" does not exist",
147  *newval)));
148  }
149  else
150  {
151  GUC_check_errdetail("Table access method \"%s\" does not exist.",
152  *newval);
153  return false;
154  }
155  }
156  }
157 
158  return true;
159 }
Oid get_table_am_oid(const char *amname, bool missing_ok)
Definition: amcmds.c:173
#define OidIsValid(objectId)
Definition: c.h:764
#define NOTICE
Definition: elog.h:35
Oid MyDatabaseId
Definition: globals.c:89
@ PGC_S_TEST
Definition: guc.h:121
#define NAMEDATALEN

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

◆ check_default_tablespace()

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

Definition at line 1097 of file tablespace.c.

1098 {
1099  /*
1100  * If we aren't inside a transaction, or connected to a database, we
1101  * cannot do the catalog accesses necessary to verify the name. Must
1102  * accept the value on faith.
1103  */
1105  {
1106  if (**newval != '\0' &&
1108  {
1109  /*
1110  * When source == PGC_S_TEST, don't throw a hard error for a
1111  * nonexistent tablespace, only a NOTICE. See comments in guc.h.
1112  */
1113  if (source == PGC_S_TEST)
1114  {
1115  ereport(NOTICE,
1116  (errcode(ERRCODE_UNDEFINED_OBJECT),
1117  errmsg("tablespace \"%s\" does not exist",
1118  *newval)));
1119  }
1120  else
1121  {
1122  GUC_check_errdetail("Tablespace \"%s\" does not exist.",
1123  *newval);
1124  return false;
1125  }
1126  }
1127  }
1128 
1129  return true;
1130 }
Oid get_tablespace_oid(const char *tablespacename, bool missing_ok)
Definition: tablespace.c:1432

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

◆ check_default_text_search_config()

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

Definition at line 602 of file ts_cache.c.

603 {
604  /*
605  * If we aren't inside a transaction, or connected to a database, we
606  * cannot do the catalog accesses necessary to verify the config name.
607  * Must accept it on faith.
608  */
610  {
611  ErrorSaveContext escontext = {T_ErrorSaveContext};
612  List *namelist;
613  Oid cfgId;
614  HeapTuple tuple;
615  Form_pg_ts_config cfg;
616  char *buf;
617 
618  namelist = stringToQualifiedNameList(*newval,
619  (Node *) &escontext);
620  if (namelist != NIL)
621  cfgId = get_ts_config_oid(namelist, true);
622  else
623  cfgId = InvalidOid; /* bad name list syntax */
624 
625  /*
626  * When source == PGC_S_TEST, don't throw a hard error for a
627  * nonexistent configuration, only a NOTICE. See comments in guc.h.
628  */
629  if (!OidIsValid(cfgId))
630  {
631  if (source == PGC_S_TEST)
632  {
633  ereport(NOTICE,
634  (errcode(ERRCODE_UNDEFINED_OBJECT),
635  errmsg("text search configuration \"%s\" does not exist", *newval)));
636  return true;
637  }
638  else
639  return false;
640  }
641 
642  /*
643  * Modify the actually stored value to be fully qualified, to ensure
644  * later changes of search_path don't affect it.
645  */
647  if (!HeapTupleIsValid(tuple))
648  elog(ERROR, "cache lookup failed for text search configuration %u",
649  cfgId);
650  cfg = (Form_pg_ts_config) GETSTRUCT(tuple);
651 
653  NameStr(cfg->cfgname));
654 
655  ReleaseSysCache(tuple);
656 
657  /* GUC wants it guc_malloc'd not palloc'd */
658  guc_free(*newval);
659  *newval = guc_strdup(LOG, buf);
660  pfree(buf);
661  if (!*newval)
662  return false;
663  }
664 
665  return true;
666 }
#define NameStr(name)
Definition: c.h:735
#define HeapTupleIsValid(tuple)
Definition: htup.h:78
#define GETSTRUCT(TUP)
Definition: htup_details.h:653
char * get_namespace_name(Oid nspid)
Definition: lsyscache.c:3348
Oid get_ts_config_oid(List *names, bool missing_ok)
Definition: namespace.c:2704
#define NIL
Definition: pg_list.h:68
static char * buf
Definition: pg_test_fsync.c:67
FormData_pg_ts_config * Form_pg_ts_config
Definition: pg_ts_config.h:48
static Datum ObjectIdGetDatum(Oid X)
Definition: postgres.h:252
unsigned int Oid
Definition: postgres_ext.h:31
List * stringToQualifiedNameList(const char *string, Node *escontext)
Definition: regproc.c:1777
char * quote_qualified_identifier(const char *qualifier, const char *ident)
Definition: ruleutils.c:12049
Definition: nodes.h:129
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:868
HeapTuple SearchSysCache1(int cacheId, Datum key1)
Definition: syscache.c:820
@ TSCONFIGOID
Definition: syscache.h:106

References buf, elog(), ereport, errcode(), errmsg(), ERROR, get_namespace_name(), get_ts_config_oid(), GETSTRUCT, guc_free(), guc_strdup(), HeapTupleIsValid, InvalidOid, IsTransactionState(), LOG, MyDatabaseId, NameStr, newval, NIL, NOTICE, ObjectIdGetDatum(), OidIsValid, pfree(), PGC_S_TEST, quote_qualified_identifier(), ReleaseSysCache(), SearchSysCache1(), source, stringToQualifiedNameList(), and TSCONFIGOID.

◆ check_default_with_oids()

bool check_default_with_oids ( bool newval,
void **  extra,
GucSource  source 
)

Definition at line 1185 of file variable.c.

1186 {
1187  if (*newval)
1188  {
1189  /* check the GUC's definition for an explanation */
1190  GUC_check_errcode(ERRCODE_FEATURE_NOT_SUPPORTED);
1191  GUC_check_errmsg("tables declared WITH OIDS are not supported");
1192 
1193  return false;
1194  }
1195 
1196  return true;
1197 }

References GUC_check_errcode(), GUC_check_errmsg, and newval.

◆ check_effective_io_concurrency()

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

Definition at line 1200 of file variable.c.

1201 {
1202 #ifndef USE_PREFETCH
1203  if (*newval != 0)
1204  {
1205  GUC_check_errdetail("effective_io_concurrency must be set to 0 on platforms that lack posix_fadvise().");
1206  return false;
1207  }
1208 #endif /* USE_PREFETCH */
1209  return true;
1210 }

References GUC_check_errdetail, and newval.

◆ check_huge_page_size()

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

Definition at line 577 of file sysv_shmem.c.

578 {
579 #if !(defined(MAP_HUGE_MASK) && defined(MAP_HUGE_SHIFT))
580  /* Recent enough Linux only, for now. See GetHugePageSize(). */
581  if (*newval != 0)
582  {
583  GUC_check_errdetail("huge_page_size must be 0 on this platform.");
584  return false;
585  }
586 #endif
587  return true;
588 }

References GUC_check_errdetail, and newval.

◆ check_locale_messages()

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

Definition at line 405 of file pg_locale.c.

406 {
407  if (**newval == '\0')
408  {
409  if (source == PGC_S_DEFAULT)
410  return true;
411  else
412  return false;
413  }
414 
415  /*
416  * LC_MESSAGES category does not exist everywhere, but accept it anyway
417  *
418  * On Windows, we can't even check the value, so accept blindly
419  */
420 #if defined(LC_MESSAGES) && !defined(WIN32)
421  return check_locale(LC_MESSAGES, *newval, NULL);
422 #else
423  return true;
424 #endif
425 }
@ PGC_S_DEFAULT
Definition: guc.h:109
bool check_locale(int category, const char *locale, char **canonname)
Definition: pg_locale.c:316

References check_locale(), newval, PGC_S_DEFAULT, and source.

◆ check_locale_monetary()

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

Definition at line 359 of file pg_locale.c.

360 {
361  return check_locale(LC_MONETARY, *newval, NULL);
362 }

References check_locale(), and newval.

◆ check_locale_numeric()

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

Definition at line 371 of file pg_locale.c.

372 {
373  return check_locale(LC_NUMERIC, *newval, NULL);
374 }

References check_locale(), and newval.

◆ check_locale_time()

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

Definition at line 383 of file pg_locale.c.

384 {
385  return check_locale(LC_TIME, *newval, NULL);
386 }

References check_locale(), and newval.

◆ check_log_destination()

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

Definition at line 2190 of file elog.c.

2191 {
2192  char *rawstring;
2193  List *elemlist;
2194  ListCell *l;
2195  int newlogdest = 0;
2196  int *myextra;
2197 
2198  /* Need a modifiable copy of string */
2199  rawstring = pstrdup(*newval);
2200 
2201  /* Parse string into list of identifiers */
2202  if (!SplitIdentifierString(rawstring, ',', &elemlist))
2203  {
2204  /* syntax error in list */
2205  GUC_check_errdetail("List syntax is invalid.");
2206  pfree(rawstring);
2207  list_free(elemlist);
2208  return false;
2209  }
2210 
2211  foreach(l, elemlist)
2212  {
2213  char *tok = (char *) lfirst(l);
2214 
2215  if (pg_strcasecmp(tok, "stderr") == 0)
2216  newlogdest |= LOG_DESTINATION_STDERR;
2217  else if (pg_strcasecmp(tok, "csvlog") == 0)
2218  newlogdest |= LOG_DESTINATION_CSVLOG;
2219  else if (pg_strcasecmp(tok, "jsonlog") == 0)
2220  newlogdest |= LOG_DESTINATION_JSONLOG;
2221 #ifdef HAVE_SYSLOG
2222  else if (pg_strcasecmp(tok, "syslog") == 0)
2223  newlogdest |= LOG_DESTINATION_SYSLOG;
2224 #endif
2225 #ifdef WIN32
2226  else if (pg_strcasecmp(tok, "eventlog") == 0)
2227  newlogdest |= LOG_DESTINATION_EVENTLOG;
2228 #endif
2229  else
2230  {
2231  GUC_check_errdetail("Unrecognized key word: \"%s\".", tok);
2232  pfree(rawstring);
2233  list_free(elemlist);
2234  return false;
2235  }
2236  }
2237 
2238  pfree(rawstring);
2239  list_free(elemlist);
2240 
2241  myextra = (int *) guc_malloc(ERROR, sizeof(int));
2242  *myextra = newlogdest;
2243  *extra = (void *) myextra;
2244 
2245  return true;
2246 }
#define LOG_DESTINATION_JSONLOG
Definition: elog.h:496
#define LOG_DESTINATION_SYSLOG
Definition: elog.h:493
#define LOG_DESTINATION_STDERR
Definition: elog.h:492
#define LOG_DESTINATION_EVENTLOG
Definition: elog.h:494
#define LOG_DESTINATION_CSVLOG
Definition: elog.h:495

References ERROR, GUC_check_errdetail, guc_malloc(), lfirst, list_free(), LOG_DESTINATION_CSVLOG, LOG_DESTINATION_EVENTLOG, LOG_DESTINATION_JSONLOG, LOG_DESTINATION_STDERR, LOG_DESTINATION_SYSLOG, newval, pfree(), pg_strcasecmp(), pstrdup(), and SplitIdentifierString().

◆ check_log_stats()

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

Definition at line 3633 of file postgres.c.

3634 {
3635  if (*newval &&
3637  {
3638  GUC_check_errdetail("Cannot enable \"log_statement_stats\" when "
3639  "\"log_parser_stats\", \"log_planner_stats\", "
3640  "or \"log_executor_stats\" is true.");
3641  return false;
3642  }
3643  return true;
3644 }
bool log_parser_stats
Definition: guc_tables.c:500
bool log_planner_stats
Definition: guc_tables.c:501
bool log_executor_stats
Definition: guc_tables.c:502

References GUC_check_errdetail, log_executor_stats, log_parser_stats, log_planner_stats, and newval.

◆ check_log_timezone()

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

Definition at line 416 of file variable.c.

417 {
418  pg_tz *new_tz;
419 
420  /*
421  * Assume it is a timezone name, and try to load it.
422  */
423  new_tz = pg_tzset(*newval);
424 
425  if (!new_tz)
426  {
427  /* Doesn't seem to be any great value in errdetail here */
428  return false;
429  }
430 
431  if (!pg_tz_acceptable(new_tz))
432  {
433  GUC_check_errmsg("time zone \"%s\" appears to use leap seconds",
434  *newval);
435  GUC_check_errdetail("PostgreSQL does not support leap seconds.");
436  return false;
437  }
438 
439  /*
440  * Pass back data for assign_log_timezone to use
441  */
442  *extra = guc_malloc(LOG, sizeof(pg_tz *));
443  if (!*extra)
444  return false;
445  *((pg_tz **) *extra) = new_tz;
446 
447  return true;
448 }
bool pg_tz_acceptable(pg_tz *tz)
Definition: localtime.c:1890
pg_tz * pg_tzset(const char *tzname)
Definition: pgtz.c:234

References GUC_check_errdetail, GUC_check_errmsg, guc_malloc(), LOG, newval, pg_tz_acceptable(), and pg_tzset().

◆ check_maintenance_io_concurrency()

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

Definition at line 1213 of file variable.c.

1214 {
1215 #ifndef USE_PREFETCH
1216  if (*newval != 0)
1217  {
1218  GUC_check_errdetail("maintenance_io_concurrency must be set to 0 on platforms that lack posix_fadvise().");
1219  return false;
1220  }
1221 #endif /* USE_PREFETCH */
1222  return true;
1223 }

References GUC_check_errdetail, and newval.

◆ check_max_connections()

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

Definition at line 576 of file postinit.c.

577 {
578  if (*newval + autovacuum_max_workers + 1 +
580  return false;
581  return true;
582 }
int autovacuum_max_workers
Definition: autovacuum.c:117

References autovacuum_max_workers, MAX_BACKENDS, max_wal_senders, max_worker_processes, and newval.

◆ check_max_stack_depth()

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

Definition at line 3570 of file postgres.c.

3571 {
3572  long newval_bytes = *newval * 1024L;
3573  long stack_rlimit = get_stack_depth_rlimit();
3574 
3575  if (stack_rlimit > 0 && newval_bytes > stack_rlimit - STACK_DEPTH_SLOP)
3576  {
3577  GUC_check_errdetail("\"max_stack_depth\" must not exceed %ldkB.",
3578  (stack_rlimit - STACK_DEPTH_SLOP) / 1024L);
3579  GUC_check_errhint("Increase the platform's stack depth limit via \"ulimit -s\" or local equivalent.");
3580  return false;
3581  }
3582  return true;
3583 }
#define GUC_check_errhint
Definition: guc.h:440
long get_stack_depth_rlimit(void)
Definition: postgres.c:4933
#define STACK_DEPTH_SLOP
Definition: tcopprot.h:26

References get_stack_depth_rlimit(), GUC_check_errdetail, GUC_check_errhint, newval, and STACK_DEPTH_SLOP.

◆ check_max_wal_senders()

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

Definition at line 612 of file postinit.c.

613 {
616  return false;
617  return true;
618 }

References autovacuum_max_workers, MAX_BACKENDS, max_worker_processes, MaxConnections, and newval.

◆ check_max_worker_processes()

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

Definition at line 600 of file postinit.c.

601 {
604  return false;
605  return true;
606 }

References autovacuum_max_workers, MAX_BACKENDS, max_wal_senders, MaxConnections, and newval.

◆ check_primary_slot_name()

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

Definition at line 4656 of file xlogrecovery.c.

4657 {
4658  if (*newval && strcmp(*newval, "") != 0 &&
4660  return false;
4661 
4662  return true;
4663 }
bool ReplicationSlotValidateName(const char *name, int elevel)
Definition: slot.c:199

References newval, ReplicationSlotValidateName(), and WARNING.

◆ check_random_seed()

bool check_random_seed ( double *  newval,
void **  extra,
GucSource  source 
)

Definition at line 648 of file variable.c.

649 {
650  *extra = guc_malloc(LOG, sizeof(int));
651  if (!*extra)
652  return false;
653  /* Arm the assign only if source of value is an interactive SET */
654  *((int *) *extra) = (source >= PGC_S_INTERACTIVE);
655 
656  return true;
657 }
@ PGC_S_INTERACTIVE
Definition: guc.h:120

References guc_malloc(), LOG, PGC_S_INTERACTIVE, and source.

◆ check_recovery_prefetch()

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

Definition at line 1087 of file xlogprefetcher.c.

1088 {
1089 #ifndef USE_PREFETCH
1090  if (*new_value == RECOVERY_PREFETCH_ON)
1091  {
1092  GUC_check_errdetail("recovery_prefetch is not supported on platforms that lack posix_fadvise().");
1093  return false;
1094  }
1095 #endif
1096 
1097  return true;
1098 }
@ RECOVERY_PREFETCH_ON

References GUC_check_errdetail, and RECOVERY_PREFETCH_ON.

◆ check_recovery_target()

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

Definition at line 4697 of file xlogrecovery.c.

4698 {
4699  if (strcmp(*newval, "immediate") != 0 && strcmp(*newval, "") != 0)
4700  {
4701  GUC_check_errdetail("The only allowed value is \"immediate\".");
4702  return false;
4703  }
4704  return true;
4705 }

References GUC_check_errdetail, and newval.

◆ check_recovery_target_lsn()

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

Definition at line 4727 of file xlogrecovery.c.

4728 {
4729  if (strcmp(*newval, "") != 0)
4730  {
4731  XLogRecPtr lsn;
4732  XLogRecPtr *myextra;
4733  bool have_error = false;
4734 
4735  lsn = pg_lsn_in_internal(*newval, &have_error);
4736  if (have_error)
4737  return false;
4738 
4739  myextra = (XLogRecPtr *) guc_malloc(ERROR, sizeof(XLogRecPtr));
4740  *myextra = lsn;
4741  *extra = (void *) myextra;
4742  }
4743  return true;
4744 }
XLogRecPtr pg_lsn_in_internal(const char *str, bool *have_error)
Definition: pg_lsn.c:30

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

◆ check_recovery_target_name()

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

Definition at line 4769 of file xlogrecovery.c.

4770 {
4771  /* Use the value of newval directly */
4772  if (strlen(*newval) >= MAXFNAMELEN)
4773  {
4774  GUC_check_errdetail("%s is too long (maximum %d characters).",
4775  "recovery_target_name", MAXFNAMELEN - 1);
4776  return false;
4777  }
4778  return true;
4779 }

References GUC_check_errdetail, MAXFNAMELEN, and newval.

◆ check_recovery_target_time()

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

Definition at line 4810 of file xlogrecovery.c.

4811 {
4812  if (strcmp(*newval, "") != 0)
4813  {
4814  /* reject some special values */
4815  if (strcmp(*newval, "now") == 0 ||
4816  strcmp(*newval, "today") == 0 ||
4817  strcmp(*newval, "tomorrow") == 0 ||
4818  strcmp(*newval, "yesterday") == 0)
4819  {
4820  return false;
4821  }
4822 
4823  /*
4824  * parse timestamp value (see also timestamptz_in())
4825  */
4826  {
4827  char *str = *newval;
4828  fsec_t fsec;
4829  struct pg_tm tt,
4830  *tm = &tt;
4831  int tz;
4832  int dtype;
4833  int nf;
4834  int dterr;
4835  char *field[MAXDATEFIELDS];
4836  int ftype[MAXDATEFIELDS];
4837  char workbuf[MAXDATELEN + MAXDATEFIELDS];
4838  DateTimeErrorExtra dtextra;
4840 
4841  dterr = ParseDateTime(str, workbuf, sizeof(workbuf),
4842  field, ftype, MAXDATEFIELDS, &nf);
4843  if (dterr == 0)
4844  dterr = DecodeDateTime(field, ftype, nf,
4845  &dtype, tm, &fsec, &tz, &dtextra);
4846  if (dterr != 0)
4847  return false;
4848  if (dtype != DTK_DATE)
4849  return false;
4850 
4851  if (tm2timestamp(tm, fsec, &tz, &timestamp) != 0)
4852  {
4853  GUC_check_errdetail("timestamp out of range: \"%s\"", str);
4854  return false;
4855  }
4856  }
4857  }
4858  return true;
4859 }
int ParseDateTime(const char *timestr, char *workbuf, size_t buflen, char **field, int *ftype, int maxfields, int *numfields)
Definition: datetime.c:756
int DecodeDateTime(char **field, int *ftype, int nf, int *dtype, struct pg_tm *tm, fsec_t *fsec, int *tzp, DateTimeErrorExtra *extra)
Definition: datetime.c:980
int tm2timestamp(struct pg_tm *tm, fsec_t fsec, int *tzp, Timestamp *result)
Definition: timestamp.c:1926
int64 TimestampTz
Definition: timestamp.h:39
int32 fsec_t
Definition: timestamp.h:41
#define MAXDATEFIELDS
Definition: datetime.h:202
#define DTK_DATE
Definition: datetime.h:144
#define MAXDATELEN
Definition: datetime.h:200
static struct pg_tm tm
Definition: localtime.c:104
int64 timestamp
Definition: pgtime.h:35

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

◆ check_recovery_target_timeline()

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

Definition at line 4881 of file xlogrecovery.c.

4882 {
4884  RecoveryTargetTimeLineGoal *myextra;
4885 
4886  if (strcmp(*newval, "current") == 0)
4888  else if (strcmp(*newval, "latest") == 0)
4890  else
4891  {
4893 
4894  errno = 0;
4895  strtoul(*newval, NULL, 0);
4896  if (errno == EINVAL || errno == ERANGE)
4897  {
4898  GUC_check_errdetail("recovery_target_timeline is not a valid number.");
4899  return false;
4900  }
4901  }
4902 
4904  *myextra = rttg;
4905  *extra = (void *) myextra;
4906 
4907  return true;
4908 }
@ RECOVERY_TARGET_TIMELINE_CONTROLFILE
Definition: xlogrecovery.h:38
@ RECOVERY_TARGET_TIMELINE_LATEST
Definition: xlogrecovery.h:39

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

◆ check_recovery_target_xid()

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

Definition at line 4927 of file xlogrecovery.c.

4928 {
4929  if (strcmp(*newval, "") != 0)
4930  {
4931  TransactionId xid;
4932  TransactionId *myextra;
4933 
4934  errno = 0;
4935  xid = (TransactionId) strtou64(*newval, NULL, 0);
4936  if (errno == EINVAL || errno == ERANGE)
4937  return false;
4938 
4939  myextra = (TransactionId *) guc_malloc(ERROR, sizeof(TransactionId));
4940  *myextra = xid;
4941  *extra = (void *) myextra;
4942  }
4943  return true;
4944 }
#define strtou64(str, endptr, base)
Definition: c.h:1308

References ERROR, guc_malloc(), newval, and strtou64.

◆ check_role()

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

Definition at line 907 of file variable.c.

908 {
909  HeapTuple roleTup;
910  Oid roleid;
911  bool is_superuser;
912  role_auth_extra *myextra;
913  Form_pg_authid roleform;
914 
915  if (strcmp(*newval, "none") == 0)
916  {
917  /* hardwired translation */
918  roleid = InvalidOid;
919  is_superuser = false;
920  }
921  else
922  {
923  if (!IsTransactionState())
924  {
925  /*
926  * Can't do catalog lookups, so fail. The result of this is that
927  * role cannot be set in postgresql.conf, which seems like a good
928  * thing anyway, so we don't work hard to avoid it.
929  */
930  return false;
931  }
932 
933  /*
934  * When source == PGC_S_TEST, we don't throw a hard error for a
935  * nonexistent user name or insufficient privileges, only a NOTICE.
936  * See comments in guc.h.
937  */
938 
939  /* Look up the username */
941  if (!HeapTupleIsValid(roleTup))
942  {
943  if (source == PGC_S_TEST)
944  {
945  ereport(NOTICE,
946  (errcode(ERRCODE_UNDEFINED_OBJECT),
947  errmsg("role \"%s\" does not exist", *newval)));
948  return true;
949  }
950  GUC_check_errmsg("role \"%s\" does not exist", *newval);
951  return false;
952  }
953 
954  roleform = (Form_pg_authid) GETSTRUCT(roleTup);
955  roleid = roleform->oid;
956  is_superuser = roleform->rolsuper;
957 
958  ReleaseSysCache(roleTup);
959 
960  /*
961  * Verify that session user is allowed to become this role, but skip
962  * this in parallel mode, where we must blindly recreate the parallel
963  * leader's state.
964  */
967  {
968  if (source == PGC_S_TEST)
969  {
970  ereport(NOTICE,
971  (errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
972  errmsg("permission will be denied to set role \"%s\"",
973  *newval)));
974  return true;
975  }
976  GUC_check_errcode(ERRCODE_INSUFFICIENT_PRIVILEGE);
977  GUC_check_errmsg("permission denied to set role \"%s\"",
978  *newval);
979  return false;
980  }
981  }
982 
983  /* Set up "extra" struct for assign_role to use */
984  myextra = (role_auth_extra *) guc_malloc(LOG, sizeof(role_auth_extra));
985  if (!myextra)
986  return false;
987  myextra->roleid = roleid;
988  myextra->is_superuser = is_superuser;
989  *extra = (void *) myextra;
990 
991  return true;
992 }
bool member_can_set_role(Oid member, Oid role)
Definition: acl.c:4995
Oid GetSessionUserId(void)
Definition: miscinit.c:543
FormData_pg_authid * Form_pg_authid
Definition: pg_authid.h:56
static bool is_superuser(Archive *fout)
Definition: pg_dump.c:4566
static Datum PointerGetDatum(const void *X)
Definition: postgres.h:322
@ AUTHNAME
Definition: syscache.h:44

References AUTHNAME, ereport, errcode(), errmsg(), GetSessionUserId(), GETSTRUCT, GUC_check_errcode(), GUC_check_errmsg, guc_malloc(), HeapTupleIsValid, InitializingParallelWorker, InvalidOid, role_auth_extra::is_superuser, is_superuser(), IsTransactionState(), LOG, member_can_set_role(), newval, NOTICE, PGC_S_TEST, PointerGetDatum(), ReleaseSysCache(), role_auth_extra::roleid, SearchSysCache1(), and source.

◆ check_search_path()

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

Definition at line 4102 of file namespace.c.

4103 {
4104  char *rawname;
4105  List *namelist;
4106 
4107  /* Need a modifiable copy of string */
4108  rawname = pstrdup(*newval);
4109 
4110  /* Parse string into list of identifiers */
4111  if (!SplitIdentifierString(rawname, ',', &namelist))
4112  {
4113  /* syntax error in name list */
4114  GUC_check_errdetail("List syntax is invalid.");
4115  pfree(rawname);
4116  list_free(namelist);
4117  return false;
4118  }
4119 
4120  /*
4121  * We used to try to check that the named schemas exist, but there are
4122  * many valid use-cases for having search_path settings that include
4123  * schemas that don't exist; and often, we are not inside a transaction
4124  * here and so can't consult the system catalogs anyway. So now, the only
4125  * requirement is syntactic validity of the identifier list.
4126  */
4127 
4128  pfree(rawname);
4129  list_free(namelist);
4130 
4131  return true;
4132 }

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

◆ check_session_authorization()

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

Definition at line 802 of file variable.c.

803 {
804  HeapTuple roleTup;
805  Form_pg_authid roleform;
806  Oid roleid;
807  bool is_superuser;
808  role_auth_extra *myextra;
809 
810  /* Do nothing for the boot_val default of NULL */
811  if (*newval == NULL)
812  return true;
813 
814  if (!IsTransactionState())
815  {
816  /*
817  * Can't do catalog lookups, so fail. The result of this is that
818  * session_authorization cannot be set in postgresql.conf, which seems
819  * like a good thing anyway, so we don't work hard to avoid it.
820  */
821  return false;
822  }
823 
824  /*
825  * When source == PGC_S_TEST, we don't throw a hard error for a
826  * nonexistent user name or insufficient privileges, only a NOTICE. See
827  * comments in guc.h.
828  */
829 
830  /* Look up the username */
832  if (!HeapTupleIsValid(roleTup))
833  {
834  if (source == PGC_S_TEST)
835  {
836  ereport(NOTICE,
837  (errcode(ERRCODE_UNDEFINED_OBJECT),
838  errmsg("role \"%s\" does not exist", *newval)));
839  return true;
840  }
841  GUC_check_errmsg("role \"%s\" does not exist", *newval);
842  return false;
843  }
844 
845  roleform = (Form_pg_authid) GETSTRUCT(roleTup);
846  roleid = roleform->oid;
847  is_superuser = roleform->rolsuper;
848 
849  ReleaseSysCache(roleTup);
850 
851  /*
852  * Only superusers may SET SESSION AUTHORIZATION a role other than itself.
853  * Note that in case of multiple SETs in a single session, the original
854  * authenticated user's superuserness is what matters.
855  */
856  if (roleid != GetAuthenticatedUserId() &&
858  {
859  if (source == PGC_S_TEST)
860  {
861  ereport(NOTICE,
862  (errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
863  errmsg("permission will be denied to set session authorization \"%s\"",
864  *newval)));
865  return true;
866  }
867  GUC_check_errcode(ERRCODE_INSUFFICIENT_PRIVILEGE);
868  GUC_check_errmsg("permission denied to set session authorization \"%s\"",
869  *newval);
870  return false;
871  }
872 
873  /* Set up "extra" struct for assign_session_authorization to use */
874  myextra = (role_auth_extra *) guc_malloc(LOG, sizeof(role_auth_extra));
875  if (!myextra)
876  return false;
877  myextra->roleid = roleid;
878  myextra->is_superuser = is_superuser;
879  *extra = (void *) myextra;
880 
881  return true;
882 }
Oid GetAuthenticatedUserId(void)
Definition: miscinit.c:578
bool superuser_arg(Oid roleid)
Definition: superuser.c:56

References AUTHNAME, ereport, errcode(), errmsg(), GetAuthenticatedUserId(), GETSTRUCT, GUC_check_errcode(), GUC_check_errmsg, guc_malloc(), HeapTupleIsValid, role_auth_extra::is_superuser, is_superuser(), IsTransactionState(), LOG, newval, NOTICE, PGC_S_TEST, PointerGetDatum(), ReleaseSysCache(), role_auth_extra::roleid, SearchSysCache1(), source, and superuser_arg().

◆ check_ssl()

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

Definition at line 1226 of file variable.c.

1227 {
1228 #ifndef USE_SSL
1229  if (*newval)
1230  {
1231  GUC_check_errmsg("SSL is not supported by this build");
1232  return false;
1233  }
1234 #endif
1235  return true;
1236 }

References GUC_check_errmsg, and newval.

◆ check_stage_log_stats()

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

Definition at line 3619 of file postgres.c.

3620 {
3621  if (*newval && log_statement_stats)
3622  {
3623  GUC_check_errdetail("Cannot enable parameter when \"log_statement_stats\" is true.");
3624  return false;
3625  }
3626  return true;
3627 }
bool log_statement_stats
Definition: guc_tables.c:503

References GUC_check_errdetail, log_statement_stats, and newval.

◆ check_synchronous_standby_names()

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

Definition at line 997 of file syncrep.c.

998 {
999  if (*newval != NULL && (*newval)[0] != '\0')
1000  {
1001  int parse_rc;
1002  SyncRepConfigData *pconf;
1003 
1004  /* Reset communication variables to ensure a fresh start */
1005  syncrep_parse_result = NULL;
1006  syncrep_parse_error_msg = NULL;
1007 
1008  /* Parse the synchronous_standby_names string */
1010  parse_rc = syncrep_yyparse();
1012 
1013  if (parse_rc != 0 || syncrep_parse_result == NULL)
1014  {
1015  GUC_check_errcode(ERRCODE_SYNTAX_ERROR);
1018  else
1019  GUC_check_errdetail("synchronous_standby_names parser failed");
1020  return false;
1021  }
1022 
1023  if (syncrep_parse_result->num_sync <= 0)
1024  {
1025  GUC_check_errmsg("number of synchronous standbys (%d) must be greater than zero",
1027  return false;
1028  }
1029 
1030  /* GUC extra value must be guc_malloc'd, not palloc'd */
1031  pconf = (SyncRepConfigData *)
1033  if (pconf == NULL)
1034  return false;
1036 
1037  *extra = (void *) pconf;
1038 
1039  /*
1040  * We need not explicitly clean up syncrep_parse_result. It, and any
1041  * other cruft generated during parsing, will be freed when the
1042  * current memory context is deleted. (This code is generally run in
1043  * a short-lived context used for config file processing, so that will
1044  * not be very long.)
1045  */
1046  }
1047  else
1048  *extra = NULL;
1049 
1050  return true;
1051 }
void syncrep_scanner_init(const char *str)
void syncrep_scanner_finish(void)
int syncrep_yyparse(void)
PGDLLIMPORT SyncRepConfigData * syncrep_parse_result
PGDLLIMPORT char * syncrep_parse_error_msg

References SyncRepConfigData::config_size, GUC_check_errcode(), GUC_check_errdetail, GUC_check_errmsg, guc_malloc(), LOG, newval, SyncRepConfigData::num_sync, syncrep_parse_error_msg, syncrep_parse_result, syncrep_scanner_finish(), syncrep_scanner_init(), and syncrep_yyparse().

◆ check_temp_buffers()

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

Definition at line 691 of file localbuf.c.

692 {
693  /*
694  * Once local buffers have been initialized, it's too late to change this.
695  * However, if this is only a test call, allow it.
696  */
697  if (source != PGC_S_TEST && NLocBuffer && NLocBuffer != *newval)
698  {
699  GUC_check_errdetail("\"temp_buffers\" cannot be changed after any temporary tables have been accessed in the session.");
700  return false;
701  }
702  return true;
703 }
int NLocBuffer
Definition: localbuf.c:42

References GUC_check_errdetail, newval, NLocBuffer, PGC_S_TEST, and source.

◆ check_temp_tablespaces()

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

Definition at line 1204 of file tablespace.c.

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

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

◆ check_timezone()

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

Definition at line 261 of file variable.c.

262 {
263  pg_tz *new_tz;
264  long gmtoffset;
265  char *endptr;
266  double hours;
267 
268  if (pg_strncasecmp(*newval, "interval", 8) == 0)
269  {
270  /*
271  * Support INTERVAL 'foo'. This is for SQL spec compliance, not
272  * because it has any actual real-world usefulness.
273  */
274  const char *valueptr = *newval;
275  char *val;
277 
278  valueptr += 8;
279  while (isspace((unsigned char) *valueptr))
280  valueptr++;
281  if (*valueptr++ != '\'')
282  return false;
283  val = pstrdup(valueptr);
284  /* Check and remove trailing quote */
285  endptr = strchr(val, '\'');
286  if (!endptr || endptr[1] != '\0')
287  {
288  pfree(val);
289  return false;
290  }
291  *endptr = '\0';
292 
293  /*
294  * Try to parse it. XXX an invalid interval format will result in
295  * ereport(ERROR), which is not desirable for GUC. We did what we
296  * could to guard against this in flatten_set_variable_args, but a
297  * string coming in from postgresql.conf might contain anything.
298  */
302  Int32GetDatum(-1)));
303 
304  pfree(val);
305  if (interval->month != 0)
306  {
307  GUC_check_errdetail("Cannot specify months in time zone interval.");
308  pfree(interval);
309  return false;
310  }
311  if (interval->day != 0)
312  {
313  GUC_check_errdetail("Cannot specify days in time zone interval.");
314  pfree(interval);
315  return false;
316  }
317 
318  /* Here we change from SQL to Unix sign convention */
319  gmtoffset = -(interval->time / USECS_PER_SEC);
320  new_tz = pg_tzset_offset(gmtoffset);
321 
322  pfree(interval);
323  }
324  else
325  {
326  /*
327  * Try it as a numeric number of hours (possibly fractional).
328  */
329  hours = strtod(*newval, &endptr);
330  if (endptr != *newval && *endptr == '\0')
331  {
332  /* Here we change from SQL to Unix sign convention */
333  gmtoffset = -hours * SECS_PER_HOUR;
334  new_tz = pg_tzset_offset(gmtoffset);
335  }
336  else
337  {
338  /*
339  * Otherwise assume it is a timezone name, and try to load it.
340  */
341  new_tz = pg_tzset(*newval);
342 
343  if (!new_tz)
344  {
345  /* Doesn't seem to be any great value in errdetail here */
346  return false;
347  }
348 
349  if (!pg_tz_acceptable(new_tz))
350  {
351  GUC_check_errmsg("time zone \"%s\" appears to use leap seconds",
352  *newval);
353  GUC_check_errdetail("PostgreSQL does not support leap seconds.");
354  return false;
355  }
356  }
357  }
358 
359  /* Test for failure in pg_tzset_offset, which we assume is out-of-range */
360  if (!new_tz)
361  {
362  GUC_check_errdetail("UTC timezone offset is out of range.");
363  return false;
364  }
365 
366  /*
367  * Pass back data for assign_timezone to use
368  */
369  *extra = guc_malloc(LOG, sizeof(pg_tz *));
370  if (!*extra)
371  return false;
372  *((pg_tz **) *extra) = new_tz;
373 
374  return true;
375 }
Datum interval_in(PG_FUNCTION_ARGS)
Definition: timestamp.c:884
#define SECS_PER_HOUR
Definition: timestamp.h:126
#define USECS_PER_SEC
Definition: timestamp.h:133
#define DirectFunctionCall3(func, arg1, arg2, arg3)
Definition: fmgr.h:646
long val
Definition: informix.c:664
pg_tz * pg_tzset_offset(long gmtoffset)
Definition: pgtz.c:320
static Datum CStringGetDatum(const char *X)
Definition: postgres.h:350
static Datum Int32GetDatum(int32 X)
Definition: postgres.h:212
static Interval * DatumGetIntervalP(Datum X)
Definition: timestamp.h:40

References CStringGetDatum(), DatumGetIntervalP(), DirectFunctionCall3, GUC_check_errdetail, GUC_check_errmsg, guc_malloc(), Int32GetDatum(), interval_in(), InvalidOid, LOG, interval::month, newval, ObjectIdGetDatum(), pfree(), pg_strncasecmp(), pg_tz_acceptable(), pg_tzset(), pg_tzset_offset(), pstrdup(), SECS_PER_HOUR, interval::time, USECS_PER_SEC, and val.

◆ check_timezone_abbreviations()

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

Definition at line 485 of file variable.c.

486 {
487  /*
488  * The boot_val for timezone_abbreviations is NULL. When we see that we
489  * just do nothing. If the value isn't overridden from the config file
490  * then pg_timezone_abbrev_initialize() will eventually replace it with
491  * "Default". This hack has two purposes: to avoid wasting cycles loading
492  * values that might soon be overridden from the config file, and to avoid
493  * trying to read the timezone abbrev files during InitializeGUCOptions().
494  * The latter doesn't work in an EXEC_BACKEND subprocess because
495  * my_exec_path hasn't been set yet and so we can't locate PGSHAREDIR.
496  */
497  if (*newval == NULL)
498  {
500  return true;
501  }
502 
503  /* OK, load the file and produce a guc_malloc'd TimeZoneAbbrevTable */
504  *extra = load_tzoffsets(*newval);
505 
506  /* tzparser.c returns NULL on failure, reporting via GUC_check_errmsg */
507  if (!*extra)
508  return false;
509 
510  return true;
511 }
Assert(fmt[strlen(fmt) - 1] !='\n')
TimeZoneAbbrevTable * load_tzoffsets(const char *filename)
Definition: tzparser.c:446

References Assert(), load_tzoffsets(), newval, PGC_S_DEFAULT, and source.

◆ check_transaction_deferrable()

bool check_transaction_deferrable ( bool newval,
void **  extra,
GucSource  source 
)

Definition at line 620 of file variable.c.

621 {
622  if (IsSubTransaction())
623  {
624  GUC_check_errcode(ERRCODE_ACTIVE_SQL_TRANSACTION);
625  GUC_check_errmsg("SET TRANSACTION [NOT] DEFERRABLE cannot be called within a subtransaction");
626  return false;
627  }
628  if (FirstSnapshotSet)
629  {
630  GUC_check_errcode(ERRCODE_ACTIVE_SQL_TRANSACTION);
631  GUC_check_errmsg("SET TRANSACTION [NOT] DEFERRABLE must be called before any query");
632  return false;
633  }
634 
635  return true;
636 }
bool FirstSnapshotSet
Definition: snapmgr.c:141
bool IsSubTransaction(void)
Definition: xact.c:4889

References FirstSnapshotSet, GUC_check_errcode(), GUC_check_errmsg, and IsSubTransaction().

◆ check_transaction_isolation()

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

Definition at line 583 of file variable.c.

584 {
585  int newXactIsoLevel = *newval;
586 
587  if (newXactIsoLevel != XactIsoLevel && IsTransactionState())
588  {
589  if (FirstSnapshotSet)
590  {
591  GUC_check_errcode(ERRCODE_ACTIVE_SQL_TRANSACTION);
592  GUC_check_errmsg("SET TRANSACTION ISOLATION LEVEL must be called before any query");
593  return false;
594  }
595  /* We ignore a subtransaction setting it to the existing value. */
596  if (IsSubTransaction())
597  {
598  GUC_check_errcode(ERRCODE_ACTIVE_SQL_TRANSACTION);
599  GUC_check_errmsg("SET TRANSACTION ISOLATION LEVEL must not be called in a subtransaction");
600  return false;
601  }
602  /* Can't go to serializable mode while recovery is still active */
603  if (newXactIsoLevel == XACT_SERIALIZABLE && RecoveryInProgress())
604  {
605  GUC_check_errcode(ERRCODE_FEATURE_NOT_SUPPORTED);
606  GUC_check_errmsg("cannot use serializable mode in a hot standby");
607  GUC_check_errhint("You can use REPEATABLE READ instead.");
608  return false;
609  }
610  }
611 
612  return true;
613 }
int XactIsoLevel
Definition: xact.c:79
#define XACT_SERIALIZABLE
Definition: xact.h:39
bool RecoveryInProgress(void)
Definition: xlog.c:5948

References FirstSnapshotSet, GUC_check_errcode(), GUC_check_errhint, GUC_check_errmsg, IsSubTransaction(), IsTransactionState(), newval, RecoveryInProgress(), XACT_SERIALIZABLE, and XactIsoLevel.

◆ check_transaction_read_only()

bool check_transaction_read_only ( bool newval,
void **  extra,
GucSource  source 
)

Definition at line 544 of file variable.c.

545 {
547  {
548  /* Can't go to r/w mode inside a r/o transaction */
549  if (IsSubTransaction())
550  {
551  GUC_check_errcode(ERRCODE_ACTIVE_SQL_TRANSACTION);
552  GUC_check_errmsg("cannot set transaction read-write mode inside a read-only transaction");
553  return false;
554  }
555  /* Top level transaction can't change to r/w after first snapshot. */
556  if (FirstSnapshotSet)
557  {
558  GUC_check_errcode(ERRCODE_ACTIVE_SQL_TRANSACTION);
559  GUC_check_errmsg("transaction read-write mode must be set before any query");
560  return false;
561  }
562  /* Can't go to r/w mode while recovery is still active */
563  if (RecoveryInProgress())
564  {
565  GUC_check_errcode(ERRCODE_FEATURE_NOT_SUPPORTED);
566  GUC_check_errmsg("cannot set transaction read-write mode during recovery");
567  return false;
568  }
569  }
570 
571  return true;
572 }
bool XactReadOnly
Definition: xact.c:82

References FirstSnapshotSet, GUC_check_errcode(), GUC_check_errmsg, InitializingParallelWorker, IsSubTransaction(), IsTransactionState(), newval, RecoveryInProgress(), and XactReadOnly.

◆ check_vacuum_buffer_usage_limit()

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

Definition at line 128 of file vacuum.c.

130 {
131  /* Value upper and lower hard limits are inclusive */
132  if (*newval == 0 || (*newval >= MIN_BAS_VAC_RING_SIZE_KB &&
134  return true;
135 
136  /* Value does not fall within any allowable range */
137  GUC_check_errdetail("\"vacuum_buffer_usage_limit\" must be 0 or between %d kB and %d kB",
139 
140  return false;
141 }
#define MIN_BAS_VAC_RING_SIZE_KB
Definition: miscadmin.h:271
#define MAX_BAS_VAC_RING_SIZE_KB
Definition: miscadmin.h:272

References GUC_check_errdetail, MAX_BAS_VAC_RING_SIZE_KB, MIN_BAS_VAC_RING_SIZE_KB, and newval.

◆ check_wal_buffers()

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

Definition at line 4279 of file xlog.c.

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

References newval, XLOGbuffers, and XLOGChooseNumBuffers().

◆ check_wal_consistency_checking()

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

Definition at line 4314 of file xlog.c.

4315 {
4316  char *rawstring;
4317  List *elemlist;
4318  ListCell *l;
4319  bool newwalconsistency[RM_MAX_ID + 1];
4320 
4321  /* Initialize the array */
4322  MemSet(newwalconsistency, 0, (RM_MAX_ID + 1) * sizeof(bool));
4323 
4324  /* Need a modifiable copy of string */
4325  rawstring = pstrdup(*newval);
4326 
4327  /* Parse string into list of identifiers */
4328  if (!SplitIdentifierString(rawstring, ',', &elemlist))
4329  {
4330  /* syntax error in list */
4331  GUC_check_errdetail("List syntax is invalid.");
4332  pfree(rawstring);
4333  list_free(elemlist);
4334  return false;
4335  }
4336 
4337  foreach(l, elemlist)
4338  {
4339  char *tok = (char *) lfirst(l);
4340  int rmid;
4341 
4342  /* Check for 'all'. */
4343  if (pg_strcasecmp(tok, "all") == 0)
4344  {
4345  for (rmid = 0; rmid <= RM_MAX_ID; rmid++)
4346  if (RmgrIdExists(rmid) && GetRmgr(rmid).rm_mask != NULL)
4347  newwalconsistency[rmid] = true;
4348  }
4349  else
4350  {
4351  /* Check if the token matches any known resource manager. */
4352  bool found = false;
4353 
4354  for (rmid = 0; rmid <= RM_MAX_ID; rmid++)
4355  {
4356  if (RmgrIdExists(rmid) && GetRmgr(rmid).rm_mask != NULL &&
4357  pg_strcasecmp(tok, GetRmgr(rmid).rm_name) == 0)
4358  {
4359  newwalconsistency[rmid] = true;
4360  found = true;
4361  break;
4362  }
4363  }
4364  if (!found)
4365  {
4366  /*
4367  * During startup, it might be a not-yet-loaded custom
4368  * resource manager. Defer checking until
4369  * InitializeWalConsistencyChecking().
4370  */
4372  {
4374  }
4375  else
4376  {
4377  GUC_check_errdetail("Unrecognized key word: \"%s\".", tok);
4378  pfree(rawstring);
4379  list_free(elemlist);
4380  return false;
4381  }
4382  }
4383  }
4384  }
4385 
4386  pfree(rawstring);
4387  list_free(elemlist);
4388 
4389  /* assign new value */
4390  *extra = guc_malloc(ERROR, (RM_MAX_ID + 1) * sizeof(bool));
4391  memcpy(*extra, newwalconsistency, (RM_MAX_ID + 1) * sizeof(bool));
4392  return true;
4393 }
#define MemSet(start, val, len)
Definition: c.h:1009
bool process_shared_preload_libraries_done
Definition: miscinit.c:1765
#define RM_MAX_ID
Definition: rmgr.h:33
void(* rm_mask)(char *pagedata, BlockNumber blkno)
static bool check_wal_consistency_checking_deferred
Definition: xlog.c:169
static RmgrData GetRmgr(RmgrId rmid)
static bool RmgrIdExists(RmgrId rmid)

References check_wal_consistency_checking_deferred, ERROR, GetRmgr(), GUC_check_errdetail, guc_malloc(), lfirst, list_free(), MemSet, newval, pfree(), pg_strcasecmp(), process_shared_preload_libraries_done, pstrdup(), RmgrData::rm_mask, RM_MAX_ID, RmgrIdExists(), and SplitIdentifierString().

◆ check_wal_segment_size()

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

Definition at line 1999 of file xlog.c.

2000 {
2001  if (!IsValidWalSegSize(*newval))
2002  {
2003  GUC_check_errdetail("The WAL segment size must be a power of two between 1 MB and 1 GB.");
2004  return false;
2005  }
2006 
2007  return true;
2008 }
#define IsValidWalSegSize(size)
Definition: xlog_internal.h:96

References GUC_check_errdetail, IsValidWalSegSize, and newval.

◆ show_archive_command()

const char* show_archive_command ( void  )

Definition at line 4452 of file xlog.c.

4453 {
4454  if (XLogArchivingActive())
4455  return XLogArchiveCommand;
4456  else
4457  return "(disabled)";
4458 }
char * XLogArchiveCommand
Definition: xlog.c:123
#define XLogArchivingActive()
Definition: xlog.h:94

References XLogArchiveCommand, and XLogArchivingActive.

◆ show_data_directory_mode()

const char* show_data_directory_mode ( void  )

Definition at line 1133 of file variable.c.

1134 {
1135  static char buf[12];
1136 
1137  snprintf(buf, sizeof(buf), "%04o", data_directory_mode);
1138  return buf;
1139 }
int data_directory_mode
Definition: globals.c:72
#define snprintf
Definition: port.h:238

References buf, data_directory_mode, and snprintf.

◆ show_in_hot_standby()

const char* show_in_hot_standby ( void  )

Definition at line 4464 of file xlog.c.

4465 {
4466  /*
4467  * We display the actual state based on shared memory, so that this GUC
4468  * reports up-to-date state if examined intra-query. The underlying
4469  * variable (in_hot_standby_guc) changes only when we transmit a new value
4470  * to the client.
4471  */
4472  return RecoveryInProgress() ? "on" : "off";
4473 }

References RecoveryInProgress().

◆ show_log_file_mode()

const char* show_log_file_mode ( void  )

Definition at line 1145 of file variable.c.

1146 {
1147  static char buf[12];
1148 
1149  snprintf(buf, sizeof(buf), "%04o", Log_file_mode);
1150  return buf;
1151 }
int Log_file_mode
Definition: syslogger.c:77

References buf, Log_file_mode, and snprintf.

◆ show_log_timezone()

const char* show_log_timezone ( void  )

Definition at line 463 of file variable.c.

464 {
465  const char *tzn;
466 
467  /* Always show the zone's canonical name */
469 
470  if (tzn != NULL)
471  return tzn;
472 
473  return "unknown";
474 }
const char * pg_get_timezone_name(pg_tz *tz)
Definition: localtime.c:1875

References log_timezone, and pg_get_timezone_name().

◆ show_random_seed()

const char* show_random_seed ( void  )

Definition at line 669 of file variable.c.

670 {
671  return "unavailable";
672 }

◆ show_role()

const char* show_role ( void  )

Definition at line 1003 of file variable.c.

1004 {
1005  /*
1006  * Check whether SET ROLE is active; if not return "none". This is a
1007  * kluge to deal with the fact that SET SESSION AUTHORIZATION logically
1008  * resets SET ROLE to NONE, but we cannot set the GUC role variable from
1009  * assign_session_authorization (because we haven't got enough info to
1010  * call set_config_option).
1011  */
1012  if (!OidIsValid(GetCurrentRoleId()))
1013  return "none";
1014 
1015  /* Otherwise we can just use the GUC string */
1016  return role_string ? role_string : "none";
1017 }
char * role_string
Definition: guc_tables.c:615
Oid GetCurrentRoleId(void)
Definition: miscinit.c:910

References GetCurrentRoleId(), OidIsValid, and role_string.

◆ show_tcp_keepalives_count()

const char* show_tcp_keepalives_count ( void  )

Definition at line 1997 of file pqcomm.c.

1998 {
1999  /* See comments in assign_tcp_keepalives_idle */
2000  static char nbuf[16];
2001 
2002  snprintf(nbuf, sizeof(nbuf), "%d", pq_getkeepalivescount(MyProcPort));
2003  return nbuf;
2004 }
int pq_getkeepalivescount(Port *port)
Definition: pqcomm.c:1778

References MyProcPort, pq_getkeepalivescount(), and snprintf.

◆ show_tcp_keepalives_idle()

const char* show_tcp_keepalives_idle ( void  )

Definition at line 1951 of file pqcomm.c.

1952 {
1953  /* See comments in assign_tcp_keepalives_idle */
1954  static char nbuf[16];
1955 
1956  snprintf(nbuf, sizeof(nbuf), "%d", pq_getkeepalivesidle(MyProcPort));
1957  return nbuf;
1958 }
int pq_getkeepalivesidle(Port *port)
Definition: pqcomm.c:1609

References MyProcPort, pq_getkeepalivesidle(), and snprintf.

◆ show_tcp_keepalives_interval()

const char* show_tcp_keepalives_interval ( void  )

Definition at line 1974 of file pqcomm.c.

1975 {
1976  /* See comments in assign_tcp_keepalives_idle */
1977  static char nbuf[16];
1978 
1979  snprintf(nbuf, sizeof(nbuf), "%d", pq_getkeepalivesinterval(MyProcPort));
1980  return nbuf;
1981 }
int pq_getkeepalivesinterval(Port *port)
Definition: pqcomm.c:1694

References MyProcPort, pq_getkeepalivesinterval(), and snprintf.

◆ show_tcp_user_timeout()

const char* show_tcp_user_timeout ( void  )

Definition at line 2020 of file pqcomm.c.

2021 {
2022  /* See comments in assign_tcp_keepalives_idle */
2023  static char nbuf[16];
2024 
2025  snprintf(nbuf, sizeof(nbuf), "%d", pq_gettcpusertimeout(MyProcPort));
2026  return nbuf;
2027 }
int pq_gettcpusertimeout(Port *port)
Definition: pqcomm.c:1853

References MyProcPort, pq_gettcpusertimeout(), and snprintf.

◆ show_timezone()

const char* show_timezone ( void  )

Definition at line 390 of file variable.c.

391 {
392  const char *tzn;
393 
394  /* Always show the zone's canonical name */
396 
397  if (tzn != NULL)
398  return tzn;
399 
400  return "unknown";
401 }

References pg_get_timezone_name(), and session_timezone.

◆ show_unix_socket_permissions()

const char* show_unix_socket_permissions ( void  )

Definition at line 1157 of file variable.c.

1158 {
1159  static char buf[12];
1160 
1161  snprintf(buf, sizeof(buf), "%04o", Unix_socket_permissions);
1162  return buf;
1163 }
int Unix_socket_permissions
Definition: pqcomm.c:106

References buf, snprintf, and Unix_socket_permissions.