Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #ifndef MISCADMIN_H
00024 #define MISCADMIN_H
00025
00026 #include "pgtime.h"
00027
00028
00029 #define PG_BACKEND_VERSIONSTR "postgres (PostgreSQL) " PG_VERSION "\n"
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074 extern PGDLLIMPORT volatile bool InterruptPending;
00075 extern volatile bool QueryCancelPending;
00076 extern volatile bool ProcDiePending;
00077
00078 extern volatile bool ClientConnectionLost;
00079
00080
00081 extern volatile bool ImmediateInterruptOK;
00082 extern PGDLLIMPORT volatile uint32 InterruptHoldoffCount;
00083 extern PGDLLIMPORT volatile uint32 CritSectionCount;
00084
00085
00086 extern void ProcessInterrupts(void);
00087
00088 #ifndef WIN32
00089
00090 #define CHECK_FOR_INTERRUPTS() \
00091 do { \
00092 if (InterruptPending) \
00093 ProcessInterrupts(); \
00094 } while(0)
00095 #else
00096
00097 #define CHECK_FOR_INTERRUPTS() \
00098 do { \
00099 if (UNBLOCKED_SIGNAL_QUEUE()) \
00100 pgwin32_dispatch_queued_signals(); \
00101 if (InterruptPending) \
00102 ProcessInterrupts(); \
00103 } while(0)
00104 #endif
00105
00106
00107 #define HOLD_INTERRUPTS() (InterruptHoldoffCount++)
00108
00109 #define RESUME_INTERRUPTS() \
00110 do { \
00111 Assert(InterruptHoldoffCount > 0); \
00112 InterruptHoldoffCount--; \
00113 } while(0)
00114
00115 #define START_CRIT_SECTION() (CritSectionCount++)
00116
00117 #define END_CRIT_SECTION() \
00118 do { \
00119 Assert(CritSectionCount > 0); \
00120 CritSectionCount--; \
00121 } while(0)
00122
00123
00124
00125
00126
00127
00128
00129
00130
00131 extern pid_t PostmasterPid;
00132 extern bool IsPostmasterEnvironment;
00133 extern PGDLLIMPORT bool IsUnderPostmaster;
00134 extern bool IsBackgroundWorker;
00135 extern bool IsBinaryUpgrade;
00136
00137 extern bool ExitOnAnyError;
00138
00139 extern PGDLLIMPORT char *DataDir;
00140
00141 extern PGDLLIMPORT int NBuffers;
00142 extern int MaxBackends;
00143 extern int MaxConnections;
00144
00145 extern PGDLLIMPORT int MyProcPid;
00146 extern PGDLLIMPORT pg_time_t MyStartTime;
00147 extern PGDLLIMPORT struct Port *MyProcPort;
00148 extern long MyCancelKey;
00149 extern int MyPMChildSlot;
00150
00151 extern char OutputFileName[];
00152 extern PGDLLIMPORT char my_exec_path[];
00153 extern char pkglib_path[];
00154
00155 #ifdef EXEC_BACKEND
00156 extern char postgres_exec_path[];
00157 #endif
00158
00159
00160
00161
00162
00163
00164 extern PGDLLIMPORT Oid MyDatabaseId;
00165
00166 extern PGDLLIMPORT Oid MyDatabaseTableSpace;
00167
00168
00169
00170
00171
00172
00173
00174
00175
00176
00177
00178
00179
00180
00181
00182
00183
00184
00185
00186
00187
00188
00189
00190
00191 #define USE_POSTGRES_DATES 0
00192 #define USE_ISO_DATES 1
00193 #define USE_SQL_DATES 2
00194 #define USE_GERMAN_DATES 3
00195 #define USE_XSD_DATES 4
00196
00197
00198 #define DATEORDER_YMD 0
00199 #define DATEORDER_DMY 1
00200 #define DATEORDER_MDY 2
00201
00202 extern int DateStyle;
00203 extern int DateOrder;
00204
00205
00206
00207
00208
00209
00210
00211
00212 #define INTSTYLE_POSTGRES 0
00213 #define INTSTYLE_POSTGRES_VERBOSE 1
00214 #define INTSTYLE_SQL_STANDARD 2
00215 #define INTSTYLE_ISO_8601 3
00216
00217 extern int IntervalStyle;
00218
00219
00220
00221
00222
00223
00224
00225 extern bool HasCTZSet;
00226 extern int CTimeZone;
00227
00228 #define MAXTZLEN 10
00229
00230 extern bool enableFsync;
00231 extern bool allowSystemTableMods;
00232 extern PGDLLIMPORT int work_mem;
00233 extern PGDLLIMPORT int maintenance_work_mem;
00234
00235 extern int VacuumCostPageHit;
00236 extern int VacuumCostPageMiss;
00237 extern int VacuumCostPageDirty;
00238 extern int VacuumCostLimit;
00239 extern int VacuumCostDelay;
00240
00241 extern int VacuumPageHit;
00242 extern int VacuumPageMiss;
00243 extern int VacuumPageDirty;
00244
00245 extern int VacuumCostBalance;
00246 extern bool VacuumCostActive;
00247
00248
00249
00250
00251 #if defined(__ia64__) || defined(__ia64)
00252 typedef struct
00253 {
00254 char *stack_base_ptr;
00255 char *register_stack_base_ptr;
00256 } pg_stack_base_t;
00257 #else
00258 typedef char *pg_stack_base_t;
00259 #endif
00260
00261 extern pg_stack_base_t set_stack_base(void);
00262 extern void restore_stack_base(pg_stack_base_t base);
00263 extern void check_stack_depth(void);
00264
00265
00266 extern void PreventCommandIfReadOnly(const char *cmdname);
00267 extern void PreventCommandDuringRecovery(const char *cmdname);
00268
00269
00270 extern int trace_recovery_messages;
00271 extern int trace_recovery(int trace_level);
00272
00273
00274
00275
00276
00277
00278
00279 #define SECURITY_LOCAL_USERID_CHANGE 0x0001
00280 #define SECURITY_RESTRICTED_OPERATION 0x0002
00281
00282 extern char *DatabasePath;
00283
00284
00285 extern void SetDatabasePath(const char *path);
00286
00287 extern char *GetUserNameFromId(Oid roleid);
00288 extern Oid GetUserId(void);
00289 extern Oid GetOuterUserId(void);
00290 extern Oid GetSessionUserId(void);
00291 extern void GetUserIdAndSecContext(Oid *userid, int *sec_context);
00292 extern void SetUserIdAndSecContext(Oid userid, int sec_context);
00293 extern bool InLocalUserIdChange(void);
00294 extern bool InSecurityRestrictedOperation(void);
00295 extern void GetUserIdAndContext(Oid *userid, bool *sec_def_context);
00296 extern void SetUserIdAndContext(Oid userid, bool sec_def_context);
00297 extern void InitializeSessionUserId(const char *rolename);
00298 extern void InitializeSessionUserIdStandalone(void);
00299 extern void SetSessionAuthorization(Oid userid, bool is_superuser);
00300 extern Oid GetCurrentRoleId(void);
00301 extern void SetCurrentRoleId(Oid roleid, bool is_superuser);
00302
00303 extern void SetDataDir(const char *dir);
00304 extern void ChangeToDataDir(void);
00305 extern char *make_absolute_path(const char *path);
00306
00307
00308 extern bool superuser(void);
00309 extern bool superuser_arg(Oid roleid);
00310
00311
00312
00313
00314
00315
00316
00317
00318
00319
00320
00321
00322
00323
00324
00325
00326
00327
00328
00329
00330
00331
00332
00333
00334
00335
00336 typedef enum ProcessingMode
00337 {
00338 BootstrapProcessing,
00339 InitProcessing,
00340 NormalProcessing
00341 } ProcessingMode;
00342
00343 extern ProcessingMode Mode;
00344
00345 #define IsBootstrapProcessingMode() (Mode == BootstrapProcessing)
00346 #define IsInitProcessingMode() (Mode == InitProcessing)
00347 #define IsNormalProcessingMode() (Mode == NormalProcessing)
00348
00349 #define GetProcessingMode() Mode
00350
00351 #define SetProcessingMode(mode) \
00352 do { \
00353 AssertArg((mode) == BootstrapProcessing || \
00354 (mode) == InitProcessing || \
00355 (mode) == NormalProcessing); \
00356 Mode = (mode); \
00357 } while(0)
00358
00359
00360
00361
00362
00363
00364
00365
00366 typedef enum
00367 {
00368 NotAnAuxProcess = -1,
00369 CheckerProcess = 0,
00370 BootstrapProcess,
00371 StartupProcess,
00372 BgWriterProcess,
00373 CheckpointerProcess,
00374 WalWriterProcess,
00375 WalReceiverProcess,
00376
00377 NUM_AUXPROCTYPES
00378 } AuxProcType;
00379
00380 extern AuxProcType MyAuxProcType;
00381
00382 #define AmBootstrapProcess() (MyAuxProcType == BootstrapProcess)
00383 #define AmStartupProcess() (MyAuxProcType == StartupProcess)
00384 #define AmBackgroundWriterProcess() (MyAuxProcType == BgWriterProcess)
00385 #define AmCheckpointerProcess() (MyAuxProcType == CheckpointerProcess)
00386 #define AmWalWriterProcess() (MyAuxProcType == WalWriterProcess)
00387 #define AmWalReceiverProcess() (MyAuxProcType == WalReceiverProcess)
00388
00389
00390
00391
00392
00393
00394
00395
00396 extern void pg_split_opts(char **argv, int *argcp, char *optstr);
00397 extern void InitializeMaxBackends(void);
00398 extern void InitPostgres(const char *in_dbname, Oid dboid, const char *username,
00399 char *out_dbname);
00400 extern void BaseInit(void);
00401
00402
00403 extern bool IgnoreSystemIndexes;
00404 extern PGDLLIMPORT bool process_shared_preload_libraries_in_progress;
00405 extern char *shared_preload_libraries_string;
00406 extern char *local_preload_libraries_string;
00407
00408
00409
00410
00411
00412
00413
00414
00415
00416
00417
00418
00419
00420
00421
00422
00423
00424
00425 #define LOCK_FILE_LINE_PID 1
00426 #define LOCK_FILE_LINE_DATA_DIR 2
00427 #define LOCK_FILE_LINE_START_TIME 3
00428 #define LOCK_FILE_LINE_PORT 4
00429 #define LOCK_FILE_LINE_SOCKET_DIR 5
00430 #define LOCK_FILE_LINE_LISTEN_ADDR 6
00431 #define LOCK_FILE_LINE_SHMEM_KEY 7
00432
00433 extern void CreateDataDirLockFile(bool amPostmaster);
00434 extern void CreateSocketLockFile(const char *socketfile, bool amPostmaster,
00435 const char *socketDir);
00436 extern void TouchSocketLockFiles(void);
00437 extern void AddToDataDirLockFile(int target_line, const char *str);
00438 extern void ValidatePgVersion(const char *path);
00439 extern void process_shared_preload_libraries(void);
00440 extern void process_local_preload_libraries(void);
00441 extern void pg_bindtextdomain(const char *domain);
00442 extern bool has_rolreplication(Oid roleid);
00443
00444
00445 extern bool BackupInProgress(void);
00446 extern void CancelBackup(void);
00447
00448 #endif