pgsql: Support +/- infinity in the interval data type.

Поиск
Список
Период
Сортировка
От Dean Rasheed
Тема pgsql: Support +/- infinity in the interval data type.
Дата
Msg-id E1r2rB1-005PHm-UL@gemulon.postgresql.org
обсуждение исходный текст
Список pgsql-committers
Support +/- infinity in the interval data type.

This adds support for infinity to the interval data type, using the
same input/output representation as the other date/time data types
that support infinity. This allows various arithmetic operations on
infinite dates, timestamps and intervals.

The new values are represented by setting all fields of the interval
to INT32/64_MIN for -infinity, and INT32/64_MAX for +infinity. This
ensures that they compare as less/greater than all other interval
values, without the need for any special-case comparison code.

Note that, since those 2 values were formerly accepted as legal finite
intervals, pg_upgrade and dump/restore from an old database will turn
them from finite to infinite intervals. That seems OK, since those
exact values should be extremely rare in practice, and they are
outside the documented range supported by the interval type, which
gives us a certain amount of leeway.

Bump catalog version.

Joseph Koshakow, Jian He, and Ashutosh Bapat, reviewed by me.

Discussion: https://postgr.es/m/CAAvxfHea4%2BsPybKK7agDYOMo9N-Z3J6ZXf3BOM79pFsFNcRjwA%40mail.gmail.com

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/519fc1bd9e9d7b408903e44f55f83f6db30742b7

Modified Files
--------------
contrib/btree_gin/btree_gin.c             |    5 +-
doc/src/sgml/datatype.sgml                |    4 +-
doc/src/sgml/func.sgml                    |    8 +-
src/backend/utils/adt/date.c              |   57 +-
src/backend/utils/adt/datetime.c          |   26 +
src/backend/utils/adt/formatting.c        |    2 +-
src/backend/utils/adt/selfuncs.c          |    4 +
src/backend/utils/adt/timestamp.c         | 1040 +++++++++++++++++++++++------
src/include/catalog/catversion.h          |    2 +-
src/include/catalog/pg_aggregate.dat      |   24 +-
src/include/catalog/pg_proc.dat           |   28 +-
src/include/datatype/timestamp.h          |   27 +-
src/test/regress/expected/brin_multi.out  |   28 +
src/test/regress/expected/horology.out    |   71 +-
src/test/regress/expected/interval.out    |  499 +++++++++++++-
src/test/regress/expected/timestamp.out   |   62 ++
src/test/regress/expected/timestamptz.out |   62 ++
src/test/regress/expected/window.out      |  469 ++++++++++++-
src/test/regress/sql/brin_multi.sql       |   19 +
src/test/regress/sql/horology.sql         |    3 +-
src/test/regress/sql/interval.sql         |  193 +++++-
src/test/regress/sql/timestamp.sql        |   19 +
src/test/regress/sql/timestamptz.sql      |   18 +
src/test/regress/sql/window.sql           |  167 ++++-
src/tools/pgindent/typedefs.list          |    1 +
25 files changed, 2541 insertions(+), 297 deletions(-)


В списке pgsql-committers по дате отправления:

Предыдущее
От: Peter Eisentraut
Дата:
Сообщение: pgsql: Fix capitalization of "Tcl"
Следующее
От: Robert Haas
Дата:
Сообщение: pgsql: Change how a base backup decides which files have checksums.