56.12. pg_collation #

В каталоге pg_collation описываются доступные правила сортировки, которые по сути представляют собой сопоставления идентификаторов SQL с категориями локалей операционной системы. За дополнительными сведениями обратитесь к Разделу 22.2. Используется в качестве источника информации при запуске команды shardmanctl schema verify --filter collations.

Таблица 56.12. Столбцы pg_collation

Тип столбца

Описание

oid oid

Идентификатор строки

collname name

Имя правила сортировки (уникальное для пространства имён и кодировки)

collnamespace oid (ссылается на pg_namespace.oid)

OID пространства имён, содержащего это правило сортировки

collowner oid (ссылается на pg_authid.oid)

Владелец правила сортировки

collprovider char

Провайдер правила сортировки: d = установленный в базе по умолчанию, b = builtin (встроенный), c = libc, i = icu

collisdeterministic bool

Является ли правило сортировки детерминированным?

collencoding int4

Кодировка, для которой применимо это правило, или -1, если оно работает с любой кодировкой

collcollate text

LC_COLLATE для этого объекта. Если провайдер локалей — не libc, collcollate имеет значение NULL и вместо него используется colllocale.

collctype text

LC_CTYPE для этого объекта. Если провайдер локалей — не libc, collcollate имеет значение NULL и вместо него используется colllocale.

colllocale text

Имя локали провайдера правил сортировки для этого объекта. Если провайдер — libc, collcollate имеет значение NULL и вместо него используются colllocale и collctype.

collicurules text

Правила сортировки ICU для данного объекта

collversion text

Определяемая провайдером версия правила сортировки. Она записывается при создании правила сортировки и проверяется при использовании для обнаружения изменений в его определении, чреватых повреждением данных.


Заметьте, что уникальный ключ в этом каталоге определён как (collname, collencoding, collnamespace), а не просто как (collname, collnamespace). Вообще Postgres Pro Shardman игнорирует все правила сортировки, для которых collencoding не равняется кодировке текущей базы данных или -1, а создание новых записей с тем же именем, которое уже имеет запись с collencoding = -1, запрещено. Таким образом, достаточно использовать полное имя SQL (схема.имя) для указания правила сортировки, несмотря на то, что оно может быть неуникальным согласно определению каталога. Такая организация каталога объясняется тем, что программа initdb наполняет его в момент инициализации кластера записями для всех локалей, обнаруженных в системе, так что она должна иметь возможность сохранить записи для всех кодировок, которые могут вообще когда-либо применяться в кластере.

В базе данных template0 может быть полезно создать правила сортировки, кодировки которых не соответствуют кодировке этой базы, но которые могут оказаться у баз данных, скопированных впоследствии из template0. В настоящее время это придётся проделать вручную.

56.12. pg_collation #

The catalog pg_collation describes the available collations, which are essentially mappings from an SQL name to operating system locale categories. See Section 22.2 for more information. Serves as an information source when running shardmanctl schema verify --filter collations.

Table 56.12. pg_collation Columns

Column Type

Description

oid oid

Row identifier

collname name

Collation name (unique per namespace and encoding)

collnamespace oid (references pg_namespace.oid)

The OID of the namespace that contains this collation

collowner oid (references pg_authid.oid)

Owner of the collation

collprovider char

Provider of the collation: d = database default, b = builtin, c = libc, i = icu

collisdeterministic bool

Is the collation deterministic?

collencoding int4

Encoding in which the collation is applicable, or -1 if it works for any encoding

collcollate text

LC_COLLATE for this collation object. If the provider is not libc, collcollate is NULL and colllocale is used instead.

collctype text

LC_CTYPE for this collation object. If the provider is not libc, collctype is NULL and colllocale is used instead.

colllocale text

Collation provider locale name for this collation object. If the provider is libc, colllocale is NULL; collcollate and collctype are used instead.

collicurules text

ICU collation rules for this collation object

collversion text

Provider-specific version of the collation. This is recorded when the collation is created and then checked when it is used, to detect changes in the collation definition that could lead to data corruption.


Note that the unique key on this catalog is (collname, collencoding, collnamespace) not just (collname, collnamespace). Postgres Pro Shardman generally ignores all collations that do not have collencoding equal to either the current database's encoding or -1, and creation of new entries with the same name as an entry with collencoding = -1 is forbidden. Therefore it is sufficient to use a qualified SQL name (schema.name) to identify a collation, even though this is not unique according to the catalog definition. The reason for defining the catalog this way is that initdb fills it in at cluster initialization time with entries for all locales available on the system, so it must be able to hold entries for all encodings that might ever be used in the cluster.

In the template0 database, it could be useful to create collations whose encoding does not match the database encoding, since they could match the encodings of databases later cloned from template0. This would currently have to be done manually.

FAQ