[PATCH] Add support for leading/trailing bytea trim()ing

From: "Joel Jacobson" <joel(at)compiler(dot)org>
To: pgsql-hackers(at)lists(dot)postgresql(dot)org
Subject: [PATCH] Add support for leading/trailing bytea trim()ing
Date: 2020-12-04 16:30:43
Message-ID: d10cd5cd-a901-42f1-b832-763ac6f7ff3a@www.fastmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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 Content-Type Size
leading-trailing-trim-bytea.patch application/octet-stream 7.6 KB

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2020-12-04 16:37:38 Re: [PATCH] Add support for leading/trailing bytea trim()ing
Previous Message Laurenz Albe 2020-12-04 15:55:52 Re: Add session statistics to pg_stat_database