diff --git a/src/kit/taosdemo/taosdemo.c b/src/kit/taosdemo/taosdemo.c index b669c75b45a79766e018ebda05452aa002e804de..6ab0ad95a466fedd7066ac34048e9a7ff704787e 100644 --- a/src/kit/taosdemo/taosdemo.c +++ b/src/kit/taosdemo/taosdemo.c @@ -1213,7 +1213,6 @@ static void fetchResult(TAOS_RES *res, threadInfo* pThreadInfo) { } int totalLen = 0; - char temp[16000]; // fetch the records row by row while((row = taos_fetch_row(res))) { @@ -1224,6 +1223,7 @@ static void fetchResult(TAOS_RES *res, threadInfo* pThreadInfo) { memset(databuf, 0, 100*1024*1024); } num_rows++; + char temp[16000] = {0}; int len = taos_print_row(temp, row, fields, num_fields); len += sprintf(temp + len, "\n"); //printf("query result:%s\n", temp); diff --git a/tests/examples/c/apitest.c b/tests/examples/c/apitest.c index 44d9d0cee6b8971f8208ae55798ef5e07b50a2ca..0f24df0f4767fe1cdace072425768473ffcaa88f 100644 --- a/tests/examples/c/apitest.c +++ b/tests/examples/c/apitest.c @@ -86,7 +86,7 @@ static int print_result(TAOS_RES* res, int blockFetch) { } } else { while ((row = taos_fetch_row(res))) { - char temp[256]; + char temp[256] = {0}; taos_print_row(temp, row, fields, num_fields); puts(temp); nRows++; @@ -391,10 +391,10 @@ void verify_prepare(TAOS* taos) { int rows = 0; int num_fields = taos_num_fields(result); TAOS_FIELD *fields = taos_fetch_fields(result); - char temp[256]; // fetch the records row by row while ((row = taos_fetch_row(result))) { + char temp[256] = {0}; rows++; taos_print_row(temp, row, fields, num_fields); printf("%s\n", temp); @@ -614,10 +614,10 @@ void verify_prepare2(TAOS* taos) { int rows = 0; int num_fields = taos_num_fields(result); TAOS_FIELD *fields = taos_fetch_fields(result); - char temp[256]; // fetch the records row by row while ((row = taos_fetch_row(result))) { + char temp[256] = {0}; rows++; taos_print_row(temp, row, fields, num_fields); printf("%s\n", temp); @@ -866,12 +866,10 @@ void verify_prepare3(TAOS* taos) { int rows = 0; int num_fields = taos_num_fields(result); TAOS_FIELD *fields = taos_fetch_fields(result); - char temp[256] = {0}; // fetch the records row by row while ((row = taos_fetch_row(result))) { - memset(temp, 0, sizeof(temp)/sizeof(temp[0])); - + char temp[256] = {0}; rows++; taos_print_row(temp, row, fields, num_fields); printf("%s\n", temp); diff --git a/tests/examples/c/demo.c b/tests/examples/c/demo.c index 0b1cd7b5d2d304a89656c98e88b2a620e16ae5a1..f8c69d0043591afa8f5e32e80bd35e9413e60e76 100644 --- a/tests/examples/c/demo.c +++ b/tests/examples/c/demo.c @@ -116,12 +116,12 @@ void Test(TAOS *taos, char *qstr, int index) { int rows = 0; int num_fields = taos_field_count(result); TAOS_FIELD *fields = taos_fetch_fields(result); - char temp[1024]; printf("num_fields = %d\n", num_fields); printf("select * from table, result:\n"); // fetch the records row by row while ((row = taos_fetch_row(result))) { + char temp[1024] = {0}; rows++; taos_print_row(temp, row, fields, num_fields); printf("%s\n", temp); diff --git a/tests/examples/c/prepare.c b/tests/examples/c/prepare.c index 13d71beea6156aa32677c20ccc2d222d28826b24..723b340a923c0bf326599e8090f8c6142a249053 100644 --- a/tests/examples/c/prepare.c +++ b/tests/examples/c/prepare.c @@ -184,10 +184,10 @@ int main(int argc, char *argv[]) int rows = 0; int num_fields = taos_num_fields(result); TAOS_FIELD *fields = taos_fetch_fields(result); - char temp[256]; // fetch the records row by row while ((row = taos_fetch_row(result))) { + char temp[256] = {0}; rows++; taos_print_row(temp, row, fields, num_fields); printf("%s\n", temp); diff --git a/tests/examples/c/subscribe.c b/tests/examples/c/subscribe.c index 1d3533fa5ee89f7425a9b0563e738b4e0703e6c8..ad12f0e7a55b0f471f249f92f30cf659c94586a5 100644 --- a/tests/examples/c/subscribe.c +++ b/tests/examples/c/subscribe.c @@ -14,8 +14,6 @@ void print_result(TAOS_RES* res, int blockFetch) { int num_fields = taos_num_fields(res); TAOS_FIELD* fields = taos_fetch_fields(res); int nRows = 0; - char buf[4096]; - if (blockFetch) { nRows = taos_fetch_block(res, &row); @@ -25,6 +23,7 @@ void print_result(TAOS_RES* res, int blockFetch) { //} } else { while ((row = taos_fetch_row(res))) { + char buf[4096] = {0}; taos_print_row(buf, row, fields, num_fields); puts(buf); nRows++;