From b0b0cd7b9a2648e066e352ae57a306a81aa770f5 Mon Sep 17 00:00:00 2001 From: wangmm0220 Date: Thu, 20 Jan 2022 13:37:28 +0800 Subject: [PATCH] [TD-11544](query):the is no use to check version, because it already checked in function of rpcProcessMsgHead --- src/client/src/tscServer.c | 4 --- src/client/src/tscSql.c | 12 ++------ src/inc/taosmsg.h | 6 ++-- src/mnode/src/mnodeShow.c | 9 ------ src/query/src/qExecutor.c | 4 --- src/util/inc/tutil.h | 3 -- src/util/src/tutil.c | 60 -------------------------------------- 7 files changed, 5 insertions(+), 93 deletions(-) diff --git a/src/client/src/tscServer.c b/src/client/src/tscServer.c index 78b038ab19..32742745c1 100644 --- a/src/client/src/tscServer.c +++ b/src/client/src/tscServer.c @@ -1905,9 +1905,6 @@ int tscBuildConnectMsg(SSqlObj *pSql, SSqlInfo *pInfo) { tstrncpy(pConnect->db, db, sizeof(pConnect->db)); pthread_mutex_unlock(&pObj->mutex); - tstrncpy(pConnect->clientVersion, version, sizeof(pConnect->clientVersion)); - tstrncpy(pConnect->msgVersion, "", sizeof(pConnect->msgVersion)); - pConnect->pid = htonl(taosGetPId()); taosGetCurrentAPPName(pConnect->appName, NULL); @@ -2007,7 +2004,6 @@ int tscBuildHeartBeatMsg(SSqlObj *pSql, SSqlInfo *pInfo) { // TODO the expired hb and client can not be identified by server till now. SHeartBeatMsg *pHeartbeat = (SHeartBeatMsg *)pCmd->payload; - tstrncpy(pHeartbeat->clientVer, version, tListLen(pHeartbeat->clientVer)); pHeartbeat->numOfQueries = numOfQueries; pHeartbeat->numOfStreams = numOfStreams; diff --git a/src/client/src/tscSql.c b/src/client/src/tscSql.c index 2a60448a3e..8eff633577 100644 --- a/src/client/src/tscSql.c +++ b/src/client/src/tscSql.c @@ -212,16 +212,8 @@ TAOS *taos_connect_internal(const char *ip, const char *user, const char *pass, tscDebug("%p DB connection is opening, rpcObj: %p, dnodeConn:%p", pObj, pObj->pRpcObj, pObj->pRpcObj->pDnodeConn); taos_free_result(pSql); - - // version compare only requires the first 3 segments of the version string - int code = taosCheckVersion(version, taos_get_server_info(pObj), 3); - if (code != 0) { - terrno = code; - taos_close(pObj); - return NULL; - } else { - return pObj; - } + + return pObj; } return NULL; diff --git a/src/inc/taosmsg.h b/src/inc/taosmsg.h index 26ce551e39..2c4d21037c 100644 --- a/src/inc/taosmsg.h +++ b/src/inc/taosmsg.h @@ -335,8 +335,8 @@ typedef struct { typedef struct { int8_t extend; - char clientVersion[TSDB_VERSION_LEN]; - char msgVersion[TSDB_VERSION_LEN]; + char clientVersion[TSDB_VERSION_LEN]; // useless + char msgVersion[TSDB_VERSION_LEN]; // useless char db[TSDB_TABLE_FNAME_LEN]; char appName[TSDB_APPNAME_LEN]; int32_t pid; @@ -920,7 +920,7 @@ typedef struct { typedef struct { int8_t extend; - char clientVer[TSDB_VERSION_LEN]; + char clientVer[TSDB_VERSION_LEN]; // useless uint32_t connId; int32_t pid; int32_t numOfQueries; diff --git a/src/mnode/src/mnodeShow.c b/src/mnode/src/mnodeShow.c index 960987e7ad..bebb73eca2 100644 --- a/src/mnode/src/mnodeShow.c +++ b/src/mnode/src/mnodeShow.c @@ -243,10 +243,6 @@ static int32_t mnodeProcessHeartBeatMsg(SMnodeMsg *pMsg) { } SHeartBeatMsg *pHBMsg = pMsg->rpcMsg.pCont; - if (taosCheckVersion(pHBMsg->clientVer, version, 3) != TSDB_CODE_SUCCESS) { - rpcFreeCont(pRsp); - return TSDB_CODE_TSC_INVALID_VERSION; // todo change the error code - } SRpcConnInfo connInfo = {0}; rpcGetConnInfo(pMsg->rpcMsg.handle, &connInfo); @@ -307,11 +303,6 @@ static int32_t mnodeProcessConnectMsg(SMnodeMsg *pMsg) { goto connect_over; } - code = taosCheckVersion(pConnectMsg->clientVersion, version, 3); - if (code != TSDB_CODE_SUCCESS) { - goto connect_over; - } - SUserObj *pUser = pMsg->pUser; SAcctObj *pAcct = pUser->pAcct; diff --git a/src/query/src/qExecutor.c b/src/query/src/qExecutor.c index e0b192be2e..64c8b0715d 100644 --- a/src/query/src/qExecutor.c +++ b/src/query/src/qExecutor.c @@ -7945,10 +7945,6 @@ static int32_t deserializeColFilterInfo(SColumnFilterInfo* pColFilters, int16_t int32_t convertQueryMsg(SQueryTableMsg *pQueryMsg, SQueryParam* param) { int32_t code = TSDB_CODE_SUCCESS; - if (taosCheckVersion(pQueryMsg->version, version, 3) != 0) { - return TSDB_CODE_QRY_INVALID_MSG; - } - pQueryMsg->numOfTables = htonl(pQueryMsg->numOfTables); pQueryMsg->window.skey = htobe64(pQueryMsg->window.skey); pQueryMsg->window.ekey = htobe64(pQueryMsg->window.ekey); diff --git a/src/util/inc/tutil.h b/src/util/inc/tutil.h index 8756ed49de..a97b731f93 100644 --- a/src/util/inc/tutil.h +++ b/src/util/inc/tutil.h @@ -41,9 +41,6 @@ char * paGetToken(char *src, char **token, int32_t *tokenLen); int32_t taosByteArrayToHexStr(char bytes[], int32_t len, char hexstr[]); int32_t taosHexStrToByteArray(char hexstr[], char bytes[]); -bool taosGetVersionNumber(char *versionStr, int *versionNubmer); -int taosCheckVersion(char *input_client_version, char *input_server_version, int compared_segments); - char * taosIpStr(uint32_t ipInt); uint32_t ip2uint(const char *const ip_addr); void jsonKeyMd5(void *pMsg, int msgLen, void *pKey); diff --git a/src/util/src/tutil.c b/src/util/src/tutil.c index c7f1385a56..8bcef9f32b 100644 --- a/src/util/src/tutil.c +++ b/src/util/src/tutil.c @@ -444,66 +444,6 @@ int32_t taosHexStrToByteArray(char hexstr[], char bytes[]) { return 0; } -// TODO move to comm module -bool taosGetVersionNumber(char *versionStr, int *versionNubmer) { - if (versionStr == NULL || versionNubmer == NULL) { - return false; - } - - int versionNumberPos[5] = {0}; - int len = (int)strlen(versionStr); - int dot = 0; - for (int pos = 0; pos < len && dot < 4; ++pos) { - if (versionStr[pos] == '.') { - versionStr[pos] = 0; - versionNumberPos[++dot] = pos + 1; - } - } - - if (dot != 3) { - return false; - } - - for (int pos = 0; pos < 4; ++pos) { - versionNubmer[pos] = atoi(versionStr + versionNumberPos[pos]); - } - versionStr[versionNumberPos[1] - 1] = '.'; - versionStr[versionNumberPos[2] - 1] = '.'; - versionStr[versionNumberPos[3] - 1] = '.'; - - return true; -} - -int taosCheckVersion(char *input_client_version, char *input_server_version, int comparedSegments) { - char client_version[TSDB_VERSION_LEN] = {0}; - char server_version[TSDB_VERSION_LEN] = {0}; - int clientVersionNumber[4] = {0}; - int serverVersionNumber[4] = {0}; - - tstrncpy(client_version, input_client_version, sizeof(client_version)); - tstrncpy(server_version, input_server_version, sizeof(server_version)); - - if (!taosGetVersionNumber(client_version, clientVersionNumber)) { - uError("invalid client version:%s", client_version); - return TSDB_CODE_TSC_INVALID_VERSION; - } - - if (!taosGetVersionNumber(server_version, serverVersionNumber)) { - uError("invalid server version:%s", server_version); - return TSDB_CODE_TSC_INVALID_VERSION; - } - - for(int32_t i = 0; i < comparedSegments; ++i) { - if (clientVersionNumber[i] != serverVersionNumber[i]) { - uError("the %d-th number of server version:%s not matched with client version:%s", i, server_version, - client_version); - return TSDB_CODE_TSC_INVALID_VERSION; - } - } - - return 0; -} - char *taosIpStr(uint32_t ipInt) { static char ipStrArray[3][30]; static int ipStrIndex = 0; -- GitLab