pgsql: Fix to_number() to correctly ignore thousands separator when it'

Поиск
Список
Период
Сортировка
От Tom Lane
Тема pgsql: Fix to_number() to correctly ignore thousands separator when it'
Дата
Msg-id E1UbGVY-0002tP-8Q@gemulon.postgresql.org
обсуждение исходный текст
Список pgsql-committers
Fix to_number() to correctly ignore thousands separator when it's '.'.

The existing code in NUM_numpart_from_char has hard-wired logic to treat
'.' as decimal point, even when we're using a locale-aware format string
and the locale says that '.' is the thousands separator.  This results in
clearly wrong answers in FM mode (where we must be able to identify the
decimal point location), as per bug report from Patryk Kordylewski.

Since the initialization code in NUM_prepare_locale already sets up
Np->decimal as either the locale decimal-point string or "." depending
on which decimal-point format code was used, there's really no need to
have any extra logic at all in NUM_numpart_from_char: we only need to
test for a match to Np->decimal.

(Note: AFAICS there's nothing in here that explicitly checks for thousands
separators --- rather, any unmatched character is silently skipped over.
That's pretty bogus IMO but it's not the issue being complained of.)

This is a longstanding bug, but it's possible that some existing apps
are depending on '.' being recognized as decimal point even when using
a D format code.  Hence, no back-patch.  We should probably list this
as a potential incompatibility in the 9.3 release notes.

Branch
------
master

Details
-------
http://git.postgresql.org/pg/commitdiff/35d50b527a9f99e22a317269ceb00491397d0e00

Modified Files
--------------
src/backend/utils/adt/formatting.c |   36 ++++++++++++------------------------
1 files changed, 12 insertions(+), 24 deletions(-)


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

Предыдущее
От: Tom Lane
Дата:
Сообщение: pgsql: Fix buildfarm incompatibility in updated pg_upgrade test script.
Следующее
От: pgsql@postgresql.org
Дата:
Сообщение: pgsql: Tag refs/tags/REL9_3_BETA1 was created