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