Handle integer overflow in interval justification functions.
Tom Lane <tgl@sss.pgh.pa.us>
Handle integer overflow in interval justification functions. justify_interval, justify_hours, and justify_days didn't check for overflow when promoting hours to days or days to months; but that's possible when the upper field's value is already large. Detect and report any such overflow. Also, we can avoid unnecessary overflow in some cases in justify_interval by pre-justifying the days field. (Thanks to Nathan Bossart for this idea.) Joe Koshakow Discussion: https://postgr.es/m/CAAvxfHeNqsJ2xYFbPUf_8nNQUiJqkag04NW6aBQQ0dbZsxfWHA@mail.gmail.com
Files
| Path | Change | +/− |
|---|---|---|
| src/backend/utils/adt/timestamp.c | modified | +31 −4 |
| src/test/regress/expected/interval.out | modified | +36 −0 |
| src/test/regress/sql/interval.sql | modified | +12 −0 |
Discussion
- Fix overflow in justify_interval related functions 12 messages · 2022-02-13 → 2022-02-28