Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
ba1dd2ca
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看板
提交
ba1dd2ca
编写于
3月 24, 2022
作者:
H
Haojun Liao
浏览文件
操作
浏览文件
下载
差异文件
[td-13039] merge 3.0.
上级
45fec965
6c5f3086
变更
61
展开全部
显示空白变更内容
内联
并排
Showing
61 changed file
with
2363 addition
and
1156 deletion
+2363
-1156
include/common/taosdef.h
include/common/taosdef.h
+0
-2
include/common/tmsg.h
include/common/tmsg.h
+63
-20
include/dnode/mnode/mnode.h
include/dnode/mnode/mnode.h
+2
-0
include/libs/nodes/nodes.h
include/libs/nodes/nodes.h
+2
-0
include/libs/nodes/plannodes.h
include/libs/nodes/plannodes.h
+13
-3
include/libs/nodes/querynodes.h
include/libs/nodes/querynodes.h
+1
-1
include/util/taoserror.h
include/util/taoserror.h
+1
-0
include/util/tdef.h
include/util/tdef.h
+4
-0
source/client/src/tmq.c
source/client/src/tmq.c
+1
-1
source/common/src/tmsg.c
source/common/src/tmsg.c
+122
-19
source/dnode/mgmt/container/inc/dnd.h
source/dnode/mgmt/container/inc/dnd.h
+2
-4
source/dnode/mgmt/container/src/dndObj.c
source/dnode/mgmt/container/src/dndObj.c
+1
-0
source/dnode/mgmt/container/src/dndTransport.c
source/dnode/mgmt/container/src/dndTransport.c
+29
-21
source/dnode/mgmt/dnode/src/dmMsg.c
source/dnode/mgmt/dnode/src/dmMsg.c
+13
-13
source/dnode/mgmt/mnode/src/mmMsg.c
source/dnode/mgmt/mnode/src/mmMsg.c
+82
-76
source/dnode/mgmt/qnode/src/qmMsg.c
source/dnode/mgmt/qnode/src/qmMsg.c
+9
-9
source/dnode/mgmt/snode/src/smMsg.c
source/dnode/mgmt/snode/src/smMsg.c
+2
-2
source/dnode/mgmt/test/vnode/vnode.cpp
source/dnode/mgmt/test/vnode/vnode.cpp
+2
-0
source/dnode/mgmt/vnode/src/vmMsg.c
source/dnode/mgmt/vnode/src/vmMsg.c
+43
-43
source/dnode/mnode/impl/inc/mndDef.h
source/dnode/mnode/impl/inc/mndDef.h
+11
-1
source/dnode/mnode/impl/inc/mndStream.h
source/dnode/mnode/impl/inc/mndStream.h
+2
-0
source/dnode/mnode/impl/src/mndDb.c
source/dnode/mnode/impl/src/mndDb.c
+31
-0
source/dnode/mnode/impl/src/mndDef.c
source/dnode/mnode/impl/src/mndDef.c
+22
-21
source/dnode/mnode/impl/src/mndScheduler.c
source/dnode/mnode/impl/src/mndScheduler.c
+17
-21
source/dnode/mnode/impl/src/mndSma.c
source/dnode/mnode/impl/src/mndSma.c
+22
-0
source/dnode/mnode/impl/src/mndStb.c
source/dnode/mnode/impl/src/mndStb.c
+98
-18
source/dnode/mnode/impl/src/mndStream.c
source/dnode/mnode/impl/src/mndStream.c
+44
-31
source/dnode/mnode/impl/src/mndVgroup.c
source/dnode/mnode/impl/src/mndVgroup.c
+2
-0
source/dnode/mnode/impl/src/mnode.c
source/dnode/mnode/impl/src/mnode.c
+3
-5
source/dnode/mnode/impl/test/sma/sma.cpp
source/dnode/mnode/impl/test/sma/sma.cpp
+95
-37
source/dnode/vnode/src/inc/tqInt.h
source/dnode/vnode/src/inc/tqInt.h
+6
-5
source/dnode/vnode/src/inc/vnd.h
source/dnode/vnode/src/inc/vnd.h
+17
-1
source/dnode/vnode/src/tq/tq.c
source/dnode/vnode/src/tq/tq.c
+4
-2
source/libs/executor/src/executorimpl.c
source/libs/executor/src/executorimpl.c
+1
-1
source/libs/nodes/src/nodesCloneFuncs.c
source/libs/nodes/src/nodesCloneFuncs.c
+5
-2
source/libs/nodes/src/nodesCodeFuncs.c
source/libs/nodes/src/nodesCodeFuncs.c
+140
-21
source/libs/nodes/src/nodesTraverseFuncs.c
source/libs/nodes/src/nodesTraverseFuncs.c
+7
-2
source/libs/nodes/src/nodesUtilFuncs.c
source/libs/nodes/src/nodesUtilFuncs.c
+15
-1
source/libs/parser/inc/parAst.h
source/libs/parser/inc/parAst.h
+1
-1
source/libs/parser/inc/sql.y
source/libs/parser/inc/sql.y
+1
-1
source/libs/parser/src/parAstCreater.c
source/libs/parser/src/parAstCreater.c
+2
-2
source/libs/parser/src/parTranslater.c
source/libs/parser/src/parTranslater.c
+42
-8
source/libs/parser/src/parUtil.c
source/libs/parser/src/parUtil.c
+3
-0
source/libs/parser/src/sql.c
source/libs/parser/src/sql.c
+184
-185
source/libs/parser/test/mockCatalogService.cpp
source/libs/parser/test/mockCatalogService.cpp
+28
-15
source/libs/parser/test/parserAstTest.cpp
source/libs/parser/test/parserAstTest.cpp
+73
-21
source/libs/planner/inc/planInt.h
source/libs/planner/inc/planInt.h
+4
-3
source/libs/planner/src/planLogicCreater.c
source/libs/planner/src/planLogicCreater.c
+38
-23
source/libs/planner/src/planOptimizer.c
source/libs/planner/src/planOptimizer.c
+20
-0
source/libs/planner/src/planPhysiCreater.c
source/libs/planner/src/planPhysiCreater.c
+416
-400
source/libs/planner/src/planScaleOut.c
source/libs/planner/src/planScaleOut.c
+203
-0
source/libs/planner/src/planSpliter.c
source/libs/planner/src/planSpliter.c
+52
-8
source/libs/planner/src/planner.c
source/libs/planner/src/planner.c
+15
-6
source/libs/planner/test/plannerTest.cpp
source/libs/planner/test/plannerTest.cpp
+51
-37
tests/script/jenkins/basic.txt
tests/script/jenkins/basic.txt
+6
-0
tests/script/tsim/db/basic7.sim
tests/script/tsim/db/basic7.sim
+1
-0
tests/script/tsim/insert/backquote.sim
tests/script/tsim/insert/backquote.sim
+41
-29
tests/script/tsim/show/basic.sim
tests/script/tsim/show/basic.sim
+215
-0
tests/script/tsim/testCaseSuite.sim
tests/script/tsim/testCaseSuite.sim
+5
-3
tools/shell/src/shellMain.c
tools/shell/src/shellMain.c
+1
-1
tools/shell/src/tnettest.c
tools/shell/src/tnettest.c
+27
-30
未找到文件。
include/common/taosdef.h
浏览文件 @
ba1dd2ca
...
@@ -78,8 +78,6 @@ typedef enum {
...
@@ -78,8 +78,6 @@ typedef enum {
extern
char
*
qtypeStr
[];
extern
char
*
qtypeStr
[];
#define TSDB_PORT_DNODEDNODE 5
#define TSDB_PORT_SYNC 10
#define TSDB_PORT_HTTP 11
#define TSDB_PORT_HTTP 11
#ifdef __cplusplus
#ifdef __cplusplus
...
...
include/common/tmsg.h
浏览文件 @
ba1dd2ca
...
@@ -184,6 +184,13 @@ typedef struct SField {
...
@@ -184,6 +184,13 @@ typedef struct SField {
int32_t
bytes
;
int32_t
bytes
;
}
SField
;
}
SField
;
typedef
struct
SRetention
{
int32_t
freq
;
int32_t
keep
;
int8_t
freqUnit
;
int8_t
keepUnit
;
}
SRetention
;
#pragma pack(push, 1)
#pragma pack(push, 1)
// null-terminated string instead of char array to avoid too many memory consumption in case of more than 1M tableMeta
// null-terminated string instead of char array to avoid too many memory consumption in case of more than 1M tableMeta
...
@@ -269,12 +276,18 @@ typedef struct SSchema {
...
@@ -269,12 +276,18 @@ typedef struct SSchema {
typedef
struct
{
typedef
struct
{
char
name
[
TSDB_TABLE_FNAME_LEN
];
char
name
[
TSDB_TABLE_FNAME_LEN
];
int8_t
igExists
;
int8_t
igExists
;
float
xFilesFactor
;
int32_t
aggregationMethod
;
int32_t
delay
;
int32_t
ttl
;
int32_t
numOfColumns
;
int32_t
numOfColumns
;
int32_t
numOfTags
;
int32_t
numOfTags
;
int32_t
numOfSmas
;
int32_t
commentLen
;
int32_t
commentLen
;
SArray
*
pColumns
;
SArray
*
pColumns
;
// array of SField
SArray
*
pTags
;
SArray
*
pTags
;
// array of SField
char
*
comment
;
SArray
*
pSmas
;
// array of SField
char
*
comment
;
}
SMCreateStbReq
;
}
SMCreateStbReq
;
int32_t
tSerializeSMCreateStbReq
(
void
*
buf
,
int32_t
bufLen
,
SMCreateStbReq
*
pReq
);
int32_t
tSerializeSMCreateStbReq
(
void
*
buf
,
int32_t
bufLen
,
SMCreateStbReq
*
pReq
);
...
@@ -501,10 +514,13 @@ typedef struct {
...
@@ -501,10 +514,13 @@ typedef struct {
int8_t
cacheLastRow
;
int8_t
cacheLastRow
;
int8_t
ignoreExist
;
int8_t
ignoreExist
;
int8_t
streamMode
;
int8_t
streamMode
;
int32_t
numOfRetensions
;
SArray
*
pRetensions
;
// SRetention
}
SCreateDbReq
;
}
SCreateDbReq
;
int32_t
tSerializeSCreateDbReq
(
void
*
buf
,
int32_t
bufLen
,
SCreateDbReq
*
pReq
);
int32_t
tSerializeSCreateDbReq
(
void
*
buf
,
int32_t
bufLen
,
SCreateDbReq
*
pReq
);
int32_t
tDeserializeSCreateDbReq
(
void
*
buf
,
int32_t
bufLen
,
SCreateDbReq
*
pReq
);
int32_t
tDeserializeSCreateDbReq
(
void
*
buf
,
int32_t
bufLen
,
SCreateDbReq
*
pReq
);
void
tFreeSCreateDbReq
(
SCreateDbReq
*
pReq
);
typedef
struct
{
typedef
struct
{
char
db
[
TSDB_DB_FNAME_LEN
];
char
db
[
TSDB_DB_FNAME_LEN
];
...
@@ -749,11 +765,13 @@ typedef struct {
...
@@ -749,11 +765,13 @@ typedef struct {
int8_t
selfIndex
;
int8_t
selfIndex
;
int8_t
streamMode
;
int8_t
streamMode
;
SReplica
replicas
[
TSDB_MAX_REPLICA
];
SReplica
replicas
[
TSDB_MAX_REPLICA
];
int32_t
numOfRetensions
;
SArray
*
pRetensions
;
// SRetention
}
SCreateVnodeReq
,
SAlterVnodeReq
;
}
SCreateVnodeReq
,
SAlterVnodeReq
;
int32_t
tSerializeSCreateVnodeReq
(
void
*
buf
,
int32_t
bufLen
,
SCreateVnodeReq
*
pReq
);
int32_t
tSerializeSCreateVnodeReq
(
void
*
buf
,
int32_t
bufLen
,
SCreateVnodeReq
*
pReq
);
int32_t
tDeserializeSCreateVnodeReq
(
void
*
buf
,
int32_t
bufLen
,
SCreateVnodeReq
*
pReq
);
int32_t
tDeserializeSCreateVnodeReq
(
void
*
buf
,
int32_t
bufLen
,
SCreateVnodeReq
*
pReq
);
int32_t
tFreeSCreateVnodeReq
(
SCreateVnodeReq
*
pReq
);
typedef
struct
{
typedef
struct
{
int32_t
vgId
;
int32_t
vgId
;
...
@@ -1149,7 +1167,7 @@ typedef struct {
...
@@ -1149,7 +1167,7 @@ typedef struct {
typedef
struct
{
typedef
struct
{
char
name
[
TSDB_TOPIC_FNAME_LEN
];
char
name
[
TSDB_TOPIC_FNAME_LEN
];
char
output
TbName
[
TSDB_TABLE_
NAME_LEN
];
char
output
STbName
[
TSDB_TABLE_F
NAME_LEN
];
int8_t
igExists
;
int8_t
igExists
;
char
*
sql
;
char
*
sql
;
char
*
ast
;
char
*
ast
;
...
@@ -2353,6 +2371,26 @@ enum {
...
@@ -2353,6 +2371,26 @@ enum {
STREAM_NEXT_OP_DST__SND
,
STREAM_NEXT_OP_DST__SND
,
};
};
enum
{
STREAM_SOURCE_TYPE__NONE
=
1
,
STREAM_SOURCE_TYPE__SUPER
,
STREAM_SOURCE_TYPE__CHILD
,
STREAM_SOURCE_TYPE__NORMAL
,
};
enum
{
STREAM_SINK_TYPE__NONE
=
1
,
STREAM_SINK_TYPE__INPLACE
,
STREAM_SINK_TYPE__ASSIGNED
,
STREAM_SINK_TYPE__MULTIPLE
,
STREAM_SINK_TYPE__TEMPORARY
,
};
enum
{
STREAM_TYPE__NORMAL
=
1
,
STREAM_TYPE__SMA
,
};
typedef
struct
{
typedef
struct
{
void
*
inputHandle
;
void
*
inputHandle
;
void
*
executor
;
void
*
executor
;
...
@@ -2363,28 +2401,33 @@ typedef struct {
...
@@ -2363,28 +2401,33 @@ typedef struct {
int32_t
taskId
;
int32_t
taskId
;
int32_t
level
;
int32_t
level
;
int8_t
status
;
int8_t
status
;
int8_t
pipeSource
;
int8_t
pipeSink
;
int8_t
numOfRunners
;
int8_t
parallelizable
;
int8_t
parallelizable
;
int8_t
nextOpDst
;
// vnode or snode
// vnode or snode
int8_t
nextOpDst
;
int8_t
sourceType
;
int8_t
sinkType
;
// for sink type assigned
int32_t
sinkVgId
;
SEpSet
NextOpEp
;
SEpSet
NextOpEp
;
// executor meta info
char
*
qmsg
;
char
*
qmsg
;
// not applied to encoder and decoder
// followings are not applied to encoder and decoder
int8_t
numOfRunners
;
SStreamRunner
runner
[
8
];
SStreamRunner
runner
[
8
];
// void* executor;
// void* stateStore;
// storage handle
}
SStreamTask
;
}
SStreamTask
;
static
FORCE_INLINE
SStreamTask
*
streamTaskNew
(
int64_t
streamId
,
int32_t
level
)
{
static
FORCE_INLINE
SStreamTask
*
streamTaskNew
(
int64_t
streamId
)
{
SStreamTask
*
pTask
=
(
SStreamTask
*
)
calloc
(
1
,
sizeof
(
SStreamTask
));
SStreamTask
*
pTask
=
(
SStreamTask
*
)
calloc
(
1
,
sizeof
(
SStreamTask
));
if
(
pTask
==
NULL
)
{
if
(
pTask
==
NULL
)
{
return
NULL
;
return
NULL
;
}
}
pTask
->
taskId
=
tGenIdPI32
();
pTask
->
taskId
=
tGenIdPI32
();
pTask
->
streamId
=
streamId
;
pTask
->
streamId
=
streamId
;
pTask
->
level
=
level
;
pTask
->
status
=
STREAM_TASK_STATUS__RUNNING
;
pTask
->
status
=
STREAM_TASK_STATUS__RUNNING
;
pTask
->
qmsg
=
NULL
;
pTask
->
qmsg
=
NULL
;
return
pTask
;
return
pTask
;
...
@@ -2417,7 +2460,7 @@ typedef struct {
...
@@ -2417,7 +2460,7 @@ typedef struct {
int64_t
streamId
;
int64_t
streamId
;
int64_t
version
;
int64_t
version
;
SArray
*
res
;
// SArray<SSDataBlock>
SArray
*
res
;
// SArray<SSDataBlock>
}
SStreamS
maS
inkReq
;
}
SStreamSinkReq
;
#pragma pack(pop)
#pragma pack(pop)
...
...
include/dnode/mnode/mnode.h
浏览文件 @
ba1dd2ca
...
@@ -17,7 +17,9 @@
...
@@ -17,7 +17,9 @@
#define _TD_MND_H_
#define _TD_MND_H_
#include "monitor.h"
#include "monitor.h"
#include "tmsg.h"
#include "tmsgcb.h"
#include "tmsgcb.h"
#include "trpc.h"
#ifdef __cplusplus
#ifdef __cplusplus
extern
"C"
{
extern
"C"
{
...
...
include/libs/nodes/nodes.h
浏览文件 @
ba1dd2ca
...
@@ -135,6 +135,7 @@ typedef enum ENodeType {
...
@@ -135,6 +135,7 @@ typedef enum ENodeType {
QUERY_NODE_PHYSICAL_PLAN_EXCHANGE
,
QUERY_NODE_PHYSICAL_PLAN_EXCHANGE
,
QUERY_NODE_PHYSICAL_PLAN_SORT
,
QUERY_NODE_PHYSICAL_PLAN_SORT
,
QUERY_NODE_PHYSICAL_PLAN_INTERVAL
,
QUERY_NODE_PHYSICAL_PLAN_INTERVAL
,
QUERY_NODE_PHYSICAL_PLAN_SESSION_WINDOW
,
QUERY_NODE_PHYSICAL_PLAN_DISPATCH
,
QUERY_NODE_PHYSICAL_PLAN_DISPATCH
,
QUERY_NODE_PHYSICAL_PLAN_INSERT
,
QUERY_NODE_PHYSICAL_PLAN_INSERT
,
QUERY_NODE_PHYSICAL_SUBPLAN
,
QUERY_NODE_PHYSICAL_SUBPLAN
,
...
@@ -169,6 +170,7 @@ void nodesDestroyNode(SNodeptr pNode);
...
@@ -169,6 +170,7 @@ void nodesDestroyNode(SNodeptr pNode);
SNodeList
*
nodesMakeList
();
SNodeList
*
nodesMakeList
();
int32_t
nodesListAppend
(
SNodeList
*
pList
,
SNodeptr
pNode
);
int32_t
nodesListAppend
(
SNodeList
*
pList
,
SNodeptr
pNode
);
int32_t
nodesListStrictAppend
(
SNodeList
*
pList
,
SNodeptr
pNode
);
int32_t
nodesListStrictAppend
(
SNodeList
*
pList
,
SNodeptr
pNode
);
int32_t
nodesListMakeAppend
(
SNodeList
**
pList
,
SNodeptr
pNode
);
int32_t
nodesListAppendList
(
SNodeList
*
pTarget
,
SNodeList
*
pSrc
);
int32_t
nodesListAppendList
(
SNodeList
*
pTarget
,
SNodeList
*
pSrc
);
int32_t
nodesListStrictAppendList
(
SNodeList
*
pTarget
,
SNodeList
*
pSrc
);
int32_t
nodesListStrictAppendList
(
SNodeList
*
pTarget
,
SNodeList
*
pSrc
);
SListCell
*
nodesListErase
(
SNodeList
*
pList
,
SListCell
*
pCell
);
SListCell
*
nodesListErase
(
SNodeList
*
pList
,
SListCell
*
pCell
);
...
...
include/libs/nodes/plannodes.h
浏览文件 @
ba1dd2ca
...
@@ -95,6 +95,7 @@ typedef struct SWindowLogicNode {
...
@@ -95,6 +95,7 @@ typedef struct SWindowLogicNode {
int8_t
intervalUnit
;
int8_t
intervalUnit
;
int8_t
slidingUnit
;
int8_t
slidingUnit
;
SFillNode
*
pFill
;
SFillNode
*
pFill
;
int64_t
sessionGap
;
}
SWindowLogicNode
;
}
SWindowLogicNode
;
typedef
enum
ESubplanType
{
typedef
enum
ESubplanType
{
...
@@ -110,7 +111,7 @@ typedef struct SSubplanId {
...
@@ -110,7 +111,7 @@ typedef struct SSubplanId {
int32_t
subplanId
;
int32_t
subplanId
;
}
SSubplanId
;
}
SSubplanId
;
typedef
struct
S
SubLogicP
lan
{
typedef
struct
S
LogicSubp
lan
{
ENodeType
type
;
ENodeType
type
;
SSubplanId
id
;
SSubplanId
id
;
SNodeList
*
pChildren
;
SNodeList
*
pChildren
;
...
@@ -120,7 +121,7 @@ typedef struct SSubLogicPlan {
...
@@ -120,7 +121,7 @@ typedef struct SSubLogicPlan {
SVgroupsInfo
*
pVgroupList
;
SVgroupsInfo
*
pVgroupList
;
int32_t
level
;
int32_t
level
;
int32_t
splitFlag
;
int32_t
splitFlag
;
}
S
SubLogicP
lan
;
}
S
LogicSubp
lan
;
typedef
struct
SQueryLogicPlan
{
typedef
struct
SQueryLogicPlan
{
ENodeType
type
;
ENodeType
type
;
...
@@ -213,10 +214,14 @@ typedef struct SExchangePhysiNode {
...
@@ -213,10 +214,14 @@ typedef struct SExchangePhysiNode {
SNodeList
*
pSrcEndPoints
;
// element is SDownstreamSource, scheduler fill by calling qSetSuplanExecutionNode
SNodeList
*
pSrcEndPoints
;
// element is SDownstreamSource, scheduler fill by calling qSetSuplanExecutionNode
}
SExchangePhysiNode
;
}
SExchangePhysiNode
;
typedef
struct
S
Interval
PhysiNode
{
typedef
struct
S
Winodw
PhysiNode
{
SPhysiNode
node
;
SPhysiNode
node
;
SNodeList
*
pExprs
;
// these are expression list of parameter expression of function
SNodeList
*
pExprs
;
// these are expression list of parameter expression of function
SNodeList
*
pFuncs
;
SNodeList
*
pFuncs
;
}
SWinodwPhysiNode
;
typedef
struct
SIntervalPhysiNode
{
SWinodwPhysiNode
window
;
int64_t
interval
;
int64_t
interval
;
int64_t
offset
;
int64_t
offset
;
int64_t
sliding
;
int64_t
sliding
;
...
@@ -225,6 +230,11 @@ typedef struct SIntervalPhysiNode {
...
@@ -225,6 +230,11 @@ typedef struct SIntervalPhysiNode {
SFillNode
*
pFill
;
SFillNode
*
pFill
;
}
SIntervalPhysiNode
;
}
SIntervalPhysiNode
;
typedef
struct
SSessionWinodwPhysiNode
{
SWinodwPhysiNode
window
;
int64_t
gap
;
}
SSessionWinodwPhysiNode
;
typedef
struct
SDataSinkNode
{
typedef
struct
SDataSinkNode
{
ENodeType
type
;
ENodeType
type
;
SDataBlockDescNode
*
pInputDataBlockDesc
;
SDataBlockDescNode
*
pInputDataBlockDesc
;
...
...
include/libs/nodes/querynodes.h
浏览文件 @
ba1dd2ca
...
@@ -191,8 +191,8 @@ typedef struct SStateWindowNode {
...
@@ -191,8 +191,8 @@ typedef struct SStateWindowNode {
typedef
struct
SSessionWindowNode
{
typedef
struct
SSessionWindowNode
{
ENodeType
type
;
// QUERY_NODE_SESSION_WINDOW
ENodeType
type
;
// QUERY_NODE_SESSION_WINDOW
int64_t
gap
;
// gap between two session window(in microseconds)
SNode
*
pCol
;
SNode
*
pCol
;
SNode
*
pGap
;
// gap between two session window(in microseconds)
}
SSessionWindowNode
;
}
SSessionWindowNode
;
typedef
struct
SIntervalWindowNode
{
typedef
struct
SIntervalWindowNode
{
...
...
include/util/taoserror.h
浏览文件 @
ba1dd2ca
...
@@ -475,6 +475,7 @@ int32_t* taosGetErrno();
...
@@ -475,6 +475,7 @@ int32_t* taosGetErrno();
#define TSDB_CODE_PAR_INVALID_PORT TAOS_DEF_ERROR_CODE(0, 0x2612)
#define TSDB_CODE_PAR_INVALID_PORT TAOS_DEF_ERROR_CODE(0, 0x2612)
#define TSDB_CODE_PAR_INVALID_ENDPOINT TAOS_DEF_ERROR_CODE(0, 0x2613)
#define TSDB_CODE_PAR_INVALID_ENDPOINT TAOS_DEF_ERROR_CODE(0, 0x2613)
#define TSDB_CODE_PAR_EXPRIE_STATEMENT TAOS_DEF_ERROR_CODE(0, 0x2614)
#define TSDB_CODE_PAR_EXPRIE_STATEMENT TAOS_DEF_ERROR_CODE(0, 0x2614)
#define TSDB_CODE_PAR_INTERVAL_VALUE_TOO_SMALL TAOS_DEF_ERROR_CODE(0, 0x2615)
#ifdef __cplusplus
#ifdef __cplusplus
}
}
...
...
include/util/tdef.h
浏览文件 @
ba1dd2ca
...
@@ -453,6 +453,10 @@ enum {
...
@@ -453,6 +453,10 @@ enum {
SND_WORKER_TYPE__UNIQUE
,
SND_WORKER_TYPE__UNIQUE
,
};
};
#define MND_VGID -1
#define QND_VGID 1
#define VND_VGID 0
#ifdef __cplusplus
#ifdef __cplusplus
}
}
#endif
#endif
...
...
source/client/src/tmq.c
浏览文件 @
ba1dd2ca
...
@@ -505,7 +505,7 @@ TAOS_RES* tmq_create_stream(TAOS* taos, const char* streamName, const char* tbNa
...
@@ -505,7 +505,7 @@ TAOS_RES* tmq_create_stream(TAOS* taos, const char* streamName, const char* tbNa
.
sql
=
(
char
*
)
sql
,
.
sql
=
(
char
*
)
sql
,
};
};
tNameExtractFullName
(
&
name
,
req
.
name
);
tNameExtractFullName
(
&
name
,
req
.
name
);
strcpy
(
req
.
outputTbName
,
tbName
);
strcpy
(
req
.
output
S
TbName
,
tbName
);
int
tlen
=
tSerializeSCMCreateStreamReq
(
NULL
,
0
,
&
req
);
int
tlen
=
tSerializeSCMCreateStreamReq
(
NULL
,
0
,
&
req
);
void
*
buf
=
malloc
(
tlen
);
void
*
buf
=
malloc
(
tlen
);
...
...
source/common/src/tmsg.c
浏览文件 @
ba1dd2ca
...
@@ -287,6 +287,7 @@ int32_t tSerializeSVCreateTbReq(void **buf, SVCreateTbReq *pReq) {
...
@@ -287,6 +287,7 @@ int32_t tSerializeSVCreateTbReq(void **buf, SVCreateTbReq *pReq) {
int32_t
tlen
=
0
;
int32_t
tlen
=
0
;
tlen
+=
taosEncodeFixedI64
(
buf
,
pReq
->
ver
);
tlen
+=
taosEncodeFixedI64
(
buf
,
pReq
->
ver
);
tlen
+=
taosEncodeString
(
buf
,
pReq
->
dbFName
);
tlen
+=
taosEncodeString
(
buf
,
pReq
->
name
);
tlen
+=
taosEncodeString
(
buf
,
pReq
->
name
);
tlen
+=
taosEncodeFixedU32
(
buf
,
pReq
->
ttl
);
tlen
+=
taosEncodeFixedU32
(
buf
,
pReq
->
ttl
);
tlen
+=
taosEncodeFixedU32
(
buf
,
pReq
->
keep
);
tlen
+=
taosEncodeFixedU32
(
buf
,
pReq
->
keep
);
...
@@ -313,7 +314,7 @@ int32_t tSerializeSVCreateTbReq(void **buf, SVCreateTbReq *pReq) {
...
@@ -313,7 +314,7 @@ int32_t tSerializeSVCreateTbReq(void **buf, SVCreateTbReq *pReq) {
for
(
col_id_t
i
=
0
;
i
<
pReq
->
stbCfg
.
nBSmaCols
;
++
i
)
{
for
(
col_id_t
i
=
0
;
i
<
pReq
->
stbCfg
.
nBSmaCols
;
++
i
)
{
tlen
+=
taosEncodeFixedI16
(
buf
,
pReq
->
stbCfg
.
pBSmaCols
[
i
]);
tlen
+=
taosEncodeFixedI16
(
buf
,
pReq
->
stbCfg
.
pBSmaCols
[
i
]);
}
}
if
(
pReq
->
rollup
&&
pReq
->
stbCfg
.
pRSmaParam
)
{
if
(
pReq
->
rollup
&&
pReq
->
stbCfg
.
pRSmaParam
)
{
SRSmaParam
*
param
=
pReq
->
stbCfg
.
pRSmaParam
;
SRSmaParam
*
param
=
pReq
->
stbCfg
.
pRSmaParam
;
tlen
+=
taosEncodeFixedU32
(
buf
,
(
uint32_t
)
param
->
xFilesFactor
);
tlen
+=
taosEncodeFixedU32
(
buf
,
(
uint32_t
)
param
->
xFilesFactor
);
tlen
+=
taosEncodeFixedI8
(
buf
,
param
->
delayUnit
);
tlen
+=
taosEncodeFixedI8
(
buf
,
param
->
delayUnit
);
...
@@ -340,7 +341,7 @@ int32_t tSerializeSVCreateTbReq(void **buf, SVCreateTbReq *pReq) {
...
@@ -340,7 +341,7 @@ int32_t tSerializeSVCreateTbReq(void **buf, SVCreateTbReq *pReq) {
for
(
col_id_t
i
=
0
;
i
<
pReq
->
ntbCfg
.
nBSmaCols
;
++
i
)
{
for
(
col_id_t
i
=
0
;
i
<
pReq
->
ntbCfg
.
nBSmaCols
;
++
i
)
{
tlen
+=
taosEncodeFixedI16
(
buf
,
pReq
->
ntbCfg
.
pBSmaCols
[
i
]);
tlen
+=
taosEncodeFixedI16
(
buf
,
pReq
->
ntbCfg
.
pBSmaCols
[
i
]);
}
}
if
(
pReq
->
rollup
&&
pReq
->
ntbCfg
.
pRSmaParam
)
{
if
(
pReq
->
rollup
&&
pReq
->
ntbCfg
.
pRSmaParam
)
{
SRSmaParam
*
param
=
pReq
->
ntbCfg
.
pRSmaParam
;
SRSmaParam
*
param
=
pReq
->
ntbCfg
.
pRSmaParam
;
tlen
+=
taosEncodeFixedU32
(
buf
,
(
uint32_t
)
param
->
xFilesFactor
);
tlen
+=
taosEncodeFixedU32
(
buf
,
(
uint32_t
)
param
->
xFilesFactor
);
tlen
+=
taosEncodeFixedI8
(
buf
,
param
->
delayUnit
);
tlen
+=
taosEncodeFixedI8
(
buf
,
param
->
delayUnit
);
...
@@ -360,6 +361,7 @@ int32_t tSerializeSVCreateTbReq(void **buf, SVCreateTbReq *pReq) {
...
@@ -360,6 +361,7 @@ int32_t tSerializeSVCreateTbReq(void **buf, SVCreateTbReq *pReq) {
void
*
tDeserializeSVCreateTbReq
(
void
*
buf
,
SVCreateTbReq
*
pReq
)
{
void
*
tDeserializeSVCreateTbReq
(
void
*
buf
,
SVCreateTbReq
*
pReq
)
{
buf
=
taosDecodeFixedI64
(
buf
,
&
(
pReq
->
ver
));
buf
=
taosDecodeFixedI64
(
buf
,
&
(
pReq
->
ver
));
buf
=
taosDecodeString
(
buf
,
&
(
pReq
->
dbFName
));
buf
=
taosDecodeString
(
buf
,
&
(
pReq
->
name
));
buf
=
taosDecodeString
(
buf
,
&
(
pReq
->
name
));
buf
=
taosDecodeFixedU32
(
buf
,
&
(
pReq
->
ttl
));
buf
=
taosDecodeFixedU32
(
buf
,
&
(
pReq
->
ttl
));
buf
=
taosDecodeFixedU32
(
buf
,
&
(
pReq
->
keep
));
buf
=
taosDecodeFixedU32
(
buf
,
&
(
pReq
->
keep
));
...
@@ -425,7 +427,7 @@ void *tDeserializeSVCreateTbReq(void *buf, SVCreateTbReq *pReq) {
...
@@ -425,7 +427,7 @@ void *tDeserializeSVCreateTbReq(void *buf, SVCreateTbReq *pReq) {
buf
=
taosDecodeStringTo
(
buf
,
pReq
->
ntbCfg
.
pSchema
[
i
].
name
);
buf
=
taosDecodeStringTo
(
buf
,
pReq
->
ntbCfg
.
pSchema
[
i
].
name
);
}
}
buf
=
taosDecodeFixedI16
(
buf
,
&
(
pReq
->
ntbCfg
.
nBSmaCols
));
buf
=
taosDecodeFixedI16
(
buf
,
&
(
pReq
->
ntbCfg
.
nBSmaCols
));
if
(
pReq
->
ntbCfg
.
nBSmaCols
>
0
)
{
if
(
pReq
->
ntbCfg
.
nBSmaCols
>
0
)
{
pReq
->
ntbCfg
.
pBSmaCols
=
(
col_id_t
*
)
malloc
(
pReq
->
ntbCfg
.
nBSmaCols
*
sizeof
(
col_id_t
));
pReq
->
ntbCfg
.
pBSmaCols
=
(
col_id_t
*
)
malloc
(
pReq
->
ntbCfg
.
nBSmaCols
*
sizeof
(
col_id_t
));
for
(
col_id_t
i
=
0
;
i
<
pReq
->
ntbCfg
.
nBSmaCols
;
++
i
)
{
for
(
col_id_t
i
=
0
;
i
<
pReq
->
ntbCfg
.
nBSmaCols
;
++
i
)
{
buf
=
taosDecodeFixedI16
(
buf
,
pReq
->
ntbCfg
.
pBSmaCols
+
i
);
buf
=
taosDecodeFixedI16
(
buf
,
pReq
->
ntbCfg
.
pBSmaCols
+
i
);
...
@@ -433,10 +435,10 @@ void *tDeserializeSVCreateTbReq(void *buf, SVCreateTbReq *pReq) {
...
@@ -433,10 +435,10 @@ void *tDeserializeSVCreateTbReq(void *buf, SVCreateTbReq *pReq) {
}
else
{
}
else
{
pReq
->
ntbCfg
.
pBSmaCols
=
NULL
;
pReq
->
ntbCfg
.
pBSmaCols
=
NULL
;
}
}
if
(
pReq
->
rollup
)
{
if
(
pReq
->
rollup
)
{
pReq
->
ntbCfg
.
pRSmaParam
=
(
SRSmaParam
*
)
malloc
(
sizeof
(
SRSmaParam
));
pReq
->
ntbCfg
.
pRSmaParam
=
(
SRSmaParam
*
)
malloc
(
sizeof
(
SRSmaParam
));
SRSmaParam
*
param
=
pReq
->
ntbCfg
.
pRSmaParam
;
SRSmaParam
*
param
=
pReq
->
ntbCfg
.
pRSmaParam
;
buf
=
taosDecodeFixedU32
(
buf
,
(
uint32_t
*
)
&
param
->
xFilesFactor
);
buf
=
taosDecodeFixedU32
(
buf
,
(
uint32_t
*
)
&
param
->
xFilesFactor
);
buf
=
taosDecodeFixedI8
(
buf
,
&
param
->
delayUnit
);
buf
=
taosDecodeFixedI8
(
buf
,
&
param
->
delayUnit
);
buf
=
taosDecodeFixedI8
(
buf
,
&
param
->
nFuncIds
);
buf
=
taosDecodeFixedI8
(
buf
,
&
param
->
nFuncIds
);
if
(
param
->
nFuncIds
>
0
)
{
if
(
param
->
nFuncIds
>
0
)
{
...
@@ -478,7 +480,7 @@ void *tDeserializeSVCreateTbBatchReq(void *buf, SVCreateTbBatchReq *pReq) {
...
@@ -478,7 +480,7 @@ void *tDeserializeSVCreateTbBatchReq(void *buf, SVCreateTbBatchReq *pReq) {
buf
=
taosDecodeFixedU32
(
buf
,
&
nsize
);
buf
=
taosDecodeFixedU32
(
buf
,
&
nsize
);
pReq
->
pArray
=
taosArrayInit
(
nsize
,
sizeof
(
SVCreateTbReq
));
pReq
->
pArray
=
taosArrayInit
(
nsize
,
sizeof
(
SVCreateTbReq
));
for
(
size_t
i
=
0
;
i
<
nsize
;
i
++
)
{
for
(
size_t
i
=
0
;
i
<
nsize
;
i
++
)
{
SVCreateTbReq
req
;
SVCreateTbReq
req
=
{
0
}
;
buf
=
tDeserializeSVCreateTbReq
(
buf
,
&
req
);
buf
=
tDeserializeSVCreateTbReq
(
buf
,
&
req
);
taosArrayPush
(
pReq
->
pArray
,
&
req
);
taosArrayPush
(
pReq
->
pArray
,
&
req
);
}
}
...
@@ -508,8 +510,13 @@ int32_t tSerializeSMCreateStbReq(void *buf, int32_t bufLen, SMCreateStbReq *pReq
...
@@ -508,8 +510,13 @@ int32_t tSerializeSMCreateStbReq(void *buf, int32_t bufLen, SMCreateStbReq *pReq
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
(
tEncodeFloat
(
&
encoder
,
pReq
->
xFilesFactor
)
<
0
)
return
-
1
;
if
(
tEncodeI32
(
&
encoder
,
pReq
->
aggregationMethod
)
<
0
)
return
-
1
;
if
(
tEncodeI32
(
&
encoder
,
pReq
->
delay
)
<
0
)
return
-
1
;
if
(
tEncodeI32
(
&
encoder
,
pReq
->
ttl
)
<
0
)
return
-
1
;
if
(
tEncodeI32
(
&
encoder
,
pReq
->
numOfColumns
)
<
0
)
return
-
1
;
if
(
tEncodeI32
(
&
encoder
,
pReq
->
numOfColumns
)
<
0
)
return
-
1
;
if
(
tEncodeI32
(
&
encoder
,
pReq
->
numOfTags
)
<
0
)
return
-
1
;
if
(
tEncodeI32
(
&
encoder
,
pReq
->
numOfTags
)
<
0
)
return
-
1
;
if
(
tEncodeI32
(
&
encoder
,
pReq
->
numOfSmas
)
<
0
)
return
-
1
;
if
(
tEncodeI32
(
&
encoder
,
pReq
->
commentLen
)
<
0
)
return
-
1
;
if
(
tEncodeI32
(
&
encoder
,
pReq
->
commentLen
)
<
0
)
return
-
1
;
for
(
int32_t
i
=
0
;
i
<
pReq
->
numOfColumns
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
pReq
->
numOfColumns
;
++
i
)
{
...
@@ -526,7 +533,16 @@ int32_t tSerializeSMCreateStbReq(void *buf, int32_t bufLen, SMCreateStbReq *pReq
...
@@ -526,7 +533,16 @@ int32_t tSerializeSMCreateStbReq(void *buf, int32_t bufLen, SMCreateStbReq *pReq
if
(
tEncodeCStr
(
&
encoder
,
pField
->
name
)
<
0
)
return
-
1
;
if
(
tEncodeCStr
(
&
encoder
,
pField
->
name
)
<
0
)
return
-
1
;
}
}
for
(
int32_t
i
=
0
;
i
<
pReq
->
numOfSmas
;
++
i
)
{
SField
*
pField
=
taosArrayGet
(
pReq
->
pSmas
,
i
);
if
(
tEncodeI8
(
&
encoder
,
pField
->
type
)
<
0
)
return
-
1
;
if
(
tEncodeI32
(
&
encoder
,
pField
->
bytes
)
<
0
)
return
-
1
;
if
(
tEncodeCStr
(
&
encoder
,
pField
->
name
)
<
0
)
return
-
1
;
}
if
(
pReq
->
commentLen
>
0
)
{
if
(
tEncodeBinary
(
&
encoder
,
pReq
->
comment
,
pReq
->
commentLen
)
<
0
)
return
-
1
;
if
(
tEncodeBinary
(
&
encoder
,
pReq
->
comment
,
pReq
->
commentLen
)
<
0
)
return
-
1
;
}
tEndEncode
(
&
encoder
);
tEndEncode
(
&
encoder
);
int32_t
tlen
=
encoder
.
pos
;
int32_t
tlen
=
encoder
.
pos
;
...
@@ -541,13 +557,19 @@ int32_t tDeserializeSMCreateStbReq(void *buf, int32_t bufLen, SMCreateStbReq *pR
...
@@ -541,13 +557,19 @@ int32_t tDeserializeSMCreateStbReq(void *buf, int32_t bufLen, SMCreateStbReq *pR
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
(
tDecodeFloat
(
&
decoder
,
&
pReq
->
xFilesFactor
)
<
0
)
return
-
1
;
if
(
tDecodeI32
(
&
decoder
,
&
pReq
->
aggregationMethod
)
<
0
)
return
-
1
;
if
(
tDecodeI32
(
&
decoder
,
&
pReq
->
delay
)
<
0
)
return
-
1
;
if
(
tDecodeI32
(
&
decoder
,
&
pReq
->
ttl
)
<
0
)
return
-
1
;
if
(
tDecodeI32
(
&
decoder
,
&
pReq
->
numOfColumns
)
<
0
)
return
-
1
;
if
(
tDecodeI32
(
&
decoder
,
&
pReq
->
numOfColumns
)
<
0
)
return
-
1
;
if
(
tDecodeI32
(
&
decoder
,
&
pReq
->
numOfTags
)
<
0
)
return
-
1
;
if
(
tDecodeI32
(
&
decoder
,
&
pReq
->
numOfTags
)
<
0
)
return
-
1
;
if
(
tDecodeI32
(
&
decoder
,
&
pReq
->
numOfSmas
)
<
0
)
return
-
1
;
if
(
tDecodeI32
(
&
decoder
,
&
pReq
->
commentLen
)
<
0
)
return
-
1
;
if
(
tDecodeI32
(
&
decoder
,
&
pReq
->
commentLen
)
<
0
)
return
-
1
;
pReq
->
pColumns
=
taosArrayInit
(
pReq
->
numOfColumns
,
sizeof
(
SField
));
pReq
->
pColumns
=
taosArrayInit
(
pReq
->
numOfColumns
,
sizeof
(
SField
));
pReq
->
pTags
=
taosArrayInit
(
pReq
->
numOfTags
,
sizeof
(
SField
));
pReq
->
pTags
=
taosArrayInit
(
pReq
->
numOfTags
,
sizeof
(
SField
));
if
(
pReq
->
pColumns
==
NULL
||
pReq
->
pTags
==
NULL
)
{
pReq
->
pSmas
=
taosArrayInit
(
pReq
->
numOfSmas
,
sizeof
(
SField
));
if
(
pReq
->
pColumns
==
NULL
||
pReq
->
pTags
==
NULL
||
pReq
->
pSmas
==
NULL
)
{
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
return
-
1
;
return
-
1
;
}
}
...
@@ -574,13 +596,23 @@ int32_t tDeserializeSMCreateStbReq(void *buf, int32_t bufLen, SMCreateStbReq *pR
...
@@ -574,13 +596,23 @@ int32_t tDeserializeSMCreateStbReq(void *buf, int32_t bufLen, SMCreateStbReq *pR
}
}
}
}
for
(
int32_t
i
=
0
;
i
<
pReq
->
numOfSmas
;
++
i
)
{
SField
field
=
{
0
};
if
(
tDecodeI8
(
&
decoder
,
&
field
.
type
)
<
0
)
return
-
1
;
if
(
tDecodeI32
(
&
decoder
,
&
field
.
bytes
)
<
0
)
return
-
1
;
if
(
tDecodeCStrTo
(
&
decoder
,
field
.
name
)
<
0
)
return
-
1
;
if
(
taosArrayPush
(
pReq
->
pSmas
,
&
field
)
==
NULL
)
{
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
return
-
1
;
}
}
if
(
pReq
->
commentLen
>
0
)
{
if
(
pReq
->
commentLen
>
0
)
{
pReq
->
comment
=
malloc
(
pReq
->
commentLen
);
pReq
->
comment
=
malloc
(
pReq
->
commentLen
);
if
(
pReq
->
comment
==
NULL
)
return
-
1
;
if
(
pReq
->
comment
==
NULL
)
return
-
1
;
if
(
tDecodeCStrTo
(
&
decoder
,
pReq
->
comment
)
<
0
)
return
-
1
;
if
(
tDecodeCStrTo
(
&
decoder
,
pReq
->
comment
)
<
0
)
return
-
1
;
}
}
if
(
tDecodeCStrTo
(
&
decoder
,
pReq
->
comment
)
<
0
)
return
-
1
;
tEndDecode
(
&
decoder
);
tEndDecode
(
&
decoder
);
tCoderClear
(
&
decoder
);
tCoderClear
(
&
decoder
);
...
@@ -590,8 +622,11 @@ int32_t tDeserializeSMCreateStbReq(void *buf, int32_t bufLen, SMCreateStbReq *pR
...
@@ -590,8 +622,11 @@ int32_t tDeserializeSMCreateStbReq(void *buf, int32_t bufLen, SMCreateStbReq *pR
void
tFreeSMCreateStbReq
(
SMCreateStbReq
*
pReq
)
{
void
tFreeSMCreateStbReq
(
SMCreateStbReq
*
pReq
)
{
taosArrayDestroy
(
pReq
->
pColumns
);
taosArrayDestroy
(
pReq
->
pColumns
);
taosArrayDestroy
(
pReq
->
pTags
);
taosArrayDestroy
(
pReq
->
pTags
);
taosArrayDestroy
(
pReq
->
pSmas
);
tfree
(
pReq
->
comment
);
pReq
->
pColumns
=
NULL
;
pReq
->
pColumns
=
NULL
;
pReq
->
pTags
=
NULL
;
pReq
->
pTags
=
NULL
;
pReq
->
pSmas
=
NULL
;
}
}
int32_t
tSerializeSMDropStbReq
(
void
*
buf
,
int32_t
bufLen
,
SMDropStbReq
*
pReq
)
{
int32_t
tSerializeSMDropStbReq
(
void
*
buf
,
int32_t
bufLen
,
SMDropStbReq
*
pReq
)
{
...
@@ -1509,6 +1544,14 @@ int32_t tSerializeSCreateDbReq(void *buf, int32_t bufLen, SCreateDbReq *pReq) {
...
@@ -1509,6 +1544,14 @@ int32_t tSerializeSCreateDbReq(void *buf, int32_t bufLen, SCreateDbReq *pReq) {
if
(
tEncodeI8
(
&
encoder
,
pReq
->
cacheLastRow
)
<
0
)
return
-
1
;
if
(
tEncodeI8
(
&
encoder
,
pReq
->
cacheLastRow
)
<
0
)
return
-
1
;
if
(
tEncodeI8
(
&
encoder
,
pReq
->
ignoreExist
)
<
0
)
return
-
1
;
if
(
tEncodeI8
(
&
encoder
,
pReq
->
ignoreExist
)
<
0
)
return
-
1
;
if
(
tEncodeI8
(
&
encoder
,
pReq
->
streamMode
)
<
0
)
return
-
1
;
if
(
tEncodeI8
(
&
encoder
,
pReq
->
streamMode
)
<
0
)
return
-
1
;
if
(
tEncodeI32
(
&
encoder
,
pReq
->
numOfRetensions
)
<
0
)
return
-
1
;
for
(
int32_t
i
=
0
;
i
<
pReq
->
numOfRetensions
;
++
i
)
{
SRetention
*
pRetension
=
taosArrayGet
(
pReq
->
pRetensions
,
i
);
if
(
tEncodeI32
(
&
encoder
,
pRetension
->
freq
)
<
0
)
return
-
1
;
if
(
tEncodeI32
(
&
encoder
,
pRetension
->
keep
)
<
0
)
return
-
1
;
if
(
tEncodeI8
(
&
encoder
,
pRetension
->
freqUnit
)
<
0
)
return
-
1
;
if
(
tEncodeI8
(
&
encoder
,
pRetension
->
keepUnit
)
<
0
)
return
-
1
;
}
tEndEncode
(
&
encoder
);
tEndEncode
(
&
encoder
);
int32_t
tlen
=
encoder
.
pos
;
int32_t
tlen
=
encoder
.
pos
;
...
@@ -1542,12 +1585,36 @@ int32_t tDeserializeSCreateDbReq(void *buf, int32_t bufLen, SCreateDbReq *pReq)
...
@@ -1542,12 +1585,36 @@ int32_t tDeserializeSCreateDbReq(void *buf, int32_t bufLen, SCreateDbReq *pReq)
if
(
tDecodeI8
(
&
decoder
,
&
pReq
->
cacheLastRow
)
<
0
)
return
-
1
;
if
(
tDecodeI8
(
&
decoder
,
&
pReq
->
cacheLastRow
)
<
0
)
return
-
1
;
if
(
tDecodeI8
(
&
decoder
,
&
pReq
->
ignoreExist
)
<
0
)
return
-
1
;
if
(
tDecodeI8
(
&
decoder
,
&
pReq
->
ignoreExist
)
<
0
)
return
-
1
;
if
(
tDecodeI8
(
&
decoder
,
&
pReq
->
streamMode
)
<
0
)
return
-
1
;
if
(
tDecodeI8
(
&
decoder
,
&
pReq
->
streamMode
)
<
0
)
return
-
1
;
if
(
tDecodeI32
(
&
decoder
,
&
pReq
->
numOfRetensions
)
<
0
)
return
-
1
;
pReq
->
pRetensions
=
taosArrayInit
(
pReq
->
numOfRetensions
,
sizeof
(
SRetention
));
if
(
pReq
->
pRetensions
==
NULL
)
{
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
return
-
1
;
}
for
(
int32_t
i
=
0
;
i
<
pReq
->
numOfRetensions
;
++
i
)
{
SRetention
rentension
=
{
0
};
if
(
tDecodeI32
(
&
decoder
,
&
rentension
.
freq
)
<
0
)
return
-
1
;
if
(
tDecodeI32
(
&
decoder
,
&
rentension
.
keep
)
<
0
)
return
-
1
;
if
(
tDecodeI8
(
&
decoder
,
&
rentension
.
freqUnit
)
<
0
)
return
-
1
;
if
(
tDecodeI8
(
&
decoder
,
&
rentension
.
keepUnit
)
<
0
)
return
-
1
;
if
(
taosArrayPush
(
pReq
->
pRetensions
,
&
rentension
)
==
NULL
)
{
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
return
-
1
;
}
}
tEndDecode
(
&
decoder
);
tEndDecode
(
&
decoder
);
tCoderClear
(
&
decoder
);
tCoderClear
(
&
decoder
);
return
0
;
return
0
;
}
}
void
tFreeSCreateDbReq
(
SCreateDbReq
*
pReq
)
{
taosArrayDestroy
(
pReq
->
pRetensions
);
pReq
->
pRetensions
=
NULL
;
}
int32_t
tSerializeSAlterDbReq
(
void
*
buf
,
int32_t
bufLen
,
SAlterDbReq
*
pReq
)
{
int32_t
tSerializeSAlterDbReq
(
void
*
buf
,
int32_t
bufLen
,
SAlterDbReq
*
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
);
...
@@ -2425,6 +2492,14 @@ int32_t tSerializeSCreateVnodeReq(void *buf, int32_t bufLen, SCreateVnodeReq *pR
...
@@ -2425,6 +2492,14 @@ int32_t tSerializeSCreateVnodeReq(void *buf, int32_t bufLen, SCreateVnodeReq *pR
SReplica
*
pReplica
=
&
pReq
->
replicas
[
i
];
SReplica
*
pReplica
=
&
pReq
->
replicas
[
i
];
if
(
tEncodeSReplica
(
&
encoder
,
pReplica
)
<
0
)
return
-
1
;
if
(
tEncodeSReplica
(
&
encoder
,
pReplica
)
<
0
)
return
-
1
;
}
}
if
(
tEncodeI32
(
&
encoder
,
pReq
->
numOfRetensions
)
<
0
)
return
-
1
;
for
(
int32_t
i
=
0
;
i
<
pReq
->
numOfRetensions
;
++
i
)
{
SRetention
*
pRetension
=
taosArrayGet
(
pReq
->
pRetensions
,
i
);
if
(
tEncodeI32
(
&
encoder
,
pRetension
->
freq
)
<
0
)
return
-
1
;
if
(
tEncodeI32
(
&
encoder
,
pRetension
->
keep
)
<
0
)
return
-
1
;
if
(
tEncodeI8
(
&
encoder
,
pRetension
->
freqUnit
)
<
0
)
return
-
1
;
if
(
tEncodeI8
(
&
encoder
,
pRetension
->
keepUnit
)
<
0
)
return
-
1
;
}
tEndEncode
(
&
encoder
);
tEndEncode
(
&
encoder
);
int32_t
tlen
=
encoder
.
pos
;
int32_t
tlen
=
encoder
.
pos
;
...
@@ -2469,11 +2544,35 @@ int32_t tDeserializeSCreateVnodeReq(void *buf, int32_t bufLen, SCreateVnodeReq *
...
@@ -2469,11 +2544,35 @@ int32_t tDeserializeSCreateVnodeReq(void *buf, int32_t bufLen, SCreateVnodeReq *
if
(
tDecodeSReplica
(
&
decoder
,
pReplica
)
<
0
)
return
-
1
;
if
(
tDecodeSReplica
(
&
decoder
,
pReplica
)
<
0
)
return
-
1
;
}
}
if
(
tDecodeI32
(
&
decoder
,
&
pReq
->
numOfRetensions
)
<
0
)
return
-
1
;
pReq
->
pRetensions
=
taosArrayInit
(
pReq
->
numOfRetensions
,
sizeof
(
SRetention
));
if
(
pReq
->
pRetensions
==
NULL
)
{
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
return
-
1
;
}
for
(
int32_t
i
=
0
;
i
<
pReq
->
numOfRetensions
;
++
i
)
{
SRetention
rentension
=
{
0
};
if
(
tDecodeI32
(
&
decoder
,
&
rentension
.
freq
)
<
0
)
return
-
1
;
if
(
tDecodeI32
(
&
decoder
,
&
rentension
.
keep
)
<
0
)
return
-
1
;
if
(
tDecodeI8
(
&
decoder
,
&
rentension
.
freqUnit
)
<
0
)
return
-
1
;
if
(
tDecodeI8
(
&
decoder
,
&
rentension
.
keepUnit
)
<
0
)
return
-
1
;
if
(
taosArrayPush
(
pReq
->
pRetensions
,
&
rentension
)
==
NULL
)
{
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
return
-
1
;
}
}
tEndDecode
(
&
decoder
);
tEndDecode
(
&
decoder
);
tCoderClear
(
&
decoder
);
tCoderClear
(
&
decoder
);
return
0
;
return
0
;
}
}
int32_t
tFreeSCreateVnodeReq
(
SCreateVnodeReq
*
pReq
)
{
taosArrayDestroy
(
pReq
->
pRetensions
);
pReq
->
pRetensions
=
NULL
;
}
int32_t
tSerializeSDropVnodeReq
(
void
*
buf
,
int32_t
bufLen
,
SDropVnodeReq
*
pReq
)
{
int32_t
tSerializeSDropVnodeReq
(
void
*
buf
,
int32_t
bufLen
,
SDropVnodeReq
*
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
);
...
@@ -2946,7 +3045,7 @@ int32_t tSerializeSCMCreateStreamReq(void *buf, int32_t bufLen, const SCMCreateS
...
@@ -2946,7 +3045,7 @@ int32_t tSerializeSCMCreateStreamReq(void *buf, int32_t bufLen, const SCMCreateS
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
(
tEncodeCStr
(
&
encoder
,
pReq
->
outputTbName
)
<
0
)
return
-
1
;
if
(
tEncodeCStr
(
&
encoder
,
pReq
->
output
S
TbName
)
<
0
)
return
-
1
;
if
(
tEncodeI8
(
&
encoder
,
pReq
->
igExists
)
<
0
)
return
-
1
;
if
(
tEncodeI8
(
&
encoder
,
pReq
->
igExists
)
<
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
;
...
@@ -2969,7 +3068,7 @@ int32_t tDeserializeSCMCreateStreamReq(void *buf, int32_t bufLen, SCMCreateStrea
...
@@ -2969,7 +3068,7 @@ int32_t tDeserializeSCMCreateStreamReq(void *buf, int32_t bufLen, SCMCreateStrea
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
(
tDecodeCStrTo
(
&
decoder
,
pReq
->
outputTbName
)
<
0
)
return
-
1
;
if
(
tDecodeCStrTo
(
&
decoder
,
pReq
->
output
S
TbName
)
<
0
)
return
-
1
;
if
(
tDecodeI8
(
&
decoder
,
&
pReq
->
igExists
)
<
0
)
return
-
1
;
if
(
tDecodeI8
(
&
decoder
,
&
pReq
->
igExists
)
<
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
;
...
@@ -3002,12 +3101,14 @@ int32_t tEncodeSStreamTask(SCoder *pEncoder, const SStreamTask *pTask) {
...
@@ -3002,12 +3101,14 @@ int32_t tEncodeSStreamTask(SCoder *pEncoder, const SStreamTask *pTask) {
if
(
tEncodeI32
(
pEncoder
,
pTask
->
taskId
)
<
0
)
return
-
1
;
if
(
tEncodeI32
(
pEncoder
,
pTask
->
taskId
)
<
0
)
return
-
1
;
if
(
tEncodeI32
(
pEncoder
,
pTask
->
level
)
<
0
)
return
-
1
;
if
(
tEncodeI32
(
pEncoder
,
pTask
->
level
)
<
0
)
return
-
1
;
if
(
tEncodeI8
(
pEncoder
,
pTask
->
status
)
<
0
)
return
-
1
;
if
(
tEncodeI8
(
pEncoder
,
pTask
->
status
)
<
0
)
return
-
1
;
if
(
tEncodeI8
(
pEncoder
,
pTask
->
pipeSource
)
<
0
)
return
-
1
;
if
(
tEncodeI8
(
pEncoder
,
pTask
->
pipeSink
)
<
0
)
return
-
1
;
if
(
tEncodeI8
(
pEncoder
,
pTask
->
parallelizable
)
<
0
)
return
-
1
;
if
(
tEncodeI8
(
pEncoder
,
pTask
->
parallelizable
)
<
0
)
return
-
1
;
if
(
tEncodeI8
(
pEncoder
,
pTask
->
nextOpDst
)
<
0
)
return
-
1
;
if
(
tEncodeI8
(
pEncoder
,
pTask
->
nextOpDst
)
<
0
)
return
-
1
;
// if (tEncodeI8(pEncoder, pTask->numOfRunners) < 0) return -1;
if
(
tEncodeI8
(
pEncoder
,
pTask
->
sourceType
)
<
0
)
return
-
1
;
if
(
tEncodeI8
(
pEncoder
,
pTask
->
sinkType
)
<
0
)
return
-
1
;
if
(
pTask
->
sinkType
==
STREAM_SINK_TYPE__ASSIGNED
)
{
if
(
tEncodeI32
(
pEncoder
,
pTask
->
sinkVgId
)
<
0
)
return
-
1
;
if
(
tEncodeSEpSet
(
pEncoder
,
&
pTask
->
NextOpEp
)
<
0
)
return
-
1
;
if
(
tEncodeSEpSet
(
pEncoder
,
&
pTask
->
NextOpEp
)
<
0
)
return
-
1
;
}
if
(
tEncodeCStr
(
pEncoder
,
pTask
->
qmsg
)
<
0
)
return
-
1
;
if
(
tEncodeCStr
(
pEncoder
,
pTask
->
qmsg
)
<
0
)
return
-
1
;
/*tEndEncode(pEncoder);*/
/*tEndEncode(pEncoder);*/
return
pEncoder
->
pos
;
return
pEncoder
->
pos
;
...
@@ -3019,12 +3120,14 @@ int32_t tDecodeSStreamTask(SCoder *pDecoder, SStreamTask *pTask) {
...
@@ -3019,12 +3120,14 @@ int32_t tDecodeSStreamTask(SCoder *pDecoder, SStreamTask *pTask) {
if
(
tDecodeI32
(
pDecoder
,
&
pTask
->
taskId
)
<
0
)
return
-
1
;
if
(
tDecodeI32
(
pDecoder
,
&
pTask
->
taskId
)
<
0
)
return
-
1
;
if
(
tDecodeI32
(
pDecoder
,
&
pTask
->
level
)
<
0
)
return
-
1
;
if
(
tDecodeI32
(
pDecoder
,
&
pTask
->
level
)
<
0
)
return
-
1
;
if
(
tDecodeI8
(
pDecoder
,
&
pTask
->
status
)
<
0
)
return
-
1
;
if
(
tDecodeI8
(
pDecoder
,
&
pTask
->
status
)
<
0
)
return
-
1
;
if
(
tDecodeI8
(
pDecoder
,
&
pTask
->
pipeSource
)
<
0
)
return
-
1
;
if
(
tDecodeI8
(
pDecoder
,
&
pTask
->
pipeSink
)
<
0
)
return
-
1
;
if
(
tDecodeI8
(
pDecoder
,
&
pTask
->
parallelizable
)
<
0
)
return
-
1
;
if
(
tDecodeI8
(
pDecoder
,
&
pTask
->
parallelizable
)
<
0
)
return
-
1
;
if
(
tDecodeI8
(
pDecoder
,
&
pTask
->
nextOpDst
)
<
0
)
return
-
1
;
if
(
tDecodeI8
(
pDecoder
,
&
pTask
->
nextOpDst
)
<
0
)
return
-
1
;
// if (tDecodeI8(pDecoder, &pTask->numOfRunners) < 0) return -1;
if
(
tDecodeI8
(
pDecoder
,
&
pTask
->
sourceType
)
<
0
)
return
-
1
;
if
(
tDecodeI8
(
pDecoder
,
&
pTask
->
sinkType
)
<
0
)
return
-
1
;
if
(
pTask
->
sinkType
==
STREAM_SINK_TYPE__ASSIGNED
)
{
if
(
tDecodeI32
(
pDecoder
,
&
pTask
->
sinkVgId
)
<
0
)
return
-
1
;
if
(
tDecodeSEpSet
(
pDecoder
,
&
pTask
->
NextOpEp
)
<
0
)
return
-
1
;
if
(
tDecodeSEpSet
(
pDecoder
,
&
pTask
->
NextOpEp
)
<
0
)
return
-
1
;
}
if
(
tDecodeCStrAlloc
(
pDecoder
,
&
pTask
->
qmsg
)
<
0
)
return
-
1
;
if
(
tDecodeCStrAlloc
(
pDecoder
,
&
pTask
->
qmsg
)
<
0
)
return
-
1
;
/*tEndDecode(pDecoder);*/
/*tEndDecode(pDecoder);*/
return
0
;
return
0
;
...
...
source/dnode/mgmt/container/inc/dnd.h
浏览文件 @
ba1dd2ca
...
@@ -75,10 +75,8 @@ typedef int32_t (*DropNodeFp)(SMgmtWrapper *pWrapper, SNodeMsg *pMsg);
...
@@ -75,10 +75,8 @@ typedef int32_t (*DropNodeFp)(SMgmtWrapper *pWrapper, SNodeMsg *pMsg);
typedef
int32_t
(
*
RequireNodeFp
)(
SMgmtWrapper
*
pWrapper
,
bool
*
required
);
typedef
int32_t
(
*
RequireNodeFp
)(
SMgmtWrapper
*
pWrapper
,
bool
*
required
);
typedef
struct
SMsgHandle
{
typedef
struct
SMsgHandle
{
int32_t
vgId
;
SMgmtWrapper
*
pQndWrapper
;
NodeMsgFp
vgIdMsgFp
;
SMgmtWrapper
*
pMndWrapper
;
SMgmtWrapper
*
pVgIdWrapper
;
// Handle the case where the same message type is distributed to qnode or vnode
NodeMsgFp
msgFp
;
SMgmtWrapper
*
pWrapper
;
SMgmtWrapper
*
pWrapper
;
}
SMsgHandle
;
}
SMsgHandle
;
...
...
source/dnode/mgmt/container/src/dndObj.c
浏览文件 @
ba1dd2ca
...
@@ -117,6 +117,7 @@ SDnode *dndCreate(const SDnodeOpt *pOption) {
...
@@ -117,6 +117,7 @@ SDnode *dndCreate(const SDnodeOpt *pOption) {
_OVER:
_OVER:
if
(
code
!=
0
&&
pDnode
)
{
if
(
code
!=
0
&&
pDnode
)
{
dndClearMemory
(
pDnode
);
dndClearMemory
(
pDnode
);
pDnode
=
NULL
;
dError
(
"failed to create dnode object since %s"
,
terrstr
());
dError
(
"failed to create dnode object since %s"
,
terrstr
());
}
else
{
}
else
{
dInfo
(
"dnode object is created, data:%p"
,
pDnode
);
dInfo
(
"dnode object is created, data:%p"
,
pDnode
);
...
...
source/dnode/mgmt/container/src/dndTransport.c
浏览文件 @
ba1dd2ca
...
@@ -20,13 +20,15 @@
...
@@ -20,13 +20,15 @@
#define INTERNAL_CKEY "_key"
#define INTERNAL_CKEY "_key"
#define INTERNAL_SECRET "_pwd"
#define INTERNAL_SECRET "_pwd"
static
inline
void
dndProcessQVnodeRpcMsg
(
SMsgHandle
*
pHandle
,
SRpcMsg
*
pMsg
,
SEpSet
*
pEpSet
)
{
static
inline
void
dndProcessQ
M
VnodeRpcMsg
(
SMsgHandle
*
pHandle
,
SRpcMsg
*
pMsg
,
SEpSet
*
pEpSet
)
{
SMsgHead
*
pHead
=
pMsg
->
pCont
;
SMsgHead
*
pHead
=
pMsg
->
pCont
;
int32_t
vgId
=
htonl
(
pHead
->
vgId
);
int32_t
vgId
=
htonl
(
pHead
->
vgId
);
SMgmtWrapper
*
pWrapper
=
pHandle
->
pWrapper
;
SMgmtWrapper
*
pWrapper
=
pHandle
->
pWrapper
;
if
(
vgId
==
pHandle
->
vgId
&&
pHandle
->
pVgIdWrapper
!=
NULL
)
{
if
(
vgId
==
QND_VGID
)
{
pWrapper
=
pHandle
->
pVgIdWrapper
;
pWrapper
=
pHandle
->
pQndWrapper
;
}
else
if
(
vgId
==
MND_VGID
)
{
pWrapper
=
pHandle
->
pMndWrapper
;
}
}
dTrace
(
"msg:%s will be processed by %s, handle:%p app:%p vgId:%d"
,
TMSG_INFO
(
pMsg
->
msgType
),
pWrapper
->
name
,
dTrace
(
"msg:%s will be processed by %s, handle:%p app:%p vgId:%d"
,
TMSG_INFO
(
pMsg
->
msgType
),
pWrapper
->
name
,
...
@@ -46,13 +48,13 @@ static void dndProcessResponse(void *parent, SRpcMsg *pRsp, SEpSet *pEpSet) {
...
@@ -46,13 +48,13 @@ static void dndProcessResponse(void *parent, SRpcMsg *pRsp, SEpSet *pEpSet) {
}
}
SMsgHandle
*
pHandle
=
&
pMgmt
->
msgHandles
[
TMSG_INDEX
(
msgType
)];
SMsgHandle
*
pHandle
=
&
pMgmt
->
msgHandles
[
TMSG_INDEX
(
msgType
)];
if
(
pHandle
->
msgFp
!=
NULL
)
{
if
(
pHandle
->
pWrapper
!=
NULL
)
{
if
(
pHandle
->
vgId
==
0
)
{
if
(
pHandle
->
pMndWrapper
==
NULL
&&
pHandle
->
pQndWrapper
==
NULL
)
{
dTrace
(
"rsp:%s will be processed by %s, handle:%p app:%p code:0x%04x:%s"
,
TMSG_INFO
(
msgType
),
dTrace
(
"rsp:%s will be processed by %s, handle:%p app:%p code:0x%04x:%s"
,
TMSG_INFO
(
msgType
),
pHandle
->
pWrapper
->
name
,
pRsp
->
handle
,
pRsp
->
ahandle
,
pRsp
->
code
&
0XFFFF
,
tstrerror
(
pRsp
->
code
));
pHandle
->
pWrapper
->
name
,
pRsp
->
handle
,
pRsp
->
ahandle
,
pRsp
->
code
&
0XFFFF
,
tstrerror
(
pRsp
->
code
));
dndProcessRpcMsg
(
pHandle
->
pWrapper
,
pRsp
,
pEpSet
);
dndProcessRpcMsg
(
pHandle
->
pWrapper
,
pRsp
,
pEpSet
);
}
else
{
}
else
{
dndProcessQVnodeRpcMsg
(
pHandle
,
pRsp
,
pEpSet
);
dndProcessQ
M
VnodeRpcMsg
(
pHandle
,
pRsp
,
pEpSet
);
}
}
}
else
{
}
else
{
dError
(
"rsp:%s not processed since no handle, handle:%p app:%p"
,
TMSG_INFO
(
msgType
),
pRsp
->
handle
,
pRsp
->
ahandle
);
dError
(
"rsp:%s not processed since no handle, handle:%p app:%p"
,
TMSG_INFO
(
msgType
),
pRsp
->
handle
,
pRsp
->
ahandle
);
...
@@ -126,13 +128,13 @@ static void dndProcessRequest(void *param, SRpcMsg *pReq, SEpSet *pEpSet) {
...
@@ -126,13 +128,13 @@ static void dndProcessRequest(void *param, SRpcMsg *pReq, SEpSet *pEpSet) {
}
}
SMsgHandle
*
pHandle
=
&
pMgmt
->
msgHandles
[
TMSG_INDEX
(
msgType
)];
SMsgHandle
*
pHandle
=
&
pMgmt
->
msgHandles
[
TMSG_INDEX
(
msgType
)];
if
(
pHandle
->
msgFp
!=
NULL
)
{
if
(
pHandle
->
pWrapper
!=
NULL
)
{
if
(
pHandle
->
vgId
==
0
)
{
if
(
pHandle
->
pMndWrapper
==
NULL
&&
pHandle
->
pQndWrapper
==
NULL
)
{
dTrace
(
"req:%s will be processed by %s, handle:%p app:%p"
,
TMSG_INFO
(
msgType
),
pHandle
->
pWrapper
->
name
,
dTrace
(
"req:%s will be processed by %s, handle:%p app:%p"
,
TMSG_INFO
(
msgType
),
pHandle
->
pWrapper
->
name
,
pReq
->
handle
,
pReq
->
ahandle
);
pReq
->
handle
,
pReq
->
ahandle
);
dndProcessRpcMsg
(
pHandle
->
pWrapper
,
pReq
,
pEpSet
);
dndProcessRpcMsg
(
pHandle
->
pWrapper
,
pReq
,
pEpSet
);
}
else
{
}
else
{
dndProcessQVnodeRpcMsg
(
pHandle
,
pReq
,
pEpSet
);
dndProcessQ
M
VnodeRpcMsg
(
pHandle
,
pReq
,
pEpSet
);
}
}
}
else
{
}
else
{
dError
(
"req:%s not processed since no handle, handle:%p app:%p"
,
TMSG_INFO
(
msgType
),
pReq
->
handle
,
pReq
->
ahandle
);
dError
(
"req:%s not processed since no handle, handle:%p app:%p"
,
TMSG_INFO
(
msgType
),
pReq
->
handle
,
pReq
->
ahandle
);
...
@@ -269,21 +271,27 @@ int32_t dndInitMsgHandle(SDnode *pDnode) {
...
@@ -269,21 +271,27 @@ int32_t dndInitMsgHandle(SDnode *pDnode) {
int32_t
vgId
=
pWrapper
->
msgVgIds
[
msgIndex
];
int32_t
vgId
=
pWrapper
->
msgVgIds
[
msgIndex
];
if
(
msgFp
==
NULL
)
continue
;
if
(
msgFp
==
NULL
)
continue
;
dTrace
(
"msg:%s will be processed by %s, vgId:%d"
,
tMsgInfo
[
msgIndex
],
pWrapper
->
name
,
vgId
);
SMsgHandle
*
pHandle
=
&
pMgmt
->
msgHandles
[
msgIndex
];
SMsgHandle
*
pHandle
=
&
pMgmt
->
msgHandles
[
msgIndex
];
if
(
pHandle
->
msgFp
!=
NULL
&&
pHandle
->
vgId
==
vgId
)
{
if
(
vgId
==
QND_VGID
)
{
dError
(
"msg:%s has multiple process nodes, prev node:%s:%d, curr node:%s:%d"
,
tMsgInfo
[
msgIndex
],
if
(
pHandle
->
pQndWrapper
!=
NULL
)
{
pHandle
->
pWrapper
->
name
,
pHandle
->
pWrapper
->
msgVgIds
[
msgIndex
],
pWrapper
->
name
,
vgId
);
dError
(
"msg:%s has multiple process nodes"
,
tMsgInfo
[
msgIndex
]
);
return
-
1
;
return
-
1
;
}
pHandle
->
pQndWrapper
=
pWrapper
;
}
else
if
(
vgId
==
MND_VGID
)
{
if
(
pHandle
->
pMndWrapper
!=
NULL
)
{
dError
(
"msg:%s has multiple process nodes"
,
tMsgInfo
[
msgIndex
]);
return
-
1
;
}
pHandle
->
pMndWrapper
=
pWrapper
;
}
else
{
}
else
{
dTrace
(
"msg:%s will be processed by %s, vgId:%d"
,
tMsgInfo
[
msgIndex
],
pWrapper
->
name
,
vgId
);
if
(
pHandle
->
pWrapper
!=
NULL
)
{
if
(
vgId
==
0
)
{
dError
(
"msg:%s has multiple process nodes"
,
tMsgInfo
[
msgIndex
]);
pHandle
->
msgFp
=
msgFp
;
return
-
1
;
pHandle
->
pWrapper
=
pWrapper
;
}
else
{
pHandle
->
vgId
=
vgId
;
pHandle
->
vgIdMsgFp
=
msgFp
;
pHandle
->
pVgIdWrapper
=
pWrapper
;
}
}
pHandle
->
pWrapper
=
pWrapper
;
}
}
}
}
}
}
...
...
source/dnode/mgmt/dnode/src/dmMsg.c
浏览文件 @
ba1dd2ca
...
@@ -114,19 +114,19 @@ int32_t dmProcessConfigReq(SDnodeMgmt *pMgmt, SNodeMsg *pMsg) {
...
@@ -114,19 +114,19 @@ int32_t dmProcessConfigReq(SDnodeMgmt *pMgmt, SNodeMsg *pMsg) {
void
dmInitMsgHandles
(
SMgmtWrapper
*
pWrapper
)
{
void
dmInitMsgHandles
(
SMgmtWrapper
*
pWrapper
)
{
// Requests handled by DNODE
// Requests handled by DNODE
dndSetMsgHandle
(
pWrapper
,
TDMT_DND_CREATE_MNODE
,
(
NodeMsgFp
)
dmProcessMgmtMsg
,
0
);
dndSetMsgHandle
(
pWrapper
,
TDMT_DND_CREATE_MNODE
,
(
NodeMsgFp
)
dmProcessMgmtMsg
,
VND_VGID
);
dndSetMsgHandle
(
pWrapper
,
TDMT_DND_DROP_MNODE
,
(
NodeMsgFp
)
dmProcessMgmtMsg
,
0
);
dndSetMsgHandle
(
pWrapper
,
TDMT_DND_DROP_MNODE
,
(
NodeMsgFp
)
dmProcessMgmtMsg
,
VND_VGID
);
dndSetMsgHandle
(
pWrapper
,
TDMT_DND_CREATE_QNODE
,
(
NodeMsgFp
)
dmProcessMgmtMsg
,
0
);
dndSetMsgHandle
(
pWrapper
,
TDMT_DND_CREATE_QNODE
,
(
NodeMsgFp
)
dmProcessMgmtMsg
,
VND_VGID
);
dndSetMsgHandle
(
pWrapper
,
TDMT_DND_DROP_QNODE
,
(
NodeMsgFp
)
dmProcessMgmtMsg
,
0
);
dndSetMsgHandle
(
pWrapper
,
TDMT_DND_DROP_QNODE
,
(
NodeMsgFp
)
dmProcessMgmtMsg
,
VND_VGID
);
dndSetMsgHandle
(
pWrapper
,
TDMT_DND_CREATE_SNODE
,
(
NodeMsgFp
)
dmProcessMgmtMsg
,
0
);
dndSetMsgHandle
(
pWrapper
,
TDMT_DND_CREATE_SNODE
,
(
NodeMsgFp
)
dmProcessMgmtMsg
,
VND_VGID
);
dndSetMsgHandle
(
pWrapper
,
TDMT_DND_DROP_SNODE
,
(
NodeMsgFp
)
dmProcessMgmtMsg
,
0
);
dndSetMsgHandle
(
pWrapper
,
TDMT_DND_DROP_SNODE
,
(
NodeMsgFp
)
dmProcessMgmtMsg
,
VND_VGID
);
dndSetMsgHandle
(
pWrapper
,
TDMT_DND_CREATE_BNODE
,
(
NodeMsgFp
)
dmProcessMgmtMsg
,
0
);
dndSetMsgHandle
(
pWrapper
,
TDMT_DND_CREATE_BNODE
,
(
NodeMsgFp
)
dmProcessMgmtMsg
,
VND_VGID
);
dndSetMsgHandle
(
pWrapper
,
TDMT_DND_DROP_BNODE
,
(
NodeMsgFp
)
dmProcessMgmtMsg
,
0
);
dndSetMsgHandle
(
pWrapper
,
TDMT_DND_DROP_BNODE
,
(
NodeMsgFp
)
dmProcessMgmtMsg
,
VND_VGID
);
dndSetMsgHandle
(
pWrapper
,
TDMT_DND_CONFIG_DNODE
,
(
NodeMsgFp
)
dmProcessMgmtMsg
,
0
);
dndSetMsgHandle
(
pWrapper
,
TDMT_DND_CONFIG_DNODE
,
(
NodeMsgFp
)
dmProcessMgmtMsg
,
VND_VGID
);
dndSetMsgHandle
(
pWrapper
,
TDMT_DND_NETWORK_TEST
,
(
NodeMsgFp
)
dmProcessMgmtMsg
,
0
);
dndSetMsgHandle
(
pWrapper
,
TDMT_DND_NETWORK_TEST
,
(
NodeMsgFp
)
dmProcessMgmtMsg
,
VND_VGID
);
// Requests handled by MNODE
// Requests handled by MNODE
dndSetMsgHandle
(
pWrapper
,
TDMT_MND_STATUS_RSP
,
(
NodeMsgFp
)
dmProcessMgmtMsg
,
0
);
dndSetMsgHandle
(
pWrapper
,
TDMT_MND_STATUS_RSP
,
(
NodeMsgFp
)
dmProcessMgmtMsg
,
VND_VGID
);
dndSetMsgHandle
(
pWrapper
,
TDMT_MND_GRANT_RSP
,
(
NodeMsgFp
)
dmProcessMgmtMsg
,
0
);
dndSetMsgHandle
(
pWrapper
,
TDMT_MND_GRANT_RSP
,
(
NodeMsgFp
)
dmProcessMgmtMsg
,
VND_VGID
);
dndSetMsgHandle
(
pWrapper
,
TDMT_MND_AUTH_RSP
,
(
NodeMsgFp
)
dmProcessMgmtMsg
,
0
);
dndSetMsgHandle
(
pWrapper
,
TDMT_MND_AUTH_RSP
,
(
NodeMsgFp
)
dmProcessMgmtMsg
,
VND_VGID
);
}
}
source/dnode/mgmt/mnode/src/mmMsg.c
浏览文件 @
ba1dd2ca
...
@@ -75,84 +75,90 @@ int32_t mmProcessAlterReq(SMnodeMgmt *pMgmt, SNodeMsg *pMsg) {
...
@@ -75,84 +75,90 @@ int32_t mmProcessAlterReq(SMnodeMgmt *pMgmt, SNodeMsg *pMsg) {
void
mmInitMsgHandles
(
SMgmtWrapper
*
pWrapper
)
{
void
mmInitMsgHandles
(
SMgmtWrapper
*
pWrapper
)
{
// Requests handled by DNODE
// Requests handled by DNODE
dndSetMsgHandle
(
pWrapper
,
TDMT_DND_CREATE_MNODE_RSP
,
(
NodeMsgFp
)
mmProcessWriteMsg
,
0
);
dndSetMsgHandle
(
pWrapper
,
TDMT_DND_CREATE_MNODE_RSP
,
(
NodeMsgFp
)
mmProcessWriteMsg
,
VND_VGID
);
dndSetMsgHandle
(
pWrapper
,
TDMT_DND_ALTER_MNODE_RSP
,
(
NodeMsgFp
)
mmProcessWriteMsg
,
0
);
dndSetMsgHandle
(
pWrapper
,
TDMT_DND_ALTER_MNODE_RSP
,
(
NodeMsgFp
)
mmProcessWriteMsg
,
VND_VGID
);
dndSetMsgHandle
(
pWrapper
,
TDMT_DND_DROP_MNODE_RSP
,
(
NodeMsgFp
)
mmProcessWriteMsg
,
0
);
dndSetMsgHandle
(
pWrapper
,
TDMT_DND_DROP_MNODE_RSP
,
(
NodeMsgFp
)
mmProcessWriteMsg
,
VND_VGID
);
dndSetMsgHandle
(
pWrapper
,
TDMT_DND_CREATE_QNODE_RSP
,
(
NodeMsgFp
)
mmProcessWriteMsg
,
0
);
dndSetMsgHandle
(
pWrapper
,
TDMT_DND_CREATE_QNODE_RSP
,
(
NodeMsgFp
)
mmProcessWriteMsg
,
VND_VGID
);
dndSetMsgHandle
(
pWrapper
,
TDMT_DND_DROP_QNODE_RSP
,
(
NodeMsgFp
)
mmProcessWriteMsg
,
0
);
dndSetMsgHandle
(
pWrapper
,
TDMT_DND_DROP_QNODE_RSP
,
(
NodeMsgFp
)
mmProcessWriteMsg
,
VND_VGID
);
dndSetMsgHandle
(
pWrapper
,
TDMT_DND_CREATE_SNODE_RSP
,
(
NodeMsgFp
)
mmProcessWriteMsg
,
0
);
dndSetMsgHandle
(
pWrapper
,
TDMT_DND_CREATE_SNODE_RSP
,
(
NodeMsgFp
)
mmProcessWriteMsg
,
VND_VGID
);
dndSetMsgHandle
(
pWrapper
,
TDMT_DND_DROP_SNODE_RSP
,
(
NodeMsgFp
)
mmProcessWriteMsg
,
0
);
dndSetMsgHandle
(
pWrapper
,
TDMT_DND_DROP_SNODE_RSP
,
(
NodeMsgFp
)
mmProcessWriteMsg
,
VND_VGID
);
dndSetMsgHandle
(
pWrapper
,
TDMT_DND_CREATE_BNODE_RSP
,
(
NodeMsgFp
)
mmProcessWriteMsg
,
0
);
dndSetMsgHandle
(
pWrapper
,
TDMT_DND_CREATE_BNODE_RSP
,
(
NodeMsgFp
)
mmProcessWriteMsg
,
VND_VGID
);
dndSetMsgHandle
(
pWrapper
,
TDMT_DND_DROP_BNODE_RSP
,
(
NodeMsgFp
)
mmProcessWriteMsg
,
0
);
dndSetMsgHandle
(
pWrapper
,
TDMT_DND_DROP_BNODE_RSP
,
(
NodeMsgFp
)
mmProcessWriteMsg
,
VND_VGID
);
dndSetMsgHandle
(
pWrapper
,
TDMT_DND_CREATE_VNODE_RSP
,
(
NodeMsgFp
)
mmProcessWriteMsg
,
0
);
dndSetMsgHandle
(
pWrapper
,
TDMT_DND_CREATE_VNODE_RSP
,
(
NodeMsgFp
)
mmProcessWriteMsg
,
VND_VGID
);
dndSetMsgHandle
(
pWrapper
,
TDMT_DND_ALTER_VNODE_RSP
,
(
NodeMsgFp
)
mmProcessWriteMsg
,
0
);
dndSetMsgHandle
(
pWrapper
,
TDMT_DND_ALTER_VNODE_RSP
,
(
NodeMsgFp
)
mmProcessWriteMsg
,
VND_VGID
);
dndSetMsgHandle
(
pWrapper
,
TDMT_DND_DROP_VNODE_RSP
,
(
NodeMsgFp
)
mmProcessWriteMsg
,
0
);
dndSetMsgHandle
(
pWrapper
,
TDMT_DND_DROP_VNODE_RSP
,
(
NodeMsgFp
)
mmProcessWriteMsg
,
VND_VGID
);
dndSetMsgHandle
(
pWrapper
,
TDMT_DND_SYNC_VNODE_RSP
,
(
NodeMsgFp
)
mmProcessWriteMsg
,
0
);
dndSetMsgHandle
(
pWrapper
,
TDMT_DND_SYNC_VNODE_RSP
,
(
NodeMsgFp
)
mmProcessWriteMsg
,
VND_VGID
);
dndSetMsgHandle
(
pWrapper
,
TDMT_DND_COMPACT_VNODE_RSP
,
(
NodeMsgFp
)
mmProcessWriteMsg
,
0
);
dndSetMsgHandle
(
pWrapper
,
TDMT_DND_COMPACT_VNODE_RSP
,
(
NodeMsgFp
)
mmProcessWriteMsg
,
VND_VGID
);
dndSetMsgHandle
(
pWrapper
,
TDMT_DND_CONFIG_DNODE_RSP
,
(
NodeMsgFp
)
mmProcessWriteMsg
,
0
);
dndSetMsgHandle
(
pWrapper
,
TDMT_DND_CONFIG_DNODE_RSP
,
(
NodeMsgFp
)
mmProcessWriteMsg
,
VND_VGID
);
// Requests handled by MNODE
// Requests handled by MNODE
dndSetMsgHandle
(
pWrapper
,
TDMT_MND_CONNECT
,
(
NodeMsgFp
)
mmProcessReadMsg
,
0
);
dndSetMsgHandle
(
pWrapper
,
TDMT_MND_CONNECT
,
(
NodeMsgFp
)
mmProcessReadMsg
,
VND_VGID
);
dndSetMsgHandle
(
pWrapper
,
TDMT_MND_CREATE_ACCT
,
(
NodeMsgFp
)
mmProcessWriteMsg
,
0
);
dndSetMsgHandle
(
pWrapper
,
TDMT_MND_CREATE_ACCT
,
(
NodeMsgFp
)
mmProcessWriteMsg
,
VND_VGID
);
dndSetMsgHandle
(
pWrapper
,
TDMT_MND_ALTER_ACCT
,
(
NodeMsgFp
)
mmProcessWriteMsg
,
0
);
dndSetMsgHandle
(
pWrapper
,
TDMT_MND_ALTER_ACCT
,
(
NodeMsgFp
)
mmProcessWriteMsg
,
VND_VGID
);
dndSetMsgHandle
(
pWrapper
,
TDMT_MND_DROP_ACCT
,
(
NodeMsgFp
)
mmProcessWriteMsg
,
0
);
dndSetMsgHandle
(
pWrapper
,
TDMT_MND_DROP_ACCT
,
(
NodeMsgFp
)
mmProcessWriteMsg
,
VND_VGID
);
dndSetMsgHandle
(
pWrapper
,
TDMT_MND_CREATE_USER
,
(
NodeMsgFp
)
mmProcessWriteMsg
,
0
);
dndSetMsgHandle
(
pWrapper
,
TDMT_MND_CREATE_USER
,
(
NodeMsgFp
)
mmProcessWriteMsg
,
VND_VGID
);
dndSetMsgHandle
(
pWrapper
,
TDMT_MND_ALTER_USER
,
(
NodeMsgFp
)
mmProcessWriteMsg
,
0
);
dndSetMsgHandle
(
pWrapper
,
TDMT_MND_ALTER_USER
,
(
NodeMsgFp
)
mmProcessWriteMsg
,
VND_VGID
);
dndSetMsgHandle
(
pWrapper
,
TDMT_MND_DROP_USER
,
(
NodeMsgFp
)
mmProcessWriteMsg
,
0
);
dndSetMsgHandle
(
pWrapper
,
TDMT_MND_DROP_USER
,
(
NodeMsgFp
)
mmProcessWriteMsg
,
VND_VGID
);
dndSetMsgHandle
(
pWrapper
,
TDMT_MND_GET_USER_AUTH
,
(
NodeMsgFp
)
mmProcessReadMsg
,
0
);
dndSetMsgHandle
(
pWrapper
,
TDMT_MND_GET_USER_AUTH
,
(
NodeMsgFp
)
mmProcessReadMsg
,
VND_VGID
);
dndSetMsgHandle
(
pWrapper
,
TDMT_MND_CREATE_DNODE
,
(
NodeMsgFp
)
mmProcessWriteMsg
,
0
);
dndSetMsgHandle
(
pWrapper
,
TDMT_MND_CREATE_DNODE
,
(
NodeMsgFp
)
mmProcessWriteMsg
,
VND_VGID
);
dndSetMsgHandle
(
pWrapper
,
TDMT_MND_CONFIG_DNODE
,
(
NodeMsgFp
)
mmProcessWriteMsg
,
0
);
dndSetMsgHandle
(
pWrapper
,
TDMT_MND_CONFIG_DNODE
,
(
NodeMsgFp
)
mmProcessWriteMsg
,
VND_VGID
);
dndSetMsgHandle
(
pWrapper
,
TDMT_MND_DROP_DNODE
,
(
NodeMsgFp
)
mmProcessWriteMsg
,
0
);
dndSetMsgHandle
(
pWrapper
,
TDMT_MND_DROP_DNODE
,
(
NodeMsgFp
)
mmProcessWriteMsg
,
VND_VGID
);
dndSetMsgHandle
(
pWrapper
,
TDMT_MND_CREATE_MNODE
,
(
NodeMsgFp
)
mmProcessWriteMsg
,
0
);
dndSetMsgHandle
(
pWrapper
,
TDMT_MND_CREATE_MNODE
,
(
NodeMsgFp
)
mmProcessWriteMsg
,
VND_VGID
);
dndSetMsgHandle
(
pWrapper
,
TDMT_MND_DROP_MNODE
,
(
NodeMsgFp
)
mmProcessWriteMsg
,
0
);
dndSetMsgHandle
(
pWrapper
,
TDMT_MND_DROP_MNODE
,
(
NodeMsgFp
)
mmProcessWriteMsg
,
VND_VGID
);
dndSetMsgHandle
(
pWrapper
,
TDMT_MND_CREATE_QNODE
,
(
NodeMsgFp
)
mmProcessWriteMsg
,
0
);
dndSetMsgHandle
(
pWrapper
,
TDMT_MND_CREATE_QNODE
,
(
NodeMsgFp
)
mmProcessWriteMsg
,
VND_VGID
);
dndSetMsgHandle
(
pWrapper
,
TDMT_MND_DROP_QNODE
,
(
NodeMsgFp
)
mmProcessWriteMsg
,
0
);
dndSetMsgHandle
(
pWrapper
,
TDMT_MND_DROP_QNODE
,
(
NodeMsgFp
)
mmProcessWriteMsg
,
VND_VGID
);
dndSetMsgHandle
(
pWrapper
,
TDMT_MND_CREATE_SNODE
,
(
NodeMsgFp
)
mmProcessWriteMsg
,
0
);
dndSetMsgHandle
(
pWrapper
,
TDMT_MND_CREATE_SNODE
,
(
NodeMsgFp
)
mmProcessWriteMsg
,
VND_VGID
);
dndSetMsgHandle
(
pWrapper
,
TDMT_MND_DROP_SNODE
,
(
NodeMsgFp
)
mmProcessWriteMsg
,
0
);
dndSetMsgHandle
(
pWrapper
,
TDMT_MND_DROP_SNODE
,
(
NodeMsgFp
)
mmProcessWriteMsg
,
VND_VGID
);
dndSetMsgHandle
(
pWrapper
,
TDMT_MND_CREATE_BNODE
,
(
NodeMsgFp
)
mmProcessWriteMsg
,
0
);
dndSetMsgHandle
(
pWrapper
,
TDMT_MND_CREATE_BNODE
,
(
NodeMsgFp
)
mmProcessWriteMsg
,
VND_VGID
);
dndSetMsgHandle
(
pWrapper
,
TDMT_MND_DROP_BNODE
,
(
NodeMsgFp
)
mmProcessWriteMsg
,
0
);
dndSetMsgHandle
(
pWrapper
,
TDMT_MND_DROP_BNODE
,
(
NodeMsgFp
)
mmProcessWriteMsg
,
VND_VGID
);
dndSetMsgHandle
(
pWrapper
,
TDMT_MND_CREATE_DB
,
(
NodeMsgFp
)
mmProcessWriteMsg
,
0
);
dndSetMsgHandle
(
pWrapper
,
TDMT_MND_CREATE_DB
,
(
NodeMsgFp
)
mmProcessWriteMsg
,
VND_VGID
);
dndSetMsgHandle
(
pWrapper
,
TDMT_MND_DROP_DB
,
(
NodeMsgFp
)
mmProcessWriteMsg
,
0
);
dndSetMsgHandle
(
pWrapper
,
TDMT_MND_DROP_DB
,
(
NodeMsgFp
)
mmProcessWriteMsg
,
VND_VGID
);
dndSetMsgHandle
(
pWrapper
,
TDMT_MND_USE_DB
,
(
NodeMsgFp
)
mmProcessWriteMsg
,
0
);
dndSetMsgHandle
(
pWrapper
,
TDMT_MND_USE_DB
,
(
NodeMsgFp
)
mmProcessWriteMsg
,
VND_VGID
);
dndSetMsgHandle
(
pWrapper
,
TDMT_MND_ALTER_DB
,
(
NodeMsgFp
)
mmProcessWriteMsg
,
0
);
dndSetMsgHandle
(
pWrapper
,
TDMT_MND_ALTER_DB
,
(
NodeMsgFp
)
mmProcessWriteMsg
,
VND_VGID
);
dndSetMsgHandle
(
pWrapper
,
TDMT_MND_SYNC_DB
,
(
NodeMsgFp
)
mmProcessWriteMsg
,
0
);
dndSetMsgHandle
(
pWrapper
,
TDMT_MND_SYNC_DB
,
(
NodeMsgFp
)
mmProcessWriteMsg
,
VND_VGID
);
dndSetMsgHandle
(
pWrapper
,
TDMT_MND_COMPACT_DB
,
(
NodeMsgFp
)
mmProcessWriteMsg
,
0
);
dndSetMsgHandle
(
pWrapper
,
TDMT_MND_COMPACT_DB
,
(
NodeMsgFp
)
mmProcessWriteMsg
,
VND_VGID
);
dndSetMsgHandle
(
pWrapper
,
TDMT_MND_CREATE_FUNC
,
(
NodeMsgFp
)
mmProcessWriteMsg
,
0
);
dndSetMsgHandle
(
pWrapper
,
TDMT_MND_CREATE_FUNC
,
(
NodeMsgFp
)
mmProcessWriteMsg
,
VND_VGID
);
dndSetMsgHandle
(
pWrapper
,
TDMT_MND_RETRIEVE_FUNC
,
(
NodeMsgFp
)
mmProcessWriteMsg
,
0
);
dndSetMsgHandle
(
pWrapper
,
TDMT_MND_RETRIEVE_FUNC
,
(
NodeMsgFp
)
mmProcessWriteMsg
,
VND_VGID
);
dndSetMsgHandle
(
pWrapper
,
TDMT_MND_DROP_FUNC
,
(
NodeMsgFp
)
mmProcessWriteMsg
,
0
);
dndSetMsgHandle
(
pWrapper
,
TDMT_MND_DROP_FUNC
,
(
NodeMsgFp
)
mmProcessWriteMsg
,
VND_VGID
);
dndSetMsgHandle
(
pWrapper
,
TDMT_MND_CREATE_STB
,
(
NodeMsgFp
)
mmProcessWriteMsg
,
0
);
dndSetMsgHandle
(
pWrapper
,
TDMT_MND_CREATE_STB
,
(
NodeMsgFp
)
mmProcessWriteMsg
,
VND_VGID
);
dndSetMsgHandle
(
pWrapper
,
TDMT_MND_ALTER_STB
,
(
NodeMsgFp
)
mmProcessWriteMsg
,
0
);
dndSetMsgHandle
(
pWrapper
,
TDMT_MND_ALTER_STB
,
(
NodeMsgFp
)
mmProcessWriteMsg
,
VND_VGID
);
dndSetMsgHandle
(
pWrapper
,
TDMT_MND_DROP_STB
,
(
NodeMsgFp
)
mmProcessWriteMsg
,
0
);
dndSetMsgHandle
(
pWrapper
,
TDMT_MND_DROP_STB
,
(
NodeMsgFp
)
mmProcessWriteMsg
,
VND_VGID
);
dndSetMsgHandle
(
pWrapper
,
TDMT_MND_CREATE_SMA
,
(
NodeMsgFp
)
mmProcessWriteMsg
,
0
);
dndSetMsgHandle
(
pWrapper
,
TDMT_MND_CREATE_SMA
,
(
NodeMsgFp
)
mmProcessWriteMsg
,
VND_VGID
);
dndSetMsgHandle
(
pWrapper
,
TDMT_MND_DROP_SMA
,
(
NodeMsgFp
)
mmProcessWriteMsg
,
0
);
dndSetMsgHandle
(
pWrapper
,
TDMT_MND_DROP_SMA
,
(
NodeMsgFp
)
mmProcessWriteMsg
,
VND_VGID
);
dndSetMsgHandle
(
pWrapper
,
TDMT_MND_TABLE_META
,
(
NodeMsgFp
)
mmProcessReadMsg
,
0
);
dndSetMsgHandle
(
pWrapper
,
TDMT_MND_TABLE_META
,
(
NodeMsgFp
)
mmProcessReadMsg
,
VND_VGID
);
dndSetMsgHandle
(
pWrapper
,
TDMT_MND_VGROUP_LIST
,
(
NodeMsgFp
)
mmProcessReadMsg
,
0
);
dndSetMsgHandle
(
pWrapper
,
TDMT_MND_VGROUP_LIST
,
(
NodeMsgFp
)
mmProcessReadMsg
,
VND_VGID
);
dndSetMsgHandle
(
pWrapper
,
TDMT_MND_KILL_QUERY
,
(
NodeMsgFp
)
mmProcessWriteMsg
,
0
);
dndSetMsgHandle
(
pWrapper
,
TDMT_MND_KILL_QUERY
,
(
NodeMsgFp
)
mmProcessWriteMsg
,
VND_VGID
);
dndSetMsgHandle
(
pWrapper
,
TDMT_MND_KILL_CONN
,
(
NodeMsgFp
)
mmProcessWriteMsg
,
0
);
dndSetMsgHandle
(
pWrapper
,
TDMT_MND_KILL_CONN
,
(
NodeMsgFp
)
mmProcessWriteMsg
,
VND_VGID
);
dndSetMsgHandle
(
pWrapper
,
TDMT_MND_HEARTBEAT
,
(
NodeMsgFp
)
mmProcessWriteMsg
,
0
);
dndSetMsgHandle
(
pWrapper
,
TDMT_MND_HEARTBEAT
,
(
NodeMsgFp
)
mmProcessWriteMsg
,
VND_VGID
);
dndSetMsgHandle
(
pWrapper
,
TDMT_MND_SHOW
,
(
NodeMsgFp
)
mmProcessReadMsg
,
0
);
dndSetMsgHandle
(
pWrapper
,
TDMT_MND_SHOW
,
(
NodeMsgFp
)
mmProcessReadMsg
,
VND_VGID
);
dndSetMsgHandle
(
pWrapper
,
TDMT_MND_SHOW_RETRIEVE
,
(
NodeMsgFp
)
mmProcessReadMsg
,
0
);
dndSetMsgHandle
(
pWrapper
,
TDMT_MND_SHOW_RETRIEVE
,
(
NodeMsgFp
)
mmProcessReadMsg
,
VND_VGID
);
dndSetMsgHandle
(
pWrapper
,
TDMT_MND_SYSTABLE_RETRIEVE
,
(
NodeMsgFp
)
mmProcessReadMsg
,
0
);
dndSetMsgHandle
(
pWrapper
,
TDMT_MND_SYSTABLE_RETRIEVE
,
(
NodeMsgFp
)
mmProcessReadMsg
,
VND_VGID
);
dndSetMsgHandle
(
pWrapper
,
TDMT_MND_STATUS
,
(
NodeMsgFp
)
mmProcessReadMsg
,
0
);
dndSetMsgHandle
(
pWrapper
,
TDMT_MND_STATUS
,
(
NodeMsgFp
)
mmProcessReadMsg
,
VND_VGID
);
dndSetMsgHandle
(
pWrapper
,
TDMT_MND_KILL_TRANS
,
(
NodeMsgFp
)
mmProcessWriteMsg
,
0
);
dndSetMsgHandle
(
pWrapper
,
TDMT_MND_KILL_TRANS
,
(
NodeMsgFp
)
mmProcessWriteMsg
,
VND_VGID
);
dndSetMsgHandle
(
pWrapper
,
TDMT_MND_GRANT
,
(
NodeMsgFp
)
mmProcessWriteMsg
,
0
);
dndSetMsgHandle
(
pWrapper
,
TDMT_MND_GRANT
,
(
NodeMsgFp
)
mmProcessWriteMsg
,
VND_VGID
);
dndSetMsgHandle
(
pWrapper
,
TDMT_MND_AUTH
,
(
NodeMsgFp
)
mmProcessReadMsg
,
0
);
dndSetMsgHandle
(
pWrapper
,
TDMT_MND_AUTH
,
(
NodeMsgFp
)
mmProcessReadMsg
,
VND_VGID
);
dndSetMsgHandle
(
pWrapper
,
TDMT_DND_ALTER_MNODE
,
(
NodeMsgFp
)
mmProcessWriteMsg
,
0
);
dndSetMsgHandle
(
pWrapper
,
TDMT_DND_ALTER_MNODE
,
(
NodeMsgFp
)
mmProcessWriteMsg
,
VND_VGID
);
dndSetMsgHandle
(
pWrapper
,
TDMT_MND_CREATE_TOPIC
,
(
NodeMsgFp
)
mmProcessWriteMsg
,
0
);
dndSetMsgHandle
(
pWrapper
,
TDMT_MND_CREATE_TOPIC
,
(
NodeMsgFp
)
mmProcessWriteMsg
,
VND_VGID
);
dndSetMsgHandle
(
pWrapper
,
TDMT_MND_ALTER_TOPIC
,
(
NodeMsgFp
)
mmProcessWriteMsg
,
0
);
dndSetMsgHandle
(
pWrapper
,
TDMT_MND_ALTER_TOPIC
,
(
NodeMsgFp
)
mmProcessWriteMsg
,
VND_VGID
);
dndSetMsgHandle
(
pWrapper
,
TDMT_MND_DROP_TOPIC
,
(
NodeMsgFp
)
mmProcessWriteMsg
,
0
);
dndSetMsgHandle
(
pWrapper
,
TDMT_MND_DROP_TOPIC
,
(
NodeMsgFp
)
mmProcessWriteMsg
,
VND_VGID
);
dndSetMsgHandle
(
pWrapper
,
TDMT_MND_SUBSCRIBE
,
(
NodeMsgFp
)
mmProcessWriteMsg
,
0
);
dndSetMsgHandle
(
pWrapper
,
TDMT_MND_SUBSCRIBE
,
(
NodeMsgFp
)
mmProcessWriteMsg
,
VND_VGID
);
dndSetMsgHandle
(
pWrapper
,
TDMT_MND_MQ_COMMIT_OFFSET
,
(
NodeMsgFp
)
mmProcessWriteMsg
,
0
);
dndSetMsgHandle
(
pWrapper
,
TDMT_MND_MQ_COMMIT_OFFSET
,
(
NodeMsgFp
)
mmProcessWriteMsg
,
VND_VGID
);
dndSetMsgHandle
(
pWrapper
,
TDMT_MND_GET_SUB_EP
,
(
NodeMsgFp
)
mmProcessReadMsg
,
0
);
dndSetMsgHandle
(
pWrapper
,
TDMT_MND_GET_SUB_EP
,
(
NodeMsgFp
)
mmProcessReadMsg
,
VND_VGID
);
dndSetMsgHandle
(
pWrapper
,
TDMT_MND_CREATE_STREAM
,
(
NodeMsgFp
)
mmProcessWriteMsg
,
0
);
dndSetMsgHandle
(
pWrapper
,
TDMT_MND_CREATE_STREAM
,
(
NodeMsgFp
)
mmProcessWriteMsg
,
VND_VGID
);
dndSetMsgHandle
(
pWrapper
,
TDMT_VND_TASK_DEPLOY_RSP
,
(
NodeMsgFp
)
mmProcessWriteMsg
,
0
);
dndSetMsgHandle
(
pWrapper
,
TDMT_VND_TASK_DEPLOY_RSP
,
(
NodeMsgFp
)
mmProcessWriteMsg
,
VND_VGID
);
// Requests handled by VNODE
// Requests handled by VNODE
dndSetMsgHandle
(
pWrapper
,
TDMT_VND_MQ_SET_CONN_RSP
,
(
NodeMsgFp
)
mmProcessWriteMsg
,
0
);
dndSetMsgHandle
(
pWrapper
,
TDMT_VND_MQ_SET_CONN_RSP
,
(
NodeMsgFp
)
mmProcessWriteMsg
,
VND_VGID
);
dndSetMsgHandle
(
pWrapper
,
TDMT_VND_MQ_REB_RSP
,
(
NodeMsgFp
)
mmProcessWriteMsg
,
0
);
dndSetMsgHandle
(
pWrapper
,
TDMT_VND_MQ_REB_RSP
,
(
NodeMsgFp
)
mmProcessWriteMsg
,
VND_VGID
);
dndSetMsgHandle
(
pWrapper
,
TDMT_VND_CREATE_STB_RSP
,
(
NodeMsgFp
)
mmProcessWriteMsg
,
0
);
dndSetMsgHandle
(
pWrapper
,
TDMT_VND_CREATE_STB_RSP
,
(
NodeMsgFp
)
mmProcessWriteMsg
,
VND_VGID
);
dndSetMsgHandle
(
pWrapper
,
TDMT_VND_ALTER_STB_RSP
,
(
NodeMsgFp
)
mmProcessWriteMsg
,
0
);
dndSetMsgHandle
(
pWrapper
,
TDMT_VND_ALTER_STB_RSP
,
(
NodeMsgFp
)
mmProcessWriteMsg
,
VND_VGID
);
dndSetMsgHandle
(
pWrapper
,
TDMT_VND_DROP_STB_RSP
,
(
NodeMsgFp
)
mmProcessWriteMsg
,
0
);
dndSetMsgHandle
(
pWrapper
,
TDMT_VND_DROP_STB_RSP
,
(
NodeMsgFp
)
mmProcessWriteMsg
,
VND_VGID
);
dndSetMsgHandle
(
pWrapper
,
TDMT_VND_CREATE_SMA_RSP
,
(
NodeMsgFp
)
mmProcessWriteMsg
,
0
);
dndSetMsgHandle
(
pWrapper
,
TDMT_VND_CREATE_SMA_RSP
,
(
NodeMsgFp
)
mmProcessWriteMsg
,
VND_VGID
);
dndSetMsgHandle
(
pWrapper
,
TDMT_VND_DROP_SMA_RSP
,
(
NodeMsgFp
)
mmProcessWriteMsg
,
0
);
dndSetMsgHandle
(
pWrapper
,
TDMT_VND_DROP_SMA_RSP
,
(
NodeMsgFp
)
mmProcessWriteMsg
,
VND_VGID
);
dndSetMsgHandle
(
pWrapper
,
TDMT_VND_QUERY
,
(
NodeMsgFp
)
mmProcessReadMsg
,
MND_VGID
);
dndSetMsgHandle
(
pWrapper
,
TDMT_VND_QUERY_CONTINUE
,
(
NodeMsgFp
)
mmProcessReadMsg
,
MND_VGID
);
dndSetMsgHandle
(
pWrapper
,
TDMT_VND_FETCH
,
(
NodeMsgFp
)
mmProcessReadMsg
,
MND_VGID
);
dndSetMsgHandle
(
pWrapper
,
TDMT_VND_FETCH_RSP
,
(
NodeMsgFp
)
mmProcessReadMsg
,
MND_VGID
);
}
}
source/dnode/mgmt/qnode/src/qmMsg.c
浏览文件 @
ba1dd2ca
...
@@ -56,14 +56,14 @@ int32_t qmProcessDropReq(SMgmtWrapper *pWrapper, SNodeMsg *pMsg) {
...
@@ -56,14 +56,14 @@ int32_t qmProcessDropReq(SMgmtWrapper *pWrapper, SNodeMsg *pMsg) {
void
qmInitMsgHandles
(
SMgmtWrapper
*
pWrapper
)
{
void
qmInitMsgHandles
(
SMgmtWrapper
*
pWrapper
)
{
// Requests handled by VNODE
// Requests handled by VNODE
dndSetMsgHandle
(
pWrapper
,
TDMT_VND_QUERY
,
(
NodeMsgFp
)
qmProcessQueryMsg
,
1
);
dndSetMsgHandle
(
pWrapper
,
TDMT_VND_QUERY
,
(
NodeMsgFp
)
qmProcessQueryMsg
,
QND_VGID
);
dndSetMsgHandle
(
pWrapper
,
TDMT_VND_QUERY_CONTINUE
,
(
NodeMsgFp
)
qmProcessQueryMsg
,
1
);
dndSetMsgHandle
(
pWrapper
,
TDMT_VND_QUERY_CONTINUE
,
(
NodeMsgFp
)
qmProcessQueryMsg
,
QND_VGID
);
dndSetMsgHandle
(
pWrapper
,
TDMT_VND_FETCH
,
(
NodeMsgFp
)
qmProcessFetchMsg
,
1
);
dndSetMsgHandle
(
pWrapper
,
TDMT_VND_FETCH
,
(
NodeMsgFp
)
qmProcessFetchMsg
,
QND_VGID
);
dndSetMsgHandle
(
pWrapper
,
TDMT_VND_FETCH_RSP
,
(
NodeMsgFp
)
qmProcessFetchMsg
,
1
);
dndSetMsgHandle
(
pWrapper
,
TDMT_VND_FETCH_RSP
,
(
NodeMsgFp
)
qmProcessFetchMsg
,
QND_VGID
);
dndSetMsgHandle
(
pWrapper
,
TDMT_VND_RES_READY
,
(
NodeMsgFp
)
qmProcessFetchMsg
,
1
);
dndSetMsgHandle
(
pWrapper
,
TDMT_VND_RES_READY
,
(
NodeMsgFp
)
qmProcessFetchMsg
,
QND_VGID
);
dndSetMsgHandle
(
pWrapper
,
TDMT_VND_TASKS_STATUS
,
(
NodeMsgFp
)
qmProcessFetchMsg
,
1
);
dndSetMsgHandle
(
pWrapper
,
TDMT_VND_TASKS_STATUS
,
(
NodeMsgFp
)
qmProcessFetchMsg
,
QND_VGID
);
dndSetMsgHandle
(
pWrapper
,
TDMT_VND_CANCEL_TASK
,
(
NodeMsgFp
)
qmProcessFetchMsg
,
1
);
dndSetMsgHandle
(
pWrapper
,
TDMT_VND_CANCEL_TASK
,
(
NodeMsgFp
)
qmProcessFetchMsg
,
QND_VGID
);
dndSetMsgHandle
(
pWrapper
,
TDMT_VND_DROP_TASK
,
(
NodeMsgFp
)
qmProcessFetchMsg
,
1
);
dndSetMsgHandle
(
pWrapper
,
TDMT_VND_DROP_TASK
,
(
NodeMsgFp
)
qmProcessFetchMsg
,
QND_VGID
);
dndSetMsgHandle
(
pWrapper
,
TDMT_VND_SHOW_TABLES
,
(
NodeMsgFp
)
qmProcessFetchMsg
,
1
);
dndSetMsgHandle
(
pWrapper
,
TDMT_VND_SHOW_TABLES
,
(
NodeMsgFp
)
qmProcessFetchMsg
,
QND_VGID
);
}
}
source/dnode/mgmt/snode/src/smMsg.c
浏览文件 @
ba1dd2ca
...
@@ -56,6 +56,6 @@ int32_t smProcessDropReq(SMgmtWrapper *pWrapper, SNodeMsg *pMsg) {
...
@@ -56,6 +56,6 @@ int32_t smProcessDropReq(SMgmtWrapper *pWrapper, SNodeMsg *pMsg) {
void
smInitMsgHandles
(
SMgmtWrapper
*
pWrapper
)
{
void
smInitMsgHandles
(
SMgmtWrapper
*
pWrapper
)
{
// Requests handled by SNODE
// Requests handled by SNODE
dndSetMsgHandle
(
pWrapper
,
TDMT_SND_TASK_DEPLOY
,
(
NodeMsgFp
)
smProcessMgmtMsg
,
0
);
dndSetMsgHandle
(
pWrapper
,
TDMT_SND_TASK_DEPLOY
,
(
NodeMsgFp
)
smProcessMgmtMsg
,
VND_VGID
);
dndSetMsgHandle
(
pWrapper
,
TDMT_SND_TASK_EXEC
,
(
NodeMsgFp
)
smProcessExecMsg
,
0
);
dndSetMsgHandle
(
pWrapper
,
TDMT_SND_TASK_EXEC
,
(
NodeMsgFp
)
smProcessExecMsg
,
VND_VGID
);
}
}
source/dnode/mgmt/test/vnode/vnode.cpp
浏览文件 @
ba1dd2ca
...
@@ -158,6 +158,7 @@ TEST_F(DndTestVnode, 03_Create_Stb) {
...
@@ -158,6 +158,7 @@ TEST_F(DndTestVnode, 03_Create_Stb) {
for
(
int
i
=
0
;
i
<
1
;
++
i
)
{
for
(
int
i
=
0
;
i
<
1
;
++
i
)
{
SVCreateTbReq
req
=
{
0
};
SVCreateTbReq
req
=
{
0
};
req
.
ver
=
0
;
req
.
ver
=
0
;
req
.
dbFName
=
(
char
*
)
"1.db1"
;
req
.
name
=
(
char
*
)
"stb1"
;
req
.
name
=
(
char
*
)
"stb1"
;
req
.
ttl
=
0
;
req
.
ttl
=
0
;
req
.
keep
=
0
;
req
.
keep
=
0
;
...
@@ -229,6 +230,7 @@ TEST_F(DndTestVnode, 04_Alter_Stb) {
...
@@ -229,6 +230,7 @@ TEST_F(DndTestVnode, 04_Alter_Stb) {
for
(
int
i
=
0
;
i
<
1
;
++
i
)
{
for
(
int
i
=
0
;
i
<
1
;
++
i
)
{
SVCreateTbReq
req
=
{
0
};
SVCreateTbReq
req
=
{
0
};
req
.
ver
=
0
;
req
.
ver
=
0
;
req
.
dbFName
=
(
char
*
)
"1.db1"
;
req
.
name
=
(
char
*
)
"stb1"
;
req
.
name
=
(
char
*
)
"stb1"
;
req
.
ttl
=
0
;
req
.
ttl
=
0
;
req
.
keep
=
0
;
req
.
keep
=
0
;
...
...
source/dnode/mgmt/vnode/src/vmMsg.c
浏览文件 @
ba1dd2ca
...
@@ -244,47 +244,47 @@ int32_t vmProcessCompactVnodeReq(SVnodesMgmt *pMgmt, SNodeMsg *pMsg) {
...
@@ -244,47 +244,47 @@ int32_t vmProcessCompactVnodeReq(SVnodesMgmt *pMgmt, SNodeMsg *pMsg) {
void
vmInitMsgHandles
(
SMgmtWrapper
*
pWrapper
)
{
void
vmInitMsgHandles
(
SMgmtWrapper
*
pWrapper
)
{
// Requests handled by VNODE
// Requests handled by VNODE
dndSetMsgHandle
(
pWrapper
,
TDMT_VND_SUBMIT
,
(
NodeMsgFp
)
vmProcessWriteMsg
,
0
);
dndSetMsgHandle
(
pWrapper
,
TDMT_VND_SUBMIT
,
(
NodeMsgFp
)
vmProcessWriteMsg
,
VND_VGID
);
dndSetMsgHandle
(
pWrapper
,
TDMT_VND_QUERY
,
(
NodeMsgFp
)
vmProcessQueryMsg
,
0
);
dndSetMsgHandle
(
pWrapper
,
TDMT_VND_QUERY
,
(
NodeMsgFp
)
vmProcessQueryMsg
,
VND_VGID
);
dndSetMsgHandle
(
pWrapper
,
TDMT_VND_QUERY_CONTINUE
,
(
NodeMsgFp
)
vmProcessQueryMsg
,
0
);
dndSetMsgHandle
(
pWrapper
,
TDMT_VND_QUERY_CONTINUE
,
(
NodeMsgFp
)
vmProcessQueryMsg
,
VND_VGID
);
dndSetMsgHandle
(
pWrapper
,
TDMT_VND_FETCH
,
(
NodeMsgFp
)
vmProcessFetchMsg
,
0
);
dndSetMsgHandle
(
pWrapper
,
TDMT_VND_FETCH
,
(
NodeMsgFp
)
vmProcessFetchMsg
,
VND_VGID
);
dndSetMsgHandle
(
pWrapper
,
TDMT_VND_FETCH_RSP
,
(
NodeMsgFp
)
vmProcessFetchMsg
,
0
);
dndSetMsgHandle
(
pWrapper
,
TDMT_VND_FETCH_RSP
,
(
NodeMsgFp
)
vmProcessFetchMsg
,
VND_VGID
);
dndSetMsgHandle
(
pWrapper
,
TDMT_VND_ALTER_TABLE
,
(
NodeMsgFp
)
vmProcessWriteMsg
,
0
);
dndSetMsgHandle
(
pWrapper
,
TDMT_VND_ALTER_TABLE
,
(
NodeMsgFp
)
vmProcessWriteMsg
,
VND_VGID
);
dndSetMsgHandle
(
pWrapper
,
TDMT_VND_UPDATE_TAG_VAL
,
(
NodeMsgFp
)
vmProcessWriteMsg
,
0
);
dndSetMsgHandle
(
pWrapper
,
TDMT_VND_UPDATE_TAG_VAL
,
(
NodeMsgFp
)
vmProcessWriteMsg
,
VND_VGID
);
dndSetMsgHandle
(
pWrapper
,
TDMT_VND_TABLE_META
,
(
NodeMsgFp
)
vmProcessFetchMsg
,
0
);
dndSetMsgHandle
(
pWrapper
,
TDMT_VND_TABLE_META
,
(
NodeMsgFp
)
vmProcessFetchMsg
,
VND_VGID
);
dndSetMsgHandle
(
pWrapper
,
TDMT_VND_TABLES_META
,
(
NodeMsgFp
)
vmProcessFetchMsg
,
0
);
dndSetMsgHandle
(
pWrapper
,
TDMT_VND_TABLES_META
,
(
NodeMsgFp
)
vmProcessFetchMsg
,
VND_VGID
);
dndSetMsgHandle
(
pWrapper
,
TDMT_VND_MQ_CONSUME
,
(
NodeMsgFp
)
vmProcessQueryMsg
,
0
);
dndSetMsgHandle
(
pWrapper
,
TDMT_VND_MQ_CONSUME
,
(
NodeMsgFp
)
vmProcessQueryMsg
,
VND_VGID
);
dndSetMsgHandle
(
pWrapper
,
TDMT_VND_MQ_QUERY
,
(
NodeMsgFp
)
vmProcessQueryMsg
,
0
);
dndSetMsgHandle
(
pWrapper
,
TDMT_VND_MQ_QUERY
,
(
NodeMsgFp
)
vmProcessQueryMsg
,
VND_VGID
);
dndSetMsgHandle
(
pWrapper
,
TDMT_VND_MQ_CONNECT
,
(
NodeMsgFp
)
vmProcessWriteMsg
,
0
);
dndSetMsgHandle
(
pWrapper
,
TDMT_VND_MQ_CONNECT
,
(
NodeMsgFp
)
vmProcessWriteMsg
,
VND_VGID
);
dndSetMsgHandle
(
pWrapper
,
TDMT_VND_MQ_DISCONNECT
,
(
NodeMsgFp
)
vmProcessWriteMsg
,
0
);
dndSetMsgHandle
(
pWrapper
,
TDMT_VND_MQ_DISCONNECT
,
(
NodeMsgFp
)
vmProcessWriteMsg
,
VND_VGID
);
dndSetMsgHandle
(
pWrapper
,
TDMT_VND_MQ_SET_CUR
,
(
NodeMsgFp
)
vmProcessWriteMsg
,
0
);
dndSetMsgHandle
(
pWrapper
,
TDMT_VND_MQ_SET_CUR
,
(
NodeMsgFp
)
vmProcessWriteMsg
,
VND_VGID
);
dndSetMsgHandle
(
pWrapper
,
TDMT_VND_RES_READY
,
(
NodeMsgFp
)
vmProcessFetchMsg
,
0
);
dndSetMsgHandle
(
pWrapper
,
TDMT_VND_RES_READY
,
(
NodeMsgFp
)
vmProcessFetchMsg
,
VND_VGID
);
dndSetMsgHandle
(
pWrapper
,
TDMT_VND_TASKS_STATUS
,
(
NodeMsgFp
)
vmProcessFetchMsg
,
0
);
dndSetMsgHandle
(
pWrapper
,
TDMT_VND_TASKS_STATUS
,
(
NodeMsgFp
)
vmProcessFetchMsg
,
VND_VGID
);
dndSetMsgHandle
(
pWrapper
,
TDMT_VND_CANCEL_TASK
,
(
NodeMsgFp
)
vmProcessFetchMsg
,
0
);
dndSetMsgHandle
(
pWrapper
,
TDMT_VND_CANCEL_TASK
,
(
NodeMsgFp
)
vmProcessFetchMsg
,
VND_VGID
);
dndSetMsgHandle
(
pWrapper
,
TDMT_VND_DROP_TASK
,
(
NodeMsgFp
)
vmProcessFetchMsg
,
0
);
dndSetMsgHandle
(
pWrapper
,
TDMT_VND_DROP_TASK
,
(
NodeMsgFp
)
vmProcessFetchMsg
,
VND_VGID
);
dndSetMsgHandle
(
pWrapper
,
TDMT_VND_CREATE_STB
,
(
NodeMsgFp
)
vmProcessWriteMsg
,
0
);
dndSetMsgHandle
(
pWrapper
,
TDMT_VND_CREATE_STB
,
(
NodeMsgFp
)
vmProcessWriteMsg
,
VND_VGID
);
dndSetMsgHandle
(
pWrapper
,
TDMT_VND_ALTER_STB
,
(
NodeMsgFp
)
vmProcessWriteMsg
,
0
);
dndSetMsgHandle
(
pWrapper
,
TDMT_VND_ALTER_STB
,
(
NodeMsgFp
)
vmProcessWriteMsg
,
VND_VGID
);
dndSetMsgHandle
(
pWrapper
,
TDMT_VND_DROP_STB
,
(
NodeMsgFp
)
vmProcessWriteMsg
,
0
);
dndSetMsgHandle
(
pWrapper
,
TDMT_VND_DROP_STB
,
(
NodeMsgFp
)
vmProcessWriteMsg
,
VND_VGID
);
dndSetMsgHandle
(
pWrapper
,
TDMT_VND_CREATE_TABLE
,
(
NodeMsgFp
)
vmProcessWriteMsg
,
0
);
dndSetMsgHandle
(
pWrapper
,
TDMT_VND_CREATE_TABLE
,
(
NodeMsgFp
)
vmProcessWriteMsg
,
VND_VGID
);
dndSetMsgHandle
(
pWrapper
,
TDMT_VND_ALTER_TABLE
,
(
NodeMsgFp
)
vmProcessWriteMsg
,
0
);
dndSetMsgHandle
(
pWrapper
,
TDMT_VND_ALTER_TABLE
,
(
NodeMsgFp
)
vmProcessWriteMsg
,
VND_VGID
);
dndSetMsgHandle
(
pWrapper
,
TDMT_VND_DROP_TABLE
,
(
NodeMsgFp
)
vmProcessWriteMsg
,
0
);
dndSetMsgHandle
(
pWrapper
,
TDMT_VND_DROP_TABLE
,
(
NodeMsgFp
)
vmProcessWriteMsg
,
VND_VGID
);
dndSetMsgHandle
(
pWrapper
,
TDMT_VND_CREATE_SMA
,
(
NodeMsgFp
)
vmProcessWriteMsg
,
0
);
dndSetMsgHandle
(
pWrapper
,
TDMT_VND_CREATE_SMA
,
(
NodeMsgFp
)
vmProcessWriteMsg
,
VND_VGID
);
dndSetMsgHandle
(
pWrapper
,
TDMT_VND_CANCEL_SMA
,
(
NodeMsgFp
)
vmProcessWriteMsg
,
0
);
dndSetMsgHandle
(
pWrapper
,
TDMT_VND_CANCEL_SMA
,
(
NodeMsgFp
)
vmProcessWriteMsg
,
VND_VGID
);
dndSetMsgHandle
(
pWrapper
,
TDMT_VND_DROP_SMA
,
(
NodeMsgFp
)
vmProcessWriteMsg
,
0
);
dndSetMsgHandle
(
pWrapper
,
TDMT_VND_DROP_SMA
,
(
NodeMsgFp
)
vmProcessWriteMsg
,
VND_VGID
);
dndSetMsgHandle
(
pWrapper
,
TDMT_VND_SHOW_TABLES
,
(
NodeMsgFp
)
vmProcessFetchMsg
,
0
);
dndSetMsgHandle
(
pWrapper
,
TDMT_VND_SHOW_TABLES
,
(
NodeMsgFp
)
vmProcessFetchMsg
,
VND_VGID
);
dndSetMsgHandle
(
pWrapper
,
TDMT_VND_SHOW_TABLES_FETCH
,
(
NodeMsgFp
)
vmProcessFetchMsg
,
0
);
dndSetMsgHandle
(
pWrapper
,
TDMT_VND_SHOW_TABLES_FETCH
,
(
NodeMsgFp
)
vmProcessFetchMsg
,
VND_VGID
);
dndSetMsgHandle
(
pWrapper
,
TDMT_VND_MQ_SET_CONN
,
(
NodeMsgFp
)
vmProcessWriteMsg
,
0
);
dndSetMsgHandle
(
pWrapper
,
TDMT_VND_MQ_SET_CONN
,
(
NodeMsgFp
)
vmProcessWriteMsg
,
VND_VGID
);
dndSetMsgHandle
(
pWrapper
,
TDMT_VND_MQ_REB
,
(
NodeMsgFp
)
vmProcessWriteMsg
,
0
);
dndSetMsgHandle
(
pWrapper
,
TDMT_VND_MQ_REB
,
(
NodeMsgFp
)
vmProcessWriteMsg
,
VND_VGID
);
dndSetMsgHandle
(
pWrapper
,
TDMT_VND_MQ_SET_CUR
,
(
NodeMsgFp
)
vmProcessFetchMsg
,
0
);
dndSetMsgHandle
(
pWrapper
,
TDMT_VND_MQ_SET_CUR
,
(
NodeMsgFp
)
vmProcessFetchMsg
,
VND_VGID
);
dndSetMsgHandle
(
pWrapper
,
TDMT_VND_CONSUME
,
(
NodeMsgFp
)
vmProcessFetchMsg
,
0
);
dndSetMsgHandle
(
pWrapper
,
TDMT_VND_CONSUME
,
(
NodeMsgFp
)
vmProcessFetchMsg
,
VND_VGID
);
dndSetMsgHandle
(
pWrapper
,
TDMT_VND_TASK_DEPLOY
,
(
NodeMsgFp
)
vmProcessWriteMsg
,
0
);
dndSetMsgHandle
(
pWrapper
,
TDMT_VND_TASK_DEPLOY
,
(
NodeMsgFp
)
vmProcessWriteMsg
,
VND_VGID
);
dndSetMsgHandle
(
pWrapper
,
TDMT_VND_QUERY_HEARTBEAT
,
(
NodeMsgFp
)
vmProcessFetchMsg
,
0
);
dndSetMsgHandle
(
pWrapper
,
TDMT_VND_QUERY_HEARTBEAT
,
(
NodeMsgFp
)
vmProcessFetchMsg
,
VND_VGID
);
dndSetMsgHandle
(
pWrapper
,
TDMT_VND_TASK_EXEC
,
(
NodeMsgFp
)
vmProcessFetchMsg
,
0
);
dndSetMsgHandle
(
pWrapper
,
TDMT_VND_TASK_EXEC
,
(
NodeMsgFp
)
vmProcessFetchMsg
,
VND_VGID
);
dndSetMsgHandle
(
pWrapper
,
TDMT_VND_STREAM_TRIGGER
,
(
NodeMsgFp
)
vmProcessFetchMsg
,
0
);
dndSetMsgHandle
(
pWrapper
,
TDMT_VND_STREAM_TRIGGER
,
(
NodeMsgFp
)
vmProcessFetchMsg
,
VND_VGID
);
dndSetMsgHandle
(
pWrapper
,
TDMT_DND_CREATE_VNODE
,
(
NodeMsgFp
)
vmProcessMgmtMsg
,
0
);
dndSetMsgHandle
(
pWrapper
,
TDMT_DND_CREATE_VNODE
,
(
NodeMsgFp
)
vmProcessMgmtMsg
,
VND_VGID
);
dndSetMsgHandle
(
pWrapper
,
TDMT_DND_ALTER_VNODE
,
(
NodeMsgFp
)
vmProcessMgmtMsg
,
0
);
dndSetMsgHandle
(
pWrapper
,
TDMT_DND_ALTER_VNODE
,
(
NodeMsgFp
)
vmProcessMgmtMsg
,
VND_VGID
);
dndSetMsgHandle
(
pWrapper
,
TDMT_DND_DROP_VNODE
,
(
NodeMsgFp
)
vmProcessMgmtMsg
,
0
);
dndSetMsgHandle
(
pWrapper
,
TDMT_DND_DROP_VNODE
,
(
NodeMsgFp
)
vmProcessMgmtMsg
,
VND_VGID
);
dndSetMsgHandle
(
pWrapper
,
TDMT_DND_SYNC_VNODE
,
(
NodeMsgFp
)
vmProcessMgmtMsg
,
0
);
dndSetMsgHandle
(
pWrapper
,
TDMT_DND_SYNC_VNODE
,
(
NodeMsgFp
)
vmProcessMgmtMsg
,
VND_VGID
);
dndSetMsgHandle
(
pWrapper
,
TDMT_DND_COMPACT_VNODE
,
(
NodeMsgFp
)
vmProcessMgmtMsg
,
0
);
dndSetMsgHandle
(
pWrapper
,
TDMT_DND_COMPACT_VNODE
,
(
NodeMsgFp
)
vmProcessMgmtMsg
,
VND_VGID
);
}
}
source/dnode/mnode/impl/inc/mndDef.h
浏览文件 @
ba1dd2ca
...
@@ -267,6 +267,8 @@ typedef struct {
...
@@ -267,6 +267,8 @@ typedef struct {
int8_t
update
;
int8_t
update
;
int8_t
cacheLastRow
;
int8_t
cacheLastRow
;
int8_t
streamMode
;
int8_t
streamMode
;
int32_t
numOfRetensions
;
SArray
*
pRetensions
;
}
SDbCfg
;
}
SDbCfg
;
typedef
struct
{
typedef
struct
{
...
@@ -341,11 +343,17 @@ typedef struct {
...
@@ -341,11 +343,17 @@ typedef struct {
int64_t
dbUid
;
int64_t
dbUid
;
int32_t
version
;
int32_t
version
;
int32_t
nextColId
;
int32_t
nextColId
;
float
xFilesFactor
;
int32_t
aggregationMethod
;
int32_t
delay
;
int32_t
ttl
;
int32_t
numOfColumns
;
int32_t
numOfColumns
;
int32_t
numOfTags
;
int32_t
numOfTags
;
int32_t
numOfSmas
;
int32_t
commentLen
;
int32_t
commentLen
;
SSchema
*
pColumns
;
SSchema
*
pColumns
;
SSchema
*
pTags
;
SSchema
*
pTags
;
SSchema
*
pSmas
;
char
*
comment
;
char
*
comment
;
SRWLatch
lock
;
SRWLatch
lock
;
}
SStbObj
;
}
SStbObj
;
...
@@ -712,6 +720,7 @@ static FORCE_INLINE void* tDecodeSMqConsumerObj(void* buf, SMqConsumerObj* pCons
...
@@ -712,6 +720,7 @@ static FORCE_INLINE void* tDecodeSMqConsumerObj(void* buf, SMqConsumerObj* pCons
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
];
char
outputSTbName
[
TSDB_TABLE_FNAME_LEN
];
int64_t
createTime
;
int64_t
createTime
;
int64_t
updateTime
;
int64_t
updateTime
;
int64_t
uid
;
int64_t
uid
;
...
@@ -721,11 +730,12 @@ typedef struct {
...
@@ -721,11 +730,12 @@ typedef struct {
SRWLatch
lock
;
SRWLatch
lock
;
int8_t
status
;
int8_t
status
;
// int32_t sqlLen;
// int32_t sqlLen;
int32_t
sinkVgId
;
// 0 for automatic
char
*
sql
;
char
*
sql
;
char
*
logicalPlan
;
char
*
logicalPlan
;
char
*
physicalPlan
;
char
*
physicalPlan
;
SArray
*
tasks
;
// SArray<SArray<SStreamTask>>
SArray
*
tasks
;
// SArray<SArray<SStreamTask>>
SArray
*
outputName
;
SArray
*
ColAlias
;
}
SStreamObj
;
}
SStreamObj
;
int32_t
tEncodeSStreamObj
(
SCoder
*
pEncoder
,
const
SStreamObj
*
pObj
);
int32_t
tEncodeSStreamObj
(
SCoder
*
pEncoder
,
const
SStreamObj
*
pObj
);
...
...
source/dnode/mnode/impl/inc/mndStream.h
浏览文件 @
ba1dd2ca
...
@@ -31,6 +31,8 @@ void mndReleaseStream(SMnode *pMnode, SStreamObj *pStream);
...
@@ -31,6 +31,8 @@ void mndReleaseStream(SMnode *pMnode, SStreamObj *pStream);
SSdbRaw
*
mndStreamActionEncode
(
SStreamObj
*
pStream
);
SSdbRaw
*
mndStreamActionEncode
(
SStreamObj
*
pStream
);
SSdbRow
*
mndStreamActionDecode
(
SSdbRaw
*
pRaw
);
SSdbRow
*
mndStreamActionDecode
(
SSdbRaw
*
pRaw
);
int32_t
mndAddStreamToTrans
(
SMnode
*
pMnode
,
SStreamObj
*
pStream
,
const
char
*
ast
,
STrans
*
pTrans
);
#ifdef __cplusplus
#ifdef __cplusplus
}
}
#endif
#endif
...
...
source/dnode/mnode/impl/src/mndDb.c
浏览文件 @
ba1dd2ca
...
@@ -100,6 +100,15 @@ static SSdbRaw *mndDbActionEncode(SDbObj *pDb) {
...
@@ -100,6 +100,15 @@ static SSdbRaw *mndDbActionEncode(SDbObj *pDb) {
SDB_SET_INT8
(
pRaw
,
dataPos
,
pDb
->
cfg
.
quorum
,
DB_ENCODE_OVER
)
SDB_SET_INT8
(
pRaw
,
dataPos
,
pDb
->
cfg
.
quorum
,
DB_ENCODE_OVER
)
SDB_SET_INT8
(
pRaw
,
dataPos
,
pDb
->
cfg
.
update
,
DB_ENCODE_OVER
)
SDB_SET_INT8
(
pRaw
,
dataPos
,
pDb
->
cfg
.
update
,
DB_ENCODE_OVER
)
SDB_SET_INT8
(
pRaw
,
dataPos
,
pDb
->
cfg
.
cacheLastRow
,
DB_ENCODE_OVER
)
SDB_SET_INT8
(
pRaw
,
dataPos
,
pDb
->
cfg
.
cacheLastRow
,
DB_ENCODE_OVER
)
SDB_SET_INT32
(
pRaw
,
dataPos
,
pDb
->
cfg
.
numOfRetensions
,
DB_ENCODE_OVER
)
for
(
int32_t
i
=
0
;
i
<
pDb
->
cfg
.
numOfRetensions
;
++
i
)
{
SRetention
*
pRetension
=
taosArrayGet
(
pDb
->
cfg
.
pRetensions
,
i
);
SDB_SET_INT32
(
pRaw
,
dataPos
,
pRetension
->
freq
,
DB_ENCODE_OVER
)
SDB_SET_INT32
(
pRaw
,
dataPos
,
pRetension
->
keep
,
DB_ENCODE_OVER
)
SDB_SET_INT8
(
pRaw
,
dataPos
,
pRetension
->
freqUnit
,
DB_ENCODE_OVER
)
SDB_SET_INT8
(
pRaw
,
dataPos
,
pRetension
->
keepUnit
,
DB_ENCODE_OVER
)
}
SDB_SET_RESERVE
(
pRaw
,
dataPos
,
TSDB_DB_RESERVE_SIZE
,
DB_ENCODE_OVER
)
SDB_SET_RESERVE
(
pRaw
,
dataPos
,
TSDB_DB_RESERVE_SIZE
,
DB_ENCODE_OVER
)
SDB_SET_DATALEN
(
pRaw
,
dataPos
,
DB_ENCODE_OVER
)
SDB_SET_DATALEN
(
pRaw
,
dataPos
,
DB_ENCODE_OVER
)
...
@@ -161,6 +170,22 @@ static SSdbRow *mndDbActionDecode(SSdbRaw *pRaw) {
...
@@ -161,6 +170,22 @@ static SSdbRow *mndDbActionDecode(SSdbRaw *pRaw) {
SDB_GET_INT8
(
pRaw
,
dataPos
,
&
pDb
->
cfg
.
quorum
,
DB_DECODE_OVER
)
SDB_GET_INT8
(
pRaw
,
dataPos
,
&
pDb
->
cfg
.
quorum
,
DB_DECODE_OVER
)
SDB_GET_INT8
(
pRaw
,
dataPos
,
&
pDb
->
cfg
.
update
,
DB_DECODE_OVER
)
SDB_GET_INT8
(
pRaw
,
dataPos
,
&
pDb
->
cfg
.
update
,
DB_DECODE_OVER
)
SDB_GET_INT8
(
pRaw
,
dataPos
,
&
pDb
->
cfg
.
cacheLastRow
,
DB_DECODE_OVER
)
SDB_GET_INT8
(
pRaw
,
dataPos
,
&
pDb
->
cfg
.
cacheLastRow
,
DB_DECODE_OVER
)
SDB_GET_INT32
(
pRaw
,
dataPos
,
&
pDb
->
cfg
.
numOfRetensions
,
DB_DECODE_OVER
)
if
(
pDb
->
cfg
.
numOfRetensions
>
0
)
{
pDb
->
cfg
.
pRetensions
=
taosArrayInit
(
pDb
->
cfg
.
numOfRetensions
,
sizeof
(
SRetention
));
if
(
pDb
->
cfg
.
pRetensions
==
NULL
)
goto
DB_DECODE_OVER
;
for
(
int32_t
i
=
0
;
i
<
pDb
->
cfg
.
numOfRetensions
;
++
i
)
{
SRetention
retension
=
{
0
};
SDB_GET_INT32
(
pRaw
,
dataPos
,
&
retension
.
freq
,
DB_DECODE_OVER
)
SDB_GET_INT32
(
pRaw
,
dataPos
,
&
retension
.
keep
,
DB_DECODE_OVER
)
SDB_GET_INT8
(
pRaw
,
dataPos
,
&
retension
.
freqUnit
,
DB_DECODE_OVER
)
SDB_GET_INT8
(
pRaw
,
dataPos
,
&
retension
.
keepUnit
,
DB_DECODE_OVER
)
if
(
taosArrayPush
(
pDb
->
cfg
.
pRetensions
,
&
retension
)
==
NULL
)
{
goto
DB_DECODE_OVER
;
}
}
}
SDB_GET_RESERVE
(
pRaw
,
dataPos
,
TSDB_DB_RESERVE_SIZE
,
DB_DECODE_OVER
)
SDB_GET_RESERVE
(
pRaw
,
dataPos
,
TSDB_DB_RESERVE_SIZE
,
DB_DECODE_OVER
)
terrno
=
0
;
terrno
=
0
;
...
@@ -183,6 +208,7 @@ static int32_t mndDbActionInsert(SSdb *pSdb, SDbObj *pDb) {
...
@@ -183,6 +208,7 @@ static int32_t mndDbActionInsert(SSdb *pSdb, SDbObj *pDb) {
static
int32_t
mndDbActionDelete
(
SSdb
*
pSdb
,
SDbObj
*
pDb
)
{
static
int32_t
mndDbActionDelete
(
SSdb
*
pSdb
,
SDbObj
*
pDb
)
{
mTrace
(
"db:%s, perform delete action, row:%p"
,
pDb
->
name
,
pDb
);
mTrace
(
"db:%s, perform delete action, row:%p"
,
pDb
->
name
,
pDb
);
taosArrayDestroy
(
pDb
->
cfg
.
pRetensions
);
return
0
;
return
0
;
}
}
...
@@ -417,6 +443,10 @@ static int32_t mndCreateDb(SMnode *pMnode, SNodeMsg *pReq, SCreateDbReq *pCreate
...
@@ -417,6 +443,10 @@ static int32_t mndCreateDb(SMnode *pMnode, SNodeMsg *pReq, SCreateDbReq *pCreate
.
streamMode
=
pCreate
->
streamMode
,
.
streamMode
=
pCreate
->
streamMode
,
};
};
dbObj
.
cfg
.
numOfRetensions
=
pCreate
->
numOfRetensions
;
dbObj
.
cfg
.
pRetensions
=
pCreate
->
pRetensions
;
pCreate
=
NULL
;
mndSetDefaultDbCfg
(
&
dbObj
.
cfg
);
mndSetDefaultDbCfg
(
&
dbObj
.
cfg
);
if
(
mndCheckDbName
(
dbObj
.
name
,
pUser
)
!=
0
)
{
if
(
mndCheckDbName
(
dbObj
.
name
,
pUser
)
!=
0
)
{
...
@@ -505,6 +535,7 @@ CREATE_DB_OVER:
...
@@ -505,6 +535,7 @@ CREATE_DB_OVER:
mndReleaseDb
(
pMnode
,
pDb
);
mndReleaseDb
(
pMnode
,
pDb
);
mndReleaseUser
(
pMnode
,
pUser
);
mndReleaseUser
(
pMnode
,
pUser
);
tFreeSCreateDbReq
(
&
createReq
);
return
code
;
return
code
;
}
}
...
...
source/dnode/mnode/impl/src/mndDef.c
浏览文件 @
ba1dd2ca
...
@@ -16,6 +16,7 @@
...
@@ -16,6 +16,7 @@
#include "mndDef.h"
#include "mndDef.h"
int32_t
tEncodeSStreamObj
(
SCoder
*
pEncoder
,
const
SStreamObj
*
pObj
)
{
int32_t
tEncodeSStreamObj
(
SCoder
*
pEncoder
,
const
SStreamObj
*
pObj
)
{
int32_t
sz
=
0
;
int32_t
outputNameSz
=
0
;
int32_t
outputNameSz
=
0
;
if
(
tEncodeCStr
(
pEncoder
,
pObj
->
name
)
<
0
)
return
-
1
;
if
(
tEncodeCStr
(
pEncoder
,
pObj
->
name
)
<
0
)
return
-
1
;
if
(
tEncodeCStr
(
pEncoder
,
pObj
->
db
)
<
0
)
return
-
1
;
if
(
tEncodeCStr
(
pEncoder
,
pObj
->
db
)
<
0
)
return
-
1
;
...
@@ -30,27 +31,26 @@ int32_t tEncodeSStreamObj(SCoder *pEncoder, const SStreamObj *pObj) {
...
@@ -30,27 +31,26 @@ int32_t tEncodeSStreamObj(SCoder *pEncoder, const SStreamObj *pObj) {
if
(
tEncodeCStr
(
pEncoder
,
pObj
->
physicalPlan
)
<
0
)
return
-
1
;
if
(
tEncodeCStr
(
pEncoder
,
pObj
->
physicalPlan
)
<
0
)
return
-
1
;
// TODO encode tasks
// TODO encode tasks
if
(
pObj
->
tasks
)
{
if
(
pObj
->
tasks
)
{
int32_t
sz
=
taosArrayGetSize
(
pObj
->
tasks
);
sz
=
taosArrayGetSize
(
pObj
->
tasks
);
tEncodeI32
(
pEncoder
,
sz
);
}
if
(
tEncodeI32
(
pEncoder
,
sz
)
<
0
)
return
-
1
;
for
(
int32_t
i
=
0
;
i
<
sz
;
i
++
)
{
for
(
int32_t
i
=
0
;
i
<
sz
;
i
++
)
{
SArray
*
pArray
=
taosArrayGet
(
pObj
->
tasks
,
i
);
SArray
*
pArray
=
taosArrayGet
(
pObj
->
tasks
,
i
);
int32_t
innerSz
=
taosArrayGetSize
(
pArray
);
int32_t
innerSz
=
taosArrayGetSize
(
pArray
);
tEncodeI32
(
pEncoder
,
innerSz
)
;
if
(
tEncodeI32
(
pEncoder
,
innerSz
)
<
0
)
return
-
1
;
for
(
int32_t
j
=
0
;
j
<
innerSz
;
j
++
)
{
for
(
int32_t
j
=
0
;
j
<
innerSz
;
j
++
)
{
SStreamTask
*
pTask
=
taosArrayGet
(
pArray
,
j
);
SStreamTask
*
pTask
=
taosArrayGet
(
pArray
,
j
);
tEncodeSStreamTask
(
pEncoder
,
pTask
);
if
(
tEncodeSStreamTask
(
pEncoder
,
pTask
)
<
0
)
return
-
1
;
}
}
}
}
else
{
tEncodeI32
(
pEncoder
,
0
);
}
}
if
(
pObj
->
outputName
!=
NULL
)
{
if
(
pObj
->
ColAlias
!=
NULL
)
{
outputNameSz
=
taosArrayGetSize
(
pObj
->
outputName
);
outputNameSz
=
taosArrayGetSize
(
pObj
->
ColAlias
);
}
}
if
(
tEncodeI32
(
pEncoder
,
outputNameSz
)
<
0
)
return
-
1
;
if
(
tEncodeI32
(
pEncoder
,
outputNameSz
)
<
0
)
return
-
1
;
for
(
int32_t
i
=
0
;
i
<
outputNameSz
;
i
++
)
{
for
(
int32_t
i
=
0
;
i
<
outputNameSz
;
i
++
)
{
char
*
name
=
taosArrayGetP
(
pObj
->
outputName
,
i
);
char
*
name
=
taosArrayGetP
(
pObj
->
ColAlias
,
i
);
if
(
tEncodeCStr
(
pEncoder
,
name
)
<
0
)
return
-
1
;
if
(
tEncodeCStr
(
pEncoder
,
name
)
<
0
)
return
-
1
;
}
}
return
pEncoder
->
pos
;
return
pEncoder
->
pos
;
...
@@ -68,6 +68,7 @@ int32_t tDecodeSStreamObj(SCoder *pDecoder, SStreamObj *pObj) {
...
@@ -68,6 +68,7 @@ int32_t tDecodeSStreamObj(SCoder *pDecoder, SStreamObj *pObj) {
if
(
tDecodeCStrAlloc
(
pDecoder
,
&
pObj
->
sql
)
<
0
)
return
-
1
;
if
(
tDecodeCStrAlloc
(
pDecoder
,
&
pObj
->
sql
)
<
0
)
return
-
1
;
if
(
tDecodeCStrAlloc
(
pDecoder
,
&
pObj
->
logicalPlan
)
<
0
)
return
-
1
;
if
(
tDecodeCStrAlloc
(
pDecoder
,
&
pObj
->
logicalPlan
)
<
0
)
return
-
1
;
if
(
tDecodeCStrAlloc
(
pDecoder
,
&
pObj
->
physicalPlan
)
<
0
)
return
-
1
;
if
(
tDecodeCStrAlloc
(
pDecoder
,
&
pObj
->
physicalPlan
)
<
0
)
return
-
1
;
pObj
->
tasks
=
NULL
;
int32_t
sz
;
int32_t
sz
;
if
(
tDecodeI32
(
pDecoder
,
&
sz
)
<
0
)
return
-
1
;
if
(
tDecodeI32
(
pDecoder
,
&
sz
)
<
0
)
return
-
1
;
if
(
sz
!=
0
)
{
if
(
sz
!=
0
)
{
...
@@ -83,19 +84,19 @@ int32_t tDecodeSStreamObj(SCoder *pDecoder, SStreamObj *pObj) {
...
@@ -83,19 +84,19 @@ int32_t tDecodeSStreamObj(SCoder *pDecoder, SStreamObj *pObj) {
}
}
taosArrayPush
(
pObj
->
tasks
,
pArray
);
taosArrayPush
(
pObj
->
tasks
,
pArray
);
}
}
}
else
{
pObj
->
tasks
=
NULL
;
}
}
int32_t
outputNameSz
;
int32_t
outputNameSz
;
if
(
tDecodeI32
(
pDecoder
,
&
outputNameSz
)
<
0
)
return
-
1
;
if
(
tDecodeI32
(
pDecoder
,
&
outputNameSz
)
<
0
)
return
-
1
;
pObj
->
outputName
=
taosArrayInit
(
outputNameSz
,
sizeof
(
void
*
));
if
(
outputNameSz
!=
0
)
{
if
(
pObj
->
outputName
==
NULL
)
{
pObj
->
ColAlias
=
taosArrayInit
(
outputNameSz
,
sizeof
(
void
*
));
if
(
pObj
->
ColAlias
==
NULL
)
{
return
-
1
;
return
-
1
;
}
}
}
for
(
int32_t
i
=
0
;
i
<
outputNameSz
;
i
++
)
{
for
(
int32_t
i
=
0
;
i
<
outputNameSz
;
i
++
)
{
char
*
name
;
char
*
name
;
if
(
tDecodeCStrAlloc
(
pDecoder
,
&
name
)
<
0
)
return
-
1
;
if
(
tDecodeCStrAlloc
(
pDecoder
,
&
name
)
<
0
)
return
-
1
;
taosArrayPush
(
pObj
->
outputName
,
&
name
);
taosArrayPush
(
pObj
->
ColAlias
,
&
name
);
}
}
return
0
;
return
0
;
}
}
source/dnode/mnode/impl/src/mndScheduler.c
浏览文件 @
ba1dd2ca
...
@@ -58,7 +58,7 @@ int32_t mndPersistTaskDeployReq(STrans* pTrans, SStreamTask* pTask, const SEpSet
...
@@ -58,7 +58,7 @@ int32_t mndPersistTaskDeployReq(STrans* pTrans, SStreamTask* pTask, const SEpSet
action
.
contLen
=
tlen
;
action
.
contLen
=
tlen
;
action
.
msgType
=
type
;
action
.
msgType
=
type
;
if
(
mndTransAppendRedoAction
(
pTrans
,
&
action
)
!=
0
)
{
if
(
mndTransAppendRedoAction
(
pTrans
,
&
action
)
!=
0
)
{
rpcFreeCont
(
buf
);
free
(
buf
);
return
-
1
;
return
-
1
;
}
}
return
0
;
return
0
;
...
@@ -131,13 +131,12 @@ int32_t mndScheduleStream(SMnode* pMnode, STrans* pTrans, SStreamObj* pStream) {
...
@@ -131,13 +131,12 @@ int32_t mndScheduleStream(SMnode* pMnode, STrans* pTrans, SStreamObj* pStream) {
lastUsedVgId
=
pVgroup
->
vgId
;
lastUsedVgId
=
pVgroup
->
vgId
;
pStream
->
vgNum
++
;
pStream
->
vgNum
++
;
// send to vnode
SStreamTask
*
pTask
=
streamTaskNew
(
pStream
->
uid
,
level
);
SStreamTask
*
pTask
=
streamTaskNew
(
pStream
->
uid
);
pTask
->
pipeSource
=
1
;
pTask
->
level
=
level
;
pTask
->
pipeSink
=
level
==
totLevel
-
1
?
1
:
0
;
pTask
->
sourceType
=
1
;
pTask
->
sinkType
=
level
==
totLevel
-
1
?
1
:
0
;
pTask
->
parallelizable
=
1
;
pTask
->
parallelizable
=
1
;
// TODO: set to
if
(
mndAssignTaskToVg
(
pMnode
,
pTrans
,
pTask
,
plan
,
pVgroup
)
<
0
)
{
if
(
mndAssignTaskToVg
(
pMnode
,
pTrans
,
pTask
,
plan
,
pVgroup
)
<
0
)
{
sdbRelease
(
pSdb
,
pVgroup
);
sdbRelease
(
pSdb
,
pVgroup
);
qDestroyQueryPlan
(
pPlan
);
qDestroyQueryPlan
(
pPlan
);
...
@@ -146,13 +145,15 @@ int32_t mndScheduleStream(SMnode* pMnode, STrans* pTrans, SStreamObj* pStream) {
...
@@ -146,13 +145,15 @@ int32_t mndScheduleStream(SMnode* pMnode, STrans* pTrans, SStreamObj* pStream) {
taosArrayPush
(
taskOneLevel
,
pTask
);
taosArrayPush
(
taskOneLevel
,
pTask
);
}
}
}
else
{
}
else
{
SStreamTask
*
pTask
=
streamTaskNew
(
pStream
->
uid
,
level
);
SStreamTask
*
pTask
=
streamTaskNew
(
pStream
->
uid
);
pTask
->
pipeSource
=
0
;
pTask
->
level
=
level
;
pTask
->
pipeSink
=
level
==
totLevel
-
1
?
1
:
0
;
pTask
->
sourceType
=
0
;
pTask
->
sinkType
=
level
==
totLevel
-
1
?
1
:
0
;
pTask
->
parallelizable
=
plan
->
subplanType
==
SUBPLAN_TYPE_SCAN
;
pTask
->
parallelizable
=
plan
->
subplanType
==
SUBPLAN_TYPE_SCAN
;
pTask
->
nextOpDst
=
STREAM_NEXT_OP_DST__VND
;
pTask
->
nextOpDst
=
STREAM_NEXT_OP_DST__VND
;
if
(
tsStreamSchedV
)
{
SSnodeObj
*
pSnode
=
mndSchedFetchSnode
(
pMnode
);
if
(
pSnode
==
NULL
||
tsStreamSchedV
)
{
ASSERT
(
lastUsedVgId
!=
0
);
ASSERT
(
lastUsedVgId
!=
0
);
SVgObj
*
pVg
=
mndAcquireVgroup
(
pMnode
,
lastUsedVgId
);
SVgObj
*
pVg
=
mndAcquireVgroup
(
pMnode
,
lastUsedVgId
);
if
(
mndAssignTaskToVg
(
pMnode
,
pTrans
,
pTask
,
plan
,
pVg
)
<
0
)
{
if
(
mndAssignTaskToVg
(
pMnode
,
pTrans
,
pTask
,
plan
,
pVg
)
<
0
)
{
...
@@ -162,24 +163,19 @@ int32_t mndScheduleStream(SMnode* pMnode, STrans* pTrans, SStreamObj* pStream) {
...
@@ -162,24 +163,19 @@ int32_t mndScheduleStream(SMnode* pMnode, STrans* pTrans, SStreamObj* pStream) {
}
}
sdbRelease
(
pSdb
,
pVg
);
sdbRelease
(
pSdb
,
pVg
);
}
else
{
}
else
{
SSnodeObj
*
pSnode
=
mndSchedFetchSnode
(
pMnode
);
if
(
pSnode
!=
NULL
)
{
if
(
mndAssignTaskToSnode
(
pMnode
,
pTrans
,
pTask
,
plan
,
pSnode
)
<
0
)
{
if
(
mndAssignTaskToSnode
(
pMnode
,
pTrans
,
pTask
,
plan
,
pSnode
)
<
0
)
{
sdbRelease
(
pSdb
,
pSnode
);
sdbRelease
(
pSdb
,
pSnode
);
qDestroyQueryPlan
(
pPlan
);
qDestroyQueryPlan
(
pPlan
);
return
-
1
;
return
-
1
;
}
}
sdbRelease
(
pMnode
->
pSdb
,
pSnode
);
}
else
{
// TODO: assign to one vg
ASSERT
(
0
);
}
}
}
sdbRelease
(
pMnode
->
pSdb
,
pSnode
);
taosArrayPush
(
taskOneLevel
,
pTask
);
taosArrayPush
(
taskOneLevel
,
pTask
);
}
}
taosArrayPush
(
pStream
->
tasks
,
taskOneLevel
);
taosArrayPush
(
pStream
->
tasks
,
taskOneLevel
);
}
}
qDestroyQueryPlan
(
pPlan
);
return
0
;
return
0
;
}
}
...
...
source/dnode/mnode/impl/src/mndSma.c
浏览文件 @
ba1dd2ca
...
@@ -22,6 +22,7 @@
...
@@ -22,6 +22,7 @@
#include "mndMnode.h"
#include "mndMnode.h"
#include "mndShow.h"
#include "mndShow.h"
#include "mndStb.c"
#include "mndStb.c"
#include "mndStream.h"
#include "mndTrans.h"
#include "mndTrans.h"
#include "mndUser.h"
#include "mndUser.h"
#include "mndVgroup.h"
#include "mndVgroup.h"
...
@@ -404,6 +405,18 @@ static int32_t mndCreateSma(SMnode *pMnode, SNodeMsg *pReq, SMCreateSmaReq *pCre
...
@@ -404,6 +405,18 @@ static int32_t mndCreateSma(SMnode *pMnode, SNodeMsg *pReq, SMCreateSmaReq *pCre
memcpy
(
smaObj
.
ast
,
pCreate
->
ast
,
smaObj
.
astLen
);
memcpy
(
smaObj
.
ast
,
pCreate
->
ast
,
smaObj
.
astLen
);
}
}
SStreamObj
streamObj
=
{
0
};
tstrncpy
(
streamObj
.
name
,
pCreate
->
name
,
TSDB_STREAM_FNAME_LEN
);
tstrncpy
(
streamObj
.
db
,
pDb
->
name
,
TSDB_DB_FNAME_LEN
);
streamObj
.
createTime
=
taosGetTimestampMs
();
streamObj
.
updateTime
=
streamObj
.
createTime
;
streamObj
.
uid
=
mndGenerateUid
(
pCreate
->
name
,
strlen
(
pCreate
->
name
));
streamObj
.
dbUid
=
pDb
->
uid
;
streamObj
.
version
=
1
;
streamObj
.
sql
=
pCreate
->
sql
;
/*streamObj.physicalPlan = "";*/
streamObj
.
logicalPlan
=
"not implemented"
;
int32_t
code
=
-
1
;
int32_t
code
=
-
1
;
STrans
*
pTrans
=
mndTransCreate
(
pMnode
,
TRN_POLICY_RETRY
,
TRN_TYPE_CREATE_SMA
,
&
pReq
->
rpcMsg
);
STrans
*
pTrans
=
mndTransCreate
(
pMnode
,
TRN_POLICY_RETRY
,
TRN_TYPE_CREATE_SMA
,
&
pReq
->
rpcMsg
);
if
(
pTrans
==
NULL
)
goto
_OVER
;
if
(
pTrans
==
NULL
)
goto
_OVER
;
...
@@ -414,6 +427,7 @@ static int32_t mndCreateSma(SMnode *pMnode, SNodeMsg *pReq, SMCreateSmaReq *pCre
...
@@ -414,6 +427,7 @@ static int32_t mndCreateSma(SMnode *pMnode, SNodeMsg *pReq, SMCreateSmaReq *pCre
if
(
mndSetCreateSmaRedoLogs
(
pMnode
,
pTrans
,
&
smaObj
)
!=
0
)
goto
_OVER
;
if
(
mndSetCreateSmaRedoLogs
(
pMnode
,
pTrans
,
&
smaObj
)
!=
0
)
goto
_OVER
;
if
(
mndSetCreateSmaCommitLogs
(
pMnode
,
pTrans
,
&
smaObj
)
!=
0
)
goto
_OVER
;
if
(
mndSetCreateSmaCommitLogs
(
pMnode
,
pTrans
,
&
smaObj
)
!=
0
)
goto
_OVER
;
if
(
mndSetCreateSmaRedoActions
(
pMnode
,
pTrans
,
pDb
,
&
smaObj
)
!=
0
)
goto
_OVER
;
if
(
mndSetCreateSmaRedoActions
(
pMnode
,
pTrans
,
pDb
,
&
smaObj
)
!=
0
)
goto
_OVER
;
if
(
mndAddStreamToTrans
(
pMnode
,
&
streamObj
,
pCreate
->
ast
,
pTrans
)
!=
0
)
goto
_OVER
;
if
(
mndTransPrepare
(
pMnode
,
pTrans
)
!=
0
)
goto
_OVER
;
if
(
mndTransPrepare
(
pMnode
,
pTrans
)
!=
0
)
goto
_OVER
;
code
=
0
;
code
=
0
;
...
@@ -457,6 +471,7 @@ static int32_t mndProcessMCreateSmaReq(SNodeMsg *pReq) {
...
@@ -457,6 +471,7 @@ static int32_t mndProcessMCreateSmaReq(SNodeMsg *pReq) {
int32_t
code
=
-
1
;
int32_t
code
=
-
1
;
SStbObj
*
pStb
=
NULL
;
SStbObj
*
pStb
=
NULL
;
SSmaObj
*
pSma
=
NULL
;
SSmaObj
*
pSma
=
NULL
;
SStreamObj
*
pStream
=
NULL
;
SDbObj
*
pDb
=
NULL
;
SDbObj
*
pDb
=
NULL
;
SUserObj
*
pUser
=
NULL
;
SUserObj
*
pUser
=
NULL
;
SMCreateSmaReq
createReq
=
{
0
};
SMCreateSmaReq
createReq
=
{
0
};
...
@@ -477,6 +492,12 @@ static int32_t mndProcessMCreateSmaReq(SNodeMsg *pReq) {
...
@@ -477,6 +492,12 @@ static int32_t mndProcessMCreateSmaReq(SNodeMsg *pReq) {
goto
_OVER
;
goto
_OVER
;
}
}
pStream
=
mndAcquireStream
(
pMnode
,
createReq
.
name
);
if
(
pStream
!=
NULL
)
{
mError
(
"sma:%s, failed to create since stream:%s already exist"
,
createReq
.
name
,
createReq
.
name
);
goto
_OVER
;
}
pSma
=
mndAcquireSma
(
pMnode
,
createReq
.
name
);
pSma
=
mndAcquireSma
(
pMnode
,
createReq
.
name
);
if
(
pSma
!=
NULL
)
{
if
(
pSma
!=
NULL
)
{
if
(
createReq
.
igExists
)
{
if
(
createReq
.
igExists
)
{
...
@@ -514,6 +535,7 @@ _OVER:
...
@@ -514,6 +535,7 @@ _OVER:
mndReleaseStb
(
pMnode
,
pStb
);
mndReleaseStb
(
pMnode
,
pStb
);
mndReleaseSma
(
pMnode
,
pSma
);
mndReleaseSma
(
pMnode
,
pSma
);
mndReleaseStream
(
pMnode
,
pStream
);
mndReleaseDb
(
pMnode
,
pDb
);
mndReleaseDb
(
pMnode
,
pDb
);
mndReleaseUser
(
pMnode
,
pUser
);
mndReleaseUser
(
pMnode
,
pUser
);
tFreeSMCreateSmaReq
(
&
createReq
);
tFreeSMCreateSmaReq
(
&
createReq
);
...
...
source/dnode/mnode/impl/src/mndStb.c
浏览文件 @
ba1dd2ca
...
@@ -72,7 +72,8 @@ void mndCleanupStb(SMnode *pMnode) {}
...
@@ -72,7 +72,8 @@ void mndCleanupStb(SMnode *pMnode) {}
SSdbRaw
*
mndStbActionEncode
(
SStbObj
*
pStb
)
{
SSdbRaw
*
mndStbActionEncode
(
SStbObj
*
pStb
)
{
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
int32_t
size
=
sizeof
(
SStbObj
)
+
(
pStb
->
numOfColumns
+
pStb
->
numOfTags
)
*
sizeof
(
SSchema
)
+
TSDB_STB_RESERVE_SIZE
;
int32_t
size
=
sizeof
(
SStbObj
)
+
(
pStb
->
numOfColumns
+
pStb
->
numOfTags
+
pStb
->
numOfSmas
)
*
sizeof
(
SSchema
)
+
TSDB_STB_RESERVE_SIZE
;
SSdbRaw
*
pRaw
=
sdbAllocRaw
(
SDB_STB
,
TSDB_STB_VER_NUMBER
,
size
);
SSdbRaw
*
pRaw
=
sdbAllocRaw
(
SDB_STB
,
TSDB_STB_VER_NUMBER
,
size
);
if
(
pRaw
==
NULL
)
goto
STB_ENCODE_OVER
;
if
(
pRaw
==
NULL
)
goto
STB_ENCODE_OVER
;
...
@@ -85,8 +86,13 @@ SSdbRaw *mndStbActionEncode(SStbObj *pStb) {
...
@@ -85,8 +86,13 @@ SSdbRaw *mndStbActionEncode(SStbObj *pStb) {
SDB_SET_INT64
(
pRaw
,
dataPos
,
pStb
->
dbUid
,
STB_ENCODE_OVER
)
SDB_SET_INT64
(
pRaw
,
dataPos
,
pStb
->
dbUid
,
STB_ENCODE_OVER
)
SDB_SET_INT32
(
pRaw
,
dataPos
,
pStb
->
version
,
STB_ENCODE_OVER
)
SDB_SET_INT32
(
pRaw
,
dataPos
,
pStb
->
version
,
STB_ENCODE_OVER
)
SDB_SET_INT32
(
pRaw
,
dataPos
,
pStb
->
nextColId
,
STB_ENCODE_OVER
)
SDB_SET_INT32
(
pRaw
,
dataPos
,
pStb
->
nextColId
,
STB_ENCODE_OVER
)
SDB_SET_INT32
(
pRaw
,
dataPos
,
(
int32_t
)(
pStb
->
xFilesFactor
*
10000
),
STB_ENCODE_OVER
)
SDB_SET_INT32
(
pRaw
,
dataPos
,
pStb
->
aggregationMethod
,
STB_ENCODE_OVER
)
SDB_SET_INT32
(
pRaw
,
dataPos
,
pStb
->
delay
,
STB_ENCODE_OVER
)
SDB_SET_INT32
(
pRaw
,
dataPos
,
pStb
->
ttl
,
STB_ENCODE_OVER
)
SDB_SET_INT32
(
pRaw
,
dataPos
,
pStb
->
numOfColumns
,
STB_ENCODE_OVER
)
SDB_SET_INT32
(
pRaw
,
dataPos
,
pStb
->
numOfColumns
,
STB_ENCODE_OVER
)
SDB_SET_INT32
(
pRaw
,
dataPos
,
pStb
->
numOfTags
,
STB_ENCODE_OVER
)
SDB_SET_INT32
(
pRaw
,
dataPos
,
pStb
->
numOfTags
,
STB_ENCODE_OVER
)
SDB_SET_INT32
(
pRaw
,
dataPos
,
pStb
->
numOfSmas
,
STB_ENCODE_OVER
)
SDB_SET_INT32
(
pRaw
,
dataPos
,
pStb
->
commentLen
,
STB_ENCODE_OVER
)
SDB_SET_INT32
(
pRaw
,
dataPos
,
pStb
->
commentLen
,
STB_ENCODE_OVER
)
for
(
int32_t
i
=
0
;
i
<
pStb
->
numOfColumns
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
pStb
->
numOfColumns
;
++
i
)
{
...
@@ -105,7 +111,17 @@ SSdbRaw *mndStbActionEncode(SStbObj *pStb) {
...
@@ -105,7 +111,17 @@ SSdbRaw *mndStbActionEncode(SStbObj *pStb) {
SDB_SET_BINARY
(
pRaw
,
dataPos
,
pSchema
->
name
,
TSDB_COL_NAME_LEN
,
STB_ENCODE_OVER
)
SDB_SET_BINARY
(
pRaw
,
dataPos
,
pSchema
->
name
,
TSDB_COL_NAME_LEN
,
STB_ENCODE_OVER
)
}
}
for
(
int32_t
i
=
0
;
i
<
pStb
->
numOfSmas
;
++
i
)
{
SSchema
*
pSchema
=
&
pStb
->
pSmas
[
i
];
SDB_SET_INT8
(
pRaw
,
dataPos
,
pSchema
->
type
,
STB_ENCODE_OVER
)
SDB_SET_INT32
(
pRaw
,
dataPos
,
pSchema
->
colId
,
STB_ENCODE_OVER
)
SDB_SET_INT32
(
pRaw
,
dataPos
,
pSchema
->
bytes
,
STB_ENCODE_OVER
)
SDB_SET_BINARY
(
pRaw
,
dataPos
,
pSchema
->
name
,
TSDB_COL_NAME_LEN
,
STB_ENCODE_OVER
)
}
if
(
pStb
->
commentLen
>
0
)
{
SDB_SET_BINARY
(
pRaw
,
dataPos
,
pStb
->
comment
,
pStb
->
commentLen
,
STB_ENCODE_OVER
)
SDB_SET_BINARY
(
pRaw
,
dataPos
,
pStb
->
comment
,
pStb
->
commentLen
,
STB_ENCODE_OVER
)
}
SDB_SET_RESERVE
(
pRaw
,
dataPos
,
TSDB_STB_RESERVE_SIZE
,
STB_ENCODE_OVER
)
SDB_SET_RESERVE
(
pRaw
,
dataPos
,
TSDB_STB_RESERVE_SIZE
,
STB_ENCODE_OVER
)
SDB_SET_DATALEN
(
pRaw
,
dataPos
,
STB_ENCODE_OVER
)
SDB_SET_DATALEN
(
pRaw
,
dataPos
,
STB_ENCODE_OVER
)
...
@@ -148,13 +164,21 @@ static SSdbRow *mndStbActionDecode(SSdbRaw *pRaw) {
...
@@ -148,13 +164,21 @@ static SSdbRow *mndStbActionDecode(SSdbRaw *pRaw) {
SDB_GET_INT64
(
pRaw
,
dataPos
,
&
pStb
->
dbUid
,
STB_DECODE_OVER
)
SDB_GET_INT64
(
pRaw
,
dataPos
,
&
pStb
->
dbUid
,
STB_DECODE_OVER
)
SDB_GET_INT32
(
pRaw
,
dataPos
,
&
pStb
->
version
,
STB_DECODE_OVER
)
SDB_GET_INT32
(
pRaw
,
dataPos
,
&
pStb
->
version
,
STB_DECODE_OVER
)
SDB_GET_INT32
(
pRaw
,
dataPos
,
&
pStb
->
nextColId
,
STB_DECODE_OVER
)
SDB_GET_INT32
(
pRaw
,
dataPos
,
&
pStb
->
nextColId
,
STB_DECODE_OVER
)
int32_t
xFilesFactor
=
0
;
SDB_GET_INT32
(
pRaw
,
dataPos
,
&
xFilesFactor
,
STB_DECODE_OVER
)
pStb
->
xFilesFactor
=
xFilesFactor
/
10000
.
0
f
;
SDB_GET_INT32
(
pRaw
,
dataPos
,
&
pStb
->
aggregationMethod
,
STB_DECODE_OVER
)
SDB_GET_INT32
(
pRaw
,
dataPos
,
&
pStb
->
delay
,
STB_DECODE_OVER
)
SDB_GET_INT32
(
pRaw
,
dataPos
,
&
pStb
->
ttl
,
STB_DECODE_OVER
)
SDB_GET_INT32
(
pRaw
,
dataPos
,
&
pStb
->
numOfColumns
,
STB_DECODE_OVER
)
SDB_GET_INT32
(
pRaw
,
dataPos
,
&
pStb
->
numOfColumns
,
STB_DECODE_OVER
)
SDB_GET_INT32
(
pRaw
,
dataPos
,
&
pStb
->
numOfTags
,
STB_DECODE_OVER
)
SDB_GET_INT32
(
pRaw
,
dataPos
,
&
pStb
->
numOfTags
,
STB_DECODE_OVER
)
SDB_GET_INT32
(
pRaw
,
dataPos
,
&
pStb
->
numOfSmas
,
STB_DECODE_OVER
)
SDB_GET_INT32
(
pRaw
,
dataPos
,
&
pStb
->
commentLen
,
STB_DECODE_OVER
)
SDB_GET_INT32
(
pRaw
,
dataPos
,
&
pStb
->
commentLen
,
STB_DECODE_OVER
)
pStb
->
pColumns
=
calloc
(
pStb
->
numOfColumns
,
sizeof
(
SSchema
));
pStb
->
pColumns
=
calloc
(
pStb
->
numOfColumns
,
sizeof
(
SSchema
));
pStb
->
pTags
=
calloc
(
pStb
->
numOfTags
,
sizeof
(
SSchema
));
pStb
->
pTags
=
calloc
(
pStb
->
numOfTags
,
sizeof
(
SSchema
));
if
(
pStb
->
pColumns
==
NULL
||
pStb
->
pTags
==
NULL
)
{
pStb
->
pSmas
=
calloc
(
pStb
->
numOfSmas
,
sizeof
(
SSchema
));
if
(
pStb
->
pColumns
==
NULL
||
pStb
->
pTags
==
NULL
||
pStb
->
pSmas
==
NULL
)
{
goto
STB_DECODE_OVER
;
goto
STB_DECODE_OVER
;
}
}
...
@@ -174,6 +198,14 @@ static SSdbRow *mndStbActionDecode(SSdbRaw *pRaw) {
...
@@ -174,6 +198,14 @@ static SSdbRow *mndStbActionDecode(SSdbRaw *pRaw) {
SDB_GET_BINARY
(
pRaw
,
dataPos
,
pSchema
->
name
,
TSDB_COL_NAME_LEN
,
STB_DECODE_OVER
)
SDB_GET_BINARY
(
pRaw
,
dataPos
,
pSchema
->
name
,
TSDB_COL_NAME_LEN
,
STB_DECODE_OVER
)
}
}
for
(
int32_t
i
=
0
;
i
<
pStb
->
numOfSmas
;
++
i
)
{
SSchema
*
pSchema
=
&
pStb
->
pSmas
[
i
];
SDB_GET_INT8
(
pRaw
,
dataPos
,
&
pSchema
->
type
,
STB_DECODE_OVER
)
SDB_GET_INT32
(
pRaw
,
dataPos
,
&
pSchema
->
colId
,
STB_DECODE_OVER
)
SDB_GET_INT32
(
pRaw
,
dataPos
,
&
pSchema
->
bytes
,
STB_DECODE_OVER
)
SDB_GET_BINARY
(
pRaw
,
dataPos
,
pSchema
->
name
,
TSDB_COL_NAME_LEN
,
STB_DECODE_OVER
)
}
if
(
pStb
->
commentLen
>
0
)
{
if
(
pStb
->
commentLen
>
0
)
{
pStb
->
comment
=
calloc
(
pStb
->
commentLen
,
1
);
pStb
->
comment
=
calloc
(
pStb
->
commentLen
,
1
);
if
(
pStb
->
comment
==
NULL
)
goto
STB_DECODE_OVER
;
if
(
pStb
->
comment
==
NULL
)
goto
STB_DECODE_OVER
;
...
@@ -239,6 +271,30 @@ static int32_t mndStbActionUpdate(SSdb *pSdb, SStbObj *pOld, SStbObj *pNew) {
...
@@ -239,6 +271,30 @@ static int32_t mndStbActionUpdate(SSdb *pSdb, SStbObj *pOld, SStbObj *pNew) {
}
}
}
}
if
(
pOld
->
numOfSmas
<
pNew
->
numOfSmas
)
{
void
*
pSmas
=
malloc
(
pNew
->
numOfSmas
*
sizeof
(
SSchema
));
if
(
pSmas
!=
NULL
)
{
free
(
pOld
->
pSmas
);
pOld
->
pSmas
=
pSmas
;
}
else
{
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
mTrace
(
"stb:%s, failed to perform update action since %s"
,
pOld
->
name
,
terrstr
());
taosWUnLockLatch
(
&
pOld
->
lock
);
}
}
if
(
pOld
->
commentLen
<
pNew
->
commentLen
)
{
void
*
comment
=
malloc
(
pNew
->
commentLen
);
if
(
comment
!=
NULL
)
{
free
(
pOld
->
comment
);
pOld
->
comment
=
comment
;
}
else
{
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
mTrace
(
"stb:%s, failed to perform update action since %s"
,
pOld
->
name
,
terrstr
());
taosWUnLockLatch
(
&
pOld
->
lock
);
}
}
pOld
->
updateTime
=
pNew
->
updateTime
;
pOld
->
updateTime
=
pNew
->
updateTime
;
pOld
->
version
=
pNew
->
version
;
pOld
->
version
=
pNew
->
version
;
pOld
->
nextColId
=
pNew
->
nextColId
;
pOld
->
nextColId
=
pNew
->
nextColId
;
...
@@ -246,7 +302,9 @@ static int32_t mndStbActionUpdate(SSdb *pSdb, SStbObj *pOld, SStbObj *pNew) {
...
@@ -246,7 +302,9 @@ static int32_t mndStbActionUpdate(SSdb *pSdb, SStbObj *pOld, SStbObj *pNew) {
pOld
->
numOfTags
=
pNew
->
numOfTags
;
pOld
->
numOfTags
=
pNew
->
numOfTags
;
memcpy
(
pOld
->
pColumns
,
pNew
->
pColumns
,
pOld
->
numOfColumns
*
sizeof
(
SSchema
));
memcpy
(
pOld
->
pColumns
,
pNew
->
pColumns
,
pOld
->
numOfColumns
*
sizeof
(
SSchema
));
memcpy
(
pOld
->
pTags
,
pNew
->
pTags
,
pOld
->
numOfTags
*
sizeof
(
SSchema
));
memcpy
(
pOld
->
pTags
,
pNew
->
pTags
,
pOld
->
numOfTags
*
sizeof
(
SSchema
));
if
(
pNew
->
commentLen
!=
0
)
{
memcpy
(
pOld
->
comment
,
pNew
->
comment
,
TSDB_STB_COMMENT_LEN
);
memcpy
(
pOld
->
comment
,
pNew
->
comment
,
TSDB_STB_COMMENT_LEN
);
}
taosWUnLockLatch
(
&
pOld
->
lock
);
taosWUnLockLatch
(
&
pOld
->
lock
);
return
0
;
return
0
;
}
}
...
@@ -278,9 +336,12 @@ static SDbObj *mndAcquireDbByStb(SMnode *pMnode, const char *stbName) {
...
@@ -278,9 +336,12 @@ static SDbObj *mndAcquireDbByStb(SMnode *pMnode, const char *stbName) {
static
void
*
mndBuildVCreateStbReq
(
SMnode
*
pMnode
,
SVgObj
*
pVgroup
,
SStbObj
*
pStb
,
int32_t
*
pContLen
)
{
static
void
*
mndBuildVCreateStbReq
(
SMnode
*
pMnode
,
SVgObj
*
pVgroup
,
SStbObj
*
pStb
,
int32_t
*
pContLen
)
{
SName
name
=
{
0
};
SName
name
=
{
0
};
tNameFromString
(
&
name
,
pStb
->
name
,
T_NAME_ACCT
|
T_NAME_DB
|
T_NAME_TABLE
);
tNameFromString
(
&
name
,
pStb
->
name
,
T_NAME_ACCT
|
T_NAME_DB
|
T_NAME_TABLE
);
char
dbFName
[
TSDB_DB_FNAME_LEN
]
=
{
0
};
tNameGetFullDbName
(
&
name
,
dbFName
);
SVCreateTbReq
req
=
{
0
};
SVCreateTbReq
req
=
{
0
};
req
.
ver
=
0
;
req
.
ver
=
0
;
req
.
dbFName
=
dbFName
;
req
.
name
=
(
char
*
)
tNameGetTableName
(
&
name
);
req
.
name
=
(
char
*
)
tNameGetTableName
(
&
name
);
req
.
ttl
=
0
;
req
.
ttl
=
0
;
req
.
keep
=
0
;
req
.
keep
=
0
;
...
@@ -497,6 +558,16 @@ static int32_t mndSetCreateStbUndoActions(SMnode *pMnode, STrans *pTrans, SDbObj
...
@@ -497,6 +558,16 @@ static int32_t mndSetCreateStbUndoActions(SMnode *pMnode, STrans *pTrans, SDbObj
return
0
;
return
0
;
}
}
static
SSchema
*
mndFindStbColumns
(
const
SStbObj
*
pStb
,
const
char
*
colName
)
{
for
(
int32_t
col
=
0
;
col
<
pStb
->
numOfColumns
;
col
++
)
{
SSchema
*
pSchema
=
&
pStb
->
pColumns
[
col
];
if
(
strcasecmp
(
pStb
->
pColumns
[
col
].
name
,
colName
)
==
0
)
{
return
pSchema
;
}
}
return
NULL
;
}
static
int32_t
mndCreateStb
(
SMnode
*
pMnode
,
SNodeMsg
*
pReq
,
SMCreateStbReq
*
pCreate
,
SDbObj
*
pDb
)
{
static
int32_t
mndCreateStb
(
SMnode
*
pMnode
,
SNodeMsg
*
pReq
,
SMCreateStbReq
*
pCreate
,
SDbObj
*
pDb
)
{
SStbObj
stbObj
=
{
0
};
SStbObj
stbObj
=
{
0
};
memcpy
(
stbObj
.
name
,
pCreate
->
name
,
TSDB_TABLE_FNAME_LEN
);
memcpy
(
stbObj
.
name
,
pCreate
->
name
,
TSDB_TABLE_FNAME_LEN
);
...
@@ -507,19 +578,24 @@ static int32_t mndCreateStb(SMnode *pMnode, SNodeMsg *pReq, SMCreateStbReq *pCre
...
@@ -507,19 +578,24 @@ static int32_t mndCreateStb(SMnode *pMnode, SNodeMsg *pReq, SMCreateStbReq *pCre
stbObj
.
dbUid
=
pDb
->
uid
;
stbObj
.
dbUid
=
pDb
->
uid
;
stbObj
.
version
=
1
;
stbObj
.
version
=
1
;
stbObj
.
nextColId
=
1
;
stbObj
.
nextColId
=
1
;
stbObj
.
ttl
=
pCreate
->
ttl
;
stbObj
.
numOfColumns
=
pCreate
->
numOfColumns
;
stbObj
.
numOfColumns
=
pCreate
->
numOfColumns
;
stbObj
.
numOfTags
=
pCreate
->
numOfTags
;
stbObj
.
numOfTags
=
pCreate
->
numOfTags
;
stbObj
.
numOfSmas
=
pCreate
->
numOfSmas
;
stbObj
.
commentLen
=
pCreate
->
commentLen
;
stbObj
.
commentLen
=
pCreate
->
commentLen
;
if
(
stbObj
.
commentLen
>
0
)
{
stbObj
.
comment
=
calloc
(
stbObj
.
commentLen
,
1
);
stbObj
.
comment
=
calloc
(
stbObj
.
commentLen
,
1
);
if
(
stbObj
.
comment
==
NULL
)
{
if
(
stbObj
.
comment
==
NULL
)
{
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
return
-
1
;
return
-
1
;
}
}
memcpy
(
stbObj
.
comment
,
pCreate
->
comment
,
stbObj
.
commentLen
);
memcpy
(
stbObj
.
comment
,
pCreate
->
comment
,
stbObj
.
commentLen
);
}
stbObj
.
pColumns
=
malloc
(
stbObj
.
numOfColumns
*
sizeof
(
SSchema
));
stbObj
.
pColumns
=
malloc
(
stbObj
.
numOfColumns
*
sizeof
(
SSchema
));
stbObj
.
pTags
=
malloc
(
stbObj
.
numOfTags
*
sizeof
(
SSchema
));
stbObj
.
pTags
=
malloc
(
stbObj
.
numOfTags
*
sizeof
(
SSchema
));
if
(
stbObj
.
pColumns
==
NULL
||
stbObj
.
pTags
==
NULL
)
{
stbObj
.
pSmas
=
malloc
(
stbObj
.
numOfSmas
*
sizeof
(
SSchema
));
if
(
stbObj
.
pColumns
==
NULL
||
stbObj
.
pTags
==
NULL
||
stbObj
.
pSmas
==
NULL
)
{
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
return
-
1
;
return
-
1
;
}
}
...
@@ -544,6 +620,18 @@ static int32_t mndCreateStb(SMnode *pMnode, SNodeMsg *pReq, SMCreateStbReq *pCre
...
@@ -544,6 +620,18 @@ static int32_t mndCreateStb(SMnode *pMnode, SNodeMsg *pReq, SMCreateStbReq *pCre
stbObj
.
nextColId
++
;
stbObj
.
nextColId
++
;
}
}
for
(
int32_t
i
=
0
;
i
<
stbObj
.
numOfSmas
;
++
i
)
{
SField
*
pField
=
taosArrayGet
(
pCreate
->
pSmas
,
i
);
SSchema
*
pSchema
=
&
stbObj
.
pSmas
[
i
];
SSchema
*
pColSchema
=
mndFindStbColumns
(
&
stbObj
,
pField
->
name
);
if
(
pColSchema
==
NULL
)
{
mError
(
"stb:%s, sma:%s not found in columns"
,
stbObj
.
name
,
pSchema
->
name
);
terrno
=
TSDB_CODE_MND_INVALID_STB_OPTION
;
return
-
1
;
}
memcpy
(
pSchema
,
pColSchema
,
sizeof
(
SSchema
));
}
int32_t
code
=
-
1
;
int32_t
code
=
-
1
;
STrans
*
pTrans
=
mndTransCreate
(
pMnode
,
TRN_POLICY_ROLLBACK
,
TRN_TYPE_CREATE_STB
,
&
pReq
->
rpcMsg
);
STrans
*
pTrans
=
mndTransCreate
(
pMnode
,
TRN_POLICY_ROLLBACK
,
TRN_TYPE_CREATE_STB
,
&
pReq
->
rpcMsg
);
if
(
pTrans
==
NULL
)
goto
CREATE_STB_OVER
;
if
(
pTrans
==
NULL
)
goto
CREATE_STB_OVER
;
...
@@ -1528,19 +1616,11 @@ static int32_t mndRetrieveStb(SNodeMsg *pReq, SShowObj *pShow, char *data, int32
...
@@ -1528,19 +1616,11 @@ static int32_t mndRetrieveStb(SNodeMsg *pReq, SShowObj *pShow, char *data, int32
if
(
pDb
==
NULL
)
return
0
;
if
(
pDb
==
NULL
)
return
0
;
}
}
tstrncpy
(
prefix
,
pShow
->
db
,
TSDB_DB_FNAME_LEN
);
strcat
(
prefix
,
TS_PATH_DELIMITER
);
int32_t
prefixLen
=
(
int32_t
)
strlen
(
prefix
);
while
(
numOfRows
<
rows
)
{
while
(
numOfRows
<
rows
)
{
pShow
->
pIter
=
sdbFetch
(
pSdb
,
SDB_STB
,
pShow
->
pIter
,
(
void
**
)
&
pStb
);
pShow
->
pIter
=
sdbFetch
(
pSdb
,
SDB_STB
,
pShow
->
pIter
,
(
void
**
)
&
pStb
);
if
(
pShow
->
pIter
==
NULL
)
break
;
if
(
pShow
->
pIter
==
NULL
)
break
;
if
(
pDb
!=
NULL
&&
pStb
->
dbUid
!=
pDb
->
uid
)
{
if
(
pDb
!=
NULL
&&
pStb
->
dbUid
!=
pDb
->
uid
)
{
if
(
strncmp
(
pStb
->
db
,
pDb
->
name
,
prefixLen
)
==
0
)
{
mError
(
"Inconsistent table data, name:%s, db:%s, dbUid:%"
PRIu64
,
pStb
->
name
,
pDb
->
name
,
pDb
->
uid
);
}
sdbRelease
(
pSdb
,
pStb
);
sdbRelease
(
pSdb
,
pStb
);
continue
;
continue
;
}
}
...
...
source/dnode/mnode/impl/src/mndStream.c
浏览文件 @
ba1dd2ca
...
@@ -240,13 +240,13 @@ static SArray *mndExtractNamesFromAst(const SNode *pAst) {
...
@@ -240,13 +240,13 @@ static SArray *mndExtractNamesFromAst(const SNode *pAst) {
return
names
;
return
names
;
}
}
static
int32_t
mndStreamGetPlanString
(
const
SCMCreateStreamReq
*
pCreate
,
char
**
pStr
)
{
static
int32_t
mndStreamGetPlanString
(
const
char
*
ast
,
char
**
pStr
)
{
if
(
NULL
==
pCreate
->
ast
)
{
if
(
NULL
==
ast
)
{
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
SNode
*
pAst
=
NULL
;
SNode
*
pAst
=
NULL
;
int32_t
code
=
nodesStringToNode
(
pCreate
->
ast
,
&
pAst
);
int32_t
code
=
nodesStringToNode
(
ast
,
&
pAst
);
SQueryPlan
*
pPlan
=
NULL
;
SQueryPlan
*
pPlan
=
NULL
;
if
(
TSDB_CODE_SUCCESS
==
code
)
{
if
(
TSDB_CODE_SUCCESS
==
code
)
{
...
@@ -267,24 +267,12 @@ static int32_t mndStreamGetPlanString(const SCMCreateStreamReq *pCreate, char **
...
@@ -267,24 +267,12 @@ static int32_t mndStreamGetPlanString(const SCMCreateStreamReq *pCreate, char **
return
code
;
return
code
;
}
}
static
int32_t
mndCreateStream
(
SMnode
*
pMnode
,
SNodeMsg
*
pReq
,
SCMCreateStreamReq
*
pCreate
,
SDbObj
*
pDb
)
{
int32_t
mndAddStreamToTrans
(
SMnode
*
pMnode
,
SStreamObj
*
pStream
,
const
char
*
ast
,
STrans
*
pTrans
)
{
mDebug
(
"stream:%s to create"
,
pCreate
->
name
);
SStreamObj
streamObj
=
{
0
};
tstrncpy
(
streamObj
.
name
,
pCreate
->
name
,
TSDB_STREAM_FNAME_LEN
);
tstrncpy
(
streamObj
.
db
,
pDb
->
name
,
TSDB_DB_FNAME_LEN
);
streamObj
.
createTime
=
taosGetTimestampMs
();
streamObj
.
updateTime
=
streamObj
.
createTime
;
streamObj
.
uid
=
mndGenerateUid
(
pCreate
->
name
,
strlen
(
pCreate
->
name
));
streamObj
.
dbUid
=
pDb
->
uid
;
streamObj
.
version
=
1
;
streamObj
.
sql
=
pCreate
->
sql
;
/*streamObj.physicalPlan = "";*/
streamObj
.
logicalPlan
=
"not implemented"
;
SNode
*
pAst
=
NULL
;
SNode
*
pAst
=
NULL
;
if
(
nodesStringToNode
(
pCreate
->
ast
,
&
pAst
)
<
0
)
{
if
(
nodesStringToNode
(
ast
,
&
pAst
)
<
0
)
{
return
-
1
;
return
-
1
;
}
}
#if 1
SArray
*
names
=
mndExtractNamesFromAst
(
pAst
);
SArray
*
names
=
mndExtractNamesFromAst
(
pAst
);
printf
(
"|"
);
printf
(
"|"
);
for
(
int
i
=
0
;
i
<
taosArrayGetSize
(
names
);
i
++
)
{
for
(
int
i
=
0
;
i
<
taosArrayGetSize
(
names
);
i
++
)
{
...
@@ -292,33 +280,58 @@ static int32_t mndCreateStream(SMnode *pMnode, SNodeMsg *pReq, SCMCreateStreamRe
...
@@ -292,33 +280,58 @@ static int32_t mndCreateStream(SMnode *pMnode, SNodeMsg *pReq, SCMCreateStreamRe
}
}
printf
(
"
\n
=======================================================
\n
"
);
printf
(
"
\n
=======================================================
\n
"
);
streamObj
.
outputName
=
names
;
pStream
->
ColAlias
=
names
;
#endif
if
(
TSDB_CODE_SUCCESS
!=
mndStreamGetPlanString
(
pCreate
,
&
streamObj
.
physicalPlan
))
{
if
(
TSDB_CODE_SUCCESS
!=
mndStreamGetPlanString
(
ast
,
&
pStream
->
physicalPlan
))
{
mError
(
"topic:%s, failed to get plan since %s"
,
p
Create
->
name
,
terrstr
());
mError
(
"topic:%s, failed to get plan since %s"
,
p
Stream
->
name
,
terrstr
());
return
-
1
;
return
-
1
;
}
}
STrans
*
pTrans
=
mndTransCreate
(
pMnode
,
TRN_POLICY_RETRY
,
TRN_TYPE_CREATE_STREAM
,
&
pReq
->
rpcMsg
);
if
(
mndScheduleStream
(
pMnode
,
pTrans
,
pStream
)
<
0
)
{
if
(
pTrans
==
NULL
)
{
mError
(
"stream:%ld, schedule stream since %s"
,
pStream
->
uid
,
terrstr
());
mError
(
"stream:%s, failed to create since %s"
,
pCreate
->
name
,
terrstr
());
return
-
1
;
return
-
1
;
}
}
mDebug
(
"trans:%d, used to create stream:%s"
,
pTrans
->
id
,
p
Create
->
name
);
mDebug
(
"trans:%d, used to create stream:%s"
,
pTrans
->
id
,
p
Stream
->
name
);
if
(
mndScheduleStream
(
pMnode
,
pTrans
,
&
streamObj
)
<
0
)
{
SSdbRaw
*
pRedoRaw
=
mndStreamActionEncode
(
pStream
);
mError
(
"stream:%ld, schedule stream since %s"
,
streamObj
.
uid
,
terrstr
());
if
(
pRedoRaw
==
NULL
||
mndTransAppendRedolog
(
pTrans
,
pRedoRaw
)
!=
0
)
{
mError
(
"trans:%d, failed to append redo log since %s"
,
pTrans
->
id
,
terrstr
());
mndTransDrop
(
pTrans
);
mndTransDrop
(
pTrans
);
return
-
1
;
return
-
1
;
}
}
sdbSetRawStatus
(
pRedoRaw
,
SDB_STATUS_READY
);
SSdbRaw
*
pRedoRaw
=
mndStreamActionEncode
(
&
streamObj
);
return
0
;
if
(
pRedoRaw
==
NULL
||
mndTransAppendRedolog
(
pTrans
,
pRedoRaw
)
!=
0
)
{
}
mError
(
"trans:%d, failed to append redo log since %s"
,
pTrans
->
id
,
terrstr
());
static
int32_t
mndCreateStream
(
SMnode
*
pMnode
,
SNodeMsg
*
pReq
,
SCMCreateStreamReq
*
pCreate
,
SDbObj
*
pDb
)
{
mDebug
(
"stream:%s to create"
,
pCreate
->
name
);
SStreamObj
streamObj
=
{
0
};
tstrncpy
(
streamObj
.
name
,
pCreate
->
name
,
TSDB_STREAM_FNAME_LEN
);
tstrncpy
(
streamObj
.
db
,
pDb
->
name
,
TSDB_DB_FNAME_LEN
);
tstrncpy
(
streamObj
.
outputSTbName
,
pCreate
->
outputSTbName
,
TSDB_TABLE_FNAME_LEN
);
streamObj
.
createTime
=
taosGetTimestampMs
();
streamObj
.
updateTime
=
streamObj
.
createTime
;
streamObj
.
uid
=
mndGenerateUid
(
pCreate
->
name
,
strlen
(
pCreate
->
name
));
streamObj
.
dbUid
=
pDb
->
uid
;
streamObj
.
version
=
1
;
streamObj
.
sql
=
pCreate
->
sql
;
/*streamObj.physicalPlan = "";*/
streamObj
.
logicalPlan
=
"not implemented"
;
STrans
*
pTrans
=
mndTransCreate
(
pMnode
,
TRN_POLICY_RETRY
,
TRN_TYPE_CREATE_STREAM
,
&
pReq
->
rpcMsg
);
if
(
pTrans
==
NULL
)
{
mError
(
"stream:%s, failed to create since %s"
,
pCreate
->
name
,
terrstr
());
return
-
1
;
}
mDebug
(
"trans:%d, used to create stream:%s"
,
pTrans
->
id
,
pCreate
->
name
);
if
(
mndAddStreamToTrans
(
pMnode
,
&
streamObj
,
pCreate
->
ast
,
pTrans
)
!=
0
)
{
mError
(
"trans:%d, failed to add stream since %s"
,
pTrans
->
id
,
terrstr
());
mndTransDrop
(
pTrans
);
mndTransDrop
(
pTrans
);
return
-
1
;
return
-
1
;
}
}
sdbSetRawStatus
(
pRedoRaw
,
SDB_STATUS_READY
);
if
(
mndTransPrepare
(
pMnode
,
pTrans
)
!=
0
)
{
if
(
mndTransPrepare
(
pMnode
,
pTrans
)
!=
0
)
{
mError
(
"trans:%d, failed to prepare since %s"
,
pTrans
->
id
,
terrstr
());
mError
(
"trans:%d, failed to prepare since %s"
,
pTrans
->
id
,
terrstr
());
...
...
source/dnode/mnode/impl/src/mndVgroup.c
浏览文件 @
ba1dd2ca
...
@@ -218,6 +218,8 @@ void *mndBuildCreateVnodeReq(SMnode *pMnode, SDnodeObj *pDnode, SDbObj *pDb, SVg
...
@@ -218,6 +218,8 @@ void *mndBuildCreateVnodeReq(SMnode *pMnode, SDnodeObj *pDnode, SDbObj *pDb, SVg
createReq
.
hashBegin
=
pVgroup
->
hashBegin
;
createReq
.
hashBegin
=
pVgroup
->
hashBegin
;
createReq
.
hashEnd
=
pVgroup
->
hashEnd
;
createReq
.
hashEnd
=
pVgroup
->
hashEnd
;
createReq
.
hashMethod
=
pDb
->
hashMethod
;
createReq
.
hashMethod
=
pDb
->
hashMethod
;
createReq
.
numOfRetensions
=
pDb
->
cfg
.
numOfRetensions
;
createReq
.
pRetensions
=
pDb
->
cfg
.
pRetensions
;
for
(
int32_t
v
=
0
;
v
<
pVgroup
->
replica
;
++
v
)
{
for
(
int32_t
v
=
0
;
v
<
pVgroup
->
replica
;
++
v
)
{
SReplica
*
pReplica
=
&
createReq
.
replicas
[
v
];
SReplica
*
pReplica
=
&
createReq
.
replicas
[
v
];
...
...
source/dnode/mnode/impl/src/mnode.c
浏览文件 @
ba1dd2ca
...
@@ -358,9 +358,7 @@ int32_t mndAlter(SMnode *pMnode, const SMnodeOpt *pOption) {
...
@@ -358,9 +358,7 @@ int32_t mndAlter(SMnode *pMnode, const SMnodeOpt *pOption) {
return
0
;
return
0
;
}
}
int32_t
mndStart
(
SMnode
*
pMnode
)
{
int32_t
mndStart
(
SMnode
*
pMnode
)
{
return
mndInitTimer
(
pMnode
);
}
return
mndInitTimer
(
pMnode
);
}
int32_t
mndProcessMsg
(
SNodeMsg
*
pMsg
)
{
int32_t
mndProcessMsg
(
SNodeMsg
*
pMsg
)
{
SMnode
*
pMnode
=
pMsg
->
pNode
;
SMnode
*
pMnode
=
pMsg
->
pNode
;
...
@@ -419,7 +417,7 @@ int64_t mndGenerateUid(char *name, int32_t len) {
...
@@ -419,7 +417,7 @@ int64_t mndGenerateUid(char *name, int32_t len) {
int64_t
x
=
(
us
&
0x000000FFFFFFFFFF
)
<<
24
;
int64_t
x
=
(
us
&
0x000000FFFFFFFFFF
)
<<
24
;
int64_t
uuid
=
x
+
((
hashval
&
((
1ul
<<
16
)
-
1ul
))
<<
8
)
+
(
taosRand
()
&
((
1ul
<<
8
)
-
1ul
));
int64_t
uuid
=
x
+
((
hashval
&
((
1ul
<<
16
)
-
1ul
))
<<
8
)
+
(
taosRand
()
&
((
1ul
<<
8
)
-
1ul
));
if
(
uuid
)
{
if
(
uuid
)
{
return
abs
(
uuid
);
return
ll
abs
(
uuid
);
}
}
}
while
(
true
);
}
while
(
true
);
}
}
...
...
source/dnode/mnode/impl/test/sma/sma.cpp
浏览文件 @
ba1dd2ca
...
@@ -26,9 +26,12 @@ class MndTestSma : public ::testing::Test {
...
@@ -26,9 +26,12 @@ class MndTestSma : public ::testing::Test {
void
*
BuildDropDbReq
(
const
char
*
dbname
,
int32_t
*
pContLen
);
void
*
BuildDropDbReq
(
const
char
*
dbname
,
int32_t
*
pContLen
);
void
*
BuildCreateStbReq
(
const
char
*
stbname
,
int32_t
*
pContLen
);
void
*
BuildCreateStbReq
(
const
char
*
stbname
,
int32_t
*
pContLen
);
void
*
BuildDropStbReq
(
const
char
*
stbname
,
int32_t
*
pContLen
);
void
*
BuildDropStbReq
(
const
char
*
stbname
,
int32_t
*
pContLen
);
void
*
BuildCreateSmaReq
(
const
char
*
smaname
,
const
char
*
stbname
,
int8_t
igExists
,
const
char
*
expr
,
void
*
BuildCreateBSmaStbReq
(
const
char
*
stbname
,
int32_t
*
pContLen
);
void
*
BuildCreateTSmaReq
(
const
char
*
smaname
,
const
char
*
stbname
,
int8_t
igExists
,
const
char
*
expr
,
const
char
*
tagsFilter
,
const
char
*
sql
,
const
char
*
ast
,
int32_t
*
pContLen
);
const
char
*
tagsFilter
,
const
char
*
sql
,
const
char
*
ast
,
int32_t
*
pContLen
);
void
*
BuildDropSmaReq
(
const
char
*
smaname
,
int8_t
igNotExists
,
int32_t
*
pContLen
);
void
*
BuildDropTSmaReq
(
const
char
*
smaname
,
int8_t
igNotExists
,
int32_t
*
pContLen
);
void
PushField
(
SArray
*
pArray
,
int32_t
bytes
,
int8_t
type
,
const
char
*
name
);
};
};
Testbase
MndTestSma
::
test
;
Testbase
MndTestSma
::
test
;
...
@@ -76,6 +79,14 @@ void* MndTestSma::BuildDropDbReq(const char* dbname, int32_t* pContLen) {
...
@@ -76,6 +79,14 @@ void* MndTestSma::BuildDropDbReq(const char* dbname, int32_t* pContLen) {
return
pReq
;
return
pReq
;
}
}
void
MndTestSma
::
PushField
(
SArray
*
pArray
,
int32_t
bytes
,
int8_t
type
,
const
char
*
name
)
{
SField
field
=
{
0
};
field
.
bytes
=
bytes
;
field
.
type
=
type
;
strcpy
(
field
.
name
,
name
);
taosArrayPush
(
pArray
,
&
field
);
}
void
*
MndTestSma
::
BuildCreateStbReq
(
const
char
*
stbname
,
int32_t
*
pContLen
)
{
void
*
MndTestSma
::
BuildCreateStbReq
(
const
char
*
stbname
,
int32_t
*
pContLen
)
{
SMCreateStbReq
createReq
=
{
0
};
SMCreateStbReq
createReq
=
{
0
};
createReq
.
numOfColumns
=
3
;
createReq
.
numOfColumns
=
3
;
...
@@ -85,37 +96,35 @@ void* MndTestSma::BuildCreateStbReq(const char* stbname, int32_t* pContLen) {
...
@@ -85,37 +96,35 @@ void* MndTestSma::BuildCreateStbReq(const char* stbname, int32_t* pContLen) {
createReq
.
pTags
=
taosArrayInit
(
createReq
.
numOfTags
,
sizeof
(
SField
));
createReq
.
pTags
=
taosArrayInit
(
createReq
.
numOfTags
,
sizeof
(
SField
));
strcpy
(
createReq
.
name
,
stbname
);
strcpy
(
createReq
.
name
,
stbname
);
{
PushField
(
createReq
.
pColumns
,
8
,
TSDB_DATA_TYPE_TIMESTAMP
,
"ts"
);
SField
field
=
{
0
};
PushField
(
createReq
.
pColumns
,
2
,
TSDB_DATA_TYPE_TINYINT
,
"col1"
);
field
.
bytes
=
8
;
PushField
(
createReq
.
pColumns
,
8
,
TSDB_DATA_TYPE_BIGINT
,
"col2"
);
field
.
type
=
TSDB_DATA_TYPE_TIMESTAMP
;
PushField
(
createReq
.
pTags
,
2
,
TSDB_DATA_TYPE_TINYINT
,
"tag1"
);
strcpy
(
field
.
name
,
"ts"
);
taosArrayPush
(
createReq
.
pColumns
,
&
field
);
}
{
int32_t
tlen
=
tSerializeSMCreateStbReq
(
NULL
,
0
,
&
createReq
);
SField
field
=
{
0
}
;
void
*
pHead
=
rpcMallocCont
(
tlen
)
;
field
.
bytes
=
2
;
tSerializeSMCreateStbReq
(
pHead
,
tlen
,
&
createReq
)
;
field
.
type
=
TSDB_DATA_TYPE_TINYINT
;
tFreeSMCreateStbReq
(
&
createReq
)
;
strcpy
(
field
.
name
,
"col1"
)
;
*
pContLen
=
tlen
;
taosArrayPush
(
createReq
.
pColumns
,
&
field
)
;
return
pHead
;
}
}
{
void
*
MndTestSma
::
BuildCreateBSmaStbReq
(
const
char
*
stbname
,
int32_t
*
pContLen
)
{
SField
field
=
{
0
};
SMCreateStbReq
createReq
=
{
0
};
field
.
bytes
=
8
;
createReq
.
numOfColumns
=
3
;
field
.
type
=
TSDB_DATA_TYPE_BIGINT
;
createReq
.
numOfTags
=
1
;
strcpy
(
field
.
name
,
"col2"
);
createReq
.
numOfSmas
=
1
;
taosArrayPush
(
createReq
.
pColumns
,
&
field
);
createReq
.
igExists
=
0
;
}
createReq
.
pColumns
=
taosArrayInit
(
createReq
.
numOfColumns
,
sizeof
(
SField
));
createReq
.
pTags
=
taosArrayInit
(
createReq
.
numOfTags
,
sizeof
(
SField
));
createReq
.
pSmas
=
taosArrayInit
(
createReq
.
numOfSmas
,
sizeof
(
SField
));
strcpy
(
createReq
.
name
,
stbname
);
{
PushField
(
createReq
.
pColumns
,
8
,
TSDB_DATA_TYPE_TIMESTAMP
,
"ts"
);
SField
field
=
{
0
};
PushField
(
createReq
.
pColumns
,
2
,
TSDB_DATA_TYPE_TINYINT
,
"col1"
);
field
.
bytes
=
2
;
PushField
(
createReq
.
pColumns
,
8
,
TSDB_DATA_TYPE_BIGINT
,
"col2"
);
field
.
type
=
TSDB_DATA_TYPE_TINYINT
;
PushField
(
createReq
.
pTags
,
2
,
TSDB_DATA_TYPE_TINYINT
,
"tag1"
);
strcpy
(
field
.
name
,
"tag1"
);
PushField
(
createReq
.
pSmas
,
2
,
TSDB_DATA_TYPE_TINYINT
,
"col1"
);
taosArrayPush
(
createReq
.
pTags
,
&
field
);
}
int32_t
tlen
=
tSerializeSMCreateStbReq
(
NULL
,
0
,
&
createReq
);
int32_t
tlen
=
tSerializeSMCreateStbReq
(
NULL
,
0
,
&
createReq
);
void
*
pHead
=
rpcMallocCont
(
tlen
);
void
*
pHead
=
rpcMallocCont
(
tlen
);
...
@@ -137,7 +146,7 @@ void* MndTestSma::BuildDropStbReq(const char* stbname, int32_t* pContLen) {
...
@@ -137,7 +146,7 @@ void* MndTestSma::BuildDropStbReq(const char* stbname, int32_t* pContLen) {
return
pReq
;
return
pReq
;
}
}
void
*
MndTestSma
::
BuildCreateSmaReq
(
const
char
*
smaname
,
const
char
*
stbname
,
int8_t
igExists
,
const
char
*
expr
,
void
*
MndTestSma
::
BuildCreate
T
SmaReq
(
const
char
*
smaname
,
const
char
*
stbname
,
int8_t
igExists
,
const
char
*
expr
,
const
char
*
tagsFilter
,
const
char
*
sql
,
const
char
*
ast
,
int32_t
*
pContLen
)
{
const
char
*
tagsFilter
,
const
char
*
sql
,
const
char
*
ast
,
int32_t
*
pContLen
)
{
SMCreateSmaReq
createReq
=
{
0
};
SMCreateSmaReq
createReq
=
{
0
};
strcpy
(
createReq
.
name
,
smaname
);
strcpy
(
createReq
.
name
,
smaname
);
...
@@ -156,7 +165,7 @@ void* MndTestSma::BuildCreateSmaReq(const char* smaname, const char* stbname, in
...
@@ -156,7 +165,7 @@ void* MndTestSma::BuildCreateSmaReq(const char* smaname, const char* stbname, in
createReq
.
tagsFilterLen
=
strlen
(
createReq
.
tagsFilter
)
+
1
;
createReq
.
tagsFilterLen
=
strlen
(
createReq
.
tagsFilter
)
+
1
;
createReq
.
sql
=
(
char
*
)
sql
;
createReq
.
sql
=
(
char
*
)
sql
;
createReq
.
sqlLen
=
strlen
(
createReq
.
sql
)
+
1
;
createReq
.
sqlLen
=
strlen
(
createReq
.
sql
)
+
1
;
createReq
.
ast
=
(
char
*
)
expr
;
createReq
.
ast
=
(
char
*
)
ast
;
createReq
.
astLen
=
strlen
(
createReq
.
ast
)
+
1
;
createReq
.
astLen
=
strlen
(
createReq
.
ast
)
+
1
;
int32_t
tlen
=
tSerializeSMCreateSmaReq
(
NULL
,
0
,
&
createReq
);
int32_t
tlen
=
tSerializeSMCreateSmaReq
(
NULL
,
0
,
&
createReq
);
...
@@ -166,7 +175,7 @@ void* MndTestSma::BuildCreateSmaReq(const char* smaname, const char* stbname, in
...
@@ -166,7 +175,7 @@ void* MndTestSma::BuildCreateSmaReq(const char* smaname, const char* stbname, in
return
pHead
;
return
pHead
;
}
}
void
*
MndTestSma
::
BuildDropSmaReq
(
const
char
*
smaname
,
int8_t
igNotExists
,
int32_t
*
pContLen
)
{
void
*
MndTestSma
::
BuildDrop
T
SmaReq
(
const
char
*
smaname
,
int8_t
igNotExists
,
int32_t
*
pContLen
)
{
SMDropSmaReq
dropsmaReq
=
{
0
};
SMDropSmaReq
dropsmaReq
=
{
0
};
dropsmaReq
.
igNotExists
=
igNotExists
;
dropsmaReq
.
igNotExists
=
igNotExists
;
strcpy
(
dropsmaReq
.
name
,
smaname
);
strcpy
(
dropsmaReq
.
name
,
smaname
);
...
@@ -180,6 +189,7 @@ void* MndTestSma::BuildDropSmaReq(const char* smaname, int8_t igNotExists, int32
...
@@ -180,6 +189,7 @@ void* MndTestSma::BuildDropSmaReq(const char* smaname, int8_t igNotExists, int32
}
}
TEST_F
(
MndTestSma
,
01
_Create_Show_Meta_Drop_Restart_Stb
)
{
TEST_F
(
MndTestSma
,
01
_Create_Show_Meta_Drop_Restart_Stb
)
{
#if 0
const char* dbname = "1.d1";
const char* dbname = "1.d1";
const char* stbname = "1.d1.stb";
const char* stbname = "1.d1.stb";
const char* smaname = "1.d1.sma";
const char* smaname = "1.d1.sma";
...
@@ -203,7 +213,7 @@ TEST_F(MndTestSma, 01_Create_Show_Meta_Drop_Restart_Stb) {
...
@@ -203,7 +213,7 @@ TEST_F(MndTestSma, 01_Create_Show_Meta_Drop_Restart_Stb) {
}
}
{
{
pReq
=
BuildCreateSmaReq
(
smaname
,
stbname
,
0
,
"expr"
,
"tagsFilter"
,
"sql"
,
"ast"
,
&
contLen
);
pReq = BuildCreate
T
SmaReq(smaname, stbname, 0, "expr", "tagsFilter", "sql", "ast", &contLen);
pRsp = test.SendReq(TDMT_MND_CREATE_SMA, pReq, contLen);
pRsp = test.SendReq(TDMT_MND_CREATE_SMA, pReq, contLen);
ASSERT_EQ(pRsp->code, 0);
ASSERT_EQ(pRsp->code, 0);
test.SendShowMetaReq(TSDB_MGMT_TABLE_INDEX, dbname);
test.SendShowMetaReq(TSDB_MGMT_TABLE_INDEX, dbname);
...
@@ -226,11 +236,59 @@ TEST_F(MndTestSma, 01_Create_Show_Meta_Drop_Restart_Stb) {
...
@@ -226,11 +236,59 @@ TEST_F(MndTestSma, 01_Create_Show_Meta_Drop_Restart_Stb) {
}
}
{
{
pReq
=
BuildDropSmaReq
(
smaname
,
0
,
&
contLen
);
pReq = BuildDrop
T
SmaReq(smaname, 0, &contLen);
pRsp = test.SendReq(TDMT_MND_DROP_SMA, pReq, contLen);
pRsp = test.SendReq(TDMT_MND_DROP_SMA, pReq, contLen);
ASSERT_EQ(pRsp->code, 0);
ASSERT_EQ(pRsp->code, 0);
test.SendShowMetaReq(TSDB_MGMT_TABLE_INDEX, dbname);
test.SendShowMetaReq(TSDB_MGMT_TABLE_INDEX, dbname);
test.SendShowRetrieveReq();
test.SendShowRetrieveReq();
EXPECT_EQ(test.GetShowRows(), 0);
EXPECT_EQ(test.GetShowRows(), 0);
}
}
#endif
}
TEST_F
(
MndTestSma
,
02
_Create_Show_Meta_Drop_Restart_BSma
)
{
const
char
*
dbname
=
"1.d1"
;
const
char
*
stbname
=
"1.d1.bsmastb"
;
int32_t
contLen
=
0
;
void
*
pReq
;
SRpcMsg
*
pRsp
;
{
pReq
=
BuildCreateDbReq
(
dbname
,
&
contLen
);
pRsp
=
test
.
SendReq
(
TDMT_MND_CREATE_DB
,
pReq
,
contLen
);
ASSERT_EQ
(
pRsp
->
code
,
0
);
}
{
pReq
=
BuildCreateBSmaStbReq
(
stbname
,
&
contLen
);
pRsp
=
test
.
SendReq
(
TDMT_MND_CREATE_STB
,
pReq
,
contLen
);
ASSERT_EQ
(
pRsp
->
code
,
0
);
test
.
SendShowMetaReq
(
TSDB_MGMT_TABLE_STB
,
dbname
);
test
.
SendShowRetrieveReq
();
EXPECT_EQ
(
test
.
GetShowRows
(),
1
);
// CheckBinary("bsmastb", TSDB_TABLE_NAME_LEN);
}
test
.
Restart
();
{
pReq
=
BuildCreateBSmaStbReq
(
stbname
,
&
contLen
);
pRsp
=
test
.
SendReq
(
TDMT_MND_CREATE_STB
,
pReq
,
contLen
);
ASSERT_EQ
(
pRsp
->
code
,
TSDB_CODE_MND_STB_ALREADY_EXIST
);
}
{
pReq
=
BuildDropStbReq
(
stbname
,
&
contLen
);
pRsp
=
test
.
SendReq
(
TDMT_MND_DROP_STB
,
pReq
,
contLen
);
ASSERT_EQ
(
pRsp
->
code
,
0
);
test
.
SendShowMetaReq
(
TSDB_MGMT_TABLE_STB
,
dbname
);
test
.
SendShowRetrieveReq
();
EXPECT_EQ
(
test
.
GetShowRows
(),
0
);
}
{
pReq
=
BuildDropStbReq
(
stbname
,
&
contLen
);
pRsp
=
test
.
SendReq
(
TDMT_MND_DROP_STB
,
pReq
,
contLen
);
ASSERT_EQ
(
pRsp
->
code
,
TSDB_CODE_MND_STB_NOT_EXIST
);
}
}
}
source/dnode/vnode/src/inc/tqInt.h
浏览文件 @
ba1dd2ca
...
@@ -161,11 +161,12 @@ typedef struct {
...
@@ -161,11 +161,12 @@ typedef struct {
struct
STQ
{
struct
STQ
{
// the collection of groups
// the collection of groups
// the handle of meta kvstore
// the handle of meta kvstore
bool
writeTrigger
;
char
*
path
;
char
*
path
;
STqCfg
*
tqConfig
;
STqCfg
*
tqConfig
;
STqMemRef
tqMemRef
;
STqMemRef
tqMemRef
;
STqMetaStore
*
tqMeta
;
STqMetaStore
*
tqMeta
;
STqPushMgr
*
tqPushMgr
;
//
STqPushMgr* tqPushMgr;
SHashObj
*
pStreamTasks
;
SHashObj
*
pStreamTasks
;
SVnode
*
pVnode
;
SVnode
*
pVnode
;
SWal
*
pWal
;
SWal
*
pWal
;
...
...
source/dnode/vnode/src/inc/vnd.h
浏览文件 @
ba1dd2ca
...
@@ -55,6 +55,21 @@ typedef struct SVnodeMgr {
...
@@ -55,6 +55,21 @@ typedef struct SVnodeMgr {
TD_DLIST
(
SVnodeTask
)
queue
;
TD_DLIST
(
SVnodeTask
)
queue
;
}
SVnodeMgr
;
}
SVnodeMgr
;
typedef
struct
{
int8_t
streamType
;
// sma or other
int8_t
dstType
;
int16_t
padding
;
int32_t
smaId
;
int64_t
tbUid
;
int64_t
lastReceivedVer
;
int64_t
lastCommittedVer
;
}
SStreamSinkInfo
;
typedef
struct
{
SVnode
*
pVnode
;
SHashObj
*
pHash
;
// streamId -> SStreamSinkInfo
}
SSink
;
extern
SVnodeMgr
vnodeMgr
;
extern
SVnodeMgr
vnodeMgr
;
// SVState
// SVState
...
@@ -72,8 +87,9 @@ struct SVnode {
...
@@ -72,8 +87,9 @@ struct SVnode {
SVBufPool
*
pBufPool
;
SVBufPool
*
pBufPool
;
SMeta
*
pMeta
;
SMeta
*
pMeta
;
STsdb
*
pTsdb
;
STsdb
*
pTsdb
;
STQ
*
pTq
;
SWal
*
pWal
;
SWal
*
pWal
;
STQ
*
pTq
;
SSink
*
pSink
;
tsem_t
canCommit
;
tsem_t
canCommit
;
SQHandle
*
pQuery
;
SQHandle
*
pQuery
;
SMsgCb
msgCb
;
SMsgCb
msgCb
;
...
...
source/dnode/vnode/src/tq/tq.c
浏览文件 @
ba1dd2ca
...
@@ -52,12 +52,14 @@ STQ* tqOpen(const char* path, SVnode* pVnode, SWal* pWal, SMeta* pVnodeMeta, STq
...
@@ -52,12 +52,14 @@ STQ* tqOpen(const char* path, SVnode* pVnode, SWal* pWal, SMeta* pVnodeMeta, STq
return
NULL
;
return
NULL
;
}
}
#if 0
pTq->tqPushMgr = tqPushMgrOpen();
pTq->tqPushMgr = tqPushMgrOpen();
if (pTq->tqPushMgr == NULL) {
if (pTq->tqPushMgr == NULL) {
// free store
// free store
free(pTq);
free(pTq);
return NULL;
return NULL;
}
}
#endif
pTq
->
pStreamTasks
=
taosHashInit
(
64
,
taosGetDefaultHashFunction
(
TSDB_DATA_TYPE_INT
),
true
,
HASH_NO_LOCK
);
pTq
->
pStreamTasks
=
taosHashInit
(
64
,
taosGetDefaultHashFunction
(
TSDB_DATA_TYPE_INT
),
true
,
HASH_NO_LOCK
);
...
@@ -559,7 +561,7 @@ int32_t tqProcessStreamTrigger(STQ* pTq, void* data, int32_t dataLen) {
...
@@ -559,7 +561,7 @@ int32_t tqProcessStreamTrigger(STQ* pTq, void* data, int32_t dataLen) {
pIter
=
taosHashIterate
(
pTq
->
pStreamTasks
,
pIter
);
pIter
=
taosHashIterate
(
pTq
->
pStreamTasks
,
pIter
);
if
(
pIter
==
NULL
)
break
;
if
(
pIter
==
NULL
)
break
;
SStreamTask
*
pTask
=
(
SStreamTask
*
)
pIter
;
SStreamTask
*
pTask
=
(
SStreamTask
*
)
pIter
;
if
(
!
pTask
->
pipeSourc
e
)
continue
;
if
(
!
pTask
->
sourceTyp
e
)
continue
;
int32_t
workerId
=
0
;
int32_t
workerId
=
0
;
void
*
exec
=
pTask
->
runner
[
workerId
].
executor
;
void
*
exec
=
pTask
->
runner
[
workerId
].
executor
;
...
@@ -576,7 +578,7 @@ int32_t tqProcessStreamTrigger(STQ* pTq, void* data, int32_t dataLen) {
...
@@ -576,7 +578,7 @@ int32_t tqProcessStreamTrigger(STQ* pTq, void* data, int32_t dataLen) {
}
}
taosArrayPush
(
pRes
,
output
);
taosArrayPush
(
pRes
,
output
);
}
}
if
(
pTask
->
pipeSink
)
{
if
(
pTask
->
sinkType
)
{
// write back
// write back
/*printf("reach end\n");*/
/*printf("reach end\n");*/
tqDebugShowSSData
(
pRes
);
tqDebugShowSSData
(
pRes
);
...
...
source/libs/executor/src/executorimpl.c
浏览文件 @
ba1dd2ca
...
@@ -8487,7 +8487,7 @@ SOperatorInfo* doCreateOperatorTreeNode(SPhysiNode* pPhyNode, SExecTaskInfo* pTa
...
@@ -8487,7 +8487,7 @@ SOperatorInfo* doCreateOperatorTreeNode(SPhysiNode* pPhyNode, SExecTaskInfo* pTa
SIntervalPhysiNode
*
pIntervalPhyNode
=
(
SIntervalPhysiNode
*
)
pPhyNode
;
SIntervalPhysiNode
*
pIntervalPhyNode
=
(
SIntervalPhysiNode
*
)
pPhyNode
;
int32_t
num
=
0
;
int32_t
num
=
0
;
SExprInfo
*
pExprInfo
=
createExprInfo
(
pIntervalPhyNode
->
pFuncs
,
NULL
,
&
num
);
SExprInfo
*
pExprInfo
=
createExprInfo
(
pIntervalPhyNode
->
window
.
pFuncs
,
NULL
,
&
num
);
SSDataBlock
*
pResBlock
=
createOutputBuf_rv1
(
pPhyNode
->
pOutputDataBlockDesc
);
SSDataBlock
*
pResBlock
=
createOutputBuf_rv1
(
pPhyNode
->
pOutputDataBlockDesc
);
SInterval
interval
=
{.
interval
=
pIntervalPhyNode
->
interval
,
.
sliding
=
pIntervalPhyNode
->
sliding
,
SInterval
interval
=
{.
interval
=
pIntervalPhyNode
->
interval
,
.
sliding
=
pIntervalPhyNode
->
sliding
,
...
...
source/libs/nodes/src/nodesCloneFuncs.c
浏览文件 @
ba1dd2ca
...
@@ -272,11 +272,14 @@ static SNode* logicWindowCopy(const SWindowLogicNode* pSrc, SWindowLogicNode* pD
...
@@ -272,11 +272,14 @@ static SNode* logicWindowCopy(const SWindowLogicNode* pSrc, SWindowLogicNode* pD
COPY_SCALAR_FIELD
(
interval
);
COPY_SCALAR_FIELD
(
interval
);
COPY_SCALAR_FIELD
(
offset
);
COPY_SCALAR_FIELD
(
offset
);
COPY_SCALAR_FIELD
(
sliding
);
COPY_SCALAR_FIELD
(
sliding
);
COPY_SCALAR_FIELD
(
intervalUnit
);
COPY_SCALAR_FIELD
(
slidingUnit
);
CLONE_NODE_FIELD
(
pFill
);
CLONE_NODE_FIELD
(
pFill
);
COPY_SCALAR_FIELD
(
sessionGap
);
return
(
SNode
*
)
pDst
;
return
(
SNode
*
)
pDst
;
}
}
static
SNode
*
logicSubplanCopy
(
const
S
SubLogicPlan
*
pSrc
,
SSubLogicP
lan
*
pDst
)
{
static
SNode
*
logicSubplanCopy
(
const
S
LogicSubplan
*
pSrc
,
SLogicSubp
lan
*
pDst
)
{
CLONE_NODE_FIELD
(
pNode
);
CLONE_NODE_FIELD
(
pNode
);
COPY_SCALAR_FIELD
(
subplanType
);
COPY_SCALAR_FIELD
(
subplanType
);
return
(
SNode
*
)
pDst
;
return
(
SNode
*
)
pDst
;
...
@@ -358,7 +361,7 @@ SNodeptr nodesCloneNode(const SNodeptr pNode) {
...
@@ -358,7 +361,7 @@ SNodeptr nodesCloneNode(const SNodeptr pNode) {
case
QUERY_NODE_LOGIC_PLAN_WINDOW
:
case
QUERY_NODE_LOGIC_PLAN_WINDOW
:
return
logicWindowCopy
((
const
SWindowLogicNode
*
)
pNode
,
(
SWindowLogicNode
*
)
pDst
);
return
logicWindowCopy
((
const
SWindowLogicNode
*
)
pNode
,
(
SWindowLogicNode
*
)
pDst
);
case
QUERY_NODE_LOGIC_SUBPLAN
:
case
QUERY_NODE_LOGIC_SUBPLAN
:
return
logicSubplanCopy
((
const
S
SubLogicPlan
*
)
pNode
,
(
SSubLogicP
lan
*
)
pDst
);
return
logicSubplanCopy
((
const
S
LogicSubplan
*
)
pNode
,
(
SLogicSubp
lan
*
)
pDst
);
default:
default:
break
;
break
;
}
}
...
...
source/libs/nodes/src/nodesCodeFuncs.c
浏览文件 @
ba1dd2ca
...
@@ -70,6 +70,14 @@ const char* nodesNodeName(ENodeType type) {
...
@@ -70,6 +70,14 @@ const char* nodesNodeName(ENodeType type) {
return
"SlotDesc"
;
return
"SlotDesc"
;
case
QUERY_NODE_COLUMN_DEF
:
case
QUERY_NODE_COLUMN_DEF
:
return
"ColumnDef"
;
return
"ColumnDef"
;
case
QUERY_NODE_DOWNSTREAM_SOURCE
:
return
"DownstreamSource"
;
case
QUERY_NODE_DATABASE_OPTIONS
:
return
"DatabaseOptions"
;
case
QUERY_NODE_TABLE_OPTIONS
:
return
"TableOptions"
;
case
QUERY_NODE_INDEX_OPTIONS
:
return
"IndexOptions"
;
case
QUERY_NODE_SET_OPERATOR
:
case
QUERY_NODE_SET_OPERATOR
:
return
"SetOperator"
;
return
"SetOperator"
;
case
QUERY_NODE_SELECT_STMT
:
case
QUERY_NODE_SELECT_STMT
:
...
@@ -78,16 +86,76 @@ const char* nodesNodeName(ENodeType type) {
...
@@ -78,16 +86,76 @@ const char* nodesNodeName(ENodeType type) {
return
"VnodeModifStmt"
;
return
"VnodeModifStmt"
;
case
QUERY_NODE_CREATE_DATABASE_STMT
:
case
QUERY_NODE_CREATE_DATABASE_STMT
:
return
"CreateDatabaseStmt"
;
return
"CreateDatabaseStmt"
;
case
QUERY_NODE_DROP_DATABASE_STMT
:
return
"DropDatabaseStmt"
;
case
QUERY_NODE_ALTER_DATABASE_STMT
:
return
"AlterDatabaseStmt"
;
case
QUERY_NODE_CREATE_TABLE_STMT
:
case
QUERY_NODE_CREATE_TABLE_STMT
:
return
"CreateTableStmt"
;
return
"CreateTableStmt"
;
case
QUERY_NODE_CREATE_SUBTABLE_CLAUSE
:
return
"CreateSubtableClause"
;
case
QUERY_NODE_CREATE_MULTI_TABLE_STMT
:
return
"CreateMultiTableStmt"
;
case
QUERY_NODE_DROP_TABLE_CLAUSE
:
return
"DropTableClause"
;
case
QUERY_NODE_DROP_TABLE_STMT
:
return
"DropTableStmt"
;
case
QUERY_NODE_DROP_SUPER_TABLE_STMT
:
return
"DropSuperTableStmt"
;
case
QUERY_NODE_ALTER_TABLE_STMT
:
return
"AlterTableStmt"
;
case
QUERY_NODE_CREATE_USER_STMT
:
return
"CreateUserStmt"
;
case
QUERY_NODE_ALTER_USER_STMT
:
return
"AlterUserStmt"
;
case
QUERY_NODE_DROP_USER_STMT
:
return
"DropUserStmt"
;
case
QUERY_NODE_USE_DATABASE_STMT
:
case
QUERY_NODE_USE_DATABASE_STMT
:
return
"UseDatabaseStmt"
;
return
"UseDatabaseStmt"
;
case
QUERY_NODE_CREATE_DNODE_STMT
:
return
"CreateDnodeStmt"
;
case
QUERY_NODE_DROP_DNODE_STMT
:
return
"DropDnodeStmt"
;
case
QUERY_NODE_ALTER_DNODE_STMT
:
return
"AlterDnodeStmt"
;
case
QUERY_NODE_CREATE_INDEX_STMT
:
return
"CreateIndexStmt"
;
case
QUERY_NODE_DROP_INDEX_STMT
:
return
"DropIndexStmt"
;
case
QUERY_NODE_CREATE_QNODE_STMT
:
return
"CreateQnodeStmt"
;
case
QUERY_NODE_DROP_QNODE_STMT
:
return
"DropQnodeStmt"
;
case
QUERY_NODE_CREATE_TOPIC_STMT
:
return
"CreateTopicStmt"
;
case
QUERY_NODE_DROP_TOPIC_STMT
:
return
"DropTopicStmt"
;
case
QUERY_NODE_ALTER_LOCAL_STMT
:
return
"AlterLocalStmt"
;
case
QUERY_NODE_SHOW_DATABASES_STMT
:
case
QUERY_NODE_SHOW_DATABASES_STMT
:
return
"ShowDatabaseStmt"
;
return
"ShowDatabaseStmt"
;
case
QUERY_NODE_SHOW_TABLES_STMT
:
case
QUERY_NODE_SHOW_TABLES_STMT
:
return
"ShowTablesStmt"
;
return
"ShowTablesStmt"
;
case
QUERY_NODE_CREATE_TOPIC_STMT
:
case
QUERY_NODE_SHOW_STABLES_STMT
:
return
"CreateTopicStmt"
;
return
"ShowStablesStmt"
;
case
QUERY_NODE_SHOW_USERS_STMT
:
return
"ShowUsersStmt"
;
case
QUERY_NODE_SHOW_DNODES_STMT
:
return
"ShowDnodesStmt"
;
case
QUERY_NODE_SHOW_VGROUPS_STMT
:
return
"ShowVgroupsStmt"
;
case
QUERY_NODE_SHOW_MNODES_STMT
:
return
"ShowMnodesStmt"
;
case
QUERY_NODE_SHOW_MODULES_STMT
:
return
"ShowModulesStmt"
;
case
QUERY_NODE_SHOW_QNODES_STMT
:
return
"ShowQnodesStmt"
;
case
QUERY_NODE_SHOW_FUNCTIONS_STMT
:
return
"ShowFunctionsStmt"
;
case
QUERY_NODE_SHOW_INDEXES_STMT
:
return
"ShowIndexesStmt"
;
case
QUERY_NODE_SHOW_STREAMS_STMT
:
return
"ShowStreamsStmt"
;
case
QUERY_NODE_LOGIC_PLAN_SCAN
:
case
QUERY_NODE_LOGIC_PLAN_SCAN
:
return
"LogicScan"
;
return
"LogicScan"
;
case
QUERY_NODE_LOGIC_PLAN_JOIN
:
case
QUERY_NODE_LOGIC_PLAN_JOIN
:
...
@@ -98,6 +166,10 @@ const char* nodesNodeName(ENodeType type) {
...
@@ -98,6 +166,10 @@ const char* nodesNodeName(ENodeType type) {
return
"LogicProject"
;
return
"LogicProject"
;
case
QUERY_NODE_LOGIC_PLAN_VNODE_MODIF
:
case
QUERY_NODE_LOGIC_PLAN_VNODE_MODIF
:
return
"LogicVnodeModif"
;
return
"LogicVnodeModif"
;
case
QUERY_NODE_LOGIC_PLAN_EXCHANGE
:
return
"LogicExchange"
;
case
QUERY_NODE_LOGIC_PLAN_WINDOW
:
return
"LogicWindow"
;
case
QUERY_NODE_LOGIC_SUBPLAN
:
case
QUERY_NODE_LOGIC_SUBPLAN
:
return
"LogicSubplan"
;
return
"LogicSubplan"
;
case
QUERY_NODE_LOGIC_PLAN
:
case
QUERY_NODE_LOGIC_PLAN
:
...
@@ -124,6 +196,8 @@ const char* nodesNodeName(ENodeType type) {
...
@@ -124,6 +196,8 @@ const char* nodesNodeName(ENodeType type) {
return
"PhysiSort"
;
return
"PhysiSort"
;
case
QUERY_NODE_PHYSICAL_PLAN_INTERVAL
:
case
QUERY_NODE_PHYSICAL_PLAN_INTERVAL
:
return
"PhysiInterval"
;
return
"PhysiInterval"
;
case
QUERY_NODE_PHYSICAL_PLAN_SESSION_WINDOW
:
return
"PhysiSessionWindow"
;
case
QUERY_NODE_PHYSICAL_PLAN_DISPATCH
:
case
QUERY_NODE_PHYSICAL_PLAN_DISPATCH
:
return
"PhysiDispatch"
;
return
"PhysiDispatch"
;
case
QUERY_NODE_PHYSICAL_PLAN_INSERT
:
case
QUERY_NODE_PHYSICAL_PLAN_INSERT
:
...
@@ -846,8 +920,37 @@ static int32_t jsonToPhysiExchangeNode(const SJson* pJson, void* pObj) {
...
@@ -846,8 +920,37 @@ static int32_t jsonToPhysiExchangeNode(const SJson* pJson, void* pObj) {
return
code
;
return
code
;
}
}
static
const
char
*
jkIntervalPhysiPlanExprs
=
"Exprs"
;
static
const
char
*
jkWindowPhysiPlanExprs
=
"Exprs"
;
static
const
char
*
jkIntervalPhysiPlanFuncs
=
"Funcs"
;
static
const
char
*
jkWindowPhysiPlanFuncs
=
"Funcs"
;
static
int32_t
physiWindowNodeToJson
(
const
void
*
pObj
,
SJson
*
pJson
)
{
const
SWinodwPhysiNode
*
pNode
=
(
const
SWinodwPhysiNode
*
)
pObj
;
int32_t
code
=
physicPlanNodeToJson
(
pObj
,
pJson
);
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
nodeListToJson
(
pJson
,
jkWindowPhysiPlanExprs
,
pNode
->
pExprs
);
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
nodeListToJson
(
pJson
,
jkWindowPhysiPlanFuncs
,
pNode
->
pFuncs
);
}
return
code
;
}
static
int32_t
jsonToPhysiWindowNode
(
const
SJson
*
pJson
,
void
*
pObj
)
{
SWinodwPhysiNode
*
pNode
=
(
SWinodwPhysiNode
*
)
pObj
;
int32_t
code
=
jsonToPhysicPlanNode
(
pJson
,
pObj
);
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
jsonToNodeList
(
pJson
,
jkWindowPhysiPlanExprs
,
&
pNode
->
pExprs
);
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
jsonToNodeList
(
pJson
,
jkWindowPhysiPlanFuncs
,
&
pNode
->
pFuncs
);
}
return
code
;
}
static
const
char
*
jkIntervalPhysiPlanInterval
=
"Interval"
;
static
const
char
*
jkIntervalPhysiPlanInterval
=
"Interval"
;
static
const
char
*
jkIntervalPhysiPlanOffset
=
"Offset"
;
static
const
char
*
jkIntervalPhysiPlanOffset
=
"Offset"
;
static
const
char
*
jkIntervalPhysiPlanSliding
=
"Sliding"
;
static
const
char
*
jkIntervalPhysiPlanSliding
=
"Sliding"
;
...
@@ -858,13 +961,7 @@ static const char* jkIntervalPhysiPlanFill = "Fill";
...
@@ -858,13 +961,7 @@ static const char* jkIntervalPhysiPlanFill = "Fill";
static
int32_t
physiIntervalNodeToJson
(
const
void
*
pObj
,
SJson
*
pJson
)
{
static
int32_t
physiIntervalNodeToJson
(
const
void
*
pObj
,
SJson
*
pJson
)
{
const
SIntervalPhysiNode
*
pNode
=
(
const
SIntervalPhysiNode
*
)
pObj
;
const
SIntervalPhysiNode
*
pNode
=
(
const
SIntervalPhysiNode
*
)
pObj
;
int32_t
code
=
physicPlanNodeToJson
(
pObj
,
pJson
);
int32_t
code
=
physiWindowNodeToJson
(
pObj
,
pJson
);
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
nodeListToJson
(
pJson
,
jkIntervalPhysiPlanExprs
,
pNode
->
pExprs
);
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
nodeListToJson
(
pJson
,
jkIntervalPhysiPlanFuncs
,
pNode
->
pFuncs
);
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
tjsonAddIntegerToObject
(
pJson
,
jkIntervalPhysiPlanInterval
,
pNode
->
interval
);
code
=
tjsonAddIntegerToObject
(
pJson
,
jkIntervalPhysiPlanInterval
,
pNode
->
interval
);
}
}
...
@@ -890,13 +987,7 @@ static int32_t physiIntervalNodeToJson(const void* pObj, SJson* pJson) {
...
@@ -890,13 +987,7 @@ static int32_t physiIntervalNodeToJson(const void* pObj, SJson* pJson) {
static
int32_t
jsonToPhysiIntervalNode
(
const
SJson
*
pJson
,
void
*
pObj
)
{
static
int32_t
jsonToPhysiIntervalNode
(
const
SJson
*
pJson
,
void
*
pObj
)
{
SIntervalPhysiNode
*
pNode
=
(
SIntervalPhysiNode
*
)
pObj
;
SIntervalPhysiNode
*
pNode
=
(
SIntervalPhysiNode
*
)
pObj
;
int32_t
code
=
jsonToPhysicPlanNode
(
pJson
,
pObj
);
int32_t
code
=
jsonToPhysiWindowNode
(
pJson
,
pObj
);
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
jsonToNodeList
(
pJson
,
jkIntervalPhysiPlanExprs
,
&
pNode
->
pExprs
);
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
jsonToNodeList
(
pJson
,
jkIntervalPhysiPlanFuncs
,
&
pNode
->
pFuncs
);
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
tjsonGetBigIntValue
(
pJson
,
jkIntervalPhysiPlanInterval
,
&
pNode
->
interval
);
code
=
tjsonGetBigIntValue
(
pJson
,
jkIntervalPhysiPlanInterval
,
&
pNode
->
interval
);
}
}
...
@@ -919,6 +1010,30 @@ static int32_t jsonToPhysiIntervalNode(const SJson* pJson, void* pObj) {
...
@@ -919,6 +1010,30 @@ static int32_t jsonToPhysiIntervalNode(const SJson* pJson, void* pObj) {
return
code
;
return
code
;
}
}
static
const
char
*
jkSessionWindowPhysiPlanGap
=
"Gap"
;
static
int32_t
physiSessionWindowNodeToJson
(
const
void
*
pObj
,
SJson
*
pJson
)
{
const
SSessionWinodwPhysiNode
*
pNode
=
(
const
SSessionWinodwPhysiNode
*
)
pObj
;
int32_t
code
=
physiWindowNodeToJson
(
pObj
,
pJson
);
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
tjsonAddIntegerToObject
(
pJson
,
jkSessionWindowPhysiPlanGap
,
pNode
->
gap
);
}
return
code
;
}
static
int32_t
jsonToPhysiSessionWindowNode
(
const
SJson
*
pJson
,
void
*
pObj
)
{
SSessionWinodwPhysiNode
*
pNode
=
(
SSessionWinodwPhysiNode
*
)
pObj
;
int32_t
code
=
jsonToPhysiWindowNode
(
pJson
,
pObj
);
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
tjsonGetNumberValue
(
pJson
,
jkSessionWindowPhysiPlanGap
,
pNode
->
gap
);
}
return
code
;
}
static
const
char
*
jkDataSinkInputDataBlockDesc
=
"InputDataBlockDesc"
;
static
const
char
*
jkDataSinkInputDataBlockDesc
=
"InputDataBlockDesc"
;
static
int32_t
physicDataSinkNodeToJson
(
const
void
*
pObj
,
SJson
*
pJson
)
{
static
int32_t
physicDataSinkNodeToJson
(
const
void
*
pObj
,
SJson
*
pJson
)
{
...
@@ -2066,6 +2181,8 @@ static int32_t specificNodeToJson(const void* pObj, SJson* pJson) {
...
@@ -2066,6 +2181,8 @@ static int32_t specificNodeToJson(const void* pObj, SJson* pJson) {
break
;
break
;
case
QUERY_NODE_PHYSICAL_PLAN_INTERVAL
:
case
QUERY_NODE_PHYSICAL_PLAN_INTERVAL
:
return
physiIntervalNodeToJson
(
pObj
,
pJson
);
return
physiIntervalNodeToJson
(
pObj
,
pJson
);
case
QUERY_NODE_PHYSICAL_PLAN_SESSION_WINDOW
:
return
physiSessionWindowNodeToJson
(
pObj
,
pJson
);
case
QUERY_NODE_PHYSICAL_PLAN_DISPATCH
:
case
QUERY_NODE_PHYSICAL_PLAN_DISPATCH
:
return
physiDispatchNodeToJson
(
pObj
,
pJson
);
return
physiDispatchNodeToJson
(
pObj
,
pJson
);
case
QUERY_NODE_PHYSICAL_PLAN_INSERT
:
case
QUERY_NODE_PHYSICAL_PLAN_INSERT
:
...
@@ -2075,7 +2192,7 @@ static int32_t specificNodeToJson(const void* pObj, SJson* pJson) {
...
@@ -2075,7 +2192,7 @@ static int32_t specificNodeToJson(const void* pObj, SJson* pJson) {
case
QUERY_NODE_PHYSICAL_PLAN
:
case
QUERY_NODE_PHYSICAL_PLAN
:
return
planToJson
(
pObj
,
pJson
);
return
planToJson
(
pObj
,
pJson
);
default:
default:
assert
(
0
);
//
assert(0);
break
;
break
;
}
}
nodesWarn
(
"specificNodeToJson unknown node = %s"
,
nodesNodeName
(
nodeType
(
pObj
)));
nodesWarn
(
"specificNodeToJson unknown node = %s"
,
nodesNodeName
(
nodeType
(
pObj
)));
...
@@ -2149,14 +2266,16 @@ static int32_t jsonToSpecificNode(const SJson* pJson, void* pObj) {
...
@@ -2149,14 +2266,16 @@ static int32_t jsonToSpecificNode(const SJson* pJson, void* pObj) {
return
jsonToPhysiAggNode
(
pJson
,
pObj
);
return
jsonToPhysiAggNode
(
pJson
,
pObj
);
case
QUERY_NODE_PHYSICAL_PLAN_EXCHANGE
:
case
QUERY_NODE_PHYSICAL_PLAN_EXCHANGE
:
return
jsonToPhysiExchangeNode
(
pJson
,
pObj
);
return
jsonToPhysiExchangeNode
(
pJson
,
pObj
);
case
QUERY_NODE_PHYSICAL_PLAN_INTERVAL
:
return
jsonToPhysiIntervalNode
(
pJson
,
pObj
);
case
QUERY_NODE_PHYSICAL_PLAN_SESSION_WINDOW
:
return
jsonToPhysiSessionWindowNode
(
pJson
,
pObj
);
case
QUERY_NODE_PHYSICAL_PLAN_DISPATCH
:
case
QUERY_NODE_PHYSICAL_PLAN_DISPATCH
:
return
jsonToPhysiDispatchNode
(
pJson
,
pObj
);
return
jsonToPhysiDispatchNode
(
pJson
,
pObj
);
case
QUERY_NODE_PHYSICAL_SUBPLAN
:
case
QUERY_NODE_PHYSICAL_SUBPLAN
:
return
jsonToSubplan
(
pJson
,
pObj
);
return
jsonToSubplan
(
pJson
,
pObj
);
case
QUERY_NODE_PHYSICAL_PLAN
:
case
QUERY_NODE_PHYSICAL_PLAN
:
return
jsonToPlan
(
pJson
,
pObj
);
return
jsonToPlan
(
pJson
,
pObj
);
case
QUERY_NODE_PHYSICAL_PLAN_INTERVAL
:
return
jsonToPhysiIntervalNode
(
pJson
,
pObj
);
default:
default:
assert
(
0
);
assert
(
0
);
break
;
break
;
...
...
source/libs/nodes/src/nodesTraverseFuncs.c
浏览文件 @
ba1dd2ca
...
@@ -79,9 +79,14 @@ static EDealRes walkNode(SNode* pNode, ETraversalOrder order, FNodeWalker walker
...
@@ -79,9 +79,14 @@ static EDealRes walkNode(SNode* pNode, ETraversalOrder order, FNodeWalker walker
case
QUERY_NODE_STATE_WINDOW
:
case
QUERY_NODE_STATE_WINDOW
:
res
=
walkNode
(((
SStateWindowNode
*
)
pNode
)
->
pCol
,
order
,
walker
,
pContext
);
res
=
walkNode
(((
SStateWindowNode
*
)
pNode
)
->
pCol
,
order
,
walker
,
pContext
);
break
;
break
;
case
QUERY_NODE_SESSION_WINDOW
:
case
QUERY_NODE_SESSION_WINDOW
:
{
res
=
walkNode
(((
SSessionWindowNode
*
)
pNode
)
->
pCol
,
order
,
walker
,
pContext
);
SSessionWindowNode
*
pSession
=
(
SSessionWindowNode
*
)
pNode
;
res
=
walkNode
(
pSession
->
pCol
,
order
,
walker
,
pContext
);
if
(
DEAL_RES_ERROR
!=
res
)
{
res
=
walkNode
(
pSession
->
pGap
,
order
,
walker
,
pContext
);
}
break
;
break
;
}
case
QUERY_NODE_INTERVAL_WINDOW
:
{
case
QUERY_NODE_INTERVAL_WINDOW
:
{
SIntervalWindowNode
*
pInterval
=
(
SIntervalWindowNode
*
)
pNode
;
SIntervalWindowNode
*
pInterval
=
(
SIntervalWindowNode
*
)
pNode
;
res
=
walkNode
(
pInterval
->
pInterval
,
order
,
walker
,
pContext
);
res
=
walkNode
(
pInterval
->
pInterval
,
order
,
walker
,
pContext
);
...
...
source/libs/nodes/src/nodesUtilFuncs.c
浏览文件 @
ba1dd2ca
...
@@ -160,7 +160,7 @@ SNodeptr nodesMakeNode(ENodeType type) {
...
@@ -160,7 +160,7 @@ SNodeptr nodesMakeNode(ENodeType type) {
case
QUERY_NODE_LOGIC_PLAN_WINDOW
:
case
QUERY_NODE_LOGIC_PLAN_WINDOW
:
return
makeNode
(
type
,
sizeof
(
SWindowLogicNode
));
return
makeNode
(
type
,
sizeof
(
SWindowLogicNode
));
case
QUERY_NODE_LOGIC_SUBPLAN
:
case
QUERY_NODE_LOGIC_SUBPLAN
:
return
makeNode
(
type
,
sizeof
(
S
SubLogicP
lan
));
return
makeNode
(
type
,
sizeof
(
S
LogicSubp
lan
));
case
QUERY_NODE_LOGIC_PLAN
:
case
QUERY_NODE_LOGIC_PLAN
:
return
makeNode
(
type
,
sizeof
(
SQueryLogicPlan
));
return
makeNode
(
type
,
sizeof
(
SQueryLogicPlan
));
case
QUERY_NODE_PHYSICAL_PLAN_TAG_SCAN
:
case
QUERY_NODE_PHYSICAL_PLAN_TAG_SCAN
:
...
@@ -185,6 +185,8 @@ SNodeptr nodesMakeNode(ENodeType type) {
...
@@ -185,6 +185,8 @@ SNodeptr nodesMakeNode(ENodeType type) {
return
makeNode
(
type
,
sizeof
(
SNode
));
return
makeNode
(
type
,
sizeof
(
SNode
));
case
QUERY_NODE_PHYSICAL_PLAN_INTERVAL
:
case
QUERY_NODE_PHYSICAL_PLAN_INTERVAL
:
return
makeNode
(
type
,
sizeof
(
SIntervalPhysiNode
));
return
makeNode
(
type
,
sizeof
(
SIntervalPhysiNode
));
case
QUERY_NODE_PHYSICAL_PLAN_SESSION_WINDOW
:
return
makeNode
(
type
,
sizeof
(
SSessionWinodwPhysiNode
));
case
QUERY_NODE_PHYSICAL_PLAN_DISPATCH
:
case
QUERY_NODE_PHYSICAL_PLAN_DISPATCH
:
return
makeNode
(
type
,
sizeof
(
SDataDispatcherNode
));
return
makeNode
(
type
,
sizeof
(
SDataDispatcherNode
));
case
QUERY_NODE_PHYSICAL_PLAN_INSERT
:
case
QUERY_NODE_PHYSICAL_PLAN_INSERT
:
...
@@ -332,6 +334,7 @@ int32_t nodesListAppend(SNodeList* pList, SNodeptr pNode) {
...
@@ -332,6 +334,7 @@ int32_t nodesListAppend(SNodeList* pList, SNodeptr pNode) {
int32_t
nodesListStrictAppend
(
SNodeList
*
pList
,
SNodeptr
pNode
)
{
int32_t
nodesListStrictAppend
(
SNodeList
*
pList
,
SNodeptr
pNode
)
{
if
(
NULL
==
pNode
)
{
if
(
NULL
==
pNode
)
{
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
return
TSDB_CODE_OUT_OF_MEMORY
;
return
TSDB_CODE_OUT_OF_MEMORY
;
}
}
int32_t
code
=
nodesListAppend
(
pList
,
pNode
);
int32_t
code
=
nodesListAppend
(
pList
,
pNode
);
...
@@ -341,6 +344,17 @@ int32_t nodesListStrictAppend(SNodeList* pList, SNodeptr pNode) {
...
@@ -341,6 +344,17 @@ int32_t nodesListStrictAppend(SNodeList* pList, SNodeptr pNode) {
return
code
;
return
code
;
}
}
int32_t
nodesListMakeAppend
(
SNodeList
**
pList
,
SNodeptr
pNode
)
{
if
(
NULL
==
*
pList
)
{
*
pList
=
nodesMakeList
();
if
(
NULL
==
*
pList
)
{
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
return
TSDB_CODE_OUT_OF_MEMORY
;
}
}
return
nodesListAppend
(
*
pList
,
pNode
);
}
int32_t
nodesListAppendList
(
SNodeList
*
pTarget
,
SNodeList
*
pSrc
)
{
int32_t
nodesListAppendList
(
SNodeList
*
pTarget
,
SNodeList
*
pSrc
)
{
if
(
NULL
==
pTarget
||
NULL
==
pSrc
)
{
if
(
NULL
==
pTarget
||
NULL
==
pSrc
)
{
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
...
...
source/libs/parser/inc/parAst.h
浏览文件 @
ba1dd2ca
...
@@ -100,7 +100,7 @@ SNode* createTempTableNode(SAstCreateContext* pCxt, SNode* pSubquery, const STok
...
@@ -100,7 +100,7 @@ SNode* createTempTableNode(SAstCreateContext* pCxt, SNode* pSubquery, const STok
SNode
*
createJoinTableNode
(
SAstCreateContext
*
pCxt
,
EJoinType
type
,
SNode
*
pLeft
,
SNode
*
pRight
,
SNode
*
pJoinCond
);
SNode
*
createJoinTableNode
(
SAstCreateContext
*
pCxt
,
EJoinType
type
,
SNode
*
pLeft
,
SNode
*
pRight
,
SNode
*
pJoinCond
);
SNode
*
createLimitNode
(
SAstCreateContext
*
pCxt
,
const
SToken
*
pLimit
,
const
SToken
*
pOffset
);
SNode
*
createLimitNode
(
SAstCreateContext
*
pCxt
,
const
SToken
*
pLimit
,
const
SToken
*
pOffset
);
SNode
*
createOrderByExprNode
(
SAstCreateContext
*
pCxt
,
SNode
*
pExpr
,
EOrder
order
,
ENullOrder
nullOrder
);
SNode
*
createOrderByExprNode
(
SAstCreateContext
*
pCxt
,
SNode
*
pExpr
,
EOrder
order
,
ENullOrder
nullOrder
);
SNode
*
createSessionWindowNode
(
SAstCreateContext
*
pCxt
,
SNode
*
pCol
,
const
SToken
*
pVal
);
SNode
*
createSessionWindowNode
(
SAstCreateContext
*
pCxt
,
SNode
*
pCol
,
SNode
*
pGap
);
SNode
*
createStateWindowNode
(
SAstCreateContext
*
pCxt
,
SNode
*
pCol
);
SNode
*
createStateWindowNode
(
SAstCreateContext
*
pCxt
,
SNode
*
pCol
);
SNode
*
createIntervalWindowNode
(
SAstCreateContext
*
pCxt
,
SNode
*
pInterval
,
SNode
*
pOffset
,
SNode
*
pSliding
,
SNode
*
pFill
);
SNode
*
createIntervalWindowNode
(
SAstCreateContext
*
pCxt
,
SNode
*
pInterval
,
SNode
*
pOffset
,
SNode
*
pSliding
,
SNode
*
pFill
);
SNode
*
createFillNode
(
SAstCreateContext
*
pCxt
,
EFillMode
mode
,
SNode
*
pValues
);
SNode
*
createFillNode
(
SAstCreateContext
*
pCxt
,
EFillMode
mode
,
SNode
*
pValues
);
...
...
source/libs/parser/inc/sql.y
浏览文件 @
ba1dd2ca
...
@@ -624,7 +624,7 @@ partition_by_clause_opt(A) ::= PARTITION BY expression_list(B).
...
@@ -624,7 +624,7 @@ partition_by_clause_opt(A) ::= PARTITION BY expression_list(B).
twindow_clause_opt(A) ::= . { A = NULL; }
twindow_clause_opt(A) ::= . { A = NULL; }
twindow_clause_opt(A) ::=
twindow_clause_opt(A) ::=
SESSION NK_LP column_reference(B) NK_COMMA
NK_INTEGER(C) NK_RP. { A = createSessionWindowNode(pCxt, releaseRawExprNode(pCxt, B), &C
); }
SESSION NK_LP column_reference(B) NK_COMMA
duration_literal(C) NK_RP. { A = createSessionWindowNode(pCxt, releaseRawExprNode(pCxt, B), releaseRawExprNode(pCxt, C)
); }
twindow_clause_opt(A) ::= STATE_WINDOW NK_LP column_reference(B) NK_RP. { A = createStateWindowNode(pCxt, releaseRawExprNode(pCxt, B)); }
twindow_clause_opt(A) ::= STATE_WINDOW NK_LP column_reference(B) NK_RP. { A = createStateWindowNode(pCxt, releaseRawExprNode(pCxt, B)); }
twindow_clause_opt(A) ::=
twindow_clause_opt(A) ::=
INTERVAL NK_LP duration_literal(B) NK_RP sliding_opt(C) fill_opt(D). { A = createIntervalWindowNode(pCxt, releaseRawExprNode(pCxt, B), NULL, C, D); }
INTERVAL NK_LP duration_literal(B) NK_RP sliding_opt(C) fill_opt(D). { A = createIntervalWindowNode(pCxt, releaseRawExprNode(pCxt, B), NULL, C, D); }
...
...
source/libs/parser/src/parAstCreater.c
浏览文件 @
ba1dd2ca
...
@@ -679,11 +679,11 @@ SNode* createOrderByExprNode(SAstCreateContext* pCxt, SNode* pExpr, EOrder order
...
@@ -679,11 +679,11 @@ SNode* createOrderByExprNode(SAstCreateContext* pCxt, SNode* pExpr, EOrder order
return
(
SNode
*
)
orderByExpr
;
return
(
SNode
*
)
orderByExpr
;
}
}
SNode
*
createSessionWindowNode
(
SAstCreateContext
*
pCxt
,
SNode
*
pCol
,
const
SToken
*
pVal
)
{
SNode
*
createSessionWindowNode
(
SAstCreateContext
*
pCxt
,
SNode
*
pCol
,
SNode
*
pGap
)
{
SSessionWindowNode
*
session
=
(
SSessionWindowNode
*
)
nodesMakeNode
(
QUERY_NODE_SESSION_WINDOW
);
SSessionWindowNode
*
session
=
(
SSessionWindowNode
*
)
nodesMakeNode
(
QUERY_NODE_SESSION_WINDOW
);
CHECK_OUT_OF_MEM
(
session
);
CHECK_OUT_OF_MEM
(
session
);
session
->
pCol
=
pCol
;
session
->
pCol
=
pCol
;
// session->gap = getInteger(pVal)
;
session
->
pGap
=
pGap
;
return
(
SNode
*
)
session
;
return
(
SNode
*
)
session
;
}
}
...
...
source/libs/parser/src/parTranslater.c
浏览文件 @
ba1dd2ca
...
@@ -824,11 +824,30 @@ static int32_t translateGroupBy(STranslateContext* pCxt, SNodeList* pGroupByList
...
@@ -824,11 +824,30 @@ static int32_t translateGroupBy(STranslateContext* pCxt, SNodeList* pGroupByList
return
translateExprList
(
pCxt
,
pGroupByList
);
return
translateExprList
(
pCxt
,
pGroupByList
);
}
}
static
int32_t
translateIntervalWindow
(
STranslateContext
*
pCxt
,
SIntervalWindowNode
*
pInterval
)
{
SValueNode
*
pIntervalVal
=
(
SValueNode
*
)
pInterval
->
pInterval
;
SValueNode
*
pIntervalOffset
=
(
SValueNode
*
)
pInterval
->
pOffset
;
SValueNode
*
pSliding
=
(
SValueNode
*
)
pInterval
->
pSliding
;
if
(
pIntervalVal
->
datum
.
i
<=
0
)
{
return
generateSyntaxErrMsg
(
&
pCxt
->
msgBuf
,
TSDB_CODE_PAR_INTERVAL_VALUE_TOO_SMALL
,
pIntervalVal
->
literal
);
}
return
TSDB_CODE_SUCCESS
;
}
static
int32_t
doTranslateWindow
(
STranslateContext
*
pCxt
,
SNode
*
pWindow
)
{
static
int32_t
doTranslateWindow
(
STranslateContext
*
pCxt
,
SNode
*
pWindow
)
{
switch
(
nodeType
(
pWindow
))
{
case
QUERY_NODE_INTERVAL_WINDOW
:
return
translateIntervalWindow
(
pCxt
,
(
SIntervalWindowNode
*
)
pWindow
);
default:
break
;
}
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
static
int32_t
translateWindow
(
STranslateContext
*
pCxt
,
SNode
*
pWindow
)
{
static
int32_t
translateWindow
(
STranslateContext
*
pCxt
,
SNode
*
pWindow
)
{
if
(
NULL
==
pWindow
)
{
return
TSDB_CODE_SUCCESS
;
}
pCxt
->
currClause
=
SQL_CLAUSE_WINDOW
;
pCxt
->
currClause
=
SQL_CLAUSE_WINDOW
;
int32_t
code
=
translateExpr
(
pCxt
,
pWindow
);
int32_t
code
=
translateExpr
(
pCxt
,
pWindow
);
if
(
TSDB_CODE_SUCCESS
==
code
)
{
if
(
TSDB_CODE_SUCCESS
==
code
)
{
...
@@ -1870,14 +1889,21 @@ static void toSchema(const SColumnDefNode* pCol, int32_t colId, SSchema* pSchema
...
@@ -1870,14 +1889,21 @@ static void toSchema(const SColumnDefNode* pCol, int32_t colId, SSchema* pSchema
}
}
static
void
destroyCreateTbReq
(
SVCreateTbReq
*
pReq
)
{
static
void
destroyCreateTbReq
(
SVCreateTbReq
*
pReq
)
{
tfree
(
pReq
->
dbFName
);
tfree
(
pReq
->
name
);
tfree
(
pReq
->
name
);
tfree
(
pReq
->
ntbCfg
.
pSchema
);
tfree
(
pReq
->
ntbCfg
.
pSchema
);
}
}
static
int32_t
buildNormalTableBatchReq
(
static
int32_t
buildNormalTableBatchReq
(
int32_t
acctId
,
const
char
*
pDbName
,
const
char
*
pTableName
,
const
char
*
pDbName
,
const
char
*
pTableName
,
const
SNodeList
*
pColumns
,
const
SVgroupInfo
*
pVgroupInfo
,
SVgroupTablesBatch
*
pBatch
)
{
const
SNodeList
*
pColumns
,
const
SVgroupInfo
*
pVgroupInfo
,
SVgroupTablesBatch
*
pBatch
)
{
char
dbFName
[
TSDB_DB_FNAME_LEN
]
=
{
0
};
SName
name
=
{
.
type
=
TSDB_DB_NAME_T
,
.
acctId
=
acctId
};
strcpy
(
name
.
dbname
,
pDbName
);
tNameGetFullDbName
(
&
name
,
dbFName
);
SVCreateTbReq
req
=
{
0
};
SVCreateTbReq
req
=
{
0
};
req
.
type
=
TD_NORMAL_TABLE
;
req
.
type
=
TD_NORMAL_TABLE
;
req
.
dbFName
=
strdup
(
dbFName
);
req
.
name
=
strdup
(
pTableName
);
req
.
name
=
strdup
(
pTableName
);
req
.
ntbCfg
.
nCols
=
LIST_LENGTH
(
pColumns
);
req
.
ntbCfg
.
nCols
=
LIST_LENGTH
(
pColumns
);
req
.
ntbCfg
.
pSchema
=
calloc
(
req
.
ntbCfg
.
nCols
,
sizeof
(
SSchema
));
req
.
ntbCfg
.
pSchema
=
calloc
(
req
.
ntbCfg
.
nCols
,
sizeof
(
SSchema
));
...
@@ -1904,7 +1930,7 @@ static int32_t buildNormalTableBatchReq(
...
@@ -1904,7 +1930,7 @@ static int32_t buildNormalTableBatchReq(
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
static
int32_t
serializeVgroupTablesBatch
(
int32_t
acctId
,
SVgroupTablesBatch
*
pTbBatch
,
SArray
*
pBufArray
)
{
static
int32_t
serializeVgroupTablesBatch
(
SVgroupTablesBatch
*
pTbBatch
,
SArray
*
pBufArray
)
{
int
tlen
=
sizeof
(
SMsgHead
)
+
tSerializeSVCreateTbBatchReq
(
NULL
,
&
(
pTbBatch
->
req
));
int
tlen
=
sizeof
(
SMsgHead
)
+
tSerializeSVCreateTbBatchReq
(
NULL
,
&
(
pTbBatch
->
req
));
void
*
buf
=
malloc
(
tlen
);
void
*
buf
=
malloc
(
tlen
);
if
(
NULL
==
buf
)
{
if
(
NULL
==
buf
)
{
...
@@ -1932,6 +1958,7 @@ static void destroyCreateTbReqBatch(SVgroupTablesBatch* pTbBatch) {
...
@@ -1932,6 +1958,7 @@ static void destroyCreateTbReqBatch(SVgroupTablesBatch* pTbBatch) {
size_t
size
=
taosArrayGetSize
(
pTbBatch
->
req
.
pArray
);
size_t
size
=
taosArrayGetSize
(
pTbBatch
->
req
.
pArray
);
for
(
int32_t
i
=
0
;
i
<
size
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
size
;
++
i
)
{
SVCreateTbReq
*
pTableReq
=
taosArrayGet
(
pTbBatch
->
req
.
pArray
,
i
);
SVCreateTbReq
*
pTableReq
=
taosArrayGet
(
pTbBatch
->
req
.
pArray
,
i
);
tfree
(
pTableReq
->
dbFName
);
tfree
(
pTableReq
->
name
);
tfree
(
pTableReq
->
name
);
if
(
pTableReq
->
type
==
TSDB_NORMAL_TABLE
)
{
if
(
pTableReq
->
type
==
TSDB_NORMAL_TABLE
)
{
...
@@ -1973,9 +2000,9 @@ static int32_t buildCreateTableDataBlock(int32_t acctId, const SCreateTableStmt*
...
@@ -1973,9 +2000,9 @@ static int32_t buildCreateTableDataBlock(int32_t acctId, const SCreateTableStmt*
}
}
SVgroupTablesBatch
tbatch
=
{
0
};
SVgroupTablesBatch
tbatch
=
{
0
};
int32_t
code
=
buildNormalTableBatchReq
(
pStmt
->
dbName
,
pStmt
->
tableName
,
pStmt
->
pCols
,
pInfo
,
&
tbatch
);
int32_t
code
=
buildNormalTableBatchReq
(
acctId
,
pStmt
->
dbName
,
pStmt
->
tableName
,
pStmt
->
pCols
,
pInfo
,
&
tbatch
);
if
(
TSDB_CODE_SUCCESS
==
code
)
{
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
serializeVgroupTablesBatch
(
acctId
,
&
tbatch
,
*
pBufArray
);
code
=
serializeVgroupTablesBatch
(
&
tbatch
,
*
pBufArray
);
}
}
destroyCreateTbReqBatch
(
&
tbatch
);
destroyCreateTbReqBatch
(
&
tbatch
);
...
@@ -2004,9 +2031,16 @@ static int32_t rewriteCreateTable(STranslateContext* pCxt, SQuery* pQuery) {
...
@@ -2004,9 +2031,16 @@ static int32_t rewriteCreateTable(STranslateContext* pCxt, SQuery* pQuery) {
return
code
;
return
code
;
}
}
static
void
addCreateTbReqIntoVgroup
(
SHashObj
*
pVgroupHashmap
,
const
char
*
pDbName
,
const
char
*
pTableName
,
SKVRow
row
,
uint64_t
suid
,
SVgroupInfo
*
pVgInfo
)
{
static
void
addCreateTbReqIntoVgroup
(
int32_t
acctId
,
SHashObj
*
pVgroupHashmap
,
const
char
*
pDbName
,
const
char
*
pTableName
,
SKVRow
row
,
uint64_t
suid
,
SVgroupInfo
*
pVgInfo
)
{
char
dbFName
[
TSDB_DB_FNAME_LEN
]
=
{
0
};
SName
name
=
{
.
type
=
TSDB_DB_NAME_T
,
.
acctId
=
acctId
};
strcpy
(
name
.
dbname
,
pDbName
);
tNameGetFullDbName
(
&
name
,
dbFName
);
struct
SVCreateTbReq
req
=
{
0
};
struct
SVCreateTbReq
req
=
{
0
};
req
.
type
=
TD_CHILD_TABLE
;
req
.
type
=
TD_CHILD_TABLE
;
req
.
dbFName
=
strdup
(
dbFName
);
req
.
name
=
strdup
(
pTableName
);
req
.
name
=
strdup
(
pTableName
);
req
.
ctbCfg
.
suid
=
suid
;
req
.
ctbCfg
.
suid
=
suid
;
req
.
ctbCfg
.
pTag
=
row
;
req
.
ctbCfg
.
pTag
=
row
;
...
@@ -2159,7 +2193,7 @@ static int32_t rewriteCreateSubTable(STranslateContext* pCxt, SCreateSubTableCla
...
@@ -2159,7 +2193,7 @@ static int32_t rewriteCreateSubTable(STranslateContext* pCxt, SCreateSubTableCla
code
=
getTableHashVgroup
(
pCxt
,
pStmt
->
dbName
,
pStmt
->
tableName
,
&
info
);
code
=
getTableHashVgroup
(
pCxt
,
pStmt
->
dbName
,
pStmt
->
tableName
,
&
info
);
}
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
if
(
TSDB_CODE_SUCCESS
==
code
)
{
addCreateTbReqIntoVgroup
(
pVgroupHashmap
,
pStmt
->
dbName
,
pStmt
->
tableName
,
row
,
pSuperTableMeta
->
uid
,
&
info
);
addCreateTbReqIntoVgroup
(
p
Cxt
->
pParseCxt
->
acctId
,
p
VgroupHashmap
,
pStmt
->
dbName
,
pStmt
->
tableName
,
row
,
pSuperTableMeta
->
uid
,
&
info
);
}
}
tfree
(
pSuperTableMeta
);
tfree
(
pSuperTableMeta
);
...
@@ -2181,7 +2215,7 @@ static SArray* serializeVgroupsTablesBatch(int32_t acctId, SHashObj* pVgroupHash
...
@@ -2181,7 +2215,7 @@ static SArray* serializeVgroupsTablesBatch(int32_t acctId, SHashObj* pVgroupHash
break
;
break
;
}
}
serializeVgroupTablesBatch
(
acctId
,
pTbBatch
,
pBufArray
);
serializeVgroupTablesBatch
(
pTbBatch
,
pBufArray
);
destroyCreateTbReqBatch
(
pTbBatch
);
destroyCreateTbReqBatch
(
pTbBatch
);
}
while
(
true
);
}
while
(
true
);
...
...
source/libs/parser/src/parUtil.c
浏览文件 @
ba1dd2ca
...
@@ -59,6 +59,8 @@ static char* getSyntaxErrFormat(int32_t errCode) {
...
@@ -59,6 +59,8 @@ static char* getSyntaxErrFormat(int32_t errCode) {
return
"Endpoint should be in the format of 'fqdn:port'"
;
return
"Endpoint should be in the format of 'fqdn:port'"
;
case
TSDB_CODE_PAR_EXPRIE_STATEMENT
:
case
TSDB_CODE_PAR_EXPRIE_STATEMENT
:
return
"This statement is no longer supported"
;
return
"This statement is no longer supported"
;
case
TSDB_CODE_PAR_INTERVAL_VALUE_TOO_SMALL
:
return
"This interval value is too small : %s"
;
case
TSDB_CODE_OUT_OF_MEMORY
:
case
TSDB_CODE_OUT_OF_MEMORY
:
return
"Out of memory"
;
return
"Out of memory"
;
default:
default:
...
@@ -71,6 +73,7 @@ int32_t generateSyntaxErrMsg(SMsgBuf* pBuf, int32_t errCode, ...) {
...
@@ -71,6 +73,7 @@ int32_t generateSyntaxErrMsg(SMsgBuf* pBuf, int32_t errCode, ...) {
va_start
(
vArgList
,
errCode
);
va_start
(
vArgList
,
errCode
);
vsnprintf
(
pBuf
->
buf
,
pBuf
->
len
,
getSyntaxErrFormat
(
errCode
),
vArgList
);
vsnprintf
(
pBuf
->
buf
,
pBuf
->
len
,
getSyntaxErrFormat
(
errCode
),
vArgList
);
va_end
(
vArgList
);
va_end
(
vArgList
);
terrno
=
errCode
;
return
errCode
;
return
errCode
;
}
}
...
...
source/libs/parser/src/sql.c
浏览文件 @
ba1dd2ca
此差异已折叠。
点击以展开。
source/libs/parser/test/mockCatalogService.cpp
浏览文件 @
ba1dd2ca
...
@@ -120,23 +120,15 @@ public:
...
@@ -120,23 +120,15 @@ public:
}
}
int32_t
catalogGetTableHashVgroup
(
const
SName
*
pTableName
,
SVgroupInfo
*
vgInfo
)
const
{
int32_t
catalogGetTableHashVgroup
(
const
SName
*
pTableName
,
SVgroupInfo
*
vgInfo
)
const
{
// todo
char
db
[
TSDB_DB_NAME_LEN
]
=
{
0
};
vgInfo
->
vgId
=
1
;
tNameGetDbName
(
pTableName
,
db
);
addEpIntoEpSet
(
&
vgInfo
->
epSet
,
"node1"
,
6030
);
return
copyTableVgroup
(
db
,
tNameGetTableName
(
pTableName
),
vgInfo
);
return
0
;
}
}
int32_t
catalogGetTableDistVgInfo
(
const
SName
*
pTableName
,
SArray
**
pVgList
)
const
{
int32_t
catalogGetTableDistVgInfo
(
const
SName
*
pTableName
,
SArray
**
vgList
)
const
{
SVgroupInfo
info
=
{
0
};
char
db
[
TSDB_DB_NAME_LEN
]
=
{
0
};
info
.
vgId
=
1
;
tNameGetDbName
(
pTableName
,
db
);
addEpIntoEpSet
(
&
info
.
epSet
,
"node1"
,
6030
);
return
copyTableVgroup
(
db
,
tNameGetTableName
(
pTableName
),
vgList
);
info
.
hashBegin
=
0
;
info
.
hashEnd
=
1
;
*
pVgList
=
taosArrayInit
(
4
,
sizeof
(
SVgroupInfo
));
taosArrayPush
(
*
pVgList
,
&
info
);
return
0
;
}
}
TableBuilder
&
createTableBuilder
(
const
std
::
string
&
db
,
const
std
::
string
&
tbname
,
int8_t
tableType
,
int32_t
numOfColumns
,
int32_t
numOfTags
)
{
TableBuilder
&
createTableBuilder
(
const
std
::
string
&
db
,
const
std
::
string
&
tbname
,
int8_t
tableType
,
int32_t
numOfColumns
,
int32_t
numOfTags
)
{
...
@@ -293,6 +285,27 @@ private:
...
@@ -293,6 +285,27 @@ private:
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
int32_t
copyTableVgroup
(
const
std
::
string
&
db
,
const
std
::
string
&
tbname
,
SVgroupInfo
*
vg
)
const
{
std
::
shared_ptr
<
MockTableMeta
>
table
=
getTableMeta
(
db
,
tbname
);
if
(
table
->
vgs
.
empty
())
{
return
TSDB_CODE_SUCCESS
;
}
memcpy
(
vg
,
&
(
table
->
vgs
[
0
]),
sizeof
(
SVgroupInfo
));
return
TSDB_CODE_SUCCESS
;
}
int32_t
copyTableVgroup
(
const
std
::
string
&
db
,
const
std
::
string
&
tbname
,
SArray
**
vgList
)
const
{
std
::
shared_ptr
<
MockTableMeta
>
table
=
getTableMeta
(
db
,
tbname
);
if
(
table
->
vgs
.
empty
())
{
return
TSDB_CODE_SUCCESS
;
}
*
vgList
=
taosArrayInit
(
table
->
vgs
.
size
(),
sizeof
(
SVgroupInfo
));
for
(
const
SVgroupInfo
&
vg
:
table
->
vgs
)
{
taosArrayPush
(
*
vgList
,
&
vg
);
}
return
TSDB_CODE_SUCCESS
;
}
uint64_t
id_
;
uint64_t
id_
;
std
::
unique_ptr
<
TableBuilder
>
builder_
;
std
::
unique_ptr
<
TableBuilder
>
builder_
;
DbMetaCache
meta_
;
DbMetaCache
meta_
;
...
...
source/libs/parser/test/parserAstTest.cpp
浏览文件 @
ba1dd2ca
...
@@ -44,6 +44,9 @@ protected:
...
@@ -44,6 +44,9 @@ protected:
query_
=
nullptr
;
query_
=
nullptr
;
bool
res
=
runImpl
(
parseCode
,
translateCode
);
bool
res
=
runImpl
(
parseCode
,
translateCode
);
qDestroyQuery
(
query_
);
qDestroyQuery
(
query_
);
if
(
!
res
)
{
dump
();
}
return
res
;
return
res
;
}
}
...
@@ -53,24 +56,38 @@ private:
...
@@ -53,24 +56,38 @@ private:
bool
runImpl
(
int32_t
parseCode
,
int32_t
translateCode
)
{
bool
runImpl
(
int32_t
parseCode
,
int32_t
translateCode
)
{
int32_t
code
=
doParse
(
&
cxt_
,
&
query_
);
int32_t
code
=
doParse
(
&
cxt_
,
&
query_
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
cout
<<
"sql:["
<<
cxt_
.
pSql
<<
"] parser code:"
<<
tstrerror
(
code
)
<<
", msg:"
<<
errMagBuf_
<<
endl
;
parseErrStr_
=
string
(
"code:"
)
+
tstrerror
(
code
)
+
string
(
", msg:"
)
+
errMagBuf_
;
return
(
TSDB_CODE_SUCCESS
!
=
parseCode
);
return
(
terrno
=
=
parseCode
);
}
}
if
(
TSDB_CODE_SUCCESS
!=
parseCode
)
{
if
(
TSDB_CODE_SUCCESS
!=
parseCode
)
{
return
false
;
return
false
;
}
}
string
parserStr
=
toString
(
query_
->
pRoot
);
parsedAstStr_
=
toString
(
query_
->
pRoot
);
code
=
doTranslate
(
&
cxt_
,
query_
);
code
=
doTranslate
(
&
cxt_
,
query_
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
cout
<<
"sql:["
<<
cxt_
.
pSql
<<
"] translate code:"
<<
code
<<
", "
<<
translateCode
<<
", msg:"
<<
errMagBuf_
<<
endl
;
translateErrStr_
=
string
(
"code:"
)
+
tstrerror
(
code
)
+
string
(
", msg:"
)
+
errMagBuf_
;
return
(
code
==
translateCode
);
return
(
terrno
==
translateCode
);
}
translatedAstStr_
=
toString
(
query_
->
pRoot
);
return
(
TSDB_CODE_SUCCESS
==
translateCode
);
}
}
void
dump
()
{
cout
<<
"input sql : ["
<<
cxt_
.
pSql
<<
"]"
<<
endl
;
cout
<<
"input sql : ["
<<
cxt_
.
pSql
<<
"]"
<<
endl
;
cout
<<
"parser output: "
<<
endl
;
if
(
!
parseErrStr_
.
empty
())
{
cout
<<
parserStr
<<
endl
;
cout
<<
"parse error: "
<<
parseErrStr_
<<
endl
;
}
if
(
!
parsedAstStr_
.
empty
())
{
cout
<<
"parse output: "
<<
endl
;
cout
<<
parsedAstStr_
<<
endl
;
}
if
(
!
translateErrStr_
.
empty
())
{
cout
<<
"translate error: "
<<
translateErrStr_
<<
endl
;
}
if
(
!
translatedAstStr_
.
empty
())
{
cout
<<
"translate output: "
<<
endl
;
cout
<<
"translate output: "
<<
endl
;
cout
<<
toString
(
query_
->
pRoot
)
<<
endl
;
cout
<<
translatedAstStr_
<<
endl
;
return
(
TSDB_CODE_SUCCESS
==
translateCode
);
}
}
}
string
toString
(
const
SNode
*
pRoot
,
bool
format
=
false
)
{
string
toString
(
const
SNode
*
pRoot
,
bool
format
=
false
)
{
...
@@ -91,6 +108,10 @@ private:
...
@@ -91,6 +108,10 @@ private:
memset
(
errMagBuf_
,
0
,
max_err_len
);
memset
(
errMagBuf_
,
0
,
max_err_len
);
cxt_
.
pMsg
=
errMagBuf_
;
cxt_
.
pMsg
=
errMagBuf_
;
cxt_
.
msgLen
=
max_err_len
;
cxt_
.
msgLen
=
max_err_len
;
parseErrStr_
.
clear
();
parsedAstStr_
.
clear
();
translateErrStr_
.
clear
();
translatedAstStr_
.
clear
();
}
}
string
acctId_
;
string
acctId_
;
...
@@ -99,8 +120,50 @@ private:
...
@@ -99,8 +120,50 @@ private:
string
sqlBuf_
;
string
sqlBuf_
;
SParseContext
cxt_
;
SParseContext
cxt_
;
SQuery
*
query_
;
SQuery
*
query_
;
string
parseErrStr_
;
string
parsedAstStr_
;
string
translateErrStr_
;
string
translatedAstStr_
;
};
};
TEST_F
(
ParserTest
,
createAccount
)
{
setDatabase
(
"root"
,
"test"
);
bind
(
"create account ac_wxy pass '123456'"
);
ASSERT_TRUE
(
run
(
TSDB_CODE_PAR_EXPRIE_STATEMENT
));
}
TEST_F
(
ParserTest
,
alterAccount
)
{
setDatabase
(
"root"
,
"test"
);
bind
(
"alter account ac_wxy pass '123456'"
);
ASSERT_TRUE
(
run
(
TSDB_CODE_PAR_EXPRIE_STATEMENT
));
}
TEST_F
(
ParserTest
,
createUser
)
{
setDatabase
(
"root"
,
"test"
);
bind
(
"create user wxy pass '123456'"
);
ASSERT_TRUE
(
run
());
}
TEST_F
(
ParserTest
,
alterUser
)
{
setDatabase
(
"root"
,
"test"
);
bind
(
"alter user wxy pass '123456'"
);
ASSERT_TRUE
(
run
());
bind
(
"alter user wxy privilege 'write'"
);
ASSERT_TRUE
(
run
());
}
TEST_F
(
ParserTest
,
dropUser
)
{
setDatabase
(
"root"
,
"test"
);
bind
(
"drop user wxy"
);
ASSERT_TRUE
(
run
());
}
TEST_F
(
ParserTest
,
selectSimple
)
{
TEST_F
(
ParserTest
,
selectSimple
)
{
setDatabase
(
"root"
,
"test"
);
setDatabase
(
"root"
,
"test"
);
...
@@ -295,12 +358,6 @@ TEST_F(ParserTest, selectSemanticError) {
...
@@ -295,12 +358,6 @@ TEST_F(ParserTest, selectSemanticError) {
ASSERT_TRUE
(
run
(
TSDB_CODE_SUCCESS
,
TSDB_CODE_PAR_NOT_SELECTED_EXPRESSION
));
ASSERT_TRUE
(
run
(
TSDB_CODE_SUCCESS
,
TSDB_CODE_PAR_NOT_SELECTED_EXPRESSION
));
}
}
TEST_F
(
ParserTest
,
createUser
)
{
setDatabase
(
"root"
,
"test"
);
bind
(
"create user wxy pass '123456'"
);
ASSERT_TRUE
(
run
());
}
TEST_F
(
ParserTest
,
showUsers
)
{
TEST_F
(
ParserTest
,
showUsers
)
{
setDatabase
(
"root"
,
"test"
);
setDatabase
(
"root"
,
"test"
);
...
@@ -309,12 +366,7 @@ TEST_F(ParserTest, showUsers) {
...
@@ -309,12 +366,7 @@ TEST_F(ParserTest, showUsers) {
ASSERT_TRUE
(
run
());
ASSERT_TRUE
(
run
());
}
}
TEST_F
(
ParserTest
,
alterAccount
)
{
setDatabase
(
"root"
,
"test"
);
bind
(
"alter account ac_wxy pass '123456'"
);
ASSERT_TRUE
(
run
(
TSDB_CODE_PAR_EXPRIE_STATEMENT
));
}
TEST_F
(
ParserTest
,
createDnode
)
{
TEST_F
(
ParserTest
,
createDnode
)
{
setDatabase
(
"root"
,
"test"
);
setDatabase
(
"root"
,
"test"
);
...
...
source/libs/planner/inc/planInt.h
浏览文件 @
ba1dd2ca
...
@@ -56,9 +56,10 @@ extern "C" {
...
@@ -56,9 +56,10 @@ extern "C" {
#define planTrace(param, ...) qTrace("PLAN: " param, __VA_ARGS__)
#define planTrace(param, ...) qTrace("PLAN: " param, __VA_ARGS__)
int32_t
createLogicPlan
(
SPlanContext
*
pCxt
,
SLogicNode
**
pLogicNode
);
int32_t
createLogicPlan
(
SPlanContext
*
pCxt
,
SLogicNode
**
pLogicNode
);
int32_t
optimize
(
SPlanContext
*
pCxt
,
SLogicNode
*
pLogicNode
);
int32_t
optimizeLogicPlan
(
SPlanContext
*
pCxt
,
SLogicNode
*
pLogicNode
);
int32_t
applySplitRule
(
SSubLogicPlan
*
pSubplan
);
int32_t
splitLogicPlan
(
SPlanContext
*
pCxt
,
SLogicNode
*
pLogicNode
,
SLogicSubplan
**
pLogicSubplan
);
int32_t
createPhysiPlan
(
SPlanContext
*
pCxt
,
SLogicNode
*
pLogicNode
,
SQueryPlan
**
pPlan
,
SArray
*
pExecNodeList
);
int32_t
scaleOutLogicPlan
(
SPlanContext
*
pCxt
,
SLogicSubplan
*
pLogicSubplan
,
SQueryLogicPlan
**
pLogicPlan
);
int32_t
createPhysiPlan
(
SPlanContext
*
pCxt
,
SQueryLogicPlan
*
pLogicPlan
,
SQueryPlan
**
pPlan
,
SArray
*
pExecNodeList
);
#ifdef __cplusplus
#ifdef __cplusplus
}
}
...
...
source/libs/planner/src/planLogicCreater.c
浏览文件 @
ba1dd2ca
...
@@ -411,6 +411,38 @@ static int32_t createAggLogicNode(SLogicPlanContext* pCxt, SSelectStmt* pSelect,
...
@@ -411,6 +411,38 @@ static int32_t createAggLogicNode(SLogicPlanContext* pCxt, SSelectStmt* pSelect,
return
code
;
return
code
;
}
}
static
int32_t
createWindowLogicNodeFinalize
(
SLogicPlanContext
*
pCxt
,
SSelectStmt
*
pSelect
,
SWindowLogicNode
*
pWindow
,
SLogicNode
**
pLogicNode
)
{
int32_t
code
=
nodesCollectFuncs
(
pSelect
,
fmIsAggFunc
,
&
pWindow
->
pFuncs
);
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
rewriteExpr
(
pWindow
->
pFuncs
,
pSelect
,
SQL_CLAUSE_WINDOW
);
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
createColumnByRewriteExps
(
pCxt
,
pWindow
->
pFuncs
,
&
pWindow
->
node
.
pTargets
);
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
*
pLogicNode
=
(
SLogicNode
*
)
pWindow
;
}
else
{
nodesDestroyNode
(
pWindow
);
}
return
code
;
}
static
int32_t
createWindowLogicNodeBySession
(
SLogicPlanContext
*
pCxt
,
SSessionWindowNode
*
pSession
,
SSelectStmt
*
pSelect
,
SLogicNode
**
pLogicNode
)
{
SWindowLogicNode
*
pWindow
=
nodesMakeNode
(
QUERY_NODE_LOGIC_PLAN_WINDOW
);
if
(
NULL
==
pWindow
)
{
return
TSDB_CODE_OUT_OF_MEMORY
;
}
pWindow
->
winType
=
WINDOW_TYPE_SESSION
;
pWindow
->
sessionGap
=
((
SValueNode
*
)
pSession
->
pGap
)
->
datum
.
i
;
return
createWindowLogicNodeFinalize
(
pCxt
,
pSelect
,
pWindow
,
pLogicNode
);
}
static
int32_t
createWindowLogicNodeByInterval
(
SLogicPlanContext
*
pCxt
,
SIntervalWindowNode
*
pInterval
,
SSelectStmt
*
pSelect
,
SLogicNode
**
pLogicNode
)
{
static
int32_t
createWindowLogicNodeByInterval
(
SLogicPlanContext
*
pCxt
,
SIntervalWindowNode
*
pInterval
,
SSelectStmt
*
pSelect
,
SLogicNode
**
pLogicNode
)
{
SWindowLogicNode
*
pWindow
=
nodesMakeNode
(
QUERY_NODE_LOGIC_PLAN_WINDOW
);
SWindowLogicNode
*
pWindow
=
nodesMakeNode
(
QUERY_NODE_LOGIC_PLAN_WINDOW
);
if
(
NULL
==
pWindow
)
{
if
(
NULL
==
pWindow
)
{
...
@@ -424,34 +456,15 @@ static int32_t createWindowLogicNodeByInterval(SLogicPlanContext* pCxt, SInterva
...
@@ -424,34 +456,15 @@ static int32_t createWindowLogicNodeByInterval(SLogicPlanContext* pCxt, SInterva
pWindow
->
sliding
=
(
NULL
!=
pInterval
->
pSliding
?
((
SValueNode
*
)
pInterval
->
pSliding
)
->
datum
.
i
:
pWindow
->
interval
);
pWindow
->
sliding
=
(
NULL
!=
pInterval
->
pSliding
?
((
SValueNode
*
)
pInterval
->
pSliding
)
->
datum
.
i
:
pWindow
->
interval
);
pWindow
->
slidingUnit
=
(
NULL
!=
pInterval
->
pSliding
?
((
SValueNode
*
)
pInterval
->
pSliding
)
->
unit
:
pWindow
->
intervalUnit
);
pWindow
->
slidingUnit
=
(
NULL
!=
pInterval
->
pSliding
?
((
SValueNode
*
)
pInterval
->
pSliding
)
->
unit
:
pWindow
->
intervalUnit
);
int32_t
code
=
TSDB_CODE_SUCCESS
;
if
(
NULL
!=
pInterval
->
pFill
)
{
if
(
NULL
!=
pInterval
->
pFill
)
{
pWindow
->
pFill
=
nodesCloneNode
(
pInterval
->
pFill
);
pWindow
->
pFill
=
nodesCloneNode
(
pInterval
->
pFill
);
if
(
NULL
==
pWindow
->
pFill
)
{
if
(
NULL
==
pWindow
->
pFill
)
{
code
=
TSDB_CODE_OUT_OF_MEMORY
;
}
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
nodesCollectFuncs
(
pSelect
,
fmIsAggFunc
,
&
pWindow
->
pFuncs
);
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
rewriteExpr
(
pWindow
->
pFuncs
,
pSelect
,
SQL_CLAUSE_WINDOW
);
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
createColumnByRewriteExps
(
pCxt
,
pWindow
->
pFuncs
,
&
pWindow
->
node
.
pTargets
);
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
*
pLogicNode
=
(
SLogicNode
*
)
pWindow
;
}
else
{
nodesDestroyNode
(
pWindow
);
nodesDestroyNode
(
pWindow
);
return
TSDB_CODE_OUT_OF_MEMORY
;
}
}
}
return
c
ode
;
return
c
reateWindowLogicNodeFinalize
(
pCxt
,
pSelect
,
pWindow
,
pLogicNode
)
;
}
}
static
int32_t
createWindowLogicNode
(
SLogicPlanContext
*
pCxt
,
SSelectStmt
*
pSelect
,
SLogicNode
**
pLogicNode
)
{
static
int32_t
createWindowLogicNode
(
SLogicPlanContext
*
pCxt
,
SSelectStmt
*
pSelect
,
SLogicNode
**
pLogicNode
)
{
...
@@ -460,6 +473,8 @@ static int32_t createWindowLogicNode(SLogicPlanContext* pCxt, SSelectStmt* pSele
...
@@ -460,6 +473,8 @@ static int32_t createWindowLogicNode(SLogicPlanContext* pCxt, SSelectStmt* pSele
}
}
switch
(
nodeType
(
pSelect
->
pWindow
))
{
switch
(
nodeType
(
pSelect
->
pWindow
))
{
case
QUERY_NODE_SESSION_WINDOW
:
return
createWindowLogicNodeBySession
(
pCxt
,
(
SSessionWindowNode
*
)
pSelect
->
pWindow
,
pSelect
,
pLogicNode
);
case
QUERY_NODE_INTERVAL_WINDOW
:
case
QUERY_NODE_INTERVAL_WINDOW
:
return
createWindowLogicNodeByInterval
(
pCxt
,
(
SIntervalWindowNode
*
)
pSelect
->
pWindow
,
pSelect
,
pLogicNode
);
return
createWindowLogicNodeByInterval
(
pCxt
,
(
SIntervalWindowNode
*
)
pSelect
->
pWindow
,
pSelect
,
pLogicNode
);
default:
default:
...
...
source/libs/planner/src/planOptimizer.c
0 → 100644
浏览文件 @
ba1dd2ca
/*
* 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 "planInt.h"
int32_t
optimizeLogicPlan
(
SPlanContext
*
pCxt
,
SLogicNode
*
pLogicNode
)
{
return
TSDB_CODE_SUCCESS
;
}
source/libs/planner/src/planPhysiCreater.c
浏览文件 @
ba1dd2ca
此差异已折叠。
点击以展开。
source/libs/planner/src/planScaleOut.c
0 → 100644
浏览文件 @
ba1dd2ca
/*
* 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 "planInt.h"
typedef
struct
SScaleOutContext
{
SPlanContext
*
pPlanCxt
;
int32_t
subplanId
;
}
SScaleOutContext
;
static
SLogicSubplan
*
singleCloneSubLogicPlan
(
SScaleOutContext
*
pCxt
,
SLogicSubplan
*
pSrc
,
int32_t
level
)
{
SLogicSubplan
*
pDst
=
nodesMakeNode
(
QUERY_NODE_LOGIC_SUBPLAN
);
if
(
NULL
==
pDst
)
{
return
NULL
;
}
pDst
->
pNode
=
nodesCloneNode
(
pSrc
->
pNode
);
if
(
NULL
==
pDst
->
pNode
)
{
nodesDestroyNode
(
pDst
);
return
NULL
;
}
pDst
->
subplanType
=
pSrc
->
subplanType
;
pDst
->
level
=
level
;
pDst
->
id
.
queryId
=
pSrc
->
id
.
queryId
;
pDst
->
id
.
groupId
=
pSrc
->
id
.
groupId
;
pDst
->
id
.
subplanId
=
pCxt
->
subplanId
++
;
return
pDst
;
}
static
int32_t
scaleOutForModify
(
SScaleOutContext
*
pCxt
,
SLogicSubplan
*
pSubplan
,
int32_t
level
,
SNodeList
*
pGroup
)
{
SVnodeModifLogicNode
*
pNode
=
(
SVnodeModifLogicNode
*
)
pSubplan
->
pNode
;
size_t
numOfVgroups
=
taosArrayGetSize
(
pNode
->
pDataBlocks
);
for
(
int32_t
i
=
0
;
i
<
numOfVgroups
;
++
i
)
{
SLogicSubplan
*
pNewSubplan
=
singleCloneSubLogicPlan
(
pCxt
,
pSubplan
,
level
);
if
(
NULL
==
pNewSubplan
)
{
return
TSDB_CODE_OUT_OF_MEMORY
;
}
((
SVnodeModifLogicNode
*
)
pNewSubplan
->
pNode
)
->
pVgDataBlocks
=
(
SVgDataBlocks
*
)
taosArrayGetP
(
pNode
->
pDataBlocks
,
i
);
if
(
TSDB_CODE_SUCCESS
!=
nodesListStrictAppend
(
pGroup
,
pNewSubplan
))
{
return
TSDB_CODE_OUT_OF_MEMORY
;
}
}
return
TSDB_CODE_SUCCESS
;
}
static
int32_t
scaleOutForMerge
(
SScaleOutContext
*
pCxt
,
SLogicSubplan
*
pSubplan
,
int32_t
level
,
SNodeList
*
pGroup
)
{
return
nodesListStrictAppend
(
pGroup
,
singleCloneSubLogicPlan
(
pCxt
,
pSubplan
,
level
));
}
static
int32_t
doSetScanVgroup
(
SLogicNode
*
pNode
,
const
SVgroupInfo
*
pVgroup
,
bool
*
pFound
)
{
if
(
QUERY_NODE_LOGIC_PLAN_SCAN
==
nodeType
(
pNode
))
{
SScanLogicNode
*
pScan
=
(
SScanLogicNode
*
)
pNode
;
pScan
->
pVgroupList
=
calloc
(
1
,
sizeof
(
SVgroupsInfo
)
+
sizeof
(
SVgroupInfo
));
if
(
NULL
==
pScan
->
pVgroupList
)
{
return
TSDB_CODE_OUT_OF_MEMORY
;
}
memcpy
(
pScan
->
pVgroupList
->
vgroups
,
pVgroup
,
sizeof
(
SVgroupInfo
));
*
pFound
=
true
;
return
TSDB_CODE_SUCCESS
;
}
SNode
*
pChild
=
NULL
;
FOREACH
(
pChild
,
pNode
->
pChildren
)
{
int32_t
code
=
doSetScanVgroup
((
SLogicNode
*
)
pChild
,
pVgroup
,
pFound
);
if
(
TSDB_CODE_SUCCESS
!=
code
||
*
pFound
)
{
return
code
;
}
}
return
TSDB_CODE_SUCCESS
;
}
static
int32_t
setScanVgroup
(
SLogicNode
*
pNode
,
const
SVgroupInfo
*
pVgroup
)
{
bool
found
=
false
;
return
doSetScanVgroup
(
pNode
,
pVgroup
,
&
found
);
}
static
int32_t
scaleOutForScan
(
SScaleOutContext
*
pCxt
,
SLogicSubplan
*
pSubplan
,
int32_t
level
,
SNodeList
*
pGroup
)
{
if
(
pSubplan
->
pVgroupList
&&
!
pCxt
->
pPlanCxt
->
streamQuery
)
{
int32_t
code
=
TSDB_CODE_SUCCESS
;
for
(
int32_t
i
=
0
;
i
<
pSubplan
->
pVgroupList
->
numOfVgroups
;
++
i
)
{
SLogicSubplan
*
pNewSubplan
=
singleCloneSubLogicPlan
(
pCxt
,
pSubplan
,
level
);
if
(
NULL
==
pNewSubplan
)
{
return
TSDB_CODE_OUT_OF_MEMORY
;
}
code
=
setScanVgroup
(
pNewSubplan
->
pNode
,
pSubplan
->
pVgroupList
->
vgroups
+
i
);
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
nodesListStrictAppend
(
pGroup
,
pNewSubplan
);
}
if
(
TSDB_CODE_SUCCESS
!=
code
)
{
break
;
}
}
return
code
;
}
else
{
return
scaleOutForMerge
(
pCxt
,
pSubplan
,
level
,
pGroup
);
}
}
static
int32_t
pushHierarchicalPlan
(
SNodeList
*
pParentsGroup
,
SNodeList
*
pCurrentGroup
)
{
int32_t
code
=
TSDB_CODE_SUCCESS
;
bool
topLevel
=
(
0
==
LIST_LENGTH
(
pParentsGroup
));
SNode
*
pChild
=
NULL
;
FOREACH
(
pChild
,
pCurrentGroup
)
{
if
(
topLevel
)
{
code
=
nodesListAppend
(
pParentsGroup
,
pChild
);
}
else
{
SNode
*
pParent
=
NULL
;
FOREACH
(
pParent
,
pParentsGroup
)
{
code
=
nodesListMakeAppend
(
&
(((
SLogicSubplan
*
)
pParent
)
->
pChildren
),
pChild
);
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
nodesListMakeAppend
(
&
(((
SLogicSubplan
*
)
pChild
)
->
pParents
),
pParent
);
}
}
}
if
(
TSDB_CODE_SUCCESS
!=
code
)
{
break
;
}
}
return
code
;
}
static
int32_t
doScaleOut
(
SScaleOutContext
*
pCxt
,
SLogicSubplan
*
pSubplan
,
int32_t
*
pLevel
,
SNodeList
*
pParentsGroup
)
{
SNodeList
*
pCurrentGroup
=
nodesMakeList
();
if
(
NULL
==
pCurrentGroup
)
{
return
TSDB_CODE_OUT_OF_MEMORY
;
}
int32_t
code
=
TSDB_CODE_SUCCESS
;
switch
(
pSubplan
->
subplanType
)
{
case
SUBPLAN_TYPE_MERGE
:
code
=
scaleOutForMerge
(
pCxt
,
pSubplan
,
*
pLevel
,
pCurrentGroup
);
break
;
case
SUBPLAN_TYPE_SCAN
:
code
=
scaleOutForScan
(
pCxt
,
pSubplan
,
*
pLevel
,
pCurrentGroup
);
break
;
case
SUBPLAN_TYPE_MODIFY
:
code
=
scaleOutForModify
(
pCxt
,
pSubplan
,
*
pLevel
,
pCurrentGroup
);
break
;
default:
break
;
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
pushHierarchicalPlan
(
pParentsGroup
,
pCurrentGroup
);
++
(
*
pLevel
);
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
SNode
*
pChild
;
FOREACH
(
pChild
,
pSubplan
->
pChildren
)
{
code
=
doScaleOut
(
pCxt
,
(
SLogicSubplan
*
)
pChild
,
pLevel
,
pCurrentGroup
);
if
(
TSDB_CODE_SUCCESS
!=
code
)
{
break
;
}
}
}
if
(
TSDB_CODE_SUCCESS
!=
code
)
{
nodesDestroyList
(
pCurrentGroup
);
}
return
code
;
}
static
SQueryLogicPlan
*
makeQueryLogicPlan
()
{
SQueryLogicPlan
*
pLogicPlan
=
(
SQueryLogicPlan
*
)
nodesMakeNode
(
QUERY_NODE_LOGIC_PLAN
);
if
(
NULL
==
pLogicPlan
)
{
return
NULL
;
}
pLogicPlan
->
pTopSubplans
=
nodesMakeList
();
if
(
NULL
==
pLogicPlan
->
pTopSubplans
)
{
nodesDestroyNode
(
pLogicPlan
);
return
NULL
;
}
return
pLogicPlan
;
}
int32_t
scaleOutLogicPlan
(
SPlanContext
*
pCxt
,
SLogicSubplan
*
pLogicSubplan
,
SQueryLogicPlan
**
pLogicPlan
)
{
SQueryLogicPlan
*
pPlan
=
makeQueryLogicPlan
();
if
(
NULL
==
pPlan
)
{
return
TSDB_CODE_OUT_OF_MEMORY
;
}
SScaleOutContext
cxt
=
{
.
pPlanCxt
=
pCxt
,
.
subplanId
=
1
};
int32_t
code
=
doScaleOut
(
&
cxt
,
pLogicSubplan
,
&
(
pPlan
->
totalLevel
),
pPlan
->
pTopSubplans
);
if
(
TSDB_CODE_SUCCESS
==
code
)
{
*
pLogicPlan
=
pPlan
;
}
else
{
nodesDestroyNode
(
pPlan
);
}
return
code
;
}
source/libs/planner/src/planSpliter.c
浏览文件 @
ba1dd2ca
...
@@ -29,7 +29,7 @@ typedef struct SSplitContext {
...
@@ -29,7 +29,7 @@ typedef struct SSplitContext {
void
*
pInfo
;
void
*
pInfo
;
}
SSplitContext
;
}
SSplitContext
;
typedef
int32_t
(
*
FMatch
)(
SSplitContext
*
pCxt
,
S
SubLogicP
lan
*
pSubplan
);
typedef
int32_t
(
*
FMatch
)(
SSplitContext
*
pCxt
,
S
LogicSubp
lan
*
pSubplan
);
typedef
int32_t
(
*
FSplit
)(
SSplitContext
*
pCxt
);
typedef
int32_t
(
*
FSplit
)(
SSplitContext
*
pCxt
);
typedef
struct
SSplitRule
{
typedef
struct
SSplitRule
{
...
@@ -40,7 +40,7 @@ typedef struct SSplitRule {
...
@@ -40,7 +40,7 @@ typedef struct SSplitRule {
typedef
struct
SStsInfo
{
typedef
struct
SStsInfo
{
SScanLogicNode
*
pScan
;
SScanLogicNode
*
pScan
;
S
SubLogicP
lan
*
pSubplan
;
S
LogicSubp
lan
*
pSubplan
;
}
SStsInfo
;
}
SStsInfo
;
static
SLogicNode
*
stsMatchByNode
(
SLogicNode
*
pNode
)
{
static
SLogicNode
*
stsMatchByNode
(
SLogicNode
*
pNode
)
{
...
@@ -58,7 +58,7 @@ static SLogicNode* stsMatchByNode(SLogicNode* pNode) {
...
@@ -58,7 +58,7 @@ static SLogicNode* stsMatchByNode(SLogicNode* pNode) {
return
NULL
;
return
NULL
;
}
}
static
int32_t
stsMatch
(
SSplitContext
*
pCxt
,
S
SubLogicP
lan
*
pSubplan
)
{
static
int32_t
stsMatch
(
SSplitContext
*
pCxt
,
S
LogicSubp
lan
*
pSubplan
)
{
if
(
SPLIT_FLAG_TEST_MASK
(
pSubplan
->
splitFlag
,
SPLIT_FLAG_STS
))
{
if
(
SPLIT_FLAG_TEST_MASK
(
pSubplan
->
splitFlag
,
SPLIT_FLAG_STS
))
{
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
...
@@ -74,7 +74,7 @@ static int32_t stsMatch(SSplitContext* pCxt, SSubLogicPlan* pSubplan) {
...
@@ -74,7 +74,7 @@ static int32_t stsMatch(SSplitContext* pCxt, SSubLogicPlan* pSubplan) {
}
}
SNode
*
pChild
;
SNode
*
pChild
;
FOREACH
(
pChild
,
pSubplan
->
pChildren
)
{
FOREACH
(
pChild
,
pSubplan
->
pChildren
)
{
int32_t
code
=
stsMatch
(
pCxt
,
(
S
SubLogicP
lan
*
)
pChild
);
int32_t
code
=
stsMatch
(
pCxt
,
(
S
LogicSubp
lan
*
)
pChild
);
if
(
TSDB_CODE_SUCCESS
!=
code
||
pCxt
->
match
)
{
if
(
TSDB_CODE_SUCCESS
!=
code
||
pCxt
->
match
)
{
return
code
;
return
code
;
}
}
...
@@ -82,8 +82,8 @@ static int32_t stsMatch(SSplitContext* pCxt, SSubLogicPlan* pSubplan) {
...
@@ -82,8 +82,8 @@ static int32_t stsMatch(SSplitContext* pCxt, SSubLogicPlan* pSubplan) {
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
static
S
SubLogicP
lan
*
stsCreateScanSubplan
(
SSplitContext
*
pCxt
,
SScanLogicNode
*
pScan
)
{
static
S
LogicSubp
lan
*
stsCreateScanSubplan
(
SSplitContext
*
pCxt
,
SScanLogicNode
*
pScan
)
{
S
SubLogicP
lan
*
pSubplan
=
nodesMakeNode
(
QUERY_NODE_LOGIC_SUBPLAN
);
S
LogicSubp
lan
*
pSubplan
=
nodesMakeNode
(
QUERY_NODE_LOGIC_SUBPLAN
);
if
(
NULL
==
pSubplan
)
{
if
(
NULL
==
pSubplan
)
{
return
NULL
;
return
NULL
;
}
}
...
@@ -95,7 +95,7 @@ static SSubLogicPlan* stsCreateScanSubplan(SSplitContext* pCxt, SScanLogicNode*
...
@@ -95,7 +95,7 @@ static SSubLogicPlan* stsCreateScanSubplan(SSplitContext* pCxt, SScanLogicNode*
return
pSubplan
;
return
pSubplan
;
}
}
static
int32_t
stsCreateExchangeNode
(
SSplitContext
*
pCxt
,
S
SubLogicP
lan
*
pSubplan
,
SScanLogicNode
*
pScan
)
{
static
int32_t
stsCreateExchangeNode
(
SSplitContext
*
pCxt
,
S
LogicSubp
lan
*
pSubplan
,
SScanLogicNode
*
pScan
)
{
SExchangeLogicNode
*
pExchange
=
nodesMakeNode
(
QUERY_NODE_LOGIC_PLAN_EXCHANGE
);
SExchangeLogicNode
*
pExchange
=
nodesMakeNode
(
QUERY_NODE_LOGIC_PLAN_EXCHANGE
);
if
(
NULL
==
pExchange
)
{
if
(
NULL
==
pExchange
)
{
return
TSDB_CODE_OUT_OF_MEMORY
;
return
TSDB_CODE_OUT_OF_MEMORY
;
...
@@ -106,6 +106,8 @@ static int32_t stsCreateExchangeNode(SSplitContext* pCxt, SSubLogicPlan* pSubpla
...
@@ -106,6 +106,8 @@ static int32_t stsCreateExchangeNode(SSplitContext* pCxt, SSubLogicPlan* pSubpla
return
TSDB_CODE_OUT_OF_MEMORY
;
return
TSDB_CODE_OUT_OF_MEMORY
;
}
}
pSubplan
->
subplanType
=
SUBPLAN_TYPE_MERGE
;
if
(
NULL
==
pScan
->
node
.
pParent
)
{
if
(
NULL
==
pScan
->
node
.
pParent
)
{
pSubplan
->
pNode
=
(
SLogicNode
*
)
pExchange
;
pSubplan
->
pNode
=
(
SLogicNode
*
)
pExchange
;
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
...
@@ -145,7 +147,7 @@ static const SSplitRule splitRuleSet[] = {
...
@@ -145,7 +147,7 @@ static const SSplitRule splitRuleSet[] = {
static
const
int32_t
splitRuleNum
=
(
sizeof
(
splitRuleSet
)
/
sizeof
(
SSplitRule
));
static
const
int32_t
splitRuleNum
=
(
sizeof
(
splitRuleSet
)
/
sizeof
(
SSplitRule
));
int32_t
applySplitRule
(
SSubLogicP
lan
*
pSubplan
)
{
static
int32_t
applySplitRule
(
SLogicSubp
lan
*
pSubplan
)
{
SSplitContext
cxt
=
{
.
errCode
=
TSDB_CODE_SUCCESS
,
.
groupId
=
pSubplan
->
id
.
groupId
+
1
,
.
match
=
false
,
.
pInfo
=
NULL
};
SSplitContext
cxt
=
{
.
errCode
=
TSDB_CODE_SUCCESS
,
.
groupId
=
pSubplan
->
id
.
groupId
+
1
,
.
match
=
false
,
.
pInfo
=
NULL
};
bool
split
=
false
;
bool
split
=
false
;
do
{
do
{
...
@@ -164,3 +166,45 @@ int32_t applySplitRule(SSubLogicPlan* pSubplan) {
...
@@ -164,3 +166,45 @@ int32_t applySplitRule(SSubLogicPlan* pSubplan) {
}
while
(
split
);
}
while
(
split
);
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
static
void
doSetLogicNodeParent
(
SLogicNode
*
pNode
,
SLogicNode
*
pParent
)
{
pNode
->
pParent
=
pParent
;
SNode
*
pChild
;
FOREACH
(
pChild
,
pNode
->
pChildren
)
{
doSetLogicNodeParent
((
SLogicNode
*
)
pChild
,
pNode
);
}
}
static
void
setLogicNodeParent
(
SLogicNode
*
pNode
)
{
doSetLogicNodeParent
(
pNode
,
NULL
);
}
int32_t
splitLogicPlan
(
SPlanContext
*
pCxt
,
SLogicNode
*
pLogicNode
,
SLogicSubplan
**
pLogicSubplan
)
{
SLogicSubplan
*
pSubplan
=
(
SLogicSubplan
*
)
nodesMakeNode
(
QUERY_NODE_LOGIC_SUBPLAN
);
if
(
NULL
==
pSubplan
)
{
return
TSDB_CODE_OUT_OF_MEMORY
;
}
pSubplan
->
pNode
=
nodesCloneNode
(
pLogicNode
);
if
(
NULL
==
pSubplan
->
pNode
)
{
nodesDestroyNode
(
pSubplan
);
return
TSDB_CODE_OUT_OF_MEMORY
;
}
if
(
QUERY_NODE_LOGIC_PLAN_VNODE_MODIF
==
nodeType
(
pLogicNode
))
{
pSubplan
->
subplanType
=
SUBPLAN_TYPE_MODIFY
;
TSWAP
(((
SVnodeModifLogicNode
*
)
pLogicNode
)
->
pDataBlocks
,
((
SVnodeModifLogicNode
*
)
pSubplan
->
pNode
)
->
pDataBlocks
,
SArray
*
);
}
else
{
pSubplan
->
subplanType
=
SUBPLAN_TYPE_SCAN
;
}
pSubplan
->
id
.
queryId
=
pCxt
->
queryId
;
setLogicNodeParent
(
pSubplan
->
pNode
);
int32_t
code
=
applySplitRule
(
pSubplan
);
if
(
TSDB_CODE_SUCCESS
==
code
)
{
*
pLogicSubplan
=
pSubplan
;
}
else
{
nodesDestroyNode
(
pSubplan
);
}
return
code
;
}
\ No newline at end of file
source/libs/planner/src/planner.c
浏览文件 @
ba1dd2ca
...
@@ -17,20 +17,29 @@
...
@@ -17,20 +17,29 @@
#include "planInt.h"
#include "planInt.h"
int32_t
optimize
(
SPlanContext
*
pCxt
,
SLogicNode
*
pLogicNode
)
{
return
TSDB_CODE_SUCCESS
;
}
int32_t
qCreateQueryPlan
(
SPlanContext
*
pCxt
,
SQueryPlan
**
pPlan
,
SArray
*
pExecNodeList
)
{
int32_t
qCreateQueryPlan
(
SPlanContext
*
pCxt
,
SQueryPlan
**
pPlan
,
SArray
*
pExecNodeList
)
{
SLogicNode
*
pLogicNode
=
NULL
;
SLogicNode
*
pLogicNode
=
NULL
;
SLogicSubplan
*
pLogicSubplan
=
NULL
;
SQueryLogicPlan
*
pLogicPlan
=
NULL
;
int32_t
code
=
createLogicPlan
(
pCxt
,
&
pLogicNode
);
int32_t
code
=
createLogicPlan
(
pCxt
,
&
pLogicNode
);
if
(
TSDB_CODE_SUCCESS
==
code
)
{
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
optimize
(
pCxt
,
pLogicNode
);
code
=
optimize
LogicPlan
(
pCxt
,
pLogicNode
);
}
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
createPhysiPlan
(
pCxt
,
pLogicNode
,
pPlan
,
pExecNodeList
);
code
=
splitLogicPlan
(
pCxt
,
pLogicNode
,
&
pLogicSubplan
);
}
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
scaleOutLogicPlan
(
pCxt
,
pLogicSubplan
,
&
pLogicPlan
);
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
createPhysiPlan
(
pCxt
,
pLogicPlan
,
pPlan
,
pExecNodeList
);
}
nodesDestroyNode
(
pLogicNode
);
nodesDestroyNode
(
pLogicNode
);
nodesDestroyNode
(
pLogicSubplan
);
nodesDestroyNode
(
pLogicPlan
);
terrno
=
code
;
return
code
;
return
code
;
}
}
...
...
source/libs/planner/test/plannerTest.cpp
浏览文件 @
ba1dd2ca
...
@@ -26,11 +26,6 @@ using namespace testing;
...
@@ -26,11 +26,6 @@ using namespace testing;
class
PlannerTest
:
public
Test
{
class
PlannerTest
:
public
Test
{
protected:
protected:
enum
TestTarget
{
TEST_LOGIC_PLAN
,
TEST_PHYSICAL_PLAN
};
void
setDatabase
(
const
string
&
acctId
,
const
string
&
db
)
{
void
setDatabase
(
const
string
&
acctId
,
const
string
&
db
)
{
acctId_
=
acctId
;
acctId_
=
acctId
;
db_
=
db
;
db_
=
db
;
...
@@ -46,7 +41,7 @@ protected:
...
@@ -46,7 +41,7 @@ protected:
cxt_
.
pSql
=
sqlBuf_
.
c_str
();
cxt_
.
pSql
=
sqlBuf_
.
c_str
();
}
}
bool
run
(
TestTarget
target
=
TEST_PHYSICAL_PLAN
)
{
bool
run
(
bool
streamQuery
=
false
)
{
int32_t
code
=
qParseQuerySql
(
&
cxt_
,
&
query_
);
int32_t
code
=
qParseQuerySql
(
&
cxt_
,
&
query_
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
...
@@ -56,28 +51,42 @@ protected:
...
@@ -56,28 +51,42 @@ protected:
const
string
syntaxTreeStr
=
toString
(
query_
->
pRoot
,
false
);
const
string
syntaxTreeStr
=
toString
(
query_
->
pRoot
,
false
);
SLogicNode
*
pLogic
Plan
=
nullptr
;
SLogicNode
*
pLogic
Node
=
nullptr
;
SPlanContext
cxt
=
{
.
queryId
=
1
,
.
acctId
=
0
};
SPlanContext
cxt
=
{
.
queryId
=
1
,
.
acctId
=
0
,
.
streamQuery
=
streamQuery
};
setPlanContext
(
query_
,
&
cxt
);
setPlanContext
(
query_
,
&
cxt
);
code
=
createLogicPlan
(
&
cxt
,
&
pLogic
Plan
);
code
=
createLogicPlan
(
&
cxt
,
&
pLogic
Node
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
cout
<<
"sql:["
<<
cxt_
.
pSql
<<
"]
logic p
lan code:"
<<
code
<<
", strerror:"
<<
tstrerror
(
code
)
<<
endl
;
cout
<<
"sql:["
<<
cxt_
.
pSql
<<
"]
createLogicP
lan code:"
<<
code
<<
", strerror:"
<<
tstrerror
(
code
)
<<
endl
;
return
false
;
return
false
;
}
}
cout
<<
"====================sql : ["
<<
cxt_
.
pSql
<<
"]"
<<
endl
;
cout
<<
"====================sql : ["
<<
cxt_
.
pSql
<<
"]"
<<
endl
;
cout
<<
"syntax t
est
: "
<<
endl
;
cout
<<
"syntax t
ree
: "
<<
endl
;
cout
<<
syntaxTreeStr
<<
endl
;
cout
<<
syntaxTreeStr
<<
endl
;
cout
<<
"unformatted logic plan : "
<<
endl
;
cout
<<
"unformatted logic plan : "
<<
endl
;
cout
<<
toString
((
const
SNode
*
)
pLogicPlan
,
false
)
<<
endl
;
cout
<<
toString
((
const
SNode
*
)
pLogicNode
,
false
)
<<
endl
;
SLogicSubplan
*
pLogicSubplan
=
nullptr
;
code
=
splitLogicPlan
(
&
cxt
,
pLogicNode
,
&
pLogicSubplan
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
cout
<<
"sql:["
<<
cxt_
.
pSql
<<
"] splitLogicPlan code:"
<<
code
<<
", strerror:"
<<
tstrerror
(
code
)
<<
endl
;
return
false
;
}
SQueryLogicPlan
*
pLogicPlan
=
NULL
;
code
=
scaleOutLogicPlan
(
&
cxt
,
pLogicSubplan
,
&
pLogicPlan
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
cout
<<
"sql:["
<<
cxt_
.
pSql
<<
"] createPhysiPlan code:"
<<
code
<<
", strerror:"
<<
tstrerror
(
code
)
<<
endl
;
return
false
;
}
if
(
TEST_PHYSICAL_PLAN
==
target
)
{
SQueryPlan
*
pPlan
=
nullptr
;
SQueryPlan
*
pPlan
=
nullptr
;
code
=
createPhysiPlan
(
&
cxt
,
pLogicPlan
,
&
pPlan
,
NULL
);
code
=
createPhysiPlan
(
&
cxt
,
pLogicPlan
,
&
pPlan
,
NULL
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
cout
<<
"sql:["
<<
cxt_
.
pSql
<<
"] physical p
lan code:"
<<
code
<<
", strerror:"
<<
tstrerror
(
code
)
<<
endl
;
cout
<<
"sql:["
<<
cxt_
.
pSql
<<
"] createPhysiP
lan code:"
<<
code
<<
", strerror:"
<<
tstrerror
(
code
)
<<
endl
;
return
false
;
return
false
;
}
}
cout
<<
"unformatted physical plan : "
<<
endl
;
cout
<<
"unformatted physical plan : "
<<
endl
;
cout
<<
toString
((
const
SNode
*
)
pPlan
,
false
)
<<
endl
;
cout
<<
toString
((
const
SNode
*
)
pPlan
,
false
)
<<
endl
;
SNode
*
pNode
;
SNode
*
pNode
;
...
@@ -88,7 +97,6 @@ protected:
...
@@ -88,7 +97,6 @@ protected:
cout
<<
toString
(
pSubplan
,
false
)
<<
endl
;
cout
<<
toString
(
pSubplan
,
false
)
<<
endl
;
}
}
}
}
}
return
true
;
return
true
;
}
}
...
@@ -120,14 +128,6 @@ private:
...
@@ -120,14 +128,6 @@ private:
cout
<<
"sql:["
<<
cxt_
.
pSql
<<
"] toString code:"
<<
code
<<
", strerror:"
<<
tstrerror
(
code
)
<<
endl
;
cout
<<
"sql:["
<<
cxt_
.
pSql
<<
"] toString code:"
<<
code
<<
", strerror:"
<<
tstrerror
(
code
)
<<
endl
;
return
string
();
return
string
();
}
}
SNode
*
pNode
;
code
=
nodesStringToNode
(
pStr
,
&
pNode
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
tfree
(
pStr
);
cout
<<
"sql:["
<<
cxt_
.
pSql
<<
"] toObject code:"
<<
code
<<
", strerror:"
<<
tstrerror
(
code
)
<<
endl
;
return
string
();
}
nodesDestroyNode
(
pNode
);
string
str
(
pStr
);
string
str
(
pStr
);
tfree
(
pStr
);
tfree
(
pStr
);
return
str
;
return
str
;
...
@@ -185,6 +185,13 @@ TEST_F(PlannerTest, interval) {
...
@@ -185,6 +185,13 @@ TEST_F(PlannerTest, interval) {
ASSERT_TRUE
(
run
());
ASSERT_TRUE
(
run
());
}
}
TEST_F
(
PlannerTest
,
sessionWindow
)
{
setDatabase
(
"root"
,
"test"
);
bind
(
"SELECT count(*) FROM t1 session(ts, 10s)"
);
ASSERT_TRUE
(
run
());
}
TEST_F
(
PlannerTest
,
showTables
)
{
TEST_F
(
PlannerTest
,
showTables
)
{
setDatabase
(
"root"
,
"test"
);
setDatabase
(
"root"
,
"test"
);
...
@@ -197,3 +204,10 @@ TEST_F(PlannerTest, createTopic) {
...
@@ -197,3 +204,10 @@ TEST_F(PlannerTest, createTopic) {
bind
(
"create topic tp as SELECT * FROM st1"
);
bind
(
"create topic tp as SELECT * FROM st1"
);
ASSERT_TRUE
(
run
());
ASSERT_TRUE
(
run
());
}
}
TEST_F
(
PlannerTest
,
stream
)
{
setDatabase
(
"root"
,
"test"
);
bind
(
"SELECT sum(c1) FROM st1"
);
ASSERT_TRUE
(
run
(
true
));
}
tests/script/jenkins/basic.txt
浏览文件 @
ba1dd2ca
...
@@ -15,10 +15,16 @@
...
@@ -15,10 +15,16 @@
# ---- insert
# ---- insert
./test.sh -f tsim/insert/basic0.sim
./test.sh -f tsim/insert/basic0.sim
./test.sh -f tsim/insert/basic1.sim
./test.sh -f tsim/insert/backquote.sim
./test.sh -f tsim/insert/null.sim
./test.sh -f tsim/insert/null.sim
# ---- query
# ---- query
./test.sh -f tsim/query/interval.sim
./test.sh -f tsim/query/interval.sim
#./test.sh -f tsim/query/interval-offset.sim
# ---- show
./test.sh -f tsim/show/basic.sim
# ---- table
# ---- table
./test.sh -f tsim/table/basic1.sim
./test.sh -f tsim/table/basic1.sim
...
...
tests/script/tsim/db/basic7.sim
浏览文件 @
ba1dd2ca
...
@@ -14,6 +14,7 @@ sql insert into tb1 values (now, 1);
...
@@ -14,6 +14,7 @@ sql insert into tb1 values (now, 1);
sql show stables
sql show stables
if $rows != 1 then
if $rows != 1 then
print $rows
return -1
return -1
endi
endi
...
...
tests/script/tsim/insert/backquote.sim
浏览文件 @
ba1dd2ca
...
@@ -36,6 +36,7 @@ while $dbCnt < 2
...
@@ -36,6 +36,7 @@ while $dbCnt < 2
$dbCnt = $dbCnt + 1
$dbCnt = $dbCnt + 1
print =============== create super table, include all type
print =============== create super table, include all type
print notes: after nchar show ok, modify binary to nchar
sql create table `stable` (`timestamp` timestamp, `int` int, `binary` binary(16), `nchar` nchar(16)) tags (`float` float, `Binary` binary(16), `Nchar` nchar(16))
sql create table `stable` (`timestamp` timestamp, `int` int, `binary` binary(16), `nchar` nchar(16)) tags (`float` float, `Binary` binary(16), `Nchar` nchar(16))
sql create table `Stable` (`timestamp` timestamp, `int` int, `Binary` binary(32), `Nchar` nchar(32)) tags (`float` float, `binary` binary(16), `nchar` nchar(16))
sql create table `Stable` (`timestamp` timestamp, `int` int, `Binary` binary(32), `Nchar` nchar(32)) tags (`float` float, `binary` binary(16), `nchar` nchar(16))
...
@@ -47,11 +48,15 @@ while $dbCnt < 2
...
@@ -47,11 +48,15 @@ while $dbCnt < 2
return -1
return -1
endi
endi
if $data00 != Stable then
if $data00 != Stable then
if $data00 != stable then
return -1
return -1
endi
endi
endi
if $data10 != Stable then
if $data10 != stable then
if $data10 != stable then
return -1
return -1
endi
endi
endi
print =============== create child table
print =============== create child table
sql create table `table` using `stable` tags(100.0, 'stable+table', 'stable+table')
sql create table `table` using `stable` tags(100.0, 'stable+table', 'stable+table')
...
@@ -146,7 +151,6 @@ while $dbCnt < 2
...
@@ -146,7 +151,6 @@ while $dbCnt < 2
return -1
return -1
endi
endi
print ======================================> super table agg not supported yet <==================================
#print =============== query data from st, but not support select * from super table, waiting fix
#print =============== query data from st, but not support select * from super table, waiting fix
#sql select count(*) from `stable`
#sql select count(*) from `stable`
#print rows: $rows
#print rows: $rows
...
@@ -166,6 +170,10 @@ while $dbCnt < 2
...
@@ -166,6 +170,10 @@ while $dbCnt < 2
#if $data00 != 4 then
#if $data00 != 4 then
# return -1
# return -1
#endi
#endi
#sql select * from `stable`
#if $rows != 4 then
# return -1
#endi
##sql select * from st
##sql select * from st
##if $rows != 4 then
##if $rows != 4 then
## return -1
## return -1
...
@@ -180,7 +188,7 @@ system sh/exec.sh -n dnode1 -s start
...
@@ -180,7 +188,7 @@ system sh/exec.sh -n dnode1 -s start
$loop_cnt = 0
$loop_cnt = 0
check_dnode_ready:
check_dnode_ready:
$loop_cnt = $loop_cnt + 1
$loop_cnt = $loop_cnt + 1
sleep
1
00
sleep
2
00
if $loop_cnt == 10 then
if $loop_cnt == 10 then
print ====> dnode not ready!
print ====> dnode not ready!
return -1
return -1
...
@@ -230,11 +238,15 @@ while $dbCnt < 2
...
@@ -230,11 +238,15 @@ while $dbCnt < 2
return -1
return -1
endi
endi
if $data00 != Stable then
if $data00 != Stable then
if $data00 != stable then
return -1
return -1
endi
endi
endi
if $data10 != Stable then
if $data10 != stable then
if $data10 != stable then
return -1
return -1
endi
endi
endi
sql show tables
sql show tables
print rows: $rows
print rows: $rows
...
@@ -315,26 +327,26 @@ while $dbCnt < 2
...
@@ -315,26 +327,26 @@ while $dbCnt < 2
return -1
return -1
endi
endi
print =============== query data from st, but not support select * from super table, waiting fix
#
print =============== query data from st, but not support select * from super table, waiting fix
sql select count(*) from `stable`
#
sql select count(*) from `stable`
print rows: $rows
#print rows: $rows
print $data00 $data01 $data02 $data03
#
print $data00 $data01 $data02 $data03
if $rows != 1 then
#if $rows != 1 then
return -1
#
return -1
endi
#endi
if $data00 != 4 then
#if $data00 != 4 then
return -1
#
return -1
endi
#endi
sql select count(*) from `Stable`
#
sql select count(*) from `Stable`
print rows: $rows
#print rows: $rows
print $data00 $data01 $data02 $data03
#
print $data00 $data01 $data02 $data03
if $rows != 1 then
#if $rows != 1 then
return -1
#
return -1
endi
#endi
if $data00 != 4 then
#if $data00 != 4 then
return -1
#
return -1
endi
#endi
#sql select * from
st
#sql select * from
`stable`
#if $rows != 4 then
#if $rows != 4 then
# return -1
# return -1
#endi
#endi
...
...
tests/script/tsim/show/basic.sim
0 → 100644
浏览文件 @
ba1dd2ca
此差异已折叠。
点击以展开。
tests/script/tsim/testCaseSuite.sim
浏览文件 @
ba1dd2ca
...
@@ -9,13 +9,15 @@ run tsim/db/error1.sim
...
@@ -9,13 +9,15 @@ run tsim/db/error1.sim
run tsim/dnode/basic1.sim
run tsim/dnode/basic1.sim
run tsim/insert/basic0.sim
run tsim/insert/basic0.sim
#run tsim/insert/basic1.sim # TD-14246
run tsim/insert/basic1.sim
#run tsim/insert/backquote.sim # TD-14261
run tsim/insert/backquote.sim
#
run tsim/insert/null.sim
run tsim/insert/null.sim
run tsim/query/interval.sim
run tsim/query/interval.sim
#run tsim/query/interval-offset.sim # TD-14266
#run tsim/query/interval-offset.sim # TD-14266
run tsim/show/basic.sim
run tsim/table/basic1.sim
run tsim/table/basic1.sim
run tsim/tmq/basic.sim
run tsim/tmq/basic.sim
...
...
tools/shell/src/shellMain.c
浏览文件 @
ba1dd2ca
...
@@ -58,7 +58,7 @@ static struct argp_option options[] = {
...
@@ -58,7 +58,7 @@ static struct argp_option options[] = {
{
"check"
,
'k'
,
"CHECK"
,
0
,
"Check tables."
},
{
"check"
,
'k'
,
"CHECK"
,
0
,
"Check tables."
},
{
"database"
,
'd'
,
"DATABASE"
,
0
,
"Database to use when connecting to the server."
},
{
"database"
,
'd'
,
"DATABASE"
,
0
,
"Database to use when connecting to the server."
},
{
"timezone"
,
'z'
,
"TIMEZONE"
,
0
,
"Time zone of the shell, default is local."
},
{
"timezone"
,
'z'
,
"TIMEZONE"
,
0
,
"Time zone of the shell, default is local."
},
{
"netrole"
,
'n'
,
"NETROLE"
,
0
,
"Net role when network connectivity test, default is startup, options: client|server|rpc|startup|sync|spee
n
|fqdn."
},
{
"netrole"
,
'n'
,
"NETROLE"
,
0
,
"Net role when network connectivity test, default is startup, options: client|server|rpc|startup|sync|spee
d
|fqdn."
},
{
"pktlen"
,
'l'
,
"PKTLEN"
,
0
,
"Packet length used for net test, default is 1000 bytes."
},
{
"pktlen"
,
'l'
,
"PKTLEN"
,
0
,
"Packet length used for net test, default is 1000 bytes."
},
{
"pktnum"
,
'N'
,
"PKTNUM"
,
0
,
"Packet numbers used for net test, default is 100."
},
{
"pktnum"
,
'N'
,
"PKTNUM"
,
0
,
"Packet numbers used for net test, default is 100."
},
// Shuduo: 3.0 does not support UDP any more
// Shuduo: 3.0 does not support UDP any more
...
...
tools/shell/src/tnettest.c
浏览文件 @
ba1dd2ca
...
@@ -406,7 +406,7 @@ static int32_t taosNetCheckRpc(const char* serverFqdn, uint16_t port, uint16_t p
...
@@ -406,7 +406,7 @@ static int32_t taosNetCheckRpc(const char* serverFqdn, uint16_t port, uint16_t p
reqMsg
.
code
=
0
;
reqMsg
.
code
=
0
;
reqMsg
.
handle
=
NULL
;
// rpc handle returned to app
reqMsg
.
handle
=
NULL
;
// rpc handle returned to app
reqMsg
.
ahandle
=
NULL
;
// app handle set by client
reqMsg
.
ahandle
=
NULL
;
// app handle set by client
strcpy
(
reqMsg
.
pCont
,
"nettest"
);
strcpy
(
reqMsg
.
pCont
,
"
dnode-
nettest"
);
rpcSendRecv
(
pRpcConn
,
&
epSet
,
&
reqMsg
,
&
rspMsg
);
rpcSendRecv
(
pRpcConn
,
&
epSet
,
&
reqMsg
,
&
rspMsg
);
...
@@ -442,7 +442,7 @@ static void taosNetTestStartup(char *host, int32_t port) {
...
@@ -442,7 +442,7 @@ static void taosNetTestStartup(char *host, int32_t port) {
SStartupReq
*
pStep
=
malloc
(
sizeof
(
SStartupReq
));
SStartupReq
*
pStep
=
malloc
(
sizeof
(
SStartupReq
));
while
(
1
)
{
while
(
1
)
{
int32_t
code
=
taosNetCheckRpc
(
host
,
port
+
TSDB_PORT_DNODEDNODE
,
20
,
0
,
pStep
);
int32_t
code
=
taosNetCheckRpc
(
host
,
port
,
20
,
0
,
pStep
);
if
(
code
>
0
)
{
if
(
code
>
0
)
{
code
=
taosNetParseStartup
(
pStep
);
code
=
taosNetParseStartup
(
pStep
);
}
}
...
@@ -499,12 +499,11 @@ static void taosNetCheckSync(char *host, int32_t port) {
...
@@ -499,12 +499,11 @@ static void taosNetCheckSync(char *host, int32_t port) {
}
}
static
void
taosNetTestRpc
(
char
*
host
,
int32_t
startPort
,
int32_t
pkgLen
)
{
static
void
taosNetTestRpc
(
char
*
host
,
int32_t
startPort
,
int32_t
pkgLen
)
{
int32_t
endPort
=
startPort
+
TSDB_PORT_SYNC
;
char
spi
=
0
;
char
spi
=
0
;
uInfo
(
"check rpc, host:%s
startPort:%d endPort:%d pkgLen:%d
\n
"
,
host
,
startPort
,
end
Port
,
pkgLen
);
uInfo
(
"check rpc, host:%s
Port:%d pkgLen:%d
\n
"
,
host
,
start
Port
,
pkgLen
);
for
(
uint16_t
port
=
startPort
;
port
<
endPort
;
port
++
)
{
uint16_t
port
=
startPort
;
int32_t
sendpkgLen
;
int32_t
sendpkgLen
;
if
(
pkgLen
<=
tsRpcMaxUdpSize
)
{
if
(
pkgLen
<=
tsRpcMaxUdpSize
)
{
sendpkgLen
=
tsRpcMaxUdpSize
+
1000
;
sendpkgLen
=
tsRpcMaxUdpSize
+
1000
;
...
@@ -525,7 +524,7 @@ static void taosNetTestRpc(char *host, int32_t startPort, int32_t pkgLen) {
...
@@ -525,7 +524,7 @@ static void taosNetTestRpc(char *host, int32_t startPort, int32_t pkgLen) {
}
else
{
}
else
{
sendpkgLen
=
pkgLen
;
sendpkgLen
=
pkgLen
;
}
}
/*
tsRpcForceTcp = 0;
tsRpcForceTcp = 0;
ret = taosNetCheckRpc(host, port, pkgLen, spi, NULL);
ret = taosNetCheckRpc(host, port, pkgLen, spi, NULL);
if (ret < 0) {
if (ret < 0) {
...
@@ -533,14 +532,13 @@ static void taosNetTestRpc(char *host, int32_t startPort, int32_t pkgLen) {
...
@@ -533,14 +532,13 @@ static void taosNetTestRpc(char *host, int32_t startPort, int32_t pkgLen) {
} else {
} else {
printf("successed to test UDP port:%d\n", port);
printf("successed to test UDP port:%d\n", port);
}
}
}
*/
taosNetCheckSync
(
host
,
startPort
+
TSDB_PORT_SYNC
);
taosNetCheckSync
(
host
,
startPort
);
}
}
static
void
taosNetTestClient
(
char
*
host
,
int32_t
startPort
,
int32_t
pkgLen
)
{
static
void
taosNetTestClient
(
char
*
host
,
int32_t
startPort
,
int32_t
pkgLen
)
{
int32_t
endPort
=
startPort
+
11
;
uInfo
(
"work as client, host:%s Port:%d pkgLen:%d
\n
"
,
host
,
startPort
,
pkgLen
);
uInfo
(
"work as client, host:%s startPort:%d endPort:%d pkgLen:%d
\n
"
,
host
,
startPort
,
endPort
,
pkgLen
);
uint32_t
serverIp
=
taosGetIpv4FromFqdn
(
host
);
uint32_t
serverIp
=
taosGetIpv4FromFqdn
(
host
);
if
(
serverIp
==
0xFFFFFFFF
)
{
if
(
serverIp
==
0xFFFFFFFF
)
{
...
@@ -549,15 +547,14 @@ static void taosNetTestClient(char *host, int32_t startPort, int32_t pkgLen) {
...
@@ -549,15 +547,14 @@ static void taosNetTestClient(char *host, int32_t startPort, int32_t pkgLen) {
}
}
uInfo
(
"server ip:%s is resolved from host:%s"
,
taosIpStr
(
serverIp
),
host
);
uInfo
(
"server ip:%s is resolved from host:%s"
,
taosIpStr
(
serverIp
),
host
);
taosNetCheckPort
(
serverIp
,
startPort
,
end
Port
,
pkgLen
);
taosNetCheckPort
(
serverIp
,
startPort
,
start
Port
,
pkgLen
);
}
}
static
void
taosNetTestServer
(
char
*
host
,
int32_t
startPort
,
int32_t
pkgLen
)
{
static
void
taosNetTestServer
(
char
*
host
,
int32_t
startPort
,
int32_t
pkgLen
)
{
int32_t
endPort
=
startPort
+
11
;
uInfo
(
"work as server, host:%s Port:%d pkgLen:%d
\n
"
,
host
,
startPort
,
pkgLen
);
uInfo
(
"work as server, host:%s startPort:%d endPort:%d pkgLen:%d
\n
"
,
host
,
startPort
,
endPort
,
pkgLen
);
int32_t
port
=
startPort
;
int32_t
port
=
startPort
;
int32_t
num
=
endPort
-
startPort
+
1
;
int32_t
num
=
1
;
if
(
num
<
0
)
num
=
1
;
if
(
num
<
0
)
num
=
1
;
TdThread
*
pids
=
malloc
(
2
*
num
*
sizeof
(
TdThread
));
TdThread
*
pids
=
malloc
(
2
*
num
*
sizeof
(
TdThread
));
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录