diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2021-01-18 15:11:32 -0500 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2021-01-18 15:11:32 -0500 |
commit | a6cf3df4ebdcbc7857910a67f259705645383e9f (patch) | |
tree | 250b8aba5eaaa349e103c87b021a8073750252d2 /doc/src | |
parent | a3ed4d1efe9f3a1765c504ba4a224f1f393b5b14 (diff) | |
download | postgresql-a6cf3df4ebdcbc7857910a67f259705645383e9f.tar.gz postgresql-a6cf3df4ebdcbc7857910a67f259705645383e9f.zip |
Add bytea equivalents of ltrim() and rtrim().
We had bytea btrim() already, but for some reason not the other two.
Joel Jacobson
Discussion: https://postgr.es/m/d10cd5cd-a901-42f1-b832-763ac6f7ff3a@www.fastmail.com
Diffstat (limited to 'doc/src')
-rw-r--r-- | doc/src/sgml/func.sgml | 49 |
1 files changed, 45 insertions, 4 deletions
diff --git a/doc/src/sgml/func.sgml b/doc/src/sgml/func.sgml index fd0370a1b43..aa99665e2eb 100644 --- a/doc/src/sgml/func.sgml +++ b/doc/src/sgml/func.sgml @@ -3948,15 +3948,16 @@ SELECT format('Testing %3$s, %2$s, %s', 'one', 'two', 'three'); <indexterm> <primary>trim</primary> </indexterm> - <function>trim</function> ( <optional> <literal>BOTH</literal> </optional> + <function>trim</function> ( <optional> <literal>LEADING</literal> | <literal>TRAILING</literal> | <literal>BOTH</literal> </optional> <parameter>bytesremoved</parameter> <type>bytea</type> <literal>FROM</literal> <parameter>bytes</parameter> <type>bytea</type> ) <returnvalue>bytea</returnvalue> </para> <para> Removes the longest string containing only bytes appearing in - <parameter>bytesremoved</parameter> from the start - and end of <parameter>bytes</parameter>. + <parameter>bytesremoved</parameter> from the start, + end, or both ends (<literal>BOTH</literal> is the default) + of <parameter>bytes</parameter>. </para> <para> <literal>trim('\x9012'::bytea from '\x1234567890'::bytea)</literal> @@ -3966,7 +3967,7 @@ SELECT format('Testing %3$s, %2$s, %s', 'one', 'two', 'three'); <row> <entry role="func_table_entry"><para role="func_signature"> - <function>trim</function> ( <optional> <literal>BOTH</literal> </optional> <optional> <literal>FROM</literal> </optional> + <function>trim</function> ( <optional> <literal>LEADING</literal> | <literal>TRAILING</literal> | <literal>BOTH</literal> </optional> <optional> <literal>FROM</literal> </optional> <parameter>bytes</parameter> <type>bytea</type>, <parameter>bytesremoved</parameter> <type>bytea</type> ) <returnvalue>bytea</returnvalue> @@ -4110,6 +4111,26 @@ SELECT format('Testing %3$s, %2$s, %s', 'one', 'two', 'three'); </row> <row> + <entry role="func_table_entry"><para role="func_signature"> + <indexterm> + <primary>ltrim</primary> + </indexterm> + <function>ltrim</function> ( <parameter>bytes</parameter> <type>bytea</type>, + <parameter>bytesremoved</parameter> <type>bytea</type> ) + <returnvalue>bytea</returnvalue> + </para> + <para> + Removes the longest string containing only bytes appearing in + <parameter>bytesremoved</parameter> from the start of + <parameter>bytes</parameter>. + </para> + <para> + <literal>ltrim('\x1234567890'::bytea, '\x9012'::bytea)</literal> + <returnvalue>\x34567890</returnvalue> + </para></entry> + </row> + + <row> <entry role="func_table_entry"><para role="func_signature"> <indexterm> <primary>md5</primary> @@ -4128,6 +4149,26 @@ SELECT format('Testing %3$s, %2$s, %s', 'one', 'two', 'three'); </row> <row> + <entry role="func_table_entry"><para role="func_signature"> + <indexterm> + <primary>rtrim</primary> + </indexterm> + <function>rtrim</function> ( <parameter>bytes</parameter> <type>bytea</type>, + <parameter>bytesremoved</parameter> <type>bytea</type> ) + <returnvalue>bytea</returnvalue> + </para> + <para> + Removes the longest string containing only bytes appearing in + <parameter>bytesremoved</parameter> from the end of + <parameter>bytes</parameter>. + </para> + <para> + <literal>rtrim('\x1234567890'::bytea, '\x9012'::bytea)</literal> + <returnvalue>\x12345678</returnvalue> + </para></entry> + </row> + + <row> <entry role="func_table_entry"><para role="func_signature"> <indexterm> <primary>set_bit</primary> |