diff --git a/src/client/src/tscAsync.c b/src/client/src/tscAsync.c index 3fedc9e7ad7c9356c59ea75d16971fd338bb35ac..3c54176d0a6b2d1ff6fc567a5ca4760e8c1a1e79 100644 --- a/src/client/src/tscAsync.c +++ b/src/client/src/tscAsync.c @@ -42,11 +42,13 @@ static void tscAsyncFetchSingleRowProxy(void *param, TAOS_RES *tres, int numOfRo int doAsyncParseSql(SSqlObj* pSql) { SSqlCmd* pCmd = &pSql->cmd; SSqlRes* pRes = &pSql->res; + int32_t code = tscAllocPayload(pCmd, TSDB_DEFAULT_PAYLOAD_SIZE); if (code != TSDB_CODE_SUCCESS) { tscError("failed to malloc payload"); + pSql->res.code = code; + tscQueueAsyncRes(pSql); -// tscQueueAsyncRes(pSql->fp, pSql->param, TSDB_CODE_TSC_OUT_OF_MEMORY); return code; } diff --git a/src/client/src/tscParseInsert.c b/src/client/src/tscParseInsert.c index d821271857ae64f834e182a169f90681498d6255..4b6178eb610a8250931f974e01e4d28916d4d25b 100644 --- a/src/client/src/tscParseInsert.c +++ b/src/client/src/tscParseInsert.c @@ -1354,7 +1354,7 @@ int tsParseSql(SSqlObj *pSql, bool initialParse) { if (TSDB_CODE_SUCCESS != ret) { return ret; } - + SSqlInfo SQLInfo = qSQLParse(pSql->sqlstr); ret = tscToSQLCmd(pSql, &SQLInfo); SQLInfoDestroy(&SQLInfo); diff --git a/src/client/src/tscSQLParser.c b/src/client/src/tscSQLParser.c index 6164c005b94aa4a5a6a20f5dd08f25f382d053a2..2566e171f4ed1797ad3d59ae0af8bde708b5af2c 100644 --- a/src/client/src/tscSQLParser.c +++ b/src/client/src/tscSQLParser.c @@ -1482,7 +1482,8 @@ int32_t addExprAndResultField(SQueryInfo* pQueryInfo, int32_t colIndex, tSQLExpr const char* msg5 = "parameter is out of range [0, 100]"; const char* msg6 = "function applied to tags not allowed"; const char* msg7 = "normal table can not apply this function"; - + const char* msg8 = "multi-columns selection does not support alias column name"; + switch (optr) { case TK_COUNT: { if (pItem->pNode->pParam != NULL && pItem->pNode->pParam->nExpr != 1) { @@ -1689,6 +1690,10 @@ int32_t addExprAndResultField(SQueryInfo* pQueryInfo, int32_t colIndex, tSQLExpr return invalidSqlErrMsg(pQueryInfo->msg, msg3); } + if (pItem->pNode->pParam->nExpr > 1 && strlen(pItem->aliasName) > 0) { + return invalidSqlErrMsg(pQueryInfo->msg, msg8); + } + /* in first/last function, multiple columns can be add to resultset */ for (int32_t i = 0; i < pItem->pNode->pParam->nExpr; ++i) { tSQLExprItem* pParamElem = &(pItem->pNode->pParam->a[i]); @@ -1755,6 +1760,11 @@ int32_t addExprAndResultField(SQueryInfo* pQueryInfo, int32_t colIndex, tSQLExpr } else { // select * from xxx int32_t numOfFields = 0; + // multicolumn selection does not support alias name + if (strlen(pItem->aliasName) != 0) { + return invalidSqlErrMsg(pQueryInfo->msg, msg8); + } + for (int32_t j = 0; j < pQueryInfo->numOfTables; ++j) { pTableMetaInfo = tscGetMetaInfo(pQueryInfo, j); SSchema* pSchema = tscGetTableSchema(pTableMetaInfo->pTableMeta); diff --git a/src/client/src/tscSubquery.c b/src/client/src/tscSubquery.c index a3e655a9711fe0df8a8bac95846a0869d2b1a6ca..aaa5ab291f5760e1518c7bb306627996f549967f 100644 --- a/src/client/src/tscSubquery.c +++ b/src/client/src/tscSubquery.c @@ -1896,7 +1896,8 @@ int32_t tscHandleMultivnodeInsert(SSqlObj *pSql) { tscTrace("%p submit data to %d vnode(s)", pSql, pDataBlocks->nSize); SSubqueryState *pState = calloc(1, sizeof(SSubqueryState)); pState->numOfTotal = pSql->numOfSubs; - + pState->numOfRemain = pState->numOfTotal; + pRes->code = TSDB_CODE_SUCCESS; int32_t i = 0; @@ -1917,8 +1918,7 @@ int32_t tscHandleMultivnodeInsert(SSqlObj *pSql) { */ pNew->fetchFp = pNew->fp; pSql->pSubs[i] = pNew; - pNew->fetchFp = pNew->fp; - + tscTrace("%p sub:%p create subObj success. orderOfSub:%d", pSql, pNew, i); } diff --git a/src/client/src/tscUtil.c b/src/client/src/tscUtil.c index cbf1aa12bef7325969632d71a556e55b9fc999c6..110a435e571e2a7595f00d64f9a7f2ed19c3fdee 100644 --- a/src/client/src/tscUtil.c +++ b/src/client/src/tscUtil.c @@ -1581,24 +1581,6 @@ void tscClearSubqueryInfo(SSqlCmd* pCmd) { } } -void doRemoveTableMetaInfo(SQueryInfo* pQueryInfo, int32_t index, bool removeFromCache) { - if (index < 0 || index >= pQueryInfo->numOfTables) { - return; - } - - STableMetaInfo* pTableMetaInfo = tscGetMetaInfo(pQueryInfo, index); - - tscClearTableMetaInfo(pTableMetaInfo, removeFromCache); - free(pTableMetaInfo); - - int32_t after = pQueryInfo->numOfTables - index - 1; - if (after > 0) { - memmove(&pQueryInfo->pTableMetaInfo[index], &pQueryInfo->pTableMetaInfo[index + 1], after * POINTER_BYTES); - } - - pQueryInfo->numOfTables -= 1; -} - void clearAllTableMetaInfo(SQueryInfo* pQueryInfo, const char* address, bool removeFromCache) { tscTrace("%p deref the table meta in cache, numOfTables:%d", address, pQueryInfo->numOfTables); diff --git a/src/mnode/src/mnodeDnode.c b/src/mnode/src/mnodeDnode.c index e3ea08aeceb34a20cdd1e3df9122d9dc7f4f918f..0f2bbb8235006ee70bcd14887caab8d3ef17a4b8 100644 --- a/src/mnode/src/mnodeDnode.c +++ b/src/mnode/src/mnodeDnode.c @@ -365,8 +365,10 @@ static int32_t mnodeProcessDnodeStatusMsg(SMnodeMsg *pMsg) { mnodeUpdateVgroupStatus(pVgroup, pDnode, pVload); pAccess->vgId = htonl(pVload->vgId); pAccess->accessState = pVgroup->accessState; + pAccess++; mnodeDecVgroupRef(pVgroup); } + } if (pDnode->status == TAOS_DN_STATUS_OFFLINE) { diff --git a/src/util/src/tcompare.c b/src/util/src/tcompare.c index f9d306e6255d9a0ad769d7f67f44b8d7ab5414c1..889d38ff207315ed489f7877e3ee9f566a5cde41 100644 --- a/src/util/src/tcompare.c +++ b/src/util/src/tcompare.c @@ -191,9 +191,7 @@ int WCSPatternMatch(const wchar_t *patterStr, const wchar_t *str, size_t size, c break; } - str++; - - int32_t ret = WCSPatternMatch(&patterStr[i], str, wcslen(str), pInfo); + int32_t ret = WCSPatternMatch(&patterStr[i], ++str, size - n - 1, pInfo); if (ret != TSDB_PATTERN_NOMATCH) { return ret; } @@ -241,9 +239,11 @@ static int32_t compareFindStrInArray(const void* pLeft, const void* pRight) { static int32_t compareWStrPatternComp(const void* pLeft, const void* pRight) { SPatternCompareInfo pInfo = {'%', '_'}; - + wchar_t pattern[128] = {0}; - memcpy(pattern, varDataVal(pRight), varDataLen(pRight)/TSDB_NCHAR_SIZE); + assert(TSDB_PATTERN_STRING_MAX_LEN < 128); + + memcpy(pattern, varDataVal(pRight), varDataLen(pRight)); assert(varDataLen(pRight) < 128); int32_t ret = WCSPatternMatch(pattern, varDataVal(pLeft), varDataLen(pLeft)/TSDB_NCHAR_SIZE, &pInfo);