Re: BUG #18348: Inconsistency with EXTRACT([field] from INTERVAL);
Tom Lane <tgl@sss.pgh.pa.us>
From: Tom Lane <tgl@sss.pgh.pa.us>
To: jian he <jian.universality@gmail.com>
Cc: Francisco Olarte <folarte@peoplecall.com>,
Michael Bondarenko <work.michael.2956@gmail.com>,
pgsql-bugs@lists.postgresql.org, dgrowleyml@gmail.com,
Peter Eisentraut <peter.eisentraut@enterprisedb.com>
Date: 2024-05-08T14:10:48Z
Lists: pgsql-bugs, pgsql-hackers
jian he <jian.universality@gmail.com> writes:
> but in real life, for week, we generally begin with 1?
> like "the first week", "second week"
> so should
> select extract(week from interval '1 day');
> return 1
> ?
Hmm, I read it as being "the number of (whole) weeks in the
interval". Starting with week 1 is what happens in the timestamp
case, true, but I don't find that appropriate for interval.
By analogy,
regression=# select extract(day from interval '23 hours');
extract
---------
0
(1 row)
There's no such thing as "day 0" in the timestamp case,
but that doesn't make this wrong.
In any case, I'm starting to wonder why this issue is on the v17
open items list. These are hardly new bugs in 17. If there's
still differences of opinion about what the definition should be,
I think cramming in a change post-feature-freeze is not appropriate.
Let's just queue the issue for the next commitfest (already done
at [1]) and take it off the open items list.
regards, tom lane
[1] https://commitfest.postgresql.org/48/4979/
Commits
Same data as JSON:
GET /api/v1/messages/:b64id/commits
the thread's linked commits as JSON, with link sources.
API reference →
-
Fix extraction of week and quarter fields from intervals.
- 6be39d77a70d 18.0 landed
-
Doc: improve explanation of type interval, especially extract().
- fcd210d496da 17.0 landed
- ebf52e9b7532 14.12 landed
- eb1d008a7a18 13.15 landed
- 6d03e8109250 15.7 landed
- 3ad319b8cad4 16.3 landed