BUG #18348: Inconsistency with EXTRACT([field] from INTERVAL);
PG Bug reporting form <noreply@postgresql.org>
From: PG Bug reporting form <noreply@postgresql.org>
To: pgsql-bugs@lists.postgresql.org
Cc: work.michael.2956@gmail.com
Date: 2024-02-16T12:06:55Z
Lists: pgsql-bugs, pgsql-hackers
The following bug has been logged on the website:
Bug reference: 18348
Logged by: Michael Bondarenko
Email address: work.michael.2956@gmail.com
PostgreSQL version: 14.10
Operating system: macOS
Description:
Hello,
I'm building a random semantically-correct SQL code generator for PostgreSQL
and I stumbled upon an inconsistency:
tpch=# select extract(year from interval '3 years');
extract
---------
3
(1 row)
tpch=# select extract(week from interval '3 weeks');
ERROR: interval units "week" not supported
In the documentation it's mentioned that 'week' is an ISO 8601 week, so it
makes sense why it's not applicable to INTERVAL, which is the same for
isoyear. However, the field is named week and not isoweek, so I expect it to
work like the `select extract(year from interval '3 years');` does.
Moreover, the documentation does not mention that the field cannot be
extracted from INTERVAL, like it does for isoyear:
https://www.postgresql.org/docs/current/functions-datetime.html#FUNCTIONS-DATETIME-EXTRACT
.
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