Re: proposal: searching in array function - array_position

From: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
To: Alvaro Herrera <alvherre(at)2ndquadrant(dot)com>
Cc: Dean Rasheed <dean(dot)a(dot)rasheed(at)gmail(dot)com>, Marko Tiikkaja <marko(at)joh(dot)to>, Jim Nasby <Jim(dot)Nasby(at)bluetreble(dot)com>, 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-22 06:11:22
Message-ID: CAFj8pRBeBapPz5eSi7v2arQbt8txMaL88-fcCrdgjw20wwQitA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi

here is updated patch with array_position, array_positions implementation.

It is based on committed code - so please, revert commit
13dbc7a824b3f905904cab51840d37f31a07a9ef and apply this patch

Regards

Pavel

2015-03-20 18:29 GMT+01:00 Alvaro Herrera <alvherre(at)2ndquadrant(dot)com>:

> Pavel Stehule wrote:
> > 2015-03-20 17:49 GMT+01:00 Dean Rasheed <dean(dot)a(dot)rasheed(at)gmail(dot)com>:
> >
> > > 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.
>
> So you can't use it as a subscript? That sounds unfriendly. Almost
> every function using this will be subtly broken.
>
> --
> Álvaro Herrera http://www.2ndQuadrant.com/
> PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services
>

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

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message David Rowley 2015-03-22 06:42:21 Re: Performance improvement for joins where outer side is unique
Previous Message Tom Lane 2015-03-22 05:42:56 Re: Zero-padding and zero-masking fixes for to_char(float)