Add overflow checks to money type.
Nathan Bossart <nathan@postgresql.org>
Add overflow checks to money type. None of the arithmetic functions for the the money type handle overflow. This commit introduces several helper functions with overflow checking and makes use of them in the money type's arithmetic functions. Fixes bug #18240. Reported-by: Alexander Lakhin Author: Joseph Koshakow Discussion: https://postgr.es/m/18240-c5da758d7dc1ecf0%40postgresql.org Discussion: https://postgr.es/m/CAAvxfHdBPOyEGS7s%2Bxf4iaW0-cgiq25jpYdWBqQqvLtLe_t6tw%40mail.gmail.com Backpatch-through: 12
Files
| Path | Change | +/− |
|---|---|---|
| src/backend/utils/adt/cash.c | modified | +94 −80 |
| src/test/regress/expected/money.out | modified | +19 −0 |
| src/test/regress/sql/money.sql | modified | +11 −0 |
Discussion
- BUG #18240: Undefined behaviour in cash_mul_flt8() and friends 24 messages · 2023-12-11 → 2024-07-19
- Remove dependence on integer wrapping 85 messages · 2024-06-09 → 2024-12-09