From: Tom Lane <tgl@sss.pgh.pa.us>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Fix extraction of week and quarter fields from intervals.
Date: Fri, 16 Aug 2024 16:36:09 +0000
Message-ID: <E1sezvt-004ULQ-GM@gemulon.postgresql.org> (raw)
Fix extraction of week and quarter fields from intervals.
"EXTRACT(WEEK FROM interval_value)" formerly threw an error.
Define it as "tm->tm_mday / 7". (With C99 division semantics,
this gives consistent results for negative intervals.)
"EXTRACT(QUARTER FROM interval_value)" has been implemented
all along, but it formerly gave extremely strange results for
negative intervals. Fix it so that the output for -N months
is the negative of the output for N months.
Per bug #18348 from Michael Bondarenko and subsequent discussion.
Discussion: https://postgr.es/m/18348-b097a3587dfde8a4@postgresql.org
Branch
------
master
Details
-------
https://git.postgresql.org/pg/commitdiff/6be39d77a70df52d5a0f2eb414ef9901ccf17e5a
Modified Files
--------------
doc/src/sgml/func.sgml | 13 +++++++-
src/backend/utils/adt/timestamp.c | 18 +++++++++-
src/test/regress/expected/interval.out | 61 ++++++++++++++++++++++++++--------
src/test/regress/sql/interval.sql | 18 ++++++++++
4 files changed, 94 insertions(+), 16 deletions(-)
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-committers@postgresql.org
Cc: tgl@sss.pgh.pa.us, pgsql-committers@lists.postgresql.org
Subject: Re: pgsql: Fix extraction of week and quarter fields from intervals.
In-Reply-To: <E1sezvt-004ULQ-GM@gemulon.postgresql.org>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox