diff --git a/src/client/src/tscSubquery.c b/src/client/src/tscSubquery.c index e9ec272ea4e030ec9dc664d263dd9cf96aeb8266..7ea5d4183b948d920e1ca68aee793c1bc0351e48 100644 --- a/src/client/src/tscSubquery.c +++ b/src/client/src/tscSubquery.c @@ -2198,16 +2198,15 @@ void **doSetResultRowData(SSqlObj *pSql, bool finalResult) { // calculate the result from several other columns if (pSup->pArithExprInfo != NULL) { if (pRes->pArithSup == NULL) { - SArithmeticSupport *sas = (SArithmeticSupport *) calloc(1, sizeof(SArithmeticSupport)); - sas->offset = 0; - sas->pArithExpr = pSup->pArithExprInfo; - sas->numOfCols = (int32_t)tscSqlExprNumOfExprs(pQueryInfo); - sas->exprList = pQueryInfo->exprList; - sas->data = calloc(sas->numOfCols, POINTER_BYTES); - - pRes->pArithSup = sas; + pRes->pArithSup = (SArithmeticSupport*)calloc(1, sizeof(SArithmeticSupport)); } + pRes->pArithSup->offset = 0; + pRes->pArithSup->pArithExpr = pSup->pArithExprInfo; + pRes->pArithSup->numOfCols = (int32_t)tscSqlExprNumOfExprs(pQueryInfo); + pRes->pArithSup->exprList = pQueryInfo->exprList; + pRes->pArithSup->data = calloc(pRes->pArithSup->numOfCols, POINTER_BYTES); + if (pRes->buffer[i] == NULL) { TAOS_FIELD* field = tscFieldInfoGetField(&pQueryInfo->fieldsInfo, i); pRes->buffer[i] = malloc(field->bytes); diff --git a/tests/script/general/parser/topbot.sim b/tests/script/general/parser/topbot.sim index 3e906f3a28fc204866ecd06453f0567de22cbe34..5c575b61633d77521ef0c8b51b6e46aaf84447aa 100644 --- a/tests/script/general/parser/topbot.sim +++ b/tests/script/general/parser/topbot.sim @@ -199,4 +199,18 @@ if $rows != 4098 then return -1 endi +print ======================>td-1454 +sql select count(*)/10, count(*)+99 from t +if $rows != 1 then + return -1 +endi + +if $data00 != 509.600000000 then + return -1 +endi + +if $data01 != 5195.000000000 then + return -1 +endi + system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file