pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: PG Bug reporting form <noreply@postgresql.org>
To: pgsql-bugs@lists.postgresql.org
Cc: work.michael.2956@gmail.com
Subject: BUG #18348: Inconsistency with EXTRACT([field] from INTERVAL);
Date: Fri, 16 Feb 2024 12:06:55 +0000
Message-ID: <18348-b097a3587dfde8a4@postgresql.org> (raw)

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
.



view thread (31+ messages)  latest in thread

Message-ID: <18348-b097a3587dfde8a4@postgresql.org>
Permalink:  ../18348-b097a3587dfde8a4@postgresql.org/
Also on:    postgresql.org/message-id/18348-b097a3587dfde8a4@postgresql.org

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-bugs@postgresql.org
  Cc: noreply@postgresql.org, pgsql-bugs@lists.postgresql.org, work.michael.2956@gmail.com
  Subject: Re: BUG #18348: Inconsistency with EXTRACT([field] from INTERVAL);
  In-Reply-To: <18348-b097a3587dfde8a4@postgresql.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox