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

Поиск
Список
Период
Сортировка
От Joel Jacobson
Тема Re: [PATCH] Add support for leading/trailing bytea trim()ing
Дата
Msg-id a2874477-56ee-46d6-b8fc-e607f0e08f4c@www.fastmail.com
обсуждение исходный текст
Ответ на Re: [PATCH] Add support for leading/trailing bytea trim()ing  (Tom Lane <tgl@sss.pgh.pa.us>)
Ответы Re: [PATCH] Add support for leading/trailing bytea trim()ing  (Tom Lane <tgl@sss.pgh.pa.us>)
Список 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


Вложения

В списке pgsql-hackers по дате отправления:

Предыдущее
От: Amit Kapila
Дата:
Сообщение: Re: POC: Cleaning up orphaned files using undo logs
Следующее
От: Amit Kapila
Дата:
Сообщение: Re: Parallel Inserts in CREATE TABLE AS