pg.ddx.io  pgsql-docs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
Substring undocumented form
2+ messages / 2 participants
[nested] [flat]

* Substring undocumented form
@ 2010-09-25 08:36  Thom Brown <thom@linux.com>
  0 siblings, 1 reply; 2+ messages in thread

From: Thom Brown @ 2010-09-25 08:36 UTC (permalink / raw)
  To: pgsql-docs

Hi all,

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?

Thanks

Thom Brown
Twitter: @darkixion
IRC (freenode): dark_ixion
Registered Linux user: #516935



^ permalink  raw  reply  [nested|flat] 2+ messages in thread

* Re: Substring undocumented form
@ 2010-09-25 13:40  Robert Haas <robertmhaas@gmail.com>
  parent: Thom Brown <thom@linux.com>
  0 siblings, 0 replies; 2+ messages in thread

From: Robert Haas @ 2010-09-25 13:40 UTC (permalink / raw)
  To: Thom Brown <thom@linux.com>; +Cc: pgsql-docs

On Sat, Sep 25, 2010 at 4:36 AM, Thom Brown <thom@linux.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



^ permalink  raw  reply  [nested|flat] 2+ messages in thread


end of thread, other threads:[~2010-09-25 13:40 UTC | newest]

Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2010-09-25 08:36 Substring undocumented form Thom Brown <thom@linux.com>
2010-09-25 13:40 ` Robert Haas <robertmhaas@gmail.com>

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