]> git.ipfire.org Git - thirdparty/postgresql.git/commit
Remove redundant function calls in timestamp[tz]_part().
authorTom Lane <tgl@sss.pgh.pa.us>
Thu, 12 Dec 2019 17:12:36 +0000 (12:12 -0500)
committerTom Lane <tgl@sss.pgh.pa.us>
Thu, 12 Dec 2019 17:12:36 +0000 (12:12 -0500)
commite284e0e2f9da268754ee0deb814b5a7310db0d0e
treed3a327cf77ff3f45b131fcb0251a30ffe05c4f11
parent6bf23e8c6e066fb7554b9076355afdfc103ad134
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
src/backend/utils/adt/timestamp.c
src/test/regress/expected/timestamp.out
src/test/regress/expected/timestamptz.out
src/test/regress/sql/timestamp.sql
src/test/regress/sql/timestamptz.sql