guc.c
来自「PostgreSQL7.4.6 for Linux」· C语言 代码 · 共 2,468 行 · 第 1/5 页
C
2,468 行
/*-------------------------------------------------------------------- * 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-2003, PostgreSQL Global Development Group * Written by Peter Eisentraut <peter_e@gmx.net>. * * IDENTIFICATION * $Header: /cvsroot/pgsql/src/backend/utils/misc/guc.c,v 1.164.2.3 2004/08/11 21:10:52 tgl Exp $ * *-------------------------------------------------------------------- */#include "postgres.h"#include <errno.h>#include <float.h>#include <limits.h>#include <unistd.h>#include "utils/guc.h"#include "utils/guc_tables.h"#include "access/xlog.h"#include "catalog/namespace.h"#include "catalog/pg_type.h"#include "commands/async.h"#include "commands/variable.h"#include "commands/vacuum.h"#include "executor/executor.h"#include "fmgr.h"#include "funcapi.h"#include "libpq/auth.h"#include "libpq/pqcomm.h"#include "libpq/pqformat.h"#include "mb/pg_wchar.h"#include "miscadmin.h"#include "optimizer/cost.h"#include "optimizer/geqo.h"#include "optimizer/paths.h"#include "optimizer/prep.h"#include "parser/parse_expr.h"#include "parser/parse_relation.h"#include "storage/fd.h"#include "storage/freespace.h"#include "storage/lock.h"#include "storage/proc.h"#include "tcop/tcopprot.h"#include "utils/array.h"#include "utils/builtins.h"#include "utils/datetime.h"#include "utils/pg_locale.h"#include "pgstat.h"#ifndef PG_KRB_SRVTAB#define PG_KRB_SRVTAB ""#endif#ifdef EXEC_BACKEND#define CONFIG_EXEC_PARAMS "global/config_exec_params"#endif/* XXX these should appear in other modules' header files */extern bool Log_connections;extern bool check_function_bodies;extern int PreAuthDelay;extern int AuthenticationTimeout;extern int CheckPointTimeout;extern int CommitDelay;extern int CommitSiblings;extern char *preload_libraries_string;#ifdef HAVE_SYSLOGextern char *Syslog_facility;extern char *Syslog_ident;static const char *assign_facility(const char *facility, bool doit, bool interactive);#endifstatic const char *assign_defaultxactisolevel(const char *newval, bool doit, bool interactive);static const char *assign_log_min_messages(const char *newval, bool doit, bool interactive);static const char *assign_client_min_messages(const char *newval, bool doit, bool interactive);static const char *assign_min_error_statement(const char *newval, bool doit, bool interactive);static const char *assign_msglvl(int *var, const char *newval, bool doit, bool interactive);static const char *assign_log_error_verbosity(const char *newval, bool doit, bool interactive);static bool assign_phony_autocommit(bool newval, bool doit, bool interactive);/* * Debugging options */#ifdef USE_ASSERT_CHECKINGbool assert_enabled = true;#endifbool log_statement = false;bool 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 SQL_inheritance = true;bool Australian_timezones = false;bool Password_encryption = true;int log_min_error_statement = PANIC;int log_min_messages = NOTICE;int client_min_messages = NOTICE;int log_min_duration_statement = -1;/* * 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_min_error_statement_str;static bool phony_autocommit;static bool session_auth_is_superuser;static double phony_random_seed;static char *client_encoding_string;static char *datestyle_string;static char *default_iso_level_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 char *timezone_string;static char *XactIsoLevel_string;/* should be static, but commands/variable.c needs to get at it */char *session_authorization_string;/* Macros for freeing malloc'd pointers only if appropriate to do so *//* Some of these tests are probably redundant, but be safe ... */#define SET_STRING_VARIABLE(rec, newval) \ do { \ if (*(rec)->variable && \ *(rec)->variable != (rec)->reset_val && \ *(rec)->variable != (rec)->session_val && \ *(rec)->variable != (rec)->tentative_val) \ free(*(rec)->variable); \ *(rec)->variable = (newval); \ } while (0)#define SET_STRING_RESET_VAL(rec, newval) \ do { \ if ((rec)->reset_val && \ (rec)->reset_val != *(rec)->variable && \ (rec)->reset_val != (rec)->session_val && \ (rec)->reset_val != (rec)->tentative_val) \ free((rec)->reset_val); \ (rec)->reset_val = (newval); \ } while (0)#define SET_STRING_SESSION_VAL(rec, newval) \ do { \ if ((rec)->session_val && \ (rec)->session_val != *(rec)->variable && \ (rec)->session_val != (rec)->reset_val && \ (rec)->session_val != (rec)->tentative_val) \ free((rec)->session_val); \ (rec)->session_val = (newval); \ } while (0)#define SET_STRING_TENTATIVE_VAL(rec, newval) \ do { \ if ((rec)->tentative_val && \ (rec)->tentative_val != *(rec)->variable && \ (rec)->tentative_val != (rec)->reset_val && \ (rec)->tentative_val != (rec)->session_val) \ free((rec)->tentative_val); \ (rec)->tentative_val = (newval); \ } while (0)/* * 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_USERLIMIT */ "userlimit", /* 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_UNPRIVILEGED */ "unprivileged", /* PGC_S_DATABASE */ "database", /* PGC_S_USER */ "user", /* PGC_S_CLIENT */ "client", /* PGC_S_OVERRIDE */ "override", /* PGC_S_SESSION */ "session"};/* * Displayable names for the groupings defined in enum config_group */const char *const config_group_names[] ={ /* UNGROUPED */ gettext_noop("Ungrouped"), /* 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 Enabling"), /* 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_SYSLOG */ gettext_noop("Reporting and Logging / Syslog"), /* 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"), /* 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"), /* 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. * * 6. Add it to src/bin/psql/tab-complete.c, if it's a USERSET option. * * 7. Don't forget to document the option. *//******** 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_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, gettext_noop("Enables the planner's use of hashed aggregation plans."), NULL }, &enable_hashagg, true, NULL, NULL }, { {"enable_nestloop", PGC_USERSET, QUERY_TUNING_METHOD, gettext_noop("Enables the planner's use of nested-loop join plans."), NULL }, &enable_nestloop, true, NULL, NULL }, { {"enable_mergejoin", PGC_USERSET, QUERY_TUNING_METHOD, gettext_noop("Enables the planner's use of merge join plans."), NULL }, &enable_mergejoin, true, NULL, NULL }, { {"enable_hashjoin", PGC_USERSET, QUERY_TUNING_METHOD, gettext_noop("Enables the planner's use of hash join plans."), NULL }, &enable_hashjoin, true, NULL, NULL }, { {"geqo", PGC_USERSET, QUERY_TUNING_GEQO, gettext_noop("Enables genetic query optimization."), gettext_noop("This algorithm attempts to do planning without " "exhaustive searching.") }, &enable_geqo, true, NULL, NULL }, { /* Not for general use --- used by SET SESSION AUTHORIZATION */ {"is_superuser", PGC_INTERNAL, UNGROUPED, gettext_noop("Shows whether the current user is a superuser."), NULL, GUC_REPORT | GUC_NO_SHOW_ALL | GUC_NO_RESET_ALL | GUC_NOT_IN_SAMPLE | GUC_DISALLOW_IN_FILE }, &session_auth_is_superuser, false, NULL, NULL }, { {"tcpip_socket", PGC_POSTMASTER, CONN_AUTH_SETTINGS, gettext_noop("Makes the server accept TCP/IP connections."), NULL }, &NetServer, false, NULL, NULL }, { {"ssl", PGC_POSTMASTER, CONN_AUTH_SECURITY, gettext_noop("Enables SSL connections."), NULL }, &EnableSSL, false, NULL, NULL }, { {"fsync", PGC_SIGHUP, WAL_SETTINGS, gettext_noop("Forces synchronization of updates to disk."), gettext_noop("The server will use the fsync() system call in several places to make " "sure that updates are physically written to disk. This insures " "that a database cluster will recover to a consistent state after " "an operating system or hardware crash.") }, &enableFsync, true, NULL, NULL }, { {"zero_damaged_pages", PGC_SUSET, DEVELOPER_OPTIONS, gettext_noop("Continues processing past damaged page headers."), gettext_noop("Detection of a damaged page header normally causes PostgreSQL to " "report an error, aborting the current transaction. Setting " "zero_damaged_pages to true causes the system to instead report a " "warning, zero out the damaged page, and continue processing. This " "behavior will destroy data, namely all the rows on the damaged page."), GUC_NOT_IN_SAMPLE }, &zero_damaged_pages, false, NULL, NULL }, { {"silent_mode", PGC_POSTMASTER, LOGGING_WHEN, gettext_noop("Runs the server silently."), gettext_noop("If this parameter is set, the server will automatically run in the " "background and any controlling terminals are dissociated.") }, &SilentMode, false, NULL, NULL }, { {"log_connections", PGC_BACKEND, LOGGING_WHAT, gettext_noop("Logs each successful connection."), NULL }, &Log_connections, false, NULL, NULL }, { {"log_timestamp", PGC_SIGHUP, LOGGING_WHAT, gettext_noop("Prefixes server log messages with a time stamp."),
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?