From: Tom Lane <tgl@sss.pgh.pa.us>
To: Andrew Gierth <andrew@tao11.riddles.org.uk>
Cc: pablopumarino@gmail.com
Cc: pgsql-bugs@postgresql.org
Subject: Re: BUG #14294: Problem in generate series between dates
Date: Wed, 24 Aug 2016 16:10:40 -0400
Message-ID: <31168.1472069440@sss.pgh.pa.us> (raw)
In-Reply-To: <87oa4i9d8w.fsf@news-spur.riddles.org.uk>
References: <20160824182920.15681.52285@wrigleys.postgresql.org>
<28256.1472064660@sss.pgh.pa.us>
<87oa4i9d8w.fsf@news-spur.riddles.org.uk>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-bugs>
Andrew Gierth <andrew@tao11.riddles.org.uk> writes:
> This _looks_ wrong:
> set timezone = 'America/Santiago';
> select timestamptz '2016-08-13', timestamptz '2016-08-13' + interval '1 day';
> timestamptz | ?column?
> ------------------------+------------------------
> 2016-08-13 00:00:00-04 | 2016-08-14 01:00:00-03
> (1 row)
> but I guess it's inevitable, since 2016-08-14 00:00:00 doesn't exist in
> the local time, so there's no other possible result to return.
Yeah. And after that, the shift persists, eg.
# select '2016-08-14 01:00:00-03'::timestamptz + '1 day'::interval;
?column?
------------------------
2016-08-15 01:00:00-03
(1 row)
That's a bit annoying, because it works if you skip over that day:
# select '2016-08-13'::timestamptz + '2 days'::interval;
?column?
------------------------
2016-08-15 00:00:00-03
(1 row)
In other words, we could make this scenario "work" if we defined
generate_series as base plus N times the increment, rather than as
repeated addition of the increment. But I wouldn't be surprised
if that would break other corner cases (and it would certainly
be slower). Daylight-savings time is not one of the more consistent
things in our world ... not that anything at all about the civil
calendar is mathematically nice :-(.
Certainly, the right answer in this example case is to use
the timestamp not timestamptz flavor of generate_series.
Or you could use the integer flavor and add the results to
a base date using the date + integer operator.
regards, tom lane
--
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-bugs@postgresql.org
Cc: tgl@sss.pgh.pa.us, andrew@tao11.riddles.org.uk, pablopumarino@gmail.com
Subject: Re: BUG #14294: Problem in generate series between dates
In-Reply-To: <31168.1472069440@sss.pgh.pa.us>
References: <20160824182920.15681.52285@wrigleys.postgresql.org> <28256.1472064660@sss.pgh.pa.us> <87oa4i9d8w.fsf@news-spur.riddles.org.uk> <31168.1472069440@sss.pgh.pa.us>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox