Support C.UTF-8 locale in the new builtin collation provider.
Jeff Davis <jdavis@postgresql.org>
Support C.UTF-8 locale in the new builtin collation provider. The builtin C.UTF-8 locale has similar semantics to the libc locale of the same name. That is, code point sort order (fast, memcmp-based) combined with Unicode semantics for character operations such as pattern matching, regular expressions, and LOWER()/INITCAP()/UPPER(). The character semantics are based on Unicode simple case mappings. The builtin provider's C.UTF-8 offers several important advantages over libc: * faster sorting -- benefits from additional optimizations such as abbreviated keys and varstrfastcmp_c * faster case conversion, e.g. LOWER(), at least compared with some libc implementations * available on all platforms with identical semantics, and the semantics are stable, testable, and documentable within a given Postgres major version Being based on memcmp, the builtin C.UTF-8 locale does not offer natural language sort order. But it is an improvement for most use cases that might otherwise use libc's "C.UTF-8" locale, as well as many use cases that use libc's "C" locale. Discussion: https://postgr.es/m/ff4c2f2f9c8fc7ca27c1c24ae37ecaeaeaff6b53.camel%40j-davis.com Reviewed-by: Daniel Vérité, Peter Eisentraut, Jeremy Schneider
Files
| Path | Change | +/− |
|---|---|---|
| doc/src/sgml/charset.sgml | modified | +26 −1 |
| doc/src/sgml/ref/create_collation.sgml | modified | +1 −1 |
| doc/src/sgml/ref/create_database.sgml | modified | +8 −5 |
| doc/src/sgml/ref/initdb.sgml | modified | +3 −2 |
| src/backend/regex/regc_pg_locale.c | modified | +35 −1 |
| src/backend/utils/adt/formatting.c | modified | +112 −0 |
| src/backend/utils/adt/pg_locale.c | modified | +41 −11 |
| src/bin/initdb/initdb.c | modified | +15 −1 |
| src/bin/initdb/t/001_initdb.pl | modified | +17 −0 |
| src/bin/pg_upgrade/t/002_pg_upgrade.pl | modified | +1 −1 |
| src/bin/scripts/t/020_createdb.pl | modified | +18 −0 |
| src/include/catalog/catversion.h | modified | +1 −1 |
| src/include/catalog/pg_collation.dat | modified | +3 −0 |
| src/test/regress/expected/collate.utf8_1.out | added | +8 −0 |
| src/test/regress/expected/collate.utf8.out | added | +136 −0 |
| src/test/regress/parallel_schedule | modified | +2 −2 |
| src/test/regress/sql/collate.utf8.sql | added | +67 −0 |
Documentation touched
Discussion
- Built-in CTYPE provider 125 messages · 2023-12-05 → 2024-07-26