pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
pgsql: Support C.UTF-8 locale in the new builtin collation provider.
3+ messages / 3 participants
[nested] [flat]

Commits from this thread:
  2024-05-07 832c4f657f  Remove obsolete comment.
* pgsql: Support C.UTF-8 locale in the new builtin collation provider.
@ 2024-03-19 22:29  Jeff Davis <jdavis@postgresql.org>
  0 siblings, 1 reply; 3+ messages in thread

From: Jeff Davis @ 2024-03-19 22:29 UTC (permalink / raw)
  To: pgsql-committers@lists.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

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/f69319f2f1fb16eda4b535bcccec90dff3a6795e

Modified Files
--------------
doc/src/sgml/charset.sgml                    |  27 +++++-
doc/src/sgml/ref/create_collation.sgml       |   2 +-
doc/src/sgml/ref/create_database.sgml        |  13 ++-
doc/src/sgml/ref/initdb.sgml                 |   5 +-
src/backend/regex/regc_pg_locale.c           |  36 ++++++-
src/backend/utils/adt/formatting.c           | 112 ++++++++++++++++++++++
src/backend/utils/adt/pg_locale.c            |  52 +++++++---
src/bin/initdb/initdb.c                      |  16 +++-
src/bin/initdb/t/001_initdb.pl               |  17 ++++
src/bin/pg_upgrade/t/002_pg_upgrade.pl       |   2 +-
src/bin/scripts/t/020_createdb.pl            |  18 ++++
src/include/catalog/catversion.h             |   2 +-
src/include/catalog/pg_collation.dat         |   3 +
src/test/regress/expected/collate.utf8.out   | 136 +++++++++++++++++++++++++++
src/test/regress/expected/collate.utf8_1.out |   8 ++
src/test/regress/parallel_schedule           |   4 +-
src/test/regress/sql/collate.utf8.sql        |  67 +++++++++++++
17 files changed, 494 insertions(+), 26 deletions(-)



^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* Re: pgsql: Support C.UTF-8 locale in the new builtin collation provider.
@ 2024-05-02 07:34  Peter Eisentraut <peter@eisentraut.org>
  parent: Jeff Davis <jdavis@postgresql.org>
  0 siblings, 1 reply; 3+ messages in thread

From: Peter Eisentraut @ 2024-05-02 07:34 UTC (permalink / raw)
  To: Jeff Davis <jdavis@postgresql.org>; pgsql-committers@lists.postgresql.org

On 19.03.24 23:29, Jeff Davis wrote:
> Support C.UTF-8 locale in the new builtin collation provider.

This commit changed the functions builtin_locale_encoding() and 
builtin_validate_locale() in pg_locale.c, but did not update the 
comments that claim that "C" is the only supported locale name.

(I think it would be best to remove the comment altogether and let the 
code speak for itself.)





^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* Re: pgsql: Support C.UTF-8 locale in the new builtin collation provider.
@ 2024-05-07 18:59  Jeff Davis <pgsql@j-davis.com>
  parent: Peter Eisentraut <peter@eisentraut.org>
  0 siblings, 0 replies; 3+ messages in thread

From: Jeff Davis @ 2024-05-07 18:59 UTC (permalink / raw)
  To: Peter Eisentraut <peter@eisentraut.org>; Jeff Davis <jdavis@postgresql.org>; pgsql-committers@lists.postgresql.org

On Thu, 2024-05-02 at 09:34 +0200, Peter Eisentraut wrote:
> This commit changed the functions builtin_locale_encoding() and 
> builtin_validate_locale() in pg_locale.c, but did not update the 
> comments that claim that "C" is the only supported locale name.
> 
> (I think it would be best to remove the comment altogether and let
> the 
> code speak for itself.)

Thank you, committed.

Regards,
	Jeff Davis






^ permalink  raw  reply  [nested|flat] 3+ messages in thread


end of thread, other threads:[~2024-05-07 18:59 UTC | newest]

Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2024-03-19 22:29 pgsql: Support C.UTF-8 locale in the new builtin collation provider. Jeff Davis <jdavis@postgresql.org>
2024-05-02 07:34 ` Peter Eisentraut <peter@eisentraut.org>
2024-05-07 18:59   ` Jeff Davis <pgsql@j-davis.com>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox