[td-225]fix memory leak.

This commit is contained in:
Haojun Liao 2021-04-25 12:00:19 +08:00
parent 7bc4a2ef42
commit 3e5aec6742
5 changed files with 12 additions and 9 deletions

View File

@ -2155,7 +2155,7 @@ int tscProcessShowRsp(SSqlObj *pSql) {
uint64_t uid = pTableMetaInfo->pTableMeta->id.uid;
for (int16_t i = 0; i < pMetaMsg->numOfColumns; ++i, ++pSchema) {
index.columnIndex = i;
tscColumnListInsert(pQueryInfo->colList, i, uid, &pSchema[i]);
tscColumnListInsert(pQueryInfo->colList, i, uid, pSchema);
TAOS_FIELD f = tscCreateField(pSchema->type, pSchema->name, pSchema->bytes);
SInternalField* pInfo = tscFieldInfoAppend(pFieldInfo, &f);

View File

@ -106,11 +106,6 @@ typedef struct STableNamePair {
SStrToken aliasName;
} STableNamePair;
//typedef struct SSubclauseInfo { // "UNION" multiple select sub-clause
// SSqlNode **pClause;
// int32_t numOfClause;
//} SSubclauseInfo;
typedef struct SRelationInfo {
int32_t type; // nested query|table name list
SArray *list; // SArray<STableNamePair>|SArray<SSqlNode*>
@ -253,7 +248,7 @@ SArray *tVariantListAppendToken(SArray *pList, SStrToken *pAliasToken, uint8_t s
SRelationInfo *setTableNameList(SRelationInfo* pFromInfo, SStrToken *pName, SStrToken* pAlias);
SRelationInfo *setSubquery(SRelationInfo* pFromInfo, SArray* pSqlNode);
void *destroyFromInfo(SRelationInfo* pFromInfo);
void *destroyRelationInfo(SRelationInfo* pFromInfo);
// sql expr leaf node
tSqlExpr *tSqlExprCreateIdValue(SStrToken *pToken, int32_t optrType);

View File

@ -506,10 +506,12 @@ distinct(X) ::= . { X.n = 0;}
// A complete FROM clause.
%type from {SRelationInfo*}
%destructor from {destroyRelationInfo($$);}
from(A) ::= FROM tablelist(X). {A = X;}
from(A) ::= FROM LP union(Y) RP. {A = setSubquery(NULL, Y);}
%type tablelist {SRelationInfo*}
%destructor tablelist {destroyRelationInfo($$);}
tablelist(A) ::= ids(X) cpxName(Y). {
X.n += Y.n;
A = setTableNameList(NULL, &X, NULL);

View File

@ -552,7 +552,7 @@ SRelationInfo* setSubquery(SRelationInfo* pRelationInfo, SArray* pList) {
return pRelationInfo;
}
void* destroyFromInfo(SRelationInfo* pRelationInfo) {
void* destroyRelationInfo(SRelationInfo* pRelationInfo) {
if (pRelationInfo == NULL) {
return NULL;
}
@ -799,7 +799,7 @@ void destroySqlNode(SSqlNode *pSqlNode) {
taosArrayDestroyEx(pSqlNode->pGroupby, freeVariant);
pSqlNode->pGroupby = NULL;
pSqlNode->from = destroyFromInfo(pSqlNode->from);
pSqlNode->from = destroyRelationInfo(pSqlNode->from);
taosArrayDestroyEx(pSqlNode->fillType, freeVariant);
pSqlNode->fillType = NULL;

View File

@ -1433,6 +1433,12 @@ destroySqlNode((yypminor->yy116));
case 261: /* exprlist */
{
tSqlExprListDestroy((yypminor->yy159));
}
break;
case 238: /* from */
case 254: /* tablelist */
{
destroyRelationInfo((yypminor->yy236));
}
break;
case 239: /* where_opt */