mirror of
https://github.com/postgres/postgres.git
synced 2025-07-30 11:03:19 +03:00
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
This commit is contained in:
@ -10316,6 +10316,12 @@ SELECT NULLIF(value, '(none)') ...
|
||||
<indexterm>
|
||||
<primary>array_prepend</primary>
|
||||
</indexterm>
|
||||
<indexterm>
|
||||
<primary>array_remove</primary>
|
||||
</indexterm>
|
||||
<indexterm>
|
||||
<primary>array_replace</primary>
|
||||
</indexterm>
|
||||
<indexterm>
|
||||
<primary>array_to_string</primary>
|
||||
</indexterm>
|
||||
@ -10432,6 +10438,29 @@ SELECT NULLIF(value, '(none)') ...
|
||||
<entry><literal>array_prepend(1, ARRAY[2,3])</literal></entry>
|
||||
<entry><literal>{1,2,3}</literal></entry>
|
||||
</row>
|
||||
<row>
|
||||
<entry>
|
||||
<literal>
|
||||
<function>array_remove</function>(<type>anyarray</type>, <type>anyelement</type>)
|
||||
</literal>
|
||||
</entry>
|
||||
<entry><type>anyarray</type></entry>
|
||||
<entry>remove all elements equal to the given value from the array
|
||||
(array must be one-dimensional)</entry>
|
||||
<entry><literal>array_remove(ARRAY[1,2,3,2], 2)</literal></entry>
|
||||
<entry><literal>{1,3}</literal></entry>
|
||||
</row>
|
||||
<row>
|
||||
<entry>
|
||||
<literal>
|
||||
<function>array_replace</function>(<type>anyarray</type>, <type>anyelement</type>, <type>anyelement</type>)
|
||||
</literal>
|
||||
</entry>
|
||||
<entry><type>anyarray</type></entry>
|
||||
<entry>replace each array element equal to the given value with a new value</entry>
|
||||
<entry><literal>array_replace(ARRAY[1,2,5,4], 5, 3)</literal></entry>
|
||||
<entry><literal>{1,2,3,4}</literal></entry>
|
||||
</row>
|
||||
<row>
|
||||
<entry>
|
||||
<literal>
|
||||
|
Reference in New Issue
Block a user