diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2013-03-04 15:13:31 -0500 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2013-03-04 15:14:00 -0500 |
commit | 3a779366025504d6993e6a3b1281cd114a0abb71 (patch) | |
tree | b6e14a1808fdbf5e847bd25b03d4d57088d74701 /src/backend/utils/adt/timestamp.c | |
parent | c0d35067a57581f7685dc2134a1c4511d925fe4d (diff) |
Fix overflow check in tm2timestamp (this time for sure).
I fixed this code back in commit 841b4a2d5, but didn't think carefully
enough about the behavior near zero, which meant it improperly rejected
1999-12-31 24:00:00. Per report from Magnus Hagander.
Diffstat (limited to 'src/backend/utils/adt/timestamp.c')
-rw-r--r-- | src/backend/utils/adt/timestamp.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/src/backend/utils/adt/timestamp.c b/src/backend/utils/adt/timestamp.c index 45e70029e53..d11962802a7 100644 --- a/src/backend/utils/adt/timestamp.c +++ b/src/backend/utils/adt/timestamp.c @@ -1564,8 +1564,9 @@ tm2timestamp(struct pg_tm * tm, fsec_t fsec, int *tzp, Timestamp *result) return -1; } /* check for just-barely overflow (okay except time-of-day wraps) */ - if ((*result < 0 && date >= 0) || - (*result >= 0 && date < 0)) + /* caution: we want to allow 1999-12-31 24:00:00 */ + if ((*result < 0 && date > 0) || + (*result > 0 && date < -1)) { *result = 0; /* keep compiler quiet */ return -1; |