From afa3c1298bfb492102b4a7715ea599d4c95d5dd9 Mon Sep 17 00:00:00 2001 From: dapan1121 Date: Fri, 10 Dec 2021 10:27:59 +0800 Subject: [PATCH] fix kill issue and add test case --- src/client/src/tscSQLParser.c | 8 +++++--- tests/pytest/stream/stream2.py | 6 +++++- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/client/src/tscSQLParser.c b/src/client/src/tscSQLParser.c index 0a4b7e9f78..9c80c8782e 100644 --- a/src/client/src/tscSQLParser.c +++ b/src/client/src/tscSQLParser.c @@ -3437,7 +3437,9 @@ int32_t setKillInfo(SSqlObj* pSql, struct SSqlInfo* pInfo, int32_t killType) { return TSDB_CODE_TSC_INVALID_OPERATION; } - strncpy(pCmd->payload, idStr->z, idStr->n); + SKillQueryMsg* msg = (SKillQueryMsg*)pCmd->payload; + + strncpy(msg->queryId, idStr->z, idStr->n); const char delim = ':'; char* connIdStr = strtok(idStr->z, &delim); @@ -3445,7 +3447,7 @@ int32_t setKillInfo(SSqlObj* pSql, struct SSqlInfo* pInfo, int32_t killType) { int32_t connId = (int32_t)strtol(connIdStr, NULL, 10); if (connId <= 0) { - memset(pCmd->payload, 0, strlen(pCmd->payload)); + memset(msg, 0, sizeof(*msg)); return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg1); } @@ -3455,7 +3457,7 @@ int32_t setKillInfo(SSqlObj* pSql, struct SSqlInfo* pInfo, int32_t killType) { int32_t queryId = (int32_t)strtol(queryIdStr, NULL, 10); if (queryId <= 0) { - memset(pCmd->payload, 0, strlen(pCmd->payload)); + memset(msg, 0, sizeof(*msg)); if (killType == TSDB_SQL_KILL_QUERY) { return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg2); } else { diff --git a/tests/pytest/stream/stream2.py b/tests/pytest/stream/stream2.py index 9b4eb8725c..95f5d23385 100644 --- a/tests/pytest/stream/stream2.py +++ b/tests/pytest/stream/stream2.py @@ -153,10 +153,14 @@ class TDTestCase: tdSql.checkRows(2) tdSql.checkData(0, 2, 's1') tdSql.checkData(1, 2, 's0') + tdSql.execute('kill stream %s ;' % tdSql.queryResult[0][0]) + time.sleep(5) + tdSql.query("show streams") + tdSql.checkRows(1) def stop(self): - tdSql.close() + #tdSql.close() tdLog.success("%s successfully executed" % __file__) -- GitLab