Fix EXTRACT(ISOYEAR FROM timestamp) for years BC.
authorTom Lane
Thu, 12 Dec 2019 17:30:44 +0000 (12:30 -0500)
committerTom Lane
Thu, 12 Dec 2019 17:30:44 +0000 (12:30 -0500)
commit07c4b6ac7d6e467f9db681772b5d5101144fcfe7
tree457c55e4dda6a6e7d2229d3d42a2c2cbcf956fc0
parent73355634959bc011508a24f0e344c6f6fddf419e
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