Fix EXTRACT(ISOYEAR FROM timestamp) for years BC.

Tom Lane <tgl@sss.pgh.pa.us>

Commit: 323c47925af9e53c4c0476553e3e13a86f3d8173
Author: Tom Lane <tgl@sss.pgh.pa.us>
Date: 2019-12-12T17:30:44Z
Releases: 9.5.21
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

Files

Discussion