diff options
Diffstat (limited to 'src/backend/utils/adt/jsonpath_exec.c')
-rw-r--r-- | src/backend/utils/adt/jsonpath_exec.c | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/src/backend/utils/adt/jsonpath_exec.c b/src/backend/utils/adt/jsonpath_exec.c index 573b6ce2ba7..8372863de74 100644 --- a/src/backend/utils/adt/jsonpath_exec.c +++ b/src/backend/utils/adt/jsonpath_exec.c @@ -268,6 +268,8 @@ static JsonbValue *getScalar(JsonbValue *scalar, enum jbvType type); static JsonbValue *wrapItemsInArray(const JsonValueList *items); static int compareDatetime(Datum val1, Oid typid1, Datum val2, Oid typid2, bool useTz, bool *cast_error); +static void checkTimezoneIsUsedForCast(bool useTz, const char *type1, + const char *type2); /****************** User interface to JsonPath executor ********************/ @@ -2409,6 +2411,8 @@ executeDateTimeMethod(JsonPathExecContext *cxt, JsonPathItem *jsp, value); break; case TIMESTAMPTZOID: + checkTimezoneIsUsedForCast(cxt->useTz, + "timestamptz", "date"); value = DirectFunctionCall1(timestamptz_date, value); break; @@ -2433,6 +2437,8 @@ executeDateTimeMethod(JsonPathExecContext *cxt, JsonPathItem *jsp, case TIMEOID: /* Nothing to do for TIME */ break; case TIMETZOID: + checkTimezoneIsUsedForCast(cxt->useTz, + "timetz", "time"); value = DirectFunctionCall1(timetz_time, value); break; @@ -2441,6 +2447,8 @@ executeDateTimeMethod(JsonPathExecContext *cxt, JsonPathItem *jsp, value); break; case TIMESTAMPTZOID: + checkTimezoneIsUsedForCast(cxt->useTz, + "timestamptz", "time"); value = DirectFunctionCall1(timestamptz_time, value); break; @@ -2480,6 +2488,8 @@ executeDateTimeMethod(JsonPathExecContext *cxt, JsonPathItem *jsp, text_to_cstring(datetime))))); break; case TIMEOID: + checkTimezoneIsUsedForCast(cxt->useTz, + "time", "timetz"); value = DirectFunctionCall1(time_timetz, value); break; @@ -2531,6 +2541,8 @@ executeDateTimeMethod(JsonPathExecContext *cxt, JsonPathItem *jsp, case TIMESTAMPOID: /* Nothing to do for TIMESTAMP */ break; case TIMESTAMPTZOID: + checkTimezoneIsUsedForCast(cxt->useTz, + "timestamptz", "timestamp"); value = DirectFunctionCall1(timestamptz_timestamp, value); break; @@ -2570,6 +2582,8 @@ executeDateTimeMethod(JsonPathExecContext *cxt, JsonPathItem *jsp, switch (typid) { case DATEOID: + checkTimezoneIsUsedForCast(cxt->useTz, + "date", "timestamptz"); value = DirectFunctionCall1(date_timestamptz, value); break; @@ -2581,6 +2595,8 @@ executeDateTimeMethod(JsonPathExecContext *cxt, JsonPathItem *jsp, text_to_cstring(datetime))))); break; case TIMESTAMPOID: + checkTimezoneIsUsedForCast(cxt->useTz, + "timestamp", "timestamptz"); value = DirectFunctionCall1(timestamp_timestamptz, value); break; |