From 156475a58985ed48ed45db595278037156ca737e Mon Sep 17 00:00:00 2001 From: Tom Lane Date: Sun, 7 Jun 2009 20:09:34 +0000 Subject: [PATCH] Revert my patch of 2009-04-04 that removed contrib/intarray's definitions of the <@ and @> operators. These are not in fact equivalent to the built-in anyarray operators of the same names, because they have different behavior for empty arrays, namely they don't think empty arrays are contained in anything. That is mathematically wrong, no doubt, but until we can persuade GIN indexes to implement the mathematical definition we should probably not change this. Another reason for not changing it now is that we can't yet ensure the opclasses will be updated correctly in a dump-and-reload upgrade. Per recent discussions. --- contrib/intarray/_int.sql.in | 46 ++++++++++++++--------------- contrib/intarray/uninstall__int.sql | 6 +++- doc/src/sgml/intarray.sgml | 35 +++++++++++++--------- doc/src/sgml/release-8.4.sgml | 16 +--------- 4 files changed, 50 insertions(+), 53 deletions(-) diff --git a/contrib/intarray/_int.sql.in b/contrib/intarray/_int.sql.in index 93930b559d5..645e9aeea2d 100644 --- a/contrib/intarray/_int.sql.in +++ b/contrib/intarray/_int.sql.in @@ -1,4 +1,4 @@ -/* $PostgreSQL: pgsql/contrib/intarray/_int.sql.in,v 1.30 2009/04/05 00:40:35 tgl Exp $ */ +/* $PostgreSQL: pgsql/contrib/intarray/_int.sql.in,v 1.31 2009/06/07 20:09:34 tgl Exp $ */ -- Adjust this setting to control where the objects get created. SET search_path = public; @@ -152,23 +152,23 @@ 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_contains, + COMMUTATOR = '<@', + RESTRICT = contsel, + JOIN = contjoinsel +); ---CREATE OPERATOR <@ ( --- LEFTARG = _int4, --- RIGHTARG = _int4, --- PROCEDURE = _int_contained, --- COMMUTATOR = '@>', --- RESTRICT = contsel, --- JOIN = contjoinsel ---); +CREATE OPERATOR <@ ( + LEFTARG = _int4, + RIGHTARG = _int4, + PROCEDURE = _int_contained, + COMMUTATOR = '@>', + RESTRICT = contsel, + JOIN = contjoinsel +); -- obsolete: CREATE OPERATOR @ ( @@ -365,8 +365,8 @@ CREATE OPERATOR CLASS gist__int_ops DEFAULT FOR TYPE _int4 USING gist AS OPERATOR 3 &&, OPERATOR 6 = (anyarray, anyarray), - OPERATOR 7 @> (anyarray, anyarray), - OPERATOR 8 <@ (anyarray, anyarray), + OPERATOR 7 @>, + OPERATOR 8 <@, OPERATOR 13 @, OPERATOR 14 ~, OPERATOR 20 @@ (_int4, query_int), @@ -442,8 +442,8 @@ FOR TYPE _int4 USING gist AS OPERATOR 3 &&, OPERATOR 6 = (anyarray, anyarray), - OPERATOR 7 @> (anyarray, anyarray), - OPERATOR 8 <@ (anyarray, anyarray), + OPERATOR 7 @>, + OPERATOR 8 <@, OPERATOR 13 @, OPERATOR 14 ~, OPERATOR 20 @@ (_int4, query_int), @@ -473,8 +473,8 @@ FOR TYPE _int4 USING gin AS OPERATOR 3 &&, OPERATOR 6 = (anyarray, anyarray), - OPERATOR 7 @> (anyarray, anyarray), - OPERATOR 8 <@ (anyarray, anyarray), + OPERATOR 7 @>, + OPERATOR 8 <@, OPERATOR 13 @, OPERATOR 14 ~, OPERATOR 20 @@ (_int4, query_int), diff --git a/contrib/intarray/uninstall__int.sql b/contrib/intarray/uninstall__int.sql index 42721ed2fb0..ba962cd0d57 100644 --- a/contrib/intarray/uninstall__int.sql +++ b/contrib/intarray/uninstall__int.sql @@ -1,4 +1,4 @@ -/* $PostgreSQL: pgsql/contrib/intarray/uninstall__int.sql,v 1.11 2009/04/05 00:40:35 tgl Exp $ */ +/* $PostgreSQL: pgsql/contrib/intarray/uninstall__int.sql,v 1.12 2009/06/07 20:09:34 tgl Exp $ */ -- Adjust this setting to control where the objects get created. SET search_path = public; @@ -91,6 +91,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); diff --git a/doc/src/sgml/intarray.sgml b/doc/src/sgml/intarray.sgml index 2e77b57de3e..9bd216ed495 100644 --- a/doc/src/sgml/intarray.sgml +++ b/doc/src/sgml/intarray.sgml @@ -1,4 +1,4 @@ - + intarray @@ -134,12 +134,12 @@ overlap — true if arrays have at least one common element - int[] @ int[] + int[] @> int[] boolean contains — true if left array contains right array - int[] ~ int[] + int[] <@ int[] boolean contained — true if left array is contained in right array @@ -203,13 +203,22 @@ - The containment operators @ and ~ are functionally - equivalent to PostgreSQL's built-in operators - @> and <@, respectively, except that - @ and ~ work only on integer arrays. These - operator names are deprecated and will eventually be retired. (Notice that - these names are reversed from the convention formerly followed by the core - geometric datatypes!) + (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!) + + + + The containment operators @> and <@ are + approximately equivalent to PostgreSQL's built-in operators + of the same names, except that they work only on integer arrays while the + built-in operators work for any array type. An important difference is + that intarray's operators do not consider an empty array to be + contained in anything else. This is consistent with the behavior of + GIN-indexed queries, but not with the usual mathematical definition of + containment. @@ -230,10 +239,8 @@ intarray provides index support for the - &&, @, ~, - and @@ operators, as well as regular array equality - and the built-in @> and <@ operators - (when used on integer arrays). + &&, @>, <@, + and @@ operators, as well as regular array equality. diff --git a/doc/src/sgml/release-8.4.sgml b/doc/src/sgml/release-8.4.sgml index a567afffb7d..cca2d033b2c 100644 --- a/doc/src/sgml/release-8.4.sgml +++ b/doc/src/sgml/release-8.4.sgml @@ -1,4 +1,4 @@ - + @@ -3321,20 +3321,6 @@ - - - Remove contrib/intarray's definitions of the - <@ and @> operators (Tom) - - - - This avoids confusion with the equivalent built-in operators. - If needed, the contrib/intarray implementations - are still available under their historical names @ - and ~. - - - Make contrib/pg_standby recover all available WAL before