-<!-- $PostgreSQL: pgsql/doc/src/sgml/func.sgml,v 1.391 2007/08/31 04:52:29 momjian Exp $ -->
+<!-- $PostgreSQL: pgsql/doc/src/sgml/func.sgml,v 1.392 2007/08/31 21:33:48 momjian Exp $ -->
<chapter id="functions">
<title>Functions and Operators</title>
<replaceable>string</replaceable> NOT SIMILAR TO <replaceable>pattern</replaceable> <optional>ESCAPE <replaceable>escape-character</replaceable></optional>
</synopsis>
- <para>
- The <function>SIMILAR TO</function> operator returns true or
- false depending on whether its pattern matches the given string.
- It is much like <function>LIKE</function>, except that it
- interprets the pattern using the SQL standard's definition of a
- regular expression. SQL regular expressions are a curious cross
- between <function>LIKE</function> notation and common regular
- expression notation.
- </para>
+ <para>
+ The <function>SIMILAR TO</function> operator returns true or
+ false depending on whether its pattern matches the given string.
+ It is much like <function>LIKE</function>, except that it
+ interprets the pattern using the SQL standard's definition of a
+ regular expression. SQL regular expressions are a curious cross
+ between <function>LIKE</function> notation and common regular
+ expression notation.
+ </para>
- <para>
- Like <function>LIKE</function>, the <function>SIMILAR TO</function>
- operator succeeds only if its pattern matches the entire string;
- this is unlike common regular expression practice, wherein the pattern
- can match any part of the string.
- Also like
- <function>LIKE</function>, <function>SIMILAR TO</function> uses
- <literal>_</> and <literal>%</> as wildcard characters denoting
- any single character and any string, respectively (these are
- comparable to <literal>.</> and <literal>.*</> in POSIX regular
- expressions).
- </para>
+ <para>
+ Like <function>LIKE</function>, the <function>SIMILAR TO</function>
+ operator succeeds only if its pattern matches the entire string;
+ this is unlike common regular expression practice, wherein the pattern
+ can match any part of the string.
+ Also like
+ <function>LIKE</function>, <function>SIMILAR TO</function> uses
+ <literal>_</> and <literal>%</> as wildcard characters denoting
+ any single character and any string, respectively (these are
+ comparable to <literal>.</> and <literal>.*</> in POSIX regular
+ expressions).
+ </para>
- <para>
- In addition to these facilities borrowed from <function>LIKE</function>,
- <function>SIMILAR TO</function> supports these pattern-matching
- metacharacters borrowed from POSIX regular expressions:
+ <para>
+ In addition to these facilities borrowed from <function>LIKE</function>,
+ <function>SIMILAR TO</function> supports these pattern-matching
+ metacharacters borrowed from POSIX regular expressions:
- <itemizedlist>
- <listitem>
- <para>
- <literal>|</literal> denotes alternation (either of two alternatives).
- </para>
- </listitem>
- <listitem>
- <para>
- <literal>*</literal> denotes repetition of the previous item zero
- or more times.
- </para>
- </listitem>
- <listitem>
- <para>
- <literal>+</literal> denotes repetition of the previous item one
- or more times.
- </para>
- </listitem>
- <listitem>
- <para>
- Parentheses <literal>()</literal> can be used to group items into
- a single logical item.
- </para>
- </listitem>
- <listitem>
- <para>
- A bracket expression <literal>[...]</literal> specifies a character
- class, just as in POSIX regular expressions.
- </para>
- </listitem>
- </itemizedlist>
+ <itemizedlist>
+ <listitem>
+ <para>
+ <literal>|</literal> denotes alternation (either of two alternatives).
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ <literal>*</literal> denotes repetition of the previous item zero
+ or more times.
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ <literal>+</literal> denotes repetition of the previous item one
+ or more times.
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ Parentheses <literal>()</literal> can be used to group items into
+ a single logical item.
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ A bracket expression <literal>[...]</literal> specifies a character
+ class, just as in POSIX regular expressions.
+ </para>
+ </listitem>
+ </itemizedlist>
- Notice that bounded repetition (<literal>?</> and <literal>{...}</>)
- are not provided, though they exist in POSIX. Also, the dot (<literal>.</>)
- is not a metacharacter.
- </para>
+ Notice that bounded repetition (<literal>?</> and <literal>{...}</>)
+ are not provided, though they exist in POSIX. Also, the dot (<literal>.</>)
+ is not a metacharacter.
+ </para>
- <para>
- As with <function>LIKE</>, a backslash disables the special meaning
- of any of these metacharacters; or a different escape character can
- be specified with <literal>ESCAPE</>.
- </para>
+ <para>
+ As with <function>LIKE</>, a backslash disables the special meaning
+ of any of these metacharacters; or a different escape character can
+ be specified with <literal>ESCAPE</>.
+ </para>
<para>
Some examples:
</programlisting>
</para>
- <para>
- The <function>substring</> function with three parameters,
- <function>substring(<replaceable>string</replaceable> from
- <replaceable>pattern</replaceable> for
- <replaceable>escape-character</replaceable>)</function>, provides
- extraction of a substring that matches an SQL
- regular expression pattern. As with <literal>SIMILAR TO</>, the
- specified pattern must match to the entire data string, else the
- function fails and returns null. To indicate the part of the
- pattern that should be returned on success, the pattern must contain
- two occurrences of the escape character followed by a double quote
- (<literal>"</>). The text matching the portion of the pattern
- between these markers is returned.
- </para>
+ <para>
+ The <function>substring</> function with three parameters,
+ <function>substring(<replaceable>string</replaceable> from
+ <replaceable>pattern</replaceable> for
+ <replaceable>escape-character</replaceable>)</function>, provides
+ extraction of a substring that matches an SQL
+ regular expression pattern. As with <literal>SIMILAR TO</>, the
+ specified pattern must match to the entire data string, else the
+ function fails and returns null. To indicate the part of the
+ pattern that should be returned on success, the pattern must contain
+ two occurrences of the escape character followed by a double quote
+ (<literal>"</>). The text matching the portion of the pattern
+ between these markers is returned.
+ </para>
<para>
Some examples:
</tgroup>
</table>
- <indexterm zone="functions-info">
+ <indexterm>
<primary>user</primary>
<secondary>current</secondary>
</indexterm>
- <indexterm zone="functions-info">
+ <indexterm>
<primary>schema</primary>
<secondary>current</secondary>
</indexterm>
- <indexterm zone="functions-info">
+ <indexterm>
<primary>search path</primary>
<secondary>current</secondary>
</indexterm>
</para>
</note>
- <indexterm zone="functions-info">
+ <indexterm>
<primary>inet_client_addr</primary>
</indexterm>
- <indexterm zone="functions-info">
+ <indexterm>
<primary>inet_client_port</primary>
</indexterm>
- <indexterm zone="functions-info">
+ <indexterm>
<primary>inet_server_addr</primary>
</indexterm>
- <indexterm zone="functions-info">
+ <indexterm>
<primary>inet_server_port</primary>
</indexterm>
Unix-domain socket.
</para>
- <indexterm zone="functions-info">
+ <indexterm>
<primary>pg_my_temp_schema</primary>
</indexterm>
- <indexterm zone="functions-info">
+ <indexterm>
<primary>pg_is_other_temp_schema</primary>
</indexterm>
tables from a catalog display.)
</para>
- <indexterm zone="functions-info">
+ <indexterm>
<primary>pg_postmaster_start_time</primary>
</indexterm>
server started.
</para>
- <indexterm zone="functions-info">
+ <indexterm>
<primary>version</primary>
</indexterm>
</tgroup>
</table>
- <indexterm zone="functions-info">
+ <indexterm>
<primary>has_database_privilege</primary>
</indexterm>
- <indexterm zone="functions-info">
+ <indexterm>
<primary>has_function_privilege</primary>
</indexterm>
- <indexterm zone="functions-info">
+ <indexterm>
<primary>has_language_privilege</primary>
</indexterm>
- <indexterm zone="functions-info">
+ <indexterm>
<primary>has_schema_privilege</primary>
</indexterm>
- <indexterm zone="functions-info">
+ <indexterm>
<primary>has_table_privilege</primary>
</indexterm>
- <indexterm zone="functions-info">
+ <indexterm>
<primary>has_tablespace_privilege</primary>
</indexterm>
- <indexterm zone="functions-info">
+ <indexterm>
<primary>pg_has_role</primary>
</indexterm>
</tgroup>
</table>
- <indexterm zone="functions-info">
+ <indexterm>
<primary>pg_conversion_is_visible</primary>
</indexterm>
- <indexterm zone="functions-info">
+ <indexterm>
<primary>pg_function_is_visible</primary>
</indexterm>
- <indexterm zone="functions-info">
+ <indexterm>
<primary>pg_operator_is_visible</primary>
</indexterm>
- <indexterm zone="functions-info">
+ <indexterm>
<primary>pg_opclass_is_visible</primary>
</indexterm>
- <indexterm zone="functions-info">
+ <indexterm>
<primary>pg_table_is_visible</primary>
</indexterm>
- <indexterm zone="functions-info">
+ <indexterm>
<primary>pg_type_is_visible</primary>
</indexterm>
this way — if the name can be recognized at all, it must be visible.
</para>
- <indexterm zone="functions-info">
+ <indexterm>
<primary>format_type</primary>
</indexterm>
- <indexterm zone="functions-info">
+ <indexterm>
<primary>pg_get_viewdef</primary>
</indexterm>
- <indexterm zone="functions-info">
+ <indexterm>
<primary>pg_get_ruledef</primary>
</indexterm>
- <indexterm zone="functions-info">
+ <indexterm>
<primary>pg_get_indexdef</primary>
</indexterm>
- <indexterm zone="functions-info">
+ <indexterm>
<primary>pg_get_triggerdef</primary>
</indexterm>
- <indexterm zone="functions-info">
+ <indexterm>
<primary>pg_get_constraintdef</primary>
</indexterm>
- <indexterm zone="functions-info">
+ <indexterm>
<primary>pg_get_expr</primary>
</indexterm>
- <indexterm zone="functions-info">
+ <indexterm>
<primary>pg_get_userbyid</primary>
</indexterm>
- <indexterm zone="functions-info">
+ <indexterm>
<primary>pg_get_serial_sequence</primary>
</indexterm>
- <indexterm zone="functions-info">
+ <indexterm>
<primary>pg_tablespace_databases</primary>
</indexterm>
<structname>pg_class</> catalogs.
</para>
- <indexterm zone="functions-info">
+ <indexterm>
<primary>col_description</primary>
</indexterm>
- <indexterm zone="functions-info">
+ <indexterm>
<primary>obj_description</primary>
</indexterm>
- <indexterm zone="functions-info">
+ <indexterm>
<primary>shobj_description</primary>
</indexterm>
- <indexterm zone="functions-info">
+ <indexterm>
<primary>comment</primary>
<secondary sortas="database objects">about database objects</secondary>
</indexterm>
</tgroup>
</table>
- <indexterm zone="functions-admin">
+ <indexterm>
<primary>SET</primary>
</indexterm>
- <indexterm zone="functions-admin">
+ <indexterm>
<primary>SHOW</primary>
</indexterm>
- <indexterm zone="functions-admin">
+ <indexterm>
<primary>configuration</primary>
<secondary sortas="server">of the server</secondary>
<tertiary>functions</tertiary>
</programlisting>
</para>
- <indexterm zone="functions-admin">
+ <indexterm>
<primary>pg_cancel_backend</primary>
</indexterm>
- <indexterm zone="functions-admin">
+ <indexterm>
<primary>pg_reload_conf</primary>
</indexterm>
- <indexterm zone="functions-admin">
+ <indexterm>
<primary>pg_rotate_logfile</primary>
</indexterm>
- <indexterm zone="functions-admin">
+ <indexterm>
<primary>signal</primary>
<secondary sortas="backend">backend processes</secondary>
</indexterm>
subprocess.
</para>
- <indexterm zone="functions-admin">
+ <indexterm>
<primary>pg_start_backup</primary>
</indexterm>
- <indexterm zone="functions-admin">
+ <indexterm>
<primary>pg_stop_backup</primary>
</indexterm>
- <indexterm zone="functions-admin">
+ <indexterm>
<primary>pg_switch_xlog</primary>
</indexterm>
- <indexterm zone="functions-admin">
+ <indexterm>
<primary>pg_current_xlog_location</primary>
</indexterm>
- <indexterm zone="functions-admin">
+ <indexterm>
<primary>pg_current_xlog_insert_location</primary>
</indexterm>
- <indexterm zone="functions-admin">
+ <indexterm>
<primary>pg_xlogfile_name_offset</primary>
</indexterm>
- <indexterm zone="functions-admin">
+ <indexterm>
<primary>pg_xlogfile_name</primary>
</indexterm>
- <indexterm zone="functions-admin">
+ <indexterm>
<primary>backup</primary>
</indexterm>
the actual disk space usage of database objects.
</para>
- <indexterm zone="functions-admin">
+ <indexterm>
<primary>pg_column_size</primary>
</indexterm>
- <indexterm zone="functions-admin">
+ <indexterm>
<primary>pg_database_size</primary>
</indexterm>
- <indexterm zone="functions-admin">
+ <indexterm>
<primary>pg_relation_size</primary>
</indexterm>
- <indexterm zone="functions-admin">
+ <indexterm>
<primary>pg_size_pretty</primary>
</indexterm>
- <indexterm zone="functions-admin">
+ <indexterm>
<primary>pg_tablespace_size</primary>
</indexterm>
- <indexterm zone="functions-admin">
+ <indexterm>
<primary>pg_total_relation_size</primary>
</indexterm>
</tgroup>
</table>
- <indexterm zone="functions-admin">
+ <indexterm>
<primary>pg_ls_dir</primary>
</indexterm>
<para>
<quote><literal>..</></>.
</para>
- <indexterm zone="functions-admin">
+ <indexterm>
<primary>pg_read_file</primary>
</indexterm>
<para>
is negative, it is relative to the end of the file.
</para>
- <indexterm zone="functions-admin">
+ <indexterm>
<primary>pg_stat_file</primary>
</indexterm>
<para>
</tgroup>
</table>
- <indexterm zone="functions-admin">
+ <indexterm>
<primary>pg_advisory_lock</primary>
</indexterm>
<para>
released for other sessions' use.
</para>
- <indexterm zone="functions-admin">
+ <indexterm>
<primary>pg_advisory_lock_shared</primary>
</indexterm>
<para>
Only would-be exclusive lockers are locked out.
</para>
- <indexterm zone="functions-admin">
+ <indexterm>
<primary>pg_try_advisory_lock</primary>
</indexterm>
<para>
acquired now.
</para>
- <indexterm zone="functions-admin">
+ <indexterm>
<primary>pg_try_advisory_lock_shared</primary>
</indexterm>
<para>
shared rather than exclusive lock.
</para>
- <indexterm zone="functions-admin">
+ <indexterm>
<primary>pg_advisory_unlock</primary>
</indexterm>
<para>
and in addition, an SQL warning will be raised by the server.
</para>
- <indexterm zone="functions-admin">
+ <indexterm>
<primary>pg_advisory_unlock_shared</primary>
</indexterm>
<para>
except to release a shared advisory lock.
</para>
- <indexterm zone="functions-admin">
+ <indexterm>
<primary>pg_advisory_unlock_all</primary>
</indexterm>
<para>