Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
367fac8b
T
TDengine
项目概览
taosdata
/
TDengine
大约 2 年 前同步成功
通知
1192
Star
22018
Fork
4786
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
367fac8b
编写于
11月 28, 2020
作者:
dengyihao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
set mnode list
上级
0081f2e7
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
102 addition
and
105 deletion
+102
-105
src/client/inc/tscUtil.h
src/client/inc/tscUtil.h
+1
-1
src/client/inc/tsclient.h
src/client/inc/tsclient.h
+1
-2
src/client/src/tscServer.c
src/client/src/tscServer.c
+34
-46
src/client/src/tscSql.c
src/client/src/tscSql.c
+62
-47
src/client/src/tscSystem.c
src/client/src/tscSystem.c
+0
-5
src/client/src/tscUtil.c
src/client/src/tscUtil.c
+4
-4
未找到文件。
src/client/inc/tscUtil.h
浏览文件 @
367fac8b
...
@@ -277,7 +277,7 @@ bool hasMoreClauseToTry(SSqlObj* pSql);
...
@@ -277,7 +277,7 @@ bool hasMoreClauseToTry(SSqlObj* pSql);
void
tscTryQueryNextVnode
(
SSqlObj
*
pSql
,
__async_cb_func_t
fp
);
void
tscTryQueryNextVnode
(
SSqlObj
*
pSql
,
__async_cb_func_t
fp
);
void
tscAsyncQuerySingleRowForNextVnode
(
void
*
param
,
TAOS_RES
*
tres
,
int
numOfRows
);
void
tscAsyncQuerySingleRowForNextVnode
(
void
*
param
,
TAOS_RES
*
tres
,
int
numOfRows
);
void
tscTryQueryNextClause
(
SSqlObj
*
pSql
,
__async_cb_func_t
fp
);
void
tscTryQueryNextClause
(
SSqlObj
*
pSql
,
__async_cb_func_t
fp
);
int
tscSetMgmtEpSetFromCfg
(
const
char
*
first
,
const
char
*
second
);
int
tscSetMgmtEpSetFromCfg
(
const
char
*
first
,
const
char
*
second
,
SRpcCorEpSet
*
corEpSet
);
bool
tscSetSqlOwner
(
SSqlObj
*
pSql
);
bool
tscSetSqlOwner
(
SSqlObj
*
pSql
);
void
tscClearSqlOwner
(
SSqlObj
*
pSql
);
void
tscClearSqlOwner
(
SSqlObj
*
pSql
);
...
...
src/client/inc/tsclient.h
浏览文件 @
367fac8b
...
@@ -334,6 +334,7 @@ typedef struct STscObj {
...
@@ -334,6 +334,7 @@ typedef struct STscObj {
int64_t
hbrid
;
int64_t
hbrid
;
struct
SSqlObj
*
sqlList
;
struct
SSqlObj
*
sqlList
;
struct
SSqlStream
*
streamList
;
struct
SSqlStream
*
streamList
;
SRpcCorEpSet
*
tscCorMgmtEpSet
;
void
*
pDnodeConn
;
void
*
pDnodeConn
;
pthread_mutex_t
mutex
;
pthread_mutex_t
mutex
;
T_REF_DECLARE
()
T_REF_DECLARE
()
...
@@ -512,8 +513,6 @@ extern int tsInsertHeadSize;
...
@@ -512,8 +513,6 @@ extern int tsInsertHeadSize;
extern
int
tscNumOfThreads
;
extern
int
tscNumOfThreads
;
extern
int
tscRefId
;
extern
int
tscRefId
;
extern
SRpcCorEpSet
tscMgmtEpSet
;
extern
int
(
*
tscBuildMsg
[
TSDB_SQL_MAX
])(
SSqlObj
*
pSql
,
SSqlInfo
*
pInfo
);
extern
int
(
*
tscBuildMsg
[
TSDB_SQL_MAX
])(
SSqlObj
*
pSql
,
SSqlInfo
*
pInfo
);
void
tscBuildVgroupTableInfo
(
SSqlObj
*
pSql
,
STableMetaInfo
*
pTableMetaInfo
,
SArray
*
tables
);
void
tscBuildVgroupTableInfo
(
SSqlObj
*
pSql
,
STableMetaInfo
*
pTableMetaInfo
,
SArray
*
tables
);
...
...
src/client/src/tscServer.c
浏览文件 @
367fac8b
...
@@ -26,8 +26,6 @@
...
@@ -26,8 +26,6 @@
#include "ttimer.h"
#include "ttimer.h"
#include "tlockfree.h"
#include "tlockfree.h"
SRpcCorEpSet
tscMgmtEpSet
;
int
(
*
tscBuildMsg
[
TSDB_SQL_MAX
])(
SSqlObj
*
pSql
,
SSqlInfo
*
pInfo
)
=
{
0
};
int
(
*
tscBuildMsg
[
TSDB_SQL_MAX
])(
SSqlObj
*
pSql
,
SSqlInfo
*
pInfo
)
=
{
0
};
int
(
*
tscProcessMsgRsp
[
TSDB_SQL_MAX
])(
SSqlObj
*
pSql
);
int
(
*
tscProcessMsgRsp
[
TSDB_SQL_MAX
])(
SSqlObj
*
pSql
);
...
@@ -73,33 +71,35 @@ static void tscSetDnodeEpSet(SSqlObj* pSql, SVgroupInfo* pVgroupInfo) {
...
@@ -73,33 +71,35 @@ static void tscSetDnodeEpSet(SSqlObj* pSql, SVgroupInfo* pVgroupInfo) {
assert
(
hasFqdn
);
assert
(
hasFqdn
);
}
}
static
void
tscDumpMgmtEpSet
(
SRpcEpSet
*
epSet
)
{
static
void
tscDumpMgmtEpSet
(
SSqlObj
*
pSql
)
{
taosCorBeginRead
(
&
tscMgmtEpSet
.
version
);
SRpcCorEpSet
*
pCorEpSet
=
pSql
->
pTscObj
->
tscCorMgmtEpSet
;
*
epSet
=
tscMgmtEpSet
.
epSet
;
taosCorBeginRead
(
&
pCorEpSet
->
version
);
taosCorEndRead
(
&
tscMgmtEpSet
.
version
);
pSql
->
epSet
=
pCorEpSet
->
epSet
;
}
taosCorEndRead
(
&
pCorEpSet
->
version
);
}
static
void
tscEpSetHtons
(
SRpcEpSet
*
s
)
{
static
void
tscEpSetHtons
(
SRpcEpSet
*
s
)
{
for
(
int32_t
i
=
0
;
i
<
s
->
numOfEps
;
i
++
)
{
for
(
int32_t
i
=
0
;
i
<
s
->
numOfEps
;
i
++
)
{
s
->
port
[
i
]
=
htons
(
s
->
port
[
i
]);
s
->
port
[
i
]
=
htons
(
s
->
port
[
i
]);
}
}
}
}
bool
tscEpSetIsEqual
(
SRpcEpSet
*
s1
,
SRpcEpSet
*
s2
)
{
bool
tscEpSetIsEqual
(
SRpcEpSet
*
s1
,
SRpcEpSet
*
s2
)
{
if
(
s1
->
numOfEps
!=
s2
->
numOfEps
||
s1
->
inUse
!=
s2
->
inUse
)
{
if
(
s1
->
numOfEps
!=
s2
->
numOfEps
||
s1
->
inUse
!=
s2
->
inUse
)
{
return
false
;
return
false
;
}
}
for
(
int32_t
i
=
0
;
i
<
s1
->
numOfEps
;
i
++
)
{
for
(
int32_t
i
=
0
;
i
<
s1
->
numOfEps
;
i
++
)
{
if
(
s1
->
port
[
i
]
!=
s2
->
port
[
i
]
if
(
s1
->
port
[
i
]
!=
s2
->
port
[
i
]
||
strncmp
(
s1
->
fqdn
[
i
],
s2
->
fqdn
[
i
],
TSDB_FQDN_LEN
)
!=
0
)
||
strncmp
(
s1
->
fqdn
[
i
],
s2
->
fqdn
[
i
],
TSDB_FQDN_LEN
)
!=
0
)
return
false
;
return
false
;
}
}
return
true
;
return
true
;
}
}
void
tscUpdateMgmtEpSet
(
SRpcEpSet
*
pEpSet
)
{
void
tscUpdateMgmtEpSet
(
S
SqlObj
*
pSql
,
S
RpcEpSet
*
pEpSet
)
{
// no need to update if equal
SRpcCorEpSet
*
pCorEpSet
=
pSql
->
pTscObj
->
tscCorMgmtEpSet
;
taosCorBeginWrite
(
&
tscMgmtEpSet
.
version
);
taosCorBeginWrite
(
&
pCorEpSet
->
version
);
tscMgmtEpSet
.
epSet
=
*
pEpSet
;
pCorEpSet
->
epSet
=
*
pEpSet
;
taosCorEndWrite
(
&
tscMgmtEpSet
.
version
);
taosCorEndWrite
(
&
pCorEpSet
->
version
);
}
}
static
void
tscDumpEpSetFromVgroupInfo
(
SCorVgroupInfo
*
pVgroupInfo
,
SRpcEpSet
*
pEpSet
)
{
static
void
tscDumpEpSetFromVgroupInfo
(
SCorVgroupInfo
*
pVgroupInfo
,
SRpcEpSet
*
pEpSet
)
{
if
(
pVgroupInfo
==
NULL
)
{
return
;}
if
(
pVgroupInfo
==
NULL
)
{
return
;}
taosCorBeginRead
(
&
pVgroupInfo
->
version
);
taosCorBeginRead
(
&
pVgroupInfo
->
version
);
...
@@ -133,18 +133,6 @@ static void tscUpdateVgroupInfo(SSqlObj *pObj, SRpcEpSet *pEpSet) {
...
@@ -133,18 +133,6 @@ static void tscUpdateVgroupInfo(SSqlObj *pObj, SRpcEpSet *pEpSet) {
taosCorEndWrite
(
&
pVgroupInfo
->
version
);
taosCorEndWrite
(
&
pVgroupInfo
->
version
);
}
}
void
tscPrintMgmtEp
()
{
SRpcEpSet
dump
;
tscDumpMgmtEpSet
(
&
dump
);
if
(
dump
.
numOfEps
<=
0
)
{
tscError
(
"invalid mnode EP list:%d"
,
dump
.
numOfEps
);
}
else
{
for
(
int
i
=
0
;
i
<
dump
.
numOfEps
;
++
i
)
{
tscDebug
(
"mnode index:%d %s:%d"
,
i
,
dump
.
fqdn
[
i
],
dump
.
port
[
i
]);
}
}
}
void
tscProcessHeartBeatRsp
(
void
*
param
,
TAOS_RES
*
tres
,
int
code
)
{
void
tscProcessHeartBeatRsp
(
void
*
param
,
TAOS_RES
*
tres
,
int
code
)
{
STscObj
*
pObj
=
(
STscObj
*
)
param
;
STscObj
*
pObj
=
(
STscObj
*
)
param
;
if
(
pObj
==
NULL
)
return
;
if
(
pObj
==
NULL
)
return
;
...
@@ -162,7 +150,7 @@ void tscProcessHeartBeatRsp(void *param, TAOS_RES *tres, int code) {
...
@@ -162,7 +150,7 @@ void tscProcessHeartBeatRsp(void *param, TAOS_RES *tres, int code) {
SRpcEpSet
*
epSet
=
&
pRsp
->
epSet
;
SRpcEpSet
*
epSet
=
&
pRsp
->
epSet
;
if
(
epSet
->
numOfEps
>
0
)
{
if
(
epSet
->
numOfEps
>
0
)
{
tscEpSetHtons
(
epSet
);
tscEpSetHtons
(
epSet
);
tscUpdateMgmtEpSet
(
epSet
);
tscUpdateMgmtEpSet
(
pSql
,
epSet
);
}
}
pSql
->
pTscObj
->
connId
=
htonl
(
pRsp
->
connId
);
pSql
->
pTscObj
->
connId
=
htonl
(
pRsp
->
connId
);
...
@@ -208,7 +196,7 @@ void tscProcessActivityTimer(void *handle, void *tmrId) {
...
@@ -208,7 +196,7 @@ void tscProcessActivityTimer(void *handle, void *tmrId) {
int
tscSendMsgToServer
(
SSqlObj
*
pSql
)
{
int
tscSendMsgToServer
(
SSqlObj
*
pSql
)
{
STscObj
*
pObj
=
pSql
->
pTscObj
;
STscObj
*
pObj
=
pSql
->
pTscObj
;
SSqlCmd
*
pCmd
=
&
pSql
->
cmd
;
SSqlCmd
*
pCmd
=
&
pSql
->
cmd
;
char
*
pMsg
=
rpcMallocCont
(
pCmd
->
payloadLen
);
char
*
pMsg
=
rpcMallocCont
(
pCmd
->
payloadLen
);
if
(
NULL
==
pMsg
)
{
if
(
NULL
==
pMsg
)
{
tscError
(
"%p msg:%s malloc failed"
,
pSql
,
taosMsg
[
pSql
->
cmd
.
msgType
]);
tscError
(
"%p msg:%s malloc failed"
,
pSql
,
taosMsg
[
pSql
->
cmd
.
msgType
]);
...
@@ -217,18 +205,18 @@ int tscSendMsgToServer(SSqlObj *pSql) {
...
@@ -217,18 +205,18 @@ int tscSendMsgToServer(SSqlObj *pSql) {
// set the mgmt ip list
// set the mgmt ip list
if
(
pSql
->
cmd
.
command
>=
TSDB_SQL_MGMT
)
{
if
(
pSql
->
cmd
.
command
>=
TSDB_SQL_MGMT
)
{
tscDumpMgmtEpSet
(
&
pSql
->
epSet
);
tscDumpMgmtEpSet
(
pSql
);
}
}
memcpy
(
pMsg
,
pSql
->
cmd
.
payload
,
pSql
->
cmd
.
payloadLen
);
memcpy
(
pMsg
,
pSql
->
cmd
.
payload
,
pSql
->
cmd
.
payloadLen
);
SRpcMsg
rpcMsg
=
{
SRpcMsg
rpcMsg
=
{
.
msgType
=
pSql
->
cmd
.
msgType
,
.
msgType
=
pSql
->
cmd
.
msgType
,
.
pCont
=
pMsg
,
.
pCont
=
pMsg
,
.
contLen
=
pSql
->
cmd
.
payloadLen
,
.
contLen
=
pSql
->
cmd
.
payloadLen
,
.
ahandle
=
(
void
*
)
pSql
->
self
,
.
ahandle
=
(
void
*
)
pSql
->
self
,
.
handle
=
NULL
,
.
handle
=
NULL
,
.
code
=
0
.
code
=
0
};
};
// NOTE: the rpc context should be acquired before sending data to server.
// NOTE: the rpc context should be acquired before sending data to server.
...
@@ -280,7 +268,7 @@ void tscProcessMsgFromServer(SRpcMsg *rpcMsg, SRpcEpSet *pEpSet) {
...
@@ -280,7 +268,7 @@ void tscProcessMsgFromServer(SRpcMsg *rpcMsg, SRpcEpSet *pEpSet) {
if
(
pCmd
->
command
<
TSDB_SQL_MGMT
)
{
if
(
pCmd
->
command
<
TSDB_SQL_MGMT
)
{
tscUpdateVgroupInfo
(
pSql
,
pEpSet
);
tscUpdateVgroupInfo
(
pSql
,
pEpSet
);
}
else
{
}
else
{
tscUpdateMgmtEpSet
(
p
EpSet
);
tscUpdateMgmtEpSet
(
p
Sql
,
pEpSet
);
}
}
}
}
}
}
...
@@ -1996,7 +1984,7 @@ int tscProcessConnectRsp(SSqlObj *pSql) {
...
@@ -1996,7 +1984,7 @@ int tscProcessConnectRsp(SSqlObj *pSql) {
if
(
pConnect
->
epSet
.
numOfEps
>
0
)
{
if
(
pConnect
->
epSet
.
numOfEps
>
0
)
{
tscEpSetHtons
(
&
pConnect
->
epSet
);
tscEpSetHtons
(
&
pConnect
->
epSet
);
tscUpdateMgmtEpSet
(
&
pConnect
->
epSet
);
tscUpdateMgmtEpSet
(
pSql
,
&
pConnect
->
epSet
);
}
}
strcpy
(
pObj
->
sversion
,
pConnect
->
serverVersion
);
strcpy
(
pObj
->
sversion
,
pConnect
->
serverVersion
);
...
...
src/client/src/tscSql.c
浏览文件 @
367fac8b
...
@@ -60,6 +60,7 @@ static SSqlObj *taosConnectImpl(const char *ip, const char *user, const char *pa
...
@@ -60,6 +60,7 @@ static SSqlObj *taosConnectImpl(const char *ip, const char *user, const char *pa
return
NULL
;
return
NULL
;
}
}
SRpcCorEpSet
corMgmtEpSet
;
char
secretEncrypt
[
32
]
=
{
0
};
char
secretEncrypt
[
32
]
=
{
0
};
int
secretEncryptLen
=
0
;
int
secretEncryptLen
=
0
;
if
(
auth
==
NULL
)
{
if
(
auth
==
NULL
)
{
...
@@ -83,24 +84,35 @@ static SSqlObj *taosConnectImpl(const char *ip, const char *user, const char *pa
...
@@ -83,24 +84,35 @@ static SSqlObj *taosConnectImpl(const char *ip, const char *user, const char *pa
}
}
secretEncryptLen
=
outlen
;
secretEncryptLen
=
outlen
;
}
}
if
(
ip
)
{
if
(
ip
)
{
if
(
tscSetMgmtEpSetFromCfg
(
ip
,
NULL
)
<
0
)
return
NULL
;
if
(
tscSetMgmtEpSetFromCfg
(
ip
,
NULL
,
&
corMgmtEpSet
)
<
0
)
return
NULL
;
if
(
port
)
tscMgmtEpSet
.
epSet
.
port
[
0
]
=
port
;
if
(
port
)
corMgmtEpSet
.
epSet
.
port
[
0
]
=
port
;
}
}
else
{
if
(
tscSetMgmtEpSetFromCfg
(
tsFirst
,
tsSecond
,
&
corMgmtEpSet
)
<
0
)
return
NULL
;
}
void
*
pDnodeConn
=
NULL
;
void
*
pDnodeConn
=
NULL
;
if
(
tscInitRpc
(
user
,
secretEncrypt
,
&
pDnodeConn
)
!=
0
)
{
if
(
tscInitRpc
(
user
,
secretEncrypt
,
&
pDnodeConn
)
!=
0
)
{
terrno
=
TSDB_CODE_RPC_NETWORK_UNAVAIL
;
terrno
=
TSDB_CODE_RPC_NETWORK_UNAVAIL
;
return
NULL
;
return
NULL
;
}
}
STscObj
*
pObj
=
(
STscObj
*
)
calloc
(
1
,
sizeof
(
STscObj
));
STscObj
*
pObj
=
(
STscObj
*
)
calloc
(
1
,
sizeof
(
STscObj
));
if
(
NULL
==
pObj
)
{
if
(
NULL
==
pObj
)
{
terrno
=
TSDB_CODE_TSC_OUT_OF_MEMORY
;
terrno
=
TSDB_CODE_TSC_OUT_OF_MEMORY
;
rpcClose
(
pDnodeConn
);
rpcClose
(
pDnodeConn
);
return
NULL
;
return
NULL
;
}
}
// set up tscObj's mgmtEpSet
pObj
->
tscCorMgmtEpSet
=
(
SRpcCorEpSet
*
)
malloc
(
sizeof
(
SRpcCorEpSet
));
if
(
NULL
==
pObj
->
tscCorMgmtEpSet
)
{
terrno
=
TSDB_CODE_TSC_OUT_OF_MEMORY
;
rpcClose
(
pDnodeConn
);
free
(
pObj
->
tscCorMgmtEpSet
);
free
(
pObj
);
}
memcpy
(
pObj
->
tscCorMgmtEpSet
,
&
corMgmtEpSet
,
sizeof
(
SRpcCorEpSet
));
pObj
->
signature
=
pObj
;
pObj
->
signature
=
pObj
;
pObj
->
pDnodeConn
=
pDnodeConn
;
pObj
->
pDnodeConn
=
pDnodeConn
;
...
@@ -116,6 +128,7 @@ static SSqlObj *taosConnectImpl(const char *ip, const char *user, const char *pa
...
@@ -116,6 +128,7 @@ static SSqlObj *taosConnectImpl(const char *ip, const char *user, const char *pa
if
(
len
>=
TSDB_DB_NAME_LEN
)
{
if
(
len
>=
TSDB_DB_NAME_LEN
)
{
terrno
=
TSDB_CODE_TSC_INVALID_DB_LENGTH
;
terrno
=
TSDB_CODE_TSC_INVALID_DB_LENGTH
;
rpcClose
(
pDnodeConn
);
rpcClose
(
pDnodeConn
);
free
(
pObj
->
tscCorMgmtEpSet
);
free
(
pObj
);
free
(
pObj
);
return
NULL
;
return
NULL
;
}
}
...
@@ -133,6 +146,7 @@ static SSqlObj *taosConnectImpl(const char *ip, const char *user, const char *pa
...
@@ -133,6 +146,7 @@ static SSqlObj *taosConnectImpl(const char *ip, const char *user, const char *pa
if
(
NULL
==
pSql
)
{
if
(
NULL
==
pSql
)
{
terrno
=
TSDB_CODE_TSC_OUT_OF_MEMORY
;
terrno
=
TSDB_CODE_TSC_OUT_OF_MEMORY
;
rpcClose
(
pDnodeConn
);
rpcClose
(
pDnodeConn
);
free
(
pObj
->
tscCorMgmtEpSet
);
free
(
pObj
);
free
(
pObj
);
return
NULL
;
return
NULL
;
}
}
...
@@ -150,6 +164,7 @@ static SSqlObj *taosConnectImpl(const char *ip, const char *user, const char *pa
...
@@ -150,6 +164,7 @@ static SSqlObj *taosConnectImpl(const char *ip, const char *user, const char *pa
terrno
=
TSDB_CODE_TSC_OUT_OF_MEMORY
;
terrno
=
TSDB_CODE_TSC_OUT_OF_MEMORY
;
rpcClose
(
pDnodeConn
);
rpcClose
(
pDnodeConn
);
free
(
pSql
);
free
(
pSql
);
free
(
pObj
->
tscCorMgmtEpSet
);
free
(
pObj
);
free
(
pObj
);
return
NULL
;
return
NULL
;
}
}
...
@@ -168,12 +183,12 @@ static SSqlObj *taosConnectImpl(const char *ip, const char *user, const char *pa
...
@@ -168,12 +183,12 @@ static SSqlObj *taosConnectImpl(const char *ip, const char *user, const char *pa
static
void
syncConnCallback
(
void
*
param
,
TAOS_RES
*
tres
,
int
code
)
{
static
void
syncConnCallback
(
void
*
param
,
TAOS_RES
*
tres
,
int
code
)
{
SSqlObj
*
pSql
=
(
SSqlObj
*
)
tres
;
SSqlObj
*
pSql
=
(
SSqlObj
*
)
tres
;
assert
(
pSql
!=
NULL
);
assert
(
pSql
!=
NULL
);
tsem_post
(
&
pSql
->
rspSem
);
tsem_post
(
&
pSql
->
rspSem
);
}
}
TAOS
*
taos_connect_internal
(
const
char
*
ip
,
const
char
*
user
,
const
char
*
pass
,
const
char
*
auth
,
const
char
*
db
,
TAOS
*
taos_connect_internal
(
const
char
*
ip
,
const
char
*
user
,
const
char
*
pass
,
const
char
*
auth
,
const
char
*
db
,
uint16_t
port
)
{
uint16_t
port
)
{
STscObj
*
pObj
=
NULL
;
STscObj
*
pObj
=
NULL
;
SSqlObj
*
pSql
=
taosConnectImpl
(
ip
,
user
,
pass
,
auth
,
db
,
port
,
syncConnCallback
,
NULL
,
(
void
**
)
&
pObj
);
SSqlObj
*
pSql
=
taosConnectImpl
(
ip
,
user
,
pass
,
auth
,
db
,
port
,
syncConnCallback
,
NULL
,
(
void
**
)
&
pObj
);
if
(
pSql
!=
NULL
)
{
if
(
pSql
!=
NULL
)
{
...
@@ -189,10 +204,10 @@ TAOS *taos_connect_internal(const char *ip, const char *user, const char *pass,
...
@@ -189,10 +204,10 @@ TAOS *taos_connect_internal(const char *ip, const char *user, const char *pass,
taos_close
(
pObj
);
taos_close
(
pObj
);
return
NULL
;
return
NULL
;
}
}
tscDebug
(
"%p DB connection is opening, dnodeConn:%p"
,
pObj
,
pObj
->
pDnodeConn
);
tscDebug
(
"%p DB connection is opening, dnodeConn:%p"
,
pObj
,
pObj
->
pDnodeConn
);
taos_free_result
(
pSql
);
taos_free_result
(
pSql
);
// version compare only requires the first 3 segments of the version string
// version compare only requires the first 3 segments of the version string
int
code
=
taosCheckVersion
(
version
,
taos_get_server_info
(
pObj
),
3
);
int
code
=
taosCheckVersion
(
version
,
taos_get_server_info
(
pObj
),
3
);
if
(
code
!=
0
)
{
if
(
code
!=
0
)
{
...
@@ -224,7 +239,7 @@ TAOS *taos_connect_auth(const char *ip, const char *user, const char *auth, cons
...
@@ -224,7 +239,7 @@ TAOS *taos_connect_auth(const char *ip, const char *user, const char *auth, cons
}
}
TAOS
*
taos_connect_c
(
const
char
*
ip
,
uint8_t
ipLen
,
const
char
*
user
,
uint8_t
userLen
,
const
char
*
pass
,
TAOS
*
taos_connect_c
(
const
char
*
ip
,
uint8_t
ipLen
,
const
char
*
user
,
uint8_t
userLen
,
const
char
*
pass
,
uint8_t
passLen
,
const
char
*
db
,
uint8_t
dbLen
,
uint16_t
port
)
{
uint8_t
passLen
,
const
char
*
db
,
uint8_t
dbLen
,
uint16_t
port
)
{
char
ipBuf
[
TSDB_EP_LEN
]
=
{
0
};
char
ipBuf
[
TSDB_EP_LEN
]
=
{
0
};
char
userBuf
[
TSDB_USER_LEN
]
=
{
0
};
char
userBuf
[
TSDB_USER_LEN
]
=
{
0
};
char
passBuf
[
TSDB_PASSWORD_LEN
]
=
{
0
};
char
passBuf
[
TSDB_PASSWORD_LEN
]
=
{
0
};
...
@@ -239,12 +254,12 @@ TAOS *taos_connect_c(const char *ip, uint8_t ipLen, const char *user, uint8_t us
...
@@ -239,12 +254,12 @@ TAOS *taos_connect_c(const char *ip, uint8_t ipLen, const char *user, uint8_t us
static
void
asyncConnCallback
(
void
*
param
,
TAOS_RES
*
tres
,
int
code
)
{
static
void
asyncConnCallback
(
void
*
param
,
TAOS_RES
*
tres
,
int
code
)
{
SSqlObj
*
pSql
=
(
SSqlObj
*
)
tres
;
SSqlObj
*
pSql
=
(
SSqlObj
*
)
tres
;
assert
(
pSql
!=
NULL
);
assert
(
pSql
!=
NULL
);
pSql
->
fetchFp
(
pSql
->
param
,
tres
,
code
);
pSql
->
fetchFp
(
pSql
->
param
,
tres
,
code
);
}
}
TAOS
*
taos_connect_a
(
char
*
ip
,
char
*
user
,
char
*
pass
,
char
*
db
,
uint16_t
port
,
void
(
*
fp
)(
void
*
,
TAOS_RES
*
,
int
),
TAOS
*
taos_connect_a
(
char
*
ip
,
char
*
user
,
char
*
pass
,
char
*
db
,
uint16_t
port
,
void
(
*
fp
)(
void
*
,
TAOS_RES
*
,
int
),
void
*
param
,
TAOS
**
taos
)
{
void
*
param
,
TAOS
**
taos
)
{
STscObj
*
pObj
=
NULL
;
STscObj
*
pObj
=
NULL
;
SSqlObj
*
pSql
=
taosConnectImpl
(
ip
,
user
,
pass
,
NULL
,
db
,
port
,
asyncConnCallback
,
param
,
(
void
**
)
&
pObj
);
SSqlObj
*
pSql
=
taosConnectImpl
(
ip
,
user
,
pass
,
NULL
,
db
,
port
,
asyncConnCallback
,
param
,
(
void
**
)
&
pObj
);
if
(
pSql
==
NULL
)
{
if
(
pSql
==
NULL
)
{
...
@@ -304,7 +319,7 @@ void taos_close(TAOS *taos) {
...
@@ -304,7 +319,7 @@ void taos_close(TAOS *taos) {
void
waitForQueryRsp
(
void
*
param
,
TAOS_RES
*
tres
,
int
code
)
{
void
waitForQueryRsp
(
void
*
param
,
TAOS_RES
*
tres
,
int
code
)
{
assert
(
tres
!=
NULL
);
assert
(
tres
!=
NULL
);
SSqlObj
*
pSql
=
(
SSqlObj
*
)
tres
;
SSqlObj
*
pSql
=
(
SSqlObj
*
)
tres
;
tsem_post
(
&
pSql
->
rspSem
);
tsem_post
(
&
pSql
->
rspSem
);
}
}
...
@@ -320,7 +335,7 @@ TAOS_RES* taos_query_c(TAOS *taos, const char *sqlstr, uint32_t sqlLen, TAOS_RES
...
@@ -320,7 +335,7 @@ TAOS_RES* taos_query_c(TAOS *taos, const char *sqlstr, uint32_t sqlLen, TAOS_RES
terrno
=
TSDB_CODE_TSC_DISCONNECTED
;
terrno
=
TSDB_CODE_TSC_DISCONNECTED
;
return
NULL
;
return
NULL
;
}
}
if
(
sqlLen
>
(
uint32_t
)
tsMaxSQLStringLen
)
{
if
(
sqlLen
>
(
uint32_t
)
tsMaxSQLStringLen
)
{
tscError
(
"sql string exceeds max length:%d"
,
tsMaxSQLStringLen
);
tscError
(
"sql string exceeds max length:%d"
,
tsMaxSQLStringLen
);
terrno
=
TSDB_CODE_TSC_INVALID_SQL
;
terrno
=
TSDB_CODE_TSC_INVALID_SQL
;
...
@@ -335,7 +350,7 @@ TAOS_RES* taos_query_c(TAOS *taos, const char *sqlstr, uint32_t sqlLen, TAOS_RES
...
@@ -335,7 +350,7 @@ TAOS_RES* taos_query_c(TAOS *taos, const char *sqlstr, uint32_t sqlLen, TAOS_RES
terrno
=
TSDB_CODE_TSC_OUT_OF_MEMORY
;
terrno
=
TSDB_CODE_TSC_OUT_OF_MEMORY
;
return
NULL
;
return
NULL
;
}
}
tsem_init
(
&
pSql
->
rspSem
,
0
,
0
);
tsem_init
(
&
pSql
->
rspSem
,
0
,
0
);
doAsyncQuery
(
pObj
,
pSql
,
waitForQueryRsp
,
taos
,
sqlstr
,
sqlLen
);
doAsyncQuery
(
pObj
,
pSql
,
waitForQueryRsp
,
taos
,
sqlstr
,
sqlLen
);
...
@@ -381,7 +396,7 @@ int taos_num_fields(TAOS_RES *res) {
...
@@ -381,7 +396,7 @@ int taos_num_fields(TAOS_RES *res) {
num
++
;
num
++
;
}
}
}
}
return
num
;
return
num
;
}
}
...
@@ -407,7 +422,7 @@ TAOS_FIELD *taos_fetch_fields(TAOS_RES *res) {
...
@@ -407,7 +422,7 @@ TAOS_FIELD *taos_fetch_fields(TAOS_RES *res) {
if
(
pQueryInfo
==
NULL
)
{
if
(
pQueryInfo
==
NULL
)
{
return
NULL
;
return
NULL
;
}
}
size_t
numOfCols
=
tscNumOfFields
(
pQueryInfo
);
size_t
numOfCols
=
tscNumOfFields
(
pQueryInfo
);
if
(
numOfCols
==
0
)
{
if
(
numOfCols
==
0
)
{
return
NULL
;
return
NULL
;
...
@@ -497,10 +512,10 @@ TAOS_ROW taos_fetch_row(TAOS_RES *res) {
...
@@ -497,10 +512,10 @@ TAOS_ROW taos_fetch_row(TAOS_RES *res) {
terrno
=
TSDB_CODE_TSC_DISCONNECTED
;
terrno
=
TSDB_CODE_TSC_DISCONNECTED
;
return
NULL
;
return
NULL
;
}
}
SSqlCmd
*
pCmd
=
&
pSql
->
cmd
;
SSqlCmd
*
pCmd
=
&
pSql
->
cmd
;
SSqlRes
*
pRes
=
&
pSql
->
res
;
SSqlRes
*
pRes
=
&
pSql
->
res
;
if
(
pRes
->
qhandle
==
0
||
if
(
pRes
->
qhandle
==
0
||
pRes
->
code
==
TSDB_CODE_TSC_QUERY_CANCELLED
||
pRes
->
code
==
TSDB_CODE_TSC_QUERY_CANCELLED
||
pCmd
->
command
==
TSDB_SQL_RETRIEVE_EMPTY_RESULT
||
pCmd
->
command
==
TSDB_SQL_RETRIEVE_EMPTY_RESULT
||
...
@@ -597,7 +612,7 @@ int taos_select_db(TAOS *taos, const char *db) {
...
@@ -597,7 +612,7 @@ int taos_select_db(TAOS *taos, const char *db) {
SSqlObj
*
pSql
=
taos_query
(
taos
,
sql
);
SSqlObj
*
pSql
=
taos_query
(
taos
,
sql
);
int32_t
code
=
pSql
->
res
.
code
;
int32_t
code
=
pSql
->
res
.
code
;
taos_free_result
(
pSql
);
taos_free_result
(
pSql
);
return
code
;
return
code
;
}
}
...
@@ -673,10 +688,10 @@ static bool hasAdditionalErrorInfo(int32_t code, SSqlCmd *pCmd) {
...
@@ -673,10 +688,10 @@ static bool hasAdditionalErrorInfo(int32_t code, SSqlCmd *pCmd) {
char
*
z
=
NULL
;
char
*
z
=
NULL
;
if
(
len
>
0
)
{
if
(
len
>
0
)
{
z
=
strstr
(
pCmd
->
payload
,
"invalid SQL"
);
z
=
strstr
(
pCmd
->
payload
,
"invalid SQL"
);
if
(
z
==
NULL
)
{
if
(
z
==
NULL
)
{
z
=
strstr
(
pCmd
->
payload
,
"syntax error"
);
z
=
strstr
(
pCmd
->
payload
,
"syntax error"
);
}
}
}
}
return
z
!=
NULL
;
return
z
!=
NULL
;
}
}
...
@@ -714,7 +729,7 @@ int* taos_fetch_lengths(TAOS_RES *res) {
...
@@ -714,7 +729,7 @@ int* taos_fetch_lengths(TAOS_RES *res) {
if
(
pSql
==
NULL
||
pSql
->
signature
!=
pSql
)
{
if
(
pSql
==
NULL
||
pSql
->
signature
!=
pSql
)
{
return
NULL
;
return
NULL
;
}
}
return
pSql
->
res
.
length
;
return
pSql
->
res
.
length
;
}
}
...
@@ -819,36 +834,36 @@ int taos_print_row(char *str, TAOS_ROW row, TAOS_FIELD *fields, int num_fields)
...
@@ -819,36 +834,36 @@ int taos_print_row(char *str, TAOS_ROW row, TAOS_FIELD *fields, int num_fields)
break
;
break
;
case
TSDB_DATA_TYPE_FLOAT
:
{
case
TSDB_DATA_TYPE_FLOAT
:
{
float
fv
=
0
;
float
fv
=
0
;
fv
=
GET_FLOAT_VAL
(
row
[
i
]);
fv
=
GET_FLOAT_VAL
(
row
[
i
]);
len
+=
sprintf
(
str
+
len
,
"%f"
,
fv
);
len
+=
sprintf
(
str
+
len
,
"%f"
,
fv
);
}
break
;
}
break
;
case
TSDB_DATA_TYPE_DOUBLE
:
{
case
TSDB_DATA_TYPE_DOUBLE
:
{
double
dv
=
0
;
double
dv
=
0
;
dv
=
GET_DOUBLE_VAL
(
row
[
i
]);
dv
=
GET_DOUBLE_VAL
(
row
[
i
]);
len
+=
sprintf
(
str
+
len
,
"%lf"
,
dv
);
len
+=
sprintf
(
str
+
len
,
"%lf"
,
dv
);
}
break
;
}
break
;
case
TSDB_DATA_TYPE_BINARY
:
case
TSDB_DATA_TYPE_BINARY
:
case
TSDB_DATA_TYPE_NCHAR
:
{
case
TSDB_DATA_TYPE_NCHAR
:
{
size_t
xlen
=
0
;
size_t
xlen
=
0
;
for
(
xlen
=
0
;
xlen
<
fields
[
i
].
bytes
-
VARSTR_HEADER_SIZE
;
xlen
++
)
{
for
(
xlen
=
0
;
xlen
<
fields
[
i
].
bytes
-
VARSTR_HEADER_SIZE
;
xlen
++
)
{
char
c
=
((
char
*
)
row
[
i
])[
xlen
];
char
c
=
((
char
*
)
row
[
i
])[
xlen
];
if
(
c
==
0
)
break
;
if
(
c
==
0
)
break
;
str
[
len
++
]
=
c
;
str
[
len
++
]
=
c
;
}
}
str
[
len
]
=
0
;
str
[
len
]
=
0
;
}
break
;
}
break
;
case
TSDB_DATA_TYPE_TIMESTAMP
:
case
TSDB_DATA_TYPE_TIMESTAMP
:
len
+=
sprintf
(
str
+
len
,
"%"
PRId64
,
*
((
int64_t
*
)
row
[
i
]));
len
+=
sprintf
(
str
+
len
,
"%"
PRId64
,
*
((
int64_t
*
)
row
[
i
]));
break
;
break
;
case
TSDB_DATA_TYPE_BOOL
:
case
TSDB_DATA_TYPE_BOOL
:
len
+=
sprintf
(
str
+
len
,
"%d"
,
*
((
int8_t
*
)
row
[
i
]));
len
+=
sprintf
(
str
+
len
,
"%d"
,
*
((
int8_t
*
)
row
[
i
]));
default:
default:
break
;
break
;
}
}
}
}
...
@@ -876,7 +891,7 @@ int taos_validate_sql(TAOS *taos, const char *sql) {
...
@@ -876,7 +891,7 @@ int taos_validate_sql(TAOS *taos, const char *sql) {
SSqlRes
*
pRes
=
&
pSql
->
res
;
SSqlRes
*
pRes
=
&
pSql
->
res
;
SSqlCmd
*
pCmd
=
&
pSql
->
cmd
;
SSqlCmd
*
pCmd
=
&
pSql
->
cmd
;
pRes
->
numOfTotal
=
0
;
pRes
->
numOfTotal
=
0
;
pRes
->
numOfClauseTotal
=
0
;
pRes
->
numOfClauseTotal
=
0
;
...
...
src/client/src/tscSystem.c
浏览文件 @
367fac8b
...
@@ -116,11 +116,6 @@ void taos_init_imp(void) {
...
@@ -116,11 +116,6 @@ void taos_init_imp(void) {
taosInitNote
(
tsNumOfLogLines
/
10
,
1
,
(
char
*
)
"tsc_note"
);
taosInitNote
(
tsNumOfLogLines
/
10
,
1
,
(
char
*
)
"tsc_note"
);
}
}
if
(
tscSetMgmtEpSetFromCfg
(
tsFirst
,
tsSecond
)
<
0
)
{
tscError
(
"failed to init mnode EP list"
);
return
;
}
tscInitMsgsFp
();
tscInitMsgsFp
();
int
queueSize
=
tsMaxConnections
*
2
;
int
queueSize
=
tsMaxConnections
*
2
;
...
...
src/client/src/tscUtil.c
浏览文件 @
367fac8b
...
@@ -783,7 +783,7 @@ void tscCloseTscObj(void *param) {
...
@@ -783,7 +783,7 @@ void tscCloseTscObj(void *param) {
rpcClose
(
pObj
->
pDnodeConn
);
rpcClose
(
pObj
->
pDnodeConn
);
pObj
->
pDnodeConn
=
NULL
;
pObj
->
pDnodeConn
=
NULL
;
}
}
tfree
(
pObj
->
tscCorMgmtEpSet
);
pthread_mutex_destroy
(
&
pObj
->
mutex
);
pthread_mutex_destroy
(
&
pObj
->
mutex
);
tscDebug
(
"%p DB connection is closed, dnodeConn:%p"
,
pObj
,
p
);
tscDebug
(
"%p DB connection is closed, dnodeConn:%p"
,
pObj
,
p
);
...
@@ -2378,10 +2378,10 @@ char* strdup_throw(const char* str) {
...
@@ -2378,10 +2378,10 @@ char* strdup_throw(const char* str) {
return
p
;
return
p
;
}
}
int
tscSetMgmtEpSetFromCfg
(
const
char
*
first
,
const
char
*
second
)
{
int
tscSetMgmtEpSetFromCfg
(
const
char
*
first
,
const
char
*
second
,
SRpcCorEpSet
*
corMgmtEpSet
)
{
// init mgmt ip set
// init mgmt ip set
tscMgmtEpSet
.
version
=
0
;
corMgmtEpSet
->
version
=
0
;
SRpcEpSet
*
mgmtEpSet
=
&
(
tscMgmtEpSet
.
epSet
);
SRpcEpSet
*
mgmtEpSet
=
&
(
corMgmtEpSet
->
epSet
);
mgmtEpSet
->
numOfEps
=
0
;
mgmtEpSet
->
numOfEps
=
0
;
mgmtEpSet
->
inUse
=
0
;
mgmtEpSet
->
inUse
=
0
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录