Hi, Recently I wanted to call array_reverse() and discovered that we still don't have it. I'm not the first one who encountered this limitation. array_reverse() was requested at least since 2009 [1] and the workaround on PostgreSQL Wiki is dated 2010 [2].
The proposed patch adds this function. Only the first dimension of the array is reversed, for consistency with the existing functions such as array_shuffle() [3]. Examples: =# SELECT array_reverse(ARRAY[1,2,3,NULL]); array_reverse --------------- {NULL,3,2,1} =# SELECT array_reverse(ARRAY[[1,2],[3,4],[5,6]]); array_reverse --------------------- {{5,6},{3,4},{1,2}} Thoughts? [1]: http://postgr.es/m/4AEE80FC.7010608%40postnewspapers.com.au [2]: https://wiki.postgresql.org/wiki/Array_reverse [3]: https://www.postgresql.org/docs/current/functions-array.html -- Best regards, Aleksander Alekseev
v1-0001-Add-array_reverse-function.patch
Description: Binary data