[td-11818]Fix memory leak.
This commit is contained in:
parent
03ee26ed90
commit
04487db683
|
@ -196,6 +196,10 @@ static void doDestroyRequest(void* p) {
|
||||||
doFreeReqResultInfo(&pRequest->body.resInfo);
|
doFreeReqResultInfo(&pRequest->body.resInfo);
|
||||||
qDestroyQueryDag(pRequest->body.pDag);
|
qDestroyQueryDag(pRequest->body.pDag);
|
||||||
|
|
||||||
|
if (pRequest->body.showInfo.pArray != NULL) {
|
||||||
|
taosArrayDestroy(pRequest->body.showInfo.pArray);
|
||||||
|
}
|
||||||
|
|
||||||
deregisterRequest(pRequest);
|
deregisterRequest(pRequest);
|
||||||
tfree(pRequest);
|
tfree(pRequest);
|
||||||
}
|
}
|
||||||
|
|
|
@ -666,6 +666,8 @@ void processMsgFromServer(void* parent, SRpcMsg* pMsg, SEpSet* pEpSet) {
|
||||||
|
|
||||||
if (pMsg->contLen > 0) {
|
if (pMsg->contLen > 0) {
|
||||||
buf.pData = calloc(1, pMsg->contLen);
|
buf.pData = calloc(1, pMsg->contLen);
|
||||||
|
printf("create------------>%p\n", buf.pData);
|
||||||
|
|
||||||
if (buf.pData == NULL) {
|
if (buf.pData == NULL) {
|
||||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
pMsg->code = TSDB_CODE_OUT_OF_MEMORY;
|
pMsg->code = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
|
|
|
@ -145,6 +145,12 @@ int32_t processShowRsp(void* param, const SDataBuf* pMsg, int32_t code) {
|
||||||
}
|
}
|
||||||
|
|
||||||
pSchema = pMetaMsg->pSchema;
|
pSchema = pMetaMsg->pSchema;
|
||||||
|
tfree(pRequest->body.resInfo.pRspMsg);
|
||||||
|
|
||||||
|
pRequest->body.resInfo.pRspMsg = pMsg->pData;
|
||||||
|
SReqResultInfo* pResInfo = &pRequest->body.resInfo;
|
||||||
|
|
||||||
|
if (pResInfo->fields == NULL) {
|
||||||
TAOS_FIELD* pFields = calloc(pMetaMsg->numOfColumns, sizeof(TAOS_FIELD));
|
TAOS_FIELD* pFields = calloc(pMetaMsg->numOfColumns, sizeof(TAOS_FIELD));
|
||||||
for (int32_t i = 0; i < pMetaMsg->numOfColumns; ++i) {
|
for (int32_t i = 0; i < pMetaMsg->numOfColumns; ++i) {
|
||||||
tstrncpy(pFields[i].name, pSchema[i].name, tListLen(pFields[i].name));
|
tstrncpy(pFields[i].name, pSchema[i].name, tListLen(pFields[i].name));
|
||||||
|
@ -152,12 +158,10 @@ int32_t processShowRsp(void* param, const SDataBuf* pMsg, int32_t code) {
|
||||||
pFields[i].bytes = pSchema[i].bytes;
|
pFields[i].bytes = pSchema[i].bytes;
|
||||||
}
|
}
|
||||||
|
|
||||||
pRequest->body.resInfo.pRspMsg = pMsg->pData;
|
|
||||||
SReqResultInfo* pResInfo = &pRequest->body.resInfo;
|
|
||||||
|
|
||||||
pResInfo->fields = pFields;
|
pResInfo->fields = pFields;
|
||||||
pResInfo->numOfCols = pMetaMsg->numOfColumns;
|
}
|
||||||
|
|
||||||
|
pResInfo->numOfCols = pMetaMsg->numOfColumns;
|
||||||
pRequest->body.showInfo.execId = pShow->showId;
|
pRequest->body.showInfo.execId = pShow->showId;
|
||||||
|
|
||||||
// todo
|
// todo
|
||||||
|
|
|
@ -451,39 +451,39 @@ TEST(testCase, driverInit_Test) {
|
||||||
//
|
//
|
||||||
// taos_close(pConn);
|
// taos_close(pConn);
|
||||||
//}
|
//}
|
||||||
//
|
|
||||||
//TEST(testCase, show_table_Test) {
|
TEST(testCase, show_table_Test) {
|
||||||
// TAOS* pConn = taos_connect("localhost", "root", "taosdata", NULL, 0);
|
TAOS* pConn = taos_connect("localhost", "root", "taosdata", NULL, 0);
|
||||||
// assert(pConn != NULL);
|
assert(pConn != NULL);
|
||||||
//
|
|
||||||
// TAOS_RES* pRes = taos_query(pConn, "show tables");
|
TAOS_RES* pRes = taos_query(pConn, "show tables");
|
||||||
// if (taos_errno(pRes) != 0) {
|
if (taos_errno(pRes) != 0) {
|
||||||
// printf("failed to show tables, reason:%s\n", taos_errstr(pRes));
|
printf("failed to show tables, reason:%s\n", taos_errstr(pRes));
|
||||||
// taos_free_result(pRes);
|
taos_free_result(pRes);
|
||||||
// }
|
}
|
||||||
//
|
|
||||||
// pRes = taos_query(pConn, "show abc1.tables");
|
pRes = taos_query(pConn, "show abc1.tables");
|
||||||
// if (taos_errno(pRes) != 0) {
|
if (taos_errno(pRes) != 0) {
|
||||||
// printf("failed to show tables, reason:%s\n", taos_errstr(pRes));
|
printf("failed to show tables, reason:%s\n", taos_errstr(pRes));
|
||||||
// taos_free_result(pRes);
|
taos_free_result(pRes);
|
||||||
// }
|
}
|
||||||
//
|
|
||||||
// TAOS_ROW pRow = NULL;
|
TAOS_ROW pRow = NULL;
|
||||||
// TAOS_FIELD* pFields = taos_fetch_fields(pRes);
|
TAOS_FIELD* pFields = taos_fetch_fields(pRes);
|
||||||
// int32_t numOfFields = taos_num_fields(pRes);
|
int32_t numOfFields = taos_num_fields(pRes);
|
||||||
//
|
|
||||||
// int32_t count = 0;
|
int32_t count = 0;
|
||||||
// char str[512] = {0};
|
char str[512] = {0};
|
||||||
//
|
|
||||||
// while ((pRow = taos_fetch_row(pRes)) != NULL) {
|
while ((pRow = taos_fetch_row(pRes)) != NULL) {
|
||||||
// int32_t code = taos_print_row(str, pRow, pFields, numOfFields);
|
int32_t code = taos_print_row(str, pRow, pFields, numOfFields);
|
||||||
// printf("%d: %s\n", ++count, str);
|
printf("%d: %s\n", ++count, str);
|
||||||
// }
|
}
|
||||||
//
|
|
||||||
// taos_free_result(pRes);
|
taos_free_result(pRes);
|
||||||
// taos_close(pConn);
|
taos_close(pConn);
|
||||||
//}
|
}
|
||||||
//
|
|
||||||
//TEST(testCase, drop_stable_Test) {
|
//TEST(testCase, drop_stable_Test) {
|
||||||
// TAOS* pConn = taos_connect("localhost", "root", "taosdata", NULL, 0);
|
// TAOS* pConn = taos_connect("localhost", "root", "taosdata", NULL, 0);
|
||||||
// assert(pConn != NULL);
|
// assert(pConn != NULL);
|
||||||
|
@ -525,29 +525,29 @@ TEST(testCase, driverInit_Test) {
|
||||||
// taosHashCleanup(phash);
|
// taosHashCleanup(phash);
|
||||||
//}
|
//}
|
||||||
//
|
//
|
||||||
TEST(testCase, create_topic_Test) {
|
//TEST(testCase, create_topic_Test) {
|
||||||
TAOS* pConn = taos_connect("localhost", "root", "taosdata", NULL, 0);
|
// TAOS* pConn = taos_connect("localhost", "root", "taosdata", NULL, 0);
|
||||||
assert(pConn != NULL);
|
// assert(pConn != NULL);
|
||||||
|
//
|
||||||
TAOS_RES* pRes = taos_query(pConn, "use abc1");
|
// TAOS_RES* pRes = taos_query(pConn, "use abc1");
|
||||||
if (taos_errno(pRes) != 0) {
|
// if (taos_errno(pRes) != 0) {
|
||||||
printf("error in use db, reason:%s\n", taos_errstr(pRes));
|
// printf("error in use db, reason:%s\n", taos_errstr(pRes));
|
||||||
}
|
// }
|
||||||
taos_free_result(pRes);
|
// taos_free_result(pRes);
|
||||||
|
//
|
||||||
TAOS_FIELD* pFields = taos_fetch_fields(pRes);
|
// TAOS_FIELD* pFields = taos_fetch_fields(pRes);
|
||||||
ASSERT_TRUE(pFields == nullptr);
|
// ASSERT_TRUE(pFields == nullptr);
|
||||||
|
//
|
||||||
int32_t numOfFields = taos_num_fields(pRes);
|
// int32_t numOfFields = taos_num_fields(pRes);
|
||||||
ASSERT_EQ(numOfFields, 0);
|
// ASSERT_EQ(numOfFields, 0);
|
||||||
|
//
|
||||||
taos_free_result(pRes);
|
// taos_free_result(pRes);
|
||||||
|
//
|
||||||
char* sql = "select * from tu";
|
// char* sql = "select * from tu";
|
||||||
pRes = taos_create_topic(pConn, "test_topic_1", sql, strlen(sql));
|
// pRes = taos_create_topic(pConn, "test_topic_1", sql, strlen(sql));
|
||||||
taos_free_result(pRes);
|
// taos_free_result(pRes);
|
||||||
taos_close(pConn);
|
// taos_close(pConn);
|
||||||
}
|
//}
|
||||||
|
|
||||||
//TEST(testCase, insert_test) {
|
//TEST(testCase, insert_test) {
|
||||||
// TAOS* pConn = taos_connect("localhost", "root", "taosdata", NULL, 0);
|
// TAOS* pConn = taos_connect("localhost", "root", "taosdata", NULL, 0);
|
||||||
|
|
|
@ -64,7 +64,6 @@ static int32_t setShowInfo(SShowInfo* pShowInfo, SParseContext* pCtx, void** out
|
||||||
|
|
||||||
*outputLen = sizeof(SVShowTablesReq);
|
*outputLen = sizeof(SVShowTablesReq);
|
||||||
*output = pShowReq;
|
*output = pShowReq;
|
||||||
|
|
||||||
*pExtension = array;
|
*pExtension = array;
|
||||||
} else {
|
} else {
|
||||||
if (showType == TSDB_MGMT_TABLE_STB || showType == TSDB_MGMT_TABLE_VGROUP) {
|
if (showType == TSDB_MGMT_TABLE_STB || showType == TSDB_MGMT_TABLE_VGROUP) {
|
||||||
|
|
|
@ -36,25 +36,29 @@ bool qIsDdlQuery(const SQueryNode* pQueryNode) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t parseQuerySql(SParseContext* pCxt, SQueryNode** pQuery) {
|
int32_t parseQuerySql(SParseContext* pCxt, SQueryNode** pQuery) {
|
||||||
|
int32_t code = TSDB_CODE_SUCCESS;
|
||||||
|
|
||||||
SSqlInfo info = doGenerateAST(pCxt->pSql);
|
SSqlInfo info = doGenerateAST(pCxt->pSql);
|
||||||
if (!info.valid) {
|
if (!info.valid) {
|
||||||
strncpy(pCxt->pMsg, info.msg, pCxt->msgLen);
|
strncpy(pCxt->pMsg, info.msg, pCxt->msgLen);
|
||||||
terrno = TSDB_CODE_TSC_SQL_SYNTAX_ERROR;
|
code = TSDB_CODE_TSC_SQL_SYNTAX_ERROR;
|
||||||
return terrno;
|
goto _end;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!isDqlSqlStatement(&info)) {
|
if (!isDqlSqlStatement(&info)) {
|
||||||
if (info.type == TSDB_SQL_CREATE_TABLE) {
|
if (info.type == TSDB_SQL_CREATE_TABLE) {
|
||||||
SVnodeModifOpStmtInfo * pModifStmtInfo = qParserValidateCreateTbSqlNode(&info, pCxt, pCxt->pMsg, pCxt->msgLen);
|
SVnodeModifOpStmtInfo * pModifStmtInfo = qParserValidateCreateTbSqlNode(&info, pCxt, pCxt->pMsg, pCxt->msgLen);
|
||||||
if (pModifStmtInfo == NULL) {
|
if (pModifStmtInfo == NULL) {
|
||||||
return terrno;
|
code = terrno;
|
||||||
|
goto _end;
|
||||||
}
|
}
|
||||||
|
|
||||||
*pQuery = (SQueryNode*)pModifStmtInfo;
|
*pQuery = (SQueryNode*)pModifStmtInfo;
|
||||||
} else {
|
} else {
|
||||||
SDclStmtInfo* pDcl = qParserValidateDclSqlNode(&info, pCxt, pCxt->pMsg, pCxt->msgLen);
|
SDclStmtInfo* pDcl = qParserValidateDclSqlNode(&info, pCxt, pCxt->pMsg, pCxt->msgLen);
|
||||||
if (pDcl == NULL) {
|
if (pDcl == NULL) {
|
||||||
return terrno;
|
code = terrno;
|
||||||
|
goto _end;
|
||||||
}
|
}
|
||||||
|
|
||||||
*pQuery = (SQueryNode*)pDcl;
|
*pQuery = (SQueryNode*)pDcl;
|
||||||
|
@ -63,21 +67,22 @@ int32_t parseQuerySql(SParseContext* pCxt, SQueryNode** pQuery) {
|
||||||
} else {
|
} else {
|
||||||
SQueryStmtInfo* pQueryInfo = createQueryInfo();
|
SQueryStmtInfo* pQueryInfo = createQueryInfo();
|
||||||
if (pQueryInfo == NULL) {
|
if (pQueryInfo == NULL) {
|
||||||
terrno = TSDB_CODE_QRY_OUT_OF_MEMORY; // set correct error code.
|
code = TSDB_CODE_QRY_OUT_OF_MEMORY; // set correct error code.
|
||||||
return terrno;
|
goto _end;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t code = qParserValidateSqlNode(pCxt, &info, pQueryInfo, pCxt->pMsg, pCxt->msgLen);
|
code = qParserValidateSqlNode(pCxt, &info, pQueryInfo, pCxt->pMsg, pCxt->msgLen);
|
||||||
if (code == TSDB_CODE_SUCCESS) {
|
if (code == TSDB_CODE_SUCCESS) {
|
||||||
*pQuery = (SQueryNode*)pQueryInfo;
|
*pQuery = (SQueryNode*)pQueryInfo;
|
||||||
} else {
|
} else {
|
||||||
terrno = code;
|
goto _end;
|
||||||
return code;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_end:
|
||||||
destroySqlInfo(&info);
|
destroySqlInfo(&info);
|
||||||
return TSDB_CODE_SUCCESS;
|
terrno = code;
|
||||||
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t qParseQuerySql(SParseContext* pCxt, SQueryNode** pQueryNode) {
|
int32_t qParseQuerySql(SParseContext* pCxt, SQueryNode** pQueryNode) {
|
||||||
|
@ -247,5 +252,6 @@ void qDestroyQuery(SQueryNode* pQueryNode) {
|
||||||
SVnodeModifOpStmtInfo* pModifInfo = (SVnodeModifOpStmtInfo*)pQueryNode;
|
SVnodeModifOpStmtInfo* pModifInfo = (SVnodeModifOpStmtInfo*)pQueryNode;
|
||||||
taosArrayDestroy(pModifInfo->pDataBlocks);
|
taosArrayDestroy(pModifInfo->pDataBlocks);
|
||||||
}
|
}
|
||||||
|
|
||||||
tfree(pQueryNode);
|
tfree(pQueryNode);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue