* compare_pathkeys * Compare two pathkeys to see if they are equivalent, and if not whether * one is "better" than the other. * * We assume the pathkeys are canonical, and so they can be checked for * equality by simple pointer comparison. */
| 611 | * equality by simple pointer comparison. |
| 612 | */ |
| 613 | PathKeysComparison |
| 614 | compare_pathkeys(List *keys1, List *keys2) |
| 615 | { |
| 616 | ListCell *key1, |
| 617 | *key2; |
| 618 | |
| 619 | /* |
| 620 | * Fall out quickly if we are passed two identical lists. This mostly |
| 621 | * catches the case where both are NIL, but that's common enough to |
| 622 | * warrant the test. |
| 623 | */ |
| 624 | if (keys1 == keys2) |
| 625 | return PATHKEYS_EQUAL; |
| 626 | |
| 627 | forboth(key1, keys1, key2, keys2) |
| 628 | { |
| 629 | PathKey *pathkey1 = (PathKey *) lfirst(key1); |
| 630 | PathKey *pathkey2 = (PathKey *) lfirst(key2); |
| 631 | |
| 632 | if (pathkey1 != pathkey2) |
| 633 | return PATHKEYS_DIFFERENT; /* no need to keep looking */ |
| 634 | } |
| 635 | |
| 636 | /* |
| 637 | * If we reached the end of only one list, the other is longer and |
| 638 | * therefore not a subset. |
| 639 | */ |
| 640 | if (key1 != NULL) |
| 641 | return PATHKEYS_BETTER1; /* key1 is longer */ |
| 642 | if (key2 != NULL) |
| 643 | return PATHKEYS_BETTER2; /* key2 is longer */ |
| 644 | return PATHKEYS_EQUAL; |
| 645 | } |
| 646 | |
| 647 | /* |
| 648 | * pathkeys_contained_in |
no test coverage detected