1996-10-31 08:10:14 +01:00
|
|
|
/*-------------------------------------------------------------------------
|
|
|
|
*
|
1999-02-14 00:22:53 +01:00
|
|
|
* miscadmin.h
|
1997-09-07 07:04:48 +02:00
|
|
|
* 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
|
1996-10-31 08:10:14 +01:00
|
|
|
*
|
|
|
|
*
|
2000-01-26 06:58:53 +01:00
|
|
|
* Portions Copyright (c) 1996-2000, PostgreSQL, Inc
|
|
|
|
* Portions Copyright (c) 1994, Regents of the University of California
|
1996-10-31 08:10:14 +01:00
|
|
|
*
|
2000-11-25 06:00:33 +01:00
|
|
|
* $Id: miscadmin.h,v 1.73 2000/11/25 05:00:30 momjian Exp $
|
1996-10-31 08:10:14 +01:00
|
|
|
*
|
|
|
|
* NOTES
|
1997-09-07 07:04:48 +02:00
|
|
|
* some of the information in this file will be moved to
|
|
|
|
* other files.
|
1996-10-31 08:10:14 +01:00
|
|
|
*
|
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
*/
|
|
|
|
#ifndef MISCADMIN_H
|
|
|
|
#define MISCADMIN_H
|
|
|
|
|
2000-04-12 19:17:23 +02:00
|
|
|
#include <sys/types.h> /* For pid_t */
|
2000-02-23 16:46:15 +01:00
|
|
|
|
2000-01-19 03:59:03 +01:00
|
|
|
#include "postgres.h"
|
2000-06-15 02:52:26 +02:00
|
|
|
#include "storage/ipc.h"
|
1999-09-27 22:27:32 +02:00
|
|
|
|
1996-10-31 08:10:14 +01:00
|
|
|
/*****************************************************************************
|
1997-09-07 07:04:48 +02:00
|
|
|
* globals.h -- *
|
1996-10-31 08:10:14 +01:00
|
|
|
*****************************************************************************/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* from postmaster/postmaster.c
|
|
|
|
*/
|
1997-09-08 04:41:22 +02:00
|
|
|
extern int PostmasterMain(int argc, char *argv[]);
|
1996-10-31 08:10:14 +01:00
|
|
|
|
|
|
|
/*
|
|
|
|
* from utils/init/globals.c
|
|
|
|
*/
|
1998-09-01 06:40:42 +02:00
|
|
|
extern bool Noversion;
|
|
|
|
extern bool Quiet;
|
|
|
|
extern bool QueryCancel;
|
1997-09-08 04:41:22 +02:00
|
|
|
extern char *DataDir;
|
1996-10-31 08:10:14 +01:00
|
|
|
|
1998-01-25 06:15:15 +01:00
|
|
|
extern int MyProcPid;
|
1998-09-01 06:40:42 +02:00
|
|
|
extern struct Port *MyProcPort;
|
|
|
|
extern long MyCancelKey;
|
1998-07-09 05:29:11 +02:00
|
|
|
|
1997-09-08 04:41:22 +02:00
|
|
|
extern char OutputFileName[];
|
1996-10-31 08:10:14 +01:00
|
|
|
|
|
|
|
/*
|
|
|
|
* done in storage/backendid.h for now.
|
|
|
|
*
|
|
|
|
* extern BackendId MyBackendId;
|
|
|
|
*/
|
1997-09-08 04:41:22 +02:00
|
|
|
extern bool MyDatabaseIdIsInitialized;
|
|
|
|
extern Oid MyDatabaseId;
|
|
|
|
extern bool TransactionInitWasProcessed;
|
1996-10-31 08:10:14 +01:00
|
|
|
|
1997-09-08 04:41:22 +02:00
|
|
|
extern bool IsUnderPostmaster;
|
1996-10-31 08:10:14 +01:00
|
|
|
|
2000-04-12 19:17:23 +02:00
|
|
|
extern int DebugLvl;
|
1996-10-31 08:10:14 +01:00
|
|
|
|
1997-03-18 17:36:50 +01:00
|
|
|
/* Date/Time Configuration
|
1997-03-25 09:11:24 +01:00
|
|
|
*
|
|
|
|
* Constants to pass info from runtime environment:
|
1997-09-07 07:04:48 +02:00
|
|
|
* 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.
|
1998-02-26 05:46:47 +01:00
|
|
|
* USE_GERMAN_DATES specifies German-style dd.mm/yyyy date format.
|
1997-03-25 09:11:24 +01:00
|
|
|
*
|
|
|
|
* DateStyle specifies preference for date formatting for output.
|
1997-03-18 17:36:50 +01:00
|
|
|
* EuroDates if client prefers dates interpreted and written w/European conventions.
|
1997-03-25 09:11:24 +01:00
|
|
|
*
|
|
|
|
* HasCTZSet if client timezone is specified by client.
|
|
|
|
* CDayLight is the apparent daylight savings time status.
|
1997-03-18 17:36:50 +01:00
|
|
|
* CTimeZone is the timezone offset in seconds.
|
|
|
|
* CTZName is the timezone label.
|
|
|
|
*/
|
|
|
|
|
2000-05-29 21:16:57 +02:00
|
|
|
#define MAXTZLEN 10 /* max TZ name len, not counting tr. null */
|
1997-03-25 09:11:24 +01:00
|
|
|
|
1997-09-07 07:04:48 +02:00
|
|
|
#define USE_POSTGRES_DATES 0
|
|
|
|
#define USE_ISO_DATES 1
|
|
|
|
#define USE_SQL_DATES 2
|
1997-12-05 00:58:01 +01:00
|
|
|
#define USE_GERMAN_DATES 3
|
1997-03-25 09:11:24 +01:00
|
|
|
|
1997-09-08 04:41:22 +02:00
|
|
|
extern int DateStyle;
|
|
|
|
extern bool EuroDates;
|
|
|
|
extern bool HasCTZSet;
|
|
|
|
extern bool CDayLight;
|
|
|
|
extern int CTimeZone;
|
|
|
|
extern char CTZName[];
|
1997-01-26 16:32:28 +01:00
|
|
|
|
1997-09-08 04:41:22 +02:00
|
|
|
extern char FloatFormat[];
|
|
|
|
extern char DateFormat[];
|
1997-03-18 21:15:39 +01:00
|
|
|
|
2000-05-31 02:28:42 +02:00
|
|
|
extern bool enableFsync;
|
1999-05-25 18:15:34 +02:00
|
|
|
extern bool allowSystemTableMods;
|
1997-09-08 04:41:22 +02:00
|
|
|
extern int SortMem;
|
1997-08-14 18:11:41 +02:00
|
|
|
|
2000-05-31 02:28:42 +02:00
|
|
|
/* a few postmaster startup options are exported here so the
|
|
|
|
configuration file processor has access to them */
|
|
|
|
|
|
|
|
extern bool NetServer;
|
2000-09-06 21:54:52 +02:00
|
|
|
extern bool EnableSSL;
|
2000-10-08 11:25:38 +02:00
|
|
|
extern bool SilentMode;
|
2000-05-31 02:28:42 +02:00
|
|
|
extern int MaxBackends;
|
|
|
|
extern int NBuffers;
|
2000-11-14 02:15:06 +01:00
|
|
|
extern int PostPortNumber;
|
2000-05-31 02:28:42 +02:00
|
|
|
|
1996-10-31 08:10:14 +01:00
|
|
|
/*****************************************************************************
|
1997-09-07 07:04:48 +02:00
|
|
|
* pdir.h -- *
|
|
|
|
* POSTGRES directory path definitions. *
|
1996-10-31 08:10:14 +01:00
|
|
|
*****************************************************************************/
|
|
|
|
|
1998-04-05 23:04:50 +02:00
|
|
|
extern char *DatabaseName;
|
|
|
|
extern char *DatabasePath;
|
|
|
|
|
1997-11-07 07:38:51 +01:00
|
|
|
/* in utils/misc/database.c */
|
2000-01-13 19:26:18 +01:00
|
|
|
extern void GetRawDatabaseInfo(const char *name, Oid *db_id, char *path);
|
|
|
|
extern char *ExpandDatabasePath(const char *path);
|
1997-11-07 07:38:51 +01:00
|
|
|
|
1996-10-31 08:10:14 +01:00
|
|
|
/* now in utils/init/miscinit.c */
|
2000-01-13 19:26:18 +01:00
|
|
|
extern void SetDatabaseName(const char *name);
|
|
|
|
extern void SetDatabasePath(const char *path);
|
1998-09-01 06:40:42 +02:00
|
|
|
|
2000-09-19 20:18:04 +02:00
|
|
|
extern char *GetUserName(Oid userid);
|
|
|
|
|
|
|
|
extern Oid GetUserId(void);
|
2000-09-06 16:15:31 +02:00
|
|
|
extern void SetUserId(Oid userid);
|
2000-09-19 20:18:04 +02:00
|
|
|
extern Oid GetSessionUserId(void);
|
|
|
|
extern void SetSessionUserId(Oid userid);
|
|
|
|
extern void SetSessionUserIdFromUserName(const char *username);
|
|
|
|
|
2000-11-04 13:43:24 +01:00
|
|
|
extern void SetDataDir(const char *dir);
|
|
|
|
|
2000-07-09 15:14:19 +02:00
|
|
|
extern int FindExec(char *full_path, const char *argv0, const char *binary_name);
|
1997-09-08 04:41:22 +02:00
|
|
|
extern int CheckPathAccess(char *path, char *name, int open_mode);
|
1996-10-31 08:10:14 +01:00
|
|
|
|
2000-11-21 22:16:06 +01:00
|
|
|
#ifdef CYR_RECODE
|
2000-11-25 06:00:33 +01:00
|
|
|
extern char *convertstr(unsigned char *buff, int len, int dest);
|
2000-11-21 22:16:06 +01:00
|
|
|
#endif
|
|
|
|
|
1996-10-31 08:10:14 +01:00
|
|
|
/*****************************************************************************
|
1997-09-07 07:04:48 +02:00
|
|
|
* pmod.h -- *
|
|
|
|
* POSTGRES processing mode definitions. *
|
1996-10-31 08:10:14 +01:00
|
|
|
*****************************************************************************/
|
|
|
|
/*
|
|
|
|
* Description:
|
2000-04-12 19:17:23 +02:00
|
|
|
* There are three processing modes in POSTGRES. They are
|
1999-10-06 23:58:18 +02:00
|
|
|
* "BootstrapProcessing or "bootstrap," InitProcessing or
|
1996-10-31 08:10:14 +01:00
|
|
|
* "initialization," and NormalProcessing or "normal."
|
|
|
|
*
|
1999-10-06 23:58:18 +02:00
|
|
|
* The first two processing modes are used during special times. When the
|
1996-10-31 08:10:14 +01:00
|
|
|
* system state indicates bootstrap processing, transactions are all given
|
1999-10-06 23:58:18 +02:00
|
|
|
* transaction id "one" and are consequently guarenteed to commit. This mode
|
1996-10-31 08:10:14 +01:00
|
|
|
* is used during the initial generation of template databases.
|
|
|
|
*
|
2000-04-12 19:17:23 +02:00
|
|
|
* Initialization mode until all normal initialization is complete.
|
|
|
|
* Some code behaves differently when executed in this mode to enable
|
1999-10-06 23:58:18 +02:00
|
|
|
* system bootstrapping.
|
|
|
|
*
|
|
|
|
* If a POSTGRES binary is in normal mode, then all code may be executed
|
2000-04-12 19:17:23 +02:00
|
|
|
* normally.
|
1996-10-31 08:10:14 +01:00
|
|
|
*/
|
|
|
|
|
1997-09-07 07:04:48 +02:00
|
|
|
typedef enum ProcessingMode
|
|
|
|
{
|
|
|
|
BootstrapProcessing, /* bootstrap creation of template database */
|
|
|
|
InitProcessing, /* initializing system */
|
|
|
|
NormalProcessing /* normal processing */
|
1997-09-08 23:56:23 +02:00
|
|
|
} ProcessingMode;
|
1996-10-31 08:10:14 +01:00
|
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************
|
1997-09-07 07:04:48 +02:00
|
|
|
* pinit.h -- *
|
|
|
|
* POSTGRES initialization and cleanup definitions. *
|
1996-10-31 08:10:14 +01:00
|
|
|
*****************************************************************************/
|
|
|
|
/*
|
|
|
|
* Note:
|
1997-09-07 07:04:48 +02:00
|
|
|
* XXX AddExitHandler not defined yet.
|
1996-10-31 08:10:14 +01:00
|
|
|
*/
|
|
|
|
|
1997-09-08 04:41:22 +02:00
|
|
|
typedef int16 ExitStatus;
|
1996-10-31 08:10:14 +01:00
|
|
|
|
1997-09-07 07:04:48 +02:00
|
|
|
#define NormalExitStatus (0)
|
|
|
|
#define FatalExitStatus (127)
|
1996-10-31 08:10:14 +01:00
|
|
|
/* XXX are there any other meaningful exit codes? */
|
|
|
|
|
|
|
|
/* in utils/init/postinit.c */
|
|
|
|
|
2000-06-28 05:33:33 +02:00
|
|
|
extern int lockingOff;
|
1996-10-31 08:10:14 +01:00
|
|
|
|
2000-09-06 16:15:31 +02:00
|
|
|
extern void InitPostgres(const char *dbname, const char *username);
|
2000-06-28 05:33:33 +02:00
|
|
|
extern void BaseInit(void);
|
2000-01-13 19:26:18 +01:00
|
|
|
|
|
|
|
/* 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) \
|
2000-04-12 19:17:23 +02:00
|
|
|
do { \
|
|
|
|
AssertArg(mode == BootstrapProcessing || mode == InitProcessing || \
|
|
|
|
mode == NormalProcessing); \
|
|
|
|
Mode = mode; \
|
|
|
|
} while(0)
|
1996-10-31 08:10:14 +01:00
|
|
|
|
2000-01-13 19:26:18 +01:00
|
|
|
#define GetProcessingMode() Mode
|
1997-09-08 04:41:22 +02:00
|
|
|
|
2000-02-18 10:30:20 +01:00
|
|
|
extern void IgnoreSystemIndexes(bool mode);
|
|
|
|
extern bool IsIgnoringSystemIndexes(void);
|
|
|
|
extern bool IsCacheInitialized(void);
|
2000-02-22 10:55:26 +01:00
|
|
|
extern void SetWaitingForLock(bool);
|
1996-10-31 08:10:14 +01:00
|
|
|
|
2000-04-12 19:17:23 +02:00
|
|
|
/*
|
2000-01-09 13:19:27 +01:00
|
|
|
* "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);
|
2000-04-12 19:17:23 +02:00
|
|
|
extern int SetPidFile(pid_t pid);
|
2000-01-09 13:19:27 +01:00
|
|
|
|
2000-07-02 17:21:27 +02:00
|
|
|
|
|
|
|
extern void ValidatePgVersion(const char *path);
|
|
|
|
|
1998-09-01 06:40:42 +02:00
|
|
|
#endif /* MISCADMIN_H */
|