PostgreSQL Source Code  git master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros
globals.c
Go to the documentation of this file.
1 /*-------------------------------------------------------------------------
2  *
3  * globals.c
4  * global variable declarations
5  *
6  * Portions Copyright (c) 1996-2016, PostgreSQL Global Development Group
7  * Portions Copyright (c) 1994, Regents of the University of California
8  *
9  *
10  * IDENTIFICATION
11  * src/backend/utils/init/globals.c
12  *
13  * NOTES
14  * Globals used all over the place should be declared here and not
15  * in other modules.
16  *
17  *-------------------------------------------------------------------------
18  */
19 #include "postgres.h"
20 
21 #include "libpq/libpq-be.h"
22 #include "libpq/pqcomm.h"
23 #include "miscadmin.h"
24 #include "storage/backendid.h"
25 
26 
28 
29 volatile bool InterruptPending = false;
30 volatile bool QueryCancelPending = false;
31 volatile bool ProcDiePending = false;
32 volatile bool ClientConnectionLost = false;
36 volatile uint32 CritSectionCount = 0;
37 
40 struct Port *MyProcPort;
43 
44 /*
45  * MyLatch points to the latch that should be used for signal handling by the
46  * current process. It will either point to a process local latch if the
47  * current process does not have a PGPROC entry in that moment, or to
48  * PGPROC->procLatch if it has. Thus it can always be used in signal handlers,
49  * without checking for its existence.
50  */
51 struct Latch *MyLatch;
52 
53 /*
54  * DataDir is the absolute path to the top level of the PGDATA directory tree.
55  * Except during early startup, this is also the server's working directory;
56  * most code therefore can simply use relative paths and not reference DataDir
57  * explicitly.
58  */
59 char *DataDir = NULL;
60 
61 char OutputFileName[MAXPGPATH]; /* debugging output file */
62 
63 char my_exec_path[MAXPGPATH]; /* full path to my executable */
64 char pkglib_path[MAXPGPATH]; /* full path to lib directory */
65 
66 #ifdef EXEC_BACKEND
67 char postgres_exec_path[MAXPGPATH]; /* full path to backend */
68 
69 /* note: currently this is not valid in backend processes */
70 #endif
71 
73 
75 
77 
78 /*
79  * DatabasePath is the path (relative to DataDir) of my database's
80  * primary directory, ie, its directory in the default tablespace.
81  */
83 
84 pid_t PostmasterPid = 0;
85 
86 /*
87  * IsPostmasterEnvironment is true in a postmaster process and any postmaster
88  * child process; it is false in a standalone process (bootstrap or
89  * standalone backend). IsUnderPostmaster is true in postmaster child
90  * processes. Note that "child process" includes all children, not only
91  * regular backends. These should be set correctly as early as possible
92  * in the execution of a process, so that error handling will do the right
93  * things if an error should occur during process initialization.
94  *
95  * These are initialized for the bootstrap/standalone case.
96  */
98 bool IsUnderPostmaster = false;
99 bool IsBinaryUpgrade = false;
100 bool IsBackgroundWorker = false;
101 
102 bool ExitOnAnyError = false;
103 
107 
108 bool enableFsync = true;
109 bool allowSystemTableMods = false;
110 int work_mem = 1024;
113 
114 /*
115  * Primary determinants of sizes of shared-memory structures.
116  *
117  * MaxBackends is computed by PostmasterMain after modules have had a chance to
118  * register background workers.
119  */
120 int NBuffers = 1000;
121 int MaxConnections = 90;
123 int MaxBackends = 0;
124 
125 int VacuumCostPageHit = 1; /* GUC parameters for vacuum */
128 int VacuumCostLimit = 200;
130 
134 
135 int VacuumCostBalance = 0; /* working state for vacuum */
136 bool VacuumCostActive = false;
bool IsPostmasterEnvironment
Definition: globals.c:97
volatile uint32 InterruptHoldoffCount
Definition: globals.c:34
int MyProcPid
Definition: globals.c:38
BackendId MyBackendId
Definition: globals.c:72
int64 pg_time_t
Definition: pgtime.h:23
int VacuumCostBalance
Definition: globals.c:135
struct Port * MyProcPort
Definition: globals.c:40
volatile bool IdleInTransactionSessionTimeoutPending
Definition: globals.c:33
int VacuumPageHit
Definition: globals.c:131
pg_time_t MyStartTime
Definition: globals.c:39
volatile uint32 QueryCancelHoldoffCount
Definition: globals.c:35
Definition: libpq-be.h:118
int IntervalStyle
Definition: globals.c:106
unsigned int Oid
Definition: postgres_ext.h:31
volatile bool QueryCancelPending
Definition: globals.c:30
int VacuumCostPageDirty
Definition: globals.c:127
bool IsBinaryUpgrade
Definition: globals.c:99
Oid MyDatabaseTableSpace
Definition: globals.c:76
#define USE_ISO_DATES
Definition: miscadmin.h:209
bool IsBackgroundWorker
Definition: globals.c:100
volatile bool ClientConnectionLost
Definition: globals.c:32
int VacuumCostLimit
Definition: globals.c:128
#define MAXPGPATH
int MaxBackends
Definition: globals.c:123
Definition: latch.h:94
char OutputFileName[MAXPGPATH]
Definition: globals.c:61
bool IsUnderPostmaster
Definition: globals.c:98
unsigned int uint32
Definition: c.h:265
long MyCancelKey
Definition: globals.c:41
volatile uint32 CritSectionCount
Definition: globals.c:36
int replacement_sort_tuples
Definition: globals.c:112
int VacuumCostPageHit
Definition: globals.c:125
int DateOrder
Definition: globals.c:105
pid_t PostmasterPid
Definition: globals.c:84
uint32 ProtocolVersion
Definition: pqcomm.h:113
bool ExitOnAnyError
Definition: globals.c:102
char my_exec_path[MAXPGPATH]
Definition: globals.c:63
int VacuumPageDirty
Definition: globals.c:133
#define InvalidBackendId
Definition: backendid.h:23
int BackendId
Definition: backendid.h:21
Oid MyDatabaseId
Definition: globals.c:74
int MaxConnections
Definition: globals.c:121
int work_mem
Definition: globals.c:110
bool allowSystemTableMods
Definition: globals.c:109
#define InvalidOid
Definition: postgres_ext.h:36
int VacuumCostDelay
Definition: globals.c:129
int maintenance_work_mem
Definition: globals.c:111
#define DATEORDER_MDY
Definition: miscadmin.h:217
volatile bool InterruptPending
Definition: globals.c:29
char * DatabasePath
Definition: globals.c:82
#define NULL
Definition: c.h:226
int DateStyle
Definition: globals.c:104
bool enableFsync
Definition: globals.c:108
volatile bool ProcDiePending
Definition: globals.c:31
int MyPMChildSlot
Definition: globals.c:42
int NBuffers
Definition: globals.c:120
char * DataDir
Definition: globals.c:59
int max_worker_processes
Definition: globals.c:122
struct Latch * MyLatch
Definition: globals.c:51
int VacuumPageMiss
Definition: globals.c:132
int VacuumCostPageMiss
Definition: globals.c:126
ProtocolVersion FrontendProtocol
Definition: globals.c:27
char pkglib_path[MAXPGPATH]
Definition: globals.c:64
bool VacuumCostActive
Definition: globals.c:136
#define INTSTYLE_POSTGRES
Definition: miscadmin.h:229