`got` must be the first occurrence of every value in column 0 of `all`. */
| 5722 | |
| 5723 | /* `got` must be the first occurrence of every value in column 0 of `all`. */ |
| 5724 | static bool ref_first_occurrences(const cbm_cypher_result_t *got, const cbm_cypher_result_t *all) { |
| 5725 | int kept = 0; |
| 5726 | for (int i = 0; i < all->row_count; i++) { |
| 5727 | bool seen = false; |
| 5728 | for (int j = 0; j < i && !seen; j++) { |
| 5729 | seen = strcmp(all->rows[i][0], all->rows[j][0]) == 0; |
| 5730 | } |
| 5731 | if (seen) { |
| 5732 | continue; |
| 5733 | } |
| 5734 | if (kept >= got->row_count || strcmp(got->rows[kept][0], all->rows[i][0]) != 0) { |
| 5735 | return false; |
| 5736 | } |
| 5737 | kept++; |
| 5738 | } |
| 5739 | return kept == got->row_count; |
| 5740 | } |
| 5741 | |
| 5742 | TEST(cypher_distinct_keeps_first_occurrences) { |
| 5743 | cbm_store_t *s = setup_reference_store(); |