1
0
mirror of https://github.com/postgres/postgres.git synced 2025-07-27 12:41:57 +03:00

Support for FF1-FF6 datetime format patterns

SQL Standard 2016 defines FF1-FF9 format patters for fractions of seconds in
jsonpath .datetime() method and CAST (... FORMAT ...) SQL clause.  Parsing
engine of upcoming .datetime() method will be shared with to_date()/
to_timestamp().

This patch implements FF1-FF6 format patterns for upcoming jsonpath .datetime()
method.  to_date()/to_timestamp() functions will also get support of this
format patterns as positive side effect.  FF7-FF9 are not supported due to
lack of precision in our internal timestamp representation.

Extracted from original patch by Nikita Glukhov, Teodor Sigaev, Oleg Bartunov.
Heavily revised by me.

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: Nikita Glukhov, Teodor Sigaev, Oleg Bartunov, Alexander Korotkov
Reviewed-by: Anastasia Lubennikova, Peter Eisentraut
This commit is contained in:
Alexander Korotkov
2019-09-16 21:02:14 +03:00
parent d812257809
commit d589f94460
10 changed files with 239 additions and 23 deletions

View File

@ -6150,6 +6150,30 @@ SELECT regexp_match('abc01234xyz', '(?:(.*?)(\d+)(.*)){1,1}');
<entry><literal>US</literal></entry>
<entry>microsecond (000000-999999)</entry>
</row>
<row>
<entry><literal>FF1</literal></entry>
<entry>tenth of second (0-9)</entry>
</row>
<row>
<entry><literal>FF2</literal></entry>
<entry>hundredth of second (00-99)</entry>
</row>
<row>
<entry><literal>FF3</literal></entry>
<entry>millisecond (000-999)</entry>
</row>
<row>
<entry><literal>FF4</literal></entry>
<entry>tenth of a millisecond (0000-9999)</entry>
</row>
<row>
<entry><literal>FF5</literal></entry>
<entry>hundredth of a millisecond (00000-99999)</entry>
</row>
<row>
<entry><literal>FF6</literal></entry>
<entry>microsecond (000000-999999)</entry>
</row>
<row>
<entry><literal>SSSS</literal></entry>
<entry>seconds past midnight (0-86399)</entry>