]> granicus.if.org Git - postgresql/commit
Implement jsonpath .datetime() method
authorAlexander Korotkov <akorotkov@postgresql.org>
Wed, 25 Sep 2019 18:54:14 +0000 (21:54 +0300)
committerAlexander Korotkov <akorotkov@postgresql.org>
Wed, 25 Sep 2019 19:51:51 +0000 (22:51 +0300)
commitbffe1bd68457e43925c362d8728ce3b25bdf1c94
treed4de7be9e4e227a170a8852ab64ff2b610ec5195
parent6dda292d4df82a9158d1acc93feecf3b84637b59
Implement jsonpath .datetime() method

This commit implements jsonpath .datetime() method as it's specified in
SQL/JSON standard.  There are no-argument and single-argument versions of
this method.  No-argument version selects first of ISO datetime formats
matching input string.  Single-argument version accepts template string as
its argument.

Additionally to .datetime() method itself this commit also implements
comparison ability of resulting date and time values.  There is some difficulty
because exising jsonb_path_*() functions are immutable, while comparison of
timezoned and non-timezoned types involves current timezone.  At first, current
timezone could be changes in session.  Moreover, timezones themselves are not
immutable and could be updated.  This is why we let existing immutable functions
throw errors on such non-immutable comparison.  In the same time this commit
provides jsonb_path_*_tz() functions which are stable and support operations
involving timezones.  As new functions are added to the system catalog,
catversion is bumped.

Support of .datetime() method was the only blocker prevents T832 from being
marked as supported.  sql_features.txt is updated correspondingly.

Extracted from original patch by Nikita Glukhov, Teodor Sigaev, Oleg Bartunov.
Heavily revised by me.  Comments were adjusted by Liudmila Mantrova.

Discussion: https://postgr.es/m/fcc6fc6a-b497-f39a-923d-aa34d0c588e8%402ndQuadrant.com
Discussion: https://postgr.es/m/CAPpHfdsZgYEra_PeCLGNoXOWYx6iU-S3wF8aX0ObQUcZU%2B4XTw%40mail.gmail.com
Author: Alexander Korotkov, Nikita Glukhov, Teodor Sigaev, Oleg Bartunov, Liudmila Mantrova
Reviewed-by: Anastasia Lubennikova, Peter Eisentraut
15 files changed:
doc/src/sgml/func.sgml
src/backend/catalog/sql_features.txt
src/backend/catalog/system_views.sql
src/backend/utils/adt/jsonpath.c
src/backend/utils/adt/jsonpath_exec.c
src/backend/utils/adt/jsonpath_gram.y
src/backend/utils/adt/jsonpath_scan.l
src/backend/utils/errcodes.txt
src/include/catalog/catversion.h
src/include/catalog/pg_proc.dat
src/include/utils/jsonpath.h
src/test/regress/expected/jsonb_jsonpath.out
src/test/regress/expected/jsonpath.out
src/test/regress/sql/jsonb_jsonpath.sql
src/test/regress/sql/jsonpath.sql