Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit a068b5b

Browse files
committed
Add opr_sanity queries to inspect commutator/negator links more closely.
Make lists of the names of all operators that are claimed to be commutator pairs or negator pairs. This is analogous to the existing queries that make lists of all operator names appearing in particular opclass strategy slots. Unexpected additions to these lists are likely to be mistakes; had we had these queries in place before, bug #11178 might've been prevented.
1 parent e3f9c16 commit a068b5b

File tree

2 files changed

+90
-6
lines changed

2 files changed

+90
-6
lines changed

src/test/regress/expected/opr_sanity.out

+70-3
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,10 @@
44
-- pg_operator, pg_proc, pg_cast, pg_aggregate, pg_am,
55
-- pg_amop, pg_amproc, pg_opclass, pg_opfamily.
66
--
7-
-- Every test failures in this file should be closely inspected. The
8-
-- description of the failing test should be read carefully before
9-
-- adjusting the expected output.
7+
-- Every test failure in this file should be closely inspected.
8+
-- The description of the failing test should be read carefully before
9+
-- adjusting the expected output. In most cases, the queries should
10+
-- not find *any* matching entries.
1011
--
1112
-- NB: we assume the oidjoins test will have caught any dangling links,
1213
-- that is OID or REGPROC fields that are not zero and do not match some
@@ -844,6 +845,72 @@ WHERE p1.oprnegate = p2.oid AND
844845
-----+---------+-----+---------
845846
(0 rows)
846847

848+
-- Make a list of the names of operators that are claimed to be commutator
849+
-- pairs. This list will grow over time, but before accepting a new entry
850+
-- make sure you didn't link the wrong operators.
851+
SELECT DISTINCT o1.oprname AS op1, o2.oprname AS op2
852+
FROM pg_operator o1, pg_operator o2
853+
WHERE o1.oprcom = o2.oid AND o1.oprname <= o2.oprname
854+
ORDER BY 1, 2;
855+
op1 | op2
856+
------+------
857+
# | #
858+
& | &
859+
&& | &&
860+
* | *
861+
*< | *>
862+
*<= | *>=
863+
*<> | *<>
864+
*= | *=
865+
+ | +
866+
-|- | -|-
867+
< | >
868+
<-> | <->
869+
<< | >>
870+
<<= | >>=
871+
<= | >=
872+
<> | <>
873+
<@ | @>
874+
= | =
875+
?# | ?#
876+
?- | ?-
877+
?-| | ?-|
878+
?| | ?|
879+
?|| | ?||
880+
@ | ~
881+
@@ | @@
882+
@@@ | @@@
883+
| | |
884+
~<=~ | ~>=~
885+
~<~ | ~>~
886+
~= | ~=
887+
(30 rows)
888+
889+
-- Likewise for negator pairs.
890+
SELECT DISTINCT o1.oprname AS op1, o2.oprname AS op2
891+
FROM pg_operator o1, pg_operator o2
892+
WHERE o1.oprnegate = o2.oid AND o1.oprname <= o2.oprname
893+
ORDER BY 1, 2;
894+
op1 | op2
895+
------+------
896+
!~ | ~
897+
!~* | ~*
898+
!~~ | ~~
899+
!~~* | ~~*
900+
#< | #>=
901+
#<= | #>
902+
#<> | #=
903+
*< | *>=
904+
*<= | *>
905+
*<> | *=
906+
< | >=
907+
<= | >
908+
<> | =
909+
<> | ~=
910+
~<=~ | ~>~
911+
~<~ | ~>=~
912+
(16 rows)
913+
847914
-- A mergejoinable or hashjoinable operator must be binary, must return
848915
-- boolean, and must have a commutator (itself, unless it's a cross-type
849916
-- operator).

src/test/regress/sql/opr_sanity.sql

+20-3
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,10 @@
44
-- pg_operator, pg_proc, pg_cast, pg_aggregate, pg_am,
55
-- pg_amop, pg_amproc, pg_opclass, pg_opfamily.
66
--
7-
-- Every test failures in this file should be closely inspected. The
8-
-- description of the failing test should be read carefully before
9-
-- adjusting the expected output.
7+
-- Every test failure in this file should be closely inspected.
8+
-- The description of the failing test should be read carefully before
9+
-- adjusting the expected output. In most cases, the queries should
10+
-- not find *any* matching entries.
1011
--
1112
-- NB: we assume the oidjoins test will have caught any dangling links,
1213
-- that is OID or REGPROC fields that are not zero and do not match some
@@ -481,6 +482,22 @@ WHERE p1.oprnegate = p2.oid AND
481482
p1.oid != p2.oprnegate OR
482483
p1.oid = p2.oid);
483484

485+
-- Make a list of the names of operators that are claimed to be commutator
486+
-- pairs. This list will grow over time, but before accepting a new entry
487+
-- make sure you didn't link the wrong operators.
488+
489+
SELECT DISTINCT o1.oprname AS op1, o2.oprname AS op2
490+
FROM pg_operator o1, pg_operator o2
491+
WHERE o1.oprcom = o2.oid AND o1.oprname <= o2.oprname
492+
ORDER BY 1, 2;
493+
494+
-- Likewise for negator pairs.
495+
496+
SELECT DISTINCT o1.oprname AS op1, o2.oprname AS op2
497+
FROM pg_operator o1, pg_operator o2
498+
WHERE o1.oprnegate = o2.oid AND o1.oprname <= o2.oprname
499+
ORDER BY 1, 2;
500+
484501
-- A mergejoinable or hashjoinable operator must be binary, must return
485502
-- boolean, and must have a commutator (itself, unless it's a cross-type
486503
-- operator).

0 commit comments

Comments
 (0)