From e82f42a52bf7acaafd06abfde7596072524d9fb9 Mon Sep 17 00:00:00 2001 From: hjxilinx Date: Sat, 25 Apr 2020 23:05:15 +0800 Subject: [PATCH] [td-197] refactor codes, and remove unused attributes in querymsg --- src/client/src/tscServer.c | 23 ----------------------- src/inc/taosmsg.h | 4 ++-- src/query/src/queryExecutor.c | 33 +-------------------------------- 3 files changed, 3 insertions(+), 57 deletions(-) diff --git a/src/client/src/tscServer.c b/src/client/src/tscServer.c index af623596a4..48935480ad 100644 --- a/src/client/src/tscServer.c +++ b/src/client/src/tscServer.c @@ -758,16 +758,10 @@ int tscBuildQueryMsg(SSqlObj *pSql, SSqlInfo *pInfo) { } } - bool hasArithmeticFunction = false; - SSqlFuncMsg *pSqlFuncExpr = (SSqlFuncMsg *)pMsg; for (int32_t i = 0; i < tscSqlExprNumOfExprs(pQueryInfo); ++i) { SSqlExpr *pExpr = tscSqlExprGet(pQueryInfo, i); - if (pExpr->functionId == TSDB_FUNC_ARITHM) { - hasArithmeticFunction = true; - } - if (!tscValidateColumnId(pTableMetaInfo, pExpr->colInfo.colId)) { /* column id is not valid according to the cached table meta, the table meta is expired */ tscError("%p table schema is not matched with parsed sql", pSql); @@ -797,23 +791,6 @@ int tscBuildQueryMsg(SSqlObj *pSql, SSqlInfo *pInfo) { pSqlFuncExpr = (SSqlFuncMsg *)pMsg; } - int32_t len = 0; - if (hasArithmeticFunction) { - for (int32_t i = 0; i < numOfCols; ++i) { - SColumn* pColBase = taosArrayGetP(pQueryInfo->colList, i); - - char * name = pSchema[pColBase[i].colIndex.columnIndex].name; - int32_t lenx = strlen(name); - memcpy(pMsg, name, lenx); - *(pMsg + lenx) = ','; - - len += (lenx + 1); // one for comma - pMsg += (lenx + 1); - } - } - - pQueryMsg->colNameLen = htonl(len); - // serialize the table info (sid, uid, tags) pMsg = doSerializeTableInfo(pSql, htons(pQueryMsg->head.vgId), pMsg); diff --git a/src/inc/taosmsg.h b/src/inc/taosmsg.h index 3d5f798b13..b89f8b871f 100644 --- a/src/inc/taosmsg.h +++ b/src/inc/taosmsg.h @@ -459,8 +459,8 @@ typedef struct { int16_t interpoType; // interpolate type uint64_t defaultVal; // default value array list - int32_t colNameLen; - int64_t colNameList; +// int32_t colNameLen; +// int64_t colNameList; int32_t tsOffset; // offset value in current msg body, NOTE: ts list is compressed int32_t tsLen; // total length of ts comp block int32_t tsNumOfBlocks; // ts comp block numbers diff --git a/src/query/src/queryExecutor.c b/src/query/src/queryExecutor.c index f4f5c48f9c..b19e024dd9 100644 --- a/src/query/src/queryExecutor.c +++ b/src/query/src/queryExecutor.c @@ -5381,8 +5381,6 @@ static int32_t convertQueryMsg(SQueryTableMsg *pQueryMsg, SArray **pTableIdList, } } - bool hasArithmeticFunction = false; - *pExpr = calloc(pQueryMsg->numOfOutput, POINTER_BYTES); SSqlFuncMsg *pExprMsg = (SSqlFuncMsg *)pMsg; @@ -5409,9 +5407,7 @@ static int32_t convertQueryMsg(SQueryTableMsg *pQueryMsg, SArray **pTableIdList, } } - if (pExprMsg->functionId == TSDB_FUNC_ARITHM) { - hasArithmeticFunction = true; - } else if (pExprMsg->functionId == TSDB_FUNC_TAG || pExprMsg->functionId == TSDB_FUNC_TAGPRJ || + if (pExprMsg->functionId == TSDB_FUNC_TAG || pExprMsg->functionId == TSDB_FUNC_TAGPRJ || pExprMsg->functionId == TSDB_FUNC_TAG_DUMMY) { if (pExprMsg->colInfo.flag != TSDB_COL_TAG) { // ignore the column index check for arithmetic expression. return TSDB_CODE_INVALID_QUERY_MSG; @@ -5425,13 +5421,6 @@ static int32_t convertQueryMsg(SQueryTableMsg *pQueryMsg, SArray **pTableIdList, pExprMsg = (SSqlFuncMsg *)pMsg; } - pQueryMsg->colNameLen = htonl(pQueryMsg->colNameLen); - if (hasArithmeticFunction) { // column name array - assert(pQueryMsg->colNameLen > 0); - pQueryMsg->colNameList = (int64_t)pMsg; - pMsg += pQueryMsg->colNameLen; - } - pMsg = createTableIdList(pQueryMsg, pMsg, pTableIdList); if (pQueryMsg->numOfGroupCols > 0) { // group by tag columns @@ -5500,10 +5489,6 @@ static int32_t convertQueryMsg(SQueryTableMsg *pQueryMsg, SArray **pTableIdList, return 0; } -//static int32_t id_compar(const void* p1, const void* p2) { -// return GET_INT16_VAL(p1) - GET_INT16_VAL(p2); -//} - static int32_t buildAirthmeticExprFromMsg(SArithExprInfo *pArithExprInfo, SQueryTableMsg *pQueryMsg) { tExprNode* pExprNode = NULL; @@ -5516,22 +5501,6 @@ static int32_t buildAirthmeticExprFromMsg(SArithExprInfo *pArithExprInfo, SQuery } pArithExprInfo->pExpr = pExprNode; - -// SArray* res = taosArrayInit(4, sizeof(int16_t)); -// tSQLBinaryExprTrv(pExprNode, res); - -// size_t num = taosArrayGetSize(res); -// qsort(res->pData, num, sizeof(int16_t), id_compar); - - // there may be duplicated referenced columns. -// pArithExprInfo->colList = calloc(pQueryMsg->numOfCols, sizeof(SColIndex)); - -// for (int32_t k = 0; k < pQueryMsg->numOfCols; ++k) { -// SColIndex* pColIndex = &pArithExprInfo->colList[k]; -// pColIndex->colId = pQueryMsg->colList[k].colId; -// } - -// pArithExprInfo->numOfCols = pQueryMsg->numOfCols; return TSDB_CODE_SUCCESS; } -- GitLab