The cubements a and b overlap.
-a @ b Contains
+a @> b Contains
The cubement a contains the cubement b.
-a ~ b Contained in
+a <@ b Contained in
The cubement a is contained in b.
+(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.
/******************************************************************************
- $PostgreSQL: pgsql/contrib/cube/cube.c,v 1.28 2006/07/27 21:55:09 tgl Exp $
+ $PostgreSQL: pgsql/contrib/cube/cube.c,v 1.29 2006/09/10 17:36:50 tgl Exp $
This file contains routines that can be bound to a Postgres backend and
called by the backend in the process of processing queries. The calling
retval = (bool) (cube_cmp_v0(key, query) == 0);
break;
case RTContainsStrategyNumber:
+ case RTOldContainsStrategyNumber:
retval = (bool) cube_contains_v0(key, query);
break;
case RTContainedByStrategyNumber:
+ case RTOldContainedByStrategyNumber:
retval = (bool) cube_contains_v0(query, key);
break;
default:
break;
case RTSameStrategyNumber:
case RTContainsStrategyNumber:
+ case RTOldContainsStrategyNumber:
retval = (bool) cube_contains_v0(key, query);
break;
case RTContainedByStrategyNumber:
+ case RTOldContainedByStrategyNumber:
retval = (bool) cube_overlap_v0(key, query);
break;
default:
RESTRICT = neqsel, JOIN = neqjoinsel
);
+CREATE OPERATOR @> (
+ LEFTARG = cube, RIGHTARG = cube, PROCEDURE = cube_contains,
+ COMMUTATOR = '<@',
+ RESTRICT = contsel, JOIN = contjoinsel
+);
+
+CREATE OPERATOR <@ (
+ LEFTARG = cube, RIGHTARG = cube, PROCEDURE = cube_contained,
+ COMMUTATOR = '@>',
+ RESTRICT = contsel, JOIN = contjoinsel
+);
+
+-- these are obsolete/deprecated:
CREATE OPERATOR @ (
LEFTARG = cube, RIGHTARG = cube, PROCEDURE = cube_contains,
COMMUTATOR = '~',
DEFAULT FOR TYPE cube USING gist AS
OPERATOR 3 && ,
OPERATOR 6 = ,
- OPERATOR 7 @ ,
- OPERATOR 8 ~ ,
+ OPERATOR 7 @> ,
+ OPERATOR 8 <@ ,
+ OPERATOR 13 @ ,
+ OPERATOR 14 ~ ,
FUNCTION 1 g_cube_consistent (internal, cube, int4),
FUNCTION 2 g_cube_union (internal, internal),
FUNCTION 3 g_cube_compress (internal),
-- "contained in" (the left operand is the cube entirely enclosed by
-- the right operand):
--
-SELECT '0'::cube ~ '0'::cube AS bool;
+SELECT '0'::cube <@ '0'::cube AS bool;
bool
------
t
(1 row)
-SELECT '0,0,0'::cube ~ '0,0,0'::cube AS bool;
+SELECT '0,0,0'::cube <@ '0,0,0'::cube AS bool;
bool
------
t
(1 row)
-SELECT '0,0'::cube ~ '0,0,1'::cube AS bool;
+SELECT '0,0'::cube <@ '0,0,1'::cube AS bool;
bool
------
t
(1 row)
-SELECT '0,0,0'::cube ~ '0,0,1'::cube AS bool;
+SELECT '0,0,0'::cube <@ '0,0,1'::cube AS bool;
bool
------
f
(1 row)
-SELECT '1,0,0'::cube ~ '0,0,1'::cube AS bool;
+SELECT '1,0,0'::cube <@ '0,0,1'::cube AS bool;
bool
------
f
(1 row)
-SELECT '(1,0,0),(0,0,1)'::cube ~ '(1,0,0),(0,0,1)'::cube AS bool;
+SELECT '(1,0,0),(0,0,1)'::cube <@ '(1,0,0),(0,0,1)'::cube AS bool;
bool
------
t
(1 row)
-SELECT '(1,0,0),(0,0,1)'::cube ~ '(-1,-1,-1),(1,1,1)'::cube AS bool;
+SELECT '(1,0,0),(0,0,1)'::cube <@ '(-1,-1,-1),(1,1,1)'::cube AS bool;
bool
------
t
(1 row)
-SELECT '(1,0,0),(0,0,1)'::cube ~ '(-1,-1,-1,-1),(1,1,1,1)'::cube AS bool;
+SELECT '(1,0,0),(0,0,1)'::cube <@ '(-1,-1,-1,-1),(1,1,1,1)'::cube AS bool;
bool
------
t
(1 row)
-SELECT '0'::cube ~ '(-1),(1)'::cube AS bool;
+SELECT '0'::cube <@ '(-1),(1)'::cube AS bool;
bool
------
t
(1 row)
-SELECT '1'::cube ~ '(-1),(1)'::cube AS bool;
+SELECT '1'::cube <@ '(-1),(1)'::cube AS bool;
bool
------
t
(1 row)
-SELECT '-1'::cube ~ '(-1),(1)'::cube AS bool;
+SELECT '-1'::cube <@ '(-1),(1)'::cube AS bool;
bool
------
t
(1 row)
-SELECT '(-1),(1)'::cube ~ '(-1),(1)'::cube AS bool;
+SELECT '(-1),(1)'::cube <@ '(-1),(1)'::cube AS bool;
bool
------
t
(1 row)
-SELECT '(-1),(1)'::cube ~ '(-1,-1),(1,1)'::cube AS bool;
+SELECT '(-1),(1)'::cube <@ '(-1,-1),(1,1)'::cube AS bool;
bool
------
t
(1 row)
-SELECT '(-2),(1)'::cube ~ '(-1),(1)'::cube AS bool;
+SELECT '(-2),(1)'::cube <@ '(-1),(1)'::cube AS bool;
bool
------
f
(1 row)
-SELECT '(-2),(1)'::cube ~ '(-1,-1),(1,1)'::cube AS bool;
+SELECT '(-2),(1)'::cube <@ '(-1,-1),(1,1)'::cube AS bool;
bool
------
f
-- "contains" (the left operand is the cube that entirely encloses the
-- right operand)
--
-SELECT '0'::cube @ '0'::cube AS bool;
+SELECT '0'::cube @> '0'::cube AS bool;
bool
------
t
(1 row)
-SELECT '0,0,0'::cube @ '0,0,0'::cube AS bool;
+SELECT '0,0,0'::cube @> '0,0,0'::cube AS bool;
bool
------
t
(1 row)
-SELECT '0,0,1'::cube @ '0,0'::cube AS bool;
+SELECT '0,0,1'::cube @> '0,0'::cube AS bool;
bool
------
t
(1 row)
-SELECT '0,0,1'::cube @ '0,0,0'::cube AS bool;
+SELECT '0,0,1'::cube @> '0,0,0'::cube AS bool;
bool
------
f
(1 row)
-SELECT '0,0,1'::cube @ '1,0,0'::cube AS bool;
+SELECT '0,0,1'::cube @> '1,0,0'::cube AS bool;
bool
------
f
(1 row)
-SELECT '(1,0,0),(0,0,1)'::cube @ '(1,0,0),(0,0,1)'::cube AS bool;
+SELECT '(1,0,0),(0,0,1)'::cube @> '(1,0,0),(0,0,1)'::cube AS bool;
bool
------
t
(1 row)
-SELECT '(-1,-1,-1),(1,1,1)'::cube @ '(1,0,0),(0,0,1)'::cube AS bool;
+SELECT '(-1,-1,-1),(1,1,1)'::cube @> '(1,0,0),(0,0,1)'::cube AS bool;
bool
------
t
(1 row)
-SELECT '(-1,-1,-1,-1),(1,1,1,1)'::cube @ '(1,0,0),(0,0,1)'::cube AS bool;
+SELECT '(-1,-1,-1,-1),(1,1,1,1)'::cube @> '(1,0,0),(0,0,1)'::cube AS bool;
bool
------
t
(1 row)
-SELECT '(-1),(1)'::cube @ '0'::cube AS bool;
+SELECT '(-1),(1)'::cube @> '0'::cube AS bool;
bool
------
t
(1 row)
-SELECT '(-1),(1)'::cube @ '1'::cube AS bool;
+SELECT '(-1),(1)'::cube @> '1'::cube AS bool;
bool
------
t
(1 row)
-SELECT '(-1),(1)'::cube @ '-1'::cube AS bool;
+SELECT '(-1),(1)'::cube @> '-1'::cube AS bool;
bool
------
t
(1 row)
-SELECT '(-1),(1)'::cube @ '(-1),(1)'::cube AS bool;
+SELECT '(-1),(1)'::cube @> '(-1),(1)'::cube AS bool;
bool
------
t
(1 row)
-SELECT '(-1,-1),(1,1)'::cube @ '(-1),(1)'::cube AS bool;
+SELECT '(-1,-1),(1,1)'::cube @> '(-1),(1)'::cube AS bool;
bool
------
t
(1 row)
-SELECT '(-1),(1)'::cube @ '(-2),(1)'::cube AS bool;
+SELECT '(-1),(1)'::cube @> '(-2),(1)'::cube AS bool;
bool
------
f
(1 row)
-SELECT '(-1,-1),(1,1)'::cube @ '(-2),(1)'::cube AS bool;
+SELECT '(-1,-1),(1,1)'::cube @> '(-2),(1)'::cube AS bool;
bool
------
f
-- "contained in" (the left operand is the cube entirely enclosed by
-- the right operand):
--
-SELECT '0'::cube ~ '0'::cube AS bool;
+SELECT '0'::cube <@ '0'::cube AS bool;
bool
------
t
(1 row)
-SELECT '0,0,0'::cube ~ '0,0,0'::cube AS bool;
+SELECT '0,0,0'::cube <@ '0,0,0'::cube AS bool;
bool
------
t
(1 row)
-SELECT '0,0'::cube ~ '0,0,1'::cube AS bool;
+SELECT '0,0'::cube <@ '0,0,1'::cube AS bool;
bool
------
t
(1 row)
-SELECT '0,0,0'::cube ~ '0,0,1'::cube AS bool;
+SELECT '0,0,0'::cube <@ '0,0,1'::cube AS bool;
bool
------
f
(1 row)
-SELECT '1,0,0'::cube ~ '0,0,1'::cube AS bool;
+SELECT '1,0,0'::cube <@ '0,0,1'::cube AS bool;
bool
------
f
(1 row)
-SELECT '(1,0,0),(0,0,1)'::cube ~ '(1,0,0),(0,0,1)'::cube AS bool;
+SELECT '(1,0,0),(0,0,1)'::cube <@ '(1,0,0),(0,0,1)'::cube AS bool;
bool
------
t
(1 row)
-SELECT '(1,0,0),(0,0,1)'::cube ~ '(-1,-1,-1),(1,1,1)'::cube AS bool;
+SELECT '(1,0,0),(0,0,1)'::cube <@ '(-1,-1,-1),(1,1,1)'::cube AS bool;
bool
------
t
(1 row)
-SELECT '(1,0,0),(0,0,1)'::cube ~ '(-1,-1,-1,-1),(1,1,1,1)'::cube AS bool;
+SELECT '(1,0,0),(0,0,1)'::cube <@ '(-1,-1,-1,-1),(1,1,1,1)'::cube AS bool;
bool
------
t
(1 row)
-SELECT '0'::cube ~ '(-1),(1)'::cube AS bool;
+SELECT '0'::cube <@ '(-1),(1)'::cube AS bool;
bool
------
t
(1 row)
-SELECT '1'::cube ~ '(-1),(1)'::cube AS bool;
+SELECT '1'::cube <@ '(-1),(1)'::cube AS bool;
bool
------
t
(1 row)
-SELECT '-1'::cube ~ '(-1),(1)'::cube AS bool;
+SELECT '-1'::cube <@ '(-1),(1)'::cube AS bool;
bool
------
t
(1 row)
-SELECT '(-1),(1)'::cube ~ '(-1),(1)'::cube AS bool;
+SELECT '(-1),(1)'::cube <@ '(-1),(1)'::cube AS bool;
bool
------
t
(1 row)
-SELECT '(-1),(1)'::cube ~ '(-1,-1),(1,1)'::cube AS bool;
+SELECT '(-1),(1)'::cube <@ '(-1,-1),(1,1)'::cube AS bool;
bool
------
t
(1 row)
-SELECT '(-2),(1)'::cube ~ '(-1),(1)'::cube AS bool;
+SELECT '(-2),(1)'::cube <@ '(-1),(1)'::cube AS bool;
bool
------
f
(1 row)
-SELECT '(-2),(1)'::cube ~ '(-1,-1),(1,1)'::cube AS bool;
+SELECT '(-2),(1)'::cube <@ '(-1,-1),(1,1)'::cube AS bool;
bool
------
f
-- "contains" (the left operand is the cube that entirely encloses the
-- right operand)
--
-SELECT '0'::cube @ '0'::cube AS bool;
+SELECT '0'::cube @> '0'::cube AS bool;
bool
------
t
(1 row)
-SELECT '0,0,0'::cube @ '0,0,0'::cube AS bool;
+SELECT '0,0,0'::cube @> '0,0,0'::cube AS bool;
bool
------
t
(1 row)
-SELECT '0,0,1'::cube @ '0,0'::cube AS bool;
+SELECT '0,0,1'::cube @> '0,0'::cube AS bool;
bool
------
t
(1 row)
-SELECT '0,0,1'::cube @ '0,0,0'::cube AS bool;
+SELECT '0,0,1'::cube @> '0,0,0'::cube AS bool;
bool
------
f
(1 row)
-SELECT '0,0,1'::cube @ '1,0,0'::cube AS bool;
+SELECT '0,0,1'::cube @> '1,0,0'::cube AS bool;
bool
------
f
(1 row)
-SELECT '(1,0,0),(0,0,1)'::cube @ '(1,0,0),(0,0,1)'::cube AS bool;
+SELECT '(1,0,0),(0,0,1)'::cube @> '(1,0,0),(0,0,1)'::cube AS bool;
bool
------
t
(1 row)
-SELECT '(-1,-1,-1),(1,1,1)'::cube @ '(1,0,0),(0,0,1)'::cube AS bool;
+SELECT '(-1,-1,-1),(1,1,1)'::cube @> '(1,0,0),(0,0,1)'::cube AS bool;
bool
------
t
(1 row)
-SELECT '(-1,-1,-1,-1),(1,1,1,1)'::cube @ '(1,0,0),(0,0,1)'::cube AS bool;
+SELECT '(-1,-1,-1,-1),(1,1,1,1)'::cube @> '(1,0,0),(0,0,1)'::cube AS bool;
bool
------
t
(1 row)
-SELECT '(-1),(1)'::cube @ '0'::cube AS bool;
+SELECT '(-1),(1)'::cube @> '0'::cube AS bool;
bool
------
t
(1 row)
-SELECT '(-1),(1)'::cube @ '1'::cube AS bool;
+SELECT '(-1),(1)'::cube @> '1'::cube AS bool;
bool
------
t
(1 row)
-SELECT '(-1),(1)'::cube @ '-1'::cube AS bool;
+SELECT '(-1),(1)'::cube @> '-1'::cube AS bool;
bool
------
t
(1 row)
-SELECT '(-1),(1)'::cube @ '(-1),(1)'::cube AS bool;
+SELECT '(-1),(1)'::cube @> '(-1),(1)'::cube AS bool;
bool
------
t
(1 row)
-SELECT '(-1,-1),(1,1)'::cube @ '(-1),(1)'::cube AS bool;
+SELECT '(-1,-1),(1,1)'::cube @> '(-1),(1)'::cube AS bool;
bool
------
t
(1 row)
-SELECT '(-1),(1)'::cube @ '(-2),(1)'::cube AS bool;
+SELECT '(-1),(1)'::cube @> '(-2),(1)'::cube AS bool;
bool
------
f
(1 row)
-SELECT '(-1,-1),(1,1)'::cube @ '(-2),(1)'::cube AS bool;
+SELECT '(-1,-1),(1,1)'::cube @> '(-2),(1)'::cube AS bool;
bool
------
f
-- "contained in" (the left operand is the cube entirely enclosed by
-- the right operand):
--
-SELECT '0'::cube ~ '0'::cube AS bool;
+SELECT '0'::cube <@ '0'::cube AS bool;
bool
------
t
(1 row)
-SELECT '0,0,0'::cube ~ '0,0,0'::cube AS bool;
+SELECT '0,0,0'::cube <@ '0,0,0'::cube AS bool;
bool
------
t
(1 row)
-SELECT '0,0'::cube ~ '0,0,1'::cube AS bool;
+SELECT '0,0'::cube <@ '0,0,1'::cube AS bool;
bool
------
t
(1 row)
-SELECT '0,0,0'::cube ~ '0,0,1'::cube AS bool;
+SELECT '0,0,0'::cube <@ '0,0,1'::cube AS bool;
bool
------
f
(1 row)
-SELECT '1,0,0'::cube ~ '0,0,1'::cube AS bool;
+SELECT '1,0,0'::cube <@ '0,0,1'::cube AS bool;
bool
------
f
(1 row)
-SELECT '(1,0,0),(0,0,1)'::cube ~ '(1,0,0),(0,0,1)'::cube AS bool;
+SELECT '(1,0,0),(0,0,1)'::cube <@ '(1,0,0),(0,0,1)'::cube AS bool;
bool
------
t
(1 row)
-SELECT '(1,0,0),(0,0,1)'::cube ~ '(-1,-1,-1),(1,1,1)'::cube AS bool;
+SELECT '(1,0,0),(0,0,1)'::cube <@ '(-1,-1,-1),(1,1,1)'::cube AS bool;
bool
------
t
(1 row)
-SELECT '(1,0,0),(0,0,1)'::cube ~ '(-1,-1,-1,-1),(1,1,1,1)'::cube AS bool;
+SELECT '(1,0,0),(0,0,1)'::cube <@ '(-1,-1,-1,-1),(1,1,1,1)'::cube AS bool;
bool
------
t
(1 row)
-SELECT '0'::cube ~ '(-1),(1)'::cube AS bool;
+SELECT '0'::cube <@ '(-1),(1)'::cube AS bool;
bool
------
t
(1 row)
-SELECT '1'::cube ~ '(-1),(1)'::cube AS bool;
+SELECT '1'::cube <@ '(-1),(1)'::cube AS bool;
bool
------
t
(1 row)
-SELECT '-1'::cube ~ '(-1),(1)'::cube AS bool;
+SELECT '-1'::cube <@ '(-1),(1)'::cube AS bool;
bool
------
t
(1 row)
-SELECT '(-1),(1)'::cube ~ '(-1),(1)'::cube AS bool;
+SELECT '(-1),(1)'::cube <@ '(-1),(1)'::cube AS bool;
bool
------
t
(1 row)
-SELECT '(-1),(1)'::cube ~ '(-1,-1),(1,1)'::cube AS bool;
+SELECT '(-1),(1)'::cube <@ '(-1,-1),(1,1)'::cube AS bool;
bool
------
t
(1 row)
-SELECT '(-2),(1)'::cube ~ '(-1),(1)'::cube AS bool;
+SELECT '(-2),(1)'::cube <@ '(-1),(1)'::cube AS bool;
bool
------
f
(1 row)
-SELECT '(-2),(1)'::cube ~ '(-1,-1),(1,1)'::cube AS bool;
+SELECT '(-2),(1)'::cube <@ '(-1,-1),(1,1)'::cube AS bool;
bool
------
f
-- "contains" (the left operand is the cube that entirely encloses the
-- right operand)
--
-SELECT '0'::cube @ '0'::cube AS bool;
+SELECT '0'::cube @> '0'::cube AS bool;
bool
------
t
(1 row)
-SELECT '0,0,0'::cube @ '0,0,0'::cube AS bool;
+SELECT '0,0,0'::cube @> '0,0,0'::cube AS bool;
bool
------
t
(1 row)
-SELECT '0,0,1'::cube @ '0,0'::cube AS bool;
+SELECT '0,0,1'::cube @> '0,0'::cube AS bool;
bool
------
t
(1 row)
-SELECT '0,0,1'::cube @ '0,0,0'::cube AS bool;
+SELECT '0,0,1'::cube @> '0,0,0'::cube AS bool;
bool
------
f
(1 row)
-SELECT '0,0,1'::cube @ '1,0,0'::cube AS bool;
+SELECT '0,0,1'::cube @> '1,0,0'::cube AS bool;
bool
------
f
(1 row)
-SELECT '(1,0,0),(0,0,1)'::cube @ '(1,0,0),(0,0,1)'::cube AS bool;
+SELECT '(1,0,0),(0,0,1)'::cube @> '(1,0,0),(0,0,1)'::cube AS bool;
bool
------
t
(1 row)
-SELECT '(-1,-1,-1),(1,1,1)'::cube @ '(1,0,0),(0,0,1)'::cube AS bool;
+SELECT '(-1,-1,-1),(1,1,1)'::cube @> '(1,0,0),(0,0,1)'::cube AS bool;
bool
------
t
(1 row)
-SELECT '(-1,-1,-1,-1),(1,1,1,1)'::cube @ '(1,0,0),(0,0,1)'::cube AS bool;
+SELECT '(-1,-1,-1,-1),(1,1,1,1)'::cube @> '(1,0,0),(0,0,1)'::cube AS bool;
bool
------
t
(1 row)
-SELECT '(-1),(1)'::cube @ '0'::cube AS bool;
+SELECT '(-1),(1)'::cube @> '0'::cube AS bool;
bool
------
t
(1 row)
-SELECT '(-1),(1)'::cube @ '1'::cube AS bool;
+SELECT '(-1),(1)'::cube @> '1'::cube AS bool;
bool
------
t
(1 row)
-SELECT '(-1),(1)'::cube @ '-1'::cube AS bool;
+SELECT '(-1),(1)'::cube @> '-1'::cube AS bool;
bool
------
t
(1 row)
-SELECT '(-1),(1)'::cube @ '(-1),(1)'::cube AS bool;
+SELECT '(-1),(1)'::cube @> '(-1),(1)'::cube AS bool;
bool
------
t
(1 row)
-SELECT '(-1,-1),(1,1)'::cube @ '(-1),(1)'::cube AS bool;
+SELECT '(-1,-1),(1,1)'::cube @> '(-1),(1)'::cube AS bool;
bool
------
t
(1 row)
-SELECT '(-1),(1)'::cube @ '(-2),(1)'::cube AS bool;
+SELECT '(-1),(1)'::cube @> '(-2),(1)'::cube AS bool;
bool
------
f
(1 row)
-SELECT '(-1,-1),(1,1)'::cube @ '(-2),(1)'::cube AS bool;
+SELECT '(-1,-1),(1,1)'::cube @> '(-2),(1)'::cube AS bool;
bool
------
f
-- "contained in" (the left operand is the cube entirely enclosed by
-- the right operand):
--
-SELECT '0'::cube ~ '0'::cube AS bool;
-SELECT '0,0,0'::cube ~ '0,0,0'::cube AS bool;
-SELECT '0,0'::cube ~ '0,0,1'::cube AS bool;
-SELECT '0,0,0'::cube ~ '0,0,1'::cube AS bool;
-SELECT '1,0,0'::cube ~ '0,0,1'::cube AS bool;
-SELECT '(1,0,0),(0,0,1)'::cube ~ '(1,0,0),(0,0,1)'::cube AS bool;
-SELECT '(1,0,0),(0,0,1)'::cube ~ '(-1,-1,-1),(1,1,1)'::cube AS bool;
-SELECT '(1,0,0),(0,0,1)'::cube ~ '(-1,-1,-1,-1),(1,1,1,1)'::cube AS bool;
-SELECT '0'::cube ~ '(-1),(1)'::cube AS bool;
-SELECT '1'::cube ~ '(-1),(1)'::cube AS bool;
-SELECT '-1'::cube ~ '(-1),(1)'::cube AS bool;
-SELECT '(-1),(1)'::cube ~ '(-1),(1)'::cube AS bool;
-SELECT '(-1),(1)'::cube ~ '(-1,-1),(1,1)'::cube AS bool;
-SELECT '(-2),(1)'::cube ~ '(-1),(1)'::cube AS bool;
-SELECT '(-2),(1)'::cube ~ '(-1,-1),(1,1)'::cube AS bool;
+SELECT '0'::cube <@ '0'::cube AS bool;
+SELECT '0,0,0'::cube <@ '0,0,0'::cube AS bool;
+SELECT '0,0'::cube <@ '0,0,1'::cube AS bool;
+SELECT '0,0,0'::cube <@ '0,0,1'::cube AS bool;
+SELECT '1,0,0'::cube <@ '0,0,1'::cube AS bool;
+SELECT '(1,0,0),(0,0,1)'::cube <@ '(1,0,0),(0,0,1)'::cube AS bool;
+SELECT '(1,0,0),(0,0,1)'::cube <@ '(-1,-1,-1),(1,1,1)'::cube AS bool;
+SELECT '(1,0,0),(0,0,1)'::cube <@ '(-1,-1,-1,-1),(1,1,1,1)'::cube AS bool;
+SELECT '0'::cube <@ '(-1),(1)'::cube AS bool;
+SELECT '1'::cube <@ '(-1),(1)'::cube AS bool;
+SELECT '-1'::cube <@ '(-1),(1)'::cube AS bool;
+SELECT '(-1),(1)'::cube <@ '(-1),(1)'::cube AS bool;
+SELECT '(-1),(1)'::cube <@ '(-1,-1),(1,1)'::cube AS bool;
+SELECT '(-2),(1)'::cube <@ '(-1),(1)'::cube AS bool;
+SELECT '(-2),(1)'::cube <@ '(-1,-1),(1,1)'::cube AS bool;
-- "contains" (the left operand is the cube that entirely encloses the
-- right operand)
--
-SELECT '0'::cube @ '0'::cube AS bool;
-SELECT '0,0,0'::cube @ '0,0,0'::cube AS bool;
-SELECT '0,0,1'::cube @ '0,0'::cube AS bool;
-SELECT '0,0,1'::cube @ '0,0,0'::cube AS bool;
-SELECT '0,0,1'::cube @ '1,0,0'::cube AS bool;
-SELECT '(1,0,0),(0,0,1)'::cube @ '(1,0,0),(0,0,1)'::cube AS bool;
-SELECT '(-1,-1,-1),(1,1,1)'::cube @ '(1,0,0),(0,0,1)'::cube AS bool;
-SELECT '(-1,-1,-1,-1),(1,1,1,1)'::cube @ '(1,0,0),(0,0,1)'::cube AS bool;
-SELECT '(-1),(1)'::cube @ '0'::cube AS bool;
-SELECT '(-1),(1)'::cube @ '1'::cube AS bool;
-SELECT '(-1),(1)'::cube @ '-1'::cube AS bool;
-SELECT '(-1),(1)'::cube @ '(-1),(1)'::cube AS bool;
-SELECT '(-1,-1),(1,1)'::cube @ '(-1),(1)'::cube AS bool;
-SELECT '(-1),(1)'::cube @ '(-2),(1)'::cube AS bool;
-SELECT '(-1,-1),(1,1)'::cube @ '(-2),(1)'::cube AS bool;
+SELECT '0'::cube @> '0'::cube AS bool;
+SELECT '0,0,0'::cube @> '0,0,0'::cube AS bool;
+SELECT '0,0,1'::cube @> '0,0'::cube AS bool;
+SELECT '0,0,1'::cube @> '0,0,0'::cube AS bool;
+SELECT '0,0,1'::cube @> '1,0,0'::cube AS bool;
+SELECT '(1,0,0),(0,0,1)'::cube @> '(1,0,0),(0,0,1)'::cube AS bool;
+SELECT '(-1,-1,-1),(1,1,1)'::cube @> '(1,0,0),(0,0,1)'::cube AS bool;
+SELECT '(-1,-1,-1,-1),(1,1,1,1)'::cube @> '(1,0,0),(0,0,1)'::cube AS bool;
+SELECT '(-1),(1)'::cube @> '0'::cube AS bool;
+SELECT '(-1),(1)'::cube @> '1'::cube AS bool;
+SELECT '(-1),(1)'::cube @> '-1'::cube AS bool;
+SELECT '(-1),(1)'::cube @> '(-1),(1)'::cube AS bool;
+SELECT '(-1,-1),(1,1)'::cube @> '(-1),(1)'::cube AS bool;
+SELECT '(-1),(1)'::cube @> '(-2),(1)'::cube AS bool;
+SELECT '(-1,-1),(1,1)'::cube @> '(-2),(1)'::cube AS bool;
-- Test of distance function
--
DROP OPERATOR @ (cube, cube);
+DROP OPERATOR <@ (cube, cube);
+
+DROP OPERATOR @> (cube, cube);
+
DROP OPERATOR <> (cube, cube);
DROP OPERATOR = (cube, cube);
two points on the surface of the Earth.
earth_box(earth, float8) - Returns a box suitable for an indexed search using
-the cube @ operator for points within a given great circle distance of a
+the cube @> operator for points within a given great circle distance of a
location. Some points in this box are further than the specified great circle
distance from the location so a second check using earth_distance should be
made at the same time.
-- Test for points that should be in bounding boxes.
--
SELECT earth_box(ll_to_earth(0,0),
- earth_distance(ll_to_earth(0,0),ll_to_earth(0,1))*1.00001) @
+ earth_distance(ll_to_earth(0,0),ll_to_earth(0,1))*1.00001) @>
ll_to_earth(0,1);
?column?
----------
(1 row)
SELECT earth_box(ll_to_earth(0,0),
- earth_distance(ll_to_earth(0,0),ll_to_earth(0,0.1))*1.00001) @
+ earth_distance(ll_to_earth(0,0),ll_to_earth(0,0.1))*1.00001) @>
ll_to_earth(0,0.1);
?column?
----------
(1 row)
SELECT earth_box(ll_to_earth(0,0),
- earth_distance(ll_to_earth(0,0),ll_to_earth(0,0.01))*1.00001) @
+ earth_distance(ll_to_earth(0,0),ll_to_earth(0,0.01))*1.00001) @>
ll_to_earth(0,0.01);
?column?
----------
(1 row)
SELECT earth_box(ll_to_earth(0,0),
- earth_distance(ll_to_earth(0,0),ll_to_earth(0,0.001))*1.00001) @
+ earth_distance(ll_to_earth(0,0),ll_to_earth(0,0.001))*1.00001) @>
ll_to_earth(0,0.001);
?column?
----------
(1 row)
SELECT earth_box(ll_to_earth(0,0),
- earth_distance(ll_to_earth(0,0),ll_to_earth(0,0.0001))*1.00001) @
+ earth_distance(ll_to_earth(0,0),ll_to_earth(0,0.0001))*1.00001) @>
ll_to_earth(0,0.0001);
?column?
----------
(1 row)
SELECT earth_box(ll_to_earth(0,0),
- earth_distance(ll_to_earth(0,0),ll_to_earth(0.0001,0.0001))*1.00001) @
+ earth_distance(ll_to_earth(0,0),ll_to_earth(0.0001,0.0001))*1.00001) @>
ll_to_earth(0.0001,0.0001);
?column?
----------
(1 row)
SELECT earth_box(ll_to_earth(45,45),
- earth_distance(ll_to_earth(45,45),ll_to_earth(45.0001,45.0001))*1.00001) @
+ earth_distance(ll_to_earth(45,45),ll_to_earth(45.0001,45.0001))*1.00001) @>
ll_to_earth(45.0001,45.0001);
?column?
----------
(1 row)
SELECT earth_box(ll_to_earth(90,180),
- earth_distance(ll_to_earth(90,180),ll_to_earth(90.0001,180.0001))*1.00001) @
+ earth_distance(ll_to_earth(90,180),ll_to_earth(90.0001,180.0001))*1.00001) @>
ll_to_earth(90.0001,180.0001);
?column?
----------
-- but further away than the distance we are testing.
--
SELECT earth_box(ll_to_earth(0,0),
- earth_distance(ll_to_earth(0,0),ll_to_earth(0,1))*.57735) @
+ earth_distance(ll_to_earth(0,0),ll_to_earth(0,1))*.57735) @>
ll_to_earth(0,1);
?column?
----------
(1 row)
SELECT earth_box(ll_to_earth(0,0),
- earth_distance(ll_to_earth(0,0),ll_to_earth(0,0.1))*.57735) @
+ earth_distance(ll_to_earth(0,0),ll_to_earth(0,0.1))*.57735) @>
ll_to_earth(0,0.1);
?column?
----------
(1 row)
SELECT earth_box(ll_to_earth(0,0),
- earth_distance(ll_to_earth(0,0),ll_to_earth(0,0.01))*.57735) @
+ earth_distance(ll_to_earth(0,0),ll_to_earth(0,0.01))*.57735) @>
ll_to_earth(0,0.01);
?column?
----------
(1 row)
SELECT earth_box(ll_to_earth(0,0),
- earth_distance(ll_to_earth(0,0),ll_to_earth(0,0.001))*.57735) @
+ earth_distance(ll_to_earth(0,0),ll_to_earth(0,0.001))*.57735) @>
ll_to_earth(0,0.001);
?column?
----------
(1 row)
SELECT earth_box(ll_to_earth(0,0),
- earth_distance(ll_to_earth(0,0),ll_to_earth(0,0.0001))*.57735) @
+ earth_distance(ll_to_earth(0,0),ll_to_earth(0,0.0001))*.57735) @>
ll_to_earth(0,0.0001);
?column?
----------
(1 row)
SELECT earth_box(ll_to_earth(0,0),
- earth_distance(ll_to_earth(0,0),ll_to_earth(0.0001,0.0001))*.57735) @
+ earth_distance(ll_to_earth(0,0),ll_to_earth(0.0001,0.0001))*.57735) @>
ll_to_earth(0.0001,0.0001);
?column?
----------
(1 row)
SELECT earth_box(ll_to_earth(45,45),
- earth_distance(ll_to_earth(45,45),ll_to_earth(45.0001,45.0001))*.57735) @
+ earth_distance(ll_to_earth(45,45),ll_to_earth(45.0001,45.0001))*.57735) @>
ll_to_earth(45.0001,45.0001);
?column?
----------
(1 row)
SELECT earth_box(ll_to_earth(90,180),
- earth_distance(ll_to_earth(90,180),ll_to_earth(90.0001,180.0001))*.57735) @
+ earth_distance(ll_to_earth(90,180),ll_to_earth(90.0001,180.0001))*.57735) @>
ll_to_earth(90.0001,180.0001);
?column?
----------
--
SELECT earth_box(ll_to_earth(0,0),
- earth_distance(ll_to_earth(0,0),ll_to_earth(0,1))*1.00001) @
+ earth_distance(ll_to_earth(0,0),ll_to_earth(0,1))*1.00001) @>
ll_to_earth(0,1);
SELECT earth_box(ll_to_earth(0,0),
- earth_distance(ll_to_earth(0,0),ll_to_earth(0,0.1))*1.00001) @
+ earth_distance(ll_to_earth(0,0),ll_to_earth(0,0.1))*1.00001) @>
ll_to_earth(0,0.1);
SELECT earth_box(ll_to_earth(0,0),
- earth_distance(ll_to_earth(0,0),ll_to_earth(0,0.01))*1.00001) @
+ earth_distance(ll_to_earth(0,0),ll_to_earth(0,0.01))*1.00001) @>
ll_to_earth(0,0.01);
SELECT earth_box(ll_to_earth(0,0),
- earth_distance(ll_to_earth(0,0),ll_to_earth(0,0.001))*1.00001) @
+ earth_distance(ll_to_earth(0,0),ll_to_earth(0,0.001))*1.00001) @>
ll_to_earth(0,0.001);
SELECT earth_box(ll_to_earth(0,0),
- earth_distance(ll_to_earth(0,0),ll_to_earth(0,0.0001))*1.00001) @
+ earth_distance(ll_to_earth(0,0),ll_to_earth(0,0.0001))*1.00001) @>
ll_to_earth(0,0.0001);
SELECT earth_box(ll_to_earth(0,0),
- earth_distance(ll_to_earth(0,0),ll_to_earth(0.0001,0.0001))*1.00001) @
+ earth_distance(ll_to_earth(0,0),ll_to_earth(0.0001,0.0001))*1.00001) @>
ll_to_earth(0.0001,0.0001);
SELECT earth_box(ll_to_earth(45,45),
- earth_distance(ll_to_earth(45,45),ll_to_earth(45.0001,45.0001))*1.00001) @
+ earth_distance(ll_to_earth(45,45),ll_to_earth(45.0001,45.0001))*1.00001) @>
ll_to_earth(45.0001,45.0001);
SELECT earth_box(ll_to_earth(90,180),
- earth_distance(ll_to_earth(90,180),ll_to_earth(90.0001,180.0001))*1.00001) @
+ earth_distance(ll_to_earth(90,180),ll_to_earth(90.0001,180.0001))*1.00001) @>
ll_to_earth(90.0001,180.0001);
--
--
SELECT earth_box(ll_to_earth(0,0),
- earth_distance(ll_to_earth(0,0),ll_to_earth(0,1))*.57735) @
+ earth_distance(ll_to_earth(0,0),ll_to_earth(0,1))*.57735) @>
ll_to_earth(0,1);
SELECT earth_box(ll_to_earth(0,0),
- earth_distance(ll_to_earth(0,0),ll_to_earth(0,0.1))*.57735) @
+ earth_distance(ll_to_earth(0,0),ll_to_earth(0,0.1))*.57735) @>
ll_to_earth(0,0.1);
SELECT earth_box(ll_to_earth(0,0),
- earth_distance(ll_to_earth(0,0),ll_to_earth(0,0.01))*.57735) @
+ earth_distance(ll_to_earth(0,0),ll_to_earth(0,0.01))*.57735) @>
ll_to_earth(0,0.01);
SELECT earth_box(ll_to_earth(0,0),
- earth_distance(ll_to_earth(0,0),ll_to_earth(0,0.001))*.57735) @
+ earth_distance(ll_to_earth(0,0),ll_to_earth(0,0.001))*.57735) @>
ll_to_earth(0,0.001);
SELECT earth_box(ll_to_earth(0,0),
- earth_distance(ll_to_earth(0,0),ll_to_earth(0,0.0001))*.57735) @
+ earth_distance(ll_to_earth(0,0),ll_to_earth(0,0.0001))*.57735) @>
ll_to_earth(0,0.0001);
SELECT earth_box(ll_to_earth(0,0),
- earth_distance(ll_to_earth(0,0),ll_to_earth(0.0001,0.0001))*.57735) @
+ earth_distance(ll_to_earth(0,0),ll_to_earth(0.0001,0.0001))*.57735) @>
ll_to_earth(0.0001,0.0001);
SELECT earth_box(ll_to_earth(45,45),
- earth_distance(ll_to_earth(45,45),ll_to_earth(45.0001,45.0001))*.57735) @
+ earth_distance(ll_to_earth(45,45),ll_to_earth(45.0001,45.0001))*.57735) @>
ll_to_earth(45.0001,45.0001);
SELECT earth_box(ll_to_earth(90,180),
- earth_distance(ll_to_earth(90,180),ll_to_earth(90.0001,180.0001))*.57735) @
+ earth_distance(ll_to_earth(90,180),ll_to_earth(90.0001,180.0001))*.57735) @>
ll_to_earth(90.0001,180.0001);
--
----------
"a"=>"b"
- * hstore @ hstore - contains operation, check if left operand contains right.
+ * hstore @> hstore - contains operation, check if left operand contains right.
-regression=# select 'a=>b, b=>1, c=>NULL'::hstore @ 'a=>c';
+regression=# select 'a=>b, b=>1, c=>NULL'::hstore @> 'a=>c';
?column?
----------
f
(1 row)
-regression=# select 'a=>b, b=>1, c=>NULL'::hstore @ 'b=>1';
+regression=# select 'a=>b, b=>1, c=>NULL'::hstore @> 'b=>1';
?column?
----------
t
(1 row)
- * hstore ~ hstore - contained operation, check if left operand is contained
+ * hstore <@ hstore - contained operation, check if left operand is contained
in right
+(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!)
+
Functions
* akeys(hstore) - returns all keys from hstore as array
Indices
-Module provides index support for '@' and '~' operations.
+Module provides index support for '@>' and '<@' operations.
create index hidx on testhstore using gist(h);
+--
+-- first, define the datatype. Turn off echoing so that expected file
+-- does not depend on contents of hstore.sql.
+--
+SET client_min_messages = warning;
\set ECHO none
-psql:hstore.sql:8: NOTICE: type "hstore" is not yet defined
-DETAIL: Creating a shell type definition.
-psql:hstore.sql:13: NOTICE: argument type hstore is only a shell
-psql:hstore.sql:132: NOTICE: type "ghstore" is not yet defined
-DETAIL: Creating a shell type definition.
-psql:hstore.sql:137: NOTICE: argument type ghstore is only a shell
+RESET client_min_messages;
+set escape_string_warning=off;
--hstore;
select ''::hstore;
hstore
aaa | bq
(3 rows)
--- @
-select 'a=>b, b=>1, c=>NULL'::hstore @ 'a=>NULL';
+-- @>
+select 'a=>b, b=>1, c=>NULL'::hstore @> 'a=>NULL';
?column?
----------
t
(1 row)
-select 'a=>b, b=>1, c=>NULL'::hstore @ 'a=>NULL, c=>NULL';
+select 'a=>b, b=>1, c=>NULL'::hstore @> 'a=>NULL, c=>NULL';
?column?
----------
t
(1 row)
-select 'a=>b, b=>1, c=>NULL'::hstore @ 'a=>NULL, g=>NULL';
+select 'a=>b, b=>1, c=>NULL'::hstore @> 'a=>NULL, g=>NULL';
?column?
----------
f
(1 row)
-select 'a=>b, b=>1, c=>NULL'::hstore @ 'g=>NULL';
+select 'a=>b, b=>1, c=>NULL'::hstore @> 'g=>NULL';
?column?
----------
f
(1 row)
-select 'a=>b, b=>1, c=>NULL'::hstore @ 'a=>c';
+select 'a=>b, b=>1, c=>NULL'::hstore @> 'a=>c';
?column?
----------
f
(1 row)
-select 'a=>b, b=>1, c=>NULL'::hstore @ 'a=>b';
+select 'a=>b, b=>1, c=>NULL'::hstore @> 'a=>b';
?column?
----------
t
(1 row)
-select 'a=>b, b=>1, c=>NULL'::hstore @ 'a=>b, c=>NULL';
+select 'a=>b, b=>1, c=>NULL'::hstore @> 'a=>b, c=>NULL';
?column?
----------
t
(1 row)
-select 'a=>b, b=>1, c=>NULL'::hstore @ 'a=>b, c=>q';
+select 'a=>b, b=>1, c=>NULL'::hstore @> 'a=>b, c=>q';
?column?
----------
f
CREATE TABLE testhstore (h hstore);
\copy testhstore from 'data/hstore.data'
-select count(*) from testhstore where h @ 'wait=>NULL';
+select count(*) from testhstore where h @> 'wait=>NULL';
count
-------
189
(1 row)
-select count(*) from testhstore where h @ 'wait=>CC';
+select count(*) from testhstore where h @> 'wait=>CC';
count
-------
15
(1 row)
-select count(*) from testhstore where h @ 'wait=>CC, public=>t';
+select count(*) from testhstore where h @> 'wait=>CC, public=>t';
count
-------
2
create index hidx on testhstore using gist(h);
set enable_seqscan=off;
-select count(*) from testhstore where h @ 'wait=>NULL';
+select count(*) from testhstore where h @> 'wait=>NULL';
count
-------
189
(1 row)
-select count(*) from testhstore where h @ 'wait=>CC';
+select count(*) from testhstore where h @> 'wait=>CC';
count
-------
15
(1 row)
-select count(*) from testhstore where h @ 'wait=>CC, public=>t';
+select count(*) from testhstore where h @> 'wait=>CC, public=>t';
count
-------
2
AS 'MODULE_PATHNAME'
LANGUAGE 'C' with (isstrict,iscachable);
+CREATE FUNCTION hs_contained(hstore,hstore)
+RETURNS bool
+AS 'MODULE_PATHNAME'
+LANGUAGE 'C' with (isstrict,iscachable);
+
+CREATE OPERATOR @> (
+ LEFTARG = hstore,
+ RIGHTARG = hstore,
+ PROCEDURE = hs_contains,
+ COMMUTATOR = '<@',
+ RESTRICT = contsel,
+ JOIN = contjoinsel
+);
+
+CREATE OPERATOR <@ (
+ LEFTARG = hstore,
+ RIGHTARG = hstore,
+ PROCEDURE = hs_contained,
+ COMMUTATOR = '@>',
+ RESTRICT = contsel,
+ JOIN = contjoinsel
+);
+
+-- obsolete:
CREATE OPERATOR @ (
LEFTARG = hstore,
RIGHTARG = hstore,
JOIN = contjoinsel
);
-CREATE FUNCTION hs_contained(hstore,hstore)
-RETURNS bool
-AS 'MODULE_PATHNAME'
-LANGUAGE 'C' with (isstrict,iscachable);
-
CREATE OPERATOR ~ (
LEFTARG = hstore,
RIGHTARG = hstore,
CREATE OPERATOR CLASS gist_hstore_ops
DEFAULT FOR TYPE hstore USING gist
AS
- OPERATOR 7 @ RECHECK,
- --OPERATOR 8 ~ RECHECK,
+ OPERATOR 7 @> RECHECK,
+ --OPERATOR 8 <@ RECHECK,
+ OPERATOR 13 @ RECHECK,
+ --OPERATOR 14 ~ RECHECK,
FUNCTION 1 ghstore_consistent (internal, internal, int4),
FUNCTION 2 ghstore_union (internal, internal),
FUNCTION 3 ghstore_compress (internal),
+--
+-- first, define the datatype. Turn off echoing so that expected file
+-- does not depend on contents of hstore.sql.
+--
+SET client_min_messages = warning;
\set ECHO none
\i hstore.sql
-set escape_string_warning=off;
\set ECHO all
+RESET client_min_messages;
+
+set escape_string_warning=off;
+
--hstore;
select ''::hstore;
select * from each('aaa=>bq, b=>NULL, ""=>1 ');
--- @
-select 'a=>b, b=>1, c=>NULL'::hstore @ 'a=>NULL';
-select 'a=>b, b=>1, c=>NULL'::hstore @ 'a=>NULL, c=>NULL';
-select 'a=>b, b=>1, c=>NULL'::hstore @ 'a=>NULL, g=>NULL';
-select 'a=>b, b=>1, c=>NULL'::hstore @ 'g=>NULL';
-select 'a=>b, b=>1, c=>NULL'::hstore @ 'a=>c';
-select 'a=>b, b=>1, c=>NULL'::hstore @ 'a=>b';
-select 'a=>b, b=>1, c=>NULL'::hstore @ 'a=>b, c=>NULL';
-select 'a=>b, b=>1, c=>NULL'::hstore @ 'a=>b, c=>q';
+-- @>
+select 'a=>b, b=>1, c=>NULL'::hstore @> 'a=>NULL';
+select 'a=>b, b=>1, c=>NULL'::hstore @> 'a=>NULL, c=>NULL';
+select 'a=>b, b=>1, c=>NULL'::hstore @> 'a=>NULL, g=>NULL';
+select 'a=>b, b=>1, c=>NULL'::hstore @> 'g=>NULL';
+select 'a=>b, b=>1, c=>NULL'::hstore @> 'a=>c';
+select 'a=>b, b=>1, c=>NULL'::hstore @> 'a=>b';
+select 'a=>b, b=>1, c=>NULL'::hstore @> 'a=>b, c=>NULL';
+select 'a=>b, b=>1, c=>NULL'::hstore @> 'a=>b, c=>q';
CREATE TABLE testhstore (h hstore);
\copy testhstore from 'data/hstore.data'
-select count(*) from testhstore where h @ 'wait=>NULL';
-select count(*) from testhstore where h @ 'wait=>CC';
-select count(*) from testhstore where h @ 'wait=>CC, public=>t';
+select count(*) from testhstore where h @> 'wait=>NULL';
+select count(*) from testhstore where h @> 'wait=>CC';
+select count(*) from testhstore where h @> 'wait=>CC, public=>t';
create index hidx on testhstore using gist(h);
set enable_seqscan=off;
-select count(*) from testhstore where h @ 'wait=>NULL';
-select count(*) from testhstore where h @ 'wait=>CC';
-select count(*) from testhstore where h @ 'wait=>CC, public=>t';
+select count(*) from testhstore where h @> 'wait=>NULL';
+select count(*) from testhstore where h @> 'wait=>CC';
+select count(*) from testhstore where h @> 'wait=>CC, public=>t';
select count(*) from (select (each(h)).key from testhstore) as wow ;
select key, count(*) from (select (each(h)).key from testhstore) as wow group by key order by count desc, key;
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
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:
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:
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,
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';
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';
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
-- 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,
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),
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,
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),
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),
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);
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));
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,
-- 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
--------
403
(1 row)
-SELECT count(*) from test__int WHERE a @ '{23,50}';
+SELECT count(*) from test__int WHERE a @> '{23,50}';
count
-------
12
12
(1 row)
-SELECT count(*) from test__int WHERE a @ '{20,23}';
+SELECT count(*) from test__int WHERE a @> '{20,23}';
count
-------
12
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
403
(1 row)
-SELECT count(*) from test__int WHERE a @ '{23,50}';
+SELECT count(*) from test__int WHERE a @> '{23,50}';
count
-------
12
12
(1 row)
-SELECT count(*) from test__int WHERE a @ '{20,23}';
+SELECT count(*) from test__int WHERE a @> '{20,23}';
count
-------
12
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
403
(1 row)
-SELECT count(*) from test__int WHERE a @ '{23,50}';
+SELECT count(*) from test__int WHERE a @> '{23,50}';
count
-------
12
12
(1 row)
-SELECT count(*) from test__int WHERE a @ '{20,23}';
+SELECT count(*) from test__int WHERE a @> '{20,23}';
count
-------
12
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
403
(1 row)
-SELECT count(*) from test__int WHERE a @ '{23,50}';
+SELECT count(*) from test__int WHERE a @> '{23,50}';
count
-------
12
12
(1 row)
-SELECT count(*) from test__int WHERE a @ '{20,23}';
+SELECT count(*) from test__int WHERE a @> '{20,23}';
count
-------
12
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
-- 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}');
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;
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;
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)';
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);
DROP FUNCTION intset(int4);
+DROP OPERATOR <@ (_int4, _int4);
+
+DROP OPERATOR @> (_int4, _int4);
+
DROP OPERATOR ~ (_int4, _int4);
DROP OPERATOR @ (_int4, _int4);
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.
-- 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
--
-- "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
-- "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
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
-- 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
--
-- "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
-- "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
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
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:
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:
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,
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),
-- 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
-- "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
--
\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;
DROP FUNCTION gseg_consistent(internal,seg,int4);
+DROP OPERATOR <@ (seg, seg);
+
+DROP OPERATOR @> (seg, seg);
+
DROP OPERATOR ~ (seg, seg);
DROP OPERATOR @ (seg, seg);
--
-- first, define the datatype. Turn off echoing so that expected file
--- does not depend on contents of seg.sql.
+-- does not depend on contents of tsearch2.sql.
--
+SET client_min_messages = warning;
\set ECHO none
-psql:tsearch2.sql:13: NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "pg_ts_dict_pkey" for table "pg_ts_dict"
-psql:tsearch2.sql:177: NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "pg_ts_parser_pkey" for table "pg_ts_parser"
-psql:tsearch2.sql:276: NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "pg_ts_cfg_pkey" for table "pg_ts_cfg"
-psql:tsearch2.sql:283: NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "pg_ts_cfgmap_pkey" for table "pg_ts_cfgmap"
-psql:tsearch2.sql:389: NOTICE: type "tsvector" is not yet defined
-DETAIL: Creating a shell type definition.
-psql:tsearch2.sql:394: NOTICE: argument type tsvector is only a shell
-psql:tsearch2.sql:448: NOTICE: type "tsquery" is not yet defined
-DETAIL: Creating a shell type definition.
-psql:tsearch2.sql:453: NOTICE: argument type tsquery is only a shell
-psql:tsearch2.sql:611: NOTICE: type "gtsvector" is not yet defined
-DETAIL: Creating a shell type definition.
-psql:tsearch2.sql:616: NOTICE: argument type gtsvector is only a shell
-psql:tsearch2.sql:1106: NOTICE: type "gtsq" is not yet defined
-DETAIL: Creating a shell type definition.
-psql:tsearch2.sql:1111: NOTICE: argument type gtsq is only a shell
+RESET client_min_messages;
--tsvector
SELECT '1'::tsvector;
tsvector
----------
- '1'
+ '1'
(1 row)
SELECT '1 '::tsvector;
tsvector
----------
- '1'
+ '1'
(1 row)
SELECT ' 1'::tsvector;
tsvector
----------
- '1'
+ '1'
(1 row)
SELECT ' 1 '::tsvector;
tsvector
----------
- '1'
+ '1'
(1 row)
SELECT '1 2'::tsvector;
tsvector
----------
- '1' '2'
+ '1' '2'
(1 row)
SELECT '''1 2'''::tsvector;
tsvector
----------
- '1 2'
+ '1 2'
(1 row)
SELECT E'''1 \\''2'''::tsvector;
SELECT '1'::tsquery;
tsquery
---------
- '1'
+ '1'
(1 row)
SELECT '1 '::tsquery;
tsquery
---------
- '1'
+ '1'
(1 row)
SELECT ' 1'::tsquery;
tsquery
---------
- '1'
+ '1'
(1 row)
SELECT ' 1 '::tsquery;
tsquery
---------
- '1'
+ '1'
(1 row)
SELECT '''1 2'''::tsquery;
tsquery
---------
- '1 2'
+ '1 2'
(1 row)
SELECT E'''1 \\''2'''::tsquery;
SELECT '!1'::tsquery;
tsquery
---------
- !'1'
+ !'1'
(1 row)
SELECT '1|2'::tsquery;
select 'a' < 'b & c'::tsquery;
?column?
----------
- t
+ t
(1 row)
select 'a' > 'b & c'::tsquery;
?column?
----------
- f
+ f
(1 row)
select 'a | f' < 'b & c'::tsquery;
?column?
----------
- t
+ t
(1 row)
select 'a | ff' < 'b & c'::tsquery;
?column?
----------
- f
+ f
(1 row)
select 'a | f | g' < 'b & c'::tsquery;
?column?
----------
- f
+ f
(1 row)
select numnode( 'new'::tsquery );
'citi' & 'foo' & ( 'qq' | 'bar' ) & ( 'nyc' | ( 'appl' & 'big' | 'york' & 'new' ) )
(1 row)
-select keyword from test_tsquery where keyword @ 'new';
+select keyword from test_tsquery where keyword @> 'new';
keyword
----------------
'new' & 'york'
(1 row)
-select keyword from test_tsquery where keyword @ 'moscow';
+select keyword from test_tsquery where keyword @> 'moscow';
keyword
----------
'moscow'
(1 row)
-select keyword from test_tsquery where keyword ~ 'new';
+select keyword from test_tsquery where keyword <@ 'new';
keyword
---------
(0 rows)
-select keyword from test_tsquery where keyword ~ 'moscow';
+select keyword from test_tsquery where keyword <@ 'moscow';
keyword
----------
'moscow'
(1 row)
-select rewrite( ARRAY[query, keyword, sample] ) from test_tsquery, to_tsquery('default', 'moscow') as query where keyword ~ query;
+select rewrite( ARRAY[query, keyword, sample] ) from test_tsquery, to_tsquery('default', 'moscow') as query where keyword <@ query;
rewrite
---------------------
'moskva' | 'moscow'
(1 row)
-select rewrite( ARRAY[query, keyword, sample] ) from test_tsquery, to_tsquery('default', 'moscow & hotel') as query where keyword ~ query;
+select rewrite( ARRAY[query, keyword, sample] ) from test_tsquery, to_tsquery('default', 'moscow & hotel') as query where keyword <@ query;
rewrite
-----------------------------------
( 'moskva' | 'moscow' ) & 'hotel'
(1 row)
-select rewrite( ARRAY[query, keyword, sample] ) from test_tsquery, to_tsquery('default', 'bar & new & qq & foo & york') as query where keyword ~ query;
+select rewrite( ARRAY[query, keyword, sample] ) from test_tsquery, to_tsquery('default', 'bar & new & qq & foo & york') as query where keyword <@ query;
rewrite
-------------------------------------------------------------------------------------
'citi' & 'foo' & ( 'qq' | 'bar' ) & ( 'nyc' | ( 'appl' & 'big' | 'york' & 'new' ) )
(1 row)
-select rewrite( ARRAY[query, keyword, sample] ) from test_tsquery, to_tsquery('default', 'moscow') as query where query @ keyword;
+select rewrite( ARRAY[query, keyword, sample] ) from test_tsquery, to_tsquery('default', 'moscow') as query where query @> keyword;
rewrite
---------------------
'moskva' | 'moscow'
(1 row)
-select rewrite( ARRAY[query, keyword, sample] ) from test_tsquery, to_tsquery('default', 'moscow & hotel') as query where query @ keyword;
+select rewrite( ARRAY[query, keyword, sample] ) from test_tsquery, to_tsquery('default', 'moscow & hotel') as query where query @> keyword;
rewrite
-----------------------------------
( 'moskva' | 'moscow' ) & 'hotel'
(1 row)
-select rewrite( ARRAY[query, keyword, sample] ) from test_tsquery, to_tsquery('default', 'bar & new & qq & foo & york') as query where query @ keyword;
+select rewrite( ARRAY[query, keyword, sample] ) from test_tsquery, to_tsquery('default', 'bar & new & qq & foo & york') as query where query @> keyword;
rewrite
-------------------------------------------------------------------------------------
'citi' & 'foo' & ( 'qq' | 'bar' ) & ( 'nyc' | ( 'appl' & 'big' | 'york' & 'new' ) )
create index qq on test_tsquery using gist (keyword gist_tp_tsquery_ops);
set enable_seqscan='off';
-select keyword from test_tsquery where keyword @ 'new';
+select keyword from test_tsquery where keyword @> 'new';
keyword
----------------
'new' & 'york'
(1 row)
-select keyword from test_tsquery where keyword @ 'moscow';
+select keyword from test_tsquery where keyword @> 'moscow';
keyword
----------
'moscow'
(1 row)
-select keyword from test_tsquery where keyword ~ 'new';
+select keyword from test_tsquery where keyword <@ 'new';
keyword
---------
(0 rows)
-select keyword from test_tsquery where keyword ~ 'moscow';
+select keyword from test_tsquery where keyword <@ 'moscow';
keyword
----------
'moscow'
(1 row)
-select rewrite( ARRAY[query, keyword, sample] ) from test_tsquery, to_tsquery('default', 'moscow') as query where keyword ~ query;
+select rewrite( ARRAY[query, keyword, sample] ) from test_tsquery, to_tsquery('default', 'moscow') as query where keyword <@ query;
rewrite
---------------------
'moskva' | 'moscow'
(1 row)
-select rewrite( ARRAY[query, keyword, sample] ) from test_tsquery, to_tsquery('default', 'moscow & hotel') as query where keyword ~ query;
+select rewrite( ARRAY[query, keyword, sample] ) from test_tsquery, to_tsquery('default', 'moscow & hotel') as query where keyword <@ query;
rewrite
-----------------------------------
( 'moskva' | 'moscow' ) & 'hotel'
(1 row)
-select rewrite( ARRAY[query, keyword, sample] ) from test_tsquery, to_tsquery('default', 'bar & new & qq & foo & york') as query where keyword ~ query;
+select rewrite( ARRAY[query, keyword, sample] ) from test_tsquery, to_tsquery('default', 'bar & new & qq & foo & york') as query where keyword <@ query;
rewrite
-------------------------------------------------------------------------------------
'citi' & 'foo' & ( 'qq' | 'bar' ) & ( 'nyc' | ( 'appl' & 'big' | 'york' & 'new' ) )
(1 row)
-select rewrite( ARRAY[query, keyword, sample] ) from test_tsquery, to_tsquery('default', 'moscow') as query where query @ keyword;
+select rewrite( ARRAY[query, keyword, sample] ) from test_tsquery, to_tsquery('default', 'moscow') as query where query @> keyword;
rewrite
---------------------
'moskva' | 'moscow'
(1 row)
-select rewrite( ARRAY[query, keyword, sample] ) from test_tsquery, to_tsquery('default', 'moscow & hotel') as query where query @ keyword;
+select rewrite( ARRAY[query, keyword, sample] ) from test_tsquery, to_tsquery('default', 'moscow & hotel') as query where query @> keyword;
rewrite
-----------------------------------
( 'moskva' | 'moscow' ) & 'hotel'
(1 row)
-select rewrite( ARRAY[query, keyword, sample] ) from test_tsquery, to_tsquery('default', 'bar & new & qq & foo & york') as query where query @ keyword;
+select rewrite( ARRAY[query, keyword, sample] ) from test_tsquery, to_tsquery('default', 'bar & new & qq & foo & york') as query where query @> keyword;
rewrite
-------------------------------------------------------------------------------------
'citi' & 'foo' & ( 'qq' | 'bar' ) & ( 'nyc' | ( 'appl' & 'big' | 'york' & 'new' ) )
select * from token_type('default');
tokid | alias | descr
-------+--------------+-----------------------------------
- 1 | lword | Latin word
- 2 | nlword | Non-latin word
- 3 | word | Word
- 4 | email | Email
- 5 | url | URL
- 6 | host | Host
- 7 | sfloat | Scientific notation
- 8 | version | VERSION
- 9 | part_hword | Part of hyphenated word
+ 1 | lword | Latin word
+ 2 | nlword | Non-latin word
+ 3 | word | Word
+ 4 | email | Email
+ 5 | url | URL
+ 6 | host | Host
+ 7 | sfloat | Scientific notation
+ 8 | version | VERSION
+ 9 | part_hword | Part of hyphenated word
10 | nlpart_hword | Non-latin part of hyphenated word
- 11 | lpart_hword | Latin part of hyphenated word
- 12 | blank | Space symbols
- 13 | tag | HTML Tag
- 14 | protocol | Protocol head
- 15 | hword | Hyphenated word
- 16 | lhword | Latin hyphenated word
- 17 | nlhword | Non-latin hyphenated word
- 18 | uri | URI
- 19 | file | File or path name
- 20 | float | Decimal notation
- 21 | int | Signed integer
- 22 | uint | Unsigned integer
- 23 | entity | HTML Entity
+ 11 | lpart_hword | Latin part of hyphenated word
+ 12 | blank | Space symbols
+ 13 | tag | HTML Tag
+ 14 | protocol | Protocol head
+ 15 | hword | Hyphenated word
+ 16 | lhword | Latin hyphenated word
+ 17 | nlhword | Non-latin hyphenated word
+ 18 | uri | URI
+ 19 | file | File or path name
+ 20 | float | Decimal notation
+ 21 | int | Signed integer
+ 22 | uint | Unsigned integer
+ 23 | entity | HTML Entity
(23 rows)
select * from parse('default', '345
[email protected] '' http://www.com/ http://aew.werc.ewr/?ad=qwe&dw 1aew.werc.ewr/?ad=qwe&dw 2aew.werc.ewr http://3aew.werc.ewr/?ad=qwe&dw http://4aew.werc.ewr http://5aew.werc.ewr:8100/? ad=qwe&dw 6aew.werc.ewr:8100/?ad=qwe&dw 7aew.werc.ewr:8100/?ad=qwe&dw=%20%32 +4.0e-10 qwe qwe qwqwe 234.435 455 5.005
[email protected] qwe-wer asdf
qwer jf sdjk ewr1> ewri2 ">
wow < jqw <> qwerty');
tokid | token
-------+--------------------------------------
- 22 | 345
- 12 |
- 1 | qwe
- 12 | @
- 19 | efd.r
- 12 | '
- 14 | http://
- 6 | www.com
- 12 | /
- 14 | http://
- 5 | aew.werc.ewr/?ad=qwe&dw
- 6 | aew.werc.ewr
- 18 | /?ad=qwe&dw
- 12 |
- 5 | 1aew.werc.ewr/?ad=qwe&dw
- 6 | 1aew.werc.ewr
- 18 | /?ad=qwe&dw
- 12 |
- 6 | 2aew.werc.ewr
- 12 |
- 14 | http://
- 5 | 3aew.werc.ewr/?ad=qwe&dw
- 6 | 3aew.werc.ewr
- 18 | /?ad=qwe&dw
- 12 |
- 14 | http://
- 6 | 4aew.werc.ewr
- 12 |
- 14 | http://
- 6 | 5aew.werc.ewr:8100
- 12 | /?
- 1 | ad
- 12 | =
- 1 | qwe
- 12 | &
- 1 | dw
- 12 |
- 5 | 6aew.werc.ewr:8100/?ad=qwe&dw
- 6 | 6aew.werc.ewr:8100
- 18 | /?ad=qwe&dw
- 12 |
+ 22 | 345
+ 12 |
+ 1 | qwe
+ 12 | @
+ 19 | efd.r
+ 12 | '
+ 14 | http://
+ 6 | www.com
+ 12 | /
+ 14 | http://
+ 5 | aew.werc.ewr/?ad=qwe&dw
+ 6 | aew.werc.ewr
+ 18 | /?ad=qwe&dw
+ 12 |
+ 5 | 1aew.werc.ewr/?ad=qwe&dw
+ 6 | 1aew.werc.ewr
+ 18 | /?ad=qwe&dw
+ 12 |
+ 6 | 2aew.werc.ewr
+ 12 |
+ 14 | http://
+ 5 | 3aew.werc.ewr/?ad=qwe&dw
+ 6 | 3aew.werc.ewr
+ 18 | /?ad=qwe&dw
+ 12 |
+ 14 | http://
+ 6 | 4aew.werc.ewr
+ 12 |
+ 14 | http://
+ 6 | 5aew.werc.ewr:8100
+ 12 | /?
+ 1 | ad
+ 12 | =
+ 1 | qwe
+ 12 | &
+ 1 | dw
+ 12 |
+ 5 | 6aew.werc.ewr:8100/?ad=qwe&dw
+ 6 | 6aew.werc.ewr:8100
+ 18 | /?ad=qwe&dw
+ 12 |
5 | 7aew.werc.ewr:8100/?ad=qwe&dw=%20%32
- 6 | 7aew.werc.ewr:8100
- 18 | /?ad=qwe&dw=%20%32
- 12 |
- 7 | +4.0e-10
- 12 |
- 1 | qwe
- 12 |
- 1 | qwe
- 12 |
- 1 | qwqwe
- 12 |
- 20 | 234.435
- 12 |
- 22 | 455
- 12 |
- 20 | 5.005
- 12 |
- 12 |
- 16 | qwe-wer
- 11 | qwe
- 12 | -
- 11 | wer
- 12 |
- 1 | asdf
- 12 |
- 13 |
- 1 | qwer
- 12 |
- 1 | jf
- 12 |
- 1 | sdjk
- 12 | <
- 1 | we
- 12 |
- 1 | hjwer
- 12 |
- 13 |
- 12 |
- 3 | ewr1
- 12 | >
- 3 | ewri2
- 12 |
- 12 |
- :
- 19 | /usr/local/fff
- 12 |
- 19 | /awdf/dwqe/4325
- 12 |
- 19 | rewt/ewr
- 12 |
- 1 | wefjn
- 12 |
- 19 | /wqe-324/ewr
- 12 |
- 19 | gist.h
- 12 |
- 19 | gist.h.c
- 12 |
- 19 | gist.c
- 12 | .
- 1 | readline
- 12 |
- 20 | 4.2
- 12 |
- 20 | 4.2
- 12 | .
- 20 | 4.2
- 12 | ,
- 15 | readline-4.2
- 11 | readline
- 12 | -
- 20 | 4.2
- 12 |
- 15 | readline-4.2
- 11 | readline
- 12 | -
- 20 | 4.2
- 12 | .
- 22 | 234
- 12 |
- :
- 12 | <
- 1 | i
- 12 |
- 13 |
- 12 |
- 1 | wow
- 12 |
- 12 | <
- 1 | jqw
- 12 |
- 12 | <>
- 1 | qwerty
+ 6 | 7aew.werc.ewr:8100
+ 18 | /?ad=qwe&dw=%20%32
+ 12 |
+ 7 | +4.0e-10
+ 12 |
+ 1 | qwe
+ 12 |
+ 1 | qwe
+ 12 |
+ 1 | qwqwe
+ 12 |
+ 20 | 234.435
+ 12 |
+ 22 | 455
+ 12 |
+ 20 | 5.005
+ 12 |
+ 12 |
+ 16 | qwe-wer
+ 11 | qwe
+ 12 | -
+ 11 | wer
+ 12 |
+ 1 | asdf
+ 12 |
+ 13 |
+ 1 | qwer
+ 12 |
+ 1 | jf
+ 12 |
+ 1 | sdjk
+ 12 | <
+ 1 | we
+ 12 |
+ 1 | hjwer
+ 12 |
+ 13 |
+ 12 |
+ 3 | ewr1
+ 12 | >
+ 3 | ewri2
+ 12 |
+ 12 |
+ :
+ 19 | /usr/local/fff
+ 12 |
+ 19 | /awdf/dwqe/4325
+ 12 |
+ 19 | rewt/ewr
+ 12 |
+ 1 | wefjn
+ 12 |
+ 19 | /wqe-324/ewr
+ 12 |
+ 19 | gist.h
+ 12 |
+ 19 | gist.h.c
+ 12 |
+ 19 | gist.c
+ 12 | .
+ 1 | readline
+ 12 |
+ 20 | 4.2
+ 12 |
+ 20 | 4.2
+ 12 | .
+ 20 | 4.2
+ 12 | ,
+ 15 | readline-4.2
+ 11 | readline
+ 12 | -
+ 20 | 4.2
+ 12 |
+ 15 | readline-4.2
+ 11 | readline
+ 12 | -
+ 20 | 4.2
+ 12 | .
+ 22 | 234
+ 12 |
+ :
+ 12 | <
+ 1 | i
+ 12 |
+ 13 |
+ 12 |
+ 1 | wow
+ 12 |
+ 12 | <
+ 1 | jqw
+ 12 |
+ 12 | <>
+ 1 | qwerty
(135 rows)
SELECT to_tsvector('default', '345
[email protected] '' http://www.com/ http://aew.werc.ewr/?ad=qwe&dw 1aew.werc.ewr/?ad=qwe&dw 2aew.werc.ewr http://3aew.werc.ewr/?ad=qwe&dw http://4aew.werc.ewr http://5aew.werc.ewr:8100/? ad=qwe&dw 6aew.werc.ewr:8100/?ad=qwe&dw 7aew.werc.ewr:8100/?ad=qwe&dw=%20%32 +4.0e-10 qwe qwe qwqwe 234.435 455 5.005
[email protected] qwe-wer asdf
qwer jf sdjk ewr1> ewri2 ">
select 'a b:89 ca:23A,64b d:34c'::tsvector @@ 'd:AC & ca';
?column?
----------
- t
+ t
(1 row)
select 'a b:89 ca:23A,64b d:34c'::tsvector @@ 'd:AC & ca:B';
?column?
----------
- t
+ t
(1 row)
select 'a b:89 ca:23A,64b d:34c'::tsvector @@ 'd:AC & ca:A';
?column?
----------
- t
+ t
(1 row)
select 'a b:89 ca:23A,64b d:34c'::tsvector @@ 'd:AC & ca:C';
?column?
----------
- f
+ f
(1 row)
select 'a b:89 ca:23A,64b d:34c'::tsvector @@ 'd:AC & ca:CB';
?column?
----------
- t
+ t
(1 row)
CREATE TABLE test_tsvector( t text, a tsvector );
select set_curcfg('default');
set_curcfg
------------
-
+
(1 row)
CREATE TRIGGER tsvectorupdate
NOTICE: TSearch cache cleaned
reset_tsearch
---------------
-
+
(1 row)
select to_tsquery('default', 'skies & books');
headline
--------------------------------------------
sea a thousand years,
- A thousand years to trace
- The granite features of this cliff
+ A thousand years to trace
+ The granite features of this cliff
(1 row)
', to_tsquery('granite&sea'));
headline
-------------------------------------------
- sea a thousand years,
- A thousand years to trace
+ sea a thousand years,
+ A thousand years to trace
The granite features of this cliff
(1 row)
', to_tsquery('sea'));
headline
------------------------------------
- sea a thousand years,
- A thousand years to trace
+ sea a thousand years,
+ A thousand years to trace
The granite features of this cliff
(1 row)
to_tsquery('sea&foo'), 'HighlightAll=true');
headline
-----------------------------------------------------------------------------
-
-
-
-
- Sea view wow foo bar qq
+
+
+
+
+ Sea view wow foo bar qq
- ff-bg
-
-
-
+ ff-bg
+
+ document.write(15);
+
+
+
(1 row)
--check debug
select * from ts_debug('Tsearch module for PostgreSQL 7.3.3');
ts_name | tok_type | description | token | dict_name | tsvector
---------+----------+-------------+------------+-----------+--------------
- default | lword | Latin word | Tsearch | {en_stem} | 'tsearch'
- default | lword | Latin word | module | {en_stem} | 'modul'
- default | lword | Latin word | for | {en_stem} |
+ default | lword | Latin word | Tsearch | {en_stem} | 'tsearch'
+ default | lword | Latin word | module | {en_stem} | 'modul'
+ default | lword | Latin word | for | {en_stem} |
default | lword | Latin word | PostgreSQL | {en_stem} | 'postgresql'
- default | version | VERSION | 7.3.3 | {simple} | '7.3.3'
+ default | version | VERSION | 7.3.3 | {simple} | '7.3.3'
(5 rows)
--check ordering
select a is null, a from test_tsvector order by a;
?column? | a
----------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
- f |
- f |
- f |
- f |
- f |
- f |
- f |
- f |
- f | &nbs