Re: add function argument name to substring and substr

From: jian he <jian(dot)universality(at)gmail(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Andrew Dunstan <andrew(at)dunslane(dot)net>, "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>, Marcos Pegoraro <marcos(at)f10(dot)com(dot)br>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: add function argument name to substring and substr
Date: 2025-10-14 07:44:11
Message-ID: CACJufxFxreB2wwWRO3PFdd8zF1wrGo4_PsOtGAxXNwrZ=LLGkg@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Tue, Oct 14, 2025 at 12:11 AM Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
>
> Andrew Dunstan <andrew(at)dunslane(dot)net> writes:
> > I'm late to the party on this, but I wonder if it wouldn't be better to
> > use a type-neutral parameter name here, like "source", which could cover
> > all these cases, instead of "string", "bytes", etc.
>
> +1 for that idea. As Jian notes, we'd need to make the docs match,
> but I think that this would be an improvement across the board.
> Parameter names like "string" don't convey much information.
>

please check the attached v8.

\df substr
List of functions
Schema | Name | Result data type | Argument data
types | Type
------------+--------+------------------+--------------------------------------------+------
pg_catalog | substr | bytea | source bytea, start integer
| func
pg_catalog | substr | bytea | source bytea, start integer,
count integer | func
pg_catalog | substr | text | source text, start integer
| func
pg_catalog | substr | text | source text, start
integer, count integer | func
(4 rows)

\df substring
List of functions
Schema | Name | Result data type | Argument data
types | Type
------------+-----------+------------------+--------------------------------------------+------
pg_catalog | substring | bit | source bit, start integer
| func
pg_catalog | substring | bit | source bit, start
integer, count integer | func
pg_catalog | substring | bytea | source bytea, start
integer | func
pg_catalog | substring | bytea | source bytea, start
integer, count integer | func
pg_catalog | substring | text | source text, pattern text
| func
pg_catalog | substring | text | source text, pattern
text, escape text | func
pg_catalog | substring | text | source text, start
integer | func
pg_catalog | substring | text | source text, start
integer, count integer | func
(8 rows)

For function substr, the doc change is not that a big deal.

For function substring, in doc/src/sgml/func/func-matching.sgml, we need
change some of the
<replaceable>string</replaceable>
to
<replaceable>source</replaceable>.

we also need to change many
<parameter>string</parameter>
to
<parameter>source</parameter>.
That's why v8-0002 is big.

Attachment Content-Type Size
v8-0002-add-function-argument-name-to-function-substring.patch text/x-patch 19.6 KB
v8-0001-add-function-argument-name-to-function-substr.patch text/x-patch 4.9 KB

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Peter Smith 2025-10-14 07:51:48 Re: POC: enable logical decoding when wal_level = 'replica' without a server restart
Previous Message Maksim.Melnikov 2025-10-14 07:08:12 Re: Panic during xlog building with big values