From 8f3798da1d4ebacd27ac695c517881cd3b364293 Mon Sep 17 00:00:00 2001 From: Haojun Liao Date: Thu, 16 Jul 2020 11:25:08 +0800 Subject: [PATCH] [td-225] refactor code --- src/client/src/tscAsync.c | 37 ++++++++++++------------------------- 1 file changed, 12 insertions(+), 25 deletions(-) diff --git a/src/client/src/tscAsync.c b/src/client/src/tscAsync.c index 8c194c031d..b856752db3 100644 --- a/src/client/src/tscAsync.c +++ b/src/client/src/tscAsync.c @@ -474,33 +474,11 @@ void tscTableMetaCallBack(void *param, TAOS_RES *res, int code) { // in case of insert, redo parsing the sql string and build new submit data block for two reasons: // 1. the table Id(tid & uid) may have been update, the submit block needs to be updated accordingly. // 2. vnode may need the schema information along with submit block to update its local table schema. - if (pCmd->command == TSDB_SQL_INSERT) { - tscDebug("%p redo parse sql string to build submit block", pSql); - - pCmd->parseFinished = false; - tscResetSqlCmdObj(pCmd); - - code = tsParseSql(pSql, true); - - if (code == TSDB_CODE_TSC_ACTION_IN_PROGRESS) { - return; - } else if (code != TSDB_CODE_SUCCESS) { - goto _error; - } - - /* - * Discard previous built submit blocks, and then parse the sql string again and build up all submit blocks, - * and send the required submit block according to index value in supporter to server. - */ - pSql->fp = pSql->fetchFp; // restore the fp - tscHandleInsertRetry(pSql); - } else if (pCmd->command == TSDB_SQL_SELECT) { // in case of other query type, continue + if (pCmd->command == TSDB_SQL_INSERT || pCmd->command == TSDB_SQL_SELECT) { tscDebug("%p redo parse sql string and proceed", pSql); - //tscDebug("before %p fp:%p, fetchFp:%p", pSql, pSql->fp, pSql->fetchFp); pCmd->parseFinished = false; tscResetSqlCmdObj(pCmd); - //tscDebug("after %p fp:%p, fetchFp:%p", pSql, pSql->fp, pSql->fetchFp); code = tsParseSql(pSql, true); if (code == TSDB_CODE_TSC_ACTION_IN_PROGRESS) { @@ -509,8 +487,17 @@ void tscTableMetaCallBack(void *param, TAOS_RES *res, int code) { goto _error; } - tscProcessSql(pSql); - } else { // in all other cases, simple retry + if (pCmd->command == TSDB_SQL_INSERT) { + /* + * Discard previous built submit blocks, and then parse the sql string again and build up all submit blocks, + * and send the required submit block according to index value in supporter to server. + */ + pSql->fp = pSql->fetchFp; // restore the fp + tscHandleInsertRetry(pSql); + } else if (pCmd->command == TSDB_SQL_SELECT) { // in case of other query type, continue + tscProcessSql(pSql); + } + }else { // in all other cases, simple retry tscProcessSql(pSql); } -- GitLab