Debian Codegraph @

src/backend/utils/init/globals.c

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