Add comment documenting actual failure case of using
authorBruce Momjian
Thu, 27 Oct 2005 02:45:22 +0000 (02:45 +0000)
committerBruce Momjian
Thu, 27 Oct 2005 02:45:22 +0000 (02:45 +0000)
interval_justify_hours in timestamp subtraction.  TODO already has text
description.

src/backend/utils/adt/timestamp.c

index b4a518a1da45320951ad0c1c2ca486d60edaaef1..43956597e31b9d362261e5ff008b2e5b00b0be86 100644 (file)
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *   $PostgreSQL: pgsql/src/backend/utils/adt/timestamp.c,v 1.156 2005/10/25 17:13:07 tgl Exp $
+ *   $PostgreSQL: pgsql/src/backend/utils/adt/timestamp.c,v 1.157 2005/10/27 02:45:22 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -1943,8 +1943,31 @@ timestamp_mi(PG_FUNCTION_ARGS)
    result->month = 0;
    result->day = 0;
 
-   /* this is wrong, but removing it breaks a lot of regression tests */
-   result = DatumGetIntervalP(DirectFunctionCall1(interval_justify_hours,
+   /*
+    *  This is wrong, but removing it breaks a lot of regression tests.
+    *  For example:
+    *
+    *  test=> SET timezone = 'EST5EDT';
+    *  test=> SELECT
+    *  test-> ('2005-10-30 13:22:00-05'::timestamptz -
+    *  test(>  '2005-10-29 13:22:00-04'::timestamptz);
+    *  ?column?
+    *  ----------------
+    *   1 day 01:00:00
+    *   (1 row)
+    *
+    *  so adding that to the first timestamp gets:
+    *
+    *   test=> SELECT
+    *   test-> ('2005-10-29 13:22:00-04'::timestamptz +
+    *   test(> ('2005-10-30 13:22:00-05'::timestamptz -
+    *   test(>  '2005-10-29 13:22:00-04'::timestamptz)) at time zone 'EST';
+    *      timezone
+    *  --------------------
+    *  2005-10-30 14:22:00
+    *  (1 row)
+    */
+   result = DatumGetIntervalP(DirectFunctionCall1(interval_justify_hours,
                                                 IntervalPGetDatum(result)));
 
    PG_RETURN_INTERVAL_P(result);