Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit29904f5

Browse files
committed
Revert "Disallow infinite endpoints in generate_series() for timestamps."
This reverts commiteafdf9dand its back-branch counterparts. Corey Huinker pointed out thatwe'd discussed this exact change back in 2016 and rejected it,on the grounds that there's at least one usage pattern with LIMITwhere an infinite endpoint can usefully be used. Perhaps thatargument needs to be re-litigated, but there's no time left beforeour back-branch releases. To keep our options open, restore thestatus quo ante; if we do end up deciding to change things, waitingone more quarter won't hurt anything.Rather than just doing a straight revert, I added a new test casedemonstrating the usage with LIMIT. That'll at least remind us ofthe issue if we forget again.Discussion:https://postgr.es/m/3603504.1652068977@sss.pgh.pa.usDiscussion:https://postgr.es/m/CADkLM=dzw0Pvdqp5yWKxMd+VmNkAMhG=4ku7GnCZxebWnzmz3Q@mail.gmail.com
1 parent0abc1a0 commit29904f5

File tree

5 files changed

+48
-56
lines changed

5 files changed

+48
-56
lines changed

‎src/backend/utils/adt/timestamp.c

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -5778,20 +5778,6 @@ generate_series_timestamp(PG_FUNCTION_ARGS)
57785778
MemoryContextoldcontext;
57795779
Intervalinterval_zero;
57805780

5781-
/* Reject infinities in start and stop values */
5782-
if (TIMESTAMP_IS_NOBEGIN(start)||
5783-
TIMESTAMP_IS_NOEND(start))
5784-
ereport(ERROR,
5785-
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
5786-
errmsg("start value cannot be infinity")));
5787-
if (TIMESTAMP_IS_NOBEGIN(finish)||
5788-
TIMESTAMP_IS_NOEND(finish))
5789-
ereport(ERROR,
5790-
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
5791-
errmsg("stop value cannot be infinity")));
5792-
5793-
/* Interval doesn't (currently) have infinity, so nothing to check */
5794-
57955781
/* create a function context for cross-call persistence */
57965782
funcctx=SRF_FIRSTCALL_INIT();
57975783

@@ -5872,20 +5858,6 @@ generate_series_timestamptz(PG_FUNCTION_ARGS)
58725858
MemoryContextoldcontext;
58735859
Intervalinterval_zero;
58745860

5875-
/* Reject infinities in start and stop values */
5876-
if (TIMESTAMP_IS_NOBEGIN(start)||
5877-
TIMESTAMP_IS_NOEND(start))
5878-
ereport(ERROR,
5879-
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
5880-
errmsg("start value cannot be infinity")));
5881-
if (TIMESTAMP_IS_NOBEGIN(finish)||
5882-
TIMESTAMP_IS_NOEND(finish))
5883-
ereport(ERROR,
5884-
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
5885-
errmsg("stop value cannot be infinity")));
5886-
5887-
/* Interval doesn't (currently) have infinity, so nothing to check */
5888-
58895861
/* create a function context for cross-call persistence */
58905862
funcctx=SRF_FIRSTCALL_INIT();
58915863

