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

Commit 4f02cbc

Browse files
committed
Doc: add cross-references between array_to_string and string_to_array.
These functions aren't exact inverses, but they're closely related; yet we document them in two different sections. Add cross-ref <link>s to improve that situation. While here, move the strpos and substr entries to re-alphabetize Table 9.10. Also, drop an ancient compatibility note about string_to_array, which wasn't even on the right page, so probably few people ever saw it. Discussion: https://postgr.es/m/164287017550.704.5840412183184961677@wrigleys.postgresql.org
1 parent d8fbbb9 commit 4f02cbc

File tree

1 file changed

+52
-62
lines changed

1 file changed

+52
-62
lines changed

doc/src/sgml/func.sgml

+52-62
Original file line numberDiff line numberDiff line change
@@ -3508,54 +3508,6 @@ repeat('Pg', 4) <returnvalue>PgPgPgPg</returnvalue>
35083508
</para></entry>
35093509
</row>
35103510

3511-
<row>
3512-
<entry role="func_table_entry"><para role="func_signature">
3513-
<indexterm>
3514-
<primary>strpos</primary>
3515-
</indexterm>
3516-
<function>strpos</function> ( <parameter>string</parameter> <type>text</type>, <parameter>substring</parameter> <type>text</type> )
3517-
<returnvalue>integer</returnvalue>
3518-
</para>
3519-
<para>
3520-
Returns first starting index of the specified <parameter>substring</parameter>
3521-
within <parameter>string</parameter>, or zero if it's not present.
3522-
(Same as <literal>position(<parameter>substring</parameter> in
3523-
<parameter>string</parameter>)</literal>, but note the reversed
3524-
argument order.)
3525-
</para>
3526-
<para>
3527-
<literal>strpos('high', 'ig')</literal>
3528-
<returnvalue>2</returnvalue>
3529-
</para></entry>
3530-
</row>
3531-
3532-
<row>
3533-
<entry role="func_table_entry"><para role="func_signature">
3534-
<indexterm>
3535-
<primary>substr</primary>
3536-
</indexterm>
3537-
<function>substr</function> ( <parameter>string</parameter> <type>text</type>, <parameter>start</parameter> <type>integer</type> <optional>, <parameter>count</parameter> <type>integer</type> </optional> )
3538-
<returnvalue>text</returnvalue>
3539-
</para>
3540-
<para>
3541-
Extracts the substring of <parameter>string</parameter> starting at
3542-
the <parameter>start</parameter>'th character,
3543-
and extending for <parameter>count</parameter> characters if that is
3544-
specified. (Same
3545-
as <literal>substring(<parameter>string</parameter>
3546-
from <parameter>start</parameter>
3547-
for <parameter>count</parameter>)</literal>.)
3548-
</para>
3549-
<para>
3550-
<literal>substr('alphabet', 3)</literal>
3551-
<returnvalue>phabet</returnvalue>
3552-
</para>
3553-
<para>
3554-
<literal>substr('alphabet', 3, 2)</literal>
3555-
<returnvalue>ph</returnvalue>
3556-
</para></entry>
3557-
</row>
3558-
35593511
<row>
35603512
<entry role="func_table_entry"><para role="func_signature">
35613513
<indexterm>
@@ -3576,7 +3528,7 @@ repeat('Pg', 4) <returnvalue>PgPgPgPg</returnvalue>
35763528

35773529
<row>
35783530
<entry role="func_table_entry"><para role="func_signature">
3579-
<indexterm>
3531+
<indexterm id="function-string-to-array">
35803532
<primary>string_to_array</primary>
35813533
</indexterm>
35823534
<function>string_to_array</function> ( <parameter>string</parameter> <type>text</type>, <parameter>delimiter</parameter> <type>text</type> <optional>, <parameter>null_string</parameter> <type>text</type> </optional> )
@@ -3594,6 +3546,7 @@ repeat('Pg', 4) <returnvalue>PgPgPgPg</returnvalue>
35943546
If <parameter>null_string</parameter> is supplied and is
35953547
not <literal>NULL</literal>, fields matching that string are
35963548
replaced by <literal>NULL</literal>.
3549+
See also <link linkend="function-array-to-string"><function>array_to_string</function></link>.
35973550
</para>
35983551
<para>
35993552
<literal>string_to_array('xx~~yy~~zz', '~~', 'yy')</literal>
@@ -3633,6 +3586,54 @@ repeat('Pg', 4) <returnvalue>PgPgPgPg</returnvalue>
36333586
</para></entry>
36343587
</row>
36353588

