提交 2e06575a 编写于 作者: H hjxilinx

[TD-98] fix a typo

上级 d8aa6d93
...@@ -1100,10 +1100,6 @@ static void rpcProcessConnError(void *param, void *id) { ...@@ -1100,10 +1100,6 @@ static void rpcProcessConnError(void *param, void *id) {
SRpcInfo *pRpc = pContext->pRpc; SRpcInfo *pRpc = pContext->pRpc;
SRpcMsg rpcMsg; SRpcMsg rpcMsg;
if (pRpc == NULL) {
return;
}
tTrace("%s connection error happens", pRpc->label); tTrace("%s connection error happens", pRpc->label);
if ( pContext->numOfTry >= pContext->ipSet.numOfIps ) { if ( pContext->numOfTry >= pContext->ipSet.numOfIps ) {
......
...@@ -24,6 +24,29 @@ ...@@ -24,6 +24,29 @@
void taosMsleep(int mseconds); 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[]) { int main(int argc, char *argv[]) {
TAOS * taos; TAOS * taos;
char qstr[1024]; char qstr[1024];
...@@ -35,7 +58,7 @@ int main(int argc, char *argv[]) { ...@@ -35,7 +58,7 @@ int main(int argc, char *argv[]) {
return 0; return 0;
} }
taos_options(TSDB_OPTION_CONFIGDIR, "~/first/cfg"); taos_options(TSDB_OPTION_CONFIGDIR, "~/sec/cfg");
// init TAOS // init TAOS
taos_init(); taos_init();
...@@ -45,25 +68,16 @@ int main(int argc, char *argv[]) { ...@@ -45,25 +68,16 @@ int main(int argc, char *argv[]) {
exit(1); exit(1);
} }
printf("success to connect to server\n"); 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); doQuery(taos, "create database if not exists test");
TAOS_FIELD* pFields = taos_fetch_fields(res); doQuery(taos, "use test");
doQuery(taos, "create table if not exists tm0 (ts timestamp, k int);");
while((row = taos_fetch_row(res)) != NULL) { doQuery(taos, "insert into tm0 values(now, 1)(now+1s, 2)(now+2s, 3)(now+3s, 4);");
taos_print_row(buf, row, pFields, numOfFields); doQuery(taos, "select * from tm0;");
printf("%s\n", buf); // doQuery(taos, "insert into tm01 values(now, 1)(now+1s, 2)(now+2s, 3)(now+3s, 4);");
memset(buf, 0, 512); // 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); taos_close(taos);
...@@ -119,14 +133,7 @@ int main(int argc, char *argv[]) { ...@@ -119,14 +133,7 @@ int main(int argc, char *argv[]) {
int num_fields = taos_field_count(taos); int num_fields = taos_field_count(taos);
TAOS_FIELD *fields = taos_fetch_fields(result); TAOS_FIELD *fields = taos_fetch_fields(result);
char temp[256]; 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); taos_free_result(result);
printf("====demo end====\n\n"); printf("====demo end====\n\n");
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册