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

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: jian he <jian(dot)universality(at)gmail(dot)com>
Cc: Francisco Olarte <folarte(at)peoplecall(dot)com>, Michael Bondarenko <work(dot)michael(dot)2956(at)gmail(dot)com>, pgsql-bugs(at)lists(dot)postgresql(dot)org, dgrowleyml(at)gmail(dot)com
Subject: Re: BUG #18348: Inconsistency with EXTRACT([field] from INTERVAL);
Date: 2024-02-18 02:19:08
Message-ID: 3749306.1708222748@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs pgsql-hackers

jian he <jian(dot)universality(at)gmail(dot)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

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message David Rowley 2024-02-18 12:53:29 Re: BUG #18344: Pruning tables partitioned by bool range fails with invalid strategy
Previous Message adfile@aol.com 2024-02-18 01:51:59 Postgresql16 dnf install postgresql16-devel.x86_64 fails - Resolve

Browse pgsql-hackers by date

  From Date Subject
Next Message Li Japin 2024-02-18 02:30:58 Re: Thoughts about NUM_BUFFER_PARTITIONS
Previous Message Andres Freund 2024-02-18 01:59:55 Re: Why is pq_begintypsend so slow?