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
Date: 2024-02-18T02:19:08Z
Lists: pgsql-bugs, pgsql-hackers
jian he <jian.universality@gmail.com> writes: > you already mentioned "Not all fields are valid for every input data type". > interval data type don't even have a unit "quarter", > so the following should generate an error? > select extract(quarter from interval '2011 year 12 month 48 hour > 1005min 2 sec 11 ms'); I'm not especially persuaded by that reasoning. Intervals don't have century or millisecond fields either, but we allow extracting those. If your argument is that we shouldn't allow it because we don't take the input INTERVAL '1 quarter', I'd be much more inclined to add that as valid input than to take away existing extract functionality. But I'm dubious about the proposition that extract's list of valid fields should exactly match the set of allowed input units. The semantics aren't really the same (as per the '80 minutes' example) so such a restriction doesn't seem to have much basis in reality. regards, tom lane
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