From cf06a3c8859149bab79cddcb3650100a81da4432 Mon Sep 17 00:00:00 2001 From: hjLiao Date: Tue, 12 May 2020 18:36:35 +0800 Subject: [PATCH] [td-225] fix bugs for 256 columns data check --- src/client/src/tscSQLParser.c | 4 ---- src/client/src/tscServer.c | 13 ++----------- src/client/src/tscUtil.c | 6 ++++++ src/inc/taosmsg.h | 1 - src/mnode/src/mgmtTable.c | 5 +++-- 5 files changed, 11 insertions(+), 18 deletions(-) diff --git a/src/client/src/tscSQLParser.c b/src/client/src/tscSQLParser.c index a81ad19e4f..3dbd5d36bd 100644 --- a/src/client/src/tscSQLParser.c +++ b/src/client/src/tscSQLParser.c @@ -1297,10 +1297,6 @@ SSqlExpr* doAddProjectCol(SQueryInfo* pQueryInfo, int32_t outputIndex, int32_t c pSchema->bytes, functionId == TSDB_FUNC_TAGPRJ); } -void addRequiredTagColumn(STableMetaInfo* pTableMetaInfo, SColumnIndex* index) { - -} - static void addProjectQueryCol(SQueryInfo* pQueryInfo, int32_t startPos, SColumnIndex* pIndex, tSQLExprItem* pItem) { SSqlExpr* pExpr = doAddProjectCol(pQueryInfo, startPos, pIndex->columnIndex, pIndex->tableIndex); diff --git a/src/client/src/tscServer.c b/src/client/src/tscServer.c index 8efe89d28a..f72f53c2b1 100644 --- a/src/client/src/tscServer.c +++ b/src/client/src/tscServer.c @@ -544,8 +544,7 @@ int tscBuildSubmitMsg(SSqlObj *pSql, SSqlInfo *pInfo) { } /* - * for meter query, simply return the size <= 1k - * for metric query, estimate size according to meter tags + * for table query, simply return the size <= 1k */ static int32_t tscEstimateQueryMsgSize(SSqlCmd *pCmd, int32_t clauseIndex) { const static int32_t MIN_QUERY_MSG_PKT_SIZE = TSDB_MAX_BYTES_PER_ROW * 5; @@ -556,15 +555,7 @@ static int32_t tscEstimateQueryMsgSize(SSqlCmd *pCmd, int32_t clauseIndex) { size_t numOfExprs = tscSqlExprNumOfExprs(pQueryInfo); int32_t exprSize = sizeof(SSqlFuncMsg) * numOfExprs; - STableMetaInfo *pTableMetaInfo = tscGetMetaInfo(pQueryInfo, 0); - - // meter query without tags values - if (!UTIL_TABLE_IS_SUPERTABLE(pTableMetaInfo)) { - return MIN_QUERY_MSG_PKT_SIZE + minMsgSize() + sizeof(SQueryTableMsg) + srcColListSize + exprSize; - } - - int32_t size = 4096; - return size; + return MIN_QUERY_MSG_PKT_SIZE + minMsgSize() + sizeof(SQueryTableMsg) + srcColListSize + exprSize + 4096; } static char *doSerializeTableInfo(SQueryTableMsg* pQueryMsg, SSqlObj *pSql, char *pMsg) { diff --git a/src/client/src/tscUtil.c b/src/client/src/tscUtil.c index c25e91a669..bea61f12c4 100644 --- a/src/client/src/tscUtil.c +++ b/src/client/src/tscUtil.c @@ -1701,6 +1701,12 @@ void tscClearTableMetaInfo(STableMetaInfo* pTableMetaInfo, bool removeFromCache) tfree(pTableMetaInfo->vgroupList); if (pTableMetaInfo->tagColList != NULL) { + size_t numOfTags = taosArrayGetSize(pTableMetaInfo->tagColList); + for(int32_t i = 0; i < numOfTags; ++i) { // todo do NOT use the allocated object + SColumn* pCol = taosArrayGetP(pTableMetaInfo->tagColList, i); + tfree(pCol); + } + taosArrayDestroy(pTableMetaInfo->tagColList); pTableMetaInfo->tagColList = NULL; } diff --git a/src/inc/taosmsg.h b/src/inc/taosmsg.h index 8dac73606d..9d16299380 100644 --- a/src/inc/taosmsg.h +++ b/src/inc/taosmsg.h @@ -626,7 +626,6 @@ typedef struct { typedef struct STableMetaMsg { int32_t contLen; char tableId[TSDB_TABLE_ID_LEN + 1]; // table id - char stableId[TSDB_TABLE_ID_LEN + 1]; // stable name if it is created according to super table uint8_t numOfTags; uint8_t precision; uint8_t tableType; diff --git a/src/mnode/src/mgmtTable.c b/src/mnode/src/mgmtTable.c index bfe357cf7c..3e11bd5f14 100644 --- a/src/mnode/src/mgmtTable.c +++ b/src/mnode/src/mgmtTable.c @@ -1206,8 +1206,10 @@ void mgmtDropAllSuperTables(SDbObj *pDropDb) { static int32_t mgmtSetSchemaFromSuperTable(SSchema *pSchema, SSuperTableObj *pTable) { int32_t numOfCols = pTable->numOfColumns + pTable->numOfTags; + assert(numOfCols <= TSDB_MAX_COLUMNS); + for (int32_t i = 0; i < numOfCols; ++i) { - strncpy(pSchema->name, pTable->schema[i].name, TSDB_TABLE_ID_LEN); + strncpy(pSchema->name, pTable->schema[i].name, TSDB_COL_NAME_LEN); pSchema->type = pTable->schema[i].type; pSchema->bytes = htons(pTable->schema[i].bytes); pSchema->colId = htons(pTable->schema[i].colId); @@ -1679,7 +1681,6 @@ static int32_t mgmtDoGetChildTableMeta(SQueuedMsg *pMsg, STableMetaMsg *pMeta) { pMeta->numOfTags = (int8_t)pTable->superTable->numOfTags; pMeta->numOfColumns = htons((int16_t)pTable->superTable->numOfColumns); pMeta->contLen = sizeof(STableMetaMsg) + mgmtSetSchemaFromSuperTable(pMeta->schema, pTable->superTable); - strncpy(pMeta->stableId, pTable->superTable->info.tableId, tListLen(pMeta->stableId)); } else { pMeta->sversion = htons(pTable->sversion); pMeta->numOfTags = 0; -- GitLab