提交 057df325 编写于 作者: H Haojun Liao

[td-225] fix invalid write

上级 acbe0ff7
...@@ -94,7 +94,7 @@ void tscSaveSlowQuery(SSqlObj *pSql) { ...@@ -94,7 +94,7 @@ void tscSaveSlowQuery(SSqlObj *pSql) {
tscTrace("%p query time:%" PRId64 " sql:%s", pSql, pSql->res.useconds, pSql->sqlstr); tscTrace("%p query time:%" PRId64 " sql:%s", pSql, pSql->res.useconds, pSql->sqlstr);
char *sql = malloc(200); 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); pSql->pTscObj->user, pSql->stime, pSql->res.useconds);
int sqlLen = snprintf(sql + len, TSDB_SHOW_SQL_LEN, "%s", pSql->sqlstr); int sqlLen = snprintf(sql + len, TSDB_SHOW_SQL_LEN, "%s", pSql->sqlstr);
if (sqlLen > TSDB_SHOW_SQL_LEN - 1) { if (sqlLen > TSDB_SHOW_SQL_LEN - 1) {
......
...@@ -26,13 +26,12 @@ ...@@ -26,13 +26,12 @@
void taosMsleep(int mseconds); void taosMsleep(int mseconds);
static int32_t doQuery(TAOS* taos, const char* sql) { static int32_t doQuery(TAOS* taos, const char* sql) {
int32_t code = taos_query(taos, sql); TAOS_RES* res = taos_query(taos, sql);
if (code != 0) { if (taos_errno(res) != 0) {
printf("failed to execute query, reason:%s\n", taos_errstr(taos)); printf("failed to execute query, reason:%s\n", taos_errstr(taos));
return -1; return -1;
} }
TAOS_RES* res = taos_use_result(taos);
TAOS_ROW row = NULL; TAOS_ROW row = NULL;
char buf[512] = {0}; char buf[512] = {0};
...@@ -46,7 +45,6 @@ static int32_t doQuery(TAOS* taos, const char* sql) { ...@@ -46,7 +45,6 @@ static int32_t doQuery(TAOS* taos, const char* sql) {
} }
taos_free_result(res); taos_free_result(res);
return 0; return 0;
} }
...@@ -81,6 +79,7 @@ static __attribute__((unused)) void multiThreadTest(int32_t numOfThreads, void* ...@@ -81,6 +79,7 @@ static __attribute__((unused)) void multiThreadTest(int32_t numOfThreads, void*
pthread_join(threadId[i], NULL); pthread_join(threadId[i], NULL);
} }
free(threadId);
pthread_attr_destroy(&thattr); pthread_attr_destroy(&thattr);
} }
...@@ -108,24 +107,11 @@ int main(int argc, char *argv[]) { ...@@ -108,24 +107,11 @@ int main(int argc, char *argv[]) {
printf("success to connect to server\n"); printf("success to connect to server\n");
// multiThreadTest(1, taos); // 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) { // for(int32_t i = 0; i < 100000; ++i) {
// doQuery(taos, "insert into t1 values(now, 2)"); // doQuery(taos, "insert into t1 values(now, 2)");
// } // }
// doQuery(taos, "create table t1(ts timestamp, k binary(12), f nchar(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); taos_close(taos);
return 0; return 0;
...@@ -172,10 +158,6 @@ int main(int argc, char *argv[]) { ...@@ -172,10 +158,6 @@ int main(int argc, char *argv[]) {
exit(1); exit(1);
} }
result = taos_use_result(taos);
if (result == NULL) { if (result == NULL) {
printf("failed to get result, reason:%s\n", taos_errstr(taos)); printf("failed to get result, reason:%s\n", taos_errstr(taos));
exit(1); exit(1);
......
...@@ -40,45 +40,47 @@ ...@@ -40,45 +40,47 @@
#run general/parser/nchar.sim #run general/parser/nchar.sim
#sleep 2000 #sleep 2000
##run general/parser/null_char.sim ##run general/parser/null_char.sim
sleep 2000 #sleep 2000
run general/parser/single_row_in_tb.sim #run general/parser/single_row_in_tb.sim
sleep 2000 #sleep 2000
run general/parser/select_from_cache_disk.sim #run general/parser/select_from_cache_disk.sim
sleep 2000 #sleep 2000
run general/parser/selectResNum.sim #run general/parser/selectResNum.sim
sleep 2000 #sleep 2000
run general/parser/mixed_blocks.sim #run general/parser/mixed_blocks.sim
sleep 2000 #sleep 2000
run general/parser/limit1.sim #run general/parser/limit1.sim
sleep 2000 #sleep 2000
run general/parser/limit.sim #run general/parser/limit.sim
sleep 2000 #sleep 2000
run general/parser/limit1_tblocks100.sim #run general/parser/limit1_tblocks100.sim
sleep 2000 #sleep 2000
run general/parser/select_across_vnodes.sim #run general/parser/select_across_vnodes.sim
sleep 2000 #sleep 2000
run general/parser/slimit1.sim #run general/parser/slimit1.sim
sleep 2000 #sleep 2000
run general/parser/tbnameIn.sim #run general/parser/tbnameIn.sim
sleep 2000 #sleep 2000
run general/parser/projection_limit_offset.sim run general/parser/projection_limit_offset.sim
sleep 2000 sleep 2000
run general/parser/limit2.sim run general/parser/limit2.sim
sleep 2000 sleep 2000
run general/parser/fill.sim #run general/parser/fill.sim
sleep 2000 #sleep 2000
run general/parser/fill_stb.sim #run general/parser/fill_stb.sim
sleep 2000 #sleep 2000
run general/parser/where.sim #run general/parser/where.sim
sleep 2000 #sleep 2000
run general/parser/slimit.sim #run general/parser/slimit.sim
#sleep 2000
#run general/parser/select_with_tags.sim
#sleep 2000
#run general/parser/interp.sim
sleep 2000 sleep 2000
run general/parser/select_with_tags.sim run general/parser/tags_dynamically_specifiy.sim
sleep 2000 sleep 2000
run general/parser/interp.sim run general/parser/groupby.sim
sleep 2000
run general/parser/tags_dynamically_specifiy.sim
sleep 2000 sleep 2000
run general/parser/set_tag_vals.sim run general/parser/set_tag_vals.sim
...@@ -97,9 +99,6 @@ sleep 2000 ...@@ -97,9 +99,6 @@ sleep 2000
run general/parser/join.sim run general/parser/join.sim
sleep 2000 sleep 2000
run general/parser/join_multivnode.sim run general/parser/join_multivnode.sim
sleep 2000
run general/parser/groupby.sim
sleep 2000 sleep 2000
run general/parser/binary_escapeCharacter.sim run general/parser/binary_escapeCharacter.sim
sleep 2000 sleep 2000
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册