[TD-98] cleanup the status code in SqlCmd object in SQL parse stage.
This commit is contained in:
parent
d8c8f197f5
commit
6dade8a092
|
@ -1291,7 +1291,7 @@ int tsParseInsertSql(SSqlObj *pSql) {
|
||||||
return doParseInsertSql(pSql, pSql->sqlstr + index);
|
return doParseInsertSql(pSql, pSql->sqlstr + index);
|
||||||
}
|
}
|
||||||
|
|
||||||
int tsParseSql(SSqlObj *pSql, bool multiVnodeInsertion) {
|
int tsParseSql(SSqlObj *pSql, bool initalParse) {
|
||||||
int32_t ret = TSDB_CODE_SUCCESS;
|
int32_t ret = TSDB_CODE_SUCCESS;
|
||||||
tscTrace("continue parse sql: %s", pSql->asyncTblPos);
|
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
|
* 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)
|
* 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;
|
pSql->fetchFp = pSql->fp;
|
||||||
|
|
||||||
// replace user defined callback function with multi-insert proxy function
|
// replace user defined callback function with multi-insert proxy function
|
||||||
|
@ -1311,7 +1311,13 @@ int tsParseSql(SSqlObj *pSql, bool multiVnodeInsertion) {
|
||||||
ret = tsParseInsertSql(pSql);
|
ret = tsParseInsertSql(pSql);
|
||||||
} else {
|
} else {
|
||||||
ret = tscAllocPayload(&pSql->cmd, TSDB_DEFAULT_PAYLOAD_SIZE);
|
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};
|
SSqlInfo SQLInfo = {0};
|
||||||
tSQLParse(&SQLInfo, pSql->sqlstr);
|
tSQLParse(&SQLInfo, pSql->sqlstr);
|
||||||
|
|
|
@ -497,6 +497,7 @@ int32_t tscToSQLCmd(SSqlObj* pSql, struct SSqlInfo* pInfo) {
|
||||||
}
|
}
|
||||||
|
|
||||||
} else if (pCreateTable->type == TSQL_CREATE_TABLE_FROM_STABLE) {
|
} else if (pCreateTable->type == TSQL_CREATE_TABLE_FROM_STABLE) {
|
||||||
|
assert(pCmd->numOfCols == 0);
|
||||||
if ((code = doCheckForCreateFromStable(pSql, pInfo)) != TSDB_CODE_SUCCESS) {
|
if ((code = doCheckForCreateFromStable(pSql, pInfo)) != TSDB_CODE_SUCCESS) {
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1225,7 +1225,6 @@ int tscBuildCreateTableMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
|
||||||
SCreateTableSQL *pCreateTable = pInfo->pCreateTableInfo;
|
SCreateTableSQL *pCreateTable = pInfo->pCreateTableInfo;
|
||||||
|
|
||||||
pCreateTableMsg->igExists = pCreateTable->existCheck ? 1 : 0;
|
pCreateTableMsg->igExists = pCreateTable->existCheck ? 1 : 0;
|
||||||
|
|
||||||
pCreateTableMsg->numOfColumns = htons(pCmd->numOfCols);
|
pCreateTableMsg->numOfColumns = htons(pCmd->numOfCols);
|
||||||
pCreateTableMsg->numOfTags = htons(pCmd->count);
|
pCreateTableMsg->numOfTags = htons(pCmd->count);
|
||||||
|
|
||||||
|
|
|
@ -394,6 +394,10 @@ void tscDestroyResPointerInfo(SSqlRes* pRes) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void tscFreeSqlCmdData(SSqlCmd* pCmd) {
|
void tscFreeSqlCmdData(SSqlCmd* pCmd) {
|
||||||
|
pCmd->command = 0;
|
||||||
|
pCmd->numOfCols = 0;
|
||||||
|
pCmd->count = 0;
|
||||||
|
|
||||||
pCmd->pDataBlocks = tscDestroyBlockArrayList(pCmd->pDataBlocks);
|
pCmd->pDataBlocks = tscDestroyBlockArrayList(pCmd->pDataBlocks);
|
||||||
tscFreeSubqueryInfo(pCmd);
|
tscFreeSubqueryInfo(pCmd);
|
||||||
}
|
}
|
||||||
|
@ -454,9 +458,7 @@ void tscFreeSqlObjPartial(SSqlObj* pSql) {
|
||||||
cmd == TSDB_SQL_METRIC_JOIN_RETRIEVE) {
|
cmd == TSDB_SQL_METRIC_JOIN_RETRIEVE) {
|
||||||
tscRemoveFromSqlList(pSql);
|
tscRemoveFromSqlList(pSql);
|
||||||
}
|
}
|
||||||
|
|
||||||
pCmd->command = 0;
|
|
||||||
|
|
||||||
// pSql->sqlstr will be used by tscBuildQueryStreamDesc
|
// pSql->sqlstr will be used by tscBuildQueryStreamDesc
|
||||||
pthread_mutex_lock(&pObj->mutex);
|
pthread_mutex_lock(&pObj->mutex);
|
||||||
tfree(pSql->sqlstr);
|
tfree(pSql->sqlstr);
|
||||||
|
@ -1899,7 +1901,6 @@ void tscFreeSubqueryInfo(SSqlCmd* pCmd) {
|
||||||
|
|
||||||
for (int32_t i = 0; i < pCmd->numOfClause; ++i) {
|
for (int32_t i = 0; i < pCmd->numOfClause; ++i) {
|
||||||
char* addr = (char*)pCmd - offsetof(SSqlObj, cmd);
|
char* addr = (char*)pCmd - offsetof(SSqlObj, cmd);
|
||||||
|
|
||||||
SQueryInfo* pQueryInfo = tscGetQueryInfoDetail(pCmd, i);
|
SQueryInfo* pQueryInfo = tscGetQueryInfoDetail(pCmd, i);
|
||||||
|
|
||||||
doClearSubqueryInfo(pQueryInfo);
|
doClearSubqueryInfo(pQueryInfo);
|
||||||
|
|
Loading…
Reference in New Issue