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