postgresql/src/include/postgres.h

217 lines
4.8 KiB
C
Raw Normal View History

1996-10-31 08:10:14 +01:00
/*-------------------------------------------------------------------------
*
* postgres.h--
* definition of (and support for) postgres system types.
1996-10-31 08:10:14 +01:00
* 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.9 1997/09/08 21:50:28 momjian Exp $
1996-10-31 08:10:14 +01:00
*
*-------------------------------------------------------------------------
*/
/*
* NOTES
* this file will eventually contain the definitions for the
* following (and perhaps other) system types:
1996-10-31 08:10:14 +01:00
*
* int2 int4 float4 float8
* Oid regproc RegProcedure
* aclitem
* struct varlena
* char8 char16 int28 oid8
* bytea text
* NameData Name
* oidint4 oidint2 oidname
1996-10-31 08:10:14 +01:00
*
* 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 CSIGNBIT, MAXPGPATH, STATUS macros
1996-10-31 08:10:14 +01:00
*
* ----------------------------------------------------------------
*/
#ifndef POSTGRES_H
#define POSTGRES_H
#include "postgres_ext.h"
1996-10-31 08:10:14 +01:00
#include "config.h"
#include "c.h"
#include "utils/elog.h"
#include "utils/palloc.h"
1996-10-31 08:10:14 +01:00
/* ----------------------------------------------------------------
* Section 1: simple type definitions
1996-10-31 08:10:14 +01:00
* ----------------------------------------------------------------
*/
typedef int16 int2;
typedef int32 int4;
typedef float float4;
typedef double float8;
1996-10-31 08:10:14 +01:00
typedef int4 aclitem;
1996-10-31 08:10:14 +01:00
#define InvalidOid 0
1996-10-31 08:10:14 +01:00
#define OidIsValid(objectId) ((bool) (objectId != InvalidOid))
/* unfortunately, both regproc and RegProcedure are used */
typedef Oid regproc;
typedef Oid RegProcedure;
1996-10-31 08:10:14 +01:00
/* ptr to func returning (char *) */
typedef char *((*func_ptr) ());
1996-10-31 08:10:14 +01:00
#define RegProcedureIsValid(p) OidIsValid(p)
1996-10-31 08:10:14 +01:00
/* ----------------------------------------------------------------
* Section 2: variable length and array types
1996-10-31 08:10:14 +01:00
* ----------------------------------------------------------------
*/
/* ----------------
* struct varlena
1996-10-31 08:10:14 +01:00
* ----------------
*/
struct varlena
{
int32 vl_len;
char vl_dat[1];
1996-10-31 08:10:14 +01:00
};
#define VARSIZE(PTR) (((struct varlena *)(PTR))->vl_len)
#define VARDATA(PTR) (((struct varlena *)(PTR))->vl_dat)
#define VARHDRSZ sizeof(int32)
1996-10-31 08:10:14 +01:00
typedef struct varlena bytea;
typedef struct varlena text;
typedef struct char8
{
char data[8];
} char8;
1996-10-31 08:10:14 +01:00
/* ----------------
* char16
1996-10-31 08:10:14 +01:00
* ----------------
*/
typedef struct char16
{
char data[16];
} char16;
1996-10-31 08:10:14 +01:00
typedef char16 *Char16;
1996-10-31 08:10:14 +01:00
typedef int2 int28[8];
typedef Oid oid8[8];
1996-10-31 08:10:14 +01:00
typedef struct nameData
{
char data[NAMEDATALEN];
} NameData;
typedef NameData *Name;
1996-10-31 08:10:14 +01:00
/* ----------------
* oidint4
1996-10-31 08:10:14 +01:00
*
* this is a new system type used by the file interface.
1996-10-31 08:10:14 +01:00
* ----------------
*/
typedef struct OidInt4Data
{
Oid oi_oid;
int32 oi_int4;
} OidInt4Data;
1996-10-31 08:10:14 +01:00
typedef struct OidInt4Data *OidInt4;
1996-10-31 08:10:14 +01:00
/* ----------------
* oidint2
1996-10-31 08:10:14 +01:00
*
* this is a new system type used to define indices on two attrs.
1996-10-31 08:10:14 +01:00
* ----------------
*/
typedef struct OidInt2Data
{
Oid oi_oid;
int16 oi_int2;
} OidInt2Data;
1996-10-31 08:10:14 +01:00
typedef struct OidInt2Data *OidInt2;
1996-10-31 08:10:14 +01:00
/* ----------------
* oidname
1996-10-31 08:10:14 +01:00
*
* this is a new system type used to define indices on two attrs.
1996-10-31 08:10:14 +01:00
* ----------------
*/
typedef struct OidNameData
{
Oid id;
NameData name;
} OidNameData;
1996-10-31 08:10:14 +01:00
typedef struct OidNameData *OidName;
1996-10-31 08:10:14 +01:00
/* ----------------------------------------------------------------
* Section 3: TransactionId and CommandId
1996-10-31 08:10:14 +01:00
* ----------------------------------------------------------------
*/
typedef uint32 TransactionId;
1996-10-31 08:10:14 +01:00
#define InvalidTransactionId 0
typedef uint16 CommandId;
1996-10-31 08:10:14 +01:00
#define FirstCommandId 0
/* ----------------------------------------------------------------
* Section 4: genbki macros used by the
* catalog/pg_xxx.h files
1996-10-31 08:10:14 +01:00
* ----------------------------------------------------------------
*/
#define CATALOG(x) \
typedef struct CppConcat(FormData_,x)
1996-10-31 08:10:14 +01:00
#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
* CSIGNBIT, MAXPGPATH, STATUS...
1996-10-31 08:10:14 +01:00
* ----------------------------------------------------------------
*/
/* msb for int/unsigned */
#define ISIGNBIT (0x80000000)
#define WSIGNBIT (0x8000)
1996-10-31 08:10:14 +01:00
/* msb for char */
#define CSIGNBIT (0x80)
1996-10-31 08:10:14 +01:00
/* ----------------
* global variables which should probably go someplace else.
1996-10-31 08:10:14 +01:00
* ----------------
*/
#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 */