A bit more editing for collation documentation.
This commit is contained in:
parent
d367d41d66
commit
c0dc44ebba
@ -1257,6 +1257,12 @@ SELECT 3 OPERATOR(pg_catalog.+) 4;
|
|||||||
</para>
|
</para>
|
||||||
</listitem>
|
</listitem>
|
||||||
|
|
||||||
|
<listitem>
|
||||||
|
<para>
|
||||||
|
A collation expression
|
||||||
|
</para>
|
||||||
|
</listitem>
|
||||||
|
|
||||||
<listitem>
|
<listitem>
|
||||||
<para>
|
<para>
|
||||||
A scalar subquery
|
A scalar subquery
|
||||||
@ -1898,8 +1904,8 @@ CAST ( <replaceable>expression</replaceable> AS <replaceable>type</replaceable>
|
|||||||
</note>
|
</note>
|
||||||
</sect2>
|
</sect2>
|
||||||
|
|
||||||
<sect2 id="sql-syntax-collate-clause">
|
<sect2 id="sql-syntax-collate-exprs">
|
||||||
<title>COLLATE Clause</title>
|
<title>Collation Expressions</title>
|
||||||
|
|
||||||
<indexterm>
|
<indexterm>
|
||||||
<primary>COLLATE</primary>
|
<primary>COLLATE</primary>
|
||||||
@ -1925,7 +1931,7 @@ CAST ( <replaceable>expression</replaceable> AS <replaceable>type</replaceable>
|
|||||||
</para>
|
</para>
|
||||||
|
|
||||||
<para>
|
<para>
|
||||||
The two typical uses of the <literal>COLLATE</literal> clause are
|
The two common uses of the <literal>COLLATE</literal> clause are
|
||||||
overriding the sort order in an <literal>ORDER BY</> clause, for
|
overriding the sort order in an <literal>ORDER BY</> clause, for
|
||||||
example:
|
example:
|
||||||
<programlisting>
|
<programlisting>
|
||||||
@ -1934,15 +1940,28 @@ SELECT a, b, c FROM tbl WHERE ... ORDER BY a COLLATE "C";
|
|||||||
and overriding the collation of a function or operator call that
|
and overriding the collation of a function or operator call that
|
||||||
has locale-sensitive results, for example:
|
has locale-sensitive results, for example:
|
||||||
<programlisting>
|
<programlisting>
|
||||||
SELECT * FROM tbl WHERE a > 'foo' COLLATE "C";
|
SELECT * FROM tbl WHERE a > 'foo' COLLATE "C";
|
||||||
</programlisting>
|
</programlisting>
|
||||||
In the latter case it doesn't matter which argument of the
|
Note that in the latter case the <literal>COLLATE</> clause is
|
||||||
operator of function call the <literal>COLLATE</> clause is
|
attached to an input argument of the operator we wish to affect.
|
||||||
attached to, because the collation that is applied by the operator
|
It doesn't matter which argument of the operator or function call the
|
||||||
or function is derived from all arguments, and
|
<literal>COLLATE</> clause is attached to, because the collation that is
|
||||||
the <literal>COLLATE</> clause will override the collations of all
|
applied by the operator or function is derived by considering all
|
||||||
other arguments. Attaching nonmatching <literal>COLLATE</>
|
arguments, and an explicit <literal>COLLATE</> clause will override the
|
||||||
clauses to more than one argument, however, is an error.
|
collations of all other arguments. (Attaching non-matching
|
||||||
|
<literal>COLLATE</> clauses to more than one argument, however, is an
|
||||||
|
error. For more details see <xref linkend="collation">.)
|
||||||
|
Thus, this gives the same result as the previous example:
|
||||||
|
<programlisting>
|
||||||
|
SELECT * FROM tbl WHERE a COLLATE "C" > 'foo';
|
||||||
|
</programlisting>
|
||||||
|
But this is an error:
|
||||||
|
<programlisting>
|
||||||
|
SELECT * FROM tbl WHERE (a > 'foo') COLLATE "C";
|
||||||
|
</programlisting>
|
||||||
|
because it attempts to apply a collation to the result of the
|
||||||
|
<literal>></> operator, which is of the non-collatable data type
|
||||||
|
<type>boolean</>.
|
||||||
</para>
|
</para>
|
||||||
</sect2>
|
</sect2>
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user