Re: BUG #18348: Inconsistency with EXTRACT([field] from INTERVAL); - Mailing list pgsql-bugs

From Tom Lane
Subject Re: BUG #18348: Inconsistency with EXTRACT([field] from INTERVAL);
Date
Msg-id 3749306.1708222748@sss.pgh.pa.us
Whole thread Raw
In response to Re: BUG #18348: Inconsistency with EXTRACT([field] from INTERVAL);  (jian he <jian.universality@gmail.com>)
Responses Re: BUG #18348: Inconsistency with EXTRACT([field] from INTERVAL);  (jian he <jian.universality@gmail.com>)
List pgsql-bugs
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



pgsql-bugs by date:

Previous
From: "adfile@aol.com"
Date:
Subject: Postgresql16 dnf install postgresql16-devel.x86_64 fails - Resolve
Next
From: David Rowley
Date:
Subject: Re: BUG #18344: Pruning tables partitioned by bool range fails with invalid strategy