Remove <@ from contrib/intarray's GiST operator classes.
authorTom Lane <tgl@sss.pgh.pa.us>
Sat, 8 Aug 2020 21:26:29 +0000 (17:26 -0400)
committerTom Lane <tgl@sss.pgh.pa.us>
Sat, 8 Aug 2020 21:26:29 +0000 (17:26 -0400)
Since commit efc77cf5f, an indexed query using <@ has required a
full-index scan, so that it actually performs worse than a plain seqscan
would do.  As I noted at the time, we'd be better off to not treat <@ as
being indexable by such indexes at all; and that's what this patch does.

It would have been difficult to remove these opclass members without
dropping the whole opclass before commit 9f9682783 fixed GiST opclass
member dependency rules, but now it's quite simple, so let's do it.

I left the existing support code in place for the time being, with
comments noting it's now unreachable.  At some point, perhaps we should
remove that code in favor of throwing an error telling people to upgrade
the extension version.

Discussion: https://postgr.es/m/2176979.1596389859@sss.pgh.pa.us
Discussion: https://postgr.es/m/458.1565114141@sss.pgh.pa.us

contrib/intarray/Makefile
contrib/intarray/_int_gist.c
contrib/intarray/_intbig_gist.c
contrib/intarray/intarray--1.3--1.4.sql [new file with mode: 0644]
contrib/intarray/intarray.control
doc/src/sgml/intarray.sgml

index b68959ebd64dd7db2818796664b8da500d3d86b8..01faa36b10732dc12b070b3e35d307c674dc6dcc 100644 (file)
@@ -12,7 +12,8 @@ OBJS = \
    _intbig_gist.o
 
 EXTENSION = intarray
-DATA = intarray--1.2--1.3.sql intarray--1.2.sql intarray--1.1--1.2.sql \
+DATA = intarray--1.3--1.4.sql intarray--1.2--1.3.sql \
+   intarray--1.2.sql intarray--1.1--1.2.sql \
    intarray--1.0--1.1.sql
 PGFILEDESC = "intarray - functions and operators for arrays of integers"
 
index fb05b06af9eb1e20c3802faa3bd2b4374121b3d9..f1817a6cce3b637762a3836fea75084062000001 100644 (file)
@@ -93,6 +93,12 @@ g_int_consistent(PG_FUNCTION_ARGS)
            break;
        case RTContainedByStrategyNumber:
        case RTOldContainedByStrategyNumber:
+
+           /*
+            * This code is unreachable as of intarray 1.4, because the <@
+            * operator has been removed from the opclass.  We keep it for now
+            * to support older versions of the SQL definitions.
+            */
            if (GIST_LEAF(entry))
                retval = inner_int_contains(query,
                                            (ArrayType *) DatumGetPointer(entry->key));
index 67c44e99a9a751ac4983d79ab77db8a76064b92a..18ecd8cda6b14629ca88eeff51c05a6b9022e04a 100644 (file)
@@ -533,6 +533,12 @@ g_intbig_consistent(PG_FUNCTION_ARGS)
            break;
        case RTContainedByStrategyNumber:
        case RTOldContainedByStrategyNumber:
+
+           /*
+            * This code is unreachable as of intarray 1.4, because the <@
+            * operator has been removed from the opclass.  We keep it for now
+            * to support older versions of the SQL definitions.
+            */
            if (GIST_LEAF(entry))
            {
                int         i,
diff --git a/contrib/intarray/intarray--1.3--1.4.sql b/contrib/intarray/intarray--1.3--1.4.sql
new file mode 100644 (file)
index 0000000..3fbebb5
--- /dev/null
@@ -0,0 +1,21 @@
+/* contrib/intarray/intarray--1.3--1.4.sql */
+
+-- complain if script is sourced in psql, rather than via ALTER EXTENSION
+\echo Use "ALTER EXTENSION intarray UPDATE TO '1.4'" to load this file. \quit
+
+-- Remove <@ from the GiST opclasses, as it's not usefully indexable
+-- due to mishandling of empty arrays.  (It's OK in GIN.)
+
+ALTER OPERATOR FAMILY gist__int_ops USING gist
+DROP OPERATOR 8 (_int4, _int4);
+
+ALTER OPERATOR FAMILY gist__intbig_ops USING gist
+DROP OPERATOR 8 (_int4, _int4);
+
+-- Likewise for the old spelling ~.
+
+ALTER OPERATOR FAMILY gist__int_ops USING gist
+DROP OPERATOR 14 (_int4, _int4);
+
+ALTER OPERATOR FAMILY gist__intbig_ops USING gist
+DROP OPERATOR 14 (_int4, _int4);
index db7746b6c7a00e5fd5e685118ed7363e66276e04..bbc837c5732ec8d843e3d949dda4ac41cdc7fa89 100644 (file)
@@ -1,6 +1,6 @@
 # intarray extension
 comment = 'functions, operators, and index support for 1-D arrays of integers'
-default_version = '1.3'
+default_version = '1.4'
 module_pathname = '$libdir/_int'
 relocatable = true
 trusted = true
index 9d2eb52eeb4f5c101499b06712e9d114c18c3fef..c8db87e97df907bfb8bd7afb3161d4cb97abf995 100644 (file)
 
   <para>
    <filename>intarray</filename> provides index support for the
-   <literal>&amp;&amp;</literal>, <literal>@&gt;</literal>, <literal>&lt;@</literal>,
+   <literal>&amp;&amp;</literal>, <literal>@&gt;</literal>,
    and <literal>@@</literal> operators, as well as regular array equality.
   </para>
 
 
   <para>
    There is also a non-default GIN operator class
-   <literal>gin__int_ops</literal> supporting the same operators.
+   <literal>gin__int_ops</literal>, which supports these operators as well
+   as <literal>&lt;@</literal>.
   </para>
 
   <para>