Re: BUG #18240: Undefined behaviour in cash_mul_flt8() and friends
Tom Lane <tgl@sss.pgh.pa.us>
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Michael Paquier <michael@paquier.xyz>
Cc: exclusion@gmail.com, pgsql-bugs@lists.postgresql.org
Date: 2023-12-11T15:05:53Z
Lists: pgsql-bugs
Michael Paquier <michael@paquier.xyz> writes: > On Mon, Dec 11, 2023 at 06:00:02AM +0000, PG Bug reporting form wrote: >> The following multiplication: >> SELECT 1_000_000_000::money * 1_000_000_000::float8; >> gives the incorrect result: >> -$92,233,720,368,547,758.08 > Yep, good catch. Reproduced here. Yeah, approximately none of cash.c pays any attention to the risks of overflow/underflow. Improving that situation would be a good finger exercise for some aspiring hacker, perhaps. Although I bet somebody will ask again why it is that we continue to support the money type. regards, tom lane
Commits
-
Add overflow checks to money type.
- e8dfe0430fad 14.13 landed
- c5321e9651c5 13.16 landed
- b82791c8fc2c 15.8 landed
- 4f962815871f 12.20 landed
- 3764ee47f78c 17.0 landed
- 34e9dce69c46 16.4 landed
- 22b0ccd65d27 18.0 landed
-
Reduce dependency to money data type in main regression test suite
- 31acee4b66f9 17.0 landed