Fix error in commit e6feef57.
authorJeff Davis <[email protected]>
Thu, 18 Jul 2019 23:53:25 +0000 (16:53 -0700)
committerJeff Davis <[email protected]>
Thu, 18 Jul 2019 23:53:25 +0000 (16:53 -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 6f9780a7bf798899ce48b399af93d74aa17f6992..e1f9ce403c07c62133b43f4d2b0985e06c67a030 100644 (file)
@@ -1366,13 +1366,15 @@ daterange_canonical(PG_FUNCTION_ARGS)
    if (empty)
        PG_RETURN_RANGE(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;