taos_fetch_row cannot be called before the query callback ends.
This commit is contained in:
parent
c95c567376
commit
d17d51194f
|
@ -273,6 +273,7 @@ typedef struct SRequestObj {
|
|||
bool killed;
|
||||
bool inRetry;
|
||||
bool isSubReq;
|
||||
bool inCallback;
|
||||
uint32_t prevCode; // previous error code: todo refactor, add update flag for catalog
|
||||
uint32_t retry;
|
||||
int64_t allocatorRefId;
|
||||
|
|
|
@ -2607,7 +2607,9 @@ void taosAsyncFetchImpl(SRequestObj* pRequest, __taos_async_fn_t fp, void* param
|
|||
}
|
||||
|
||||
void doRequestCallback(SRequestObj* pRequest, int32_t code) {
|
||||
pRequest->inCallback = true;
|
||||
pRequest->body.queryFp(((SSyncQueryParam *)pRequest->body.interParam)->userParam, pRequest, code);
|
||||
pRequest->inCallback = false;
|
||||
}
|
||||
|
||||
int32_t clientParseSql(void* param, const char* dbName, const char* sql, bool parseOnly, const char* effectiveUser, SParseSqlRes* pRes) {
|
||||
|
|
|
@ -418,6 +418,12 @@ TAOS_ROW taos_fetch_row(TAOS_RES *res) {
|
|||
return NULL;
|
||||
}
|
||||
|
||||
if(pRequest->inCallback) {
|
||||
tscError("can not call taos_fetch_row before query callback ends.");
|
||||
terrno = TSDB_CODE_TSC_INVALID_OPERATION;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return doAsyncFetchRows(pRequest, true, true);
|
||||
} else if (TD_RES_TMQ(res) || TD_RES_TMQ_METADATA(res)) {
|
||||
SMqRspObj *msg = ((SMqRspObj *)res);
|
||||
|
|
|
@ -190,10 +190,12 @@ void queryCallback2(void* param, void* res, int32_t code) {
|
|||
ASSERT_TRUE(param == pUserParam);
|
||||
// After using taos_query_a to query, using taos_fetch_row in the callback will cause blocking.
|
||||
// Reason: schProcessOnCbBegin SCH_LOCK_TASK(pTask)
|
||||
/* TAOS_ROW row;
|
||||
while ((row = taos_fetch_row(res))) {
|
||||
getRecordCounts++;
|
||||
} */
|
||||
TAOS_ROW row;
|
||||
row = taos_fetch_row(res);
|
||||
ASSERT_TRUE(row == NULL);
|
||||
int* errCode = taosGetErrno();
|
||||
ASSERT_TRUE(*errCode = TSDB_CODE_TSC_INVALID_OPERATION);
|
||||
|
||||
tsem_post(&query_sem);
|
||||
taos_free_result(res);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue