From 84a42560c82aeb9f3690d93a0d03cf544f53b89b Mon Sep 17 00:00:00 2001 From: Tom Lane Date: Wed, 11 Jul 2012 13:59:35 -0400 Subject: Add array_remove() and array_replace() functions. These functions support removing or replacing array element value(s) matching a given search value. Although intended mainly to support a future array-foreign-key feature, they seem useful in their own right. Marco Nenciarini and Gabriele Bartolini, reviewed by Alex Hunsaker --- doc/src/sgml/func.sgml | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) (limited to 'doc/src') diff --git a/doc/src/sgml/func.sgml b/doc/src/sgml/func.sgml index 4f539428e28..157de09b4ea 100644 --- a/doc/src/sgml/func.sgml +++ b/doc/src/sgml/func.sgml @@ -10316,6 +10316,12 @@ SELECT NULLIF(value, '(none)') ... array_prepend + + array_remove + + + array_replace + array_to_string @@ -10432,6 +10438,29 @@ SELECT NULLIF(value, '(none)') ... array_prepend(1, ARRAY[2,3]) {1,2,3} + + + + array_remove(anyarray, anyelement) + + + anyarray + remove all elements equal to the given value from the array + (array must be one-dimensional) + array_remove(ARRAY[1,2,3,2], 2) + {1,3} + + + + + array_replace(anyarray, anyelement, anyelement) + + + anyarray + replace each array element equal to the given value with a new value + array_replace(ARRAY[1,2,5,4], 5, 3) + {1,2,3,4} + -- cgit v1.2.3