[PATCH] Add support for leading/trailing bytea trim()ing
Joel Jacobson <joel@compiler.org>
From: "Joel Jacobson" <joel@compiler.org>
To: pgsql-hackers@lists.postgresql.org
Date: 2020-12-04T16:30:43Z
Lists: pgsql-hackers
Attachments
- leading-trailing-trim-bytea.patch (application/octet-stream) patch
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
Commits
-
Add bytea equivalents of ltrim() and rtrim().
- a6cf3df4ebdc 14.0 landed
-
Improve our ability to regurgitate SQL-syntax function calls.
- 40c24bfef925 14.0 cited