* Whether the index relation was created via a composite index opclass */
| 380 | * Whether the index relation was created via a composite index opclass |
| 381 | */ |
| 382 | bool |
| 383 | IsCompositeOpClass(Relation indexRelation) |
| 384 | { |
| 385 | const BsonIndexAmEntry *amEntry = GetBsonIndexAmEntryByIndexOid( |
| 386 | indexRelation->rd_rel->relam); |
| 387 | if (amEntry == NULL) |
| 388 | { |
| 389 | return false; |
| 390 | } |
| 391 | |
| 392 | /* Non unique indexes will have 1 attribute that has the entire composite key |
| 393 | * Unique indexes will have the first attribute matching non-unique indexes, and the |
| 394 | * second attribute matching the unique constraint key. |
| 395 | * We put the composite column first just for convenience, so we can keep the order by |
| 396 | * and query paths the same between the two. |
| 397 | */ |
| 398 | if (IndexRelationGetNumberOfKeyAttributes(indexRelation) == 1 || |
| 399 | IndexRelationGetNumberOfKeyAttributes(indexRelation) == 2) |
| 400 | { |
| 401 | return indexRelation->rd_opfamily[0] == |
| 402 | amEntry->get_composite_path_op_family_oid(); |
| 403 | } |
| 404 | |
| 405 | return false; |
| 406 | } |
| 407 | |
| 408 | |
| 409 | bool |
no test coverage detected