1 /*-------------------------------------------------------------------------
4 * this file contains general postgres administration and initialization
5 * stuff that used to be spread out between the following files:
6 * globals.h global variables
7 * magic.h PG_RELEASE, PG_VERSION, etc defines
8 * pdir.h directory path crud
9 * pinit.h postgres initialization
10 * pmod.h processing modes
13 * Copyright (c) 1994, Regents of the University of California
15 * $Id: miscadmin.h,v 1.3 1996/11/12 06:47:10 bryanh Exp $
18 * some of the information in this file will be moved to
21 *-------------------------------------------------------------------------
26 /*****************************************************************************
28 *****************************************************************************/
31 * from postmaster/postmaster.c
33 extern int PostmasterMain(int argc, char* argv[]);
36 * from utils/init/globals.c
39 extern int Noversion; /* moved from magic.c */
40 extern int MasterPid; /* declared and defined in utils/initglobals.c */
44 extern char OutputFileName[];
45 extern void InitGlobals(void);
48 * done in storage/backendid.h for now.
50 * extern BackendId MyBackendId;
51 * extern BackendTag MyBackendTag;
53 extern bool MyDatabaseIdIsInitialized;
54 extern Oid MyDatabaseId;
55 extern bool TransactionInitWasProcessed;
57 extern bool IsUnderPostmaster;
58 extern bool IsPostmaster;
60 extern short DebugLvl;
62 extern Oid LastOidProcessed; /* for query rewrite */
64 #define MAX_PARSE_BUFFER 8192
67 * default number of buffers in buffer pool
72 /*****************************************************************************
74 * POSTGRES directory path definitions. *
75 *****************************************************************************/
77 /* now in utils/init/miscinit.c */
78 extern char *GetDatabasePath(void);
79 extern char *GetDatabaseName(void);
80 extern void SetDatabaseName(char *name);
81 extern void SetDatabasePath(char *path);
82 extern char *GetPgUserName(void);
83 extern void SetPgUserName(void);
84 extern Oid GetUserId(void);
85 extern void SetUserId(void);
86 extern char *GetPGHome(void);
87 extern char *GetPGData(void);
88 extern int ValidateBackend(char *path);
89 extern int FindBackend(char *backend, char *argv0);
90 extern int CheckPathAccess(char *path, char *name, int open_mode);
93 /*****************************************************************************
95 * POSTGRES processing mode definitions. *
96 *****************************************************************************/
99 * There are four processing modes in POSTGRES. They are NoProcessing
100 * or "none," BootstrapProcessing or "bootstrap," InitProcessing or
101 * "initialization," and NormalProcessing or "normal."
103 * If a POSTGRES binary is in normal mode, then all code may be executed
104 * normally. In the none mode, only bookkeeping code may be called. In
105 * particular, access method calls may not occur in this mode since the
106 * execution state is outside a transaction.
108 * The final two processing modes are used during special times. When the
109 * system state indicates bootstrap processing, transactions are all given
110 * transaction id "one" and are consequently guarenteed to commit. This mode
111 * is used during the initial generation of template databases.
113 * Finally, the execution state is in initialization mode until all normal
114 * initialization is complete. Some code behaves differently when executed in
115 * this mode to enable system bootstrapping.
118 typedef enum ProcessingMode {
119 NoProcessing, /* "nothing" can be done */
120 BootstrapProcessing, /* bootstrap creation of template database */
121 InitProcessing, /* initializing system */
122 NormalProcessing /* normal processing */
126 /*****************************************************************************
128 * POSTGRES initialization and cleanup definitions. *
129 *****************************************************************************/
132 * XXX AddExitHandler not defined yet.
135 typedef int16 ExitStatus;
137 #define NormalExitStatus (0)
138 #define FatalExitStatus (127)
139 /* XXX are there any other meaningful exit codes? */
141 /* in utils/init/postinit.c */
142 extern void InitMyDatabaseId(void);
143 extern void InitUserid(void);
144 extern void InitCommunication(void);
145 extern void InitStdio(void);
147 extern bool PostgresIsInitialized;
149 extern void InitPostgres(char *name);
152 extern void ExitPostgres(ExitStatus status);
153 extern void AbortPostgres(void);
154 extern void StatusBackendExit(int status);
155 extern void StatusPostmasterExit(int status);
157 extern bool IsNoProcessingMode(void);
158 extern bool IsBootstrapProcessingMode(void);
159 extern bool IsInitProcessingMode(void);
160 extern bool IsNormalProcessingMode(void);
161 extern void SetProcessingMode(ProcessingMode mode);
162 extern ProcessingMode GetProcessingMode(void);
164 #endif /* MISCADMIN_H */