Fix EXTRACT(ISOYEAR FROM timestamp) for years BC.
authorTom Lane <[email protected]>
Thu, 12 Dec 2019 17:30:44 +0000 (12:30 -0500)
committerTom Lane <[email protected]>
Thu, 12 Dec 2019 17:30:44 +0000 (12:30 -0500)
commit6aa1263113a6aeeaf1a2405018bff50b4666134e
treed9275f217b17e7c415f4be5ef65e73965491edd0
parent8b0fd6d04137d8c436a34f3261a0f7fa3068f891
Fix EXTRACT(ISOYEAR FROM timestamp) for years BC.

The test cases added by commit 26ae3aa80 exposed an old oversight in
timestamp[tz]_part: they didn't correct the result of date2isoyear()
for BC years, so that we produced an off-by-one answer for such years.
Fix that, and back-patch to all supported branches.

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