提交 9c4343b1 编写于 作者: D dingbo

test: add async query example for C to CI

上级 41355a99
...@@ -172,7 +172,7 @@ Query OK, 5 row(s) in set (0.001521s) ...@@ -172,7 +172,7 @@ Query OK, 5 row(s) in set (0.001521s)
<TabItem label="C#" value="csharp"> <TabItem label="C#" value="csharp">
<CsAsync /> <CsAsync />
</TabItem> </TabItem>
{/* <TabItem label="C" value="c"> <TabItem label="C" value="c">
<CAsync /> <CAsync />
</TabItem> */} </TabItem>
</Tabs> </Tabs>
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <sys/time.h>
#include <taos.h> #include <taos.h>
typedef int16_t VarDataLenT; typedef int16_t VarDataLenT;
...@@ -132,6 +133,7 @@ void *fetch_row_callback(void *param, TAOS_RES *res, int numOfRow) { ...@@ -132,6 +133,7 @@ void *fetch_row_callback(void *param, TAOS_RES *res, int numOfRow) {
} }
taos_fetch_rows_a(res, fetch_row_callback, _taos); taos_fetch_rows_a(res, fetch_row_callback, _taos);
} else { } else {
printf("no more data, close the connection.\n");
taos_free_result(res); taos_free_result(res);
taos_close(_taos); taos_close(_taos);
taos_cleanup(); taos_cleanup();
...@@ -173,7 +175,7 @@ int main() { ...@@ -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 // 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. // here, because we want to close it after getting data.
taos_query_a(taos, "SELECT * FROM meters", select_callback, taos); taos_query_a(taos, "SELECT * FROM meters", select_callback, taos);
getchar(); sleep(1);
} }
// output: // output:
...@@ -189,4 +191,5 @@ int main() { ...@@ -189,4 +191,5 @@ int main() {
// 1538548685000 10.800000 223 0.290000 beijing.haidian 3 // 1538548685000 10.800000 223 0.290000 beijing.haidian 3
// 1538548686500 11.500000 221 0.350000 beijing.haidian 3 // 1538548686500 11.500000 221 0.350000 beijing.haidian 3
// numOfRow = 0 // numOfRow = 0
// no more data, close the connection.
// ANCHOR_END: demo // ANCHOR_END: demo
\ No newline at end of file
...@@ -11,6 +11,9 @@ cd ../../docs-examples/c ...@@ -11,6 +11,9 @@ cd ../../docs-examples/c
gcc connect_example.c -o connect_example -ltaos gcc connect_example.c -o connect_example -ltaos
./connect_example ./connect_example
gcc -o async_query_example async_query_example.c -ltaos
./async_query_example
# 2 # 2
taos -s "drop database if exists power" taos -s "drop database if exists power"
gcc -o insert_example insert_example.c -ltaos gcc -o insert_example insert_example.c -ltaos
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册