diff options
| author | Tom Lane | 2016-11-30 18:34:14 +0000 |
|---|---|---|
| committer | Tom Lane | 2016-11-30 18:34:14 +0000 |
| commit | 3e65fd045a924f4c4cfaa0f73857db28558afd11 (patch) | |
| tree | 1aa1e8443571dcc3e81b92d6759f587a9bb42b66 /doc | |
| parent | f45719997d3c8c8feb563ea9976ced15681de1ce (diff) | |
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
Diffstat (limited to 'doc')
| -rw-r--r-- | doc/src/sgml/func.sgml | 27 |
1 files changed, 14 insertions, 13 deletions
diff --git a/doc/src/sgml/func.sgml b/doc/src/sgml/func.sgml index 5752c0f9e75..c37ef80026e 100644 --- a/doc/src/sgml/func.sgml +++ b/doc/src/sgml/func.sgml @@ -1306,11 +1306,12 @@ </entry> <entry><type>text</type></entry> <entry> - Remove the longest string containing only the + Remove the longest string containing only characters from <parameter>characters</parameter> (a space by default) from the - start/end/both ends of the <parameter>string</parameter> + start, end, or both ends (<literal>both</> is the default) + of <parameter>string</parameter> </entry> - <entry><literal>trim(both 'x' from 'xTomxx')</literal></entry> + <entry><literal>trim(both 'xyz' from 'yxTomxx')</literal></entry> <entry><literal>Tom</literal></entry> </row> @@ -1382,7 +1383,7 @@ in <parameter>characters</parameter> (a space by default) from the start and end of <parameter>string</parameter> </entry> - <entry><literal>btrim('xyxtrimyyx', 'xy')</literal></entry> + <entry><literal>btrim('xyxtrimyyx', 'xyz')</literal></entry> <entry><literal>trim</literal></entry> </row> @@ -1657,8 +1658,8 @@ <parameter>characters</parameter> (a space by default) from the start of <parameter>string</parameter> </entry> - <entry><literal>ltrim('zzzytrim', 'xyz')</literal></entry> - <entry><literal>trim</literal></entry> + <entry><literal>ltrim('zzzytest', 'xyz')</literal></entry> + <entry><literal>test</literal></entry> </row> <row> @@ -1940,8 +1941,8 @@ <parameter>characters</parameter> (a space by default) from the end of <parameter>string</parameter> </entry> - <entry><literal>rtrim('trimxxxx', 'x')</literal></entry> - <entry><literal>trim</literal></entry> + <entry><literal>rtrim('testxxzx', 'xyz')</literal></entry> + <entry><literal>test</literal></entry> </row> <row> @@ -2985,11 +2986,11 @@ </entry> <entry><type>bytea</type></entry> <entry> - Remove the longest string containing only the bytes in + Remove the longest string containing only bytes appearing in <parameter>bytes</parameter> from the start and end of <parameter>string</parameter> </entry> - <entry><literal>trim(E'\\000'::bytea from E'\\000Tom\\000'::bytea)</literal></entry> + <entry><literal>trim(E'\\000\\001'::bytea from E'\\000Tom\\001'::bytea)</literal></entry> <entry><literal>Tom</literal></entry> </row> </tbody> @@ -3028,11 +3029,11 @@ </entry> <entry><type>bytea</type></entry> <entry> - Remove the longest string consisting only of bytes - in <parameter>bytes</parameter> from the start and end of + Remove the longest string containing only bytes appearing in + <parameter>bytes</parameter> from the start and end of <parameter>string</parameter> </entry> - <entry><literal>btrim(E'\\000trim\\000'::bytea, E'\\000'::bytea)</literal></entry> + <entry><literal>btrim(E'\\000trim\\001'::bytea, E'\\000\\001'::bytea)</literal></entry> <entry><literal>trim</literal></entry> </row> |
