|
10 | 10 | *
|
11 | 11 | *
|
12 | 12 | * IDENTIFICATION
|
13 |
| - * $PostgreSQL: pgsql/src/backend/utils/adt/nabstime.c,v 1.140 2005/07/2203:46:33 momjian Exp $ |
| 13 | + * $PostgreSQL: pgsql/src/backend/utils/adt/nabstime.c,v 1.141 2005/07/2219:55:50 tgl Exp $ |
14 | 14 | *
|
15 | 15 | *-------------------------------------------------------------------------
|
16 | 16 | */
|
|
29 | 29 | #include"utils/builtins.h"
|
30 | 30 | #include"utils/nabstime.h"
|
31 | 31 |
|
32 |
| -#defineMIN_DAYNUM -24856/* December 13, 1901 */ |
| 32 | +#defineMIN_DAYNUM(-24856)/* December 13, 1901 */ |
33 | 33 | #defineMAX_DAYNUM 24854/* January 18, 2038 */
|
34 | 34 |
|
35 | 35 | #defineINVALID_RELTIME_STR"Undefined RelTime"
|
@@ -201,9 +201,12 @@ tm2abstime(struct pg_tm *tm, int tz)
|
201 | 201 | /* convert to seconds */
|
202 | 202 | sec=tm->tm_sec+tz+ (tm->tm_min+ (day*HOURS_PER_DAY+tm->tm_hour)*MINS_PER_HOUR)*SECS_PER_MINUTE;
|
203 | 203 |
|
204 |
| -/* check for overflow */ |
205 |
| -if ((day==MAX_DAYNUM&&sec<0)|| |
206 |
| -(day==MIN_DAYNUM&&sec>0)) |
| 204 | +/* |
| 205 | + * check for overflow. We need a little slop here because the H/M/S plus |
| 206 | + * TZ offset could add up to more than 1 day. |
| 207 | + */ |
| 208 | +if ((day >=MAX_DAYNUM-10&&sec<0)|| |
| 209 | +(day <=MIN_DAYNUM+10&&sec>0)) |
207 | 210 | returnINVALID_ABSTIME;
|
208 | 211 |
|
209 | 212 | /* check for reserved values (e.g. "current" on edge of usual range */
|
|