1
0
mirror of https://github.com/postgres/postgres.git synced 2025-06-13 07:41:39 +03:00

Teach regular expression operators to honor collations.

This involves getting the character classification and case-folding
functions in the regex library to use the collations infrastructure.
Most of this work had been done already in connection with the upper/lower
and LIKE logic, so it was a simple matter of transposition.

While at it, split out these functions into a separate source file
regc_pg_locale.c, so that they can be correctly labeled with the Postgres
project's license rather than the Scriptics license.  These functions are
100% Postgres-written code whereas what remains in regc_locale.c is still
mostly not ours, so lumping them both under the same copyright notice was
getting more and more misleading.
This commit is contained in:
Tom Lane
2011-04-10 18:02:17 -04:00
parent 210f95f1cd
commit 1e16a8107d
12 changed files with 821 additions and 194 deletions

View File

@ -221,26 +221,36 @@ initdb --locale=sv_SE
<listitem>
<para>
The ability to use indexes with <literal>LIKE</> clauses
<indexterm><primary>LIKE</><secondary>and locales</></indexterm>
</para>
</listitem>
<listitem>
<para>
The <function>upper</>, <function>lower</>, and <function>initcap</>
The <function>upper</>, <function>lower</>, and <function>initcap</>
functions
<indexterm><primary>upper</><secondary>and locales</></indexterm>
<indexterm><primary>lower</><secondary>and locales</></indexterm>
</para>
</listitem>
<listitem>
<para>
Pattern matching operators (<literal>LIKE</>, <literal>SIMILAR TO</>,
and POSIX-style regular expressions); locales affect both case
insensitive matching and the classification of characters by
character-class regular expressions
<indexterm><primary>LIKE</><secondary>and locales</></indexterm>
<indexterm><primary>regular expressions</><secondary>and locales</></indexterm>
</para>
</listitem>
<listitem>
<para>
The <function>to_char</> family of functions
<indexterm><primary>to_char</><secondary>and locales</></indexterm>
</para>
</listitem>
<listitem>
<para>
The ability to use indexes with <literal>LIKE</> clauses
</para>
</listitem>
</itemizedlist>
</para>
@ -319,8 +329,8 @@ initdb --locale=sv_SE
<indexterm zone="collation"><primary>collation</></>
<para>
The collation feature allows specifying the sort order and certain
other locale aspects of data per-column, or even per-operation.
The collation feature allows specifying the sort order and character
classification behavior of data per-column, or even per-operation.
This alleviates the restriction that the
<symbol>LC_COLLATE</symbol> and <symbol>LC_CTYPE</symbol> settings
of a database cannot be changed after its creation.
@ -351,8 +361,8 @@ initdb --locale=sv_SE
</para>
<para>
When the database system has to perform an ordering or a
comparison, it uses the collation of the input expression. This
When the database system has to perform an ordering or a character
classification, it uses the collation of the input expression. This
happens, for example, with <literal>ORDER BY</literal> clauses
and function or operator calls such as <literal>&lt;</literal>.
The collation to apply for an <literal>ORDER BY</literal> clause
@ -361,7 +371,8 @@ initdb --locale=sv_SE
below. In addition to comparison operators, collations are taken into
account by functions that convert between lower and upper case
letters, such as <function>lower</>, <function>upper</>, and
<function>initcap</>.
<function>initcap</>; by pattern matching operators; and by
<function>to_char</> and related functions.
</para>
<para>