Skip to content

Commit 69f16b5

Browse files
committed
Add comment documenting actual failure case of using
interval_justify_hours in timestamp subtraction. TODO already has text description.
1 parent 807da29 commit 69f16b5

File tree

1 file changed

+26
-3
lines changed

1 file changed

+26
-3
lines changed

src/backend/utils/adt/timestamp.c

Lines changed: 26 additions & 3 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.156 2005/10/25 17:13:07 tgl Exp $
11+
* $PostgreSQL: pgsql/src/backend/utils/adt/timestamp.c,v 1.157 2005/10/27 02:45:22 momjian Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -1943,8 +1943,31 @@ timestamp_mi(PG_FUNCTION_ARGS)
19431943
result->month = 0;
19441944
result->day = 0;
19451945

1946-
/* this is wrong, but removing it breaks a lot of regression tests */
1947-
result = DatumGetIntervalP(DirectFunctionCall1(interval_justify_hours,
1946+
/*
1947+
* This is wrong, but removing it breaks a lot of regression tests.
1948+
* For example:
1949+
*
1950+
* test=> SET timezone = 'EST5EDT';
1951+
* test=> SELECT
1952+
* test-> ('2005-10-30 13:22:00-05'::timestamptz -
1953+
* test(> '2005-10-29 13:22:00-04'::timestamptz);
1954+
* ?column?
1955+
* ----------------
1956+
* 1 day 01:00:00
1957+
* (1 row)
1958+
*
1959+
* so adding that to the first timestamp gets:
1960+
*
1961+
* test=> SELECT
1962+
* test-> ('2005-10-29 13:22:00-04'::timestamptz +
1963+
* test(> ('2005-10-30 13:22:00-05'::timestamptz -
1964+
* test(> '2005-10-29 13:22:00-04'::timestamptz)) at time zone 'EST';
1965+
* timezone
1966+
* --------------------
1967+
* 2005-10-30 14:22:00
1968+
* (1 row)
1969+
*/
1970+
result = DatumGetIntervalP(DirectFunctionCall1(interval_justify_hours,
19481971
IntervalPGetDatum(result)));
19491972

19501973
PG_RETURN_INTERVAL_P(result);

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