From b194ff18c41c83ebb9d0a4e0917ea6a9f270fe28 Mon Sep 17 00:00:00 2001 From: shenglian zhou Date: Tue, 11 Jan 2022 14:30:29 +0800 Subject: [PATCH] (query):use tlv for client/server message compability --- src/client/src/tscServer.c | 16 +++++++--------- src/inc/taosmsg.h | 2 -- src/query/inc/qExecutor.h | 2 ++ src/query/src/qExecutor.c | 29 +++++++++++++++-------------- src/query/src/queryMain.c | 4 ++-- 5 files changed, 26 insertions(+), 27 deletions(-) diff --git a/src/client/src/tscServer.c b/src/client/src/tscServer.c index eb3038a152..78b038ab19 100644 --- a/src/client/src/tscServer.c +++ b/src/client/src/tscServer.c @@ -964,9 +964,7 @@ int tscBuildQueryMsg(SSqlObj *pSql, SSqlInfo *pInfo) { pQueryMsg->numOfGroupCols = htons(pQueryInfo->groupbyExpr.numOfGroupCols); pQueryMsg->queryType = htonl(pQueryInfo->type); pQueryMsg->prevResultLen = htonl(pQueryInfo->bufLen); - - pQueryMsg->schemaVersion = htons(pTableMeta->sversion); - pQueryMsg->tagVersion = htons(pTableMeta->tversion); + // set column list ids size_t numOfCols = taosArrayGetSize(pQueryInfo->colList); char *pMsg = (char *)(pQueryMsg->tableCols) + numOfCols * sizeof(SColumnInfo); @@ -1152,21 +1150,21 @@ int tscBuildQueryMsg(SSqlObj *pSql, SSqlInfo *pInfo) { pMsg += sqlLen; -/* - //MSG EXTEND DEMO + pQueryMsg->extend = 1; STLV *tlv = (STLV *)pMsg; - tlv->type = htons(TLV_TYPE_DUMMY); - tlv->len = htonl(sizeof(int16_t)); - *(int16_t *)tlv->value = htons(12345); + tlv->type = htons(TLV_TYPE_META_VERSION); + tlv->len = htonl(sizeof(int16_t) * 2); + *(int16_t*)tlv->value = htons(pTableMeta->sversion); + *(int16_t*)(tlv->value+sizeof(int16_t)) = htons(pTableMeta->tversion); pMsg += sizeof(*tlv) + ntohl(tlv->len); tlv = (STLV *)pMsg; + tlv->type = htons(TLV_TYPE_END_MARK); tlv->len = 0; pMsg += sizeof(*tlv); -*/ int32_t msgLen = (int32_t)(pMsg - pCmd->payload); diff --git a/src/inc/taosmsg.h b/src/inc/taosmsg.h index bd17349443..26ce551e39 100644 --- a/src/inc/taosmsg.h +++ b/src/inc/taosmsg.h @@ -523,8 +523,6 @@ typedef struct { int32_t udfNum; // number of udf function int32_t udfContentOffset; int32_t udfContentLen; - int16_t schemaVersion; - int16_t tagVersion; SColumnInfo tableCols[]; } SQueryTableMsg; diff --git a/src/query/inc/qExecutor.h b/src/query/inc/qExecutor.h index f399cbc7e1..0b938078e3 100644 --- a/src/query/inc/qExecutor.h +++ b/src/query/inc/qExecutor.h @@ -428,6 +428,8 @@ typedef struct SQueryParam { int32_t tableScanOperator; SArray *pOperator; SUdfInfo *pUdfInfo; + int16_t schemaVersion; + int16_t tagVersion; } SQueryParam; typedef struct SColumnDataParam{ diff --git a/src/query/src/qExecutor.c b/src/query/src/qExecutor.c index 310c82ad04..69076045be 100644 --- a/src/query/src/qExecutor.c +++ b/src/query/src/qExecutor.c @@ -8264,10 +8264,6 @@ int32_t convertQueryMsg(SQueryTableMsg *pQueryMsg, SQueryParam* param) { goto _cleanup; } - - -/* - //MSG EXTEND DEMO if (pQueryMsg->extend) { pMsg += pQueryMsg->sqlstrLen; @@ -8276,19 +8272,24 @@ int32_t convertQueryMsg(SQueryTableMsg *pQueryMsg, SQueryParam* param) { tlv = (STLV *)pMsg; tlv->type = ntohs(tlv->type); tlv->len = ntohl(tlv->len); - if (tlv->len > 0) { - *(int16_t *)tlv->value = ntohs(*(int16_t *)tlv->value); - qDebug("Got TLV,type:%d,len:%d,value:%d", tlv->type, tlv->len, *(int16_t*)tlv->value); - pMsg += sizeof(*tlv) + tlv->len; - continue; + if (tlv->type == TLV_TYPE_END_MARK) { + break; + } + switch(tlv->type) { + case TLV_TYPE_META_VERSION: { + assert(tlv->len == 2*sizeof(int16_t)); + param->schemaVersion = ntohs(*(int16_t*)tlv->value); + param->tagVersion = ntohs(*(int16_t*)(tlv->value + sizeof(int16_t))); + pMsg += sizeof(*tlv) + tlv->len; + break; + } + default: { + pMsg += sizeof(*tlv) + tlv->len; + break; + } } - - break; } } - -*/ - qDebug("qmsg:%p query %d tables, type:%d, qrange:%" PRId64 "-%" PRId64 ", numOfGroupbyTagCols:%d, order:%d, " "outputCols:%d, numOfCols:%d, interval:%" PRId64 ", fillType:%d, comptsLen:%d, compNumOfBlocks:%d, limit:%" PRId64 ", offset:%" PRId64, diff --git a/src/query/src/queryMain.c b/src/query/src/queryMain.c index adf688feba..abbce6d3cf 100644 --- a/src/query/src/queryMain.c +++ b/src/query/src/queryMain.c @@ -162,8 +162,8 @@ int32_t qCreateQueryInfo(void* tsdb, int32_t vgId, SQueryTableMsg* pQueryMsg, qi assert(0); } - int16_t queryTagVersion = ntohs(pQueryMsg->tagVersion); - int16_t querySchemaVersion = ntohs(pQueryMsg->schemaVersion); + int16_t queryTagVersion = param.tagVersion; + int16_t querySchemaVersion = param.schemaVersion; if (queryTagVersion < tableGroupInfo.tVersion || querySchemaVersion < tableGroupInfo.sVersion) { code = TSDB_CODE_QRY_INVALID_SCHEMA_VERSION; goto _over; -- GitLab