From ff2a76910f4b4da1741e9888f673343099784045 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Mon, 13 Feb 2023 18:15:59 +0100 Subject: Adding upstream version 1.38.1. Signed-off-by: Daniel Baumann --- web/api/queries/query.c | 28 +++++++++++++++++++--------- 1 file changed, 19 insertions(+), 9 deletions(-) (limited to 'web/api/queries/query.c') diff --git a/web/api/queries/query.c b/web/api/queries/query.c index 1f10c5137..df7e09799 100644 --- a/web/api/queries/query.c +++ b/web/api/queries/query.c @@ -2273,9 +2273,11 @@ RRDR *rrd2rrdr(ONEWAYALLOC *owa, QUERY_TARGET *qt) { r->internal.grouping_reset(r); if(ops[c]) { - r->od[c] |= RRDR_DIMENSION_SELECTED; + r->od[c] |= RRDR_DIMENSION_QUERIED; rrd2rrdr_query_execute(r, c, ops[c]); } + else + continue; global_statistics_rrdr_query_completed( 1, @@ -2385,15 +2387,23 @@ RRDR *rrd2rrdr(ONEWAYALLOC *owa, QUERY_TARGET *qt) { // free all resources used by the grouping method r->internal.grouping_free(r); - // when all the dimensions are zero, we should return all of them - if(unlikely((qt->window.options & RRDR_OPTION_NONZERO) && !dimensions_nonzero && !(r->result_options & RRDR_RESULT_OPTION_CANCEL))) { - // all the dimensions are zero - // mark them as NONZERO to send them all - for(size_t c = 0, max = qt->query.used; c < max ; c++) { - if(unlikely(r->od[c] & RRDR_DIMENSION_HIDDEN)) continue; - r->od[c] |= RRDR_DIMENSION_NONZERO; + if(likely(dimensions_used)) { + // when all the dimensions are zero, we should return all of them + if (unlikely((qt->window.options & RRDR_OPTION_NONZERO) && !dimensions_nonzero && + !(r->result_options & RRDR_RESULT_OPTION_CANCEL))) { + // all the dimensions are zero + // mark them as NONZERO to send them all + for (size_t c = 0, max = qt->query.used; c < max; c++) { + if (unlikely(r->od[c] & RRDR_DIMENSION_HIDDEN)) continue; + if (unlikely(!(r->od[c] & RRDR_DIMENSION_QUERIED))) continue; + r->od[c] |= RRDR_DIMENSION_NONZERO; + } } + + return r; } - return r; + // we couldn't query any dimension + rrdr_free(owa, r); + return NULL; } -- cgit v1.2.3