diff --git a/src/common/inc/tglobal.h b/src/common/inc/tglobal.h index 650bb6bb4e6acd013bcfe3e9a43e67309ce0f570..80cef9a893bbe15c8a187464fb9bfb51108e6017 100644 --- a/src/common/inc/tglobal.h +++ b/src/common/inc/tglobal.h @@ -219,6 +219,7 @@ extern int32_t cqDebugFlag; extern int32_t debugFlag; extern int8_t tsClientMerge; +extern int8_t tsCountAlwaysReturnValue; // probe alive connection extern int32_t tsProbeSeconds; diff --git a/src/common/src/tglobal.c b/src/common/src/tglobal.c index 6260b22c81112647e605247621fdecb0524c43ff..41419cbc4ead207d757208492bd184079c94b084 100644 --- a/src/common/src/tglobal.c +++ b/src/common/src/tglobal.c @@ -273,6 +273,7 @@ int32_t cqDebugFlag = 131; int32_t fsDebugFlag = 135; int8_t tsClientMerge = 0; +int8_t tsCountAlwaysReturnValue = 0; // probe alive connection int32_t tsProbeSeconds = 5 * 60; // start probe link alive after tsProbeSeconds from starting query @@ -1690,6 +1691,16 @@ static void doInitGlobalConfig(void) { cfg.unitType = TAOS_CFG_UTYPE_NONE; taosInitConfigOption(cfg); + cfg.option = "countAlwaysReturnValue"; + cfg.ptr = &tsCountAlwaysReturnValue; + cfg.valType = TAOS_CFG_VTYPE_INT8; + cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_SHOW; + cfg.minValue = 0; + cfg.maxValue = 1; + cfg.ptrLength = 1; + cfg.unitType = TAOS_CFG_UTYPE_NONE; + taosInitConfigOption(cfg); + // default JSON string type option "binary"/"nchar" cfg.option = "defaultJSONStrType"; cfg.ptr = tsDefaultJSONStrType; diff --git a/src/query/src/qAggMain.c b/src/query/src/qAggMain.c index d12bb28ab819cad0c041828ceeaa72ea924fe4f1..e8c0c8c3b871794e1f790f6ff34764f2042bb1b1 100644 --- a/src/query/src/qAggMain.c +++ b/src/query/src/qAggMain.c @@ -936,12 +936,12 @@ static void count_function(SQLFunctionCtx *pCtx) { } } - if (numOfElem > 0) { + if (numOfElem > 0 || tsCountAlwaysReturnValue) { GET_RES_INFO(pCtx)->hasResult = DATA_SET_FLAG; + *((int64_t *)pCtx->pOutput) += numOfElem; + pCtx->resultInfo->numOfRes = 1; } - *((int64_t *)pCtx->pOutput) += numOfElem; - SET_VAL(pCtx, numOfElem, 1); } static void count_func_merge(SQLFunctionCtx *pCtx) { diff --git a/src/util/inc/tconfig.h b/src/util/inc/tconfig.h index a2c293772213fe804bc49fb2b74b9cc557dca269..cd46d51de1c595107deb7096b46db64fbf248150 100644 --- a/src/util/inc/tconfig.h +++ b/src/util/inc/tconfig.h @@ -20,7 +20,7 @@ extern "C" { #endif -#define TSDB_CFG_MAX_NUM 136 +#define TSDB_CFG_MAX_NUM 137 #define TSDB_CFG_PRINT_LEN 23 #define TSDB_CFG_OPTION_LEN 24 #define TSDB_CFG_VALUE_LEN 41