Fix float4/8 to handle Infinity and Nan consistently, e.g. Infinity is a
Bruce Momjian <bruce@momjian.us>
Fix float4/8 to handle Infinity and Nan consistently, e.g. Infinity is a valid result from a computation if one of the input values was infinity. The previous code assumed an operation that returned infinity was an overflow. Handle underflow/overflow consistently, and add checks for aggregate overflow. Consistently prevent Inf/Nan from being cast to integer data types. Fix INT_MIN % -1 to prevent overflow. Update regression results for new error text. Per report from Roman Kononov.
Files
| Path | Change | +/− |
|---|---|---|
| src/backend/utils/adt/float.c | modified | +147 −225 |
| src/backend/utils/adt/int.c | modified | +6 −1 |
| src/test/regress/expected/float4-exp-three-digits.out | modified | +13 −9 |
| src/test/regress/expected/float4.out | modified | +13 −9 |
| src/test/regress/expected/float8-exp-three-digits-win32.out | modified | +8 −4 |
| src/test/regress/expected/float8.out | modified | +8 −4 |
| src/test/regress/expected/float8-small-is-zero_1.out | modified | +8 −4 |
| src/test/regress/expected/float8-small-is-zero.out | modified | +8 −4 |
| src/test/regress/sql/float4.sql | modified | +4 −4 |