miscadmin.h 6.69 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
 *
 *
Bruce Momjian's avatar
Add:  
Bruce Momjian committed
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.64 2000/08/03 16:34:43 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"
Bruce Momjian's avatar
Bruce Momjian committed
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

Bruce Momjian's avatar
Bruce Momjian committed
48
extern int	MyProcPid;
49 50
extern struct Port *MyProcPort;
extern long MyCancelKey;
51

52
extern char OutputFileName[];
53

54 55
extern char *UserName;

56 57 58 59 60 61
/*
 * done in storage/backendid.h for now.
 *
 * extern BackendId    MyBackendId;
 * extern BackendTag   MyBackendTag;
 */
62 63 64
extern bool MyDatabaseIdIsInitialized;
extern Oid	MyDatabaseId;
extern bool TransactionInitWasProcessed;
65

66
extern bool IsUnderPostmaster;
67

68
extern int	DebugLvl;
69

70
/* Date/Time Configuration
71 72
 *
 * Constants to pass info from runtime environment:
73 74 75
 *	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.
76
 *	USE_GERMAN_DATES specifies German-style dd.mm/yyyy date format.
77 78
 *
 * DateStyle specifies preference for date formatting for output.
79
 * EuroDates if client prefers dates interpreted and written w/European conventions.
80 81 82
 *
 * HasCTZSet if client timezone is specified by client.
 * CDayLight is the apparent daylight savings time status.
83 84 85 86
 * CTimeZone is the timezone offset in seconds.
 * CTZName is the timezone label.
 */

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

89 90 91
#define USE_POSTGRES_DATES		0
#define USE_ISO_DATES			1
#define USE_SQL_DATES			2
92
#define USE_GERMAN_DATES		3
93

94 95 96 97 98 99
extern int	DateStyle;
extern bool EuroDates;
extern bool HasCTZSet;
extern bool CDayLight;
extern int	CTimeZone;
extern char CTZName[];
100

101 102
extern char FloatFormat[];
extern char DateFormat[];
103

104
extern bool enableFsync;
Bruce Momjian's avatar
Bruce Momjian committed
105
extern bool allowSystemTableMods;
106
extern int	SortMem;
107

108 109 110 111 112 113 114 115
/* a few postmaster startup options are exported here so the
   configuration file processor has access to them */

extern bool NetServer;
extern int MaxBackends;
extern int NBuffers;
extern int PostPortName;

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

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

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

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

132
extern char *GetPgUserName(void);
133
extern void SetPgUserName(void);
134
extern int	GetUserId(void);
135
extern void SetUserId(void);
136
extern int	FindExec(char *full_path, const char *argv0, const char *binary_name);
137
extern int	CheckPathAccess(char *path, char *name, int open_mode);
138 139

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

162 163 164 165 166
typedef enum ProcessingMode
{
	BootstrapProcessing,		/* bootstrap creation of template database */
	InitProcessing,				/* initializing system */
	NormalProcessing			/* normal processing */
167
} ProcessingMode;
168 169 170


/*****************************************************************************
171 172
 *	  pinit.h --															 *
 *			POSTGRES initialization and cleanup definitions.				 *
173 174 175
 *****************************************************************************/
/*
 * Note:
176
 *		XXX AddExitHandler not defined yet.
177 178
 */

179
typedef int16 ExitStatus;
180

181 182
#define NormalExitStatus		(0)
#define FatalExitStatus			(127)
183 184 185 186
/* XXX are there any other meaningful exit codes? */

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

187
extern int	lockingOff;
188

189
extern void InitPostgres(const char *dbname);
190
extern void BaseInit(void);
191 192 193 194 195 196 197 198 199 200 201 202

/* 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) \
203 204 205 206 207
	do { \
		AssertArg(mode == BootstrapProcessing || mode == InitProcessing || \
				  mode == NormalProcessing); \
		Mode = mode; \
	} while(0)
208

209
#define GetProcessingMode() Mode
210

Hiroshi Inoue's avatar
Hiroshi Inoue committed
211 212 213
extern void IgnoreSystemIndexes(bool mode);
extern bool IsIgnoringSystemIndexes(void);
extern bool IsCacheInitialized(void);
214
extern void SetWaitingForLock(bool);
215

216
/*
Tatsuo Ishii's avatar
Tatsuo Ishii committed
217 218 219 220 221 222 223 224
 * "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);
225
extern int	SetPidFile(pid_t pid);
Tatsuo Ishii's avatar
Tatsuo Ishii committed
226

227 228 229

extern void ValidatePgVersion(const char *path);

230
#endif	 /* MISCADMIN_H */