miscadmin.h 6.2 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 12 13
 *
 *
 * Copyright (c) 1994, Regents of the University of California
 *
T
Tatsuo Ishii 已提交
14
 * $Id: miscadmin.h,v 1.46 2000/01/09 12:19:27 ishii Exp $
15 16
 *
 * NOTES
17 18
 *	  some of the information in this file will be moved to
 *	  other files.
19 20 21 22 23 24
 *
 *-------------------------------------------------------------------------
 */
#ifndef MISCADMIN_H
#define MISCADMIN_H

25 26
#include "utils/trace.h"

27
/*****************************************************************************
28
 *	  globals.h --															 *
29 30 31 32 33
 *****************************************************************************/

/*
 * from postmaster/postmaster.c
 */
34
extern int	PostmasterMain(int argc, char *argv[]);
35 36 37 38

/*
 * from utils/init/globals.c
 */
39 40 41
extern bool Noversion;
extern bool Quiet;
extern bool QueryCancel;
42
extern char *DataDir;
43

B
Bruce Momjian 已提交
44
extern int	MyProcPid;
45 46
extern struct Port *MyProcPort;
extern long MyCancelKey;
M
 
Marc G. Fournier 已提交
47

48
extern char OutputFileName[];
49 50 51 52 53 54 55

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

60
extern bool IsUnderPostmaster;
61

62
extern int DebugLvl;
63

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

81
#define MAXTZLEN		7
82

83 84 85
#define USE_POSTGRES_DATES		0
#define USE_ISO_DATES			1
#define USE_SQL_DATES			2
86
#define USE_GERMAN_DATES		3
87

88 89 90 91 92 93
extern int	DateStyle;
extern bool EuroDates;
extern bool HasCTZSet;
extern bool CDayLight;
extern int	CTimeZone;
extern char CTZName[];
94

95 96
extern char FloatFormat[];
extern char DateFormat[];
97

98
#define disableFsync	pg_options[OPT_NOFSYNC]
B
Bruce Momjian 已提交
99
extern bool allowSystemTableMods;
100
extern int	SortMem;
101

102
extern Oid	LastOidProcessed;	/* for query rewrite */
103 104

/*****************************************************************************
105 106
 *	  pdir.h --																 *
 *			POSTGRES directory path definitions.							 *
107 108
 *****************************************************************************/

109 110 111
extern char *DatabaseName;
extern char *DatabasePath;

112
/* in utils/misc/database.c */
113
extern void GetRawDatabaseInfo(char *name, Oid *db_id, char *path);
114
extern int	GetDatabaseInfo(char *name, int4 *owner, char *path);
115 116
extern char *ExpandDatabasePath(char *path);

117
/* now in utils/init/miscinit.c */
118 119
extern void SetDatabaseName(char *name);
extern void SetDatabasePath(char *path);
120

M
 
Marc G. Fournier 已提交
121 122 123 124 125
/* even if MB is not enabled, this function is neccesary
 * since pg_proc.h does have.
 */
extern const char *getdatabaseencoding(void);

126 127
extern char *getpgusername(void);
extern void SetPgUserName(void);
128
extern int	GetUserId(void);
129
extern void SetUserId(void);
130 131
extern int	ValidateBinary(char *path);
extern int	FindExec(char *backend, char *argv0, char *binary_name);
132
extern int	CheckPathAccess(char *path, char *name, int open_mode);
133

134 135
/* lower case version for case-insensitive SQL referenced in pg_proc.h */
#define GetPgUserName() getpgusername()
136 137

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

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


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

177
typedef int16 ExitStatus;
178

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

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

185
extern bool PostgresIsInitialized;
186

187
extern void InitPostgres(char *name);
188 189

/* in miscinit.c */
190 191 192 193 194 195
extern void ExitPostgres(ExitStatus status);

extern bool IsBootstrapProcessingMode(void);
extern bool IsInitProcessingMode(void);
extern bool IsNormalProcessingMode(void);
extern void SetProcessingMode(ProcessingMode mode);
196 197
extern ProcessingMode GetProcessingMode(void);

T
Tatsuo Ishii 已提交
198 199 200 201 202 203 204 205 206 207 208 209
/* 
 * "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 char *GetPidFname(void);
extern void UnlinkPidFile(void);
extern int SetPidFile(pid_t pid);

210
#endif	 /* MISCADMIN_H */