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 collation-aware system catalog columns use "C" collation.
Date: Tue, 18 Dec 2018 17:48:23 +0000
Message-ID: <E1gZJTj-0004pv-WA@gemulon.postgresql.org> (raw)

Make collation-aware system catalog columns use "C" collation.

Up to now we allowed text columns in system catalogs to use collation
"default", but that isn't really safe because it might mean something
different in template0 than it means in a database cloned from template0.
In particular, this could mean that cloned pg_statistic entries for such
columns weren't entirely valid, possibly leading to bogus planner
estimates, though (probably) not any outright failures.

In the wake of commit 5e0928005, a better solution is available: if we
label such columns with "C" collation, then their pg_statistic entries
will also use that collation and hence will be valid independently of
the database collation.

This also provides a cleaner solution for indexes on such columns than
the hack added by commit 0b28ea79c: the indexes will naturally inherit
"C" collation and don't have to be forced to use text_pattern_ops.

Also, with the planned improvement of type "name" to be collation-aware,
this policy will apply cleanly to both text and name columns.

Because of the pg_statistic angle, we should also apply this policy
to the tables in information_schema.  This patch does that by adjusting
information_schema's textual domain types to specify "C" collation.
That has the user-visible effect that order-sensitive comparisons to
textual information_schema view columns will now use "C" collation
by default.  The SQL standard says that the collation of those view
columns is implementation-defined, so I think this is legal per spec.
At some point this might allow for translation of such comparisons
into indexable conditions on the underlying "name" columns, although
additional work will be needed before that can happen.

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

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/6b0faf723647a851eaaddfed11e14861f8d0f588

Modified Files
--------------
src/backend/access/common/scankey.c        |  8 ++++----
src/backend/bootstrap/bootstrap.c          |  9 +++++++++
src/backend/catalog/genbki.pl              |  8 +++++++-
src/backend/catalog/information_schema.sql |  6 +++---
src/backend/utils/cache/catcache.c         | 13 +++++++------
src/include/catalog/catversion.h           |  2 +-
src/include/catalog/indexing.h             |  6 +++---
src/test/regress/expected/opr_sanity.out   | 21 ++++++++++++++-------
src/test/regress/sql/opr_sanity.sql        | 19 ++++++++++++-------
9 files changed, 60 insertions(+), 32 deletions(-)



Message-ID: <E1gZJTj-0004pv-WA@gemulon.postgresql.org>
Permalink:  ../E1gZJTj-0004pv-WA@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1gZJTj-0004pv-WA@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 collation-aware system catalog columns use "C" collation.
  In-Reply-To: <E1gZJTj-0004pv-WA@gemulon.postgresql.org>
  References: <E1gZJTj-0004pv-WA@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