diff --git a/src/client/src/tscSQLParser.c b/src/client/src/tscSQLParser.c index c2542fb8c6ffbb1af18a1d2b719767575a73fd3c..9e8cb325a8e978a9ccdc2aea7b52b3bab5177ab6 100644 --- a/src/client/src/tscSQLParser.c +++ b/src/client/src/tscSQLParser.c @@ -2766,8 +2766,7 @@ static bool isTablenameToken(SStrToken* token) { SStrToken tableToken = {0}; extractTableNameFromToken(&tmpToken, &tableToken); - - return (strncasecmp(TSQL_TBNAME_L, tmpToken.z, tmpToken.n) == 0 && tmpToken.n == strlen(TSQL_TBNAME_L)); + return (tmpToken.n == strlen(TSQL_TBNAME_L) && strncasecmp(TSQL_TBNAME_L, tmpToken.z, tmpToken.n) == 0); } static int16_t doGetColumnIndex(SQueryInfo* pQueryInfo, int32_t index, SStrToken* pToken) { @@ -2798,7 +2797,8 @@ int32_t doGetColumnIndexByName(SStrToken* pToken, SQueryInfo* pQueryInfo, SColum if (isTablenameToken(pToken)) { pIndex->columnIndex = TSDB_TBNAME_COLUMN_INDEX; - } else if (strncasecmp(pToken->z, DEFAULT_PRIMARY_TIMESTAMP_COL_NAME, pToken->n) == 0) { + } else if (strlen(DEFAULT_PRIMARY_TIMESTAMP_COL_NAME) == pToken->n && + strncasecmp(pToken->z, DEFAULT_PRIMARY_TIMESTAMP_COL_NAME, pToken->n) == 0) { pIndex->columnIndex = PRIMARYKEY_TIMESTAMP_COL_INDEX; } else { // not specify the table name, try to locate the table index by column name diff --git a/src/client/src/tscSubquery.c b/src/client/src/tscSubquery.c index 8ab3512cba0a2bd2b220bade0830e8ea20c32f58..804878fa45caff4359d076a9ebab30e93983b638 100644 --- a/src/client/src/tscSubquery.c +++ b/src/client/src/tscSubquery.c @@ -3047,9 +3047,10 @@ static void multiVnodeInsertFinalize(void* param, TAOS_RES* tres, int numOfRows) pParentObj->cmd.insertParam.schemaAttached = 1; } } - - if (!subAndCheckDone(tres, pParentObj, pSupporter->index)) { - tscDebug("0x%"PRIx64" insert:%p,%d completed, total:%d", pParentObj->self, tres, pSupporter->index, pParentObj->subState.numOfSub); + + int32_t suppIdx = pSupporter->index; + if (!subAndCheckDone(tres, pParentObj, suppIdx)) { + tscDebug("0x%"PRIx64" insert:%p,%d completed, total:%d", pParentObj->self, tres, suppIdx, pParentObj->subState.numOfSub); return; } diff --git a/src/client/src/tscUtil.c b/src/client/src/tscUtil.c index b42724a2ec3b01be71b94b06f7e2ef7dbd8b9887..3195e74f027409df3123ddd9ce693b2e5adf751b 100644 --- a/src/client/src/tscUtil.c +++ b/src/client/src/tscUtil.c @@ -297,7 +297,7 @@ bool tscHasColumnFilter(SQueryInfo* pQueryInfo) { size_t size = taosArrayGetSize(pQueryInfo->colList); for (int32_t i = 0; i < size; ++i) { - SColumn* pCol = taosArrayGet(pQueryInfo->colList, i); + SColumn* pCol = taosArrayGetP(pQueryInfo->colList, i); if (pCol->info.flist.numOfFilters > 0) { return true; } @@ -4382,7 +4382,9 @@ int32_t tscCreateQueryFromQueryInfo(SQueryInfo* pQueryInfo, SQueryAttr* pQueryAt if (pQueryAttr->fillType != TSDB_FILL_NONE) { pQueryAttr->fillVal = calloc(pQueryAttr->numOfOutput, sizeof(int64_t)); - memcpy(pQueryAttr->fillVal, pQueryInfo->fillVal, pQueryAttr->numOfOutput * sizeof(int64_t)); + int32_t fields = tscNumOfFields(pQueryInfo); + int32_t cpySize = fields < pQueryAttr->numOfOutput ? fields : pQueryAttr->numOfOutput; + memcpy(pQueryAttr->fillVal, pQueryInfo->fillVal, cpySize * sizeof(int64_t)); } pQueryAttr->srcRowSize = 0; diff --git a/src/query/src/qExecutor.c b/src/query/src/qExecutor.c index ef88f8bc0641b50438fd4e72e335ccb7828e124e..ecdbc3be4fc4838f5c3e258409715380961377c8 100644 --- a/src/query/src/qExecutor.c +++ b/src/query/src/qExecutor.c @@ -5956,8 +5956,13 @@ SColumnInfo* extractColumnFilterInfo(SExprInfo* pExpr, int32_t numOfOutput, int3 pCols[i].colId = pExpr[i].base.resColId; pCols[i].flist.numOfFilters = pExpr[i].base.flist.numOfFilters; - pCols[i].flist.filterInfo = calloc(pCols[i].flist.numOfFilters, sizeof(SColumnFilterInfo)); - memcpy(pCols[i].flist.filterInfo, pExpr[i].base.flist.filterInfo, pCols[i].flist.numOfFilters * sizeof(SColumnFilterInfo)); + if (pCols[i].flist.numOfFilters != 0) { + pCols[i].flist.filterInfo = calloc(pCols[i].flist.numOfFilters, sizeof(SColumnFilterInfo)); + memcpy(pCols[i].flist.filterInfo, pExpr[i].base.flist.filterInfo, pCols[i].flist.numOfFilters * sizeof(SColumnFilterInfo)); + } else { + // avoid runtime error + pCols[i].flist.filterInfo = NULL; + } } assert(numOfFilter > 0); @@ -6416,10 +6421,10 @@ static SSDataBlock* hashDistinct(void* param, bool* newgroup) { if (isNull(val, type)) { continue; } - + int dummy; void* res = taosHashGet(pInfo->pSet, val, bytes); if (res == NULL) { - taosHashPut(pInfo->pSet, val, bytes, NULL, 0); + taosHashPut(pInfo->pSet, val, bytes, &dummy, sizeof(dummy)); char* start = pResultColInfoData->pData + bytes * pInfo->pRes->info.rows; memcpy(start, val, bytes); pRes->info.rows += 1;