Skip to content

Commit f2ebd01

Browse files
committed
timestamptz_izone should return the input, not NULL, when the input
is a non-finite timestamp, for consistency with related functions. In other words: +infinity rotated to a different timezone is still +infinity.
1 parent a239af0 commit f2ebd01

File tree

1 file changed

+4
-8
lines changed

1 file changed

+4
-8
lines changed

src/backend/utils/adt/timestamp.c

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $PostgreSQL: pgsql/src/backend/utils/adt/timestamp.c,v 1.152 2005/09/09 02:31:49 tgl Exp $
11+
* $PostgreSQL: pgsql/src/backend/utils/adt/timestamp.c,v 1.153 2005/09/09 06:46:14 tgl Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -1897,18 +1897,14 @@ timestamp_mi(PG_FUNCTION_ARGS)
18971897
result = (Interval *) palloc(sizeof(Interval));
18981898

18991899
if (TIMESTAMP_NOT_FINITE(dt1) || TIMESTAMP_NOT_FINITE(dt2))
1900-
{
19011900
ereport(ERROR,
19021901
(errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
19031902
errmsg("cannot subtract infinite timestamps")));
19041903

1905-
result->time = 0;
1906-
}
1907-
else
19081904
#ifdef HAVE_INT64_TIMESTAMP
1909-
result->time = dt1 - dt2;
1905+
result->time = dt1 - dt2;
19101906
#else
1911-
result->time = JROUND(dt1 - dt2);
1907+
result->time = JROUND(dt1 - dt2);
19121908
#endif
19131909

19141910
result->month = 0;
@@ -4196,7 +4192,7 @@ timestamptz_izone(PG_FUNCTION_ARGS)
41964192
int tz;
41974193

41984194
if (TIMESTAMP_NOT_FINITE(timestamp))
4199-
PG_RETURN_NULL();
4195+
PG_RETURN_TIMESTAMP(timestamp);
42004196

42014197
if (zone->month != 0)
42024198
ereport(ERROR,

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy