Re: add function argument name to substring and substr - Mailing list pgsql-hackers

From jian he
Subject Re: add function argument name to substring and substr
Date
Msg-id CACJufxFxreB2wwWRO3PFdd8zF1wrGo4_PsOtGAxXNwrZ=LLGkg@mail.gmail.com
Whole thread Raw
In response to Re: add function argument name to substring and substr  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-hackers
On Tue, Oct 14, 2025 at 12:11 AM Tom Lane <tgl@sss.pgh.pa.us> wrote:
>
> Andrew Dunstan <andrew@dunslane.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

pgsql-hackers by date:

Previous
From: "Maksim.Melnikov"
Date:
Subject: Re: Panic during xlog building with big values
Next
From: Peter Smith
Date:
Subject: Re: POC: enable logical decoding when wal_level = 'replica' without a server restart