From ade49c605f1d8f517497829363f8b83f69c73a60 Mon Sep 17 00:00:00 2001 From: Tom Lane Date: Tue, 29 Nov 2016 15:05:22 -0500 Subject: [PATCH] Test all contrib-created operator classes with amvalidate. I'd supposed that people would do this manually when creating new operator classes, but the folly of that was exposed today. The tests seem fast enough that we can just apply them during the normal regression tests. contrib/isn fails the checks for lack of complete sets of cross-type operators. That's a nice-to-have policy rather than a functional requirement, so leave it as-is, but insert ORDER BY in the query to ensure consistent cross-platform output. Discussion: https://postgr.es/m/7076.1480446837@sss.pgh.pa.us --- .../btree_gin/expected/install_btree_gin.out | 8 ++++ contrib/btree_gin/sql/install_btree_gin.sql | 5 +++ contrib/btree_gist/expected/init.out | 8 ++++ contrib/btree_gist/sql/init.sql | 5 +++ contrib/citext/expected/citext.out | 8 ++++ contrib/citext/expected/citext_1.out | 8 ++++ contrib/citext/sql/citext.sql | 5 +++ contrib/cube/expected/cube.out | 8 ++++ contrib/cube/expected/cube_2.out | 8 ++++ contrib/cube/sql/cube.sql | 5 +++ contrib/hstore/expected/hstore.out | 8 ++++ contrib/hstore/sql/hstore.sql | 5 +++ contrib/intarray/expected/_int.out | 8 ++++ contrib/intarray/sql/_int.sql | 5 +++ contrib/isn/expected/isn.out | 44 +++++++++++++++++++ contrib/isn/sql/isn.sql | 9 ++++ contrib/ltree/expected/ltree.out | 8 ++++ contrib/ltree/sql/ltree.sql | 5 +++ contrib/pg_trgm/expected/pg_trgm.out | 8 ++++ contrib/pg_trgm/sql/pg_trgm.sql | 5 +++ contrib/seg/expected/seg.out | 8 ++++ contrib/seg/expected/seg_1.out | 8 ++++ contrib/seg/sql/seg.sql | 5 +++ contrib/tsearch2/expected/tsearch2.out | 8 ++++ contrib/tsearch2/sql/tsearch2.sql | 5 +++ 25 files changed, 207 insertions(+) diff --git a/contrib/btree_gin/expected/install_btree_gin.out b/contrib/btree_gin/expected/install_btree_gin.out index 0fae4c5bfe..631a0df722 100644 --- a/contrib/btree_gin/expected/install_btree_gin.out +++ b/contrib/btree_gin/expected/install_btree_gin.out @@ -1 +1,9 @@ CREATE EXTENSION btree_gin; +-- Check whether any of our opclasses fail amvalidate +SELECT amname, opcname +FROM pg_opclass opc LEFT JOIN pg_am am ON am.oid = opcmethod +WHERE opc.oid >= 16384 AND NOT amvalidate(opc.oid); + amname | opcname +--------+--------- +(0 rows) + diff --git a/contrib/btree_gin/sql/install_btree_gin.sql b/contrib/btree_gin/sql/install_btree_gin.sql index 0fae4c5bfe..746e77654f 100644 --- a/contrib/btree_gin/sql/install_btree_gin.sql +++ b/contrib/btree_gin/sql/install_btree_gin.sql @@ -1 +1,6 @@ CREATE EXTENSION btree_gin; + +-- Check whether any of our opclasses fail amvalidate +SELECT amname, opcname +FROM pg_opclass opc LEFT JOIN pg_am am ON am.oid = opcmethod +WHERE opc.oid >= 16384 AND NOT amvalidate(opc.oid); diff --git a/contrib/btree_gist/expected/init.out b/contrib/btree_gist/expected/init.out index afe0534682..ce4559d8b0 100644 --- a/contrib/btree_gist/expected/init.out +++ b/contrib/btree_gist/expected/init.out @@ -1 +1,9 @@ CREATE EXTENSION btree_gist; +-- Check whether any of our opclasses fail amvalidate +SELECT amname, opcname +FROM pg_opclass opc LEFT JOIN pg_am am ON am.oid = opcmethod +WHERE opc.oid >= 16384 AND NOT amvalidate(opc.oid); + amname | opcname +--------+--------- +(0 rows) + diff --git a/contrib/btree_gist/sql/init.sql b/contrib/btree_gist/sql/init.sql index afe0534682..a6d2cffc67 100644 --- a/contrib/btree_gist/sql/init.sql +++ b/contrib/btree_gist/sql/init.sql @@ -1 +1,6 @@ CREATE EXTENSION btree_gist; + +-- Check whether any of our opclasses fail amvalidate +SELECT amname, opcname +FROM pg_opclass opc LEFT JOIN pg_am am ON am.oid = opcmethod +WHERE opc.oid >= 16384 AND NOT amvalidate(opc.oid); diff --git a/contrib/citext/expected/citext.out b/contrib/citext/expected/citext.out index 1a1e6c82f7..bc5d92eb91 100644 --- a/contrib/citext/expected/citext.out +++ b/contrib/citext/expected/citext.out @@ -2,6 +2,14 @@ -- Test citext datatype -- CREATE EXTENSION citext; +-- Check whether any of our opclasses fail amvalidate +SELECT amname, opcname +FROM pg_opclass opc LEFT JOIN pg_am am ON am.oid = opcmethod +WHERE opc.oid >= 16384 AND NOT amvalidate(opc.oid); + amname | opcname +--------+--------- +(0 rows) + -- Test the operators and indexing functions -- Test = and <>. SELECT 'a'::citext = 'a'::citext AS t; diff --git a/contrib/citext/expected/citext_1.out b/contrib/citext/expected/citext_1.out index 3331dbc255..3d02d06b9c 100644 --- a/contrib/citext/expected/citext_1.out +++ b/contrib/citext/expected/citext_1.out @@ -2,6 +2,14 @@ -- Test citext datatype -- CREATE EXTENSION citext; +-- Check whether any of our opclasses fail amvalidate +SELECT amname, opcname +FROM pg_opclass opc LEFT JOIN pg_am am ON am.oid = opcmethod +WHERE opc.oid >= 16384 AND NOT amvalidate(opc.oid); + amname | opcname +--------+--------- +(0 rows) + -- Test the operators and indexing functions -- Test = and <>. SELECT 'a'::citext = 'a'::citext AS t; diff --git a/contrib/citext/sql/citext.sql b/contrib/citext/sql/citext.sql index a802484663..f70f9ebae9 100644 --- a/contrib/citext/sql/citext.sql +++ b/contrib/citext/sql/citext.sql @@ -4,6 +4,11 @@ CREATE EXTENSION citext; +-- Check whether any of our opclasses fail amvalidate +SELECT amname, opcname +FROM pg_opclass opc LEFT JOIN pg_am am ON am.oid = opcmethod +WHERE opc.oid >= 16384 AND NOT amvalidate(opc.oid); + -- Test the operators and indexing functions -- Test = and <>. diff --git a/contrib/cube/expected/cube.out b/contrib/cube/expected/cube.out index 095491fa0c..ada54b2885 100644 --- a/contrib/cube/expected/cube.out +++ b/contrib/cube/expected/cube.out @@ -2,6 +2,14 @@ -- Test cube datatype -- CREATE EXTENSION cube; +-- Check whether any of our opclasses fail amvalidate +SELECT amname, opcname +FROM pg_opclass opc LEFT JOIN pg_am am ON am.oid = opcmethod +WHERE opc.oid >= 16384 AND NOT amvalidate(opc.oid); + amname | opcname +--------+--------- +(0 rows) + -- -- testing the input and output functions -- diff --git a/contrib/cube/expected/cube_2.out b/contrib/cube/expected/cube_2.out index eaeae45fca..c58614ef05 100644 --- a/contrib/cube/expected/cube_2.out +++ b/contrib/cube/expected/cube_2.out @@ -2,6 +2,14 @@ -- Test cube datatype -- CREATE EXTENSION cube; +-- Check whether any of our opclasses fail amvalidate +SELECT amname, opcname +FROM pg_opclass opc LEFT JOIN pg_am am ON am.oid = opcmethod +WHERE opc.oid >= 16384 AND NOT amvalidate(opc.oid); + amname | opcname +--------+--------- +(0 rows) + -- -- testing the input and output functions -- diff --git a/contrib/cube/sql/cube.sql b/contrib/cube/sql/cube.sql index cc5a1ce458..a61fba1ea8 100644 --- a/contrib/cube/sql/cube.sql +++ b/contrib/cube/sql/cube.sql @@ -4,6 +4,11 @@ CREATE EXTENSION cube; +-- Check whether any of our opclasses fail amvalidate +SELECT amname, opcname +FROM pg_opclass opc LEFT JOIN pg_am am ON am.oid = opcmethod +WHERE opc.oid >= 16384 AND NOT amvalidate(opc.oid); + -- -- testing the input and output functions -- diff --git a/contrib/hstore/expected/hstore.out b/contrib/hstore/expected/hstore.out index 6773a2b72f..f0d421602d 100644 --- a/contrib/hstore/expected/hstore.out +++ b/contrib/hstore/expected/hstore.out @@ -1,4 +1,12 @@ CREATE EXTENSION hstore; +-- Check whether any of our opclasses fail amvalidate +SELECT amname, opcname +FROM pg_opclass opc LEFT JOIN pg_am am ON am.oid = opcmethod +WHERE opc.oid >= 16384 AND NOT amvalidate(opc.oid); + amname | opcname +--------+--------- +(0 rows) + set escape_string_warning=off; --hstore; select ''::hstore; diff --git a/contrib/hstore/sql/hstore.sql b/contrib/hstore/sql/hstore.sql index 48514789e6..d64b9f77c7 100644 --- a/contrib/hstore/sql/hstore.sql +++ b/contrib/hstore/sql/hstore.sql @@ -1,5 +1,10 @@ CREATE EXTENSION hstore; +-- Check whether any of our opclasses fail amvalidate +SELECT amname, opcname +FROM pg_opclass opc LEFT JOIN pg_am am ON am.oid = opcmethod +WHERE opc.oid >= 16384 AND NOT amvalidate(opc.oid); + set escape_string_warning=off; --hstore; diff --git a/contrib/intarray/expected/_int.out b/contrib/intarray/expected/_int.out index 962e5c6a4b..0a5dd463ac 100644 --- a/contrib/intarray/expected/_int.out +++ b/contrib/intarray/expected/_int.out @@ -1,4 +1,12 @@ CREATE EXTENSION intarray; +-- Check whether any of our opclasses fail amvalidate +SELECT amname, opcname +FROM pg_opclass opc LEFT JOIN pg_am am ON am.oid = opcmethod +WHERE opc.oid >= 16384 AND NOT amvalidate(opc.oid); + amname | opcname +--------+--------- +(0 rows) + SELECT intset(1234); intset -------- diff --git a/contrib/intarray/sql/_int.sql b/contrib/intarray/sql/_int.sql index f6fe2de55c..44e1a729b4 100644 --- a/contrib/intarray/sql/_int.sql +++ b/contrib/intarray/sql/_int.sql @@ -1,5 +1,10 @@ CREATE EXTENSION intarray; +-- Check whether any of our opclasses fail amvalidate +SELECT amname, opcname +FROM pg_opclass opc LEFT JOIN pg_am am ON am.oid = opcmethod +WHERE opc.oid >= 16384 AND NOT amvalidate(opc.oid); + SELECT intset(1234); SELECT icount('{1234234,234234}'); SELECT sort('{1234234,-30,234234}'); diff --git a/contrib/isn/expected/isn.out b/contrib/isn/expected/isn.out index 140bc86656..ef9d3a61e7 100644 --- a/contrib/isn/expected/isn.out +++ b/contrib/isn/expected/isn.out @@ -2,6 +2,50 @@ -- Test ISN extension -- CREATE EXTENSION isn; +-- Check whether any of our opclasses fail amvalidate +-- ... they will, because of missing cross-type operators +SELECT amname, opcname +FROM (SELECT amname, opcname, opc.oid + FROM pg_opclass opc LEFT JOIN pg_am am ON am.oid = opcmethod + WHERE opc.oid >= 16384 + ORDER BY 1, 2 OFFSET 0) ss +WHERE NOT amvalidate(oid); +INFO: btree operator family "isn_ops" is missing cross-type operator(s) +INFO: btree operator family "isn_ops" is missing cross-type operator(s) +INFO: btree operator family "isn_ops" is missing cross-type operator(s) +INFO: btree operator family "isn_ops" is missing cross-type operator(s) +INFO: btree operator family "isn_ops" is missing cross-type operator(s) +INFO: btree operator family "isn_ops" is missing cross-type operator(s) +INFO: btree operator family "isn_ops" is missing cross-type operator(s) +INFO: btree operator family "isn_ops" is missing cross-type operator(s) +INFO: hash operator family "isn_ops" is missing cross-type operator(s) +INFO: hash operator family "isn_ops" is missing cross-type operator(s) +INFO: hash operator family "isn_ops" is missing cross-type operator(s) +INFO: hash operator family "isn_ops" is missing cross-type operator(s) +INFO: hash operator family "isn_ops" is missing cross-type operator(s) +INFO: hash operator family "isn_ops" is missing cross-type operator(s) +INFO: hash operator family "isn_ops" is missing cross-type operator(s) +INFO: hash operator family "isn_ops" is missing cross-type operator(s) + amname | opcname +--------+------------ + btree | ean13_ops + btree | isbn13_ops + btree | isbn_ops + btree | ismn13_ops + btree | ismn_ops + btree | issn13_ops + btree | issn_ops + btree | upc_ops + hash | ean13_ops + hash | isbn13_ops + hash | isbn_ops + hash | ismn13_ops + hash | ismn_ops + hash | issn13_ops + hash | issn_ops + hash | upc_ops +(16 rows) + -- -- test valid conversions -- diff --git a/contrib/isn/sql/isn.sql b/contrib/isn/sql/isn.sql index 5ef6d8aa3b..71577d5590 100644 --- a/contrib/isn/sql/isn.sql +++ b/contrib/isn/sql/isn.sql @@ -4,6 +4,15 @@ CREATE EXTENSION isn; +-- Check whether any of our opclasses fail amvalidate +-- ... they will, because of missing cross-type operators +SELECT amname, opcname +FROM (SELECT amname, opcname, opc.oid + FROM pg_opclass opc LEFT JOIN pg_am am ON am.oid = opcmethod + WHERE opc.oid >= 16384 + ORDER BY 1, 2 OFFSET 0) ss +WHERE NOT amvalidate(oid); + -- -- test valid conversions -- diff --git a/contrib/ltree/expected/ltree.out b/contrib/ltree/expected/ltree.out index da6e39a785..db52069c26 100644 --- a/contrib/ltree/expected/ltree.out +++ b/contrib/ltree/expected/ltree.out @@ -1,4 +1,12 @@ CREATE EXTENSION ltree; +-- Check whether any of our opclasses fail amvalidate +SELECT amname, opcname +FROM pg_opclass opc LEFT JOIN pg_am am ON am.oid = opcmethod +WHERE opc.oid >= 16384 AND NOT amvalidate(opc.oid); + amname | opcname +--------+--------- +(0 rows) + SELECT ''::ltree; ltree ------- diff --git a/contrib/ltree/sql/ltree.sql b/contrib/ltree/sql/ltree.sql index 46cfa41a41..b4f62e3feb 100644 --- a/contrib/ltree/sql/ltree.sql +++ b/contrib/ltree/sql/ltree.sql @@ -1,5 +1,10 @@ CREATE EXTENSION ltree; +-- Check whether any of our opclasses fail amvalidate +SELECT amname, opcname +FROM pg_opclass opc LEFT JOIN pg_am am ON am.oid = opcmethod +WHERE opc.oid >= 16384 AND NOT amvalidate(opc.oid); + SELECT ''::ltree; SELECT '1'::ltree; SELECT '1.2'::ltree; diff --git a/contrib/pg_trgm/expected/pg_trgm.out b/contrib/pg_trgm/expected/pg_trgm.out index 9bc55f1d0d..f646cbf90a 100644 --- a/contrib/pg_trgm/expected/pg_trgm.out +++ b/contrib/pg_trgm/expected/pg_trgm.out @@ -1,4 +1,12 @@ CREATE EXTENSION pg_trgm; +-- Check whether any of our opclasses fail amvalidate +SELECT amname, opcname +FROM pg_opclass opc LEFT JOIN pg_am am ON am.oid = opcmethod +WHERE opc.oid >= 16384 AND NOT amvalidate(opc.oid); + amname | opcname +--------+--------- +(0 rows) + select show_trgm(''); show_trgm ----------- diff --git a/contrib/pg_trgm/sql/pg_trgm.sql b/contrib/pg_trgm/sql/pg_trgm.sql index 244946bb8d..34d0614edb 100644 --- a/contrib/pg_trgm/sql/pg_trgm.sql +++ b/contrib/pg_trgm/sql/pg_trgm.sql @@ -1,5 +1,10 @@ CREATE EXTENSION pg_trgm; +-- Check whether any of our opclasses fail amvalidate +SELECT amname, opcname +FROM pg_opclass opc LEFT JOIN pg_am am ON am.oid = opcmethod +WHERE opc.oid >= 16384 AND NOT amvalidate(opc.oid); + select show_trgm(''); select show_trgm('(*&^$@%@'); select show_trgm('a b c'); diff --git a/contrib/seg/expected/seg.out b/contrib/seg/expected/seg.out index 1f82a4abb8..18010c4d5c 100644 --- a/contrib/seg/expected/seg.out +++ b/contrib/seg/expected/seg.out @@ -2,6 +2,14 @@ -- Test seg datatype -- CREATE EXTENSION seg; +-- Check whether any of our opclasses fail amvalidate +SELECT amname, opcname +FROM pg_opclass opc LEFT JOIN pg_am am ON am.oid = opcmethod +WHERE opc.oid >= 16384 AND NOT amvalidate(opc.oid); + amname | opcname +--------+--------- +(0 rows) + -- -- testing the input and output functions -- diff --git a/contrib/seg/expected/seg_1.out b/contrib/seg/expected/seg_1.out index 563c744b2d..566ce394ed 100644 --- a/contrib/seg/expected/seg_1.out +++ b/contrib/seg/expected/seg_1.out @@ -2,6 +2,14 @@ -- Test seg datatype -- CREATE EXTENSION seg; +-- Check whether any of our opclasses fail amvalidate +SELECT amname, opcname +FROM pg_opclass opc LEFT JOIN pg_am am ON am.oid = opcmethod +WHERE opc.oid >= 16384 AND NOT amvalidate(opc.oid); + amname | opcname +--------+--------- +(0 rows) + -- -- testing the input and output functions -- diff --git a/contrib/seg/sql/seg.sql b/contrib/seg/sql/seg.sql index 7b7f138dbf..aa91931474 100644 --- a/contrib/seg/sql/seg.sql +++ b/contrib/seg/sql/seg.sql @@ -4,6 +4,11 @@ CREATE EXTENSION seg; +-- Check whether any of our opclasses fail amvalidate +SELECT amname, opcname +FROM pg_opclass opc LEFT JOIN pg_am am ON am.oid = opcmethod +WHERE opc.oid >= 16384 AND NOT amvalidate(opc.oid); + -- -- testing the input and output functions -- diff --git a/contrib/tsearch2/expected/tsearch2.out b/contrib/tsearch2/expected/tsearch2.out index e84e4d27f2..eef85ef09d 100644 --- a/contrib/tsearch2/expected/tsearch2.out +++ b/contrib/tsearch2/expected/tsearch2.out @@ -1,4 +1,12 @@ CREATE EXTENSION tsearch2; +-- Check whether any of our opclasses fail amvalidate +SELECT amname, opcname +FROM pg_opclass opc LEFT JOIN pg_am am ON am.oid = opcmethod +WHERE opc.oid >= 16384 AND NOT amvalidate(opc.oid); + amname | opcname +--------+--------- +(0 rows) + --tsvector SELECT '1'::tsvector; tsvector diff --git a/contrib/tsearch2/sql/tsearch2.sql b/contrib/tsearch2/sql/tsearch2.sql index 53e3073af4..2c37c4a1dd 100644 --- a/contrib/tsearch2/sql/tsearch2.sql +++ b/contrib/tsearch2/sql/tsearch2.sql @@ -1,5 +1,10 @@ CREATE EXTENSION tsearch2; +-- Check whether any of our opclasses fail amvalidate +SELECT amname, opcname +FROM pg_opclass opc LEFT JOIN pg_am am ON am.oid = opcmethod +WHERE opc.oid >= 16384 AND NOT amvalidate(opc.oid); + --tsvector SELECT '1'::tsvector; SELECT '1 '::tsvector;