pgsql: Fix mis-rounding and overflow hazards in date_bin().

2024-02-28 Thread Tom Lane
Fix mis-rounding and overflow hazards in date_bin(). In the case where the target timestamp is before the origin timestamp and their difference is already an exact multiple of the stride, the code incorrectly subtracted the stride anyway. Also detect several integer-overflow cases that previously

pgsql: Fix mis-rounding and overflow hazards in date_bin().

2024-02-28 Thread Tom Lane
Fix mis-rounding and overflow hazards in date_bin(). In the case where the target timestamp is before the origin timestamp and their difference is already an exact multiple of the stride, the code incorrectly subtracted the stride anyway. Also detect several integer-overflow cases that previously

pgsql: Fix mis-rounding and overflow hazards in date_bin().

2024-02-28 Thread Tom Lane
Fix mis-rounding and overflow hazards in date_bin(). In the case where the target timestamp is before the origin timestamp and their difference is already an exact multiple of the stride, the code incorrectly subtracted the stride anyway. Also detect several integer-overflow cases that previously

pgsql: Fix mis-rounding and overflow hazards in date_bin().

2024-02-28 Thread Tom Lane
Fix mis-rounding and overflow hazards in date_bin(). In the case where the target timestamp is before the origin timestamp and their difference is already an exact multiple of the stride, the code incorrectly subtracted the stride anyway. Also detect several integer-overflow cases that previously