77 * Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group
88 * Portions Copyright (c) 1994, Regents of the University of California
99 *
10- * $PostgreSQL: pgsql/src/include/utils/date.h,v 1.29 2004/12/31 22:03:45 pgsql Exp $
10+ * $PostgreSQL: pgsql/src/include/utils/date.h,v 1.30 2005/02/25 16:13:29 teodor Exp $
1111 *
1212 *-------------------------------------------------------------------------
1313 */
@@ -38,18 +38,28 @@ typedef struct
3838int32 zone ;/* numeric time zone, in seconds */
3939}TimeTzADT ;
4040
41+ /*
42+ * Macros for fmgr-callable functions.
43+ *
44+ * For TimeADT, we make use of the same support routines as for float8 or int64.
45+ * Therefore TimeADT is pass-by-reference if and only if float8 or int64 is!
46+ */
4147#ifdef HAVE_INT64_TIMESTAMP
48+
4249#define MAX_TIME_PRECISION 6
50+
51+ #define DatumGetDateADT (X ) ((DateADT) DatumGetInt32(X))
52+ #define DatumGetTimeADT (X ) ((TimeADT) DatumGetInt64(X))
53+ #define DatumGetTimeTzADTP (X ) ((TimeTzADT *) DatumGetPointer(X))
54+
55+ #define DateADTGetDatum (X ) Int32GetDatum(X)
56+ #define TimeADTGetDatum (X ) Int64GetDatum(X)
57+ #define TimeTzADTPGetDatum (X ) PointerGetDatum(X)
58+
4359#else
60+
4461#define MAX_TIME_PRECISION 10
45- #endif
4662
47- /*
48- * Macros for fmgr-callable functions.
49- *
50- * For TimeADT, we make use of the same support routines as for float8.
51- * Therefore TimeADT is pass-by-reference if and only if float8 is!
52- */
5363#define DatumGetDateADT (X ) ((DateADT) DatumGetInt32(X))
5464#define DatumGetTimeADT (X ) ((TimeADT) DatumGetFloat8(X))
5565#define DatumGetTimeTzADTP (X ) ((TimeTzADT *) DatumGetPointer(X))
@@ -58,6 +68,8 @@ typedef struct
5868#define TimeADTGetDatum (X ) Float8GetDatum(X)
5969#define TimeTzADTPGetDatum (X ) PointerGetDatum(X)
6070
71+ #endif /* HAVE_INT64_TIMESTAMP */
72+
6173#define PG_GETARG_DATEADT (n ) DatumGetDateADT(PG_GETARG_DATUM(n))
6274#define PG_GETARG_TIMEADT (n ) DatumGetTimeADT(PG_GETARG_DATUM(n))
6375#define PG_GETARG_TIMETZADT_P (n ) DatumGetTimeTzADTP(PG_GETARG_DATUM(n))