8000 Doc: improve description of trim() and related functions. · iakio/postgres@3e65fd0 · GitHub
[go: up one dir, main page]

Skip to content

Commit 3e65fd0

Browse files
committed
Doc: improve description of trim() and related functions.
Per bug #14441 from Mark Pether, the documentation could be misread, mainly because some of the examples failed to show what happens with a multicharacter "characters to trim" string. Also, while the text description in most of these entries was fairly clear that the "characters" argument is a set of characters not a substring to match, some of them used variant wording that was a bit less clear. trim() itself suffered from both deficiencies and was thus pretty misinterpretable. Also fix failure to explain which of LEADING/TRAILING/BOTH is the default. Discussion: https://postgr.es/m/20161130011710.6539.53657@wrigleys.postgresql.org
1 parent f457199 commit 3e65fd0

File tree

1 file changed

+14
-13
lines changed

doc/src/sgml/func.sgml

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1306,11 +1306,12 @@
13061306
</entry>
13071307
<entry><type>text</type></entry>
13081308
<entry>
1309-
Remove the longest string containing only the
1309+
Remove the longest string containing only characters from
13101310
<parameter>characters</parameter> (a space by default) from the
1311-
start/end/both ends of the <parameter>string</parameter>
1311+
start, end, or both ends (<literal>both</> is the default)
1312+
of <parameter>string</parameter>
13121313
</entry>
1313-
<entry><literal>trim(both 'x' from 'xTomxx')</literal></entry>
1314+
<entry><literal>trim(both 'xyz' from 'yxTomxx')</literal></entry>
13141315
<entry><literal>Tom</literal></entry>
13151316
</row>
13161317

@@ -1382,7 +1383,7 @@
13821383
in <parameter>characters</parameter> (a space by default)
13831384
from the start and end of <parameter>string</parameter>
13841385
</entry>
1385-
<entry><literal>btrim('xyxtrimyyx', 'xy')</literal></entry>
1386+
<entry><literal>btrim('xyxtrimyyx', 'xyz')</literal></entry>
13861387
<entry><literal>trim</literal></entry>
13871388
</row>
13881389

@@ -1657,8 +1658,8 @@
16571658
<parameter>characters</parameter> (a space by default) from the start of
16581659
<parameter>string</parameter>
16591660
</entry>
1660-
<entry><literal>ltrim('zzzytrim', 'xyz')</literal></entry>
1661-
<entry><literal>trim</literal></entry>
1661+
<entry><literal>ltrim('zzzytest', 'xyz')</literal></entry>
1662+
<entry><literal>test</literal></entry>
16621663
</row>
16631664

16641665
<row>
@@ -1940,8 +1941,8 @@
19401941
<parameter>characters</parameter> (a space by default) from the end of
19411942
<parameter>string</parameter>
19421943
</entry>
1943-
<entry><literal>rtrim('trimxxxx', 'x')</literal></entry>
1944-
<entry><literal>trim</literal></entry>
1944+
<entry><literal>rtrim('testxxzx', 'xyz')</literal></entry>
1945+
<entry><literal>test</literal></entry>
19451946
</row>
19461947

19471948
<row>
@@ -2985,11 +2986,11 @@
29852986
</entry>
29862987
<entry><type>bytea</type></entry>
29872988
<entry>
2988-
Remove the longest string containing only the bytes in
2989+
Remove the longest string containing only bytes appearing in
29892990
<parameter>bytes</parameter> from the start
29902991
and end of <parameter>string</parameter>
29912992
</entry>
2992-
<entry><literal>trim(E'\\000'::bytea from E'\\000Tom\\000'::bytea)</literal></entry>
2993+
<entry><literal>trim(E'\\000\\001'::bytea from E'\\000Tom\\001'::bytea)</literal></entry>
29932994
<entry><literal>Tom</literal></entry>
29942995
</row>
29952996
</tbody>
@@ -3028,11 +3029,11 @@
30283029
</entry>
30293030
<entry><type>bytea</type></entry>
30303031
<entry>
3031-
Remove the longest string consisting only of bytes
3032-
in <parameter>bytes</parameter> from the start and end of
3032+
Remove the longest string containing only bytes appearing in
3033+
<parameter>bytes</parameter> from the start and end of
30333034
<parameter>string</parameter>
30343035
</entry>
3035-
<entry><literal>btrim(E'\\000trim\\000'::bytea, E'\\000'::bytea)</literal></entry>
3036+
<entry><literal>btrim(E'\\000trim\\001'::bytea, E'\\000\\001'::bytea)</literal></entry>
30363037
<entry><literal>trim</literal></entry>
30373038
</row>
30383039

0 commit comments

Comments
 (0)
0