On 08.04.22 15:10, Tom Lane wrote:
Peter Eisentraut writes:
We really wanted to avoid doing calculations in numeric as much as
possible. So we should figure out a different way to write this. The
attached patch works for me. It's a bit ugly since it hardcodes some
factors. Maybe we can reph
Peter Eisentraut writes:
> We really wanted to avoid doing calculations in numeric as much as
> possible. So we should figure out a different way to write this. The
> attached patch works for me. It's a bit ugly since it hardcodes some
> factors. Maybe we can rephrase it a bit more elegantl
On 24.02.22 03:35, Joseph Koshakow wrote:
However when executing EXTRACT we first truncate
DAYS_PER_YEAR to an integer, and then multiply it
by the total years in the Interval
/* this always fits into int64 */
secs_from_day_month = ((int64) DAYS_PER_YEAR * (interval->month /
MONTHS_PER_YEAR) +
Joseph Koshakow writes:
> I do want to briefly mention, if I'm understanding the history of
> EXTRACT correctly, that the previous behavior
> actually was to multiply by 365.25, not 365. However The commit that
> changed the return type from numeric [1]
> changed that behavior. Looking through the
On Thu, Feb 24, 2022 at 4:47 AM Aleksander Alekseev
wrote:
> Extracting an epoch from an interval is quite a strange case since intervals
> are not connected to any specific dates.
I agree, I think it's a weird use case and that it's probably not
worth fixing. Though it was fun for me to try.
>
Hi Joseph,
> > Is this truncation on purpose? It seems like
> > EXTRACT is not accounting for leap years in
> > it's calculation.
Extracting an epoch from an interval is quite a strange case since
intervals are not connected to any specific dates.
For instance:
select extract('epoch' from inter
On Wed, Feb 23, 2022 at 7:42 PM Joseph Koshakow wrote:
>
> Hi all,
>
> I noticed something odd when going through some
> of the Interval code. The DAYS_PER_YEAR constant
> is defined in src/include/datatype/timestamp.h.
> > #define DAYS_PER_YEAR365.25/* assumes leap year every four years *
Hi all,
I noticed something odd when going through some
of the Interval code. The DAYS_PER_YEAR constant
is defined in src/include/datatype/timestamp.h.
> #define DAYS_PER_YEAR365.25/* assumes leap year every four years */
We execute the EXTRACT and date_part functions in
src/backend/util