* op_hashjoinable * * Returns true if the operator is hashjoinable. (There must be a suitable * hash opfamily entry for this operator if it is so marked.) * * In some cases (currently only array_eq), hashjoinability depends on the * specific input data type the operator is invoked for, so that must be * passed as well. We currently assume that only one input's type is needed * to check t
| 1578 | * to check this --- by convention, pass the left input's data type. |
| 1579 | */ |
| 1580 | bool |
| 1581 | op_hashjoinable(Oid opno, Oid inputtype) |
| 1582 | { |
| 1583 | bool result = false; |
| 1584 | HeapTuple tp; |
| 1585 | TypeCacheEntry *typentry; |
| 1586 | |
| 1587 | /* As in op_mergejoinable, let the typcache handle the hard cases */ |
| 1588 | if (opno == ARRAY_EQ_OP) |
| 1589 | { |
| 1590 | typentry = lookup_type_cache(inputtype, TYPECACHE_HASH_PROC); |
| 1591 | if (typentry->hash_proc == F_HASH_ARRAY) |
| 1592 | result = true; |
| 1593 | } |
| 1594 | else if (opno == RECORD_EQ_OP) |
| 1595 | { |
| 1596 | typentry = lookup_type_cache(inputtype, TYPECACHE_HASH_PROC); |
| 1597 | if (typentry->hash_proc == F_HASH_RECORD) |
| 1598 | result = true; |
| 1599 | } |
| 1600 | else |
| 1601 | { |
| 1602 | /* For all other operators, rely on pg_operator.oprcanhash */ |
| 1603 | tp = SearchSysCache1(OPEROID, ObjectIdGetDatum(opno)); |
| 1604 | if (HeapTupleIsValid(tp)) |
| 1605 | { |
| 1606 | Form_pg_operator optup = (Form_pg_operator) GETSTRUCT(tp); |
| 1607 | |
| 1608 | result = optup->oprcanhash; |
| 1609 | ReleaseSysCache(tp); |
| 1610 | } |
| 1611 | } |
| 1612 | return result; |
| 1613 | } |
| 1614 | |
| 1615 | /* |
| 1616 | * op_strict |
no test coverage detected