提交 4aa7802e 编写于 作者: A Alex Duan

feat(query): select count return value if no rows

上级 5f9f3e7a
......@@ -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;
......
......@@ -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;
......
......@@ -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) {
......
......@@ -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
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册