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

From: "Joel Jacobson" <joel(at)compiler(dot)org>
To: "Tom Lane" <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: pgsql-hackers(at)lists(dot)postgresql(dot)org
Subject: Re: [PATCH] Add support for leading/trailing bytea trim()ing
Date: 2020-12-05 07:22:13
Message-ID: a2874477-56ee-46d6-b8fc-e607f0e08f4c@www.fastmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Fri, Dec 4, 2020, at 22:02, Tom Lane wrote:
>"trim left ends" (plural) seems wrong. A string only has one left end,
>at least in my universe.

Fixed, the extra "s" came from copying from btrim()'s description.

>(Maybe the existing ltrim/rtrim descrs are also like this, but if so
I>'d change them too.)

They weren't, but I think the description for the bytea functions
can be improved to have a more precise description
if we take inspiration from the the text functions.

Here is an overview of all functions containing "trim" in the function name,
to get the full picture of the trim description terminology:

SELECT
oid,
pg_describe_object('pg_proc'::regclass,oid,0),
pg_catalog.obj_description(oid, 'pg_proc')
FROM pg_proc
WHERE proname LIKE '%trim%'
ORDER BY oid;

oid | pg_describe_object | obj_description
------+------------------------------+----------------------------------------------------------
875 | function ltrim(text,text) | trim selected characters from left end of string
876 | function rtrim(text,text) | trim selected characters from right end of string
881 | function ltrim(text) | trim spaces from left end of string
882 | function rtrim(text) | trim spaces from right end of string
884 | function btrim(text,text) | trim selected characters from both ends of string
885 | function btrim(text) | trim spaces from both ends of string
2015 | function btrim(bytea,bytea) | trim both ends of string
5043 | function trim_scale(numeric) | numeric with minimum scale needed to represent the value

Do we want the two new functions to derive their description from the existing bytea function?

9612 | function ltrim(bytea,bytea) | trim left end of string
9613 | function rtrim(bytea,bytea) | trim right end of string

Patch with this wording: leading-trailing-trim-bytea-left-right-end-of-string.patch

Or would it be better to be inspired by the more precise descriptions for the two parameter text functions,
and to change the existing btrim() function's description as well?

2015 | function btrim(bytea,bytea) | trim selected bytes from both ends of string
9612 | function ltrim(bytea,bytea) | trim selected bytes from left end of string
9613 | function rtrim(bytea,bytea) | trim selected bytes from right end of string

Patch with this wording: leading-trailing-trim-bytea-selected-bytes.patch

Best regards,

Joel

Attachment Content-Type Size
leading-trailing-trim-bytea-left-right-end-of-string.patch application/octet-stream 13.1 KB
leading-trailing-trim-bytea-selected-bytes.patch application/octet-stream 13.4 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Amit Kapila 2020-12-05 10:59:07 Re: Parallel Inserts in CREATE TABLE AS
Previous Message Amit Kapila 2020-12-05 06:00:56 Re: POC: Cleaning up orphaned files using undo logs