Collation patch's handling of wcstombs/mbstowcs is sheerest fantasy

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Collation patch's handling of wcstombs/mbstowcs is sheerest fantasy
Дата
Msg-id 9844.1303504350@sss.pgh.pa.us
обсуждение исходный текст
Ответы Re: Collation patch's handling of wcstombs/mbstowcs is sheerest fantasy  (Tom Lane <tgl@sss.pgh.pa.us>)
Re: Collation patch's handling of wcstombs/mbstowcs is sheerest fantasy  (Peter Eisentraut <peter_e@gmx.net>)
Список pgsql-hackers
I just noticed that the collation patch has modified char2wchar and
wchar2char to accept a collation OID as argument ... but it hasn't done
anything to make those arguments actually work.  Since those functions
depend on wcstombs and mbstowcs, which respond to LC_CTYPE and nothing
else, this flat out does not work in non-default collations.  What's
more, there doesn't seem to be any such thing as wcstombs_l or
mbstowcs_l (at least my Fedora box hasn't got them), so this can't be
fixed within the available glibc API.

Right at the moment this only affects str_tolower, str_toupper, and
str_initcap; there are other uses of these functions in the text search
code, but those always pass DEFAULT_COLLATION_OID.

It's possible that things are not too broken in practice, because it's
likely that the transformations done by these functions only depend on
the encoding indicated by LC_CTYPE, and we (try to) enforce that all
locales used in a given database match the database encoding.  Still,
that's a rather shaky chain of reasoning.

The complete lack of code comments on this doesn't make me any happier
--- in fact, the comments for char2wchar and wchar2char still claim that
they have the same API as wcstombs and mbstowcs, which can hardly be
considered true when they don't even have the same argument lists.

Any thoughts what to do about this?
        regards, tom lane


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

Предыдущее
От: Merlin Moncure
Дата:
Сообщение: Re: "stored procedures"
Следующее
От: Tom Lane
Дата:
Сообщение: Re: "stored procedures"