Catch overflow when rounding intervals in AdjustIntervalForTypmod.
Tom Lane <tgl@sss.pgh.pa.us>
Catch overflow when rounding intervals in AdjustIntervalForTypmod. Previously, an interval microseconds field close to INT64_MAX or INT64_MIN could overflow, producing a result with not even the correct sign, while being rounded to match a precision specification. This seems worth fixing, but not worth back-patching, in part because the ereturn() notation doesn't exist very far back. Report and patch by Joseph Koshakow (some cosmetic mods by me) Discussion: https://postgr.es/m/CAAvxfHfpuLgqJYzkUcher466Z1LpmE+5Sm+zc8L6zKCOQ+6TDQ@mail.gmail.com
Files
| Path | Change | +/− |
|---|---|---|
| src/backend/utils/adt/timestamp.c | modified | +14 −8 |
| src/test/regress/expected/interval.out | modified | +8 −0 |
| src/test/regress/sql/interval.sql | modified | +2 −0 |
Discussion
- Fix overflow hazard in interval rounding 6 messages · 2024-02-13 → 2024-06-02