Re: proposal: searching in array function - array_position

From: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
To: Jim Nasby <Jim(dot)Nasby(at)bluetreble(dot)com>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, 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-21 06:06:55
Message-ID: CAFj8pRCYak+N7E83F2SR9dTi0QrXBbSkezqkLzo=b9-2phRqsg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

2015-03-21 0:27 GMT+01:00 Jim Nasby <Jim(dot)Nasby(at)bluetreble(dot)com>:

> 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.
>

additional implementation of array_position needs few lines more

>
> 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?

We talked about it, when we talked about MD searching - and we moved it to
next stage.

I am thinking so array_postions can support MD arrays due returning a array

Regards

Pavel

>
>
> --
> Jim Nasby, Data Architect, Blue Treble Consulting
> Data in Trouble? Get it in Treble! http://BlueTreble.com
>

Attachment Content-Type Size
array_position.patch text/x-patch 7.0 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Jaime Casanova 2015-03-21 06:28:22 Re: Remove fsync ON/OFF as a visible option?
Previous Message Michael Paquier 2015-03-21 04:29:22 Re: Remove fsync ON/OFF as a visible option?