diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2016-11-30 13:34:14 -0500 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2016-11-30 13:34:14 -0500 |
commit | dd3edfe630fecd561568455a2c47ec5858a95e8c (patch) | |
tree | 83d219e56a165d7a4a50e3a58afee6296dfaaf77 | |
parent | e5b8aa636a63a9446e244fcc8d3a262e3e14049a (diff) | |
download | postgresql-dd3edfe630fecd561568455a2c47ec5858a95e8c.tar.gz postgresql-dd3edfe630fecd561568455a2c47ec5858a95e8c.zip |
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
-rw-r--r-- | doc/src/sgml/func.sgml | 33 |
1 files changed, 17 insertions, 16 deletions
diff --git a/doc/src/sgml/func.sgml b/doc/src/sgml/func.sgml index 960342973ce..4f832a76aad 100644 --- a/doc/src/sgml/func.sgml +++ b/doc/src/sgml/func.sgml @@ -1534,11 +1534,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> @@ -1547,14 +1548,14 @@ <literal><function>trim(<optional>leading | trailing | both</optional> <optional>from</optional> <parameter>string</parameter> - <optional><parameter>, characters</parameter></optional> + <optional>, <parameter>characters</parameter></optional> )</function></literal> </entry> <entry><type>text</type></entry> <entry> - Non-standard version of <function>trim()</> + Non-standard syntax for <function>trim()</> </entry> - <entry><literal>trim(both from 'xTomxx', 'x')</literal></entry> + <entry><literal>trim(both from 'yxTomxx', 'xyz')</literal></entry> <entry><literal>Tom</literal></entry> </row> @@ -1626,7 +1627,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> @@ -1895,8 +1896,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> @@ -2201,8 +2202,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> @@ -3467,11 +3468,11 @@ SELECT format('Testing %3$s, %2$s, %s', 'one', 'two', 'three'); </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> @@ -3510,11 +3511,11 @@ SELECT format('Testing %3$s, %2$s, %s', 'one', 'two', 'three'); </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> |