From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
---|---|
To: | pgsql-committers(at)postgresql(dot)org |
Subject: | pgsql: Fix char2wchar/wchar2char to support collations properly. |
Date: | 2011-04-23 16:36:07 |
Message-ID: | E1QDfoV-0002Kb-5D@gemulon.postgresql.org |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-committers |
Fix char2wchar/wchar2char to support collations properly.
These functions should take a pg_locale_t, not a collation OID, and should
call mbstowcs_l/wcstombs_l where available. Where those functions are not
available, temporarily select the correct locale with uselocale().
This change removes the bogus assumption that all locales selectable in
a given database have the same wide-character conversion method; in
particular, the collate.linux.utf8 regression test now passes with
LC_CTYPE=C, so long as the database encoding is UTF8.
I decided to move the char2wchar/wchar2char functions out of mbutils.c and
into pg_locale.c, because they work on wchar_t not pg_wchar_t and thus
don't really belong with the mbutils.c functions. Keeping them where they
were would have required importing pg_locale_t into pg_wchar.h somehow,
which did not seem like a good plan.
Branch
------
master
Details
-------
http://git.postgresql.org/pg/commitdiff/2ab0796d7a3a7116a79b65531fd33f1548514b52
Modified Files
--------------
configure | 3 +-
configure.in | 2 +-
src/backend/tsearch/ts_locale.c | 17 +++--
src/backend/tsearch/wparser_def.c | 6 +-
src/backend/utils/adt/formatting.c | 16 ++--
src/backend/utils/adt/pg_locale.c | 173 ++++++++++++++++++++++++++++++++++++
src/backend/utils/mb/mbutils.c | 121 -------------------------
src/include/mb/pg_wchar.h | 7 --
src/include/pg_config.h.in | 3 +
src/include/pg_config.h.win32 | 3 +
src/include/port/win32.h | 2 +
src/include/utils/pg_locale.h | 8 ++
12 files changed, 217 insertions(+), 144 deletions(-)
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 2011-04-23 16:52:18 | pgsql: Adjust comments about collate.linux.utf8 regression test. |
Previous Message | Tom Lane | 2011-04-23 00:20:10 | pgsql: Fix contrib/btree_gist to handle collations properly. |