Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
162b3087
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看板
提交
162b3087
编写于
4月 22, 2022
作者:
D
dapan1121
浏览文件
操作
浏览文件
下载
差异文件
Merge remote-tracking branch 'origin/3.0' into feature/qnode
上级
31528bbe
db2b9931
变更
90
展开全部
隐藏空白更改
内联
并排
Showing
90 changed file
with
3210 addition
and
3103 deletion
+3210
-3103
Jenkinsfile2
Jenkinsfile2
+0
-12
include/common/taosdef.h
include/common/taosdef.h
+0
-7
include/common/tmsg.h
include/common/tmsg.h
+55
-12
include/libs/function/function.h
include/libs/function/function.h
+2
-1
include/libs/nodes/nodes.h
include/libs/nodes/nodes.h
+3
-0
include/libs/nodes/plannodes.h
include/libs/nodes/plannodes.h
+0
-1
include/libs/nodes/querynodes.h
include/libs/nodes/querynodes.h
+5
-3
include/libs/planner/planner.h
include/libs/planner/planner.h
+1
-0
include/libs/transport/trpc.h
include/libs/transport/trpc.h
+12
-8
include/os/osEnv.h
include/os/osEnv.h
+1
-0
include/util/talgo.h
include/util/talgo.h
+2
-2
include/util/taoserror.h
include/util/taoserror.h
+1
-0
source/client/inc/clientInt.h
source/client/inc/clientInt.h
+1
-1
source/client/src/clientEnv.c
source/client/src/clientEnv.c
+21
-30
source/client/src/clientImpl.c
source/client/src/clientImpl.c
+31
-24
source/client/src/clientMain.c
source/client/src/clientMain.c
+10
-0
source/client/test/clientTests.cpp
source/client/test/clientTests.cpp
+1
-1
source/common/src/tdataformat.c
source/common/src/tdataformat.c
+1
-1
source/common/src/tmsg.c
source/common/src/tmsg.c
+54
-9
source/dnode/mgmt/implement/src/dmHandle.c
source/dnode/mgmt/implement/src/dmHandle.c
+125
-0
source/dnode/mgmt/implement/src/dmTransport.c
source/dnode/mgmt/implement/src/dmTransport.c
+4
-4
source/dnode/mgmt/interface/inc/dmDef.h
source/dnode/mgmt/interface/inc/dmDef.h
+14
-0
source/dnode/mgmt/test/sut/src/sut.cpp
source/dnode/mgmt/test/sut/src/sut.cpp
+0
-1
source/dnode/mnode/impl/inc/mndDef.h
source/dnode/mnode/impl/inc/mndDef.h
+23
-314
source/dnode/mnode/impl/inc/mndScheduler.h
source/dnode/mnode/impl/inc/mndScheduler.h
+2
-0
source/dnode/mnode/impl/src/mndDb.c
source/dnode/mnode/impl/src/mndDb.c
+2
-0
source/dnode/mnode/impl/src/mndDef.c
source/dnode/mnode/impl/src/mndDef.c
+18
-67
source/dnode/mnode/impl/src/mndOffset.c
source/dnode/mnode/impl/src/mndOffset.c
+3
-3
source/dnode/mnode/impl/src/mndProfile.c
source/dnode/mnode/impl/src/mndProfile.c
+49
-42
source/dnode/mnode/impl/src/mndScheduler.c
source/dnode/mnode/impl/src/mndScheduler.c
+48
-0
source/dnode/mnode/impl/src/mndShow.c
source/dnode/mnode/impl/src/mndShow.c
+69
-11
source/dnode/mnode/impl/src/mndStb.c
source/dnode/mnode/impl/src/mndStb.c
+24
-0
source/dnode/mnode/impl/src/mndSubscribe.c
source/dnode/mnode/impl/src/mndSubscribe.c
+18
-568
source/dnode/mnode/impl/src/mndTopic.c
source/dnode/mnode/impl/src/mndTopic.c
+44
-42
source/dnode/mnode/impl/test/profile/profile.cpp
source/dnode/mnode/impl/test/profile/profile.cpp
+13
-0
source/dnode/mnode/impl/test/show/show.cpp
source/dnode/mnode/impl/test/show/show.cpp
+9
-3
source/dnode/vnode/inc/vnode.h
source/dnode/vnode/inc/vnode.h
+1
-2
source/dnode/vnode/src/inc/tsdb.h
source/dnode/vnode/src/inc/tsdb.h
+1
-0
source/dnode/vnode/src/meta/metaTDBImpl.c
source/dnode/vnode/src/meta/metaTDBImpl.c
+6
-6
source/dnode/vnode/src/tq/tq.c
source/dnode/vnode/src/tq/tq.c
+0
-121
source/dnode/vnode/src/tq/tqRead.c
source/dnode/vnode/src/tq/tqRead.c
+21
-26
source/dnode/vnode/src/tsdb/tsdbRead.c
source/dnode/vnode/src/tsdb/tsdbRead.c
+3
-0
source/dnode/vnode/src/tsdb/tsdbReadImpl.c
source/dnode/vnode/src/tsdb/tsdbReadImpl.c
+23
-17
source/dnode/vnode/src/tsdb/tsdbSma.c
source/dnode/vnode/src/tsdb/tsdbSma.c
+22
-15
source/dnode/vnode/src/vnd/vnodeSvr.c
source/dnode/vnode/src/vnd/vnodeSvr.c
+11
-0
source/libs/executor/inc/executorimpl.h
source/libs/executor/inc/executorimpl.h
+2
-3
source/libs/executor/src/executorimpl.c
source/libs/executor/src/executorimpl.c
+49
-58
source/libs/executor/src/scanoperator.c
source/libs/executor/src/scanoperator.c
+133
-179
source/libs/function/inc/builtinsimpl.h
source/libs/function/inc/builtinsimpl.h
+3
-0
source/libs/function/inc/tudf.h
source/libs/function/inc/tudf.h
+12
-22
source/libs/function/inc/udfc.h
source/libs/function/inc/udfc.h
+5
-5
source/libs/function/src/builtins.c
source/libs/function/src/builtins.c
+13
-6
source/libs/function/src/builtinsimpl.c
source/libs/function/src/builtinsimpl.c
+132
-15
source/libs/function/src/taggfunction.c
source/libs/function/src/taggfunction.c
+120
-242
source/libs/function/src/tudf.c
source/libs/function/src/tudf.c
+92
-137
source/libs/function/src/udfd.c
source/libs/function/src/udfd.c
+53
-18
source/libs/function/test/runUdf.c
source/libs/function/test/runUdf.c
+5
-4
source/libs/parser/inc/sql.y
source/libs/parser/inc/sql.y
+2
-0
source/libs/parser/src/parTranslater.c
source/libs/parser/src/parTranslater.c
+89
-6
source/libs/parser/src/parUtil.c
source/libs/parser/src/parUtil.c
+2
-0
source/libs/parser/src/sql.c
source/libs/parser/src/sql.c
+532
-526
source/libs/planner/src/planLogicCreater.c
source/libs/planner/src/planLogicCreater.c
+166
-8
source/libs/planner/src/planPhysiCreater.c
source/libs/planner/src/planPhysiCreater.c
+2
-2
source/libs/planner/src/planScaleOut.c
source/libs/planner/src/planScaleOut.c
+6
-7
source/libs/planner/src/planSpliter.c
source/libs/planner/src/planSpliter.c
+177
-17
source/libs/planner/test/planSetOpTest.cpp
source/libs/planner/test/planSetOpTest.cpp
+35
-0
source/libs/planner/test/planTestMain.cpp
source/libs/planner/test/planTestMain.cpp
+0
-0
source/libs/planner/test/planTestUtil.cpp
source/libs/planner/test/planTestUtil.cpp
+19
-2
source/libs/scalar/src/sclfunc.c
source/libs/scalar/src/sclfunc.c
+2
-1
source/libs/transport/inc/transComm.h
source/libs/transport/inc/transComm.h
+12
-11
source/libs/transport/inc/transportInt.h
source/libs/transport/inc/transportInt.h
+7
-6
source/libs/transport/src/trans.c
source/libs/transport/src/trans.c
+5
-5
source/libs/transport/src/transCli.c
source/libs/transport/src/transCli.c
+23
-33
source/libs/transport/src/transSrv.c
source/libs/transport/src/transSrv.c
+34
-23
source/os/src/osEnv.c
source/os/src/osEnv.c
+1
-0
source/os/src/osFile.c
source/os/src/osFile.c
+1
-1
source/os/src/osProc.c
source/os/src/osProc.c
+1
-1
source/util/src/talgo.c
source/util/src/talgo.c
+21
-24
source/util/src/tlog.c
source/util/src/tlog.c
+1
-1
tests/script/runAllSimCases.sh
tests/script/runAllSimCases.sh
+1
-1
tests/script/test.sh
tests/script/test.sh
+2
-2
tests/script/tsim/query/session.sim
tests/script/tsim/query/session.sim
+2
-1
tests/script/tsim/tmq/basic1.sim
tests/script/tsim/tmq/basic1.sim
+206
-157
tests/script/tsim/tmq/clearConsume.sim
tests/script/tsim/tmq/clearConsume.sim
+28
-0
tests/script/tsim/tmq/consume.sh
tests/script/tsim/tmq/consume.sh
+17
-5
tests/script/tsim/tmq/prepareBasicEnv.sim
tests/script/tsim/tmq/prepareBasicEnv.sim
+88
-0
tests/system-test/2-query/cast.py
tests/system-test/2-query/cast.py
+121
-70
tests/system-test/fulltest.sh
tests/system-test/fulltest.sh
+5
-1
tests/test/c/tmqSim.c
tests/test/c/tmqSim.c
+177
-127
tools/shell/src/shellEngine.c
tools/shell/src/shellEngine.c
+52
-22
未找到文件。
Jenkinsfile2
浏览文件 @
162b3087
...
@@ -88,12 +88,6 @@ def pre_test(){
...
@@ -88,12 +88,6 @@ def pre_test(){
cmake .. > /dev/null
cmake .. > /dev/null
make -j4> /dev/null
make -j4> /dev/null
'''
'''
sh'''
cd ${WKPY}
git reset --hard
git pull
pip3 install .
'''
return 1
return 1
}
}
...
@@ -103,7 +97,6 @@ pipeline {
...
@@ -103,7 +97,6 @@ pipeline {
environment{
environment{
WK = '/var/lib/jenkins/workspace/TDinternal'
WK = '/var/lib/jenkins/workspace/TDinternal'
WKC= '/var/lib/jenkins/workspace/TDengine'
WKC= '/var/lib/jenkins/workspace/TDengine'
WKPY= '/var/lib/jenkins/workspace/taos-connector-python'
}
}
stages {
stages {
stage('pre_build'){
stage('pre_build'){
...
@@ -124,11 +117,6 @@ pipeline {
...
@@ -124,11 +117,6 @@ pipeline {
./test-all.sh b1fq
./test-all.sh b1fq
'''
'''
sh'''
sh'''
export LD_LIBRARY_PATH=${WKC}/debug/build/lib
cd ${WKC}/tests/system-test
./fulltest.sh
'''
sh'''
cd ${WKC}/debug
cd ${WKC}/debug
ctest
ctest
'''
'''
...
...
include/common/taosdef.h
浏览文件 @
162b3087
...
@@ -78,13 +78,6 @@ typedef enum {
...
@@ -78,13 +78,6 @@ typedef enum {
TSDB_SMA_TYPE_ROLLUP
=
2
,
// Rollup SMA
TSDB_SMA_TYPE_ROLLUP
=
2
,
// Rollup SMA
}
ETsdbSmaType
;
}
ETsdbSmaType
;
typedef
enum
{
TSDB_BSMA_TYPE_NONE
=
0
,
// no block-wise SMA
TSDB_BSMA_TYPE_I
=
1
,
// sum/min/max(default)
}
ETsdbBSmaType
;
#define TSDB_BSMA_TYPE_LATEST TSDB_BSMA_TYPE_I
extern
char
*
qtypeStr
[];
extern
char
*
qtypeStr
[];
#define TSDB_PORT_HTTP 11
#define TSDB_PORT_HTTP 11
...
...
include/common/tmsg.h
浏览文件 @
162b3087
...
@@ -326,11 +326,20 @@ int32_t tDecodeSEpSet(SCoder* pDecoder, SEpSet* pEp);
...
@@ -326,11 +326,20 @@ int32_t tDecodeSEpSet(SCoder* pDecoder, SEpSet* pEp);
int32_t
taosEncodeSEpSet
(
void
**
buf
,
const
SEpSet
*
pEp
);
int32_t
taosEncodeSEpSet
(
void
**
buf
,
const
SEpSet
*
pEp
);
void
*
taosDecodeSEpSet
(
const
void
*
buf
,
SEpSet
*
pEp
);
void
*
taosDecodeSEpSet
(
const
void
*
buf
,
SEpSet
*
pEp
);
typedef
struct
{
SEpSet
epSet
;
}
SMEpSet
;
int32_t
tSerializeSMEpSet
(
void
*
buf
,
int32_t
bufLen
,
SMEpSet
*
pReq
);
int32_t
tDeserializeSMEpSet
(
void
*
buf
,
int32_t
buflen
,
SMEpSet
*
pReq
);
typedef
struct
{
typedef
struct
{
int8_t
connType
;
int8_t
connType
;
int32_t
pid
;
int32_t
pid
;
char
app
[
TSDB_APP_NAME_LEN
];
char
app
[
TSDB_APP_NAME_LEN
];
char
db
[
TSDB_DB_NAME_LEN
];
char
db
[
TSDB_DB_NAME_LEN
];
char
user
[
TSDB_USER_LEN
];
char
passwd
[
TSDB_PASSWORD_LEN
];
int64_t
startTime
;
int64_t
startTime
;
}
SConnectReq
;
}
SConnectReq
;
...
@@ -482,7 +491,7 @@ typedef struct {
...
@@ -482,7 +491,7 @@ typedef struct {
char
intervalUnit
;
char
intervalUnit
;
char
slidingUnit
;
char
slidingUnit
;
char
char
offsetUnit
;
// TODO Remove it, the offset is the number of precision tickle, and it must be a immutable duration.
offsetUnit
;
// TODO Remove it, the offset is the number of precision tickle, and it must be a immutable duration.
int8_t
precision
;
int8_t
precision
;
int64_t
interval
;
int64_t
interval
;
int64_t
sliding
;
int64_t
sliding
;
...
@@ -982,7 +991,6 @@ int32_t tDeserializeSShowRsp(void* buf, int32_t bufLen, SShowRsp* pRsp);
...
@@ -982,7 +991,6 @@ int32_t tDeserializeSShowRsp(void* buf, int32_t bufLen, SShowRsp* pRsp);
void
tFreeSShowRsp
(
SShowRsp
*
pRsp
);
void
tFreeSShowRsp
(
SShowRsp
*
pRsp
);
typedef
struct
{
typedef
struct
{
int32_t
type
;
char
db
[
TSDB_DB_FNAME_LEN
];
char
db
[
TSDB_DB_FNAME_LEN
];
char
tb
[
TSDB_TABLE_NAME_LEN
];
char
tb
[
TSDB_TABLE_NAME_LEN
];
int64_t
showId
;
int64_t
showId
;
...
@@ -1275,11 +1283,16 @@ typedef struct {
...
@@ -1275,11 +1283,16 @@ typedef struct {
}
SMVCreateStreamRsp
,
SMSCreateStreamRsp
;
}
SMVCreateStreamRsp
,
SMSCreateStreamRsp
;
typedef
struct
{
typedef
struct
{
char
name
[
TSDB_TOPIC_FNAME_LEN
];
char
name
[
TSDB_TOPIC_FNAME_LEN
];
int8_t
igExists
;
int8_t
igExists
;
char
*
sql
;
int8_t
withTbName
;
char
*
ast
;
int8_t
withSchema
;
char
subscribeDbName
[
TSDB_DB_NAME_LEN
];
int8_t
withTag
;
int8_t
withTagSchema
;
char
*
sql
;
char
*
ast
;
int64_t
subDbUid
;
char
subscribeDbName
[
TSDB_DB_NAME_LEN
];
}
SCMCreateTopicReq
;
}
SCMCreateTopicReq
;
int32_t
tSerializeSCMCreateTopicReq
(
void
*
buf
,
int32_t
bufLen
,
const
SCMCreateTopicReq
*
pReq
);
int32_t
tSerializeSCMCreateTopicReq
(
void
*
buf
,
int32_t
bufLen
,
const
SCMCreateTopicReq
*
pReq
);
...
@@ -1473,8 +1486,12 @@ typedef struct {
...
@@ -1473,8 +1486,12 @@ typedef struct {
typedef
struct
{
typedef
struct
{
float
xFilesFactor
;
float
xFilesFactor
;
int32_t
delay
;
int32_t
delay
;
int8_t
nFuncIds
;
int32_t
qmsg1Len
;
int32_t
qmsg2Len
;
func_id_t
*
pFuncIds
;
func_id_t
*
pFuncIds
;
char
*
qmsg1
;
// not null: pAst1:qmsg1:SRetention1 => trigger aggr task1
char
*
qmsg2
;
// not null: pAst2:qmsg2:SRetention2 => trigger aggr task2
int8_t
nFuncIds
;
}
SRSmaParam
;
}
SRSmaParam
;
typedef
struct
SVCreateTbReq
{
typedef
struct
SVCreateTbReq
{
...
@@ -1934,12 +1951,22 @@ static FORCE_INLINE void* taosDecodeSMqMsg(void* buf, SMqHbMsg* pMsg) {
...
@@ -1934,12 +1951,22 @@ static FORCE_INLINE void* taosDecodeSMqMsg(void* buf, SMqHbMsg* pMsg) {
return
buf
;
return
buf
;
}
}
enum
{
TOPIC_SUB_TYPE__DB
=
1
,
TOPIC_SUB_TYPE__TABLE
,
};
typedef
struct
{
typedef
struct
{
int64_t
leftForVer
;
int64_t
leftForVer
;
int32_t
vgId
;
int32_t
vgId
;
int64_t
oldConsumerId
;
int64_t
oldConsumerId
;
int64_t
newConsumerId
;
int64_t
newConsumerId
;
char
subKey
[
TSDB_SUBSCRIBE_KEY_LEN
];
char
subKey
[
TSDB_SUBSCRIBE_KEY_LEN
];
int8_t
subType
;
int8_t
withTbName
;
int8_t
withSchema
;
int8_t
withTag
;
int8_t
withTagSchema
;
char
*
qmsg
;
char
*
qmsg
;
}
SMqRebVgReq
;
}
SMqRebVgReq
;
...
@@ -1950,7 +1977,14 @@ static FORCE_INLINE int32_t tEncodeSMqRebVgReq(void** buf, const SMqRebVgReq* pR
...
@@ -1950,7 +1977,14 @@ static FORCE_INLINE int32_t tEncodeSMqRebVgReq(void** buf, const SMqRebVgReq* pR
tlen
+=
taosEncodeFixedI64
(
buf
,
pReq
->
oldConsumerId
);
tlen
+=
taosEncodeFixedI64
(
buf
,
pReq
->
oldConsumerId
);
tlen
+=
taosEncodeFixedI64
(
buf
,
pReq
->
newConsumerId
);
tlen
+=
taosEncodeFixedI64
(
buf
,
pReq
->
newConsumerId
);
tlen
+=
taosEncodeString
(
buf
,
pReq
->
subKey
);
tlen
+=
taosEncodeString
(
buf
,
pReq
->
subKey
);
tlen
+=
taosEncodeString
(
buf
,
pReq
->
qmsg
);
tlen
+=
taosEncodeFixedI8
(
buf
,
pReq
->
subType
);
tlen
+=
taosEncodeFixedI8
(
buf
,
pReq
->
withTbName
);
tlen
+=
taosEncodeFixedI8
(
buf
,
pReq
->
withSchema
);
tlen
+=
taosEncodeFixedI8
(
buf
,
pReq
->
withTag
);
tlen
+=
taosEncodeFixedI8
(
buf
,
pReq
->
withTagSchema
);
if
(
pReq
->
subType
==
TOPIC_SUB_TYPE__TABLE
)
{
tlen
+=
taosEncodeString
(
buf
,
pReq
->
qmsg
);
}
return
tlen
;
return
tlen
;
}
}
...
@@ -1960,7 +1994,14 @@ static FORCE_INLINE void* tDecodeSMqRebVgReq(const void* buf, SMqRebVgReq* pReq)
...
@@ -1960,7 +1994,14 @@ static FORCE_INLINE void* tDecodeSMqRebVgReq(const void* buf, SMqRebVgReq* pReq)
buf
=
taosDecodeFixedI64
(
buf
,
&
pReq
->
oldConsumerId
);
buf
=
taosDecodeFixedI64
(
buf
,
&
pReq
->
oldConsumerId
);
buf
=
taosDecodeFixedI64
(
buf
,
&
pReq
->
newConsumerId
);
buf
=
taosDecodeFixedI64
(
buf
,
&
pReq
->
newConsumerId
);
buf
=
taosDecodeStringTo
(
buf
,
pReq
->
subKey
);
buf
=
taosDecodeStringTo
(
buf
,
pReq
->
subKey
);
buf
=
taosDecodeString
(
buf
,
&
pReq
->
qmsg
);
buf
=
taosDecodeFixedI8
(
buf
,
&
pReq
->
subType
);
buf
=
taosDecodeFixedI8
(
buf
,
&
pReq
->
withTbName
);
buf
=
taosDecodeFixedI8
(
buf
,
&
pReq
->
withSchema
);
buf
=
taosDecodeFixedI8
(
buf
,
&
pReq
->
withTag
);
buf
=
taosDecodeFixedI8
(
buf
,
&
pReq
->
withTagSchema
);
if
(
pReq
->
subType
==
TOPIC_SUB_TYPE__TABLE
)
{
buf
=
taosDecodeString
(
buf
,
&
pReq
->
qmsg
);
}
return
(
void
*
)
buf
;
return
(
void
*
)
buf
;
}
}
...
@@ -2300,9 +2341,10 @@ static FORCE_INLINE void tdDestroyTSmaWrapper(STSmaWrapper* pSW) {
...
@@ -2300,9 +2341,10 @@ static FORCE_INLINE void tdDestroyTSmaWrapper(STSmaWrapper* pSW) {
}
}
}
}
static
FORCE_INLINE
void
tdFreeTSmaWrapper
(
STSmaWrapper
*
pSW
)
{
static
FORCE_INLINE
void
*
tdFreeTSmaWrapper
(
STSmaWrapper
*
pSW
)
{
tdDestroyTSmaWrapper
(
pSW
);
tdDestroyTSmaWrapper
(
pSW
);
taosMemoryFreeClear
(
pSW
);
taosMemoryFree
(
pSW
);
return
NULL
;
}
}
static
FORCE_INLINE
int32_t
tEncodeTSma
(
void
**
buf
,
const
STSma
*
pSma
)
{
static
FORCE_INLINE
int32_t
tEncodeTSma
(
void
**
buf
,
const
STSma
*
pSma
)
{
...
@@ -2690,6 +2732,7 @@ static FORCE_INLINE void* tDecodeSMqCMGetSubEpRsp(void* buf, SMqCMGetSubEpRsp* p
...
@@ -2690,6 +2732,7 @@ static FORCE_INLINE void* tDecodeSMqCMGetSubEpRsp(void* buf, SMqCMGetSubEpRsp* p
}
}
return
buf
;
return
buf
;
}
}
#pragma pack(pop)
#pragma pack(pop)
#ifdef __cplusplus
#ifdef __cplusplus
...
...
include/libs/function/function.h
浏览文件 @
162b3087
...
@@ -166,6 +166,7 @@ typedef struct SInputColumnInfoData {
...
@@ -166,6 +166,7 @@ typedef struct SInputColumnInfoData {
SColumnInfoData
*
pPTS
;
// primary timestamp column
SColumnInfoData
*
pPTS
;
// primary timestamp column
SColumnInfoData
**
pData
;
SColumnInfoData
**
pData
;
SColumnDataAgg
**
pColumnDataAgg
;
SColumnDataAgg
**
pColumnDataAgg
;
uint64_t
uid
;
// table uid
}
SInputColumnInfoData
;
}
SInputColumnInfoData
;
// sql function runtime context
// sql function runtime context
...
@@ -191,7 +192,7 @@ typedef struct SqlFunctionCtx {
...
@@ -191,7 +192,7 @@ typedef struct SqlFunctionCtx {
int16_t
functionId
;
// function id
int16_t
functionId
;
// function id
char
*
pOutput
;
// final result output buffer, point to sdata->data
char
*
pOutput
;
// final result output buffer, point to sdata->data
int32_t
numOfParams
;
int32_t
numOfParams
;
S
Variant
param
[
4
];
// input parameter, e.g., top(k, 20), the number of results for top query is kept in param
S
FunctParam
*
param
;
// input parameter, e.g., top(k, 20), the number of results for top query is kept in param
int64_t
*
ptsList
;
// corresponding timestamp array list
int64_t
*
ptsList
;
// corresponding timestamp array list
SColumnInfoData
*
pTsOutput
;
// corresponding output buffer for timestamp of each result, e.g., top/bottom*/
SColumnInfoData
*
pTsOutput
;
// corresponding output buffer for timestamp of each result, e.g., top/bottom*/
int32_t
offset
;
int32_t
offset
;
...
...
include/libs/nodes/nodes.h
浏览文件 @
162b3087
...
@@ -48,6 +48,9 @@ extern "C" {
...
@@ -48,6 +48,9 @@ extern "C" {
(NULL == cell1 ? (node1 = NULL, false) : (node1 = cell1->pNode, true)), (NULL == cell2 ? (node2 = NULL, false) : (node2 = cell2->pNode, true)), (node1 != NULL && node2 != NULL); \
(NULL == cell1 ? (node1 = NULL, false) : (node1 = cell1->pNode, true)), (NULL == cell2 ? (node2 = NULL, false) : (node2 = cell2->pNode, true)), (node1 != NULL && node2 != NULL); \
cell1 = cell1->pNext, cell2 = cell2->pNext)
cell1 = cell1->pNext, cell2 = cell2->pNext)
#define REPLACE_LIST1_NODE(newNode) cell1->pNode = (SNode*)(newNode)
#define REPLACE_LIST2_NODE(newNode) cell2->pNode = (SNode*)(newNode)
#define FOREACH_FOR_REWRITE(node, list) \
#define FOREACH_FOR_REWRITE(node, list) \
for (SListCell* cell = (NULL != (list) ? (list)->pHead : NULL); (NULL != cell ? (node = &(cell->pNode), true) : (node = NULL, false)); cell = cell->pNext)
for (SListCell* cell = (NULL != (list) ? (list)->pHead : NULL); (NULL != cell ? (node = &(cell->pNode), true) : (node = NULL, false)); cell = cell->pNext)
...
...
include/libs/nodes/plannodes.h
浏览文件 @
162b3087
...
@@ -155,7 +155,6 @@ typedef struct SLogicSubplan {
...
@@ -155,7 +155,6 @@ typedef struct SLogicSubplan {
typedef
struct
SQueryLogicPlan
{
typedef
struct
SQueryLogicPlan
{
ENodeType
type
;
ENodeType
type
;
int32_t
totalLevel
;
SNodeList
*
pTopSubplans
;
SNodeList
*
pTopSubplans
;
}
SQueryLogicPlan
;
}
SQueryLogicPlan
;
...
...
include/libs/nodes/querynodes.h
浏览文件 @
162b3087
...
@@ -229,10 +229,10 @@ typedef struct SFillNode {
...
@@ -229,10 +229,10 @@ typedef struct SFillNode {
typedef
struct
SSelectStmt
{
typedef
struct
SSelectStmt
{
ENodeType
type
;
// QUERY_NODE_SELECT_STMT
ENodeType
type
;
// QUERY_NODE_SELECT_STMT
bool
isDistinct
;
bool
isDistinct
;
SNodeList
*
pProjectionList
;
// SNode
SNodeList
*
pProjectionList
;
SNode
*
pFromTable
;
SNode
*
pFromTable
;
SNode
*
pWhere
;
SNode
*
pWhere
;
SNodeList
*
pPartitionByList
;
// SNode
SNodeList
*
pPartitionByList
;
SNode
*
pWindow
;
SNode
*
pWindow
;
SNodeList
*
pGroupByList
;
// SGroupingSetNode
SNodeList
*
pGroupByList
;
// SGroupingSetNode
SNode
*
pHaving
;
SNode
*
pHaving
;
...
@@ -245,12 +245,14 @@ typedef struct SSelectStmt {
...
@@ -245,12 +245,14 @@ typedef struct SSelectStmt {
}
SSelectStmt
;
}
SSelectStmt
;
typedef
enum
ESetOperatorType
{
typedef
enum
ESetOperatorType
{
SET_OP_TYPE_UNION_ALL
=
1
SET_OP_TYPE_UNION_ALL
=
1
,
SET_OP_TYPE_UNION
}
ESetOperatorType
;
}
ESetOperatorType
;
typedef
struct
SSetOperator
{
typedef
struct
SSetOperator
{
ENodeType
type
;
// QUERY_NODE_SET_OPERATOR
ENodeType
type
;
// QUERY_NODE_SET_OPERATOR
ESetOperatorType
opType
;
ESetOperatorType
opType
;
SNodeList
*
pProjectionList
;
SNode
*
pLeft
;
SNode
*
pLeft
;
SNode
*
pRight
;
SNode
*
pRight
;
SNodeList
*
pOrderByList
;
// SOrderByExprNode
SNodeList
*
pOrderByList
;
// SOrderByExprNode
...
...
include/libs/planner/planner.h
浏览文件 @
162b3087
...
@@ -30,6 +30,7 @@ typedef struct SPlanContext {
...
@@ -30,6 +30,7 @@ typedef struct SPlanContext {
SNode
*
pAstRoot
;
SNode
*
pAstRoot
;
bool
topicQuery
;
bool
topicQuery
;
bool
streamQuery
;
bool
streamQuery
;
bool
rSmaQuery
;
bool
showRewrite
;
bool
showRewrite
;
int8_t
triggerType
;
int8_t
triggerType
;
int64_t
watermark
;
int64_t
watermark
;
...
...
include/libs/transport/trpc.h
浏览文件 @
162b3087
...
@@ -54,12 +54,13 @@ typedef struct {
...
@@ -54,12 +54,13 @@ typedef struct {
uint16_t
clientPort
;
uint16_t
clientPort
;
SRpcMsg
rpcMsg
;
SRpcMsg
rpcMsg
;
int32_t
rspLen
;
int32_t
rspLen
;
void
*
pRsp
;
void
*
pRsp
;
void
*
pNode
;
void
*
pNode
;
}
SNodeMsg
;
}
SNodeMsg
;
typedef
void
(
*
RpcCfp
)(
void
*
parent
,
SRpcMsg
*
,
SEpSet
*
);
typedef
void
(
*
RpcCfp
)(
void
*
parent
,
SRpcMsg
*
,
SEpSet
*
);
typedef
int
(
*
RpcAfp
)(
void
*
parent
,
char
*
tableId
,
char
*
spi
,
char
*
encrypt
,
char
*
secret
,
char
*
ckey
);
typedef
int
(
*
RpcAfp
)(
void
*
parent
,
char
*
tableId
,
char
*
spi
,
char
*
encrypt
,
char
*
secret
,
char
*
ckey
);
typedef
int
(
*
RpcRfp
)(
void
*
parent
,
SRpcMsg
*
,
SEpSet
*
);
typedef
struct
SRpcInit
{
typedef
struct
SRpcInit
{
uint16_t
localPort
;
// local port
uint16_t
localPort
;
// local port
...
@@ -80,22 +81,25 @@ typedef struct SRpcInit {
...
@@ -80,22 +81,25 @@ typedef struct SRpcInit {
RpcCfp
cfp
;
RpcCfp
cfp
;
// call back to retrieve the client auth info, for server app only
// call back to retrieve the client auth info, for server app only
RpcAfp
afp
;;
RpcAfp
afp
;
// user defined retry func
RpcRfp
rfp
;
void
*
parent
;
void
*
parent
;
}
SRpcInit
;
}
SRpcInit
;
typedef
struct
{
typedef
struct
{
void
*
val
;
void
*
val
;
int32_t
(
*
clone
)(
void
*
src
,
void
**
dst
);
int32_t
(
*
clone
)(
void
*
src
,
void
**
dst
);
void
(
*
freeFunc
)(
const
void
*
arg
);
void
(
*
freeFunc
)(
const
void
*
arg
);
}
SRpcCtxVal
;
}
SRpcCtxVal
;
typedef
struct
{
typedef
struct
{
int32_t
msgType
;
int32_t
msgType
;
void
*
val
;
void
*
val
;
int32_t
(
*
clone
)(
void
*
src
,
void
**
dst
);
int32_t
(
*
clone
)(
void
*
src
,
void
**
dst
);
void
(
*
freeFunc
)(
const
void
*
arg
);
void
(
*
freeFunc
)(
const
void
*
arg
);
}
SRpcBrokenlinkVal
;
}
SRpcBrokenlinkVal
;
typedef
struct
{
typedef
struct
{
...
...
include/os/osEnv.h
浏览文件 @
162b3087
...
@@ -34,6 +34,7 @@ extern int64_t tsOpenMax;
...
@@ -34,6 +34,7 @@ extern int64_t tsOpenMax;
extern
int64_t
tsStreamMax
;
extern
int64_t
tsStreamMax
;
extern
float
tsNumOfCores
;
extern
float
tsNumOfCores
;
extern
int64_t
tsTotalMemoryKB
;
extern
int64_t
tsTotalMemoryKB
;
extern
char
*
tsProcPath
;
extern
char
configDir
[];
extern
char
configDir
[];
extern
char
tsDataDir
[];
extern
char
tsDataDir
[];
...
...
include/util/talgo.h
浏览文件 @
162b3087
...
@@ -82,7 +82,7 @@ void *taosbsearch(const void *key, const void *base, int64_t nmemb, int64_t size
...
@@ -82,7 +82,7 @@ void *taosbsearch(const void *key, const void *base, int64_t nmemb, int64_t size
* @return
* @return
*/
*/
void
taosheapadjust
(
void
*
base
,
int32_t
size
,
int32_t
start
,
int32_t
end
,
const
void
*
parcompar
,
void
taosheapadjust
(
void
*
base
,
int32_t
size
,
int32_t
start
,
int32_t
end
,
const
void
*
parcompar
,
__ext_compar_fn_t
compar
,
c
onst
void
*
parswap
,
__ext_swap_fn_t
swap
,
bool
maxroot
);
__ext_compar_fn_t
compar
,
c
har
*
buf
,
bool
maxroot
);
/**
/**
* sort heap to make sure it is a max/min root heap
* sort heap to make sure it is a max/min root heap
...
@@ -98,7 +98,7 @@ void taosheapadjust(void *base, int32_t size, int32_t start, int32_t end, const
...
@@ -98,7 +98,7 @@ void taosheapadjust(void *base, int32_t size, int32_t start, int32_t end, const
* @return
* @return
*/
*/
void
taosheapsort
(
void
*
base
,
int32_t
size
,
int32_t
len
,
const
void
*
parcompar
,
__ext_compar_fn_t
compar
,
void
taosheapsort
(
void
*
base
,
int32_t
size
,
int32_t
len
,
const
void
*
parcompar
,
__ext_compar_fn_t
compar
,
const
void
*
parswap
,
__ext_swap_fn_t
swap
,
bool
maxroot
);
bool
maxroot
);
#ifdef __cplusplus
#ifdef __cplusplus
}
}
...
...
include/util/taoserror.h
浏览文件 @
162b3087
...
@@ -614,6 +614,7 @@ int32_t* taosGetErrno();
...
@@ -614,6 +614,7 @@ int32_t* taosGetErrno();
#define TSDB_CODE_PAR_INTER_SLIDING_TOO_BIG TAOS_DEF_ERROR_CODE(0, 0x2631)
#define TSDB_CODE_PAR_INTER_SLIDING_TOO_BIG TAOS_DEF_ERROR_CODE(0, 0x2631)
#define TSDB_CODE_PAR_INTER_SLIDING_TOO_SMALL TAOS_DEF_ERROR_CODE(0, 0x2632)
#define TSDB_CODE_PAR_INTER_SLIDING_TOO_SMALL TAOS_DEF_ERROR_CODE(0, 0x2632)
#define TSDB_CODE_PAR_ONLY_ONE_JSON_TAG TAOS_DEF_ERROR_CODE(0, 0x2633)
#define TSDB_CODE_PAR_ONLY_ONE_JSON_TAG TAOS_DEF_ERROR_CODE(0, 0x2633)
#define TSDB_CODE_PAR_INCORRECT_NUM_OF_COL TAOS_DEF_ERROR_CODE(0, 0x2634)
//planner
//planner
#define TSDB_CODE_PLAN_INTERNAL_ERROR TAOS_DEF_ERROR_CODE(0, 0x2700)
#define TSDB_CODE_PLAN_INTERNAL_ERROR TAOS_DEF_ERROR_CODE(0, 0x2700)
...
...
source/client/inc/clientInt.h
浏览文件 @
162b3087
...
@@ -219,6 +219,7 @@ void doSetOneRowPtr(SReqResultInfo* pResultInfo);
...
@@ -219,6 +219,7 @@ void doSetOneRowPtr(SReqResultInfo* pResultInfo);
void
setResPrecision
(
SReqResultInfo
*
pResInfo
,
int32_t
precision
);
void
setResPrecision
(
SReqResultInfo
*
pResInfo
,
int32_t
precision
);
int32_t
setQueryResultFromRsp
(
SReqResultInfo
*
pResultInfo
,
const
SRetrieveTableRsp
*
pRsp
,
bool
convertUcs4
);
int32_t
setQueryResultFromRsp
(
SReqResultInfo
*
pResultInfo
,
const
SRetrieveTableRsp
*
pRsp
,
bool
convertUcs4
);
void
setResSchemaInfo
(
SReqResultInfo
*
pResInfo
,
const
SSchema
*
pSchema
,
int32_t
numOfCols
);
void
setResSchemaInfo
(
SReqResultInfo
*
pResInfo
,
const
SSchema
*
pSchema
,
int32_t
numOfCols
);
void
doFreeReqResultInfo
(
SReqResultInfo
*
pResInfo
);
static
FORCE_INLINE
SReqResultInfo
*
tmqGetCurResInfo
(
TAOS_RES
*
res
)
{
static
FORCE_INLINE
SReqResultInfo
*
tmqGetCurResInfo
(
TAOS_RES
*
res
)
{
SMqRspObj
*
msg
=
(
SMqRspObj
*
)
res
;
SMqRspObj
*
msg
=
(
SMqRspObj
*
)
res
;
...
@@ -306,7 +307,6 @@ void hbMgrInitMqHbRspHandle();
...
@@ -306,7 +307,6 @@ void hbMgrInitMqHbRspHandle();
SRequestObj
*
launchQueryImpl
(
SRequestObj
*
pRequest
,
SQuery
*
pQuery
,
int32_t
code
,
bool
keepQuery
);
SRequestObj
*
launchQueryImpl
(
SRequestObj
*
pRequest
,
SQuery
*
pQuery
,
int32_t
code
,
bool
keepQuery
);
#ifdef __cplusplus
#ifdef __cplusplus
}
}
#endif
#endif
...
...
source/client/src/clientEnv.c
浏览文件 @
162b3087
...
@@ -30,15 +30,15 @@
...
@@ -30,15 +30,15 @@
#define TSC_VAR_RELEASED 0
#define TSC_VAR_RELEASED 0
SAppInfo
appInfo
;
SAppInfo
appInfo
;
int32_t
clientReqRefPool
=
-
1
;
int32_t
clientReqRefPool
=
-
1
;
int32_t
clientConnRefPool
=
-
1
;
int32_t
clientConnRefPool
=
-
1
;
static
TdThreadOnce
tscinit
=
PTHREAD_ONCE_INIT
;
static
TdThreadOnce
tscinit
=
PTHREAD_ONCE_INIT
;
volatile
int32_t
tscInitRes
=
0
;
volatile
int32_t
tscInitRes
=
0
;
static
void
registerRequest
(
SRequestObj
*
pRequest
)
{
static
void
registerRequest
(
SRequestObj
*
pRequest
)
{
STscObj
*
pTscObj
=
acquireTscObj
(
pRequest
->
pTscObj
->
id
);
STscObj
*
pTscObj
=
acquireTscObj
(
pRequest
->
pTscObj
->
id
);
assert
(
pTscObj
!=
NULL
);
assert
(
pTscObj
!=
NULL
);
// connection has been released already, abort creating request.
// connection has been released already, abort creating request.
...
@@ -49,8 +49,8 @@ static void registerRequest(SRequestObj *pRequest) {
...
@@ -49,8 +49,8 @@ static void registerRequest(SRequestObj *pRequest) {
if
(
pTscObj
->
pAppInfo
)
{
if
(
pTscObj
->
pAppInfo
)
{
SInstanceSummary
*
pSummary
=
&
pTscObj
->
pAppInfo
->
summary
;
SInstanceSummary
*
pSummary
=
&
pTscObj
->
pAppInfo
->
summary
;
int32_t
total
=
atomic_add_fetch_64
((
int64_t
*
)
&
pSummary
->
totalRequests
,
1
);
int32_t
total
=
atomic_add_fetch_64
((
int64_t
*
)
&
pSummary
->
totalRequests
,
1
);
int32_t
currentInst
=
atomic_add_fetch_64
((
int64_t
*
)
&
pSummary
->
currentRequests
,
1
);
int32_t
currentInst
=
atomic_add_fetch_64
((
int64_t
*
)
&
pSummary
->
currentRequests
,
1
);
tscDebug
(
"0x%"
PRIx64
" new Request from connObj:0x%"
PRIx64
tscDebug
(
"0x%"
PRIx64
" new Request from connObj:0x%"
PRIx64
", current:%d, app current:%d, total:%d, reqId:0x%"
PRIx64
,
", current:%d, app current:%d, total:%d, reqId:0x%"
PRIx64
,
pRequest
->
self
,
pRequest
->
pTscObj
->
id
,
num
,
currentInst
,
total
,
pRequest
->
requestId
);
pRequest
->
self
,
pRequest
->
pTscObj
->
id
,
num
,
currentInst
,
total
,
pRequest
->
requestId
);
...
@@ -60,16 +60,16 @@ static void registerRequest(SRequestObj *pRequest) {
...
@@ -60,16 +60,16 @@ static void registerRequest(SRequestObj *pRequest) {
static
void
deregisterRequest
(
SRequestObj
*
pRequest
)
{
static
void
deregisterRequest
(
SRequestObj
*
pRequest
)
{
assert
(
pRequest
!=
NULL
);
assert
(
pRequest
!=
NULL
);
STscObj
*
pTscObj
=
pRequest
->
pTscObj
;
STscObj
*
pTscObj
=
pRequest
->
pTscObj
;
SInstanceSummary
*
pActivity
=
&
pTscObj
->
pAppInfo
->
summary
;
SInstanceSummary
*
pActivity
=
&
pTscObj
->
pAppInfo
->
summary
;
int32_t
currentInst
=
atomic_sub_fetch_64
((
int64_t
*
)
&
pActivity
->
currentRequests
,
1
);
int32_t
currentInst
=
atomic_sub_fetch_64
((
int64_t
*
)
&
pActivity
->
currentRequests
,
1
);
int32_t
num
=
atomic_sub_fetch_32
(
&
pTscObj
->
numOfReqs
,
1
);
int32_t
num
=
atomic_sub_fetch_32
(
&
pTscObj
->
numOfReqs
,
1
);
int64_t
duration
=
taosGetTimestampUs
()
-
pRequest
->
metric
.
start
;
int64_t
duration
=
taosGetTimestampUs
()
-
pRequest
->
metric
.
start
;
tscDebug
(
"0x%"
PRIx64
" free Request from connObj: 0x%"
PRIx64
", reqId:0x%"
PRIx64
" elapsed:%"
PRIu64
tscDebug
(
"0x%"
PRIx64
" free Request from connObj: 0x%"
PRIx64
", reqId:0x%"
PRIx64
" elapsed:%"
PRIu64
" ms, current:%d, app current:%d"
,
" ms, current:%d, app current:%d"
,
pRequest
->
self
,
pTscObj
->
id
,
pRequest
->
requestId
,
duration
/
1000
,
num
,
currentInst
);
pRequest
->
self
,
pTscObj
->
id
,
pRequest
->
requestId
,
duration
/
1000
,
num
,
currentInst
);
releaseTscObj
(
pTscObj
->
id
);
releaseTscObj
(
pTscObj
->
id
);
}
}
...
@@ -109,12 +109,12 @@ void *openTransporter(const char *user, const char *auth, int32_t numOfThread) {
...
@@ -109,12 +109,12 @@ void *openTransporter(const char *user, const char *auth, int32_t numOfThread) {
}
}
void
closeAllRequests
(
SHashObj
*
pRequests
)
{
void
closeAllRequests
(
SHashObj
*
pRequests
)
{
void
*
pIter
=
taosHashIterate
(
pRequests
,
NULL
);
void
*
pIter
=
taosHashIterate
(
pRequests
,
NULL
);
while
(
pIter
!=
NULL
)
{
while
(
pIter
!=
NULL
)
{
int64_t
*
rid
=
pIter
;
int64_t
*
rid
=
pIter
;
releaseRequest
(
*
rid
);
releaseRequest
(
*
rid
);
pIter
=
taosHashIterate
(
pRequests
,
pIter
);
pIter
=
taosHashIterate
(
pRequests
,
pIter
);
}
}
}
}
...
@@ -144,7 +144,7 @@ void *createTscObj(const char *user, const char *auth, const char *db, SAppInstI
...
@@ -144,7 +144,7 @@ void *createTscObj(const char *user, const char *auth, const char *db, SAppInstI
terrno
=
TSDB_CODE_TSC_OUT_OF_MEMORY
;
terrno
=
TSDB_CODE_TSC_OUT_OF_MEMORY
;
return
NULL
;
return
NULL
;
}
}
pObj
->
pAppInfo
=
pAppInfo
;
pObj
->
pAppInfo
=
pAppInfo
;
tstrncpy
(
pObj
->
user
,
user
,
sizeof
(
pObj
->
user
));
tstrncpy
(
pObj
->
user
,
user
,
sizeof
(
pObj
->
user
));
memcpy
(
pObj
->
pass
,
auth
,
TSDB_PASSWORD_LEN
);
memcpy
(
pObj
->
pass
,
auth
,
TSDB_PASSWORD_LEN
);
...
@@ -160,13 +160,9 @@ void *createTscObj(const char *user, const char *auth, const char *db, SAppInstI
...
@@ -160,13 +160,9 @@ void *createTscObj(const char *user, const char *auth, const char *db, SAppInstI
return
pObj
;
return
pObj
;
}
}
STscObj
*
acquireTscObj
(
int64_t
rid
)
{
STscObj
*
acquireTscObj
(
int64_t
rid
)
{
return
(
STscObj
*
)
taosAcquireRef
(
clientConnRefPool
,
rid
);
}
return
(
STscObj
*
)
taosAcquireRef
(
clientConnRefPool
,
rid
);
}
int32_t
releaseTscObj
(
int64_t
rid
)
{
int32_t
releaseTscObj
(
int64_t
rid
)
{
return
taosReleaseRef
(
clientConnRefPool
,
rid
);
}
return
taosReleaseRef
(
clientConnRefPool
,
rid
);
}
void
*
createRequest
(
STscObj
*
pObj
,
__taos_async_fn_t
fp
,
void
*
param
,
int32_t
type
)
{
void
*
createRequest
(
STscObj
*
pObj
,
__taos_async_fn_t
fp
,
void
*
param
,
int32_t
type
)
{
assert
(
pObj
!=
NULL
);
assert
(
pObj
!=
NULL
);
...
@@ -190,11 +186,11 @@ void *createRequest(STscObj *pObj, __taos_async_fn_t fp, void *param, int32_t ty
...
@@ -190,11 +186,11 @@ void *createRequest(STscObj *pObj, __taos_async_fn_t fp, void *param, int32_t ty
tsem_init
(
&
pRequest
->
body
.
rspSem
,
0
,
0
);
tsem_init
(
&
pRequest
->
body
.
rspSem
,
0
,
0
);
registerRequest
(
pRequest
);
registerRequest
(
pRequest
);
return
pRequest
;
return
pRequest
;
}
}
static
void
doFreeReqResultInfo
(
SReqResultInfo
*
pResInfo
)
{
void
doFreeReqResultInfo
(
SReqResultInfo
*
pResInfo
)
{
taosMemoryFreeClear
(
pResInfo
->
pRspMsg
);
taosMemoryFreeClear
(
pResInfo
->
pRspMsg
);
taosMemoryFreeClear
(
pResInfo
->
length
);
taosMemoryFreeClear
(
pResInfo
->
length
);
taosMemoryFreeClear
(
pResInfo
->
row
);
taosMemoryFreeClear
(
pResInfo
->
row
);
...
@@ -217,7 +213,7 @@ static void doDestroyRequest(void *p) {
...
@@ -217,7 +213,7 @@ static void doDestroyRequest(void *p) {
assert
(
RID_VALID
(
pRequest
->
self
));
assert
(
RID_VALID
(
pRequest
->
self
));
taosHashRemove
(
pRequest
->
pTscObj
->
pRequests
,
&
pRequest
->
self
,
sizeof
(
pRequest
->
self
));
taosHashRemove
(
pRequest
->
pTscObj
->
pRequests
,
&
pRequest
->
self
,
sizeof
(
pRequest
->
self
));
taosMemoryFreeClear
(
pRequest
->
msgBuf
);
taosMemoryFreeClear
(
pRequest
->
msgBuf
);
taosMemoryFreeClear
(
pRequest
->
sqlstr
);
taosMemoryFreeClear
(
pRequest
->
sqlstr
);
taosMemoryFreeClear
(
pRequest
->
pDb
);
taosMemoryFreeClear
(
pRequest
->
pDb
);
...
@@ -244,14 +240,9 @@ void destroyRequest(SRequestObj *pRequest) {
...
@@ -244,14 +240,9 @@ void destroyRequest(SRequestObj *pRequest) {
taosRemoveRef
(
clientReqRefPool
,
pRequest
->
self
);
taosRemoveRef
(
clientReqRefPool
,
pRequest
->
self
);
}
}
SRequestObj
*
acquireRequest
(
int64_t
rid
)
{
SRequestObj
*
acquireRequest
(
int64_t
rid
)
{
return
(
SRequestObj
*
)
taosAcquireRef
(
clientReqRefPool
,
rid
);
}
return
(
SRequestObj
*
)
taosAcquireRef
(
clientReqRefPool
,
rid
);
}
int32_t
releaseRequest
(
int64_t
rid
)
{
return
taosReleaseRef
(
clientReqRefPool
,
rid
);
}
int32_t
releaseRequest
(
int64_t
rid
)
{
return
taosReleaseRef
(
clientReqRefPool
,
rid
);
}
void
taos_init_imp
(
void
)
{
void
taos_init_imp
(
void
)
{
// In the APIs of other program language, taos_cleanup is not available yet.
// In the APIs of other program language, taos_cleanup is not available yet.
...
@@ -380,7 +371,7 @@ uint64_t generateRequestId() {
...
@@ -380,7 +371,7 @@ uint64_t generateRequestId() {
}
}
uint64_t
id
=
0
;
uint64_t
id
=
0
;
while
(
true
)
{
while
(
true
)
{
int64_t
ts
=
taosGetTimestampMs
();
int64_t
ts
=
taosGetTimestampMs
();
uint64_t
pid
=
taosGetPId
();
uint64_t
pid
=
taosGetPId
();
...
...
source/client/src/clientImpl.c
浏览文件 @
162b3087
...
@@ -146,7 +146,8 @@ int32_t buildRequest(STscObj* pTscObj, const char* sql, int sqlLen, SRequestObj*
...
@@ -146,7 +146,8 @@ int32_t buildRequest(STscObj* pTscObj, const char* sql, int sqlLen, SRequestObj*
(
*
pRequest
)
->
sqlstr
[
sqlLen
]
=
0
;
(
*
pRequest
)
->
sqlstr
[
sqlLen
]
=
0
;
(
*
pRequest
)
->
sqlLen
=
sqlLen
;
(
*
pRequest
)
->
sqlLen
=
sqlLen
;
if
(
taosHashPut
(
pTscObj
->
pRequests
,
&
(
*
pRequest
)
->
self
,
sizeof
((
*
pRequest
)
->
self
),
&
(
*
pRequest
)
->
self
,
sizeof
((
*
pRequest
)
->
self
)))
{
if
(
taosHashPut
(
pTscObj
->
pRequests
,
&
(
*
pRequest
)
->
self
,
sizeof
((
*
pRequest
)
->
self
),
&
(
*
pRequest
)
->
self
,
sizeof
((
*
pRequest
)
->
self
)))
{
destroyRequest
(
*
pRequest
);
destroyRequest
(
*
pRequest
);
*
pRequest
=
NULL
;
*
pRequest
=
NULL
;
tscError
(
"put request to request hash failed"
);
tscError
(
"put request to request hash failed"
);
...
@@ -263,7 +264,8 @@ void setResSchemaInfo(SReqResultInfo* pResInfo, const SSchema* pSchema, int32_t
...
@@ -263,7 +264,8 @@ void setResSchemaInfo(SReqResultInfo* pResInfo, const SSchema* pSchema, int32_t
}
}
void
setResPrecision
(
SReqResultInfo
*
pResInfo
,
int32_t
precision
)
{
void
setResPrecision
(
SReqResultInfo
*
pResInfo
,
int32_t
precision
)
{
if
(
precision
!=
TSDB_TIME_PRECISION_MILLI
&&
precision
!=
TSDB_TIME_PRECISION_MICRO
&&
precision
!=
TSDB_TIME_PRECISION_NANO
)
{
if
(
precision
!=
TSDB_TIME_PRECISION_MILLI
&&
precision
!=
TSDB_TIME_PRECISION_MICRO
&&
precision
!=
TSDB_TIME_PRECISION_NANO
)
{
return
;
return
;
}
}
...
@@ -275,7 +277,7 @@ int32_t scheduleQuery(SRequestObj* pRequest, SQueryPlan* pDag, SArray* pNodeList
...
@@ -275,7 +277,7 @@ int32_t scheduleQuery(SRequestObj* pRequest, SQueryPlan* pDag, SArray* pNodeList
SQueryResult
res
=
{.
code
=
0
,
.
numOfRows
=
0
,
.
msgSize
=
ERROR_MSG_BUF_DEFAULT_SIZE
,
.
msg
=
pRequest
->
msgBuf
};
SQueryResult
res
=
{.
code
=
0
,
.
numOfRows
=
0
,
.
msgSize
=
ERROR_MSG_BUF_DEFAULT_SIZE
,
.
msg
=
pRequest
->
msgBuf
};
int32_t
code
=
schedulerExecJob
(
pTransporter
,
pNodeList
,
pDag
,
&
pRequest
->
body
.
queryJob
,
pRequest
->
sqlstr
,
int32_t
code
=
schedulerExecJob
(
pTransporter
,
pNodeList
,
pDag
,
&
pRequest
->
body
.
queryJob
,
pRequest
->
sqlstr
,
pRequest
->
metric
.
start
,
&
res
);
pRequest
->
metric
.
start
,
&
res
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
if
(
pRequest
->
body
.
queryJob
!=
0
)
{
if
(
pRequest
->
body
.
queryJob
!=
0
)
{
schedulerFreeJob
(
pRequest
->
body
.
queryJob
);
schedulerFreeJob
(
pRequest
->
body
.
queryJob
);
...
@@ -300,7 +302,7 @@ int32_t scheduleQuery(SRequestObj* pRequest, SQueryPlan* pDag, SArray* pNodeList
...
@@ -300,7 +302,7 @@ int32_t scheduleQuery(SRequestObj* pRequest, SQueryPlan* pDag, SArray* pNodeList
}
}
SRequestObj
*
launchQueryImpl
(
SRequestObj
*
pRequest
,
SQuery
*
pQuery
,
int32_t
code
,
bool
keepQuery
)
{
SRequestObj
*
launchQueryImpl
(
SRequestObj
*
pRequest
,
SQuery
*
pQuery
,
int32_t
code
,
bool
keepQuery
)
{
SArray
*
pNodeList
=
taosArrayInit
(
4
,
sizeof
(
struct
SQueryNodeAddr
));
SArray
*
pNodeList
=
taosArrayInit
(
4
,
sizeof
(
struct
SQueryNodeAddr
));
if
(
TSDB_CODE_SUCCESS
==
code
)
{
if
(
TSDB_CODE_SUCCESS
==
code
)
{
switch
(
pQuery
->
execMode
)
{
switch
(
pQuery
->
execMode
)
{
...
@@ -328,7 +330,7 @@ SRequestObj* launchQueryImpl(SRequestObj* pRequest, SQuery* pQuery, int32_t code
...
@@ -328,7 +330,7 @@ SRequestObj* launchQueryImpl(SRequestObj* pRequest, SQuery* pQuery, int32_t code
if
(
!
keepQuery
)
{
if
(
!
keepQuery
)
{
qDestroyQuery
(
pQuery
);
qDestroyQuery
(
pQuery
);
}
}
if
(
NULL
!=
pRequest
&&
TSDB_CODE_SUCCESS
!=
code
)
{
if
(
NULL
!=
pRequest
&&
TSDB_CODE_SUCCESS
!=
code
)
{
pRequest
->
code
=
terrno
;
pRequest
->
code
=
terrno
;
}
}
...
@@ -336,7 +338,6 @@ SRequestObj* launchQueryImpl(SRequestObj* pRequest, SQuery* pQuery, int32_t code
...
@@ -336,7 +338,6 @@ SRequestObj* launchQueryImpl(SRequestObj* pRequest, SQuery* pQuery, int32_t code
return
pRequest
;
return
pRequest
;
}
}
SRequestObj
*
launchQuery
(
STscObj
*
pTscObj
,
const
char
*
sql
,
int
sqlLen
)
{
SRequestObj
*
launchQuery
(
STscObj
*
pTscObj
,
const
char
*
sql
,
int
sqlLen
)
{
SRequestObj
*
pRequest
=
NULL
;
SRequestObj
*
pRequest
=
NULL
;
SQuery
*
pQuery
=
NULL
;
SQuery
*
pQuery
=
NULL
;
...
@@ -522,6 +523,8 @@ static SMsgSendInfo* buildConnectMsg(SRequestObj* pRequest, int8_t connType) {
...
@@ -522,6 +523,8 @@ static SMsgSendInfo* buildConnectMsg(SRequestObj* pRequest, int8_t connType) {
connectReq
.
pid
=
htonl
(
appInfo
.
pid
);
connectReq
.
pid
=
htonl
(
appInfo
.
pid
);
connectReq
.
startTime
=
htobe64
(
appInfo
.
startTime
);
connectReq
.
startTime
=
htobe64
(
appInfo
.
startTime
);
tstrncpy
(
connectReq
.
app
,
appInfo
.
appName
,
sizeof
(
connectReq
.
app
));
tstrncpy
(
connectReq
.
app
,
appInfo
.
appName
,
sizeof
(
connectReq
.
app
));
tstrncpy
(
connectReq
.
user
,
pObj
->
user
,
sizeof
(
connectReq
.
user
));
tstrncpy
(
connectReq
.
passwd
,
pObj
->
pass
,
sizeof
(
connectReq
.
passwd
));
int32_t
contLen
=
tSerializeSConnectReq
(
NULL
,
0
,
&
connectReq
);
int32_t
contLen
=
tSerializeSConnectReq
(
NULL
,
0
,
&
connectReq
);
void
*
pReq
=
taosMemoryMalloc
(
contLen
);
void
*
pReq
=
taosMemoryMalloc
(
contLen
);
...
@@ -726,7 +729,7 @@ static int32_t doConvertUCS4(SReqResultInfo* pResultInfo, int32_t numOfRows, int
...
@@ -726,7 +729,7 @@ static int32_t doConvertUCS4(SReqResultInfo* pResultInfo, int32_t numOfRows, int
int32_t
len
=
taosUcs4ToMbs
((
TdUcs4
*
)
varDataVal
(
pStart
),
varDataLen
(
pStart
),
varDataVal
(
p
));
int32_t
len
=
taosUcs4ToMbs
((
TdUcs4
*
)
varDataVal
(
pStart
),
varDataLen
(
pStart
),
varDataVal
(
p
));
ASSERT
(
len
<=
bytes
);
ASSERT
(
len
<=
bytes
);
ASSERT
((
p
+
len
)
<
(
pResultInfo
->
convertBuf
[
i
]
+
colLength
[
i
]));
ASSERT
((
p
+
len
)
<
(
pResultInfo
->
convertBuf
[
i
]
+
colLength
[
i
]));
varDataSetLen
(
p
,
len
);
varDataSetLen
(
p
,
len
);
pCol
->
offset
[
j
]
=
(
p
-
pResultInfo
->
convertBuf
[
i
]);
pCol
->
offset
[
j
]
=
(
p
-
pResultInfo
->
convertBuf
[
i
]);
p
+=
(
len
+
VARSTR_HEADER_SIZE
);
p
+=
(
len
+
VARSTR_HEADER_SIZE
);
...
@@ -744,51 +747,55 @@ static int32_t doConvertUCS4(SReqResultInfo* pResultInfo, int32_t numOfRows, int
...
@@ -744,51 +747,55 @@ static int32_t doConvertUCS4(SReqResultInfo* pResultInfo, int32_t numOfRows, int
}
}
pResultInfo
->
convertBuf
[
i
]
=
p
;
pResultInfo
->
convertBuf
[
i
]
=
p
;
int32_t
len
=
0
;
int32_t
len
=
0
;
SResultColumn
*
pCol
=
&
pResultInfo
->
pCol
[
i
];
SResultColumn
*
pCol
=
&
pResultInfo
->
pCol
[
i
];
for
(
int32_t
j
=
0
;
j
<
numOfRows
;
++
j
)
{
for
(
int32_t
j
=
0
;
j
<
numOfRows
;
++
j
)
{
if
(
pCol
->
offset
[
j
]
!=
-
1
)
{
if
(
pCol
->
offset
[
j
]
!=
-
1
)
{
char
*
pStart
=
pCol
->
offset
[
j
]
+
pCol
->
pData
;
char
*
pStart
=
pCol
->
offset
[
j
]
+
pCol
->
pData
;
int32_t
jsonInnerType
=
*
pStart
;
int32_t
jsonInnerType
=
*
pStart
;
char
*
jsonInnerData
=
pStart
+
CHAR_BYTES
;
char
*
jsonInnerData
=
pStart
+
CHAR_BYTES
;
char
dst
[
TSDB_MAX_JSON_TAG_LEN
]
=
{
0
};
char
dst
[
TSDB_MAX_JSON_TAG_LEN
]
=
{
0
};
if
(
jsonInnerType
==
TSDB_DATA_TYPE_NULL
)
{
if
(
jsonInnerType
==
TSDB_DATA_TYPE_NULL
)
{
sprintf
(
varDataVal
(
dst
),
"%s"
,
TSDB_DATA_NULL_STR_L
);
sprintf
(
varDataVal
(
dst
),
"%s"
,
TSDB_DATA_NULL_STR_L
);
varDataSetLen
(
dst
,
strlen
(
varDataVal
(
dst
)));
varDataSetLen
(
dst
,
strlen
(
varDataVal
(
dst
)));
}
else
if
(
jsonInnerType
==
TSDB_DATA_TYPE_JSON
){
}
else
if
(
jsonInnerType
==
TSDB_DATA_TYPE_JSON
)
{
int32_t
length
=
taosUcs4ToMbs
((
TdUcs4
*
)
varDataVal
(
jsonInnerData
),
varDataLen
(
jsonInnerData
),
varDataVal
(
dst
));
int32_t
length
=
taosUcs4ToMbs
((
TdUcs4
*
)
varDataVal
(
jsonInnerData
),
varDataLen
(
jsonInnerData
),
varDataVal
(
dst
));
if
(
length
<=
0
)
{
if
(
length
<=
0
)
{
tscError
(
"charset:%s to %s. val:%s convert failed."
,
DEFAULT_UNICODE_ENCODEC
,
tsCharset
,
varDataVal
(
jsonInnerData
));
tscError
(
"charset:%s to %s. val:%s convert failed."
,
DEFAULT_UNICODE_ENCODEC
,
tsCharset
,
varDataVal
(
jsonInnerData
));
length
=
0
;
length
=
0
;
}
}
varDataSetLen
(
dst
,
length
);
varDataSetLen
(
dst
,
length
);
}
else
if
(
jsonInnerType
==
TSDB_DATA_TYPE_NCHAR
)
{
// value -> "value"
}
else
if
(
jsonInnerType
==
TSDB_DATA_TYPE_NCHAR
)
{
// value -> "value"
*
(
char
*
)
varDataVal
(
dst
)
=
'\"'
;
*
(
char
*
)
varDataVal
(
dst
)
=
'\"'
;
int32_t
length
=
taosUcs4ToMbs
((
TdUcs4
*
)
varDataVal
(
jsonInnerData
),
varDataLen
(
jsonInnerData
),
varDataVal
(
dst
)
+
CHAR_BYTES
);
int32_t
length
=
taosUcs4ToMbs
((
TdUcs4
*
)
varDataVal
(
jsonInnerData
),
varDataLen
(
jsonInnerData
),
varDataVal
(
dst
)
+
CHAR_BYTES
);
if
(
length
<=
0
)
{
if
(
length
<=
0
)
{
tscError
(
"charset:%s to %s. val:%s convert failed."
,
DEFAULT_UNICODE_ENCODEC
,
tsCharset
,
varDataVal
(
jsonInnerData
));
tscError
(
"charset:%s to %s. val:%s convert failed."
,
DEFAULT_UNICODE_ENCODEC
,
tsCharset
,
varDataVal
(
jsonInnerData
));
length
=
0
;
length
=
0
;
}
}
varDataSetLen
(
dst
,
length
+
CHAR_BYTES
*
2
);
varDataSetLen
(
dst
,
length
+
CHAR_BYTES
*
2
);
*
(
char
*
)(
varDataVal
(
dst
),
length
+
CHAR_BYTES
)
=
'\"'
;
*
(
char
*
)(
varDataVal
(
dst
),
length
+
CHAR_BYTES
)
=
'\"'
;
}
else
if
(
jsonInnerType
==
TSDB_DATA_TYPE_DOUBLE
)
{
}
else
if
(
jsonInnerType
==
TSDB_DATA_TYPE_DOUBLE
)
{
double
jsonVd
=
*
(
double
*
)(
jsonInnerData
);
double
jsonVd
=
*
(
double
*
)(
jsonInnerData
);
sprintf
(
varDataVal
(
dst
),
"%.9lf"
,
jsonVd
);
sprintf
(
varDataVal
(
dst
),
"%.9lf"
,
jsonVd
);
varDataSetLen
(
dst
,
strlen
(
varDataVal
(
dst
)));
varDataSetLen
(
dst
,
strlen
(
varDataVal
(
dst
)));
}
else
if
(
jsonInnerType
==
TSDB_DATA_TYPE_BIGINT
)
{
}
else
if
(
jsonInnerType
==
TSDB_DATA_TYPE_BIGINT
)
{
int64_t
jsonVd
=
*
(
int64_t
*
)(
jsonInnerData
);
int64_t
jsonVd
=
*
(
int64_t
*
)(
jsonInnerData
);
sprintf
(
varDataVal
(
dst
),
"%"
PRId64
,
jsonVd
);
sprintf
(
varDataVal
(
dst
),
"%"
PRId64
,
jsonVd
);
varDataSetLen
(
dst
,
strlen
(
varDataVal
(
dst
)));
varDataSetLen
(
dst
,
strlen
(
varDataVal
(
dst
)));
}
else
if
(
jsonInnerType
==
TSDB_DATA_TYPE_BOOL
)
{
}
else
if
(
jsonInnerType
==
TSDB_DATA_TYPE_BOOL
)
{
sprintf
(
varDataVal
(
dst
),
"%s"
,
(
*
((
char
*
)
jsonInnerData
)
==
1
)
?
"true"
:
"false"
);
sprintf
(
varDataVal
(
dst
),
"%s"
,
(
*
((
char
*
)
jsonInnerData
)
==
1
)
?
"true"
:
"false"
);
varDataSetLen
(
dst
,
strlen
(
varDataVal
(
dst
)));
varDataSetLen
(
dst
,
strlen
(
varDataVal
(
dst
)));
}
else
{
}
else
{
ASSERT
(
0
);
ASSERT
(
0
);
}
}
if
(
len
+
varDataTLen
(
dst
)
>
colLength
[
i
])
{
if
(
len
+
varDataTLen
(
dst
)
>
colLength
[
i
])
{
p
=
taosMemoryRealloc
(
pResultInfo
->
convertBuf
[
i
],
len
+
varDataTLen
(
dst
));
p
=
taosMemoryRealloc
(
pResultInfo
->
convertBuf
[
i
],
len
+
varDataTLen
(
dst
));
if
(
p
==
NULL
)
{
if
(
p
==
NULL
)
{
return
TSDB_CODE_OUT_OF_MEMORY
;
return
TSDB_CODE_OUT_OF_MEMORY
;
...
...
source/client/src/clientMain.c
浏览文件 @
162b3087
...
@@ -135,6 +135,16 @@ void taos_free_result(TAOS_RES *res) {
...
@@ -135,6 +135,16 @@ void taos_free_result(TAOS_RES *res) {
if
(
TD_RES_QUERY
(
res
))
{
if
(
TD_RES_QUERY
(
res
))
{
SRequestObj
*
pRequest
=
(
SRequestObj
*
)
res
;
SRequestObj
*
pRequest
=
(
SRequestObj
*
)
res
;
destroyRequest
(
pRequest
);
destroyRequest
(
pRequest
);
}
else
if
(
TD_RES_TMQ
(
res
))
{
SMqRspObj
*
pRsp
=
(
SMqRspObj
*
)
res
;
if
(
pRsp
->
rsp
.
blockData
)
taosArrayDestroyP
(
pRsp
->
rsp
.
blockData
,
taosMemoryFree
);
if
(
pRsp
->
rsp
.
blockDataLen
)
taosArrayDestroy
(
pRsp
->
rsp
.
blockDataLen
);
if
(
pRsp
->
rsp
.
blockSchema
)
taosArrayDestroy
(
pRsp
->
rsp
.
blockSchema
);
if
(
pRsp
->
rsp
.
blockTbName
)
taosArrayDestroy
(
pRsp
->
rsp
.
blockTbName
);
if
(
pRsp
->
rsp
.
blockTags
)
taosArrayDestroy
(
pRsp
->
rsp
.
blockTags
);
if
(
pRsp
->
rsp
.
blockTagSchema
)
taosArrayDestroy
(
pRsp
->
rsp
.
blockTagSchema
);
pRsp
->
resInfo
.
pRspMsg
=
NULL
;
doFreeReqResultInfo
(
&
pRsp
->
resInfo
);
}
}
}
}
...
...
source/client/test/clientTests.cpp
浏览文件 @
162b3087
...
@@ -662,7 +662,7 @@ TEST(testCase, agg_query_tables) {
...
@@ -662,7 +662,7 @@ TEST(testCase, agg_query_tables) {
TAOS_RES
*
pRes
=
taos_query
(
pConn
,
"use abc1"
);
TAOS_RES
*
pRes
=
taos_query
(
pConn
,
"use abc1"
);
taos_free_result
(
pRes
);
taos_free_result
(
pRes
);
pRes
=
taos_query
(
pConn
,
"select
count(*) from tu
"
);
pRes
=
taos_query
(
pConn
,
"select
now() from m1
"
);
if
(
taos_errno
(
pRes
)
!=
0
)
{
if
(
taos_errno
(
pRes
)
!=
0
)
{
printf
(
"failed to select from table, reason:%s
\n
"
,
taos_errstr
(
pRes
));
printf
(
"failed to select from table, reason:%s
\n
"
,
taos_errstr
(
pRes
));
taos_free_result
(
pRes
);
taos_free_result
(
pRes
);
...
...
source/common/src/tdataformat.c
浏览文件 @
162b3087
...
@@ -110,7 +110,7 @@ void *tdDecodeSchema(void *buf, STSchema **pRSchema) {
...
@@ -110,7 +110,7 @@ void *tdDecodeSchema(void *buf, STSchema **pRSchema) {
for
(
int
i
=
0
;
i
<
numOfCols
;
i
++
)
{
for
(
int
i
=
0
;
i
<
numOfCols
;
i
++
)
{
col_type_t
type
=
0
;
col_type_t
type
=
0
;
int8_t
sma
=
TSDB_BSMA_TYPE_NONE
;
int8_t
sma
=
0
;
col_id_t
colId
=
0
;
col_id_t
colId
=
0
;
col_bytes_t
bytes
=
0
;
col_bytes_t
bytes
=
0
;
buf
=
taosDecodeFixedI8
(
buf
,
&
type
);
buf
=
taosDecodeFixedI8
(
buf
,
&
type
);
...
...
source/common/src/tmsg.c
浏览文件 @
162b3087
...
@@ -434,6 +434,15 @@ int32_t tSerializeSVCreateTbReq(void **buf, SVCreateTbReq *pReq) {
...
@@ -434,6 +434,15 @@ int32_t tSerializeSVCreateTbReq(void **buf, SVCreateTbReq *pReq) {
for
(
int8_t
i
=
0
;
i
<
param
->
nFuncIds
;
++
i
)
{
for
(
int8_t
i
=
0
;
i
<
param
->
nFuncIds
;
++
i
)
{
tlen
+=
taosEncodeFixedI32
(
buf
,
param
->
pFuncIds
[
i
]);
tlen
+=
taosEncodeFixedI32
(
buf
,
param
->
pFuncIds
[
i
]);
}
}
tlen
+=
taosEncodeFixedI32
(
buf
,
param
->
qmsg1Len
);
if
(
param
->
qmsg1Len
>
0
)
{
tlen
+=
taosEncodeString
(
buf
,
param
->
qmsg1
);
}
tlen
+=
taosEncodeFixedI32
(
buf
,
param
->
qmsg2Len
);
if
(
param
->
qmsg2Len
>
0
)
{
tlen
+=
taosEncodeString
(
buf
,
param
->
qmsg2
);
}
}
}
break
;
break
;
case
TD_CHILD_TABLE
:
case
TD_CHILD_TABLE
:
...
@@ -496,18 +505,25 @@ void *tDeserializeSVCreateTbReq(void *buf, SVCreateTbReq *pReq) {
...
@@ -496,18 +505,25 @@ void *tDeserializeSVCreateTbReq(void *buf, SVCreateTbReq *pReq) {
buf
=
taosDecodeStringTo
(
buf
,
pReq
->
stbCfg
.
pTagSchema
[
i
].
name
);
buf
=
taosDecodeStringTo
(
buf
,
pReq
->
stbCfg
.
pTagSchema
[
i
].
name
);
}
}
if
(
pReq
->
rollup
)
{
if
(
pReq
->
rollup
)
{
pReq
->
stbCfg
.
pRSmaParam
=
(
SRSmaParam
*
)
taosMemory
Malloc
(
sizeof
(
SRSmaParam
));
pReq
->
stbCfg
.
pRSmaParam
=
(
SRSmaParam
*
)
taosMemory
Calloc
(
1
,
sizeof
(
SRSmaParam
));
SRSmaParam
*
param
=
pReq
->
stbCfg
.
pRSmaParam
;
SRSmaParam
*
param
=
pReq
->
stbCfg
.
pRSmaParam
;
buf
=
taosDecodeBinaryTo
(
buf
,
(
void
*
)
&
param
->
xFilesFactor
,
sizeof
(
param
->
xFilesFactor
));
buf
=
taosDecodeBinaryTo
(
buf
,
(
void
*
)
&
param
->
xFilesFactor
,
sizeof
(
param
->
xFilesFactor
));
buf
=
taosDecodeFixedI32
(
buf
,
&
param
->
delay
);
buf
=
taosDecodeFixedI32
(
buf
,
&
param
->
delay
);
buf
=
taosDecodeFixedI8
(
buf
,
&
param
->
nFuncIds
);
buf
=
taosDecodeFixedI8
(
buf
,
&
param
->
nFuncIds
);
if
(
param
->
nFuncIds
>
0
)
{
if
(
param
->
nFuncIds
>
0
)
{
param
->
pFuncIds
=
(
func_id_t
*
)
taosMemory
Malloc
(
param
->
nFuncIds
*
sizeof
(
func_id_t
));
param
->
pFuncIds
=
(
func_id_t
*
)
taosMemory
Calloc
(
param
->
nFuncIds
,
sizeof
(
func_id_t
));
for
(
int8_t
i
=
0
;
i
<
param
->
nFuncIds
;
++
i
)
{
for
(
int8_t
i
=
0
;
i
<
param
->
nFuncIds
;
++
i
)
{
buf
=
taosDecodeFixedI32
(
buf
,
param
->
pFuncIds
+
i
);
buf
=
taosDecodeFixedI32
(
buf
,
param
->
pFuncIds
+
i
);
}
}
}
else
{
}
param
->
pFuncIds
=
NULL
;
buf
=
taosDecodeFixedI32
(
buf
,
&
param
->
qmsg1Len
);
if
(
param
->
qmsg1Len
>
0
)
{
buf
=
taosDecodeString
(
buf
,
&
param
->
qmsg1
);
}
buf
=
taosDecodeFixedI32
(
buf
,
&
param
->
qmsg2Len
);
if
(
param
->
qmsg2Len
>
0
)
{
buf
=
taosDecodeString
(
buf
,
&
param
->
qmsg2
);
}
}
}
else
{
}
else
{
pReq
->
stbCfg
.
pRSmaParam
=
NULL
;
pReq
->
stbCfg
.
pRSmaParam
=
NULL
;
...
@@ -828,6 +844,27 @@ void tFreeSMAltertbReq(SMAltertbReq *pReq) {
...
@@ -828,6 +844,27 @@ void tFreeSMAltertbReq(SMAltertbReq *pReq) {
taosArrayDestroy
(
pReq
->
pFields
);
taosArrayDestroy
(
pReq
->
pFields
);
pReq
->
pFields
=
NULL
;
pReq
->
pFields
=
NULL
;
}
}
int32_t
tSerializeSMEpSet
(
void
*
buf
,
int32_t
bufLen
,
SMEpSet
*
pReq
)
{
SCoder
encoder
=
{
0
};
tCoderInit
(
&
encoder
,
TD_LITTLE_ENDIAN
,
buf
,
bufLen
,
TD_ENCODER
);
if
(
tStartEncode
(
&
encoder
)
<
0
)
return
-
1
;
if
(
tEncodeSEpSet
(
&
encoder
,
&
pReq
->
epSet
)
<
0
)
return
-
1
;
tEndEncode
(
&
encoder
);
int32_t
tlen
=
encoder
.
pos
;
tCoderClear
(
&
encoder
);
return
tlen
;
}
int32_t
tDeserializeSMEpSet
(
void
*
buf
,
int32_t
bufLen
,
SMEpSet
*
pReq
)
{
SCoder
decoder
=
{
0
};
tCoderInit
(
&
decoder
,
TD_LITTLE_ENDIAN
,
buf
,
bufLen
,
TD_DECODER
);
if
(
tStartDecode
(
&
decoder
)
<
0
)
return
-
1
;
if
(
tDecodeSEpSet
(
&
decoder
,
&
pReq
->
epSet
)
<
0
)
return
-
1
;
tEndDecode
(
&
decoder
);
tCoderClear
(
&
decoder
);
return
0
;
}
int32_t
tSerializeSMCreateSmaReq
(
void
*
buf
,
int32_t
bufLen
,
SMCreateSmaReq
*
pReq
)
{
int32_t
tSerializeSMCreateSmaReq
(
void
*
buf
,
int32_t
bufLen
,
SMCreateSmaReq
*
pReq
)
{
SCoder
encoder
=
{
0
};
SCoder
encoder
=
{
0
};
...
@@ -2425,7 +2462,6 @@ int32_t tSerializeSRetrieveTableReq(void *buf, int32_t bufLen, SRetrieveTableReq
...
@@ -2425,7 +2462,6 @@ int32_t tSerializeSRetrieveTableReq(void *buf, int32_t bufLen, SRetrieveTableReq
if
(
tStartEncode
(
&
encoder
)
<
0
)
return
-
1
;
if
(
tStartEncode
(
&
encoder
)
<
0
)
return
-
1
;
if
(
tEncodeI64
(
&
encoder
,
pReq
->
showId
)
<
0
)
return
-
1
;
if
(
tEncodeI64
(
&
encoder
,
pReq
->
showId
)
<
0
)
return
-
1
;
if
(
tEncodeI32
(
&
encoder
,
pReq
->
type
)
<
0
)
return
-
1
;
if
(
tEncodeCStr
(
&
encoder
,
pReq
->
db
)
<
0
)
return
-
1
;
if
(
tEncodeCStr
(
&
encoder
,
pReq
->
db
)
<
0
)
return
-
1
;
if
(
tEncodeCStr
(
&
encoder
,
pReq
->
tb
)
<
0
)
return
-
1
;
if
(
tEncodeCStr
(
&
encoder
,
pReq
->
tb
)
<
0
)
return
-
1
;
tEndEncode
(
&
encoder
);
tEndEncode
(
&
encoder
);
...
@@ -2441,7 +2477,6 @@ int32_t tDeserializeSRetrieveTableReq(void *buf, int32_t bufLen, SRetrieveTableR
...
@@ -2441,7 +2477,6 @@ int32_t tDeserializeSRetrieveTableReq(void *buf, int32_t bufLen, SRetrieveTableR
if
(
tStartDecode
(
&
decoder
)
<
0
)
return
-
1
;
if
(
tStartDecode
(
&
decoder
)
<
0
)
return
-
1
;
if
(
tDecodeI64
(
&
decoder
,
&
pReq
->
showId
)
<
0
)
return
-
1
;
if
(
tDecodeI64
(
&
decoder
,
&
pReq
->
showId
)
<
0
)
return
-
1
;
if
(
tDecodeI32
(
&
decoder
,
&
pReq
->
type
)
<
0
)
return
-
1
;
if
(
tDecodeCStrTo
(
&
decoder
,
pReq
->
db
)
<
0
)
return
-
1
;
if
(
tDecodeCStrTo
(
&
decoder
,
pReq
->
db
)
<
0
)
return
-
1
;
if
(
tDecodeCStrTo
(
&
decoder
,
pReq
->
tb
)
<
0
)
return
-
1
;
if
(
tDecodeCStrTo
(
&
decoder
,
pReq
->
tb
)
<
0
)
return
-
1
;
tEndDecode
(
&
decoder
);
tEndDecode
(
&
decoder
);
...
@@ -2696,6 +2731,10 @@ int32_t tSerializeSCMCreateTopicReq(void *buf, int32_t bufLen, const SCMCreateTo
...
@@ -2696,6 +2731,10 @@ int32_t tSerializeSCMCreateTopicReq(void *buf, int32_t bufLen, const SCMCreateTo
if
(
tStartEncode
(
&
encoder
)
<
0
)
return
-
1
;
if
(
tStartEncode
(
&
encoder
)
<
0
)
return
-
1
;
if
(
tEncodeCStr
(
&
encoder
,
pReq
->
name
)
<
0
)
return
-
1
;
if
(
tEncodeCStr
(
&
encoder
,
pReq
->
name
)
<
0
)
return
-
1
;
if
(
tEncodeI8
(
&
encoder
,
pReq
->
igExists
)
<
0
)
return
-
1
;
if
(
tEncodeI8
(
&
encoder
,
pReq
->
igExists
)
<
0
)
return
-
1
;
if
(
tEncodeI8
(
&
encoder
,
pReq
->
withTbName
)
<
0
)
return
-
1
;
if
(
tEncodeI8
(
&
encoder
,
pReq
->
withSchema
)
<
0
)
return
-
1
;
if
(
tEncodeI8
(
&
encoder
,
pReq
->
withTag
)
<
0
)
return
-
1
;
if
(
tEncodeI8
(
&
encoder
,
pReq
->
withTagSchema
)
<
0
)
return
-
1
;
if
(
tEncodeI32
(
&
encoder
,
sqlLen
)
<
0
)
return
-
1
;
if
(
tEncodeI32
(
&
encoder
,
sqlLen
)
<
0
)
return
-
1
;
if
(
tEncodeI32
(
&
encoder
,
astLen
)
<
0
)
return
-
1
;
if
(
tEncodeI32
(
&
encoder
,
astLen
)
<
0
)
return
-
1
;
if
(
sqlLen
>
0
&&
tEncodeCStr
(
&
encoder
,
pReq
->
sql
)
<
0
)
return
-
1
;
if
(
sqlLen
>
0
&&
tEncodeCStr
(
&
encoder
,
pReq
->
sql
)
<
0
)
return
-
1
;
...
@@ -2718,6 +2757,10 @@ int32_t tDeserializeSCMCreateTopicReq(void *buf, int32_t bufLen, SCMCreateTopicR
...
@@ -2718,6 +2757,10 @@ int32_t tDeserializeSCMCreateTopicReq(void *buf, int32_t bufLen, SCMCreateTopicR
if
(
tStartDecode
(
&
decoder
)
<
0
)
return
-
1
;
if
(
tStartDecode
(
&
decoder
)
<
0
)
return
-
1
;
if
(
tDecodeCStrTo
(
&
decoder
,
pReq
->
name
)
<
0
)
return
-
1
;
if
(
tDecodeCStrTo
(
&
decoder
,
pReq
->
name
)
<
0
)
return
-
1
;
if
(
tDecodeI8
(
&
decoder
,
&
pReq
->
igExists
)
<
0
)
return
-
1
;
if
(
tDecodeI8
(
&
decoder
,
&
pReq
->
igExists
)
<
0
)
return
-
1
;
if
(
tDecodeI8
(
&
decoder
,
&
pReq
->
withTbName
)
<
0
)
return
-
1
;
if
(
tDecodeI8
(
&
decoder
,
&
pReq
->
withSchema
)
<
0
)
return
-
1
;
if
(
tDecodeI8
(
&
decoder
,
&
pReq
->
withTag
)
<
0
)
return
-
1
;
if
(
tDecodeI8
(
&
decoder
,
&
pReq
->
withTagSchema
)
<
0
)
return
-
1
;
if
(
tDecodeI32
(
&
decoder
,
&
sqlLen
)
<
0
)
return
-
1
;
if
(
tDecodeI32
(
&
decoder
,
&
sqlLen
)
<
0
)
return
-
1
;
if
(
tDecodeI32
(
&
decoder
,
&
astLen
)
<
0
)
return
-
1
;
if
(
tDecodeI32
(
&
decoder
,
&
astLen
)
<
0
)
return
-
1
;
...
@@ -2778,6 +2821,8 @@ int32_t tSerializeSConnectReq(void *buf, int32_t bufLen, SConnectReq *pReq) {
...
@@ -2778,6 +2821,8 @@ int32_t tSerializeSConnectReq(void *buf, int32_t bufLen, SConnectReq *pReq) {
if
(
tEncodeI32
(
&
encoder
,
pReq
->
pid
)
<
0
)
return
-
1
;
if
(
tEncodeI32
(
&
encoder
,
pReq
->
pid
)
<
0
)
return
-
1
;
if
(
tEncodeCStr
(
&
encoder
,
pReq
->
app
)
<
0
)
return
-
1
;
if
(
tEncodeCStr
(
&
encoder
,
pReq
->
app
)
<
0
)
return
-
1
;
if
(
tEncodeCStr
(
&
encoder
,
pReq
->
db
)
<
0
)
return
-
1
;
if
(
tEncodeCStr
(
&
encoder
,
pReq
->
db
)
<
0
)
return
-
1
;
if
(
tEncodeCStr
(
&
encoder
,
pReq
->
user
)
<
0
)
return
-
1
;
if
(
tEncodeCStr
(
&
encoder
,
pReq
->
passwd
)
<
0
)
return
-
1
;
if
(
tEncodeI64
(
&
encoder
,
pReq
->
startTime
)
<
0
)
return
-
1
;
if
(
tEncodeI64
(
&
encoder
,
pReq
->
startTime
)
<
0
)
return
-
1
;
tEndEncode
(
&
encoder
);
tEndEncode
(
&
encoder
);
...
@@ -2795,6 +2840,8 @@ int32_t tDeserializeSConnectReq(void *buf, int32_t bufLen, SConnectReq *pReq) {
...
@@ -2795,6 +2840,8 @@ int32_t tDeserializeSConnectReq(void *buf, int32_t bufLen, SConnectReq *pReq) {
if
(
tDecodeI32
(
&
decoder
,
&
pReq
->
pid
)
<
0
)
return
-
1
;
if
(
tDecodeI32
(
&
decoder
,
&
pReq
->
pid
)
<
0
)
return
-
1
;
if
(
tDecodeCStrTo
(
&
decoder
,
pReq
->
app
)
<
0
)
return
-
1
;
if
(
tDecodeCStrTo
(
&
decoder
,
pReq
->
app
)
<
0
)
return
-
1
;
if
(
tDecodeCStrTo
(
&
decoder
,
pReq
->
db
)
<
0
)
return
-
1
;
if
(
tDecodeCStrTo
(
&
decoder
,
pReq
->
db
)
<
0
)
return
-
1
;
if
(
tDecodeCStrTo
(
&
decoder
,
pReq
->
user
)
<
0
)
return
-
1
;
if
(
tDecodeCStrTo
(
&
decoder
,
pReq
->
passwd
)
<
0
)
return
-
1
;
if
(
tDecodeI64
(
&
decoder
,
&
pReq
->
startTime
)
<
0
)
return
-
1
;
if
(
tDecodeI64
(
&
decoder
,
&
pReq
->
startTime
)
<
0
)
return
-
1
;
tEndDecode
(
&
decoder
);
tEndDecode
(
&
decoder
);
...
@@ -3054,7 +3101,6 @@ int32_t tDeserializeSCompactVnodeReq(void *buf, int32_t bufLen, SCompactVnodeReq
...
@@ -3054,7 +3101,6 @@ int32_t tDeserializeSCompactVnodeReq(void *buf, int32_t bufLen, SCompactVnodeReq
return
0
;
return
0
;
}
}
int32_t
tSerializeSAlterVnodeReq
(
void
*
buf
,
int32_t
bufLen
,
SAlterVnodeReq
*
pReq
)
{
int32_t
tSerializeSAlterVnodeReq
(
void
*
buf
,
int32_t
bufLen
,
SAlterVnodeReq
*
pReq
)
{
SCoder
encoder
=
{
0
};
SCoder
encoder
=
{
0
};
tCoderInit
(
&
encoder
,
TD_LITTLE_ENDIAN
,
buf
,
bufLen
,
TD_ENCODER
);
tCoderInit
(
&
encoder
,
TD_LITTLE_ENDIAN
,
buf
,
bufLen
,
TD_ENCODER
);
...
@@ -3074,7 +3120,7 @@ int32_t tSerializeSAlterVnodeReq(void *buf, int32_t bufLen, SAlterVnodeReq *pReq
...
@@ -3074,7 +3120,7 @@ int32_t tSerializeSAlterVnodeReq(void *buf, int32_t bufLen, SAlterVnodeReq *pReq
SReplica
*
pReplica
=
&
pReq
->
replicas
[
i
];
SReplica
*
pReplica
=
&
pReq
->
replicas
[
i
];
if
(
tEncodeSReplica
(
&
encoder
,
pReplica
)
<
0
)
return
-
1
;
if
(
tEncodeSReplica
(
&
encoder
,
pReplica
)
<
0
)
return
-
1
;
}
}
tEndEncode
(
&
encoder
);
tEndEncode
(
&
encoder
);
int32_t
tlen
=
encoder
.
pos
;
int32_t
tlen
=
encoder
.
pos
;
...
@@ -3107,7 +3153,6 @@ int32_t tDeserializeSAlterVnodeReq(void *buf, int32_t bufLen, SAlterVnodeReq *pR
...
@@ -3107,7 +3153,6 @@ int32_t tDeserializeSAlterVnodeReq(void *buf, int32_t bufLen, SAlterVnodeReq *pR
return
0
;
return
0
;
}
}
int32_t
tSerializeSKillQueryReq
(
void
*
buf
,
int32_t
bufLen
,
SKillQueryReq
*
pReq
)
{
int32_t
tSerializeSKillQueryReq
(
void
*
buf
,
int32_t
bufLen
,
SKillQueryReq
*
pReq
)
{
SCoder
encoder
=
{
0
};
SCoder
encoder
=
{
0
};
tCoderInit
(
&
encoder
,
TD_LITTLE_ENDIAN
,
buf
,
bufLen
,
TD_ENCODER
);
tCoderInit
(
&
encoder
,
TD_LITTLE_ENDIAN
,
buf
,
bufLen
,
TD_ENCODER
);
...
...
source/dnode/mgmt/implement/src/dmHandle.c
浏览文件 @
162b3087
...
@@ -216,6 +216,126 @@ static void dmStopMgmt(SMgmtWrapper *pWrapper) {
...
@@ -216,6 +216,126 @@ static void dmStopMgmt(SMgmtWrapper *pWrapper) {
dmStopStatusThread
(
pWrapper
->
pDnode
);
dmStopStatusThread
(
pWrapper
->
pDnode
);
}
}
static
int32_t
dmSpawnUdfd
(
SDnode
*
pDnode
);
void
dmUdfdExit
(
uv_process_t
*
process
,
int64_t
exitStatus
,
int
termSignal
)
{
dInfo
(
"udfd process exited with status %"
PRId64
", signal %d"
,
exitStatus
,
termSignal
);
uv_close
((
uv_handle_t
*
)
process
,
NULL
);
SDnode
*
pDnode
=
process
->
data
;
SUdfdData
*
pData
=
&
pDnode
->
udfdData
;
if
(
atomic_load_8
(
&
pData
->
stopping
)
!=
0
)
{
dDebug
(
"udfd process exit due to stopping"
);
}
else
{
uv_close
((
uv_handle_t
*
)
&
pData
->
ctrlPipe
,
NULL
);
dmSpawnUdfd
(
pDnode
);
}
}
static
int32_t
dmSpawnUdfd
(
SDnode
*
pDnode
)
{
dInfo
(
"dnode start spawning udfd"
);
uv_process_options_t
options
=
{
0
};
char
path
[
PATH_MAX
]
=
{
0
};
if
(
tsProcPath
==
NULL
)
{
path
[
0
]
=
'.'
;
}
else
{
strncpy
(
path
,
tsProcPath
,
strlen
(
tsProcPath
));
taosDirName
(
path
);
}
strcat
(
path
,
"/udfd"
);
char
*
argsUdfd
[]
=
{
path
,
"-c"
,
configDir
,
NULL
};
options
.
args
=
argsUdfd
;
options
.
file
=
path
;
options
.
exit_cb
=
dmUdfdExit
;
SUdfdData
*
pData
=
&
pDnode
->
udfdData
;
uv_pipe_init
(
&
pData
->
loop
,
&
pData
->
ctrlPipe
,
1
);
uv_stdio_container_t
child_stdio
[
3
];
child_stdio
[
0
].
flags
=
UV_CREATE_PIPE
|
UV_READABLE_PIPE
;
child_stdio
[
0
].
data
.
stream
=
(
uv_stream_t
*
)
&
pData
->
ctrlPipe
;
child_stdio
[
1
].
flags
=
UV_IGNORE
;
child_stdio
[
2
].
flags
=
UV_INHERIT_FD
;
child_stdio
[
2
].
data
.
fd
=
2
;
options
.
stdio_count
=
3
;
options
.
stdio
=
child_stdio
;
char
dnodeIdEnvItem
[
32
]
=
{
0
};
char
thrdPoolSizeEnvItem
[
32
]
=
{
0
};
snprintf
(
dnodeIdEnvItem
,
32
,
"%s=%d"
,
"DNODE_ID"
,
pDnode
->
data
.
dnodeId
);
float
numCpuCores
=
4
;
taosGetCpuCores
(
&
numCpuCores
);
snprintf
(
thrdPoolSizeEnvItem
,
32
,
"%s=%d"
,
"UV_THREADPOOL_SIZE"
,
(
int
)
numCpuCores
*
2
);
char
*
envUdfd
[]
=
{
dnodeIdEnvItem
,
thrdPoolSizeEnvItem
,
NULL
};
options
.
env
=
envUdfd
;
int
err
=
uv_spawn
(
&
pData
->
loop
,
&
pData
->
process
,
&
options
);
pData
->
process
.
data
=
(
void
*
)
pDnode
;
if
(
err
!=
0
)
{
dError
(
"can not spawn udfd. path: %s, error: %s"
,
path
,
uv_strerror
(
err
));
}
return
err
;
}
static
void
dmUdfdCloseWalkCb
(
uv_handle_t
*
handle
,
void
*
arg
)
{
if
(
!
uv_is_closing
(
handle
))
{
uv_close
(
handle
,
NULL
);
}
}
void
dmWatchUdfd
(
void
*
args
)
{
SDnode
*
pDnode
=
args
;
SUdfdData
*
pData
=
&
pDnode
->
udfdData
;
uv_loop_init
(
&
pData
->
loop
);
int32_t
err
=
dmSpawnUdfd
(
pDnode
);
atomic_store_32
(
&
pData
->
spawnErr
,
err
);
uv_barrier_wait
(
&
pData
->
barrier
);
uv_run
(
&
pData
->
loop
,
UV_RUN_DEFAULT
);
err
=
uv_loop_close
(
&
pData
->
loop
);
while
(
err
==
UV_EBUSY
)
{
uv_walk
(
&
pData
->
loop
,
dmUdfdCloseWalkCb
,
NULL
);
uv_run
(
&
pData
->
loop
,
UV_RUN_DEFAULT
);
err
=
uv_loop_close
(
&
pData
->
loop
);
}
return
;
}
int32_t
dmStartUdfd
(
SDnode
*
pDnode
)
{
SUdfdData
*
pData
=
&
pDnode
->
udfdData
;
if
(
pData
->
startCalled
)
{
dInfo
(
"dnode-mgmt start udfd already called"
);
return
0
;
}
uv_barrier_init
(
&
pData
->
barrier
,
2
);
pData
->
stopping
=
0
;
uv_thread_create
(
&
pData
->
thread
,
dmWatchUdfd
,
pDnode
);
uv_barrier_wait
(
&
pData
->
barrier
);
pData
->
startCalled
=
true
;
pData
->
needCleanUp
=
true
;
return
pData
->
spawnErr
;
}
int32_t
dmStopUdfd
(
SDnode
*
pDnode
)
{
dInfo
(
"dnode-mgmt to stop udfd. need cleanup: %d, spawn err: %d"
,
pDnode
->
udfdData
.
needCleanUp
,
pDnode
->
udfdData
.
spawnErr
);
SUdfdData
*
pData
=
&
pDnode
->
udfdData
;
if
(
!
pData
->
needCleanUp
)
{
return
0
;
}
atomic_store_8
(
&
pData
->
stopping
,
1
);
uv_barrier_destroy
(
&
pData
->
barrier
);
if
(
pData
->
spawnErr
==
0
)
{
uv_process_kill
(
&
pData
->
process
,
SIGINT
);
}
uv_stop
(
&
pData
->
loop
);
uv_thread_join
(
&
pData
->
thread
);
atomic_store_8
(
&
pData
->
stopping
,
0
);
return
0
;
}
static
int32_t
dmInitMgmt
(
SMgmtWrapper
*
pWrapper
)
{
static
int32_t
dmInitMgmt
(
SMgmtWrapper
*
pWrapper
)
{
dInfo
(
"dnode-mgmt start to init"
);
dInfo
(
"dnode-mgmt start to init"
);
SDnode
*
pDnode
=
pWrapper
->
pDnode
;
SDnode
*
pDnode
=
pWrapper
->
pDnode
;
...
@@ -247,6 +367,10 @@ static int32_t dmInitMgmt(SMgmtWrapper *pWrapper) {
...
@@ -247,6 +367,10 @@ static int32_t dmInitMgmt(SMgmtWrapper *pWrapper) {
}
}
dmReportStartup
(
pDnode
,
"dnode-transport"
,
"initialized"
);
dmReportStartup
(
pDnode
,
"dnode-transport"
,
"initialized"
);
if
(
dmStartUdfd
(
pDnode
)
!=
0
)
{
dError
(
"failed to start udfd"
);
}
dInfo
(
"dnode-mgmt is initialized"
);
dInfo
(
"dnode-mgmt is initialized"
);
return
0
;
return
0
;
}
}
...
@@ -254,6 +378,7 @@ static int32_t dmInitMgmt(SMgmtWrapper *pWrapper) {
...
@@ -254,6 +378,7 @@ static int32_t dmInitMgmt(SMgmtWrapper *pWrapper) {
static
void
dmCleanupMgmt
(
SMgmtWrapper
*
pWrapper
)
{
static
void
dmCleanupMgmt
(
SMgmtWrapper
*
pWrapper
)
{
dInfo
(
"dnode-mgmt start to clean up"
);
dInfo
(
"dnode-mgmt start to clean up"
);
SDnode
*
pDnode
=
pWrapper
->
pDnode
;
SDnode
*
pDnode
=
pWrapper
->
pDnode
;
dmStopUdfd
(
pDnode
);
dmStopWorker
(
pDnode
);
dmStopWorker
(
pDnode
);
taosWLockLatch
(
&
pDnode
->
data
.
latch
);
taosWLockLatch
(
&
pDnode
->
data
.
latch
);
...
...
source/dnode/mgmt/implement/src/dmTransport.c
浏览文件 @
162b3087
...
@@ -119,10 +119,10 @@ _OVER:
...
@@ -119,10 +119,10 @@ _OVER:
}
}
static
void
dmProcessMsg
(
SDnode
*
pDnode
,
SRpcMsg
*
pMsg
,
SEpSet
*
pEpSet
)
{
static
void
dmProcessMsg
(
SDnode
*
pDnode
,
SRpcMsg
*
pMsg
,
SEpSet
*
pEpSet
)
{
SDnodeTrans
*
pTrans
=
&
pDnode
->
trans
;
SDnodeTrans
*
pTrans
=
&
pDnode
->
trans
;
tmsg_t
msgType
=
pMsg
->
msgType
;
tmsg_t
msgType
=
pMsg
->
msgType
;
bool
isReq
=
msgType
&
1u
;
bool
isReq
=
msgType
&
1u
;
SMsgHandle
*
pHandle
=
&
pTrans
->
msgHandles
[
TMSG_INDEX
(
msgType
)];
SMsgHandle
*
pHandle
=
&
pTrans
->
msgHandles
[
TMSG_INDEX
(
msgType
)];
SMgmtWrapper
*
pWrapper
=
pHandle
->
pNdWrapper
;
SMgmtWrapper
*
pWrapper
=
pHandle
->
pNdWrapper
;
if
(
msgType
==
TDMT_DND_SERVER_STATUS
)
{
if
(
msgType
==
TDMT_DND_SERVER_STATUS
)
{
...
@@ -443,7 +443,7 @@ static inline int32_t dmRetrieveUserAuthInfo(SDnode *pDnode, char *user, char *s
...
@@ -443,7 +443,7 @@ static inline int32_t dmRetrieveUserAuthInfo(SDnode *pDnode, char *user, char *s
SAuthReq
authReq
=
{
0
};
SAuthReq
authReq
=
{
0
};
tstrncpy
(
authReq
.
user
,
user
,
TSDB_USER_LEN
);
tstrncpy
(
authReq
.
user
,
user
,
TSDB_USER_LEN
);
int32_t
contLen
=
tSerializeSAuthReq
(
NULL
,
0
,
&
authReq
);
int32_t
contLen
=
tSerializeSAuthReq
(
NULL
,
0
,
&
authReq
);
void
*
pReq
=
rpcMallocCont
(
contLen
);
void
*
pReq
=
rpcMallocCont
(
contLen
);
tSerializeSAuthReq
(
pReq
,
contLen
,
&
authReq
);
tSerializeSAuthReq
(
pReq
,
contLen
,
&
authReq
);
SRpcMsg
rpcMsg
=
{.
pCont
=
pReq
,
.
contLen
=
contLen
,
.
msgType
=
TDMT_MND_AUTH
,
.
ahandle
=
(
void
*
)
9528
};
SRpcMsg
rpcMsg
=
{.
pCont
=
pReq
,
.
contLen
=
contLen
,
.
msgType
=
TDMT_MND_AUTH
,
.
ahandle
=
(
void
*
)
9528
};
...
@@ -523,4 +523,4 @@ SMsgCb dmGetMsgcb(SMgmtWrapper *pWrapper) {
...
@@ -523,4 +523,4 @@ SMsgCb dmGetMsgcb(SMgmtWrapper *pWrapper) {
.
pWrapper
=
pWrapper
,
.
pWrapper
=
pWrapper
,
};
};
return
msgCb
;
return
msgCb
;
}
}
\ No newline at end of file
source/dnode/mgmt/interface/inc/dmDef.h
浏览文件 @
162b3087
...
@@ -16,6 +16,7 @@
...
@@ -16,6 +16,7 @@
#ifndef _TD_DM_DEF_H_
#ifndef _TD_DM_DEF_H_
#define _TD_DM_DEF_H_
#define _TD_DM_DEF_H_
#include "uv.h"
#include "dmLog.h"
#include "dmLog.h"
#include "cJSON.h"
#include "cJSON.h"
...
@@ -142,6 +143,18 @@ typedef struct {
...
@@ -142,6 +143,18 @@ typedef struct {
char
desc
[
TSDB_STEP_DESC_LEN
];
char
desc
[
TSDB_STEP_DESC_LEN
];
}
SStartupInfo
;
}
SStartupInfo
;
typedef
struct
SUdfdData
{
bool
startCalled
;
bool
needCleanUp
;
uv_loop_t
loop
;
uv_thread_t
thread
;
uv_barrier_t
barrier
;
uv_process_t
process
;
int
spawnErr
;
int8_t
stopping
;
uv_pipe_t
ctrlPipe
;
}
SUdfdData
;
typedef
struct
SDnode
{
typedef
struct
SDnode
{
EDndProcType
ptype
;
EDndProcType
ptype
;
EDndNodeType
ntype
;
EDndNodeType
ntype
;
...
@@ -150,6 +163,7 @@ typedef struct SDnode {
...
@@ -150,6 +163,7 @@ typedef struct SDnode {
SStartupInfo
startup
;
SStartupInfo
startup
;
SDnodeTrans
trans
;
SDnodeTrans
trans
;
SDnodeData
data
;
SDnodeData
data
;
SUdfdData
udfdData
;
TdThreadMutex
mutex
;
TdThreadMutex
mutex
;
SMgmtWrapper
wrappers
[
NODE_END
];
SMgmtWrapper
wrappers
[
NODE_END
];
}
SDnode
;
}
SDnode
;
...
...
source/dnode/mgmt/test/sut/src/sut.cpp
浏览文件 @
162b3087
...
@@ -89,7 +89,6 @@ int32_t Testbase::SendShowReq(int8_t showType, const char *tb, const char* db) {
...
@@ -89,7 +89,6 @@ int32_t Testbase::SendShowReq(int8_t showType, const char *tb, const char* db) {
}
}
SRetrieveTableReq
retrieveReq
=
{
0
};
SRetrieveTableReq
retrieveReq
=
{
0
};
retrieveReq
.
type
=
showType
;
strcpy
(
retrieveReq
.
db
,
db
);
strcpy
(
retrieveReq
.
db
,
db
);
strcpy
(
retrieveReq
.
tb
,
tb
);
strcpy
(
retrieveReq
.
tb
,
tb
);
...
...
source/dnode/mnode/impl/inc/mndDef.h
浏览文件 @
162b3087
...
@@ -391,7 +391,6 @@ typedef struct {
...
@@ -391,7 +391,6 @@ typedef struct {
int16_t
numOfColumns
;
int16_t
numOfColumns
;
int32_t
rowSize
;
int32_t
rowSize
;
int32_t
numOfRows
;
int32_t
numOfRows
;
int32_t
payloadLen
;
void
*
pIter
;
void
*
pIter
;
SMnode
*
pMnode
;
SMnode
*
pMnode
;
STableMetaRsp
*
pMeta
;
STableMetaRsp
*
pMeta
;
...
@@ -418,82 +417,6 @@ typedef struct {
...
@@ -418,82 +417,6 @@ typedef struct {
char
payload
[];
char
payload
[];
}
SSysTableRetrieveObj
;
}
SSysTableRetrieveObj
;
typedef
struct
{
int32_t
vgId
;
// -1 for unassigned
int32_t
status
;
int32_t
epoch
;
SEpSet
epSet
;
int64_t
oldConsumerId
;
int64_t
consumerId
;
// -1 for unassigned
char
*
qmsg
;
}
SMqConsumerEp
;
static
FORCE_INLINE
int32_t
tEncodeSMqConsumerEp
(
void
**
buf
,
const
SMqConsumerEp
*
pConsumerEp
)
{
int32_t
tlen
=
0
;
tlen
+=
taosEncodeFixedI32
(
buf
,
pConsumerEp
->
vgId
);
tlen
+=
taosEncodeFixedI32
(
buf
,
pConsumerEp
->
status
);
tlen
+=
taosEncodeFixedI32
(
buf
,
pConsumerEp
->
epoch
);
tlen
+=
taosEncodeSEpSet
(
buf
,
&
pConsumerEp
->
epSet
);
tlen
+=
taosEncodeFixedI64
(
buf
,
pConsumerEp
->
oldConsumerId
);
tlen
+=
taosEncodeFixedI64
(
buf
,
pConsumerEp
->
consumerId
);
tlen
+=
taosEncodeString
(
buf
,
pConsumerEp
->
qmsg
);
return
tlen
;
}
static
FORCE_INLINE
void
*
tDecodeSMqConsumerEp
(
void
**
buf
,
SMqConsumerEp
*
pConsumerEp
)
{
buf
=
taosDecodeFixedI32
(
buf
,
&
pConsumerEp
->
vgId
);
buf
=
taosDecodeFixedI32
(
buf
,
&
pConsumerEp
->
status
);
buf
=
taosDecodeFixedI32
(
buf
,
&
pConsumerEp
->
epoch
);
buf
=
taosDecodeSEpSet
(
buf
,
&
pConsumerEp
->
epSet
);
buf
=
taosDecodeFixedI64
(
buf
,
&
pConsumerEp
->
oldConsumerId
);
buf
=
taosDecodeFixedI64
(
buf
,
&
pConsumerEp
->
consumerId
);
buf
=
taosDecodeString
(
buf
,
&
pConsumerEp
->
qmsg
);
return
buf
;
}
static
FORCE_INLINE
void
tDeleteSMqConsumerEp
(
SMqConsumerEp
*
pConsumerEp
)
{
if
(
pConsumerEp
)
{
taosMemoryFreeClear
(
pConsumerEp
->
qmsg
);
}
}
typedef
struct
{
int64_t
consumerId
;
SArray
*
vgInfo
;
// SArray<SMqConsumerEp>
}
SMqSubConsumer
;
static
FORCE_INLINE
int32_t
tEncodeSMqSubConsumer
(
void
**
buf
,
const
SMqSubConsumer
*
pConsumer
)
{
int32_t
tlen
=
0
;
tlen
+=
taosEncodeFixedI64
(
buf
,
pConsumer
->
consumerId
);
int32_t
sz
=
taosArrayGetSize
(
pConsumer
->
vgInfo
);
tlen
+=
taosEncodeFixedI32
(
buf
,
sz
);
for
(
int32_t
i
=
0
;
i
<
sz
;
i
++
)
{
SMqConsumerEp
*
pCEp
=
taosArrayGet
(
pConsumer
->
vgInfo
,
i
);
tlen
+=
tEncodeSMqConsumerEp
(
buf
,
pCEp
);
}
return
tlen
;
}
static
FORCE_INLINE
void
*
tDecodeSMqSubConsumer
(
void
**
buf
,
SMqSubConsumer
*
pConsumer
)
{
int32_t
sz
;
buf
=
taosDecodeFixedI64
(
buf
,
&
pConsumer
->
consumerId
);
buf
=
taosDecodeFixedI32
(
buf
,
&
sz
);
pConsumer
->
vgInfo
=
taosArrayInit
(
sz
,
sizeof
(
SMqConsumerEp
));
for
(
int32_t
i
=
0
;
i
<
sz
;
i
++
)
{
SMqConsumerEp
consumerEp
;
buf
=
tDecodeSMqConsumerEp
(
buf
,
&
consumerEp
);
taosArrayPush
(
pConsumer
->
vgInfo
,
&
consumerEp
);
}
return
buf
;
}
static
FORCE_INLINE
void
tDeleteSMqSubConsumer
(
SMqSubConsumer
*
pSubConsumer
)
{
if
(
pSubConsumer
->
vgInfo
)
{
taosArrayDestroyEx
(
pSubConsumer
->
vgInfo
,
(
void
(
*
)(
void
*
))
tDeleteSMqConsumerEp
);
pSubConsumer
->
vgInfo
=
NULL
;
}
}
typedef
struct
{
typedef
struct
{
char
key
[
TSDB_PARTITION_KEY_LEN
];
char
key
[
TSDB_PARTITION_KEY_LEN
];
int64_t
offset
;
int64_t
offset
;
...
@@ -512,147 +435,21 @@ static FORCE_INLINE void* tDecodeSMqOffsetObj(void* buf, SMqOffsetObj* pOffset)
...
@@ -512,147 +435,21 @@ static FORCE_INLINE void* tDecodeSMqOffsetObj(void* buf, SMqOffsetObj* pOffset)
return
buf
;
return
buf
;
}
}
#if 0
typedef struct {
char key[TSDB_SUBSCRIBE_KEY_LEN];
int32_t status;
int32_t vgNum;
SArray* consumers; // SArray<SMqSubConsumer>
SArray* lostConsumers; // SArray<SMqSubConsumer>
SArray* unassignedVg; // SArray<SMqConsumerEp>
} SMqSubscribeObj;
static FORCE_INLINE SMqSubscribeObj* tNewSubscribeObj() {
SMqSubscribeObj* pSub = taosMemoryCalloc(1, sizeof(SMqSubscribeObj));
if (pSub == NULL) {
return NULL;
}
pSub->consumers = taosArrayInit(0, sizeof(SMqSubConsumer));
if (pSub->consumers == NULL) {
goto _err;
}
pSub->lostConsumers = taosArrayInit(0, sizeof(SMqSubConsumer));
if (pSub->lostConsumers == NULL) {
goto _err;
}
pSub->unassignedVg = taosArrayInit(0, sizeof(SMqConsumerEp));
if (pSub->unassignedVg == NULL) {
goto _err;
}
pSub->key[0] = 0;
pSub->vgNum = 0;
pSub->status = 0;
return pSub;
_err:
taosMemoryFreeClear(pSub->consumers);
taosMemoryFreeClear(pSub->lostConsumers);
taosMemoryFreeClear(pSub->unassignedVg);
taosMemoryFreeClear(pSub);
return NULL;
}
static FORCE_INLINE int32_t tEncodeSubscribeObj(void** buf, const SMqSubscribeObj* pSub) {
int32_t tlen = 0;
tlen += taosEncodeString(buf, pSub->key);
tlen += taosEncodeFixedI32(buf, pSub->vgNum);
tlen += taosEncodeFixedI32(buf, pSub->status);
int32_t sz;
sz = taosArrayGetSize(pSub->consumers);
tlen += taosEncodeFixedI32(buf, sz);
for (int32_t i = 0; i < sz; i++) {
SMqSubConsumer* pSubConsumer = taosArrayGet(pSub->consumers, i);
tlen += tEncodeSMqSubConsumer(buf, pSubConsumer);
}
sz = taosArrayGetSize(pSub->lostConsumers);
tlen += taosEncodeFixedI32(buf, sz);
for (int32_t i = 0; i < sz; i++) {
SMqSubConsumer* pSubConsumer = taosArrayGet(pSub->lostConsumers, i);
tlen += tEncodeSMqSubConsumer(buf, pSubConsumer);
}
sz = taosArrayGetSize(pSub->unassignedVg);
tlen += taosEncodeFixedI32(buf, sz);
for (int32_t i = 0; i < sz; i++) {
SMqConsumerEp* pCEp = taosArrayGet(pSub->unassignedVg, i);
tlen += tEncodeSMqConsumerEp(buf, pCEp);
}
return tlen;
}
static FORCE_INLINE void* tDecodeSubscribeObj(void* buf, SMqSubscribeObj* pSub) {
buf = taosDecodeStringTo(buf, pSub->key);
buf = taosDecodeFixedI32(buf, &pSub->vgNum);
buf = taosDecodeFixedI32(buf, &pSub->status);
int32_t sz;
buf = taosDecodeFixedI32(buf, &sz);
pSub->consumers = taosArrayInit(sz, sizeof(SMqSubConsumer));
if (pSub->consumers == NULL) {
return NULL;
}
for (int32_t i = 0; i < sz; i++) {
SMqSubConsumer subConsumer = {0};
buf = tDecodeSMqSubConsumer(buf, &subConsumer);
taosArrayPush(pSub->consumers, &subConsumer);
}
buf = taosDecodeFixedI32(buf, &sz);
pSub->lostConsumers = taosArrayInit(sz, sizeof(SMqSubConsumer));
if (pSub->lostConsumers == NULL) {
return NULL;
}
for (int32_t i = 0; i < sz; i++) {
SMqSubConsumer subConsumer = {0};
buf = tDecodeSMqSubConsumer(buf, &subConsumer);
taosArrayPush(pSub->lostConsumers, &subConsumer);
}
buf = taosDecodeFixedI32(buf, &sz);
pSub->unassignedVg = taosArrayInit(sz, sizeof(SMqConsumerEp));
if (pSub->unassignedVg == NULL) {
return NULL;
}
for (int32_t i = 0; i < sz; i++) {
SMqConsumerEp consumerEp = {0};
buf = tDecodeSMqConsumerEp(buf, &consumerEp);
taosArrayPush(pSub->unassignedVg, &consumerEp);
}
return buf;
}
static FORCE_INLINE void tDeleteSMqSubscribeObj(SMqSubscribeObj* pSub) {
if (pSub->consumers) {
// taosArrayDestroyEx(pSub->consumers, (void (*)(void*))tDeleteSMqSubConsumer);
// taosArrayDestroy(pSub->consumers);
pSub->consumers = NULL;
}
if (pSub->unassignedVg) {
// taosArrayDestroyEx(pSub->unassignedVg, (void (*)(void*))tDeleteSMqConsumerEp);
// taosArrayDestroy(pSub->unassignedVg);
pSub->unassignedVg = NULL;
}
}
#endif
typedef
struct
{
typedef
struct
{
char
name
[
TSDB_TOPIC_FNAME_LEN
];
char
name
[
TSDB_TOPIC_FNAME_LEN
];
char
db
[
TSDB_DB_FNAME_LEN
];
char
db
[
TSDB_DB_FNAME_LEN
];
int64_t
createTime
;
int64_t
createTime
;
int64_t
updateTime
;
int64_t
updateTime
;
int64_t
uid
;
int64_t
uid
;
// TODO: use subDbUid
int64_t
dbUid
;
int64_t
dbUid
;
int64_t
subDbUid
;
int32_t
version
;
int32_t
version
;
int8_t
subType
;
// db or table
int8_t
withTbName
;
int8_t
withSchema
;
int8_t
withTag
;
int8_t
withTagSchema
;
SRWLatch
lock
;
SRWLatch
lock
;
int32_t
sqlLen
;
int32_t
sqlLen
;
int32_t
astLen
;
int32_t
astLen
;
...
@@ -662,79 +459,6 @@ typedef struct {
...
@@ -662,79 +459,6 @@ typedef struct {
SSchemaWrapper
schema
;
SSchemaWrapper
schema
;
}
SMqTopicObj
;
}
SMqTopicObj
;
#if 0
typedef struct {
int64_t consumerId;
int64_t connId;
SRWLatch lock;
char cgroup[TSDB_CGROUP_LEN];
SArray* currentTopics; // SArray<char*>
SArray* recentRemovedTopics; // SArray<char*>
int32_t epoch;
// stat
int64_t pollCnt;
// status
int32_t status;
// heartbeat from the consumer reset hbStatus to 0
// each checkConsumerAlive msg add hbStatus by 1
// if checkConsumerAlive > CONSUMER_REBALANCE_CNT, mask to lost
int32_t hbStatus;
} SMqConsumerObj;
static FORCE_INLINE int32_t tEncodeSMqConsumerObj(void** buf, const SMqConsumerObj* pConsumer) {
int32_t sz;
int32_t tlen = 0;
tlen += taosEncodeFixedI64(buf, pConsumer->consumerId);
tlen += taosEncodeFixedI64(buf, pConsumer->connId);
tlen += taosEncodeFixedI32(buf, pConsumer->epoch);
tlen += taosEncodeFixedI64(buf, pConsumer->pollCnt);
tlen += taosEncodeFixedI32(buf, pConsumer->status);
tlen += taosEncodeString(buf, pConsumer->cgroup);
sz = taosArrayGetSize(pConsumer->currentTopics);
tlen += taosEncodeFixedI32(buf, sz);
for (int32_t i = 0; i < sz; i++) {
char* topic = taosArrayGetP(pConsumer->currentTopics, i);
tlen += taosEncodeString(buf, topic);
}
sz = taosArrayGetSize(pConsumer->recentRemovedTopics);
tlen += taosEncodeFixedI32(buf, sz);
for (int32_t i = 0; i < sz; i++) {
char* topic = taosArrayGetP(pConsumer->recentRemovedTopics, i);
tlen += taosEncodeString(buf, topic);
}
return tlen;
}
static FORCE_INLINE void* tDecodeSMqConsumerObj(void* buf, SMqConsumerObj* pConsumer) {
int32_t sz;
buf = taosDecodeFixedI64(buf, &pConsumer->consumerId);
buf = taosDecodeFixedI64(buf, &pConsumer->connId);
buf = taosDecodeFixedI32(buf, &pConsumer->epoch);
buf = taosDecodeFixedI64(buf, &pConsumer->pollCnt);
buf = taosDecodeFixedI32(buf, &pConsumer->status);
buf = taosDecodeStringTo(buf, pConsumer->cgroup);
buf = taosDecodeFixedI32(buf, &sz);
pConsumer->currentTopics = taosArrayInit(sz, sizeof(void*));
for (int32_t i = 0; i < sz; i++) {
char* topic;
buf = taosDecodeString(buf, &topic);
taosArrayPush(pConsumer->currentTopics, &topic);
}
buf = taosDecodeFixedI32(buf, &sz);
pConsumer->recentRemovedTopics = taosArrayInit(sz, sizeof(void*));
for (int32_t i = 0; i < sz; i++) {
char* topic;
buf = taosDecodeString(buf, &topic);
taosArrayPush(pConsumer->recentRemovedTopics, &topic);
}
return buf;
}
#endif
enum
{
enum
{
CONSUMER_UPDATE__TOUCH
=
1
,
CONSUMER_UPDATE__TOUCH
=
1
,
CONSUMER_UPDATE__ADD
,
CONSUMER_UPDATE__ADD
,
...
@@ -753,12 +477,9 @@ typedef struct {
...
@@ -753,12 +477,9 @@ typedef struct {
int32_t
hbStatus
;
int32_t
hbStatus
;
// lock is used for topics update
// lock is used for topics update
SRWLatch
lock
;
SRWLatch
lock
;
SArray
*
currentTopics
;
// SArray<char*>
SArray
*
currentTopics
;
// SArray<char*>
#if 0
SArray
*
rebNewTopics
;
// SArray<char*>
SArray* waitingRebTopics; // SArray<char*>
SArray
*
rebRemovedTopics
;
// SArray<char*>
#endif
SArray
*
rebNewTopics
;
// SArray<char*>
SArray
*
rebRemovedTopics
;
// SArray<char*>
}
SMqConsumerObj
;
}
SMqConsumerObj
;
SMqConsumerObj
*
tNewSMqConsumerObj
(
int64_t
consumerId
,
char
cgroup
[
TSDB_CGROUP_LEN
]);
SMqConsumerObj
*
tNewSMqConsumerObj
(
int64_t
consumerId
,
char
cgroup
[
TSDB_CGROUP_LEN
]);
...
@@ -769,8 +490,7 @@ void* tDecodeSMqConsumerObj(const void* buf, SMqConsumerObj* pConsumer
...
@@ -769,8 +490,7 @@ void* tDecodeSMqConsumerObj(const void* buf, SMqConsumerObj* pConsumer
typedef
struct
{
typedef
struct
{
int32_t
vgId
;
int32_t
vgId
;
char
*
qmsg
;
char
*
qmsg
;
// char topic[TSDB_TOPIC_FNAME_LEN];
SEpSet
epSet
;
SEpSet
epSet
;
}
SMqVgEp
;
}
SMqVgEp
;
SMqVgEp
*
tCloneSMqVgEp
(
const
SMqVgEp
*
pVgEp
);
SMqVgEp
*
tCloneSMqVgEp
(
const
SMqVgEp
*
pVgEp
);
...
@@ -792,7 +512,14 @@ typedef struct {
...
@@ -792,7 +512,14 @@ typedef struct {
char
key
[
TSDB_SUBSCRIBE_KEY_LEN
];
char
key
[
TSDB_SUBSCRIBE_KEY_LEN
];
SRWLatch
lock
;
SRWLatch
lock
;
int32_t
vgNum
;
int32_t
vgNum
;
int8_t
subType
;
int8_t
withTbName
;
int8_t
withSchema
;
int8_t
withTag
;
int8_t
withTagSchema
;
SHashObj
*
consumerHash
;
// consumerId -> SMqConsumerEpInSub
SHashObj
*
consumerHash
;
// consumerId -> SMqConsumerEpInSub
// TODO put -1 into unassignVgs
// SArray* unassignedVgs;
}
SMqSubscribeObj
;
}
SMqSubscribeObj
;
SMqSubscribeObj
*
tNewSubscribeObj
(
const
char
key
[
TSDB_SUBSCRIBE_KEY_LEN
]);
SMqSubscribeObj
*
tNewSubscribeObj
(
const
char
key
[
TSDB_SUBSCRIBE_KEY_LEN
]);
...
@@ -821,18 +548,6 @@ void tDeleteSMqSubActionLogObj(SMqSubActionLogObj* pLog);
...
@@ -821,18 +548,6 @@ void tDeleteSMqSubActionLogObj(SMqSubActionLogObj* pLog);
int32_t
tEncodeSMqSubActionLogObj
(
void
**
buf
,
const
SMqSubActionLogObj
*
pLog
);
int32_t
tEncodeSMqSubActionLogObj
(
void
**
buf
,
const
SMqSubActionLogObj
*
pLog
);
void
*
tDecodeSMqSubActionLogObj
(
const
void
*
buf
,
SMqSubActionLogObj
*
pLog
);
void
*
tDecodeSMqSubActionLogObj
(
const
void
*
buf
,
SMqSubActionLogObj
*
pLog
);
typedef
struct
{
int64_t
consumerId
;
char
cgroup
[
TSDB_CGROUP_LEN
];
SRWLatch
lock
;
SArray
*
vgs
;
// SArray<SMqVgEp*>
}
SMqConsumerEpObj
;
SMqConsumerEpObj
*
tCloneSMqConsumerEpObj
(
const
SMqConsumerEpObj
*
pConsumerEp
);
void
tDeleteSMqConsumerEpObj
(
SMqConsumerEpObj
*
pConsumerEp
);
int32_t
tEncodeSMqConsumerEpObj
(
void
**
buf
,
const
SMqConsumerEpObj
*
pConsumerEp
);
void
*
tDecodeSMqConsumerEpObj
(
const
void
*
buf
,
SMqConsumerEpObj
*
pConsumerEp
);
typedef
struct
{
typedef
struct
{
const
SMqSubscribeObj
*
pOldSub
;
const
SMqSubscribeObj
*
pOldSub
;
const
SMqTopicObj
*
pTopic
;
const
SMqTopicObj
*
pTopic
;
...
@@ -845,12 +560,6 @@ typedef struct {
...
@@ -845,12 +560,6 @@ typedef struct {
SMqVgEp
*
pVgEp
;
SMqVgEp
*
pVgEp
;
}
SMqRebOutputVg
;
}
SMqRebOutputVg
;
#if 0
typedef struct {
int64_t consumerId;
} SMqRebOutputConsumer;
#endif
typedef
struct
{
typedef
struct
{
SArray
*
rebVgs
;
// SArray<SMqRebOutputVg>
SArray
*
rebVgs
;
// SArray<SMqRebOutputVg>
SArray
*
newConsumers
;
// SArray<int64_t>
SArray
*
newConsumers
;
// SArray<int64_t>
...
...
source/dnode/mnode/impl/inc/mndScheduler.h
浏览文件 @
162b3087
...
@@ -29,6 +29,8 @@ int32_t mndSchedInitSubEp(SMnode* pMnode, const SMqTopicObj* pTopic, SMqSubscrib
...
@@ -29,6 +29,8 @@ int32_t mndSchedInitSubEp(SMnode* pMnode, const SMqTopicObj* pTopic, SMqSubscrib
int32_t
mndScheduleStream
(
SMnode
*
pMnode
,
STrans
*
pTrans
,
SStreamObj
*
pStream
);
int32_t
mndScheduleStream
(
SMnode
*
pMnode
,
STrans
*
pTrans
,
SStreamObj
*
pStream
);
int32_t
mndConvertRSmaTask
(
const
char
*
ast
,
int8_t
triggerType
,
int64_t
watermark
,
char
**
pStr
,
int32_t
*
pLen
);
#ifdef __cplusplus
#ifdef __cplusplus
}
}
#endif
#endif
...
...
source/dnode/mnode/impl/src/mndDb.c
浏览文件 @
162b3087
...
@@ -851,6 +851,8 @@ static int32_t mndProcessGetDbCfgReq(SNodeMsg *pReq) {
...
@@ -851,6 +851,8 @@ static int32_t mndProcessGetDbCfgReq(SNodeMsg *pReq) {
cfgRsp
.
cacheLastRow
=
pDb
->
cfg
.
cacheLastRow
;
cfgRsp
.
cacheLastRow
=
pDb
->
cfg
.
cacheLastRow
;
cfgRsp
.
streamMode
=
pDb
->
cfg
.
streamMode
;
cfgRsp
.
streamMode
=
pDb
->
cfg
.
streamMode
;
cfgRsp
.
singleSTable
=
pDb
->
cfg
.
singleSTable
;
cfgRsp
.
singleSTable
=
pDb
->
cfg
.
singleSTable
;
cfgRsp
.
numOfRetensions
=
pDb
->
cfg
.
numOfRetensions
;
cfgRsp
.
pRetensions
=
pDb
->
cfg
.
pRetensions
;
int32_t
contLen
=
tSerializeSDbCfgRsp
(
NULL
,
0
,
&
cfgRsp
);
int32_t
contLen
=
tSerializeSDbCfgRsp
(
NULL
,
0
,
&
cfgRsp
);
void
*
pRsp
=
rpcMallocCont
(
contLen
);
void
*
pRsp
=
rpcMallocCont
(
contLen
);
...
...
source/dnode/mnode/impl/src/mndDef.c
浏览文件 @
162b3087
...
@@ -32,9 +32,6 @@ SMqConsumerObj *tNewSMqConsumerObj(int64_t consumerId, char cgroup[TSDB_CGROUP_L
...
@@ -32,9 +32,6 @@ SMqConsumerObj *tNewSMqConsumerObj(int64_t consumerId, char cgroup[TSDB_CGROUP_L
taosInitRWLatch
(
&
pConsumer
->
lock
);
taosInitRWLatch
(
&
pConsumer
->
lock
);
pConsumer
->
currentTopics
=
taosArrayInit
(
0
,
sizeof
(
void
*
));
pConsumer
->
currentTopics
=
taosArrayInit
(
0
,
sizeof
(
void
*
));
#if 0
pConsumer->waitingRebTopics = NULL;
#endif
pConsumer
->
rebNewTopics
=
taosArrayInit
(
0
,
sizeof
(
void
*
));
pConsumer
->
rebNewTopics
=
taosArrayInit
(
0
,
sizeof
(
void
*
));
pConsumer
->
rebRemovedTopics
=
taosArrayInit
(
0
,
sizeof
(
void
*
));
pConsumer
->
rebRemovedTopics
=
taosArrayInit
(
0
,
sizeof
(
void
*
));
...
@@ -53,11 +50,6 @@ void tDeleteSMqConsumerObj(SMqConsumerObj *pConsumer) {
...
@@ -53,11 +50,6 @@ void tDeleteSMqConsumerObj(SMqConsumerObj *pConsumer) {
if
(
pConsumer
->
currentTopics
)
{
if
(
pConsumer
->
currentTopics
)
{
taosArrayDestroyP
(
pConsumer
->
currentTopics
,
(
FDelete
)
taosMemoryFree
);
taosArrayDestroyP
(
pConsumer
->
currentTopics
,
(
FDelete
)
taosMemoryFree
);
}
}
#if 0
if (pConsumer->waitingRebTopics) {
taosArrayDestroyP(pConsumer->waitingRebTopics, taosMemoryFree);
}
#endif
if
(
pConsumer
->
rebNewTopics
)
{
if
(
pConsumer
->
rebNewTopics
)
{
taosArrayDestroyP
(
pConsumer
->
rebNewTopics
,
(
FDelete
)
taosMemoryFree
);
taosArrayDestroyP
(
pConsumer
->
rebNewTopics
,
(
FDelete
)
taosMemoryFree
);
}
}
...
@@ -87,20 +79,6 @@ int32_t tEncodeSMqConsumerObj(void **buf, const SMqConsumerObj *pConsumer) {
...
@@ -87,20 +79,6 @@ int32_t tEncodeSMqConsumerObj(void **buf, const SMqConsumerObj *pConsumer) {
tlen
+=
taosEncodeFixedI32
(
buf
,
0
);
tlen
+=
taosEncodeFixedI32
(
buf
,
0
);
}
}
#if 0
// waiting reb topics
if (pConsumer->waitingRebTopics) {
sz = taosArrayGetSize(pConsumer->waitingRebTopics);
tlen += taosEncodeFixedI32(buf, sz);
for (int32_t i = 0; i < sz; i++) {
char *topic = taosArrayGetP(pConsumer->waitingRebTopics, i);
tlen += taosEncodeString(buf, topic);
}
} else {
tlen += taosEncodeFixedI32(buf, 0);
}
#endif
// reb new topics
// reb new topics
if
(
pConsumer
->
rebNewTopics
)
{
if
(
pConsumer
->
rebNewTopics
)
{
sz
=
taosArrayGetSize
(
pConsumer
->
rebNewTopics
);
sz
=
taosArrayGetSize
(
pConsumer
->
rebNewTopics
);
...
@@ -145,17 +123,6 @@ void *tDecodeSMqConsumerObj(const void *buf, SMqConsumerObj *pConsumer) {
...
@@ -145,17 +123,6 @@ void *tDecodeSMqConsumerObj(const void *buf, SMqConsumerObj *pConsumer) {
taosArrayPush
(
pConsumer
->
currentTopics
,
&
topic
);
taosArrayPush
(
pConsumer
->
currentTopics
,
&
topic
);
}
}
#if 0
// waiting reb topics
buf = taosDecodeFixedI32(buf, &sz);
pConsumer->waitingRebTopics = taosArrayInit(sz, sizeof(void *));
for (int32_t i = 0; i < sz; i++) {
char *topic;
buf = taosDecodeString(buf, &topic);
taosArrayPush(pConsumer->waitingRebTopics, &topic);
}
#endif
// reb new topics
// reb new topics
buf
=
taosDecodeFixedI32
(
buf
,
&
sz
);
buf
=
taosDecodeFixedI32
(
buf
,
&
sz
);
pConsumer
->
rebNewTopics
=
taosArrayInit
(
sz
,
sizeof
(
void
*
));
pConsumer
->
rebNewTopics
=
taosArrayInit
(
sz
,
sizeof
(
void
*
));
...
@@ -182,7 +149,6 @@ SMqVgEp *tCloneSMqVgEp(const SMqVgEp *pVgEp) {
...
@@ -182,7 +149,6 @@ SMqVgEp *tCloneSMqVgEp(const SMqVgEp *pVgEp) {
if
(
pVgEpNew
==
NULL
)
return
NULL
;
if
(
pVgEpNew
==
NULL
)
return
NULL
;
pVgEpNew
->
vgId
=
pVgEp
->
vgId
;
pVgEpNew
->
vgId
=
pVgEp
->
vgId
;
pVgEpNew
->
qmsg
=
strdup
(
pVgEp
->
qmsg
);
pVgEpNew
->
qmsg
=
strdup
(
pVgEp
->
qmsg
);
/*memcpy(pVgEpNew->topic, pVgEp->topic, TSDB_TOPIC_FNAME_LEN);*/
pVgEpNew
->
epSet
=
pVgEp
->
epSet
;
pVgEpNew
->
epSet
=
pVgEp
->
epSet
;
return
pVgEpNew
;
return
pVgEpNew
;
}
}
...
@@ -193,7 +159,6 @@ int32_t tEncodeSMqVgEp(void **buf, const SMqVgEp *pVgEp) {
...
@@ -193,7 +159,6 @@ int32_t tEncodeSMqVgEp(void **buf, const SMqVgEp *pVgEp) {
int32_t
tlen
=
0
;
int32_t
tlen
=
0
;
tlen
+=
taosEncodeFixedI32
(
buf
,
pVgEp
->
vgId
);
tlen
+=
taosEncodeFixedI32
(
buf
,
pVgEp
->
vgId
);
tlen
+=
taosEncodeString
(
buf
,
pVgEp
->
qmsg
);
tlen
+=
taosEncodeString
(
buf
,
pVgEp
->
qmsg
);
/*tlen += taosEncodeString(buf, pVgEp->topic);*/
tlen
+=
taosEncodeSEpSet
(
buf
,
&
pVgEp
->
epSet
);
tlen
+=
taosEncodeSEpSet
(
buf
,
&
pVgEp
->
epSet
);
return
tlen
;
return
tlen
;
}
}
...
@@ -201,40 +166,10 @@ int32_t tEncodeSMqVgEp(void **buf, const SMqVgEp *pVgEp) {
...
@@ -201,40 +166,10 @@ int32_t tEncodeSMqVgEp(void **buf, const SMqVgEp *pVgEp) {
void
*
tDecodeSMqVgEp
(
const
void
*
buf
,
SMqVgEp
*
pVgEp
)
{
void
*
tDecodeSMqVgEp
(
const
void
*
buf
,
SMqVgEp
*
pVgEp
)
{
buf
=
taosDecodeFixedI32
(
buf
,
&
pVgEp
->
vgId
);
buf
=
taosDecodeFixedI32
(
buf
,
&
pVgEp
->
vgId
);
buf
=
taosDecodeString
(
buf
,
&
pVgEp
->
qmsg
);
buf
=
taosDecodeString
(
buf
,
&
pVgEp
->
qmsg
);
/*buf = taosDecodeStringTo(buf, pVgEp->topic);*/
buf
=
taosDecodeSEpSet
(
buf
,
&
pVgEp
->
epSet
);
buf
=
taosDecodeSEpSet
(
buf
,
&
pVgEp
->
epSet
);
return
(
void
*
)
buf
;
return
(
void
*
)
buf
;
}
}
SMqConsumerEpObj
*
tCloneSMqConsumerEpObj
(
const
SMqConsumerEpObj
*
pConsumerEp
)
{
SMqConsumerEpObj
*
pConsumerEpNew
=
taosMemoryMalloc
(
sizeof
(
SMqConsumerEpObj
));
if
(
pConsumerEpNew
==
NULL
)
return
NULL
;
pConsumerEpNew
->
consumerId
=
pConsumerEp
->
consumerId
;
memcpy
(
pConsumerEpNew
->
cgroup
,
pConsumerEp
->
cgroup
,
TSDB_CGROUP_LEN
);
taosInitRWLatch
(
&
pConsumerEpNew
->
lock
);
pConsumerEpNew
->
vgs
=
taosArrayDeepCopy
(
pConsumerEpNew
->
vgs
,
(
FCopy
)
tCloneSMqVgEp
);
return
pConsumerEpNew
;
}
void
tDeleteSMqConsumerEpObj
(
SMqConsumerEpObj
*
pConsumerEp
)
{
taosArrayDestroyEx
(
pConsumerEp
->
vgs
,
(
FDelete
)
tDeleteSMqVgEp
);
}
int32_t
tEncodeSMqConsumerEpObj
(
void
**
buf
,
const
SMqConsumerEpObj
*
pConsumerEp
)
{
int32_t
tlen
=
0
;
tlen
+=
taosEncodeFixedI64
(
buf
,
pConsumerEp
->
consumerId
);
tlen
+=
taosEncodeString
(
buf
,
pConsumerEp
->
cgroup
);
tlen
+=
taosEncodeArray
(
buf
,
pConsumerEp
->
vgs
,
(
FEncode
)
tEncodeSMqVgEp
);
return
tlen
;
}
void
*
tDecodeSMqConsumerEpObj
(
const
void
*
buf
,
SMqConsumerEpObj
*
pConsumerEp
)
{
buf
=
taosDecodeFixedI64
(
buf
,
&
pConsumerEp
->
consumerId
);
buf
=
taosDecodeStringTo
(
buf
,
pConsumerEp
->
cgroup
);
buf
=
taosDecodeArray
(
buf
,
&
pConsumerEp
->
vgs
,
(
FDecode
)
tDecodeSMqVgEp
,
sizeof
(
SMqSubVgEp
));
return
(
void
*
)
buf
;
}
SMqConsumerEpInSub
*
tCloneSMqConsumerEpInSub
(
const
SMqConsumerEpInSub
*
pEpInSub
)
{
SMqConsumerEpInSub
*
tCloneSMqConsumerEpInSub
(
const
SMqConsumerEpInSub
*
pEpInSub
)
{
SMqConsumerEpInSub
*
pEpInSubNew
=
taosMemoryMalloc
(
sizeof
(
SMqConsumerEpInSub
));
SMqConsumerEpInSub
*
pEpInSubNew
=
taosMemoryMalloc
(
sizeof
(
SMqConsumerEpInSub
));
if
(
pEpInSubNew
==
NULL
)
return
NULL
;
if
(
pEpInSubNew
==
NULL
)
return
NULL
;
...
@@ -276,7 +211,7 @@ void *tDecodeSMqConsumerEpInSub(const void *buf, SMqConsumerEpInSub *pEpInSub) {
...
@@ -276,7 +211,7 @@ void *tDecodeSMqConsumerEpInSub(const void *buf, SMqConsumerEpInSub *pEpInSub) {
}
}
SMqSubscribeObj
*
tNewSubscribeObj
(
const
char
key
[
TSDB_SUBSCRIBE_KEY_LEN
])
{
SMqSubscribeObj
*
tNewSubscribeObj
(
const
char
key
[
TSDB_SUBSCRIBE_KEY_LEN
])
{
SMqSubscribeObj
*
pSubNew
=
taosMemory
Malloc
(
sizeof
(
SMqSubscribeObj
));
SMqSubscribeObj
*
pSubNew
=
taosMemory
Calloc
(
1
,
sizeof
(
SMqSubscribeObj
));
if
(
pSubNew
==
NULL
)
return
NULL
;
if
(
pSubNew
==
NULL
)
return
NULL
;
memcpy
(
pSubNew
->
key
,
key
,
TSDB_SUBSCRIBE_KEY_LEN
);
memcpy
(
pSubNew
->
key
,
key
,
TSDB_SUBSCRIBE_KEY_LEN
);
taosInitRWLatch
(
&
pSubNew
->
lock
);
taosInitRWLatch
(
&
pSubNew
->
lock
);
...
@@ -297,8 +232,14 @@ SMqSubscribeObj *tCloneSubscribeObj(const SMqSubscribeObj *pSub) {
...
@@ -297,8 +232,14 @@ SMqSubscribeObj *tCloneSubscribeObj(const SMqSubscribeObj *pSub) {
if
(
pSubNew
==
NULL
)
return
NULL
;
if
(
pSubNew
==
NULL
)
return
NULL
;
memcpy
(
pSubNew
->
key
,
pSub
->
key
,
TSDB_SUBSCRIBE_KEY_LEN
);
memcpy
(
pSubNew
->
key
,
pSub
->
key
,
TSDB_SUBSCRIBE_KEY_LEN
);
taosInitRWLatch
(
&
pSubNew
->
lock
);
taosInitRWLatch
(
&
pSubNew
->
lock
);
pSubNew
->
subType
=
pSub
->
subType
;
pSubNew
->
withTbName
=
pSub
->
withTbName
;
pSubNew
->
withSchema
=
pSub
->
withSchema
;
pSubNew
->
withTag
=
pSub
->
withTag
;
pSubNew
->
withTagSchema
=
pSub
->
withTagSchema
;
pSubNew
->
vgNum
=
pSub
->
vgNum
;
pSubNew
->
vgNum
=
pSub
->
vgNum
;
/*pSubNew->consumerEps = taosArrayDeepCopy(pSub->consumerEps, (FCopy)tCloneSMqConsumerEpInSub);*/
pSubNew
->
consumerHash
=
taosHashInit
(
64
,
taosGetDefaultHashFunction
(
TSDB_DATA_TYPE_BIGINT
),
false
,
HASH_NO_LOCK
);
pSubNew
->
consumerHash
=
taosHashInit
(
64
,
taosGetDefaultHashFunction
(
TSDB_DATA_TYPE_BIGINT
),
false
,
HASH_NO_LOCK
);
/*taosHashSetFreeFp(pSubNew->consumerHash, taosArrayDestroy);*/
/*taosHashSetFreeFp(pSubNew->consumerHash, taosArrayDestroy);*/
void
*
pIter
=
NULL
;
void
*
pIter
=
NULL
;
...
@@ -325,6 +266,11 @@ int32_t tEncodeSubscribeObj(void **buf, const SMqSubscribeObj *pSub) {
...
@@ -325,6 +266,11 @@ int32_t tEncodeSubscribeObj(void **buf, const SMqSubscribeObj *pSub) {
int32_t
tlen
=
0
;
int32_t
tlen
=
0
;
tlen
+=
taosEncodeString
(
buf
,
pSub
->
key
);
tlen
+=
taosEncodeString
(
buf
,
pSub
->
key
);
tlen
+=
taosEncodeFixedI32
(
buf
,
pSub
->
vgNum
);
tlen
+=
taosEncodeFixedI32
(
buf
,
pSub
->
vgNum
);
tlen
+=
taosEncodeFixedI8
(
buf
,
pSub
->
subType
);
tlen
+=
taosEncodeFixedI8
(
buf
,
pSub
->
withTbName
);
tlen
+=
taosEncodeFixedI8
(
buf
,
pSub
->
withSchema
);
tlen
+=
taosEncodeFixedI8
(
buf
,
pSub
->
withTag
);
tlen
+=
taosEncodeFixedI8
(
buf
,
pSub
->
withTagSchema
);
void
*
pIter
=
NULL
;
void
*
pIter
=
NULL
;
int32_t
sz
=
taosHashGetSize
(
pSub
->
consumerHash
);
int32_t
sz
=
taosHashGetSize
(
pSub
->
consumerHash
);
...
@@ -347,6 +293,11 @@ void *tDecodeSubscribeObj(const void *buf, SMqSubscribeObj *pSub) {
...
@@ -347,6 +293,11 @@ void *tDecodeSubscribeObj(const void *buf, SMqSubscribeObj *pSub) {
//
//
buf
=
taosDecodeStringTo
(
buf
,
pSub
->
key
);
buf
=
taosDecodeStringTo
(
buf
,
pSub
->
key
);
buf
=
taosDecodeFixedI32
(
buf
,
&
pSub
->
vgNum
);
buf
=
taosDecodeFixedI32
(
buf
,
&
pSub
->
vgNum
);
buf
=
taosDecodeFixedI8
(
buf
,
&
pSub
->
subType
);
buf
=
taosDecodeFixedI8
(
buf
,
&
pSub
->
withTbName
);
buf
=
taosDecodeFixedI8
(
buf
,
&
pSub
->
withSchema
);
buf
=
taosDecodeFixedI8
(
buf
,
&
pSub
->
withTag
);
buf
=
taosDecodeFixedI8
(
buf
,
&
pSub
->
withTagSchema
);
int32_t
sz
;
int32_t
sz
;
buf
=
taosDecodeFixedI32
(
buf
,
&
sz
);
buf
=
taosDecodeFixedI32
(
buf
,
&
sz
);
...
...
source/dnode/mnode/impl/src/mndOffset.c
浏览文件 @
162b3087
...
@@ -133,9 +133,9 @@ OFFSET_DECODE_OVER:
...
@@ -133,9 +133,9 @@ OFFSET_DECODE_OVER:
int32_t
mndCreateOffsets
(
STrans
*
pTrans
,
const
char
*
cgroup
,
const
char
*
topicName
,
const
SArray
*
vgs
)
{
int32_t
mndCreateOffsets
(
STrans
*
pTrans
,
const
char
*
cgroup
,
const
char
*
topicName
,
const
SArray
*
vgs
)
{
int32_t
sz
=
taosArrayGetSize
(
vgs
);
int32_t
sz
=
taosArrayGetSize
(
vgs
);
for
(
int32_t
i
=
0
;
i
<
sz
;
i
++
)
{
for
(
int32_t
i
=
0
;
i
<
sz
;
i
++
)
{
SMqConsumerEp
*
pConsumerEp
=
taosArrayGet
(
vgs
,
i
);
int32_t
vgId
=
*
(
int32_t
*
)
taosArrayGet
(
vgs
,
i
);
SMqOffsetObj
offsetObj
;
SMqOffsetObj
offsetObj
;
if
(
mndMakePartitionKey
(
offsetObj
.
key
,
cgroup
,
topicName
,
pConsumerEp
->
vgId
)
<
0
)
{
if
(
mndMakePartitionKey
(
offsetObj
.
key
,
cgroup
,
topicName
,
vgId
)
<
0
)
{
return
-
1
;
return
-
1
;
}
}
offsetObj
.
offset
=
-
1
;
offsetObj
.
offset
=
-
1
;
...
...
source/dnode/mnode/impl/src/mndProfile.c
浏览文件 @
162b3087
...
@@ -24,20 +24,20 @@
...
@@ -24,20 +24,20 @@
#include "version.h"
#include "version.h"
typedef
struct
{
typedef
struct
{
uint32_t
id
;
uint32_t
id
;
int8_t
connType
;
int8_t
connType
;
char
user
[
TSDB_USER_LEN
];
char
user
[
TSDB_USER_LEN
];
char
app
[
TSDB_APP_NAME_LEN
];
// app name that invokes taosc
char
app
[
TSDB_APP_NAME_LEN
];
// app name that invokes taosc
int64_t
appStartTimeMs
;
// app start time
int64_t
appStartTimeMs
;
// app start time
int32_t
pid
;
// pid of app that invokes taosc
int32_t
pid
;
// pid of app that invokes taosc
uint32_t
ip
;
uint32_t
ip
;
uint16_t
port
;
uint16_t
port
;
int8_t
killed
;
int8_t
killed
;
int64_t
loginTimeMs
;
int64_t
loginTimeMs
;
int64_t
lastAccessTimeMs
;
int64_t
lastAccessTimeMs
;
uint64_t
killId
;
uint64_t
killId
;
int32_t
numOfQueries
;
int32_t
numOfQueries
;
SArray
*
pQueries
;
//
SArray<SQueryDesc>
SArray
*
pQueries
;
//
SArray<SQueryDesc>
}
SConnObj
;
}
SConnObj
;
static
SConnObj
*
mndCreateConn
(
SMnode
*
pMnode
,
const
char
*
user
,
int8_t
connType
,
uint32_t
ip
,
uint16_t
port
,
static
SConnObj
*
mndCreateConn
(
SMnode
*
pMnode
,
const
char
*
user
,
int8_t
connType
,
uint32_t
ip
,
uint16_t
port
,
...
@@ -45,7 +45,7 @@ static SConnObj *mndCreateConn(SMnode *pMnode, const char *user, int8_t connType
...
@@ -45,7 +45,7 @@ static SConnObj *mndCreateConn(SMnode *pMnode, const char *user, int8_t connType
static
void
mndFreeConn
(
SConnObj
*
pConn
);
static
void
mndFreeConn
(
SConnObj
*
pConn
);
static
SConnObj
*
mndAcquireConn
(
SMnode
*
pMnode
,
uint32_t
connId
);
static
SConnObj
*
mndAcquireConn
(
SMnode
*
pMnode
,
uint32_t
connId
);
static
void
mndReleaseConn
(
SMnode
*
pMnode
,
SConnObj
*
pConn
);
static
void
mndReleaseConn
(
SMnode
*
pMnode
,
SConnObj
*
pConn
);
static
void
*
mndGetNextConn
(
SMnode
*
pMnode
,
SCacheIter
*
pIter
);
static
void
*
mndGetNextConn
(
SMnode
*
pMnode
,
SCacheIter
*
pIter
);
static
void
mndCancelGetNextConn
(
SMnode
*
pMnode
,
void
*
pIter
);
static
void
mndCancelGetNextConn
(
SMnode
*
pMnode
,
void
*
pIter
);
static
int32_t
mndProcessHeartBeatReq
(
SNodeMsg
*
pReq
);
static
int32_t
mndProcessHeartBeatReq
(
SNodeMsg
*
pReq
);
static
int32_t
mndProcessConnectReq
(
SNodeMsg
*
pReq
);
static
int32_t
mndProcessConnectReq
(
SNodeMsg
*
pReq
);
...
@@ -71,9 +71,9 @@ int32_t mndInitProfile(SMnode *pMnode) {
...
@@ -71,9 +71,9 @@ int32_t mndInitProfile(SMnode *pMnode) {
mndSetMsgHandle
(
pMnode
,
TDMT_MND_KILL_QUERY
,
mndProcessKillQueryReq
);
mndSetMsgHandle
(
pMnode
,
TDMT_MND_KILL_QUERY
,
mndProcessKillQueryReq
);
mndSetMsgHandle
(
pMnode
,
TDMT_MND_KILL_CONN
,
mndProcessKillConnReq
);
mndSetMsgHandle
(
pMnode
,
TDMT_MND_KILL_CONN
,
mndProcessKillConnReq
);
// mndAddShowRetrieveHandle(pMnode, TSDB_MGMT_TABLE_CONNS, mndRetrieveConns);
// mndAddShowRetrieveHandle(pMnode, TSDB_MGMT_TABLE_CONNS, mndRetrieveConns);
mndAddShowFreeIterHandle
(
pMnode
,
TSDB_MGMT_TABLE_CONNS
,
mndCancelGetNextConn
);
mndAddShowFreeIterHandle
(
pMnode
,
TSDB_MGMT_TABLE_CONNS
,
mndCancelGetNextConn
);
// mndAddShowRetrieveHandle(pMnode, TSDB_MGMT_TABLE_QUERIES, mndRetrieveQueries);
// mndAddShowRetrieveHandle(pMnode, TSDB_MGMT_TABLE_QUERIES, mndRetrieveQueries);
mndAddShowFreeIterHandle
(
pMnode
,
TSDB_MGMT_TABLE_QUERIES
,
mndCancelGetNextQuery
);
mndAddShowFreeIterHandle
(
pMnode
,
TSDB_MGMT_TABLE_QUERIES
,
mndCancelGetNextQuery
);
return
0
;
return
0
;
...
@@ -91,7 +91,7 @@ static SConnObj *mndCreateConn(SMnode *pMnode, const char *user, int8_t connType
...
@@ -91,7 +91,7 @@ static SConnObj *mndCreateConn(SMnode *pMnode, const char *user, int8_t connType
int32_t
pid
,
const
char
*
app
,
int64_t
startTime
)
{
int32_t
pid
,
const
char
*
app
,
int64_t
startTime
)
{
SProfileMgmt
*
pMgmt
=
&
pMnode
->
profileMgmt
;
SProfileMgmt
*
pMgmt
=
&
pMnode
->
profileMgmt
;
char
connStr
[
255
]
=
{
0
};
char
connStr
[
255
]
=
{
0
};
int32_t
len
=
snprintf
(
connStr
,
sizeof
(
connStr
),
"%s%d%d%d%s"
,
user
,
ip
,
port
,
pid
,
app
);
int32_t
len
=
snprintf
(
connStr
,
sizeof
(
connStr
),
"%s%d%d%d%s"
,
user
,
ip
,
port
,
pid
,
app
);
int32_t
connId
=
mndGenerateUid
(
connStr
,
len
);
int32_t
connId
=
mndGenerateUid
(
connStr
,
len
);
if
(
startTime
==
0
)
startTime
=
taosGetTimestampMs
();
if
(
startTime
==
0
)
startTime
=
taosGetTimestampMs
();
...
@@ -174,10 +174,10 @@ static void mndCancelGetNextConn(SMnode *pMnode, void *pIter) {
...
@@ -174,10 +174,10 @@ static void mndCancelGetNextConn(SMnode *pMnode, void *pIter) {
}
}
static
int32_t
mndProcessConnectReq
(
SNodeMsg
*
pReq
)
{
static
int32_t
mndProcessConnectReq
(
SNodeMsg
*
pReq
)
{
SMnode
*
pMnode
=
pReq
->
pNode
;
SMnode
*
pMnode
=
pReq
->
pNode
;
SUserObj
*
pUser
=
NULL
;
SUserObj
*
pUser
=
NULL
;
SDbObj
*
pDb
=
NULL
;
SDbObj
*
pDb
=
NULL
;
SConnObj
*
pConn
=
NULL
;
SConnObj
*
pConn
=
NULL
;
int32_t
code
=
-
1
;
int32_t
code
=
-
1
;
SConnectReq
connReq
=
{
0
};
SConnectReq
connReq
=
{
0
};
char
ip
[
30
]
=
{
0
};
char
ip
[
30
]
=
{
0
};
...
@@ -194,6 +194,11 @@ static int32_t mndProcessConnectReq(SNodeMsg *pReq) {
...
@@ -194,6 +194,11 @@ static int32_t mndProcessConnectReq(SNodeMsg *pReq) {
mError
(
"user:%s, failed to login while acquire user since %s"
,
pReq
->
user
,
terrstr
());
mError
(
"user:%s, failed to login while acquire user since %s"
,
pReq
->
user
,
terrstr
());
goto
CONN_OVER
;
goto
CONN_OVER
;
}
}
if
(
0
!=
strncmp
(
connReq
.
passwd
,
pUser
->
pass
,
TSDB_PASSWORD_LEN
-
1
))
{
mError
(
"user:%s, failed to auth while acquire user
\n
%s
\r\n
%s"
,
pReq
->
user
,
connReq
.
passwd
,
pUser
->
pass
);
code
=
TSDB_CODE_RPC_AUTH_FAILURE
;
goto
CONN_OVER
;
}
if
(
connReq
.
db
[
0
])
{
if
(
connReq
.
db
[
0
])
{
char
db
[
TSDB_DB_FNAME_LEN
];
char
db
[
TSDB_DB_FNAME_LEN
];
...
@@ -253,8 +258,8 @@ static int32_t mndSaveQueryList(SConnObj *pConn, SQueryHbReqBasic *pBasic) {
...
@@ -253,8 +258,8 @@ static int32_t mndSaveQueryList(SConnObj *pConn, SQueryHbReqBasic *pBasic) {
pConn
->
pQueries
=
pBasic
->
queryDesc
;
pConn
->
pQueries
=
pBasic
->
queryDesc
;
pBasic
->
queryDesc
=
NULL
;
pBasic
->
queryDesc
=
NULL
;
pConn
->
numOfQueries
=
pBasic
->
queryDesc
?
taosArrayGetSize
(
pBasic
->
queryDesc
)
:
0
;
pConn
->
numOfQueries
=
pBasic
->
queryDesc
?
taosArrayGetSize
(
pBasic
->
queryDesc
)
:
0
;
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
...
@@ -324,9 +329,10 @@ static SClientHbRsp *mndMqHbBuildRsp(SMnode *pMnode, SClientHbReq *pReq) {
...
@@ -324,9 +329,10 @@ static SClientHbRsp *mndMqHbBuildRsp(SMnode *pMnode, SClientHbReq *pReq) {
return
NULL
;
return
NULL
;
}
}
static
int32_t
mndProcessQueryHeartBeat
(
SMnode
*
pMnode
,
SRpcMsg
*
pMsg
,
SClientHbReq
*
pHbReq
,
SClientHbBatchRsp
*
pBatchRsp
)
{
static
int32_t
mndProcessQueryHeartBeat
(
SMnode
*
pMnode
,
SRpcMsg
*
pMsg
,
SClientHbReq
*
pHbReq
,
SClientHbBatchRsp
*
pBatchRsp
)
{
SProfileMgmt
*
pMgmt
=
&
pMnode
->
profileMgmt
;
SProfileMgmt
*
pMgmt
=
&
pMnode
->
profileMgmt
;
SClientHbRsp
hbRsp
=
{.
connKey
=
pHbReq
->
connKey
,
.
status
=
0
,
.
info
=
NULL
,
.
query
=
NULL
};
SClientHbRsp
hbRsp
=
{.
connKey
=
pHbReq
->
connKey
,
.
status
=
0
,
.
info
=
NULL
,
.
query
=
NULL
};
if
(
pHbReq
->
query
)
{
if
(
pHbReq
->
query
)
{
SQueryHbReqBasic
*
pBasic
=
pHbReq
->
query
;
SQueryHbReqBasic
*
pBasic
=
pHbReq
->
query
;
...
@@ -335,8 +341,9 @@ static int32_t mndProcessQueryHeartBeat(SMnode *pMnode, SRpcMsg *pMsg, SClientHb
...
@@ -335,8 +341,9 @@ static int32_t mndProcessQueryHeartBeat(SMnode *pMnode, SRpcMsg *pMsg, SClientHb
rpcGetConnInfo
(
pMsg
->
handle
,
&
connInfo
);
rpcGetConnInfo
(
pMsg
->
handle
,
&
connInfo
);
SConnObj
*
pConn
=
mndAcquireConn
(
pMnode
,
pBasic
->
connId
);
SConnObj
*
pConn
=
mndAcquireConn
(
pMnode
,
pBasic
->
connId
);
if
(
pConn
==
NULL
)
{
if
(
pConn
==
NULL
)
{
pConn
=
mndCreateConn
(
pMnode
,
connInfo
.
user
,
CONN_TYPE__QUERY
,
connInfo
.
clientIp
,
connInfo
.
clientPort
,
pBasic
->
pid
,
pBasic
->
app
,
0
);
pConn
=
mndCreateConn
(
pMnode
,
connInfo
.
user
,
CONN_TYPE__QUERY
,
connInfo
.
clientIp
,
connInfo
.
clientPort
,
pBasic
->
pid
,
pBasic
->
app
,
0
);
if
(
pConn
==
NULL
)
{
if
(
pConn
==
NULL
)
{
mError
(
"user:%s, conn:%u is freed and failed to create new since %s"
,
connInfo
.
user
,
pBasic
->
connId
,
terrstr
());
mError
(
"user:%s, conn:%u is freed and failed to create new since %s"
,
connInfo
.
user
,
pBasic
->
connId
,
terrstr
());
return
-
1
;
return
-
1
;
...
@@ -345,7 +352,7 @@ static int32_t mndProcessQueryHeartBeat(SMnode *pMnode, SRpcMsg *pMsg, SClientHb
...
@@ -345,7 +352,7 @@ static int32_t mndProcessQueryHeartBeat(SMnode *pMnode, SRpcMsg *pMsg, SClientHb
}
}
}
else
if
(
pConn
->
killed
)
{
}
else
if
(
pConn
->
killed
)
{
mError
(
"user:%s, conn:%u is already killed"
,
connInfo
.
user
,
pConn
->
id
);
mError
(
"user:%s, conn:%u is already killed"
,
connInfo
.
user
,
pConn
->
id
);
mndReleaseConn
(
pMnode
,
pConn
);
mndReleaseConn
(
pMnode
,
pConn
);
terrno
=
TSDB_CODE_MND_INVALID_CONNECTION
;
terrno
=
TSDB_CODE_MND_INVALID_CONNECTION
;
return
-
1
;
return
-
1
;
}
}
...
@@ -369,8 +376,8 @@ static int32_t mndProcessQueryHeartBeat(SMnode *pMnode, SRpcMsg *pMsg, SClientHb
...
@@ -369,8 +376,8 @@ static int32_t mndProcessQueryHeartBeat(SMnode *pMnode, SRpcMsg *pMsg, SClientHb
}
}
rspBasic
->
connId
=
pConn
->
id
;
rspBasic
->
connId
=
pConn
->
id
;
rspBasic
->
totalDnodes
=
1
;
//
TODO
rspBasic
->
totalDnodes
=
1
;
//
TODO
rspBasic
->
onlineDnodes
=
1
;
//
TODO
rspBasic
->
onlineDnodes
=
1
;
//
TODO
mndGetMnodeEpSet
(
pMnode
,
&
rspBasic
->
epSet
);
mndGetMnodeEpSet
(
pMnode
,
&
rspBasic
->
epSet
);
mndReleaseConn
(
pMnode
,
pConn
);
mndReleaseConn
(
pMnode
,
pConn
);
...
@@ -379,7 +386,7 @@ static int32_t mndProcessQueryHeartBeat(SMnode *pMnode, SRpcMsg *pMsg, SClientHb
...
@@ -379,7 +386,7 @@ static int32_t mndProcessQueryHeartBeat(SMnode *pMnode, SRpcMsg *pMsg, SClientHb
int32_t
kvNum
=
taosHashGetSize
(
pHbReq
->
info
);
int32_t
kvNum
=
taosHashGetSize
(
pHbReq
->
info
);
if
(
NULL
==
pHbReq
->
info
||
kvNum
<=
0
)
{
if
(
NULL
==
pHbReq
->
info
||
kvNum
<=
0
)
{
taosArrayPush
(
pBatchRsp
->
rsps
,
&
hbRsp
);
taosArrayPush
(
pBatchRsp
->
rsps
,
&
hbRsp
);
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
...
@@ -396,7 +403,7 @@ static int32_t mndProcessQueryHeartBeat(SMnode *pMnode, SRpcMsg *pMsg, SClientHb
...
@@ -396,7 +403,7 @@ static int32_t mndProcessQueryHeartBeat(SMnode *pMnode, SRpcMsg *pMsg, SClientHb
switch
(
kv
->
key
)
{
switch
(
kv
->
key
)
{
case
HEARTBEAT_KEY_DBINFO
:
{
case
HEARTBEAT_KEY_DBINFO
:
{
void
*
rspMsg
=
NULL
;
void
*
rspMsg
=
NULL
;
int32_t
rspLen
=
0
;
int32_t
rspLen
=
0
;
mndValidateDbInfo
(
pMnode
,
kv
->
value
,
kv
->
valueLen
/
sizeof
(
SDbVgVersion
),
&
rspMsg
,
&
rspLen
);
mndValidateDbInfo
(
pMnode
,
kv
->
value
,
kv
->
valueLen
/
sizeof
(
SDbVgVersion
),
&
rspMsg
,
&
rspLen
);
if
(
rspMsg
&&
rspLen
>
0
)
{
if
(
rspMsg
&&
rspLen
>
0
)
{
...
@@ -406,7 +413,7 @@ static int32_t mndProcessQueryHeartBeat(SMnode *pMnode, SRpcMsg *pMsg, SClientHb
...
@@ -406,7 +413,7 @@ static int32_t mndProcessQueryHeartBeat(SMnode *pMnode, SRpcMsg *pMsg, SClientHb
break
;
break
;
}
}
case
HEARTBEAT_KEY_STBINFO
:
{
case
HEARTBEAT_KEY_STBINFO
:
{
void
*
rspMsg
=
NULL
;
void
*
rspMsg
=
NULL
;
int32_t
rspLen
=
0
;
int32_t
rspLen
=
0
;
mndValidateStbInfo
(
pMnode
,
kv
->
value
,
kv
->
valueLen
/
sizeof
(
SSTableMetaVersion
),
&
rspMsg
,
&
rspLen
);
mndValidateStbInfo
(
pMnode
,
kv
->
value
,
kv
->
valueLen
/
sizeof
(
SSTableMetaVersion
),
&
rspMsg
,
&
rspLen
);
if
(
rspMsg
&&
rspLen
>
0
)
{
if
(
rspMsg
&&
rspLen
>
0
)
{
...
@@ -457,7 +464,7 @@ static int32_t mndProcessHeartBeatReq(SNodeMsg *pReq) {
...
@@ -457,7 +464,7 @@ static int32_t mndProcessHeartBeatReq(SNodeMsg *pReq) {
taosArrayDestroyEx
(
batchReq
.
reqs
,
tFreeClientHbReq
);
taosArrayDestroyEx
(
batchReq
.
reqs
,
tFreeClientHbReq
);
int32_t
tlen
=
tSerializeSClientHbBatchRsp
(
NULL
,
0
,
&
batchRsp
);
int32_t
tlen
=
tSerializeSClientHbBatchRsp
(
NULL
,
0
,
&
batchRsp
);
void
*
buf
=
rpcMallocCont
(
tlen
);
void
*
buf
=
rpcMallocCont
(
tlen
);
tSerializeSClientHbBatchRsp
(
buf
,
tlen
,
&
batchRsp
);
tSerializeSClientHbBatchRsp
(
buf
,
tlen
,
&
batchRsp
);
int32_t
rspNum
=
(
int32_t
)
taosArrayGetSize
(
batchRsp
.
rsps
);
int32_t
rspNum
=
(
int32_t
)
taosArrayGetSize
(
batchRsp
.
rsps
);
...
@@ -479,7 +486,7 @@ static int32_t mndProcessHeartBeatReq(SNodeMsg *pReq) {
...
@@ -479,7 +486,7 @@ static int32_t mndProcessHeartBeatReq(SNodeMsg *pReq) {
}
}
static
int32_t
mndProcessKillQueryReq
(
SNodeMsg
*
pReq
)
{
static
int32_t
mndProcessKillQueryReq
(
SNodeMsg
*
pReq
)
{
SMnode
*
pMnode
=
pReq
->
pNode
;
SMnode
*
pMnode
=
pReq
->
pNode
;
SProfileMgmt
*
pMgmt
=
&
pMnode
->
profileMgmt
;
SProfileMgmt
*
pMgmt
=
&
pMnode
->
profileMgmt
;
SUserObj
*
pUser
=
mndAcquireUser
(
pMnode
,
pReq
->
user
);
SUserObj
*
pUser
=
mndAcquireUser
(
pMnode
,
pReq
->
user
);
...
@@ -513,7 +520,7 @@ static int32_t mndProcessKillQueryReq(SNodeMsg *pReq) {
...
@@ -513,7 +520,7 @@ static int32_t mndProcessKillQueryReq(SNodeMsg *pReq) {
}
}
static
int32_t
mndProcessKillConnReq
(
SNodeMsg
*
pReq
)
{
static
int32_t
mndProcessKillConnReq
(
SNodeMsg
*
pReq
)
{
SMnode
*
pMnode
=
pReq
->
pNode
;
SMnode
*
pMnode
=
pReq
->
pNode
;
SProfileMgmt
*
pMgmt
=
&
pMnode
->
profileMgmt
;
SProfileMgmt
*
pMgmt
=
&
pMnode
->
profileMgmt
;
SUserObj
*
pUser
=
mndAcquireUser
(
pMnode
,
pReq
->
user
);
SUserObj
*
pUser
=
mndAcquireUser
(
pMnode
,
pReq
->
user
);
...
@@ -545,11 +552,11 @@ static int32_t mndProcessKillConnReq(SNodeMsg *pReq) {
...
@@ -545,11 +552,11 @@ static int32_t mndProcessKillConnReq(SNodeMsg *pReq) {
}
}
static
int32_t
mndRetrieveConns
(
SNodeMsg
*
pReq
,
SShowObj
*
pShow
,
char
*
data
,
int32_t
rows
)
{
static
int32_t
mndRetrieveConns
(
SNodeMsg
*
pReq
,
SShowObj
*
pShow
,
char
*
data
,
int32_t
rows
)
{
SMnode
*
pMnode
=
pReq
->
pNode
;
SMnode
*
pMnode
=
pReq
->
pNode
;
int32_t
numOfRows
=
0
;
int32_t
numOfRows
=
0
;
SConnObj
*
pConn
=
NULL
;
SConnObj
*
pConn
=
NULL
;
int32_t
cols
=
0
;
int32_t
cols
=
0
;
char
*
pWrite
;
char
*
pWrite
;
char
ipStr
[
TSDB_IPv4ADDR_LEN
+
6
];
char
ipStr
[
TSDB_IPv4ADDR_LEN
+
6
];
if
(
pShow
->
pIter
==
NULL
)
{
if
(
pShow
->
pIter
==
NULL
)
{
...
@@ -604,8 +611,8 @@ static int32_t mndRetrieveConns(SNodeMsg *pReq, SShowObj *pShow, char *data, int
...
@@ -604,8 +611,8 @@ static int32_t mndRetrieveConns(SNodeMsg *pReq, SShowObj *pShow, char *data, int
}
}
static
int32_t
mndRetrieveQueries
(
SNodeMsg
*
pReq
,
SShowObj
*
pShow
,
char
*
data
,
int32_t
rows
)
{
static
int32_t
mndRetrieveQueries
(
SNodeMsg
*
pReq
,
SShowObj
*
pShow
,
char
*
data
,
int32_t
rows
)
{
SMnode
*
pMnode
=
pReq
->
pNode
;
SMnode
*
pMnode
=
pReq
->
pNode
;
int32_t
numOfRows
=
0
;
int32_t
numOfRows
=
0
;
#if 0
#if 0
SConnObj *pConn = NULL;
SConnObj *pConn = NULL;
int32_t cols = 0;
int32_t cols = 0;
...
@@ -703,7 +710,7 @@ static int32_t mndRetrieveQueries(SNodeMsg *pReq, SShowObj *pShow, char *data, i
...
@@ -703,7 +710,7 @@ static int32_t mndRetrieveQueries(SNodeMsg *pReq, SShowObj *pShow, char *data, i
}
}
pShow->numOfRows += numOfRows;
pShow->numOfRows += numOfRows;
#endif
#endif
return
numOfRows
;
return
numOfRows
;
}
}
...
...
source/dnode/mnode/impl/src/mndScheduler.c
浏览文件 @
162b3087
...
@@ -34,6 +34,54 @@
...
@@ -34,6 +34,54 @@
extern
bool
tsStreamSchedV
;
extern
bool
tsStreamSchedV
;
int32_t
mndConvertRSmaTask
(
const
char
*
ast
,
int8_t
triggerType
,
int64_t
watermark
,
char
**
pStr
,
int32_t
*
pLen
)
{
SNode
*
pAst
=
NULL
;
SQueryPlan
*
pPlan
=
NULL
;
terrno
=
TSDB_CODE_SUCCESS
;
if
(
nodesStringToNode
(
ast
,
&
pAst
)
<
0
)
{
terrno
=
TSDB_CODE_QRY_INVALID_INPUT
;
goto
END
;
}
SPlanContext
cxt
=
{
.
pAstRoot
=
pAst
,
.
topicQuery
=
false
,
.
streamQuery
=
true
,
.
rSmaQuery
=
true
,
.
triggerType
=
triggerType
,
.
watermark
=
watermark
,
};
if
(
qCreateQueryPlan
(
&
cxt
,
&
pPlan
,
NULL
)
<
0
)
{
terrno
=
TSDB_CODE_QRY_INVALID_INPUT
;
goto
END
;
}
int32_t
levelNum
=
LIST_LENGTH
(
pPlan
->
pSubplans
);
if
(
levelNum
!=
1
)
{
terrno
=
TSDB_CODE_QRY_INVALID_INPUT
;
goto
END
;
}
SNodeListNode
*
inner
=
nodesListGetNode
(
pPlan
->
pSubplans
,
0
);
int32_t
opNum
=
LIST_LENGTH
(
inner
->
pNodeList
);
if
(
opNum
!=
1
)
{
terrno
=
TSDB_CODE_QRY_INVALID_INPUT
;
goto
END
;
}
SSubplan
*
plan
=
nodesListGetNode
(
inner
->
pNodeList
,
0
);
if
(
qSubPlanToString
(
plan
,
pStr
,
pLen
)
<
0
)
{
terrno
=
TSDB_CODE_QRY_INVALID_INPUT
;
goto
END
;
}
END:
if
(
pAst
)
nodesDestroyNode
(
pAst
);
if
(
pPlan
)
nodesDestroyNode
(
pPlan
);
return
terrno
;
}
int32_t
mndPersistTaskDeployReq
(
STrans
*
pTrans
,
SStreamTask
*
pTask
,
const
SEpSet
*
pEpSet
,
tmsg_t
type
,
int32_t
nodeId
)
{
int32_t
mndPersistTaskDeployReq
(
STrans
*
pTrans
,
SStreamTask
*
pTask
,
const
SEpSet
*
pEpSet
,
tmsg_t
type
,
int32_t
nodeId
)
{
SCoder
encoder
;
SCoder
encoder
;
tCoderInit
(
&
encoder
,
TD_LITTLE_ENDIAN
,
NULL
,
0
,
TD_ENCODER
);
tCoderInit
(
&
encoder
,
TD_LITTLE_ENDIAN
,
NULL
,
0
,
TD_ENCODER
);
...
...
source/dnode/mnode/impl/src/mndShow.c
浏览文件 @
162b3087
...
@@ -18,7 +18,7 @@
...
@@ -18,7 +18,7 @@
#define SHOW_STEP_SIZE 100
#define SHOW_STEP_SIZE 100
static
SShowObj
*
mndCreateShowObj
(
SMnode
*
pMnode
,
S
Show
Req
*
pReq
);
static
SShowObj
*
mndCreateShowObj
(
SMnode
*
pMnode
,
S
RetrieveTable
Req
*
pReq
);
static
void
mndFreeShowObj
(
SShowObj
*
pShow
);
static
void
mndFreeShowObj
(
SShowObj
*
pShow
);
static
SShowObj
*
mndAcquireShowObj
(
SMnode
*
pMnode
,
int64_t
showId
);
static
SShowObj
*
mndAcquireShowObj
(
SMnode
*
pMnode
,
int64_t
showId
);
static
void
mndReleaseShowObj
(
SShowObj
*
pShow
,
bool
forceRemove
);
static
void
mndReleaseShowObj
(
SShowObj
*
pShow
,
bool
forceRemove
);
...
@@ -47,18 +47,80 @@ void mndCleanupShow(SMnode *pMnode) {
...
@@ -47,18 +47,80 @@ void mndCleanupShow(SMnode *pMnode) {
}
}
}
}
static
SShowObj
*
mndCreateShowObj
(
SMnode
*
pMnode
,
SShowReq
*
pReq
)
{
static
int32_t
convertToRetrieveType
(
char
*
name
,
int32_t
len
)
{
int32_t
type
=
-
1
;
if
(
strncasecmp
(
name
,
TSDB_INS_TABLE_DNODES
,
len
)
==
0
)
{
type
=
TSDB_MGMT_TABLE_DNODE
;
}
else
if
(
strncasecmp
(
name
,
TSDB_INS_TABLE_MNODES
,
len
)
==
0
)
{
type
=
TSDB_MGMT_TABLE_MNODE
;
}
else
if
(
strncasecmp
(
name
,
TSDB_INS_TABLE_MODULES
,
len
)
==
0
)
{
type
=
TSDB_MGMT_TABLE_MODULE
;
}
else
if
(
strncasecmp
(
name
,
TSDB_INS_TABLE_QNODES
,
len
)
==
0
)
{
type
=
TSDB_MGMT_TABLE_QNODE
;
}
else
if
(
strncasecmp
(
name
,
TSDB_INS_TABLE_BNODES
,
len
)
==
0
)
{
type
=
TSDB_MGMT_TABLE_BNODE
;
}
else
if
(
strncasecmp
(
name
,
TSDB_INS_TABLE_SNODES
,
len
)
==
0
)
{
type
=
TSDB_MGMT_TABLE_SNODE
;
}
else
if
(
strncasecmp
(
name
,
TSDB_INS_TABLE_CLUSTER
,
len
)
==
0
)
{
type
=
TSDB_MGMT_TABLE_CLUSTER
;
}
else
if
(
strncasecmp
(
name
,
TSDB_INS_TABLE_USER_DATABASES
,
len
)
==
0
)
{
type
=
TSDB_MGMT_TABLE_DB
;
}
else
if
(
strncasecmp
(
name
,
TSDB_INS_TABLE_USER_FUNCTIONS
,
len
)
==
0
)
{
type
=
TSDB_MGMT_TABLE_FUNC
;
}
else
if
(
strncasecmp
(
name
,
TSDB_INS_TABLE_USER_INDEXES
,
len
)
==
0
)
{
// type = TSDB_MGMT_TABLE_INDEX;
}
else
if
(
strncasecmp
(
name
,
TSDB_INS_TABLE_USER_STABLES
,
len
)
==
0
)
{
type
=
TSDB_MGMT_TABLE_STB
;
}
else
if
(
strncasecmp
(
name
,
TSDB_INS_TABLE_USER_STREAMS
,
len
)
==
0
)
{
type
=
TSDB_MGMT_TABLE_STREAMS
;
}
else
if
(
strncasecmp
(
name
,
TSDB_INS_TABLE_USER_TABLES
,
len
)
==
0
)
{
type
=
TSDB_MGMT_TABLE_TABLE
;
}
else
if
(
strncasecmp
(
name
,
TSDB_INS_TABLE_USER_TABLE_DISTRIBUTED
,
len
)
==
0
)
{
// type = TSDB_MGMT_TABLE_DIST;
}
else
if
(
strncasecmp
(
name
,
TSDB_INS_TABLE_USER_USERS
,
len
)
==
0
)
{
type
=
TSDB_MGMT_TABLE_USER
;
}
else
if
(
strncasecmp
(
name
,
TSDB_INS_TABLE_LICENCES
,
len
)
==
0
)
{
type
=
TSDB_MGMT_TABLE_GRANTS
;
}
else
if
(
strncasecmp
(
name
,
TSDB_INS_TABLE_VGROUPS
,
len
)
==
0
)
{
type
=
TSDB_MGMT_TABLE_VGROUP
;
}
else
if
(
strncasecmp
(
name
,
TSDB_INS_TABLE_TOPICS
,
len
)
==
0
)
{
type
=
TSDB_MGMT_TABLE_TOPICS
;
}
else
if
(
strncasecmp
(
name
,
TSDB_INS_TABLE_CONSUMERS
,
len
)
==
0
)
{
type
=
TSDB_MGMT_TABLE_CONSUMERS
;
}
else
if
(
strncasecmp
(
name
,
TSDB_INS_TABLE_SUBSCRIBES
,
len
)
==
0
)
{
type
=
TSDB_MGMT_TABLE_SUBSCRIBES
;
}
else
if
(
strncasecmp
(
name
,
TSDB_INS_TABLE_TRANS
,
len
)
==
0
)
{
type
=
TSDB_MGMT_TABLE_TRANS
;
}
else
if
(
strncasecmp
(
name
,
TSDB_INS_TABLE_SMAS
,
len
)
==
0
)
{
type
=
TSDB_MGMT_TABLE_SMAS
;
}
else
if
(
strncasecmp
(
name
,
TSDB_INS_TABLE_CONFIGS
,
len
)
==
0
)
{
type
=
TSDB_MGMT_TABLE_CONFIGS
;
}
else
if
(
strncasecmp
(
name
,
TSDB_INS_TABLE_CONNS
,
len
)
==
0
)
{
type
=
TSDB_MGMT_TABLE_CONNS
;
}
else
if
(
strncasecmp
(
name
,
TSDB_INS_TABLE_QUERIES
,
len
)
==
0
)
{
type
=
TSDB_MGMT_TABLE_QUERIES
;
}
else
if
(
strncasecmp
(
name
,
TSDB_INS_TABLE_VNODES
,
len
)
==
0
)
{
type
=
TSDB_MGMT_TABLE_VNODES
;
}
else
{
// ASSERT(0);
}
return
type
;
}
static
SShowObj
*
mndCreateShowObj
(
SMnode
*
pMnode
,
SRetrieveTableReq
*
pReq
)
{
SShowMgmt
*
pMgmt
=
&
pMnode
->
showMgmt
;
SShowMgmt
*
pMgmt
=
&
pMnode
->
showMgmt
;
int64_t
showId
=
atomic_add_fetch_64
(
&
pMgmt
->
showId
,
1
);
int64_t
showId
=
atomic_add_fetch_64
(
&
pMgmt
->
showId
,
1
);
if
(
showId
==
0
)
atomic_add_fetch_64
(
&
pMgmt
->
showId
,
1
);
if
(
showId
==
0
)
atomic_add_fetch_64
(
&
pMgmt
->
showId
,
1
);
int32_t
size
=
sizeof
(
SShowObj
)
+
pReq
->
payloadLen
;
int32_t
size
=
sizeof
(
SShowObj
);
SShowObj
showObj
=
{
0
};
SShowObj
showObj
=
{
0
};
showObj
.
id
=
showId
;
showObj
.
id
=
showId
;
showObj
.
pMnode
=
pMnode
;
showObj
.
pMnode
=
pMnode
;
showObj
.
type
=
pReq
->
type
;
showObj
.
type
=
convertToRetrieveType
(
pReq
->
tb
,
tListLen
(
pReq
->
tb
));
showObj
.
payloadLen
=
pReq
->
payloadLen
;
memcpy
(
showObj
.
db
,
pReq
->
db
,
TSDB_DB_FNAME_LEN
);
memcpy
(
showObj
.
db
,
pReq
->
db
,
TSDB_DB_FNAME_LEN
);
int32_t
keepTime
=
tsShellActivityTimer
*
6
*
1000
;
int32_t
keepTime
=
tsShellActivityTimer
*
6
*
1000
;
...
@@ -127,10 +189,6 @@ static int32_t mndProcessRetrieveSysTableReq(SNodeMsg *pReq) {
...
@@ -127,10 +189,6 @@ static int32_t mndProcessRetrieveSysTableReq(SNodeMsg *pReq) {
}
}
if
(
retrieveReq
.
showId
==
0
)
{
if
(
retrieveReq
.
showId
==
0
)
{
SShowReq
req
=
{
0
};
req
.
type
=
retrieveReq
.
type
;
strncpy
(
req
.
db
,
retrieveReq
.
db
,
tListLen
(
req
.
db
));
STableMetaRsp
*
pMeta
=
(
STableMetaRsp
*
)
taosHashGet
(
pMnode
->
infosMeta
,
retrieveReq
.
tb
,
strlen
(
retrieveReq
.
tb
)
+
1
);
STableMetaRsp
*
pMeta
=
(
STableMetaRsp
*
)
taosHashGet
(
pMnode
->
infosMeta
,
retrieveReq
.
tb
,
strlen
(
retrieveReq
.
tb
)
+
1
);
if
(
pMeta
==
NULL
)
{
if
(
pMeta
==
NULL
)
{
terrno
=
TSDB_CODE_MND_INVALID_INFOS_TBL
;
terrno
=
TSDB_CODE_MND_INVALID_INFOS_TBL
;
...
@@ -138,7 +196,7 @@ static int32_t mndProcessRetrieveSysTableReq(SNodeMsg *pReq) {
...
@@ -138,7 +196,7 @@ static int32_t mndProcessRetrieveSysTableReq(SNodeMsg *pReq) {
return
-
1
;
return
-
1
;
}
}
pShow
=
mndCreateShowObj
(
pMnode
,
&
req
);
pShow
=
mndCreateShowObj
(
pMnode
,
&
re
trieveRe
q
);
if
(
pShow
==
NULL
)
{
if
(
pShow
==
NULL
)
{
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
mError
(
"failed to process show-meta req since %s"
,
terrstr
());
mError
(
"failed to process show-meta req since %s"
,
terrstr
());
...
...
source/dnode/mnode/impl/src/mndStb.c
浏览文件 @
162b3087
...
@@ -20,6 +20,7 @@
...
@@ -20,6 +20,7 @@
#include "mndInfoSchema.h"
#include "mndInfoSchema.h"
#include "mndMnode.h"
#include "mndMnode.h"
#include "mndPerfSchema.h"
#include "mndPerfSchema.h"
#include "mndScheduler.h"
#include "mndShow.h"
#include "mndShow.h"
#include "mndTrans.h"
#include "mndTrans.h"
#include "mndUser.h"
#include "mndUser.h"
...
@@ -443,6 +444,25 @@ static void *mndBuildVCreateStbReq(SMnode *pMnode, SVgObj *pVgroup, SStbObj *pSt
...
@@ -443,6 +444,25 @@ static void *mndBuildVCreateStbReq(SMnode *pMnode, SVgObj *pVgroup, SStbObj *pSt
for
(
int32_t
f
=
0
;
f
<
pRSmaParam
->
nFuncIds
;
++
f
)
{
for
(
int32_t
f
=
0
;
f
<
pRSmaParam
->
nFuncIds
;
++
f
)
{
*
(
pRSmaParam
->
pFuncIds
+
f
)
=
pStb
->
aggregationMethod
;
*
(
pRSmaParam
->
pFuncIds
+
f
)
=
pStb
->
aggregationMethod
;
}
}
if
(
pStb
->
ast1Len
>
0
)
{
if
(
mndConvertRSmaTask
(
pStb
->
pAst1
,
0
,
0
,
&
pRSmaParam
->
qmsg1
,
&
pRSmaParam
->
qmsg1Len
)
!=
TSDB_CODE_SUCCESS
)
{
taosMemoryFreeClear
(
pRSmaParam
->
pFuncIds
);
taosMemoryFreeClear
(
req
.
stbCfg
.
pRSmaParam
);
taosMemoryFreeClear
(
req
.
stbCfg
.
pSchema
);
return
NULL
;
}
}
if
(
pStb
->
ast2Len
>
0
)
{
int32_t
qmsgLen2
=
0
;
if
(
mndConvertRSmaTask
(
pStb
->
pAst2
,
0
,
0
,
&
pRSmaParam
->
qmsg2
,
&
pRSmaParam
->
qmsg2Len
)
!=
TSDB_CODE_SUCCESS
)
{
taosMemoryFreeClear
(
pRSmaParam
->
pFuncIds
);
taosMemoryFreeClear
(
pRSmaParam
->
qmsg1
);
taosMemoryFreeClear
(
req
.
stbCfg
.
pRSmaParam
);
taosMemoryFreeClear
(
req
.
stbCfg
.
pSchema
);
return
NULL
;
}
}
req
.
stbCfg
.
pRSmaParam
=
pRSmaParam
;
req
.
stbCfg
.
pRSmaParam
=
pRSmaParam
;
}
}
...
@@ -451,6 +471,8 @@ static void *mndBuildVCreateStbReq(SMnode *pMnode, SVgObj *pVgroup, SStbObj *pSt
...
@@ -451,6 +471,8 @@ static void *mndBuildVCreateStbReq(SMnode *pMnode, SVgObj *pVgroup, SStbObj *pSt
if
(
pHead
==
NULL
)
{
if
(
pHead
==
NULL
)
{
if
(
pRSmaParam
)
{
if
(
pRSmaParam
)
{
taosMemoryFreeClear
(
pRSmaParam
->
pFuncIds
);
taosMemoryFreeClear
(
pRSmaParam
->
pFuncIds
);
taosMemoryFreeClear
(
pRSmaParam
->
qmsg1
);
taosMemoryFreeClear
(
pRSmaParam
->
qmsg2
);
taosMemoryFreeClear
(
pRSmaParam
);
taosMemoryFreeClear
(
pRSmaParam
);
}
}
taosMemoryFreeClear
(
req
.
stbCfg
.
pSchema
);
taosMemoryFreeClear
(
req
.
stbCfg
.
pSchema
);
...
@@ -467,6 +489,8 @@ static void *mndBuildVCreateStbReq(SMnode *pMnode, SVgObj *pVgroup, SStbObj *pSt
...
@@ -467,6 +489,8 @@ static void *mndBuildVCreateStbReq(SMnode *pMnode, SVgObj *pVgroup, SStbObj *pSt
*
pContLen
=
contLen
;
*
pContLen
=
contLen
;
if
(
pRSmaParam
)
{
if
(
pRSmaParam
)
{
taosMemoryFreeClear
(
pRSmaParam
->
pFuncIds
);
taosMemoryFreeClear
(
pRSmaParam
->
pFuncIds
);
taosMemoryFreeClear
(
pRSmaParam
->
qmsg1
);
taosMemoryFreeClear
(
pRSmaParam
->
qmsg2
);
taosMemoryFreeClear
(
pRSmaParam
);
taosMemoryFreeClear
(
pRSmaParam
);
}
}
taosMemoryFreeClear
(
req
.
stbCfg
.
pSchema
);
taosMemoryFreeClear
(
req
.
stbCfg
.
pSchema
);
...
...
source/dnode/mnode/impl/src/mndSubscribe.c
浏览文件 @
162b3087
此差异已折叠。
点击以展开。
source/dnode/mnode/impl/src/mndTopic.c
浏览文件 @
162b3087
...
@@ -76,7 +76,13 @@ SSdbRaw *mndTopicActionEncode(SMqTopicObj *pTopic) {
...
@@ -76,7 +76,13 @@ SSdbRaw *mndTopicActionEncode(SMqTopicObj *pTopic) {
SDB_SET_INT64
(
pRaw
,
dataPos
,
pTopic
->
updateTime
,
TOPIC_ENCODE_OVER
);
SDB_SET_INT64
(
pRaw
,
dataPos
,
pTopic
->
updateTime
,
TOPIC_ENCODE_OVER
);
SDB_SET_INT64
(
pRaw
,
dataPos
,
pTopic
->
uid
,
TOPIC_ENCODE_OVER
);
SDB_SET_INT64
(
pRaw
,
dataPos
,
pTopic
->
uid
,
TOPIC_ENCODE_OVER
);
SDB_SET_INT64
(
pRaw
,
dataPos
,
pTopic
->
dbUid
,
TOPIC_ENCODE_OVER
);
SDB_SET_INT64
(
pRaw
,
dataPos
,
pTopic
->
dbUid
,
TOPIC_ENCODE_OVER
);
SDB_SET_INT64
(
pRaw
,
dataPos
,
pTopic
->
subDbUid
,
TOPIC_ENCODE_OVER
);
SDB_SET_INT32
(
pRaw
,
dataPos
,
pTopic
->
version
,
TOPIC_ENCODE_OVER
);
SDB_SET_INT32
(
pRaw
,
dataPos
,
pTopic
->
version
,
TOPIC_ENCODE_OVER
);
SDB_SET_INT8
(
pRaw
,
dataPos
,
pTopic
->
subType
,
TOPIC_ENCODE_OVER
);
SDB_SET_INT8
(
pRaw
,
dataPos
,
pTopic
->
withTbName
,
TOPIC_ENCODE_OVER
);
SDB_SET_INT8
(
pRaw
,
dataPos
,
pTopic
->
withSchema
,
TOPIC_ENCODE_OVER
);
SDB_SET_INT8
(
pRaw
,
dataPos
,
pTopic
->
withTag
,
TOPIC_ENCODE_OVER
);
SDB_SET_INT8
(
pRaw
,
dataPos
,
pTopic
->
withTagSchema
,
TOPIC_ENCODE_OVER
);
SDB_SET_INT32
(
pRaw
,
dataPos
,
pTopic
->
sqlLen
,
TOPIC_ENCODE_OVER
);
SDB_SET_INT32
(
pRaw
,
dataPos
,
pTopic
->
sqlLen
,
TOPIC_ENCODE_OVER
);
SDB_SET_BINARY
(
pRaw
,
dataPos
,
pTopic
->
sql
,
pTopic
->
sqlLen
,
TOPIC_ENCODE_OVER
);
SDB_SET_BINARY
(
pRaw
,
dataPos
,
pTopic
->
sql
,
pTopic
->
sqlLen
,
TOPIC_ENCODE_OVER
);
SDB_SET_INT32
(
pRaw
,
dataPos
,
pTopic
->
astLen
,
TOPIC_ENCODE_OVER
);
SDB_SET_INT32
(
pRaw
,
dataPos
,
pTopic
->
astLen
,
TOPIC_ENCODE_OVER
);
...
@@ -134,7 +140,13 @@ SSdbRow *mndTopicActionDecode(SSdbRaw *pRaw) {
...
@@ -134,7 +140,13 @@ SSdbRow *mndTopicActionDecode(SSdbRaw *pRaw) {
SDB_GET_INT64
(
pRaw
,
dataPos
,
&
pTopic
->
updateTime
,
TOPIC_DECODE_OVER
);
SDB_GET_INT64
(
pRaw
,
dataPos
,
&
pTopic
->
updateTime
,
TOPIC_DECODE_OVER
);
SDB_GET_INT64
(
pRaw
,
dataPos
,
&
pTopic
->
uid
,
TOPIC_DECODE_OVER
);
SDB_GET_INT64
(
pRaw
,
dataPos
,
&
pTopic
->
uid
,
TOPIC_DECODE_OVER
);
SDB_GET_INT64
(
pRaw
,
dataPos
,
&
pTopic
->
dbUid
,
TOPIC_DECODE_OVER
);
SDB_GET_INT64
(
pRaw
,
dataPos
,
&
pTopic
->
dbUid
,
TOPIC_DECODE_OVER
);
SDB_GET_INT64
(
pRaw
,
dataPos
,
&
pTopic
->
subDbUid
,
TOPIC_DECODE_OVER
);
SDB_GET_INT32
(
pRaw
,
dataPos
,
&
pTopic
->
version
,
TOPIC_DECODE_OVER
);
SDB_GET_INT32
(
pRaw
,
dataPos
,
&
pTopic
->
version
,
TOPIC_DECODE_OVER
);
SDB_GET_INT8
(
pRaw
,
dataPos
,
&
pTopic
->
subType
,
TOPIC_DECODE_OVER
);
SDB_GET_INT8
(
pRaw
,
dataPos
,
&
pTopic
->
withTbName
,
TOPIC_DECODE_OVER
);
SDB_GET_INT8
(
pRaw
,
dataPos
,
&
pTopic
->
withSchema
,
TOPIC_DECODE_OVER
);
SDB_GET_INT8
(
pRaw
,
dataPos
,
&
pTopic
->
withTag
,
TOPIC_DECODE_OVER
);
SDB_GET_INT8
(
pRaw
,
dataPos
,
&
pTopic
->
withTagSchema
,
TOPIC_DECODE_OVER
);
SDB_GET_INT32
(
pRaw
,
dataPos
,
&
pTopic
->
sqlLen
,
TOPIC_DECODE_OVER
);
SDB_GET_INT32
(
pRaw
,
dataPos
,
&
pTopic
->
sqlLen
,
TOPIC_DECODE_OVER
);
pTopic
->
sql
=
taosMemoryCalloc
(
pTopic
->
sqlLen
,
sizeof
(
char
));
pTopic
->
sql
=
taosMemoryCalloc
(
pTopic
->
sqlLen
,
sizeof
(
char
));
...
@@ -254,33 +266,13 @@ static int32_t mndCheckCreateTopicReq(SCMCreateTopicReq *pCreate) {
...
@@ -254,33 +266,13 @@ static int32_t mndCheckCreateTopicReq(SCMCreateTopicReq *pCreate) {
terrno
=
TSDB_CODE_MND_INVALID_TOPIC_OPTION
;
terrno
=
TSDB_CODE_MND_INVALID_TOPIC_OPTION
;
return
-
1
;
return
-
1
;
}
}
return
0
;
}
#if 0
static int32_t mndGetPlanString(const SCMCreateTopicReq *pCreate, char **pStr) {
if (NULL == pCreate->ast) {
return TSDB_CODE_SUCCESS;
}
SNode *pAst = NULL;
int32_t code = nodesStringToNode(pCreate->ast, &pAst);
SQueryPlan *pPlan = NULL;
if
((
pCreate
->
ast
==
NULL
||
pCreate
->
ast
[
0
]
==
0
)
&&
pCreate
->
subscribeDbName
[
0
]
==
0
)
{
if (TSDB_CODE_SUCCESS == code) {
terrno
=
TSDB_CODE_MND_INVALID_TOPIC_OPTION
;
SPlanContext cxt = {.pAstRoot = pAst, .topicQuery = true};
return
-
1
;
code = qCreateQueryPlan(&cxt, &pPlan, NULL);
}
if (TSDB_CODE_SUCCESS == code) {
code = nodesNodeToString(pPlan, false, pStr, NULL);
}
}
nodesDestroyNode(pAst);
return
0
;
nodesDestroyNode(pPlan);
terrno = code;
return code;
}
}
#endif
static
int32_t
mndCreateTopic
(
SMnode
*
pMnode
,
SNodeMsg
*
pReq
,
SCMCreateTopicReq
*
pCreate
,
SDbObj
*
pDb
)
{
static
int32_t
mndCreateTopic
(
SMnode
*
pMnode
,
SNodeMsg
*
pReq
,
SCMCreateTopicReq
*
pCreate
,
SDbObj
*
pDb
)
{
mDebug
(
"topic:%s to create"
,
pCreate
->
name
);
mDebug
(
"topic:%s to create"
,
pCreate
->
name
);
...
@@ -297,28 +289,38 @@ static int32_t mndCreateTopic(SMnode *pMnode, SNodeMsg *pReq, SCMCreateTopicReq
...
@@ -297,28 +289,38 @@ static int32_t mndCreateTopic(SMnode *pMnode, SNodeMsg *pReq, SCMCreateTopicReq
topicObj
.
ast
=
strdup
(
pCreate
->
ast
);
topicObj
.
ast
=
strdup
(
pCreate
->
ast
);
topicObj
.
astLen
=
strlen
(
pCreate
->
ast
)
+
1
;
topicObj
.
astLen
=
strlen
(
pCreate
->
ast
)
+
1
;
SNode
*
pAst
=
NULL
;
if
(
pCreate
->
ast
&&
pCreate
->
ast
[
0
])
{
if
(
nodesStringToNode
(
pCreate
->
ast
,
&
pAst
)
!=
0
)
{
topicObj
.
subType
=
TOPIC_SUB_TYPE__TABLE
;
mError
(
"topic:%s, failed to create since %s"
,
pCreate
->
name
,
terrstr
());
topicObj
.
withTbName
=
0
;
return
-
1
;
topicObj
.
withSchema
=
0
;
}
SQueryPlan
*
pPlan
=
NULL
;
SNode
*
pAst
=
NULL
;
if
(
nodesStringToNode
(
pCreate
->
ast
,
&
pAst
)
!=
0
)
{
mError
(
"topic:%s, failed to create since %s"
,
pCreate
->
name
,
terrstr
());
return
-
1
;
}
SPlanContext
cxt
=
{.
pAstRoot
=
pAst
,
.
topicQuery
=
true
};
SQueryPlan
*
pPlan
=
NULL
;
if
(
qCreateQueryPlan
(
&
cxt
,
&
pPlan
,
NULL
)
!=
0
)
{
mError
(
"topic:%s, failed to create since %s"
,
pCreate
->
name
,
terrstr
());
return
-
1
;
}
if
(
qExtractResultSchema
(
pAst
,
&
topicObj
.
schema
.
nCols
,
&
topicObj
.
schema
.
pSchema
)
!=
0
)
{
SPlanContext
cxt
=
{.
pAstRoot
=
pAst
,
.
topicQuery
=
true
};
mError
(
"topic:%s, failed to create since %s"
,
pCreate
->
name
,
terrstr
());
if
(
qCreateQueryPlan
(
&
cxt
,
&
pPlan
,
NULL
)
!=
0
)
{
return
-
1
;
mError
(
"topic:%s, failed to create since %s"
,
pCreate
->
name
,
terrstr
());
}
return
-
1
;
}
if
(
nodesNodeToString
(
pPlan
,
false
,
&
topicObj
.
physicalPlan
,
NULL
)
!=
0
)
{
if
(
qExtractResultSchema
(
pAst
,
&
topicObj
.
schema
.
nCols
,
&
topicObj
.
schema
.
pSchema
)
!=
0
)
{
mError
(
"topic:%s, failed to create since %s"
,
pCreate
->
name
,
terrstr
());
mError
(
"topic:%s, failed to create since %s"
,
pCreate
->
name
,
terrstr
());
return
-
1
;
return
-
1
;
}
if
(
nodesNodeToString
(
pPlan
,
false
,
&
topicObj
.
physicalPlan
,
NULL
)
!=
0
)
{
mError
(
"topic:%s, failed to create since %s"
,
pCreate
->
name
,
terrstr
());
return
-
1
;
}
}
else
{
topicObj
.
subType
=
TOPIC_SUB_TYPE__DB
;
topicObj
.
withTbName
=
1
;
topicObj
.
withSchema
=
1
;
}
}
STrans
*
pTrans
=
mndTransCreate
(
pMnode
,
TRN_POLICY_ROLLBACK
,
TRN_TYPE_CREATE_TOPIC
,
&
pReq
->
rpcMsg
);
STrans
*
pTrans
=
mndTransCreate
(
pMnode
,
TRN_POLICY_ROLLBACK
,
TRN_TYPE_CREATE_TOPIC
,
&
pReq
->
rpcMsg
);
...
...
source/dnode/mnode/impl/test/profile/profile.cpp
浏览文件 @
162b3087
...
@@ -30,8 +30,15 @@ int32_t MndTestProfile::connId;
...
@@ -30,8 +30,15 @@ int32_t MndTestProfile::connId;
TEST_F
(
MndTestProfile
,
01
_ConnectMsg
)
{
TEST_F
(
MndTestProfile
,
01
_ConnectMsg
)
{
SConnectReq
connectReq
=
{
0
};
SConnectReq
connectReq
=
{
0
};
connectReq
.
pid
=
1234
;
connectReq
.
pid
=
1234
;
char
passwd
[]
=
"taosdata"
;
char
secretEncrypt
[
TSDB_PASSWORD_LEN
]
=
{
0
};
taosEncryptPass_c
((
uint8_t
*
)
passwd
,
strlen
(
passwd
),
secretEncrypt
);
strcpy
(
connectReq
.
app
,
"mnode_test_profile"
);
strcpy
(
connectReq
.
app
,
"mnode_test_profile"
);
strcpy
(
connectReq
.
db
,
""
);
strcpy
(
connectReq
.
db
,
""
);
strcpy
(
connectReq
.
user
,
"root"
);
strcpy
(
connectReq
.
passwd
,
secretEncrypt
);
int32_t
contLen
=
tSerializeSConnectReq
(
NULL
,
0
,
&
connectReq
);
int32_t
contLen
=
tSerializeSConnectReq
(
NULL
,
0
,
&
connectReq
);
void
*
pReq
=
rpcMallocCont
(
contLen
);
void
*
pReq
=
rpcMallocCont
(
contLen
);
...
@@ -58,10 +65,16 @@ TEST_F(MndTestProfile, 01_ConnectMsg) {
...
@@ -58,10 +65,16 @@ TEST_F(MndTestProfile, 01_ConnectMsg) {
}
}
TEST_F
(
MndTestProfile
,
02
_ConnectMsg_InvalidDB
)
{
TEST_F
(
MndTestProfile
,
02
_ConnectMsg_InvalidDB
)
{
char
passwd
[]
=
"taosdata"
;
char
secretEncrypt
[
TSDB_PASSWORD_LEN
]
=
{
0
};
taosEncryptPass_c
((
uint8_t
*
)
passwd
,
strlen
(
passwd
),
secretEncrypt
);
SConnectReq
connectReq
=
{
0
};
SConnectReq
connectReq
=
{
0
};
connectReq
.
pid
=
1234
;
connectReq
.
pid
=
1234
;
strcpy
(
connectReq
.
app
,
"mnode_test_profile"
);
strcpy
(
connectReq
.
app
,
"mnode_test_profile"
);
strcpy
(
connectReq
.
db
,
"invalid_db"
);
strcpy
(
connectReq
.
db
,
"invalid_db"
);
strcpy
(
connectReq
.
user
,
"root"
);
strcpy
(
connectReq
.
passwd
,
secretEncrypt
);
int32_t
contLen
=
tSerializeSConnectReq
(
NULL
,
0
,
&
connectReq
);
int32_t
contLen
=
tSerializeSConnectReq
(
NULL
,
0
,
&
connectReq
);
void
*
pReq
=
rpcMallocCont
(
contLen
);
void
*
pReq
=
rpcMallocCont
(
contLen
);
...
...
source/dnode/mnode/impl/test/show/show.cpp
浏览文件 @
162b3087
...
@@ -36,7 +36,7 @@ TEST_F(MndTestShow, 01_ShowMsg_InvalidMsgMax) {
...
@@ -36,7 +36,7 @@ TEST_F(MndTestShow, 01_ShowMsg_InvalidMsgMax) {
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_SYSTABLE_RETRIEVE
,
pReq
,
contLen
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_SYSTABLE_RETRIEVE
,
pReq
,
contLen
);
ASSERT_NE
(
pRsp
,
nullptr
);
ASSERT_NE
(
pRsp
,
nullptr
);
ASSERT_
EQ
(
pRsp
->
code
,
TSDB_CODE_INVALID_MSG
);
ASSERT_
NE
(
pRsp
->
code
,
0
);
}
}
TEST_F
(
MndTestShow
,
02
_ShowMsg_InvalidMsgStart
)
{
TEST_F
(
MndTestShow
,
02
_ShowMsg_InvalidMsgStart
)
{
...
@@ -50,14 +50,20 @@ TEST_F(MndTestShow, 02_ShowMsg_InvalidMsgStart) {
...
@@ -50,14 +50,20 @@ TEST_F(MndTestShow, 02_ShowMsg_InvalidMsgStart) {
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_SYSTABLE_RETRIEVE
,
pReq
,
contLen
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_SYSTABLE_RETRIEVE
,
pReq
,
contLen
);
ASSERT_NE
(
pRsp
,
nullptr
);
ASSERT_NE
(
pRsp
,
nullptr
);
ASSERT_
EQ
(
pRsp
->
code
,
TSDB_CODE_INVALID_MSG
);
ASSERT_
NE
(
pRsp
->
code
,
0
);
}
}
TEST_F
(
MndTestShow
,
03
_ShowMsg_Conn
)
{
TEST_F
(
MndTestShow
,
03
_ShowMsg_Conn
)
{
char
passwd
[]
=
"taosdata"
;
char
secretEncrypt
[
TSDB_PASSWORD_LEN
]
=
{
0
};
taosEncryptPass_c
((
uint8_t
*
)
passwd
,
strlen
(
passwd
),
secretEncrypt
);
SConnectReq
connectReq
=
{
0
};
SConnectReq
connectReq
=
{
0
};
connectReq
.
pid
=
1234
;
connectReq
.
pid
=
1234
;
strcpy
(
connectReq
.
app
,
"mnode_test_show"
);
strcpy
(
connectReq
.
app
,
"mnode_test_show"
);
strcpy
(
connectReq
.
db
,
""
);
strcpy
(
connectReq
.
db
,
""
);
strcpy
(
connectReq
.
user
,
"root"
);
strcpy
(
connectReq
.
passwd
,
secretEncrypt
);
int32_t
contLen
=
tSerializeSConnectReq
(
NULL
,
0
,
&
connectReq
);
int32_t
contLen
=
tSerializeSConnectReq
(
NULL
,
0
,
&
connectReq
);
void
*
pReq
=
rpcMallocCont
(
contLen
);
void
*
pReq
=
rpcMallocCont
(
contLen
);
...
@@ -74,4 +80,4 @@ TEST_F(MndTestShow, 03_ShowMsg_Conn) {
...
@@ -74,4 +80,4 @@ TEST_F(MndTestShow, 03_ShowMsg_Conn) {
TEST_F
(
MndTestShow
,
04
_ShowMsg_Cluster
)
{
TEST_F
(
MndTestShow
,
04
_ShowMsg_Cluster
)
{
test
.
SendShowReq
(
TSDB_MGMT_TABLE_CLUSTER
,
"cluster"
,
""
);
test
.
SendShowReq
(
TSDB_MGMT_TABLE_CLUSTER
,
"cluster"
,
""
);
EXPECT_EQ
(
test
.
GetShowRows
(),
1
);
EXPECT_EQ
(
test
.
GetShowRows
(),
1
);
}
}
\ No newline at end of file
source/dnode/vnode/inc/vnode.h
浏览文件 @
162b3087
...
@@ -109,8 +109,7 @@ int tqReadHandleSetTbUidList(STqReadHandle *pHandle, const SArray *tbUidList
...
@@ -109,8 +109,7 @@ int tqReadHandleSetTbUidList(STqReadHandle *pHandle, const SArray *tbUidList
int
tqReadHandleAddTbUidList
(
STqReadHandle
*
pHandle
,
const
SArray
*
tbUidList
);
int
tqReadHandleAddTbUidList
(
STqReadHandle
*
pHandle
,
const
SArray
*
tbUidList
);
int32_t
tqReadHandleSetMsg
(
STqReadHandle
*
pHandle
,
SSubmitReq
*
pMsg
,
int64_t
ver
);
int32_t
tqReadHandleSetMsg
(
STqReadHandle
*
pHandle
,
SSubmitReq
*
pMsg
,
int64_t
ver
);
bool
tqNextDataBlock
(
STqReadHandle
*
pHandle
);
bool
tqNextDataBlock
(
STqReadHandle
*
pHandle
);
int
tqRetrieveDataBlockInfo
(
STqReadHandle
*
pHandle
,
SDataBlockInfo
*
pBlockInfo
);
int32_t
tqRetrieveDataBlock
(
SArray
**
ppCols
,
STqReadHandle
*
pHandle
,
uint64_t
*
pGroupId
,
int32_t
*
pNumOfRows
);
SArray
*
tqRetrieveDataBlock
(
STqReadHandle
*
pHandle
);
// need to reposition
// need to reposition
...
...
source/dnode/vnode/src/inc/tsdb.h
浏览文件 @
162b3087
...
@@ -391,6 +391,7 @@ struct SReadH {
...
@@ -391,6 +391,7 @@ struct SReadH {
#define TSDB_READ_REPO_ID(rh) REPO_ID(TSDB_READ_REPO(rh))
#define TSDB_READ_REPO_ID(rh) REPO_ID(TSDB_READ_REPO(rh))
#define TSDB_READ_FSET(rh) (&((rh)->rSet))
#define TSDB_READ_FSET(rh) (&((rh)->rSet))
#define TSDB_READ_TABLE(rh) ((rh)->pTable)
#define TSDB_READ_TABLE(rh) ((rh)->pTable)
#define TSDB_READ_TABLE_UID(rh) ((rh)->pTable->uid)
#define TSDB_READ_HEAD_FILE(rh) TSDB_DFILE_IN_SET(TSDB_READ_FSET(rh), TSDB_FILE_HEAD)
#define TSDB_READ_HEAD_FILE(rh) TSDB_DFILE_IN_SET(TSDB_READ_FSET(rh), TSDB_FILE_HEAD)
#define TSDB_READ_DATA_FILE(rh) TSDB_DFILE_IN_SET(TSDB_READ_FSET(rh), TSDB_FILE_DATA)
#define TSDB_READ_DATA_FILE(rh) TSDB_DFILE_IN_SET(TSDB_READ_FSET(rh), TSDB_FILE_DATA)
#define TSDB_READ_LAST_FILE(rh) TSDB_DFILE_IN_SET(TSDB_READ_FSET(rh), TSDB_FILE_LAST)
#define TSDB_READ_LAST_FILE(rh) TSDB_DFILE_IN_SET(TSDB_READ_FSET(rh), TSDB_FILE_LAST)
...
...
source/dnode/vnode/src/meta/metaTDBImpl.c
浏览文件 @
162b3087
...
@@ -626,14 +626,8 @@ STSmaWrapper *metaGetSmaInfoByTable(SMeta *pMeta, tb_uid_t uid) {
...
@@ -626,14 +626,8 @@ STSmaWrapper *metaGetSmaInfoByTable(SMeta *pMeta, tb_uid_t uid) {
#ifdef META_TDB_SMA_TEST
#ifdef META_TDB_SMA_TEST
STSmaWrapper
*
pSW
=
NULL
;
STSmaWrapper
*
pSW
=
NULL
;
pSW
=
taosMemoryCalloc
(
1
,
sizeof
(
*
pSW
));
if
(
pSW
==
NULL
)
{
return
NULL
;
}
SMSmaCursor
*
pCur
=
metaOpenSmaCursor
(
pMeta
,
uid
);
SMSmaCursor
*
pCur
=
metaOpenSmaCursor
(
pMeta
,
uid
);
if
(
pCur
==
NULL
)
{
if
(
pCur
==
NULL
)
{
taosMemoryFree
(
pSW
);
return
NULL
;
return
NULL
;
}
}
...
@@ -653,6 +647,12 @@ STSmaWrapper *metaGetSmaInfoByTable(SMeta *pMeta, tb_uid_t uid) {
...
@@ -653,6 +647,12 @@ STSmaWrapper *metaGetSmaInfoByTable(SMeta *pMeta, tb_uid_t uid) {
continue
;
continue
;
}
}
if
((
pSW
==
NULL
)
&&
((
pSW
=
taosMemoryCalloc
(
1
,
sizeof
(
*
pSW
)))
==
NULL
))
{
TDB_FREE
(
pSmaVal
);
metaCloseSmaCursor
(
pCur
);
return
NULL
;
}
++
pSW
->
number
;
++
pSW
->
number
;
STSma
*
tptr
=
(
STSma
*
)
taosMemoryRealloc
(
pSW
->
tSma
,
pSW
->
number
*
sizeof
(
STSma
));
STSma
*
tptr
=
(
STSma
*
)
taosMemoryRealloc
(
pSW
->
tSma
,
pSW
->
number
*
sizeof
(
STSma
));
if
(
tptr
==
NULL
)
{
if
(
tptr
==
NULL
)
{
...
...
source/dnode/vnode/src/tq/tq.c
浏览文件 @
162b3087
...
@@ -618,127 +618,6 @@ int32_t tqProcessVgChangeReq(STQ* pTq, char* msg, int32_t msgLen) {
...
@@ -618,127 +618,6 @@ int32_t tqProcessVgChangeReq(STQ* pTq, char* msg, int32_t msgLen) {
}
}
}
}
#if 0
int32_t tqProcessRebReq(STQ* pTq, char* msg) {
SMqMVRebReq req = {0};
terrno = TSDB_CODE_SUCCESS;
tDecodeSMqMVRebReq(msg, &req);
vDebug("vg %d set from consumer %ld to consumer %ld", req.vgId, req.oldConsumerId, req.newConsumerId);
STqConsumer* pConsumer = tqHandleGet(pTq->tqMeta, req.oldConsumerId);
ASSERT(pConsumer);
ASSERT(pConsumer->consumerId == req.oldConsumerId);
int32_t numOfTopics = taosArrayGetSize(pConsumer->topics);
if (numOfTopics == 1) {
STqTopic* pTopic = taosArrayGet(pConsumer->topics, 0);
ASSERT(strcmp(pTopic->topicName, req.topic) == 0);
STqConsumer* pNewConsumer = tqHandleGet(pTq->tqMeta, req.newConsumerId);
if (pNewConsumer == NULL) {
pConsumer->consumerId = req.newConsumerId;
tqHandleMovePut(pTq->tqMeta, req.newConsumerId, pConsumer);
tqHandleCommit(pTq->tqMeta, req.newConsumerId);
tqHandlePurge(pTq->tqMeta, req.oldConsumerId);
return 0;
} else {
taosArrayPush(pNewConsumer->topics, pTopic);
}
} else {
for (int32_t i = 0; i < numOfTopics; i++) {
STqTopic* pTopic = taosArrayGet(pConsumer->topics, i);
if (strcmp(pTopic->topicName, req.topic) == 0) {
STqConsumer* pNewConsumer = tqHandleGet(pTq->tqMeta, req.newConsumerId);
if (pNewConsumer == NULL) {
pNewConsumer = taosMemoryCalloc(1, sizeof(STqConsumer));
if (pNewConsumer == NULL) {
terrno = TSDB_CODE_TQ_OUT_OF_MEMORY;
return -1;
}
strcpy(pNewConsumer->cgroup, pConsumer->cgroup);
pNewConsumer->topics = taosArrayInit(0, sizeof(STqTopic));
pNewConsumer->consumerId = req.newConsumerId;
pNewConsumer->epoch = 0;
taosArrayPush(pNewConsumer->topics, pTopic);
tqHandleMovePut(pTq->tqMeta, req.newConsumerId, pConsumer);
tqHandleCommit(pTq->tqMeta, req.newConsumerId);
return 0;
}
ASSERT(pNewConsumer->consumerId == req.newConsumerId);
taosArrayPush(pNewConsumer->topics, pTopic);
break;
}
}
//
}
return 0;
}
int32_t tqProcessSetConnReq(STQ* pTq, char* msg) {
SMqSetCVgReq req = {0};
tDecodeSMqSetCVgReq(msg, &req);
bool create = false;
vDebug("vg %d set to consumer %ld", req.vgId, req.consumerId);
STqConsumer* pConsumer = tqHandleGet(pTq->tqMeta, req.consumerId);
if (pConsumer == NULL) {
pConsumer = taosMemoryCalloc(1, sizeof(STqConsumer));
if (pConsumer == NULL) {
terrno = TSDB_CODE_TQ_OUT_OF_MEMORY;
return -1;
}
strcpy(pConsumer->cgroup, req.cgroup);
pConsumer->topics = taosArrayInit(0, sizeof(STqTopic));
pConsumer->consumerId = req.consumerId;
pConsumer->epoch = 0;
create = true;
}
STqTopic* pTopic = taosMemoryCalloc(1, sizeof(STqTopic));
if (pTopic == NULL) {
taosArrayDestroy(pConsumer->topics);
taosMemoryFree(pConsumer);
return -1;
}
strcpy(pTopic->topicName, req.topicName);
pTopic->sql = req.sql;
pTopic->physicalPlan = req.physicalPlan;
pTopic->qmsg = req.qmsg;
/*pTopic->committedOffset = -1;*/
/*pTopic->currentOffset = -1;*/
pTopic->buffer.firstOffset = -1;
pTopic->buffer.lastOffset = -1;
pTopic->pReadhandle = walOpenReadHandle(pTq->pWal);
if (pTopic->pReadhandle == NULL) {
ASSERT(false);
}
for (int i = 0; i < TQ_BUFFER_SIZE; i++) {
pTopic->buffer.output[i].status = 0;
STqReadHandle* pReadHandle = tqInitSubmitMsgScanner(pTq->pVnodeMeta);
SReadHandle handle = {
.reader = pReadHandle,
.meta = pTq->pVnodeMeta,
};
pTopic->buffer.output[i].pReadHandle = pReadHandle;
pTopic->buffer.output[i].task = qCreateStreamExecTaskInfo(req.qmsg, &handle);
ASSERT(pTopic->buffer.output[i].task);
}
vDebug("set topic %s to consumer %ld on vg %d", pTopic->topicName, req.consumerId, TD_VID(pTq->pVnode));
taosArrayPush(pConsumer->topics, pTopic);
if (create) {
tqHandleMovePut(pTq->tqMeta, req.consumerId, pConsumer);
tqHandleCommit(pTq->tqMeta, req.consumerId);
}
terrno = TSDB_CODE_SUCCESS;
return 0;
}
int32_t tqProcessCancelConnReq(STQ* pTq, char* msg) {
terrno = TSDB_CODE_SUCCESS;
return 0;
}
#endif
int32_t
tqExpandTask
(
STQ
*
pTq
,
SStreamTask
*
pTask
,
int32_t
parallel
)
{
int32_t
tqExpandTask
(
STQ
*
pTq
,
SStreamTask
*
pTask
,
int32_t
parallel
)
{
if
(
pTask
->
execType
==
TASK_EXEC__NONE
)
return
0
;
if
(
pTask
->
execType
==
TASK_EXEC__NONE
)
return
0
;
...
...
source/dnode/vnode/src/tq/tqRead.c
浏览文件 @
162b3087
...
@@ -82,16 +82,7 @@ bool tqNextDataBlock(STqReadHandle* pHandle) {
...
@@ -82,16 +82,7 @@ bool tqNextDataBlock(STqReadHandle* pHandle) {
return
false
;
return
false
;
}
}
int
tqRetrieveDataBlockInfo
(
STqReadHandle
*
pHandle
,
SDataBlockInfo
*
pBlockInfo
)
{
int32_t
tqRetrieveDataBlock
(
SArray
**
ppCols
,
STqReadHandle
*
pHandle
,
uint64_t
*
pGroupId
,
int32_t
*
pNumOfRows
)
{
// currently only rows are used
pBlockInfo
->
numOfCols
=
taosArrayGetSize
(
pHandle
->
pColIdList
);
pBlockInfo
->
rows
=
pHandle
->
pBlock
->
numOfRows
;
// pBlockInfo->uid = pHandle->pBlock->uid; // the uid can not be assigned to pBlockData.
return
0
;
}
SArray
*
tqRetrieveDataBlock
(
STqReadHandle
*
pHandle
)
{
/*int32_t sversion = pHandle->pBlock->sversion;*/
/*int32_t sversion = pHandle->pBlock->sversion;*/
// TODO set to real sversion
// TODO set to real sversion
int32_t
sversion
=
0
;
int32_t
sversion
=
0
;
...
@@ -112,7 +103,7 @@ SArray* tqRetrieveDataBlock(STqReadHandle* pHandle) {
...
@@ -112,7 +103,7 @@ SArray* tqRetrieveDataBlock(STqReadHandle* pHandle) {
STSchema
*
pTschema
=
pHandle
->
pSchema
;
STSchema
*
pTschema
=
pHandle
->
pSchema
;
SSchemaWrapper
*
pSchemaWrapper
=
pHandle
->
pSchemaWrapper
;
SSchemaWrapper
*
pSchemaWrapper
=
pHandle
->
pSchemaWrapper
;
int32_t
n
umOfRows
=
pHandle
->
pBlock
->
numOfRows
;
*
pN
umOfRows
=
pHandle
->
pBlock
->
numOfRows
;
/*int32_t numOfCols = pHandle->pSchema->numOfCols;*/
/*int32_t numOfCols = pHandle->pSchema->numOfCols;*/
int32_t
colNumNeed
=
taosArrayGetSize
(
pHandle
->
pColIdList
);
int32_t
colNumNeed
=
taosArrayGetSize
(
pHandle
->
pColIdList
);
...
@@ -120,10 +111,11 @@ SArray* tqRetrieveDataBlock(STqReadHandle* pHandle) {
...
@@ -120,10 +111,11 @@ SArray* tqRetrieveDataBlock(STqReadHandle* pHandle) {
colNumNeed
=
pSchemaWrapper
->
nCols
;
colNumNeed
=
pSchemaWrapper
->
nCols
;
}
}
SArray
*
pArray
=
taosArrayInit
(
colNumNeed
,
sizeof
(
SColumnInfoData
));
*
ppCols
=
taosArrayInit
(
colNumNeed
,
sizeof
(
SColumnInfoData
));
if
(
pArray
==
NULL
)
{
if
(
*
ppCols
==
NULL
)
{
return
NULL
;
return
-
1
;
}
}
int32_t
colMeta
=
0
;
int32_t
colMeta
=
0
;
int32_t
colNeed
=
0
;
int32_t
colNeed
=
0
;
while
(
colMeta
<
pSchemaWrapper
->
nCols
&&
colNeed
<
colNumNeed
)
{
while
(
colMeta
<
pSchemaWrapper
->
nCols
&&
colNeed
<
colNumNeed
)
{
...
@@ -136,21 +128,24 @@ SArray* tqRetrieveDataBlock(STqReadHandle* pHandle) {
...
@@ -136,21 +128,24 @@ SArray* tqRetrieveDataBlock(STqReadHandle* pHandle) {
colNeed
++
;
colNeed
++
;
}
else
{
}
else
{
SColumnInfoData
colInfo
=
{
0
};
SColumnInfoData
colInfo
=
{
0
};
/*int sz = numOfRows * pColSchema->bytes;*/
colInfo
.
info
.
bytes
=
pColSchema
->
bytes
;
colInfo
.
info
.
bytes
=
pColSchema
->
bytes
;
colInfo
.
info
.
colId
=
pColSchema
->
colId
;
colInfo
.
info
.
colId
=
pColSchema
->
colId
;
colInfo
.
info
.
type
=
pColSchema
->
type
;
colInfo
.
info
.
type
=
pColSchema
->
type
;
if
(
colInfoDataEnsureCapacity
(
&
colInfo
,
0
,
numOfRows
)
<
0
)
{
if
(
colInfoDataEnsureCapacity
(
&
colInfo
,
0
,
*
pNumOfRows
)
<
0
)
{
taosArrayDestroyEx
(
pArray
,
(
void
(
*
)(
void
*
))
tDeleteSSDataBlock
);
goto
FAIL
;
return
NULL
;
}
}
taosArrayPush
(
pArray
,
&
colInfo
);
taosArrayPush
(
*
ppCols
,
&
colInfo
);
colMeta
++
;
colMeta
++
;
colNeed
++
;
colNeed
++
;
}
}
}
}
int32_t
colActual
=
taosArrayGetSize
(
*
ppCols
);
// TODO in stream shuffle case, fetch groupId
*
pGroupId
=
0
;
STSRowIter
iter
=
{
0
};
STSRowIter
iter
=
{
0
};
tdSTSRowIterInit
(
&
iter
,
pTschema
);
tdSTSRowIterInit
(
&
iter
,
pTschema
);
STSRow
*
row
;
STSRow
*
row
;
...
@@ -159,22 +154,22 @@ SArray* tqRetrieveDataBlock(STqReadHandle* pHandle) {
...
@@ -159,22 +154,22 @@ SArray* tqRetrieveDataBlock(STqReadHandle* pHandle) {
while
((
row
=
tGetSubmitBlkNext
(
&
pHandle
->
blkIter
))
!=
NULL
)
{
while
((
row
=
tGetSubmitBlkNext
(
&
pHandle
->
blkIter
))
!=
NULL
)
{
tdSTSRowIterReset
(
&
iter
,
row
);
tdSTSRowIterReset
(
&
iter
,
row
);
// get all wanted col of that block
// get all wanted col of that block
int32_t
colTot
=
taosArrayGetSize
(
pArray
);
for
(
int32_t
i
=
0
;
i
<
colActual
;
i
++
)
{
for
(
int32_t
i
=
0
;
i
<
colTot
;
i
++
)
{
SColumnInfoData
*
pColData
=
taosArrayGet
(
*
ppCols
,
i
);
SColumnInfoData
*
pColData
=
taosArrayGet
(
pArray
,
i
);
SCellVal
sVal
=
{
0
};
SCellVal
sVal
=
{
0
};
if
(
!
tdSTSRowIterNext
(
&
iter
,
pColData
->
info
.
colId
,
pColData
->
info
.
type
,
&
sVal
))
{
if
(
!
tdSTSRowIterNext
(
&
iter
,
pColData
->
info
.
colId
,
pColData
->
info
.
type
,
&
sVal
))
{
break
;
break
;
}
}
/*if (colDataAppend(pColData, curRow, sVal.val, false) < 0) {*/
if
(
colDataAppend
(
pColData
,
curRow
,
sVal
.
val
,
sVal
.
valType
==
TD_VTYPE_NULL
)
<
0
)
{
if
(
colDataAppend
(
pColData
,
curRow
,
sVal
.
val
,
sVal
.
valType
==
TD_VTYPE_NULL
)
<
0
)
{
taosArrayDestroyEx
(
pArray
,
(
void
(
*
)(
void
*
))
tDeleteSSDataBlock
);
goto
FAIL
;
return
NULL
;
}
}
}
}
curRow
++
;
curRow
++
;
}
}
return
pArray
;
return
0
;
FAIL:
taosArrayDestroy
(
*
ppCols
);
return
-
1
;
}
}
void
tqReadHandleSetColIdList
(
STqReadHandle
*
pReadHandle
,
SArray
*
pColIdList
)
{
pReadHandle
->
pColIdList
=
pColIdList
;
}
void
tqReadHandleSetColIdList
(
STqReadHandle
*
pReadHandle
,
SArray
*
pColIdList
)
{
pReadHandle
->
pColIdList
=
pColIdList
;
}
...
...
source/dnode/vnode/src/tsdb/tsdbRead.c
浏览文件 @
162b3087
...
@@ -3260,6 +3260,9 @@ int32_t tsdbRetrieveDataBlockStatisInfo(tsdbReaderT* pTsdbReadHandle, SColumnDat
...
@@ -3260,6 +3260,9 @@ int32_t tsdbRetrieveDataBlockStatisInfo(tsdbReaderT* pTsdbReadHandle, SColumnDat
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
tsdbDebug
(
"vgId:%d succeed to load block statis part for uid %"
PRIu64
,
REPO_ID
(
pHandle
->
pTsdb
),
TSDB_READ_TABLE_UID
(
&
pHandle
->
rhelper
));
int16_t
*
colIds
=
pHandle
->
defaultLoadColumn
->
pData
;
int16_t
*
colIds
=
pHandle
->
defaultLoadColumn
->
pData
;
size_t
numOfCols
=
QH_GET_NUM_OF_COLS
(
pHandle
);
size_t
numOfCols
=
QH_GET_NUM_OF_COLS
(
pHandle
);
...
...
source/dnode/vnode/src/tsdb/tsdbReadImpl.c
浏览文件 @
162b3087
...
@@ -322,15 +322,18 @@ int tsdbLoadBlockStatis(SReadH *pReadh, SBlock *pBlock) {
...
@@ -322,15 +322,18 @@ int tsdbLoadBlockStatis(SReadH *pReadh, SBlock *pBlock) {
ASSERT
(
pBlock
->
numOfSubBlocks
<=
1
);
ASSERT
(
pBlock
->
numOfSubBlocks
<=
1
);
if
(
!
pBlock
->
aggrStat
)
{
if
(
!
pBlock
->
aggrStat
)
{
tsdbDebug
(
"vgId:%d no need to load block statis part for uid %"
PRIu64
" since not exist"
,
REPO_ID
(
pReadh
->
pRepo
),
TSDB_READ_TABLE_UID
(
pReadh
));
return
TSDB_STATIS_NONE
;
return
TSDB_STATIS_NONE
;
}
}
SDFile
*
pDFileAggr
=
pBlock
->
last
?
TSDB_READ_SMAL_FILE
(
pReadh
)
:
TSDB_READ_SMAD_FILE
(
pReadh
);
SDFile
*
pDFileAggr
=
pBlock
->
last
?
TSDB_READ_SMAL_FILE
(
pReadh
)
:
TSDB_READ_SMAD_FILE
(
pReadh
);
if
(
tsdbSeekDFile
(
pDFileAggr
,
pBlock
->
aggrOffset
,
SEEK_SET
)
<
0
)
{
if
(
tsdbSeekDFile
(
pDFileAggr
,
pBlock
->
aggrOffset
,
SEEK_SET
)
<
0
)
{
tsdbError
(
"vgId:%d failed to load block aggr part while seek file %s to offset %"
PRIu64
" since %s"
,
tsdbError
(
"vgId:%d failed to load block statis part for uid %"
PRIu64
" while seek file %s to offset %"
PRIu64
TSDB_READ_REPO_ID
(
pReadh
),
TSDB_FILE_FULL_NAME
(
pDFileAggr
),
(
uint64_t
)
pBlock
->
aggrOffset
,
" since %s"
,
tstrerror
(
terrno
));
TSDB_READ_REPO_ID
(
pReadh
),
TSDB_READ_TABLE_UID
(
pReadh
),
TSDB_FILE_FULL_NAME
(
pDFileAggr
),
(
uint64_t
)
pBlock
->
aggrOffset
,
tstrerror
(
terrno
));
return
-
1
;
return
-
1
;
}
}
...
@@ -339,25 +342,28 @@ int tsdbLoadBlockStatis(SReadH *pReadh, SBlock *pBlock) {
...
@@ -339,25 +342,28 @@ int tsdbLoadBlockStatis(SReadH *pReadh, SBlock *pBlock) {
int64_t
nreadAggr
=
tsdbReadDFile
(
pDFileAggr
,
(
void
*
)(
pReadh
->
pAggrBlkData
),
sizeAggr
);
int64_t
nreadAggr
=
tsdbReadDFile
(
pDFileAggr
,
(
void
*
)(
pReadh
->
pAggrBlkData
),
sizeAggr
);
if
(
nreadAggr
<
0
)
{
if
(
nreadAggr
<
0
)
{
tsdbError
(
"vgId:%d failed to load block aggr part while read file %s since %s, offset:%"
PRIu64
" len :%"
PRIzu
,
tsdbError
(
"vgId:%d failed to load block statis part for uid %"
PRIu64
TSDB_READ_REPO_ID
(
pReadh
),
TSDB_FILE_FULL_NAME
(
pDFileAggr
),
tstrerror
(
terrno
),
" while read file %s since %s, offset:%"
PRIu64
" len :%"
PRIzu
,
(
uint64_t
)
pBlock
->
aggrOffset
,
sizeAggr
);
TSDB_READ_REPO_ID
(
pReadh
),
TSDB_READ_TABLE_UID
(
pReadh
),
TSDB_FILE_FULL_NAME
(
pDFileAggr
),
tstrerror
(
terrno
),
(
uint64_t
)
pBlock
->
aggrOffset
,
sizeAggr
);
return
-
1
;
return
-
1
;
}
}
if
(
nreadAggr
<
sizeAggr
)
{
if
(
nreadAggr
<
sizeAggr
)
{
terrno
=
TSDB_CODE_TDB_FILE_CORRUPTED
;
terrno
=
TSDB_CODE_TDB_FILE_CORRUPTED
;
tsdbError
(
"vgId:%d block
aggr part in file %s is corrupted, offset:%"
PRIu64
" expected bytes:%"
PRIzu
tsdbError
(
"vgId:%d block
statis part for uid %"
PRIu64
" in file %s is corrupted, offset:%"
PRIu64
" read bytes: %"
PRId64
,
"
expected bytes:%"
PRIzu
"
read bytes: %"
PRId64
,
TSDB_READ_REPO_ID
(
pReadh
),
TSDB_
FILE_FULL_NAME
(
pDFileAggr
),
(
uint64_t
)
pBlock
->
aggrOffset
,
sizeAggr
,
TSDB_READ_REPO_ID
(
pReadh
),
TSDB_
READ_TABLE_UID
(
pReadh
),
TSDB_FILE_FULL_NAME
(
pDFileAggr
)
,
nreadAggr
);
(
uint64_t
)
pBlock
->
aggrOffset
,
sizeAggr
,
nreadAggr
);
return
-
1
;
return
-
1
;
}
}
if
(
!
taosCheckChecksumWhole
((
uint8_t
*
)(
pReadh
->
pAggrBlkData
),
(
uint32_t
)
sizeAggr
))
{
if
(
!
taosCheckChecksumWhole
((
uint8_t
*
)(
pReadh
->
pAggrBlkData
),
(
uint32_t
)
sizeAggr
))
{
terrno
=
TSDB_CODE_TDB_FILE_CORRUPTED
;
terrno
=
TSDB_CODE_TDB_FILE_CORRUPTED
;
tsdbError
(
"vgId:%d block aggr part in file %s is corrupted since wrong checksum, offset:%"
PRIu64
" len :%"
PRIzu
,
tsdbError
(
"vgId:%d block statis part for uid %"
PRIu64
TSDB_READ_REPO_ID
(
pReadh
),
TSDB_FILE_FULL_NAME
(
pDFileAggr
),
(
uint64_t
)
pBlock
->
aggrOffset
,
sizeAggr
);
"in file %s is corrupted since wrong checksum, offset:%"
PRIu64
" len :%"
PRIzu
,
TSDB_READ_REPO_ID
(
pReadh
),
TSDB_READ_TABLE_UID
(
pReadh
),
TSDB_FILE_FULL_NAME
(
pDFileAggr
),
(
uint64_t
)
pBlock
->
aggrOffset
,
sizeAggr
);
return
-
1
;
return
-
1
;
}
}
return
0
;
return
0
;
...
@@ -367,7 +373,7 @@ static int tsdbLoadBlockOffset(SReadH *pReadh, SBlock *pBlock) {
...
@@ -367,7 +373,7 @@ static int tsdbLoadBlockOffset(SReadH *pReadh, SBlock *pBlock) {
ASSERT
(
pBlock
->
numOfSubBlocks
<=
1
);
ASSERT
(
pBlock
->
numOfSubBlocks
<=
1
);
SDFile
*
pDFile
=
(
pBlock
->
last
)
?
TSDB_READ_LAST_FILE
(
pReadh
)
:
TSDB_READ_DATA_FILE
(
pReadh
);
SDFile
*
pDFile
=
(
pBlock
->
last
)
?
TSDB_READ_LAST_FILE
(
pReadh
)
:
TSDB_READ_DATA_FILE
(
pReadh
);
if
(
tsdbSeekDFile
(
pDFile
,
pBlock
->
offset
,
SEEK_SET
)
<
0
)
{
if
(
tsdbSeekDFile
(
pDFile
,
pBlock
->
offset
,
SEEK_SET
)
<
0
)
{
tsdbError
(
"vgId:%d failed to load block
statis
part while seek file %s to offset %"
PRId64
" since %s"
,
tsdbError
(
"vgId:%d failed to load block
head
part while seek file %s to offset %"
PRId64
" since %s"
,
TSDB_READ_REPO_ID
(
pReadh
),
TSDB_FILE_FULL_NAME
(
pDFile
),
(
int64_t
)
pBlock
->
offset
,
tstrerror
(
terrno
));
TSDB_READ_REPO_ID
(
pReadh
),
TSDB_FILE_FULL_NAME
(
pDFile
),
(
int64_t
)
pBlock
->
offset
,
tstrerror
(
terrno
));
return
-
1
;
return
-
1
;
}
}
...
@@ -377,14 +383,14 @@ static int tsdbLoadBlockOffset(SReadH *pReadh, SBlock *pBlock) {
...
@@ -377,14 +383,14 @@ static int tsdbLoadBlockOffset(SReadH *pReadh, SBlock *pBlock) {
int64_t
nread
=
tsdbReadDFile
(
pDFile
,
(
void
*
)(
pReadh
->
pBlkData
),
size
);
int64_t
nread
=
tsdbReadDFile
(
pDFile
,
(
void
*
)(
pReadh
->
pBlkData
),
size
);
if
(
nread
<
0
)
{
if
(
nread
<
0
)
{
tsdbError
(
"vgId:%d failed to load block
statis
part while read file %s since %s, offset:%"
PRId64
" len :%"
PRIzu
,
tsdbError
(
"vgId:%d failed to load block
head
part while read file %s since %s, offset:%"
PRId64
" len :%"
PRIzu
,
TSDB_READ_REPO_ID
(
pReadh
),
TSDB_FILE_FULL_NAME
(
pDFile
),
tstrerror
(
terrno
),
(
int64_t
)
pBlock
->
offset
,
size
);
TSDB_READ_REPO_ID
(
pReadh
),
TSDB_FILE_FULL_NAME
(
pDFile
),
tstrerror
(
terrno
),
(
int64_t
)
pBlock
->
offset
,
size
);
return
-
1
;
return
-
1
;
}
}
if
(
nread
<
size
)
{
if
(
nread
<
size
)
{
terrno
=
TSDB_CODE_TDB_FILE_CORRUPTED
;
terrno
=
TSDB_CODE_TDB_FILE_CORRUPTED
;
tsdbError
(
"vgId:%d block
statis
part in file %s is corrupted, offset:%"
PRId64
" expected bytes:%"
PRIzu
tsdbError
(
"vgId:%d block
head
part in file %s is corrupted, offset:%"
PRId64
" expected bytes:%"
PRIzu
" read bytes: %"
PRId64
,
" read bytes: %"
PRId64
,
TSDB_READ_REPO_ID
(
pReadh
),
TSDB_FILE_FULL_NAME
(
pDFile
),
(
int64_t
)
pBlock
->
offset
,
size
,
nread
);
TSDB_READ_REPO_ID
(
pReadh
),
TSDB_FILE_FULL_NAME
(
pDFile
),
(
int64_t
)
pBlock
->
offset
,
size
,
nread
);
return
-
1
;
return
-
1
;
...
@@ -392,7 +398,7 @@ static int tsdbLoadBlockOffset(SReadH *pReadh, SBlock *pBlock) {
...
@@ -392,7 +398,7 @@ static int tsdbLoadBlockOffset(SReadH *pReadh, SBlock *pBlock) {
if
(
!
taosCheckChecksumWhole
((
uint8_t
*
)(
pReadh
->
pBlkData
),
(
uint32_t
)
size
))
{
if
(
!
taosCheckChecksumWhole
((
uint8_t
*
)(
pReadh
->
pBlkData
),
(
uint32_t
)
size
))
{
terrno
=
TSDB_CODE_TDB_FILE_CORRUPTED
;
terrno
=
TSDB_CODE_TDB_FILE_CORRUPTED
;
tsdbError
(
"vgId:%d block
statis
part in file %s is corrupted since wrong checksum, offset:%"
PRId64
" len :%"
PRIzu
,
tsdbError
(
"vgId:%d block
head
part in file %s is corrupted since wrong checksum, offset:%"
PRId64
" len :%"
PRIzu
,
TSDB_READ_REPO_ID
(
pReadh
),
TSDB_FILE_FULL_NAME
(
pDFile
),
(
int64_t
)
pBlock
->
offset
,
size
);
TSDB_READ_REPO_ID
(
pReadh
),
TSDB_FILE_FULL_NAME
(
pDFile
),
(
int64_t
)
pBlock
->
offset
,
size
);
return
-
1
;
return
-
1
;
}
}
...
@@ -546,7 +552,7 @@ static int tsdbLoadBlockDataImpl(SReadH *pReadh, SBlock *pBlock, SDataCols *pDat
...
@@ -546,7 +552,7 @@ static int tsdbLoadBlockDataImpl(SReadH *pReadh, SBlock *pBlock, SDataCols *pDat
int32_t
tsize
=
(
int32_t
)
tsdbBlockStatisSize
(
pBlock
->
numOfCols
,
(
uint32_t
)
pBlock
->
blkVer
);
int32_t
tsize
=
(
int32_t
)
tsdbBlockStatisSize
(
pBlock
->
numOfCols
,
(
uint32_t
)
pBlock
->
blkVer
);
if
(
!
taosCheckChecksumWhole
((
uint8_t
*
)
TSDB_READ_BUF
(
pReadh
),
tsize
))
{
if
(
!
taosCheckChecksumWhole
((
uint8_t
*
)
TSDB_READ_BUF
(
pReadh
),
tsize
))
{
terrno
=
TSDB_CODE_TDB_FILE_CORRUPTED
;
terrno
=
TSDB_CODE_TDB_FILE_CORRUPTED
;
tsdbError
(
"vgId:%d block
statis
part in file %s is corrupted since wrong checksum, offset:%"
PRId64
" len :%d"
,
tsdbError
(
"vgId:%d block
head
part in file %s is corrupted since wrong checksum, offset:%"
PRId64
" len :%d"
,
TSDB_READ_REPO_ID
(
pReadh
),
TSDB_FILE_FULL_NAME
(
pDFile
),
(
int64_t
)
pBlock
->
offset
,
tsize
);
TSDB_READ_REPO_ID
(
pReadh
),
TSDB_FILE_FULL_NAME
(
pDFile
),
(
int64_t
)
pBlock
->
offset
,
tsize
);
return
-
1
;
return
-
1
;
}
}
...
...
source/dnode/vnode/src/tsdb/tsdbSma.c
浏览文件 @
162b3087
...
@@ -643,6 +643,7 @@ int32_t tsdbUpdateExpiredWindowImpl(STsdb *pTsdb, SSubmitReq *pMsg, int64_t vers
...
@@ -643,6 +643,7 @@ int32_t tsdbUpdateExpiredWindowImpl(STsdb *pTsdb, SSubmitReq *pMsg, int64_t vers
SSubmitMsgIter
msgIter
=
{
0
};
SSubmitMsgIter
msgIter
=
{
0
};
SSubmitBlk
*
pBlock
=
NULL
;
SSubmitBlk
*
pBlock
=
NULL
;
SInterval
interval
=
{
0
};
SInterval
interval
=
{
0
};
TSKEY
lastWinSKey
=
INT64_MIN
;
if
(
tInitSubmitMsgIter
(
pMsg
,
&
msgIter
)
!=
TSDB_CODE_SUCCESS
)
{
if
(
tInitSubmitMsgIter
(
pMsg
,
&
msgIter
)
!=
TSDB_CODE_SUCCESS
)
{
return
TSDB_CODE_FAILED
;
return
TSDB_CODE_FAILED
;
...
@@ -657,7 +658,7 @@ int32_t tsdbUpdateExpiredWindowImpl(STsdb *pTsdb, SSubmitReq *pMsg, int64_t vers
...
@@ -657,7 +658,7 @@ int32_t tsdbUpdateExpiredWindowImpl(STsdb *pTsdb, SSubmitReq *pMsg, int64_t vers
SSubmitBlkIter
blkIter
=
{
0
};
SSubmitBlkIter
blkIter
=
{
0
};
if
(
tInitSubmitBlkIter
(
pBlock
,
&
blkIter
)
!=
TSDB_CODE_SUCCESS
)
{
if
(
tInitSubmitBlkIter
(
pBlock
,
&
blkIter
)
!=
TSDB_CODE_SUCCESS
)
{
tdFreeTSmaWrapper
(
pSW
);
pSW
=
tdFreeTSmaWrapper
(
pSW
);
break
;
break
;
}
}
...
@@ -667,31 +668,37 @@ int32_t tsdbUpdateExpiredWindowImpl(STsdb *pTsdb, SSubmitReq *pMsg, int64_t vers
...
@@ -667,31 +668,37 @@ int32_t tsdbUpdateExpiredWindowImpl(STsdb *pTsdb, SSubmitReq *pMsg, int64_t vers
tdFreeTSmaWrapper
(
pSW
);
tdFreeTSmaWrapper
(
pSW
);
break
;
break
;
}
}
if
(
pSW
==
NULL
)
{
if
(
!
pSW
||
(
pTSma
->
tableUid
!=
pBlock
->
suid
))
{
if
(
pSW
)
{
pSW
=
tdFreeTSmaWrapper
(
pSW
);
}
if
((
pSW
=
metaGetSmaInfoByTable
(
REPO_META
(
pTsdb
),
pBlock
->
suid
))
==
NULL
)
{
if
((
pSW
=
metaGetSmaInfoByTable
(
REPO_META
(
pTsdb
),
pBlock
->
suid
))
==
NULL
)
{
break
;
break
;
}
}
if
((
pSW
->
number
)
<=
0
||
(
pSW
->
tSma
==
NULL
))
{
if
((
pSW
->
number
)
<=
0
||
(
pSW
->
tSma
==
NULL
))
{
tdFreeTSmaWrapper
(
pSW
);
pSW
=
tdFreeTSmaWrapper
(
pSW
);
break
;
break
;
}
}
pTSma
=
pSW
->
tSma
;
pTSma
=
pSW
->
tSma
;
}
interval
.
interval
=
pTSma
->
interval
;
interval
.
interval
=
pTSma
->
interval
;
interval
.
intervalUnit
=
pTSma
->
intervalUnit
;
interval
.
intervalUnit
=
pTSma
->
intervalUnit
;
interval
.
offset
=
pTSma
->
offset
;
interval
.
offset
=
pTSma
->
offset
;
interval
.
precision
=
REPO_CFG
(
pTsdb
)
->
precision
;
interval
.
precision
=
REPO_CFG
(
pTsdb
)
->
precision
;
interval
.
sliding
=
pTSma
->
sliding
;
interval
.
sliding
=
pTSma
->
sliding
;
interval
.
slidingUnit
=
pTSma
->
slidingUnit
;
interval
.
slidingUnit
=
pTSma
->
slidingUnit
;
}
TSKEY
winSKey
=
taosTimeTruncate
(
TD_ROW_KEY
(
row
),
&
interval
,
interval
.
precision
);
TSKEY
winSKey
=
taosTimeTruncate
(
TD_ROW_KEY
(
row
),
&
interval
,
interval
.
precision
);
tsdbSetExpiredWindow
(
pTsdb
,
pItemsHash
,
pTSma
->
indexUid
,
winSKey
,
version
);
if
(
lastWinSKey
!=
winSKey
)
{
lastWinSKey
=
winSKey
;
// TODO: release only when suid changes.
tsdbSetExpiredWindow
(
pTsdb
,
pItemsHash
,
pTSma
->
indexUid
,
winSKey
,
version
);
tdDestroyTSmaWrapper
(
pSW
);
}
else
{
taosMemoryFreeClear
(
pSW
);
tsdbDebug
(
"vgId:%d smaIndex %"
PRIi64
", put skey %"
PRIi64
" to expire window ignore as duplicated"
,
REPO_ID
(
pTsdb
),
pTSma
->
indexUid
,
winSKey
);
}
}
}
}
}
...
...
source/dnode/vnode/src/vnd/vnodeSvr.c
浏览文件 @
162b3087
...
@@ -215,10 +215,21 @@ static int vnodeProcessCreateStbReq(SVnode *pVnode, void *pReq) {
...
@@ -215,10 +215,21 @@ static int vnodeProcessCreateStbReq(SVnode *pVnode, void *pReq) {
return
-
1
;
return
-
1
;
}
}
// TODO: remove the debug log
SRSmaParam
*
param
=
vCreateTbReq
.
stbCfg
.
pRSmaParam
;
if
(
param
)
{
printf
(
"qmsg1 len = %d, body = %s
\n
"
,
param
->
qmsg1
?
(
int32_t
)
strlen
(
param
->
qmsg1
)
:
0
,
param
->
qmsg1
?
param
->
qmsg1
:
""
);
printf
(
"qmsg1 len = %d, body = %s
\n
"
,
param
->
qmsg2
?
(
int32_t
)
strlen
(
param
->
qmsg2
)
:
0
,
param
->
qmsg2
?
param
->
qmsg2
:
""
);
}
taosMemoryFree
(
vCreateTbReq
.
stbCfg
.
pSchema
);
taosMemoryFree
(
vCreateTbReq
.
stbCfg
.
pSchema
);
taosMemoryFree
(
vCreateTbReq
.
stbCfg
.
pTagSchema
);
taosMemoryFree
(
vCreateTbReq
.
stbCfg
.
pTagSchema
);
if
(
vCreateTbReq
.
stbCfg
.
pRSmaParam
)
{
if
(
vCreateTbReq
.
stbCfg
.
pRSmaParam
)
{
taosMemoryFree
(
vCreateTbReq
.
stbCfg
.
pRSmaParam
->
pFuncIds
);
taosMemoryFree
(
vCreateTbReq
.
stbCfg
.
pRSmaParam
->
pFuncIds
);
taosMemoryFree
(
vCreateTbReq
.
stbCfg
.
pRSmaParam
->
qmsg1
);
taosMemoryFree
(
vCreateTbReq
.
stbCfg
.
pRSmaParam
->
qmsg2
);
taosMemoryFree
(
vCreateTbReq
.
stbCfg
.
pRSmaParam
);
taosMemoryFree
(
vCreateTbReq
.
stbCfg
.
pRSmaParam
);
}
}
taosMemoryFree
(
vCreateTbReq
.
name
);
taosMemoryFree
(
vCreateTbReq
.
name
);
...
...
source/libs/executor/inc/executorimpl.h
浏览文件 @
162b3087
...
@@ -382,7 +382,7 @@ typedef struct SSysTableScanInfo {
...
@@ -382,7 +382,7 @@ typedef struct SSysTableScanInfo {
void
*
pCur
;
// cursor for iterate the local table meta store.
void
*
pCur
;
// cursor for iterate the local table meta store.
SArray
*
scanCols
;
// SArray<int16_t> scan column id list
SArray
*
scanCols
;
// SArray<int16_t> scan column id list
int32_t
type
;
// show type, TODO remove it
//
int32_t type; // show type, TODO remove it
SName
name
;
SName
name
;
SSDataBlock
*
pRes
;
SSDataBlock
*
pRes
;
int32_t
capacity
;
int32_t
capacity
;
...
@@ -479,7 +479,7 @@ typedef struct {
...
@@ -479,7 +479,7 @@ typedef struct {
typedef
struct
SGroupbyOperatorInfo
{
typedef
struct
SGroupbyOperatorInfo
{
SOptrBasicInfo
binfo
;
SOptrBasicInfo
binfo
;
SArray
*
pGroupCols
;
SArray
*
pGroupCols
;
// group by columns, SArray<SColumn>
SArray
*
pGroupColVals
;
// current group column values, SArray<SGroupKeys>
SArray
*
pGroupColVals
;
// current group column values, SArray<SGroupKeys>
SNode
*
pCondition
;
SNode
*
pCondition
;
bool
isInit
;
// denote if current val is initialized or not
bool
isInit
;
// denote if current val is initialized or not
...
@@ -600,7 +600,6 @@ typedef struct SJoinOperatorInfo {
...
@@ -600,7 +600,6 @@ typedef struct SJoinOperatorInfo {
int32_t
rightPos
;
int32_t
rightPos
;
SColumnInfo
rightCol
;
SColumnInfo
rightCol
;
SNode
*
pOnCondition
;
SNode
*
pOnCondition
;
// SRspResultInfo resultInfo;
}
SJoinOperatorInfo
;
}
SJoinOperatorInfo
;
int32_t
operatorDummyOpenFn
(
SOperatorInfo
*
pOperator
);
int32_t
operatorDummyOpenFn
(
SOperatorInfo
*
pOperator
);
...
...
source/libs/executor/src/executorimpl.c
浏览文件 @
162b3087
...
@@ -1087,6 +1087,7 @@ static int32_t doSetInputDataBlock(SOperatorInfo* pOperator, SqlFunctionCtx* pCt
...
@@ -1087,6 +1087,7 @@ static int32_t doSetInputDataBlock(SOperatorInfo* pOperator, SqlFunctionCtx* pCt
pCtx
[
i
].
currentStage
=
MAIN_SCAN
;
pCtx
[
i
].
currentStage
=
MAIN_SCAN
;
SInputColumnInfoData
*
pInput
=
&
pCtx
[
i
].
input
;
SInputColumnInfoData
*
pInput
=
&
pCtx
[
i
].
input
;
pInput
->
uid
=
pBlock
->
info
.
uid
;
SExprInfo
*
pOneExpr
=
&
pOperator
->
pExpr
[
i
];
SExprInfo
*
pOneExpr
=
&
pOperator
->
pExpr
[
i
];
for
(
int32_t
j
=
0
;
j
<
pOneExpr
->
base
.
numOfParams
;
++
j
)
{
for
(
int32_t
j
=
0
;
j
<
pOneExpr
->
base
.
numOfParams
;
++
j
)
{
...
@@ -1101,7 +1102,9 @@ static int32_t doSetInputDataBlock(SOperatorInfo* pOperator, SqlFunctionCtx* pCt
...
@@ -1101,7 +1102,9 @@ static int32_t doSetInputDataBlock(SOperatorInfo* pOperator, SqlFunctionCtx* pCt
pInput
->
pPTS
=
taosArrayGet
(
pBlock
->
pDataBlock
,
0
);
// todo set the correct timestamp column
pInput
->
pPTS
=
taosArrayGet
(
pBlock
->
pDataBlock
,
0
);
// todo set the correct timestamp column
ASSERT
(
pInput
->
pData
[
j
]
!=
NULL
);
ASSERT
(
pInput
->
pData
[
j
]
!=
NULL
);
}
else
if
(
pFuncParam
->
type
==
FUNC_PARAM_TYPE_VALUE
)
{
}
else
if
(
pFuncParam
->
type
==
FUNC_PARAM_TYPE_VALUE
)
{
if
(
createDummyCol
)
{
// todo avoid case: top(k, 12), 12 is the value parameter.
// sum(11), 11 is also the value parameter.
if
(
createDummyCol
&&
pOneExpr
->
base
.
numOfParams
==
1
)
{
code
=
doCreateConstantValColumnInfo
(
pInput
,
pFuncParam
,
pFuncParam
->
param
.
nType
,
j
,
pBlock
->
info
.
rows
);
code
=
doCreateConstantValColumnInfo
(
pInput
,
pFuncParam
,
pFuncParam
->
param
.
nType
,
j
,
pBlock
->
info
.
rows
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
return
code
;
return
code
;
...
@@ -1876,67 +1879,58 @@ SqlFunctionCtx* createSqlFunctionCtx(SExprInfo* pExprInfo, int32_t numOfOutput,
...
@@ -1876,67 +1879,58 @@ SqlFunctionCtx* createSqlFunctionCtx(SExprInfo* pExprInfo, int32_t numOfOutput,
}
}
}
}
pCtx
->
resDataInfo
.
interBufSize
=
env
.
calcMemSize
;
pCtx
->
resDataInfo
.
interBufSize
=
env
.
calcMemSize
;
}
else
if
(
pExpr
->
pExpr
->
nodeType
==
QUERY_NODE_COLUMN
||
pExpr
->
pExpr
->
nodeType
==
QUERY_NODE_OPERATOR
||
pExpr
->
pExpr
->
nodeType
==
QUERY_NODE_VALUE
)
{
}
else
if
(
pExpr
->
pExpr
->
nodeType
==
QUERY_NODE_COLUMN
||
pExpr
->
pExpr
->
nodeType
==
QUERY_NODE_OPERATOR
||
pCtx
->
resDataInfo
.
interBufSize
=
pFunct
->
resSchema
.
bytes
;
// for simple column, the intermediate buffer needs to hold one element.
pExpr
->
pExpr
->
nodeType
==
QUERY_NODE_VALUE
)
{
// for simple column, the intermediate buffer needs to hold one element.
pCtx
->
resDataInfo
.
interBufSize
=
pFunct
->
resSchema
.
bytes
;
}
}
pCtx
->
input
.
numOfInputCols
=
pFunct
->
numOfParams
;
pCtx
->
input
.
numOfInputCols
=
pFunct
->
numOfParams
;
pCtx
->
input
.
pData
=
taosMemoryCalloc
(
pFunct
->
numOfParams
,
POINTER_BYTES
);
pCtx
->
input
.
pData
=
taosMemoryCalloc
(
pFunct
->
numOfParams
,
POINTER_BYTES
);
pCtx
->
input
.
pColumnDataAgg
=
taosMemoryCalloc
(
pFunct
->
numOfParams
,
POINTER_BYTES
);
pCtx
->
input
.
pColumnDataAgg
=
taosMemoryCalloc
(
pFunct
->
numOfParams
,
POINTER_BYTES
);
pCtx
->
pTsOutput
=
NULL
;
pCtx
->
pTsOutput
=
NULL
;
pCtx
->
resDataInfo
.
bytes
=
pFunct
->
resSchema
.
bytes
;
pCtx
->
resDataInfo
.
bytes
=
pFunct
->
resSchema
.
bytes
;
pCtx
->
resDataInfo
.
type
=
pFunct
->
resSchema
.
type
;
pCtx
->
resDataInfo
.
type
=
pFunct
->
resSchema
.
type
;
pCtx
->
order
=
TSDB_ORDER_ASC
;
pCtx
->
order
=
TSDB_ORDER_ASC
;
pCtx
->
start
.
key
=
INT64_MIN
;
pCtx
->
start
.
key
=
INT64_MIN
;
pCtx
->
end
.
key
=
INT64_MIN
;
pCtx
->
end
.
key
=
INT64_MIN
;
#if 0
pCtx
->
numOfParams
=
pExpr
->
base
.
numOfParams
;
for (int32_t j = 0; j < pCtx->numOfParams; ++j) {
// int16_t type = pFunct->param[j].nType
;
pCtx
->
param
=
pFunct
->
pParam
;
//
int16_t bytes = pFunct->param[j].nLen;
//
for (int32_t j = 0; j < pCtx->numOfParams; ++j) {
// // set the order information for top/bottom query
// i
f (type == TSDB_DATA_TYPE_BINARY || type == TSDB_DATA_TYPE_NCHAR) {
// i
nt32_t functionId = pCtx->functionId;
//
taosVariantCreateFromBinary(&pCtx->param[j], pFunct->param[j].pz, bytes, type);
//
if (functionId == FUNCTION_TOP || functionId == FUNCTION_BOTTOM || functionId == FUNCTION_DIFF) {
//
} else {
//
int32_t f = getExprFunctionId(&pExpr[0]);
//
taosVariantCreateFromBinary(&pCtx->param[j], (char *)&pFunct->param[j].i, bytes, type
);
//
assert(f == FUNCTION_TS || f == FUNCTION_TS_DUMMY
);
//
}
//
}
// // pCtx->param[2].i = pQueryAttr->order.order;
// // pCtx->param[2].nType = TSDB_DATA_TYPE_BIGINT;
// set the order information for top/bottom query
// // pCtx->param[3].i = functionId;
int32_t functionId = pCtx->functionId
;
// // pCtx->param[3].nType = TSDB_DATA_TYPE_BIGINT
;
if (functionId == FUNCTION_TOP || functionId == FUNCTION_BOTTOM || functionId == FUNCTION_DIFF) {
//
int32_t f = getExprFunctionId(&pExpr[0])
;
// // pCtx->param[1].i = pQueryAttr->order.col.info.colId
;
assert(f == FUNCTION_TS || f == FUNCTION_TS_DUMMY);
// } else if (functionId == FUNCTION_INTERP) {
// // pCtx->param[2].i = (int8_t)pQueryAttr->fillType;
//
pCtx->param[2].i = pQueryAttr->order.order;
//
// if (pQueryAttr->fillVal != NULL) {
pCtx->param[2].nType = TSDB_DATA_TYPE_BIGINT;
// // if (isNull((const char *)&pQueryAttr->fillVal[i], pCtx->inputType)) {
pCtx->param[3].i = functionId
;
// // pCtx->param[1].nType = TSDB_DATA_TYPE_NULL
;
pCtx->param[3].nType = TSDB_DATA_TYPE_BIGINT;
// // } else { // todo refactor, taosVariantCreateFromBinary should handle the NULL value
// // if (pCtx->inputType != TSDB_DATA_TYPE_BINARY && pCtx->inputType != TSDB_DATA_TYPE_NCHAR) {
//
pCtx->param[1].i = pQueryAttr->order.col.info.colId
;
//
// taosVariantCreateFromBinary(&pCtx->param[1], (char *)&pQueryAttr->fillVal[i], pCtx->inputBytes, pCtx->inputType)
;
} else if (functionId == FUNCTION_INTERP) {
// // }
//
pCtx->param[2].i = (int8_t)pQueryAttr->fillType;
//
// }
//
if (pQueryAttr->fillVal != NULL) {
//
// }
//
if (isNull((const char *)&pQueryAttr->fillVal[i], pCtx->inputType)
) {
//
} else if (functionId == FUNCTION_TWA
) {
//
pCtx->param[1].nType = TSDB_DATA_TYPE_NULL
;
//
// pCtx->param[1].i = pQueryAttr->window.skey
;
//
} else { // todo refactor, taosVariantCreateFromBinary should handle the NULL value
//
// pCtx->param[1].nType = TSDB_DATA_TYPE_BIGINT;
//
if (pCtx->inputType != TSDB_DATA_TYPE_BINARY && pCtx->inputType != TSDB_DATA_TYPE_NCHAR) {
//
// pCtx->param[2].i = pQueryAttr->window.ekey;
//
taosVariantCreateFromBinary(&pCtx->param[1], (char *)&pQueryAttr->fillVal[i], pCtx->inputBytes, pCtx->inputType)
;
//
// pCtx->param[2].nType = TSDB_DATA_TYPE_BIGINT
;
//
}
//
} else if (functionId == FUNCTION_ARITHM) {
//
}
//
// pCtx->param[1].pz = (char*) getScalarFuncSupport(pRuntimeEnv->scalarSup, i);
// }
// }
} else if (functionId == FUNCTION_TS_COMP) {
// }
// pCtx->param[0].i = pQueryAttr->vgId; //TODO this should be the parameter from client
pCtx->param[0].nType = TSDB_DATA_TYPE_BIGINT;
} else if (functionId == FUNCTION_TWA) {
// pCtx->param[1].i = pQueryAttr->window.skey;
pCtx->param[1].nType = TSDB_DATA_TYPE_BIGINT;
// pCtx->param[2].i = pQueryAttr->window.ekey;
pCtx->param[2].nType = TSDB_DATA_TYPE_BIGINT;
} else if (functionId == FUNCTION_ARITHM) {
// pCtx->param[1].pz = (char*) getScalarFuncSupport(pRuntimeEnv->scalarSup, i);
}
#endif
}
}
for
(
int32_t
i
=
1
;
i
<
numOfOutput
;
++
i
)
{
for
(
int32_t
i
=
1
;
i
<
numOfOutput
;
++
i
)
{
...
@@ -1955,7 +1949,7 @@ static void* destroySqlFunctionCtx(SqlFunctionCtx* pCtx, int32_t numOfOutput) {
...
@@ -1955,7 +1949,7 @@ static void* destroySqlFunctionCtx(SqlFunctionCtx* pCtx, int32_t numOfOutput) {
for
(
int32_t
i
=
0
;
i
<
numOfOutput
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
numOfOutput
;
++
i
)
{
for
(
int32_t
j
=
0
;
j
<
pCtx
[
i
].
numOfParams
;
++
j
)
{
for
(
int32_t
j
=
0
;
j
<
pCtx
[
i
].
numOfParams
;
++
j
)
{
taosVariantDestroy
(
&
pCtx
[
i
].
param
[
j
]);
taosVariantDestroy
(
&
pCtx
[
i
].
param
[
j
]
.
param
);
}
}
taosVariantDestroy
(
&
pCtx
[
i
].
tag
);
taosVariantDestroy
(
&
pCtx
[
i
].
tag
);
...
@@ -6487,9 +6481,6 @@ SOperatorInfo* createOperatorTree(SPhysiNode* pPhyNode, SExecTaskInfo* pTaskInfo
...
@@ -6487,9 +6481,6 @@ SOperatorInfo* createOperatorTree(SPhysiNode* pPhyNode, SExecTaskInfo* pTaskInfo
int32_t
numOfCols
=
0
;
int32_t
numOfCols
=
0
;
tsdbReaderT
pDataReader
=
doCreateDataReader
(
pTableScanNode
,
pHandle
,
pTableGroupInfo
,
(
uint64_t
)
queryId
,
taskId
);
tsdbReaderT
pDataReader
=
doCreateDataReader
(
pTableScanNode
,
pHandle
,
pTableGroupInfo
,
(
uint64_t
)
queryId
,
taskId
);
if
(
pDataReader
==
NULL
)
{
return
NULL
;
}
SArray
*
pColList
=
extractColMatchInfo
(
pScanPhyNode
->
pScanCols
,
pScanPhyNode
->
node
.
pOutputDataBlockDesc
,
&
numOfCols
);
SArray
*
pColList
=
extractColMatchInfo
(
pScanPhyNode
->
pScanCols
,
pScanPhyNode
->
node
.
pOutputDataBlockDesc
,
&
numOfCols
);
SSDataBlock
*
pResBlock
=
createResDataBlock
(
pScanPhyNode
->
node
.
pOutputDataBlockDesc
);
SSDataBlock
*
pResBlock
=
createResDataBlock
(
pScanPhyNode
->
node
.
pOutputDataBlockDesc
);
...
...
source/libs/executor/src/scanoperator.c
浏览文件 @
162b3087
此差异已折叠。
点击以展开。
source/libs/function/inc/builtinsimpl.h
浏览文件 @
162b3087
...
@@ -58,6 +58,9 @@ bool getFirstLastFuncEnv(struct SFunctionNode* pFunc, SFuncExecEnv* pEnv);
...
@@ -58,6 +58,9 @@ bool getFirstLastFuncEnv(struct SFunctionNode* pFunc, SFuncExecEnv* pEnv);
int32_t
firstFunction
(
SqlFunctionCtx
*
pCtx
);
int32_t
firstFunction
(
SqlFunctionCtx
*
pCtx
);
int32_t
lastFunction
(
SqlFunctionCtx
*
pCtx
);
int32_t
lastFunction
(
SqlFunctionCtx
*
pCtx
);
bool
getTopBotFuncEnv
(
SFunctionNode
*
UNUSED_PARAM
(
pFunc
),
SFuncExecEnv
*
pEnv
);
int32_t
topFunction
(
SqlFunctionCtx
*
pCtx
);
#ifdef __cplusplus
#ifdef __cplusplus
}
}
#endif
#endif
...
...
source/libs/function/inc/tudf.h
浏览文件 @
162b3087
...
@@ -27,41 +27,31 @@ extern "C" {
...
@@ -27,41 +27,31 @@ extern "C" {
#endif
#endif
#define UDF_LISTEN_PIPE_NAME_LEN 32
#define UDF_LISTEN_PIPE_NAME_LEN 32
#define UDF_LISTEN_PIPE_NAME_PREFIX "udf.sock."
#define UDF_LISTEN_PIPE_NAME_PREFIX "udf
d
.sock."
//======================================================================================
//======================================================================================
//begin API to taosd and qworker
//begin API to taosd and qworker
enum
{
enum
{
UDFC_CODE_STOPPING
=
-
1
,
UDFC_CODE_STOPPING
=
-
1
,
UDFC_CODE_RESTARTING
=
-
2
,
UDFC_CODE_PIPE_READ_ERR
=
-
3
,
UDFC_CODE_PIPE_READ_ERR
=
-
3
,
};
};
/*TODO: no api for dnode startudfd/stopudfd*/
typedef
void
*
UdfcHandle
;
/**
typedef
void
*
UdfcFuncHandle
;
* start udfd dameon service
*/
int32_t
startUdfd
(
int32_t
dnodeId
);
/**
* stop udfd dameon service
*/
int32_t
stopUdfd
(
int32_t
dnodeId
);
/**
/**
* create udfd proxy, called once in process that call setupUdf/callUdfxxx/teardownUdf
* create udfd proxy, called once in process that call setupUdf/callUdfxxx/teardownUdf
* @return error code
* @return error code
*/
*/
int32_t
createUdfdProxy
(
int32_t
dnodeId
);
int32_t
udfcOpen
(
int32_t
dnodeId
,
UdfcHandle
*
proxyHandle
);
/**
/**
* destroy udfd proxy
* destroy udfd proxy
* @return error code
* @return error code
*/
*/
int32_t
destroyUdfdProxy
(
int32_t
dnodeId
);
int32_t
udfcClose
(
UdfcHandle
proxyhandle
);
typedef
void
*
UdfHandle
;
/**
/**
* setup udf
* setup udf
...
@@ -69,7 +59,7 @@ typedef void *UdfHandle;
...
@@ -69,7 +59,7 @@ typedef void *UdfHandle;
* @param handle, out
* @param handle, out
* @return error code
* @return error code
*/
*/
int32_t
setupUdf
(
char
udfName
[],
SEpSet
*
epSet
,
Udf
Handle
*
handle
);
int32_t
setupUdf
(
UdfcHandle
proxyHandle
,
char
udfName
[],
SEpSet
*
epSet
,
UdfcFunc
Handle
*
handle
);
typedef
struct
SUdfColumnMeta
{
typedef
struct
SUdfColumnMeta
{
int16_t
type
;
int16_t
type
;
...
@@ -116,26 +106,26 @@ typedef struct SUdfInterBuf {
...
@@ -116,26 +106,26 @@ typedef struct SUdfInterBuf {
}
SUdfInterBuf
;
}
SUdfInterBuf
;
// output: interBuf
// output: interBuf
int32_t
callUdfAggInit
(
UdfHandle
handle
,
SUdfInterBuf
*
interBuf
);
int32_t
callUdfAggInit
(
Udf
cFunc
Handle
handle
,
SUdfInterBuf
*
interBuf
);
// input: block, state
// input: block, state
// output: newState
// output: newState
int32_t
callUdfAggProcess
(
UdfHandle
handle
,
SSDataBlock
*
block
,
SUdfInterBuf
*
state
,
SUdfInterBuf
*
newState
);
int32_t
callUdfAggProcess
(
Udf
cFunc
Handle
handle
,
SSDataBlock
*
block
,
SUdfInterBuf
*
state
,
SUdfInterBuf
*
newState
);
// input: interBuf
// input: interBuf
// output: resultData
// output: resultData
int32_t
callUdfAggFinalize
(
UdfHandle
handle
,
SUdfInterBuf
*
interBuf
,
SUdfInterBuf
*
resultData
);
int32_t
callUdfAggFinalize
(
Udf
cFunc
Handle
handle
,
SUdfInterBuf
*
interBuf
,
SUdfInterBuf
*
resultData
);
// input: interbuf1, interbuf2
// input: interbuf1, interbuf2
// output: resultBuf
// output: resultBuf
int32_t
callUdfAggMerge
(
UdfHandle
handle
,
SUdfInterBuf
*
interBuf1
,
SUdfInterBuf
*
interBuf2
,
SUdfInterBuf
*
resultBuf
);
int32_t
callUdfAggMerge
(
Udf
cFunc
Handle
handle
,
SUdfInterBuf
*
interBuf1
,
SUdfInterBuf
*
interBuf2
,
SUdfInterBuf
*
resultBuf
);
// input: block
// input: block
// output: resultData
// output: resultData
int32_t
callUdfScalaProcess
(
UdfHandle
handle
,
SSDataBlock
*
block
,
SSDataBlock
*
resultData
);
int32_t
callUdfScalaProcess
(
Udf
cFunc
Handle
handle
,
SSDataBlock
*
block
,
SSDataBlock
*
resultData
);
/**
/**
* tearn down udf
* tearn down udf
* @param handle
* @param handle
* @return
* @return
*/
*/
int32_t
teardownUdf
(
UdfHandle
handle
);
int32_t
teardownUdf
(
Udf
cFunc
Handle
handle
);
// end API to taosd and qworker
// end API to taosd and qworker
//=============================================================================================================================
//=============================================================================================================================
...
...
source/libs/function/inc/udfc.h
浏览文件 @
162b3087
...
@@ -30,20 +30,20 @@ typedef struct SUdfInfo {
...
@@ -30,20 +30,20 @@ typedef struct SUdfInfo {
char
*
path
;
char
*
path
;
}
SUdfInfo
;
}
SUdfInfo
;
typedef
void
*
UdfHandle
;
typedef
void
*
Udf
cFunc
Handle
;
int32_t
createUdfdProxy
();
int32_t
createUdfdProxy
();
int32_t
destroyUdfdProxy
();
int32_t
destroyUdfdProxy
();
//int32_t setupUdf(SUdfInfo *udf, int32_t numOfUdfs, UdfHandle *handles);
//int32_t setupUdf(SUdfInfo *udf, int32_t numOfUdfs, Udf
cFunc
Handle *handles);
int32_t
setupUdf
(
SUdfInfo
*
udf
,
UdfHandle
*
handle
);
int32_t
setupUdf
(
SUdfInfo
*
udf
,
Udf
cFunc
Handle
*
handle
);
int32_t
callUdf
(
UdfHandle
handle
,
int8_t
step
,
char
*
state
,
int32_t
stateSize
,
SSDataBlock
input
,
char
**
newstate
,
int32_t
callUdf
(
Udf
cFunc
Handle
handle
,
int8_t
step
,
char
*
state
,
int32_t
stateSize
,
SSDataBlock
input
,
char
**
newstate
,
int32_t
*
newStateSize
,
SSDataBlock
*
output
);
int32_t
*
newStateSize
,
SSDataBlock
*
output
);
int32_t
teardownUdf
(
UdfHandle
handle
);
int32_t
teardownUdf
(
Udf
cFunc
Handle
handle
);
typedef
struct
SUdfSetupRequest
{
typedef
struct
SUdfSetupRequest
{
char
udfName
[
16
];
//
char
udfName
[
16
];
//
...
...
source/libs/function/src/builtins.c
浏览文件 @
162b3087
...
@@ -193,8 +193,15 @@ static int32_t translateApercentile(SFunctionNode* pFunc, char* pErrBuf, int32_t
...
@@ -193,8 +193,15 @@ static int32_t translateApercentile(SFunctionNode* pFunc, char* pErrBuf, int32_t
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
static
int32_t
translateTbnameColumn
(
SFunctionNode
*
pFunc
,
char
*
pErrBuf
,
int32_t
len
)
{
// pseudo column do not need to check parameters
pFunc
->
node
.
resType
=
(
SDataType
){.
bytes
=
TSDB_TABLE_FNAME_LEN
-
1
+
VARSTR_HEADER_SIZE
,
.
type
=
TSDB_DATA_TYPE_VARCHAR
};
return
TSDB_CODE_SUCCESS
;
}
static
int32_t
translateTop
(
SFunctionNode
*
pFunc
,
char
*
pErrBuf
,
int32_t
len
)
{
static
int32_t
translateTop
(
SFunctionNode
*
pFunc
,
char
*
pErrBuf
,
int32_t
len
)
{
// todo
SDataType
*
pType
=
&
((
SExprNode
*
)
nodesListGetNode
(
pFunc
->
pParameterList
,
0
))
->
resType
;
pFunc
->
node
.
resType
=
(
SDataType
){.
bytes
=
pType
->
bytes
,
.
type
=
pType
->
type
};
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
...
@@ -497,9 +504,9 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = {
...
@@ -497,9 +504,9 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = {
.
type
=
FUNCTION_TYPE_TOP
,
.
type
=
FUNCTION_TYPE_TOP
,
.
classification
=
FUNC_MGT_AGG_FUNC
,
.
classification
=
FUNC_MGT_AGG_FUNC
,
.
translateFunc
=
translateTop
,
.
translateFunc
=
translateTop
,
.
getEnvFunc
=
get
Minmax
FuncEnv
,
.
getEnvFunc
=
get
TopBot
FuncEnv
,
.
initFunc
=
maxF
unctionSetup
,
.
initFunc
=
f
unctionSetup
,
.
processFunc
=
max
Function
,
.
processFunc
=
top
Function
,
.
finalizeFunc
=
functionFinalize
.
finalizeFunc
=
functionFinalize
},
},
{
{
...
@@ -876,7 +883,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = {
...
@@ -876,7 +883,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = {
.
name
=
"tbname"
,
.
name
=
"tbname"
,
.
type
=
FUNCTION_TYPE_TBNAME
,
.
type
=
FUNCTION_TYPE_TBNAME
,
.
classification
=
FUNC_MGT_PSEUDO_COLUMN_FUNC
,
.
classification
=
FUNC_MGT_PSEUDO_COLUMN_FUNC
,
.
translateFunc
=
NULL
,
.
translateFunc
=
translateTbnameColumn
,
.
getEnvFunc
=
NULL
,
.
getEnvFunc
=
NULL
,
.
initFunc
=
NULL
,
.
initFunc
=
NULL
,
.
sprocessFunc
=
NULL
,
.
sprocessFunc
=
NULL
,
...
@@ -914,7 +921,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = {
...
@@ -914,7 +921,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = {
},
},
{
{
.
name
=
"_wendts"
,
.
name
=
"_wendts"
,
.
type
=
FUNCTION_TYPE_
Q
ENDTS
,
.
type
=
FUNCTION_TYPE_
W
ENDTS
,
.
classification
=
FUNC_MGT_PSEUDO_COLUMN_FUNC
|
FUNC_MGT_WINDOW_PC_FUNC
,
.
classification
=
FUNC_MGT_PSEUDO_COLUMN_FUNC
|
FUNC_MGT_WINDOW_PC_FUNC
,
.
translateFunc
=
translateTimePseudoColumn
,
.
translateFunc
=
translateTimePseudoColumn
,
.
getEnvFunc
=
getTimePseudoFuncEnv
,
.
getEnvFunc
=
getTimePseudoFuncEnv
,
...
...
source/libs/function/src/builtinsimpl.c
浏览文件 @
162b3087
...
@@ -14,10 +14,11 @@
...
@@ -14,10 +14,11 @@
*/
*/
#include "builtinsimpl.h"
#include "builtinsimpl.h"
#include
"tpercentile.h"
#include
<libs/nodes/querynodes.h>
#include "querynodes.h"
#include "querynodes.h"
#include "taggfunction.h"
#include "taggfunction.h"
#include "tdatablock.h"
#include "tdatablock.h"
#include "tpercentile.h"
#define SET_VAL(_info, numOfElem, res) \
#define SET_VAL(_info, numOfElem, res) \
do { \
do { \
...
@@ -472,17 +473,6 @@ int32_t maxFunction(SqlFunctionCtx *pCtx) {
...
@@ -472,17 +473,6 @@ int32_t maxFunction(SqlFunctionCtx *pCtx) {
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
typedef
struct
STopBotRes
{
int32_t
num
;
}
STopBotRes
;
bool
getTopBotFuncEnv
(
SFunctionNode
*
pFunc
,
SFuncExecEnv
*
pEnv
)
{
SColumnNode
*
pColNode
=
(
SColumnNode
*
)
nodesListGetNode
(
pFunc
->
pParameterList
,
0
);
int32_t
bytes
=
pColNode
->
node
.
resType
.
bytes
;
SValueNode
*
pkNode
=
(
SValueNode
*
)
nodesListGetNode
(
pFunc
->
pParameterList
,
1
);
return
true
;
}
typedef
struct
SStddevRes
{
typedef
struct
SStddevRes
{
double
result
;
double
result
;
int64_t
count
;
int64_t
count
;
...
@@ -523,7 +513,7 @@ int32_t stddevFunction(SqlFunctionCtx* pCtx) {
...
@@ -523,7 +513,7 @@ int32_t stddevFunction(SqlFunctionCtx* pCtx) {
switch
(
type
)
{
switch
(
type
)
{
case
TSDB_DATA_TYPE_TINYINT
:
{
case
TSDB_DATA_TYPE_TINYINT
:
{
int8_t
*
plist
=
(
int8_t
*
)
pCol
->
pData
;
int8_t
*
plist
=
(
int8_t
*
)
pCol
->
pData
;
for
(
int32_t
i
=
start
;
i
<
numOfRows
+
pInput
->
startRowIndex
;
++
i
)
{
for
(
int32_t
i
=
start
;
i
<
numOfRows
+
start
;
++
i
)
{
if
(
pCol
->
hasNull
&&
colDataIsNull_f
(
pCol
->
nullbitmap
,
i
))
{
if
(
pCol
->
hasNull
&&
colDataIsNull_f
(
pCol
->
nullbitmap
,
i
))
{
continue
;
continue
;
}
}
...
@@ -749,9 +739,9 @@ int32_t percentileFunction(SqlFunctionCtx *pCtx) {
...
@@ -749,9 +739,9 @@ int32_t percentileFunction(SqlFunctionCtx *pCtx) {
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
// TODO set the correct parameter.
void
percentileFinalize
(
SqlFunctionCtx
*
pCtx
)
{
void
percentileFinalize
(
SqlFunctionCtx
*
pCtx
)
{
double
v
=
50
;
//pCtx->param[0].nType == TSDB_DATA_TYPE_INT ? pCtx->param[0].i64 : pCtx->param[0].dKey;
SVariant
*
pVal
=
&
pCtx
->
param
[
1
].
param
;
double
v
=
pVal
->
nType
==
TSDB_DATA_TYPE_INT
?
pVal
->
i
:
pVal
->
d
;
SResultRowEntryInfo
*
pResInfo
=
GET_RES_INFO
(
pCtx
);
SResultRowEntryInfo
*
pResInfo
=
GET_RES_INFO
(
pCtx
);
SPercentileInfo
*
ppInfo
=
(
SPercentileInfo
*
)
GET_ROWCELL_INTERBUF
(
pResInfo
);
SPercentileInfo
*
ppInfo
=
(
SPercentileInfo
*
)
GET_ROWCELL_INTERBUF
(
pResInfo
);
...
@@ -1173,3 +1163,130 @@ int32_t diffFunction(SqlFunctionCtx *pCtx) {
...
@@ -1173,3 +1163,130 @@ int32_t diffFunction(SqlFunctionCtx *pCtx) {
}
}
}
}
typedef
struct
STopBotResItem
{
SVariant
v
;
uint64_t
uid
;
// it is a table uid, used to extract tag data during building of the final result for the tag data
struct
{
int32_t
pageId
;
int32_t
offset
;
}
tuplePos
;
// tuple data of this chosen row
}
STopBotResItem
;
typedef
struct
STopBotRes
{
int32_t
num
;
STopBotResItem
*
pItems
;
}
STopBotRes
;
bool
getTopBotFuncEnv
(
SFunctionNode
*
pFunc
,
SFuncExecEnv
*
pEnv
)
{
SColumnNode
*
pColNode
=
(
SColumnNode
*
)
nodesListGetNode
(
pFunc
->
pParameterList
,
0
);
int32_t
bytes
=
pColNode
->
node
.
resType
.
bytes
;
SValueNode
*
pkNode
=
(
SValueNode
*
)
nodesListGetNode
(
pFunc
->
pParameterList
,
1
);
pEnv
->
calcMemSize
=
sizeof
(
STopBotRes
)
+
pkNode
->
datum
.
i
*
bytes
;
return
true
;
}
static
STopBotRes
*
getTopBotOutputInfo
(
SqlFunctionCtx
*
pCtx
)
{
SResultRowEntryInfo
*
pResInfo
=
GET_RES_INFO
(
pCtx
);
STopBotRes
*
pRes
=
GET_ROWCELL_INTERBUF
(
pResInfo
);
pRes
->
pItems
=
(
STopBotResItem
*
)((
char
*
)
pRes
+
sizeof
(
STopBotRes
));
return
pRes
;
}
static
void
doAddIntoResult
(
STopBotRes
*
pRes
,
int32_t
maxSize
,
void
*
pData
,
uint16_t
type
,
uint64_t
uid
);
int32_t
topFunction
(
SqlFunctionCtx
*
pCtx
)
{
int32_t
numOfElems
=
0
;
STopBotRes
*
pRes
=
getTopBotOutputInfo
(
pCtx
);
assert
(
pRes
->
num
>=
0
);
// if ((void *)pRes->res[0] != (void *)((char *)pRes + sizeof(STopBotRes) + POINTER_BYTES * pCtx->param[0].i)) {
// buildTopBotStruct(pRes, pCtx);
// }
SInputColumnInfoData
*
pInput
=
&
pCtx
->
input
;
SColumnInfoData
*
pCol
=
pInput
->
pData
[
0
];
int32_t
type
=
pInput
->
pData
[
0
]
->
info
.
type
;
int32_t
start
=
pInput
->
startRowIndex
;
int32_t
numOfRows
=
pInput
->
numOfRows
;
for
(
int32_t
i
=
start
;
i
<
numOfRows
+
start
;
++
i
)
{
if
(
pCol
->
hasNull
&&
colDataIsNull_f
(
pCol
->
nullbitmap
,
i
))
{
continue
;
}
numOfElems
++
;
char
*
data
=
colDataGetData
(
pCol
,
i
);
doAddIntoResult
(
pRes
,
pCtx
->
param
[
1
].
param
.
i
,
data
,
type
,
pInput
->
uid
);
}
// treat the result as only one result
SET_VAL
(
GET_RES_INFO
(
pCtx
),
numOfElems
,
1
);
return
TSDB_CODE_SUCCESS
;
}
static
int32_t
topBotResComparFn
(
const
void
*
p1
,
const
void
*
p2
,
const
void
*
param
)
{
uint16_t
type
=
*
(
uint16_t
*
)
param
;
STopBotResItem
*
val1
=
(
STopBotResItem
*
)
p1
;
STopBotResItem
*
val2
=
(
STopBotResItem
*
)
p2
;
if
(
IS_SIGNED_NUMERIC_TYPE
(
type
))
{
if
(
val1
->
v
.
i
==
val2
->
v
.
i
)
{
return
0
;
}
return
(
val1
->
v
.
i
>
val2
->
v
.
i
)
?
1
:
-
1
;
}
else
if
(
IS_UNSIGNED_NUMERIC_TYPE
(
type
))
{
if
(
val1
->
v
.
u
==
val2
->
v
.
u
)
{
return
0
;
}
return
(
val1
->
v
.
u
>
val2
->
v
.
u
)
?
1
:
-
1
;
}
if
(
val1
->
v
.
d
==
val2
->
v
.
d
)
{
return
0
;
}
return
(
val1
->
v
.
d
>
val2
->
v
.
d
)
?
1
:
-
1
;
}
void
doAddIntoResult
(
STopBotRes
*
pRes
,
int32_t
maxSize
,
void
*
pData
,
uint16_t
type
,
uint64_t
uid
)
{
SVariant
val
=
{
0
};
taosVariantCreateFromBinary
(
&
val
,
pData
,
tDataTypes
[
type
].
bytes
,
type
);
STopBotResItem
*
pItems
=
pRes
->
pItems
;
assert
(
pItems
!=
NULL
);
// not full yet
if
(
pRes
->
num
<
maxSize
)
{
STopBotResItem
*
pItem
=
&
pItems
[
pRes
->
num
];
pItem
->
v
=
val
;
pItem
->
uid
=
uid
;
pItem
->
tuplePos
.
pageId
=
-
1
;
// todo set the corresponding tuple data in the disk-based buffer
pRes
->
num
++
;
taosheapsort
((
void
*
)
pItem
,
sizeof
(
STopBotResItem
),
pRes
->
num
,
(
const
void
*
)
&
type
,
topBotResComparFn
,
false
);
}
else
{
// replace the minimum value in the result
if
((
IS_SIGNED_NUMERIC_TYPE
(
type
)
&&
val
.
i
>
pItems
[
0
].
v
.
i
)
||
(
IS_UNSIGNED_NUMERIC_TYPE
(
type
)
&&
val
.
u
>
pItems
[
0
].
v
.
u
)
||
(
IS_FLOAT_TYPE
(
type
)
&&
val
.
d
>
pItems
[
0
].
v
.
d
))
{
STopBotResItem
*
pItem
=
&
pItems
[
pRes
->
num
];
pItem
->
v
=
val
;
pItem
->
uid
=
uid
;
pItem
->
tuplePos
.
pageId
=
-
1
;
// todo set the corresponding tuple data in the disk-based buffer
taosheapadjust
((
void
*
)
pItem
,
sizeof
(
STopBotResItem
),
0
,
pRes
->
num
-
1
,
(
const
void
*
)
&
type
,
topBotResComparFn
,
NULL
,
false
);
}
}
}
void
topBotFinalize
(
SqlFunctionCtx
*
pCtx
)
{
functionFinalize
(
pCtx
);
}
\ No newline at end of file
source/libs/function/src/taggfunction.c
浏览文件 @
162b3087
此差异已折叠。
点击以展开。
source/libs/function/src/tudf.c
浏览文件 @
162b3087
...
@@ -14,19 +14,15 @@
...
@@ -14,19 +14,15 @@
*/
*/
#include "uv.h"
#include "uv.h"
#include "os.h"
#include "os.h"
#include "tlog.h"
#include "tudf.h"
#include "tudf.h"
#include "tudfInt.h"
#include "tudfInt.h"
#include "tarray.h"
#include "tarray.h"
#include "tdatablock.h"
#include "tdatablock.h"
//TODO: when startup, set thread poll size. add it to cfg
//TODO: test for udfd restart
//TODO: udfd restart when exist or aborts
//TODO: deal with uv task that has been started and then udfd core dumped
//TODO: network error processing.
//TODO: network error processing.
//TODO: add unit test
//TODO: add unit test
//TODO: include all global variable under context struct
//TODO: include all global variable under context struct
/* Copyright (c) 2013, Ben Noordhuis <info@bnoordhuis.nl>
/* Copyright (c) 2013, Ben Noordhuis <info@bnoordhuis.nl>
* The QUEUE is copied from queue.h under libuv
* The QUEUE is copied from queue.h under libuv
* */
* */
...
@@ -125,12 +121,35 @@ enum {
...
@@ -125,12 +121,35 @@ enum {
UV_TASK_DISCONNECT
=
2
UV_TASK_DISCONNECT
=
2
};
};
int64_t
gUdfTaskSeqNum
=
0
;
typedef
struct
SUdfdProxy
{
int32_t
dnodeId
;
uv_barrier_t
gUdfInitBarrier
;
uv_loop_t
gUdfdLoop
;
uv_thread_t
gUdfLoopThread
;
uv_async_t
gUdfLoopTaskAync
;
uv_async_t
gUdfLoopStopAsync
;
uv_mutex_t
gUdfTaskQueueMutex
;
int8_t
gUdfcState
;
QUEUE
gUdfTaskQueue
;
QUEUE
gUvProcTaskQueue
;
// int8_t gUdfcState = UDFC_STATE_INITAL;
// QUEUE gUdfTaskQueue = {0};
// QUEUE gUvProcTaskQueue = {0};
}
SUdfdProxy
;
typedef
struct
SUdfUvSession
{
typedef
struct
SUdfUvSession
{
SUdfdProxy
*
udfc
;
int64_t
severHandle
;
int64_t
severHandle
;
uv_pipe_t
*
udfSvcPipe
;
uv_pipe_t
*
udfSvcPipe
;
}
SUdfUvSession
;
}
SUdfUvSession
;
typedef
struct
SClientUvTaskNode
{
typedef
struct
SClientUvTaskNode
{
SUdfdProxy
*
udfc
;
int8_t
type
;
int8_t
type
;
int
errCode
;
int
errCode
;
...
@@ -169,7 +188,6 @@ typedef struct SClientUdfTask {
...
@@ -169,7 +188,6 @@ typedef struct SClientUdfTask {
}
_teardown
;
}
_teardown
;
};
};
}
SClientUdfTask
;
}
SClientUdfTask
;
typedef
struct
SClientConnBuf
{
typedef
struct
SClientConnBuf
{
...
@@ -185,34 +203,13 @@ typedef struct SClientUvConn {
...
@@ -185,34 +203,13 @@ typedef struct SClientUvConn {
SClientConnBuf
readBuf
;
SClientConnBuf
readBuf
;
}
SClientUvConn
;
}
SClientUvConn
;
uv_process_t
gUdfdProcess
;
uv_barrier_t
gUdfInitBarrier
;
uv_loop_t
gUdfdLoop
;
uv_thread_t
gUdfLoopThread
;
uv_async_t
gUdfLoopTaskAync
;
uv_async_t
gUdfLoopStopAsync
;
uv_mutex_t
gUdfTaskQueueMutex
;
int64_t
gUdfTaskSeqNum
=
0
;
enum
{
enum
{
UDFC_STATE_INITAL
=
0
,
// initial state
UDFC_STATE_INITAL
=
0
,
// initial state
UDFC_STATE_STARTNG
,
// starting after
createUdfdProxy
UDFC_STATE_STARTNG
,
// starting after
udfcOpen
UDFC_STATE_READY
,
// started and begin to receive quests
UDFC_STATE_READY
,
// started and begin to receive quests
UDFC_STATE_RESTARTING
,
// udfd abnormal exit. cleaning up and restart.
UDFC_STATE_STOPPING
,
// stopping after udfcClose
UDFC_STATE_STOPPING
,
// stopping after destroyUdfdProxy
UDFC_STATUS_FINAL
,
// stopped
UDFC_STATUS_FINAL
,
// stopped
};
};
int8_t
gUdfcState
=
UDFC_STATE_INITAL
;
//double circular linked list
QUEUE
gUdfTaskQueue
=
{
0
};
QUEUE
gUvProcTaskQueue
=
{
0
};
int32_t
encodeUdfSetupRequest
(
void
**
buf
,
const
SUdfSetupRequest
*
setup
)
{
int32_t
encodeUdfSetupRequest
(
void
**
buf
,
const
SUdfSetupRequest
*
setup
)
{
int32_t
len
=
0
;
int32_t
len
=
0
;
...
@@ -777,13 +774,14 @@ void onUdfClientConnect(uv_connect_t *connect, int status) {
...
@@ -777,13 +774,14 @@ void onUdfClientConnect(uv_connect_t *connect, int status) {
int32_t
createUdfcUvTask
(
SClientUdfTask
*
task
,
int8_t
uvTaskType
,
SClientUvTaskNode
**
pUvTask
)
{
int32_t
createUdfcUvTask
(
SClientUdfTask
*
task
,
int8_t
uvTaskType
,
SClientUvTaskNode
**
pUvTask
)
{
SClientUvTaskNode
*
uvTask
=
taosMemoryCalloc
(
1
,
sizeof
(
SClientUvTaskNode
));
SClientUvTaskNode
*
uvTask
=
taosMemoryCalloc
(
1
,
sizeof
(
SClientUvTaskNode
));
uvTask
->
type
=
uvTaskType
;
uvTask
->
type
=
uvTaskType
;
uvTask
->
udfc
=
task
->
session
->
udfc
;
if
(
uvTaskType
==
UV_TASK_CONNECT
)
{
if
(
uvTaskType
==
UV_TASK_CONNECT
)
{
}
else
if
(
uvTaskType
==
UV_TASK_REQ_RSP
)
{
}
else
if
(
uvTaskType
==
UV_TASK_REQ_RSP
)
{
uvTask
->
pipe
=
task
->
session
->
udfSvcPipe
;
uvTask
->
pipe
=
task
->
session
->
udfSvcPipe
;
SUdfRequest
request
;
SUdfRequest
request
;
request
.
type
=
task
->
type
;
request
.
type
=
task
->
type
;
request
.
seqNum
=
gUdfTaskSeqNum
++
;
request
.
seqNum
=
atomic_fetch_add_64
(
&
gUdfTaskSeqNum
,
1
)
;
if
(
task
->
type
==
UDF_TASK_SETUP
)
{
if
(
task
->
type
==
UDF_TASK_SETUP
)
{
request
.
setup
=
task
->
_setup
.
req
;
request
.
setup
=
task
->
_setup
.
req
;
...
@@ -815,11 +813,11 @@ int32_t createUdfcUvTask(SClientUdfTask *task, int8_t uvTaskType, SClientUvTaskN
...
@@ -815,11 +813,11 @@ int32_t createUdfcUvTask(SClientUdfTask *task, int8_t uvTaskType, SClientUvTaskN
int32_t
queueUvUdfTask
(
SClientUvTaskNode
*
uvTask
)
{
int32_t
queueUvUdfTask
(
SClientUvTaskNode
*
uvTask
)
{
debugPrint
(
"%s, %d"
,
"queue uv task"
,
uvTask
->
type
);
debugPrint
(
"%s, %d"
,
"queue uv task"
,
uvTask
->
type
);
SUdfdProxy
*
udfc
=
uvTask
->
udfc
;
uv_mutex_lock
(
&
gUdfTaskQueueMutex
);
uv_mutex_lock
(
&
udfc
->
gUdfTaskQueueMutex
);
QUEUE_INSERT_TAIL
(
&
gUdfTaskQueue
,
&
uvTask
->
recvTaskQueue
);
QUEUE_INSERT_TAIL
(
&
udfc
->
gUdfTaskQueue
,
&
uvTask
->
recvTaskQueue
);
uv_mutex_unlock
(
&
gUdfTaskQueueMutex
);
uv_mutex_unlock
(
&
udfc
->
gUdfTaskQueueMutex
);
uv_async_send
(
&
gUdfLoopTaskAync
);
uv_async_send
(
&
udfc
->
gUdfLoopTaskAync
);
uv_sem_wait
(
&
uvTask
->
taskSem
);
uv_sem_wait
(
&
uvTask
->
taskSem
);
uv_sem_destroy
(
&
uvTask
->
taskSem
);
uv_sem_destroy
(
&
uvTask
->
taskSem
);
...
@@ -832,7 +830,7 @@ int32_t startUvUdfTask(SClientUvTaskNode *uvTask) {
...
@@ -832,7 +830,7 @@ int32_t startUvUdfTask(SClientUvTaskNode *uvTask) {
switch
(
uvTask
->
type
)
{
switch
(
uvTask
->
type
)
{
case
UV_TASK_CONNECT
:
{
case
UV_TASK_CONNECT
:
{
uv_pipe_t
*
pipe
=
taosMemoryMalloc
(
sizeof
(
uv_pipe_t
));
uv_pipe_t
*
pipe
=
taosMemoryMalloc
(
sizeof
(
uv_pipe_t
));
uv_pipe_init
(
&
gUdfdLoop
,
pipe
,
0
);
uv_pipe_init
(
&
uvTask
->
udfc
->
gUdfdLoop
,
pipe
,
0
);
uvTask
->
pipe
=
pipe
;
uvTask
->
pipe
=
pipe
;
SClientUvConn
*
conn
=
taosMemoryMalloc
(
sizeof
(
SClientUvConn
));
SClientUvConn
*
conn
=
taosMemoryMalloc
(
sizeof
(
SClientUvConn
));
...
@@ -873,142 +871,98 @@ int32_t startUvUdfTask(SClientUvTaskNode *uvTask) {
...
@@ -873,142 +871,98 @@ int32_t startUvUdfTask(SClientUvTaskNode *uvTask) {
}
}
void
udfClientAsyncCb
(
uv_async_t
*
async
)
{
void
udfClientAsyncCb
(
uv_async_t
*
async
)
{
SUdfdProxy
*
udfc
=
async
->
data
;
QUEUE
wq
;
QUEUE
wq
;
uv_mutex_lock
(
&
gUdfTaskQueueMutex
);
uv_mutex_lock
(
&
udfc
->
gUdfTaskQueueMutex
);
QUEUE_MOVE
(
&
gUdfTaskQueue
,
&
wq
);
QUEUE_MOVE
(
&
udfc
->
gUdfTaskQueue
,
&
wq
);
uv_mutex_unlock
(
&
gUdfTaskQueueMutex
);
uv_mutex_unlock
(
&
udfc
->
gUdfTaskQueueMutex
);
while
(
!
QUEUE_EMPTY
(
&
wq
))
{
while
(
!
QUEUE_EMPTY
(
&
wq
))
{
QUEUE
*
h
=
QUEUE_HEAD
(
&
wq
);
QUEUE
*
h
=
QUEUE_HEAD
(
&
wq
);
QUEUE_REMOVE
(
h
);
QUEUE_REMOVE
(
h
);
SClientUvTaskNode
*
task
=
QUEUE_DATA
(
h
,
SClientUvTaskNode
,
recvTaskQueue
);
SClientUvTaskNode
*
task
=
QUEUE_DATA
(
h
,
SClientUvTaskNode
,
recvTaskQueue
);
startUvUdfTask
(
task
);
startUvUdfTask
(
task
);
QUEUE_INSERT_TAIL
(
&
gUvProcTaskQueue
,
&
task
->
procTaskQueue
);
QUEUE_INSERT_TAIL
(
&
udfc
->
gUvProcTaskQueue
,
&
task
->
procTaskQueue
);
}
}
}
}
void
cleanUpUvTasks
()
{
void
cleanUpUvTasks
(
SUdfdProxy
*
udfc
)
{
QUEUE
wq
;
QUEUE
wq
;
uv_mutex_lock
(
&
gUdfTaskQueueMutex
);
uv_mutex_lock
(
&
udfc
->
gUdfTaskQueueMutex
);
QUEUE_MOVE
(
&
gUdfTaskQueue
,
&
wq
);
QUEUE_MOVE
(
&
udfc
->
gUdfTaskQueue
,
&
wq
);
uv_mutex_unlock
(
&
gUdfTaskQueueMutex
);
uv_mutex_unlock
(
&
udfc
->
gUdfTaskQueueMutex
);
while
(
!
QUEUE_EMPTY
(
&
wq
))
{
while
(
!
QUEUE_EMPTY
(
&
wq
))
{
QUEUE
*
h
=
QUEUE_HEAD
(
&
wq
);
QUEUE
*
h
=
QUEUE_HEAD
(
&
wq
);
QUEUE_REMOVE
(
h
);
QUEUE_REMOVE
(
h
);
SClientUvTaskNode
*
task
=
QUEUE_DATA
(
h
,
SClientUvTaskNode
,
recvTaskQueue
);
SClientUvTaskNode
*
task
=
QUEUE_DATA
(
h
,
SClientUvTaskNode
,
recvTaskQueue
);
if
(
gUdfcState
==
UDFC_STATE_STOPPING
)
{
if
(
udfc
->
gUdfcState
==
UDFC_STATE_STOPPING
)
{
task
->
errCode
=
UDFC_CODE_STOPPING
;
task
->
errCode
=
UDFC_CODE_STOPPING
;
}
else
if
(
gUdfcState
==
UDFC_STATE_RESTARTING
)
{
task
->
errCode
=
UDFC_CODE_RESTARTING
;
}
}
uv_sem_post
(
&
task
->
taskSem
);
uv_sem_post
(
&
task
->
taskSem
);
}
}
// TODO: deal with tasks that are waiting result.
// TODO: deal with tasks that are waiting result.
while
(
!
QUEUE_EMPTY
(
&
gUvProcTaskQueue
))
{
while
(
!
QUEUE_EMPTY
(
&
udfc
->
gUvProcTaskQueue
))
{
QUEUE
*
h
=
QUEUE_HEAD
(
&
gUvProcTaskQueue
);
QUEUE
*
h
=
QUEUE_HEAD
(
&
udfc
->
gUvProcTaskQueue
);
QUEUE_REMOVE
(
h
);
QUEUE_REMOVE
(
h
);
SClientUvTaskNode
*
task
=
QUEUE_DATA
(
h
,
SClientUvTaskNode
,
procTaskQueue
);
SClientUvTaskNode
*
task
=
QUEUE_DATA
(
h
,
SClientUvTaskNode
,
procTaskQueue
);
if
(
gUdfcState
==
UDFC_STATE_STOPPING
)
{
if
(
udfc
->
gUdfcState
==
UDFC_STATE_STOPPING
)
{
task
->
errCode
=
UDFC_CODE_STOPPING
;
task
->
errCode
=
UDFC_CODE_STOPPING
;
}
else
if
(
gUdfcState
==
UDFC_STATE_RESTARTING
)
{
task
->
errCode
=
UDFC_CODE_RESTARTING
;
}
}
uv_sem_post
(
&
task
->
taskSem
);
uv_sem_post
(
&
task
->
taskSem
);
}
}
}
}
void
udfStopAsyncCb
(
uv_async_t
*
async
)
{
void
udfStopAsyncCb
(
uv_async_t
*
async
)
{
cleanUpUvTasks
();
SUdfdProxy
*
udfc
=
async
->
data
;
if
(
gUdfcState
==
UDFC_STATE_STOPPING
)
{
cleanUpUvTasks
(
udfc
);
uv_stop
(
&
gUdfdLoop
);
if
(
udfc
->
gUdfcState
==
UDFC_STATE_STOPPING
)
{
uv_stop
(
&
udfc
->
gUdfdLoop
);
}
}
}
}
int32_t
udfcSpawnUdfd
();
void
onUdfdExit
(
uv_process_t
*
req
,
int64_t
exit_status
,
int
term_signal
)
{
//TODO: pipe close will be first received
debugPrint
(
"Process exited with status %"
PRId64
", signal %d"
,
exit_status
,
term_signal
);
uv_close
((
uv_handle_t
*
)
req
,
NULL
);
//TODO: restart the udfd process
if
(
gUdfcState
==
UDFC_STATE_STOPPING
)
{
if
(
term_signal
!=
SIGINT
)
{
//TODO: log error
}
}
if
(
gUdfcState
==
UDFC_STATE_READY
)
{
gUdfcState
=
UDFC_STATE_RESTARTING
;
//TODO: asynchronous without blocking. how to do it
//cleanUpUvTasks();
udfcSpawnUdfd
();
}
}
int32_t
udfcSpawnUdfd
()
{
//TODO: path
uv_process_options_t
options
=
{
0
};
static
char
path
[
256
]
=
{
0
};
size_t
cwdSize
;
uv_cwd
(
path
,
&
cwdSize
);
strcat
(
path
,
"/udfd"
);
char
*
args
[
2
]
=
{
path
,
NULL
};
options
.
args
=
args
;
options
.
file
=
path
;
options
.
exit_cb
=
onUdfdExit
;
options
.
stdio_count
=
3
;
uv_stdio_container_t
child_stdio
[
3
];
child_stdio
[
0
].
flags
=
UV_IGNORE
;
child_stdio
[
1
].
flags
=
UV_INHERIT_FD
;
child_stdio
[
1
].
data
.
fd
=
1
;
child_stdio
[
2
].
flags
=
UV_INHERIT_FD
;
child_stdio
[
2
].
data
.
fd
=
2
;
options
.
stdio
=
child_stdio
;
//TODO spawn error
int
err
=
uv_spawn
(
&
gUdfdLoop
,
&
gUdfdProcess
,
&
options
);
if
(
err
!=
0
)
{
debugPrint
(
"can not spawn udfd. path: %s, error: %s"
,
path
,
uv_strerror
(
err
));
}
return
err
;
}
void
constructUdfService
(
void
*
argsThread
)
{
void
constructUdfService
(
void
*
argsThread
)
{
uv_loop_init
(
&
gUdfdLoop
);
SUdfdProxy
*
udfc
=
(
SUdfdProxy
*
)
argsThread
;
uv_loop_init
(
&
udfc
->
gUdfdLoop
);
uv_async_init
(
&
gUdfdLoop
,
&
gUdfLoopTaskAync
,
udfClientAsyncCb
);
uv_async_init
(
&
gUdfdLoop
,
&
gUdfLoopStopAsync
,
udfStopAsyncCb
);
uv_async_init
(
&
udfc
->
gUdfdLoop
,
&
udfc
->
gUdfLoopTaskAync
,
udfClientAsyncCb
);
uv_mutex_init
(
&
gUdfTaskQueueMutex
);
udfc
->
gUdfLoopTaskAync
.
data
=
udfc
;
QUEUE_INIT
(
&
gUdfTaskQueue
);
uv_async_init
(
&
udfc
->
gUdfdLoop
,
&
udfc
->
gUdfLoopStopAsync
,
udfStopAsyncCb
);
QUEUE_INIT
(
&
gUvProcTaskQueue
);
udfc
->
gUdfLoopStopAsync
.
data
=
udfc
;
uv_barrier_wait
(
&
gUdfInitBarrier
);
uv_mutex_init
(
&
udfc
->
gUdfTaskQueueMutex
);
QUEUE_INIT
(
&
udfc
->
gUdfTaskQueue
);
QUEUE_INIT
(
&
udfc
->
gUvProcTaskQueue
);
uv_barrier_wait
(
&
udfc
->
gUdfInitBarrier
);
//TODO return value of uv_run
//TODO return value of uv_run
uv_run
(
&
gUdfdLoop
,
UV_RUN_DEFAULT
);
uv_run
(
&
udfc
->
gUdfdLoop
,
UV_RUN_DEFAULT
);
uv_loop_close
(
&
gUdfdLoop
);
uv_loop_close
(
&
udfc
->
gUdfdLoop
);
}
}
int32_t
udfcOpen
(
int32_t
dnodeId
,
UdfcHandle
*
udfc
)
{
int32_t
createUdfdProxy
(
int32_t
dnodeId
)
{
SUdfdProxy
*
proxy
=
taosMemoryCalloc
(
1
,
sizeof
(
SUdfdProxy
));
gUdfcState
=
UDFC_STATE_STARTNG
;
proxy
->
dnodeId
=
dnodeId
;
uv_barrier_init
(
&
gUdfInitBarrier
,
2
);
proxy
->
gUdfcState
=
UDFC_STATE_STARTNG
;
uv_thread_create
(
&
gUdfLoopThread
,
constructUdfService
,
0
);
uv_barrier_init
(
&
proxy
->
gUdfInitBarrier
,
2
);
uv_barrier_wait
(
&
gUdfInitBarrier
);
gUdfcState
=
UDFC_STATE_READY
;
uv_thread_create
(
&
proxy
->
gUdfLoopThread
,
constructUdfService
,
proxy
);
uv_barrier_wait
(
&
proxy
->
gUdfInitBarrier
);
proxy
->
gUdfcState
=
UDFC_STATE_READY
;
*
udfc
=
proxy
;
return
0
;
return
0
;
}
}
int32_t
destroyUdfdProxy
(
int32_t
dnodeId
)
{
int32_t
udfcClose
(
UdfcHandle
udfcHandle
)
{
gUdfcState
=
UDFC_STATE_STOPPING
;
SUdfdProxy
*
udfc
=
udfcHandle
;
uv_barrier_destroy
(
&
gUdfInitBarrier
);
udfc
->
gUdfcState
=
UDFC_STATE_STOPPING
;
// if (gUdfcState == UDFC_STATE_STOPPING) {
uv_async_send
(
&
udfc
->
gUdfLoopStopAsync
);
// uv_process_kill(&gUdfdProcess, SIGINT);
uv_thread_join
(
&
udfc
->
gUdfLoopThread
);
// }
uv_mutex_destroy
(
&
udfc
->
gUdfTaskQueueMutex
);
uv_async_send
(
&
gUdfLoopStopAsync
);
uv_barrier_destroy
(
&
udfc
->
gUdfInitBarrier
);
uv_thread_join
(
&
gUdfLoopThread
);
udfc
->
gUdfcState
=
UDFC_STATUS_FINAL
;
uv_mutex_destroy
(
&
gUdfTaskQueueMutex
);
taosMemoryFree
(
udfc
);
gUdfcState
=
UDFC_STATUS_FINAL
;
return
0
;
return
0
;
}
}
...
@@ -1026,11 +980,12 @@ int32_t udfcRunUvTask(SClientUdfTask *task, int8_t uvTaskType) {
...
@@ -1026,11 +980,12 @@ int32_t udfcRunUvTask(SClientUdfTask *task, int8_t uvTaskType) {
return
task
->
errCode
;
return
task
->
errCode
;
}
}
int32_t
setupUdf
(
char
udfName
[],
SEpSet
*
epSet
,
UdfHandle
*
h
andle
)
{
int32_t
setupUdf
(
UdfcHandle
udfc
,
char
udfName
[],
SEpSet
*
epSet
,
UdfcFuncHandle
*
funcH
andle
)
{
debugPrint
(
"%s"
,
"client setup udf"
);
debugPrint
(
"%s"
,
"client setup udf"
);
SClientUdfTask
*
task
=
taosMemoryMalloc
(
sizeof
(
SClientUdfTask
));
SClientUdfTask
*
task
=
taosMemoryMalloc
(
sizeof
(
SClientUdfTask
));
task
->
errCode
=
0
;
task
->
errCode
=
0
;
task
->
session
=
taosMemoryMalloc
(
sizeof
(
SUdfUvSession
));
task
->
session
=
taosMemoryMalloc
(
sizeof
(
SUdfUvSession
));
task
->
session
->
udfc
=
udfc
;
task
->
type
=
UDF_TASK_SETUP
;
task
->
type
=
UDF_TASK_SETUP
;
SUdfSetupRequest
*
req
=
&
task
->
_setup
.
req
;
SUdfSetupRequest
*
req
=
&
task
->
_setup
.
req
;
...
@@ -1046,13 +1001,13 @@ int32_t setupUdf(char udfName[], SEpSet *epSet, UdfHandle *handle) {
...
@@ -1046,13 +1001,13 @@ int32_t setupUdf(char udfName[], SEpSet *epSet, UdfHandle *handle) {
SUdfSetupResponse
*
rsp
=
&
task
->
_setup
.
rsp
;
SUdfSetupResponse
*
rsp
=
&
task
->
_setup
.
rsp
;
task
->
session
->
severHandle
=
rsp
->
udfHandle
;
task
->
session
->
severHandle
=
rsp
->
udfHandle
;
*
h
andle
=
task
->
session
;
*
funcH
andle
=
task
->
session
;
int32_t
err
=
task
->
errCode
;
int32_t
err
=
task
->
errCode
;
taosMemoryFree
(
task
);
taosMemoryFree
(
task
);
return
err
;
return
err
;
}
}
int32_t
callUdf
(
UdfHandle
handle
,
int8_t
callType
,
SSDataBlock
*
input
,
SUdfInterBuf
*
state
,
SUdfInterBuf
*
state2
,
int32_t
callUdf
(
Udf
cFunc
Handle
handle
,
int8_t
callType
,
SSDataBlock
*
input
,
SUdfInterBuf
*
state
,
SUdfInterBuf
*
state2
,
SSDataBlock
*
output
,
SUdfInterBuf
*
newState
)
{
SSDataBlock
*
output
,
SUdfInterBuf
*
newState
)
{
debugPrint
(
"%s"
,
"client call udf"
);
debugPrint
(
"%s"
,
"client call udf"
);
...
@@ -1121,7 +1076,7 @@ int32_t callUdf(UdfHandle handle, int8_t callType, SSDataBlock *input, SUdfInter
...
@@ -1121,7 +1076,7 @@ int32_t callUdf(UdfHandle handle, int8_t callType, SSDataBlock *input, SUdfInter
}
}
//TODO: translate these calls to callUdf
//TODO: translate these calls to callUdf
int32_t
callUdfAggInit
(
UdfHandle
handle
,
SUdfInterBuf
*
interBuf
)
{
int32_t
callUdfAggInit
(
Udf
cFunc
Handle
handle
,
SUdfInterBuf
*
interBuf
)
{
int8_t
callType
=
TSDB_UDF_CALL_AGG_INIT
;
int8_t
callType
=
TSDB_UDF_CALL_AGG_INIT
;
int32_t
err
=
callUdf
(
handle
,
callType
,
NULL
,
NULL
,
NULL
,
NULL
,
interBuf
);
int32_t
err
=
callUdf
(
handle
,
callType
,
NULL
,
NULL
,
NULL
,
NULL
,
interBuf
);
...
@@ -1131,7 +1086,7 @@ int32_t callUdfAggInit(UdfHandle handle, SUdfInterBuf *interBuf) {
...
@@ -1131,7 +1086,7 @@ int32_t callUdfAggInit(UdfHandle handle, SUdfInterBuf *interBuf) {
// input: block, state
// input: block, state
// output: interbuf,
// output: interbuf,
int32_t
callUdfAggProcess
(
UdfHandle
handle
,
SSDataBlock
*
block
,
SUdfInterBuf
*
state
,
SUdfInterBuf
*
newState
)
{
int32_t
callUdfAggProcess
(
Udf
cFunc
Handle
handle
,
SSDataBlock
*
block
,
SUdfInterBuf
*
state
,
SUdfInterBuf
*
newState
)
{
int8_t
callType
=
TSDB_UDF_CALL_AGG_PROC
;
int8_t
callType
=
TSDB_UDF_CALL_AGG_PROC
;
int32_t
err
=
callUdf
(
handle
,
callType
,
block
,
state
,
NULL
,
NULL
,
newState
);
int32_t
err
=
callUdf
(
handle
,
callType
,
block
,
state
,
NULL
,
NULL
,
newState
);
return
err
;
return
err
;
...
@@ -1139,7 +1094,7 @@ int32_t callUdfAggProcess(UdfHandle handle, SSDataBlock *block, SUdfInterBuf *st
...
@@ -1139,7 +1094,7 @@ int32_t callUdfAggProcess(UdfHandle handle, SSDataBlock *block, SUdfInterBuf *st
// input: interbuf1, interbuf2
// input: interbuf1, interbuf2
// output: resultBuf
// output: resultBuf
int32_t
callUdfAggMerge
(
UdfHandle
handle
,
SUdfInterBuf
*
interBuf1
,
SUdfInterBuf
*
interBuf2
,
SUdfInterBuf
*
resultBuf
)
{
int32_t
callUdfAggMerge
(
Udf
cFunc
Handle
handle
,
SUdfInterBuf
*
interBuf1
,
SUdfInterBuf
*
interBuf2
,
SUdfInterBuf
*
resultBuf
)
{
int8_t
callType
=
TSDB_UDF_CALL_AGG_MERGE
;
int8_t
callType
=
TSDB_UDF_CALL_AGG_MERGE
;
int32_t
err
=
callUdf
(
handle
,
callType
,
NULL
,
interBuf1
,
interBuf2
,
NULL
,
resultBuf
);
int32_t
err
=
callUdf
(
handle
,
callType
,
NULL
,
interBuf1
,
interBuf2
,
NULL
,
resultBuf
);
return
err
;
return
err
;
...
@@ -1147,7 +1102,7 @@ int32_t callUdfAggMerge(UdfHandle handle, SUdfInterBuf *interBuf1, SUdfInterBuf
...
@@ -1147,7 +1102,7 @@ int32_t callUdfAggMerge(UdfHandle handle, SUdfInterBuf *interBuf1, SUdfInterBuf
// input: interBuf
// input: interBuf
// output: resultData
// output: resultData
int32_t
callUdfAggFinalize
(
UdfHandle
handle
,
SUdfInterBuf
*
interBuf
,
SUdfInterBuf
*
resultData
)
{
int32_t
callUdfAggFinalize
(
Udf
cFunc
Handle
handle
,
SUdfInterBuf
*
interBuf
,
SUdfInterBuf
*
resultData
)
{
int8_t
callType
=
TSDB_UDF_CALL_AGG_PROC
;
int8_t
callType
=
TSDB_UDF_CALL_AGG_PROC
;
int32_t
err
=
callUdf
(
handle
,
callType
,
NULL
,
interBuf
,
NULL
,
NULL
,
resultData
);
int32_t
err
=
callUdf
(
handle
,
callType
,
NULL
,
interBuf
,
NULL
,
NULL
,
resultData
);
return
err
;
return
err
;
...
@@ -1155,13 +1110,13 @@ int32_t callUdfAggFinalize(UdfHandle handle, SUdfInterBuf *interBuf, SUdfInterBu
...
@@ -1155,13 +1110,13 @@ int32_t callUdfAggFinalize(UdfHandle handle, SUdfInterBuf *interBuf, SUdfInterBu
// input: block
// input: block
// output: resultData
// output: resultData
int32_t
callUdfScalaProcess
(
UdfHandle
handle
,
SSDataBlock
*
block
,
SSDataBlock
*
resultData
)
{
int32_t
callUdfScalaProcess
(
Udf
cFunc
Handle
handle
,
SSDataBlock
*
block
,
SSDataBlock
*
resultData
)
{
int8_t
callType
=
TSDB_UDF_CALL_SCALA_PROC
;
int8_t
callType
=
TSDB_UDF_CALL_SCALA_PROC
;
int32_t
err
=
callUdf
(
handle
,
callType
,
block
,
NULL
,
NULL
,
resultData
,
NULL
);
int32_t
err
=
callUdf
(
handle
,
callType
,
block
,
NULL
,
NULL
,
resultData
,
NULL
);
return
err
;
return
err
;
}
}
int32_t
teardownUdf
(
UdfHandle
handle
)
{
int32_t
teardownUdf
(
Udf
cFunc
Handle
handle
)
{
debugPrint
(
"%s"
,
"client teardown udf"
);
debugPrint
(
"%s"
,
"client teardown udf"
);
SClientUdfTask
*
task
=
taosMemoryMalloc
(
sizeof
(
SClientUdfTask
));
SClientUdfTask
*
task
=
taosMemoryMalloc
(
sizeof
(
SClientUdfTask
));
...
...
source/libs/function/src/udfd.c
浏览文件 @
162b3087
...
@@ -27,7 +27,10 @@
...
@@ -27,7 +27,10 @@
typedef
struct
SUdfdContext
{
typedef
struct
SUdfdContext
{
uv_loop_t
*
loop
;
uv_loop_t
*
loop
;
uv_pipe_t
ctrlPipe
;
uv_signal_t
intrSignal
;
char
listenPipeName
[
UDF_LISTEN_PIPE_NAME_LEN
];
char
listenPipeName
[
UDF_LISTEN_PIPE_NAME_LEN
];
uv_pipe_t
listeningPipe
;
void
*
clientRpc
;
void
*
clientRpc
;
uv_mutex_t
udfsMutex
;
uv_mutex_t
udfsMutex
;
...
@@ -76,9 +79,9 @@ typedef struct SUdf {
...
@@ -76,9 +79,9 @@ typedef struct SUdf {
// TODO: low priority: change name onxxx to xxxCb, and udfc or udfd as prefix
// TODO: low priority: change name onxxx to xxxCb, and udfc or udfd as prefix
// TODO: add private udf structure.
// TODO: add private udf structure.
typedef
struct
SUdfHandle
{
typedef
struct
SUdf
cFunc
Handle
{
SUdf
*
udf
;
SUdf
*
udf
;
}
SUdfHandle
;
}
SUdf
cFunc
Handle
;
int32_t
udfdLoadUdf
(
char
*
udfName
,
SUdf
*
udf
)
{
int32_t
udfdLoadUdf
(
char
*
udfName
,
SUdf
*
udf
)
{
strcpy
(
udf
->
name
,
udfName
);
strcpy
(
udf
->
name
,
udfName
);
...
@@ -143,7 +146,7 @@ void udfdProcessRequest(uv_work_t *req) {
...
@@ -143,7 +146,7 @@ void udfdProcessRequest(uv_work_t *req) {
}
}
uv_mutex_unlock
(
&
udf
->
lock
);
uv_mutex_unlock
(
&
udf
->
lock
);
}
}
SUdf
Handle
*
handle
=
taosMemoryMalloc
(
sizeof
(
SUdf
Handle
));
SUdf
cFuncHandle
*
handle
=
taosMemoryMalloc
(
sizeof
(
SUdfcFunc
Handle
));
handle
->
udf
=
udf
;
handle
->
udf
=
udf
;
// TODO: allocate private structure and call init function and set it to handle
// TODO: allocate private structure and call init function and set it to handle
SUdfResponse
rsp
;
SUdfResponse
rsp
;
...
@@ -166,7 +169,7 @@ void udfdProcessRequest(uv_work_t *req) {
...
@@ -166,7 +169,7 @@ void udfdProcessRequest(uv_work_t *req) {
case
UDF_TASK_CALL
:
{
case
UDF_TASK_CALL
:
{
SUdfCallRequest
*
call
=
&
request
.
call
;
SUdfCallRequest
*
call
=
&
request
.
call
;
fnDebug
(
"%"
PRId64
"call request. call type %d, handle: %"
PRIx64
,
request
.
seqNum
,
call
->
callType
,
call
->
udfHandle
);
fnDebug
(
"%"
PRId64
"call request. call type %d, handle: %"
PRIx64
,
request
.
seqNum
,
call
->
callType
,
call
->
udfHandle
);
SUdf
Handle
*
handle
=
(
SUdf
Handle
*
)(
call
->
udfHandle
);
SUdf
cFuncHandle
*
handle
=
(
SUdfcFunc
Handle
*
)(
call
->
udfHandle
);
SUdf
*
udf
=
handle
->
udf
;
SUdf
*
udf
=
handle
->
udf
;
SUdfDataBlock
input
=
{
0
};
SUdfDataBlock
input
=
{
0
};
...
@@ -204,7 +207,7 @@ void udfdProcessRequest(uv_work_t *req) {
...
@@ -204,7 +207,7 @@ void udfdProcessRequest(uv_work_t *req) {
case
UDF_TASK_TEARDOWN
:
{
case
UDF_TASK_TEARDOWN
:
{
SUdfTeardownRequest
*
teardown
=
&
request
.
teardown
;
SUdfTeardownRequest
*
teardown
=
&
request
.
teardown
;
fnInfo
(
"teardown. %"
PRId64
"handle:%"
PRIx64
,
request
.
seqNum
,
teardown
->
udfHandle
)
fnInfo
(
"teardown. %"
PRId64
"handle:%"
PRIx64
,
request
.
seqNum
,
teardown
->
udfHandle
)
SUdf
Handle
*
handle
=
(
SUdf
Handle
*
)(
teardown
->
udfHandle
);
SUdf
cFuncHandle
*
handle
=
(
SUdfcFunc
Handle
*
)(
teardown
->
udfHandle
);
SUdf
*
udf
=
handle
->
udf
;
SUdf
*
udf
=
handle
->
udf
;
bool
unloadUdf
=
false
;
bool
unloadUdf
=
false
;
uv_mutex_lock
(
&
global
.
udfsMutex
);
uv_mutex_lock
(
&
global
.
udfsMutex
);
...
@@ -380,10 +383,12 @@ void udfdOnNewConnection(uv_stream_t *server, int status) {
...
@@ -380,10 +383,12 @@ void udfdOnNewConnection(uv_stream_t *server, int status) {
}
}
}
}
void
removeListeningPipe
(
int
sig
)
{
void
udfdIntrSignalHandler
(
uv_signal_t
*
handle
,
int
signum
)
{
fnInfo
(
"udfd signal received: %d
\n
"
,
signum
);
uv_fs_t
req
;
uv_fs_t
req
;
uv_fs_unlink
(
global
.
loop
,
&
req
,
"udf.sock"
,
NULL
);
uv_fs_unlink
(
global
.
loop
,
&
req
,
global
.
listenPipeName
,
NULL
);
exit
(
0
);
uv_signal_stop
(
handle
);
uv_stop
(
global
.
loop
);
}
}
void
udfdProcessRpcRsp
(
void
*
parent
,
SRpcMsg
*
pMsg
,
SEpSet
*
pEpSet
)
{
return
;
}
void
udfdProcessRpcRsp
(
void
*
parent
,
SRpcMsg
*
pMsg
,
SEpSet
*
pEpSet
)
{
return
;
}
...
@@ -492,37 +497,67 @@ static int32_t udfdInitLog() {
...
@@ -492,37 +497,67 @@ static int32_t udfdInitLog() {
return
taosCreateLog
(
logName
,
1
,
configDir
,
NULL
,
NULL
,
NULL
,
0
);
return
taosCreateLog
(
logName
,
1
,
configDir
,
NULL
,
NULL
,
NULL
,
0
);
}
}
void
udfdCtrlAllocBufCb
(
uv_handle_t
*
handle
,
size_t
suggested_size
,
uv_buf_t
*
buf
)
{
buf
->
base
=
taosMemoryMalloc
(
suggested_size
);
buf
->
len
=
suggested_size
;
}
void
udfdCtrlReadCb
(
uv_stream_t
*
q
,
ssize_t
nread
,
const
uv_buf_t
*
buf
)
{
if
(
nread
<
0
)
{
fnError
(
"udfd ctrl pipe read error. %s"
,
uv_err_name
(
nread
));
uv_close
((
uv_handle_t
*
)
q
,
NULL
);
uv_stop
(
global
.
loop
);
return
;
}
fnError
(
"udfd ctrl pipe read %zu bytes"
,
nread
);
taosMemoryFree
(
buf
->
base
);
}
static
int32_t
removeListeningPipe
()
{
uv_fs_t
req
;
int
err
=
uv_fs_unlink
(
global
.
loop
,
&
req
,
global
.
listenPipeName
,
NULL
);
uv_fs_req_cleanup
(
&
req
);
return
err
;
}
static
int32_t
udfdUvInit
()
{
static
int32_t
udfdUvInit
()
{
uv_loop_t
*
loop
=
taosMemoryMalloc
(
sizeof
(
uv_loop_t
));
uv_loop_t
*
loop
=
taosMemoryMalloc
(
sizeof
(
uv_loop_t
));
if
(
loop
)
{
if
(
loop
)
{
uv_loop_init
(
loop
);
uv_loop_init
(
loop
);
}
}
global
.
loop
=
loop
;
global
.
loop
=
loop
;
uv_pipe_init
(
global
.
loop
,
&
global
.
ctrlPipe
,
1
);
uv_pipe_open
(
&
global
.
ctrlPipe
,
0
);
uv_read_start
((
uv_stream_t
*
)
&
global
.
ctrlPipe
,
udfdCtrlAllocBufCb
,
udfdCtrlReadCb
);
char
dnodeId
[
8
]
=
{
0
};
char
dnodeId
[
8
]
=
{
0
};
size_t
dnodeIdSize
;
size_t
dnodeIdSize
;
uv_os_getenv
(
"DNODE_ID"
,
dnodeId
,
&
dnodeIdSize
);
int32_t
err
=
uv_os_getenv
(
"DNODE_ID"
,
dnodeId
,
&
dnodeIdSize
);
if
(
err
!=
0
)
{
dnodeId
[
0
]
=
'1'
;
}
char
listenPipeName
[
32
]
=
{
0
};
char
listenPipeName
[
32
]
=
{
0
};
snprintf
(
listenPipeName
,
sizeof
(
listenPipeName
),
"%s%s"
,
UDF_LISTEN_PIPE_NAME_PREFIX
,
dnodeId
);
snprintf
(
listenPipeName
,
sizeof
(
listenPipeName
),
"%s%s"
,
UDF_LISTEN_PIPE_NAME_PREFIX
,
dnodeId
);
strcpy
(
global
.
listenPipeName
,
listenPipeName
);
strcpy
(
global
.
listenPipeName
,
listenPipeName
);
uv_fs_t
req
;
removeListeningPipe
();
uv_fs_unlink
(
global
.
loop
,
&
req
,
global
.
listenPipeName
,
NULL
);
uv_pipe_t
server
;
uv_pipe_init
(
global
.
loop
,
&
global
.
listeningPipe
,
0
);
uv_pipe_init
(
global
.
loop
,
&
server
,
0
);
signal
(
SIGINT
,
removeListeningPipe
);
uv_signal_init
(
global
.
loop
,
&
global
.
intrSignal
);
uv_signal_start
(
&
global
.
intrSignal
,
udfdIntrSignalHandler
,
SIGINT
);
int
r
;
int
r
;
fnInfo
(
"bind to pipe %s"
,
global
.
listenPipeName
);
fnInfo
(
"bind to pipe %s"
,
global
.
listenPipeName
);
if
((
r
=
uv_pipe_bind
(
&
server
,
listenPipeName
)))
{
if
((
r
=
uv_pipe_bind
(
&
global
.
listeningPipe
,
listenPipeName
)))
{
fnError
(
"Bind error %s"
,
uv_err_name
(
r
));
fnError
(
"Bind error %s"
,
uv_err_name
(
r
));
removeListeningPipe
(
0
);
removeListeningPipe
();
return
-
1
;
return
-
1
;
}
}
if
((
r
=
uv_listen
((
uv_stream_t
*
)
&
server
,
128
,
udfdOnNewConnection
)))
{
if
((
r
=
uv_listen
((
uv_stream_t
*
)
&
global
.
listeningPipe
,
128
,
udfdOnNewConnection
)))
{
fnError
(
"Listen error %s"
,
uv_err_name
(
r
));
fnError
(
"Listen error %s"
,
uv_err_name
(
r
));
removeListeningPipe
(
0
);
removeListeningPipe
();
return
-
2
;
return
-
2
;
}
}
return
0
;
return
0
;
...
...
source/libs/function/test/runUdf.c
浏览文件 @
162b3087
...
@@ -8,7 +8,8 @@
...
@@ -8,7 +8,8 @@
#include "tdatablock.h"
#include "tdatablock.h"
int
main
(
int
argc
,
char
*
argv
[])
{
int
main
(
int
argc
,
char
*
argv
[])
{
createUdfdProxy
(
1
);
UdfcHandle
udfc
;
udfcOpen
(
1
,
&
udfc
);
uv_sleep
(
1000
);
uv_sleep
(
1000
);
char
path
[
256
]
=
{
0
};
char
path
[
256
]
=
{
0
};
size_t
cwdSize
=
256
;
size_t
cwdSize
=
256
;
...
@@ -20,9 +21,9 @@ int main(int argc, char *argv[]) {
...
@@ -20,9 +21,9 @@ int main(int argc, char *argv[]) {
fprintf
(
stdout
,
"current working directory:%s
\n
"
,
path
);
fprintf
(
stdout
,
"current working directory:%s
\n
"
,
path
);
strcat
(
path
,
"/libudf1.so"
);
strcat
(
path
,
"/libudf1.so"
);
UdfHandle
handle
;
Udf
cFunc
Handle
handle
;
SEpSet
epSet
;
SEpSet
epSet
;
setupUdf
(
"udf1"
,
&
epSet
,
&
handle
);
setupUdf
(
udfc
,
"udf1"
,
&
epSet
,
&
handle
);
SSDataBlock
block
=
{
0
};
SSDataBlock
block
=
{
0
};
SSDataBlock
*
pBlock
=
&
block
;
SSDataBlock
*
pBlock
=
&
block
;
...
@@ -53,5 +54,5 @@ int main(int argc, char *argv[]) {
...
@@ -53,5 +54,5 @@ int main(int argc, char *argv[]) {
}
}
teardownUdf
(
handle
);
teardownUdf
(
handle
);
destroyUdfdProxy
(
1
);
udfcClose
(
udfc
);
}
}
source/libs/parser/inc/sql.y
浏览文件 @
162b3087
...
@@ -837,6 +837,8 @@ query_expression(A) ::=
...
@@ -837,6 +837,8 @@ query_expression(A) ::=
query_expression_body(A) ::= query_primary(B). { A = B; }
query_expression_body(A) ::= query_primary(B). { A = B; }
query_expression_body(A) ::=
query_expression_body(A) ::=
query_expression_body(B) UNION ALL query_expression_body(D). { A = createSetOperator(pCxt, SET_OP_TYPE_UNION_ALL, B, D); }
query_expression_body(B) UNION ALL query_expression_body(D). { A = createSetOperator(pCxt, SET_OP_TYPE_UNION_ALL, B, D); }
query_expression_body(A) ::=
query_expression_body(B) UNION query_expression_body(D). { A = createSetOperator(pCxt, SET_OP_TYPE_UNION, B, D); }
query_primary(A) ::= query_specification(B). { A = B; }
query_primary(A) ::= query_specification(B). { A = B; }
//query_primary(A) ::=
//query_primary(A) ::=
...
...
source/libs/parser/src/parTranslater.c
浏览文件 @
162b3087
此差异已折叠。
点击以展开。
source/libs/parser/src/parUtil.c
浏览文件 @
162b3087
...
@@ -118,6 +118,8 @@ static char* getSyntaxErrFormat(int32_t errCode) {
...
@@ -118,6 +118,8 @@ static char* getSyntaxErrFormat(int32_t errCode) {
return
"sliding value can not less than 1% of interval value"
;
return
"sliding value can not less than 1% of interval value"
;
case
TSDB_CODE_PAR_ONLY_ONE_JSON_TAG
:
case
TSDB_CODE_PAR_ONLY_ONE_JSON_TAG
:
return
"Only one tag if there is a json tag"
;
return
"Only one tag if there is a json tag"
;
case
TSDB_CODE_PAR_INCORRECT_NUM_OF_COL
:
return
"Query block has incorrect number of result columns"
;
case
TSDB_CODE_OUT_OF_MEMORY
:
case
TSDB_CODE_OUT_OF_MEMORY
:
return
"Out of memory"
;
return
"Out of memory"
;
default:
default:
...
...
source/libs/parser/src/sql.c
浏览文件 @
162b3087
此差异已折叠。
点击以展开。
source/libs/planner/src/planLogicCreater.c
浏览文件 @
162b3087
此差异已折叠。
点击以展开。
source/libs/planner/src/planPhysiCreater.c
浏览文件 @
162b3087
...
@@ -38,7 +38,7 @@ typedef struct SPhysiPlanContext {
...
@@ -38,7 +38,7 @@ typedef struct SPhysiPlanContext {
static
int32_t
getSlotKey
(
SNode
*
pNode
,
const
char
*
pStmtName
,
char
*
pKey
)
{
static
int32_t
getSlotKey
(
SNode
*
pNode
,
const
char
*
pStmtName
,
char
*
pKey
)
{
if
(
QUERY_NODE_COLUMN
==
nodeType
(
pNode
))
{
if
(
QUERY_NODE_COLUMN
==
nodeType
(
pNode
))
{
SColumnNode
*
pCol
=
(
SColumnNode
*
)
pNode
;
SColumnNode
*
pCol
=
(
SColumnNode
*
)
pNode
;
if
(
NULL
!=
pStmtName
)
{
if
(
NULL
!=
pStmtName
&&
'\0'
!=
pStmtName
[
0
]
)
{
return
sprintf
(
pKey
,
"%s.%s"
,
pStmtName
,
pCol
->
node
.
aliasName
);
return
sprintf
(
pKey
,
"%s.%s"
,
pStmtName
,
pCol
->
node
.
aliasName
);
}
}
if
(
'\0'
==
pCol
->
tableAlias
[
0
])
{
if
(
'\0'
==
pCol
->
tableAlias
[
0
])
{
...
@@ -47,7 +47,7 @@ static int32_t getSlotKey(SNode* pNode, const char* pStmtName, char* pKey) {
...
@@ -47,7 +47,7 @@ static int32_t getSlotKey(SNode* pNode, const char* pStmtName, char* pKey) {
return
sprintf
(
pKey
,
"%s.%s"
,
pCol
->
tableAlias
,
pCol
->
colName
);
return
sprintf
(
pKey
,
"%s.%s"
,
pCol
->
tableAlias
,
pCol
->
colName
);
}
}
if
(
NULL
!=
pStmtName
)
{
if
(
NULL
!=
pStmtName
&&
'\0'
!=
pStmtName
[
0
]
)
{
return
sprintf
(
pKey
,
"%s.%s"
,
pStmtName
,
((
SExprNode
*
)
pNode
)
->
aliasName
);
return
sprintf
(
pKey
,
"%s.%s"
,
pStmtName
,
((
SExprNode
*
)
pNode
)
->
aliasName
);
}
}
return
sprintf
(
pKey
,
"%s"
,
((
SExprNode
*
)
pNode
)
->
aliasName
);
return
sprintf
(
pKey
,
"%s"
,
((
SExprNode
*
)
pNode
)
->
aliasName
);
...
...
source/libs/planner/src/planScaleOut.c
浏览文件 @
162b3087
此差异已折叠。
点击以展开。
source/libs/planner/src/planSpliter.c
浏览文件 @
162b3087
此差异已折叠。
点击以展开。
source/libs/planner/test/planSetOpTest.cpp
0 → 100644
浏览文件 @
162b3087
/*
* Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
*
* This program is free software: you can use, redistribute, and/or modify
* it under the terms of the GNU Affero General Public License, version 3
* or later ("AGPL"), as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "planTestUtil.h"
#include "planner.h"
using
namespace
std
;
class
PlanSetOpTest
:
public
PlannerTestBase
{
};
TEST_F
(
PlanSetOpTest
,
unionAll
)
{
useDb
(
"root"
,
"test"
);
run
(
"select c1, c2 from t1 where c1 > 10 union all select c1, c2 from t1 where c1 > 20"
);
}
TEST_F
(
PlanSetOpTest
,
union
)
{
useDb
(
"root"
,
"test"
);
run
(
"select c1, c2 from t1 where c1 > 10 union select c1, c2 from t1 where c1 > 20"
);
}
source/libs/planner/test/plan
ner
TestMain.cpp
→
source/libs/planner/test/planTestMain.cpp
浏览文件 @
162b3087
文件已移动
source/libs/planner/test/planTestUtil.cpp
浏览文件 @
162b3087
此差异已折叠。
点击以展开。
source/libs/scalar/src/sclfunc.c
浏览文件 @
162b3087
此差异已折叠。
点击以展开。
source/libs/transport/inc/transComm.h
浏览文件 @
162b3087
此差异已折叠。
点击以展开。
source/libs/transport/inc/transportInt.h
浏览文件 @
162b3087
此差异已折叠。
点击以展开。
source/libs/transport/src/trans.c
浏览文件 @
162b3087
此差异已折叠。
点击以展开。
source/libs/transport/src/transCli.c
浏览文件 @
162b3087
此差异已折叠。
点击以展开。
source/libs/transport/src/transSrv.c
浏览文件 @
162b3087
此差异已折叠。
点击以展开。
source/os/src/osEnv.c
浏览文件 @
162b3087
此差异已折叠。
点击以展开。
source/os/src/osFile.c
浏览文件 @
162b3087
此差异已折叠。
点击以展开。
source/os/src/osProc.c
浏览文件 @
162b3087
此差异已折叠。
点击以展开。
source/util/src/talgo.c
浏览文件 @
162b3087
此差异已折叠。
点击以展开。
source/util/src/tlog.c
浏览文件 @
162b3087
此差异已折叠。
点击以展开。
tests/script/runAllSimCases.sh
浏览文件 @
162b3087
!
/bin/bash
#
!/bin/bash
##################################################
##################################################
#
#
...
...
tests/script/test.sh
浏览文件 @
162b3087
此差异已折叠。
点击以展开。
tests/script/tsim/query/session.sim
浏览文件 @
162b3087
此差异已折叠。
点击以展开。
tests/script/tsim/tmq/basic1.sim
浏览文件 @
162b3087
此差异已折叠。
点击以展开。
tests/script/tsim/tmq/clearConsume.sim
0 → 100644
浏览文件 @
162b3087
此差异已折叠。
点击以展开。
tests/script/tsim/tmq/consume.sh
浏览文件 @
162b3087
此差异已折叠。
点击以展开。
tests/script/tsim/tmq/prepareBasicEnv.sim
0 → 100644
浏览文件 @
162b3087
此差异已折叠。
点击以展开。
tests/system-test/2-query/cast.py
浏览文件 @
162b3087
此差异已折叠。
点击以展开。
tests/system-test/fulltest.sh
浏览文件 @
162b3087
此差异已折叠。
点击以展开。
tests/test/c/tmqSim.c
浏览文件 @
162b3087
此差异已折叠。
点击以展开。
tools/shell/src/shellEngine.c
浏览文件 @
162b3087
此差异已折叠。
点击以展开。
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录