提交 cc53777c 编写于 作者: J jiaoqiyuan

init array before use it.

上级 7f77f036
...@@ -1209,7 +1209,6 @@ static void fetchResult(TAOS_RES *res, threadInfo* pThreadInfo) { ...@@ -1209,7 +1209,6 @@ static void fetchResult(TAOS_RES *res, threadInfo* pThreadInfo) {
} }
int totalLen = 0; int totalLen = 0;
char temp[16000];
// fetch the records row by row // fetch the records row by row
while((row = taos_fetch_row(res))) { while((row = taos_fetch_row(res))) {
...@@ -1220,6 +1219,7 @@ static void fetchResult(TAOS_RES *res, threadInfo* pThreadInfo) { ...@@ -1220,6 +1219,7 @@ static void fetchResult(TAOS_RES *res, threadInfo* pThreadInfo) {
memset(databuf, 0, 100*1024*1024); memset(databuf, 0, 100*1024*1024);
} }
num_rows++; num_rows++;
char temp[16000] = {0};
int len = taos_print_row(temp, row, fields, num_fields); int len = taos_print_row(temp, row, fields, num_fields);
len += sprintf(temp + len, "\n"); len += sprintf(temp + len, "\n");
//printf("query result:%s\n", temp); //printf("query result:%s\n", temp);
......
...@@ -86,7 +86,7 @@ static int print_result(TAOS_RES* res, int blockFetch) { ...@@ -86,7 +86,7 @@ static int print_result(TAOS_RES* res, int blockFetch) {
} }
} else { } else {
while ((row = taos_fetch_row(res))) { while ((row = taos_fetch_row(res))) {
char temp[256]; char temp[256] = {0};
taos_print_row(temp, row, fields, num_fields); taos_print_row(temp, row, fields, num_fields);
puts(temp); puts(temp);
nRows++; nRows++;
...@@ -389,10 +389,10 @@ void verify_prepare(TAOS* taos) { ...@@ -389,10 +389,10 @@ void verify_prepare(TAOS* taos) {
int rows = 0; int rows = 0;
int num_fields = taos_num_fields(result); int num_fields = taos_num_fields(result);
TAOS_FIELD *fields = taos_fetch_fields(result); TAOS_FIELD *fields = taos_fetch_fields(result);
char temp[256];
// fetch the records row by row // fetch the records row by row
while ((row = taos_fetch_row(result))) { while ((row = taos_fetch_row(result))) {
char temp[256] = {0};
rows++; rows++;
taos_print_row(temp, row, fields, num_fields); taos_print_row(temp, row, fields, num_fields);
printf("%s\n", temp); printf("%s\n", temp);
...@@ -606,10 +606,10 @@ void verify_prepare2(TAOS* taos) { ...@@ -606,10 +606,10 @@ void verify_prepare2(TAOS* taos) {
int rows = 0; int rows = 0;
int num_fields = taos_num_fields(result); int num_fields = taos_num_fields(result);
TAOS_FIELD *fields = taos_fetch_fields(result); TAOS_FIELD *fields = taos_fetch_fields(result);
char temp[256];
// fetch the records row by row // fetch the records row by row
while ((row = taos_fetch_row(result))) { while ((row = taos_fetch_row(result))) {
char temp[256] = {0};
rows++; rows++;
taos_print_row(temp, row, fields, num_fields); taos_print_row(temp, row, fields, num_fields);
printf("%s\n", temp); printf("%s\n", temp);
...@@ -856,8 +856,7 @@ void verify_prepare3(TAOS* taos) { ...@@ -856,8 +856,7 @@ void verify_prepare3(TAOS* taos) {
// fetch the records row by row // fetch the records row by row
while ((row = taos_fetch_row(result))) { while ((row = taos_fetch_row(result))) {
memset(temp, 0, sizeof(temp)/sizeof(temp[0])); char temp[256] = {0};
rows++; rows++;
taos_print_row(temp, row, fields, num_fields); taos_print_row(temp, row, fields, num_fields);
printf("%s\n", temp); printf("%s\n", temp);
......
...@@ -116,12 +116,12 @@ void Test(TAOS *taos, char *qstr, int index) { ...@@ -116,12 +116,12 @@ void Test(TAOS *taos, char *qstr, int index) {
int rows = 0; int rows = 0;
int num_fields = taos_field_count(result); int num_fields = taos_field_count(result);
TAOS_FIELD *fields = taos_fetch_fields(result); TAOS_FIELD *fields = taos_fetch_fields(result);
char temp[1024];
printf("num_fields = %d\n", num_fields); printf("num_fields = %d\n", num_fields);
printf("select * from table, result:\n"); printf("select * from table, result:\n");
// fetch the records row by row // fetch the records row by row
while ((row = taos_fetch_row(result))) { while ((row = taos_fetch_row(result))) {
char temp[1024] = {0};
rows++; rows++;
taos_print_row(temp, row, fields, num_fields); taos_print_row(temp, row, fields, num_fields);
printf("%s\n", temp); printf("%s\n", temp);
......
...@@ -184,10 +184,10 @@ int main(int argc, char *argv[]) ...@@ -184,10 +184,10 @@ int main(int argc, char *argv[])
int rows = 0; int rows = 0;
int num_fields = taos_num_fields(result); int num_fields = taos_num_fields(result);
TAOS_FIELD *fields = taos_fetch_fields(result); TAOS_FIELD *fields = taos_fetch_fields(result);
char temp[256];
// fetch the records row by row // fetch the records row by row
while ((row = taos_fetch_row(result))) { while ((row = taos_fetch_row(result))) {
char temp[256] = {0};
rows++; rows++;
taos_print_row(temp, row, fields, num_fields); taos_print_row(temp, row, fields, num_fields);
printf("%s\n", temp); printf("%s\n", temp);
......
...@@ -14,8 +14,6 @@ void print_result(TAOS_RES* res, int blockFetch) { ...@@ -14,8 +14,6 @@ void print_result(TAOS_RES* res, int blockFetch) {
int num_fields = taos_num_fields(res); int num_fields = taos_num_fields(res);
TAOS_FIELD* fields = taos_fetch_fields(res); TAOS_FIELD* fields = taos_fetch_fields(res);
int nRows = 0; int nRows = 0;
char buf[4096];
if (blockFetch) { if (blockFetch) {
nRows = taos_fetch_block(res, &row); nRows = taos_fetch_block(res, &row);
...@@ -25,6 +23,7 @@ void print_result(TAOS_RES* res, int blockFetch) { ...@@ -25,6 +23,7 @@ void print_result(TAOS_RES* res, int blockFetch) {
//} //}
} else { } else {
while ((row = taos_fetch_row(res))) { while ((row = taos_fetch_row(res))) {
char buf[4096] = {0};
taos_print_row(buf, row, fields, num_fields); taos_print_row(buf, row, fields, num_fields);
puts(buf); puts(buf);
nRows++; nRows++;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册