aboutsummaryrefslogtreecommitdiff
path: root/contrib/intarray
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/intarray')
-rw-r--r--contrib/intarray/README.intarray22
-rw-r--r--contrib/intarray/_int.sql.in65
-rw-r--r--contrib/intarray/_int_gin.c2
-rw-r--r--contrib/intarray/_int_gist.c2
-rw-r--r--contrib/intarray/_intbig_gist.c2
-rw-r--r--contrib/intarray/expected/_int.out32
-rw-r--r--contrib/intarray/sql/_int.sql26
-rw-r--r--contrib/intarray/uninstall__int.sql10
8 files changed, 103 insertions, 58 deletions
diff --git a/contrib/intarray/README.intarray b/contrib/intarray/README.intarray
index 9c3ecbe2615..fd5fc8b685a 100644
--- a/contrib/intarray/README.intarray
+++ b/contrib/intarray/README.intarray
@@ -70,10 +70,10 @@ test=# select intset(1);
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[] - overlap - returns TRUE if arrays have at least one common element
+ 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[] - returns 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
@@ -81,8 +81,14 @@ OPERATIONS:
int[] | int - returns intarray - union of arguments
int[] | int[] - returns intarray as a union of two arrays
int[] & int[] - returns intersection of arrays
- int[] @@ query_int - returns TRUE if array satisfies query (like '1&(2|3)')
- query_int ~~ int[] - -/-
+ int[] @@ query_int - returns TRUE if array satisfies query (like '1&(2|3)')
+ query_int ~~ int[] - returns TRUE if array satisfies query (commutator of @@)
+
+(Before PostgreSQL 8.2, the containment operators @> and <@ were
+respectively called @ and ~. These names are still available, but are
+deprecated and will eventually be retired. Notice that the old names
+are reversed from the convention formerly followed by the core geometric
+datatypes!)
CHANGES:
@@ -128,9 +134,9 @@ CREATE INDEX message_rdtree_idx on message using gist ( sections gist__int_ops);
select message.mid from message where message.sections && '{1,2}';
-- select messages contains in sections 1 AND 2 - CONTAINS operator
- select message.mid from message where message.sections @ '{1,2}';
+ select message.mid from message where message.sections @> '{1,2}';
-- the same, CONTAINED operator
- select message.mid from message where '{1,2}' ~ message.sections;
+ select message.mid from message where '{1,2}' <@ message.sections;
BENCHMARK:
diff --git a/contrib/intarray/_int.sql.in b/contrib/intarray/_int.sql.in
index 31fae745415..37530a9062c 100644
--- a/contrib/intarray/_int.sql.in
+++ b/contrib/intarray/_int.sql.in
@@ -12,12 +12,12 @@ BEGIN;
CREATE FUNCTION bqarr_in(cstring)
RETURNS query_int
AS 'MODULE_PATHNAME'
-LANGUAGE C RETURNS NULL ON NULL INPUT;
+LANGUAGE C RETURNS NULL ON NULL INPUT IMMUTABLE;
CREATE FUNCTION bqarr_out(query_int)
RETURNS cstring
AS 'MODULE_PATHNAME'
-LANGUAGE C RETURNS NULL ON NULL INPUT;
+LANGUAGE C RETURNS NULL ON NULL INPUT IMMUTABLE;
CREATE TYPE query_int (
INTERNALLENGTH = -1,
@@ -29,20 +29,20 @@ CREATE TYPE query_int (
CREATE FUNCTION querytree(query_int)
RETURNS text
AS 'MODULE_PATHNAME'
-LANGUAGE C RETURNS NULL ON NULL INPUT;
+LANGUAGE C RETURNS NULL ON NULL INPUT IMMUTABLE;
CREATE FUNCTION boolop(_int4, query_int)
RETURNS bool
AS 'MODULE_PATHNAME'
-LANGUAGE C RETURNS NULL ON NULL INPUT;
+LANGUAGE C RETURNS NULL ON NULL INPUT IMMUTABLE;
COMMENT ON FUNCTION boolop(_int4, query_int) IS 'boolean operation with array';
CREATE FUNCTION rboolop(query_int, _int4)
RETURNS bool
AS 'MODULE_PATHNAME'
-LANGUAGE C RETURNS NULL ON NULL INPUT;
+LANGUAGE C RETURNS NULL ON NULL INPUT IMMUTABLE;
COMMENT ON FUNCTION rboolop(query_int, _int4) IS 'boolean operation with array';
@@ -74,35 +74,35 @@ CREATE OPERATOR ~~ (
CREATE FUNCTION _int_contains(_int4, _int4)
RETURNS bool
AS 'MODULE_PATHNAME'
-LANGUAGE C RETURNS NULL ON NULL INPUT;
+LANGUAGE C RETURNS NULL ON NULL INPUT IMMUTABLE;
COMMENT ON FUNCTION _int_contains(_int4, _int4) IS 'contains';
CREATE FUNCTION _int_contained(_int4, _int4)
RETURNS bool
AS 'MODULE_PATHNAME'
-LANGUAGE C RETURNS NULL ON NULL INPUT;
+LANGUAGE C RETURNS NULL ON NULL INPUT IMMUTABLE;
COMMENT ON FUNCTION _int_contained(_int4, _int4) IS 'contained in';
CREATE FUNCTION _int_overlap(_int4, _int4)
RETURNS bool
AS 'MODULE_PATHNAME'
-LANGUAGE C RETURNS NULL ON NULL INPUT;
+LANGUAGE C RETURNS NULL ON NULL INPUT IMMUTABLE;
COMMENT ON FUNCTION _int_overlap(_int4, _int4) IS 'overlaps';
CREATE FUNCTION _int_same(_int4, _int4)
RETURNS bool
AS 'MODULE_PATHNAME'
-LANGUAGE C RETURNS NULL ON NULL INPUT;
+LANGUAGE C RETURNS NULL ON NULL INPUT IMMUTABLE;
COMMENT ON FUNCTION _int_same(_int4, _int4) IS 'same as';
CREATE FUNCTION _int_different(_int4, _int4)
RETURNS bool
AS 'MODULE_PATHNAME'
-LANGUAGE C RETURNS NULL ON NULL INPUT;
+LANGUAGE C RETURNS NULL ON NULL INPUT IMMUTABLE;
COMMENT ON FUNCTION _int_different(_int4, _int4) IS 'different';
@@ -111,12 +111,12 @@ COMMENT ON FUNCTION _int_different(_int4, _int4) IS 'different';
CREATE FUNCTION _int_union(_int4, _int4)
RETURNS _int4
AS 'MODULE_PATHNAME'
-LANGUAGE C RETURNS NULL ON NULL INPUT;
+LANGUAGE C RETURNS NULL ON NULL INPUT IMMUTABLE;
CREATE FUNCTION _int_inter(_int4, _int4)
RETURNS _int4
AS 'MODULE_PATHNAME'
-LANGUAGE C RETURNS NULL ON NULL INPUT;
+LANGUAGE C RETURNS NULL ON NULL INPUT IMMUTABLE;
--
-- OPERATORS
@@ -153,6 +153,25 @@ CREATE OPERATOR && (
-- JOIN = neqjoinsel
--);
+CREATE OPERATOR @> (
+ LEFTARG = _int4,
+ RIGHTARG = _int4,
+ PROCEDURE = _int_contains,
+ COMMUTATOR = '<@',
+ RESTRICT = contsel,
+ JOIN = contjoinsel
+);
+
+CREATE OPERATOR <@ (
+ LEFTARG = _int4,
+ RIGHTARG = _int4,
+ PROCEDURE = _int_contained,
+ COMMUTATOR = '@>',
+ RESTRICT = contsel,
+ JOIN = contjoinsel
+);
+
+-- obsolete:
CREATE OPERATOR @ (
LEFTARG = _int4,
RIGHTARG = _int4,
@@ -347,8 +366,10 @@ CREATE OPERATOR CLASS gist__int_ops
DEFAULT FOR TYPE _int4 USING gist AS
OPERATOR 3 &&,
OPERATOR 6 = (anyarray, anyarray) RECHECK,
- OPERATOR 7 @,
- OPERATOR 8 ~,
+ OPERATOR 7 @>,
+ OPERATOR 8 <@,
+ OPERATOR 13 @,
+ OPERATOR 14 ~,
OPERATOR 20 @@ (_int4, query_int),
FUNCTION 1 g_int_consistent (internal, _int4, int4),
FUNCTION 2 g_int_union (internal, internal),
@@ -367,12 +388,12 @@ DEFAULT FOR TYPE _int4 USING gist AS
CREATE FUNCTION _intbig_in(cstring)
RETURNS intbig_gkey
AS 'MODULE_PATHNAME'
-LANGUAGE C RETURNS NULL ON NULL INPUT;
+LANGUAGE C RETURNS NULL ON NULL INPUT IMMUTABLE;
CREATE FUNCTION _intbig_out(intbig_gkey)
RETURNS cstring
AS 'MODULE_PATHNAME'
-LANGUAGE C RETURNS NULL ON NULL INPUT;
+LANGUAGE C RETURNS NULL ON NULL INPUT IMMUTABLE;
CREATE TYPE intbig_gkey (
INTERNALLENGTH = -1,
@@ -422,8 +443,10 @@ FOR TYPE _int4 USING gist
AS
OPERATOR 3 && RECHECK,
OPERATOR 6 = (anyarray, anyarray) RECHECK,
- OPERATOR 7 @ RECHECK,
- OPERATOR 8 ~ RECHECK,
+ OPERATOR 7 @> RECHECK,
+ OPERATOR 8 <@ RECHECK,
+ OPERATOR 13 @ RECHECK,
+ OPERATOR 14 ~ RECHECK,
OPERATOR 20 @@ (_int4, query_int) RECHECK,
FUNCTION 1 g_intbig_consistent (internal, internal, int4),
FUNCTION 2 g_intbig_union (internal, internal),
@@ -455,8 +478,10 @@ DEFAULT FOR TYPE _int4 USING gin
AS
OPERATOR 3 &&,
OPERATOR 6 = (anyarray, anyarray) RECHECK,
- OPERATOR 7 @,
- OPERATOR 8 ~ RECHECK,
+ OPERATOR 7 @>,
+ OPERATOR 8 <@ RECHECK,
+ OPERATOR 13 @,
+ OPERATOR 14 ~ RECHECK,
OPERATOR 20 @@ (_int4, query_int),
FUNCTION 1 btint4cmp (int4, int4),
FUNCTION 2 ginarrayextract (anyarray, internal),
diff --git a/contrib/intarray/_int_gin.c b/contrib/intarray/_int_gin.c
index dfbb6e2ff1d..2a2830e578d 100644
--- a/contrib/intarray/_int_gin.c
+++ b/contrib/intarray/_int_gin.c
@@ -68,12 +68,14 @@ ginint4_consistent(PG_FUNCTION_ARGS) {
switch( strategy ) {
case RTOverlapStrategyNumber:
case RTContainedByStrategyNumber:
+ case RTOldContainedByStrategyNumber:
/* at least one element in check[] is true, so result = true */
res = TRUE;
break;
case RTSameStrategyNumber:
case RTContainsStrategyNumber:
+ case RTOldContainsStrategyNumber:
res = TRUE;
do {
ArrayType *query = PG_GETARG_ARRAYTYPE_P(2);
diff --git a/contrib/intarray/_int_gist.c b/contrib/intarray/_int_gist.c
index df5ae03e54d..71c9ad0cec5 100644
--- a/contrib/intarray/_int_gist.c
+++ b/contrib/intarray/_int_gist.c
@@ -72,10 +72,12 @@ g_int_consistent(PG_FUNCTION_ARGS)
query);
break;
case RTContainsStrategyNumber:
+ case RTOldContainsStrategyNumber:
retval = inner_int_contains((ArrayType *) DatumGetPointer(entry->key),
query);
break;
case RTContainedByStrategyNumber:
+ case RTOldContainedByStrategyNumber:
if (GIST_LEAF(entry))
retval = inner_int_contains(query,
(ArrayType *) DatumGetPointer(entry->key));
diff --git a/contrib/intarray/_intbig_gist.c b/contrib/intarray/_intbig_gist.c
index 626421f83c3..b25814c7ce7 100644
--- a/contrib/intarray/_intbig_gist.c
+++ b/contrib/intarray/_intbig_gist.c
@@ -560,9 +560,11 @@ g_intbig_consistent(PG_FUNCTION_ARGS)
retval = _intbig_contains((GISTTYPE *) DatumGetPointer(entry->key), query);
break;
case RTContainsStrategyNumber:
+ case RTOldContainsStrategyNumber:
retval = _intbig_contains((GISTTYPE *) DatumGetPointer(entry->key), query);
break;
case RTContainedByStrategyNumber:
+ case RTOldContainedByStrategyNumber:
if (GIST_LEAF(entry))
{
int i,
diff --git a/contrib/intarray/expected/_int.out b/contrib/intarray/expected/_int.out
index e45ed3cfa83..140aa20a172 100644
--- a/contrib/intarray/expected/_int.out
+++ b/contrib/intarray/expected/_int.out
@@ -2,13 +2,9 @@
-- first, define the datatype. Turn off echoing so that expected file
-- does not depend on contents of _int.sql.
--
+SET client_min_messages = warning;
\set ECHO none
-psql:_int.sql:15: NOTICE: type "query_int" is not yet defined
-DETAIL: Creating a shell type definition.
-psql:_int.sql:20: NOTICE: argument type query_int is only a shell
-psql:_int.sql:370: NOTICE: type "intbig_gkey" is not yet defined
-DETAIL: Creating a shell type definition.
-psql:_int.sql:375: NOTICE: argument type intbig_gkey is only a shell
+RESET client_min_messages;
SELECT intset(1234);
intset
--------
@@ -384,7 +380,7 @@ SELECT count(*) from test__int WHERE a @@ '23|50';
403
(1 row)
-SELECT count(*) from test__int WHERE a @ '{23,50}';
+SELECT count(*) from test__int WHERE a @> '{23,50}';
count
-------
12
@@ -396,7 +392,7 @@ SELECT count(*) from test__int WHERE a @@ '23&50';
12
(1 row)
-SELECT count(*) from test__int WHERE a @ '{20,23}';
+SELECT count(*) from test__int WHERE a @> '{20,23}';
count
-------
12
@@ -408,7 +404,7 @@ SELECT count(*) from test__int WHERE a @@ '50&68';
9
(1 row)
-SELECT count(*) from test__int WHERE a @ '{20,23}' or a @ '{50,68}';
+SELECT count(*) from test__int WHERE a @> '{20,23}' or a @> '{50,68}';
count
-------
21
@@ -433,7 +429,7 @@ SELECT count(*) from test__int WHERE a @@ '23|50';
403
(1 row)
-SELECT count(*) from test__int WHERE a @ '{23,50}';
+SELECT count(*) from test__int WHERE a @> '{23,50}';
count
-------
12
@@ -445,7 +441,7 @@ SELECT count(*) from test__int WHERE a @@ '23&50';
12
(1 row)
-SELECT count(*) from test__int WHERE a @ '{20,23}';
+SELECT count(*) from test__int WHERE a @> '{20,23}';
count
-------
12
@@ -457,7 +453,7 @@ SELECT count(*) from test__int WHERE a @@ '50&68';
9
(1 row)
-SELECT count(*) from test__int WHERE a @ '{20,23}' or a @ '{50,68}';
+SELECT count(*) from test__int WHERE a @> '{20,23}' or a @> '{50,68}';
count
-------
21
@@ -483,7 +479,7 @@ SELECT count(*) from test__int WHERE a @@ '23|50';
403
(1 row)
-SELECT count(*) from test__int WHERE a @ '{23,50}';
+SELECT count(*) from test__int WHERE a @> '{23,50}';
count
-------
12
@@ -495,7 +491,7 @@ SELECT count(*) from test__int WHERE a @@ '23&50';
12
(1 row)
-SELECT count(*) from test__int WHERE a @ '{20,23}';
+SELECT count(*) from test__int WHERE a @> '{20,23}';
count
-------
12
@@ -507,7 +503,7 @@ SELECT count(*) from test__int WHERE a @@ '50&68';
9
(1 row)
-SELECT count(*) from test__int WHERE a @ '{20,23}' or a @ '{50,68}';
+SELECT count(*) from test__int WHERE a @> '{20,23}' or a @> '{50,68}';
count
-------
21
@@ -533,7 +529,7 @@ SELECT count(*) from test__int WHERE a @@ '23|50';
403
(1 row)
-SELECT count(*) from test__int WHERE a @ '{23,50}';
+SELECT count(*) from test__int WHERE a @> '{23,50}';
count
-------
12
@@ -545,7 +541,7 @@ SELECT count(*) from test__int WHERE a @@ '23&50';
12
(1 row)
-SELECT count(*) from test__int WHERE a @ '{20,23}';
+SELECT count(*) from test__int WHERE a @> '{20,23}';
count
-------
12
@@ -557,7 +553,7 @@ SELECT count(*) from test__int WHERE a @@ '50&68';
9
(1 row)
-SELECT count(*) from test__int WHERE a @ '{20,23}' or a @ '{50,68}';
+SELECT count(*) from test__int WHERE a @> '{20,23}' or a @> '{50,68}';
count
-------
21
diff --git a/contrib/intarray/sql/_int.sql b/contrib/intarray/sql/_int.sql
index e04b88e7512..481754057e4 100644
--- a/contrib/intarray/sql/_int.sql
+++ b/contrib/intarray/sql/_int.sql
@@ -2,9 +2,11 @@
-- first, define the datatype. Turn off echoing so that expected file
-- does not depend on contents of _int.sql.
--
+SET client_min_messages = warning;
\set ECHO none
\i _int.sql
\set ECHO all
+RESET client_min_messages;
SELECT intset(1234);
SELECT icount('{1234234,234234}');
@@ -78,22 +80,22 @@ CREATE TABLE test__int( a int[] );
SELECT count(*) from test__int WHERE a && '{23,50}';
SELECT count(*) from test__int WHERE a @@ '23|50';
-SELECT count(*) from test__int WHERE a @ '{23,50}';
+SELECT count(*) from test__int WHERE a @> '{23,50}';
SELECT count(*) from test__int WHERE a @@ '23&50';
-SELECT count(*) from test__int WHERE a @ '{20,23}';
+SELECT count(*) from test__int WHERE a @> '{20,23}';
SELECT count(*) from test__int WHERE a @@ '50&68';
-SELECT count(*) from test__int WHERE a @ '{20,23}' or a @ '{50,68}';
+SELECT count(*) from test__int WHERE a @> '{20,23}' or a @> '{50,68}';
SELECT count(*) from test__int WHERE a @@ '(20&23)|(50&68)';
CREATE INDEX text_idx on test__int using gist ( a gist__int_ops );
SELECT count(*) from test__int WHERE a && '{23,50}';
SELECT count(*) from test__int WHERE a @@ '23|50';
-SELECT count(*) from test__int WHERE a @ '{23,50}';
+SELECT count(*) from test__int WHERE a @> '{23,50}';
SELECT count(*) from test__int WHERE a @@ '23&50';
-SELECT count(*) from test__int WHERE a @ '{20,23}';
+SELECT count(*) from test__int WHERE a @> '{20,23}';
SELECT count(*) from test__int WHERE a @@ '50&68';
-SELECT count(*) from test__int WHERE a @ '{20,23}' or a @ '{50,68}';
+SELECT count(*) from test__int WHERE a @> '{20,23}' or a @> '{50,68}';
SELECT count(*) from test__int WHERE a @@ '(20&23)|(50&68)';
DROP INDEX text_idx;
@@ -101,11 +103,11 @@ CREATE INDEX text_idx on test__int using gist ( a gist__intbig_ops );
SELECT count(*) from test__int WHERE a && '{23,50}';
SELECT count(*) from test__int WHERE a @@ '23|50';
-SELECT count(*) from test__int WHERE a @ '{23,50}';
+SELECT count(*) from test__int WHERE a @> '{23,50}';
SELECT count(*) from test__int WHERE a @@ '23&50';
-SELECT count(*) from test__int WHERE a @ '{20,23}';
+SELECT count(*) from test__int WHERE a @> '{20,23}';
SELECT count(*) from test__int WHERE a @@ '50&68';
-SELECT count(*) from test__int WHERE a @ '{20,23}' or a @ '{50,68}';
+SELECT count(*) from test__int WHERE a @> '{20,23}' or a @> '{50,68}';
SELECT count(*) from test__int WHERE a @@ '(20&23)|(50&68)';
DROP INDEX text_idx;
@@ -113,9 +115,9 @@ CREATE INDEX text_idx on test__int using gin ( a );
SELECT count(*) from test__int WHERE a && '{23,50}';
SELECT count(*) from test__int WHERE a @@ '23|50';
-SELECT count(*) from test__int WHERE a @ '{23,50}';
+SELECT count(*) from test__int WHERE a @> '{23,50}';
SELECT count(*) from test__int WHERE a @@ '23&50';
-SELECT count(*) from test__int WHERE a @ '{20,23}';
+SELECT count(*) from test__int WHERE a @> '{20,23}';
SELECT count(*) from test__int WHERE a @@ '50&68';
-SELECT count(*) from test__int WHERE a @ '{20,23}' or a @ '{50,68}';
+SELECT count(*) from test__int WHERE a @> '{20,23}' or a @> '{50,68}';
SELECT count(*) from test__int WHERE a @@ '(20&23)|(50&68)';
diff --git a/contrib/intarray/uninstall__int.sql b/contrib/intarray/uninstall__int.sql
index 49522b7c6c7..6f5b863fea2 100644
--- a/contrib/intarray/uninstall__int.sql
+++ b/contrib/intarray/uninstall__int.sql
@@ -1,5 +1,11 @@
SET search_path = public;
+DROP OPERATOR CLASS gin__int_ops USING gin;
+
+DROP FUNCTION ginint4_queryextract(internal, internal, int2);
+
+DROP FUNCTION ginint4_consistent(internal, int2, internal);
+
DROP OPERATOR CLASS gist__intbig_ops USING gist;
DROP FUNCTION g_intbig_same(internal, internal, internal);
@@ -82,6 +88,10 @@ DROP FUNCTION icount(_int4);
DROP FUNCTION intset(int4);
+DROP OPERATOR <@ (_int4, _int4);
+
+DROP OPERATOR @> (_int4, _int4);
+
DROP OPERATOR ~ (_int4, _int4);
DROP OPERATOR @ (_int4, _int4);