amroutine->amcanorder = false;
amroutine->amcanorderbyop = false;
amroutine->amcanhash = false;
- amroutine->amcancrosscompare = false;
+ amroutine->amconsistentequality = false;
+ amroutine->amconsistentordering = false;
amroutine->amcanbackward = false;
amroutine->amcanunique = false;
amroutine->amcanmulticol = true;
bool amcanorderbyop;
/* does AM support hashing using API consistent with the hash AM? */
bool amcanhash;
- /* does AM support cross-type comparisons? */
- bool amcancrosscompare;
+ /* do operators within an opfamily have consistent equality semantics? */
+ bool amconsistentequality;
+ /* do operators within an opfamily have consistent ordering semantics? */
+ bool amconsistentordering;
/* does AM support backward scanning? */
bool amcanbackward;
/* does AM support UNIQUE indexes? */
amroutine->amcanorder = false;
amroutine->amcanorderbyop = false;
amroutine->amcanhash = false;
- amroutine->amcancrosscompare = false;
+ amroutine->amconsistentequality = false;
+ amroutine->amconsistentordering = false;
amroutine->amcanbackward = false;
amroutine->amcanunique = false;
amroutine->amcanmulticol = true;
amroutine->amcanorder = false;
amroutine->amcanorderbyop = false;
amroutine->amcanhash = false;
- amroutine->amcancrosscompare = false;
+ amroutine->amconsistentequality = false;
+ amroutine->amconsistentordering = false;
amroutine->amcanbackward = false;
amroutine->amcanunique = false;
amroutine->amcanmulticol = true;
amroutine->amcanorder = false;
amroutine->amcanorderbyop = true;
amroutine->amcanhash = false;
- amroutine->amcancrosscompare = false;
+ amroutine->amconsistentequality = false;
+ amroutine->amconsistentordering = false;
amroutine->amcanbackward = false;
amroutine->amcanunique = false;
amroutine->amcanmulticol = true;
amroutine->amcanorder = false;
amroutine->amcanorderbyop = false;
amroutine->amcanhash = true;
- amroutine->amcancrosscompare = true;
+ amroutine->amconsistentequality = true;
+ amroutine->amconsistentequality = false;
amroutine->amcanbackward = true;
amroutine->amcanunique = false;
amroutine->amcanmulticol = false;
amroutine->amcanorder = true;
amroutine->amcanorderbyop = false;
amroutine->amcanhash = false;
- amroutine->amcancrosscompare = true;
+ amroutine->amconsistentequality = true;
+ amroutine->amconsistentordering = true;
amroutine->amcanbackward = true;
amroutine->amcanunique = true;
amroutine->amcanmulticol = true;
amroutine->amcanorder = false;
amroutine->amcanorderbyop = true;
amroutine->amcanhash = false;
- amroutine->amcancrosscompare = false;
+ amroutine->amconsistentequality = false;
+ amroutine->amconsistentordering = false;
amroutine->amcanbackward = false;
amroutine->amcanunique = false;
amroutine->amcanmulticol = false;
* the values are distinct. (Note: the opids entries could be cross-type
* operators, and thus not exactly the equality operators that the subquery
* would use itself. We use equality_ops_are_compatible() to check
- * compatibility. That looks at btree or hash opfamily membership, and so
- * should give trustworthy answers for all operators that we might need
- * to deal with here.)
+ * compatibility. That looks at opfamily membership for index AMs that have
+ * declared that they support consistent equality semantics within an
+ * opfamily, and so should give trustworthy answers for all operators that we
+ * might need to deal with here.)
*/
bool
query_is_distinct_for(Query *query, List *colnos, List *opids)
* semantics.
*
* This is trivially true if they are the same operator. Otherwise,
- * we look to see if they can be found in the same btree or hash opfamily.
- * Either finding allows us to assume that they have compatible notions
- * of equality. (The reason we need to do these pushups is that one might
- * be a cross-type operator; for instance int24eq vs int4eq.)
+ * Otherwise, we look to see if they both belong to an opfamily that
+ * guarantees compatible semantics for equality. Either finding allows us to
+ * assume that they have compatible notions of equality. (The reason we need
+ * to do these pushups is that one might be a cross-type operator; for
+ * instance int24eq vs int4eq.)
*/
bool
equality_ops_are_compatible(Oid opno1, Oid opno2)
Form_pg_amop op_form = (Form_pg_amop) GETSTRUCT(op_tuple);
IndexAmRoutine *amroutine = GetIndexAmRoutineByAmId(op_form->amopmethod, false);
- if (amroutine->amcancrosscompare)
+ if (amroutine->amconsistentequality)
{
if (op_in_opfamily(opno2, op_form->amopfamily))
{
* Return true if the two given comparison operators have compatible
* semantics.
*
- * This is trivially true if they are the same operator. Otherwise,
- * we look to see if they can be found in the same btree opfamily.
- * For example, '<' and '>=' ops match if they belong to the same family.
+ * This is trivially true if they are the same operator. Otherwise, we look
+ * to see if they both belong to an opfamily that guarantees compatible
+ * semantics for ordering. (For example, for btree, '<' and '>=' ops match if
+ * they belong to the same family.)
*
- * (This is identical to equality_ops_are_compatible(), except that we
- * don't bother to examine hash opclasses.)
+ * (This is identical to equality_ops_are_compatible(), except that we check
+ * amcanorder plus amconsistentordering instead of amconsistentequality.)
*/
bool
comparison_ops_are_compatible(Oid opno1, Oid opno2)
Form_pg_amop op_form = (Form_pg_amop) GETSTRUCT(op_tuple);
IndexAmRoutine *amroutine = GetIndexAmRoutineByAmId(op_form->amopmethod, false);
- if (amroutine->amcanorder && amroutine->amcancrosscompare)
+ if (amroutine->amcanorder && amroutine->amconsistentordering)
{
if (op_in_opfamily(opno2, op_form->amopfamily))
{
bool amcanorderbyop;
/* does AM support hashing using API consistent with the hash AM? */
bool amcanhash;
- /* does AM support cross-type comparisons? */
- bool amcancrosscompare;
+ /* do operators within an opfamily have consistent equality semantics? */
+ bool amconsistentequality;
+ /* do operators within an opfamily have consistent ordering semantics? */
+ bool amconsistentordering;
/* does AM support backward scanning? */
bool amcanbackward;
/* does AM support UNIQUE indexes? */
amroutine->amcanorder = false;
amroutine->amcanorderbyop = false;
amroutine->amcanhash = false;
- amroutine->amcancrosscompare = false;
+ amroutine->amconsistentequality = false;
+ amroutine->amconsistentordering = false;
amroutine->amcanbackward = false;
amroutine->amcanunique = false;
amroutine->amcanmulticol = false;