pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Peter Eisentraut <peter@eisentraut.org>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Collations with nondeterministic comparison
Date: Fri, 22 Mar 2019 11:19:54 +0000
Message-ID: <E1h7IDK-0001r8-I4@gemulon.postgresql.org> (raw)

Collations with nondeterministic comparison

This adds a flag "deterministic" to collations.  If that is false,
such a collation disables various optimizations that assume that
strings are equal only if they are byte-wise equal.  That then allows
use cases such as case-insensitive or accent-insensitive comparisons
or handling of strings with different Unicode normal forms.

This functionality is only supported with the ICU provider.  At least
glibc doesn't appear to have any locales that work in a
nondeterministic way, so it's not worth supporting this for the libc
provider.

The term "deterministic comparison" in this context is from Unicode
Technical Standard #10
(https://unicode.org/reports/tr10/#Deterministic_Comparison).

This patch makes changes in three areas:

- CREATE COLLATION DDL changes and system catalog changes to support
  this new flag.

- Many executor nodes and auxiliary code are extended to track
  collations.  Previously, this code would just throw away collation
  information, because the eventually-called user-defined functions
  didn't use it since they only cared about equality, which didn't
  need collation information.

- String data type functions that do equality comparisons and hashing
  are changed to take the (non-)deterministic flag into account.  For
  comparison, this just means skipping various shortcuts and tie
  breakers that use byte-wise comparison.  For hashing, we first need
  to convert the input string to a canonical "sort key" using the ICU
  analogue of strxfrm().

Reviewed-by: Daniel Verite <daniel@manitou-mail.org>
Reviewed-by: Peter Geoghegan <pg@bowt.ie>
Discussion: https://www.postgresql.org/message-id/flat/1ccc668f-4cbc-0bef-af67-450b47cdfee7@2ndquadrant.com

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/5e1963fb764e9cc092e0f7b58b28985c311431d9

Modified Files
--------------
contrib/bloom/bloom.h                            |   1 +
contrib/bloom/blutils.c                          |   3 +-
doc/src/sgml/catalogs.sgml                       |   7 +
doc/src/sgml/charset.sgml                        |  61 +-
doc/src/sgml/citext.sgml                         |  21 +
doc/src/sgml/func.sgml                           |   6 +
doc/src/sgml/ref/create_collation.sgml           |  22 +
src/backend/access/hash/hashfunc.c               | 100 +++-
src/backend/access/spgist/spgtextproc.c          |   3 +-
src/backend/catalog/pg_collation.c               |   2 +
src/backend/commands/collationcmds.c             |  25 +-
src/backend/commands/extension.c                 |   6 +-
src/backend/executor/execExpr.c                  |   4 +-
src/backend/executor/execGrouping.c              |  14 +-
src/backend/executor/execPartition.c             |   1 +
src/backend/executor/execReplication.c           |   5 +-
src/backend/executor/nodeAgg.c                   |   9 +-
src/backend/executor/nodeGroup.c                 |   1 +
src/backend/executor/nodeHash.c                  |  14 +-
src/backend/executor/nodeHashjoin.c              |   5 +
src/backend/executor/nodeRecursiveunion.c        |   1 +
src/backend/executor/nodeSetOp.c                 |   2 +
src/backend/executor/nodeSubplan.c               |  14 +-
src/backend/executor/nodeUnique.c                |   1 +
src/backend/executor/nodeWindowAgg.c             |   2 +
src/backend/nodes/copyfuncs.c                    |   7 +
src/backend/nodes/outfuncs.c                     |   7 +
src/backend/nodes/readfuncs.c                    |   7 +
src/backend/optimizer/plan/createplan.c          |  54 +-
src/backend/optimizer/util/tlist.c               |  25 +
src/backend/partitioning/partbounds.c            |   4 +-
src/backend/partitioning/partprune.c             |   3 +-
src/backend/regex/regc_pg_locale.c               |   5 +
src/backend/utils/adt/arrayfuncs.c               |   2 +-
src/backend/utils/adt/like.c                     |  27 +-
src/backend/utils/adt/like_support.c             |  14 +
src/backend/utils/adt/name.c                     |  32 +-
src/backend/utils/adt/orderedsetaggs.c           |   3 +-
src/backend/utils/adt/pg_locale.c                |   1 +
src/backend/utils/adt/ri_triggers.c              |  33 +-
src/backend/utils/adt/varchar.c                  | 194 ++++++-
src/backend/utils/adt/varlena.c                  | 333 +++++++----
src/backend/utils/cache/catcache.c               |   9 +-
src/backend/utils/cache/lsyscache.c              |  16 +
src/bin/initdb/initdb.c                          |   4 +-
src/bin/pg_dump/pg_dump.c                        |  39 +-
src/bin/psql/describe.c                          |  17 +-
src/include/catalog/catversion.h                 |   2 +-
src/include/catalog/pg_collation.h               |   2 +
src/include/executor/executor.h                  |   4 +
src/include/executor/hashjoin.h                  |   1 +
src/include/executor/nodeHash.h                  |   2 +-
src/include/nodes/execnodes.h                    |   3 +
src/include/nodes/plannodes.h                    |   7 +
src/include/optimizer/planmain.h                 |   2 +-
src/include/optimizer/tlist.h                    |   1 +
src/include/partitioning/partbounds.h            |   1 +
src/include/utils/lsyscache.h                    |   1 +
src/include/utils/pg_locale.h                    |   1 +
src/test/regress/expected/collate.icu.utf8.out   | 710 +++++++++++++++++++++++
src/test/regress/expected/collate.linux.utf8.out |   5 +
src/test/regress/expected/collate.out            |  15 +
src/test/regress/expected/subselect.out          |  19 +
src/test/regress/sql/collate.icu.utf8.sql        | 250 ++++++++
src/test/regress/sql/collate.linux.utf8.sql      |   7 +
src/test/regress/sql/collate.sql                 |   5 +
src/test/regress/sql/subselect.sql               |  17 +
src/test/subscription/Makefile                   |   2 +
src/test/subscription/t/012_collation.pl         | 103 ++++
69 files changed, 2087 insertions(+), 239 deletions(-)



view thread (7+ messages)  latest in thread

Message-ID: <E1h7IDK-0001r8-I4@gemulon.postgresql.org>
Permalink:  ../E1h7IDK-0001r8-I4@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1h7IDK-0001r8-I4@gemulon.postgresql.org

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-committers@postgresql.org
  Cc: peter@eisentraut.org
  Subject: Re: pgsql: Collations with nondeterministic comparison
  In-Reply-To: <E1h7IDK-0001r8-I4@gemulon.postgresql.org>
  References: <E1h7IDK-0001r8-I4@gemulon.postgresql.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

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