summaryrefslogtreecommitdiff
path: root/src/include/utils
diff options
context:
space:
mode:
Diffstat (limited to 'src/include/utils')
-rw-r--r--src/include/utils/acl.h163
-rw-r--r--src/include/utils/array.h166
-rw-r--r--src/include/utils/bit.h39
-rw-r--r--src/include/utils/builtins.h433
-rw-r--r--src/include/utils/catcache.h85
-rw-r--r--src/include/utils/datum.h64
-rw-r--r--src/include/utils/dynamic_loader.h53
-rw-r--r--src/include/utils/elog.h38
-rw-r--r--src/include/utils/exc.h101
-rw-r--r--src/include/utils/excid.h31
-rw-r--r--src/include/utils/fcache.h55
-rw-r--r--src/include/utils/fcache2.h19
-rw-r--r--src/include/utils/fmgrtab.h29
-rw-r--r--src/include/utils/geo-decls.h248
-rw-r--r--src/include/utils/hsearch.h141
-rw-r--r--src/include/utils/inval.h56
-rw-r--r--src/include/utils/lselect.h40
-rw-r--r--src/include/utils/lsyscache.h45
-rw-r--r--src/include/utils/mcxt.h56
-rw-r--r--src/include/utils/memutils.h281
-rw-r--r--src/include/utils/module.h25
-rw-r--r--src/include/utils/nabstime.h165
-rw-r--r--src/include/utils/oidcompos.h52
-rw-r--r--src/include/utils/palloc.h26
-rw-r--r--src/include/utils/portal.h97
-rw-r--r--src/include/utils/psort.h86
-rw-r--r--src/include/utils/rel.h170
-rw-r--r--src/include/utils/rel2.h23
-rw-r--r--src/include/utils/relcache.h47
-rw-r--r--src/include/utils/sets.h22
-rw-r--r--src/include/utils/syscache.h90
-rw-r--r--src/include/utils/tqual.h55
32 files changed, 3001 insertions, 0 deletions
diff --git a/src/include/utils/acl.h b/src/include/utils/acl.h
new file mode 100644
index 0000000000..d954cedecc
--- /dev/null
+++ b/src/include/utils/acl.h
@@ -0,0 +1,163 @@
+/*-------------------------------------------------------------------------
+ *
+ * acl.h--
+ * Definition of (and support for) access control list data structures.
+ *
+ *
+ * Copyright (c) 1994, Regents of the University of California
+ *
+ * $Id: acl.h,v 1.1 1996/08/28 01:58:40 scrappy Exp $
+ *
+ * NOTES
+ * For backward-compatability purposes we have to allow there
+ * to be a null ACL in a pg_class tuple. This will be defined as
+ * meaning "no protection" (i.e., old catalogs get old semantics).
+ *
+ * The AclItems in an ACL array are currently kept in sorted order.
+ * Things will break hard if you change that without changing the
+ * code wherever this is included.
+ *
+ *-------------------------------------------------------------------------
+ */
+#ifndef ACL_H
+#define ACL_H
+
+#include "postgres.h"
+#include "utils/array.h"
+#include "nodes/parsenodes.h" /* for ChangeACLStmt */
+
+/*
+ * AclId system identifier for the user, group, etc.
+ * XXX currently UNIX uid for users...
+ */
+typedef uint32 AclId;
+#define ACL_ID_WORLD 0 /* XXX only idtype should be checked */
+
+/*
+ * AclIdType tag that describes if the AclId is a user, group, etc.
+ */
+typedef uint8 AclIdType;
+#define ACL_IDTYPE_WORLD 0x00
+#define ACL_IDTYPE_UID 0x01 /* user id - from pg_user */
+#define ACL_IDTYPE_GID 0x02 /* group id - from pg_group */
+
+/*
+ * AclMode the actual permissions
+ * XXX should probably use bit.h routines.
+ * XXX should probably also stuff the modechg cruft in the
+ * high bits, too.
+ */
+typedef uint8 AclMode;
+#define ACL_NO 0 /* no permissions */
+#define ACL_AP (1<<0) /* append */
+#define ACL_RD (1<<1) /* read */
+#define ACL_WR (1<<2) /* write (append/delete/replace) */
+#define ACL_RU (1<<3) /* place rules */
+#define N_ACL_MODES 4
+
+#define ACL_MODECHG_ADD 1
+#define ACL_MODECHG_DEL 2
+#define ACL_MODECHG_EQL 3
+
+/* change this line if you want to set the default acl permission */
+#define ACL_WORLD_DEFAULT (ACL_RD)
+/* #define ACL_WORLD_DEFAULT (ACL_RD|ACL_WR|ACL_AP|ACL_RU) */
+#define ACL_OWNER_DEFAULT (ACL_RD|ACL_WR|ACL_AP|ACL_RU)
+
+/*
+ * AclItem
+ */
+typedef struct AclItem {
+ AclId ai_id;
+ AclIdType ai_idtype;
+ AclMode ai_mode;
+} AclItem;
+/* Note: if the size of AclItem changes,
+ change the aclitem typlen in pg_type.h */
+
+/*
+ * The value of the first dimension-array element. Since these arrays
+ * always have a lower-bound of 0, this is the same as the number of
+ * elements in the array.
+ */
+#define ARR_DIM0(a) (((unsigned *) (((char *) a) + sizeof(ArrayType)))[0])
+
+/*
+ * Acl a one-dimensional POSTGRES array of AclItem
+ */
+typedef ArrayType Acl;
+#define ACL_NUM(ACL) ARR_DIM0(ACL)
+#define ACL_DAT(ACL) ((AclItem *) ARR_DATA_PTR(ACL))
+#define ACL_N_SIZE(N) \
+ ((unsigned) (ARR_OVERHEAD(1) + ((N) * sizeof(AclItem))))
+#define ACL_SIZE(ACL) ARR_SIZE(ACL)
+
+/*
+ * IdList a one-dimensional POSTGRES array of AclId
+ */
+typedef ArrayType IdList;
+#define IDLIST_NUM(IDL) ARR_DIM0(IDL)
+#define IDLIST_DAT(IDL) ((AclId *) ARR_DATA_PTR(IDL))
+#define IDLIST_N_SIZE(N) \
+ ((unsigned) (ARR_OVERHEAD(1) + ((N) * sizeof(AclId))))
+#define IDLIST_SIZE(IDL) ARR_SIZE(IDL)
+
+#define ACL_MODECHG_STR "+-=" /* list of valid characters */
+#define ACL_MODECHG_ADD_CHR '+'
+#define ACL_MODECHG_DEL_CHR '-'
+#define ACL_MODECHG_EQL_CHR '='
+#define ACL_MODE_STR "arwR" /* list of valid characters */
+#define ACL_MODE_AP_CHR 'a'
+#define ACL_MODE_RD_CHR 'r'
+#define ACL_MODE_WR_CHR 'w'
+#define ACL_MODE_RU_CHR 'R'
+
+/* we use this warning string both for non-existent tables and
+ insufficient privilege so non-privileged users cannot ascertain whether
+ the class exists or not */
+#define ACL_NO_PRIV_WARNING "Either no such class or insufficient privilege"
+
+/*
+ * Enable ACL execution tracing and table dumps
+ */
+/*#define ACLDEBUG_TRACE*/
+
+/*
+ * routines used internally (parser, etc.)
+ */
+extern char *aclparse(char *s, AclItem *aip, unsigned *modechg);
+extern Acl *aclownerdefault(AclId ownerid);
+extern Acl *acldefault();
+extern Acl *aclinsert3(Acl *old_acl, AclItem *mod_aip, unsigned modechg);
+
+extern char* aclmakepriv(char* old_privlist, char new_priv);
+extern char* aclmakeuser(char* user_type, char* user);
+extern ChangeACLStmt* makeAclStmt(char* privs, List* rel_list, char* grantee,
+ char grant_or_revoke);
+
+/*
+ * exported routines (from acl.c)
+ */
+extern Acl *makeacl(int n);
+extern AclItem *aclitemin(char *s);
+extern char *aclitemout(AclItem *aip);
+extern Acl *aclinsert(Acl *old_acl, AclItem *mod_aip);
+extern Acl *aclremove(Acl *old_acl, AclItem *mod_aip);
+extern int32 aclcontains(Acl *acl, AclItem *aip);
+
+/*
+ * prototypes for functions in aclchk.c
+ */
+extern void ChangeAcl(char *relname, AclItem *mod_aip, unsigned modechg);
+extern AclId get_grosysid(char *groname);
+extern char *get_groname(AclId grosysid);
+extern int32 aclcheck(Acl *acl, AclId id, AclIdType idtype, AclMode mode);
+
+/* XXX move these elsewhere -pma */
+extern int32 pg_aclcheck(char *relname, char *usename, AclMode mode);
+extern int32 pg_ownercheck(char *usename, char *value, int cacheid);
+extern int32 pg_func_ownercheck(char *usename, char *funcname,
+ int nargs, Oid *arglist);
+
+#endif /* ACL_H */
+
diff --git a/src/include/utils/array.h b/src/include/utils/array.h
new file mode 100644
index 0000000000..f8bd6fdfd7
--- /dev/null
+++ b/src/include/utils/array.h
@@ -0,0 +1,166 @@
+/*-------------------------------------------------------------------------
+ *
+ * array.h--
+ * Utilities for the new array code. Contain prototypes from the
+ * following files:
+ * utils/adt/arrayfuncs.c
+ * utils/adt/arrayutils.c
+ * utils/adt/chunk.c
+ *
+ *
+ * Copyright (c) 1994, Regents of the University of California
+ *
+ * $Id: array.h,v 1.1 1996/08/28 01:58:42 scrappy Exp $
+ *
+ * NOTES
+ * XXX the data array should be LONGALIGN'd -- notice that the array
+ * allocation code does not allocate the extra space required for this,
+ * even though the array-packing code does the LONGALIGNs.
+ *
+ *-------------------------------------------------------------------------
+ */
+#ifndef ARRAY_H
+#define ARRAY_H
+
+#include <stdio.h> /* for FILE (XXX should use File) */
+#include "utils/memutils.h"
+
+typedef struct {
+ int size; /* total array size (in bytes) */
+ int ndim; /* # of dimensions */
+ int flags; /* implementation flags */
+} ArrayType;
+
+/*
+ * bitmask of ArrayType flags field:
+ * 1st bit - large object flag
+ * 2nd bit - chunk flag (array is chunked if set)
+ * 3rd,4th,&5th bit - large object type (used only if bit 1 is set)
+ */
+#define ARR_LOB_FLAG (0x1)
+#define ARR_CHK_FLAG (0x2)
+#define ARR_OBJ_MASK (0x1c)
+
+#define ARR_FLAGS(a) ((ArrayType *) a)->flags
+#define ARR_SIZE(a) (((ArrayType *) a)->size)
+
+#define ARR_NDIM(a) (((ArrayType *) a)->ndim)
+#define ARR_NDIM_PTR(a) (&(((ArrayType *) a)->ndim))
+
+#define ARR_IS_LO(a) \
+ (((ArrayType *) a)->flags & ARR_LOB_FLAG)
+#define SET_LO_FLAG(f,a) \
+ (((ArrayType *) a)->flags |= ((f) ? ARR_LOB_FLAG : 0x0))
+
+#define ARR_IS_CHUNKED(a) \
+ (((ArrayType *) a)->flags & ARR_CHK_FLAG)
+#define SET_CHUNK_FLAG(f,a) \
+ (((ArrayType *) a)->flags |= ((f) ? ARR_CHK_FLAG : 0x0))
+
+#define ARR_OBJ_TYPE(a) \
+ ((ARR_FLAGS(a) & ARR_OBJ_MASK) >> 2)
+#define SET_OBJ_TYPE(f,a) \
+ ((ARR_FLAGS(a)&= ~ARR_OBJ_MASK), (ARR_FLAGS(a)|=((f<<2)&ARR_OBJ_MASK)))
+
+/*
+ * ARR_DIMS returns a pointer to an array of array dimensions (number of
+ * elements along the various array axes).
+ *
+ * ARR_LBOUND returns a pointer to an array of array lower bounds.
+ *
+ * That is: if the third axis of an array has elements 5 through 10, then
+ * ARR_DIMS(a)[2] == 6 and ARR_LBOUND[2] == 5.
+ *
+ * Unlike C, the default lower bound is 1.
+ */
+#define ARR_DIMS(a) \
+ ((int *) (((char *) a) + sizeof(ArrayType)))
+#define ARR_LBOUND(a) \
+ ((int *) (((char *) a) + sizeof(ArrayType) + \
+ (sizeof(int) * (((ArrayType *) a)->ndim))))
+
+/*
+ * Returns a pointer to the actual array data.
+ */
+#define ARR_DATA_PTR(a) \
+ (((char *) a) + \
+ DOUBLEALIGN(sizeof(ArrayType) + 2 * (sizeof(int) * (a)->ndim)))
+
+/*
+ * The total array header size for an array of dimension n (in bytes).
+ */
+#define ARR_OVERHEAD(n) \
+ (DOUBLEALIGN(sizeof(ArrayType) + 2 * (n) * sizeof(int)))
+
+/*------------------------------------------------------------------------
+ * Miscellaneous helper definitions and routines for arrayfuncs.c
+ *------------------------------------------------------------------------
+ */
+
+/* #if defined(PORTNAME_irix5) */
+/* #define RETURN_NULL {*isNull = true; return(0); }*/
+/* #else*/ /* PORTNAME_irix5 */
+#define RETURN_NULL {*isNull = true; return(0); }
+/* #endif */ /* PORTNAME_irix5 */
+#define NAME_LEN 30
+#define MAX_BUFF_SIZE (1 << 13)
+
+typedef struct {
+ char lo_name[NAME_LEN];
+ int C[MAXDIM];
+} CHUNK_INFO;
+
+/*
+ * prototypes for functions defined in arrayfuncs.c
+ */
+extern char *array_in(char *string, Oid element_type);
+extern char *array_out(ArrayType *v, Oid element_type);
+extern char *array_dims(ArrayType *v, bool *isNull);
+extern Datum array_ref(ArrayType *array, int n, int indx[], int reftype,
+ int elmlen, int arraylen, bool *isNull);
+extern Datum array_clip(ArrayType *array, int n, int upperIndx[],
+ int lowerIndx[], int reftype, int len, bool *isNull);
+extern char *array_set(ArrayType *array, int n, int indx[], char *dataPtr,
+ int reftype, int elmlen, int arraylen, bool *isNull);
+extern char *array_assgn(ArrayType *array, int n, int upperIndx[],
+ int lowerIndx[], ArrayType *newArr, int reftype,
+ int len, bool *isNull);
+extern int array_eq (ArrayType *array1, ArrayType *array2);
+extern SanityCheckInput(int ndim, int n, int dim[], int lb[], int indx[]);
+extern char *array_seek(char *ptr, int eltsize, int nitems);
+extern int array_read(char *destptr, int eltsize, int nitems, char *srcptr);
+extern int _LOtransfer(char **destfd, int size, int nitems, char **srcfd,
+ int isSrcLO, int isDestLO);
+
+extern char * _array_newLO(int *fd, int flag);
+
+
+/*
+ * prototypes for functions defined in arrayutils.c
+ * [these names seem to be too generic. Add prefix for arrays? -- AY]
+ */
+
+extern int GetOffset(int n, int dim[], int lb[], int indx[]);
+extern int getNitems(int n, int a[]);
+extern int compute_size(int st[], int endp[], int n, int base);
+extern void mda_get_offset_values(int n, int dist[], int PC[], int span[]);
+extern void mda_get_range(int n, int span[], int st[], int endp[]);
+extern void mda_get_prod(int n, int range[], int P[]);
+extern int tuple2linear(int n, int tup[], int scale[]);
+extern void array2chunk_coord(int n, int C[], int a_coord[], int c_coord[]);
+extern int next_tuple(int n, int curr[], int span[]);
+
+/*
+ * prototypes for functions defined in chunk.c
+ */
+extern char * _ChunkArray(int fd, FILE *afd, int ndim, int dim[], int baseSize,
+ int *nbytes, char *chunkfile);
+extern int GetChunkSize(FILE *fd, int ndim, int dim[MAXDIM], int baseSize,
+ int d[MAXDIM]);
+extern int _ReadChunkArray(int st[], int endp[], int bsize, int fp,
+ char *destfp, ArrayType *array, int isDestLO, bool *isNull);
+extern struct varlena *_ReadChunkArray1El(int st[], int bsize, int fp,
+ ArrayType *array, bool *isNull);
+
+
+#endif /* ARRAY_H */
diff --git a/src/include/utils/bit.h b/src/include/utils/bit.h
new file mode 100644
index 0000000000..dc190accc6
--- /dev/null
+++ b/src/include/utils/bit.h
@@ -0,0 +1,39 @@
+/*-------------------------------------------------------------------------
+ *
+ * bit.h--
+ * Standard bit array definitions.
+ *
+ *
+ * Copyright (c) 1994, Regents of the University of California
+ *
+ * $Id: bit.h,v 1.1 1996/08/28 01:58:43 scrappy Exp $
+ *
+ *-------------------------------------------------------------------------
+ */
+#ifndef BIT_H
+#define BIT_H
+
+typedef bits8 *BitArray;
+typedef uint32 BitIndex;
+
+#define BitsPerByte 8
+
+/*
+ * BitArraySetBit --
+ * Sets (to 1) the value of a bit in a bit array.
+ */
+extern void BitArraySetBit(BitArray bitArray, BitIndex bitIndex);
+
+/*
+ * BitArrayClearBit --
+ * Clears (to 0) the value of a bit in a bit array.
+ */
+extern void BitArrayClearBit(BitArray bitArray, BitIndex bitIndex);
+
+/*
+ * BitArrayBitIsSet --
+ * True iff the bit is set (1) in a bit array.
+ */
+extern bool BitArrayBitIsSet(BitArray bitArray, BitIndex bitIndex);
+
+#endif /* BIT_H */
diff --git a/src/include/utils/builtins.h b/src/include/utils/builtins.h
new file mode 100644
index 0000000000..9695cd5839
--- /dev/null
+++ b/src/include/utils/builtins.h
@@ -0,0 +1,433 @@
+/*-------------------------------------------------------------------------
+ *
+ * builtins.h--
+ * Declarations for operations on built-in types.
+ *
+ *
+ * Copyright (c) 1994, Regents of the University of California
+ *
+ * $Id: builtins.h,v 1.1 1996/08/28 01:58:45 scrappy Exp $
+ *
+ * NOTES
+ * This should normally only be included by fmgr.h.
+ * Under no circumstances should it ever be included before
+ * including fmgr.h!
+ *
+ *-------------------------------------------------------------------------
+ */
+#ifndef BUILTINS_H
+#define BUILTINS_H
+
+#include "postgres.h"
+
+#include "storage/itemptr.h"
+
+#include "storage/large_object.h"
+
+#include "utils/geo-decls.h"
+
+/*
+ * Defined in adt/
+ */
+/* bool.c */
+extern int32 boolin(char *b);
+extern char *boolout(long b);
+extern int32 booleq(int8 arg1, int8 arg2);
+extern int32 boolne(int8 arg1, int8 arg2);
+
+/* char.c */
+extern int32 charin(char *ch);
+extern char *charout(int32 ch);
+extern int32 cidin(char *s);
+extern char *cidout(int32 c);
+extern char *char16in(char *s);
+extern char *char16out(char *s);
+extern int32 chareq(int8 arg1, int8 arg2);
+extern int32 charne(int8 arg1, int8 arg2);
+extern int32 charlt(int8 arg1, int8 arg2);
+extern int32 charle(int8 arg1, int8 arg2);
+extern int32 chargt(int8 arg1, int8 arg2);
+extern int32 charge(int8 arg1, int8 arg2);
+extern int8 charpl(int8 arg1, int8 arg2);
+extern int8 charmi(int8 arg1, int8 arg2);
+extern int8 charmul(int8 arg1, int8 arg2);
+extern int8 chardiv(int8 arg1, int8 arg2);
+extern int32 cideq(int8 arg1, int8 arg2);
+extern int32 char16eq(char *arg1, char *arg2);
+extern int32 char16ne(char *arg1, char *arg2);
+extern int32 char16lt(char *arg1, char *arg2);
+extern int32 char16le(char *arg1, char *arg2);
+extern int32 char16gt(char *arg1, char *arg2);
+extern int32 char16ge(char *arg1, char *arg2);
+extern uint16 char2in(char *s);
+extern char *char2out(uint16 s);
+extern int32 char2eq(uint16 a, uint16 b);
+extern int32 char2ne(uint16 a, uint16 b);
+extern int32 char2lt(uint16 a, uint16 b);
+extern int32 char2le(uint16 a, uint16 b);
+extern int32 char2gt(uint16 a, uint16 b);
+extern int32 char2ge(uint16 a, uint16 b);
+extern int32 char2cmp(uint16 a, uint16 b);
+extern uint32 char4in(char *s);
+extern char *char4out(uint32 s);
+extern int32 char4eq(uint32 a, uint32 b);
+extern int32 char4ne(uint32 a, uint32 b);
+extern int32 char4lt(uint32 a, uint32 b);
+extern int32 char4le(uint32 a, uint32 b);
+extern int32 char4gt(uint32 a, uint32 b);
+extern int32 char4ge(uint32 a, uint32 b);
+extern int32 char4cmp(uint32 a, uint32 b);
+extern char *char8in(char *s);
+extern char *char8out(char *s);
+extern int32 char8eq(char *arg1, char *arg2);
+extern int32 char8ne(char *arg1, char *arg2);
+extern int32 char8lt(char *arg1, char *arg2);
+extern int32 char8le(char *arg1, char *arg2);
+extern int32 char8gt(char *arg1, char *arg2);
+extern int32 char8ge(char *arg1, char *arg2);
+extern int32 char8cmp(char *arg1, char *arg2);
+
+/* int.c */
+extern int32 int2in(char *num);
+extern char *int2out(int16 sh);
+extern int16 *int28in(char *shs);
+extern char *int28out(int16 (*shs)[]);
+extern int32 *int44in(char *input_string);
+extern char *int44out(int32 an_array[]);
+extern int32 int4in(char *num);
+extern char *int4out(int32 l);
+extern int32 i2toi4(int16 arg1);
+extern int16 i4toi2(int32 arg1);
+extern int32 int4eq(int32 arg1, int32 arg2);
+extern int32 int4ne(int32 arg1, int32 arg2);
+extern int32 int4lt(int32 arg1, int32 arg2);
+extern int32 int4le(int32 arg1, int32 arg2);
+extern int32 int4gt(int32 arg1, int32 arg2);
+extern int32 int4ge(int32 arg1, int32 arg2);
+extern int32 int2eq(int16 arg1, int16 arg2);
+extern int32 int2ne(int16 arg1, int16 arg2);
+extern int32 int2lt(int16 arg1, int16 arg2);
+extern int32 int2le(int16 arg1, int16 arg2);
+extern int32 int2gt(int16 arg1, int16 arg2);
+extern int32 int2ge(int16 arg1, int16 arg2);
+extern int32 int24eq(int32 arg1, int32 arg2);
+extern int32 int24ne(int32 arg1, int32 arg2);
+extern int32 int24lt(int32 arg1, int32 arg2);
+extern int32 int24le(int32 arg1, int32 arg2);
+extern int32 int24gt(int32 arg1, int32 arg2);
+extern int32 int24ge(int32 arg1, int32 arg2);
+extern int32 int42eq(int32 arg1, int32 arg2);
+extern int32 int42ne(int32 arg1, int32 arg2);
+extern int32 int42lt(int32 arg1, int32 arg2);
+extern int32 int42le(int32 arg1, int32 arg2);
+extern int32 int42gt(int32 arg1, int32 arg2);
+extern int32 int42ge(int32 arg1, int32 arg2);
+extern int32 keyfirsteq(int16 *arg1, int16 arg2);
+extern int32 int4um(int32 arg);
+extern int32 int4pl(int32 arg1, int32 arg2);
+extern int32 int4mi(int32 arg1, int32 arg2);
+extern int32 int4mul(int32 arg1, int32 arg2);
+extern int32 int4div(int32 arg1, int32 arg2);
+extern int32 int4inc(int32 arg);
+extern int16 int2um(int16 arg);
+extern int16 int2pl(int16 arg1, int16 arg2);
+extern int16 int2mi(int16 arg1, int16 arg2);
+extern int16 int2mul(int16 arg1, int16 arg2);
+extern int16 int2div(int16 arg1, int16 arg2);
+extern int16 int2inc(int16 arg);
+extern int32 int24pl(int32 arg1, int32 arg2);
+extern int32 int24mi(int32 arg1, int32 arg2);
+extern int32 int24mul(int32 arg1, int32 arg2);
+extern int32 int24div(int32 arg1, int32 arg2);
+extern int32 int42pl(int32 arg1, int32 arg2);
+extern int32 int42mi(int32 arg1, int32 arg2);
+extern int32 int42mul(int32 arg1, int32 arg2);
+extern int32 int42div(int32 arg1, int32 arg2);
+extern int32 int4mod(int32 arg1, int32 arg2);
+extern int32 int2mod(int16 arg1, int16 arg2);
+extern int32 int24mod(int32 arg1, int32 arg2);
+extern int32 int42mod(int32 arg1, int32 arg2);
+extern int32 int4fac(int32 arg1);
+extern int32 int2fac(int16 arg1);
+extern int16 int2larger(int16 arg1, int16 arg2);
+extern int16 int2smaller(int16 arg1, int16 arg2);
+extern int32 int4larger(int32 arg1, int32 arg2);
+extern int32 int4smaller(int32 arg1, int32 arg2);
+
+/* name.c */
+extern NameData *namein(char *s);
+extern char *nameout(NameData *s);
+extern int32 nameeq(NameData *arg1, NameData *arg2);
+extern int32 namene(NameData *arg1, NameData *arg2);
+extern int32 namelt(NameData *arg1, NameData *arg2);
+extern int32 namele(NameData *arg1, NameData *arg2);
+extern int32 namegt(NameData *arg1, NameData *arg2);
+extern int32 namege(NameData *arg1, NameData *arg2);
+extern int namecmp(Name n1, Name n2);
+extern int namecpy(Name n1, Name n2);
+extern int namecat(Name n1, Name n2);
+extern int namestrcpy(Name name, char *str);
+extern int namestrcat(Name name, char *str);
+extern int namestrcmp(Name name, char *str);
+extern uint32 NameComputeLength(Name name);
+
+/* numutils.c */
+/* XXX hack. HP-UX has a ltoa (with different arguments) already. */
+#ifdef PORTNAME_hpux
+#define ltoa pg_ltoa
+#endif /* PORTNAME_hpux */
+extern int32 pg_atoi(char *s, int size, int c);
+extern void itoa(int i, char *a);
+extern void ltoa(int32 l, char *a);
+extern int ftoa(double value, char *ascii, int width, int prec1, char format);
+extern int atof1(char *str, double *val);
+
+/*
+ * Per-opclass comparison functions for new btrees. These are
+ * stored in pg_amproc and defined in nbtree/
+ */
+extern int32 btint2cmp();
+extern int32 btint4cmp();
+extern int32 btint24cmp();
+extern int32 btint42cmp();
+extern int32 btfloat4cmp();
+extern int32 btfloat8cmp();
+extern int32 btoidcmp();
+extern int32 btabstimecmp();
+extern int32 btcharcmp();
+extern int32 btchar16cmp();
+extern int32 bttextcmp();
+
+/*
+ * RTree code.
+ * Defined in access/index-rtree/
+ */
+extern char *rtinsert();
+extern char *rtdelete();
+extern char *rtgettuple();
+extern char *rtbeginscan();
+extern void rtendscan();
+extern void rtreebuild();
+extern void rtmarkpos();
+extern void rtrestrpos();
+extern void rtrescan();
+extern void rtbuild();
+
+/* support routines for the rtree access method, by opclass */
+extern BOX *rt_box_union();
+extern BOX *rt_box_inter();
+extern float *rt_box_size();
+extern float *rt_bigbox_size();
+extern float *rt_poly_size();
+extern POLYGON *rt_poly_union();
+extern POLYGON *rt_poly_inter();
+
+/* projection utilities */
+/* extern char *GetAttributeByName();
+ extern char *GetAttributeByNum(); ,
+ in executor/executor.h*/
+
+
+extern int32 pqtest(struct varlena *vlena);
+
+/* arrayfuncs.c */
+#include "utils/array.h"
+
+/* date.c */
+extern int32 reltimein(char *timestring);
+extern char *reltimeout(int32 timevalue);
+extern TimeInterval tintervalin(char *intervalstr);
+extern char *tintervalout(TimeInterval interval);
+extern TimeInterval mktinterval(AbsoluteTime t1, AbsoluteTime t2);
+extern AbsoluteTime timepl(AbsoluteTime t1, RelativeTime t2);
+extern AbsoluteTime timemi(AbsoluteTime t1, RelativeTime t2);
+/* extern RelativeTime abstimemi(AbsoluteTime t1, AbsoluteTime t2); static*/
+extern int ininterval(AbsoluteTime t, TimeInterval interval);
+extern RelativeTime intervalrel(TimeInterval interval);
+extern AbsoluteTime timenow(void);
+extern int32 reltimeeq(RelativeTime t1, RelativeTime t2);
+extern int32 reltimene(RelativeTime t1, RelativeTime t2);
+extern int32 reltimelt(RelativeTime t1, RelativeTime t2);
+extern int32 reltimegt(RelativeTime t1, RelativeTime t2);
+extern int32 reltimele(RelativeTime t1, RelativeTime t2);
+extern int32 reltimege(RelativeTime t1, RelativeTime t2);
+extern int32 intervaleq(TimeInterval i1, TimeInterval i2);
+extern int32 intervalleneq(TimeInterval i, RelativeTime t);
+extern int32 intervallenne(TimeInterval i, RelativeTime t);
+extern int32 intervallenlt(TimeInterval i, RelativeTime t);
+extern int32 intervallengt(TimeInterval i, RelativeTime t);
+extern int32 intervallenle(TimeInterval i, RelativeTime t);
+extern int32 intervallenge(TimeInterval i, RelativeTime t);
+extern int32 intervalct(TimeInterval i1, TimeInterval i2);
+extern int32 intervalov(TimeInterval i1, TimeInterval i2);
+extern AbsoluteTime intervalstart(TimeInterval i);
+extern AbsoluteTime intervalend(TimeInterval i);
+extern int isreltime(char *timestring, int *sign, long *quantity, int *unitnr);
+
+/* dt.c */
+extern int32 dtin(char *datetime);
+extern char *dtout(int32 datetime);
+
+/* filename.c */
+extern char *filename_in(char *file);
+extern char *filename_out(char *s);
+
+/* float.c */
+extern float32 float4in(char *num);
+extern char *float4out(float32 num);
+extern float64 float8in(char *num);
+extern char *float8out(float64 num);
+extern float32 float4abs(float32 arg1);
+extern float32 float4um(float32 arg1);
+extern float32 float4larger(float32 arg1, float32 arg2);
+extern float32 float4smaller(float32 arg1, float32 arg2);
+extern float64 float8abs(float64 arg1);
+extern float64 float8um(float64 arg1);
+extern float64 float8larger(float64 arg1, float64 arg2);
+extern float64 float8smaller(float64 arg1, float64 arg2);
+extern float32 float4pl(float32 arg1, float32 arg2);
+extern float32 float4mi(float32 arg1, float32 arg2);
+extern float32 float4mul(float32 arg1, float32 arg2);
+extern float32 float4div(float32 arg1, float32 arg2);
+extern float32 float4inc(float32 arg1);
+extern float64 float8pl(float64 arg1, float64 arg2);
+extern float64 float8mi(float64 arg1, float64 arg2);
+extern float64 float8mul(float64 arg1, float64 arg2);
+extern float64 float8div(float64 arg1, float64 arg2);
+extern float64 float8inc(float64 arg1);
+extern long float4eq(float32 arg1, float32 arg2);
+extern long float4ne(float32 arg1, float32 arg2);
+extern long float4lt(float32 arg1, float32 arg2);
+extern long float4le(float32 arg1, float32 arg2);
+extern long float4gt(float32 arg1, float32 arg2);
+extern long float4ge(float32 arg1, float32 arg2);
+extern long float8eq(float64 arg1, float64 arg2);
+extern long float8ne(float64 arg1, float64 arg2);
+extern long float8lt(float64 arg1, float64 arg2);
+extern long float8le(float64 arg1, float64 arg2);
+extern long float8gt(float64 arg1, float64 arg2);
+extern long float8ge(float64 arg1, float64 arg2);
+extern float64 ftod(float32 num);
+extern float32 dtof(float64 num);
+extern float64 dround(float64 arg1);
+extern float64 dtrunc(float64 arg1);
+extern float64 dsqrt(float64 arg1);
+extern float64 dcbrt(float64 arg1);
+extern float64 dpow(float64 arg1, float64 arg2);
+extern float64 dexp(float64 arg1);
+extern float64 dlog1(float64 arg1);
+extern float64 float48pl(float32 arg1, float64 arg2);
+extern float64 float48mi(float32 arg1, float64 arg2);
+extern float64 float48mul(float32 arg1, float64 arg2);
+extern float64 float48div(float32 arg1, float64 arg2);
+extern float64 float84pl(float64 arg1, float32 arg2);
+extern float64 float84mi(float64 arg1, float32 arg2);
+extern float64 float84mul(float64 arg1, float32 arg2);
+extern float64 float84div(float64 arg1, float32 arg2);
+extern long float48eq(float32 arg1, float64 arg2);
+extern long float48ne(float32 arg1, float64 arg2);
+extern long float48lt(float32 arg1, float64 arg2);
+extern long float48le(float32 arg1, float64 arg2);
+extern long float48gt(float32 arg1, float64 arg2);
+extern long float48ge(float32 arg1, float64 arg2);
+extern long float84eq(float64 arg1, float32 arg2);
+extern long float84ne(float64 arg1, float32 arg2);
+extern long float84lt(float64 arg1, float32 arg2);
+extern long float84le(float64 arg1, float32 arg2);
+extern long float84gt(float64 arg1, float32 arg2);
+extern long float84ge(float64 arg1, float32 arg2);
+
+/* geo-ops.c, geo-selfuncs.c */
+#include "utils/geo-decls.h"
+
+/* misc.c */
+extern bool NullValue(Datum value, bool *isNull);
+extern bool NonNullValue(Datum value, bool *isNull);
+extern int32 userfntest(int i);
+
+/* not_in.c */
+extern bool int4notin(int16 not_in_arg, char *relation_and_attr);
+extern bool oidnotin(Oid the_oid, char *compare);
+extern int my_varattno(Relation rd, char *a);
+
+/* oid.c */
+extern Oid *oid8in(char *oidString);
+extern char *oid8out(Oid (*oidArray)[]);
+extern Oid oidin(char *s);
+extern char *oidout(Oid o);
+extern int32 oideq(Oid arg1, Oid arg2);
+extern int32 oidne(Oid arg1, Oid arg2);
+extern int32 oid8eq(Oid arg1[], Oid arg2[]);
+
+/* regexp.c */
+extern bool char2regexeq(uint16 arg1, struct varlena *p);
+extern bool char2regexne(uint16 arg1, struct varlena *p);
+extern bool char4regexeq(uint32 arg1, struct varlena *p);
+extern bool char4regexne(uint32 arg1, struct varlena *p);
+extern bool char8regexeq(char *s, struct varlena *p);
+extern bool char8regexne(char *s, struct varlena *p);
+extern bool char16regexeq(char *s, struct varlena *p);
+extern bool char16regexne(char *s, struct varlena *p);
+extern bool textregexeq(struct varlena *s, struct varlena *p);
+extern bool textregexne(struct varlena *s, struct varlena *p);
+extern bool char2icregexeq(uint16 arg1, struct varlena *p);
+extern bool char2icregexne(uint16 arg1, struct varlena *p);
+extern bool char4icregexeq(uint32 arg1, struct varlena *p);
+extern bool char4icregexne(uint32 arg1, struct varlena *p);
+extern bool char8icregexeq(char *s, struct varlena *p);
+extern bool char8icregexne(char *s, struct varlena *p);
+extern bool char16icregexeq(char *s, struct varlena *p);
+extern bool char16icregexne(char *s, struct varlena *p);
+extern bool nameicregexeq(NameData *s, struct varlena *p);
+extern bool nameicregexne(NameData *s, struct varlena *p);
+extern bool texticregexeq(struct varlena *s, struct varlena *p);
+extern bool texticregexne(struct varlena *s, struct varlena *p);
+
+
+/* regproc.c */
+extern int32 regprocin(char *proname);
+extern char *regprocout(RegProcedure proid);
+extern Oid RegprocToOid(RegProcedure rp);
+
+/* selfuncs.c */
+extern float64 eqsel(Oid opid, Oid relid, AttrNumber attno, char *value, int32 flag);
+extern float64 neqsel(Oid opid, Oid relid, AttrNumber attno, char *value, int32 flag);
+extern float64 intltsel(Oid opid, Oid relid, AttrNumber attno, int32 value, int32 flag);
+extern float64 intgtsel(Oid opid, Oid relid, AttrNumber attno, int32 value, int32 flag);
+extern float64 eqjoinsel(Oid opid, Oid relid1, AttrNumber attno1, Oid relid2, AttrNumber attno2);
+extern float64 neqjoinsel(Oid opid, Oid relid1, AttrNumber attno1, Oid relid2, AttrNumber attno2);
+extern float64 intltjoinsel(Oid opid, Oid relid1, AttrNumber attno1, Oid relid2, AttrNumber attno2);
+extern float64 intgtjoinsel(Oid opid, Oid relid1, AttrNumber attno1, Oid relid2, AttrNumber attno2);
+extern float64 btreesel(Oid operatorOid, Oid indrelid, AttrNumber attributeNumber, char *constValue, int32 constFlag, int32 nIndexKeys, Oid indexrelid);
+extern float64 btreenpage(Oid operatorOid, Oid indrelid, AttrNumber attributeNumber, char *constValue, int32 constFlag, int32 nIndexKeys, Oid indexrelid);
+extern float64 hashsel(Oid operatorOid, Oid indrelid, AttrNumber attributeNumber, char *constValue, int32 constFlag, int32 nIndexKeys, Oid indexrelid);
+extern float64 hashnpage(Oid operatorOid, Oid indrelid, AttrNumber attributeNumber, char *constValue, int32 constFlag, int32 nIndexKeys, Oid indexrelid);
+extern float64 rtsel(Oid operatorOid, Oid indrelid, AttrNumber attributeNumber, char *constValue, int32 constFlag, int32 nIndexKeys, Oid indexrelid);
+extern float64 rtnpage(Oid operatorOid, Oid indrelid, AttrNumber attributeNumber, char *constValue, int32 constFlag, int32 nIndexKeys, Oid indexrelid);
+
+/* tid.c */
+extern ItemPointer tidin(char *str);
+extern char *tidout(ItemPointer itemPtr);
+
+/* varlena.c */
+extern struct varlena *byteain(char *inputText);
+extern struct varlena *shove_bytes(unsigned char *stuff, int len);
+extern char *byteaout(struct varlena *vlena);
+extern struct varlena *textin(char *inputText);
+extern char *textout(struct varlena *vlena);
+extern int32 texteq(struct varlena *arg1, struct varlena *arg2);
+extern int32 textne(struct varlena *arg1, struct varlena *arg2);
+extern int32 text_lt(struct varlena *arg1, struct varlena *arg2);
+extern int32 text_le(struct varlena *arg1, struct varlena *arg2);
+extern int32 text_gt(struct varlena *arg1, struct varlena *arg2);
+extern int32 text_ge(struct varlena *arg1, struct varlena *arg2);
+extern int32 byteaGetSize(struct varlena *v);
+extern int32 byteaGetByte(struct varlena *v, int32 n);
+extern int32 byteaGetBit(struct varlena *v, int32 n);
+extern struct varlena *byteaSetByte(struct varlena *v, int32 n, int32 newByte);
+extern struct varlena *byteaSetBit(struct varlena *v, int32 n, int32 newBit);
+
+/* acl.c */
+#include "utils/acl.h"
+
+#endif /* BUILTINS_H */
diff --git a/src/include/utils/catcache.h b/src/include/utils/catcache.h
new file mode 100644
index 0000000000..317e350543
--- /dev/null
+++ b/src/include/utils/catcache.h
@@ -0,0 +1,85 @@
+/*-------------------------------------------------------------------------
+ *
+ * catcache.h--
+ * Low-level catalog cache definitions.
+ *
+ *
+ * Copyright (c) 1994, Regents of the University of California
+ *
+ * $Id: catcache.h,v 1.1 1996/08/28 01:58:46 scrappy Exp $
+ *
+ *-------------------------------------------------------------------------
+ */
+#ifndef CATCACHE_H
+#define CATCACHE_H
+
+/* #define CACHEDEBUG turns DEBUG elogs on */
+
+#include "postgres.h"
+
+#include "access/skey.h"
+#include "access/htup.h"
+#include "utils/rel.h"
+#include "nodes/memnodes.h"
+#include "lib/dllist.h"
+
+/*
+ * struct catctup: tuples in the cache.
+ * struct catcache: information for managing a cache.
+ */
+
+typedef struct catctup {
+ HeapTuple ct_tup; /* A pointer to a tuple */
+ Dlelem *ct_node; /* points to LRU list is the CatCTup is in the cache,
+ else, points to the cache if the CatCTup is in
+ LRU list */
+} CatCTup;
+
+/* voodoo constants */
+#define NCCBUCK 500 /* CatCache buckets*/
+#define MAXTUP 300 /* Maximum # of tuples cached per cache */
+
+typedef struct catcache {
+ Oid relationId;
+ Oid indexId;
+ char *cc_relname; /* relation name for defered open */
+ char *cc_indname; /* index name for defered open */
+ HeapTuple (*cc_iscanfunc)(); /* index scanfunction */
+ TupleDesc cc_tupdesc; /* tuple descriptor from reldesc */
+ int id; /* XXX could be improved -hirohama */
+ short cc_ntup; /* # of tuples in this cache */
+ short cc_maxtup; /* max # of tuples allowed (LRU)*/
+ short cc_nkeys;
+ short cc_size;
+ short cc_key[4];
+ short cc_klen[4];
+ ScanKeyData cc_skey[4];
+ struct catcache *cc_next;
+ Dllist *cc_lrulist; /* LRU list, most recent first */
+ Dllist *cc_cache[NCCBUCK+1];
+} CatCache;
+
+#define InvalidCatalogCacheId (-1)
+
+extern struct catcache *Caches;
+extern GlobalMemory CacheCxt;
+
+extern void CatalogCacheInitializeCache(struct catcache *cache,
+ Relation relation);
+extern void CatalogCacheSetId(CatCache *cacheInOutP, int id);
+extern long comphash(long l, char *v);
+extern Index CatalogCacheComputeHashIndex(struct catcache *cacheInP);
+extern Index CatalogCacheComputeTupleHashIndex(struct catcache *cacheInOutP,
+ Relation relation, HeapTuple tuple);
+extern void CatCacheRemoveCTup(CatCache *cache, Dlelem *e);
+extern void CatalogCacheIdInvalidate(int cacheId, Index hashIndex,
+ ItemPointer pointer);
+extern void ResetSystemCache(void);
+extern CatCache *InitSysCache(char *relname, char *indname, int id, int nkeys,
+ int key[], HeapTuple (*iScanfuncP)());
+extern HeapTuple SearchSysCache(struct catcache *cache, Datum v1, Datum v2,
+ Datum v3, Datum v4);
+extern void RelationInvalidateCatalogCacheTuple(Relation relation,
+ HeapTuple tuple, void (*function)());
+
+#endif /* CATCACHE_H */
diff --git a/src/include/utils/datum.h b/src/include/utils/datum.h
new file mode 100644
index 0000000000..1a0b256616
--- /dev/null
+++ b/src/include/utils/datum.h
@@ -0,0 +1,64 @@
+/*-------------------------------------------------------------------------
+ *
+ * datum.h--
+ * POSTGRES abstract data type datum representation definitions.
+ *
+ *
+ * Copyright (c) 1994, Regents of the University of California
+ *
+ * $Id: datum.h,v 1.1 1996/08/28 01:58:48 scrappy Exp $
+ *
+ *-------------------------------------------------------------------------
+ */
+#ifndef DATUM_H
+#define DATUM_H
+
+#include "postgres.h"
+
+/*--------------------------------------------------------
+ * SOME NOT VERY PORTABLE ROUTINES ???
+ *--------------------------------------------------------
+ *
+ * In the implementation of the next routines we assume the following:
+ *
+ * A) if a type is "byVal" then all the information is stored in the
+ * Datum itself (i.e. no pointers involved!). In this case the
+ * length of the type is always greater than zero and less than
+ * "sizeof(Datum)"
+ * B) if a type is not "byVal" and it has a fixed length, then
+ * the "Datum" always contain a pointer to a stream of bytes.
+ * The number of significant bytes are always equal to the length of thr
+ * type.
+ * C) if a type is not "byVal" and is of variable length (i.e. it has
+ * length == -1) then "Datum" always points to a "struct varlena".
+ * This varlena structure has information about the actual length of this
+ * particular instance of the type and about its value.
+ */
+
+/*---------------
+ * datumGetSize
+ * find the "real" length of a datum
+ */
+extern Size datumGetSize(Datum value, Oid type, bool byVal, Size len);
+
+/*---------------
+ * datumCopy
+ * make a copy of a datum.
+ */
+extern Datum datumCopy(Datum value, Oid type, bool byVal, Size len);
+
+/*---------------
+ * datumFree
+ * free space that *might* have been palloced by "datumCopy"
+ */
+extern void datumFree(Datum value, Oid type, bool byVal, Size len);
+
+/*---------------
+ * datumIsEqual
+ * return true if thwo datums are equal, false otherwise.
+ * XXX : See comments in the code for restrictions!
+ */
+extern bool datumIsEqual(Datum value1, Datum value2, Oid type,
+ bool byVal, Size len);
+
+#endif /* DATUM_H */
diff --git a/src/include/utils/dynamic_loader.h b/src/include/utils/dynamic_loader.h
new file mode 100644
index 0000000000..81ea4a4cf5
--- /dev/null
+++ b/src/include/utils/dynamic_loader.h
@@ -0,0 +1,53 @@
+/*-------------------------------------------------------------------------
+ *
+ * dynamic_loader.h--
+ *
+ *
+ *
+ * Copyright (c) 1994, Regents of the University of California
+ *
+ * $Id: dynamic_loader.h,v 1.1 1996/08/28 01:58:49 scrappy Exp $
+ *
+ *-------------------------------------------------------------------------
+ */
+#ifndef DYNAMIC_LOADER_H
+#define DYNAMIC_LOADER_H
+
+#ifdef MIN
+#undef MIN
+#undef MAX
+#endif /* MIN */
+
+#ifdef WIN32
+#define MAXPATHLEN 250
+#endif
+
+#include <sys/param.h> /* for MAXPATHLEN */
+#include <sys/types.h> /* for dev_t, ino_t, etc. */
+#ifdef WIN32
+#include <wchar.h>
+#endif
+
+/*
+ * List of dynamically loaded files.
+ */
+
+typedef struct df_files {
+ char filename[MAXPATHLEN]; /* Full pathname of file */
+#ifdef WIN32
+ _dev_t device; /* Device file is on */
+ _ino_t inode; /* Inode number of file */
+#else
+ dev_t device; /* Device file is on */
+ ino_t inode; /* Inode number of file */
+#endif /* WIN32 */
+ void *handle; /* a handle for pg_dl* functions */
+ struct df_files *next;
+} DynamicFileList;
+
+extern void *pg_dlopen(char *filename);
+extern func_ptr pg_dlsym(void *handle, char *funcname);
+extern void pg_dlclose(void *handle);
+extern char *pg_dlerror(void);
+
+#endif /* DYNAMIC_LOADER_H */
diff --git a/src/include/utils/elog.h b/src/include/utils/elog.h
new file mode 100644
index 0000000000..4db2ced26c
--- /dev/null
+++ b/src/include/utils/elog.h
@@ -0,0 +1,38 @@
+/*-------------------------------------------------------------------------
+ *
+ * elog.h--
+ * POSTGRES error logging definitions.
+ *
+ *
+ * Copyright (c) 1994, Regents of the University of California
+ *
+ * $Id: elog.h,v 1.1 1996/08/28 01:58:52 scrappy Exp $
+ *
+ *-------------------------------------------------------------------------
+ */
+#ifndef ELOG_H
+#define ELOG_H
+
+#define NOTICE 0 /* random info - no special action */
+#define WARN -1 /* Warning error - return to known state */
+#define FATAL 1 /* Fatal error - abort process */
+#define DEBUG -2 /* debug message */
+#define NOIND -3 /* debug message, don't indent as far */
+
+#define PTIME 0x100 /* prepend time to message */
+#define POS 0x200 /* prepend source position to message */
+#define USERMSG 0x400 /* send message to user */
+#define TERM 0x800 /* send message to terminal */
+#define DBLOG 0x1000 /* put message in per db log */
+#define SLOG 0x2000 /* put message in system log */
+#define ABORT 0x4000 /* abort process after logging */
+
+#define ELOG_MAXLEN 4096
+
+
+/* uncomment the following if you want your elog's to be timestamped */
+/* #define ELOG_TIMESTAMPS */
+
+extern void elog(int lev, const char *fmt, ...);
+
+#endif /* ELOG_H */
diff --git a/src/include/utils/exc.h b/src/include/utils/exc.h
new file mode 100644
index 0000000000..8ed17d2409
--- /dev/null
+++ b/src/include/utils/exc.h
@@ -0,0 +1,101 @@
+/*-------------------------------------------------------------------------
+ *
+ * exc.h--
+ * POSTGRES exception handling definitions.
+ *
+ *
+ * Copyright (c) 1994, Regents of the University of California
+ *
+ * $Id: exc.h,v 1.1 1996/08/28 01:58:53 scrappy Exp $
+ *
+ *-------------------------------------------------------------------------
+ */
+#ifndef EXC_H
+#define EXC_H
+
+#include "c.h" /* for Exception, etc. */
+#include <setjmp.h>
+
+extern char *ExcFileName;
+extern Index ExcLineNumber;
+
+/*
+ * ExcMessage and Exception are now defined in c.h
+ */
+
+#if defined(PORTNAME_hpux) || \
+ defined(PORTNAME_linux) || \
+ defined(PORTNAME_next) || \
+ defined(WIN32)
+typedef jmp_buf ExcContext;
+#else
+typedef sigjmp_buf ExcContext;
+#endif
+
+typedef Exception* ExcId;
+typedef long ExcDetail;
+typedef char* ExcData;
+
+typedef struct ExcFrame {
+ struct ExcFrame *link;
+ ExcContext context;
+ ExcId id;
+ ExcDetail detail;
+ ExcData data;
+ ExcMessage message;
+} ExcFrame;
+
+extern ExcFrame* ExcCurFrameP;
+
+#define ExcBegin() \
+ { \
+ ExcFrame exception; \
+ \
+ exception.link = ExcCurFrameP; \
+ if (sigsetjmp(exception.context, 1) == 0) { \
+ ExcCurFrameP = &exception; \
+ {
+#define ExcExcept() \
+ } \
+ ExcCurFrameP = exception.link; \
+ } else { \
+ {
+#define ExcEnd() \
+ } \
+ } \
+ }
+
+#define raise4(x, t, d, message) \
+ ExcRaise(&(x), (ExcDetail)(t), (ExcData)(d), (ExcMessage)(message))
+
+#define reraise() \
+ raise4(*exception.id,exception.detail,exception.data,exception.message)
+
+typedef void ExcProc(Exception*, ExcDetail, ExcData, ExcMessage);
+
+
+/*
+ * prototypes for functions in exc.c
+ */
+extern void EnableExceptionHandling(bool on);
+extern void ExcPrint(Exception *excP, ExcDetail detail, ExcData data,
+ ExcMessage message);
+extern ExcProc *ExcGetUnCaught();
+extern ExcProc *ExcSetUnCaught(ExcProc *newP);
+extern void ExcUnCaught(Exception *excP, ExcDetail detail, ExcData data,
+ ExcMessage message);
+extern void ExcUnCaught(Exception *excP, ExcDetail detail, ExcData data,
+ ExcMessage message);
+extern void ExcRaise(Exception *excP,
+ ExcDetail detail,
+ ExcData data,
+ ExcMessage message);
+
+
+/*
+ * prototypes for functions in excabort.c
+ */
+extern void ExcAbort(const Exception *excP, ExcDetail detail, ExcData data,
+ ExcMessage message);
+
+#endif /* EXC_H */
diff --git a/src/include/utils/excid.h b/src/include/utils/excid.h
new file mode 100644
index 0000000000..50431e3fbf
--- /dev/null
+++ b/src/include/utils/excid.h
@@ -0,0 +1,31 @@
+/*-------------------------------------------------------------------------
+ *
+ * excid.h--
+ * POSTGRES known exception identifier definitions.
+ *
+ *
+ * Copyright (c) 1994, Regents of the University of California
+ *
+ * $Id: excid.h,v 1.1 1996/08/28 01:58:55 scrappy Exp $
+ *
+ *-------------------------------------------------------------------------
+ */
+#ifndef EXCID_H
+#define EXCID_H
+
+#include "c.h"
+#include "utils/exc.h" /* for Exception */
+
+extern Exception FailedAssertion;
+extern Exception BadState;
+extern Exception BadArg;
+extern Exception BadAllocSize;
+extern Exception ExhaustedMemory;
+extern Exception Unimplemented;
+
+extern Exception CatalogFailure; /* XXX inconsistent naming style */
+extern Exception InternalError; /* XXX inconsistent naming style */
+extern Exception SemanticError; /* XXX inconsistent naming style */
+extern Exception SystemError; /* XXX inconsistent naming style */
+
+#endif /* EXCID_H */
diff --git a/src/include/utils/fcache.h b/src/include/utils/fcache.h
new file mode 100644
index 0000000000..9802fdbfce
--- /dev/null
+++ b/src/include/utils/fcache.h
@@ -0,0 +1,55 @@
+/*-------------------------------------------------------------------------
+ *
+ * fcache.h--
+ *
+ *
+ *
+ * Copyright (c) 1994, Regents of the University of California
+ *
+ * $Id: fcache.h,v 1.1 1996/08/28 01:58:57 scrappy Exp $
+ *
+ *-------------------------------------------------------------------------
+ */
+#ifndef FCACHE_H
+#define FCACHE_H
+
+#include "fmgr.h"
+
+typedef struct
+{
+ int typlen; /* length of the return type */
+ int typbyval; /* true if return type is pass by value */
+ func_ptr func; /* address of function to call (for c funcs) */
+ Oid foid; /* oid of the function in pg_proc */
+ Oid language; /* oid of the language in pg_language */
+ int nargs; /* number of arguments */
+
+ /* Might want to make these two arrays of size MAXFUNCARGS */
+
+ Oid *argOidVect; /* oids of all the arguments */
+ bool *nullVect; /* keep track of null arguments */
+
+ char *src; /* source code of the function */
+ char *bin; /* binary object code ?? */
+ char *func_state; /* fuction_state struct for execution */
+
+ bool oneResult; /* true we only want 1 result from the
+ * function
+ */
+ bool hasSetArg; /* true if func is part of a nested dot expr
+ * whose argument is func returning a set ugh!
+ */
+
+ Pointer funcSlot; /* if one result we need to copy it before we
+ * end execution of the function and free stuff
+ */
+
+ char *setArg; /* current argument for nested dot execution
+ * Nested dot expressions mean we have funcs
+ * whose argument is a set of tuples
+ */
+
+ bool istrusted; /* trusted fn? */
+} FunctionCache, *FunctionCachePtr;
+
+#endif /* FCACHE_H */
diff --git a/src/include/utils/fcache2.h b/src/include/utils/fcache2.h
new file mode 100644
index 0000000000..a7dd535722
--- /dev/null
+++ b/src/include/utils/fcache2.h
@@ -0,0 +1,19 @@
+/*-------------------------------------------------------------------------
+ *
+ * fcache2.h--
+ *
+ *
+ *
+ * Copyright (c) 1994, Regents of the University of California
+ *
+ * $Id: fcache2.h,v 1.1 1996/08/28 01:58:58 scrappy Exp $
+ *
+ *-------------------------------------------------------------------------
+ */
+#ifndef FCACHE2_H
+#define FCACHE2_H
+
+extern void
+setFcache(Node *node, Oid foid, List *argList, ExprContext *econtext);
+
+#endif /* FCACHE2_H */
diff --git a/src/include/utils/fmgrtab.h b/src/include/utils/fmgrtab.h
new file mode 100644
index 0000000000..8fe5547b54
--- /dev/null
+++ b/src/include/utils/fmgrtab.h
@@ -0,0 +1,29 @@
+/*-------------------------------------------------------------------------
+ *
+ * fmgrtab.h--
+ *
+ *
+ *
+ * Copyright (c) 1994, Regents of the University of California
+ *
+ * $Id: fmgrtab.h,v 1.1 1996/08/28 01:58:59 scrappy Exp $
+ *
+ *-------------------------------------------------------------------------
+ */
+#ifndef FMGRTAB_H
+#define FMGRTAB_H
+
+#include "postgres.h" /* for ObjectId */
+#include "fmgr.h" /* genearated by Gen_fmgrtab.sh */
+
+typedef struct {
+ Oid proid;
+ uint16 nargs;
+ func_ptr func;
+ char* funcName;
+} FmgrCall;
+
+extern FmgrCall *fmgr_isbuiltin(Oid id);
+extern func_ptr fmgr_lookupByName(char* name);
+
+#endif /* FMGRTAB_H */
diff --git a/src/include/utils/geo-decls.h b/src/include/utils/geo-decls.h
new file mode 100644
index 0000000000..b4292c38f9
--- /dev/null
+++ b/src/include/utils/geo-decls.h
@@ -0,0 +1,248 @@
+/*-------------------------------------------------------------------------
+ *
+ * geo-decls.h--
+ * Declarations for various 2D constructs.
+ *
+ *
+ * Copyright (c) 1994, Regents of the University of California
+ *
+ * $Id: geo-decls.h,v 1.1 1996/08/28 01:59:03 scrappy Exp $
+ *
+ * NOTE
+ * These routines do *not* use the float types from adt/.
+ *
+ * XXX These routines were not written by a numerical analyst.
+ *
+ *-------------------------------------------------------------------------
+ */
+#ifndef GEO_DECLS_H
+#define GEO_DECLS_H
+
+/*#ifndef FmgrIncluded -- seems like always included. (it's FMgrIncluded) AY */
+
+/*--------------------------------------------------------------------
+ * Useful floating point utilities and constants.
+ *-------------------------------------------------------------------*/
+
+#include <math.h>
+#include "c.h"
+
+#define EPSILON 1.0E-06
+
+#define FPzero(A) (fabs(A) <= EPSILON)
+#define FPeq(A,B) (fabs((A) - (B)) <= EPSILON)
+#define FPlt(A,B) ((B) - (A) > EPSILON)
+#define FPle(A,B) ((A) - (B) <= EPSILON)
+#define FPgt(A,B) ((A) - (B) > EPSILON)
+#define FPge(A,B) ((B) - (A) <= EPSILON)
+
+#define HYPOT(A, B) sqrt((A) * (A) + (B) * (B))
+
+/*--------------------------------------------------------------------
+ * Memory management.
+ *-------------------------------------------------------------------*/
+
+#define PALLOC(SIZE) palloc(SIZE)
+#define PFREE(P) pfree(P)
+#define PALLOCTYPE(TYPE) (TYPE *) PALLOC(sizeof(TYPE))
+
+/*#endif !FmgrIncluded */
+
+/*---------------------------------------------------------------------
+ * Point - (x,y)
+ *-------------------------------------------------------------------*/
+typedef struct {
+ double x, y;
+} Point;
+
+
+/*---------------------------------------------------------------------
+ * LSEG - A straight line, specified by endpoints.
+ *-------------------------------------------------------------------*/
+typedef struct {
+ Point p[2];
+
+ double m; /* precomputed to save time, not in tuple */
+} LSEG;
+
+
+/*---------------------------------------------------------------------
+ * PATH - Specified by vertex points.
+ *-------------------------------------------------------------------*/
+typedef struct {
+ int32 length; /* XXX varlena */
+ int32 npts;
+ int32 closed; /* is this a closed polygon? */
+ int32 dummy; /* padding to make it double align */
+ Point p[1]; /* variable length array of POINTs */
+} PATH;
+
+
+/*---------------------------------------------------------------------
+ * LINE - Specified by its general equation (Ax+By+C=0).
+ * If there is a y-intercept, it is C, which
+ * incidentally gives a freebie point on the line
+ * (if B=0, then C is the x-intercept).
+ * Slope m is precalculated to save time; if
+ * the line is not vertical, m == A.
+ *-------------------------------------------------------------------*/
+typedef struct {
+ double A, B, C;
+ double m;
+} LINE;
+
+
+/*---------------------------------------------------------------------
+ * BOX - Specified by two corner points, which are
+ * sorted to save calculation time later.
+ *-------------------------------------------------------------------*/
+typedef struct {
+ double xh, yh, xl, yl; /* high and low coords */
+} BOX;
+
+/*---------------------------------------------------------------------
+ * POLYGON - Specified by an array of doubles defining the points,
+ * keeping the number of points and the bounding box for
+ * speed purposes.
+ *-------------------------------------------------------------------*/
+typedef struct {
+ int32 size; /* XXX varlena */
+ int32 npts;
+ BOX boundbox;
+ char pts[1];
+} POLYGON;
+
+
+/*
+ * in geo-ops.h
+ */
+extern BOX *box_in(char *str);
+extern char *box_out(BOX *box);
+extern BOX *box_construct(double x1, double x2, double y1, double y2);
+extern BOX *box_fill(BOX *result, double x1, double x2, double y1, double y2);
+extern BOX *box_copy(BOX *box);
+extern long box_same(BOX *box1, BOX *box2);
+extern long box_overlap(BOX *box1, BOX *box2);
+extern long box_overleft(BOX *box1, BOX *box2);
+extern long box_left(BOX *box1, BOX *box2);
+extern long box_right(BOX *box1, BOX *box2);
+extern long box_overright(BOX *box1, BOX *box2);
+extern long box_contained(BOX *box1, BOX *box2);
+extern long box_contain(BOX *box1, BOX *box2);
+extern long box_below(BOX *box1, BOX *box2);
+extern long box_above(BOX *box1, BOX *box2);
+extern long box_lt(BOX *box1, BOX *box2);
+extern long box_gt(BOX *box1, BOX *box2);
+extern long box_eq(BOX *box1, BOX *box2);
+extern long box_le(BOX *box1, BOX *box2);
+extern long box_ge(BOX *box1, BOX *box2);
+extern double *box_area(BOX *box);
+extern double *box_length(BOX *box);
+extern double *box_height(BOX *box);
+extern double *box_distance(BOX *box1, BOX *box2);
+extern Point *box_center(BOX *box);
+extern double box_ar(BOX *box);
+extern double box_ln(BOX *box);
+extern double box_ht(BOX *box);
+extern double box_dt(BOX *box1, BOX *box2);
+extern BOX *box_intersect(BOX *box1, BOX *box2);
+extern LSEG *box_diagonal(BOX *box);
+extern LINE *line_construct_pm(Point *pt, double m);
+extern LINE *line_construct_pp(Point *pt1, Point *pt2);
+extern long line_intersect(LINE *l1, LINE *l2);
+extern long line_parallel(LINE *l1, LINE *l2);
+extern long line_perp(LINE *l1, LINE *l2);
+extern long line_vertical(LINE *line);
+extern long line_horizontal(LINE *line);
+extern long line_eq(LINE *l1, LINE *l2);
+extern double *line_distance(LINE *l1, LINE *l2);
+extern Point *line_interpt(LINE *l1, LINE *l2);
+extern PATH *path_in(char *str);
+extern char *path_out(PATH *path);
+extern long path_n_lt(PATH *p1, PATH *p2);
+extern long path_n_gt(PATH *p1, PATH *p2);
+extern long path_n_eq(PATH *p1, PATH *p2);
+extern long path_n_le(PATH *p1, PATH *p2);
+extern long path_n_ge(PATH *p1, PATH *p2);
+extern long path_inter(PATH *p1, PATH *p2);
+extern double *path_distance(PATH *p1, PATH *p2);
+extern double *path_length(PATH *path);
+extern double path_ln(PATH *path);
+extern Point *point_in(char *str);
+extern char *point_out(Point *pt);
+extern Point *point_construct(double x, double y);
+extern Point *point_copy(Point *pt);
+extern long point_left(Point *pt1, Point *pt2);
+extern long point_right(Point *pt1, Point *pt2);
+extern long point_above(Point *pt1, Point *pt2);
+extern long point_below(Point *pt1, Point *pt2);
+extern long point_vert(Point *pt1, Point *pt2);
+extern long point_horiz(Point *pt1, Point *pt2);
+extern long point_eq(Point *pt1, Point *pt2);
+extern long pointdist(Point *p1, Point *p2);
+extern double *point_distance(Point *pt1, Point *pt2);
+extern double point_dt(Point *pt1, Point *pt2);
+extern double *point_slope(Point *pt1, Point *pt2);
+extern double point_sl(Point *pt1, Point *pt2);
+extern LSEG *lseg_in(char *str);
+extern char *lseg_out(LSEG *ls);
+extern LSEG *lseg_construct(Point *pt1, Point *pt2);
+extern void statlseg_construct(LSEG *lseg, Point *pt1, Point *pt2);
+extern long lseg_intersect(LSEG *l1, LSEG *l2);
+extern long lseg_parallel(LSEG *l1, LSEG *l2);
+extern long lseg_perp(LSEG *l1, LSEG *l2);
+extern long lseg_vertical(LSEG *lseg);
+extern long lseg_horizontal(LSEG *lseg);
+extern long lseg_eq(LSEG *l1, LSEG *l2);
+extern double *lseg_distance(LSEG *l1, LSEG *l2);
+extern double lseg_dt(LSEG *l1, LSEG *l2);
+extern Point *lseg_interpt(LSEG *l1, LSEG *l2);
+extern double *dist_pl(Point *pt, LINE *line);
+extern double *dist_ps(Point *pt, LSEG *lseg);
+extern double *dist_ppth(Point *pt, PATH *path);
+extern double *dist_pb(Point *pt, BOX *box);
+extern double *dist_sl(LSEG *lseg, LINE *line);
+extern double *dist_sb(LSEG *lseg, BOX *box);
+extern double *dist_lb(LINE *line, BOX *box);
+extern Point *interpt_sl(LSEG *lseg, LINE *line);
+extern Point *close_pl(Point *pt, LINE *line);
+extern Point *close_ps(Point *pt, LSEG *lseg);
+extern Point *close_pb(Point *pt, BOX *box);
+extern Point *close_sl(LSEG *lseg, LINE *line);
+extern Point *close_sb(LSEG *lseg, BOX *box);
+extern Point *close_lb(LINE *line, BOX *box);
+extern long on_pl(Point *pt, LINE *line);
+extern long on_ps(Point *pt, LSEG *lseg);
+extern long on_pb(Point *pt, BOX *box);
+extern long on_ppath(Point *pt, PATH *path);
+extern long on_sl(LSEG *lseg, LINE *line);
+extern long on_sb(LSEG *lseg, BOX *box);
+extern long inter_sl(LSEG *lseg, LINE *line);
+extern long inter_sb(LSEG *lseg, BOX *box);
+extern long inter_lb(LINE *line, BOX *box);
+extern void make_bound_box(POLYGON *poly);
+extern POLYGON *poly_in(char *s);
+extern long poly_pt_count(char *s, char delim);
+extern char *poly_out(POLYGON *poly);
+extern double poly_max(double *coords, int ncoords);
+extern double poly_min(double *coords, int ncoords);
+extern long poly_left(POLYGON *polya, POLYGON *polyb);
+extern long poly_overleft(POLYGON *polya, POLYGON *polyb);
+extern long poly_right(POLYGON *polya, POLYGON *polyb);
+extern long poly_overright(POLYGON *polya, POLYGON *polyb);
+extern long poly_same(POLYGON *polya, POLYGON *polyb);
+extern long poly_overlap(POLYGON *polya, POLYGON *polyb);
+extern long poly_contain(POLYGON *polya, POLYGON *polyb);
+extern long poly_contained(POLYGON *polya, POLYGON *polyb);
+
+/* geo-selfuncs.c */
+#if 0 /* FIX ME! */
+extern float64 areasel(Oid opid, Oid relid, AttrNumber attno, char *value, int32 flag);
+extern float64 areajoinsel(Oid opid, Oid relid, AttrNumber attno, char *value, int32 flag);
+extern float64 leftsel(Oid opid, Oid relid, AttrNumber attno, char *value, int32 flag);
+extern float64 leftjoinsel(Oid opid, Oid relid, AttrNumber attno, char *value, int32 flag);
+extern float64 contsel(Oid opid, Oid relid, AttrNumber attno, char *value, int32 flag);
+extern float64 contjoinsel(Oid opid, Oid relid, AttrNumber attno, char *value, int32 flag);
+#endif
+
+#endif /* GEO_DECLS_H */
diff --git a/src/include/utils/hsearch.h b/src/include/utils/hsearch.h
new file mode 100644
index 0000000000..0818d1ba79
--- /dev/null
+++ b/src/include/utils/hsearch.h
@@ -0,0 +1,141 @@
+/*-------------------------------------------------------------------------
+ *
+ * hsearch.h--
+ * for hashing in the new buffer manager
+ *
+ *
+ * Copyright (c) 1994, Regents of the University of California
+ *
+ * $Id: hsearch.h,v 1.1 1996/08/28 01:59:04 scrappy Exp $
+ *
+ *-------------------------------------------------------------------------
+ */
+#ifndef HSEARCH_H
+#define HSEARCH_H
+
+#include "postgres.h"
+
+/*
+ * Constants
+ */
+# define DEF_BUCKET_SIZE 256
+# define DEF_BUCKET_SHIFT 8 /* log2(BUCKET) */
+# define DEF_SEGSIZE 256
+# define DEF_SEGSIZE_SHIFT 8 /* log2(SEGSIZE) */
+# define DEF_DIRSIZE 256
+# define PRIME1 37
+# define PRIME2 1048583
+# define DEF_FFACTOR 1
+# define SPLTMAX 8
+
+
+/*
+ * Hash bucket is actually bigger than this. Key field can have
+ * variable length and a variable length data field follows it.
+ */
+typedef struct element {
+ unsigned long next; /* secret from user */
+ long key;
+} ELEMENT;
+
+typedef unsigned long BUCKET_INDEX;
+/* segment is an array of bucket pointers */
+typedef BUCKET_INDEX *SEGMENT;
+typedef unsigned long SEG_OFFSET;
+
+typedef struct hashhdr {
+ long bsize; /* Bucket/Page Size */
+ long bshift; /* Bucket shift */
+ long dsize; /* Directory Size */
+ long ssize; /* Segment Size */
+ long sshift; /* Segment shift */
+ long max_bucket; /* ID of Maximum bucket in use */
+ long high_mask; /* Mask to modulo into entire table */
+ long low_mask; /* Mask to modulo into lower half of table */
+ long ffactor; /* Fill factor */
+ long nkeys; /* Number of keys in hash table */
+ long nsegs; /* Number of allocated segments */
+ long keysize; /* hash key length in bytes */
+ long datasize; /* elem data length in bytes */
+ long max_dsize; /* 'dsize' limit if directory is fixed size */
+ BUCKET_INDEX freeBucketIndex;
+ /* index of first free bucket */
+#ifdef HASH_STATISTICS
+ long accesses;
+ long collisions;
+#endif
+} HHDR;
+
+typedef struct htab {
+ HHDR *hctl; /* shared control information */
+ long (*hash)(); /* Hash Function */
+ char *segbase; /* segment base address for
+ * calculating pointer values
+ */
+ SEG_OFFSET *dir; /* 'directory' of segm starts */
+ long *(*alloc)(); /* memory allocator
+ * (long * for alignment reasons)
+ */
+
+} HTAB;
+
+typedef struct hashctl {
+ long bsize; /* Bucket Size */
+ long ssize; /* Segment Size */
+ long dsize; /* Dirsize Size */
+ long ffactor; /* Fill factor */
+ long (*hash)(); /* Hash Function */
+ long keysize; /* hash key length in bytes */
+ long datasize; /* elem data length in bytes */
+ long max_size; /* limit to dsize if directory size is limited */
+ long *segbase; /* base for calculating bucket + seg ptrs */
+ long * (*alloc)(); /* memory allocation function */
+ long *dir; /* directory if allocated already */
+ long *hctl; /* location of header information in shd mem */
+} HASHCTL;
+
+/* Flags to indicate action for hctl */
+#define HASH_BUCKET 0x001 /* Setting bucket size */
+#define HASH_SEGMENT 0x002 /* Setting segment size */
+#define HASH_DIRSIZE 0x004 /* Setting directory size */
+#define HASH_FFACTOR 0x008 /* Setting fill factor */
+#define HASH_FUNCTION 0x010 /* Set user defined hash function */
+#define HASH_ELEM 0x020 /* Setting key/data size */
+#define HASH_SHARED_MEM 0x040 /* Setting shared mem const */
+#define HASH_ATTACH 0x080 /* Do not initialize hctl */
+#define HASH_ALLOC 0x100 /* Setting memory allocator */
+
+
+/* seg_alloc assumes that INVALID_INDEX is 0*/
+#define INVALID_INDEX (0)
+#define NO_MAX_DSIZE (-1)
+/* number of hash buckets allocated at once */
+#define BUCKET_ALLOC_INCR (30)
+
+/* hash_search operations */
+typedef enum {
+ HASH_FIND,
+ HASH_ENTER,
+ HASH_REMOVE,
+ HASH_FIND_SAVE,
+ HASH_REMOVE_SAVED
+} HASHACTION;
+
+/*
+ * prototypes from functions in dynahash.c
+ */
+extern HTAB *hash_create(int nelem, HASHCTL *info, int flags);
+extern void hash_destroy(HTAB *hashp);
+extern void hash_stats(char *where, HTAB *hashp);
+extern long *hash_search(HTAB *hashp, char *keyPtr, HASHACTION action,
+ bool *foundPtr);
+extern long *hash_seq(HTAB *hashp);
+
+/*
+ * prototypes from functions in hashfn.c
+ */
+extern long string_hash(char *key, int keysize);
+extern long tag_hash(int *key, int keysize);
+extern long disk_hash(char *key);
+
+#endif /* HSEARCH_H */
diff --git a/src/include/utils/inval.h b/src/include/utils/inval.h
new file mode 100644
index 0000000000..7b5418e14a
--- /dev/null
+++ b/src/include/utils/inval.h
@@ -0,0 +1,56 @@
+/*-------------------------------------------------------------------------
+ *
+ * inval.h--
+ * POSTGRES cache invalidation dispatcher definitions.
+ *
+ *
+ * Copyright (c) 1994, Regents of the University of California
+ *
+ * $Id: inval.h,v 1.1 1996/08/28 01:59:05 scrappy Exp $
+ *
+ *-------------------------------------------------------------------------
+ */
+#ifndef INVAL_H
+#define INVAL_H
+
+#include "postgres.h"
+#include "access/htup.h"
+#include "utils/rel.h"
+
+extern void DiscardInvalid(void);
+
+extern void RegisterInvalid(bool send);
+
+extern void SetRefreshWhenInvalidate(bool on);
+
+extern void RelationInvalidateHeapTuple(Relation relation, HeapTuple tuple);
+
+/*
+ * POSTGRES local cache invalidation definitions. (originates from linval.h)
+ */
+typedef struct InvalidationUserData {
+ struct InvalidationUserData *dataP[1]; /* VARIABLE LENGTH */
+} InvalidationUserData; /* VARIABLE LENGTH STRUCTURE */
+
+typedef struct InvalidationEntryData {
+ InvalidationUserData *nextP;
+ InvalidationUserData userData; /* VARIABLE LENGTH ARRAY */
+} InvalidationEntryData; /* VARIABLE LENGTH STRUCTURE */
+
+typedef Pointer InvalidationEntry;
+
+typedef InvalidationEntry LocalInvalid;
+
+#define EmptyLocalInvalid NULL
+
+extern InvalidationEntry InvalidationEntryAllocate(uint16 size);
+
+extern LocalInvalid LocalInvalidRegister(LocalInvalid invalid,
+ InvalidationEntry entry);
+
+extern void LocalInvalidInvalidate(LocalInvalid invalid, void (*function)());
+
+extern void getmyrelids(void);
+
+#endif /* INVAL_H */
+
diff --git a/src/include/utils/lselect.h b/src/include/utils/lselect.h
new file mode 100644
index 0000000000..d130f3dd2a
--- /dev/null
+++ b/src/include/utils/lselect.h
@@ -0,0 +1,40 @@
+/*-------------------------------------------------------------------------
+ *
+ * lselect.h--
+ * definitions for the replacement selection algorithm.
+ *
+ *
+ * Copyright (c) 1994, Regents of the University of California
+ *
+ * $Id: lselect.h,v 1.1 1996/08/28 01:59:07 scrappy Exp $
+ *
+ *-------------------------------------------------------------------------
+ */
+#ifndef LSELECT_H
+#define LSELECT_H
+
+#include "c.h"
+#include "access/htup.h"
+
+struct leftist {
+ short lt_dist; /* distance to leaf/empty node */
+ short lt_devnum; /* device number of tuple */
+ HeapTuple lt_tuple;
+ struct leftist *lt_left;
+ struct leftist *lt_right;
+};
+
+extern struct leftist *Tuples;
+
+extern struct leftist *lmerge(struct leftist *pt, struct leftist *qt);
+extern HeapTuple gettuple(struct leftist **treep, short *devnum);
+extern int puttuple(struct leftist **treep, HeapTuple newtuple, int devnum);
+extern void dumptuples(FILE *file);
+extern int tuplecmp(HeapTuple ltup, HeapTuple rtup);
+
+#ifdef EBUG
+extern void checktree(struct leftist *tree);
+extern int checktreer(struct leftist *tree, int level);
+#endif /* EBUG */
+
+#endif /* LSELECT_H */
diff --git a/src/include/utils/lsyscache.h b/src/include/utils/lsyscache.h
new file mode 100644
index 0000000000..2eb66f0bf5
--- /dev/null
+++ b/src/include/utils/lsyscache.h
@@ -0,0 +1,45 @@
+/*-------------------------------------------------------------------------
+ *
+ * lsyscache.h--
+ *
+ *
+ *
+ * Copyright (c) 1994, Regents of the University of California
+ *
+ * $Id: lsyscache.h,v 1.1 1996/08/28 01:59:08 scrappy Exp $
+ *
+ *-------------------------------------------------------------------------
+ */
+#ifndef LSYSCACHE_H
+#define LSYSCACHE_H
+
+#include "access/htup.h"
+
+extern bool op_class(Oid opid, int32 opclass, Oid amopid);
+extern char *get_attname(Oid relid, AttrNumber attnum);
+extern AttrNumber get_attnum(Oid relid, char *attname);
+extern Oid get_atttype(Oid relid, AttrNumber attnum);
+extern bool get_attisset(Oid relid, char *attname);
+extern RegProcedure get_opcode(Oid opid);
+extern char *get_opname(Oid opid);
+extern bool op_mergesortable(Oid opid, Oid ltype, Oid rtype,
+ Oid *leftOp, Oid *rightOp);
+extern Oid op_hashjoinable(Oid opid, Oid ltype, Oid rtype);
+extern Oid get_commutator(Oid opid);
+extern HeapTuple get_operator_tuple(Oid opno);
+extern Oid get_negator(Oid opid);
+extern RegProcedure get_oprrest(Oid opid);
+extern RegProcedure get_oprjoin(Oid opid);
+extern int get_relnatts(Oid relid);
+extern char *get_rel_name(Oid relid);
+extern struct varlena * get_relstub(Oid relid, int no, bool *islast);
+extern Oid get_ruleid(char *rulename);
+extern Oid get_eventrelid(Oid ruleid);
+extern int16 get_typlen(Oid typid);
+extern char get_typalign(Oid typid);
+extern bool get_typbyval(Oid typid);
+extern struct varlena *get_typdefault(Oid typid);
+extern char get_typtype(Oid typid);
+
+#endif /* LSYSCACHE_H */
+
diff --git a/src/include/utils/mcxt.h b/src/include/utils/mcxt.h
new file mode 100644
index 0000000000..ca047cd4c4
--- /dev/null
+++ b/src/include/utils/mcxt.h
@@ -0,0 +1,56 @@
+/*-------------------------------------------------------------------------
+ *
+ * mcxt.h--
+ * POSTGRES memory context definitions.
+ *
+ *
+ * Copyright (c) 1994, Regents of the University of California
+ *
+ * $Id: mcxt.h,v 1.1 1996/08/28 01:59:09 scrappy Exp $
+ *
+ *-------------------------------------------------------------------------
+ */
+#ifndef MCXT_H
+#define MCXT_H
+
+#include "c.h"
+
+#include "nodes/memnodes.h"
+#include "nodes/nodes.h"
+
+extern MemoryContext CurrentMemoryContext;
+extern MemoryContext TopMemoryContext;
+
+
+/*
+ * MaxAllocSize --
+ * Arbitrary limit on size of allocations.
+ *
+ * Note:
+ * There is no guarantee that allocations smaller than MaxAllocSize
+ * will succeed. Allocation requests larger than MaxAllocSize will
+ * be summarily denied.
+ *
+ * This value should not be referenced except in one place in the code.
+ *
+ * XXX This should be defined in a file of tunable constants.
+ */
+#define MaxAllocSize (0xfffffff) /* 16G - 1 */
+
+/*
+ * prototypes for functions in mcxt.c
+ */
+extern void EnableMemoryContext(bool on);
+extern Pointer MemoryContextAlloc(MemoryContext context, Size size);
+extern Pointer MemoryContextRealloc(MemoryContext context,
+ Pointer pointer,
+ Size size);
+extern void MemoryContextFree(MemoryContext context, Pointer pointer);
+extern char *MemoryContextGetName(MemoryContext context);
+extern Size PointerGetAllocSize(Pointer pointer);
+extern MemoryContext MemoryContextSwitchTo(MemoryContext context);
+extern GlobalMemory CreateGlobalMemory(char *name);
+extern void GlobalMemoryDestroy(GlobalMemory context);
+
+
+#endif /* MCXT_H */
diff --git a/src/include/utils/memutils.h b/src/include/utils/memutils.h
new file mode 100644
index 0000000000..5582bd6b68
--- /dev/null
+++ b/src/include/utils/memutils.h
@@ -0,0 +1,281 @@
+/*-------------------------------------------------------------------------
+ *
+ * memutils.h--
+ * this file contains general memory alignment, allocation
+ * and manipulation stuff that used to be spread out
+ * between the following files:
+ *
+ * align.h alignment macros
+ * aset.h memory allocation set stuff
+ * oset.h (used by aset.h)
+ * (bit.h bit array type / extern)
+ * clib.h mem routines
+ * limit.h max bits/byte, etc.
+ *
+ *
+ * Copyright (c) 1994, Regents of the University of California
+ *
+ * $Id: memutils.h,v 1.1 1996/08/28 01:59:10 scrappy Exp $
+ *
+ * NOTES
+ * some of the information in this file will be moved to
+ * other files, (like MaxHeapTupleSize and MaxAttributeSize).
+ *
+ *-------------------------------------------------------------------------
+ */
+#ifndef MEMUTILS_H
+#define MEMUTILS_H
+
+#include "c.h"
+
+#if 0
+/*****************************************************************************
+ * align.h - alignment macros *
+ ****************************************************************************
+ [TRH] Let the compiler decide what alignment it uses instead of
+tending
+ we know better.
+ GCC (at least v2.5.8 and up) has an __alignof__ keyword.
+ However, we cannot use it here since on some architectures it reports
+ just a _recommended_ alignment instead of the actual alignment used in
+ padding structures (or at least, this is how I understand gcc's
+s...)
+ So define a macro that gives us the _actual_ alignment inside a struct.
+ {{note: assumes that alignment size is always a power of 2.}}
+ */
+#define _ALIGNSIZE(TYPE) offsetof(struct { char __c; TYPE __t;}, __t)
+#define _ALIGN(TYPE, LEN) \
+ (((long)(LEN) + (_ALIGNSIZE(TYPE) - 1)) & ~(_ALIGNSIZE(TYPE) - 1))
+#define SHORTALIGN(LEN) _ALIGN(short, (LEN))
+#define INTALIGN(LEN) _ALIGN(int, (LEN))
+#define LONGALIGN(LEN) _ALIGN(long, (LEN))
+#define DOUBLEALIGN(LEN) _ALIGN(double, (LEN))
+#define MAXALIGN(LEN) _ALIGN(double, (LEN))
+
+#endif /* 0 */
+
+/*
+ * SHORTALIGN(LEN) - length (or address) aligned for shorts
+ */
+#define SHORTALIGN(LEN)\
+ (((long)(LEN) + (sizeof (short) - 1)) & ~(sizeof (short) - 1))
+
+#define INTALIGN(LEN)\
+ (((long)(LEN) + (sizeof (int) - 1)) & ~(sizeof (int) -1))
+
+/*
+ * LONGALIGN(LEN) - length (or address) aligned for longs
+ */
+#if defined(sun) && ! defined(sparc)
+#define LONGALIGN(LEN) SHORTALIGN(LEN)
+#elif defined (PORTNAME_alpha)
+#define LONGALIGN(LEN)\
+ (((long)(LEN) + (sizeof (int) - 1)) & ~(sizeof (int) -1))
+#else
+#define LONGALIGN(LEN)\
+ (((long)(LEN) + (sizeof (long) - 1)) & ~(sizeof (long) -1))
+#endif
+
+#define DOUBLEALIGN(LEN)\
+ (((long)(LEN) + (sizeof (double) - 1)) & ~(sizeof (double) -1))
+
+#define MAXALIGN(LEN)\
+ (((long)(LEN) + (sizeof (double) - 1)) & ~(sizeof (double) -1))
+
+/*****************************************************************************
+ * bit.h *
+ *****************************************************************************/
+#include "utils/bit.h"
+
+/*****************************************************************************
+ * oset.h -- Fixed format ordered set definitions. *
+ *****************************************************************************/
+/* Note:
+ * Fixed format ordered sets are <EXPLAIN>.
+ * XXX This is a preliminary version. Work is needed to explain
+ * XXX semantics of the external definitions. Otherwise, the
+ * XXX functional interface should not change.
+ *
+ * Identification:
+ * $Header: /cvsroot/pgsql/src/include/utils/memutils.h,v 1.1 1996/08/28 01:59:10 scrappy Exp $
+ */
+
+typedef struct OrderedElemData OrderedElemData;
+typedef OrderedElemData* OrderedElem;
+
+typedef struct OrderedSetData OrderedSetData;
+typedef OrderedSetData* OrderedSet;
+
+struct OrderedElemData {
+ OrderedElem next; /* Next elem or &this->set->dummy */
+ OrderedElem prev; /* Previous elem or &this->set->head */
+ OrderedSet set; /* Parent set */
+};
+
+struct OrderedSetData {
+ OrderedElem head; /* First elem or &this->dummy */
+ OrderedElem dummy; /* (hack) Terminator == NULL */
+ OrderedElem tail; /* Last elem or &this->head */
+ Offset offset; /* Offset from struct base to elem */
+ /* this could be signed short int! */
+};
+
+extern void OrderedSetInit(OrderedSet set, Offset offset);
+extern bool OrderedSetContains(OrderedSet set, OrderedElem elem);
+extern Pointer OrderedSetGetHead(OrderedSet set);
+extern Pointer OrderedSetGetTail(OrderedSet set);
+extern Pointer OrderedElemGetPredecessor(OrderedElem elem);
+extern Pointer OrderedElemGetSuccessor(OrderedElem elem);
+extern void OrderedElemPop(OrderedElem elem);
+extern void OrderedElemPushInto(OrderedElem elem, OrderedSet Set);
+
+/*****************************************************************************
+ * aset.h -- Allocation set definitions. *
+ *****************************************************************************/
+/*
+ * Description:
+ * An allocation set is a set containing allocated elements. When
+ * an allocation is requested for a set, memory is allocated and a
+ * pointer is returned. Subsequently, this memory may be freed or
+ * reallocated. In addition, an allocation set may be reset which
+ * will cause all allocated memory to be freed.
+ *
+ * Allocations may occur in four different modes. The mode of
+ * allocation does not affect the behavior of allocations except in
+ * terms of performance. The allocation mode is set at the time of
+ * set initialization. Once the mode is chosen, it cannot be changed
+ * unless the set is reinitialized.
+ *
+ * "Dynamic" mode forces all allocations to occur in a heap. This
+ * is a good mode to use when small memory segments are allocated
+ * and freed very frequently. This is a good choice when allocation
+ * characteristics are unknown. This is the default mode.
+ *
+ * "Static" mode attemts to allocate space as efficiently as possible
+ * without regard to freeing memory. This mode should be chosen only
+ * when it is known that many allocations will occur but that very
+ * little of the allocated memory will be explicitly freed.
+ *
+ * "Tunable" mode is a hybrid of dynamic and static modes. The
+ * tunable mode will use static mode allocation except when the
+ * allocation request exceeds a size limit supplied at the time of set
+ * initialization. "Big" objects are allocated using dynamic mode.
+ *
+ * "Bounded" mode attempts to allocate space efficiently given a limit
+ * on space consumed by the allocation set. This restriction can be
+ * considered a "soft" restriction, because memory segments will
+ * continue to be returned after the limit is exceeded. The limit is
+ * specified at the time of set initialization like for tunable mode.
+ *
+ * Note:
+ * Allocation sets are not automatically reset on a system reset.
+ * Higher level code is responsible for cleaning up.
+ *
+ * There may other modes in the future.
+ */
+
+/*
+ * AllocPointer --
+ * Aligned pointer which may be a member of an allocation set.
+ */
+typedef Pointer AllocPointer;
+
+/*
+ * AllocMode --
+ * Mode of allocation for an allocation set.
+ *
+ * Note:
+ * See above for a description of the various nodes.
+ */
+typedef enum AllocMode {
+ DynamicAllocMode, /* always dynamically allocate */
+ StaticAllocMode, /* always "statically" allocate */
+ TunableAllocMode, /* allocations are "tuned" */
+ BoundedAllocMode /* allocations bounded to fixed usage */
+} AllocMode;
+
+#define DefaultAllocMode DynamicAllocMode
+
+/*
+ * AllocSet --
+ * Allocation set.
+ */
+typedef struct AllocSetData {
+ OrderedSetData setData;
+ /* Note: this will change in the future to support other modes */
+} AllocSetData;
+
+typedef AllocSetData *AllocSet;
+
+/*
+ * AllocPointerIsValid --
+ * True iff pointer is valid allocation pointer.
+ */
+#define AllocPointerIsValid(pointer) PointerIsValid(pointer)
+
+/*
+ * AllocSetIsValid --
+ * True iff set is valid allocation set.
+ */
+#define AllocSetIsValid(set) PointerIsValid(set)
+
+extern void AllocSetInit(AllocSet set, AllocMode mode, Size limit);
+
+extern void AllocSetReset(AllocSet set);
+
+extern bool AllocSetContains(AllocSet set, AllocPointer pointer);
+extern AllocPointer AllocSetAlloc(AllocSet set, Size size);
+extern void AllocSetFree(AllocSet set, AllocPointer pointer);
+extern AllocPointer AllocSetRealloc(AllocSet set, AllocPointer pointer,
+ Size size);
+
+extern int AllocSetIterate(AllocSet set,
+ void (*function)(AllocPointer pointer));
+
+extern int AllocSetCount(AllocSet set);
+
+extern void AllocPointerDump(AllocPointer pointer);
+extern void AllocSetDump(AllocSet set);
+
+/*****************************************************************************
+ * clib.h -- Standard C library definitions *
+ *****************************************************************************/
+/*
+ * Note:
+ * This file is OPERATING SYSTEM dependent!!!
+ *
+ */
+/* #include <memory.h> */
+/* use <string.h> because it's ANSI */
+#include <string.h>
+
+/*
+ * LibCCopyLength is only used within this file. -cim 6/12/90
+ *
+ */
+typedef int LibCCopyLength;
+
+typedef CLibCopyLength;
+
+/*
+ * MemoryCopy --
+ * Copies fixed length block of memory to another.
+ */
+#define MemoryCopy(toBuffer, fromBuffer, length)\
+ memcpy(toBuffer, fromBuffer, length)
+
+/*****************************************************************************
+ * limit.h -- POSTGRES limit definitions. *
+ *****************************************************************************/
+
+#define MaxBitsPerByte 8
+
+typedef uint32 AttributeSize; /* XXX should be defined elsewhere */
+
+#define MaxHeapTupleSize 0x7fffffff
+#define MaxAttributeSize 0x7fffffff
+
+#define MaxIndexAttributeNumber 7
+
+
+#endif /* MEMUTILS_H */
diff --git a/src/include/utils/module.h b/src/include/utils/module.h
new file mode 100644
index 0000000000..6c5d77d6ad
--- /dev/null
+++ b/src/include/utils/module.h
@@ -0,0 +1,25 @@
+/*-------------------------------------------------------------------------
+ *
+ * module.h--
+ * this file contains general "module" stuff that used to be
+ * spread out between the following files:
+ *
+ * enbl.h module enable stuff
+ * trace.h module trace stuff (now gone)
+ *
+ *
+ * Copyright (c) 1994, Regents of the University of California
+ *
+ * $Id: module.h,v 1.1 1996/08/28 01:59:12 scrappy Exp $
+ *
+ *-------------------------------------------------------------------------
+ */
+#ifndef MODULE_H
+#define MODULE_H
+
+/*
+ * prototypes for functions in init/enbl.c
+ */
+extern bool BypassEnable(int *enableCountInOutP, bool on);
+
+#endif /* MODULE_H */
diff --git a/src/include/utils/nabstime.h b/src/include/utils/nabstime.h
new file mode 100644
index 0000000000..d36dec3ac7
--- /dev/null
+++ b/src/include/utils/nabstime.h
@@ -0,0 +1,165 @@
+/*-------------------------------------------------------------------------
+ *
+ * nabstime.h--
+ * Definitions for the "new" abstime code.
+ *
+ *
+ * Copyright (c) 1994, Regents of the University of California
+ *
+ * $Id: nabstime.h,v 1.1 1996/08/28 01:59:13 scrappy Exp $
+ *
+ *-------------------------------------------------------------------------
+ */
+#ifndef NABSTIME_H
+#define NABSTIME_H
+
+#include <sys/types.h>
+#include <time.h>
+#if !defined(PORTNAME_irix5)
+#include <sys/timeb.h>
+#endif
+#include "miscadmin.h" /* for SystemTime */
+
+/* ----------------------------------------------------------------
+ * time types + support macros
+ *
+ *
+ * ----------------------------------------------------------------
+ */
+typedef int32 AbsoluteTime;
+typedef int32 RelativeTime;
+
+typedef struct {
+ int32 status;
+ AbsoluteTime data[2];
+} TimeIntervalData;
+typedef TimeIntervalData *TimeInterval;
+
+#define EPOCH_ABSTIME ((AbsoluteTime) 0)
+#define INVALID_ABSTIME ((AbsoluteTime) 2147483647) /* 2^31 - 1 */
+#define CURRENT_ABSTIME ((AbsoluteTime) 2147483646) /* 2^31 - 2 */
+#define NOEND_ABSTIME ((AbsoluteTime) 2147483645) /* 2^31 - 3 */
+
+
+#if defined(PORTNAME_aix)
+/*
+ * AIX considers 2147483648 == -2147483648 (since they have the same bit
+ * representation) but uses a different sign sense in a comparison to
+ * these integer constants depending on whether the constant is signed
+ * or not!
+ */
+#include <values.h>
+/*#define NOSTART_ABSTIME ((AbsoluteTime) HIBITI) */ /* - 2^31 */
+#define NOSTART_ABSTIME ((AbsoluteTime) INT_MIN)
+#else
+/*#define NOSTART_ABSTIME ((AbsoluteTime) 2147483648)*/ /* - 2^31 */
+#define NOSTART_ABSTIME ((AbsoluteTime) -2147483647) /* - 2^31 */
+#endif /* PORTNAME_aix */
+
+#define INVALID_RELTIME ((RelativeTime) 2147483647) /* 2^31 - 1 */
+
+/* ----------------
+ * time support macros (from tim.h)
+ * ----------------
+ */
+
+#define AbsoluteTimeIsValid(time) \
+ ((bool) ((time) != INVALID_ABSTIME))
+
+#define AbsoluteTimeIsReal(time) \
+ ((bool) (((AbsoluteTime) time) < NOEND_ABSTIME && \
+ ((AbsoluteTime) time) > NOSTART_ABSTIME))
+
+/* have to include this because EPOCH_ABSTIME used to be invalid - yuk */
+#define AbsoluteTimeIsBackwardCompatiblyValid(time) \
+ ((bool) (((AbsoluteTime) time) != INVALID_ABSTIME && \
+ ((AbsoluteTime) time) > EPOCH_ABSTIME))
+
+#define AbsoluteTimeIsBackwardCompatiblyReal(time) \
+ ((bool) (((AbsoluteTime) time) < NOEND_ABSTIME && \
+ ((AbsoluteTime) time) > NOSTART_ABSTIME && \
+ ((AbsoluteTime) time) > EPOCH_ABSTIME))
+
+#define RelativeTimeIsValid(time) \
+ ((bool) (((RelativeTime) time) != INVALID_RELTIME))
+
+#define GetCurrentAbsoluteTime() \
+ ((AbsoluteTime) getSystemTime())
+
+/*
+ * getSystemTime --
+ * Returns system time.
+ */
+#define getSystemTime() \
+ ((time_t) (time(0l)))
+
+
+/*
+ * Meridian: am, pm, or 24-hour style.
+ */
+#define AM 0
+#define PM 1
+#define HR24 2
+
+/* can't have more of these than there are bits in an unsigned long */
+#define MONTH 1
+#define YEAR 2
+#define DAY 3
+#define TIME 4
+#define TZ 5
+#define DTZ 6
+#define PG_IGNORE 7
+#define AMPM 8
+/* below here are unused so far */
+#define SECONDS 9
+#define MONTHS 10
+#define YEARS 11
+#define NUMBER 12
+/* these are only for relative dates */
+#define ABS_BEFORE 13
+#define ABS_AFTER 14
+#define AGO 15
+
+
+#define SECS(n) ((time_t)(n))
+#define MINS(n) ((time_t)(n) * SECS(60))
+#define HOURS(n) ((time_t)(n) * MINS(60)) /* 3600 secs */
+#define DAYS(n) ((time_t)(n) * HOURS(24)) /* 86400 secs */
+/* months and years are not constant length, must be specially dealt with */
+
+#define TOKMAXLEN 6 /* only this many chars are stored in datetktbl */
+
+/* keep this struct small; it gets used a lot */
+typedef struct {
+#if defined(PORTNAME_aix)
+ char *token;
+#else
+ char token[TOKMAXLEN];
+#endif /* PORTNAME_aix */
+ char type;
+ char value; /* this may be unsigned, alas */
+} datetkn;
+
+/*
+ * nabstime.c prototypes
+ */
+extern AbsoluteTime nabstimein(char *timestr);
+extern int prsabsdate(char *timestr, struct tm *tm, int *tzp);
+extern int tryabsdate(char *fields[], int nf, struct tm *tm, int *tzp);
+extern int parsetime(char *time, struct tm *tm);
+extern int split(char *string, char *fields[], int nfields, char *sep);
+extern char *nabstimeout(AbsoluteTime time);
+extern AbsoluteTime dateconv(struct tm *tm, int zone);
+extern time_t qmktime(struct tm *tp);
+extern datetkn *datetoktype(char *s, int *bigvalp);
+extern datetkn *datebsearch(char *key, datetkn *base, unsigned int nel);
+extern bool AbsoluteTimeIsBefore(AbsoluteTime time1, AbsoluteTime time2);
+extern bool AbsoluteTimeIsAfter(AbsoluteTime time1, AbsoluteTime time2);
+extern int32 abstimeeq(AbsoluteTime t1, AbsoluteTime t2);
+extern int32 abstimene(AbsoluteTime t1, AbsoluteTime t2);
+extern int32 abstimelt(AbsoluteTime t1, AbsoluteTime t2);
+extern int32 abstimegt(AbsoluteTime t1, AbsoluteTime t2);
+extern int32 abstimele(AbsoluteTime t1, AbsoluteTime t2);
+extern int32 abstimege(AbsoluteTime t1, AbsoluteTime t2);
+
+#endif /* NABSTIME_H */
diff --git a/src/include/utils/oidcompos.h b/src/include/utils/oidcompos.h
new file mode 100644
index 0000000000..290fb08ee6
--- /dev/null
+++ b/src/include/utils/oidcompos.h
@@ -0,0 +1,52 @@
+/*-------------------------------------------------------------------------
+ *
+ * oidcompos.h--
+ * prototype file for the oid {char16,int4} composite type functions.
+ *
+ *
+ * Copyright (c) 1994, Regents of the University of California
+ *
+ * $Id: oidcompos.h,v 1.1 1996/08/28 01:59:15 scrappy Exp $
+ *
+ *-------------------------------------------------------------------------
+ */
+#ifndef OIDCOMPOS_H
+#define OIDCOMPOS_H
+
+/* oidint4.c */
+OidInt4 oidint4in(char *o);
+char *oidint4out(OidInt4 o);
+bool oidint4lt(OidInt4 o1, OidInt4 o2);
+bool oidint4le(OidInt4 o1, OidInt4 o2);
+bool oidint4eq(OidInt4 o1, OidInt4 o2);
+bool oidint4ge(OidInt4 o1, OidInt4 o2);
+bool oidint4gt(OidInt4 o1, OidInt4 o2);
+bool oidint4ne(OidInt4 o1, OidInt4 o2);
+int oidint4cmp(OidInt4 o1, OidInt4 o2);
+OidInt4 mkoidint4(Oid v_oid, uint32 v_int4);
+
+/* oidint2.c */
+OidInt2 oidint2in(char *o);
+char *oidint2out(OidInt2 o);
+bool oidint2lt(OidInt2 o1, OidInt2 o2);
+bool oidint2le(OidInt2 o1, OidInt2 o2);
+bool oidint2eq(OidInt2 o1, OidInt2 o2);
+bool oidint2ge(OidInt2 o1, OidInt2 o2);
+bool oidint2gt(OidInt2 o1, OidInt2 o2);
+bool oidint2ne(OidInt2 o1, OidInt2 o2);
+int oidint2cmp(OidInt2 o1, OidInt2 o2);
+OidInt2 mkoidint2(Oid v_oid, uint16 v_int2);
+
+/* oidname.c */
+OidName oidnamein(char *inStr);
+char *oidnameout(OidName oidname);
+bool oidnamelt(OidName o1, OidName o2);
+bool oidnamele(OidName o1, OidName o2);
+bool oidnameeq(OidName o1, OidName o2);
+bool oidnamene(OidName o1, OidName o2);
+bool oidnamege(OidName o1, OidName o2);
+bool oidnamegt(OidName o1, OidName o2);
+int oidnamecmp(OidName o1, OidName o2);
+OidName mkoidname(Oid id, char *name);
+
+#endif /* OIDCOMPOS_H */
diff --git a/src/include/utils/palloc.h b/src/include/utils/palloc.h
new file mode 100644
index 0000000000..d3953e941a
--- /dev/null
+++ b/src/include/utils/palloc.h
@@ -0,0 +1,26 @@
+/*-------------------------------------------------------------------------
+ *
+ * palloc.h--
+ * POSTGRES memory allocator definitions.
+ *
+ *
+ * Copyright (c) 1994, Regents of the University of California
+ *
+ * $Id: palloc.h,v 1.1 1996/08/28 01:59:16 scrappy Exp $
+ *
+ *-------------------------------------------------------------------------
+ */
+#ifndef PALLOC_H
+#define PALLOC_H
+
+#include "c.h"
+
+extern void* palloc(Size size);
+extern void pfree(void *pointer);
+extern void *repalloc(void *pointer, Size size);
+
+/* like strdup except uses palloc */
+extern char* pstrdup(char* pointer);
+
+#endif /* PALLOC_H */
+
diff --git a/src/include/utils/portal.h b/src/include/utils/portal.h
new file mode 100644
index 0000000000..4eb1ece56d
--- /dev/null
+++ b/src/include/utils/portal.h
@@ -0,0 +1,97 @@
+/*-------------------------------------------------------------------------
+ *
+ * portal.h--
+ * POSTGRES portal definitions.
+ *
+ *
+ * Copyright (c) 1994, Regents of the University of California
+ *
+ * $Id: portal.h,v 1.1 1996/08/28 01:59:18 scrappy Exp $
+ *
+ *-------------------------------------------------------------------------
+ */
+/*
+ * Note:
+ * A portal is an abstraction which represents the execution state of
+ * a running query (or a fixed sequence of queries). The "blank portal" is
+ * a portal with an InvalidName. This blank portal is in existance except
+ * between calls to BlankPortalAssignName and GetPortalByName(NULL).
+ *
+ * Note:
+ * now that PQ calls can be made from within a backend, a portal
+ * may also be used to keep track of the tuples resulting
+ * from the execution of a query. In this case, entryIndex
+ */
+#ifndef PORTAL_H
+#define PORTAL_H
+
+#include "c.h"
+
+#include "nodes/execnodes.h" /* for EState */
+#include "nodes/memnodes.h"
+#include "nodes/nodes.h"
+#include "nodes/pg_list.h"
+#include "nodes/plannodes.h" /* for Plan */
+#include "executor/execdesc.h"
+
+typedef struct PortalBlockData {
+ AllocSetData setData;
+ FixedItemData itemData;
+} PortalBlockData;
+
+typedef PortalBlockData *PortalBlock;
+
+typedef struct PortalD PortalD;
+typedef PortalD *Portal;
+
+struct PortalD {
+ char *name; /* XXX PortalName */
+ struct PortalVariableMemory variable;
+ struct PortalHeapMemory heap;
+ QueryDesc *queryDesc;
+ TupleDesc attinfo;
+ EState *state;
+ void (*cleanup)(Portal);
+};
+
+/*
+ * PortalIsValid --
+ * True iff portal is valid.
+ */
+#define PortalIsValid(p) PointerIsValid(p)
+
+/*
+ * Special portals (well, their names anyway)
+ */
+#define VACPNAME "<vacuum>"
+
+extern bool PortalNameIsSpecial(char *pname);
+extern void CollectNamedPortals(Portal *portalP, int destroy);
+extern void AtEOXact_portals(void);
+extern void EnablePortalManager(bool on);
+extern Portal GetPortalByName(char *name);
+extern Portal BlankPortalAssignName(char *name);
+extern void PortalSetQuery(Portal portal, QueryDesc *queryDesc,
+ TupleDesc attinfo, EState *state,
+ void (*cleanup)(Portal portal));
+extern QueryDesc *PortalGetQueryDesc(Portal portal);
+extern EState *PortalGetState(Portal portal);
+extern Portal CreatePortal(char *name);
+extern void PortalDestroy(Portal *portalP);
+extern void PortalResetHeapMemory(Portal portal);
+extern void StartPortalAllocMode(AllocMode mode, Size limit);
+extern void EndPortalAllocMode(void);
+extern PortalVariableMemory PortalGetVariableMemory(Portal portal);
+extern PortalHeapMemory PortalGetHeapMemory(Portal portal);
+extern Portal PortalVariableMemoryGetPortal(PortalVariableMemory context);
+extern Portal PortalHeapMemoryGetPortal(PortalHeapMemory context);
+extern PortalHeapMemory PortalVariableMemoryGetHeapMemory(PortalVariableMemory context);
+extern PortalVariableMemory PortalHeapMemoryGetVariableMemory(PortalHeapMemory context);
+
+/* estimate of the maximum number of open portals a user would have,
+ * used in initially sizing the PortalHashTable in EnablePortalManager()
+ */
+#define PORTALS_PER_USER 10
+
+
+#endif /* PORTAL_H */
diff --git a/src/include/utils/psort.h b/src/include/utils/psort.h
new file mode 100644
index 0000000000..45d5231981
--- /dev/null
+++ b/src/include/utils/psort.h
@@ -0,0 +1,86 @@
+/*-------------------------------------------------------------------------
+ *
+ * psort.h--
+ *
+ *
+ *
+ * Copyright (c) 1994, Regents of the University of California
+ *
+ * $Id: psort.h,v 1.1 1996/08/28 01:59:20 scrappy Exp $
+ *
+ *-------------------------------------------------------------------------
+ */
+#ifndef PSORT_H
+#define PSORT_H
+
+#define SORTMEM (1 << 18) /* 1/4 M - any static memory */
+#define MAXTAPES 7 /* 7--See Fig. 70, p273 */
+#define TAPEEXT "pg_psort.XXXXXX" /* TEMPDIR/TAPEEXT */
+#define FREE(x) free((char *) x)
+
+struct tape {
+ int tp_dummy; /* (D) */
+ int tp_fib; /* (A) */
+ FILE *tp_file; /* (TAPE) */
+ struct tape *tp_prev;
+};
+
+struct cmplist {
+ int cp_attn; /* attribute number */
+ int cp_num; /* comparison function code */
+ int cp_rev; /* invert comparison flag */
+ struct cmplist *cp_next; /* next in chain */
+};
+
+extern int Nkeys;
+extern ScanKey key;
+extern int SortMemory; /* free memory */
+extern Relation SortRdesc;
+extern struct leftist *Tuples;
+
+#ifdef EBUG
+#include <stdio.h>
+#include "utils/elog.h"
+#include "storage/buf.h"
+#include "storage/bufmgr.h"
+
+#define PDEBUG(PROC, S1)\
+elog(DEBUG, "%s:%d>> PROC: %s.", __FILE__, __LINE__, S1)
+
+#define PDEBUG2(PROC, S1, D1)\
+elog(DEBUG, "%s:%d>> PROC: %s %d.", __FILE__, __LINE__, S1, D1)
+
+#define PDEBUG4(PROC, S1, D1, S2, D2)\
+elog(DEBUG, "%s:%d>> PROC: %s %d, %s %d.", __FILE__, __LINE__, S1, D1, S2, D2)
+
+#define VDEBUG(VAR, FMT)\
+elog(DEBUG, "%s:%d>> VAR =FMT", __FILE__, __LINE__, VAR)
+
+#define ASSERT(EXPR, STR)\
+if (!(EXPR)) elog(FATAL, "%s:%d>> %s", __FILE__, __LINE__, STR)
+
+#define TRACE(VAL, CODE)\
+if (1) CODE; else
+
+#else
+#define PDEBUG(MSG)
+#define VDEBUG(VAR, FMT)
+#define ASSERT(EXPR, MSG)
+#define TRACE(VAL, CODE)
+#endif
+
+/* psort.c */
+extern void psort(Relation oldrel, Relation newrel, int nkeys, ScanKey key);
+extern void initpsort(void);
+extern void resetpsort(void);
+extern void initialrun(Relation rdesc);
+extern bool createrun(HeapScanDesc sdesc, FILE *file);
+extern HeapTuple tuplecopy(HeapTuple tup, Relation rdesc, Buffer b);
+extern FILE *mergeruns(void);
+extern void merge(struct tape *dest);
+extern void endpsort(Relation rdesc, FILE *file);
+extern FILE *gettape(void);
+extern void resettape(FILE *file);
+extern void destroytape(FILE *file);
+
+#endif /* PSORT_H */
diff --git a/src/include/utils/rel.h b/src/include/utils/rel.h
new file mode 100644
index 0000000000..c848ae138e
--- /dev/null
+++ b/src/include/utils/rel.h
@@ -0,0 +1,170 @@
+/*-------------------------------------------------------------------------
+ *
+ * rel.h--
+ * POSTGRES relation descriptor definitions.
+ *
+ *
+ * Copyright (c) 1994, Regents of the University of California
+ *
+ * $Id: rel.h,v 1.1 1996/08/28 01:59:21 scrappy Exp $
+ *
+ *-------------------------------------------------------------------------
+ */
+#ifndef REL_H
+#define REL_H
+
+#include "postgres.h"
+
+#include "storage/fd.h"
+#include "access/strat.h"
+#include "access/tupdesc.h"
+
+#include "catalog/pg_am.h"
+#include "catalog/pg_operator.h"
+#include "catalog/pg_class.h"
+
+#include "rewrite/prs2lock.h"
+
+typedef struct RelationData {
+ File rd_fd; /* open file descriptor */
+ int rd_nblocks; /* number of blocks in rel */
+ uint16 rd_refcnt; /* reference count */
+ bool rd_islocal; /* uses the local buffer mgr */
+ bool rd_isnailed; /* rel is nailed in cache */
+ Form_pg_am rd_am; /* AM tuple */
+ Form_pg_class rd_rel; /* RELATION tuple */
+ Oid rd_id; /* relations's object id */
+ Pointer lockInfo; /* ptr. to misc. info. */
+ TupleDesc rd_att; /* tuple desciptor */
+ RuleLock *rd_rules; /* rewrite rules */
+ IndexStrategy rd_istrat;
+ RegProcedure* rd_support;
+} RelationData;
+
+typedef RelationData *Relation;
+
+/* ----------------
+ * RelationPtr is used in the executor to support index scans
+ * where we have to keep track of several index relations in an
+ * array. -cim 9/10/89
+ * ----------------
+ */
+typedef Relation *RelationPtr;
+
+#define InvalidRelation ((Relation)NULL)
+
+typedef char ArchiveMode;
+
+/*
+ * RelationIsValid --
+ * True iff relation descriptor is valid.
+ */
+#define RelationIsValid(relation) PointerIsValid(relation)
+
+/*
+ * RelationGetSystemPort --
+ * Returns system port of a relation.
+ *
+ * Note:
+ * Assumes relation descriptor is valid.
+ */
+#define RelationGetSystemPort(relation) ((relation)->rd_fd)
+
+/*
+ * RelationGetLockInfo --
+ * Returns the lock information structure in the reldesc
+ *
+ */
+#define RelationGetLockInfo(relation) ((relation)->lockInfo)
+
+/*
+ * RelationHasReferenceCountZero --
+ * True iff relation reference count is zero.
+ *
+ * Note:
+ * Assumes relation descriptor is valid.
+ */
+#define RelationHasReferenceCountZero(relation) \
+ ((bool)((relation)->rd_refcnt == 0))
+
+/*
+ * RelationSetReferenceCount --
+ * Sets relation reference count.
+ */
+#define RelationSetReferenceCount(relation,count) ((relation)->rd_refcnt = count)
+
+/*
+ * RelationIncrementReferenceCount --
+ * Increments relation reference count.
+ */
+#define RelationIncrementReferenceCount(relation) ((relation)->rd_refcnt += 1);
+
+/*
+ * RelationDecrementReferenceCount --
+ * Decrements relation reference count.
+ */
+#define RelationDecrementReferenceCount(relation) ((relation)->rd_refcnt -= 1)
+
+/*
+ * RelationGetAccessMethodTupleForm --
+ * Returns access method attribute values for a relation.
+ *
+ * Note:
+ * Assumes relation descriptor is valid.
+ */
+#define RelationGetAccessMethodTupleForm(relation) ((relation)->rd_am)
+
+/*
+ * RelationGetRelationTupleForm --
+ * Returns relation attribute values for a relation.
+ *
+ * Note:
+ * Assumes relation descriptor is valid.
+ */
+#define RelationGetRelationTupleForm(relation) ((relation)->rd_rel)
+
+
+/*
+ * RelationGetRelationId --
+ *
+ * returns the object id of the relation
+ *
+ */
+#define RelationGetRelationId(relation) ((relation)->rd_id)
+
+/*
+ * RelationGetFile --
+ *
+ * Returns the open File decscriptor
+ */
+#define RelationGetFile(relation) ((relation)->rd_fd)
+
+
+/*
+ * RelationGetRelationName --
+ *
+ * Returns a Relation Name
+ */
+#define RelationGetRelationName(relation) (&(relation)->rd_rel->relname)
+
+/*
+ * RelationGetRelationName --
+ *
+ * Returns a the number of attributes.
+ */
+#define RelationGetNumberOfAttributes(relation) ((relation)->rd_rel->relnatts)
+
+/*
+ * RelationGetTupleDescriptor --
+ * Returns tuple descriptor for a relation.
+ *
+ * Note:
+ * Assumes relation descriptor is valid.
+ */
+#define RelationGetTupleDescriptor(relation) ((relation)->rd_att)
+
+extern IndexStrategy RelationGetIndexStrategy(Relation relation);
+
+extern void RelationSetIndexSupport(Relation relation, IndexStrategy strategy,
+ RegProcedure *support);
+#endif /* REL_H */
diff --git a/src/include/utils/rel2.h b/src/include/utils/rel2.h
new file mode 100644
index 0000000000..8f2742457c
--- /dev/null
+++ b/src/include/utils/rel2.h
@@ -0,0 +1,23 @@
+/*-------------------------------------------------------------------------
+ *
+ * rel2.h--
+ *
+ *
+ *
+ * Copyright (c) 1994, Regents of the University of California
+ *
+ * $Id: rel2.h,v 1.1 1996/08/28 01:59:22 scrappy Exp $
+ *
+ *-------------------------------------------------------------------------
+ */
+#ifndef TMP_REL2_H
+#define TMP_REL2_H
+
+#include "access/istrat.h"
+
+extern IndexStrategy RelationGetIndexStrategy(Relation relation);
+
+extern void RelationSetIndexSupport(Relation relation, IndexStrategy strategy,
+ RegProcedure *support);
+
+#endif /* TMP_REL2_H */
diff --git a/src/include/utils/relcache.h b/src/include/utils/relcache.h
new file mode 100644
index 0000000000..3ad124d7f6
--- /dev/null
+++ b/src/include/utils/relcache.h
@@ -0,0 +1,47 @@
+/*-------------------------------------------------------------------------
+ *
+ * relcache.h--
+ * Relation descriptor cache definitions.
+ *
+ *
+ * Copyright (c) 1994, Regents of the University of California
+ *
+ * $Id: relcache.h,v 1.1 1996/08/28 01:59:24 scrappy Exp $
+ *
+ *-------------------------------------------------------------------------
+ */
+#ifndef RELCACHE_H
+#define RELCACHE_H
+
+#include <sys/types.h>
+
+#include "postgres.h"
+#include "utils/rel.h"
+
+/*
+ * relation lookup routines
+ */
+extern Relation RelationIdCacheGetRelation(Oid relationId);
+extern Relation RelationNameCacheGetRelation(char *relationName);
+extern Relation RelationIdGetRelation(Oid relationId);
+extern Relation RelationNameGetRelation(char *relationName);
+extern Relation getreldesc(char *relationName);
+
+extern void RelationClose(Relation relation);
+extern void RelationFlushRelation(Relation *relationPtr,
+ bool onlyFlushReferenceCountZero);
+extern void RelationIdInvalidateRelationCacheByRelationId(Oid relationId);
+
+extern void
+RelationIdInvalidateRelationCacheByAccessMethodId(Oid accessMethodId);
+
+extern void RelationCacheInvalidate(bool onlyFlushReferenceCountZero);
+
+extern void RelationRegisterRelation(Relation relation);
+extern void RelationPurgeLocalRelation(bool xactComitted);
+extern void RelationInitialize();
+extern void init_irels();
+extern void write_irels();
+
+
+#endif /* RELCACHE_H */
diff --git a/src/include/utils/sets.h b/src/include/utils/sets.h
new file mode 100644
index 0000000000..4580f15a3d
--- /dev/null
+++ b/src/include/utils/sets.h
@@ -0,0 +1,22 @@
+/*-------------------------------------------------------------------------
+ *
+ * sets.h--
+ *
+ *
+ *
+ * Copyright (c) 1994, Regents of the University of California
+ *
+ * $Id: sets.h,v 1.1 1996/08/28 01:59:25 scrappy Exp $
+ *
+ *-------------------------------------------------------------------------
+ */
+#ifndef SETS_H
+#define SETS_H
+
+/* Temporary name of set, before SetDefine changes it. */
+#define GENERICSETNAME "zyxset"
+
+extern Oid SetDefine(char *querystr, char *typename);
+extern int seteval(Oid funcoid);
+
+#endif /* SETS_H */
diff --git a/src/include/utils/syscache.h b/src/include/utils/syscache.h
new file mode 100644
index 0000000000..82f38b9a90
--- /dev/null
+++ b/src/include/utils/syscache.h
@@ -0,0 +1,90 @@
+/*-------------------------------------------------------------------------
+ *
+ * syscache.h--
+ * System catalog cache definitions.
+ *
+ *
+ * Copyright (c) 1994, Regents of the University of California
+ *
+ * $Id: syscache.h,v 1.1 1996/08/28 01:59:26 scrappy Exp $
+ *
+ *-------------------------------------------------------------------------
+ */
+#ifndef SYSCACHE_H
+#define SYSCACHE_H
+
+/*#define CACHEDEBUG*/ /* turns DEBUG elogs on */
+
+#include "postgres.h"
+#include "access/htup.h"
+#include "nodes/pg_list.h"
+
+/*
+ * Declarations for util/syscache.c.
+ *
+ * SysCache identifiers.
+ *
+ * The order of these must match the order
+ * they are entered into the structure cacheinfo[] in syscache.c
+ * The best thing to do is to add yours at the END, because some
+ * code assumes that certain caches are at certain places in this
+ * array.
+ */
+
+#define AMOPOPID 0
+#define AMOPSTRATEGY 1
+#define ATTNAME 2
+#define ATTNUM 3
+#define INDEXRELID 4
+#define LANNAME 5
+#define OPRNAME 6
+#define OPROID 7
+#define PRONAME 8
+#define PROOID 9
+#define RELNAME 10
+#define RELOID 11
+#define TYPNAME 12
+#define TYPOID 13
+#define AMNAME 14
+#define CLANAME 15
+#define INDRELIDKEY 16
+#define INHRELID 17
+#define RULOID 18
+#define AGGNAME 19
+#define LISTENREL 20
+#define USENAME 21
+#define USESYSID 22
+#define GRONAME 23
+#define GROSYSID 24
+#define REWRITENAME 25
+#define PROSRC 26
+#define CLADEFTYPE 27
+
+/* ----------------
+ * struct cachedesc: information needed for a call to InitSysCache()
+ * ----------------
+ */
+struct cachedesc {
+ char *name; /* this is Name * so that we can initialize it */
+ int nkeys;
+ int key[4];
+ int size; /* sizeof(appropriate struct) */
+ char *indname; /* index relation for this cache, if exists */
+ HeapTuple (*iScanFunc)(); /* function to handle index scans */
+};
+
+extern void zerocaches(void);
+extern void InitCatalogCache(void);
+extern HeapTuple SearchSysCacheTuple(int cacheId, Datum key1, Datum key2,
+ Datum key3, Datum key4);
+extern int32 SearchSysCacheStruct(int cacheId, char *returnStruct,
+ Datum key1, Datum key2, Datum key3, Datum key4);
+extern void *SearchSysCacheGetAttribute(int cacheId,
+ AttrNumber attributeNumber,
+ Datum key1,
+ Datum key2,
+ Datum key3,
+ Datum key4);
+extern void *TypeDefaultRetrieve(Oid typId);
+
+#endif /* SYSCACHE_H */
diff --git a/src/include/utils/tqual.h b/src/include/utils/tqual.h
new file mode 100644
index 0000000000..a082d757bb
--- /dev/null
+++ b/src/include/utils/tqual.h
@@ -0,0 +1,55 @@
+/*-------------------------------------------------------------------------
+ *
+ * tqual.h--
+ * POSTGRES time qualification definitions.
+ *
+ *
+ * Copyright (c) 1994, Regents of the University of California
+ *
+ * $Id: tqual.h,v 1.1 1996/08/28 01:59:28 scrappy Exp $
+ *
+ * NOTE
+ * It may be desirable to allow time qualifications to indicate
+ * relative times.
+ *
+ *-------------------------------------------------------------------------
+ */
+#ifndef TQUAL_H
+#define TQUAL_H
+
+#include "postgres.h"
+#include "utils/nabstime.h"
+#include "access/htup.h"
+
+typedef struct TimeQualSpace {
+ char data[12];
+} TimeQualSpace;
+
+typedef Pointer TimeQual;
+
+/* Tuples valid as of StartTransactionCommand */
+#define NowTimeQual ((TimeQual) NULL)
+
+/* As above, plus updates in this command */
+extern TimeQual SelfTimeQual;
+
+extern void setheapoverride(bool on);
+extern bool heapisoverride(void);
+
+extern bool TimeQualIsValid(TimeQual qual);
+extern bool TimeQualIsLegal(TimeQual qual);
+extern bool TimeQualIncludesNow(TimeQual qual);
+extern bool TimeQualIncludesPast(TimeQual qual);
+extern bool TimeQualIsSnapshot(TimeQual qual);
+extern bool TimeQualIsRanged(TimeQual qual);
+extern bool TimeQualIndicatesDisableValidityChecking(TimeQual qual);
+extern AbsoluteTime TimeQualGetSnapshotTime(TimeQual qual);
+extern AbsoluteTime TimeQualGetStartTime(TimeQual qual);
+extern AbsoluteTime TimeQualGetEndTime(TimeQual qual);
+extern TimeQual TimeFormSnapshotTimeQual(AbsoluteTime time);
+extern TimeQual TimeFormRangedTimeQual(AbsoluteTime startTime,
+ AbsoluteTime endTime);
+extern bool HeapTupleSatisfiesTimeQual(HeapTuple tuple, TimeQual qual);
+
+
+#endif /* TQUAL_H */