model-writtenrun 8544 - may be wrong, links go to the source messages. Commit-by-commit LLM analysis is in the Commits dialog.
- Jianqiao Han proposed detecting a significand that rounds up to ten, incrementing the exponent, and recomputing the significand, with numeric and bigint regression tests, after finding that to_char(999::numeric, '9.9EEEE') produced unnormalized output #1.
- Tom Lane accepted the simple recomputation approach but asked whether rounding could instead produce a leading zero #2; Han explained that a nonzero input's scaled magnitude stays between one and ten after rounding, ruling out that reverse problem #3.
- Dean Rasheed confirmed the patch looked correct and proposed assertions plus directly changing the rounded significand from ten to one to document the algorithm without another division #4, then noted that alternative NBASE values would complicate that approach #5.
- Tom Lane favored retaining Han's straightforward implementation #6, and Dean accepted its simplicity while rejecting the need to replace the conditional with a loop #7.
- Tom Lane committed #1 as 68b927397e, preserving its executable logic while revising the comment, simplifying the tests, and documenting the expected scientific notation; the commit specifies backpatching through PostgreSQL 15, and his final announcement leaves no outstanding patch work #8.