Re: Add generate_series(date,date) and generate_series(date,date,integer) - Mailing list pgsql-hackers

From Michael Paquier
Subject Re: Add generate_series(date,date) and generate_series(date,date,integer)
Date
Msg-id CAB7nPqQUuUh_W3s55eSiMnt901Ud3meF7f_96yPkKcqfd1ZaMg@mail.gmail.com
Whole thread Raw
In response to Add generate_series(date,date) and generate_series(date,date,integer)  (Corey Huinker <corey.huinker@gmail.com>)
Responses Re: Add generate_series(date,date) and generate_series(date,date,integer)
List pgsql-hackers
On Mon, Jan 25, 2016 at 3:00 PM, Corey Huinker <corey.huinker@gmail.com> wrote:
> This patch addresses a personal need: nearly every time I use
> generate_series for timestamps, I end up casting the result into date or the
> ISO string thereof. Like such:
>
> [...]
>
> One thing I discovered in doing this patch is that if you do a timestamp
> generate_series involving infinity....it tries to do it. I didn't wait to
> see if it finished.

Well, I would think that this is a bug that we had better address and
backpatch. It does not make much sense to use infinity for timestamps,
but letting it run infinitely is not good either.

> For the date series, I put in checks to return an empty set:
>
> SELECT d.date_val FROM generate_series('-infinity'::date,'1999-12-29'::date)
> as d(date_val);
>  date_val
> ----------
> (0 rows)
>
> SELECT d.date_val FROM generate_series('1991-09-24'::date,'infinity'::date)
> as d(date_val);
>  date_val
> ----------
> (0 rows)

Wouldn't a proper error be more adapted?
-- 
Michael



pgsql-hackers by date:

Previous
From: Corey Huinker
Date:
Subject: Add generate_series(date,date) and generate_series(date,date,integer)
Next
From: Tom Lane
Date:
Subject: Re: Add generate_series(date,date) and generate_series(date,date,integer)