postgresql/src/include/catalog/pg_collation.h
Peter Eisentraut eccfef81e1 ICU support
Add a column collprovider to pg_collation that determines which library
provides the collation data.  The existing choices are default and libc,
and this adds an icu choice, which uses the ICU4C library.

The pg_locale_t type is changed to a union that contains the
provider-specific locale handles.  Users of locale information are
changed to look into that struct for the appropriate handle to use.

Also add a collversion column that records the version of the collation
when it is created, and check at run time whether it is still the same.
This detects potentially incompatible library upgrades that can corrupt
indexes and other structures.  This is currently only supported by
ICU-provided collations.

initdb initializes the default collation set as before from the `locale
-a` output but also adds all available ICU locales with a "-x-icu"
appended.

Currently, ICU-provided collations can only be explicitly named
collations.  The global database locales are still always libc-provided.

ICU support is enabled by configure --with-icu.

Reviewed-by: Thomas Munro <thomas.munro@enterprisedb.com>
Reviewed-by: Andreas Karlsson <andreas@proxel.se>
2017-03-23 15:28:48 -04:00

88 lines
2.6 KiB
C

/*-------------------------------------------------------------------------
*
* pg_collation.h
* definition of the system "collation" relation (pg_collation)
* along with the relation's initial contents.
*
*
* Portions Copyright (c) 1996-2017, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
* src/include/catalog/pg_collation.h
*
* NOTES
* the genbki.pl script reads this file and generates .bki
* information from the DATA() statements.
*
*-------------------------------------------------------------------------
*/
#ifndef PG_COLLATION_H
#define PG_COLLATION_H
#include "catalog/genbki.h"
/* ----------------
* pg_collation definition. cpp turns this into
* typedef struct FormData_pg_collation
* ----------------
*/
#define CollationRelationId 3456
CATALOG(pg_collation,3456)
{
NameData collname; /* collation name */
Oid collnamespace; /* OID of namespace containing collation */
Oid collowner; /* owner of collation */
char collprovider; /* see constants below */
int32 collencoding; /* encoding for this collation; -1 = "all" */
NameData collcollate; /* LC_COLLATE setting */
NameData collctype; /* LC_CTYPE setting */
#ifdef CATALOG_VARLEN /* variable-length fields start here */
text collversion; /* provider-dependent version of collation data */
#endif
} FormData_pg_collation;
/* ----------------
* Form_pg_collation corresponds to a pointer to a row with
* the format of pg_collation relation.
* ----------------
*/
typedef FormData_pg_collation *Form_pg_collation;
/* ----------------
* compiler constants for pg_collation
* ----------------
*/
#define Natts_pg_collation 8
#define Anum_pg_collation_collname 1
#define Anum_pg_collation_collnamespace 2
#define Anum_pg_collation_collowner 3
#define Anum_pg_collation_collprovider 4
#define Anum_pg_collation_collencoding 5
#define Anum_pg_collation_collcollate 6
#define Anum_pg_collation_collctype 7
#define Anum_pg_collation_collversion 8
/* ----------------
* initial contents of pg_collation
* ----------------
*/
DATA(insert OID = 100 ( default PGNSP PGUID d -1 "" "" 0 ));
DESCR("database's default collation");
#define DEFAULT_COLLATION_OID 100
DATA(insert OID = 950 ( C PGNSP PGUID c -1 "C" "C" 0 ));
DESCR("standard C collation");
#define C_COLLATION_OID 950
DATA(insert OID = 951 ( POSIX PGNSP PGUID c -1 "POSIX" "POSIX" 0 ));
DESCR("standard POSIX collation");
#define POSIX_COLLATION_OID 951
#define COLLPROVIDER_DEFAULT 'd'
#define COLLPROVIDER_ICU 'i'
#define COLLPROVIDER_LIBC 'c'
#endif /* PG_COLLATION_H */