Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
慢慢CG
TDengine
提交
59c6434a
T
TDengine
项目概览
慢慢CG
/
TDengine
与 Fork 源项目一致
Fork自
taosdata / TDengine
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
59c6434a
编写于
4月 24, 2020
作者:
H
hjxilinx
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[td-187] 1. support group by query, 2. fix memory leaks in client side. 3. refactor mgmtConn
上级
7ddbf619
变更
10
显示空白变更内容
内联
并排
Showing
10 changed file
with
44 addition
and
38 deletion
+44
-38
src/client/inc/tscUtil.h
src/client/inc/tscUtil.h
+2
-2
src/client/inc/tsclient.h
src/client/inc/tsclient.h
+2
-3
src/client/src/tscAsync.c
src/client/src/tscAsync.c
+1
-1
src/client/src/tscSQLParser.c
src/client/src/tscSQLParser.c
+1
-1
src/client/src/tscServer.c
src/client/src/tscServer.c
+3
-2
src/client/src/tscSql.c
src/client/src/tscSql.c
+3
-1
src/client/src/tscStream.c
src/client/src/tscStream.c
+3
-3
src/client/src/tscSystem.c
src/client/src/tscSystem.c
+7
-15
src/client/src/tscUtil.c
src/client/src/tscUtil.c
+20
-8
tests/examples/c/demo.c
tests/examples/c/demo.c
+2
-2
未找到文件。
src/client/inc/tscUtil.h
浏览文件 @
59c6434a
...
@@ -196,14 +196,14 @@ STableMetaInfo* tscGetMetaInfo(SQueryInfo *pQueryInfo, int32_t tableIndex);
...
@@ -196,14 +196,14 @@ STableMetaInfo* tscGetMetaInfo(SQueryInfo *pQueryInfo, int32_t tableIndex);
SQueryInfo
*
tscGetQueryInfoDetail
(
SSqlCmd
*
pCmd
,
int32_t
subClauseIndex
);
SQueryInfo
*
tscGetQueryInfoDetail
(
SSqlCmd
*
pCmd
,
int32_t
subClauseIndex
);
int32_t
tscGetQueryInfoDetailSafely
(
SSqlCmd
*
pCmd
,
int32_t
subClauseIndex
,
SQueryInfo
**
pQueryInfo
);
int32_t
tscGetQueryInfoDetailSafely
(
SSqlCmd
*
pCmd
,
int32_t
subClauseIndex
,
SQueryInfo
**
pQueryInfo
);
void
tscClear
Meter
MetaInfo
(
STableMetaInfo
*
pTableMetaInfo
,
bool
removeFromCache
);
void
tscClear
Table
MetaInfo
(
STableMetaInfo
*
pTableMetaInfo
,
bool
removeFromCache
);
STableMetaInfo
*
tscAddTableMetaInfo
(
SQueryInfo
*
pQueryInfo
,
const
char
*
name
,
STableMeta
*
pTableMeta
,
STableMetaInfo
*
tscAddTableMetaInfo
(
SQueryInfo
*
pQueryInfo
,
const
char
*
name
,
STableMeta
*
pTableMeta
,
SVgroupsInfo
*
vgroupList
,
SArray
*
pTagCols
);
SVgroupsInfo
*
vgroupList
,
SArray
*
pTagCols
);
STableMetaInfo
*
tscAddEmptyMetaInfo
(
SQueryInfo
*
pQueryInfo
);
STableMetaInfo
*
tscAddEmptyMetaInfo
(
SQueryInfo
*
pQueryInfo
);
int32_t
tscAddSubqueryInfo
(
SSqlCmd
*
pCmd
);
int32_t
tscAddSubqueryInfo
(
SSqlCmd
*
pCmd
);
void
tscFree
Subq
ueryInfo
(
SSqlCmd
*
pCmd
);
void
tscFree
Q
ueryInfo
(
SSqlCmd
*
pCmd
);
void
tscClearSubqueryInfo
(
SSqlCmd
*
pCmd
);
void
tscClearSubqueryInfo
(
SSqlCmd
*
pCmd
);
int
tscGetSTableVgroupInfo
(
SSqlObj
*
pSql
,
int32_t
clauseIndex
);
int
tscGetSTableVgroupInfo
(
SSqlObj
*
pSql
,
int32_t
clauseIndex
);
...
...
src/client/inc/tsclient.h
浏览文件 @
59c6434a
...
@@ -298,6 +298,7 @@ typedef struct STscObj {
...
@@ -298,6 +298,7 @@ typedef struct STscObj {
char
sversion
[
TSDB_VERSION_LEN
];
char
sversion
[
TSDB_VERSION_LEN
];
char
writeAuth
:
1
;
char
writeAuth
:
1
;
char
superAuth
:
1
;
char
superAuth
:
1
;
void
*
pMgmtConn
;
struct
SSqlObj
*
pSql
;
struct
SSqlObj
*
pSql
;
struct
SSqlObj
*
pHb
;
struct
SSqlObj
*
pHb
;
struct
SSqlObj
*
sqlList
;
struct
SSqlObj
*
sqlList
;
...
@@ -359,7 +360,7 @@ typedef struct SSqlStream {
...
@@ -359,7 +360,7 @@ typedef struct SSqlStream {
struct
SSqlStream
*
prev
,
*
next
;
struct
SSqlStream
*
prev
,
*
next
;
}
SSqlStream
;
}
SSqlStream
;
int32_t
tscInitRpc
(
const
char
*
user
,
const
char
*
secret
);
int32_t
tscInitRpc
(
const
char
*
user
,
const
char
*
secret
,
void
**
pMgmtConn
);
void
tscInitMsgsFp
();
void
tscInitMsgsFp
();
int
tsParseSql
(
SSqlObj
*
pSql
,
bool
multiVnodeInsertion
);
int
tsParseSql
(
SSqlObj
*
pSql
,
bool
multiVnodeInsertion
);
...
@@ -427,9 +428,7 @@ int32_t tscToSQLCmd(SSqlObj *pSql, struct SSqlInfo *pInfo);
...
@@ -427,9 +428,7 @@ int32_t tscToSQLCmd(SSqlObj *pSql, struct SSqlInfo *pInfo);
char
*
tscGetResultColumnChr
(
SSqlRes
*
pRes
,
SQueryInfo
*
pQueryInfo
,
int32_t
column
);
char
*
tscGetResultColumnChr
(
SSqlRes
*
pRes
,
SQueryInfo
*
pQueryInfo
,
int32_t
column
);
extern
void
*
pVnodeConn
;
extern
void
*
pVnodeConn
;
extern
void
*
pTscMgmtConn
;
extern
void
*
tscCacheHandle
;
extern
void
*
tscCacheHandle
;
extern
int
slaveIndex
;
extern
void
*
tscTmr
;
extern
void
*
tscTmr
;
extern
void
*
tscQhandle
;
extern
void
*
tscQhandle
;
extern
int
tscKeepConn
[];
extern
int
tscKeepConn
[];
...
...
src/client/src/tscAsync.c
浏览文件 @
59c6434a
...
@@ -46,7 +46,7 @@ void doAsyncQuery(STscObj* pObj, SSqlObj* pSql, void (*fp)(), void* param, const
...
@@ -46,7 +46,7 @@ void doAsyncQuery(STscObj* pObj, SSqlObj* pSql, void (*fp)(), void* param, const
pSql
->
signature
=
pSql
;
pSql
->
signature
=
pSql
;
pSql
->
param
=
param
;
pSql
->
param
=
param
;
pSql
->
pTscObj
=
pObj
;
pSql
->
pTscObj
=
pObj
;
pSql
->
maxRetry
=
1
;
pSql
->
maxRetry
=
TSDB_REPLICA_MAX_NUM
;
pSql
->
fp
=
fp
;
pSql
->
fp
=
fp
;
if
(
TSDB_CODE_SUCCESS
!=
tscAllocPayload
(
pCmd
,
TSDB_DEFAULT_PAYLOAD_SIZE
))
{
if
(
TSDB_CODE_SUCCESS
!=
tscAllocPayload
(
pCmd
,
TSDB_DEFAULT_PAYLOAD_SIZE
))
{
...
...
src/client/src/tscSQLParser.c
浏览文件 @
59c6434a
...
@@ -733,7 +733,7 @@ int32_t tscSetTableId(STableMetaInfo* pTableMetaInfo, SSQLToken* pzTableName, SS
...
@@ -733,7 +733,7 @@ int32_t tscSetTableId(STableMetaInfo* pTableMetaInfo, SSQLToken* pzTableName, SS
*/
*/
if
(
size
>
0
)
{
if
(
size
>
0
)
{
if
(
strncasecmp
(
oldName
,
pTableMetaInfo
->
name
,
tListLen
(
pTableMetaInfo
->
name
))
!=
0
)
{
if
(
strncasecmp
(
oldName
,
pTableMetaInfo
->
name
,
tListLen
(
pTableMetaInfo
->
name
))
!=
0
)
{
tscClear
Meter
MetaInfo
(
pTableMetaInfo
,
false
);
tscClear
Table
MetaInfo
(
pTableMetaInfo
,
false
);
}
}
}
else
{
}
else
{
assert
(
pTableMetaInfo
->
pTableMeta
==
NULL
);
assert
(
pTableMetaInfo
->
pTableMeta
==
NULL
);
...
...
src/client/src/tscServer.c
浏览文件 @
59c6434a
...
@@ -188,6 +188,7 @@ void tscProcessActivityTimer(void *handle, void *tmrId) {
...
@@ -188,6 +188,7 @@ void tscProcessActivityTimer(void *handle, void *tmrId) {
}
}
int
tscSendMsgToServer
(
SSqlObj
*
pSql
)
{
int
tscSendMsgToServer
(
SSqlObj
*
pSql
)
{
STscObj
*
pObj
=
pSql
->
pTscObj
;
SSqlCmd
*
pCmd
=
&
pSql
->
cmd
;
SSqlCmd
*
pCmd
=
&
pSql
->
cmd
;
char
*
pMsg
=
rpcMallocCont
(
pCmd
->
payloadLen
);
char
*
pMsg
=
rpcMallocCont
(
pCmd
->
payloadLen
);
...
@@ -221,7 +222,7 @@ int tscSendMsgToServer(SSqlObj *pSql) {
...
@@ -221,7 +222,7 @@ int tscSendMsgToServer(SSqlObj *pSql) {
.
handle
=
pSql
,
.
handle
=
pSql
,
.
code
=
0
.
code
=
0
};
};
rpcSendRequest
(
p
Tsc
MgmtConn
,
&
pSql
->
ipList
,
&
rpcMsg
);
rpcSendRequest
(
p
Obj
->
p
MgmtConn
,
&
pSql
->
ipList
,
&
rpcMsg
);
}
}
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
...
@@ -2597,7 +2598,7 @@ int tscGetSTableVgroupInfo(SSqlObj *pSql, int32_t clauseIndex) {
...
@@ -2597,7 +2598,7 @@ int tscGetSTableVgroupInfo(SSqlObj *pSql, int32_t clauseIndex) {
// if (pSql->fp != NULL && pSql->pStream == NULL) {
// if (pSql->fp != NULL && pSql->pStream == NULL) {
// pCmd->pDataBlocks = tscDestroyBlockArrayList(pCmd->pDataBlocks);
// pCmd->pDataBlocks = tscDestroyBlockArrayList(pCmd->pDataBlocks);
// tscFree
Subq
ueryInfo(pCmd);
// tscFree
Q
ueryInfo(pCmd);
// }
// }
tscTrace
(
"%p allocate new pSqlObj:%p to get stable vgroupInfo"
,
pSql
,
pNew
);
tscTrace
(
"%p allocate new pSqlObj:%p to get stable vgroupInfo"
,
pSql
,
pNew
);
...
...
src/client/src/tscSql.c
浏览文件 @
59c6434a
...
@@ -66,7 +66,8 @@ STscObj *taosConnectImpl(const char *ip, const char *user, const char *pass, con
...
@@ -66,7 +66,8 @@ STscObj *taosConnectImpl(const char *ip, const char *user, const char *pass, con
return
NULL
;
return
NULL
;
}
}
if
(
tscInitRpc
(
user
,
pass
)
!=
0
)
{
void
*
pMgmtConn
=
NULL
;
if
(
tscInitRpc
(
user
,
pass
,
&
pMgmtConn
)
!=
0
)
{
terrno
=
TSDB_CODE_NETWORK_UNAVAIL
;
terrno
=
TSDB_CODE_NETWORK_UNAVAIL
;
return
NULL
;
return
NULL
;
}
}
...
@@ -118,6 +119,7 @@ STscObj *taosConnectImpl(const char *ip, const char *user, const char *pass, con
...
@@ -118,6 +119,7 @@ STscObj *taosConnectImpl(const char *ip, const char *user, const char *pass, con
strtolower
(
pObj
->
db
,
tmp
);
strtolower
(
pObj
->
db
,
tmp
);
}
}
pObj
->
pMgmtConn
=
pMgmtConn
;
pthread_mutex_init
(
&
pObj
->
mutex
,
NULL
);
pthread_mutex_init
(
&
pObj
->
mutex
,
NULL
);
SSqlObj
*
pSql
=
(
SSqlObj
*
)
calloc
(
1
,
sizeof
(
SSqlObj
));
SSqlObj
*
pSql
=
(
SSqlObj
*
)
calloc
(
1
,
sizeof
(
SSqlObj
));
...
...
src/client/src/tscStream.c
浏览文件 @
59c6434a
...
@@ -147,7 +147,7 @@ static void tscProcessStreamQueryCallback(void *param, TAOS_RES *tres, int numOf
...
@@ -147,7 +147,7 @@ static void tscProcessStreamQueryCallback(void *param, TAOS_RES *tres, int numOf
retryDelay
);
retryDelay
);
STableMetaInfo
*
pTableMetaInfo
=
tscGetTableMetaInfoFromCmd
(
&
pStream
->
pSql
->
cmd
,
0
,
0
);
STableMetaInfo
*
pTableMetaInfo
=
tscGetTableMetaInfoFromCmd
(
&
pStream
->
pSql
->
cmd
,
0
,
0
);
tscClear
Meter
MetaInfo
(
pTableMetaInfo
,
true
);
tscClear
Table
MetaInfo
(
pTableMetaInfo
,
true
);
tscSetRetryTimer
(
pStream
,
pStream
->
pSql
,
retryDelay
);
tscSetRetryTimer
(
pStream
,
pStream
->
pSql
,
retryDelay
);
return
;
return
;
...
@@ -177,7 +177,7 @@ static void tscProcessStreamRetrieveResult(void *param, TAOS_RES *res, int numOf
...
@@ -177,7 +177,7 @@ static void tscProcessStreamRetrieveResult(void *param, TAOS_RES *res, int numOf
if
(
pSql
==
NULL
||
numOfRows
<
0
)
{
if
(
pSql
==
NULL
||
numOfRows
<
0
)
{
int64_t
retryDelayTime
=
tscGetRetryDelayTime
(
pStream
->
slidingTime
,
pStream
->
precision
);
int64_t
retryDelayTime
=
tscGetRetryDelayTime
(
pStream
->
slidingTime
,
pStream
->
precision
);
tscError
(
"%p stream:%p, retrieve data failed, code:%d, retry in %"
PRId64
"ms"
,
pSql
,
pStream
,
numOfRows
,
retryDelayTime
);
tscError
(
"%p stream:%p, retrieve data failed, code:%d, retry in %"
PRId64
"ms"
,
pSql
,
pStream
,
numOfRows
,
retryDelayTime
);
tscClear
Meter
MetaInfo
(
pTableMetaInfo
,
true
);
tscClear
Table
MetaInfo
(
pTableMetaInfo
,
true
);
tscSetRetryTimer
(
pStream
,
pStream
->
pSql
,
retryDelayTime
);
tscSetRetryTimer
(
pStream
,
pStream
->
pSql
,
retryDelayTime
);
return
;
return
;
...
@@ -259,7 +259,7 @@ static void tscProcessStreamRetrieveResult(void *param, TAOS_RES *res, int numOf
...
@@ -259,7 +259,7 @@ static void tscProcessStreamRetrieveResult(void *param, TAOS_RES *res, int numOf
pStream
->
numOfRes
);
pStream
->
numOfRes
);
// release the metric/meter meta information reference, so data in cache can be updated
// release the metric/meter meta information reference, so data in cache can be updated
tscClear
Meter
MetaInfo
(
pTableMetaInfo
,
false
);
tscClear
Table
MetaInfo
(
pTableMetaInfo
,
false
);
tscSetNextLaunchTimer
(
pStream
,
pSql
);
tscSetNextLaunchTimer
(
pStream
,
pSql
);
}
}
}
}
...
...
src/client/src/tscSystem.c
浏览文件 @
59c6434a
...
@@ -33,9 +33,6 @@
...
@@ -33,9 +33,6 @@
// global, not configurable
// global, not configurable
void
*
pVnodeConn
;
void
*
pVnodeConn
;
void
*
pVMeterConn
;
void
*
pTscMgmtConn
;
void
*
pSlaveConn
;
void
*
tscCacheHandle
;
void
*
tscCacheHandle
;
int
slaveIndex
;
int
slaveIndex
;
void
*
tscTmr
;
void
*
tscTmr
;
...
@@ -55,7 +52,7 @@ void tscCheckDiskUsage(void *para, void *unused) {
...
@@ -55,7 +52,7 @@ void tscCheckDiskUsage(void *para, void *unused) {
taosTmrReset
(
tscCheckDiskUsage
,
1000
,
NULL
,
tscTmr
,
&
tscCheckDiskUsageTmr
);
taosTmrReset
(
tscCheckDiskUsage
,
1000
,
NULL
,
tscTmr
,
&
tscCheckDiskUsageTmr
);
}
}
int32_t
tscInitRpc
(
const
char
*
user
,
const
char
*
secret
)
{
int32_t
tscInitRpc
(
const
char
*
user
,
const
char
*
secret
,
void
**
pMgmtConn
)
{
SRpcInit
rpcInit
;
SRpcInit
rpcInit
;
char
secretEncrypt
[
32
]
=
{
0
};
char
secretEncrypt
[
32
]
=
{
0
};
taosEncryptPass
((
uint8_t
*
)
secret
,
strlen
(
secret
),
secretEncrypt
);
taosEncryptPass
((
uint8_t
*
)
secret
,
strlen
(
secret
),
secretEncrypt
);
...
@@ -83,13 +80,13 @@ int32_t tscInitRpc(const char *user, const char *secret) {
...
@@ -83,13 +80,13 @@ int32_t tscInitRpc(const char *user, const char *secret) {
}
}
// not stop service, switch users
// not stop service, switch users
if
(
strcmp
(
tsLastUser
,
user
)
!=
0
&&
pTsc
MgmtConn
!=
NULL
)
{
if
(
strcmp
(
tsLastUser
,
user
)
!=
0
&&
*
p
MgmtConn
!=
NULL
)
{
tscTrace
(
"switch user from %s to %s"
,
user
,
tsLastUser
);
tscTrace
(
"switch user from %s to %s"
,
user
,
tsLastUser
);
rpcClose
(
pTsc
MgmtConn
);
rpcClose
(
*
p
MgmtConn
);
pTsc
MgmtConn
=
NULL
;
*
p
MgmtConn
=
NULL
;
}
}
if
(
pTsc
MgmtConn
==
NULL
)
{
if
(
*
p
MgmtConn
==
NULL
)
{
memset
(
&
rpcInit
,
0
,
sizeof
(
rpcInit
));
memset
(
&
rpcInit
,
0
,
sizeof
(
rpcInit
));
rpcInit
.
localIp
=
tsLocalIp
;
rpcInit
.
localIp
=
tsLocalIp
;
rpcInit
.
localPort
=
0
;
rpcInit
.
localPort
=
0
;
...
@@ -104,8 +101,8 @@ int32_t tscInitRpc(const char *user, const char *secret) {
...
@@ -104,8 +101,8 @@ int32_t tscInitRpc(const char *user, const char *secret) {
rpcInit
.
secret
=
secretEncrypt
;
rpcInit
.
secret
=
secretEncrypt
;
strcpy
(
tsLastUser
,
user
);
strcpy
(
tsLastUser
,
user
);
pTsc
MgmtConn
=
rpcOpen
(
&
rpcInit
);
*
p
MgmtConn
=
rpcOpen
(
&
rpcInit
);
if
(
pTsc
MgmtConn
==
NULL
)
{
if
(
*
p
MgmtConn
==
NULL
)
{
tscError
(
"failed to init connection to mgmt"
);
tscError
(
"failed to init connection to mgmt"
);
return
-
1
;
return
-
1
;
}
}
...
@@ -219,11 +216,6 @@ void taos_cleanup() {
...
@@ -219,11 +216,6 @@ void taos_cleanup() {
pVnodeConn
=
NULL
;
pVnodeConn
=
NULL
;
}
}
if
(
pTscMgmtConn
!=
NULL
)
{
rpcClose
(
pTscMgmtConn
);
pTscMgmtConn
=
NULL
;
}
taosTmrCleanUp
(
tscTmr
);
taosTmrCleanUp
(
tscTmr
);
}
}
...
...
src/client/src/tscUtil.c
浏览文件 @
59c6434a
...
@@ -337,7 +337,7 @@ void tscResetSqlCmdObj(SSqlCmd* pCmd) {
...
@@ -337,7 +337,7 @@ void tscResetSqlCmdObj(SSqlCmd* pCmd) {
pCmd
->
pTableList
=
NULL
;
pCmd
->
pTableList
=
NULL
;
pCmd
->
pDataBlocks
=
tscDestroyBlockArrayList
(
pCmd
->
pDataBlocks
);
pCmd
->
pDataBlocks
=
tscDestroyBlockArrayList
(
pCmd
->
pDataBlocks
);
tscFree
Subq
ueryInfo
(
pCmd
);
tscFree
Q
ueryInfo
(
pCmd
);
}
}
/*
/*
...
@@ -761,6 +761,8 @@ void tscCloseTscObj(STscObj* pObj) {
...
@@ -761,6 +761,8 @@ void tscCloseTscObj(STscObj* pObj) {
tscFreeSqlObj
(
pSql
);
tscFreeSqlObj
(
pSql
);
sem_destroy
(
&
pSql
->
rspSem
);
sem_destroy
(
&
pSql
->
rspSem
);
rpcClose
(
pObj
->
pMgmtConn
);
pthread_mutex_destroy
(
&
pObj
->
mutex
);
pthread_mutex_destroy
(
&
pObj
->
mutex
);
tscTrace
(
"%p DB connection is closed"
,
pObj
);
tscTrace
(
"%p DB connection is closed"
,
pObj
);
...
@@ -1459,7 +1461,7 @@ bool tscShouldFreeHeatBeat(SSqlObj* pHb) {
...
@@ -1459,7 +1461,7 @@ bool tscShouldFreeHeatBeat(SSqlObj* pHb) {
void
tscCleanSqlCmd
(
SSqlCmd
*
pCmd
)
{
void
tscCleanSqlCmd
(
SSqlCmd
*
pCmd
)
{
pCmd
->
pDataBlocks
=
tscDestroyBlockArrayList
(
pCmd
->
pDataBlocks
);
pCmd
->
pDataBlocks
=
tscDestroyBlockArrayList
(
pCmd
->
pDataBlocks
);
tscFree
Subq
ueryInfo
(
pCmd
);
tscFree
Q
ueryInfo
(
pCmd
);
uint32_t
allocSize
=
pCmd
->
allocSize
;
uint32_t
allocSize
=
pCmd
->
allocSize
;
char
*
allocPtr
=
pCmd
->
payload
;
char
*
allocPtr
=
pCmd
->
payload
;
...
@@ -1601,7 +1603,7 @@ int32_t tscAddSubqueryInfo(SSqlCmd* pCmd) {
...
@@ -1601,7 +1603,7 @@ int32_t tscAddSubqueryInfo(SSqlCmd* pCmd) {
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
static
void
doClearSubqueryInfo
(
SQueryInfo
*
pQueryInfo
)
{
static
void
freeQueryInfoImpl
(
SQueryInfo
*
pQueryInfo
)
{
tscTagCondRelease
(
&
pQueryInfo
->
tagCond
);
tscTagCondRelease
(
&
pQueryInfo
->
tagCond
);
tscFieldInfoClear
(
&
pQueryInfo
->
fieldsInfo
);
tscFieldInfoClear
(
&
pQueryInfo
->
fieldsInfo
);
...
@@ -1611,6 +1613,11 @@ static void doClearSubqueryInfo(SQueryInfo* pQueryInfo) {
...
@@ -1611,6 +1613,11 @@ static void doClearSubqueryInfo(SQueryInfo* pQueryInfo) {
tscColumnListDestroy
(
pQueryInfo
->
colList
);
tscColumnListDestroy
(
pQueryInfo
->
colList
);
memset
(
&
pQueryInfo
->
colList
,
0
,
sizeof
(
pQueryInfo
->
colList
));
memset
(
&
pQueryInfo
->
colList
,
0
,
sizeof
(
pQueryInfo
->
colList
));
if
(
pQueryInfo
->
groupbyExpr
.
columnInfo
!=
NULL
)
{
taosArrayDestroy
(
pQueryInfo
->
groupbyExpr
.
columnInfo
);
pQueryInfo
->
groupbyExpr
.
columnInfo
=
NULL
;
}
pQueryInfo
->
tsBuf
=
tsBufDestory
(
pQueryInfo
->
tsBuf
);
pQueryInfo
->
tsBuf
=
tsBufDestory
(
pQueryInfo
->
tsBuf
);
tfree
(
pQueryInfo
->
defaultVal
);
tfree
(
pQueryInfo
->
defaultVal
);
...
@@ -1619,11 +1626,11 @@ static void doClearSubqueryInfo(SQueryInfo* pQueryInfo) {
...
@@ -1619,11 +1626,11 @@ static void doClearSubqueryInfo(SQueryInfo* pQueryInfo) {
void
tscClearSubqueryInfo
(
SSqlCmd
*
pCmd
)
{
void
tscClearSubqueryInfo
(
SSqlCmd
*
pCmd
)
{
for
(
int32_t
i
=
0
;
i
<
pCmd
->
numOfClause
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
pCmd
->
numOfClause
;
++
i
)
{
SQueryInfo
*
pQueryInfo
=
tscGetQueryInfoDetail
(
pCmd
,
i
);
SQueryInfo
*
pQueryInfo
=
tscGetQueryInfoDetail
(
pCmd
,
i
);
doClearSubqueryInfo
(
pQueryInfo
);
freeQueryInfoImpl
(
pQueryInfo
);
}
}
}
}
void
tscFree
Subq
ueryInfo
(
SSqlCmd
*
pCmd
)
{
void
tscFree
Q
ueryInfo
(
SSqlCmd
*
pCmd
)
{
if
(
pCmd
==
NULL
||
pCmd
->
numOfClause
==
0
)
{
if
(
pCmd
==
NULL
||
pCmd
->
numOfClause
==
0
)
{
return
;
return
;
}
}
...
@@ -1632,7 +1639,7 @@ void tscFreeSubqueryInfo(SSqlCmd* pCmd) {
...
@@ -1632,7 +1639,7 @@ void tscFreeSubqueryInfo(SSqlCmd* pCmd) {
char
*
addr
=
(
char
*
)
pCmd
-
offsetof
(
SSqlObj
,
cmd
);
char
*
addr
=
(
char
*
)
pCmd
-
offsetof
(
SSqlObj
,
cmd
);
SQueryInfo
*
pQueryInfo
=
tscGetQueryInfoDetail
(
pCmd
,
i
);
SQueryInfo
*
pQueryInfo
=
tscGetQueryInfoDetail
(
pCmd
,
i
);
doClearSubqueryInfo
(
pQueryInfo
);
freeQueryInfoImpl
(
pQueryInfo
);
tscClearAllTableMetaInfo
(
pQueryInfo
,
(
const
char
*
)
addr
,
false
);
tscClearAllTableMetaInfo
(
pQueryInfo
,
(
const
char
*
)
addr
,
false
);
tfree
(
pQueryInfo
);
tfree
(
pQueryInfo
);
}
}
...
@@ -1691,7 +1698,7 @@ void doRemoveTableMetaInfo(SQueryInfo* pQueryInfo, int32_t index, bool removeFro
...
@@ -1691,7 +1698,7 @@ void doRemoveTableMetaInfo(SQueryInfo* pQueryInfo, int32_t index, bool removeFro
STableMetaInfo
*
pTableMetaInfo
=
tscGetMetaInfo
(
pQueryInfo
,
index
);
STableMetaInfo
*
pTableMetaInfo
=
tscGetMetaInfo
(
pQueryInfo
,
index
);
tscClear
Meter
MetaInfo
(
pTableMetaInfo
,
removeFromCache
);
tscClear
Table
MetaInfo
(
pTableMetaInfo
,
removeFromCache
);
free
(
pTableMetaInfo
);
free
(
pTableMetaInfo
);
int32_t
after
=
pQueryInfo
->
numOfTables
-
index
-
1
;
int32_t
after
=
pQueryInfo
->
numOfTables
-
index
-
1
;
...
@@ -1713,13 +1720,18 @@ void tscClearAllTableMetaInfo(SQueryInfo* pQueryInfo, const char* address, bool
...
@@ -1713,13 +1720,18 @@ void tscClearAllTableMetaInfo(SQueryInfo* pQueryInfo, const char* address, bool
tfree
(
pQueryInfo
->
pTableMetaInfo
);
tfree
(
pQueryInfo
->
pTableMetaInfo
);
}
}
void
tscClear
Meter
MetaInfo
(
STableMetaInfo
*
pTableMetaInfo
,
bool
removeFromCache
)
{
void
tscClear
Table
MetaInfo
(
STableMetaInfo
*
pTableMetaInfo
,
bool
removeFromCache
)
{
if
(
pTableMetaInfo
==
NULL
)
{
if
(
pTableMetaInfo
==
NULL
)
{
return
;
return
;
}
}
taosCacheRelease
(
tscCacheHandle
,
(
void
**
)
&
(
pTableMetaInfo
->
pTableMeta
),
removeFromCache
);
taosCacheRelease
(
tscCacheHandle
,
(
void
**
)
&
(
pTableMetaInfo
->
pTableMeta
),
removeFromCache
);
tfree
(
pTableMetaInfo
->
vgroupList
);
tfree
(
pTableMetaInfo
->
vgroupList
);
if
(
pTableMetaInfo
->
tagColList
!=
NULL
)
{
taosArrayDestroy
(
pTableMetaInfo
->
tagColList
);
pTableMetaInfo
->
tagColList
=
NULL
;
}
}
}
void
tscResetForNextRetrieve
(
SSqlRes
*
pRes
)
{
void
tscResetForNextRetrieve
(
SSqlRes
*
pRes
)
{
...
...
tests/examples/c/demo.c
浏览文件 @
59c6434a
...
@@ -75,7 +75,7 @@ int main(int argc, char *argv[]) {
...
@@ -75,7 +75,7 @@ int main(int argc, char *argv[]) {
doQuery
(
taos
,
"create database if not exists test"
);
doQuery
(
taos
,
"create database if not exists test"
);
doQuery
(
taos
,
"use test"
);
doQuery
(
taos
,
"use test"
);
doQuery
(
taos
,
"
insert into tm99 values('2020-01-01 1:1:1', 99);
"
);
doQuery
(
taos
,
"
select count(*),k,sum(k) from m1 group by k
"
);
// doQuery(taos, "create table if not exists tm0 (ts timestamp, k int);");
// doQuery(taos, "create table if not exists tm0 (ts timestamp, k int);");
// doQuery(taos, "insert into tm0 values('2020-1-1 1:1:1', 1);");
// doQuery(taos, "insert into tm0 values('2020-1-1 1:1:1', 1);");
// doQuery(taos, "insert into tm0 values('2020-1-1 1:1:2', 2);");
// doQuery(taos, "insert into tm0 values('2020-1-1 1:1:2', 2);");
...
@@ -86,7 +86,7 @@ int main(int argc, char *argv[]) {
...
@@ -86,7 +86,7 @@ int main(int argc, char *argv[]) {
// doQuery(taos, "insert into tm0 values('2020-1-1 1:1:7', 7);");
// doQuery(taos, "insert into tm0 values('2020-1-1 1:1:7', 7);");
// doQuery(taos, "insert into tm0 values('2020-1-1 1:1:8', 8);");
// doQuery(taos, "insert into tm0 values('2020-1-1 1:1:8', 8);");
// doQuery(taos, "insert into tm0 values('2020-1-1 1:1:9', 9);");
// doQuery(taos, "insert into tm0 values('2020-1-1 1:1:9', 9);");
doQuery
(
taos
,
"select sum(k),count(*) from m1 group by a"
);
//
doQuery(taos, "select sum(k),count(*) from m1 group by a");
taos_close
(
taos
);
taos_close
(
taos
);
return
0
;
return
0
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录