|
|
|
/*-------------------------------------------------------------------------
|
|
|
|
*
|
|
|
|
* globals.c
|
|
|
|
* global variable declarations
|
|
|
|
*
|
|
|
|
* Portions Copyright (c) 1996-2010, PostgreSQL Global Development Group
|
|
|
|
* Portions Copyright (c) 1994, Regents of the University of California
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* IDENTIFICATION
|
|
|
|
* $PostgreSQL: pgsql/src/backend/utils/init/globals.c,v 1.111 2010/01/02 16:57:56 momjian Exp $
|
|
|
|
*
|
|
|
|
* NOTES
|
|
|
|
* Globals used all over the place should be declared here and not
|
|
|
|
* in other modules.
|
|
|
|
*
|
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
*/
|
XLOG (and related) changes:
* Store two past checkpoint locations, not just one, in pg_control.
On startup, we fall back to the older checkpoint if the newer one
is unreadable. Also, a physical copy of the newest checkpoint record
is kept in pg_control for possible use in disaster recovery (ie,
complete loss of pg_xlog). Also add a version number for pg_control
itself. Remove archdir from pg_control; it ought to be a GUC
parameter, not a special case (not that it's implemented yet anyway).
* Suppress successive checkpoint records when nothing has been entered
in the WAL log since the last one. This is not so much to avoid I/O
as to make it actually useful to keep track of the last two
checkpoints. If the things are right next to each other then there's
not a lot of redundancy gained...
* Change CRC scheme to a true 64-bit CRC, not a pair of 32-bit CRCs
on alternate bytes. Polynomial borrowed from ECMA DLT1 standard.
* Fix XLOG record length handling so that it will work at BLCKSZ = 32k.
* Change XID allocation to work more like OID allocation. (This is of
dubious necessity, but I think it's a good idea anyway.)
* Fix a number of minor bugs, such as off-by-one logic for XLOG file
wraparound at the 4 gig mark.
* Add documentation and clean up some coding infelicities; move file
format declarations out to include files where planned contrib
utilities can get at them.
* Checkpoint will now occur every CHECKPOINT_SEGMENTS log segments or
every CHECKPOINT_TIMEOUT seconds, whichever comes first. It is also
possible to force a checkpoint by sending SIGUSR1 to the postmaster
(undocumented feature...)
* Defend against kill -9 postmaster by storing shmem block's key and ID
in postmaster.pid lockfile, and checking at startup to ensure that no
processes are still connected to old shmem block (if it still exists).
* Switch backends to accept SIGQUIT rather than SIGUSR1 for emergency
stop, for symmetry with postmaster and xlog utilities. Clean up signal
handling in bootstrap.c so that xlog utilities launched by postmaster
will react to signals better.
* Standalone bootstrap now grabs lockfile in target directory, as added
insurance against running it in parallel with live postmaster.
25 years ago
|
|
|
#include "postgres.h"
|
|
|
|
|
|
|
|
#include "libpq/pqcomm.h"
|
|
|
|
#include "miscadmin.h"
|
|
|
|
#include "storage/backendid.h"
|
|
|
|
|
|
|
|
|
|
|
|
ProtocolVersion FrontendProtocol;
|
|
|
|
|
|
|
|
volatile bool InterruptPending = false;
|
|
|
|
volatile bool QueryCancelPending = false;
|
|
|
|
volatile bool ProcDiePending = false;
|
|
|
|
volatile bool ImmediateInterruptOK = false;
|
|
|
|
volatile uint32 InterruptHoldoffCount = 0;
|
|
|
|
volatile uint32 CritSectionCount = 0;
|
|
|
|
|
|
|
|
int MyProcPid;
|
|
|
|
pg_time_t MyStartTime;
|
|
|
|
struct Port *MyProcPort;
|
|
|
|
long MyCancelKey;
|
Install a "dead man switch" to allow the postmaster to detect cases where
a backend has done exit(0) or exit(1) without having disengaged itself
from shared memory. We are at risk for this whenever third-party code is
loaded into a backend, since such code might not know it's supposed to go
through proc_exit() instead. Also, it is reported that under Windows
there are ways to externally kill a process that cause the status code
returned to the postmaster to be indistinguishable from a voluntary exit
(thank you, Microsoft). If this does happen then the system is probably
hosed --- for instance, the dead session might still be holding locks.
So the best recovery method is to treat this like a backend crash.
The dead man switch is armed for a particular child process when it
acquires a regular PGPROC, and disarmed when the PGPROC is released;
these should be the first and last touches of shared memory resources
in a backend, or close enough anyway. This choice means there is no
coverage for auxiliary processes, but I doubt we need that, since they
shouldn't be executing any user-provided code anyway.
This patch also improves the management of the EXEC_BACKEND
ShmemBackendArray array a bit, by reducing search costs.
Although this problem is of long standing, the lack of field complaints
seems to mean it's not critical enough to risk back-patching; at least
not till we get some more testing of this mechanism.
17 years ago
|
|
|
int MyPMChildSlot;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* DataDir is the absolute path to the top level of the PGDATA directory tree.
|
|
|
|
* Except during early startup, this is also the server's working directory;
|
|
|
|
* most code therefore can simply use relative paths and not reference DataDir
|
|
|
|
* explicitly.
|
|
|
|
*/
|
|
|
|
char *DataDir = NULL;
|
|
|
|
|
|
|
|
char OutputFileName[MAXPGPATH]; /* debugging output file */
|
|
|
|
|
|
|
|
char my_exec_path[MAXPGPATH]; /* full path to my executable */
|
|
|
|
char pkglib_path[MAXPGPATH]; /* full path to lib directory */
|
|
|
|
|
|
|
|
#ifdef EXEC_BACKEND
|
|
|
|
char postgres_exec_path[MAXPGPATH]; /* full path to backend */
|
|
|
|
|
|
|
|
/* note: currently this is not valid in backend processes */
|
|
|
|
#endif
|
|
|
|
|
|
|
|
BackendId MyBackendId = InvalidBackendId;
|
|
|
|
|
|
|
|
Oid MyDatabaseId = InvalidOid;
|
|
|
|
|
|
|
|
Oid MyDatabaseTableSpace = InvalidOid;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* DatabasePath is the path (relative to DataDir) of my database's
|
|
|
|
* primary directory, ie, its directory in the default tablespace.
|
|
|
|
*/
|
|
|
|
char *DatabasePath = NULL;
|
|
|
|
|
|
|
|
pid_t PostmasterPid = 0;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* IsPostmasterEnvironment is true in a postmaster process and any postmaster
|
|
|
|
* child process; it is false in a standalone process (bootstrap or
|
|
|
|
* standalone backend). IsUnderPostmaster is true in postmaster child
|
|
|
|
* processes. Note that "child process" includes all children, not only
|
|
|
|
* regular backends. These should be set correctly as early as possible
|
|
|
|
* in the execution of a process, so that error handling will do the right
|
|
|
|
* things if an error should occur during process initialization.
|
|
|
|
*
|
|
|
|
* These are initialized for the bootstrap/standalone case.
|
|
|
|
*/
|
|
|
|
bool IsPostmasterEnvironment = false;
|
|
|
|
bool IsUnderPostmaster = false;
|
|
|
|
|
|
|
|
bool ExitOnAnyError = false;
|
|
|
|
|
Make ISO date style (e.g. "2000-02-16 09:33") the default.
Implement "date/time grand unification".
Transform datetime and timespan into timestamp and interval.
Deprecate datetime and timespan, though translate to new types in gram.y.
Transform all datetime and timespan catalog entries into new types.
Make "INTERVAL" reserved word allowed as a column identifier in gram.y.
Remove dt.h, dt.c files, and retarget datetime.h, datetime.c as utility
routines for all date/time types.
date.{h,c} now deals with date, time types.
timestamp.{h,c} now deals with timestamp, interval types.
nabstime.{h,c} now deals with abstime, reltime, tinterval types.
Make NUMERIC a known native type for purposes of type coersion. Not tested.
26 years ago
|
|
|
int DateStyle = USE_ISO_DATES;
|
|
|
|
int DateOrder = DATEORDER_MDY;
|
|
|
|
int IntervalStyle = INTSTYLE_POSTGRES;
|
|
|
|
bool HasCTZSet = false;
|
|
|
|
int CTimeZone = 0;
|
|
|
|
|
|
|
|
bool enableFsync = true;
|
|
|
|
bool allowSystemTableMods = false;
|
|
|
|
int work_mem = 1024;
|
|
|
|
int maintenance_work_mem = 16384;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Primary determinants of sizes of shared-memory structures. MaxBackends is
|
|
|
|
* MaxConnections + autovacuum_max_workers + 1 (it is computed by the GUC
|
|
|
|
* assign hooks for those variables):
|
|
|
|
*/
|
|
|
|
int NBuffers = 1000;
|
|
|
|
int MaxBackends = 100;
|
|
|
|
int MaxConnections = 90;
|
|
|
|
|
|
|
|
int VacuumCostPageHit = 1; /* GUC parameters for vacuum */
|
|
|
|
int VacuumCostPageMiss = 10;
|
|
|
|
int VacuumCostPageDirty = 20;
|
|
|
|
int VacuumCostLimit = 200;
|
|
|
|
int VacuumCostDelay = 0;
|
|
|
|
|
|
|
|
int VacuumCostBalance = 0; /* working state for vacuum */
|
|
|
|
bool VacuumCostActive = false;
|
|
|
|
|
|
|
|
int GinFuzzySearchLimit = 0;
|