Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit b313bca

Browse files
committed
DDL support for collations
- collowner field - CREATE COLLATION - ALTER COLLATION - DROP COLLATION - COMMENT ON COLLATION - integration with extensions - pg_dump support for the above - dependency management - psql tab completion - psql \dO command
1 parent d31e2a4 commit b313bca

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+1860
-91
lines changed

doc/src/sgml/catalogs.sgml

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2114,11 +2114,30 @@
21142114
</entry>
21152115
</row>
21162116

2117+
<row>
2118+
<entry><structfield>collowner</structfield></entry>
2119+
<entry><type>oid</type></entry>
2120+
<entry><literal><link linkend="catalog-pg-authid"><structname>pg_authid</structname></link>.oid</literal></entry>
2121+
<entry>Owner of the collation</entry>
2122+
</row>
2123+
21172124
<row>
21182125
<entry><structfield>collencoding</structfield></entry>
21192126
<entry><type>int4</type></entry>
21202127
<entry></entry>
2121-
<entry>Encoding to which the collation is applicable</entry>
2128+
<entry>
2129+
Encoding to which the collation is applicable. SQL-level
2130+
commands such as <command>ALTER COLLATION</command> only
2131+
operate on the collation belonging to the current database
2132+
encoding. But this field is necessary because when this
2133+
catalog is initialized, the encoding of future databases is not
2134+
yet known. For practical purposes, collations that do not
2135+
match the current database encoding should be considered
2136+
invalid or invisible. It could be useful, however, to create
2137+
collations whose encoding does not match the database encoding
2138+
in template databases. This would currently have to be done
2139+
manually.
2140+
</entry>
21222141
</row>
21232142

21242143
<row>

doc/src/sgml/charset.sgml

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -459,11 +459,12 @@ SELECT a || ('foo' COLLATE "y") FROM test1;
459459

460460
<para>
461461
In case a collation is needed that has different values for
462-
<symbol>LC_COLLATE</symbol> and <symbol>LC_CTYPE</symbol>, or a
463-
different name is needed for a collation (for example, for
464-
compatibility with existing applications), a new collation may be
465-
created. But there is currently no SQL-level support for creating
466-
or changing collations.
462+
<symbol>LC_COLLATE</symbol> and <symbol>LC_CTYPE</symbol>, a new
463+
collation may be created using
464+
the <xref linkend="sql-createcollation"> command. That command
465+
can also be used to create a new collation from an existing
466+
collation, which can be useful to be able to use operating-system
467+
independent collation names in applications.
467468
</para>
468469
</sect2>
469470
</sect1>

doc/src/sgml/ref/allfiles.sgml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ Complete list of usable sgml source files in this directory.
77
<!-- SQL commands -->
88
<!entity abort system "abort.sgml">
99
<!entity alterAggregate system "alter_aggregate.sgml">
10+
<!entity alterCollation system "alter_collation.sgml">
1011
<!entity alterConversion system "alter_conversion.sgml">
1112
<!entity alterDatabase system "alter_database.sgml">
1213
<!entity alterDefaultPrivileges system "alter_default_privileges.sgml">
@@ -48,6 +49,7 @@ Complete list of usable sgml source files in this directory.
4849
<!entity copyTable system "copy.sgml">
4950
<!entity createAggregate system "create_aggregate.sgml">
5051
<!entity createCast system "create_cast.sgml">
52+
<!entity createCollation system "create_collation.sgml">
5153
<!entity createConversion system "create_conversion.sgml">
5254
<!entity createDatabase system "create_database.sgml">
5355
<!entity createDomain system "create_domain.sgml">
@@ -85,6 +87,7 @@ Complete list of usable sgml source files in this directory.
8587
<!entity do system "do.sgml">
8688
<!entity dropAggregate system "drop_aggregate.sgml">
8789
<!entity dropCast system "drop_cast.sgml">
90+
<!entity dropCollation system "drop_collation.sgml">
8891
<!entity dropConversion system "drop_conversion.sgml">
8992
<!entity dropDatabase system "drop_database.sgml">
9093
<!entity dropDomain system "drop_domain.sgml">

doc/src/sgml/ref/alter_collation.sgml

