Add overflow checks to money type.
authorNathan Bossart <nathan@postgresql.org>
Fri, 19 Jul 2024 16:52:32 +0000 (11:52 -0500)
committerNathan Bossart <nathan@postgresql.org>
Fri, 19 Jul 2024 16:52:32 +0000 (11:52 -0500)
commite8dfe0430fad922948f56889a84af41da532c853
tree525723f2e5af399d0732e1238a66d1989cf14197
parentd42f60ccf07d89c12645efa8a41c57320d01c184
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
src/backend/utils/adt/cash.c
src/test/regress/expected/money.out
src/test/regress/sql/money.sql