Dear hackers,

Let's say we want to strip the leading zero bytes from 
'\x0000beefbabe00'::bytea.

This is currently not supported, since trim() for bytea values only support the 
BOTH mode:

SELECT trim(LEADING '\x00'::bytea FROM '\x0000beefbabe00'::bytea);
ERROR:  function pg_catalog.ltrim(bytea, bytea) does not exist

The attached patch adds LEADING | TRAILING support for the bytea version of 
trim():

SELECT trim(LEADING '\x00'::bytea FROM '\x0000beefbabe00'::bytea);
    ltrim
--------------
\xbeefbabe00

SELECT trim(TRAILING '\x00'::bytea FROM '\x0000beefbabe00'::bytea);
     rtrim
----------------
\x0000beefbabe

Best regards,

Joel Jacobson

Attachment: leading-trailing-trim-bytea.patch
Description: Binary data

Reply via email to