Commit 83311355 authored by Marc G. Fournier's avatar Marc G. Fournier

Add these files to ${SRCDIR}/include

parent 0a761375
This diff is collapsed.
/*-------------------------------------------------------------------------
*
* miscadmin.h--
* this file contains general postgres administration and initialization
* stuff that used to be spread out between the following files:
* globals.h global variables
* magic.h PG_RELEASE, PG_VERSION, etc defines
* pdir.h directory path crud
* pinit.h postgres initialization
* pmod.h processing modes
*
*
* Copyright (c) 1994, Regents of the University of California
*
* $Id: miscadmin.h,v 1.1 1996/10/31 07:10:13 scrappy Exp $
*
* NOTES
* some of the information in this file will be moved to
* other files.
*
*-------------------------------------------------------------------------
*/
#ifndef MISCADMIN_H
#define MISCADMIN_H
/*****************************************************************************
* globals.h -- *
*****************************************************************************/
#include "postgres.h"
/* #include "storage/sinval.h" */
/*
* from postmaster/postmaster.c
*/
extern int PostmasterMain(int argc, char* argv[]);
/*
* from utils/init/globals.c
*/
extern int Portfd;
extern int Noversion; /* moved from magic.c */
extern int MasterPid; /* declared and defined in utils/initglobals.c */
extern int Quiet;
extern char *DataDir;
extern char OutputFileName[];
extern void InitGlobals(void);
/*
* done in storage/backendid.h for now.
*
* extern BackendId MyBackendId;
* extern BackendTag MyBackendTag;
*/
extern bool MyDatabaseIdIsInitialized;
extern Oid MyDatabaseId;
extern bool TransactionInitWasProcessed;
extern bool IsUnderPostmaster;
extern bool IsPostmaster;
extern short DebugLvl;
extern Oid LastOidProcessed; /* for query rewrite */
#define MAX_PARSE_BUFFER 8192
/*
* default number of buffers in buffer pool
*
*/
#define NDBUFS 64
/*****************************************************************************
* magic.h - definitions of the indexes of the magic numbers *
*****************************************************************************/
#define PG_RELEASE 6
#define PG_VERSION 0
#define PG_VERFILE "PG_VERSION"
/*****************************************************************************
* pdir.h -- *
* POSTGRES directory path definitions. *
*****************************************************************************/
/* now in utils/init/miscinit.c */
extern char *GetDatabasePath(void);
extern char *GetDatabaseName(void);
extern void SetDatabaseName(char *name);
extern void SetDatabasePath(char *path);
extern char *GetPgUserName(void);
extern void SetPgUserName(void);
extern Oid GetUserId(void);
extern void SetUserId(void);
extern char *GetPGHome(void);
extern char *GetPGData(void);
extern int ValidateBackend(char *path);
extern int FindBackend(char *backend, char *argv0);
extern int CheckPathAccess(char *path, char *name, int open_mode);
/*****************************************************************************
* pmod.h -- *
* POSTGRES processing mode definitions. *
*****************************************************************************/
/*
* Description:
* There are four processing modes in POSTGRES. They are NoProcessing
* or "none," BootstrapProcessing or "bootstrap," InitProcessing or
* "initialization," and NormalProcessing or "normal."
*
* If a POSTGRES binary is in normal mode, then all code may be executed
* normally. In the none mode, only bookkeeping code may be called. In
* particular, access method calls may not occur in this mode since the
* execution state is outside a transaction.
*
* The final two processing modes are used during special times. When the
* system state indicates bootstrap processing, transactions are all given
* transaction id "one" and are consequently guarenteed to commit. This mode
* is used during the initial generation of template databases.
*
* Finally, the execution state is in initialization mode until all normal
* initialization is complete. Some code behaves differently when executed in
* this mode to enable system bootstrapping.
*/
typedef enum ProcessingMode {
NoProcessing, /* "nothing" can be done */
BootstrapProcessing, /* bootstrap creation of template database */
InitProcessing, /* initializing system */
NormalProcessing /* normal processing */
} ProcessingMode;
/*****************************************************************************
* pinit.h -- *
* POSTGRES initialization and cleanup definitions. *
*****************************************************************************/
/*
* Note:
* XXX AddExitHandler not defined yet.
*/
typedef int16 ExitStatus;
#define NormalExitStatus (0)
#define FatalExitStatus (127)
/* XXX are there any other meaningful exit codes? */
/* in utils/init/postinit.c */
extern void InitMyDatabaseId(void);
extern void DoChdirAndInitDatabaseNameAndPath(char *name, char *path);
extern void InitUserid(void);
extern void InitCommunication(void);
extern void InitStdio(void);
extern bool PostgresIsInitialized;
extern void InitPostgres(char *name);
/* in miscinit.c */
extern void ExitPostgres(ExitStatus status);
extern void AbortPostgres(void);
extern void StatusBackendExit(int status);
extern void StatusPostmasterExit(int status);
extern bool IsNoProcessingMode(void);
extern bool IsBootstrapProcessingMode(void);
extern bool IsInitProcessingMode(void);
extern bool IsNormalProcessingMode(void);
extern void SetProcessingMode(ProcessingMode mode);
extern ProcessingMode GetProcessingMode(void);
/*
* Prototypes for utils/init/magic.c
*/
extern int DatabaseMetaGunkIsConsistent(const char *database, char *path);
extern int ValidPgVersion(const char *path);
extern void SetPgVersion(const char *path);
#endif /* MISCADMIN_H */
/*-------------------------------------------------------------------------
*
* postgres.h--
* definition of (and support for) postgres system types.
* this file is included by almost every .c in the system
*
* Copyright (c) 1995, Regents of the University of California
*
* $Id: postgres.h,v 1.1 1996/10/31 07:10:14 scrappy Exp $
*
*-------------------------------------------------------------------------
*/
/*
* NOTES
* this file will eventually contain the definitions for the
* following (and perhaps other) system types:
*
* int2 int4 float4 float8
* Oid regproc RegProcedure
* aclitem
* struct varlena
* char8 char16 int28 oid8
* bytea text
* NameData Name
* oidint4 oidint2 oidname
*
* TABLE OF CONTENTS
* 1) simple type definitions
* 2) varlena and array types
* 3) TransactionId and CommandId
* 4) genbki macros used by catalog/pg_xxx.h files
* 5) random SIGNBIT, MAXPGPATH, STATUS macros
*
* ----------------------------------------------------------------
*/
#ifndef POSTGRES_H
#define POSTGRES_H
#include "config.h"
#include "c.h"
#include "utils/elog.h"
/* ----------------------------------------------------------------
* Section 1: simple type definitions
* ----------------------------------------------------------------
*/
typedef int16 int2;
typedef int32 int4;
typedef float float4;
typedef double float8;
typedef int4 aclitem;
typedef uint32 Oid;
#define InvalidOid 0
#define OidIsValid(objectId) ((bool) (objectId != InvalidOid))
/* unfortunately, both regproc and RegProcedure are used */
typedef Oid regproc;
typedef Oid RegProcedure;
/* ptr to func returning (char *) */
typedef char * ((*func_ptr)());
#define RegProcedureIsValid(p) OidIsValid(p)
/* ----------------------------------------------------------------
* Section 2: variable length and array types
* ----------------------------------------------------------------
*/
/* ----------------
* struct varlena
* ----------------
*/
struct varlena {
int32 vl_len;
char vl_dat[1];
};
#define VARSIZE(PTR) (((struct varlena *)(PTR))->vl_len)
#define VARDATA(PTR) (((struct varlena *)(PTR))->vl_dat)
#define VARHDRSZ sizeof(int32)
typedef struct varlena bytea;
typedef struct varlena text;
typedef struct char8 {
char data[8];
} char8;
/* ----------------
* char16
* ----------------
*/
typedef struct char16 {
char data[16];
} char16;
typedef char16 *Char16;
typedef int2 int28[8];
typedef Oid oid8[8];
/* char16 is distinct from Name.
now, you can truly change the max length of system names
by altering the NAMEDATALEN define below.
don't set the value too high because tuples are still constrained
to be less than 8K
*/
/* NAMEDATALEN is the maximum string length (counting terminating null)
of a Name */
/* defined in Makefile.global */
/* if you change the value of NAMEDATALEN, you may need to change the
alignment of the 'name' type in pg_type.h */
#ifndef NAMEDATALEN
#define NAMEDATALEN 16
#endif /* NAMEDATALEN */
/* OIDNAMELEN should be NAMEDATALEN + sizeof(Oid) */
#ifndef OIDNAMELEN
#define OIDNAMELEN 20
#endif /* OIDNAMELEN */
typedef struct nameData {
char data[NAMEDATALEN];
} NameData;
typedef NameData *Name;
/* ----------------
* oidint4
*
* this is a new system type used by the file interface.
* ----------------
*/
typedef struct OidInt4Data {
Oid oi_oid;
int32 oi_int4;
} OidInt4Data;
typedef struct OidInt4Data *OidInt4;
/* ----------------
* oidint2
*
* this is a new system type used to define indices on two attrs.
* ----------------
*/
typedef struct OidInt2Data {
Oid oi_oid;
int16 oi_int2;
} OidInt2Data;
typedef struct OidInt2Data *OidInt2;
/* ----------------
* oidname
*
* this is a new system type used to define indices on two attrs.
* ----------------
*/
typedef struct OidNameData {
Oid id;
NameData name;
} OidNameData;
typedef struct OidNameData *OidName;
/* ----------------------------------------------------------------
* Section 3: TransactionId and CommandId
* ----------------------------------------------------------------
*/
typedef uint32 TransactionId;
#define InvalidTransactionId 0
typedef uint16 CommandId;
#define FirstCommandId 0
/* ----------------------------------------------------------------
* Section 4: genbki macros used by the
* catalog/pg_xxx.h files
* ----------------------------------------------------------------
*/
#define CATALOG(x) \
typedef struct CppConcat(FormData_,x)
#define DATA(x) extern int errno
#define DECLARE_INDEX(x) extern int errno
#define BUILD_INDICES
#define BOOTSTRAP
#define BKI_BEGIN
#define BKI_END
/* ----------------------------------------------------------------
* Section 5: random stuff
* SIGNBIT, MAXPGPATH, STATUS...
* ----------------------------------------------------------------
*/
/* msb for int/unsigned */
#define SIGNBIT (0x8000)
/* msb for char */
#define CSIGNBIT (1 << 7)
/* ----------------
* global variables which should probably go someplace else.
* ----------------
*/
#define MAXPGPATH 128
#define STATUS_OK (0)
#define STATUS_ERROR (-1)
#define STATUS_NOT_FOUND (-2)
#define STATUS_INVALID (-3)
#define STATUS_UNCATALOGUED (-4)
#define STATUS_REPLACED (-5)
#define STATUS_NOT_DONE (-6)
#define STATUS_BAD_PACKET (-7)
#define STATUS_FOUND (1)
#endif /* POSTGRES_H */
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment