提交 40e97536 编写于 作者: H hjliao

fix bug #570

上级 2a623947
...@@ -134,10 +134,12 @@ TAOS *taos_connect(char *ip, char *user, char *pass, char *db, int port) { ...@@ -134,10 +134,12 @@ TAOS *taos_connect(char *ip, char *user, char *pass, char *db, int port) {
void *taos = taos_connect_imp(ip, user, pass, db, port, NULL, NULL, NULL); void *taos = taos_connect_imp(ip, user, pass, db, port, NULL, NULL, NULL);
if (taos != NULL) { if (taos != NULL) {
STscObj* pObj = (STscObj*) taos;
int clientVersionNumber[4] = {0}; int clientVersionNumber[4] = {0};
if (!taosGetVersionNumber(version, clientVersionNumber)) { if (!taosGetVersionNumber(version, clientVersionNumber)) {
tscError("taos:%p, invalid client version:%s", taos, version); tscError("taos:%p, invalid client version:%s", taos, version);
globalCode = TSDB_CODE_INVALID_CLIENT_VERSION; pObj->pSql->res.code = TSDB_CODE_INVALID_CLIENT_VERSION;
taos_close(taos); taos_close(taos);
return NULL; return NULL;
} }
...@@ -146,33 +148,22 @@ TAOS *taos_connect(char *ip, char *user, char *pass, char *db, int port) { ...@@ -146,33 +148,22 @@ TAOS *taos_connect(char *ip, char *user, char *pass, char *db, int port) {
int serverVersionNumber[4] = {0}; int serverVersionNumber[4] = {0};
if (!taosGetVersionNumber(server_version, serverVersionNumber)) { if (!taosGetVersionNumber(server_version, serverVersionNumber)) {
tscError("taos:%p, invalid server version:%s", taos, server_version); tscError("taos:%p, invalid server version:%s", taos, server_version);
globalCode = TSDB_CODE_INVALID_CLIENT_VERSION; pObj->pSql->res.code = TSDB_CODE_INVALID_CLIENT_VERSION;
taos_close(taos); taos_close(taos);
return NULL; return NULL;
} }
if (clientVersionNumber[0] != serverVersionNumber[0]) { // version compare only requires the first 3 segments of the version string
tscError("taos:%p, the 1st number of server version:%s not matched with client version:%s, close connection", int32_t comparedSegments = 3;
taos, server_version, version);
globalCode = TSDB_CODE_INVALID_CLIENT_VERSION;
taos_close(taos);
return NULL;
}
if (clientVersionNumber[1] != serverVersionNumber[1]) { for(int32_t i = 0; i < comparedSegments; ++i) {
tscError("taos:%p, the 2nd number of server version:%s not matched with client version:%s, close connection", if (clientVersionNumber[i] != serverVersionNumber[i]) {
taos, server_version, version); tscError("taos:%p, the %d-th number of server version:%s not matched with client version:%s, close connection",
globalCode = TSDB_CODE_INVALID_CLIENT_VERSION; taos, i, server_version, version);
taos_close(taos); pObj->pSql->res.code = TSDB_CODE_INVALID_CLIENT_VERSION;
return NULL; taos_close(taos);
} return NULL;
}
if (clientVersionNumber[2] != serverVersionNumber[2]) {
tscError("taos:%p, the 3rd number of server version:%s not matched with client version:%s, close connection",
taos, server_version, version);
globalCode = TSDB_CODE_INVALID_CLIENT_VERSION;
taos_close(taos);
return NULL;
} }
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册