Skip site navigation (1) Skip section navigation (2)

Re: Substring undocumented form

From: Robert Haas <robertmhaas(at)gmail(dot)com>
To: Thom Brown <thom(at)linux(dot)com>
Cc: pgsql-docs <pgsql-docs(at)postgresql(dot)org>
Subject: Re: Substring undocumented form
Date: 2010-09-25 13:40:08
Message-ID: AANLkTimdO6f41h40LcdUGCGsK-8cGpB2Mm9moEE5jH8r@mail.gmail.com (view raw or flat)
Thread:
Lists: pgsql-docs
On Sat, Sep 25, 2010 at 4:36 AM, Thom Brown <thom(at)linux(dot)com> wrote:
> Someone submitted a comment to the documentation which made mention of
> the fact that while we provide one form of the 3-parameter substring
> function, we don't mention an alternative one.
>
> substring(string from pattern for escape)
> can be written:
> substring(string, pattern, escape)
>
> Curiously, this doesn't appear to be the same with similar functions.
> For instance, the following can't be changed in a similar way:
>
> overlay('Txxxxas' placing 'hom' from 2 for 4)
> can't be written:
> overlay('Txxxxas', 'hom', 2, 4)
>
> position('om' in 'Thomas')
> can't be written:
> position('om', 'Thomas')
>
> So this doesn't look like a general alternative form.  Is the
> alternative form of substring deprecated or just missing from the
> documentation?

You can call any of them with the normal function call syntax as
pg_catalog.fn_name(...).  I think the reason why substring() works
anyway is because the substr_list nonterminal in gram.y includes a
production for expr_list.  The overlay_list and position_list
nonterminals are not similarly equipped.

As to whether or not such alternative forms should be documented, I
could go either way.

-- 
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise Postgres Company

In response to

pgsql-docs by date

Next:From: Robert HaasDate: 2010-09-25 13:50:00
Subject: Re: Inconsistent index links
Previous:From: Thom BrownDate: 2010-09-25 08:36:36
Subject: Substring undocumented form

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group