pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Alexander Korotkov <akorotkov@postgresql.org>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Implement jsonpath .datetime() method
Date: Wed, 25 Sep 2019 19:52:13 +0000
Message-ID: <E1iDDKf-0008VX-RT@gemulon.postgresql.org> (raw)

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

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/bffe1bd68457e43925c362d8728ce3b25bdf1c94

Modified Files
--------------
doc/src/sgml/func.sgml                       | 117 +++++-
src/backend/catalog/sql_features.txt         |   2 +-
src/backend/catalog/system_views.sql         |  40 +++
src/backend/utils/adt/jsonpath.c             |  24 +-
src/backend/utils/adt/jsonpath_exec.c        | 470 ++++++++++++++++++++++--
src/backend/utils/adt/jsonpath_gram.y        |  14 +
src/backend/utils/adt/jsonpath_scan.l        |   1 +
src/backend/utils/errcodes.txt               |   1 +
src/include/catalog/catversion.h             |   2 +-
src/include/catalog/pg_proc.dat              |  22 ++
src/include/utils/jsonpath.h                 |   1 +
src/test/regress/expected/jsonb_jsonpath.out | 520 +++++++++++++++++++++++++++
src/test/regress/expected/jsonpath.out       |  12 +
src/test/regress/sql/jsonb_jsonpath.sql      | 172 +++++++++
src/test/regress/sql/jsonpath.sql            |   2 +
15 files changed, 1355 insertions(+), 45 deletions(-)



view thread (16+ messages)  latest in thread

Message-ID: <E1iDDKf-0008VX-RT@gemulon.postgresql.org>
Permalink:  ../E1iDDKf-0008VX-RT@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1iDDKf-0008VX-RT@gemulon.postgresql.org

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-committers@postgresql.org
  Cc: akorotkov@postgresql.org, pgsql-committers@lists.postgresql.org
  Subject: Re: pgsql: Implement jsonpath .datetime() method
  In-Reply-To: <E1iDDKf-0008VX-RT@gemulon.postgresql.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox