From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
---|---|
To: | Francisco Olarte <folarte(at)peoplecall(dot)com> |
Cc: | Michael Bondarenko <work(dot)michael(dot)2956(at)gmail(dot)com>, jian he <jian(dot)universality(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-17 20:30:25 |
Message-ID: | 3709307.1708201825@sss.pgh.pa.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-bugs pgsql-hackers |
Francisco Olarte <folarte(at)peoplecall(dot)com> writes:
> On Sat, 17 Feb 2024 at 09:01, Michael Bondarenko
> <work(dot)michael(dot)2956(at)gmail(dot)com> wrote:
>> When testing I stumbled upon that too, but I thought no calculation was happening in the interval field. However, it's different with the days and months etc. It seems no calculation for day and month and more:
>> ...
>> But calculation is present for hour, and minutes and seconds (90061 sec is 1 day 1 hour 1 minute 1 second):
> No, intervals have seconds, days and months.
Yeah. I think much of the confusion here comes from starting with
non-normalized interval input. Sure you can write "2011 year 12 month
48 hour 1005 min 2 sec 11 ms", but that's not how it's stored:
regression=# select interval '2011 year 12 month 48 hour 1005 min 2 sec 11 ms';
interval
-------------------------
2012 years 64:45:02.011
(1 row)
(Actually, what's stored is 2012*12 months, 0 days, and some number
of microseconds that I don't feel like working out. Conversion of
the microseconds to HH:MM:SS.SSS happens on output.)
Once you look at the normalized value, the results of extract()
are far less surprising.
Probably the right place to enlarge on this point is not in the
extract() section at all, but in 8.5.4. Interval Input. That does
mention the months/days/microseconds representation, but it doesn't
follow through by illustrating how other input is combined. Perhaps
we'd want to adopt something like the attached (this is separate from
the other patches I posted in the thread).
regards, tom lane
Attachment | Content-Type | Size |
---|---|---|
0003-clarify-interval-behavior.patch | text/x-diff | 4.6 KB |
From | Date | Subject | |
---|---|---|---|
Next Message | jian he | 2024-02-18 01:48:27 | Re: BUG #18348: Inconsistency with EXTRACT([field] from INTERVAL); |
Previous 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 |
From | Date | Subject | |
---|---|---|---|
Next Message | Matthias van de Meent | 2024-02-17 21:48:44 | Re: Revisiting {CREATE INDEX, REINDEX} CONCURRENTLY improvements |
Previous Message | Andres Freund | 2024-02-17 20:24:33 | Re: Speeding up COPY TO for uuids and arrays |