[PATCH] Add support for leading/trailing bytea trim()ing - Mailing list pgsql-hackers

From Joel Jacobson
Subject [PATCH] Add support for leading/trailing bytea trim()ing
Date
Msg-id d10cd5cd-a901-42f1-b832-763ac6f7ff3a@www.fastmail.com
Whole thread Raw
Responses Re: [PATCH] Add support for leading/trailing bytea trim()ing
List pgsql-hackers
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

pgsql-hackers by date:

Previous
From: Laurenz Albe
Date:
Subject: Re: Add session statistics to pg_stat_database
Next
From: Tom Lane
Date:
Subject: Re: [PATCH] Add support for leading/trailing bytea trim()ing