Modernize to_char's Roman-numeral code, fixing overflow problems.
Tom Lane <tgl@sss.pgh.pa.us>
Modernize to_char's Roman-numeral code, fixing overflow problems. int_to_roman() only accepts plain "int" input, which is fine since we're going to produce '###############' for any value above 3999 anyway. However, the numeric and int8 variants of to_char() would throw an error if the given input exceeded the integer range, while the float-input variants invoked undefined-per-C-standard behavior. Fix things so that you uniformly get '###############' for out of range input. Also add test cases covering this code, plus the equally-untested EEEE, V, and PL format codes. Discussion: https://postgr.es/m/2956175.1725831136@sss.pgh.pa.us
Files
| Path | Change | +/− |
|---|---|---|
| doc/src/sgml/func.sgml | modified | +2 −0 |
| src/backend/utils/adt/formatting.c | modified | +69 −23 |
| src/test/regress/expected/int8.out | modified | +50 −0 |
| src/test/regress/expected/numeric.out | modified | +87 −0 |
| src/test/regress/sql/int8.sql | modified | +8 −0 |
| src/test/regress/sql/numeric.sql | modified | +15 −0 |
Documentation touched
Discussion
- Test improvements and minor code fixes for formatting.c. 7 messages · 2024-09-08 → 2024-09-26