aboutsummaryrefslogtreecommitdiff
path: root/src/backend/utils/adt/jsonpath_exec.c
diff options
context:
space:
mode:
authorAlexander Korotkov <akorotkov@postgresql.org>2020-09-29 11:41:46 +0300
committerAlexander Korotkov <akorotkov@postgresql.org>2020-09-29 12:00:12 +0300
commit651bdbc811652638e1205440c3181a18feb8f967 (patch)
tree002799900567fe55f7a0ce50347bdbf90be4a712 /src/backend/utils/adt/jsonpath_exec.c
parentabcc0ab163003d2ab7c82a1e810ba257ebbec15f (diff)
downloadpostgresql-651bdbc811652638e1205440c3181a18feb8f967.tar.gz
postgresql-651bdbc811652638e1205440c3181a18feb8f967.zip
Support for ISO 8601 in the jsonpath .datetime() method
The SQL standard doesn't require jsonpath .datetime() method to support the ISO 8601 format. But our to_json[b]() functions convert timestamps to text in the ISO 8601 format in the sake of compatibility with javascript. So, we add support of the ISO 8601 to the jsonpath .datetime() in the sake compatibility with to_json[b](). The standard mode of datetime parsing currently supports just template patterns and separators in the format string. In order to implement ISO 8601, we have to add support of the format string double quotes to the standard parsing mode. Discussion: https://postgr.es/m/94321be0-cc96-1a81-b6df-796f437f7c66%40postgrespro.ru Author: Nikita Glukhov, revised by me Backpatch-through: 13
Diffstat (limited to 'src/backend/utils/adt/jsonpath_exec.c')
-rw-r--r--src/backend/utils/adt/jsonpath_exec.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/src/backend/utils/adt/jsonpath_exec.c b/src/backend/utils/adt/jsonpath_exec.c
index 728a99a68aa..4b6e239b672 100644
--- a/src/backend/utils/adt/jsonpath_exec.c
+++ b/src/backend/utils/adt/jsonpath_exec.c
@@ -1837,6 +1837,9 @@ executeDateTimeMethod(JsonPathExecContext *cxt, JsonPathItem *jsp,
/*
* According to SQL/JSON standard enumerate ISO formats for: date,
* timetz, time, timestamptz, timestamp.
+ *
+ * We also support ISO 8601 for timestamps, because to_json[b]()
+ * functions use this format.
*/
static const char *fmt_str[] =
{
@@ -1846,7 +1849,10 @@ executeDateTimeMethod(JsonPathExecContext *cxt, JsonPathItem *jsp,
"HH24:MI:SS",
"yyyy-mm-dd HH24:MI:SSTZH:TZM",
"yyyy-mm-dd HH24:MI:SSTZH",
- "yyyy-mm-dd HH24:MI:SS"
+ "yyyy-mm-dd HH24:MI:SS",
+ "yyyy-mm-dd\"T\"HH24:MI:SSTZH:TZM",
+ "yyyy-mm-dd\"T\"HH24:MI:SSTZH",
+ "yyyy-mm-dd\"T\"HH24:MI:SS"
};
/* cache for format texts */