From: Robert Haas Date: Tue, 6 Jun 2017 15:07:20 +0000 (-0400) Subject: Clean up partcollation handling for OID 0. X-Git-Tag: REL_10_BETA2~219 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=2186b608b3cb859fe0ec04015a5c4e4cbf69caed;p=postgresql Clean up partcollation handling for OID 0. Consistent with what we do for indexes, we shouldn't try to record dependencies on collation OID 0 or the default collation OID (which is pinned). Also, the fact that indcollation and partcollation can contain zero OIDs when the data type is not collatable should be documented. Amit Langote, per a complaint from me. Discussion: http://postgr.es/m/CA+Tgmoba5mtPgM3NKfG06vv8na5gGbVOj0h4zvivXQwLw8wXXQ@mail.gmail.com --- diff --git a/doc/src/sgml/catalogs.sgml b/doc/src/sgml/catalogs.sgml index 5723be744d..61ce12c560 100644 --- a/doc/src/sgml/catalogs.sgml +++ b/doc/src/sgml/catalogs.sgml @@ -3783,7 +3783,8 @@ SCRAM-SHA-256$<iteration count>:<salt>< pg_collation.oid For each column in the index key, this contains the OID of the - collation to use for the index. + the collation to use for the index, or zero if the column is not + of a collatable data type. @@ -4770,7 +4771,8 @@ SCRAM-SHA-256$<iteration count>:<salt>< pg_opclass.oid For each column in the partition key, this contains the OID of the - the collation to use for partitioning. + the collation to use for partitioning, or zero if the column is not + of a collatable data type. diff --git a/src/backend/catalog/heap.c b/src/backend/catalog/heap.c index 0ce94f346f..4e5b79ef94 100644 --- a/src/backend/catalog/heap.c +++ b/src/backend/catalog/heap.c @@ -3160,9 +3160,14 @@ StorePartitionKey(Relation rel, recordDependencyOn(&myself, &referenced, DEPENDENCY_NORMAL); - referenced.classId = CollationRelationId; - referenced.objectId = partcollation[i]; - referenced.objectSubId = 0; + /* The default collation is pinned, so don't bother recording it */ + if (OidIsValid(partcollation[i]) && + partcollation[i] != DEFAULT_COLLATION_OID) + { + referenced.classId = CollationRelationId; + referenced.objectId = partcollation[i]; + referenced.objectSubId = 0; + } recordDependencyOn(&myself, &referenced, DEPENDENCY_NORMAL); }