summaryrefslogtreecommitdiff
path: root/contrib/seg
diff options
context:
space:
mode:
authorTom Lane2006-09-10 17:36:52 +0000
committerTom Lane2006-09-10 17:36:52 +0000
commit684ad6a92fcc33adebdab65c4e7d72a68ba05408 (patch)
tree4cd0fc427b2100214e18452cc528e1b2e2d150fb /contrib/seg
parentba920e1c9182eac55d5f1327ab0d29b721154277 (diff)
Rename contrib contains/contained-by operators to @> and <@, per discussion.
Diffstat (limited to 'contrib/seg')
-rw-r--r--contrib/seg/README.seg10
-rw-r--r--contrib/seg/expected/seg.out39
-rw-r--r--contrib/seg/expected/seg_1.out39
-rw-r--r--contrib/seg/seg.c4
-rw-r--r--contrib/seg/seg.sql.in25
-rw-r--r--contrib/seg/sql/seg.sql36
-rw-r--r--contrib/seg/uninstall_seg.sql4
7 files changed, 96 insertions, 61 deletions
diff --git a/contrib/seg/README.seg b/contrib/seg/README.seg
index 9e741756c33..7fa29c44e08 100644
--- a/contrib/seg/README.seg
+++ b/contrib/seg/README.seg
@@ -257,16 +257,22 @@ The operators supported by the GiST access method include:
The segments [a, b] and [c, d] overlap.
-[a, b] @ [c, d] Contains
+[a, b] @> [c, d] Contains
The segment [a, b] contains the segment [c, d], that is,
a <= c and b >= d
-[a, b] @ [c, d] Contained in
+[a, b] <@ [c, d] Contained in
The segment [a, b] is contained in [c, d], that is,
a >= c and b <= d
+(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!)
+
Although the mnemonics of the following operators is questionable, I
preserved them to maintain visual consistency with other geometric
data types defined in Postgres.
diff --git a/contrib/seg/expected/seg.out b/contrib/seg/expected/seg.out
index 06971ae265b..de410490bc7 100644
--- a/contrib/seg/expected/seg.out
+++ b/contrib/seg/expected/seg.out
@@ -5,10 +5,9 @@
-- first, define the datatype. Turn off echoing so that expected file
-- does not depend on contents of seg.sql.
--
+SET client_min_messages = warning;
\set ECHO none
-psql:seg.sql:10: NOTICE: type "seg" is not yet defined
-DETAIL: Creating a shell type definition.
-psql:seg.sql:15: NOTICE: argument type seg is only a shell
+RESET client_min_messages;
--
-- testing the input and output functions
--
@@ -814,49 +813,49 @@ SELECT '2 .. 3'::seg >> '0 .. 1'::seg AS bool;
-- "contained in" (the left value belongs within the interval specified in the right value):
--
-SELECT '0'::seg ~ '0'::seg AS bool;
+SELECT '0'::seg <@ '0'::seg AS bool;
bool
------
t
(1 row)
-SELECT '0'::seg ~ '0 ..'::seg AS bool;
+SELECT '0'::seg <@ '0 ..'::seg AS bool;
bool
------
t
(1 row)
-SELECT '0'::seg ~ '.. 0'::seg AS bool;
+SELECT '0'::seg <@ '.. 0'::seg AS bool;
bool
------
t
(1 row)
-SELECT '0'::seg ~ '-1 .. 1'::seg AS bool;
+SELECT '0'::seg <@ '-1 .. 1'::seg AS bool;
bool
------
t
(1 row)
-SELECT '0'::seg ~ '-1 .. 1'::seg AS bool;
+SELECT '0'::seg <@ '-1 .. 1'::seg AS bool;
bool
------
t
(1 row)
-SELECT '-1'::seg ~ '-1 .. 1'::seg AS bool;
+SELECT '-1'::seg <@ '-1 .. 1'::seg AS bool;
bool
------
t
(1 row)
-SELECT '1'::seg ~ '-1 .. 1'::seg AS bool;
+SELECT '1'::seg <@ '-1 .. 1'::seg AS bool;
bool
------
t
(1 row)
-SELECT '-1 .. 1'::seg ~ '-1 .. 1'::seg AS bool;
+SELECT '-1 .. 1'::seg <@ '-1 .. 1'::seg AS bool;
bool
------
t
@@ -864,43 +863,43 @@ SELECT '-1 .. 1'::seg ~ '-1 .. 1'::seg AS bool;
-- "contains" (the left value contains the interval specified in the right value):
--
-SELECT '0'::seg @ '0'::seg AS bool;
+SELECT '0'::seg @> '0'::seg AS bool;
bool
------
t
(1 row)
-SELECT '0 .. '::seg ~ '0'::seg AS bool;
+SELECT '0 .. '::seg <@ '0'::seg AS bool;
bool
------
f
(1 row)
-SELECT '.. 0'::seg ~ '0'::seg AS bool;
+SELECT '.. 0'::seg <@ '0'::seg AS bool;
bool
------
f
(1 row)
-SELECT '-1 .. 1'::seg ~ '0'::seg AS bool;
+SELECT '-1 .. 1'::seg <@ '0'::seg AS bool;
bool
------
f
(1 row)
-SELECT '0'::seg ~ '-1 .. 1'::seg AS bool;
+SELECT '0'::seg <@ '-1 .. 1'::seg AS bool;
bool
------
t
(1 row)
-SELECT '-1'::seg ~ '-1 .. 1'::seg AS bool;
+SELECT '-1'::seg <@ '-1 .. 1'::seg AS bool;
bool
------
t
(1 row)
-SELECT '1'::seg ~ '-1 .. 1'::seg AS bool;
+SELECT '1'::seg <@ '-1 .. 1'::seg AS bool;
bool
------
t
@@ -911,14 +910,14 @@ SELECT '1'::seg ~ '-1 .. 1'::seg AS bool;
CREATE TABLE test_seg (s seg);
\copy test_seg from 'data/test_seg.data'
CREATE INDEX test_seg_ix ON test_seg USING gist (s);
-SELECT count(*) FROM test_seg WHERE s @ '11..11.3';
+SELECT count(*) FROM test_seg WHERE s @> '11..11.3';
count
-------
143
(1 row)
-- Test sorting
-SELECT * FROM test_seg WHERE s @ '11..11.3' GROUP BY s;
+SELECT * FROM test_seg WHERE s @> '11..11.3' GROUP BY s;
s
-----------------
.. 4.0e1
diff --git a/contrib/seg/expected/seg_1.out b/contrib/seg/expected/seg_1.out
index 2c446b7cc6e..446714f8ba0 100644
--- a/contrib/seg/expected/seg_1.out
+++ b/contrib/seg/expected/seg_1.out
@@ -5,10 +5,9 @@
-- first, define the datatype. Turn off echoing so that expected file
-- does not depend on contents of seg.sql.
--
+SET client_min_messages = warning;
\set ECHO none
-psql:seg.sql:10: NOTICE: type "seg" is not yet defined
-DETAIL: Creating a shell type definition.
-psql:seg.sql:15: NOTICE: argument type seg is only a shell
+RESET client_min_messages;
--
-- testing the input and output functions
--
@@ -814,49 +813,49 @@ SELECT '2 .. 3'::seg >> '0 .. 1'::seg AS bool;
-- "contained in" (the left value belongs within the interval specified in the right value):
--
-SELECT '0'::seg ~ '0'::seg AS bool;
+SELECT '0'::seg <@ '0'::seg AS bool;
bool
------
t
(1 row)
-SELECT '0'::seg ~ '0 ..'::seg AS bool;
+SELECT '0'::seg <@ '0 ..'::seg AS bool;
bool
------
t
(1 row)
-SELECT '0'::seg ~ '.. 0'::seg AS bool;
+SELECT '0'::seg <@ '.. 0'::seg AS bool;
bool
------
t
(1 row)
-SELECT '0'::seg ~ '-1 .. 1'::seg AS bool;
+SELECT '0'::seg <@ '-1 .. 1'::seg AS bool;
bool
------
t
(1 row)
-SELECT '0'::seg ~ '-1 .. 1'::seg AS bool;
+SELECT '0'::seg <@ '-1 .. 1'::seg AS bool;
bool
------
t
(1 row)
-SELECT '-1'::seg ~ '-1 .. 1'::seg AS bool;
+SELECT '-1'::seg <@ '-1 .. 1'::seg AS bool;
bool
------
t
(1 row)
-SELECT '1'::seg ~ '-1 .. 1'::seg AS bool;
+SELECT '1'::seg <@ '-1 .. 1'::seg AS bool;
bool
------
t
(1 row)
-SELECT '-1 .. 1'::seg ~ '-1 .. 1'::seg AS bool;
+SELECT '-1 .. 1'::seg <@ '-1 .. 1'::seg AS bool;
bool
------
t
@@ -864,43 +863,43 @@ SELECT '-1 .. 1'::seg ~ '-1 .. 1'::seg AS bool;
-- "contains" (the left value contains the interval specified in the right value):
--
-SELECT '0'::seg @ '0'::seg AS bool;
+SELECT '0'::seg @> '0'::seg AS bool;
bool
------
t
(1 row)
-SELECT '0 .. '::seg ~ '0'::seg AS bool;
+SELECT '0 .. '::seg <@ '0'::seg AS bool;
bool
------
f
(1 row)
-SELECT '.. 0'::seg ~ '0'::seg AS bool;
+SELECT '.. 0'::seg <@ '0'::seg AS bool;
bool
------
f
(1 row)
-SELECT '-1 .. 1'::seg ~ '0'::seg AS bool;
+SELECT '-1 .. 1'::seg <@ '0'::seg AS bool;
bool
------
f
(1 row)
-SELECT '0'::seg ~ '-1 .. 1'::seg AS bool;
+SELECT '0'::seg <@ '-1 .. 1'::seg AS bool;
bool
------
t
(1 row)
-SELECT '-1'::seg ~ '-1 .. 1'::seg AS bool;
+SELECT '-1'::seg <@ '-1 .. 1'::seg AS bool;
bool
------
t
(1 row)
-SELECT '1'::seg ~ '-1 .. 1'::seg AS bool;
+SELECT '1'::seg <@ '-1 .. 1'::seg AS bool;
bool
------
t
@@ -911,14 +910,14 @@ SELECT '1'::seg ~ '-1 .. 1'::seg AS bool;
CREATE TABLE test_seg (s seg);
\copy test_seg from 'data/test_seg.data'
CREATE INDEX test_seg_ix ON test_seg USING gist (s);
-SELECT count(*) FROM test_seg WHERE s @ '11..11.3';
+SELECT count(*) FROM test_seg WHERE s @> '11..11.3';
count
-------
143
(1 row)
-- Test sorting
-SELECT * FROM test_seg WHERE s @ '11..11.3' GROUP BY s;
+SELECT * FROM test_seg WHERE s @> '11..11.3' GROUP BY s;
s
-----------------
.. 4.0e1
diff --git a/contrib/seg/seg.c b/contrib/seg/seg.c
index 8f0c83c298d..aea86765568 100644
--- a/contrib/seg/seg.c
+++ b/contrib/seg/seg.c
@@ -492,9 +492,11 @@ gseg_leaf_consistent(SEG * key,
retval = (bool) seg_same(key, query);
break;
case RTContainsStrategyNumber:
+ case RTOldContainsStrategyNumber:
retval = (bool) seg_contains(key, query);
break;
case RTContainedByStrategyNumber:
+ case RTOldContainedByStrategyNumber:
retval = (bool) seg_contained(key, query);
break;
default:
@@ -533,9 +535,11 @@ gseg_internal_consistent(SEG * key,
break;
case RTSameStrategyNumber:
case RTContainsStrategyNumber:
+ case RTOldContainsStrategyNumber:
retval = (bool) seg_contains(key, query);
break;
case RTContainedByStrategyNumber:
+ case RTOldContainedByStrategyNumber:
retval = (bool) seg_overlap(key, query);
break;
default:
diff --git a/contrib/seg/seg.sql.in b/contrib/seg/seg.sql.in
index 94a02224a0e..b5e56d34629 100644
--- a/contrib/seg/seg.sql.in
+++ b/contrib/seg/seg.sql.in
@@ -281,6 +281,25 @@ CREATE OPERATOR <> (
JOIN = neqjoinsel
);
+CREATE OPERATOR @> (
+ LEFTARG = seg,
+ RIGHTARG = seg,
+ PROCEDURE = seg_contains,
+ COMMUTATOR = '<@',
+ RESTRICT = contsel,
+ JOIN = contjoinsel
+);
+
+CREATE OPERATOR <@ (
+ LEFTARG = seg,
+ RIGHTARG = seg,
+ PROCEDURE = seg_contained,
+ COMMUTATOR = '@>',
+ RESTRICT = contsel,
+ JOIN = contjoinsel
+);
+
+-- obsolete:
CREATE OPERATOR @ (
LEFTARG = seg,
RIGHTARG = seg,
@@ -357,8 +376,10 @@ AS
OPERATOR 4 &> ,
OPERATOR 5 >> ,
OPERATOR 6 = ,
- OPERATOR 7 @ ,
- OPERATOR 8 ~ ,
+ OPERATOR 7 @> ,
+ OPERATOR 8 <@ ,
+ OPERATOR 13 @ ,
+ OPERATOR 14 ~ ,
FUNCTION 1 gseg_consistent (internal, seg, int4),
FUNCTION 2 gseg_union (internal, internal),
FUNCTION 3 gseg_compress (internal),
diff --git a/contrib/seg/sql/seg.sql b/contrib/seg/sql/seg.sql
index 95394c95d04..91d771db181 100644
--- a/contrib/seg/sql/seg.sql
+++ b/contrib/seg/sql/seg.sql
@@ -6,9 +6,11 @@
-- first, define the datatype. Turn off echoing so that expected file
-- does not depend on contents of seg.sql.
--
+SET client_min_messages = warning;
\set ECHO none
\i seg.sql
\set ECHO all
+RESET client_min_messages;
--
-- testing the input and output functions
@@ -191,24 +193,24 @@ SELECT '2 .. 3'::seg >> '0 .. 1'::seg AS bool;
-- "contained in" (the left value belongs within the interval specified in the right value):
--
-SELECT '0'::seg ~ '0'::seg AS bool;
-SELECT '0'::seg ~ '0 ..'::seg AS bool;
-SELECT '0'::seg ~ '.. 0'::seg AS bool;
-SELECT '0'::seg ~ '-1 .. 1'::seg AS bool;
-SELECT '0'::seg ~ '-1 .. 1'::seg AS bool;
-SELECT '-1'::seg ~ '-1 .. 1'::seg AS bool;
-SELECT '1'::seg ~ '-1 .. 1'::seg AS bool;
-SELECT '-1 .. 1'::seg ~ '-1 .. 1'::seg AS bool;
+SELECT '0'::seg <@ '0'::seg AS bool;
+SELECT '0'::seg <@ '0 ..'::seg AS bool;
+SELECT '0'::seg <@ '.. 0'::seg AS bool;
+SELECT '0'::seg <@ '-1 .. 1'::seg AS bool;
+SELECT '0'::seg <@ '-1 .. 1'::seg AS bool;
+SELECT '-1'::seg <@ '-1 .. 1'::seg AS bool;
+SELECT '1'::seg <@ '-1 .. 1'::seg AS bool;
+SELECT '-1 .. 1'::seg <@ '-1 .. 1'::seg AS bool;
-- "contains" (the left value contains the interval specified in the right value):
--
-SELECT '0'::seg @ '0'::seg AS bool;
-SELECT '0 .. '::seg ~ '0'::seg AS bool;
-SELECT '.. 0'::seg ~ '0'::seg AS bool;
-SELECT '-1 .. 1'::seg ~ '0'::seg AS bool;
-SELECT '0'::seg ~ '-1 .. 1'::seg AS bool;
-SELECT '-1'::seg ~ '-1 .. 1'::seg AS bool;
-SELECT '1'::seg ~ '-1 .. 1'::seg AS bool;
+SELECT '0'::seg @> '0'::seg AS bool;
+SELECT '0 .. '::seg <@ '0'::seg AS bool;
+SELECT '.. 0'::seg <@ '0'::seg AS bool;
+SELECT '-1 .. 1'::seg <@ '0'::seg AS bool;
+SELECT '0'::seg <@ '-1 .. 1'::seg AS bool;
+SELECT '-1'::seg <@ '-1 .. 1'::seg AS bool;
+SELECT '1'::seg <@ '-1 .. 1'::seg AS bool;
-- Load some example data and build the index
--
@@ -217,7 +219,7 @@ CREATE TABLE test_seg (s seg);
\copy test_seg from 'data/test_seg.data'
CREATE INDEX test_seg_ix ON test_seg USING gist (s);
-SELECT count(*) FROM test_seg WHERE s @ '11..11.3';
+SELECT count(*) FROM test_seg WHERE s @> '11..11.3';
-- Test sorting
-SELECT * FROM test_seg WHERE s @ '11..11.3' GROUP BY s;
+SELECT * FROM test_seg WHERE s @> '11..11.3' GROUP BY s;
diff --git a/contrib/seg/uninstall_seg.sql b/contrib/seg/uninstall_seg.sql
index 21ffdfd700f..ebf93e49301 100644
--- a/contrib/seg/uninstall_seg.sql
+++ b/contrib/seg/uninstall_seg.sql
@@ -18,6 +18,10 @@ DROP FUNCTION gseg_compress(internal);
DROP FUNCTION gseg_consistent(internal,seg,int4);
+DROP OPERATOR <@ (seg, seg);
+
+DROP OPERATOR @> (seg, seg);
+
DROP OPERATOR ~ (seg, seg);
DROP OPERATOR @ (seg, seg);