Skip to content

Commit 7881bb1

Browse files
committed
Correctly cast types to Datum and back in compareDatetime()
Discussion: https://postgr.es/m/CAPpHfdteFKW6MLpXM4md99m55YAuXs0n9_P2wiTq_EmG09doUA%40mail.gmail.com
1 parent b81a9c2 commit 7881bb1

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

src/backend/utils/adt/jsonpath_exec.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2592,7 +2592,7 @@ compareDatetime(Datum val1, Oid typid1, Datum val2, Oid typid2,
25922592
break;
25932593

25942594
case TIMESTAMPOID:
2595-
val1 = date2timestamp_opt_error(val1, have_error);
2595+
val1 = TimestampGetDatum(date2timestamp_opt_error(DatumGetDateADT(val1), have_error));
25962596
if (have_error && *have_error)
25972597
return 0;
25982598
cmpfunc = timestamp_cmp;
@@ -2606,7 +2606,7 @@ compareDatetime(Datum val1, Oid typid1, Datum val2, Oid typid2,
26062606
errmsg("cannot convert value from %s to %s without timezone usage",
26072607
"date", "timestamptz"),
26082608
errhint("use *_tz() function for timezone support")));
2609-
val1 = date2timestamptz_opt_error(val1, have_error);
2609+
val1 = TimestampTzGetDatum(date2timestamptz_opt_error(DatumGetDateADT(val1), have_error));
26102610
if (have_error && *have_error)
26112611
return 0;
26122612
cmpfunc = timestamp_cmp;
@@ -2680,7 +2680,7 @@ compareDatetime(Datum val1, Oid typid1, Datum val2, Oid typid2,
26802680
switch (typid2)
26812681
{
26822682
case DATEOID:
2683-
val2 = date2timestamp_opt_error(val2, have_error);
2683+
val2 = TimestampGetDatum(date2timestamp_opt_error(DatumGetDateADT(val2), have_error));
26842684
if (have_error && *have_error)
26852685
return 0;
26862686
cmpfunc = timestamp_cmp;
@@ -2699,7 +2699,7 @@ compareDatetime(Datum val1, Oid typid1, Datum val2, Oid typid2,
26992699
errmsg("cannot convert value from %s to %s without timezone usage",
27002700
"timestamp", "timestamptz"),
27012701
errhint("use *_tz() function for timezone support")));
2702-
val1 = timestamp2timestamptz_opt_error(val1, have_error);
2702+
val1 = TimestampTzGetDatum(timestamp2timestamptz_opt_error(DatumGetTimestamp(val1), have_error));
27032703
if (have_error && *have_error)
27042704
return 0;
27052705
cmpfunc = timestamp_cmp;
@@ -2723,7 +2723,7 @@ compareDatetime(Datum val1, Oid typid1, Datum val2, Oid typid2,
27232723
errmsg("cannot convert value from %s to %s without timezone usage",
27242724
"date", "timestamptz"),
27252725
errhint("use *_tz() function for timezone support")));
2726-
val2 = date2timestamptz_opt_error(val2, have_error);
2726+
val2 = TimestampTzGetDatum(date2timestamptz_opt_error(DatumGetDateADT(val2), have_error));
27272727
if (have_error && *have_error)
27282728
return 0;
27292729
cmpfunc = timestamp_cmp;
@@ -2737,7 +2737,7 @@ compareDatetime(Datum val1, Oid typid1, Datum val2, Oid typid2,
27372737
errmsg("cannot convert value from %s to %s without timezone usage",
27382738
"timestamp", "timestamptz"),
27392739
errhint("use *_tz() function for timezone support")));
2740-
val2 = timestamp2timestamptz_opt_error(val2, have_error);
2740+
val2 = TimestampTzGetDatum(timestamp2timestamptz_opt_error(DatumGetTimestamp(val2), have_error));
27412741
if (have_error && *have_error)
27422742
return 0;
27432743
cmpfunc = timestamp_cmp;

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