aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas G. Lockhart <lockhart@fourpalms.org>2002-08-04 06:42:18 +0000
committerThomas G. Lockhart <lockhart@fourpalms.org>2002-08-04 06:42:18 +0000
commite025bb7a725610e327401d7afacedaad7079b989 (patch)
tree258dc87c86f6cb0b9f1ef156f7d508b103b52943
parent043f9eb90afcc565a88834ff26ed127c5d31d103 (diff)
downloadpostgresql-e025bb7a725610e327401d7afacedaad7079b989.tar.gz
postgresql-e025bb7a725610e327401d7afacedaad7079b989.zip
Define macros for handling typmod manipulation for date/time types.
Should be more robust than all of that brute-force inline code. Rename macros for masking and typmod manipulation to put TIMESTAMP_ or INTERVAL_ in front of the macro name, to reduce the possibility of name space collisions.
-rw-r--r--src/include/utils/timestamp.h22
1 files changed, 17 insertions, 5 deletions
diff --git a/src/include/utils/timestamp.h b/src/include/utils/timestamp.h
index aea1c17841b..b2a7f85b8ca 100644
--- a/src/include/utils/timestamp.h
+++ b/src/include/utils/timestamp.h
@@ -6,7 +6,7 @@
* Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: timestamp.h,v 1.27 2002/06/20 20:29:53 momjian Exp $
+ * $Id: timestamp.h,v 1.28 2002/08/04 06:42:18 thomas Exp $
*
*-------------------------------------------------------------------------
*/
@@ -52,6 +52,10 @@ typedef struct
} Interval;
+#define MAX_TIMESTAMP_PRECISION 6
+#define MAX_INTERVAL_PRECISION 6
+
+
/*
* Macros for fmgr-callable functions.
*
@@ -117,10 +121,6 @@ typedef struct
#define TIMESTAMP_NOT_FINITE(j) (TIMESTAMP_IS_NOBEGIN(j) || TIMESTAMP_IS_NOEND(j))
-
-#define MAX_TIMESTAMP_PRECISION 6
-#define MAX_INTERVAL_PRECISION 6
-
#ifdef HAVE_INT64_TIMESTAMP
typedef int32 fsec_t;
@@ -134,6 +134,18 @@ typedef double fsec_t;
#endif
+#define TIMESTAMP_MASK(b) (1 << (b))
+#define INTERVAL_MASK(b) (1 << (b))
+
+/* Macros to handle packing and unpacking the typmod field for intervals */
+#define INTERVAL_FULL_RANGE (0x7FFF)
+#define INTERVAL_RANGE_MASK (0x7FFF)
+#define INTERVAL_FULL_PRECISION (0xFFFF)
+#define INTERVAL_PRECISION_MASK (0xFFFF)
+#define INTERVAL_TYPMOD(p,r) ((((r) & INTERVAL_RANGE_MASK) << 16) | ((p) & INTERVAL_PRECISION_MASK))
+#define INTERVAL_PRECISION(t) ((t) & INTERVAL_PRECISION_MASK)
+#define INTERVAL_RANGE(t) (((t) >> 16) & INTERVAL_RANGE_MASK)
+
/*
* timestamp.c prototypes