Biginteger array functions

Are there any available functions for working with large integers?

I found the intarray module , but the functions from this module only work with integer, not bigint.

I am missing a function to remove an element from an array. Something like the implementation of the minus operator in the specified module:

int[] - int (remove the entries matching the correct argument from the array)

+2
source share
1 answer

Updated 2015 with the best version.
You can replace your own function. This is fast enough:

CREATE OR REPLACE FUNCTION arr_subtract(int8[], int8[])
  RETURNS int8[] AS
$func$
SELECT ARRAY(
    SELECT a
    FROM   unnest($1) WITH ORDINALITY x(a, ord)
    WHERE  a <> ALL ($2)
    ORDER  BY ord
    );
$func$  LANGUAGE sql IMMUTABLE;

Call:

SELECT arr_subtract('{3,5,6,7,8,9}':: int8[], '{3,4,8}'::int8[]);

Result:

{5,6,7,9}

Preserves the original array order.

on this topic:

+3

Source: https://habr.com/ru/post/1624504/


All Articles