Re: Collatability of type "name"

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Robert Haas <robertmhaas(at)gmail(dot)com>
Cc: PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: Collatability of type "name"
Date: 2018-12-19 19:02:07
Message-ID: 18204.1545246127@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

I wrote:
> We could eliminate those two problems if we made "name" have
> typcollation "C" rather than "default", so that its semantics
> wouldn't change without explicit collation specs. This feels
> like pretty much of a wart to me, but maybe it's worth doing
> in the name of avoiding compatibility issues. We could still
> unify name_ops with text_ops, but now "name" would act more like
> a domain with an explicit collation spec.

Here's a variant patch that does it like that. On reflection this seems
like a safer way to proceed. It feels like a wart because it violates
the system's original assumption that collatable base types all have
DEFAULT_COLLATION_OID, but as far as I can tell that doesn't have any
really severe consequences. The main ugliness is that CREATE TYPE can
only set typcollation to 0 or DEFAULT_COLLATION_OID for new base types,
meaning that it's impossible to duplicate the behavior of type "name"
in a user-defined type, which seems like an extensibility failure.
But it's not one that I'm sufficiently excited about to wish to fix.
Another point is that there are places in parse_collate.c that suppose
that "domain's typcollation is different from DEFAULT_COLLATION_OID"
is equivalent to "domain's collation was explicitly specified", which
would not be the case for domains over type name. But this seems to be
isomorphic to the situation where "name" is a domain with COLLATE "C"
over some anonymous base type, so I don't think that any fundamental
semantic breakage ensues.

Barring objections I'm going to push forward with committing this and
unifying name_ops with text_ops.

regards, tom lane

Attachment Content-Type Size
make-type-name-collatable-2.patch text/x-diff 26.0 KB

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Magnus Hagander 2018-12-19 19:02:44 Re: Remove Deprecated Exclusive Backup Mode
Previous Message Darafei Komяpa Praliaskouski 2018-12-19 18:37:00 Re: What to name the current heap after pluggable storage / what to rename?