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: PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: proposal: searching in array function - array_position
Date: 2015-01-17 18:56:54
Message-ID: CAFj8pRAXwxo_=HxSSww-DaADfThWb1NKkr4bnpVv-HHwJw7agw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

2015-01-16 17:57 GMT+01:00 Jim Nasby <Jim(dot)Nasby(at)bluetreble(dot)com>:

> On 1/16/15 3:39 AM, Pavel Stehule wrote:
>
>> I am proposing a simple function, that returns a position of element in
>> array.
>>
>
> Yes please!
>
> FUNCTION array_position(anyarray, anyelement) RETURNS int
>>
>
> That won't work on a multi-dimensional array. Ideally it needs to accept a
> slice or an element and return the specifier for the slice.
>

theoretically you can use this function for md arrays too. This function
returns offset, and you can calculate a Nd possition

so maybe better name -- array_offset or some similar

Regards

Pavel

>
> This wouldn't be so bad if we had an easier way to extract subsets of an
> array, but even that is really ugly because whatever you extract keeps the
> original number of dimensions.
>
> Implementation is simple (plpgsql code)
>>
>
> This would actually be written in C though, yes? Otherwise it's not really
> any better than just doing an extension...
> --
> Jim Nasby, Data Architect, Blue Treble Consulting
> Data in Trouble? Get it in Treble! http://BlueTreble.com
>

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Petr Jelinek 2015-01-17 19:16:39 Re: TABLESAMPLE patch
Previous Message Sawada Masahiko 2015-01-17 16:33:24 Re: Merging postgresql.conf and postgresql.auto.conf