11<!--
2- $PostgreSQL: pgsql/doc/src/sgml/func.sgml,v 1.231 2004/12/21 01:02:28 momjian Exp $
2+ $PostgreSQL: pgsql/doc/src/sgml/func.sgml,v 1.232 2004/12/23 23:07:38 tgl Exp $
33PostgreSQL documentation
44-->
55
@@ -1347,7 +1347,8 @@ PostgreSQL documentation
13471347 <footnote>
13481348 <para>
13491349 The <function>to_ascii</function> function supports conversion from
1350- <literal>LATIN1</>, <literal>LATIN2</>, and <literal>WIN1250</> only.
1350+ <literal>LATIN1</>, <literal>LATIN2</>, <literal>LATIN9</>,
1351+ and <literal>WIN1250</> encodings only.
13511352 </para>
13521353 </footnote>
13531354 </entry>
@@ -2483,11 +2484,11 @@ cast(-44 as bit(12)) <lineannotation>111111010100</lineannotation>
24832484 There are three separate approaches to pattern matching provided
24842485 by <productname>PostgreSQL</productname>: the traditional
24852486 <acronym>SQL</acronym> <function>LIKE</function> operator, the
2486- more recent <literal>> SIMILAR TO</literal > operator (since
2487+ more recent <function> SIMILAR TO</function > operator (added in
24872488 SQL:1999), and <acronym>POSIX</acronym>-style regular expressions.
24882489 Additionally, a pattern matching function,
24892490 <function>substring</function>, is available, using either
2490- <literal >SIMILAR TO</literal >-style or POSIX-style regular
2491+ <function >SIMILAR TO</function >-style or POSIX-style regular
24912492 expressions.
24922493 </para>
24932494
@@ -2544,7 +2545,7 @@ cast(-44 as bit(12)) <lineannotation>111111010100</lineannotation>
25442545
25452546 <para>
25462547 <function>LIKE</function> pattern matches always cover the entire
2547- string. To match apattern anywhere within a string, the
2548+ string. To match asequence anywhere within a string, the
25482549 pattern must therefore start and end with a percent sign.
25492550 </para>
25502551
@@ -2578,7 +2579,7 @@ cast(-44 as bit(12)) <lineannotation>111111010100</lineannotation>
25782579
25792580 <para>
25802581 The key word <token>ILIKE</token> can be used instead of
2581- <token>LIKE</token> to make the match case insensitive according
2582+ <token>LIKE</token> to make the match case- insensitive according
25822583 to the active locale. This is not in the <acronym>SQL</acronym> standard but is a
25832584 <productname>PostgreSQL</productname> extension.
25842585 </para>
@@ -2818,9 +2819,11 @@ substring('foobar' from '#"o_b#"%' for '#') <lineannotation>NULL</lineannotat
28182819 pattern. But if the pattern contains any parentheses, the portion
28192820 of the text that matched the first parenthesized subexpression (the
28202821 one whose left parenthesis comes first) is
2821- returned. You canalways put parentheses around the whole expression
2822+ returned. You can put parentheses around the whole expression
28222823 if you want to use parentheses within it without triggering this
2823- exception. Also see the non-capturing parentheses described below.
2824+ exception. If you need parentheses in the pattern before the
2825+ subexpression you want to extract, see the non-capturing parentheses
2826+ described below.
28242827 </para>
28252828
28262829 <para>
@@ -3073,7 +3076,7 @@ substring('foobar' from 'o(.)b') <lineannotation>o</lineannotation>
30733076
30743077 <para>
30753078 The forms using <literal>{</><replaceable>...</><literal>}</>
3076- are known as <firstterm>bound </>s .
3079+ are known as <firstterm>bounds </>.
30773080 The numbers <replaceable>m</> and <replaceable>n</> within a bound are
30783081 unsigned decimal integers with permissible values from 0 to 255 inclusive.
30793082 </para>
@@ -3603,9 +3606,10 @@ substring('foobar' from 'o(.)b') <lineannotation>o</lineannotation>
36033606 Normally the flavor of RE being used is determined by
36043607 <varname>regex_flavor</>.
36053608 However, this can be overridden by a <firstterm>director</> prefix.
3606- If an RE of any flavor begins with <literal>***:</>,
3607- the rest of the RE is taken as an ARE.
3608- If an RE of any flavor begins with <literal>***=</>,
3609+ If an RE begins with <literal>***:</>,
3610+ the rest of the RE is taken as an ARE regardless of
3611+ <varname>regex_flavor</>.
3612+ If an RE begins with <literal>***=</>,
36093613 the rest of the RE is taken to be a literal string,
36103614 with all characters considered ordinary characters.
36113615 </para>
@@ -3703,8 +3707,8 @@ substring('foobar' from 'o(.)b') <lineannotation>o</lineannotation>
37033707
37043708 <para>
37053709 Embedded options take effect at the <literal>)</> terminating the sequence.
3706- Theyare available only at the start of an ARE,
3707- and may not be used later within it .
3710+ Theymay appear only at the start of an ARE (after the
3711+ <literal>***:</> director if any) .
37083712 </para>
37093713
37103714 <para>
@@ -3732,13 +3736,13 @@ substring('foobar' from 'o(.)b') <lineannotation>o</lineannotation>
37323736 </listitem>
37333737 <listitem>
37343738 <para>
3735- white space and commentsare illegal within multi-character symbols,
3736- like the ARE <literal>(?:</> or the BRE <literal>\( </>
3739+ white space and commentscannot appear within multi-character symbols,
3740+ such as <literal>(?:</>
37373741 </para>
37383742 </listitem>
37393743 </itemizedlist>
37403744
3741- Expanded-syntax white-space characters are blank, tab, newline, and
3745+ For this purpose, white-space characters are blank, tab, newline, and
37423746 any character that belongs to the <replaceable>space</> character class.
37433747 </para>
37443748
@@ -4330,7 +4334,7 @@ substring('foobar' from 'o(.)b') <lineannotation>o</lineannotation>
43304334 </table>
43314335
43324336 <para>
4333- Usage notes forthe date/time formatting:
4337+ Usage notes for date/time formatting:
43344338
43354339 <itemizedlist>
43364340 <listitem>
@@ -4506,7 +4510,7 @@ substring('foobar' from 'o(.)b') <lineannotation>o</lineannotation>
45064510 </table>
45074511
45084512 <para>
4509- Usage notes forthe numeric formatting:
4513+ Usage notes for numeric formatting:
45104514
45114515 <itemizedlist>
45124516 <listitem>
@@ -5068,10 +5072,10 @@ EXTRACT (<replaceable>field</replaceable> FROM <replaceable>source</replaceable>
50685072
50695073 <para>
50705074 The <function>extract</function> function retrieves subfields
5071- from date/time values, such as year or hour.
5072- <replaceable>source</replaceable>is a value expressionthat
5073- evaluates to type <type>timestamp</type> or <type>interval</type>.
5074- (Expressions of type <type>date</type>or <type>time</type> will
5075+ such as year or hour from date/time values .
5076+ <replaceable>source</replaceable>must be a value expressionof
5077+ type <type>timestamp</type>, <type>time</type>, or <type>interval</type>.
5078+ (Expressions of type <type>date</type> will
50755079 be cast to <type>timestamp</type> and can therefore be used as
50765080 well.) <replaceable>field</replaceable> is an identifier or
50775081 string that selects what field to extract from the source value.
@@ -5699,7 +5703,7 @@ SELECT TIMESTAMP 'now';
56995703</programlisting>
57005704 </para>
57015705
5702- <note >
5706+ <tip >
57035707 <para>
57045708 You do not want to use the third form when specifying a <literal>DEFAULT</>
57055709 clause while creating a table. The system will convert <literal>now</literal>
@@ -5710,7 +5714,7 @@ SELECT TIMESTAMP 'now';
57105714 because they are function calls. Thus they will give the desired
57115715 behavior of defaulting to the time of row insertion.
57125716 </para>
5713- </note >
5717+ </tip >
57145718 </sect2>
57155719 </sect1>
57165720
@@ -6803,7 +6807,7 @@ SELECT NULLIF(value, '(none)') ...
68036807 <para>
68046808 <xref linkend="array-functions-table"> shows the functions
68056809 available for use with array types. See <xref linkend="arrays">
6806- for more discussion and examplesfor the use of these functions.
6810+ for more discussion and examplesof the use of these functions.
68076811 </para>
68086812
68096813 <table id="array-functions-table">
@@ -6827,10 +6831,7 @@ SELECT NULLIF(value, '(none)') ...
68276831 </literal>
68286832 </entry>
68296833<entry><type>anyarray</type></entry>
6830- <entry>
6831- concatenate two arrays, returning <literal>NULL</literal>
6832- for <literal>NULL</literal> inputs
6833- </entry>
6834+ <entry>concatenate two arrays</entry>
68346835<entry><literal>array_cat(ARRAY[1,2,3], ARRAY[4,5])</literal></entry>
68356836<entry><literal>{1,2,3,4,5}</literal></entry>
68366837 </row>
@@ -6842,10 +6843,7 @@ SELECT NULLIF(value, '(none)') ...
68426843 </literal>
68436844 </entry>
68446845<entry><type>anyarray</type></entry>
6845- <entry>
6846- append an element to the end of an array, returning
6847- <literal>NULL</literal> for <literal>NULL</literal> inputs
6848- </entry>
6846+ <entry>append an element to the end of an array</entry>
68496847<entry><literal>array_append(ARRAY[1,2], 3)</literal></entry>
68506848<entry><literal>{1,2,3}</literal></entry>
68516849 </row>
@@ -6857,10 +6855,7 @@ SELECT NULLIF(value, '(none)') ...
68576855 </literal>
68586856 </entry>
68596857<entry><type>anyarray</type></entry>
6860- <entry>
6861- append an element to the beginning of an array, returning
6862- <literal>NULL</literal> for <literal>NULL</literal> inputs
6863- </entry>
6858+ <entry>append an element to the beginning of an array</entry>
68646859<entry><literal>array_prepend(1, ARRAY[2,3])</literal></entry>
68656860<entry><literal>{1,2,3}</literal></entry>
68666861 </row>
@@ -6872,10 +6867,7 @@ SELECT NULLIF(value, '(none)') ...
68726867 </literal>
68736868 </entry>
68746869<entry><type>text</type></entry>
6875- <entry>
6876- returns a text representation of array dimension lower and upper bounds,
6877- generating an ERROR for <literal>NULL</literal> inputs
6878- </entry>
6870+ <entry>returns a text representation of array's dimensions</entry>
68796871<entry><literal>array_dims(array[[1,2,3], [4,5,6]])</literal></entry>
68806872<entry><literal>[1:2][1:3]</literal></entry>
68816873 </row>
@@ -6887,10 +6879,7 @@ SELECT NULLIF(value, '(none)') ...
68876879 </literal>
68886880 </entry>
68896881<entry><type>integer</type></entry>
6890- <entry>
6891- returns lower bound of the requested array dimension, returning
6892- <literal>NULL</literal> for <literal>NULL</literal> inputs
6893- </entry>
6882+ <entry>returns lower bound of the requested array dimension</entry>
68946883<entry><literal>array_lower(array_prepend(0, ARRAY[1,2,3]), 1)</literal></entry>
68956884<entry><literal>0</literal></entry>
68966885 </row>
@@ -6902,10 +6891,7 @@ SELECT NULLIF(value, '(none)') ...
69026891 </literal>
69036892 </entry>
69046893<entry><type>integer</type></entry>
6905- <entry>
6906- returns upper bound of the requested array dimension, returning
6907- <literal>NULL</literal> for <literal>NULL</literal> inputs
6908- </entry>
6894+ <entry>returns upper bound of the requested array dimension</entry>
69096895<entry><literal>array_upper(ARRAY[1,2,3,4], 1)</literal></entry>
69106896<entry><literal>4</literal></entry>
69116897 </row>
@@ -6917,10 +6903,7 @@ SELECT NULLIF(value, '(none)') ...
69176903 </literal>
69186904 </entry>
69196905<entry><type>text</type></entry>
6920- <entry>
6921- concatenates array elements using provided delimiter, returning
6922- <literal>NULL</literal> for <literal>NULL</literal> inputs
6923- </entry>
6906+ <entry>concatenates array elements using provided delimiter</entry>
69246907<entry><literal>array_to_string(array[1, 2, 3], '~^~')</literal></entry>
69256908<entry><literal>1~^~2~^~3</literal></entry>
69266909 </row>
@@ -6932,10 +6915,7 @@ SELECT NULLIF(value, '(none)') ...
69326915 </literal>
69336916 </entry>
69346917<entry><type>text[]</type></entry>
6935- <entry>
6936- splits string into array elements using provided delimiter, returning
6937- <literal>NULL</literal> for <literal>NULL</literal> inputs
6938- </entry>
6918+ <entry>splits string into array elements using provided delimiter</entry>
69396919<entry><literal>string_to_array( 'xx~^~yy~^~zz', '~^~')</literal></entry>
69406920<entry><literal>{xx,yy,zz}</literal></entry>
69416921 </row>
@@ -7181,7 +7161,7 @@ SELECT NULLIF(value, '(none)') ...
71817161 It should be noted that except for <function>count</function>,
71827162 these functions return a null value when no rows are selected. In
71837163 particular, <function>sum</function> of no rows returns null, not
7184- zero as one might expect. Thefunction <function>coalesce</function> may be
7164+ zero as one might expect. The <function>coalesce</function> function may be
71857165 used to substitute zero for null when necessary.
71867166 </para>
71877167
@@ -8045,9 +8025,10 @@ select current_date + s.a as dates from generate_series(0,14,7) as s(a);
80458025 </indexterm>
80468026
80478027 <para>
8048- The <function>session_user</function> is the user that initiated a
8049- database connection; it is fixed for the duration of that
8050- connection. The <function>current_user</function> is the user identifier
8028+ The <function>session_user</function> is normally the user who initiated
8029+ the current database connection; but superusers can change this setting
8030+ with <xref linkend="sql-set-session-authorization">.
8031+ The <function>current_user</function> is the user identifier
80518032 that is applicable for permission checking. Normally, it is equal
80528033 to the session user, but it changes during the execution of
80538034 functions with the attribute <literal>SECURITY DEFINER</literal>.
@@ -8106,8 +8087,8 @@ SET search_path TO <replaceable>schema</> <optional>, <replaceable>schema</>, ..
81068087 <function>inet_server_addr</function> returns the IP address on which
81078088 the server accepted the current connection, and
81088089 <function>inet_server_port</function> returns the port number.
8109- All these functions return NULL if the connection is via a Unix-domain
8110- socket.
8090+ All these functions return NULL if thecurrent connection is via a
8091+ Unix-domain socket.
81118092 </para>
81128093
81138094 <indexterm zone="functions-info">
@@ -8325,7 +8306,7 @@ SELECT has_function_privilege('joeuser', 'myfunc(int, text)', 'execute');
83258306 </para>
83268307
83278308 <para>
8328- Toevaluate whether a user holds a grant option on the privilege,
8309+ Totest whether a user holds a grant option on the privilege,
83298310 append <literal> WITH GRANT OPTION</literal> to the privilege key
83308311 word; for example <literal>'UPDATE WITH GRANT OPTION'</literal>.
83318312 </para>