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

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: David Rowley <dgrowleyml(at)gmail(dot)com>
Cc: work(dot)michael(dot)2956(at)gmail(dot)com, pgsql-bugs(at)lists(dot)postgresql(dot)org, Peter Eisentraut <peter(dot)eisentraut(at)enterprisedb(dot)com>
Subject: Re: BUG #18348: Inconsistency with EXTRACT([field] from INTERVAL);
Date: 2024-02-17 18:14:19
Message-ID: 3693246.1708193659@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs pgsql-hackers

David Rowley <dgrowleyml(at)gmail(dot)com> writes:
> On Sat, 17 Feb 2024 at 01:27, PG Bug reporting form
> <noreply(at)postgresql(dot)org> wrote:
>> 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

> Maybe that table should specify which type(s) each of the items listed
> is applicable to. Seems better than mentioning which types they're not
> applicable to.

The thing's not laid out as a table though, and converting it seems
like more trouble than this is worth. The rejected cases hardly seem
surprising. I propose just mentioning that not all fields apply for
all data types, as in 0001 attached.

(Parenthetically, one case that perhaps is surprising is
ERROR: unit "week" not supported for type interval
Why not just return the day field divided by 7?)

Unrelated but adjacent, the discussion of the century field seems
more than a bit flippant when I read it now. In other places we
are typically content to use examples to make similar points.
I propose doing so here too, as in 0002 attached.

Lastly, the entire page is quite schizophrenic about whether to leave
a blank line between adjacent examples. I could go either way on
whether to have that whitespace or not, but I do think it would be
better to make it uniform. Any votes on what to do there?

regards, tom lane

Attachment Content-Type Size
0001-update-extract-description.patch text/x-diff 2.1 KB
0002-condense-century-discussion.patch text/x-diff 1.2 KB

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message PG Bug reporting form 2024-02-17 20:00:00 BUG #18351: VACUUM FULL fails with error: missing chunk number 0 for toast value XXX
Previous Message Francisco Olarte 2024-02-17 15:12:15 Re: BUG #18348: Inconsistency with EXTRACT([field] from INTERVAL);

Browse pgsql-hackers by date

  From Date Subject
Next Message Tomas Vondra 2024-02-17 18:49:21 Re: Add pg_basetype() function to obtain a DOMAIN base type
Previous Message Pavel Luzanov 2024-02-17 18:06:16 Re: Things I don't like about \du's "Attributes" column