miscadmin.h 6.9 KB
Newer Older
1 2
/*-------------------------------------------------------------------------
 *
3
 * miscadmin.h
4 5 6 7 8 9
 *	  this file contains general postgres administration and initialization
 *	  stuff that used to be spread out between the following files:
 *		globals.h						global variables
 *		pdir.h							directory path crud
 *		pinit.h							postgres initialization
 *		pmod.h							processing modes
10 11
 *
 *
B
Add:  
Bruce Momjian 已提交
12 13
 * Portions Copyright (c) 1996-2000, PostgreSQL, Inc
 * Portions Copyright (c) 1994, Regents of the University of California
14
 *
15
 * $Id: miscadmin.h,v 1.70 2000/11/12 20:51:52 tgl Exp $
16 17
 *
 * NOTES
18 19
 *	  some of the information in this file will be moved to
 *	  other files.
20 21 22 23 24 25
 *
 *-------------------------------------------------------------------------
 */
#ifndef MISCADMIN_H
#define MISCADMIN_H

26
#include <sys/types.h>			/* For pid_t */
27

28
#include "postgres.h"
B
Bruce Momjian 已提交
29
#include "storage/ipc.h"
30

31
/*****************************************************************************
32
 *	  globals.h --															 *
33 34 35 36 37
 *****************************************************************************/

/*
 * from postmaster/postmaster.c
 */
38
extern int	PostmasterMain(int argc, char *argv[]);
39 40 41 42

/*
 * from utils/init/globals.c
 */
43 44 45
extern bool Noversion;
extern bool Quiet;
extern bool QueryCancel;
46
extern char *DataDir;
47

B
Bruce Momjian 已提交
48
extern int	MyProcPid;
49 50
extern struct Port *MyProcPort;
extern long MyCancelKey;
M
 
Marc G. Fournier 已提交
51

52
extern char OutputFileName[];
53 54 55 56 57 58

/*
 * done in storage/backendid.h for now.
 *
 * extern BackendId    MyBackendId;
 */
59 60 61
extern bool MyDatabaseIdIsInitialized;
extern Oid	MyDatabaseId;
extern bool TransactionInitWasProcessed;
62

63
extern bool IsUnderPostmaster;
64

65
extern int	DebugLvl;
66

67
/* Date/Time Configuration
68 69
 *
 * Constants to pass info from runtime environment:
70 71 72
 *	USE_POSTGRES_DATES specifies traditional postgres format for output.
 *	USE_ISO_DATES specifies ISO-compliant format for output.
 *	USE_SQL_DATES specified Oracle/Ingres-compliant format for output.
73
 *	USE_GERMAN_DATES specifies German-style dd.mm/yyyy date format.
74 75
 *
 * DateStyle specifies preference for date formatting for output.
76
 * EuroDates if client prefers dates interpreted and written w/European conventions.
77 78 79
 *
 * HasCTZSet if client timezone is specified by client.
 * CDayLight is the apparent daylight savings time status.
80 81 82 83
 * CTimeZone is the timezone offset in seconds.
 * CTZName is the timezone label.
 */

84
#define MAXTZLEN		10		/* max TZ name len, not counting tr. null */
85

86 87 88
#define USE_POSTGRES_DATES		0
#define USE_ISO_DATES			1
#define USE_SQL_DATES			2
89
#define USE_GERMAN_DATES		3
90

91 92 93 94 95 96
extern int	DateStyle;
extern bool EuroDates;
extern bool HasCTZSet;
extern bool CDayLight;
extern int	CTimeZone;
extern char CTZName[];
97

98 99
extern char FloatFormat[];
extern char DateFormat[];
100

101
extern bool enableFsync;
B
Bruce Momjian 已提交
102
extern bool allowSystemTableMods;
103
extern int	SortMem;
104

105 106 107 108
/* a few postmaster startup options are exported here so the
   configuration file processor has access to them */

extern bool NetServer;
109
extern bool EnableSSL;
110
extern bool SilentMode;
111 112 113 114
extern int MaxBackends;
extern int NBuffers;
extern int PostPortName;

115
/*****************************************************************************
116 117
 *	  pdir.h --																 *
 *			POSTGRES directory path definitions.							 *
118 119
 *****************************************************************************/

120 121 122
extern char *DatabaseName;
extern char *DatabasePath;

