Re: [PATCH] Don't truncate integer part in to_char for 'FM99.'

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: [PATCH] Don't truncate integer part in to_char for 'FM99.'
Дата
Msg-id 26932.1315420647@sss.pgh.pa.us
обсуждение исходный текст
Ответ на [PATCH] Don't truncate integer part in to_char for 'FM99.'  (Marti Raudsepp <marti@juffo.org>)
Ответы Re: [PATCH] Don't truncate integer part in to_char for 'FM99.'
Список pgsql-hackers
Marti Raudsepp <marti@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


В списке pgsql-hackers по дате отправления:

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: custom variables and PGC_SUSET issue
Следующее
От: Bruce Momjian
Дата:
Сообщение: Re: [GENERAL] pg_upgrade problem