diff --git a/tests/examples/c/apitest.c b/tests/examples/c/apitest.c index b2411d1212de3cb930ce6d7032e6b1f8ec0dcc5d..2961750efce3f1e746aa2e82ecb5160488065681 100644 --- a/tests/examples/c/apitest.c +++ b/tests/examples/c/apitest.c @@ -402,10 +402,6 @@ void verify_prepare(TAOS* taos) { taos_stmt_close(stmt); } - - - - void verify_prepare2(TAOS* taos) { TAOS_RES* result = taos_query(taos, "drop database if exists test;"); taos_free_result(result); @@ -531,10 +527,9 @@ void verify_prepare2(TAOS* taos) { params[9].is_null = is_null; params[9].num = 10; - - sql = "insert into ? values(?,?,?,?,?,?,?,?,?,?)"; + sql = "insert into ? (ts, b, v1, v2, v4, v8, f4, f8, bin, blob) values(?,?,?,?,?,?,?,?,?,?)"; code = taos_stmt_prepare(stmt, sql, 0); - if (code != 0){ + if (code != 0) { printf("\033[31mfailed to execute taos_stmt_prepare. code:0x%x\033[0m\n", code); } @@ -577,9 +572,8 @@ void verify_prepare2(TAOS* taos) { printf("\033[31mfailed to execute insert statement.\033[0m\n"); return; } - taos_stmt_close(stmt); - + taos_stmt_close(stmt); // query the records stmt = taos_stmt_init(taos); @@ -623,9 +617,16 @@ void verify_prepare2(TAOS* taos) { taos_free_result(result); taos_stmt_close(stmt); -} - + free(t8_len); + free(t16_len); + free(t32_len); + free(t64_len); + free(float_len); + free(double_len); + free(bin_len); + free(blob_len); +} void verify_prepare3(TAOS* taos) { TAOS_RES* result = taos_query(taos, "drop database if exists test;"); @@ -810,7 +811,6 @@ void verify_prepare3(TAOS* taos) { blob_len[i] = (int32_t)strlen(v.blob[i]); } - taos_stmt_bind_param_batch(stmt, params); taos_stmt_add_batch(stmt); @@ -852,10 +852,12 @@ 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]; + char temp[256] = {0}; // fetch the records row by row while ((row = taos_fetch_row(result))) { + memset(temp, 0, sizeof(temp)/sizeof(temp[0])); + rows++; taos_print_row(temp, row, fields, num_fields); printf("%s\n", temp); @@ -863,9 +865,16 @@ void verify_prepare3(TAOS* taos) { taos_free_result(result); taos_stmt_close(stmt); -} - + free(t8_len); + free(t16_len); + free(t32_len); + free(t64_len); + free(float_len); + free(double_len); + free(bin_len); + free(blob_len); +} void retrieve_callback(void *param, TAOS_RES *tres, int numOfRows) {