From 8076c8c7f0830da376b585380945d411841eab62 Mon Sep 17 00:00:00 2001
From: Tom Lane <tgl@sss.pgh.pa.us>
Date: Tue, 6 Feb 2007 03:52:59 +0000
Subject: [PATCH] Come to think of it, we should check that commutator pairs
 have the same merges/hashes property settings.

---
 src/test/regress/expected/opr_sanity.out | 10 ++++++++++
 src/test/regress/sql/opr_sanity.sql      |  8 ++++++++
 2 files changed, 18 insertions(+)

diff --git a/src/test/regress/expected/opr_sanity.out b/src/test/regress/expected/opr_sanity.out
index 2bc25de0525..8b5f64473d5 100644
--- a/src/test/regress/expected/opr_sanity.out
+++ b/src/test/regress/expected/opr_sanity.out
@@ -382,6 +382,16 @@ WHERE (p1.oprcanmerge OR p1.oprcanhash) AND NOT
 -----+---------
 (0 rows)
 
+-- What's more, the commutator had better be mergejoinable/hashjoinable too.
+SELECT p1.oid, p1.oprname, p2.oid, p2.oprname
+FROM pg_operator AS p1, pg_operator AS p2
+WHERE p1.oprcom = p2.oid AND
+    (p1.oprcanmerge != p2.oprcanmerge OR
+     p1.oprcanhash != p2.oprcanhash);
+ oid | oprname | oid | oprname 
+-----+---------+-----+---------
+(0 rows)
+
 -- Mergejoinable operators should appear as equality members of btree index
 -- opfamilies.
 SELECT p1.oid, p1.oprname
diff --git a/src/test/regress/sql/opr_sanity.sql b/src/test/regress/sql/opr_sanity.sql
index 9496422458e..f93a71ddf9c 100644
--- a/src/test/regress/sql/opr_sanity.sql
+++ b/src/test/regress/sql/opr_sanity.sql
@@ -315,6 +315,14 @@ SELECT p1.oid, p1.oprname FROM pg_operator AS p1
 WHERE (p1.oprcanmerge OR p1.oprcanhash) AND NOT
     (p1.oprkind = 'b' AND p1.oprresult = 'bool'::regtype AND p1.oprcom != 0);
 
+-- What's more, the commutator had better be mergejoinable/hashjoinable too.
+
+SELECT p1.oid, p1.oprname, p2.oid, p2.oprname
+FROM pg_operator AS p1, pg_operator AS p2
+WHERE p1.oprcom = p2.oid AND
+    (p1.oprcanmerge != p2.oprcanmerge OR
+     p1.oprcanhash != p2.oprcanhash);
+
 -- Mergejoinable operators should appear as equality members of btree index
 -- opfamilies.
 
-- 
GitLab