Re: BUG #19771: to_char(): NUL byte in result for formats with a trailing decimal point (regression from ec352b37d)
Re: BUG #19771: to_char(): NUL byte in result for formats with a trailing decimal point (regression from ec352b37d)
От:
Tom Lane <tgl@sss.pgh.pa.us>
Дата:
Gowtham Reddy writes: > Please find attached a proposed patch for BUG #NNNNN. > It stops NUM_numpart_to_char() from emitting the number string's > terminating '\0' as a digit, and adds a regression test to numeric.sql > (the test fails without the fix). make check passes (239/239) on > master 45fc51fcbf45. > Tom, CCing you since this became visible with ec352b37d. That's definitely a bug, but on what basis do you say that it wasn't visible before ec352b37d? AFAICT it's ancient. I get this as far back as 9.2, for instance: regression=# select to_char(7, 'FM99.SG') AS d; d --- 7 (1 row) Normally I'd think we should back-patch, but it's possible that people didn't realize this behavior was unintended --- else we'd have heard bug reports sooner. (It's not instantly obvious that we should drop the decimal point but not the sign, I think.) So I'm inclined to leave the stable branches alone. Maybe there's still room to squeeze the fix into v19, though. regards, tom lane
Re: BUG #19771: to_char(): NUL byte in result for formats with a trailing decimal point (regression from ec352b37d)
От:
Tom Lane <tgl@sss.pgh.pa.us>
Дата:
I wrote: > Normally I'd think we should back-patch, but it's possible that > people didn't realize this behavior was unintended --- else we'd > have heard bug reports sooner. (It's not instantly obvious that > we should drop the decimal point but not the sign, I think.) > So I'm inclined to leave the stable branches alone. Maybe there's > still room to squeeze the fix into v19, though. Hearing no objections, pushed to 19 and master only. A fair question about this is why dropping the decimal point is a good idea at all. Maybe the actual bug is that there's not a decimal point available in the input string. But that would be a bigger behavioral change, and again we've heard no complaints in this area. Even if we did change how the initial conversion works, this patch would remain a good safety feature, so I'm content for now to do this and stop here. regards, tom lane
Re: BUG #19771: to_char(): NUL byte in result for formats with a trailing decimal point (regression from ec352b37d)
От:
Gowtham Reddy <gowthamdoma18@gmail.com>
Дата:
Hi Tom, Thank you for committing this, and for the explanation about the back-branches. I understand the reasoning for leaving the decimal-point question as it is for now. Regards, Gowtham On Tue, 20 Oct 2026 at 22:33, Tom Lane wrote: > > I wrote: > > Normally I'd think we should back-patch, but it's possible that > > people didn't realize this behavior was unintended --- else we'd > > have heard bug reports sooner. (It's not instantly obvious that > > we should drop the decimal point but not the sign, I think.) > > So I'm inclined to leave the stable branches alone. Maybe there's > > still room to squeeze the fix into v19, though. > > Hearing no objections, pushed to 19 and master only. > > A fair question about this is why dropping the decimal point is a good > idea at all. Maybe the actual bug is that there's not a decimal point > available in the input string. But that would be a bigger behavioral > change, and again we've heard no complaints in this area. Even if we > did change how the initial conversion works, this patch would remain a > good safety feature, so I'm content for now to do this and stop here. > > regards, tom lane