BUG #18348: Inconsistency with EXTRACT([field] from INTERVAL);

From: PG Bug reporting form <noreply(at)postgresql(dot)org>
To: pgsql-bugs(at)lists(dot)postgresql(dot)org
Cc: work(dot)michael(dot)2956(at)gmail(dot)com
Subject: BUG #18348: Inconsistency with EXTRACT([field] from INTERVAL);
Date: 2024-02-16 12:06:55
Message-ID: 18348-b097a3587dfde8a4@postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs pgsql-hackers

The following bug has been logged on the website:

Bug reference: 18348
Logged by: Michael Bondarenko
Email address: work(dot)michael(dot)2956(at)gmail(dot)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
.

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Michael Bondarenko 2024-02-16 12:21:57 Re: BUG #18348: Inconsistency with EXTRACT([field] from INTERVAL);
Previous Message David Rowley 2024-02-16 11:25:28 Re: UPDATE modifies more rows that it should

Browse pgsql-hackers by date

  From Date Subject
Next Message vignesh C 2024-02-16 12:09:47 confirmed flush lsn seems to be move backward in certain error cases
Previous Message Joe Conway 2024-02-16 11:56:13 Re: Replace current implementations in crypt() and gen_salt() to OpenSSL