aboutsummaryrefslogtreecommitdiff
path: root/src/backend/utils/adt/jsonpath_exec.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/backend/utils/adt/jsonpath_exec.c')
-rw-r--r--src/backend/utils/adt/jsonpath_exec.c25
1 files changed, 25 insertions, 0 deletions
diff --git a/src/backend/utils/adt/jsonpath_exec.c b/src/backend/utils/adt/jsonpath_exec.c
index d79c9298227..c47221b7ee7 100644
--- a/src/backend/utils/adt/jsonpath_exec.c
+++ b/src/backend/utils/adt/jsonpath_exec.c
@@ -2707,12 +2707,27 @@ executeDateTimeMethod(JsonPathExecContext *cxt, JsonPathItem *jsp,
break;
case jpiTimestampTz:
{
+ struct pg_tm tm;
+ fsec_t fsec;
+
/* Convert result type to timestamp with time zone */
switch (typid)
{
case DATEOID:
checkTimezoneIsUsedForCast(cxt->useTz,
"date", "timestamptz");
+
+ /*
+ * Get the timezone value explicitly since JsonbValue
+ * keeps that separate.
+ */
+ j2date(DatumGetDateADT(value) + POSTGRES_EPOCH_JDATE,
+ &(tm.tm_year), &(tm.tm_mon), &(tm.tm_mday));
+ tm.tm_hour = 0;
+ tm.tm_min = 0;
+ tm.tm_sec = 0;
+ tz = DetermineTimeZoneOffset(&tm, session_timezone);
+
value = DirectFunctionCall1(date_timestamptz,
value);
break;
@@ -2726,6 +2741,16 @@ executeDateTimeMethod(JsonPathExecContext *cxt, JsonPathItem *jsp,
case TIMESTAMPOID:
checkTimezoneIsUsedForCast(cxt->useTz,
"timestamp", "timestamptz");
+
+ /*
+ * Get the timezone value explicitly since JsonbValue
+ * keeps that separate.
+ */
+ if (timestamp2tm(DatumGetTimestamp(value), NULL, &tm,
+ &fsec, NULL, NULL) == 0)
+ tz = DetermineTimeZoneOffset(&tm,
+ session_timezone);
+
value = DirectFunctionCall1(timestamp_timestamptz,
value);
break;