Lines changed: 128 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,128 @@
1+
<!--
2+
doc/src/sgml/ref/alter_collation.sgml
3+
PostgreSQL documentation
4+
-->
5+
6+
<refentry id="SQL-ALTERCOLLATION">
7+
<refmeta>
8+
<refentrytitle>ALTER COLLATION</refentrytitle>
9+
<manvolnum>7</manvolnum>
10+
<refmiscinfo>SQL - Language Statements</refmiscinfo>
11+
</refmeta>
12+
13+
<refnamediv>
14+
<refname>ALTER COLLATION</refname>
15+
<refpurpose>change the definition of a collation</refpurpose>
16+
</refnamediv>
17+
18+
<indexterm zone="sql-altercollation">
19+
<primary>ALTER COLLATION</primary>
20+
</indexterm>
21+
22+
<refsynopsisdiv>
23+
<synopsis>
24+
ALTER COLLATION <replaceable>name</replaceable> RENAME TO <replaceable>new_name</replaceable>
25+
ALTER COLLATION <replaceable>name</replaceable> OWNER TO <replaceable>new_owner</replaceable>
26+
ALTER COLLATION <replaceable>name</replaceable> SET SCHEMA <replaceable>new_schema</replaceable>
27+
</synopsis>
28+
</refsynopsisdiv>
29+
30+
<refsect1>
31+
<title>Description</title>
32+
33+
<para>
34+
<command>ALTER COLLATION</command> changes the definition of a
35+
collation.
36+
</para>
37+
38+
<para>
39+
You must own the collation to use <command>ALTER COLLATION</>.
40+
To alter the owner, you must also be a direct or indirect member of the new
41+
owning role, and that role must have <literal>CREATE</literal> privilege on
42+
the collation's schema. (These restrictions enforce that altering the
43+
owner doesn't do anything you couldn't do by dropping and recreating the
44+
collation. However, a superuser can alter ownership of any collation
45+
anyway.)
46+
</para>
47+
</refsect1>
48+
49+
<refsect1>
50+
<title>Parameters</title>
51+
52+
<variablelist>
53+
<varlistentry>
54+
<term><replaceable class="parameter">name</replaceable></term>
55+
<listitem>
56+
<para>
57+
The name (optionally schema-qualified) of an existing collation.
58+
</para>
59+
</listitem>
60+
</varlistentry>
61+
62+
<varlistentry>
63+
<term><replaceable class="parameter">new_name</replaceable></term>
64+
<listitem>
65+
<para>
66+
The new name of the collation.
67+
</para>
68+
</listitem>
69+
</varlistentry>
70+
71+
<varlistentry>
72+
<term><replaceable class="parameter">new_owner</replaceable></term>
73+
<listitem>
74+
<para>
75+
The new owner of the collation.
76+
</para>
77+
</listitem>
78+
</varlistentry>
79+
80+
<varlistentry>
81+
<term><replaceable class="parameter">new_schema</replaceable></term>
82+
<listitem>
83+
<para>
84+
The new schema for the collation.
85+
</para>
86+
</listitem>
87+
</varlistentry>
88+
</variablelist>
89+
</refsect1>
90+
91+
<refsect1>
92+
<title>Examples</title>
93+
94+
<para>
95+
To rename the collation <literal>de_DE</literal> to
96+
<literal>german</literal>:
97+
<programlisting>
98+
ALTER COLLATION "de_DE" RENAME TO german;
99+
</programlisting>
100+
</para>
101+
102+
<para>
103+
To change the owner of the collation <literal>en_US</literal> to
104+
<literal>joe</literal>:
105+
<programlisting>
106+
ALTER COLLATION "en_US" OWNER TO joe;
107+
</programlisting>
108+
</para>
109+
</refsect1>
110+
111+
<refsect1>
112+
<title>Compatibility</title>
113+
114+
<para>
115+
There is no <command>ALTER COLLATION</command> statement in the SQL
116+
standard.
117+
</para>
118+
</refsect1>
119+
120+
<refsect1>
121+
<title>See Also</title>
122+
123+
<simplelist type="inline">
124+
<member><xref linkend="sql-createcollation"></member>
125+
<member><xref linkend="sql-dropcollation"></member>
126+
</simplelist>
127+
</refsect1>
128+
</refentry>

doc/src/sgml/ref/alter_extension.sgml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ ALTER EXTENSION <replaceable class="PARAMETER">extension_name</replaceable> DROP
3232

3333
AGGREGATE <replaceable class="PARAMETER">agg_name</replaceable> (<replaceable class="PARAMETER">agg_type</replaceable> [, ...] ) |
3434
CAST (<replaceable>source_type</replaceable> AS <replaceable>target_type</replaceable>) |
35+
COLLATION <replaceable class="PARAMETER">object_name</replaceable> |
3536
CONVERSION <replaceable class="PARAMETER">object_name</replaceable> |
3637
DOMAIN <replaceable class="PARAMETER">object_name</replaceable> |
3738
FOREIGN DATA WRAPPER <replaceable class="PARAMETER">object_name</replaceable> |

doc/src/sgml/ref/comment.sgml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ COMMENT ON
2727
COLUMN <replaceable class="PARAMETER">table_name</replaceable>.<replaceable class="PARAMETER">column_name</replaceable> |
2828
AGGREGATE <replaceable class="PARAMETER">agg_name</replaceable> (<replaceable class="PARAMETER">agg_type</replaceable> [, ...] ) |
2929
CAST (<replaceable>source_type</replaceable> AS <replaceable>target_type</replaceable>) |
30+
COLLATION <replaceable class="PARAMETER">object_name</replaceable> |
3031
CONSTRAINT <replaceable class="PARAMETER">constraint_name</replaceable> ON <replaceable class="PARAMETER">table_name</replaceable> |
3132
CONVERSION <replaceable class="PARAMETER">object_name</replaceable> |
3233
DATABASE <replaceable class="PARAMETER">object_name</replaceable> |
@@ -245,6 +246,7 @@ COMMENT ON TABLE mytable IS NULL;
245246
<programlisting>
246247
COMMENT ON AGGREGATE my_aggregate (double precision) IS 'Computes sample variance';
247248
COMMENT ON CAST (text AS int4) IS 'Allow casts from text to int4';
249+
COMMENT ON COLLATION "fr_CA" IS 'Canadian French';
248250
COMMENT ON COLUMN my_table.my_column IS 'Employee ID number';
249251
COMMENT ON CONVERSION my_conv IS 'Conversion to UTF8';
250252
COMMENT ON DATABASE my_database IS 'Development Database';

0 commit comments

Comments
 (0)