pgsql: Remove redundant function calls in timestamp[tz]_part(). - Mailing list pgsql-committers

From Tom Lane
Subject pgsql: Remove redundant function calls in timestamp[tz]_part().
Date
Msg-id E1ifS1e-0006v0-0e@gemulon.postgresql.org
Whole thread Raw
List pgsql-committers
Remove redundant function calls in timestamp[tz]_part().

The DTK_DOW/DTK_ISODOW and DTK_DOY switch cases in timestamp_part() and
timestamptz_part() contained calls of timestamp2tm() that were fully
redundant with the ones done just above the switch.  This evidently crept
in during commit 258ee1b63, which relocated that code from another place
where the calls were indeed needed.  Just delete the redundant calls.

I (tgl) noted that our test coverage of these functions left quite a
bit to be desired, so extend timestamp.sql and timestamptz.sql to
cover all the branches.

Back-patch to all supported branches, as the previous commit was.
There's no real issue here other than some wasted cycles in some
not-too-heavily-used code paths, but the test coverage seems valuable.

Report and patch by Li Japin; test case adjustments by me.

Discussion: https://postgr.es/m/SG2PR06MB37762CAE45DB0F6CA7001EA9B6550@SG2PR06MB3776.apcprd06.prod.outlook.com

Branch
------
REL9_4_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/8b0fd6d04137d8c436a34f3261a0f7fa3068f891

Modified Files
--------------
src/backend/utils/adt/timestamp.c         |  16 -
src/test/regress/expected/timestamp.out   | 469 +++++++++++++++----------
src/test/regress/expected/timestamptz.out | 551 ++++++++++++++++++++----------
src/test/regress/sql/timestamp.sql        |  23 +-
src/test/regress/sql/timestamptz.sql      |  29 +-
5 files changed, 693 insertions(+), 395 deletions(-)


pgsql-committers by date:

Previous
From: Tom Lane
Date:
Subject: pgsql: Remove redundant function calls in timestamp[tz]_part().
Next
From: Tom Lane
Date:
Subject: pgsql: Fix EXTRACT(ISOYEAR FROM timestamp) for years BC.