diff --git a/src/client/src/tscUtil.c b/src/client/src/tscUtil.c index 11b51f97bd4b6b0278d6a7825a15bfe80f60649a..15ae41f9b408c1d6c6780d6363b4d3d050e923af 100644 --- a/src/client/src/tscUtil.c +++ b/src/client/src/tscUtil.c @@ -4236,7 +4236,8 @@ void executeQuery(SSqlObj* pSql, SQueryInfo* pQueryInfo) { tscAddIntoSqlList(pSql); } - if (taosArrayGetSize(pQueryInfo->pUpstream) > 0) { // nest query. do execute it firstly + // upstream may be freed before retry + if (pQueryInfo->pUpstream && taosArrayGetSize(pQueryInfo->pUpstream) > 0) { // nest query. do execute it firstly code = doInitSubState(pSql, (int32_t) taosArrayGetSize(pQueryInfo->pUpstream)); if (code != TSDB_CODE_SUCCESS) { goto _error;