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 * pdir.h directory path crud
8 * pinit.h postgres initialization
9 * pmod.h processing modes
12 * Copyright (c) 1994, Regents of the University of California
14 * $Id: miscadmin.h,v 1.28 1998/07/24 03:32:13 scrappy Exp $
17 * some of the information in this file will be moved to
20 *-------------------------------------------------------------------------
25 /*****************************************************************************
27 *****************************************************************************/
30 * from postmaster/postmaster.c
32 extern int PostmasterMain(int argc, char *argv[]);
35 * from utils/init/globals.c
38 extern bool Noversion;
40 extern bool QueryCancel;
45 extern long MyCancelKey;
47 extern char OutputFileName[];
50 * done in storage/backendid.h for now.
52 * extern BackendId MyBackendId;
53 * extern BackendTag MyBackendTag;
55 extern bool MyDatabaseIdIsInitialized;
56 extern Oid MyDatabaseId;
57 extern bool TransactionInitWasProcessed;
59 extern bool IsUnderPostmaster;
61 extern short DebugLvl;
63 /* Date/Time Configuration
65 * Constants to pass info from runtime environment:
66 * USE_POSTGRES_DATES specifies traditional postgres format for output.
67 * USE_ISO_DATES specifies ISO-compliant format for output.
68 * USE_SQL_DATES specified Oracle/Ingres-compliant format for output.
69 * USE_GERMAN_DATES specifies German-style dd.mm/yyyy date format.
71 * DateStyle specifies preference for date formatting for output.
72 * EuroDates if client prefers dates interpreted and written w/European conventions.
74 * HasCTZSet if client timezone is specified by client.
75 * CDayLight is the apparent daylight savings time status.
76 * CTimeZone is the timezone offset in seconds.
77 * CTZName is the timezone label.
82 #define USE_POSTGRES_DATES 0
83 #define USE_ISO_DATES 1
84 #define USE_SQL_DATES 2
85 #define USE_GERMAN_DATES 3
88 extern bool EuroDates;
89 extern bool HasCTZSet;
90 extern bool CDayLight;
92 extern char CTZName[];
94 extern char FloatFormat[];
95 extern char DateFormat[];
100 extern Oid LastOidProcessed; /* for query rewrite */
102 #define MAX_PARSE_BUFFER 8192
105 * default number of buffers in buffer pool
110 /*****************************************************************************
112 * POSTGRES directory path definitions. *
113 *****************************************************************************/
115 extern char *DatabaseName;
116 extern char *DatabasePath;
118 /* in utils/misc/database.c */
120 extern void GetRawDatabaseInfo(char *name, Oid *owner, Oid *db_id, char *path, int *encoding);
122 extern void GetRawDatabaseInfo(char *name, Oid *owner, Oid *db_id, char *path);
124 extern int GetDatabaseInfo(char *name, Oid *owner, char *path);
125 extern char *ExpandDatabasePath(char *path);
127 /* now in utils/init/miscinit.c */
128 extern void SetDatabaseName(char *name);
129 extern void SetDatabasePath(char *path);
130 /* even if MB is not enabled, this function is neccesary
131 * since pg_proc.h does have.
133 extern const char *getdatabaseencoding(void);
135 extern char *getpgusername(void);
136 extern void SetPgUserName(void);
137 extern Oid GetUserId(void);
138 extern void SetUserId(void);
139 extern int ValidateBinary(char *path);
140 extern int FindExec(char *backend, char *argv0, char *binary_name);
141 extern int CheckPathAccess(char *path, char *name, int open_mode);
143 /* lower case version for case-insensitive SQL referenced in pg_proc.h */
144 #define GetPgUserName() getpgusername()
146 /*****************************************************************************
148 * POSTGRES processing mode definitions. *
149 *****************************************************************************/
152 * There are four processing modes in POSTGRES. They are NoProcessing
153 * or "none," BootstrapProcessing or "bootstrap," InitProcessing or
154 * "initialization," and NormalProcessing or "normal."
156 * If a POSTGRES binary is in normal mode, then all code may be executed
157 * normally. In the none mode, only bookkeeping code may be called. In
158 * particular, access method calls may not occur in this mode since the
159 * execution state is outside a transaction.
161 * The final two processing modes are used during special times. When the
162 * system state indicates bootstrap processing, transactions are all given
163 * transaction id "one" and are consequently guarenteed to commit. This mode
164 * is used during the initial generation of template databases.
166 * Finally, the execution state is in initialization mode until all normal
167 * initialization is complete. Some code behaves differently when executed in
168 * this mode to enable system bootstrapping.
171 typedef enum ProcessingMode
173 NoProcessing, /* "nothing" can be done */
174 BootstrapProcessing, /* bootstrap creation of template database */
175 InitProcessing, /* initializing system */
176 NormalProcessing /* normal processing */
180 /*****************************************************************************
182 * POSTGRES initialization and cleanup definitions. *
183 *****************************************************************************/
186 * XXX AddExitHandler not defined yet.
189 typedef int16 ExitStatus;
191 #define NormalExitStatus (0)
192 #define FatalExitStatus (127)
193 /* XXX are there any other meaningful exit codes? */
195 /* in utils/init/postinit.c */
197 extern bool PostgresIsInitialized;
199 extern void InitPostgres(char *name);
202 extern void ExitPostgres(ExitStatus status);
203 extern void StatusBackendExit(int status);
204 extern void StatusPostmasterExit(int status);
206 extern bool IsNoProcessingMode(void);
207 extern bool IsBootstrapProcessingMode(void);
208 extern bool IsInitProcessingMode(void);
209 extern bool IsNormalProcessingMode(void);
210 extern void SetProcessingMode(ProcessingMode mode);
211 extern ProcessingMode GetProcessingMode(void);
213 #endif /* MISCADMIN_H */