Re: Why 'infinity' is not in range '[2019-01-02, infinity]'?
"Jonathan S. Katz" <[email protected]>
| Newsgroups | gmane.comp.db.postgresql.devel.documentation |
|---|---|
| Message-ID | <[email protected]> |
On 4/29/19 12:12 PM, PG Doc comments form wrote:
> The following documentation comment has been logged on the website:
>
> Page: https://www.postgresql.org/docs/11/rangetypes.html
> Description:
>
> Hi.
>
> May I read this:
>
> But [today,infinity] means something different from [today,infinity) — the
> latter excludes the special timestamp value infinity.
>
> as
>
> But [today,infinity] means something different from [today,infinity) — the
> **first includes** the special timestamp value infinity.
>
> But previous paragraph says:
>
> But note that these infinite values are never values of the range's element
> type, and can never be part of the range. (So there is no such thing as an
> inclusive infinite bound — if you try to write one, it will automatically be
> converted to an exclusive bound.)
>
> if 'infinity' can not be the part of a range this will mean:
>
> [today,infinity] means same as [today,infinity)
>
> errr... which one is correct? Please fix documentation.
'infinity' in that case is a special type of date/timestamp:
https://www.postgresql.org/docs/current/datatype-datetime.html#id-1.5.7.13.19.8
which is what that paragraph is referring to. It's discussing
"infinity-like" objects you may see that are different than how range
types treat infinity.
I re-read the language, I would not advocate for making any changes.
> PS. The problem I am faced into:
> I am implementing be-temporal interface. I have current period. It can be
> [2019-01-01,2019-02-01),
> [2019-02-01,2019-03-01) and [2019-03-01,infinity) for the current month.
>
> When I setup current_period to one of those I will get Orders at that
> period. The Orders have with 'last_bill_date' field which will show the date
> of Invoice for that Order.
> For new Order we can set 'infinity' into 'last_bill_date' which will mean
> that we should create Invoice.
> Now to select all Order for which we should create Invoice we can write:
>
> select * from "order" o where o.last_bill_date +interval o.bill_interval <@
> current_period();
>
> This seems obvious that infinity is part of [value, infinity) ( or
> [value,infinity] ) range. (in other words the 'infinity' is always the part
> of range with infinite inclusive or exclusive bound.
>
> This is just view from my point, there can be things that I am not aware of.
You should drop the 'infinity' and just let it be NULL, i.e.
daterange('2019-03-01', NULL);
Jonathan
signature.asc
(application/pgp-signature, 833 B)
-----BEGIN PGP SIGNATURE----- iQIzBAEBCAAdFiEE+oS2la8r95ogZD/x8QSccp8cZScFAlzHMPIACgkQ8QSccp8c ZSeO+RAAjrR0RHilo9TXG1S9y6Li8vnoyMeIl82Jl2BjFFzNIQ+JG5mE4zh59bBJ 3ZfHCtB6oZ87RExOIHpZO3VxXQ1FkszYu4+cdXjplS1hPHdISHh+VGuzGaCuKExN 9PRKiA9WA0x6J9qwzjlx+qT7zwEE5qkVdFgJYi/5r6P3cODcCa+bhIL48GqdKV14 RR91mMsCp14Benf9jv1ob2xwTqmJRwDKSxRKtEBv/JSgXGjrwvi108x41OiMAA4u gzn3w1mUywY/2TcN9nbXIt1cuiA+6M4QNXITuESfik4h4X30gZRQgyECLchGVVqc 6swCzhOuIQuB7mBaikBiZWTrtVK9RZrrzpsMNQNzYp3PL1E0bP/R/qX2M5oPaK0L guxiE5TYPlEBmLDNTYxD/ehf4CvuRIFvhIyzB/E5kgGwJ2NoVOrGF3hUc84L1KoD GR10LaARgzNaaGKHkSnFE57BU90zjP46Qp+Vt/8YNkpE9FamqH2/ZXFBl4Vmx4xF tLlHbY37ItqdsFUoQwQIpQVRdysWRGbcet+6mHEpB7Ubc5z6/5R8MoljgBpG+phs +8yj6soIcEJ8nhBwAw1wm9O62BWQqeABOQ0wi6zcryXepWMys9b4Lg5MN7RqlaAO mvH/rczpHgMdkwmnbTaVXb67RlvP81O3XPppMhr1h+2E6KtizoU= =t0Jx -----END PGP SIGNATURE-----