[TD-98] cleanup the status code in SqlCmd object in SQL parse stage.

This commit is contained in:
hjxilinx 2020-04-04 16:20:25 +08:00
parent d8c8f197f5
commit 6dade8a092
4 changed files with 15 additions and 8 deletions

View File

@ -1291,7 +1291,7 @@ int tsParseInsertSql(SSqlObj *pSql) {
return doParseInsertSql(pSql, pSql->sqlstr + index);
}
int tsParseSql(SSqlObj *pSql, bool multiVnodeInsertion) {
int tsParseSql(SSqlObj *pSql, bool initalParse) {
int32_t ret = TSDB_CODE_SUCCESS;
tscTrace("continue parse sql: %s", pSql->asyncTblPos);
@ -1301,7 +1301,7 @@ int tsParseSql(SSqlObj *pSql, bool multiVnodeInsertion) {
* 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 && multiVnodeInsertion) {
if (pSql->fp != NULL && initalParse) {
pSql->fetchFp = pSql->fp;
// replace user defined callback function with multi-insert proxy function
@ -1311,7 +1311,13 @@ int tsParseSql(SSqlObj *pSql, bool multiVnodeInsertion) {
ret = tsParseInsertSql(pSql);
} else {
ret = tscAllocPayload(&pSql->cmd, TSDB_DEFAULT_PAYLOAD_SIZE);
if (TSDB_CODE_SUCCESS != ret) return ret;
if (TSDB_CODE_SUCCESS != ret) {
return ret;
}
if (initalParse) {
tscFreeSqlCmdData(&pSql->cmd);
}
SSqlInfo SQLInfo = {0};
tSQLParse(&SQLInfo, pSql->sqlstr);

View File

@ -497,6 +497,7 @@ int32_t tscToSQLCmd(SSqlObj* pSql, struct SSqlInfo* pInfo) {
}
} else if (pCreateTable->type == TSQL_CREATE_TABLE_FROM_STABLE) {
assert(pCmd->numOfCols == 0);
if ((code = doCheckForCreateFromStable(pSql, pInfo)) != TSDB_CODE_SUCCESS) {
return code;
}

View File

@ -1225,7 +1225,6 @@ int tscBuildCreateTableMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
SCreateTableSQL *pCreateTable = pInfo->pCreateTableInfo;
pCreateTableMsg->igExists = pCreateTable->existCheck ? 1 : 0;
pCreateTableMsg->numOfColumns = htons(pCmd->numOfCols);
pCreateTableMsg->numOfTags = htons(pCmd->count);

View File

@ -394,6 +394,10 @@ void tscDestroyResPointerInfo(SSqlRes* pRes) {
}
void tscFreeSqlCmdData(SSqlCmd* pCmd) {
pCmd->command = 0;
pCmd->numOfCols = 0;
pCmd->count = 0;
pCmd->pDataBlocks = tscDestroyBlockArrayList(pCmd->pDataBlocks);
tscFreeSubqueryInfo(pCmd);
}
@ -454,9 +458,7 @@ void tscFreeSqlObjPartial(SSqlObj* pSql) {
cmd == TSDB_SQL_METRIC_JOIN_RETRIEVE) {
tscRemoveFromSqlList(pSql);
}
pCmd->command = 0;
// pSql->sqlstr will be used by tscBuildQueryStreamDesc
pthread_mutex_lock(&pObj->mutex);
tfree(pSql->sqlstr);
@ -1899,7 +1901,6 @@ void tscFreeSubqueryInfo(SSqlCmd* pCmd) {
for (int32_t i = 0; i < pCmd->numOfClause; ++i) {
char* addr = (char*)pCmd - offsetof(SSqlObj, cmd);
SQueryInfo* pQueryInfo = tscGetQueryInfoDetail(pCmd, i);
doClearSubqueryInfo(pQueryInfo);