From a7e7b8e21e6733d4b0acc0d4c6ab7288378d65ec Mon Sep 17 00:00:00 2001 From: chang Date: Wed, 3 Jun 2020 11:17:31 +0800 Subject: [PATCH] test: importOneRow --- tests/test/c/importOneRow.c | 45 ++++++++++++++++++++++++++++++++----- 1 file changed, 39 insertions(+), 6 deletions(-) diff --git a/tests/test/c/importOneRow.c b/tests/test/c/importOneRow.c index 902cf46c3a..0690d89837 100644 --- a/tests/test/c/importOneRow.c +++ b/tests/test/c/importOneRow.c @@ -122,10 +122,26 @@ void* taos_execute(void *param) { int64_t timestamp = 1530374400000L; sprintf(sql, "insert into db.t%d values(%ld, %d, %d, %d)", pThread->index, timestamp, 0, 0, 0); - int code = taos_query(taos, sql); - if (code != 0) printf("error code:%d, sql:%s\n", code, sql); + TAOS_RES *pSql = taos_query(taos, sql); + int code = taos_errno(pSql); + if (code != 0) + { + printf("error code:%d, sql:%s\n", code, sql); + taos_free_result(pSql); + taos_close(taos); + return NULL; + } int affectrows = taos_affected_rows(taos); - if (affectrows != 1) printf("affect rows:%d, sql:%s\n", affectrows, sql); + if (affectrows != 1) + { + printf("affect rows:%d, sql:%s\n", affectrows, sql); + taos_free_result(pSql); + taos_close(taos); + return NULL; + } + taos_free_result(pSql); + pSql = NULL; + timestamp -= 1000; @@ -133,17 +149,34 @@ void* taos_execute(void *param) { for (int i = 1; i < rowNum; ++i) { sprintf(sql, "import into db.t%d values(%ld, %d, %d, %d)", pThread->index, timestamp, i, i, i); - code = taos_query(taos, sql); - if (code != 0) printf("error code:%d, sql:%s\n", code, sql); + + pSql = taos_query(taos, sql); + code = taos_errno(pSql); + if (code != 0) + { + printf("error code:%d, sql:%s\n", code, sql); + taos_free_result(pSql); + pSql = NULL; + taos_close(taos); + return NULL; + } int affectrows = taos_affected_rows(taos); - if (affectrows != 1) printf("affect rows:%d, sql:%s\n", affectrows, sql); + if (affectrows != 1) { + printf("affect rows:%d, sql:%s\n", affectrows, sql); + taos_free_result(pSql); + pSql = NULL; + taos_close(taos); + } total_affect_rows += affectrows; + taos_free_result(pSql); + pSql = NULL; timestamp -= 1000; } printf("thread:%d run finished total_affect_rows:%d\n", pThread->index, total_affect_rows); + taos_close(taos); return NULL; } -- GitLab