3589+
<row>
3590+
<entry role="func_table_entry"><para role="func_signature">
3591+
<indexterm>
3592+
<primary>strpos</primary>
3593+
</indexterm>
3594+
<function>strpos</function> ( <parameter>string</parameter> <type>text</type>, <parameter>substring</parameter> <type>text</type> )
3595+
<returnvalue>integer</returnvalue>
3596+
</para>
3597+
<para>
3598+
Returns first starting index of the specified <parameter>substring</parameter>
3599+
within <parameter>string</parameter>, or zero if it's not present.
3600+
(Same as <literal>position(<parameter>substring</parameter> in
3601+
<parameter>string</parameter>)</literal>, but note the reversed
3602+
argument order.)
3603+
</para>
3604+
<para>
3605+
<literal>strpos('high', 'ig')</literal>
3606+
<returnvalue>2</returnvalue>
3607+
</para></entry>
3608+
</row>
3609+
3610+
<row>
3611+
<entry role="func_table_entry"><para role="func_signature">
3612+
<indexterm>
3613+
<primary>substr</primary>
3614+
</indexterm>
3615+
<function>substr</function> ( <parameter>string</parameter> <type>text</type>, <parameter>start</parameter> <type>integer</type> <optional>, <parameter>count</parameter> <type>integer</type> </optional> )
3616+
<returnvalue>text</returnvalue>
3617+
</para>
3618+
<para>
3619+
Extracts the substring of <parameter>string</parameter> starting at
3620+
the <parameter>start</parameter>'th character,
3621+
and extending for <parameter>count</parameter> characters if that is
3622+
specified. (Same
3623+
as <literal>substring(<parameter>string</parameter>
3624+
from <parameter>start</parameter>
3625+
for <parameter>count</parameter>)</literal>.)
3626+
</para>
3627+
<para>
3628+
<literal>substr('alphabet', 3)</literal>
3629+
<returnvalue>phabet</returnvalue>
3630+
</para>
3631+
<para>
3632+
<literal>substr('alphabet', 3, 2)</literal>
3633+
<returnvalue>ph</returnvalue>
3634+
</para></entry>
3635+
</row>
3636+
36363637
<row>
36373638
<entry role="func_table_entry"><para role="func_signature">
36383639
<indexterm>
@@ -18452,7 +18453,7 @@ SELECT NULLIF(value, '(none)') ...
1845218453

1845318454
<row>
1845418455
<entry role="func_table_entry"><para role="func_signature">
18455-
<indexterm>
18456+
<indexterm id="function-array-to-string">
1845618457
<primary>array_to_string</primary>
1845718458
</indexterm>
1845818459
<function>array_to_string</function> ( <parameter>array</parameter> <type>anyarray</type>, <parameter>delimiter</parameter> <type>text</type> <optional>, <parameter>null_string</parameter> <type>text</type> </optional> )
@@ -18465,6 +18466,7 @@ SELECT NULLIF(value, '(none)') ...
1846518466
If <parameter>null_string</parameter> is given and is
1846618467
not <literal>NULL</literal>, then <literal>NULL</literal> array
1846718468
entries are represented by that string; otherwise, they are omitted.
18469+
See also <link linkend="function-string-to-array"><function>string_to_array</function></link>.
1846818470
</para>
1846918471
<para>
1847018472
<literal>array_to_string(ARRAY[1, 2, 3, NULL, 5], ',', '*')</literal>
@@ -18584,18 +18586,6 @@ SELECT NULLIF(value, '(none)') ...
1858418586
</tgroup>
1858518587
</table>
1858618588

18587-
<note>
18588-
<para>
18589-
There are two differences in the behavior of <function>string_to_array</function>
18590-
from pre-9.1 versions of <productname>PostgreSQL</productname>.
18591-
First, it will return an empty (zero-element) array rather
18592-
than <literal>NULL</literal> when the input string is of zero length.
18593-
Second, if the delimiter string is <literal>NULL</literal>, the function
18594-
splits the input into individual characters, rather than
18595-
returning <literal>NULL</literal> as before.
18596-
</para>
18597-
</note>
18598-
1859918589
<para>
1860018590
See also <xref linkend="functions-aggregate"/> about the aggregate
1860118591
function <function>array_agg</function> for use with arrays.

0 commit comments

Comments
 (0)