public inbox for [email protected]  
help / color / mirror / Atom feed
From: David G. Johnston <[email protected]>
To: jian he <[email protected]>
Cc: PostgreSQL-development <[email protected]>
Subject: Re: add function argument name to substring and substr
Date: Mon, 17 Feb 2025 15:12:59 -0700
Message-ID: <CAKFQuwYD477A9Oy2PxRr_KY8t=k=jbOUK83ie0dS7fcpBsXS3Q@mail.gmail.com> (raw)
In-Reply-To: <CACJufxHTBkymh06D4mGKNe1YfRNFN+gFBybmygWk=PtMqu00LQ@mail.gmail.com>
References: <CACJufxHTBkymh06D4mGKNe1YfRNFN+gFBybmygWk=PtMqu00LQ@mail.gmail.com>

On Tue, Jan 21, 2025 at 11:21 PM jian he <[email protected]>
wrote:

> hi.
>
> attached patch add function argument name to function substring and substr
> you can see the visual changes.
> mater behavior:
>
> \df substring
>                              List of functions
>    Schema   |   Name    | Result data type |   Argument data types   | Type
>
> ------------+-----------+------------------+-------------------------+------
>  pg_catalog | substring | bit              | bit, integer            | func
>  pg_catalog | substring | bit              | bit, integer, integer   | func
>  pg_catalog | substring | bytea         | bytea, integer          | func
>  pg_catalog | substring | bytea         | bytea, integer, integer | func
>  pg_catalog | substring | text             | text, integer           | func
>  pg_catalog | substring | text             | text, integer, integer  | func
>  pg_catalog | substring | text             | text, text              | func
>  pg_catalog | substring | text             | text, text, text        | func
>
> with patch
>                                           List of functions
>    Schema   |   Name    | Result data type |               Argument
> data types                | Type
>
> ------------+-----------+------------------+--------------------------------------------------+------
>  pg_catalog | substring | bit              | bits bit, start integer
>                        | func
>  pg_catalog | substring | bit              | bits bit, start integer,
> count integer           | func
>  pg_catalog | substring | bytea         | bytes bytea, start integer
>                     | func
>  pg_catalog | substring | bytea         | bytes bytea, start integer,
> count integer        | func
>  pg_catalog | substring | text             | string text, pattern text
>                        | func
>  pg_catalog | substring | text             | string text, pattern
> text, escape_character text | func
>  pg_catalog | substring | text             | string text, start
> integer                       | func
>  pg_catalog | substring | text             | string text, start
> integer, count integer        | func
>
> I did the same change to the function substr.
> since 9.7.2. SIMILAR TO Regular Expressions we use
> substring(string, pattern, escape-character)
> so i refactor the substring function argument name to
> substring(string text, pattern text, escape_character text).
>
> we can make it as ``substring(string text, pattern text, escape text).``
> then in 9.7.2, we need to change the substring synopsis section.
>
>
>

> one thing I am not sure is about
> 9.4. String Functions and Operators
> Table 9.9. SQL String Functions and Operators.
> Do we need entries for substring related functions?
>
> current signature
> substring ( string text [ FROM start integer ] [ FOR count integer ] )
> is kind of different from
> substring(string text, start integer, count integer).
> since the previous one can allow keywords "FROM", "FOR", the latter one
> won't.
>
>
Table 9.9 limits itself to those functions defined in the SQL standard;
which are basically the ones that use keywords instead of commas.

The substring(string, start, count) function you note is already covered in
Table 9.10 but we spell it substr(...)

I don't think adding yet more spellings of this same function is warranted
or desirable at this point.  I'd maybe add a note if substring(,,,) works
to substr saying that substring is a valid alias.  I could be convinced to
just document though.

David J.


view thread (12+ messages)  latest in thread

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: [email protected]
  Cc: [email protected], [email protected]
  Subject: Re: add function argument name to substring and substr
  In-Reply-To: <CAKFQuwYD477A9Oy2PxRr_KY8t=k=jbOUK83ie0dS7fcpBsXS3Q@mail.gmail.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox