diff --git a/doc/src/sgml/information_schema.sgml b/doc/src/sgml/information_schema.sgml
index 5861595c292..52407a741fe 100644
--- a/doc/src/sgml/information_schema.sgml
+++ b/doc/src/sgml/information_schema.sgml
@@ -498,6 +498,140 @@
+
+ character_sets
+
+
+ The view character_sets identifies the character
+ sets available in the current database. Since PostgreSQL does not
+ support multiple character sets within one database, this view only
+ shows one, which is the database encoding.
+
+
+
+ Take note of how the following terms are used in the SQL standard:
+
+
+ character repertoire
+
+
+ An abstract collection of characters, for
+ example UNICODE, UCS, or
+ LATIN1. Not exposed as an SQL object, but
+ visible in this view.
+
+
+
+
+
+ character encoding form
+
+
+ An encoding of some character repertoire. Most older character
+ repertoires only use one encoding form, and so there are no
+ separate names for them (e.g., LATIN1 is an
+ encoding form applicable to the LATIN1
+ repertoire). But for example Unicode has the encoding forms
+ UTF8, UTF16, etc. (not
+ all supported by PostgreSQL). Encoding forms are not exposed
+ as an SQL object, but are visible in this view.
+
+
+
+
+
+ character set
+
+
+ A named SQL object that identifies a character repertoire, a
+ character encoding, and a default collation. A predefined
+ character set would typically have the same name as an encoding
+ form, but users could define other names. For example, the
+ character set UTF8 would typically identify
+ the character repertoire UCS, encoding
+ form UTF8, and some default collation.
+
+
+
+
+
+ You can think of an encoding
in PostgreSQL either as
+ a character set or a character encoding form. They will have the
+ same name, and there can only be one in one database.
+
+
+
+ character_sets Columns
+
+
+
+
+ Name
+ Data Type
+ Description
+
+
+
+
+
+ character_set_catalog
+ sql_identifier
+ Character sets are currently not implemented as schema objects, so this column is null.
+
+
+
+ character_set_schema
+ sql_identifier
+ Character sets are currently not implemented as schema objects, so this column is null.
+
+
+
+ character_set_name
+ sql_identifier
+ Name of the character set, currently implemented as showing the name of the database encoding
+
+
+
+ character_repertoire
+ sql_identifier
+ Character repertoire, showing UCS if the encoding is UTF8, else just the encoding name
+
+
+
+ form_of_use
+ sql_identifier
+ Character encoding form, same as the database encoding
+
+
+
+ default_collate_catalog
+ sql_identifier
+ Name of the database containing the default collation (always the current database, if any collation is identified)
+
+
+
+ default_collate_schema
+ sql_identifier
+ Name of the schema containing the default collation
+
+
+
+ default_collate_name
+ sql_identifier
+
+ Name of the default collation. The default collation is
+ identified as the collation that matches
+ the COLLATE and CTYPE
+ settings of the current database. If there is no such
+ collation, then this column and the associated schema and
+ catalog columns are null.
+
+
+
+
+
+
+
check_constraint_routine_usage
@@ -615,6 +749,123 @@
+
+ collations
+
+
+ The view collations contains the collations
+ available in the current database.
+
+
+
+ collations Columns
+
+
+
+
+ Name
+ Data Type
+ Description
+
+
+
+
+
+ collation_catalog
+ sql_identifier
+ Name of the database containing the collation (always the current database)
+
+
+
+ collation_schema
+ sql_identifier
+ Name of the schema containing the collation
+
+
+
+ collation_name
+ sql_identifier
+ Name of the default collation
+
+
+
+ pad_attribute
+ character_data
+
+ Always NO PAD (The alternative PAD
+ SPACE is not supported by PostgreSQL.)
+
+
+
+
+
+
+
+
+ collation_character_set_applicability
+
+
+ The view collation_character_set_applicability
+ identifies which character set the available collations are
+ applicable to. In PostgreSQL, there is only one character set per
+ database (see explanation
+ in ), so this view does
+ not provide much useful information.
+
+
+
+ collation_character_set_applicability Columns
+
+
+
+
+ Name
+ Data Type
+ Description
+
+
+
+
+
+ collation_catalog
+ sql_identifier
+ Name of the database containing the collation (always the current database)
+
+
+
+ collation_schema
+ sql_identifier
+ Name of the schema containing the collation
+
+
+
+ collation_name
+ sql_identifier
+ Name of the default collation
+
+
+
+ character_set_catalog
+ sql_identifier
+ Character sets are currently not implemented as schema objects, so this column is null
+
+
+
+ character_set_schema
+ sql_identifier
+ Character sets are currently not implemented as schema objects, so this column is null
+
+
+
+ character_set_name
+ sql_identifier
+ Name of the character set
+
+
+
+
+
+
column_domain_usage
diff --git a/src/backend/catalog/information_schema.sql b/src/backend/catalog/information_schema.sql
index 5b8b9417701..e81a3bb40df 100644
--- a/src/backend/catalog/information_schema.sql
+++ b/src/backend/catalog/information_schema.sql
@@ -354,7 +354,23 @@ GRANT SELECT ON attributes TO PUBLIC;
* CHARACTER_SETS view
*/
--- feature not supported
+CREATE VIEW character_sets AS
+ SELECT CAST(null AS sql_identifier) AS character_set_catalog,
+ CAST(null AS sql_identifier) AS character_set_schema,
+ CAST(getdatabaseencoding() AS sql_identifier) AS character_set_name,
+ CAST(CASE WHEN getdatabaseencoding() = 'UTF8' THEN 'UCS' ELSE getdatabaseencoding() END AS sql_identifier) AS character_repertoire,
+ CAST(getdatabaseencoding() AS sql_identifier) AS form_of_use,
+ CAST(current_database() AS sql_identifier) AS default_collate_catalog,
+ CAST(nc.nspname AS sql_identifier) AS default_collate_schema,
+ CAST(c.collname AS sql_identifier) AS default_collate_name
+ FROM pg_database d
+ LEFT JOIN (pg_collation c JOIN pg_namespace nc ON (c.collnamespace = nc.oid))
+ ON (datcollate = collcollate AND datctype = collctype)
+ WHERE d.datname = current_database()
+ ORDER BY char_length(c.collname) DESC, c.collname ASC -- prefer full/canonical name
+ LIMIT 1;
+
+GRANT SELECT ON character_sets TO PUBLIC;
/*
@@ -425,14 +441,35 @@ GRANT SELECT ON check_constraints TO PUBLIC;
* COLLATIONS view
*/
--- feature not supported
+CREATE VIEW collations AS
+ SELECT CAST(current_database() AS sql_identifier) AS collation_catalog,
+ CAST(nc.nspname AS sql_identifier) AS collation_schema,
+ CAST(c.collname AS sql_identifier) AS collation_name,
+ CAST('NO PAD' AS character_data) AS pad_attribute
+ FROM pg_collation c, pg_namespace nc
+ WHERE c.collnamespace = nc.oid
+ AND collencoding = (SELECT encoding FROM pg_catalog.pg_database WHERE datname = pg_catalog.current_database());
+
+GRANT SELECT ON collations TO PUBLIC;
+
/*
* 5.16
* COLLATION_CHARACTER_SET_APPLICABILITY view
*/
--- feature not supported
+CREATE VIEW collation_character_set_applicability AS
+ SELECT CAST(current_database() AS sql_identifier) AS collation_catalog,
+ CAST(nc.nspname AS sql_identifier) AS collation_schema,
+ CAST(c.collname AS sql_identifier) AS collation_name,
+ CAST(null AS sql_identifier) AS character_set_catalog,
+ CAST(null AS sql_identifier) AS character_set_schema,
+ CAST(getdatabaseencoding() AS sql_identifier) AS character_set_name
+ FROM pg_collation c, pg_namespace nc
+ WHERE c.collnamespace = nc.oid
+ AND collencoding = (SELECT encoding FROM pg_catalog.pg_database WHERE datname = pg_catalog.current_database());
+
+GRANT SELECT ON collation_character_set_applicability TO PUBLIC;
/*
diff --git a/src/include/catalog/catversion.h b/src/include/catalog/catversion.h
index 019cd8fab5a..18739adb391 100644
--- a/src/include/catalog/catversion.h
+++ b/src/include/catalog/catversion.h
@@ -53,6 +53,6 @@
*/
/* yyyymmddN */
-#define CATALOG_VERSION_NO 201102084
+#define CATALOG_VERSION_NO 201102091
#endif