The same comparison on values resolved once per binding. order_key_value * may return a rotating thread-local buffer, so the values are copies. */
| 4456 | /* The same comparison on values resolved once per binding. order_key_value |
| 4457 | * may return a rotating thread-local buffer, so the values are copies. */ |
| 4458 | static int with_order_compare(const void *context, int a, int b) { |
| 4459 | const with_order_ctx_t *ctx = context; |
| 4460 | size_t keys = (size_t)ctx->wc->order_key_count; |
| 4461 | int cmp = 0; |
| 4462 | for (size_t k = 0; k < keys && cmp == 0; k++) { |
| 4463 | size_t ia = (size_t)a * keys + k; |
| 4464 | size_t ib = (size_t)b * keys + k; |
| 4465 | if (ctx->numbered[ia] && ctx->numbered[ib]) { |
| 4466 | cmp = (ctx->numbers[ia] > ctx->numbers[ib]) - (ctx->numbers[ia] < ctx->numbers[ib]); |
| 4467 | } else { |
| 4468 | cmp = strcmp(ctx->values[ia], ctx->values[ib]); |
| 4469 | } |
| 4470 | if (ctx->wc->order_descs[k]) { |
| 4471 | cmp = -cmp; |
| 4472 | } |
| 4473 | } |
| 4474 | return cmp; |
| 4475 | } |
| 4476 | |
| 4477 | /* Sort bindings by the ORDER BY key list (virtual variables), stably. */ |
| 4478 | static void sort_bindings(binding_t *vbindings, int count, const cbm_return_clause_t *wc) { |
nothing calls this directly
no outgoing calls
no test coverage detected