guc.c
来自「postgresql8.3.4源码,开源数据库」· C语言 代码 · 共 2,400 行 · 第 1/5 页
C
2,400 行
/*-------------------------------------------------------------------- * guc.c * * Support for grand unified configuration scheme, including SET * command, configuration file, and command line options. * See src/backend/utils/misc/README for more information. * * * Copyright (c) 2000-2008, PostgreSQL Global Development Group * Written by Peter Eisentraut <peter_e@gmx.net>. * * IDENTIFICATION * $PostgreSQL: pgsql/src/backend/utils/misc/guc.c,v 1.432.2.2 2008/07/06 19:48:53 tgl Exp $ * *-------------------------------------------------------------------- */#include "postgres.h"#include <ctype.h>#include <float.h>#include <limits.h>#include <unistd.h>#include <sys/stat.h>#ifdef HAVE_SYSLOG#include <syslog.h>#endif#include "access/gin.h"#include "access/transam.h"#include "access/twophase.h"#include "access/xact.h"#include "catalog/namespace.h"#include "commands/async.h"#include "commands/prepare.h"#include "commands/vacuum.h"#include "commands/variable.h"#include "commands/trigger.h"#include "funcapi.h"#include "libpq/auth.h"#include "libpq/pqformat.h"#include "miscadmin.h"#include "optimizer/cost.h"#include "optimizer/geqo.h"#include "optimizer/paths.h"#include "optimizer/planmain.h"#include "parser/gramparse.h"#include "parser/parse_expr.h"#include "parser/parse_relation.h"#include "parser/parse_type.h"#include "parser/scansup.h"#include "pgstat.h"#include "postmaster/autovacuum.h"#include "postmaster/bgwriter.h"#include "postmaster/postmaster.h"#include "postmaster/syslogger.h"#include "postmaster/walwriter.h"#include "storage/fd.h"#include "storage/freespace.h"#include "tcop/tcopprot.h"#include "tsearch/ts_cache.h"#include "utils/builtins.h"#include "utils/guc_tables.h"#include "utils/memutils.h"#include "utils/pg_locale.h"#include "utils/plancache.h"#include "utils/portal.h"#include "utils/ps_status.h"#include "utils/tzparser.h"#include "utils/xml.h"#ifndef PG_KRB_SRVTAB#define PG_KRB_SRVTAB ""#endif#ifndef PG_KRB_SRVNAM#define PG_KRB_SRVNAM ""#endif#define CONFIG_FILENAME "postgresql.conf"#define HBA_FILENAME "pg_hba.conf"#define IDENT_FILENAME "pg_ident.conf"#ifdef EXEC_BACKEND#define CONFIG_EXEC_PARAMS "global/config_exec_params"#define CONFIG_EXEC_PARAMS_NEW "global/config_exec_params.new"#endif/* upper limit for GUC variables measured in kilobytes of memory */#if SIZEOF_SIZE_T > 4#define MAX_KILOBYTES INT_MAX#else#define MAX_KILOBYTES (INT_MAX / 1024)#endif#define KB_PER_MB (1024)#define KB_PER_GB (1024*1024)#define MS_PER_S 1000#define S_PER_MIN 60#define MS_PER_MIN (1000 * 60)#define MIN_PER_H 60#define S_PER_H (60 * 60)#define MS_PER_H (1000 * 60 * 60)#define MIN_PER_D (60 * 24)#define S_PER_D (60 * 60 * 24)#define MS_PER_D (1000 * 60 * 60 * 24)/* XXX these should appear in other modules' header files */extern bool Log_disconnections;extern int CommitDelay;extern int CommitSiblings;extern char *default_tablespace;extern char *temp_tablespaces;extern bool synchronize_seqscans;extern bool fullPageWrites;#ifdef TRACE_SORTextern bool trace_sort;#endif#ifdef TRACE_SYNCSCANextern bool trace_syncscan;#endif#ifdef DEBUG_BOUNDED_SORTextern bool optimize_bounded_sort;#endif#ifdef USE_SSLextern char *SSLCipherSuites;#endifstatic const char *assign_log_destination(const char *value, bool doit, GucSource source);#ifdef HAVE_SYSLOGstatic int syslog_facility = LOG_LOCAL0;static const char *assign_syslog_facility(const char *facility, bool doit, GucSource source);static const char *assign_syslog_ident(const char *ident, bool doit, GucSource source);#endifstatic const char *assign_defaultxactisolevel(const char *newval, bool doit, GucSource source);static const char *assign_session_replication_role(const char *newval, bool doit, GucSource source);static const char *assign_log_min_messages(const char *newval, bool doit, GucSource source);static const char *assign_client_min_messages(const char *newval, bool doit, GucSource source);static const char *assign_min_error_statement(const char *newval, bool doit, GucSource source);static const char *assign_msglvl(int *var, const char *newval, bool doit, GucSource source);static const char *assign_log_error_verbosity(const char *newval, bool doit, GucSource source);static const char *assign_log_statement(const char *newval, bool doit, GucSource source);static const char *show_num_temp_buffers(void);static bool assign_phony_autocommit(bool newval, bool doit, GucSource source);static const char *assign_custom_variable_classes(const char *newval, bool doit, GucSource source);static bool assign_debug_assertions(bool newval, bool doit, GucSource source);static bool assign_ssl(bool newval, bool doit, GucSource source);static bool assign_stage_log_stats(bool newval, bool doit, GucSource source);static bool assign_log_stats(bool newval, bool doit, GucSource source);static bool assign_transaction_read_only(bool newval, bool doit, GucSource source);static const char *assign_canonical_path(const char *newval, bool doit, GucSource source);static const char *assign_backslash_quote(const char *newval, bool doit, GucSource source);static const char *assign_timezone_abbreviations(const char *newval, bool doit, GucSource source);static const char *assign_xmlbinary(const char *newval, bool doit, GucSource source);static const char *assign_xmloption(const char *newval, bool doit, GucSource source);static const char *show_archive_command(void);static bool assign_tcp_keepalives_idle(int newval, bool doit, GucSource source);static bool assign_tcp_keepalives_interval(int newval, bool doit, GucSource source);static bool assign_tcp_keepalives_count(int newval, bool doit, GucSource source);static const char *show_tcp_keepalives_idle(void);static const char *show_tcp_keepalives_interval(void);static const char *show_tcp_keepalives_count(void);static bool assign_autovacuum_max_workers(int newval, bool doit, GucSource source);static bool assign_maxconnections(int newval, bool doit, GucSource source);/* * GUC option variables that are exported from this module */#ifdef USE_ASSERT_CHECKINGbool assert_enabled = true;#elsebool assert_enabled = false;#endifbool log_duration = false;bool Debug_print_plan = false;bool Debug_print_parse = false;bool Debug_print_rewritten = false;bool Debug_pretty_print = false;bool Explain_pretty_print = true;bool log_parser_stats = false;bool log_planner_stats = false;bool log_executor_stats = false;bool log_statement_stats = false; /* this is sort of all three * above together */bool log_btree_build_stats = false;bool check_function_bodies = true;bool default_with_oids = false;bool SQL_inheritance = true;bool Password_encryption = true;int log_min_error_statement = ERROR;int log_min_messages = NOTICE;int client_min_messages = NOTICE;int log_min_duration_statement = -1;int log_temp_files = -1;int num_temp_buffers = 1000;char *ConfigFileName;char *HbaFileName;char *IdentFileName;char *external_pid_file;int tcp_keepalives_idle;int tcp_keepalives_interval;int tcp_keepalives_count;/* * These variables are all dummies that don't do anything, except in some * cases provide the value for SHOW to display. The real state is elsewhere * and is kept in sync by assign_hooks. */static char *client_min_messages_str;static char *log_min_messages_str;static char *log_error_verbosity_str;static char *log_statement_str;static char *log_min_error_statement_str;static char *log_destination_string;#ifdef HAVE_SYSLOGstatic char *syslog_facility_str;static char *syslog_ident_str;#endifstatic bool phony_autocommit;static bool session_auth_is_superuser;static double phony_random_seed;static char *backslash_quote_string;static char *client_encoding_string;static char *datestyle_string;static char *default_iso_level_string;static char *session_replication_role_string;static char *locale_collate;static char *locale_ctype;static char *regex_flavor_string;static char *server_encoding_string;static char *server_version_string;static int server_version_num;static char *timezone_string;static char *log_timezone_string;static char *timezone_abbreviations_string;static char *XactIsoLevel_string;static char *data_directory;static char *custom_variable_classes;static char *xmlbinary_string;static char *xmloption_string;static int max_function_args;static int max_index_keys;static int max_identifier_length;static int block_size;static bool integer_datetimes;/* should be static, but commands/variable.c needs to get at these */char *role_string;char *session_authorization_string;/* * Displayable names for context types (enum GucContext) * * Note: these strings are deliberately not localized. */const char *const GucContext_Names[] ={ /* PGC_INTERNAL */ "internal", /* PGC_POSTMASTER */ "postmaster", /* PGC_SIGHUP */ "sighup", /* PGC_BACKEND */ "backend", /* PGC_SUSET */ "superuser", /* PGC_USERSET */ "user"};/* * Displayable names for source types (enum GucSource) * * Note: these strings are deliberately not localized. */const char *const GucSource_Names[] ={ /* PGC_S_DEFAULT */ "default", /* PGC_S_ENV_VAR */ "environment variable", /* PGC_S_FILE */ "configuration file", /* PGC_S_ARGV */ "command line", /* PGC_S_DATABASE */ "database", /* PGC_S_USER */ "user", /* PGC_S_CLIENT */ "client", /* PGC_S_OVERRIDE */ "override", /* PGC_S_INTERACTIVE */ "interactive", /* PGC_S_TEST */ "test", /* PGC_S_SESSION */ "session"};/* * Displayable names for the groupings defined in enum config_group */const char *const config_group_names[] ={ /* UNGROUPED */ gettext_noop("Ungrouped"), /* FILE_LOCATIONS */ gettext_noop("File Locations"), /* CONN_AUTH */ gettext_noop("Connections and Authentication"), /* CONN_AUTH_SETTINGS */ gettext_noop("Connections and Authentication / Connection Settings"), /* CONN_AUTH_SECURITY */ gettext_noop("Connections and Authentication / Security and Authentication"), /* RESOURCES */ gettext_noop("Resource Usage"), /* RESOURCES_MEM */ gettext_noop("Resource Usage / Memory"), /* RESOURCES_FSM */ gettext_noop("Resource Usage / Free Space Map"), /* RESOURCES_KERNEL */ gettext_noop("Resource Usage / Kernel Resources"), /* WAL */ gettext_noop("Write-Ahead Log"), /* WAL_SETTINGS */ gettext_noop("Write-Ahead Log / Settings"), /* WAL_CHECKPOINTS */ gettext_noop("Write-Ahead Log / Checkpoints"), /* QUERY_TUNING */ gettext_noop("Query Tuning"), /* QUERY_TUNING_METHOD */ gettext_noop("Query Tuning / Planner Method Configuration"), /* QUERY_TUNING_COST */ gettext_noop("Query Tuning / Planner Cost Constants"), /* QUERY_TUNING_GEQO */ gettext_noop("Query Tuning / Genetic Query Optimizer"), /* QUERY_TUNING_OTHER */ gettext_noop("Query Tuning / Other Planner Options"), /* LOGGING */ gettext_noop("Reporting and Logging"), /* LOGGING_WHERE */ gettext_noop("Reporting and Logging / Where to Log"), /* LOGGING_WHEN */ gettext_noop("Reporting and Logging / When to Log"), /* LOGGING_WHAT */ gettext_noop("Reporting and Logging / What to Log"), /* STATS */ gettext_noop("Statistics"), /* STATS_MONITORING */ gettext_noop("Statistics / Monitoring"), /* STATS_COLLECTOR */ gettext_noop("Statistics / Query and Index Statistics Collector"), /* AUTOVACUUM */ gettext_noop("Autovacuum"), /* CLIENT_CONN */ gettext_noop("Client Connection Defaults"), /* CLIENT_CONN_STATEMENT */ gettext_noop("Client Connection Defaults / Statement Behavior"), /* CLIENT_CONN_LOCALE */ gettext_noop("Client Connection Defaults / Locale and Formatting"), /* CLIENT_CONN_OTHER */ gettext_noop("Client Connection Defaults / Other Defaults"), /* LOCK_MANAGEMENT */ gettext_noop("Lock Management"), /* COMPAT_OPTIONS */ gettext_noop("Version and Platform Compatibility"), /* COMPAT_OPTIONS_PREVIOUS */ gettext_noop("Version and Platform Compatibility / Previous PostgreSQL Versions"), /* COMPAT_OPTIONS_CLIENT */ gettext_noop("Version and Platform Compatibility / Other Platforms and Clients"), /* PRESET_OPTIONS */ gettext_noop("Preset Options"), /* CUSTOM_OPTIONS */ gettext_noop("Customized Options"), /* DEVELOPER_OPTIONS */ gettext_noop("Developer Options"), /* help_config wants this array to be null-terminated */ NULL};/* * Displayable names for GUC variable types (enum config_type) * * Note: these strings are deliberately not localized. */const char *const config_type_names[] ={ /* PGC_BOOL */ "bool", /* PGC_INT */ "integer", /* PGC_REAL */ "real", /* PGC_STRING */ "string"};/* * Contents of GUC tables * * See src/backend/utils/misc/README for design notes. * * TO ADD AN OPTION: * * 1. Declare a global variable of type bool, int, double, or char* * and make use of it. * * 2. Decide at what times it's safe to set the option. See guc.h for * details. * * 3. Decide on a name, a default value, upper and lower bounds (if * applicable), etc. * * 4. Add a record below. * * 5. Add it to src/backend/utils/misc/postgresql.conf.sample, if * appropriate. * * 6. Don't forget to document the option (at least in config.sgml). * * 7. If it's a new GUC_LIST option you must edit pg_dumpall.c to ensure * it is not single quoted at dump time. *//******** option records follow ********/static struct config_bool ConfigureNamesBool[] ={ { {"enable_seqscan", PGC_USERSET, QUERY_TUNING_METHOD, gettext_noop("Enables the planner's use of sequential-scan plans."), NULL }, &enable_seqscan, true, NULL, NULL }, { {"enable_indexscan", PGC_USERSET, QUERY_TUNING_METHOD, gettext_noop("Enables the planner's use of index-scan plans."), NULL }, &enable_indexscan, true, NULL, NULL }, { {"enable_bitmapscan", PGC_USERSET, QUERY_TUNING_METHOD, gettext_noop("Enables the planner's use of bitmap-scan plans."), NULL }, &enable_bitmapscan, true, NULL, NULL }, { {"enable_tidscan", PGC_USERSET, QUERY_TUNING_METHOD, gettext_noop("Enables the planner's use of TID scan plans."), NULL }, &enable_tidscan, true, NULL, NULL }, { {"enable_sort", PGC_USERSET, QUERY_TUNING_METHOD, gettext_noop("Enables the planner's use of explicit sort steps."), NULL }, &enable_sort, true, NULL, NULL }, { {"enable_hashagg", PGC_USERSET, QUERY_TUNING_METHOD,
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?