mirror of
https://github.com/postgres/postgres.git
synced 2025-07-03 20:02:46 +03:00
Correctly cast types to Datum and back in compareDatetime()
Discussion: https://postgr.es/m/CAPpHfdteFKW6MLpXM4md99m55YAuXs0n9_P2wiTq_EmG09doUA%40mail.gmail.com
This commit is contained in:
@ -2592,7 +2592,7 @@ compareDatetime(Datum val1, Oid typid1, Datum val2, Oid typid2,
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case TIMESTAMPOID:
|
case TIMESTAMPOID:
|
||||||
val1 = date2timestamp_opt_error(val1, have_error);
|
val1 = TimestampGetDatum(date2timestamp_opt_error(DatumGetDateADT(val1), have_error));
|
||||||
if (have_error && *have_error)
|
if (have_error && *have_error)
|
||||||
return 0;
|
return 0;
|
||||||
cmpfunc = timestamp_cmp;
|
cmpfunc = timestamp_cmp;
|
||||||
@ -2606,7 +2606,7 @@ compareDatetime(Datum val1, Oid typid1, Datum val2, Oid typid2,
|
|||||||
errmsg("cannot convert value from %s to %s without timezone usage",
|
errmsg("cannot convert value from %s to %s without timezone usage",
|
||||||
"date", "timestamptz"),
|
"date", "timestamptz"),
|
||||||
errhint("use *_tz() function for timezone support")));
|
errhint("use *_tz() function for timezone support")));
|
||||||
val1 = date2timestamptz_opt_error(val1, have_error);
|
val1 = TimestampTzGetDatum(date2timestamptz_opt_error(DatumGetDateADT(val1), have_error));
|
||||||
if (have_error && *have_error)
|
if (have_error && *have_error)
|
||||||
return 0;
|
return 0;
|
||||||
cmpfunc = timestamp_cmp;
|
cmpfunc = timestamp_cmp;
|
||||||
@ -2680,7 +2680,7 @@ compareDatetime(Datum val1, Oid typid1, Datum val2, Oid typid2,
|
|||||||
switch (typid2)
|
switch (typid2)
|
||||||
{
|
{
|
||||||
case DATEOID:
|
case DATEOID:
|
||||||
val2 = date2timestamp_opt_error(val2, have_error);
|
val2 = TimestampGetDatum(date2timestamp_opt_error(DatumGetDateADT(val2), have_error));
|
||||||
if (have_error && *have_error)
|
if (have_error && *have_error)
|
||||||
return 0;
|
return 0;
|
||||||
cmpfunc = timestamp_cmp;
|
cmpfunc = timestamp_cmp;
|
||||||
@ -2699,7 +2699,7 @@ compareDatetime(Datum val1, Oid typid1, Datum val2, Oid typid2,
|
|||||||
errmsg("cannot convert value from %s to %s without timezone usage",
|
errmsg("cannot convert value from %s to %s without timezone usage",
|
||||||
"timestamp", "timestamptz"),
|
"timestamp", "timestamptz"),
|
||||||
errhint("use *_tz() function for timezone support")));
|
errhint("use *_tz() function for timezone support")));
|
||||||
val1 = timestamp2timestamptz_opt_error(val1, have_error);
|
val1 = TimestampTzGetDatum(timestamp2timestamptz_opt_error(DatumGetTimestamp(val1), have_error));
|
||||||
if (have_error && *have_error)
|
if (have_error && *have_error)
|
||||||
return 0;
|
return 0;
|
||||||
cmpfunc = timestamp_cmp;
|
cmpfunc = timestamp_cmp;
|
||||||
@ -2723,7 +2723,7 @@ compareDatetime(Datum val1, Oid typid1, Datum val2, Oid typid2,
|
|||||||
errmsg("cannot convert value from %s to %s without timezone usage",
|
errmsg("cannot convert value from %s to %s without timezone usage",
|
||||||
"date", "timestamptz"),
|
"date", "timestamptz"),
|
||||||
errhint("use *_tz() function for timezone support")));
|
errhint("use *_tz() function for timezone support")));
|
||||||
val2 = date2timestamptz_opt_error(val2, have_error);
|
val2 = TimestampTzGetDatum(date2timestamptz_opt_error(DatumGetDateADT(val2), have_error));
|
||||||
if (have_error && *have_error)
|
if (have_error && *have_error)
|
||||||
return 0;
|
return 0;
|
||||||
cmpfunc = timestamp_cmp;
|
cmpfunc = timestamp_cmp;
|
||||||
@ -2737,7 +2737,7 @@ compareDatetime(Datum val1, Oid typid1, Datum val2, Oid typid2,
|
|||||||
errmsg("cannot convert value from %s to %s without timezone usage",
|
errmsg("cannot convert value from %s to %s without timezone usage",
|
||||||
"timestamp", "timestamptz"),
|
"timestamp", "timestamptz"),
|
||||||
errhint("use *_tz() function for timezone support")));
|
errhint("use *_tz() function for timezone support")));
|
||||||
val2 = timestamp2timestamptz_opt_error(val2, have_error);
|
val2 = TimestampTzGetDatum(timestamp2timestamptz_opt_error(DatumGetTimestamp(val2), have_error));
|
||||||
if (have_error && *have_error)
|
if (have_error && *have_error)
|
||||||
return 0;
|
return 0;
|
||||||
cmpfunc = timestamp_cmp;
|
cmpfunc = timestamp_cmp;
|
||||||
|
Reference in New Issue
Block a user