Re: proposal: searching in array function - array_position

From: Jim Nasby <Jim(dot)Nasby(at)BlueTreble(dot)com>
To: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Alvaro Herrera <alvherre(at)2ndquadrant(dot)com>, Dean Rasheed <dean(dot)a(dot)rasheed(at)gmail(dot)com>, Marko Tiikkaja <marko(at)joh(dot)to>, Petr Jelinek <petr(at)2ndquadrant(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>, Robert Haas <robertmhaas(at)gmail(dot)com>
Subject: Re: proposal: searching in array function - array_position
Date: 2015-03-20 23:27:40
Message-ID: 550CACEC.8030609@BlueTreble.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 3/20/15 2:48 PM, Pavel Stehule wrote:
>
>
> 2015-03-20 18:47 GMT+01:00 Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us
> <mailto:tgl(at)sss(dot)pgh(dot)pa(dot)us>>:
>
> Alvaro Herrera <alvherre(at)2ndquadrant(dot)com
> <mailto:alvherre(at)2ndquadrant(dot)com>> writes:
> > Pavel Stehule wrote:
> >> I am thinking, so it is ok - it returns a offset, not position.
>
> > So you can't use it as a subscript? That sounds unfriendly. Almost
> > every function using this will be subtly broken.
>
> I concur; perhaps "offset" was the design intention, but it's wrong.
> The result should be a subscript.
>
>
> do you have any idea about name for this function? array_position is ok?

+1 on array_position. It's possible at some point we'll actually want
array_offset that does what it claims.

On another note, you mentioned elsewhere that it's not possible to
return anything other than an integer. Why can't there be a variation of
this function that returns an array of ndims-1 that is the slice where a
value was found?
--
Jim Nasby, Data Architect, Blue Treble Consulting
Data in Trouble? Get it in Treble! http://BlueTreble.com

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Jim Nasby 2015-03-20 23:44:03 Re: Superuser connect during smart shutdown
Previous Message David E. Wheeler 2015-03-20 23:25:07 Re: Patch: Add launchd Support