mirror of
https://git.postgresql.org/git/postgresql.git
synced 2025-01-06 15:24:56 +08:00
Accept "+infinity" in date and timestamp[tz] input.
The float and numeric types accept this variant spelling of "infinity", so it seems like the datetime types should too. Vik Fearing, some cosmetic mods by me Discussion: https://postgr.es/m/d0bef637-2dbd-0a5d-e539-48243b6f6c5e@postgresfriends.org
This commit is contained in:
parent
d747dc85ae
commit
2ceea5adb0
@ -105,6 +105,7 @@ const char *const days[] = {"Sunday", "Monday", "Tuesday", "Wednesday",
|
|||||||
*/
|
*/
|
||||||
static const datetkn datetktbl[] = {
|
static const datetkn datetktbl[] = {
|
||||||
/* token, type, value */
|
/* token, type, value */
|
||||||
|
{"+infinity", RESERV, DTK_LATE}, /* same as "infinity" */
|
||||||
{EARLY, RESERV, DTK_EARLY}, /* "-infinity" reserved for "early time" */
|
{EARLY, RESERV, DTK_EARLY}, /* "-infinity" reserved for "early time" */
|
||||||
{DA_D, ADBC, AD}, /* "ad" for years > 0 */
|
{DA_D, ADBC, AD}, /* "ad" for years > 0 */
|
||||||
{"allballs", RESERV, DTK_ZULU}, /* 00:00:00 */
|
{"allballs", RESERV, DTK_ZULU}, /* 00:00:00 */
|
||||||
|
@ -1373,6 +1373,12 @@ select isfinite('infinity'::date), isfinite('-infinity'::date), isfinite('today'
|
|||||||
f | f | t
|
f | f | t
|
||||||
(1 row)
|
(1 row)
|
||||||
|
|
||||||
|
select 'infinity'::date = '+infinity'::date as t;
|
||||||
|
t
|
||||||
|
---
|
||||||
|
t
|
||||||
|
(1 row)
|
||||||
|
|
||||||
--
|
--
|
||||||
-- oscillating fields from non-finite date:
|
-- oscillating fields from non-finite date:
|
||||||
--
|
--
|
||||||
|
@ -76,6 +76,12 @@ TRUNCATE TIMESTAMP_TBL;
|
|||||||
INSERT INTO TIMESTAMP_TBL VALUES ('-infinity');
|
INSERT INTO TIMESTAMP_TBL VALUES ('-infinity');
|
||||||
INSERT INTO TIMESTAMP_TBL VALUES ('infinity');
|
INSERT INTO TIMESTAMP_TBL VALUES ('infinity');
|
||||||
INSERT INTO TIMESTAMP_TBL VALUES ('epoch');
|
INSERT INTO TIMESTAMP_TBL VALUES ('epoch');
|
||||||
|
SELECT timestamp 'infinity' = timestamp '+infinity' AS t;
|
||||||
|
t
|
||||||
|
---
|
||||||
|
t
|
||||||
|
(1 row)
|
||||||
|
|
||||||
-- Postgres v6.0 standard output format
|
-- Postgres v6.0 standard output format
|
||||||
INSERT INTO TIMESTAMP_TBL VALUES ('Mon Feb 10 17:32:01 1997 PST');
|
INSERT INTO TIMESTAMP_TBL VALUES ('Mon Feb 10 17:32:01 1997 PST');
|
||||||
-- Variations on Postgres v6.1 standard output format
|
-- Variations on Postgres v6.1 standard output format
|
||||||
|
@ -87,6 +87,12 @@ TRUNCATE TIMESTAMPTZ_TBL;
|
|||||||
INSERT INTO TIMESTAMPTZ_TBL VALUES ('-infinity');
|
INSERT INTO TIMESTAMPTZ_TBL VALUES ('-infinity');
|
||||||
INSERT INTO TIMESTAMPTZ_TBL VALUES ('infinity');
|
INSERT INTO TIMESTAMPTZ_TBL VALUES ('infinity');
|
||||||
INSERT INTO TIMESTAMPTZ_TBL VALUES ('epoch');
|
INSERT INTO TIMESTAMPTZ_TBL VALUES ('epoch');
|
||||||
|
SELECT timestamptz 'infinity' = timestamptz '+infinity' AS t;
|
||||||
|
t
|
||||||
|
---
|
||||||
|
t
|
||||||
|
(1 row)
|
||||||
|
|
||||||
-- Postgres v6.0 standard output format
|
-- Postgres v6.0 standard output format
|
||||||
INSERT INTO TIMESTAMPTZ_TBL VALUES ('Mon Feb 10 17:32:01 1997 PST');
|
INSERT INTO TIMESTAMPTZ_TBL VALUES ('Mon Feb 10 17:32:01 1997 PST');
|
||||||
-- Variations on Postgres v6.1 standard output format
|
-- Variations on Postgres v6.1 standard output format
|
||||||
|
@ -329,6 +329,8 @@ select 'infinity'::date, '-infinity'::date;
|
|||||||
select 'infinity'::date > 'today'::date as t;
|
select 'infinity'::date > 'today'::date as t;
|
||||||
select '-infinity'::date < 'today'::date as t;
|
select '-infinity'::date < 'today'::date as t;
|
||||||
select isfinite('infinity'::date), isfinite('-infinity'::date), isfinite('today'::date);
|
select isfinite('infinity'::date), isfinite('-infinity'::date), isfinite('today'::date);
|
||||||
|
select 'infinity'::date = '+infinity'::date as t;
|
||||||
|
|
||||||
--
|
--
|
||||||
-- oscillating fields from non-finite date:
|
-- oscillating fields from non-finite date:
|
||||||
--
|
--
|
||||||
|
@ -49,6 +49,8 @@ INSERT INTO TIMESTAMP_TBL VALUES ('-infinity');
|
|||||||
INSERT INTO TIMESTAMP_TBL VALUES ('infinity');
|
INSERT INTO TIMESTAMP_TBL VALUES ('infinity');
|
||||||
INSERT INTO TIMESTAMP_TBL VALUES ('epoch');
|
INSERT INTO TIMESTAMP_TBL VALUES ('epoch');
|
||||||
|
|
||||||
|
SELECT timestamp 'infinity' = timestamp '+infinity' AS t;
|
||||||
|
|
||||||
-- Postgres v6.0 standard output format
|
-- Postgres v6.0 standard output format
|
||||||
INSERT INTO TIMESTAMP_TBL VALUES ('Mon Feb 10 17:32:01 1997 PST');
|
INSERT INTO TIMESTAMP_TBL VALUES ('Mon Feb 10 17:32:01 1997 PST');
|
||||||
|
|
||||||
|
@ -50,6 +50,8 @@ INSERT INTO TIMESTAMPTZ_TBL VALUES ('-infinity');
|
|||||||
INSERT INTO TIMESTAMPTZ_TBL VALUES ('infinity');
|
INSERT INTO TIMESTAMPTZ_TBL VALUES ('infinity');
|
||||||
INSERT INTO TIMESTAMPTZ_TBL VALUES ('epoch');
|
INSERT INTO TIMESTAMPTZ_TBL VALUES ('epoch');
|
||||||
|
|
||||||
|
SELECT timestamptz 'infinity' = timestamptz '+infinity' AS t;
|
||||||
|
|
||||||
-- Postgres v6.0 standard output format
|
-- Postgres v6.0 standard output format
|
||||||
INSERT INTO TIMESTAMPTZ_TBL VALUES ('Mon Feb 10 17:32:01 1997 PST');
|
INSERT INTO TIMESTAMPTZ_TBL VALUES ('Mon Feb 10 17:32:01 1997 PST');
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user