BEGINNER HACKERS: array_remove(anyarray, anyarray)

From: Jim Nasby <Jim(dot)Nasby(at)BlueTreble(dot)com>
To: Pg Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: BEGINNER HACKERS: array_remove(anyarray, anyarray)
Date: 2016-01-08 00:33:51
Message-ID: 568F03EF.4070804@BlueTreble.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 12/10/15 6:25 PM, Jim Nasby wrote:
> Recently I had need of removing occurrences of a number of values from
> an array. Obviously I could have nested array_remove() call or wrapped
> the whole thing in a SELECT unnest(), but that seems rather silly and
> inefficient.
>
> Any one have objections to changing array_replace_internal() to make
> search and replace arrays instead of Datums?

Seeing none... let's see if someone wants to tackle this.

The goal is to modify array_replace_internal() (in
src/backend/utils/adt/arrayfuncs.c) so that two of it's arguments
(search and replace) can be arrays. I believe the best way to do that
would be to add bool search_isarray and bool replace_isarray arguments,
and have array_replace_internal() act accordingly if those are true.

The expected behavior when search_isarray is true would be to search for
a group of elements that completely match the search array. When
replace_isarray is true, then any replacements into *array would be the
elements from replace, growing or shrinking the array as necessary.

The user visible array_remove and array_replace functions will need to
check the data type of their inputs using get_fn_expr_argtype(). You can
find examples of that in arrayfuncs.c.

A complete patch will also need regression tests
(src/test/regress/sql/arrays.sql) and tweaks to the documentation for
those functions (doc/src/sgml/func.sgml).
--
Jim Nasby, Data Architect, Blue Treble Consulting, Austin TX
Experts in Analytics, Data Architecture and PostgreSQL
Data in Trouble? Get it in Treble! http://BlueTreble.com

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2016-01-08 00:53:21 Re: BUG #13854: SSPI authentication failure: wrong realm name used
Previous Message chris 2016-01-08 00:25:26 BUG #13854: SSPI authentication failure: wrong realm name used