diff --git a/src/client/src/tscSql.c b/src/client/src/tscSql.c index 49711b6dee2b257b60225e8acd25bbe6ee4b24dd..00a795c5474629c537d0825b0c7db998d7505ccb 100644 --- a/src/client/src/tscSql.c +++ b/src/client/src/tscSql.c @@ -547,6 +547,28 @@ int taos_fetch_block(TAOS_RES *res, TAOS_ROW *rows) { return pRes->numOfRows; } +TAOS_ROW *taos_result_block(TAOS_RES *res) { + SSqlObj *pSql = (SSqlObj *)res; + if (pSql == NULL || pSql->signature != pSql) { + terrno = TSDB_CODE_TSC_DISCONNECTED; + return NULL; + } + + SSqlCmd *pCmd = &pSql->cmd; + SSqlRes *pRes = &pSql->res; + + if (pCmd == NULL || + pRes == NULL || + pRes->qId == 0 || + pRes->code == TSDB_CODE_TSC_QUERY_CANCELLED || + pCmd->command == TSDB_SQL_RETRIEVE_EMPTY_RESULT || + pCmd->command == TSDB_SQL_INSERT) { + return NULL; + } + + return &pRes->urow; +} + int taos_select_db(TAOS *taos, const char *db) { char sql[256] = {0}; diff --git a/src/inc/taos.h b/src/inc/taos.h index 2b74f9c1844641ccef5ad1fb8e9d25a4d3262ecc..ea8e1d9dad61bdd513e8beded93d996ae66137dd 100644 --- a/src/inc/taos.h +++ b/src/inc/taos.h @@ -179,6 +179,7 @@ DLL_EXPORT bool taos_is_null(TAOS_RES *res, int32_t row, int32_t col); DLL_EXPORT bool taos_is_update_query(TAOS_RES *res); DLL_EXPORT int taos_fetch_block(TAOS_RES *res, TAOS_ROW *rows); DLL_EXPORT int* taos_fetch_lengths(TAOS_RES *res); +DLL_EXPORT TAOS_ROW *taos_result_block(TAOS_RES *res); DLL_EXPORT int taos_validate_sql(TAOS *taos, const char *sql); DLL_EXPORT void taos_reset_current_db(TAOS *taos);