From 057df32571d8aef734e8662fabcf1b3d22544604 Mon Sep 17 00:00:00 2001 From: Haojun Liao Date: Tue, 2 Jun 2020 17:27:56 +0800 Subject: [PATCH] [td-225] fix invalid write --- src/client/src/tscProfile.c | 2 +- tests/examples/c/demo.c | 26 ++------- tests/script/general/parser/testSuite.sim | 69 +++++++++++------------ 3 files changed, 39 insertions(+), 58 deletions(-) diff --git a/src/client/src/tscProfile.c b/src/client/src/tscProfile.c index 74294d38e0..ee89b5f580 100644 --- a/src/client/src/tscProfile.c +++ b/src/client/src/tscProfile.c @@ -94,7 +94,7 @@ void tscSaveSlowQuery(SSqlObj *pSql) { tscTrace("%p query time:%" PRId64 " sql:%s", pSql, pSql->res.useconds, pSql->sqlstr); char *sql = malloc(200); - int len = snprintf(sql, 200, "insert into %s.slowquery values(now, '%s', %" PRId64 ", %" PRId64 ", '", tsMonitorDbName, + int len = snprintf(sql, 190, "insert into %s.slowquery values(now, '%s', %" PRId64 ", %" PRId64 ", '", tsMonitorDbName, pSql->pTscObj->user, pSql->stime, pSql->res.useconds); int sqlLen = snprintf(sql + len, TSDB_SHOW_SQL_LEN, "%s", pSql->sqlstr); if (sqlLen > TSDB_SHOW_SQL_LEN - 1) { diff --git a/tests/examples/c/demo.c b/tests/examples/c/demo.c index e27c73891f..e5746084e5 100644 --- a/tests/examples/c/demo.c +++ b/tests/examples/c/demo.c @@ -26,13 +26,12 @@ void taosMsleep(int mseconds); static int32_t doQuery(TAOS* taos, const char* sql) { - int32_t code = taos_query(taos, sql); - if (code != 0) { + TAOS_RES* res = taos_query(taos, sql); + if (taos_errno(res) != 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}; @@ -46,7 +45,6 @@ static int32_t doQuery(TAOS* taos, const char* sql) { } taos_free_result(res); - return 0; } @@ -81,6 +79,7 @@ static __attribute__((unused)) void multiThreadTest(int32_t numOfThreads, void* pthread_join(threadId[i], NULL); } + free(threadId); pthread_attr_destroy(&thattr); } @@ -108,24 +107,11 @@ int main(int argc, char *argv[]) { printf("success to connect to server\n"); // multiThreadTest(1, taos); - doQuery(taos, "select max(c1), min(c2), sum(c3), avg(c4), first(c7), last(c8), first(c9) from lm2_db0.lm2_stb0 where ts >= 1537146000000 and ts <= 1543145400000 interval(5m) fill(value, -1, -2) group by t1 limit 2 offset 10;"); + doQuery(taos, "insert into tb9 (ts, c1, c2) using stb (t1, t2) tags ('tag4', 4) values ( now + 4s, 'binary4', 4);"); // for(int32_t i = 0; i < 100000; ++i) { // doQuery(taos, "insert into t1 values(now, 2)"); // } // doQuery(taos, "create table t1(ts timestamp, k binary(12), f nchar(2))"); - -// doQuery(taos, "insert into tm0 values('2020-1-1 1:1:1', 'abc')"); -// doQuery(taos, "create table if not exists tm0 (ts timestamp, k int);"); -// doQuery(taos, "insert into tm0 values('2020-1-1 1:1:1', 1);"); -// doQuery(taos, "insert into tm0 values('2020-1-1 1:1:2', 2);"); -// doQuery(taos, "insert into tm0 values('2020-1-1 1:1:3', 3);"); -// doQuery(taos, "insert into tm0 values('2020-1-1 1:1:4', 4);"); -// doQuery(taos, "insert into tm0 values('2020-1-1 1:1:5', 5);"); -// doQuery(taos, "insert into tm0 values('2020-1-1 1:1:6', 6);"); -// doQuery(taos, "insert into tm0 values('2020-1-1 1:1:7', 7);"); -// doQuery(taos, "insert into tm0 values('2020-1-1 1:1:8', 8);"); -// doQuery(taos, "insert into tm0 values('2020-1-1 1:1:9', 9);"); -// doQuery(taos, "select sum(k),count(*) from m1 group by a"); taos_close(taos); return 0; @@ -172,10 +158,6 @@ int main(int argc, char *argv[]) { exit(1); } - - result = taos_use_result(taos); - - if (result == NULL) { printf("failed to get result, reason:%s\n", taos_errstr(taos)); exit(1); diff --git a/tests/script/general/parser/testSuite.sim b/tests/script/general/parser/testSuite.sim index cc95246f06..4a3da2f2a0 100644 --- a/tests/script/general/parser/testSuite.sim +++ b/tests/script/general/parser/testSuite.sim @@ -40,45 +40,47 @@ #run general/parser/nchar.sim #sleep 2000 ##run general/parser/null_char.sim -sleep 2000 -run general/parser/single_row_in_tb.sim -sleep 2000 -run general/parser/select_from_cache_disk.sim -sleep 2000 -run general/parser/selectResNum.sim -sleep 2000 -run general/parser/mixed_blocks.sim -sleep 2000 -run general/parser/limit1.sim -sleep 2000 -run general/parser/limit.sim -sleep 2000 -run general/parser/limit1_tblocks100.sim -sleep 2000 -run general/parser/select_across_vnodes.sim -sleep 2000 -run general/parser/slimit1.sim -sleep 2000 -run general/parser/tbnameIn.sim -sleep 2000 +#sleep 2000 +#run general/parser/single_row_in_tb.sim +#sleep 2000 +#run general/parser/select_from_cache_disk.sim +#sleep 2000 +#run general/parser/selectResNum.sim +#sleep 2000 +#run general/parser/mixed_blocks.sim +#sleep 2000 +#run general/parser/limit1.sim +#sleep 2000 +#run general/parser/limit.sim +#sleep 2000 +#run general/parser/limit1_tblocks100.sim +#sleep 2000 +#run general/parser/select_across_vnodes.sim +#sleep 2000 +#run general/parser/slimit1.sim +#sleep 2000 +#run general/parser/tbnameIn.sim +#sleep 2000 run general/parser/projection_limit_offset.sim sleep 2000 run general/parser/limit2.sim sleep 2000 -run general/parser/fill.sim -sleep 2000 -run general/parser/fill_stb.sim -sleep 2000 -run general/parser/where.sim -sleep 2000 -run general/parser/slimit.sim +#run general/parser/fill.sim +#sleep 2000 +#run general/parser/fill_stb.sim +#sleep 2000 +#run general/parser/where.sim +#sleep 2000 +#run general/parser/slimit.sim +#sleep 2000 +#run general/parser/select_with_tags.sim +#sleep 2000 +#run general/parser/interp.sim sleep 2000 -run general/parser/select_with_tags.sim +run general/parser/tags_dynamically_specifiy.sim sleep 2000 -run general/parser/interp.sim +run general/parser/groupby.sim -sleep 2000 -run general/parser/tags_dynamically_specifiy.sim sleep 2000 run general/parser/set_tag_vals.sim @@ -97,9 +99,6 @@ sleep 2000 run general/parser/join.sim sleep 2000 run general/parser/join_multivnode.sim - -sleep 2000 -run general/parser/groupby.sim sleep 2000 run general/parser/binary_escapeCharacter.sim sleep 2000 -- GitLab