diff --git a/src/client/src/tscSQLParser.c b/src/client/src/tscSQLParser.c index cee3998017523b09cba96bc86b70a057321b5261..7c9d85491bb679a002027828841899c7698cccda 100644 --- a/src/client/src/tscSQLParser.c +++ b/src/client/src/tscSQLParser.c @@ -1945,6 +1945,7 @@ static int16_t doGetColumnIndex(SQueryInfo* pQueryInfo, int32_t index, SSQLToken if (strncasecmp(pSchema[i].name, pToken->z, pToken->n) == 0) { columnIndex = i; + break; } } diff --git a/src/client/src/tscServer.c b/src/client/src/tscServer.c index ed937bb68a67847deb8c2a9d7af6ad439479551e..10ea9de835d104a59eadd8328daf907a26ce3c03 100644 --- a/src/client/src/tscServer.c +++ b/src/client/src/tscServer.c @@ -710,15 +710,21 @@ int32_t tscLaunchJoinSubquery(SSqlObj *pSql, int16_t tableIndex, SJoinSubquerySu int doProcessSql(SSqlObj *pSql) { SSqlCmd *pCmd = &pSql->cmd; SSqlRes *pRes = &pSql->res; + int32_t code = TSDB_CODE_SUCCESS; void *asyncFp = pSql->fp; if (pCmd->command == TSDB_SQL_SELECT || pCmd->command == TSDB_SQL_FETCH || pCmd->command == TSDB_SQL_RETRIEVE || pCmd->command == TSDB_SQL_INSERT || pCmd->command == TSDB_SQL_CONNECT || pCmd->command == TSDB_SQL_HB || pCmd->command == TSDB_SQL_META || pCmd->command == TSDB_SQL_METRIC) { - tscBuildMsg[pCmd->command](pSql, NULL); + code = tscBuildMsg[pCmd->command](pSql, NULL); } - int32_t code = tscSendMsgToServer(pSql); + if (code != TSDB_CODE_SUCCESS) { + pRes->code = code; + return code; + } + + code = tscSendMsgToServer(pSql); if (asyncFp) { if (code != TSDB_CODE_SUCCESS) { @@ -994,7 +1000,13 @@ int tscLaunchSTableSubqueries(SSqlObj *pSql) { SRetrieveSupport* pSupport = pSub->param; tscTrace("%p sub:%p launch subquery, orderOfSub:%d.", pSql, pSub, pSupport->subqueryIndex); - tscProcessSql(pSub); + int code = tscProcessSql(pSub); + if (code != TSDB_CODE_SUCCESS) { + tscLocalReducerEnvDestroy(pMemoryBuf, pDesc, pModel, numOfSubQueries); + doCleanupSubqueries(pSql, i, pState); + pRes->code = code; + return pRes->code; + } } return TSDB_CODE_SUCCESS; @@ -2702,7 +2714,7 @@ int tscBuildMultiMeterMetaMsg(SSqlObj *pSql, SSqlInfo *pInfo) { tscTrace("%p build load multi-metermeta msg completed, numOfMeters:%d, msg size:%d", pSql, pCmd->count, pCmd->payloadLen); - return pCmd->payloadLen; + return TSDB_CODE_SUCCESS; } static int32_t tscEstimateMetricMetaMsgSize(SSqlCmd *pCmd) { @@ -2929,7 +2941,7 @@ int tscBuildHeartBeatMsg(SSqlObj *pSql, SSqlInfo *pInfo) { pCmd->msgType = TSDB_MSG_TYPE_HEARTBEAT; assert(msgLen + minMsgSize() <= size); - return msgLen; + return TSDB_CODE_SUCCESS; } int tscProcessMeterMetaRsp(SSqlObj *pSql) { diff --git a/src/client/src/tscSql.c b/src/client/src/tscSql.c index a0089379a9c71434ed1a7aa7547724145241b89f..210c63adb6c97fd9bf9d7399e79feb04ac7a0de9 100644 --- a/src/client/src/tscSql.c +++ b/src/client/src/tscSql.c @@ -321,6 +321,9 @@ TAOS_FIELD *taos_fetch_fields(TAOS_RES *res) { if (pSql == NULL || pSql->signature != pSql) return 0; SQueryInfo *pQueryInfo = tscGetQueryInfoDetail(&pSql->cmd, 0); + if(NULL == pQueryInfo){ + return NULL; + } return pQueryInfo->fieldsInfo.pFields; } diff --git a/src/client/src/tscUtil.c b/src/client/src/tscUtil.c index dbd3f464eaf457b9002bb5cd6af6bfd88e5cfbc1..2d86e7c4e006fe0785826746e17d4865eaf26fe4 100644 --- a/src/client/src/tscUtil.c +++ b/src/client/src/tscUtil.c @@ -2010,7 +2010,7 @@ SSqlObj* createSubqueryObj(SSqlObj* pSql, int16_t tableIndex, void (*fp)(), void } // create the fields info from the sql functions - SColumnList columnList = {.num = 1}; + SColumnList columnList = {.num = 0}; for(int32_t k = 0; k < numOfOutputCols; ++k) { SSqlExpr* pExpr = tscSqlExprGet(pQueryInfo, indexList[k]); diff --git a/src/sdb/src/sdbEngine.c b/src/sdb/src/sdbEngine.c index 2bdc64cdecd14f7951f2385a751999a71cd94770..e2bde1eb8b7588691fb1c986eca668bace340728 100644 --- a/src/sdb/src/sdbEngine.c +++ b/src/sdb/src/sdbEngine.c @@ -812,11 +812,10 @@ void sdbResetTable(SSdbTable *pTable) { SRowHead *rowHead = NULL; void * pMetaRow = NULL; int64_t oldId = pTable->id; - //TODO: check - //int oldNumOfRows = pTable->numOfRows; + int oldNumOfRows = pTable->numOfRows; if (sdbOpenSdbFile(pTable) < 0) return; - //pTable->numOfRows = oldNumOfRows; + pTable->numOfRows = oldNumOfRows; total_size = sizeof(SRowHead) + pTable->maxRowSize + sizeof(TSCKSUM); rowHead = (SRowHead *)malloc(total_size); diff --git a/src/system/detail/src/vnodeQueryImpl.c b/src/system/detail/src/vnodeQueryImpl.c index e69b5a5b8cf0cc49ada67f44ec5d4eb17b7eff57..a24a241baa9b3ad2b760c52e02f2427ab123ebe2 100644 --- a/src/system/detail/src/vnodeQueryImpl.c +++ b/src/system/detail/src/vnodeQueryImpl.c @@ -1529,7 +1529,7 @@ static STimeWindow getActiveTimeWindow(SWindowResInfo *pWindowResInfo, int64_t t w.ekey = w.skey + pQuery->intervalTime - 1; } - assert(ts >= w.skey && ts <= w.ekey && w.skey != 0); + assert(ts >= w.skey && ts <= w.ekey/* && w.skey != 0*/); return w; } @@ -1646,7 +1646,7 @@ static void doCheckQueryCompleted(SQueryRuntimeEnv *pRuntimeEnv, TSKEY lastKey, setQueryStatus(pQuery, QUERY_COMPLETED | QUERY_RESBUF_FULL); } else { // set the current index to be the last unclosed window int32_t i = 0; - int64_t skey = 0; + int64_t skey = INT64_MIN; for (i = 0; i < pWindowResInfo->size; ++i) { SWindowResult *pResult = &pWindowResInfo->pResult[i]; @@ -1668,7 +1668,7 @@ static void doCheckQueryCompleted(SQueryRuntimeEnv *pRuntimeEnv, TSKEY lastKey, } // all windows are closed, set the last one to be the skey - if (skey == 0) { + if (skey == INT64_MIN) { assert(i == pWindowResInfo->size); pWindowResInfo->curIndex = pWindowResInfo->size - 1; } else { @@ -1686,7 +1686,7 @@ static void doCheckQueryCompleted(SQueryRuntimeEnv *pRuntimeEnv, TSKEY lastKey, dTrace("QInfo:%p total window:%d, closed:%d", GET_QINFO_ADDR(pQuery), pWindowResInfo->size, n); } - assert(pWindowResInfo->prevSKey != 0); + assert(pWindowResInfo->prevSKey != INT64_MIN); } static int32_t getNumOfRowsInTimeWindow(SQuery *pQuery, SBlockInfo *pBlockInfo, TSKEY *pPrimaryColumn, int32_t startPos, @@ -4020,16 +4020,7 @@ bool normalizedFirstQueryRange(bool dataInDisk, bool dataInCache, STableQuerySup *key = nextKey; } - // needs the data before the begin timestamp of query time window - if (nextKey != pQuery->skey) { - if (!pRuntimeEnv->hasTimeWindow) { - pQuery->skey = nextKey; // change the query skey - pQuery->lastKey = pQuery->skey; - } - return true; - } else { - return doGetQueryPos(nextKey, pSupporter, pPointInterpSupporter); - } + return doGetQueryPos(nextKey, pSupporter, pPointInterpSupporter); } // set no data in file diff --git a/src/util/src/tnote.c b/src/util/src/tnote.c index 7a133590d2a450d8e8b688bc63515c0ad9e81912..1a1b3a644de580b0fc26bb6aa459635a86ed5204 100644 --- a/src/util/src/tnote.c +++ b/src/util/src/tnote.c @@ -77,7 +77,7 @@ void taosUnLockNote(int fd, taosNoteInfo * pNote) void *taosThreadToOpenNewNote(void *param) { - char name[NOTE_FILE_NAME_LEN]; + char name[NOTE_FILE_NAME_LEN + 16]; taosNoteInfo * pNote = (taosNoteInfo *)param; pNote->taosNoteFlag ^= 1; @@ -170,7 +170,7 @@ void taosGetNoteName(char *fn, taosNoteInfo * pNote) int taosOpenNoteWithMaxLines(char *fn, int maxLines, int maxNoteNum, taosNoteInfo * pNote) { - char name[NOTE_FILE_NAME_LEN] = "\0"; + char name[NOTE_FILE_NAME_LEN + 16] = "\0"; struct stat notestat0, notestat1; int size;