Skip to content

Commit 2ceea5a

Browse files
committed
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
1 parent d747dc8 commit 2ceea5a

File tree

7 files changed

+25
-0
lines changed

7 files changed

+25
-0
lines changed

src/backend/utils/adt/datetime.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@ const char *const days[] = {"Sunday", "Monday", "Tuesday", "Wednesday",
105105
*/
106106
static const datetkn datetktbl[] = {
107107
/* token, type, value */
108+
{"+infinity", RESERV, DTK_LATE}, /* same as "infinity" */
108109
{EARLY, RESERV, DTK_EARLY}, /* "-infinity" reserved for "early time" */
109110
{DA_D, ADBC, AD}, /* "ad" for years > 0 */
110111
{"allballs", RESERV, DTK_ZULU}, /* 00:00:00 */

src/test/regress/expected/date.out

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1373,6 +1373,12 @@ select isfinite('infinity'::date), isfinite('-infinity'::date), isfinite('today'
13731373
f | f | t
13741374
(1 row)
13751375

1376+
select 'infinity'::date = '+infinity'::date as t;
1377+
t
1378+
---
1379+
t
1380+
(1 row)
1381+
13761382
--
13771383
-- oscillating fields from non-finite date:
13781384
--

src/test/regress/expected/timestamp.out

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,12 @@ TRUNCATE TIMESTAMP_TBL;
7676
INSERT INTO TIMESTAMP_TBL VALUES ('-infinity');
7777
INSERT INTO TIMESTAMP_TBL VALUES ('infinity');
7878
INSERT INTO TIMESTAMP_TBL VALUES ('epoch');
79+
SELECT timestamp 'infinity' = timestamp '+infinity' AS t;
80+
t
81+
---
82+
t
83+
(1 row)
84+
7985
-- Postgres v6.0 standard output format
8086
INSERT INTO TIMESTAMP_TBL VALUES ('Mon Feb 10 17:32:01 1997 PST');
8187
-- Variations on Postgres v6.1 standard output format

src/test/regress/expected/timestamptz.out

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,12 @@ TRUNCATE TIMESTAMPTZ_TBL;
8787
INSERT INTO TIMESTAMPTZ_TBL VALUES ('-infinity');
8888
INSERT INTO TIMESTAMPTZ_TBL VALUES ('infinity');
8989
INSERT INTO TIMESTAMPTZ_TBL VALUES ('epoch');
90+
SELECT timestamptz 'infinity' = timestamptz '+infinity' AS t;
91+
t
92+
---
93+
t
94+
(1 row)
95+
9096
-- Postgres v6.0 standard output format
9197
INSERT INTO TIMESTAMPTZ_TBL VALUES ('Mon Feb 10 17:32:01 1997 PST');
9298
-- Variations on Postgres v6.1 standard output format

src/test/regress/sql/date.sql

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -329,6 +329,8 @@ select 'infinity'::date, '-infinity'::date;
329329
select 'infinity'::date > 'today'::date as t;
330330
select '-infinity'::date < 'today'::date as t;
331331
select isfinite('infinity'::date), isfinite('-infinity'::date), isfinite('today'::date);
332+
select 'infinity'::date = '+infinity'::date as t;
333+
332334
--
333335
-- oscillating fields from non-finite date:
334336
--

src/test/regress/sql/timestamp.sql

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,8 @@ INSERT INTO TIMESTAMP_TBL VALUES ('-infinity');
4949
INSERT INTO TIMESTAMP_TBL VALUES ('infinity');
5050
INSERT INTO TIMESTAMP_TBL VALUES ('epoch');
5151

52+
SELECT timestamp 'infinity' = timestamp '+infinity' AS t;
53+
5254
-- Postgres v6.0 standard output format
5355
INSERT INTO TIMESTAMP_TBL VALUES ('Mon Feb 10 17:32:01 1997 PST');
5456

src/test/regress/sql/timestamptz.sql

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,8 @@ INSERT INTO TIMESTAMPTZ_TBL VALUES ('-infinity');
5050
INSERT INTO TIMESTAMPTZ_TBL VALUES ('infinity');
5151
INSERT INTO TIMESTAMPTZ_TBL VALUES ('epoch');
5252

53+
SELECT timestamptz 'infinity' = timestamptz '+infinity' AS t;
54+
5355
-- Postgres v6.0 standard output format
5456
INSERT INTO TIMESTAMPTZ_TBL VALUES ('Mon Feb 10 17:32:01 1997 PST');
5557

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy