aboutsummaryrefslogtreecommitdiff
path: root/src/include/postgres.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/include/postgres.h')
-rw-r--r--src/include/postgres.h16
1 files changed, 11 insertions, 5 deletions
diff --git a/src/include/postgres.h b/src/include/postgres.h
index c06333573e2..5234c34e291 100644
--- a/src/include/postgres.h
+++ b/src/include/postgres.h
@@ -10,7 +10,7 @@
* Portions Copyright (c) 1996-2007, PostgreSQL Global Development Group
* Portions Copyright (c) 1995, Regents of the University of California
*
- * $PostgreSQL: pgsql/src/include/postgres.h,v 1.77 2007/02/27 23:48:09 tgl Exp $
+ * $PostgreSQL: pgsql/src/include/postgres.h,v 1.78 2007/03/23 20:24:41 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -125,13 +125,18 @@ typedef struct varattrib
*
* sizeof(short) == 2
*
- * If your machine meets these requirements, Datums should also be checked
- * to see if the positioning is correct.
+ * When a type narrower than Datum is stored in a Datum, we place it in the
+ * low-order bits and are careful that the DatumGetXXX macro for it discards
+ * the unused high-order bits (as opposed to, say, assuming they are zero).
+ * This is needed to support old-style user-defined functions, since depending
+ * on architecture and compiler, the return value of a function returning char
+ * or short may contain garbage when called as if it returned Datum.
*/
typedef unsigned long Datum; /* XXX sizeof(long) >= sizeof(void *) */
#define SIZEOF_DATUM SIZEOF_UNSIGNED_LONG
+
typedef Datum *DatumPtr;
#define GET_1_BYTE(datum) (((Datum) (datum)) & 0x000000ff)
@@ -145,10 +150,11 @@ typedef Datum *DatumPtr;
* DatumGetBool
* Returns boolean value of a datum.
*
- * Note: any nonzero value will be considered TRUE.
+ * Note: any nonzero value will be considered TRUE, but we ignore bits to
+ * the left of the width of bool, per comment above.
*/
-#define DatumGetBool(X) ((bool) (((Datum) (X)) != 0))
+#define DatumGetBool(X) ((bool) (((bool) (X)) != 0))
/*
* BoolGetDatum