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