Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commite025bb7

Browse files
author
Thomas G. Lockhart
committed
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.
1 parent043f9eb commite025bb7

File tree

1 file changed

+17
-5
lines changed

1 file changed

+17
-5
lines changed

‎src/include/utils/timestamp.h

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
77
* Portions Copyright (c) 1994, Regents of the University of California
88
*
9-
* $Id: timestamp.h,v 1.27 2002/06/20 20:29:53 momjian Exp $
9+
* $Id: timestamp.h,v 1.28 2002/08/04 06:42:18 thomas Exp $
1010
*
1111
*-------------------------------------------------------------------------
1212
*/
@@ -52,6 +52,10 @@ typedef struct
5252
}Interval;
5353

5454

55+
#defineMAX_TIMESTAMP_PRECISION 6
56+
#defineMAX_INTERVAL_PRECISION 6
57+
58+
5559
/*
5660
* Macros for fmgr-callable functions.
5761
*
@@ -117,10 +121,6 @@ typedef struct
117121

118122
#defineTIMESTAMP_NOT_FINITE(j) (TIMESTAMP_IS_NOBEGIN(j) || TIMESTAMP_IS_NOEND(j))
119123

120-
121-
#defineMAX_TIMESTAMP_PRECISION 6
122-
#defineMAX_INTERVAL_PRECISION 6
123-
124124
#ifdefHAVE_INT64_TIMESTAMP
125125

126126
typedefint32fsec_t;
@@ -134,6 +134,18 @@ typedef double fsec_t;
134134

135135
#endif
136136

137+
#defineTIMESTAMP_MASK(b) (1 << (b))
138+
#defineINTERVAL_MASK(b) (1 << (b))
139+
140+
/* Macros to handle packing and unpacking the typmod field for intervals */
141+
#defineINTERVAL_FULL_RANGE (0x7FFF)
142+
#defineINTERVAL_RANGE_MASK (0x7FFF)
143+
#defineINTERVAL_FULL_PRECISION (0xFFFF)
144+
#defineINTERVAL_PRECISION_MASK (0xFFFF)
145+
#defineINTERVAL_TYPMOD(p,r) ((((r) & INTERVAL_RANGE_MASK) << 16) | ((p) & INTERVAL_PRECISION_MASK))
146+
#defineINTERVAL_PRECISION(t) ((t) & INTERVAL_PRECISION_MASK)
147+
#defineINTERVAL_RANGE(t) (((t) >> 16) & INTERVAL_RANGE_MASK)
148+
137149

138150
/*
139151
* timestamp.c prototypes

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp