Declare range inclusion operators as taking anyelement not anynonarray.

Use of anynonarray was a crude hack to get around ambiguity versus the
array inclusion operators of the same names.  My previous patch to extend
the parser's type resolution heuristics makes that unnecessary, so use
the more general declaration instead.  This eliminates a wart that these
operators couldn't be used with ranges over arrays, which are otherwise
supported just fine.

Also, mark range_before and range_after as commutator operators,
per discussion with Jeff Davis.
This commit is contained in:
Tom Lane 2011-11-17 18:56:33 -05:00
parent 1a8b9fb549
commit 709aca5960
6 changed files with 24 additions and 9 deletions

View File

@ -53,6 +53,6 @@
*/
/* yyyymmddN */
#define CATALOG_VERSION_NO 201111161
#define CATALOG_VERSION_NO 201111171
#endif

View File

@ -729,8 +729,8 @@ DATA(insert ( 3903 3831 3831 1 s 3882 405 0 ));
DATA(insert ( 3919 3831 3831 1 s 3882 783 0 ));
DATA(insert ( 3919 3831 3831 2 s 3883 783 0 ));
DATA(insert ( 3919 3831 3831 3 s 3888 783 0 ));
DATA(insert ( 3919 3831 2776 4 s 3889 783 0 ));
DATA(insert ( 3919 2776 3831 5 s 3891 783 0 ));
DATA(insert ( 3919 3831 2283 4 s 3889 783 0 ));
DATA(insert ( 3919 2283 3831 5 s 3891 783 0 ));
DATA(insert ( 3919 3831 3831 6 s 3890 783 0 ));
DATA(insert ( 3919 3831 3831 7 s 3892 783 0 ));
DATA(insert ( 3919 3831 3831 8 s 3893 783 0 ));

View File

@ -1676,17 +1676,17 @@ DATA(insert OID = 3887 ( ">" PGNSP PGUID b f f 3831 3831 16 3884 3885 range_
DESCR("greater than");
DATA(insert OID = 3888 ( "&&" PGNSP PGUID b f f 3831 3831 16 3888 0 range_overlaps - - ));
DESCR("overlaps");
DATA(insert OID = 3889 ( "@>" PGNSP PGUID b f f 3831 2776 16 3891 0 range_contains_elem - - ));
DATA(insert OID = 3889 ( "@>" PGNSP PGUID b f f 3831 2283 16 3891 0 range_contains_elem - - ));
DESCR("contains");
DATA(insert OID = 3890 ( "@>" PGNSP PGUID b f f 3831 3831 16 3892 0 range_contains - - ));
DESCR("contains");
DATA(insert OID = 3891 ( "<@" PGNSP PGUID b f f 2776 3831 16 3889 0 elem_contained_by_range - - ));
DATA(insert OID = 3891 ( "<@" PGNSP PGUID b f f 2283 3831 16 3889 0 elem_contained_by_range - - ));
DESCR("is contained by");
DATA(insert OID = 3892 ( "<@" PGNSP PGUID b f f 3831 3831 16 3890 0 range_contained_by - - ));
DESCR("is contained by");
DATA(insert OID = 3893 ( "<<" PGNSP PGUID b f f 3831 3831 16 0 0 range_before scalarltsel scalarltjoinsel ));
DATA(insert OID = 3893 ( "<<" PGNSP PGUID b f f 3831 3831 16 3894 0 range_before scalarltsel scalarltjoinsel ));
DESCR("is left of");
DATA(insert OID = 3894 ( ">>" PGNSP PGUID b f f 3831 3831 16 0 0 range_after scalargtsel scalargtjoinsel ));
DATA(insert OID = 3894 ( ">>" PGNSP PGUID b f f 3831 3831 16 3893 0 range_after scalargtsel scalargtjoinsel ));
DESCR("is right of");
DATA(insert OID = 3895 ( "&<" PGNSP PGUID b f f 3831 3831 16 0 0 range_overleft scalarltsel scalarltjoinsel ));
DESCR("overlaps or is left of");

View File

@ -4367,11 +4367,11 @@ DATA(insert OID = 3856 ( range_ne PGNSP PGUID 12 1 0 0 0 f f f t f i 2 0 16 "38
DESCR("implementation of <> operator");
DATA(insert OID = 3857 ( range_overlaps PGNSP PGUID 12 1 0 0 0 f f f t f i 2 0 16 "3831 3831" _null_ _null_ _null_ _null_ range_overlaps _null_ _null_ _null_ ));
DESCR("implementation of && operator");
DATA(insert OID = 3858 ( range_contains_elem PGNSP PGUID 12 1 0 0 0 f f f t f i 2 0 16 "3831 2776" _null_ _null_ _null_ _null_ range_contains_elem _null_ _null_ _null_ ));
DATA(insert OID = 3858 ( range_contains_elem PGNSP PGUID 12 1 0 0 0 f f f t f i 2 0 16 "3831 2283" _null_ _null_ _null_ _null_ range_contains_elem _null_ _null_ _null_ ));
DESCR("implementation of @> operator");
DATA(insert OID = 3859 ( range_contains PGNSP PGUID 12 1 0 0 0 f f f t f i 2 0 16 "3831 3831" _null_ _null_ _null_ _null_ range_contains _null_ _null_ _null_ ));
DESCR("implementation of @> operator");
DATA(insert OID = 3860 ( elem_contained_by_range PGNSP PGUID 12 1 0 0 0 f f f t f i 2 0 16 "2776 3831" _null_ _null_ _null_ _null_ elem_contained_by_range _null_ _null_ _null_ ));
DATA(insert OID = 3860 ( elem_contained_by_range PGNSP PGUID 12 1 0 0 0 f f f t f i 2 0 16 "2283 3831" _null_ _null_ _null_ _null_ elem_contained_by_range _null_ _null_ _null_ ));
DESCR("implementation of <@ operator");
DATA(insert OID = 3861 ( range_contained_by PGNSP PGUID 12 1 0 0 0 f f f t f i 2 0 16 "3831 3831" _null_ _null_ _null_ _null_ range_contained_by _null_ _null_ _null_ ));
DESCR("implementation of <@ operator");

View File

@ -964,6 +964,18 @@ select arrayrange(ARRAY[1,2], ARRAY[2,1]);
["{1,2}","{2,1}")
(1 row)
select array[1,1] <@ arrayrange(array[1,2], array[2,1]);
?column?
----------
f
(1 row)
select array[1,3] <@ arrayrange(array[1,2], array[2,1]);
?column?
----------
t
(1 row)
--
-- OUT/INOUT/TABLE functions
--

View File

@ -346,6 +346,9 @@ create type arrayrange as range (subtype=int4[]);
select arrayrange(ARRAY[1,2], ARRAY[2,1]);
select array[1,1] <@ arrayrange(array[1,2], array[2,1]);
select array[1,3] <@ arrayrange(array[1,2], array[2,1]);
--
-- OUT/INOUT/TABLE functions
--