1
0
mirror of https://github.com/postgres/postgres.git synced 2025-07-31 22:04:40 +03:00

Add trim_array() function.

This has been in the SQL spec since 2008.  It's a pretty thin
wrapper around the array slice functionality, but the spec
says we should have it, so here it is.

Vik Fearing, reviewed by Dian Fay

Discussion: https://postgr.es/m/fc92ce17-9655-8ff1-c62a-4dc4c8ccd815@postgresfriends.org
This commit is contained in:
Tom Lane
2021-03-03 16:39:57 -05:00
parent 3769e11a31
commit 0a687c8f10
7 changed files with 100 additions and 2 deletions

View File

@ -17930,6 +17930,24 @@ SELECT NULLIF(value, '(none)') ...
</para></entry>
</row>
<row>
<entry role="func_table_entry"><para role="func_signature">
<indexterm>
<primary>trim_array</primary>
</indexterm>
<function>trim_array</function> ( <parameter>array</parameter> <type>anyarray</type>, <parameter>n</parameter> <type>integer</type> )
<returnvalue>anyarray</returnvalue>
</para>
<para>
Trims an array by removing the last <parameter>n</parameter> elements.
If the array is multidimensional, only the first dimension is trimmed.
</para>
<para>
<literal>trim_array(ARRAY[1,2,3,4,5,6], 2)</literal>
<returnvalue>{1,2,3,4}</returnvalue>
</para></entry>
</row>
<row>
<entry role="func_table_entry"><para role="func_signature">
<indexterm>