1
0
mirror of https://github.com/postgres/postgres.git synced 2025-07-28 23:42:10 +03:00

August 6, 2002

1. Reworked patch from Andrey Oktyabrski (ano@spider.ru) with
      functions: icount, sort, sort_asc, uniq, idx, subarray
      operations: #, +, -, |, &

FUNCTIONS:

  int   icount(int[]) - the number of elements in intarray
  int[] sort(int[], 'asc' | 'desc') - sort intarray
  int[] sort(int[]) - sort in ascending order
  int[] sort_asc(int[]),sort_desc(int[]) - shortcuts for sort
  int[] uniq(int[]) - returns unique elements
  int   idx(int[], int item) - returns index of first intarray matching element
                               to item, or '0' if matching failed.
  int[] subarray(int[],int START [, int LEN]) - returns part of intarray
                               starting from element number START (from 1)
                               and length LEN.
OPERATIONS:

  int[] && int[]  - overlap - returns TRUE if arrays has at least one common elements.
  int[] @  int[]  - contains - returns TRUE if left array contains right array
  int[] ~ int[]   - contained - returns TRUE if left array is contained in right array
  # int[]         - return the number of elements in array
  int[] + int     - push element to array ( add to end of array)
  int[] + int[]   - merge of arrays (right array added to the end of left one)
  int[] - int     - remove entries matched by right argument from array
  int[] - int[]   - remove left array from right
  int[] | int     - returns intarray - union of arguments
  int[] | int[]   - returns intarray as a union of two arrays
  int[] & int[]   - returns intersection of arrays

Oleg Bartunov
This commit is contained in:
Bruce Momjian
2002-08-10 20:38:29 +00:00
parent c5354dff20
commit 181ca96e7a
5 changed files with 572 additions and 1 deletions

View File

@ -123,6 +123,81 @@ CREATE OPERATOR ~ (
COMMUTATOR = '@', RESTRICT = contsel, JOIN = contjoinsel
);
--------------
CREATE FUNCTION intset(int4) RETURNS _int4
AS 'MODULE_PATHNAME' LANGUAGE 'c' WITH (isStrict, isCachable);
CREATE FUNCTION icount(_int4) RETURNS int4
AS 'MODULE_PATHNAME' LANGUAGE 'c' WITH (isStrict, isCachable);
CREATE OPERATOR # (
RIGHTARG = _int4, PROCEDURE = icount
);
CREATE FUNCTION sort(_int4, text) RETURNS _int4
AS 'MODULE_PATHNAME' LANGUAGE 'c' WITH (isStrict, isCachable);
CREATE FUNCTION sort(_int4) RETURNS _int4
AS 'MODULE_PATHNAME' LANGUAGE 'c' WITH (isStrict, isCachable);
CREATE FUNCTION sort_asc(_int4) RETURNS _int4
AS 'MODULE_PATHNAME' LANGUAGE 'c' WITH (isStrict, isCachable);
CREATE FUNCTION sort_desc(_int4) RETURNS _int4
AS 'MODULE_PATHNAME' LANGUAGE 'c' WITH (isStrict, isCachable);
CREATE FUNCTION uniq(_int4) RETURNS _int4
AS 'MODULE_PATHNAME' LANGUAGE 'c' WITH (isStrict, isCachable);
CREATE FUNCTION idx(_int4, int4) RETURNS int4
AS 'MODULE_PATHNAME' LANGUAGE 'c' WITH (isStrict, isCachable);
CREATE OPERATOR # (
LEFTARG = _int4, RIGHTARG = int4, PROCEDURE = idx
);
CREATE FUNCTION subarray(_int4, int4, int4) RETURNS _int4
AS 'MODULE_PATHNAME' LANGUAGE 'c' WITH (isStrict, isCachable);
CREATE FUNCTION subarray(_int4, int4) RETURNS _int4
AS 'MODULE_PATHNAME' LANGUAGE 'c' WITH (isStrict, isCachable);
CREATE FUNCTION intarray_push_elem(_int4, int4) RETURNS _int4
AS 'MODULE_PATHNAME' LANGUAGE 'c' WITH (isStrict, isCachable);
CREATE OPERATOR + (
LEFTARG = _int4, RIGHTARG = int4, PROCEDURE = intarray_push_elem
);
CREATE FUNCTION intarray_push_array(_int4, _int4) RETURNS _int4
AS 'MODULE_PATHNAME' LANGUAGE 'c' WITH (isStrict, isCachable);
CREATE OPERATOR + (
LEFTARG = _int4, RIGHTARG = _int4, COMMUTATOR = +, PROCEDURE = intarray_push_array
);
CREATE FUNCTION intarray_del_elem(_int4, int4) RETURNS _int4
AS 'MODULE_PATHNAME' LANGUAGE 'c' WITH (isStrict, isCachable);
CREATE OPERATOR - (
LEFTARG = _int4, RIGHTARG = int4, PROCEDURE = intarray_del_elem
);
CREATE FUNCTION intset_union_elem(_int4, int4) RETURNS _int4
AS 'MODULE_PATHNAME' LANGUAGE 'c' WITH (isStrict, isCachable);
CREATE OPERATOR | (
LEFTARG = _int4, RIGHTARG = int4, PROCEDURE = intset_union_elem
);
CREATE OPERATOR | (
LEFTARG = _int4, RIGHTARG = _int4, COMMUTATOR = |, PROCEDURE = _int_union
);
CREATE FUNCTION intset_subtract(_int4, _int4) RETURNS _int4
AS 'MODULE_PATHNAME' LANGUAGE 'c' WITH (isStrict, isCachable);
CREATE OPERATOR - (
LEFTARG = _int4, RIGHTARG = _int4, PROCEDURE = intset_subtract
);
CREATE OPERATOR & (
LEFTARG = _int4, RIGHTARG = _int4, COMMUTATOR = &, PROCEDURE = _int_inter
);
--------------
-- define the GiST support methods
CREATE FUNCTION g_int_consistent(opaque,_int4,int4) RETURNS bool