aboutsummaryrefslogtreecommitdiff
path: root/src/include/utils/jsonpath.h
diff options
context:
space:
mode:
authorAndrew Dunstan <andrew@dunslane.net>2024-01-25 10:15:43 -0500
committerAndrew Dunstan <andrew@dunslane.net>2024-01-25 10:15:43 -0500
commit66ea94e8e606529bb334515f388c62314956739e (patch)
tree82bbcc7b7837412ca86df6b3a04e7046f51871e5 /src/include/utils/jsonpath.h
parent924d046dcf55887c98a1628675a30f4b0eebe556 (diff)
downloadpostgresql-66ea94e8e606529bb334515f388c62314956739e.tar.gz
postgresql-66ea94e8e606529bb334515f388c62314956739e.zip
Implement various jsonpath methods
This commit implements ithe jsonpath .bigint(), .boolean(), .date(), .decimal([precision [, scale]]), .integer(), .number(), .string(), .time(), .time_tz(), .timestamp(), and .timestamp_tz() methods. .bigint() converts the given JSON string or a numeric value to the bigint type representation. .boolean() converts the given JSON string, numeric, or boolean value to the boolean type representation. In the numeric case, only integers are allowed. We use the parse_bool() backend function to convert a string to a bool. .decimal([precision [, scale]]) converts the given JSON string or a numeric value to the numeric type representation. If precision and scale are provided for .decimal(), then it is converted to the equivalent numeric typmod and applied to the numeric number. .integer() and .number() convert the given JSON string or a numeric value to the int4 and numeric type representation. .string() uses the datatype's output function to convert numeric and various date/time types to the string representation. The JSON string representing a valid date/time is converted to the specific date or time type representation using jsonpath .date(), .time(), .time_tz(), .timestamp(), .timestamp_tz() methods. The changes use the infrastructure of the .datetime() method and perform the datatype conversion as appropriate. Unlike the .datetime() method, none of these methods accept a format template and use ISO DateTime format instead. However, except for .date(), the date/time related methods take an optional precision to adjust the fractional seconds. Jeevan Chalke, reviewed by Peter Eisentraut and Andrew Dunstan.
Diffstat (limited to 'src/include/utils/jsonpath.h')
-rw-r--r--src/include/utils/jsonpath.h11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/include/utils/jsonpath.h b/src/include/utils/jsonpath.h
index 9d55c25ebc5..0f0e126e03e 100644
--- a/src/include/utils/jsonpath.h
+++ b/src/include/utils/jsonpath.h
@@ -102,6 +102,17 @@ typedef enum JsonPathItemType
jpiLast, /* LAST array subscript */
jpiStartsWith, /* STARTS WITH predicate */
jpiLikeRegex, /* LIKE_REGEX predicate */
+ jpiBigint, /* .bigint() item method */
+ jpiBoolean, /* .boolean() item method */
+ jpiDate, /* .date() item method */
+ jpiDecimal, /* .decimal() item method */
+ jpiInteger, /* .integer() item method */
+ jpiNumber, /* .number() item method */
+ jpiStringFunc, /* .string() item method */
+ jpiTime, /* .time() item method */
+ jpiTimeTz, /* .time_tz() item method */
+ jpiTimestamp, /* .timestamp() item method */
+ jpiTimestampTz, /* .timestamp_tz() item method */
} JsonPathItemType;
/* XQuery regex mode flags for LIKE_REGEX predicate */