Fix to_char() for number formats ending in a decimal point. When a number format has a decimal point with no digit positions after it (e.g. '9.' or 'FM999.PL'), NUM_numpart_to_char() copied the terminating '\0' of the number string into the output as if it were a digit, resulting in apparent truncation of the output; for example, a sign or literal text following the decimal point would disappear. Fix it by not copying the '\0'.
This is clearly a bug, but given the lack of field complaints, people who have run into it may think it's expected behavior, and may even have written applications that depend on it. Therefore it seems unwise to change it in stable branches. I (tgl) think it's not too late to fix it in v19 though. Bug: #19771 Author: Gowtham Reddy <[email protected]> Reviewed-by: Tom Lane <[email protected]> Discussion: https://postgr.es/m/[email protected] Backpatch-through: 19 Branch ------ master Details ------- https://git.postgresql.org/pg/commitdiff/776df8a6d7c42282825d658ff631509f033e8f34 Modified Files -------------- src/backend/utils/adt/formatting.c | 4 ++-- src/test/regress/expected/numeric.out | 6 ++++++ src/test/regress/sql/numeric.sql | 1 + 3 files changed, 9 insertions(+), 2 deletions(-)
