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-2017, 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;
34 volatile sig_atomic_t ConfigReloadPending = false;
37 volatile uint32 CritSectionCount = 0;
38 
41 struct Port *MyProcPort;
44 
45 /*
46  * MyLatch points to the latch that should be used for signal handling by the
47  * current process. It will either point to a process local latch if the
48  * current process does not have a PGPROC entry in that moment, or to
49  * PGPROC->procLatch if it has. Thus it can always be used in signal handlers,
50  * without checking for its existence.
51  */
52 struct Latch *MyLatch;
53 
54 /*
55  * DataDir is the absolute path to the top level of the PGDATA directory tree.
56  * Except during early startup, this is also the server's working directory;
57  * most code therefore can simply use relative paths and not reference DataDir
58  * explicitly.
59  */
60 char *DataDir = NULL;
61 
62 char OutputFileName[MAXPGPATH]; /* debugging output file */
63 
64 char my_exec_path[MAXPGPATH]; /* full path to my executable */
65 char pkglib_path[MAXPGPATH]; /* full path to lib directory */
66 
67 #ifdef EXEC_BACKEND
68 char postgres_exec_path[MAXPGPATH]; /* full path to backend */
69 
70 /* note: currently this is not valid in backend processes */
71 #endif
72 
74 
76 
78 
80 
81 /*
82  * DatabasePath is the path (relative to DataDir) of my database's
83  * primary directory, ie, its directory in the default tablespace.
84  */
86 
87 pid_t PostmasterPid = 0;
88 
89 /*
90  * IsPostmasterEnvironment is true in a postmaster process and any postmaster
91  * child process; it is false in a standalone process (bootstrap or
92  * standalone backend). IsUnderPostmaster is true in postmaster child
93  * processes. Note that "child process" includes all children, not only
94  * regular backends. These should be set correctly as early as possible
95  * in the execution of a process, so that error handling will do the right
96  * things if an error should occur during process initialization.
97  *
98  * These are initialized for the bootstrap/standalone case.
99  */
101 bool IsUnderPostmaster = false;
102 bool IsBinaryUpgrade = false;
103 bool IsBackgroundWorker = false;
104 
105 bool ExitOnAnyError = false;
106 
110 
111 bool enableFsync = true;
112 bool allowSystemTableMods = false;
113 int work_mem = 1024;
116 
117 /*
118  * Primary determinants of sizes of shared-memory structures.
119  *
120  * MaxBackends is computed by PostmasterMain after modules have had a chance to
121  * register background workers.
122  */
123 int NBuffers = 1000;
124 int MaxConnections = 90;
127 int MaxBackends = 0;
128 
129 int VacuumCostPageHit = 1; /* GUC parameters for vacuum */
132 int VacuumCostLimit = 200;
134 
138 
139 int VacuumCostBalance = 0; /* working state for vacuum */
140 bool VacuumCostActive = false;
int max_parallel_workers
Definition: globals.c:126
bool IsPostmasterEnvironment
Definition: globals.c:100
volatile uint32 InterruptHoldoffCount
Definition: globals.c:35
int MyProcPid
Definition: globals.c:39
BackendId MyBackendId
Definition: globals.c:73
int64 pg_time_t
Definition: pgtime.h:23
int VacuumCostBalance
Definition: globals.c:139
struct Port * MyProcPort
Definition: globals.c:41
volatile bool IdleInTransactionSessionTimeoutPending
Definition: globals.c:33
int VacuumPageHit
Definition: globals.c:135
pg_time_t MyStartTime
Definition: globals.c:40
volatile uint32 QueryCancelHoldoffCount
Definition: globals.c:36
Definition: libpq-be.h:116
int IntervalStyle
Definition: globals.c:109
unsigned int Oid
Definition: postgres_ext.h:31
volatile bool QueryCancelPending
Definition: globals.c:30
int VacuumCostPageDirty
Definition: globals.c:131
bool IsBinaryUpgrade
Definition: globals.c:102
signed int int32
Definition: c.h:256
Oid MyDatabaseTableSpace
Definition: globals.c:79
#define USE_ISO_DATES
Definition: miscadmin.h:213
bool IsBackgroundWorker
Definition: globals.c:103
volatile bool ClientConnectionLost
Definition: globals.c:32
int VacuumCostLimit
Definition: globals.c:132
int32 MyCancelKey
Definition: globals.c:42
#define MAXPGPATH
int MaxBackends
Definition: globals.c:127
Definition: latch.h:110
char OutputFileName[MAXPGPATH]
Definition: globals.c:62
bool IsUnderPostmaster
Definition: globals.c:101
unsigned int uint32
Definition: c.h:268
volatile uint32 CritSectionCount
Definition: globals.c:37
int replacement_sort_tuples
Definition: globals.c:115
int VacuumCostPageHit
Definition: globals.c:129
int DateOrder
Definition: globals.c:108
volatile sig_atomic_t ConfigReloadPending
Definition: globals.c:34
pid_t PostmasterPid
Definition: globals.c:87
uint32 ProtocolVersion
Definition: pqcomm.h:113
bool ExitOnAnyError
Definition: globals.c:105
char my_exec_path[MAXPGPATH]
Definition: globals.c:64
int VacuumPageDirty
Definition: globals.c:137
#define InvalidBackendId
Definition: backendid.h:23
int BackendId
Definition: backendid.h:21
Oid MyDatabaseId
Definition: globals.c:77
int MaxConnections
Definition: globals.c:124
int work_mem
Definition: globals.c:113
bool allowSystemTableMods
Definition: globals.c:112
#define InvalidOid
Definition: postgres_ext.h:36
int VacuumCostDelay
Definition: globals.c:133
int maintenance_work_mem
Definition: globals.c:114
#define DATEORDER_MDY
Definition: miscadmin.h:221
volatile bool InterruptPending
Definition: globals.c:29
char * DatabasePath
Definition: globals.c:85
#define NULL
Definition: c.h:229
BackendId ParallelMasterBackendId
Definition: globals.c:75
int DateStyle
Definition: globals.c:107
bool enableFsync
Definition: globals.c:111
volatile bool ProcDiePending
Definition: globals.c:31
int MyPMChildSlot
Definition: globals.c:43
int NBuffers
Definition: globals.c:123
char * DataDir
Definition: globals.c:60
int max_worker_processes
Definition: globals.c:125
struct Latch * MyLatch
Definition: globals.c:52
int VacuumPageMiss
Definition: globals.c:136
int VacuumCostPageMiss
Definition: globals.c:130
ProtocolVersion FrontendProtocol
Definition: globals.c:27
char pkglib_path[MAXPGPATH]
Definition: globals.c:65
bool VacuumCostActive
Definition: globals.c:140
#define INTSTYLE_POSTGRES
Definition: miscadmin.h:233