[td-197] refactor codes, and remove unused attributes in querymsg
This commit is contained in:
parent
ba6acfd498
commit
e82f42a52b
|
@ -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);
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue