mirror of
https://github.com/postgres/postgres.git
synced 2025-09-09 13:09:39 +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:
@@ -432,6 +432,17 @@ select unnest(array[1,2,3,4.5]::float8[]);
|
||||
select unnest(array[1,2,3,4.5]::numeric[]);
|
||||
select unnest(array[1,2,3,null,4,null,null,5,6]);
|
||||
select unnest(array[1,2,3,null,4,null,null,5,6]::text[]);
|
||||
select array_remove(array[1,2,2,3], 2);
|
||||
select array_remove(array[1,2,2,3], 5);
|
||||
select array_remove(array[1,NULL,NULL,3], NULL);
|
||||
select array_remove(array['A','CC','D','C','RR'], 'RR');
|
||||
select array_remove('{{1,2,2},{1,4,3}}', 2); -- not allowed
|
||||
select array_replace(array[1,2,5,4],5,3);
|
||||
select array_replace(array[1,2,5,4],5,NULL);
|
||||
select array_replace(array[1,2,NULL,4,NULL],NULL,5);
|
||||
select array_replace(array['A','B','DD','B'],'B','CC');
|
||||
select array_replace(array[1,NULL,3],NULL,NULL);
|
||||
select array_replace(array['AB',NULL,'CDE'],NULL,'12');
|
||||
|
||||
-- Insert/update on a column that is array of composite
|
||||
|
||||
|
Reference in New Issue
Block a user