123
/* in utils/misc/database.c */
124 125
extern void GetRawDatabaseInfo(const char *name, Oid *db_id, char *path);
extern char *ExpandDatabasePath(const char *path);
126

127
/* now in utils/init/miscinit.c */
128 129
extern void SetDatabaseName(const char *name);
extern void SetDatabasePath(const char *path);
130

131 132 133
extern char *GetUserName(Oid userid);

extern Oid GetUserId(void);
134
extern void SetUserId(Oid userid);
135 136 137 138
extern Oid GetSessionUserId(void);
extern void SetSessionUserId(Oid userid);
extern void SetSessionUserIdFromUserName(const char *username);

139 140
extern void SetDataDir(const char *dir);

141
extern int	FindExec(char *full_path, const char *argv0, const char *binary_name);
142
extern int	CheckPathAccess(char *path, char *name, int open_mode);
143 144

/*****************************************************************************
145 146
 *	  pmod.h --																 *
 *			POSTGRES processing mode definitions.							 *
147 148 149
 *****************************************************************************/
/*
 * Description:
150
 *		There are three processing modes in POSTGRES.  They are
151
 * "BootstrapProcessing or "bootstrap," InitProcessing or
152 153
 * "initialization," and NormalProcessing or "normal."
 *
154
 * The first two processing modes are used during special times. When the
155
 * system state indicates bootstrap processing, transactions are all given
156
 * transaction id "one" and are consequently guarenteed to commit. This mode
157 158
 * is used during the initial generation of template databases.
 *
159 160
 * Initialization mode until all normal initialization is complete.
 * Some code behaves differently when executed in this mode to enable
161 162 163
 * system bootstrapping.
 *
 * If a POSTGRES binary is in normal mode, then all code may be executed
164
 * normally.
165 166
 */

167 168 169 170 171
typedef enum ProcessingMode
{
	BootstrapProcessing,		/* bootstrap creation of template database */
	InitProcessing,				/* initializing system */
	NormalProcessing			/* normal processing */
172
} ProcessingMode;
173 174 175


/*****************************************************************************
176 177
 *	  pinit.h --															 *
 *			POSTGRES initialization and cleanup definitions.				 *
178 179 180
 *****************************************************************************/
/*
 * Note:
181
 *		XXX AddExitHandler not defined yet.
182 183
 */

184
typedef int16 ExitStatus;
185

186 187
#define NormalExitStatus		(0)
#define FatalExitStatus			(127)
188 189 190 191
/* XXX are there any other meaningful exit codes? */

/* in utils/init/postinit.c */

192
extern int	lockingOff;
193

194
extern void InitPostgres(const char *dbname, const char *username);
195
extern void BaseInit(void);
196 197 198 199 200 201 202 203 204 205 206 207

/* one of the ways to get out of here */
#define ExitPostgres(status) proc_exec(status)

/* processing mode support stuff */
extern ProcessingMode Mode;

#define IsBootstrapProcessingMode() ((bool)(Mode == BootstrapProcessing))
#define IsInitProcessingMode() ((bool)(Mode == InitProcessing))
#define IsNormalProcessingMode() ((bool)(Mode == NormalProcessing))

#define SetProcessingMode(mode) \
208 209 210 211 212
	do { \
		AssertArg(mode == BootstrapProcessing || mode == InitProcessing || \
				  mode == NormalProcessing); \
		Mode = mode; \
	} while(0)
213

214
#define GetProcessingMode() Mode
215

H
Hiroshi Inoue 已提交
216 217 218
extern void IgnoreSystemIndexes(bool mode);
extern bool IsIgnoringSystemIndexes(void);
extern bool IsCacheInitialized(void);
219
extern void SetWaitingForLock(bool);
220

221
/*
T
Tatsuo Ishii 已提交
222 223 224 225 226 227 228 229
 * "postmaster.pid" is a file containing postmaster's pid, being
 * created uder $PGDATA upon postmaster's starting up. When postmaster
 * shuts down, it will be unlinked.
*/
#define PIDFNAME	"postmaster.pid"

extern void SetPidFname(char *datadir);
extern void UnlinkPidFile(void);
230
extern int	SetPidFile(pid_t pid);
T
Tatsuo Ishii 已提交
231

232 233 234

extern void ValidatePgVersion(const char *path);

235
#endif	 /* MISCADMIN_H */