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

Commit5045c79

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 parent880511c commit5045c79

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
@@ -5392,20 +5392,6 @@ generate_series_timestamp(PG_FUNCTION_ARGS)
53925392
MemoryContextoldcontext;
53935393
Intervalinterval_zero;
53945394

5395-
/* Reject infinities in start and stop values */
5396-
if (TIMESTAMP_IS_NOBEGIN(start)||
5397-
TIMESTAMP_IS_NOEND(start))
5398-
ereport(ERROR,
5399-
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
5400-
errmsg("start value cannot be infinity")));
5401-
if (TIMESTAMP_IS_NOBEGIN(finish)||
5402-
TIMESTAMP_IS_NOEND(finish))
5403-
ereport(ERROR,
5404-
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
5405-
errmsg("stop value cannot be infinity")));
5406-
5407-
/* Interval doesn't (currently) have infinity, so nothing to check */
5408-
54095395
/* create a function context for cross-call persistence */
54105396
funcctx=SRF_FIRSTCALL_INIT();
54115397

@@ -5487,20 +5473,6 @@ generate_series_timestamptz(PG_FUNCTION_ARGS)
54875473
MemoryContextoldcontext;
54885474
Intervalinterval_zero;
54895475

5490-
/* Reject infinities in start and stop values */
5491-
if (TIMESTAMP_IS_NOBEGIN(start)||
5492-
TIMESTAMP_IS_NOEND(start))
5493-
ereport(ERROR,
5494-
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
5495-
errmsg("start value cannot be infinity")));
5496-
if (TIMESTAMP_IS_NOBEGIN(finish)||
5497-
TIMESTAMP_IS_NOEND(finish))
5498-
ereport(ERROR,
5499-
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
5500-
errmsg("stop value cannot be infinity")));
5501-
5502-
/* Interval doesn't (currently) have infinity, so nothing to check */
5503-
55045476
/* create a function context for cross-call persistence */
55055477
funcctx=SRF_FIRSTCALL_INIT();
55065478

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

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

1770+
-- the LIMIT should allow this to terminate in a reasonable amount of time
1771+
-- (but that unfortunately doesn't work yet for SELECT * FROM ...)
1772+
select generate_series('2022-01-01 00:00'::timestamp,
1773+
'infinity'::timestamp,
1774+
'1 month'::interval) limit 10;
1775+
generate_series
1776+
--------------------------
1777+
Sat Jan 01 00:00:00 2022
1778+
Tue Feb 01 00:00:00 2022
1779+
Tue Mar 01 00:00:00 2022
1780+
Fri Apr 01 00:00:00 2022
1781+
Sun May 01 00:00:00 2022
1782+
Wed Jun 01 00:00:00 2022
1783+
Fri Jul 01 00:00:00 2022
1784+
Mon Aug 01 00:00:00 2022
1785+
Thu Sep 01 00:00:00 2022
1786+
Sat Oct 01 00:00:00 2022
1787+
(10 rows)
1788+
17701789
-- errors
1771-
select * from generate_series('-infinity'::timestamp,
1772-
'2020-01-02 03:00'::timestamp,
1773-
'1 hour'::interval);
1774-
ERROR: start value cannot be infinity
1775-
select * from generate_series('2020-01-01 00:00'::timestamp,
1776-
'infinity'::timestamp,
1777-
'1 hour'::interval);
1778-
ERROR: stop value cannot be infinity
17791790
select * from generate_series('2020-01-01 00:00'::timestamp,
17801791
'2020-01-02 03:00'::timestamp,
17811792
'0 hour'::interval);

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

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

2130+
-- the LIMIT should allow this to terminate in a reasonable amount of time
2131+
-- (but that unfortunately doesn't work yet for SELECT * FROM ...)
2132+
select generate_series('2022-01-01 00:00'::timestamptz,
2133+
'infinity'::timestamptz,
2134+
'1 month'::interval) limit 10;
2135+
generate_series
2136+
------------------------------
2137+
Sat Jan 01 00:00:00 2022 PST
2138+
Tue Feb 01 00:00:00 2022 PST
2139+
Tue Mar 01 00:00:00 2022 PST
2140+
Fri Apr 01 00:00:00 2022 PDT
2141+
Sun May 01 00:00:00 2022 PDT
2142+
Wed Jun 01 00:00:00 2022 PDT
2143+
Fri Jul 01 00:00:00 2022 PDT
2144+
Mon Aug 01 00:00:00 2022 PDT
2145+
Thu Sep 01 00:00:00 2022 PDT
2146+
Sat Oct 01 00:00:00 2022 PDT
2147+
(10 rows)
2148+
21302149
-- errors
2131-
select * from generate_series('-infinity'::timestamptz,
2132-
'2020-01-02 03:00'::timestamptz,
2133-
'1 hour'::interval);
2134-
ERROR: start value cannot be infinity
2135-
select * from generate_series('2020-01-01 00:00'::timestamptz,
2136-
'infinity'::timestamptz,
2137-
'1 hour'::interval);
2138-
ERROR: stop value cannot be infinity
21392150
select * from generate_series('2020-01-01 00:00'::timestamptz,
21402151
'2020-01-02 03:00'::timestamptz,
21412152
'0 hour'::interval);

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

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -244,13 +244,12 @@ SELECT make_timestamp(2014,12,28,6,30,45.887);
244244
select*from generate_series('2020-01-01 00:00'::timestamp,
245245
'2020-01-02 03:00'::timestamp,
246246
'1 hour'::interval);
247+
-- the LIMIT should allow this to terminate in a reasonable amount of time
248+
-- (but that unfortunately doesn't work yet for SELECT * FROM ...)
249+
select generate_series('2022-01-01 00:00'::timestamp,
250+
'infinity'::timestamp,
251+
'1 month'::interval)limit10;
247252
-- errors
248-
select*from generate_series('-infinity'::timestamp,
249-
'2020-01-02 03:00'::timestamp,
250-
'1 hour'::interval);
251-
select*from generate_series('2020-01-01 00:00'::timestamp,
252-
'infinity'::timestamp,
253-
'1 hour'::interval);
254253
select*from generate_series('2020-01-01 00:00'::timestamp,
255254
'2020-01-02 03:00'::timestamp,
256255
'0 hour'::interval);

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

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -338,13 +338,12 @@ RESET TimeZone;
338338
select*from generate_series('2020-01-01 00:00'::timestamptz,
339339
'2020-01-02 03:00'::timestamptz,
340340
'1 hour'::interval);
341+
-- the LIMIT should allow this to terminate in a reasonable amount of time
342+
-- (but that unfortunately doesn't work yet for SELECT * FROM ...)
343+
select generate_series('2022-01-01 00:00'::timestamptz,
344+
'infinity'::timestamptz,
345+
'1 month'::interval)limit10;
341346
-- errors
342-
select*from generate_series('-infinity'::timestamptz,
343-
'2020-01-02 03:00'::timestamptz,
344-
'1 hour'::interval);
345-
select*from generate_series('2020-01-01 00:00'::timestamptz,
346-
'infinity'::timestamptz,
347-
'1 hour'::interval);
348347
select*from generate_series('2020-01-01 00:00'::timestamptz,
349348
'2020-01-02 03:00'::timestamptz,
350349
'0 hour'::interval);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp