diff options
Diffstat (limited to 'src/backend/commands/variable.c')
-rw-r--r-- | src/backend/commands/variable.c | 271 |
1 files changed, 269 insertions, 2 deletions
diff --git a/src/backend/commands/variable.c b/src/backend/commands/variable.c index e5ddcda0b4a..c795cb7a29c 100644 --- a/src/backend/commands/variable.c +++ b/src/backend/commands/variable.c @@ -22,15 +22,23 @@ #include "access/parallel.h" #include "access/xact.h" #include "access/xlog.h" +#include "access/xlogprefetcher.h" #include "catalog/pg_authid.h" -#include "commands/variable.h" +#include "common/string.h" #include "mb/pg_wchar.h" #include "miscadmin.h" +#include "postmaster/postmaster.h" +#include "postmaster/syslogger.h" +#include "storage/bufmgr.h" #include "utils/acl.h" +#include "utils/backend_status.h" #include "utils/builtins.h" +#include "utils/datetime.h" +#include "utils/guc_hooks.h" #include "utils/snapmgr.h" #include "utils/syscache.h" #include "utils/timestamp.h" +#include "utils/tzparser.h" #include "utils/varlena.h" /* @@ -467,6 +475,56 @@ show_log_timezone(void) /* + * TIMEZONE_ABBREVIATIONS + */ + +/* + * GUC check_hook for assign_timezone_abbreviations + */ +bool +check_timezone_abbreviations(char **newval, void **extra, GucSource source) +{ + /* + * The boot_val for timezone_abbreviations is NULL. When we see that we + * just do nothing. If the value isn't overridden from the config file + * then pg_timezone_abbrev_initialize() will eventually replace it with + * "Default". This hack has two purposes: to avoid wasting cycles loading + * values that might soon be overridden from the config file, and to avoid + * trying to read the timezone abbrev files during InitializeGUCOptions(). + * The latter doesn't work in an EXEC_BACKEND subprocess because + * my_exec_path hasn't been set yet and so we can't locate PGSHAREDIR. + */ + if (*newval == NULL) + { + Assert(source == PGC_S_DEFAULT); + return true; + } + + /* OK, load the file and produce a malloc'd TimeZoneAbbrevTable */ + *extra = load_tzoffsets(*newval); + + /* tzparser.c returns NULL on failure, reporting via GUC_check_errmsg */ + if (!*extra) + return false; + + return true; +} + +/* + * GUC assign_hook for assign_timezone_abbreviations + */ +void +assign_timezone_abbreviations(const char *newval, void *extra) +{ + /* Do nothing for the boot_val default of NULL */ + if (!extra) + return; + + InstallTimeZoneAbbrevs((TimeZoneAbbrevTable *) extra); +} + + +/* * SET TRANSACTION READ ONLY and SET TRANSACTION READ WRITE * * We allow idempotent changes (r/w -> r/w and r/o -> r/o) at any time, and @@ -522,7 +580,7 @@ check_transaction_read_only(bool *newval, void **extra, GucSource source) * As in check_transaction_read_only, allow it if not inside a transaction. */ bool -check_XactIsoLevel(int *newval, void **extra, GucSource source) +check_transaction_isolation(int *newval, void **extra, GucSource source) { int newXactIsoLevel = *newval; @@ -933,3 +991,212 @@ show_role(void) /* Otherwise we can just use the GUC string */ return role_string ? role_string : "none"; } + + +/* + * PATH VARIABLES + * + * check_canonical_path is used for log_directory and some other GUCs where + * all we want to do is canonicalize the represented path name. + */ + +bool +check_canonical_path(char **newval, void **extra, GucSource source) +{ + /* + * Since canonicalize_path never enlarges the string, we can just modify + * newval in-place. But watch out for NULL, which is the default value + * for external_pid_file. + */ + if (*newval) + canonicalize_path(*newval); + return true; +} + + +/* + * MISCELLANEOUS + */ + +/* + * GUC check_hook for application_name + */ +bool +check_application_name(char **newval, void **extra, GucSource source) +{ + char *clean; + + /* Only allow clean ASCII chars in the application name */ + clean = pg_clean_ascii(*newval, MCXT_ALLOC_NO_OOM); + if (!clean) + return false; + + clean = guc_strdup(WARNING, clean); + if (!clean) + return false; + + *newval = clean; + return true; +} + +/* + * GUC assign_hook for application_name + */ +void +assign_application_name(const char *newval, void *extra) +{ + /* Update the pg_stat_activity view */ + pgstat_report_appname(newval); +} + +/* + * GUC check_hook for cluster_name + */ +bool +check_cluster_name(char **newval, void **extra, GucSource source) +{ + char *clean; + + /* Only allow clean ASCII chars in the cluster name */ + clean = pg_clean_ascii(*newval, MCXT_ALLOC_NO_OOM); + if (!clean) + return false; + + clean = guc_strdup(WARNING, clean); + if (!clean) + return false; + + *newval = clean; + return true; +} + +/* + * GUC assign_hook for maintenance_io_concurrency + */ +void +assign_maintenance_io_concurrency(int newval, void *extra) +{ +#ifdef USE_PREFETCH + /* + * Reconfigure recovery prefetching, because a setting it depends on + * changed. + */ + maintenance_io_concurrency = newval; + if (AmStartupProcess()) + XLogPrefetchReconfigure(); +#endif +} + + +/* + * These show hooks just exist because we want to show the values in octal. + */ + +/* + * GUC show_hook for data_directory_mode + */ +const char * +show_data_directory_mode(void) +{ + static char buf[12]; + + snprintf(buf, sizeof(buf), "%04o", data_directory_mode); + return buf; +} + +/* + * GUC show_hook for log_file_mode + */ +const char * +show_log_file_mode(void) +{ + static char buf[12]; + + snprintf(buf, sizeof(buf), "%04o", Log_file_mode); + return buf; +} + +/* + * GUC show_hook for unix_socket_permissions + */ +const char * +show_unix_socket_permissions(void) +{ + static char buf[12]; + + snprintf(buf, sizeof(buf), "%04o", Unix_socket_permissions); + return buf; +} + + +/* + * These check hooks do nothing more than reject non-default settings + * in builds that don't support them. + */ + +bool +check_bonjour(bool *newval, void **extra, GucSource source) +{ +#ifndef USE_BONJOUR + if (*newval) + { + GUC_check_errmsg("Bonjour is not supported by this build"); + return false; + } +#endif + return true; +} + +bool +check_default_with_oids(bool *newval, void **extra, GucSource source) +{ + if (*newval) + { + /* check the GUC's definition for an explanation */ + GUC_check_errcode(ERRCODE_FEATURE_NOT_SUPPORTED); + GUC_check_errmsg("tables declared WITH OIDS are not supported"); + + return false; + } + + return true; +} + +bool +check_effective_io_concurrency(int *newval, void **extra, GucSource source) +{ +#ifndef USE_PREFETCH + if (*newval != 0) + { + GUC_check_errdetail("effective_io_concurrency must be set to 0 on platforms that lack posix_fadvise()."); + return false; + } +#endif /* USE_PREFETCH */ + return true; +} + +bool +check_maintenance_io_concurrency(int *newval, void **extra, GucSource source) +{ +#ifndef USE_PREFETCH + if (*newval != 0) + { + GUC_check_errdetail("maintenance_io_concurrency must be set to 0 on platforms that lack posix_fadvise()."); + return false; + } +#endif /* USE_PREFETCH */ + return true; +} + +bool +check_ssl(bool *newval, void **extra, GucSource source) +{ +#ifndef USE_SSL + if (*newval) + { + GUC_check_errmsg("SSL is not supported by this build"); + return false; + } +#endif + return true; +} |