]> granicus.if.org Git - postgresql/commitdiff
Fix error in commit e6feef57.
authorJeff Davis <jdavis@postgresql.org>
Thu, 18 Jul 2019 23:38:39 +0000 (16:38 -0700)
committerJeff Davis <jdavis@postgresql.org>
Fri, 19 Jul 2019 00:04:50 +0000 (17:04 -0700)
I was careless passing a datum directly to DATE_NOT_FINITE without
calling DatumGetDateADT() first.

Backpatch-through: 9.4

src/backend/utils/adt/rangetypes.c

index 5fb347eacd81f4f6e9e3862afe4a2ba8630922e4..e5c7e5c7eea178c905cd7a9ca77c619ec88ae7bf 100644 (file)
@@ -1431,13 +1431,15 @@ daterange_canonical(PG_FUNCTION_ARGS)
        if (empty)
                PG_RETURN_RANGE_P(r);
 
-       if (!lower.infinite && !DATE_NOT_FINITE(lower.val) && !lower.inclusive)
+       if (!lower.infinite && !DATE_NOT_FINITE(DatumGetDateADT(lower.val)) &&
+               !lower.inclusive)
        {
                lower.val = DirectFunctionCall2(date_pli, lower.val, Int32GetDatum(1));
                lower.inclusive = true;
        }
 
-       if (!upper.infinite && !DATE_NOT_FINITE(upper.val) && upper.inclusive)
+       if (!upper.infinite && !DATE_NOT_FINITE(DatumGetDateADT(upper.val)) &&
+               upper.inclusive)
        {
                upper.val = DirectFunctionCall2(date_pli, upper.val, Int32GetDatum(1));
                upper.inclusive = false;