From 9c4343b14818f387bc8447f4be303143cd5740c0 Mon Sep 17 00:00:00 2001 From: dingbo Date: Thu, 28 Apr 2022 17:16:01 +0800 Subject: [PATCH] test: add async query example for C to CI --- docs-cn/04-develop/04-query-data/index.mdx | 4 ++-- docs-examples/c/async_query_example.c | 5 ++++- tests/docs-examples-test/test_c.sh | 3 +++ 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/docs-cn/04-develop/04-query-data/index.mdx b/docs-cn/04-develop/04-query-data/index.mdx index 2185d6a3d8..829280fba5 100644 --- a/docs-cn/04-develop/04-query-data/index.mdx +++ b/docs-cn/04-develop/04-query-data/index.mdx @@ -172,7 +172,7 @@ Query OK, 5 row(s) in set (0.001521s) - {/* + - */} + diff --git a/docs-examples/c/async_query_example.c b/docs-examples/c/async_query_example.c index c45e5de39d..77002891bb 100644 --- a/docs-examples/c/async_query_example.c +++ b/docs-examples/c/async_query_example.c @@ -5,6 +5,7 @@ #include #include #include +#include #include typedef int16_t VarDataLenT; @@ -132,6 +133,7 @@ void *fetch_row_callback(void *param, TAOS_RES *res, int numOfRow) { } taos_fetch_rows_a(res, fetch_row_callback, _taos); } else { + printf("no more data, close the connection.\n"); taos_free_result(res); taos_close(_taos); taos_cleanup(); @@ -173,7 +175,7 @@ int main() { // param four can be any pointer. It will be passed to your callback function as the first parameter. we use taos // here, because we want to close it after getting data. taos_query_a(taos, "SELECT * FROM meters", select_callback, taos); - getchar(); + sleep(1); } // output: @@ -189,4 +191,5 @@ int main() { // 1538548685000 10.800000 223 0.290000 beijing.haidian 3 // 1538548686500 11.500000 221 0.350000 beijing.haidian 3 // numOfRow = 0 +// no more data, close the connection. // ANCHOR_END: demo \ No newline at end of file diff --git a/tests/docs-examples-test/test_c.sh b/tests/docs-examples-test/test_c.sh index 520f795f09..06813795b9 100755 --- a/tests/docs-examples-test/test_c.sh +++ b/tests/docs-examples-test/test_c.sh @@ -11,6 +11,9 @@ cd ../../docs-examples/c gcc connect_example.c -o connect_example -ltaos ./connect_example +gcc -o async_query_example async_query_example.c -ltaos +./async_query_example + # 2 taos -s "drop database if exists power" gcc -o insert_example insert_example.c -ltaos -- GitLab