提交 550028db 编写于 作者: H Haojun Liao

[td-225] fix compiler error

上级 327cfce6
...@@ -1914,6 +1914,7 @@ int32_t tscHandleMultivnodeInsert(SSqlObj *pSql) { ...@@ -1914,6 +1914,7 @@ int32_t tscHandleMultivnodeInsert(SSqlObj *pSql) {
pSql->pSubs[0] = pSql; // the first sub insert points back to itself pSql->pSubs[0] = pSql; // the first sub insert points back to itself
tscTrace("%p sub:%p create subObj success. orderOfSub:%d", pSql, pSql, 0); tscTrace("%p sub:%p create subObj success. orderOfSub:%d", pSql, pSql, 0);
int32_t numOfSub = 1;
int32_t code = tscCopyDataBlockToPayload(pSql, pDataBlocks->pData[0]); int32_t code = tscCopyDataBlockToPayload(pSql, pDataBlocks->pData[0]);
if (code != TSDB_CODE_SUCCESS) { if (code != TSDB_CODE_SUCCESS) {
tscTrace("%p prepare submit data block failed in async insertion, vnodeIdx:%d, total:%d, code:%d", pSql, 0, tscTrace("%p prepare submit data block failed in async insertion, vnodeIdx:%d, total:%d, code:%d", pSql, 0,
...@@ -1921,15 +1922,14 @@ int32_t tscHandleMultivnodeInsert(SSqlObj *pSql) { ...@@ -1921,15 +1922,14 @@ int32_t tscHandleMultivnodeInsert(SSqlObj *pSql) {
goto _error; goto _error;
} }
int32_t i = 1; for (; numOfSub < pSql->numOfSubs; ++numOfSub) {
for (; i < pSql->numOfSubs; ++i) {
SInsertSupporter* pSupporter1 = calloc(1, sizeof(SInsertSupporter)); SInsertSupporter* pSupporter1 = calloc(1, sizeof(SInsertSupporter));
pSupporter1->pSql = pSql; pSupporter1->pSql = pSql;
pSupporter1->pState = pState; pSupporter1->pState = pState;
SSqlObj *pNew = createSubqueryObj(pSql, 0, multiVnodeInsertFinalize, pSupporter1, TSDB_SQL_INSERT, NULL); SSqlObj *pNew = createSubqueryObj(pSql, 0, multiVnodeInsertFinalize, pSupporter1, TSDB_SQL_INSERT, NULL);
if (pNew == NULL) { if (pNew == NULL) {
tscError("%p failed to malloc buffer for subObj, orderOfSub:%d, reason:%s", pSql, i, strerror(errno)); tscError("%p failed to malloc buffer for subObj, orderOfSub:%d, reason:%s", pSql, numOfSub, strerror(errno));
goto _error; goto _error;
} }
...@@ -1938,26 +1938,25 @@ int32_t tscHandleMultivnodeInsert(SSqlObj *pSql) { ...@@ -1938,26 +1938,25 @@ int32_t tscHandleMultivnodeInsert(SSqlObj *pSql) {
* the callback function (multiVnodeInsertFinalize) correctly. * the callback function (multiVnodeInsertFinalize) correctly.
*/ */
pNew->fetchFp = pNew->fp; pNew->fetchFp = pNew->fp;
pSql->pSubs[i] = pNew; pSql->pSubs[numOfSub] = pNew;
code = tscCopyDataBlockToPayload(pNew, pDataBlocks->pData[i]); code = tscCopyDataBlockToPayload(pNew, pDataBlocks->pData[numOfSub]);
if (code != TSDB_CODE_SUCCESS) { if (code != TSDB_CODE_SUCCESS) {
tscTrace("%p prepare submit data block failed in async insertion, vnodeIdx:%d, total:%d, code:%d", pSql, i, tscTrace("%p prepare submit data block failed in async insertion, vnodeIdx:%d, total:%d, code:%d", pSql, numOfSub,
pDataBlocks->nSize, code); pDataBlocks->nSize, code);
goto _error; goto _error;
} else { } else {
tscTrace("%p sub:%p create subObj success. orderOfSub:%d", pSql, pNew, i); tscTrace("%p sub:%p create subObj success. orderOfSub:%d", pSql, pNew, numOfSub);
} }
} }
if (i < pSql->numOfSubs) { if (numOfSub < pSql->numOfSubs) {
tscError("%p failed to prepare subObj structure and launch sub-insertion", pSql); tscError("%p failed to prepare subObj structure and launch sub-insertion", pSql);
pRes->code = TSDB_CODE_TSC_OUT_OF_MEMORY; pRes->code = TSDB_CODE_TSC_OUT_OF_MEMORY;
return pRes->code; // free all allocated resource return pRes->code; // free all allocated resource
} }
// use the local variable // use the local variable
int32_t numOfSub = pSql->numOfSubs;
for (int32_t j = 0; j < numOfSub; ++j) { for (int32_t j = 0; j < numOfSub; ++j) {
SSqlObj *pSub = pSql->pSubs[j]; SSqlObj *pSub = pSql->pSubs[j];
tscTrace("%p sub:%p launch sub insert, orderOfSub:%d", pSql, pSub, j); tscTrace("%p sub:%p launch sub insert, orderOfSub:%d", pSql, pSub, j);
...@@ -1969,11 +1968,12 @@ int32_t tscHandleMultivnodeInsert(SSqlObj *pSql) { ...@@ -1969,11 +1968,12 @@ int32_t tscHandleMultivnodeInsert(SSqlObj *pSql) {
_error: _error:
// restore the udf fp // restore the udf fp
pSql->fp = pSql->fetchFp; pSql->fp = pSql->fetchFp;
pSql->pSubs[0] = NULL;
tfree(pState); tfree(pState);
tfree(pSql->param); tfree(pSql->param);
for(int32_t j = 1; j < i; ++j) { for(int32_t j = 1; j < numOfSub; ++j) {
tfree(pSql->pSubs[j]->param); tfree(pSql->pSubs[j]->param);
taos_free_result(pSql->pSubs[j]); taos_free_result(pSql->pSubs[j]);
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册