Main and count SQL over the name ranges: one UNION ALL arm per range, each * the plain WHERE plus its range, so every arm seeks idx_nodes_name. The arms * are disjoint and each yields (name, id) order, so ORDER BY 4, 1 (n.name, * n.id) merges them without a sort and the per-row degree subqueries run only * for rows the page emits; the count sums the per-range counts. On false * (allocation, b
| 7270 | /* Append to buf[0..cap) at *len; false (nothing written past cap) when it |
| 7271 | * does not fit. */ |
| 7272 | static bool search_sql_append(char *buf, size_t cap, size_t *len, const char *fmt, ...) { |
| 7273 | if (*len >= cap) { |
| 7274 | return false; |
| 7275 | } |
| 7276 | va_list args; |
| 7277 | va_start(args, fmt); |
| 7278 | int wrote = vsnprintf(buf + *len, cap - *len, fmt, args); |
| 7279 | va_end(args); |
| 7280 | if (wrote < 0 || (size_t)wrote >= cap - *len) { |
| 7281 | return false; |
| 7282 | } |
| 7283 | *len += (size_t)wrote; |
| 7284 | return true; |
| 7285 | } |
| 7286 | |
| 7287 | static bool search_build_ranged_sql(const char *select_cols, const char *where, |
| 7288 | const search_name_ranges_t *r, int limit, int offset, |
no outgoing calls
no test coverage detected