Marti Raudsepp <ma...@juffo.org> writes:
> This patch fixes an edge case bug in the numeric to_char() function.

> When the numeric to_char format used fillmode (FM), didn't contain 0s
> and had a trailing dot, the integer part of the number was truncated in
> error.

> to_char(10, 'FM99.') used to return '1', after this patch it will return '10'


Hmm.  I agree that this is a bug, but the proposed fix seems like a bit
of a kluge.  Wouldn't it be better to make get_last_relevant_decnum
honor its contract, that is not delete any relevant digits?  I'm
thinking instead of this

        if (!p)
                p = num;

when there is no decimal point it should do something like

        if (!p)
                return num + strlen(num) - 1;

                        regards, tom lane

-- 
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

Reply via email to