fix nested query bug
This commit is contained in:
parent
35b82a644f
commit
16fe1e27bf
|
@ -2717,10 +2717,19 @@ void tscHandleSubqueryError(SRetrieveSupport *trsupport, SSqlObj *pSql, int numO
|
|||
if (!TSDB_QUERY_HAS_TYPE(pQueryInfo->type, TSDB_QUERY_TYPE_JOIN_SEC_STAGE)) {
|
||||
|
||||
int32_t code = pParentSql->res.code;
|
||||
SSqlObj *userSql = ((SRetrieveSupport*)pParentSql->param)->pParentSql;
|
||||
SSqlObj *userSql = NULL;
|
||||
if (pParentSql->param) {
|
||||
userSql = ((SRetrieveSupport*)pParentSql->param)->pParentSql;
|
||||
}
|
||||
|
||||
if (userSql == NULL) {
|
||||
userSql = pParentSql;
|
||||
}
|
||||
|
||||
if ((code == TSDB_CODE_TDB_INVALID_TABLE_ID || code == TSDB_CODE_VND_INVALID_VGROUP_ID) && userSql->retry < userSql->maxRetry) {
|
||||
tscFreeRetrieveSup(pParentSql);
|
||||
if (userSql != pParentSql) {
|
||||
tscFreeRetrieveSup(pParentSql);
|
||||
}
|
||||
|
||||
tscFreeSubobj(userSql);
|
||||
tfree(userSql->pSubs);
|
||||
|
|
|
@ -3747,8 +3747,7 @@ static void tscSubqueryCompleteCallback(void* param, TAOS_RES* tres, int code) {
|
|||
int32_t index = ps->subqueryIndex;
|
||||
bool ret = subAndCheckDone(pSql, pParentSql, index);
|
||||
|
||||
tfree(ps);
|
||||
pSql->param = NULL;
|
||||
tscFreeRetrieveSup(pSql);
|
||||
|
||||
if (!ret) {
|
||||
tscDebug("0x%"PRIx64" sub:0x%"PRIx64" orderOfSub:%d completed, not all subquery finished", pParentSql->self, pSql->self, index);
|
||||
|
@ -3758,41 +3757,37 @@ static void tscSubqueryCompleteCallback(void* param, TAOS_RES* tres, int code) {
|
|||
// todo refactor
|
||||
tscDebug("0x%"PRIx64" all subquery response received, retry", pParentSql->self);
|
||||
|
||||
SSqlObj *userSql = ((SRetrieveSupport*)pParentSql->param)->pParentSql;
|
||||
|
||||
tscFreeRetrieveSup(pParentSql);
|
||||
|
||||
if (code && !((code == TSDB_CODE_TDB_INVALID_TABLE_ID || code == TSDB_CODE_VND_INVALID_VGROUP_ID) && userSql->retry < userSql->maxRetry)) {
|
||||
if (code && !((code == TSDB_CODE_TDB_INVALID_TABLE_ID || code == TSDB_CODE_VND_INVALID_VGROUP_ID) && pParentSql->retry < pParentSql->maxRetry)) {
|
||||
tscAsyncResultOnError(pParentSql);
|
||||
return;
|
||||
}
|
||||
|
||||
tscFreeSubobj(userSql);
|
||||
tfree(userSql->pSubs);
|
||||
tscFreeSubobj(pParentSql);
|
||||
tfree(pParentSql->pSubs);
|
||||
|
||||
userSql->res.code = TSDB_CODE_SUCCESS;
|
||||
userSql->retry++;
|
||||
pParentSql->res.code = TSDB_CODE_SUCCESS;
|
||||
pParentSql->retry++;
|
||||
|
||||
tscDebug("0x%"PRIx64" retry parse sql and send query, prev error: %s, retry:%d", userSql->self,
|
||||
tstrerror(code), userSql->retry);
|
||||
tscDebug("0x%"PRIx64" retry parse sql and send query, prev error: %s, retry:%d", pParentSql->self,
|
||||
tstrerror(code), pParentSql->retry);
|
||||
|
||||
|
||||
tscResetSqlCmd(&userSql->cmd, true);
|
||||
tscResetSqlCmd(&pParentSql->cmd, true);
|
||||
|
||||
code = tsParseSql(userSql, true);
|
||||
code = tsParseSql(pParentSql, true);
|
||||
if (code == TSDB_CODE_TSC_ACTION_IN_PROGRESS) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
userSql->res.code = code;
|
||||
tscAsyncResultOnError(userSql);
|
||||
pParentSql->res.code = code;
|
||||
tscAsyncResultOnError(pParentSql);
|
||||
return;
|
||||
}
|
||||
|
||||
SQueryInfo *pQueryInfo = tscGetQueryInfo(&userSql->cmd);
|
||||
SQueryInfo *pQueryInfo = tscGetQueryInfo(&pParentSql->cmd);
|
||||
|
||||
executeQuery(userSql, pQueryInfo);
|
||||
executeQuery(pParentSql, pQueryInfo);
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue