Re: proposal: searching in array function - array_position - Mailing list pgsql-hackers

From Pavel Stehule
Subject Re: proposal: searching in array function - array_position
Date
Msg-id CAFj8pRA5t81AgvmwmCPNzJLZKeahENvG3QXrCrf+qGX3E6mqPQ@mail.gmail.com
Whole thread Raw
In response to Re: proposal: searching in array function - array_position  (Dean Rasheed <dean.a.rasheed@gmail.com>)
Responses Re: proposal: searching in array function - array_position
List pgsql-hackers


2015-03-20 17:49 GMT+01:00 Dean Rasheed <dean.a.rasheed@gmail.com>:
On 18 March 2015 at 19:03, Alvaro Herrera <alvherre@2ndquadrant.com> wrote:
> Pushed after adding error checks there and fixing the docs to match.
> Please verify.
>

There's an issue when the array's lower bound isn't 1:

select array_offset('[2:4]={1,2,3}'::int[], 1);
 array_offset
--------------
            1
(1 row)

whereas I would expect this to return 2. Similarly for
array_offsets(), so the offsets can be used as indexes into the
original array.

I am thinking, so it is ok - it returns a offset, not position.

Regards

Pavel
 

Regards,
Dean

pgsql-hackers by date:

Previous
From: Dean Rasheed
Date:
Subject: Re: proposal: searching in array function - array_position
Next
From: David Christensen
Date:
Subject: Re: [PATCH] two-arg current_setting() with fallback