diff options
author | Tom Lane | 2018-12-19 22:35:12 +0000 |
---|---|---|
committer | Tom Lane | 2018-12-19 22:46:25 +0000 |
commit | 586b98fdf1aaef4a27744f8b988479aad4bd9a01 (patch) | |
tree | a74687bfd94d9abc9a68c0f076aad66dbe619865 /src/include | |
parent | 68f6f2b7395fe3e403034bcd97a1fcfbcc68ae10 (diff) |
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/[email protected]
Diffstat (limited to 'src/include')
-rw-r--r-- | src/include/catalog/catversion.h | 2 | ||||
-rw-r--r-- | src/include/catalog/pg_type.dat | 2 | ||||
-rw-r--r-- | src/include/catalog/pg_type.h | 5 | ||||
-rw-r--r-- | src/include/utils/varlena.h | 2 |
4 files changed, 6 insertions, 5 deletions
diff --git a/src/include/catalog/catversion.h b/src/include/catalog/catversion.h index aa27471437a..887a620d33f 100644 --- a/src/include/catalog/catversion.h +++ b/src/include/catalog/catversion.h @@ -53,6 +53,6 @@ */ /* yyyymmddN */ -#define CATALOG_VERSION_NO 201812182 +#define CATALOG_VERSION_NO 201812191 #endif diff --git a/src/include/catalog/pg_type.dat b/src/include/catalog/pg_type.dat index d295eae1b99..7bca400ec23 100644 --- a/src/include/catalog/pg_type.dat +++ b/src/include/catalog/pg_type.dat @@ -54,7 +54,7 @@ typname => 'name', typlen => 'NAMEDATALEN', typbyval => 'f', typcategory => 'S', typelem => 'char', typinput => 'namein', typoutput => 'nameout', typreceive => 'namerecv', typsend => 'namesend', - typalign => 'c' }, + typalign => 'c', typcollation => '950' }, { oid => '20', array_type_oid => '1016', descr => '~18 digit integer, 8-byte storage', typname => 'int8', typlen => '8', typbyval => 'FLOAT8PASSBYVAL', diff --git a/src/include/catalog/pg_type.h b/src/include/catalog/pg_type.h index 05185dd809d..43bc08ee528 100644 --- a/src/include/catalog/pg_type.h +++ b/src/include/catalog/pg_type.h @@ -211,8 +211,9 @@ CATALOG(pg_type,1247,TypeRelationId) BKI_BOOTSTRAP BKI_ROWTYPE_OID(71,TypeRelati int32 typndims BKI_DEFAULT(0); /* - * Collation: 0 if type cannot use collations, DEFAULT_COLLATION_OID for - * collatable base types, possibly other OID for domains + * Collation: 0 if type cannot use collations, nonzero (typically + * DEFAULT_COLLATION_OID) for collatable base types, possibly some other + * OID for domains over collatable types */ Oid typcollation BKI_DEFAULT(0); diff --git a/src/include/utils/varlena.h b/src/include/utils/varlena.h index c776931bc48..ee3e205b7a4 100644 --- a/src/include/utils/varlena.h +++ b/src/include/utils/varlena.h @@ -17,7 +17,7 @@ #include "utils/sortsupport.h" extern int varstr_cmp(const char *arg1, int len1, const char *arg2, int len2, Oid collid); -extern void varstr_sortsupport(SortSupport ssup, Oid collid, bool bpchar); +extern void varstr_sortsupport(SortSupport ssup, Oid typeid, Oid collid); extern int varstr_levenshtein(const char *source, int slen, const char *target, int tlen, int ins_c, int del_c, int sub_c, |