pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Make type "name" collation-aware.
Date: Wed, 19 Dec 2018 22:46:34 +0000
Message-ID: <E1gZkbq-0005XP-Og@gemulon.postgresql.org> (raw)

Make type "name" collation-aware.

The "name" comparison operators now all support collations, making them
functionally equivalent to "text" comparisons, except for the different
physical representation of the datatype.  They do, in fact, mostly share
the varstr_cmp and varstr_sortsupport infrastructure, which has been
slightly enlarged to handle the case.

To avoid changes in the default behavior of the datatype, set name's
typcollation to C_COLLATION_OID not DEFAULT_COLLATION_OID, so that
by default comparisons to a name value will continue to use strcmp
semantics.  (This would have been the case for system catalog columns
anyway, because of commit 6b0faf723, but doing this makes it true for
user-created name columns as well.  In particular, this avoids
locale-dependent changes in our regression test results.)

In consequence, tweak a couple of places that made assumptions about
collatable base types always having typcollation DEFAULT_COLLATION_OID.
I have not, however, attempted to relax the restriction that user-
defined collatable types must have that.  Hence, "name" doesn't
behave quite like a user-defined type; it acts more like a domain
with COLLATE "C".  (Conceivably, if we ever get rid of the need for
catalog name columns to be fixed-length, "name" could actually become
such a domain over text.  But that'd be a pretty massive undertaking,
and I'm not volunteering.)

Discussion: https://postgr.es/m/15938.1544377821@sss.pgh.pa.us

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/586b98fdf1aaef4a27744f8b988479aad4bd9a01

Modified Files
--------------
doc/src/sgml/catalogs.sgml             |   8 +--
src/backend/access/nbtree/nbtcompare.c |  27 -------
src/backend/bootstrap/bootstrap.c      |   2 +-
src/backend/commands/explain.c         |  11 +--
src/backend/nodes/nodeFuncs.c          |  10 ++-
src/backend/optimizer/path/indxpath.c  |   2 +-
src/backend/parser/parse_clause.c      |   2 +-
src/backend/utils/adt/name.c           |  80 ++++++++++++++++-----
src/backend/utils/adt/selfuncs.c       |  44 +++++++-----
src/backend/utils/adt/varchar.c        |   5 +-
src/backend/utils/adt/varlena.c        | 126 +++++++++++++++++++++++----------
src/include/catalog/catversion.h       |   2 +-
src/include/catalog/pg_type.dat        |   2 +-
src/include/catalog/pg_type.h          |   5 +-
src/include/utils/varlena.h            |   2 +-
src/pl/plpgsql/src/pl_comp.c           |   8 +--
16 files changed, 211 insertions(+), 125 deletions(-)



Message-ID: <E1gZkbq-0005XP-Og@gemulon.postgresql.org>
Permalink:  ../E1gZkbq-0005XP-Og@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1gZkbq-0005XP-Og@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: tgl@sss.pgh.pa.us
  Subject: Re: pgsql: Make type "name" collation-aware.
  In-Reply-To: <E1gZkbq-0005XP-Og@gemulon.postgresql.org>
  References: <E1gZkbq-0005XP-Og@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