diff --git a/src/rpc/src/rpcMain.c b/src/rpc/src/rpcMain.c index f60c68608946dd11b78abf09518c31ee2c624afe..8dbbb97a1af438049adb40c12b2b6bec466dcb6e 100755 --- a/src/rpc/src/rpcMain.c +++ b/src/rpc/src/rpcMain.c @@ -1100,10 +1100,6 @@ static void rpcProcessConnError(void *param, void *id) { SRpcInfo *pRpc = pContext->pRpc; SRpcMsg rpcMsg; - if (pRpc == NULL) { - return; - } - tTrace("%s connection error happens", pRpc->label); if ( pContext->numOfTry >= pContext->ipSet.numOfIps ) { diff --git a/tests/examples/c/demo.c b/tests/examples/c/demo.c index b621781a3c81e4155841ac5d4ec31aae6a38518e..ddca1ac05d97617cdf718e5f0a2e5ed9e8c035a7 100644 --- a/tests/examples/c/demo.c +++ b/tests/examples/c/demo.c @@ -24,6 +24,29 @@ void taosMsleep(int mseconds); +static int32_t doQuery(TAOS* taos, const char* sql) { + int32_t code = taos_query(taos, sql); + if (code != 0) { + printf("failed to execute query, reason:%s\n", taos_errstr(taos)); + return -1; + } + + TAOS_RES* res = taos_use_result(taos); + TAOS_ROW row = NULL; + char buf[512] = {0}; + + int32_t numOfFields = taos_num_fields(res); + TAOS_FIELD* pFields = taos_fetch_fields(res); + + while((row = taos_fetch_row(res)) != NULL) { + taos_print_row(buf, row, pFields, numOfFields); + printf("%s\n", buf); + memset(buf, 0, 512); + } + + taos_free_result(res); +} + int main(int argc, char *argv[]) { TAOS * taos; char qstr[1024]; @@ -35,7 +58,7 @@ int main(int argc, char *argv[]) { return 0; } - taos_options(TSDB_OPTION_CONFIGDIR, "~/first/cfg"); + taos_options(TSDB_OPTION_CONFIGDIR, "~/sec/cfg"); // init TAOS taos_init(); @@ -45,25 +68,16 @@ int main(int argc, char *argv[]) { exit(1); } printf("success to connect to server\n"); - -// int32_t code = taos_query(taos, "insert into test.tm2 values(now, 1)(now+1m,2)(now+2m,3) (now+3m, 4) (now+4m, 5);"); - int32_t code = taos_query(taos, "insert into test.tm2 values(now, 99)"); - if (code != 0) { - printf("failed to execute query, reason:%s\n", taos_errstr(taos)); - } - - TAOS_RES* res = taos_use_result(taos); - TAOS_ROW row = NULL; - char buf[512] = {0}; - int32_t numOfFields = taos_num_fields(res); - TAOS_FIELD* pFields = taos_fetch_fields(res); - - while((row = taos_fetch_row(res)) != NULL) { - taos_print_row(buf, row, pFields, numOfFields); - printf("%s\n", buf); - memset(buf, 0, 512); - } + doQuery(taos, "create database if not exists test"); + doQuery(taos, "use test"); + doQuery(taos, "create table if not exists tm0 (ts timestamp, k int);"); + doQuery(taos, "insert into tm0 values(now, 1)(now+1s, 2)(now+2s, 3)(now+3s, 4);"); + doQuery(taos, "select * from tm0;"); +// doQuery(taos, "insert into tm01 values(now, 1)(now+1s, 2)(now+2s, 3)(now+3s, 4);"); +// doQuery(taos, "insert into tm0 values(now, 1)(now+1s, 2)(now+2s, 3)(now+3s, 4);"); +// doQuery(taos, "insert into tm0 values(now, 1)(now+1s, 2)(now+2s, 3)(now+3s, 4);"); +// doQuery(taos, "insert into tm0 values(now, 1)(now+1s, 2)(now+2s, 3)(now+3s, 4);"); taos_close(taos); @@ -119,14 +133,7 @@ int main(int argc, char *argv[]) { int num_fields = taos_field_count(taos); TAOS_FIELD *fields = taos_fetch_fields(result); char temp[256]; - - printf("select * from table, result:\n"); - // fetch the records row by row - while ((row = taos_fetch_row(result))) { - rows++; - taos_print_row(temp, row, fields, num_fields); - printf("%s\n", temp); - } + taos_free_result(result); printf("====demo end====\n\n");