‎src/test/regress/expected/timestamp.out

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2055,15 +2055,26 @@ select * from generate_series('2020-01-01 00:00'::timestamp,
20552055
Thu Jan 02 03:00:00 2020
20562056
(28 rows)
20572057

2058+
-- the LIMIT should allow this to terminate in a reasonable amount of time
2059+
-- (but that unfortunately doesn't work yet for SELECT * FROM ...)
2060+
select generate_series('2022-01-01 00:00'::timestamp,
2061+
'infinity'::timestamp,
2062+
'1 month'::interval) limit 10;
2063+
generate_series
2064+
--------------------------
2065+
Sat Jan 01 00:00:00 2022
2066+
Tue Feb 01 00:00:00 2022
2067+
Tue Mar 01 00:00:00 2022
2068+
Fri Apr 01 00:00:00 2022
2069+
Sun May 01 00:00:00 2022
2070+
Wed Jun 01 00:00:00 2022
2071+
Fri Jul 01 00:00:00 2022
2072+
Mon Aug 01 00:00:00 2022
2073+
Thu Sep 01 00:00:00 2022
2074+
Sat Oct 01 00:00:00 2022
2075+
(10 rows)
2076+
20582077
-- errors
2059-
select * from generate_series('-infinity'::timestamp,
2060-
'2020-01-02 03:00'::timestamp,
2061-
'1 hour'::interval);
2062-
ERROR: start value cannot be infinity
2063-
select * from generate_series('2020-01-01 00:00'::timestamp,
2064-
'infinity'::timestamp,
2065-
'1 hour'::interval);
2066-
ERROR: stop value cannot be infinity
20672078
select * from generate_series('2020-01-01 00:00'::timestamp,
20682079
'2020-01-02 03:00'::timestamp,
20692080
'0 hour'::interval);

‎src/test/regress/expected/timestamptz.out

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2398,15 +2398,26 @@ select * from generate_series('2020-01-01 00:00'::timestamptz,
23982398
Thu Jan 02 03:00:00 2020 PST
23992399
(28 rows)
24002400

2401+
-- the LIMIT should allow this to terminate in a reasonable amount of time
2402+
-- (but that unfortunately doesn't work yet for SELECT * FROM ...)
2403+
select generate_series('2022-01-01 00:00'::timestamptz,
2404+
'infinity'::timestamptz,
2405+
'1 month'::interval) limit 10;
2406+
generate_series
2407+
------------------------------
2408+
Sat Jan 01 00:00:00 2022 PST
2409+
Tue Feb 01 00:00:00 2022 PST
2410+
Tue Mar 01 00:00:00 2022 PST
2411+
Fri Apr 01 00:00:00 2022 PDT
2412+
Sun May 01 00:00:00 2022 PDT
2413+
Wed Jun 01 00:00:00 2022 PDT
2414+
Fri Jul 01 00:00:00 2022 PDT
2415+
Mon Aug 01 00:00:00 2022 PDT
2416+
Thu Sep 01 00:00:00 2022 PDT
2417+
Sat Oct 01 00:00:00 2022 PDT
2418+
(10 rows)
2419+
24012420
-- errors
2402-
select * from generate_series('-infinity'::timestamptz,
2403-
'2020-01-02 03:00'::timestamptz,
2404-
'1 hour'::interval);
2405-
ERROR: start value cannot be infinity
2406-
select * from generate_series('2020-01-01 00:00'::timestamptz,
2407-
'infinity'::timestamptz,
2408-
'1 hour'::interval);
2409-
ERROR: stop value cannot be infinity
24102421
select * from generate_series('2020-01-01 00:00'::timestamptz,
24112422
'2020-01-02 03:00'::timestamptz,
24122423
'0 hour'::interval);

‎src/test/regress/sql/timestamp.sql

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -375,13 +375,12 @@ select make_timestamp(0, 7, 15, 12, 30, 15);
375375
select*from generate_series('2020-01-01 00:00'::timestamp,
376376
'2020-01-02 03:00'::timestamp,
377377
'1 hour'::interval);
378+
-- the LIMIT should allow this to terminate in a reasonable amount of time
379+
-- (but that unfortunately doesn't work yet for SELECT * FROM ...)
380+
select generate_series('2022-01-01 00:00'::timestamp,
381+
'infinity'::timestamp,
382+
'1 month'::interval)limit10;
378383
-- errors
379-
select*from generate_series('-infinity'::timestamp,
380-
'2020-01-02 03:00'::timestamp,
381-
'1 hour'::interval);
382-
select*from generate_series('2020-01-01 00:00'::timestamp,
383-
'infinity'::timestamp,
384-
'1 hour'::interval);
385384
select*from generate_series('2020-01-01 00:00'::timestamp,
386385
'2020-01-02 03:00'::timestamp,
387386
'0 hour'::interval);

‎src/test/regress/sql/timestamptz.sql

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -436,13 +436,12 @@ RESET TimeZone;
436436
select*from generate_series('2020-01-01 00:00'::timestamptz,
437437
'2020-01-02 03:00'::timestamptz,
438438
'1 hour'::interval);
439+
-- the LIMIT should allow this to terminate in a reasonable amount of time
440+
-- (but that unfortunately doesn't work yet for SELECT * FROM ...)
441+
select generate_series('2022-01-01 00:00'::timestamptz,
442+
'infinity'::timestamptz,
443+
'1 month'::interval)limit10;
439444
-- errors
440-
select*from generate_series('-infinity'::timestamptz,
441-
'2020-01-02 03:00'::timestamptz,
442-
'1 hour'::interval);
443-
select*from generate_series('2020-01-01 00:00'::timestamptz,
444-
'infinity'::timestamptz,
445-
'1 hour'::interval);
446445
select*from generate_series('2020-01-01 00:00'::timestamptz,
447446
'2020-01-02 03:00'::timestamptz,
448447
'0 hour'::interval);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp