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.
This commit is contained in:
Thomas G. Lockhart 2002-08-04 06:42:18 +00:00
parent 043f9eb90a
commit e025bb7a72
1 changed files with 17 additions and 5 deletions

View File

@ -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