* ExecIndexAdvanceArrayKeys * Advance to the next set of array key values, if any. * * Returns true if there is another set of values to consider, false if not. * On true result, the scankeys are initialized with the next set of values. */
| 740 | * On true result, the scankeys are initialized with the next set of values. |
| 741 | */ |
| 742 | bool |
| 743 | ExecIndexAdvanceArrayKeys(IndexArrayKeyInfo *arrayKeys, int numArrayKeys) |
| 744 | { |
| 745 | bool found = false; |
| 746 | int j; |
| 747 | |
| 748 | /* |
| 749 | * Note we advance the rightmost array key most quickly, since it will |
| 750 | * correspond to the lowest-order index column among the available |
| 751 | * qualifications. This is hypothesized to result in better locality of |
| 752 | * access in the index. |
| 753 | */ |
| 754 | for (j = numArrayKeys - 1; j >= 0; j--) |
| 755 | { |
| 756 | ScanKey scan_key = arrayKeys[j].scan_key; |
| 757 | int next_elem = arrayKeys[j].next_elem; |
| 758 | int num_elems = arrayKeys[j].num_elems; |
| 759 | Datum *elem_values = arrayKeys[j].elem_values; |
| 760 | bool *elem_nulls = arrayKeys[j].elem_nulls; |
| 761 | |
| 762 | if (next_elem >= num_elems) |
| 763 | { |
| 764 | next_elem = 0; |
| 765 | found = false; /* need to advance next array key */ |
| 766 | } |
| 767 | else |
| 768 | found = true; |
| 769 | scan_key->sk_argument = elem_values[next_elem]; |
| 770 | if (elem_nulls[next_elem]) |
| 771 | scan_key->sk_flags |= SK_ISNULL; |
| 772 | else |
| 773 | scan_key->sk_flags &= ~SK_ISNULL; |
| 774 | arrayKeys[j].next_elem = next_elem + 1; |
| 775 | if (found) |
| 776 | break; |
| 777 | } |
| 778 | |
| 779 | return found; |
| 780 | } |
| 781 | |
| 782 | |
| 783 | /* ---------------------------------------------------------------- |
no outgoing calls
no test coverage detected