From 7b0db0df9cbfc89ad98e3dc9539413cdfa0fb9b8 Mon Sep 17 00:00:00 2001 From: Ganlin Zhao Date: Fri, 7 Jan 2022 13:11:57 +0800 Subject: [PATCH] [TD-12723](query): add taos_result_block api for taosAdaptor ulimited pulling function --- src/client/src/tscSql.c | 22 ++++++++++++++++++++++ src/inc/taos.h | 1 + 2 files changed, 23 insertions(+) diff --git a/src/client/src/tscSql.c b/src/client/src/tscSql.c index 49711b6dee..00a795c547 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 2b74f9c184..ea8e1d9dad 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); -- GitLab