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