Build a group key from non-aggregate WITH items */
| 3833 | |
| 3834 | /* Build a group key from non-aggregate WITH items */ |
| 3835 | static int with_agg_build_key(cbm_return_clause_t *wc, binding_t *b, char *key, size_t key_sz) { |
| 3836 | int kl = 0; |
| 3837 | for (int ci = 0; ci < wc->count; ci++) { |
| 3838 | if (is_aggregate_func(wc->items[ci].func)) { |
| 3839 | continue; |
| 3840 | } |
| 3841 | char vbuf[CBM_SZ_512]; |
| 3842 | const char *v = project_item(b, &wc->items[ci], vbuf, sizeof(vbuf)); |
| 3843 | kl += snprintf(key + kl, key_sz - (size_t)kl, "%s|", v); |
| 3844 | if (kl >= (int)key_sz) { |
| 3845 | kl = (int)key_sz - SKIP_ONE; |
| 3846 | } |
| 3847 | } |
| 3848 | return kl; |
| 3849 | } |
| 3850 | |
| 3851 | /* Find or create an aggregation group. Returns index. */ |
| 3852 | static int with_agg_find_or_create(with_agg_t **aggs, int *agg_cnt, int *agg_cap, |
no test coverage detected