summaryrefslogtreecommitdiff
path: root/src/include
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2001-02-10 02:31:31 +0000
committerTom Lane <tgl@sss.pgh.pa.us>2001-02-10 02:31:31 +0000
commitd08741eab55f44214d08f33177523ec4821de532 (patch)
tree192af3b22d30b8be1ec3256ebf4806e601234612 /src/include
parentcf21985ab59e0075704b0322f7ba84033bf7e16e (diff)
downloadpostgresql-d08741eab55f44214d08f33177523ec4821de532.tar.gz
Restructure the key include files per recent pghackers discussion: there
are now separate files "postgres.h" and "postgres_fe.h", which are meant to be the primary include files for backend .c files and frontend .c files respectively. By default, only include files meant for frontend use are installed into the installation include directory. There is a new make target 'make install-all-headers' that adds the whole content of the src/include tree to the installed fileset, for use by people who want to develop server-side code without keeping the complete source tree on hand. Cleaned up a whole lot of crufty and inconsistent header inclusions.
Diffstat (limited to 'src/include')
-rw-r--r--src/include/Makefile59
-rw-r--r--src/include/c.h751
-rw-r--r--src/include/executor/spi.h4
-rw-r--r--src/include/libpq/libpq-fs.h77
-rw-r--r--src/include/libpq/pqcomm.h6
-rw-r--r--src/include/mb/pg_wchar.h3
-rw-r--r--src/include/miscadmin.h4
-rw-r--r--src/include/postgres.h605
-rw-r--r--src/include/postgres_ext.h11
-rw-r--r--src/include/postgres_fe.h24
-rw-r--r--src/include/regex/regex.h1
-rw-r--r--src/include/regex/regex2.h4
-rw-r--r--src/include/regex/utils.h10
-rw-r--r--src/include/storage/ipc.h4
-rw-r--r--src/include/utils/dynamic_loader.h8
-rw-r--r--src/include/utils/exc.h4
-rw-r--r--src/include/utils/geo_decls.h3
-rw-r--r--src/include/utils/guc.h4
-rw-r--r--src/include/utils/palloc.h22
19 files changed, 752 insertions, 852 deletions
diff --git a/src/include/Makefile b/src/include/Makefile
index 2b78e9ef62..df3c9a2f89 100644
--- a/src/include/Makefile
+++ b/src/include/Makefile
@@ -2,10 +2,11 @@
#
# Makefile for src/include
#
-# Install exported headers to the include directory (these headers are
-# the minimal ones needed to build loadable backend extensions).
+# 'make install' installs only those headers needed for client-side
+# programming. 'make install-all-headers' installs the whole contents
+# of src/include.
#
-# $Header: /cvsroot/pgsql/src/include/Makefile,v 1.5 2000/10/20 21:04:03 petere Exp $
+# $Header: /cvsroot/pgsql/src/include/Makefile,v 1.6 2001/02/10 02:31:28 tgl Exp $
#
#-------------------------------------------------------------------------
@@ -13,30 +14,23 @@ subdir = src/include
top_builddir = ../..
include $(top_builddir)/src/Makefile.global
+# Headers needed by clients
+srcdir_headers := c.h postgres_ext.h postgres_fe.h \
+ libpq/pqcomm.h libpq/libpq-fs.h lib/dllist.h
-srcdir_headers := c.h postgres.h postgres_ext.h fmgr.h \
- libpq/pqcomm.h libpq/libpq-fs.h lib/dllist.h \
- utils/geo_decls.h utils/elog.h utils/palloc.h \
- access/attnum.h executor/spi.h commands/trigger.h
-
-builddir_headers := os.h config.h utils/fmgroids.h
+builddir_headers := os.h config.h
HEADERS = $(srcdir_headers) $(builddir_headers)
-
-all: $(HEADERS)
+# Subdirectories containing headers that install-all-headers should install
+SUBDIRS = access bootstrap catalog commands executor lib libpq mb \
+ nodes optimizer parser port regex rewrite storage tcop utils
-# These rules are necessary in case someone installs the include tree
-# before building the backend tree. Very messy.
-utils/fmgroids.h: $(top_builddir)/src/backend/utils/fmgroids.h
- cd utils && rm -f fmgroids.h && $(LN_S) ../$(top_builddir)/src/backend/utils/fmgroids.h .
+all: $(HEADERS)
-# This file is built in the backend tree, but we need to keep track of
-# the dependencies here.
-$(top_builddir)/src/backend/utils/fmgroids.h: $(top_srcdir)/src/backend/utils/Gen_fmgrtab.sh catalog/pg_proc.h
- $(MAKE) -C $(dir $@) fmgroids.h
+# Install only selected headers
install: all installdirs
for file in $(srcdir_headers); do \
@@ -46,13 +40,34 @@ install: all installdirs
$(INSTALL_DATA) $$file $(DESTDIR)$(includedir)/$$file || exit; \
done
-# Automatically pick out the needed subdirectories for the include
-# tree.
+# Automatically pick out the needed subdirectories for the include tree.
installdirs:
$(mkinstalldirs) $(addprefix $(DESTDIR)$(includedir)/, $(sort $(dir $(HEADERS))))
+
+# Install all headers
+
+install-all-headers: all install-all-dirs
+ for file in $(srcdir)/*.h; do \
+ $(INSTALL_DATA) $$file $(DESTDIR)$(includedir)/`basename $$file` || exit; \
+ done
+ for dir in $(SUBDIRS); do \
+ for file in $(srcdir)/$$dir/*.h; do \
+ $(INSTALL_DATA) $$file $(DESTDIR)$(includedir)/$$dir/`basename $$file` || exit; \
+ done \
+ done
+ for file in $(builddir_headers); do \
+ $(INSTALL_DATA) $$file $(DESTDIR)$(includedir)/$$file || exit; \
+ done
+
+install-all-dirs:
+ $(mkinstalldirs) $(addprefix $(DESTDIR)$(includedir)/, $(SUBDIRS))
+
+
+# This isn't a complete uninstall, but rm'ing everything under
+# $(DESTDIR)$(includedir) is probably too drastic...
uninstall:
- rm -f $(addprefix $(DESTDIR)$(includedir)/, $(HEADERS))
+ rm -rf $(addprefix $(DESTDIR)$(includedir)/, $(HEADERS) $(SUBDIRS))
clean:
rm -f utils/fmgroids.h parser/parse.h
diff --git a/src/include/c.h b/src/include/c.h
index dc791d0d54..78001289c4 100644
--- a/src/include/c.h
+++ b/src/include/c.h
@@ -2,17 +2,22 @@
*
* c.h
* Fundamental C definitions. This is included by every .c file in
- * postgres.
+ * PostgreSQL (via either postgres.h or postgres_fe.h, as appropriate).
+ *
+ * Note that the definitions here are not intended to be exposed to clients of
+ * the frontend interface libraries --- so we don't worry much about polluting
+ * the namespace with lots of stuff...
*
*
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: c.h,v 1.89 2001/01/24 19:43:19 momjian Exp $
+ * $Id: c.h,v 1.90 2001/02/10 02:31:28 tgl Exp $
*
*-------------------------------------------------------------------------
*/
/*
+ *----------------------------------------------------------------
* TABLE OF CONTENTS
*
* When adding stuff to this file, please try to put stuff
@@ -20,21 +25,21 @@
*
* section description
* ------- ------------------------------------------------
- * 1) bool, true, false, TRUE, FALSE, NULL
- * 2) non-ansi C definitions:
- * type prefixes: const, signed, volatile, inline
- * cpp magic macros
+ * 0) config.h and standard system headers
+ * 1) hacks to cope with non-ANSI C compilers
+ * 2) bool, true, false, TRUE, FALSE, NULL
* 3) standard system types
- * 4) datum type
- * 5) IsValid macros for system types
- * 6) offsetof, lengthof, endof
- * 7) exception handling definitions, Assert, Trap, etc macros
- * 8) Min, Max, Abs, StrNCpy macros
- * 9) externs
- * 10) Berkeley-specific defs
- * 11) system-specific hacks
+ * 4) IsValid macros for system types
+ * 5) offsetof, lengthof, endof, alignment
+ * 6) widely useful macros
+ * 7) random stuff
+ * 8) system-specific hacks
*
- * ----------------------------------------------------------------
+ * NOTE: since this file is included by both frontend and backend modules, it's
+ * almost certainly wrong to put an "extern" declaration here. typedefs and macros
+ * are the kind of thing that might go here.
+ *
+ *----------------------------------------------------------------
*/
#ifndef C_H
#define C_H
@@ -63,56 +68,11 @@
#include <SupportDefs.h>
#endif
-/* ----------------------------------------------------------------
- * Section 1: bool, true, false, TRUE, FALSE, NULL
- * ----------------------------------------------------------------
- */
-/*
- * bool
- * Boolean value, either true or false.
- *
- */
-
-/* BeOS defines bool already, but the compiler chokes on the
- * #ifndef unless we wrap it in this check.
- */
-#ifndef __BEOS__
-#ifndef __cplusplus
-#ifndef bool
-typedef char bool;
-
-#endif /* ndef bool */
-#endif /* not C++ */
-#ifndef true
-#define true ((bool) 1)
-#endif
-#ifndef false
-#define false ((bool) 0)
-#endif
-#endif /* __BEOS__ */
-typedef bool *BoolPtr;
-
-#ifndef TRUE
-#define TRUE 1
-#endif /* TRUE */
-
-#ifndef FALSE
-#define FALSE 0
-#endif /* FALSE */
-
-/*
- * NULL
- * Null pointer.
- */
-#ifndef NULL
-#define NULL ((void *) 0)
-#endif /* !defined(NULL) */
/* ----------------------------------------------------------------
- * Section 2: non-ansi C definitions:
+ * Section 1: hacks to cope with non-ANSI C compilers
*
- * type prefixes: const, signed, volatile, inline
- * cpp magic macros
+ * type prefixes (const, signed, volatile, inline) are now handled in config.h.
* ----------------------------------------------------------------
*/
@@ -157,6 +117,57 @@ typedef bool *BoolPtr;
#define dummyret char
#endif
+
+/* ----------------------------------------------------------------
+ * Section 2: bool, true, false, TRUE, FALSE, NULL
+ * ----------------------------------------------------------------
+ */
+/*
+ * bool
+ * Boolean value, either true or false.
+ *
+ */
+
+/* BeOS defines bool already, but the compiler chokes on the
+ * #ifndef unless we wrap it in this check.
+ */
+#ifndef __BEOS__
+
+#ifndef __cplusplus
+#ifndef bool
+typedef char bool;
+#endif /* ndef bool */
+#endif /* not C++ */
+
+#ifndef true
+#define true ((bool) 1)
+#endif
+
+#ifndef false
+#define false ((bool) 0)
+#endif
+
+#endif /* __BEOS__ */
+
+typedef bool *BoolPtr;
+
+#ifndef TRUE
+#define TRUE 1
+#endif
+
+#ifndef FALSE
+#define FALSE 0
+#endif
+
+/*
+ * NULL
+ * Null pointer.
+ */
+#ifndef NULL
+#define NULL ((void *) 0)
+#endif
+
+
/* ----------------------------------------------------------------
* Section 3: standard system types
* ----------------------------------------------------------------
@@ -182,6 +193,7 @@ typedef signed char int8; /* == 8 bits */
typedef signed short int16; /* == 16 bits */
typedef signed int int32; /* == 32 bits */
#endif /* __BEOS__ */
+
/*
* uintN
* Unsigned integer, EXACTLY N BITS IN SIZE,
@@ -193,21 +205,6 @@ typedef unsigned char uint8; /* == 8 bits */
typedef unsigned short uint16; /* == 16 bits */
typedef unsigned int uint32; /* == 32 bits */
#endif /* __BEOS__ */
-/*
- * floatN
- * Floating point number, AT LEAST N BITS IN SIZE,
- * used for numerical computations.
- *
- * Since sizeof(floatN) may be > sizeof(char *), always pass
- * floatN by reference.
- *
- * XXX: these typedefs are now deprecated in favor of float4 and float8.
- * They will eventually go away.
- */
-typedef float float32data;
-typedef double float64data;
-typedef float *float32;
-typedef double *float64;
/*
* boolN
@@ -235,44 +232,24 @@ typedef uint16 word16; /* >= 16 bits */
typedef uint32 word32; /* >= 32 bits */
/*
- * Size
- * Size of any memory resident object, as returned by sizeof.
- */
-typedef size_t Size;
-
-/*
- * Index
- * Index into any memory resident array.
+ * floatN
+ * Floating point number, AT LEAST N BITS IN SIZE,
+ * used for numerical computations.
*
- * Note:
- * Indices are non negative.
- */
-typedef unsigned int Index;
-
-#define MAXDIM 6
-typedef struct
-{
- int indx[MAXDIM];
-} IntArray;
-
-/*
- * Offset
- * Offset into any memory resident array.
+ * Since sizeof(floatN) may be > sizeof(char *), always pass
+ * floatN by reference.
*
- * Note:
- * This differs from an Index in that an Index is always
- * non negative, whereas Offset may be negative.
+ * XXX: these typedefs are now deprecated in favor of float4 and float8.
+ * They will eventually go away.
*/
-typedef signed int Offset;
+typedef float float32data;
+typedef double float64data;
+typedef float *float32;
+typedef double *float64;
/*
- * Common Postgres datatypes.
+ * 64-bit integers
*/
-typedef int16 int2;
-typedef int32 int4;
-typedef float float4;
-typedef double float8;
-
#ifndef __BEOS__ /* this is already defined on BeOS */
#ifdef HAVE_LONG_INT_64
/* Plain "long int" fits, use it */
@@ -292,344 +269,117 @@ typedef unsigned long int uint64;
#endif
#endif /* __BEOS__ */
-/* ----------------------------------------------------------------
- * Section 4: datum type + support macros
- * ----------------------------------------------------------------
- */
-/*
- * datum.h
- * POSTGRES abstract data type datum representation definitions.
- *
- * Note:
- *
- * Port Notes:
- * Postgres makes the following assumption about machines:
- *
- * sizeof(Datum) == sizeof(long) >= sizeof(void *) >= 4
- *
- * Postgres also assumes that
- *
- * sizeof(char) == 1
- *
- * and that
- *
- * sizeof(short) == 2
- *
- * If your machine meets these requirements, Datums should also be checked
- * to see if the positioning is correct.
- */
-
-typedef unsigned long Datum; /* XXX sizeof(long) >= sizeof(void *) */
-typedef Datum *DatumPtr;
-
-#define GET_1_BYTE(datum) (((Datum) (datum)) & 0x000000ff)
-#define GET_2_BYTES(datum) (((Datum) (datum)) & 0x0000ffff)
-#define GET_4_BYTES(datum) (((Datum) (datum)) & 0xffffffff)
-#define SET_1_BYTE(value) (((Datum) (value)) & 0x000000ff)
-#define SET_2_BYTES(value) (((Datum) (value)) & 0x0000ffff)
-#define SET_4_BYTES(value) (((Datum) (value)) & 0xffffffff)
-
-/*
- * DatumGetBool
- * Returns boolean value of a datum.
- *
- * Note: any nonzero value will be considered TRUE.
- */
-
-#define DatumGetBool(X) ((bool) (((Datum) (X)) != 0))
-
-/*
- * BoolGetDatum
- * Returns datum representation for a boolean.
- *
- * Note: any nonzero value will be considered TRUE.
- */
-
-#define BoolGetDatum(X) ((Datum) ((X) ? 1 : 0))
-
-/*
- * DatumGetChar
- * Returns character value of a datum.
- */
-
-#define DatumGetChar(X) ((char) GET_1_BYTE(X))
-
/*
- * CharGetDatum
- * Returns datum representation for a character.
- */
-
-#define CharGetDatum(X) ((Datum) SET_1_BYTE(X))
-
-/*
- * Int8GetDatum
- * Returns datum representation for an 8-bit integer.
- */
-
-#define Int8GetDatum(X) ((Datum) SET_1_BYTE(X))
-
-/*
- * DatumGetUInt8
- * Returns 8-bit unsigned integer value of a datum.
- */
-
-#define DatumGetUInt8(X) ((uint8) GET_1_BYTE(X))
-
-/*
- * UInt8GetDatum
- * Returns datum representation for an 8-bit unsigned integer.
- */
-
-#define UInt8GetDatum(X) ((Datum) SET_1_BYTE(X))
-
-/*
- * DatumGetInt16
- * Returns 16-bit integer value of a datum.
- */
-
-#define DatumGetInt16(X) ((int16) GET_2_BYTES(X))
-
-/*
- * Int16GetDatum
- * Returns datum representation for a 16-bit integer.
- */
-
-#define Int16GetDatum(X) ((Datum) SET_2_BYTES(X))
-
-/*
- * DatumGetUInt16
- * Returns 16-bit unsigned integer value of a datum.
- */
-
-#define DatumGetUInt16(X) ((uint16) GET_2_BYTES(X))
-
-/*
- * UInt16GetDatum
- * Returns datum representation for a 16-bit unsigned integer.
- */
-
-#define UInt16GetDatum(X) ((Datum) SET_2_BYTES(X))
-
-/*
- * DatumGetInt32
- * Returns 32-bit integer value of a datum.
- */
-
-#define DatumGetInt32(X) ((int32) GET_4_BYTES(X))
-
-/*
- * Int32GetDatum
- * Returns datum representation for a 32-bit integer.
- */
-
-#define Int32GetDatum(X) ((Datum) SET_4_BYTES(X))
-
-/*
- * DatumGetUInt32
- * Returns 32-bit unsigned integer value of a datum.
- */
-
-#define DatumGetUInt32(X) ((uint32) GET_4_BYTES(X))
-
-/*
- * UInt32GetDatum
- * Returns datum representation for a 32-bit unsigned integer.
- */
-
-#define UInt32GetDatum(X) ((Datum) SET_4_BYTES(X))
-
-/*
- * DatumGetObjectId
- * Returns object identifier value of a datum.
- */
-
-#define DatumGetObjectId(X) ((Oid) GET_4_BYTES(X))
-
-/*
- * ObjectIdGetDatum
- * Returns datum representation for an object identifier.
- */
-
-#define ObjectIdGetDatum(X) ((Datum) SET_4_BYTES(X))
-
-/*
- * DatumGetPointer
- * Returns pointer value of a datum.
- */
-
-#define DatumGetPointer(X) ((Pointer) (X))
-
-/*
- * PointerGetDatum
- * Returns datum representation for a pointer.
- */
-
-#define PointerGetDatum(X) ((Datum) (X))
-
-/*
- * DatumGetCString
- * Returns C string (null-terminated string) value of a datum.
- *
- * Note: C string is not a full-fledged Postgres type at present,
- * but type input functions use this conversion for their inputs.
- */
-
-#define DatumGetCString(X) ((char *) DatumGetPointer(X))
-
-/*
- * CStringGetDatum
- * Returns datum representation for a C string (null-terminated string).
- *
- * Note: C string is not a full-fledged Postgres type at present,
- * but type output functions use this conversion for their outputs.
- * Note: CString is pass-by-reference; caller must ensure the pointed-to
- * value has adequate lifetime.
- */
-
-#define CStringGetDatum(X) PointerGetDatum(X)
-
-/*
- * DatumGetName
- * Returns name value of a datum.
- */
-
-#define DatumGetName(X) ((Name) DatumGetPointer(X))
-
-/*
- * NameGetDatum
- * Returns datum representation for a name.
- *
- * Note: Name is pass-by-reference; caller must ensure the pointed-to
- * value has adequate lifetime.
+ * Size
+ * Size of any memory resident object, as returned by sizeof.
*/
-
-#define NameGetDatum(X) PointerGetDatum(X)
+typedef size_t Size;
/*
- * DatumGetInt64
- * Returns 64-bit integer value of a datum.
+ * Index
+ * Index into any memory resident array.
*
- * Note: this macro hides the fact that int64 is currently a
- * pass-by-reference type. Someday it may be pass-by-value,
- * at least on some platforms.
+ * Note:
+ * Indices are non negative.
*/
-
-#define DatumGetInt64(X) (* ((int64 *) DatumGetPointer(X)))
+typedef unsigned int Index;
/*
- * Int64GetDatum
- * Returns datum representation for a 64-bit integer.
+ * Offset
+ * Offset into any memory resident array.
*
- * Note: this routine returns a reference to palloc'd space.
+ * Note:
+ * This differs from an Index in that an Index is always
+ * non negative, whereas Offset may be negative.
*/
-
-extern Datum Int64GetDatum(int64 X);
+typedef signed int Offset;
/*
- * DatumGetFloat4
- * Returns 4-byte floating point value of a datum.
- *
- * Note: this macro hides the fact that float4 is currently a
- * pass-by-reference type. Someday it may be pass-by-value.
+ * Common Postgres datatype names (as used in the catalogs)
*/
-
-#define DatumGetFloat4(X) (* ((float4 *) DatumGetPointer(X)))
+typedef int16 int2;
+typedef int32 int4;
+typedef float float4;
+typedef double float8;
/*
- * Float4GetDatum
- * Returns datum representation for a 4-byte floating point number.
- *
- * Note: this routine returns a reference to palloc'd space.
+ * Oid, RegProcedure, TransactionId, CommandId
*/
-extern Datum Float4GetDatum(float4 X);
+/* typedef Oid is in postgres_ext.h */
-/*
- * DatumGetFloat8
- * Returns 8-byte floating point value of a datum.
- *
- * Note: this macro hides the fact that float8 is currently a
- * pass-by-reference type. Someday it may be pass-by-value,
- * at least on some platforms.
- */
+/* unfortunately, both regproc and RegProcedure are used */
+typedef Oid regproc;
+typedef Oid RegProcedure;
-#define DatumGetFloat8(X) (* ((float8 *) DatumGetPointer(X)))
+typedef uint32 TransactionId;
-/*
- * Float8GetDatum
- * Returns datum representation for an 8-byte floating point number.
- *
- * Note: this routine returns a reference to palloc'd space.
- */
+#define InvalidTransactionId 0
-extern Datum Float8GetDatum(float8 X);
+typedef uint32 CommandId;
+#define FirstCommandId 0
/*
- * DatumGetFloat32
- * Returns 32-bit floating point value of a datum.
- * This is really a pointer, of course.
- *
- * XXX: this macro is now deprecated in favor of DatumGetFloat4.
- * It will eventually go away.
+ * Array indexing support
*/
+#define MAXDIM 6
+typedef struct
+{
+ int indx[MAXDIM];
+} IntArray;
-#define DatumGetFloat32(X) ((float32) DatumGetPointer(X))
-
-/*
- * Float32GetDatum
- * Returns datum representation for a 32-bit floating point number.
- * This is really a pointer, of course.
+/* ----------------
+ * Variable-length datatypes all share the 'struct varlena' header.
*
- * XXX: this macro is now deprecated in favor of Float4GetDatum.
- * It will eventually go away.
+ * NOTE: for TOASTable types, this is an oversimplification, since the value may be
+ * compressed or moved out-of-line. However datatype-specific routines are mostly
+ * content to deal with de-TOASTed values only, and of course client-side routines
+ * should never see a TOASTed value. See postgres.h for details of the TOASTed form.
+ * ----------------
*/
+struct varlena
+{
+ int32 vl_len;
+ char vl_dat[1];
+};
-#define Float32GetDatum(X) PointerGetDatum(X)
+#define VARHDRSZ ((int32) sizeof(int32))
/*
- * DatumGetFloat64
- * Returns 64-bit floating point value of a datum.
- * This is really a pointer, of course.
- *
- * XXX: this macro is now deprecated in favor of DatumGetFloat8.
- * It will eventually go away.
+ * These widely-used datatypes are just a varlena header and the data bytes.
+ * There is no terminating null or anything like that --- the data length is
+ * always VARSIZE(ptr) - VARHDRSZ.
*/
-
-#define DatumGetFloat64(X) ((float64) DatumGetPointer(X))
+typedef struct varlena bytea;
+typedef struct varlena text;
+typedef struct varlena BpChar; /* blank-padded char, ie SQL char(n) */
+typedef struct varlena VarChar; /* var-length char, ie SQL varchar(n) */
/*
- * Float64GetDatum
- * Returns datum representation for a 64-bit floating point number.
- * This is really a pointer, of course.
- *
- * XXX: this macro is now deprecated in favor of Float8GetDatum.
- * It will eventually go away.
+ * Fixed-length array types (these are not varlena's!)
*/
-#define Float64GetDatum(X) PointerGetDatum(X)
+typedef int2 int2vector[INDEX_MAX_KEYS];
+typedef Oid oidvector[INDEX_MAX_KEYS];
/*
- * Int64GetDatumFast
- * Float4GetDatumFast
- * Float8GetDatumFast
- *
- * These macros are intended to allow writing code that does not depend on
- * whether int64, float4, float8 are pass-by-reference types, while not
- * sacrificing performance when they are. The argument must be a variable
- * that will exist and have the same value for as long as the Datum is needed.
- * In the pass-by-ref case, the address of the variable is taken to use as
- * the Datum. In the pass-by-val case, these will be the same as the non-Fast
- * macros.
+ * We want NameData to have length NAMEDATALEN and int alignment,
+ * because that's how the data type 'name' is defined in pg_type.
+ * Use a union to make sure the compiler agrees.
*/
+typedef union nameData
+{
+ char data[NAMEDATALEN];
+ int alignmentDummy;
+} NameData;
+typedef NameData *Name;
-#define Int64GetDatumFast(X) PointerGetDatum(&(X))
-#define Float4GetDatumFast(X) PointerGetDatum(&(X))
-#define Float8GetDatumFast(X) PointerGetDatum(&(X))
+#define NameStr(name) ((name).data)
/* ----------------------------------------------------------------
- * Section 5: IsValid macros for system types
+ * Section 4: IsValid macros for system types
* ----------------------------------------------------------------
*/
/*
@@ -651,8 +401,13 @@ extern Datum Float8GetDatum(float8 X);
#define PointerIsAligned(pointer, type) \
(((long)(pointer) % (sizeof (type))) == 0)
+#define OidIsValid(objectId) ((bool) ((objectId) != InvalidOid))
+
+#define RegProcedureIsValid(p) OidIsValid(p)
+
+
/* ----------------------------------------------------------------
- * Section 6: offsetof, lengthof, endof
+ * Section 5: offsetof, lengthof, endof, alignment
* ----------------------------------------------------------------
*/
/*
@@ -678,125 +433,28 @@ extern Datum Float8GetDatum(float8 X);
*/
#define endof(array) (&array[lengthof(array)])
-/* ----------------------------------------------------------------
- * Section 7: exception handling definitions
- * Assert, Trap, etc macros
- * ----------------------------------------------------------------
- */
-/*
- * Exception Handling definitions
- */
-
-typedef char *ExcMessage;
-typedef struct Exception
-{
- ExcMessage message;
-} Exception;
-
-/*
- * USE_ASSERT_CHECKING, if defined, turns on all the assertions.
- * - plai 9/5/90
- *
- * It should _NOT_ be defined in releases or in benchmark copies
- */
-
-/*
- * Trap
- * Generates an exception if the given condition is true.
- *
- */
-#define Trap(condition, exception) \
- do { \
- if ((assert_enabled) && (condition)) \
- ExceptionalCondition(CppAsString(condition), &(exception), \
- (char*)NULL, __FILE__, __LINE__); \
- } while (0)
-
-/*
- * TrapMacro is the same as Trap but it's intended for use in macros:
+/* ----------------
+ * Alignment macros: align a length or address appropriately for a given type.
*
- * #define foo(x) (AssertM(x != 0) && bar(x))
- *
- * Isn't CPP fun?
- */
-#define TrapMacro(condition, exception) \
- ((bool) ((! assert_enabled) || ! (condition) || \
- (ExceptionalCondition(CppAsString(condition), \
- &(exception), \
- (char*) NULL, __FILE__, __LINE__))))
-
-#ifndef USE_ASSERT_CHECKING
-#define Assert(condition)
-#define AssertMacro(condition) ((void)true)
-#define AssertArg(condition)
-#define AssertState(condition)
-#define assert_enabled 0
-#else
-#define Assert(condition) \
- Trap(!(condition), FailedAssertion)
-
-#define AssertMacro(condition) \
- ((void) TrapMacro(!(condition), FailedAssertion))
-
-#define AssertArg(condition) \
- Trap(!(condition), BadArg)
-
-#define AssertState(condition) \
- Trap(!(condition), BadState)
-
-extern bool assert_enabled;
-
-#endif /* USE_ASSERT_CHECKING */
-
-/*
- * LogTrap
- * Generates an exception with a message if the given condition is true.
+ * There used to be some incredibly crufty platform-dependent hackery here,
+ * but now we rely on the configure script to get the info for us. Much nicer.
*
+ * NOTE: TYPEALIGN will not work if ALIGNVAL is not a power of 2.
+ * That case seems extremely unlikely to occur in practice, however.
+ * ----------------
*/
-#define LogTrap(condition, exception, printArgs) \
- do { \
- if ((assert_enabled) && (condition)) \
- ExceptionalCondition(CppAsString(condition), &(exception), \
- vararg_format printArgs, __FILE__, __LINE__); \
- } while (0)
-
-/*
- * LogTrapMacro is the same as LogTrap but it's intended for use in macros:
- *
- * #define foo(x) (LogAssertMacro(x != 0, "yow!") && bar(x))
- */
-#define LogTrapMacro(condition, exception, printArgs) \
- ((bool) ((! assert_enabled) || ! (condition) || \
- (ExceptionalCondition(CppAsString(condition), \
- &(exception), \
- vararg_format printArgs, __FILE__, __LINE__))))
-
-#ifndef USE_ASSERT_CHECKING
-#define LogAssert(condition, printArgs)
-#define LogAssertMacro(condition, printArgs) true
-#define LogAssertArg(condition, printArgs)
-#define LogAssertState(condition, printArgs)
-#else
-#define LogAssert(condition, printArgs) \
- LogTrap(!(condition), FailedAssertion, printArgs)
-#define LogAssertMacro(condition, printArgs) \
- LogTrapMacro(!(condition), FailedAssertion, printArgs)
+#define TYPEALIGN(ALIGNVAL,LEN) (((long)(LEN) + (ALIGNVAL-1)) & ~(ALIGNVAL-1))
-#define LogAssertArg(condition, printArgs) \
- LogTrap(!(condition), BadArg, printArgs)
+#define SHORTALIGN(LEN) TYPEALIGN(ALIGNOF_SHORT, (LEN))
+#define INTALIGN(LEN) TYPEALIGN(ALIGNOF_INT, (LEN))
+#define LONGALIGN(LEN) TYPEALIGN(ALIGNOF_LONG, (LEN))
+#define DOUBLEALIGN(LEN) TYPEALIGN(ALIGNOF_DOUBLE, (LEN))
+#define MAXALIGN(LEN) TYPEALIGN(MAXIMUM_ALIGNOF, (LEN))
-#define LogAssertState(condition, printArgs) \
- LogTrap(!(condition), BadState, printArgs)
-
-#ifdef ASSERT_CHECKING_TEST
-extern int assertTest(int val);
-
-#endif
-#endif /* USE_ASSERT_CHECKING */
/* ----------------------------------------------------------------
- * Section 8: Min, Max, Abs macros
+ * Section 6: widely useful macros
* ----------------------------------------------------------------
*/
/*
@@ -887,56 +545,30 @@ extern int assertTest(int val);
/* ----------------------------------------------------------------
- * Section 9: externs
- * ----------------------------------------------------------------
- */
-
-extern Exception FailedAssertion;
-extern Exception BadArg;
-extern Exception BadState;
-
-/* in utils/error/assert.c */
-extern int ExceptionalCondition(char *conditionName,
- Exception *exceptionP, char *details,
- char *fileName, int lineNumber);
-
-
-/* ----------------
- * vararg_format is used by assert and the exception handling stuff
- * ----------------
- */
-extern char *vararg_format(const char *fmt,...);
-
-
-
-/* ----------------------------------------------------------------
- * Section 10: berkeley-specific configuration
- *
- * this section contains settings which are only relevant to the UC Berkeley
- * sites. Other sites can ignore this
+ * Section 7: random stuff
* ----------------------------------------------------------------
*/
-/* ----------------
- * storage managers
- *
- * These are experimental and are not supported in the code that
- * we distribute to other sites.
- * ----------------
- */
-#ifdef NOT_USED
-#define STABLE_MEMORY_STORAGE
-#endif
+/* msb for char */
+#define CSIGNBIT (0x80)
+#define STATUS_OK (0)
+#define STATUS_ERROR (-1)
+#define STATUS_NOT_FOUND (-2)
+#define STATUS_INVALID (-3)
+#define STATUS_UNCATALOGUED (-4)
+#define STATUS_REPLACED (-5)
+#define STATUS_NOT_DONE (-6)
+#define STATUS_BAD_PACKET (-7)
+#define STATUS_FOUND (1)
/* ----------------------------------------------------------------
- * Section 11: system-specific hacks
+ * Section 8: system-specific hacks
*
* This should be limited to things that absolutely have to be
- * included in every source file. The changes should be factored
- * into a separate file so that changes to one port don't require
- * changes to c.h (and everyone recompiling their whole system).
+ * included in every source file. The port-specific header file
+ * is usually a better place for this sort of thing.
* ----------------------------------------------------------------
*/
@@ -951,7 +583,6 @@ extern char *vararg_format(const char *fmt,...);
#endif
#if defined(sun) && defined(__sparc__) && !defined(__SVR4)
-#define memmove(d, s, l) bcopy(s, d, l)
#include <unistd.h>
#include <varargs.h>
#endif
@@ -989,8 +620,8 @@ extern int vsnprintf(char *str, size_t count, const char *fmt, va_list args);
#endif
-#ifndef HAVE_MEMMOVE
-#include <regex/utils.h>
+#if !defined(HAVE_MEMMOVE) && !defined(memmove)
+#define memmove(d, s, c) bcopy(s, d, c)
#endif
/* ----------------
diff --git a/src/include/executor/spi.h b/src/include/executor/spi.h
index 2db0c5d577..4834ab4dd8 100644
--- a/src/include/executor/spi.h
+++ b/src/include/executor/spi.h
@@ -8,6 +8,10 @@
#ifndef SPI_H
#define SPI_H
+/*
+ * This file may be used by client modules that haven't already
+ * included postgres.h
+ */
#include "postgres.h"
/*
diff --git a/src/include/libpq/libpq-fs.h b/src/include/libpq/libpq-fs.h
index 79aa4be80b..64ded84dbc 100644
--- a/src/include/libpq/libpq-fs.h
+++ b/src/include/libpq/libpq-fs.h
@@ -1,95 +1,24 @@
/*-------------------------------------------------------------------------
*
* libpq-fs.h
- * definitions for using Inversion file system routines
+ * definitions for using Inversion file system routines (ie, large objects)
*
*
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: libpq-fs.h,v 1.11 2001/01/24 19:43:25 momjian Exp $
+ * $Id: libpq-fs.h,v 1.12 2001/02/10 02:31:28 tgl Exp $
*
*-------------------------------------------------------------------------
*/
#ifndef LIBPQ_FS_H
#define LIBPQ_FS_H
-/* UNIX compatibility junk. This should be in all systems' include files,
- but this is not always the case. */
-
-#ifndef MAXNAMLEN
-#define MAXNAMLEN 255
-#endif /* MAXNAMLEN */
-
-struct pgdirent
-{
- unsigned long d_ino;
- unsigned short d_namlen;
- char d_name[MAXNAMLEN + 1];
-};
-
-
-/* for stat(2) */
-#ifndef S_IRUSR
-/* file modes */
-
-#define S_IRWXU 00700 /* read, write, execute: owner */
-#define S_IRUSR 00400 /* read permission: owner */
-#define S_IWUSR 00200 /* write permission: owner */
-#define S_IXUSR 00100 /* execute permission: owner */
-
-#define S_IRWXG 00070 /* read, write, execute: group */
-#define S_IRGRP 00040 /* read permission: group */
-#define S_IWGRP 00020 /* write permission: group */
-#define S_IXGRP 00010 /* execute permission: group */
-
-#define S_IRWXO 00007 /* read, write, execute: other */
-#define S_IROTH 00004 /* read permission: other */
-#define S_IWOTH 00002 /* write permission: other */
-#define S_IXOTH 00001 /* execute permission: other */
-
-#define _S_IFMT 0170000 /* type of file; sync with S_IFMT */
-#define _S_IFBLK 0060000 /* block special; sync with S_IFBLK */
-#define _S_IFCHR 0020000 /* character special sync with S_IFCHR */
-#define _S_IFDIR 0040000 /* directory; sync with S_IFDIR */
-#define _S_IFIFO 0010000 /* FIFO - named pipe; sync with S_IFIFO */
-#define _S_IFREG 0100000 /* regular; sync with S_IFREG */
-
-#define S_IFDIR _S_IFDIR
-#define S_IFREG _S_IFREG
-
-#define S_ISDIR( mode ) (((mode) & _S_IFMT) == _S_IFDIR)
-
-#endif /* S_IRUSR */
-
/*
- * Inversion doesn't have links.
- */
-#ifndef S_ISLNK
-#define S_ISLNK(x) 0
-#endif
-
-/*
- * Flags for inversion file system large objects. Normally, creat()
- * takes mode arguments, but we don't use them in inversion, since
- * you get postgres protections. Instead, we use the low sixteen bits
- * of the integer mode argument to store the number of the storage
- * manager to be used, and the high sixteen bits for flags.
+ * Read/write mode flags for inversion (large object) calls
*/
#define INV_WRITE 0x00020000
#define INV_READ 0x00040000
-/* Error values for p_errno */
-#define PEPERM 1 /* Not owner */
-#define PENOENT 2 /* No such file or directory */
-#define PEACCES 13 /* Permission denied */
-#define PEEXIST 17 /* File exists */
-#define PENOTDIR 20 /* Not a directory */
-#define PEISDIR 21 /* Is a directory */
-#define PEINVAL 22 /* Invalid argument */
-#define PENAMETOOLONG 63 /* File name too long */
-#define PENOTEMPTY 66 /* Directory not empty */
-#define PEPGIO 99 /* postgres backend had problems */
-
#endif /* LIBPQ_FS_H */
diff --git a/src/include/libpq/pqcomm.h b/src/include/libpq/pqcomm.h
index d7c6fb9fe4..b952891411 100644
--- a/src/include/libpq/pqcomm.h
+++ b/src/include/libpq/pqcomm.h
@@ -9,18 +9,16 @@
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: pqcomm.h,v 1.53 2001/01/24 19:43:25 momjian Exp $
+ * $Id: pqcomm.h,v 1.54 2001/02/10 02:31:28 tgl Exp $
*
*-------------------------------------------------------------------------
*/
#ifndef PQCOMM_H
#define PQCOMM_H
-#include "postgres.h"
-
#include <sys/types.h>
#ifdef WIN32
-# include "winsock.h"
+# include <winsock.h>
#else /* not WIN32 */
# include <sys/socket.h>
# ifdef HAVE_SYS_UN_H
diff --git a/src/include/mb/pg_wchar.h b/src/include/mb/pg_wchar.h
index 0b0c2e3137..b137da7cec 100644
--- a/src/include/mb/pg_wchar.h
+++ b/src/include/mb/pg_wchar.h
@@ -1,9 +1,8 @@
-/* $Id: pg_wchar.h,v 1.23 2000/11/14 18:37:48 tgl Exp $ */
+/* $Id: pg_wchar.h,v 1.24 2001/02/10 02:31:28 tgl Exp $ */
#ifndef PG_WCHAR_H
#define PG_WCHAR_H
-#include "postgres.h"
#include <sys/types.h>
#ifdef FRONTEND
diff --git a/src/include/miscadmin.h b/src/include/miscadmin.h
index fa73145787..46d7ab534e 100644
--- a/src/include/miscadmin.h
+++ b/src/include/miscadmin.h
@@ -12,7 +12,7 @@
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: miscadmin.h,v 1.80 2001/01/27 00:05:31 tgl Exp $
+ * $Id: miscadmin.h,v 1.81 2001/02/10 02:31:28 tgl Exp $
*
* NOTES
* some of the information in this file should be moved to
@@ -216,6 +216,8 @@ extern int FindExec(char *full_path, const char *argv0,
extern int CheckPathAccess(char *path, char *name, int open_mode);
#ifdef CYR_RECODE
+extern void GetCharSetByHost(char *TableName, int host, const char *DataDir);
+extern void SetCharSet(void);
extern char *convertstr(unsigned char *buff, int len, int dest);
#endif
diff --git a/src/include/postgres.h b/src/include/postgres.h
index 5ff6446e6f..fbc38197d7 100644
--- a/src/include/postgres.h
+++ b/src/include/postgres.h
@@ -1,37 +1,45 @@
/*-------------------------------------------------------------------------
*
* postgres.h
- * definition of (and support for) postgres system types.
- * this file is included by almost every .c in the system
+ * Primary include file for PostgreSQL server .c files
+ *
+ * This should be the first file included by PostgreSQL backend modules.
+ * Client-side code should include postgres_fe.h instead.
+ *
*
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1995, Regents of the University of California
*
- * $Id: postgres.h,v 1.45 2001/01/24 19:43:19 momjian Exp $
+ * $Id: postgres.h,v 1.46 2001/02/10 02:31:28 tgl Exp $
*
*-------------------------------------------------------------------------
*/
/*
- * NOTES
- * this file will eventually contain the definitions for the
- * following (and perhaps other) system types:
+ *----------------------------------------------------------------
+ * TABLE OF CONTENTS
*
- * int2 int4 float4 float8
- * Oid regproc RegProcedure
- * aclitem
- * struct varlena
- * int2vector oidvector
- * bytea text
- * NameData Name
+ * When adding stuff to this file, please try to put stuff
+ * into the relevant section, or add new sections as appropriate.
*
- * TABLE OF CONTENTS
- * 1) simple type definitions
- * 2) varlena and array types
- * 3) TransactionId and CommandId
+ * section description
+ * ------- ------------------------------------------------
+ * 1) variable-length datatypes (TOAST support)
+ * 2) datum type + support macros
+ * 3) exception handling definitions
* 4) genbki macros used by catalog/pg_xxx.h files
- * 5) random stuff
*
- * ----------------------------------------------------------------
+ * NOTES
+ *
+ * In general, this file should contain declarations that are widely needed in the
+ * backend environment, but are of no interest outside the backend.
+ *
+ * Simple type definitions live in c.h, where they are shared with postgres_fe.h.
+ * We do that since those type definitions are needed by frontend modules that want
+ * to deal with binary data transmission to or from the backend. Type definitions
+ * in this file should be for representations that never escape the backend, such
+ * as Datum or TOASTed varlena objects.
+ *
+ *----------------------------------------------------------------
*/
#ifndef POSTGRES_H
#define POSTGRES_H
@@ -42,59 +50,16 @@
#include "utils/palloc.h"
/* ----------------------------------------------------------------
- * Section 1: simple type definitions
+ * Section 1: variable-length datatypes (TOAST support)
* ----------------------------------------------------------------
*/
-#define InvalidOid ((Oid) 0)
-#define OidIsValid(objectId) ((bool) ((objectId) != InvalidOid))
-
-/* unfortunately, both regproc and RegProcedure are used */
-typedef Oid regproc;
-typedef Oid RegProcedure;
-
-#define RegProcedureIsValid(p) OidIsValid(p)
-
-typedef int4 aclitem; /* PHONY definition for catalog use only */
-
-/* ----------------------------------------------------------------
- * Section 2: variable length and array types
- * ----------------------------------------------------------------
- */
/* ----------------
- * struct varlena
+ * struct varattrib is the header of a varlena object that may have been TOASTed.
* ----------------
*/
-struct varlena
-{
- int32 vl_len;
- char vl_dat[1];
-};
-
#define TUPLE_TOASTER_ACTIVE
-#ifndef TUPLE_TOASTER_ACTIVE
-#define VARSIZE(PTR) (((struct varlena *)(PTR))->vl_len)
-#define VARDATA(PTR) (((struct varlena *)(PTR))->vl_dat)
-#endif
-#define VARHDRSZ ((int32) sizeof(int32))
-
-/*
- * These widely-used datatypes are just a varlena header and the data bytes.
- * There is no terminating null or anything like that --- the data length is
- * always VARSIZE(ptr) - VARHDRSZ.
- */
-typedef struct varlena bytea;
-typedef struct varlena text;
-typedef struct varlena BpChar; /* blank-padded char, ie SQL char(n) */
-typedef struct varlena VarChar; /* var-length char, ie SQL varchar(n) */
-
-/*
- * Proposed new layout for variable length attributes
- * DO NOT USE YET - Jan
- */
-
-#ifdef TUPLE_TOASTER_ACTIVE
typedef struct varattrib
{
int32 va_header; /* External/compressed storage */
@@ -142,64 +107,466 @@ typedef struct varattrib
#define VARATT_IS_COMPRESSED(PTR) \
((VARATT_SIZEP(PTR) & VARATT_FLAG_COMPRESSED) != 0)
-/* ----------
- * This is regularly declared in access/tuptoaster.h,
- * but we don't want to include that into every source,
- * so we (evil evil evil) declare it here once more.
- * ----------
+
+/* ----------------------------------------------------------------
+ * Section 2: datum type + support macros
+ * ----------------------------------------------------------------
+ */
+
+/*
+ * Port Notes:
+ * Postgres makes the following assumption about machines:
+ *
+ * sizeof(Datum) == sizeof(long) >= sizeof(void *) >= 4
+ *
+ * Postgres also assumes that
+ *
+ * sizeof(char) == 1
+ *
+ * and that
+ *
+ * sizeof(short) == 2
+ *
+ * If your machine meets these requirements, Datums should also be checked
+ * to see if the positioning is correct.
+ */
+
+typedef unsigned long Datum; /* XXX sizeof(long) >= sizeof(void *) */
+typedef Datum *DatumPtr;
+
+#define GET_1_BYTE(datum) (((Datum) (datum)) & 0x000000ff)
+#define GET_2_BYTES(datum) (((Datum) (datum)) & 0x0000ffff)
+#define GET_4_BYTES(datum) (((Datum) (datum)) & 0xffffffff)
+#define SET_1_BYTE(value) (((Datum) (value)) & 0x000000ff)
+#define SET_2_BYTES(value) (((Datum) (value)) & 0x0000ffff)
+#define SET_4_BYTES(value) (((Datum) (value)) & 0xffffffff)
+
+/*
+ * DatumGetBool
+ * Returns boolean value of a datum.
+ *
+ * Note: any nonzero value will be considered TRUE.
*/
-extern varattrib *heap_tuple_untoast_attr(varattrib * attr);
-#define VARATT_GETPLAIN(_ARG,_VAR) { \
- if (VARATT_IS_EXTENDED(_ARG)) \
- (_VAR) = (void *)heap_tuple_untoast_attr(_ARG); \
- else \
- (_VAR) = (void *)(_ARG); \
- }
-#define VARATT_FREE(_ARG,_VAR) do { \
- if ((void *)(_VAR) != (void *)(_ARG)) \
- pfree((void *)(_VAR)); \
- } while (0)
-#else /* TUPLE_TOASTER_ACTIVE */
-#define VARATT_SIZE(__PTR) VARSIZE(__PTR)
-#define VARATT_SIZEP(__PTR) VARSIZE(__PTR)
-#endif /* TUPLE_TOASTER_ACTIVE */
+#define DatumGetBool(X) ((bool) (((Datum) (X)) != 0))
+
+/*
+ * BoolGetDatum
+ * Returns datum representation for a boolean.
+ *
+ * Note: any nonzero value will be considered TRUE.
+ */
+#define BoolGetDatum(X) ((Datum) ((X) ? 1 : 0))
-/* fixed-length array types (these are not varlena's!) */
+/*
+ * DatumGetChar
+ * Returns character value of a datum.
+ */
-typedef int2 int2vector[INDEX_MAX_KEYS];
-typedef Oid oidvector[INDEX_MAX_KEYS];
+#define DatumGetChar(X) ((char) GET_1_BYTE(X))
-/* We want NameData to have length NAMEDATALEN and int alignment,
- * because that's how the data type 'name' is defined in pg_type.
- * Use a union to make sure the compiler agrees.
+/*
+ * CharGetDatum
+ * Returns datum representation for a character.
+ */
+
+#define CharGetDatum(X) ((Datum) SET_1_BYTE(X))
+
+/*
+ * Int8GetDatum
+ * Returns datum representation for an 8-bit integer.
+ */
+
+#define Int8GetDatum(X) ((Datum) SET_1_BYTE(X))
+
+/*
+ * DatumGetUInt8
+ * Returns 8-bit unsigned integer value of a datum.
+ */
+
+#define DatumGetUInt8(X) ((uint8) GET_1_BYTE(X))
+
+/*
+ * UInt8GetDatum
+ * Returns datum representation for an 8-bit unsigned integer.
+ */
+
+#define UInt8GetDatum(X) ((Datum) SET_1_BYTE(X))
+
+/*
+ * DatumGetInt16
+ * Returns 16-bit integer value of a datum.
+ */
+
+#define DatumGetInt16(X) ((int16) GET_2_BYTES(X))
+
+/*
+ * Int16GetDatum
+ * Returns datum representation for a 16-bit integer.
+ */
+
+#define Int16GetDatum(X) ((Datum) SET_2_BYTES(X))
+
+/*
+ * DatumGetUInt16
+ * Returns 16-bit unsigned integer value of a datum.
+ */
+
+#define DatumGetUInt16(X) ((uint16) GET_2_BYTES(X))
+
+/*
+ * UInt16GetDatum
+ * Returns datum representation for a 16-bit unsigned integer.
+ */
+
+#define UInt16GetDatum(X) ((Datum) SET_2_BYTES(X))
+
+/*
+ * DatumGetInt32
+ * Returns 32-bit integer value of a datum.
+ */
+
+#define DatumGetInt32(X) ((int32) GET_4_BYTES(X))
+
+/*
+ * Int32GetDatum
+ * Returns datum representation for a 32-bit integer.
+ */
+
+#define Int32GetDatum(X) ((Datum) SET_4_BYTES(X))
+
+/*
+ * DatumGetUInt32
+ * Returns 32-bit unsigned integer value of a datum.
+ */
+
+#define DatumGetUInt32(X) ((uint32) GET_4_BYTES(X))
+
+/*
+ * UInt32GetDatum
+ * Returns datum representation for a 32-bit unsigned integer.
+ */
+
+#define UInt32GetDatum(X) ((Datum) SET_4_BYTES(X))
+
+/*
+ * DatumGetObjectId
+ * Returns object identifier value of a datum.
+ */
+
+#define DatumGetObjectId(X) ((Oid) GET_4_BYTES(X))
+
+/*
+ * ObjectIdGetDatum
+ * Returns datum representation for an object identifier.
+ */
+
+#define ObjectIdGetDatum(X) ((Datum) SET_4_BYTES(X))
+
+/*
+ * DatumGetPointer
+ * Returns pointer value of a datum.
+ */
+
+#define DatumGetPointer(X) ((Pointer) (X))
+
+/*
+ * PointerGetDatum
+ * Returns datum representation for a pointer.
*/
-typedef union nameData
-{
- char data[NAMEDATALEN];
- int alignmentDummy;
-} NameData;
-typedef NameData *Name;
-#define NameStr(name) ((name).data)
+#define PointerGetDatum(X) ((Datum) (X))
+
+/*
+ * DatumGetCString
+ * Returns C string (null-terminated string) value of a datum.
+ *
+ * Note: C string is not a full-fledged Postgres type at present,
+ * but type input functions use this conversion for their inputs.
+ */
+
+#define DatumGetCString(X) ((char *) DatumGetPointer(X))
+
+/*
+ * CStringGetDatum
+ * Returns datum representation for a C string (null-terminated string).
+ *
+ * Note: C string is not a full-fledged Postgres type at present,
+ * but type output functions use this conversion for their outputs.
+ * Note: CString is pass-by-reference; caller must ensure the pointed-to
+ * value has adequate lifetime.
+ */
+
+#define CStringGetDatum(X) PointerGetDatum(X)
+
+/*
+ * DatumGetName
+ * Returns name value of a datum.
+ */
+
+#define DatumGetName(X) ((Name) DatumGetPointer(X))
+
+/*
+ * NameGetDatum
+ * Returns datum representation for a name.
+ *
+ * Note: Name is pass-by-reference; caller must ensure the pointed-to
+ * value has adequate lifetime.
+ */
+
+#define NameGetDatum(X) PointerGetDatum(X)
+
+/*
+ * DatumGetInt64
+ * Returns 64-bit integer value of a datum.
+ *
+ * Note: this macro hides the fact that int64 is currently a
+ * pass-by-reference type. Someday it may be pass-by-value,
+ * at least on some platforms.
+ */
+
+#define DatumGetInt64(X) (* ((int64 *) DatumGetPointer(X)))
+
+/*
+ * Int64GetDatum
+ * Returns datum representation for a 64-bit integer.
+ *
+ * Note: this routine returns a reference to palloc'd space.
+ */
+
+extern Datum Int64GetDatum(int64 X);
+
+/*
+ * DatumGetFloat4
+ * Returns 4-byte floating point value of a datum.
+ *
+ * Note: this macro hides the fact that float4 is currently a
+ * pass-by-reference type. Someday it may be pass-by-value.
+ */
+
+#define DatumGetFloat4(X) (* ((float4 *) DatumGetPointer(X)))
+
+/*
+ * Float4GetDatum
+ * Returns datum representation for a 4-byte floating point number.
+ *
+ * Note: this routine returns a reference to palloc'd space.
+ */
+
+extern Datum Float4GetDatum(float4 X);
+
+/*
+ * DatumGetFloat8
+ * Returns 8-byte floating point value of a datum.
+ *
+ * Note: this macro hides the fact that float8 is currently a
+ * pass-by-reference type. Someday it may be pass-by-value,
+ * at least on some platforms.
+ */
+
+#define DatumGetFloat8(X) (* ((float8 *) DatumGetPointer(X)))
+
+/*
+ * Float8GetDatum
+ * Returns datum representation for an 8-byte floating point number.
+ *
+ * Note: this routine returns a reference to palloc'd space.
+ */
+
+extern Datum Float8GetDatum(float8 X);
+
+
+/*
+ * DatumGetFloat32
+ * Returns 32-bit floating point value of a datum.
+ * This is really a pointer, of course.
+ *
+ * XXX: this macro is now deprecated in favor of DatumGetFloat4.
+ * It will eventually go away.
+ */
+
+#define DatumGetFloat32(X) ((float32) DatumGetPointer(X))
+
+/*
+ * Float32GetDatum
+ * Returns datum representation for a 32-bit floating point number.
+ * This is really a pointer, of course.
+ *
+ * XXX: this macro is now deprecated in favor of Float4GetDatum.
+ * It will eventually go away.
+ */
+
+#define Float32GetDatum(X) PointerGetDatum(X)
+
+/*
+ * DatumGetFloat64
+ * Returns 64-bit floating point value of a datum.
+ * This is really a pointer, of course.
+ *
+ * XXX: this macro is now deprecated in favor of DatumGetFloat8.
+ * It will eventually go away.
+ */
+
+#define DatumGetFloat64(X) ((float64) DatumGetPointer(X))
+
+/*
+ * Float64GetDatum
+ * Returns datum representation for a 64-bit floating point number.
+ * This is really a pointer, of course.
+ *
+ * XXX: this macro is now deprecated in favor of Float8GetDatum.
+ * It will eventually go away.
+ */
+
+#define Float64GetDatum(X) PointerGetDatum(X)
+
+/*
+ * Int64GetDatumFast
+ * Float4GetDatumFast
+ * Float8GetDatumFast
+ *
+ * These macros are intended to allow writing code that does not depend on
+ * whether int64, float4, float8 are pass-by-reference types, while not
+ * sacrificing performance when they are. The argument must be a variable
+ * that will exist and have the same value for as long as the Datum is needed.
+ * In the pass-by-ref case, the address of the variable is taken to use as
+ * the Datum. In the pass-by-val case, these will be the same as the non-Fast
+ * macros.
+ */
+
+#define Int64GetDatumFast(X) PointerGetDatum(&(X))
+#define Float4GetDatumFast(X) PointerGetDatum(&(X))
+#define Float8GetDatumFast(X) PointerGetDatum(&(X))
+
/* ----------------------------------------------------------------
- * Section 3: TransactionId and CommandId
+ * Section 3: exception handling definitions
+ * Assert, Trap, etc macros
* ----------------------------------------------------------------
*/
-typedef uint32 TransactionId;
+typedef char *ExcMessage;
+
+typedef struct Exception
+{
+ ExcMessage message;
+} Exception;
+
+extern Exception FailedAssertion;
+extern Exception BadArg;
+extern Exception BadState;
-#define InvalidTransactionId 0
+extern bool assert_enabled;
-typedef uint32 CommandId;
+/*
+ * USE_ASSERT_CHECKING, if defined, turns on all the assertions.
+ * - plai 9/5/90
+ *
+ * It should _NOT_ be defined in releases or in benchmark copies
+ */
-#define FirstCommandId 0
+/*
+ * Trap
+ * Generates an exception if the given condition is true.
+ *
+ */
+#define Trap(condition, exception) \
+ do { \
+ if ((assert_enabled) && (condition)) \
+ ExceptionalCondition(CppAsString(condition), &(exception), \
+ (char*)NULL, __FILE__, __LINE__); \
+ } while (0)
+
+/*
+ * TrapMacro is the same as Trap but it's intended for use in macros:
+ *
+ * #define foo(x) (AssertM(x != 0) && bar(x))
+ *
+ * Isn't CPP fun?
+ */
+#define TrapMacro(condition, exception) \
+ ((bool) ((! assert_enabled) || ! (condition) || \
+ (ExceptionalCondition(CppAsString(condition), \
+ &(exception), \
+ (char*) NULL, __FILE__, __LINE__))))
+
+#ifndef USE_ASSERT_CHECKING
+#define Assert(condition)
+#define AssertMacro(condition) ((void)true)
+#define AssertArg(condition)
+#define AssertState(condition)
+#define assert_enabled 0
+#else
+#define Assert(condition) \
+ Trap(!(condition), FailedAssertion)
+
+#define AssertMacro(condition) \
+ ((void) TrapMacro(!(condition), FailedAssertion))
+
+#define AssertArg(condition) \
+ Trap(!(condition), BadArg)
+
+#define AssertState(condition) \
+ Trap(!(condition), BadState)
+
+#endif /* USE_ASSERT_CHECKING */
+
+/*
+ * LogTrap
+ * Generates an exception with a message if the given condition is true.
+ *
+ */
+#define LogTrap(condition, exception, printArgs) \
+ do { \
+ if ((assert_enabled) && (condition)) \
+ ExceptionalCondition(CppAsString(condition), &(exception), \
+ vararg_format printArgs, __FILE__, __LINE__); \
+ } while (0)
+
+/*
+ * LogTrapMacro is the same as LogTrap but it's intended for use in macros:
+ *
+ * #define foo(x) (LogAssertMacro(x != 0, "yow!") && bar(x))
+ */
+#define LogTrapMacro(condition, exception, printArgs) \
+ ((bool) ((! assert_enabled) || ! (condition) || \
+ (ExceptionalCondition(CppAsString(condition), \
+ &(exception), \
+ vararg_format printArgs, __FILE__, __LINE__))))
+
+extern int ExceptionalCondition(char *conditionName,
+ Exception *exceptionP, char *details,
+ char *fileName, int lineNumber);
+extern char *vararg_format(const char *fmt, ...);
+
+#ifndef USE_ASSERT_CHECKING
+#define LogAssert(condition, printArgs)
+#define LogAssertMacro(condition, printArgs) true
+#define LogAssertArg(condition, printArgs)
+#define LogAssertState(condition, printArgs)
+#else
+#define LogAssert(condition, printArgs) \
+ LogTrap(!(condition), FailedAssertion, printArgs)
+
+#define LogAssertMacro(condition, printArgs) \
+ LogTrapMacro(!(condition), FailedAssertion, printArgs)
+
+#define LogAssertArg(condition, printArgs) \
+ LogTrap(!(condition), BadArg, printArgs)
+
+#define LogAssertState(condition, printArgs) \
+ LogTrap(!(condition), BadState, printArgs)
+
+#ifdef ASSERT_CHECKING_TEST
+extern int assertTest(int val);
+
+#endif
+
+#endif /* USE_ASSERT_CHECKING */
/* ----------------------------------------------------------------
- * Section 4: genbki macros used by the
- * catalog/pg_xxx.h files
+ * Section 4: genbki macros used by catalog/pg_xxx.h files
* ----------------------------------------------------------------
*/
#define CATALOG(x) \
@@ -217,35 +584,7 @@ typedef uint32 CommandId;
#define BKI_BEGIN
#define BKI_END
-/* ----------------------------------------------------------------
- * Section 5: random stuff
- * CSIGNBIT, STATUS...
- * ----------------------------------------------------------------
- */
-
-/* msb for int/unsigned */
-#define ISIGNBIT (0x80000000)
-#define WSIGNBIT (0x8000)
-
-/* msb for char */
-#define CSIGNBIT (0x80)
-
-#define STATUS_OK (0)
-#define STATUS_ERROR (-1)
-#define STATUS_NOT_FOUND (-2)
-#define STATUS_INVALID (-3)
-#define STATUS_UNCATALOGUED (-4)
-#define STATUS_REPLACED (-5)
-#define STATUS_NOT_DONE (-6)
-#define STATUS_BAD_PACKET (-7)
-#define STATUS_FOUND (1)
+typedef int4 aclitem; /* PHONY definition for catalog use only */
-/* ---------------
- * Cyrillic on the fly charsets recode
- * ---------------
- */
-#ifdef CYR_RECODE
-extern void SetCharSet(void);
-#endif /* CYR_RECODE */
#endif /* POSTGRES_H */
diff --git a/src/include/postgres_ext.h b/src/include/postgres_ext.h
index 18be70ea92..a5696f2a02 100644
--- a/src/include/postgres_ext.h
+++ b/src/include/postgres_ext.h
@@ -2,10 +2,9 @@
*
* postgres_ext.h
*
- * This file contains declarations of things that are visible
- * external to Postgres. For example, the Oid type is part of a
- * structure that is passed to the front end via libpq, and is
- * accordingly referenced in libpq-fe.h.
+ * This file contains declarations of things that are visible everywhere
+ * in PostgreSQL *and* are visible to clients of frontend interface libraries.
+ * For example, the Oid type is part of the API of libpq and other libraries.
*
* Declarations which are specific to a particular interface should
* go in the header file for that interface (such as libpq-fe.h). This
@@ -16,7 +15,7 @@
* use header files that are otherwise internal to Postgres to interface
* with the backend.
*
- * $Id: postgres_ext.h,v 1.5 2000/12/22 21:36:09 tgl Exp $
+ * $Id: postgres_ext.h,v 1.6 2001/02/10 02:31:28 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -29,6 +28,8 @@
*/
typedef unsigned int Oid;
+#define InvalidOid ((Oid) 0)
+
#define OID_MAX UINT_MAX
/* you will need to include <limits.h> to use the above #define */
diff --git a/src/include/postgres_fe.h b/src/include/postgres_fe.h
new file mode 100644
index 0000000000..b76d43d7a3
--- /dev/null
+++ b/src/include/postgres_fe.h
@@ -0,0 +1,24 @@
+/*-------------------------------------------------------------------------
+ *
+ * postgres_fe.h
+ * Primary include file for PostgreSQL client-side .c files
+ *
+ * This should be the first file included by PostgreSQL client libraries and
+ * application programs --- but not by backend modules, which should include
+ * postgres.h.
+ *
+ *
+ * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
+ * Portions Copyright (c) 1995, Regents of the University of California
+ *
+ * $Id: postgres_fe.h,v 1.1 2001/02/10 02:31:28 tgl Exp $
+ *
+ *-------------------------------------------------------------------------
+ */
+#ifndef POSTGRES_FE_H
+#define POSTGRES_FE_H
+
+#include "postgres_ext.h"
+#include "c.h"
+
+#endif /* POSTGRES_FE_H */
diff --git a/src/include/regex/regex.h b/src/include/regex/regex.h
index 677f5ca9a2..b0b86f3cb6 100644
--- a/src/include/regex/regex.h
+++ b/src/include/regex/regex.h
@@ -40,7 +40,6 @@
#ifndef _REGEX_H_
#define _REGEX_H_
-#include "postgres.h"
#include <sys/types.h>
#include "mb/pg_wchar.h"
diff --git a/src/include/regex/regex2.h b/src/include/regex/regex2.h
index f655a1f2a2..b885ff4318 100644
--- a/src/include/regex/regex2.h
+++ b/src/include/regex/regex2.h
@@ -37,9 +37,7 @@
* @(#)regex2.h 8.4 (Berkeley) 3/20/94
*/
-#include "postgres.h"
-
-#include "limits.h"
+#include <limits.h>
/*
* First, the stuff that ends up in the outside-world include file
diff --git a/src/include/regex/utils.h b/src/include/regex/utils.h
index 461e7ad6b0..72f89dcafc 100644
--- a/src/include/regex/utils.h
+++ b/src/include/regex/utils.h
@@ -37,9 +37,7 @@
* @(#)utils.h 8.3 (Berkeley) 3/20/94
*/
-#include "postgres.h"
-
-#include "limits.h"
+#include <limits.h>
/* utility definitions */
#define DUPMAX 100000000 /* xxx is this right? */
@@ -50,6 +48,7 @@
#else
#define NC (CHAR_MAX - CHAR_MIN + 1)
#endif
+
typedef unsigned char uch;
/* switch off assertions (if not already off) if no REDEBUG */
@@ -58,8 +57,3 @@ typedef unsigned char uch;
#define NDEBUG /* no assertions please */
#endif
#endif
-
-/* for old systems with bcopy() but no memmove() */
-#if !defined(HAVE_MEMMOVE) && !defined(memmove)
-#define memmove(d, s, c) bcopy(s, d, c)
-#endif
diff --git a/src/include/storage/ipc.h b/src/include/storage/ipc.h
index 49ca90ad85..3173121850 100644
--- a/src/include/storage/ipc.h
+++ b/src/include/storage/ipc.h
@@ -7,7 +7,7 @@
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: ipc.h,v 1.46 2001/01/24 19:43:27 momjian Exp $
+ * $Id: ipc.h,v 1.47 2001/02/10 02:31:28 tgl Exp $
*
* Some files that would normally need to include only sys/ipc.h must
* instead include this file because on Ultrix, sys/ipc.h is not designed
@@ -18,8 +18,6 @@
#ifndef IPC_H
#define IPC_H
-#include "config.h"
-
#include <sys/types.h>
#ifdef HAVE_SYS_IPC_H
#include <sys/ipc.h>
diff --git a/src/include/utils/dynamic_loader.h b/src/include/utils/dynamic_loader.h
index 953495251b..569aba644f 100644
--- a/src/include/utils/dynamic_loader.h
+++ b/src/include/utils/dynamic_loader.h
@@ -7,19 +7,13 @@
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: dynamic_loader.h,v 1.16 2001/01/24 19:43:28 momjian Exp $
+ * $Id: dynamic_loader.h,v 1.17 2001/02/10 02:31:29 tgl Exp $
*
*-------------------------------------------------------------------------
*/
#ifndef DYNAMIC_LOADER_H
#define DYNAMIC_LOADER_H
-#include <sys/types.h>
-
-/* we need this include because port files use them */
-#include "postgres.h"
-
-/* and this one for typedef PGFunction */
#include "fmgr.h"
diff --git a/src/include/utils/exc.h b/src/include/utils/exc.h
index e44f9b46d9..09b4179097 100644
--- a/src/include/utils/exc.h
+++ b/src/include/utils/exc.h
@@ -7,15 +7,13 @@
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: exc.h,v 1.18 2001/01/24 19:43:28 momjian Exp $
+ * $Id: exc.h,v 1.19 2001/02/10 02:31:29 tgl Exp $
*
*-------------------------------------------------------------------------
*/
#ifndef EXC_H
#define EXC_H
-#include "config.h"
-
#include <setjmp.h>
extern char *ExcFileName;
diff --git a/src/include/utils/geo_decls.h b/src/include/utils/geo_decls.h
index 67ab1cd4fb..27b0dc7fac 100644
--- a/src/include/utils/geo_decls.h
+++ b/src/include/utils/geo_decls.h
@@ -6,7 +6,7 @@
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: geo_decls.h,v 1.32 2001/01/24 19:43:28 momjian Exp $
+ * $Id: geo_decls.h,v 1.33 2001/02/10 02:31:29 tgl Exp $
*
* NOTE
* These routines do *not* use the float types from adt/.
@@ -21,7 +21,6 @@
#ifndef GEO_DECLS_H
#define GEO_DECLS_H
-#include "access/attnum.h"
#include "fmgr.h"
/*--------------------------------------------------------------------
diff --git a/src/include/utils/guc.h b/src/include/utils/guc.h
index 0d8661442f..7953e5a8e7 100644
--- a/src/include/utils/guc.h
+++ b/src/include/utils/guc.h
@@ -4,13 +4,11 @@
* External declarations pertaining to backend/utils/misc/guc.c and
* backend/utils/misc/guc-file.l
*
- * $Header: /cvsroot/pgsql/src/include/utils/guc.h,v 1.4 2000/07/27 19:49:24 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/include/utils/guc.h,v 1.5 2001/02/10 02:31:29 tgl Exp $
*/
#ifndef GUC_H
#define GUC_H
-#include "postgres.h"
-
/*
* Certain options can only be set at certain times. The rules are
* like this:
diff --git a/src/include/utils/palloc.h b/src/include/utils/palloc.h
index c1613c0509..cb86616d80 100644
--- a/src/include/utils/palloc.h
+++ b/src/include/utils/palloc.h
@@ -21,7 +21,7 @@
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: palloc.h,v 1.14 2001/01/24 19:43:28 momjian Exp $
+ * $Id: palloc.h,v 1.15 2001/02/10 02:31:29 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -64,24 +64,4 @@ extern char *MemoryContextStrdup(MemoryContext context, const char *string);
#define pstrdup(str) MemoryContextStrdup(CurrentMemoryContext, (str))
-/* ----------------
- * Alignment macros: align a length or address appropriately for a given type.
- *
- * There used to be some incredibly crufty platform-dependent hackery here,
- * but now we rely on the configure script to get the info for us. Much nicer.
- *
- * NOTE: TYPEALIGN will not work if ALIGNVAL is not a power of 2.
- * That case seems extremely unlikely to occur in practice, however.
- * ----------------
- */
-
-#define TYPEALIGN(ALIGNVAL,LEN) (((long)(LEN) + (ALIGNVAL-1)) & ~(ALIGNVAL-1))
-
-#define SHORTALIGN(LEN) TYPEALIGN(ALIGNOF_SHORT, (LEN))
-#define INTALIGN(LEN) TYPEALIGN(ALIGNOF_INT, (LEN))
-#define LONGALIGN(LEN) TYPEALIGN(ALIGNOF_LONG, (LEN))
-#define DOUBLEALIGN(LEN) TYPEALIGN(ALIGNOF_DOUBLE, (LEN))
-#define MAXALIGN(LEN) TYPEALIGN(MAXIMUM_ALIGNOF, (LEN))
-
-
#endif /* PALLOC_H */