diff --git a/src/client/src/tscParseInsert.c b/src/client/src/tscParseInsert.c index d4cb66e16fd8abe9709e0e07aebf207a89cb473b..3e4c0d4fa4d3d11112638d53364667520541a84b 100644 --- a/src/client/src/tscParseInsert.c +++ b/src/client/src/tscParseInsert.c @@ -1291,7 +1291,7 @@ int tsParseInsertSql(SSqlObj *pSql) { return doParseInsertSql(pSql, pSql->sqlstr + index); } -int tsParseSql(SSqlObj *pSql, bool initalParse) { +int tsParseSql(SSqlObj *pSql, bool initialParse) { int32_t ret = TSDB_CODE_SUCCESS; tscTrace("continue parse sql: %s", pSql->asyncTblPos); @@ -1301,10 +1301,11 @@ int tsParseSql(SSqlObj *pSql, bool initalParse) { * Set the fp before parse the sql string, in case of getmetermeta failed, in which * the error handle callback function can rightfully restore the user defined function (fp) */ - if (pSql->fp != NULL && initalParse) { - pSql->fetchFp = pSql->fp; - + if (initialParse) { + tscFreeSqlCmdData(&pSql->cmd); + // replace user defined callback function with multi-insert proxy function + pSql->fetchFp = pSql->fp; pSql->fp = (void(*)())tscHandleMultivnodeInsert; } @@ -1315,7 +1316,7 @@ int tsParseSql(SSqlObj *pSql, bool initalParse) { return ret; } - if (initalParse) { + if (initialParse) { tscFreeSqlCmdData(&pSql->cmd); } @@ -1449,57 +1450,6 @@ static int tscInsertDataFromFile(SSqlObj *pSql, FILE *fp, char *tmpTokenBuf) { return numOfRows; } -/* multi-vnodes insertion in sync query model - * - * modify history - * 2019.05.10 lihui - * Remove the code for importing records from files - */ -void tscProcessMultiVnodesInsert(SSqlObj *pSql) { - SSqlCmd *pCmd = &pSql->cmd; - - // not insert/import, return directly - if (pCmd->command != TSDB_SQL_INSERT) { - return; - } - - // SSqlCmd may have been released - if (pCmd->pDataBlocks == NULL) { - return; - } - - STableDataBlocks *pDataBlock = NULL; - STableMetaInfo * pTableMetaInfo = tscGetTableMetaInfoFromCmd(pCmd, pCmd->clauseIndex, 0); - assert(pCmd->numOfClause == 1); - - int32_t code = TSDB_CODE_SUCCESS; - - /* the first block has been sent to server in processSQL function */ - assert(pTableMetaInfo->vnodeIndex >= 1 && pCmd->pDataBlocks != NULL); - - if (pTableMetaInfo->vnodeIndex < pCmd->pDataBlocks->nSize) { - SDataBlockList *pDataBlocks = pCmd->pDataBlocks; - - for (int32_t i = pTableMetaInfo->vnodeIndex; i < pDataBlocks->nSize; ++i) { - pDataBlock = pDataBlocks->pData[i]; - if (pDataBlock == NULL) { - continue; - } - - if ((code = tscCopyDataBlockToPayload(pSql, pDataBlock)) != TSDB_CODE_SUCCESS) { - tscTrace("%p build submit data block failed, vnodeIdx:%d, total:%d", pSql, pTableMetaInfo->vnodeIndex, - pDataBlocks->nSize); - continue; - } - - tscProcessSql(pSql); - } - } - - // all data have been submit to vnode, release data blocks - pCmd->pDataBlocks = tscDestroyBlockArrayList(pCmd->pDataBlocks); -} - // multi-vnodes insertion in sync query model void tscProcessMultiVnodesInsertFromFile(SSqlObj *pSql) { SSqlCmd *pCmd = &pSql->cmd; diff --git a/src/client/src/tscSql.c b/src/client/src/tscSql.c index 8d635e3e7603e5eef6a0eb18ce1837c8f6faec54..953f8b9bac0b30bf3b0c7b6a6b2aff4b7231c068 100644 --- a/src/client/src/tscSql.c +++ b/src/client/src/tscSql.c @@ -297,11 +297,6 @@ int taos_query(TAOS *taos, const char *sqlstr) { // wait for the callback function to post the semaphore sem_wait(&pSql->rspSem); - - if (pSql->res.code != TSDB_CODE_SUCCESS) { - tscFreeSqlCmdData(&pSql->cmd); - } - return pSql->res.code; }