Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
e52429e3
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看板
提交
e52429e3
编写于
6月 16, 2022
作者:
X
Xiaoyu Wang
浏览文件
操作
浏览文件
下载
差异文件
merge 3.0
上级
7f78d4a7
69eb9dad
变更
112
展开全部
隐藏空白更改
内联
并排
Showing
112 changed file
with
2662 addition
and
1791 deletion
+2662
-1791
docs/examples/.gitignre
docs/examples/.gitignre
+2
-0
examples/c/stream_demo.c
examples/c/stream_demo.c
+2
-1
include/common/tmsg.h
include/common/tmsg.h
+31
-2
include/common/tmsgdef.h
include/common/tmsgdef.h
+1
-0
include/libs/executor/executor.h
include/libs/executor/executor.h
+6
-3
include/libs/function/function.h
include/libs/function/function.h
+0
-1
include/libs/function/functionMgt.h
include/libs/function/functionMgt.h
+2
-0
include/libs/nodes/querynodes.h
include/libs/nodes/querynodes.h
+1
-0
include/libs/planner/planner.h
include/libs/planner/planner.h
+1
-1
include/libs/stream/tstream.h
include/libs/stream/tstream.h
+31
-1
include/libs/sync/sync.h
include/libs/sync/sync.h
+1
-9
include/util/taoserror.h
include/util/taoserror.h
+5
-1
include/util/tdef.h
include/util/tdef.h
+1
-0
source/client/inc/clientInt.h
source/client/inc/clientInt.h
+4
-1
source/client/inc/clientStmt.h
source/client/inc/clientStmt.h
+1
-1
source/client/src/clientHb.c
source/client/src/clientHb.c
+16
-12
source/client/src/clientImpl.c
source/client/src/clientImpl.c
+12
-5
source/client/src/clientMain.c
source/client/src/clientMain.c
+63
-20
source/client/src/clientSml.c
source/client/src/clientSml.c
+30
-21
source/client/src/clientStmt.c
source/client/src/clientStmt.c
+1
-1
source/client/src/tmq.c
source/client/src/tmq.c
+84
-0
source/common/src/systable.c
source/common/src/systable.c
+13
-12
source/common/src/tmsg.c
source/common/src/tmsg.c
+18
-2
source/dnode/mgmt/mgmt_mnode/src/mmHandle.c
source/dnode/mgmt/mgmt_mnode/src/mmHandle.c
+1
-0
source/dnode/mgmt/mgmt_vnode/src/vmHandle.c
source/dnode/mgmt/mgmt_vnode/src/vmHandle.c
+1
-0
source/dnode/mnode/impl/inc/mndAuth.h
source/dnode/mnode/impl/inc/mndAuth.h
+32
-13
source/dnode/mnode/impl/inc/mndDef.h
source/dnode/mnode/impl/inc/mndDef.h
+5
-2
source/dnode/mnode/impl/inc/mndStream.h
source/dnode/mnode/impl/inc/mndStream.h
+1
-1
source/dnode/mnode/impl/src/mndAuth.c
source/dnode/mnode/impl/src/mndAuth.c
+100
-58
source/dnode/mnode/impl/src/mndBnode.c
source/dnode/mnode/impl/src/mndBnode.c
+2
-19
source/dnode/mnode/impl/src/mndDb.c
source/dnode/mnode/impl/src/mndDb.c
+5
-35
source/dnode/mnode/impl/src/mndDef.c
source/dnode/mnode/impl/src/mndDef.c
+4
-4
source/dnode/mnode/impl/src/mndDnode.c
source/dnode/mnode/impl/src/mndDnode.c
+2
-18
source/dnode/mnode/impl/src/mndFunc.c
source/dnode/mnode/impl/src/mndFunc.c
+6
-24
source/dnode/mnode/impl/src/mndMain.c
source/dnode/mnode/impl/src/mndMain.c
+10
-5
source/dnode/mnode/impl/src/mndMnode.c
source/dnode/mnode/impl/src/mndMnode.c
+2
-19
source/dnode/mnode/impl/src/mndProfile.c
source/dnode/mnode/impl/src/mndProfile.c
+120
-123
source/dnode/mnode/impl/src/mndQnode.c
source/dnode/mnode/impl/src/mndQnode.c
+2
-19
source/dnode/mnode/impl/src/mndScheduler.c
source/dnode/mnode/impl/src/mndScheduler.c
+6
-2
source/dnode/mnode/impl/src/mndShow.c
source/dnode/mnode/impl/src/mndShow.c
+3
-0
source/dnode/mnode/impl/src/mndSma.c
source/dnode/mnode/impl/src/mndSma.c
+5
-19
source/dnode/mnode/impl/src/mndSnode.c
source/dnode/mnode/impl/src/mndSnode.c
+2
-19
source/dnode/mnode/impl/src/mndStb.c
source/dnode/mnode/impl/src/mndStb.c
+4
-26
source/dnode/mnode/impl/src/mndStream.c
source/dnode/mnode/impl/src/mndStream.c
+105
-47
source/dnode/mnode/impl/src/mndSync.c
source/dnode/mnode/impl/src/mndSync.c
+9
-9
source/dnode/mnode/impl/src/mndTopic.c
source/dnode/mnode/impl/src/mndTopic.c
+10
-17
source/dnode/mnode/impl/src/mndTrans.c
source/dnode/mnode/impl/src/mndTrans.c
+1
-8
source/dnode/mnode/impl/src/mndUser.c
source/dnode/mnode/impl/src/mndUser.c
+31
-18
source/dnode/mnode/impl/src/mndVgroup.c
source/dnode/mnode/impl/src/mndVgroup.c
+13
-35
source/dnode/mnode/impl/test/profile/profile.cpp
source/dnode/mnode/impl/test/profile/profile.cpp
+1
-1
source/dnode/vnode/src/inc/vnodeInt.h
source/dnode/vnode/src/inc/vnodeInt.h
+1
-0
source/dnode/vnode/src/tq/tq.c
source/dnode/vnode/src/tq/tq.c
+23
-8
source/dnode/vnode/src/vnd/vnodeSvr.c
source/dnode/vnode/src/vnd/vnodeSvr.c
+13
-4
source/dnode/vnode/src/vnd/vnodeSync.c
source/dnode/vnode/src/vnd/vnodeSync.c
+8
-19
source/libs/catalog/src/ctgCache.c
source/libs/catalog/src/ctgCache.c
+1
-1
source/libs/executor/inc/executil.h
source/libs/executor/inc/executil.h
+1
-4
source/libs/executor/inc/executorInt.h
source/libs/executor/inc/executorInt.h
+2
-0
source/libs/executor/inc/executorimpl.h
source/libs/executor/inc/executorimpl.h
+28
-14
source/libs/executor/inc/tfill.h
source/libs/executor/inc/tfill.h
+0
-2
source/libs/executor/src/executil.c
source/libs/executor/src/executil.c
+0
-246
source/libs/executor/src/executor.c
source/libs/executor/src/executor.c
+13
-7
source/libs/executor/src/executorMain.c
source/libs/executor/src/executorMain.c
+12
-10
source/libs/executor/src/executorimpl.c
source/libs/executor/src/executorimpl.c
+79
-103
source/libs/executor/src/groupoperator.c
source/libs/executor/src/groupoperator.c
+7
-11
source/libs/executor/src/scanoperator.c
source/libs/executor/src/scanoperator.c
+511
-16
source/libs/executor/src/sortoperator.c
source/libs/executor/src/sortoperator.c
+4
-2
source/libs/executor/src/timewindowoperator.c
source/libs/executor/src/timewindowoperator.c
+313
-135
source/libs/executor/src/tsort.c
source/libs/executor/src/tsort.c
+5
-1
source/libs/function/inc/builtinsimpl.h
source/libs/function/inc/builtinsimpl.h
+4
-0
source/libs/function/inc/functionMgtInt.h
source/libs/function/inc/functionMgtInt.h
+2
-1
source/libs/function/inc/texpr.h
source/libs/function/inc/texpr.h
+0
-6
source/libs/function/inc/tunaryoperator.h
source/libs/function/inc/tunaryoperator.h
+0
-32
source/libs/function/src/builtins.c
source/libs/function/src/builtins.c
+58
-4
source/libs/function/src/builtinsimpl.c
source/libs/function/src/builtinsimpl.c
+216
-6
source/libs/function/src/functionMgt.c
source/libs/function/src/functionMgt.c
+2
-0
source/libs/function/src/taggfunction.c
source/libs/function/src/taggfunction.c
+7
-7
source/libs/function/src/texpr.c
source/libs/function/src/texpr.c
+0
-239
source/libs/function/src/udfd.c
source/libs/function/src/udfd.c
+2
-2
source/libs/nodes/src/nodesUtilFuncs.c
source/libs/nodes/src/nodesUtilFuncs.c
+1
-0
source/libs/parser/src/parAstParser.c
source/libs/parser/src/parAstParser.c
+14
-0
source/libs/parser/src/parTranslater.c
source/libs/parser/src/parTranslater.c
+10
-1
source/libs/planner/src/planLogicCreater.c
source/libs/planner/src/planLogicCreater.c
+1
-1
source/libs/planner/src/planPhysiCreater.c
source/libs/planner/src/planPhysiCreater.c
+2
-2
source/libs/scheduler/src/scheduler.c
source/libs/scheduler/src/scheduler.c
+3
-1
source/libs/stream/inc/streamInc.h
source/libs/stream/inc/streamInc.h
+7
-0
source/libs/stream/src/stream.c
source/libs/stream/src/stream.c
+67
-1
source/libs/stream/src/streamExec.c
source/libs/stream/src/streamExec.c
+8
-6
source/libs/stream/src/streamTask.c
source/libs/stream/src/streamTask.c
+2
-0
source/libs/sync/src/syncMain.c
source/libs/sync/src/syncMain.c
+112
-61
source/libs/sync/test/syncConfigChangeSnapshotTest.cpp
source/libs/sync/test/syncConfigChangeSnapshotTest.cpp
+1
-1
source/libs/sync/test/syncConfigChangeTest.cpp
source/libs/sync/test/syncConfigChangeTest.cpp
+1
-1
source/libs/sync/test/syncReplicateTest.cpp
source/libs/sync/test/syncReplicateTest.cpp
+1
-1
source/libs/sync/test/syncTestTool.cpp
source/libs/sync/test/syncTestTool.cpp
+1
-1
source/libs/wal/src/walRead.c
source/libs/wal/src/walRead.c
+1
-1
source/libs/wal/src/walWrite.c
source/libs/wal/src/walWrite.c
+4
-1
source/util/src/tarray.c
source/util/src/tarray.c
+5
-1
source/util/src/tcache.c
source/util/src/tcache.c
+8
-8
source/util/src/terror.c
source/util/src/terror.c
+4
-0
tests/pytest/util/dnodes.py
tests/pytest/util/dnodes.py
+16
-16
tests/pytest/util/sql.py
tests/pytest/util/sql.py
+1
-0
tests/system-test/0-others/user_control.py
tests/system-test/0-others/user_control.py
+13
-7
tests/system-test/2-query/json_tag.py
tests/system-test/2-query/json_tag.py
+1
-1
tests/system-test/6-cluster/5dnode2mnode.py
tests/system-test/6-cluster/5dnode2mnode.py
+5
-1
tests/system-test/6-cluster/5dnode3mnodeDrop.py
tests/system-test/6-cluster/5dnode3mnodeDrop.py
+69
-39
tests/system-test/6-cluster/5dnode3mnodeStop.py
tests/system-test/6-cluster/5dnode3mnodeStop.py
+49
-42
tests/system-test/6-cluster/5dnode3mnodeStopInsert.py
tests/system-test/6-cluster/5dnode3mnodeStopInsert.py
+114
-71
tests/system-test/7-tmq/basic5.py
tests/system-test/7-tmq/basic5.py
+3
-1
tests/system-test/7-tmq/tmqError.py
tests/system-test/7-tmq/tmqError.py
+2
-2
tests/system-test/fulltest.sh
tests/system-test/fulltest.sh
+1
-1
tests/system-test/test-all.bat
tests/system-test/test-all.bat
+3
-2
tests/system-test/test.py
tests/system-test/test.py
+11
-4
tools/taosadapter
tools/taosadapter
+0
-1
未找到文件。
docs/examples/.gitignre
0 → 100644
浏览文件 @
e52429e3
.vscode
*.lock
\ No newline at end of file
examples/c/stream_demo.c
浏览文件 @
e52429e3
...
...
@@ -82,7 +82,8 @@ int32_t create_stream() {
/*const char* sql = "select sum(k) from tu1 interval(10m)";*/
/*pRes = tmq_create_stream(pConn, "stream1", "out1", sql);*/
pRes
=
taos_query
(
pConn
,
"create stream stream1 trigger at_once into outstb as select _wstartts, sum(k) from st1 interval(10m)"
);
pConn
,
"create stream stream1 trigger max_delay 10s into outstb as select _wstartts, sum(k) from st1 interval(10m)"
);
if
(
taos_errno
(
pRes
)
!=
0
)
{
printf
(
"failed to create stream stream1, reason:%s
\n
"
,
taos_errstr
(
pRes
));
return
-
1
;
...
...
include/common/tmsg.h
浏览文件 @
e52429e3
...
...
@@ -135,6 +135,8 @@ typedef enum _mgmt_table {
#define TSDB_ALTER_USER_REMOVE_WRITE_DB 0x6
#define TSDB_ALTER_USER_ADD_ALL_DB 0x7
#define TSDB_ALTER_USER_REMOVE_ALL_DB 0x8
#define TSDB_ALTER_USER_ENABLE 0x9
#define TSDB_ALTER_USER_SYSINFO 0xA
#define TSDB_ALTER_USER_PRIVILEGES 0x2
...
...
@@ -534,6 +536,8 @@ int32_t tDeserializeSDropUserReq(void* buf, int32_t bufLen, SDropUserReq* pReq);
typedef
struct
{
int8_t
createType
;
int8_t
superUser
;
// denote if it is a super user or not
int8_t
sysInfo
;
int8_t
enable
;
char
user
[
TSDB_USER_LEN
];
char
pass
[
TSDB_USET_PASSWORD_LEN
];
}
SCreateUserReq
;
...
...
@@ -544,6 +548,8 @@ int32_t tDeserializeSCreateUserReq(void* buf, int32_t bufLen, SCreateUserReq* pR
typedef
struct
{
int8_t
alterType
;
int8_t
superUser
;
int8_t
sysInfo
;
int8_t
enable
;
char
user
[
TSDB_USER_LEN
];
char
pass
[
TSDB_USET_PASSWORD_LEN
];
char
dbname
[
TSDB_DB_FNAME_LEN
];
...
...
@@ -563,6 +569,9 @@ typedef struct {
char
user
[
TSDB_USER_LEN
];
int32_t
version
;
int8_t
superAuth
;
int8_t
sysInfo
;
int8_t
enable
;
int8_t
reserve
;
SHashObj
*
createdDbs
;
SHashObj
*
readDbs
;
SHashObj
*
writeDbs
;
...
...
@@ -1992,16 +2001,17 @@ typedef struct {
typedef
struct
{
int64_t
tid
;
int32_t
status
;
char
status
[
TSDB_JOB_STATUS_LEN
]
;
}
SQuerySubDesc
;
typedef
struct
{
char
sql
[
TSDB_SHOW_SQL_LEN
];
uint64_t
queryId
;
int64_t
useconds
;
int64_t
stime
;
int64_t
stime
;
// timestamp precision ms
int64_t
reqRid
;
int32_t
pid
;
bool
stableQuery
;
char
fqdn
[
TSDB_FQDN_LEN
];
int32_t
subPlanNum
;
SArray
*
subDesc
;
// SArray<SQuerySubDesc>
...
...
@@ -2246,6 +2256,25 @@ typedef struct {
int8_t
reserved
;
}
SMqVDeleteRsp
;
typedef
struct
{
char
name
[
TSDB_STREAM_FNAME_LEN
];
int64_t
streamId
;
}
SMDropStreamTaskReq
;
typedef
struct
{
int8_t
reserved
;
}
SMDropStreamTaskRsp
;
typedef
struct
{
SMsgHead
head
;
int64_t
leftForVer
;
int32_t
taskId
;
}
SVDropStreamTaskReq
;
typedef
struct
{
int8_t
reserved
;
}
SVDropStreamTaskRsp
;
typedef
struct
{
int64_t
leftForVer
;
int32_t
vgId
;
...
...
include/common/tmsgdef.h
浏览文件 @
e52429e3
...
...
@@ -187,6 +187,7 @@ enum {
TD_DEF_MSG_TYPE
(
TDMT_VND_CONSUME
,
"vnode-consume"
,
SMqPollReq
,
SMqDataBlkRsp
)
TD_DEF_MSG_TYPE
(
TDMT_VND_STREAM_TRIGGER
,
"vnode-stream-trigger"
,
NULL
,
NULL
)
TD_DEF_MSG_TYPE
(
TDMT_VND_STREAM_DISPATCH_WRITE
,
"vnode-stream-task-dispatch-write"
,
NULL
,
NULL
)
TD_DEF_MSG_TYPE
(
TDMT_VND_STREAM_TASK_DROP
,
"vnode-stream-task-drop"
,
NULL
,
NULL
)
TD_DEF_MSG_TYPE
(
TDMT_VND_CREATE_SMA
,
"vnode-create-sma"
,
NULL
,
NULL
)
TD_DEF_MSG_TYPE
(
TDMT_VND_CANCEL_SMA
,
"vnode-cancel-sma"
,
NULL
,
NULL
)
TD_DEF_MSG_TYPE
(
TDMT_VND_DROP_SMA
,
"vnode-drop-sma"
,
NULL
,
NULL
)
...
...
include/libs/executor/executor.h
浏览文件 @
e52429e3
...
...
@@ -38,8 +38,10 @@ typedef struct SReadHandle {
SMsgCb
*
pMsgCb
;
}
SReadHandle
;
#define STREAM_DATA_TYPE_SUBMIT_BLOCK 0x1
#define STREAM_DATA_TYPE_SSDATA_BLOCK 0x2
enum
{
STREAM_DATA_TYPE_SUBMIT_BLOCK
=
1
,
STREAM_DATA_TYPE_SSDATA_BLOCK
=
2
,
};
typedef
enum
{
OPTR_EXEC_MODEL_BATCH
=
0x1
,
...
...
@@ -102,7 +104,8 @@ int32_t qCreateExecTask(SReadHandle* readHandle, int32_t vgId, uint64_t taskId,
* @param tversion
* @return
*/
int32_t
qGetQueriedTableSchemaVersion
(
qTaskInfo_t
tinfo
,
char
*
dbName
,
char
*
tableName
,
int32_t
*
sversion
,
int32_t
*
tversion
);
int32_t
qGetQueriedTableSchemaVersion
(
qTaskInfo_t
tinfo
,
char
*
dbName
,
char
*
tableName
,
int32_t
*
sversion
,
int32_t
*
tversion
);
/**
* The main task execution function, including query on both table and multiple tables,
...
...
include/libs/function/function.h
浏览文件 @
e52429e3
...
...
@@ -132,7 +132,6 @@ typedef struct SqlFunctionCtx {
char
*
pOutput
;
// final result output buffer, point to sdata->data
int32_t
numOfParams
;
SFunctParam
*
param
;
// input parameter, e.g., top(k, 20), the number of results for top query is kept in param
int64_t
*
ptsList
;
// corresponding timestamp array list, todo remove it
SColumnInfoData
*
pTsOutput
;
// corresponding output buffer for timestamp of each result, e.g., top/bottom*/
int32_t
offset
;
struct
SResultRowEntryInfo
*
resultInfo
;
...
...
include/libs/function/functionMgt.h
浏览文件 @
e52429e3
...
...
@@ -134,6 +134,7 @@ typedef enum EFunctionType {
FUNCTION_TYPE_HYPERLOGLOG_MERGE
,
FUNCTION_TYPE_ELAPSED_PARTIAL
,
FUNCTION_TYPE_ELAPSED_MERGE
,
FUNCTION_TYPE_TOP_PARTIAL
,
FUNCTION_TYPE_TOP_MERGE
,
FUNCTION_TYPE_BOTTOM_PARTIAL
,
...
...
@@ -184,6 +185,7 @@ bool fmIsUserDefinedFunc(int32_t funcId);
bool
fmIsDistExecFunc
(
int32_t
funcId
);
bool
fmIsForbidFillFunc
(
int32_t
funcId
);
bool
fmIsForbidStreamFunc
(
int32_t
funcId
);
bool
fmIsIntervalInterpoFunc
(
int32_t
funcId
);
int32_t
fmGetDistMethod
(
const
SFunctionNode
*
pFunc
,
SFunctionNode
**
pPartialFunc
,
SFunctionNode
**
pMergeFunc
);
...
...
include/libs/nodes/querynodes.h
浏览文件 @
e52429e3
...
...
@@ -351,6 +351,7 @@ typedef struct SQuery {
int32_t
placeholderNum
;
SArray
*
pPlaceholderValues
;
SNode
*
pPrepareRoot
;
bool
stableQuery
;
}
SQuery
;
void
nodesWalkSelectStmt
(
SSelectStmt
*
pSelect
,
ESqlClause
clause
,
FNodeWalker
walker
,
void
*
pContext
);
...
...
include/libs/planner/planner.h
浏览文件 @
e52429e3
...
...
@@ -36,7 +36,7 @@ typedef struct SPlanContext {
int64_t
watermark
;
char
*
pMsg
;
int32_t
msgLen
;
double
filesFactor
;
//
double filesFactor;
}
SPlanContext
;
// Create the physical plan for the query, according to the AST.
...
...
include/libs/stream/tstream.h
浏览文件 @
e52429e3
...
...
@@ -58,6 +58,7 @@ enum {
enum
{
STREAM_INPUT__DATA_SUBMIT
=
1
,
STREAM_INPUT__DATA_BLOCK
,
STREAM_INPUT__TRIGGER
,
STREAM_INPUT__CHECKPOINT
,
};
...
...
@@ -85,6 +86,11 @@ typedef struct {
int8_t
type
;
}
SStreamCheckpoint
;
typedef
struct
{
int8_t
type
;
SSDataBlock
*
pBlock
;
}
SStreamTrigger
;
enum
{
STREAM_QUEUE__SUCESS
=
1
,
STREAM_QUEUE__FAILED
,
...
...
@@ -98,6 +104,9 @@ typedef struct {
int8_t
status
;
}
SStreamQueue
;
int32_t
streamInit
();
void
streamCleanUp
();
SStreamQueue
*
streamQueueOpen
();
void
streamQueueClose
(
SStreamQueue
*
queue
);
...
...
@@ -220,6 +229,11 @@ enum {
TASK_INPUT_TYPE__DATA_BLOCK
,
};
enum
{
TASK_TRIGGER_STATUS__IN_ACTIVE
=
1
,
TASK_TRIGGER_STATUS__ACTIVE
,
};
struct
SStreamTask
{
int64_t
streamId
;
int32_t
taskId
;
...
...
@@ -262,8 +276,16 @@ struct SStreamTask {
SStreamQueue
*
inputQueue
;
SStreamQueue
*
outputQueue
;
// trigger
int8_t
triggerStatus
;
int64_t
triggerParam
;
void
*
timer
;
// application storage
// void* ahandle;
// msg handle
SMsgCb
*
pMsgCb
;
};
SStreamTask
*
tNewSStreamTask
(
int64_t
streamId
);
...
...
@@ -292,6 +314,13 @@ static FORCE_INLINE int32_t streamTaskInput(SStreamTask* pTask, SStreamQueueItem
taosWriteQitem
(
pTask
->
inputQueue
->
queue
,
pItem
);
}
else
if
(
pItem
->
type
==
STREAM_INPUT__CHECKPOINT
)
{
taosWriteQitem
(
pTask
->
inputQueue
->
queue
,
pItem
);
}
else
if
(
pItem
->
type
==
STREAM_INPUT__TRIGGER
)
{
taosWriteQitem
(
pTask
->
inputQueue
->
queue
,
pItem
);
}
if
(
pItem
->
type
!=
STREAM_INPUT__TRIGGER
&&
pItem
->
type
!=
STREAM_INPUT__CHECKPOINT
&&
pTask
->
triggerParam
!=
0
&&
pTask
->
triggerStatus
==
TASK_TRIGGER_STATUS__IN_ACTIVE
)
{
atomic_store_8
(
&
pTask
->
triggerStatus
,
TASK_TRIGGER_STATUS__ACTIVE
);
}
// TODO: back pressure
...
...
@@ -370,7 +399,8 @@ typedef struct {
int32_t
tDecodeStreamDispatchReq
(
SDecoder
*
pDecoder
,
SStreamDispatchReq
*
pReq
);
int32_t
streamTriggerByWrite
(
SStreamTask
*
pTask
,
int32_t
vgId
,
SMsgCb
*
pMsgCb
);
int32_t
streamLaunchByWrite
(
SStreamTask
*
pTask
,
int32_t
vgId
,
SMsgCb
*
pMsgCb
);
int32_t
streamSetupTrigger
(
SStreamTask
*
pTask
);
int32_t
streamTaskRun
(
SStreamTask
*
pTask
);
...
...
include/libs/sync/sync.h
浏览文件 @
e52429e3
...
...
@@ -24,7 +24,7 @@ extern "C" {
#include "tdef.h"
#include "tmsgcb.h"
#define SYNC_INDEX_BEGIN 0
#define SYNC_INDEX_BEGIN
0
#define SYNC_INDEX_INVALID -1
typedef
uint64_t
SyncNodeId
;
...
...
@@ -44,14 +44,6 @@ typedef enum {
TAOS_SYNC_STATE_ERROR
=
103
,
}
ESyncState
;
typedef
enum
{
TAOS_SYNC_PROPOSE_SUCCESS
=
0
,
TAOS_SYNC_PROPOSE_NOT_LEADER
=
1
,
TAOS_SYNC_ONLY_ONE_REPLICA
=
2
,
TAOS_SYNC_NOT_IN_NEW_CONFIG
=
3
,
TAOS_SYNC_OTHER_ERROR
=
100
,
}
ESyncProposeCode
;
typedef
enum
{
TAOS_SYNC_FSM_CB_SUCCESS
=
0
,
TAOS_SYNC_FSM_CB_OTHER_ERROR
=
1
,
...
...
include/util/taoserror.h
浏览文件 @
e52429e3
...
...
@@ -132,7 +132,8 @@ int32_t* taosGetErrno();
#define TSDB_CODE_MND_APP_ERROR TAOS_DEF_ERROR_CODE(0, 0x0300)
#define TSDB_CODE_MND_NOT_READY TAOS_DEF_ERROR_CODE(0, 0x0301)
#define TSDB_CODE_MND_NO_RIGHTS TAOS_DEF_ERROR_CODE(0, 0x0302)
#define TSDB_CODE_MND_INVALID_CONNECTION TAOS_DEF_ERROR_CODE(0, 0x0303)
#define TSDB_CODE_MND_USER_DISABLED TAOS_DEF_ERROR_CODE(0, 0x0303)
#define TSDB_CODE_MND_INVALID_CONNECTION TAOS_DEF_ERROR_CODE(0, 0x0304)
// mnode-show
#define TSDB_CODE_MND_INVALID_SHOWOBJ TAOS_DEF_ERROR_CODE(0, 0x0310)
...
...
@@ -411,6 +412,8 @@ int32_t* taosGetErrno();
#define TSDB_CODE_SYN_INVALID_MSGTYPE TAOS_DEF_ERROR_CODE(0, 0x090A)
#define TSDB_CODE_SYN_NOT_LEADER TAOS_DEF_ERROR_CODE(0, 0x0910)
#define TSDB_CODE_SYN_ONE_REPLICA TAOS_DEF_ERROR_CODE(0, 0x0911)
#define TSDB_CODE_SYN_NOT_IN_NEW_CONFIG TAOS_DEF_ERROR_CODE(0, 0x0912)
#define TSDB_CODE_SYN_INTERNAL_ERROR TAOS_DEF_ERROR_CODE(0, 0x09FF)
// tq
...
...
@@ -434,6 +437,7 @@ int32_t* taosGetErrno();
#define TSDB_CODE_WAL_SIZE_LIMIT TAOS_DEF_ERROR_CODE(0, 0x1002)
#define TSDB_CODE_WAL_INVALID_VER TAOS_DEF_ERROR_CODE(0, 0x1003)
#define TSDB_CODE_WAL_OUT_OF_MEMORY TAOS_DEF_ERROR_CODE(0, 0x1004)
#define TSDB_CODE_WAL_LOG_NOT_EXIST TAOS_DEF_ERROR_CODE(0, 0x1005)
// http
#define TSDB_CODE_HTTP_SERVER_OFFLINE TAOS_DEF_ERROR_CODE(0, 0x1100) //"http server is not online"
...
...
include/util/tdef.h
浏览文件 @
e52429e3
...
...
@@ -243,6 +243,7 @@ typedef enum ELogicConditionType {
#define TSDB_USET_PASSWORD_LEN 129
#define TSDB_VERSION_LEN 12
#define TSDB_LABEL_LEN 8
#define TSDB_JOB_STATUS_LEN 32
#define TSDB_CLUSTER_ID_LEN 40
#define TSDB_FQDN_LEN 128
...
...
source/client/inc/clientInt.h
浏览文件 @
e52429e3
...
...
@@ -213,6 +213,7 @@ typedef struct SRequestObj {
SArray
*
tableList
;
SQueryExecMetric
metric
;
SRequestSendRecvBody
body
;
bool
stableQuery
;
uint32_t
prevCode
;
//previous error code: todo refactor, add update flag for catalog
uint32_t
retry
;
...
...
@@ -294,7 +295,7 @@ void* openTransporter(const char* user, const char* auth, int32_t numOfThreads);
bool
persistConnForSpecificMsg
(
void
*
parenct
,
tmsg_t
msgType
);
void
processMsgFromServer
(
void
*
parent
,
SRpcMsg
*
pMsg
,
SEpSet
*
pEpSet
);
TAOS
*
taos_connect_internal
(
const
char
*
ip
,
const
char
*
user
,
const
char
*
pass
,
const
char
*
auth
,
const
char
*
db
,
STscObj
*
taos_connect_internal
(
const
char
*
ip
,
const
char
*
user
,
const
char
*
pass
,
const
char
*
auth
,
const
char
*
db
,
uint16_t
port
,
int
connType
);
SRequestObj
*
launchQuery
(
STscObj
*
pTscObj
,
const
char
*
sql
,
int
sqlLen
);
...
...
@@ -305,6 +306,8 @@ int32_t getPlan(SRequestObj* pRequest, SQuery* pQuery, SQueryPlan** pPlan, SArra
int32_t
buildRequest
(
STscObj
*
pTscObj
,
const
char
*
sql
,
int
sqlLen
,
SRequestObj
**
pRequest
);
void
taos_close_internal
(
void
*
taos
);
// --- heartbeat
// global, called by mgmt
int
hbMgrInit
();
...
...
source/client/inc/clientStmt.h
浏览文件 @
e52429e3
...
...
@@ -107,7 +107,7 @@ typedef struct STscStmt {
#define STMT_RET(c) do { int32_t _code = c; if (_code != TSDB_CODE_SUCCESS) { terrno = _code; } return _code; } while (0)
#define STMT_ERR_JRET(c) do { code = c; if (code != TSDB_CODE_SUCCESS) { terrno = code; goto _return; } } while (0)
TAOS_STMT
*
stmtInit
(
TAOS
*
taos
);
TAOS_STMT
*
stmtInit
(
STscObj
*
taos
);
int
stmtClose
(
TAOS_STMT
*
stmt
);
int
stmtExec
(
TAOS_STMT
*
stmt
);
const
char
*
stmtErrstr
(
TAOS_STMT
*
stmt
);
...
...
source/client/src/clientHb.c
浏览文件 @
e52429e3
...
...
@@ -174,7 +174,7 @@ static int32_t hbQueryHbRspHandle(SAppHbMgr *pAppHbMgr, SClientHbRsp *pRsp) {
}
if
(
pRsp
->
query
->
killConnection
)
{
taos_close
(
pTscObj
);
taos_close
_internal
(
pTscObj
);
}
if
(
pRsp
->
query
->
pQnodeList
)
{
...
...
@@ -310,11 +310,12 @@ int32_t hbBuildQueryDesc(SQueryHbReqBasic *hbBasic, STscObj *pObj) {
}
tstrncpy
(
desc
.
sql
,
pRequest
->
sqlstr
,
sizeof
(
desc
.
sql
));
desc
.
stime
=
pRequest
->
metric
.
start
;
desc
.
stime
=
pRequest
->
metric
.
start
/
1000
;
desc
.
queryId
=
pRequest
->
requestId
;
desc
.
useconds
=
now
-
pRequest
->
metric
.
start
;
desc
.
reqRid
=
pRequest
->
self
;
desc
.
pid
=
hbBasic
->
pid
;
desc
.
stableQuery
=
pRequest
->
stableQuery
;
taosGetFqdn
(
desc
.
fqdn
);
desc
.
subPlanNum
=
pRequest
->
body
.
pDag
?
pRequest
->
body
.
pDag
->
numOfSubplans
:
0
;
...
...
@@ -329,6 +330,7 @@ int32_t hbBuildQueryDesc(SQueryHbReqBasic *hbBasic, STscObj *pObj) {
if
(
code
)
{
taosArrayDestroy
(
desc
.
subDesc
);
desc
.
subDesc
=
NULL
;
desc
.
subPlanNum
=
0
;
}
}
else
{
desc
.
subDesc
=
NULL
;
...
...
@@ -350,19 +352,24 @@ int32_t hbGetQueryBasicInfo(SClientHbKey *connKey, SClientHbReq *req) {
return
TSDB_CODE_QRY_APP_ERROR
;
}
int32_t
numOfQueries
=
pTscObj
->
pRequests
?
taosHashGetSize
(
pTscObj
->
pRequests
)
:
0
;
if
(
numOfQueries
<=
0
)
{
releaseTscObj
(
connKey
->
tscRid
);
tscDebug
(
"no queries on connection"
);
return
TSDB_CODE_QRY_APP_ERROR
;
}
SQueryHbReqBasic
*
hbBasic
=
(
SQueryHbReqBasic
*
)
taosMemoryCalloc
(
1
,
sizeof
(
SQueryHbReqBasic
));
if
(
NULL
==
hbBasic
)
{
tscError
(
"calloc %d failed"
,
(
int32_t
)
sizeof
(
SQueryHbReqBasic
));
releaseTscObj
(
connKey
->
tscRid
);
return
TSDB_CODE_QRY_OUT_OF_MEMORY
;
}
hbBasic
->
connId
=
pTscObj
->
connId
;
hbBasic
->
pid
=
taosGetPId
();
taosGetAppName
(
hbBasic
->
app
,
NULL
);
int32_t
numOfQueries
=
pTscObj
->
pRequests
?
taosHashGetSize
(
pTscObj
->
pRequests
)
:
0
;
if
(
numOfQueries
<=
0
)
{
req
->
query
=
hbBasic
;
releaseTscObj
(
connKey
->
tscRid
);
tscDebug
(
"no queries on connection"
);
return
TSDB_CODE_SUCCESS
;
}
hbBasic
->
queryDesc
=
taosArrayInit
(
numOfQueries
,
sizeof
(
SQueryDesc
));
if
(
NULL
==
hbBasic
->
queryDesc
)
{
...
...
@@ -372,9 +379,6 @@ int32_t hbGetQueryBasicInfo(SClientHbKey *connKey, SClientHbReq *req) {
return
TSDB_CODE_QRY_OUT_OF_MEMORY
;
}
hbBasic
->
connId
=
pTscObj
->
connId
;
hbBasic
->
pid
=
taosGetPId
();
taosGetAppName
(
hbBasic
->
app
,
NULL
);
int32_t
code
=
hbBuildQueryDesc
(
hbBasic
,
pTscObj
);
if
(
code
)
{
...
...
source/client/src/clientImpl.c
浏览文件 @
e52429e3
...
...
@@ -58,7 +58,7 @@ static char* getClusterKey(const char* user, const char* auth, const char* ip, i
static
STscObj
*
taosConnectImpl
(
const
char
*
user
,
const
char
*
auth
,
const
char
*
db
,
__taos_async_fn_t
fp
,
void
*
param
,
SAppInstInfo
*
pAppInfo
,
int
connType
);
TAOS
*
taos_connect_internal
(
const
char
*
ip
,
const
char
*
user
,
const
char
*
pass
,
const
char
*
auth
,
const
char
*
db
,
STscObj
*
taos_connect_internal
(
const
char
*
ip
,
const
char
*
user
,
const
char
*
pass
,
const
char
*
auth
,
const
char
*
db
,
uint16_t
port
,
int
connType
)
{
if
(
taos_init
()
!=
TSDB_CODE_SUCCESS
)
{
return
NULL
;
...
...
@@ -692,6 +692,8 @@ SRequestObj* launchQuery(STscObj* pTscObj, const char* sql, int sqlLen) {
return
pRequest
;
}
pRequest
->
stableQuery
=
pQuery
->
stableQuery
;
return
launchQueryImpl
(
pRequest
,
pQuery
,
false
,
NULL
);
}
...
...
@@ -917,7 +919,7 @@ STscObj* taosConnectImpl(const char* user, const char* auth, const char* db, __t
terrno
=
pRequest
->
code
;
destroyRequest
(
pRequest
);
taos_close
(
pTscObj
);
taos_close
_internal
(
pTscObj
);
pTscObj
=
NULL
;
}
else
{
tscDebug
(
"0x%"
PRIx64
" connection is opening, connId:%u, dnodeConn:%p, reqId:0x%"
PRIx64
,
pTscObj
->
id
,
...
...
@@ -952,8 +954,8 @@ static SMsgSendInfo* buildConnectMsg(SRequestObj* pRequest) {
taosMemoryFreeClear
(
db
);
connectReq
.
connType
=
pObj
->
connType
;
connectReq
.
pid
=
htonl
(
appInfo
.
pid
)
;
connectReq
.
startTime
=
htobe64
(
appInfo
.
startTime
)
;
connectReq
.
pid
=
appInfo
.
pid
;
connectReq
.
startTime
=
appInfo
.
startTime
;
tstrncpy
(
connectReq
.
app
,
appInfo
.
appName
,
sizeof
(
connectReq
.
app
));
tstrncpy
(
connectReq
.
user
,
pObj
->
user
,
sizeof
(
connectReq
.
user
));
...
...
@@ -1081,7 +1083,12 @@ TAOS* taos_connect_auth(const char* ip, const char* user, const char* auth, cons
return
NULL
;
}
return
taos_connect_internal
(
ip
,
user
,
NULL
,
auth
,
db
,
port
,
CONN_TYPE__QUERY
);
STscObj
*
pObj
=
taos_connect_internal
(
ip
,
user
,
NULL
,
auth
,
db
,
port
,
CONN_TYPE__QUERY
);
if
(
pObj
)
{
return
(
TAOS
*
)
pObj
->
id
;
}
return
(
TAOS
*
)
0
;
}
TAOS
*
taos_connect_l
(
const
char
*
ip
,
int
ipLen
,
const
char
*
user
,
int
userLen
,
const
char
*
pass
,
int
passLen
,
...
...
source/client/src/clientMain.c
浏览文件 @
e52429e3
...
...
@@ -97,10 +97,15 @@ TAOS *taos_connect(const char *ip, const char *user, const char *pass, const cha
pass
=
TSDB_DEFAULT_PASS
;
}
return
taos_connect_internal
(
ip
,
user
,
pass
,
NULL
,
db
,
port
,
CONN_TYPE__QUERY
);
STscObj
*
pObj
=
taos_connect_internal
(
ip
,
user
,
pass
,
NULL
,
db
,
port
,
CONN_TYPE__QUERY
);
if
(
pObj
)
{
return
(
TAOS
*
)
pObj
->
id
;
}
return
(
TAOS
*
)
0
;
}
void
taos_close
(
TAOS
*
taos
)
{
void
taos_close
_internal
(
void
*
taos
)
{
if
(
taos
==
NULL
)
{
return
;
}
...
...
@@ -111,6 +116,17 @@ void taos_close(TAOS *taos) {
taosRemoveRef
(
clientConnRefPool
,
pTscObj
->
id
);
}
void
taos_close
(
TAOS
*
taos
)
{
STscObj
*
pObj
=
acquireTscObj
((
int64_t
)
taos
);
if
(
NULL
==
pObj
)
{
return
;
}
taos_close_internal
(
pObj
);
releaseTscObj
((
int64_t
)
taos
);
}
int
taos_errno
(
TAOS_RES
*
tres
)
{
if
(
tres
==
NULL
)
{
return
terrno
;
...
...
@@ -190,29 +206,36 @@ static void syncQueryFn(void *param, void *res, int32_t code) {
}
TAOS_RES
*
taos_query
(
TAOS
*
taos
,
const
char
*
sql
)
{
if
(
taos
==
NULL
||
sql
==
NULL
)
{
STscObj
*
pTscObj
=
acquireTscObj
((
int64_t
)
taos
);
if
(
pTscObj
==
NULL
||
sql
==
NULL
)
{
terrno
=
TSDB_CODE_TSC_DISCONNECTED
;
return
NULL
;
}
STscObj
*
pTscObj
=
(
STscObj
*
)
taos
;
#if SYNC_ON_TOP_OF_ASYNC
SSyncQueryParam
*
param
=
taosMemoryCalloc
(
1
,
sizeof
(
SSyncQueryParam
));
tsem_init
(
&
param
->
sem
,
0
,
0
);
taos_query_a
(
pTscObj
,
sql
,
syncQueryFn
,
param
);
taos_query_a
(
taos
,
sql
,
syncQueryFn
,
param
);
tsem_wait
(
&
param
->
sem
);
releaseTscObj
((
int64_t
)
taos
);
return
param
->
pRequest
;
#else
size_t
sqlLen
=
strlen
(
sql
);
if
(
sqlLen
>
(
size_t
)
TSDB_MAX_ALLOWED_SQL_LEN
)
{
releaseTscObj
((
int64_t
)
taos
);
tscError
(
"sql string exceeds max length:%d"
,
TSDB_MAX_ALLOWED_SQL_LEN
);
terrno
=
TSDB_CODE_TSC_EXCEED_SQL_LIMIT
;
return
NULL
;
}
return
execQuery
(
pTscObj
,
sql
,
sqlLen
);
TAOS_RES
*
pRes
=
execQuery
(
pTscObj
,
sql
,
sqlLen
);
releaseTscObj
((
int64_t
)
taos
);
return
pRes
;
#endif
}
...
...
@@ -429,13 +452,15 @@ int taos_result_precision(TAOS_RES *res) {
}
int
taos_select_db
(
TAOS
*
taos
,
const
char
*
db
)
{
STscObj
*
pObj
=
(
STscObj
*
)
taos
;
STscObj
*
pObj
=
acquireTscObj
((
int64_t
)
taos
)
;
if
(
pObj
==
NULL
)
{
releaseTscObj
((
int64_t
)
taos
);
terrno
=
TSDB_CODE_TSC_DISCONNECTED
;
return
TSDB_CODE_TSC_DISCONNECTED
;
}
if
(
db
==
NULL
||
strlen
(
db
)
==
0
)
{
releaseTscObj
((
int64_t
)
taos
);
terrno
=
TSDB_CODE_TSC_INVALID_INPUT
;
return
terrno
;
}
...
...
@@ -447,6 +472,7 @@ int taos_select_db(TAOS *taos, const char *db) {
int32_t
code
=
taos_errno
(
pRequest
);
taos_free_result
(
pRequest
);
releaseTscObj
((
int64_t
)
taos
);
return
code
;
}
...
...
@@ -593,19 +619,26 @@ int *taos_get_column_data_offset(TAOS_RES *res, int columnIndex) {
int
taos_validate_sql
(
TAOS
*
taos
,
const
char
*
sql
)
{
return
true
;
}
void
taos_reset_current_db
(
TAOS
*
taos
)
{
if
(
taos
==
NULL
)
{
STscObj
*
pTscObj
=
acquireTscObj
((
int64_t
)
taos
);
if
(
pTscObj
==
NULL
)
{
terrno
=
TSDB_CODE_TSC_DISCONNECTED
;
return
;
}
resetConnectDB
(
taos
);
resetConnectDB
(
pTscObj
);
releaseTscObj
((
int64_t
)
taos
);
}
const
char
*
taos_get_server_info
(
TAOS
*
taos
)
{
if
(
taos
==
NULL
)
{
STscObj
*
pTscObj
=
acquireTscObj
((
int64_t
)
taos
);
if
(
pTscObj
==
NULL
)
{
terrno
=
TSDB_CODE_TSC_DISCONNECTED
;
return
NULL
;
}
STscObj
*
pTscObj
=
(
STscObj
*
)
taos
;
releaseTscObj
((
int64_t
)
taos
);
return
pTscObj
->
ver
;
}
...
...
@@ -637,6 +670,7 @@ void retrieveMetaCallback(SMetaData *pResultMeta, void *param, int32_t code) {
if
(
code
==
TSDB_CODE_SUCCESS
)
{
code
=
qAnalyseSqlSemantic
(
pWrapper
->
pCtx
,
&
pWrapper
->
catalogReq
,
pResultMeta
,
pQuery
);
pRequest
->
stableQuery
=
pQuery
->
stableQuery
;
}
if
(
code
==
TSDB_CODE_SUCCESS
)
{
...
...
@@ -670,10 +704,14 @@ void retrieveMetaCallback(SMetaData *pResultMeta, void *param, int32_t code) {
}
void
taos_query_a
(
TAOS
*
taos
,
const
char
*
sql
,
__taos_async_fn_t
fp
,
void
*
param
)
{
ASSERT
(
fp
!=
NULL
);
if
(
taos
==
NULL
||
sql
==
NULL
)
{
STscObj
*
pTscObj
=
acquireTscObj
((
int64_t
)
taos
);
if
(
pTscObj
==
NULL
||
sql
==
NULL
||
NULL
==
fp
)
{
terrno
=
TSDB_CODE_INVALID_PARA
;
if
(
pTscObj
)
{
releaseTscObj
((
int64_t
)
taos
);
}
else
{
terrno
=
TSDB_CODE_TSC_DISCONNECTED
;
}
fp
(
param
,
NULL
,
terrno
);
return
;
}
...
...
@@ -688,7 +726,7 @@ void taos_query_a(TAOS *taos, const char *sql, __taos_async_fn_t fp, void *param
}
SRequestObj
*
pRequest
=
NULL
;
int32_t
code
=
buildRequest
(
taos
,
sql
,
sqlLen
,
&
pRequest
);
int32_t
code
=
buildRequest
(
pTscObj
,
sql
,
sqlLen
,
&
pRequest
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
terrno
=
code
;
fp
(
param
,
NULL
,
terrno
);
...
...
@@ -888,13 +926,18 @@ int taos_load_table_info(TAOS *taos, const char *tableNameList) {
}
TAOS_STMT
*
taos_stmt_init
(
TAOS
*
taos
)
{
if
(
taos
==
NULL
)
{
tscError
(
"NULL parameter for %s"
,
__FUNCTION__
);
terrno
=
TSDB_CODE_INVALID_PARA
;
STscObj
*
pObj
=
acquireTscObj
((
int64_t
)
taos
);
if
(
NULL
==
pObj
)
{
tscError
(
"invalid parameter for %s"
,
__FUNCTION__
);
terrno
=
TSDB_CODE_TSC_DISCONNECTED
;
return
NULL
;
}
return
stmtInit
(
taos
);
TAOS_STMT
*
pStmt
=
stmtInit
(
pObj
);
releaseTscObj
((
int64_t
)
taos
);
return
pStmt
;
}
int
taos_stmt_prepare
(
TAOS_STMT
*
stmt
,
const
char
*
sql
,
unsigned
long
length
)
{
...
...
source/client/src/clientSml.c
浏览文件 @
e52429e3
...
...
@@ -309,7 +309,7 @@ static int32_t smlApplySchemaAction(SSmlHandle *info, SSchemaAction *action) {
case
SCHEMA_ACTION_ADD_COLUMN
:
{
int
n
=
sprintf
(
result
,
"alter stable `%s` add column "
,
action
->
alterSTable
.
sTableName
);
smlBuildColumnDescription
(
action
->
alterSTable
.
field
,
result
+
n
,
capacity
-
n
,
&
outBytes
);
TAOS_RES
*
res
=
taos_query
(
info
->
taos
,
result
);
// TODO async doAsyncQuery
TAOS_RES
*
res
=
taos_query
(
(
TAOS
*
)
info
->
taos
->
id
,
result
);
// TODO async doAsyncQuery
code
=
taos_errno
(
res
);
const
char
*
errStr
=
taos_errstr
(
res
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
...
...
@@ -323,7 +323,7 @@ static int32_t smlApplySchemaAction(SSmlHandle *info, SSchemaAction *action) {
case
SCHEMA_ACTION_ADD_TAG
:
{
int
n
=
sprintf
(
result
,
"alter stable `%s` add tag "
,
action
->
alterSTable
.
sTableName
);
smlBuildColumnDescription
(
action
->
alterSTable
.
field
,
result
+
n
,
capacity
-
n
,
&
outBytes
);
TAOS_RES
*
res
=
taos_query
(
info
->
taos
,
result
);
// TODO async doAsyncQuery
TAOS_RES
*
res
=
taos_query
(
(
TAOS
*
)
info
->
taos
->
id
,
result
);
// TODO async doAsyncQuery
code
=
taos_errno
(
res
);
const
char
*
errStr
=
taos_errstr
(
res
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
...
...
@@ -337,7 +337,7 @@ static int32_t smlApplySchemaAction(SSmlHandle *info, SSchemaAction *action) {
case
SCHEMA_ACTION_CHANGE_COLUMN_SIZE
:
{
int
n
=
sprintf
(
result
,
"alter stable `%s` modify column "
,
action
->
alterSTable
.
sTableName
);
smlBuildColumnDescription
(
action
->
alterSTable
.
field
,
result
+
n
,
capacity
-
n
,
&
outBytes
);
TAOS_RES
*
res
=
taos_query
(
info
->
taos
,
result
);
// TODO async doAsyncQuery
TAOS_RES
*
res
=
taos_query
(
(
TAOS
*
)
info
->
taos
->
id
,
result
);
// TODO async doAsyncQuery
code
=
taos_errno
(
res
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
uError
(
"SML:0x%"
PRIx64
" apply schema action. error : %s"
,
info
->
id
,
taos_errstr
(
res
));
...
...
@@ -350,7 +350,7 @@ static int32_t smlApplySchemaAction(SSmlHandle *info, SSchemaAction *action) {
case
SCHEMA_ACTION_CHANGE_TAG_SIZE
:
{
int
n
=
sprintf
(
result
,
"alter stable `%s` modify tag "
,
action
->
alterSTable
.
sTableName
);
smlBuildColumnDescription
(
action
->
alterSTable
.
field
,
result
+
n
,
capacity
-
n
,
&
outBytes
);
TAOS_RES
*
res
=
taos_query
(
info
->
taos
,
result
);
// TODO async doAsyncQuery
TAOS_RES
*
res
=
taos_query
(
(
TAOS
*
)
info
->
taos
->
id
,
result
);
// TODO async doAsyncQuery
code
=
taos_errno
(
res
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
uError
(
"SML:0x%"
PRIx64
" apply schema action. error : %s"
,
info
->
id
,
taos_errstr
(
res
));
...
...
@@ -405,7 +405,7 @@ static int32_t smlApplySchemaAction(SSmlHandle *info, SSchemaAction *action) {
pos
--
;
++
freeBytes
;
outBytes
=
snprintf
(
pos
,
freeBytes
,
")"
);
TAOS_RES
*
res
=
taos_query
(
info
->
taos
,
result
);
TAOS_RES
*
res
=
taos_query
(
(
TAOS
*
)
info
->
taos
->
id
,
result
);
code
=
taos_errno
(
res
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
uError
(
"SML:0x%"
PRIx64
" apply schema action. error : %s"
,
info
->
id
,
taos_errstr
(
res
));
...
...
@@ -1453,9 +1453,9 @@ static void smlDestroyInfo(SSmlHandle *info) {
taosMemoryFreeClear
(
info
);
}
static
SSmlHandle
*
smlBuildSmlInfo
(
TAOS
*
taos
,
SRequestObj
*
request
,
SMLProtocolType
protocol
,
int8_t
precision
)
{
int32_t
code
=
TSDB_CODE_SUCCESS
;
SSmlHandle
*
info
=
(
SSmlHandle
*
)
taosMemoryCalloc
(
1
,
sizeof
(
SSmlHandle
));
static
SSmlHandle
*
smlBuildSmlInfo
(
STscObj
*
pTscObj
,
SRequestObj
*
request
,
SMLProtocolType
protocol
,
int8_t
precision
)
{
int32_t
code
=
TSDB_CODE_SUCCESS
;
SSmlHandle
*
info
=
(
SSmlHandle
*
)
taosMemoryCalloc
(
1
,
sizeof
(
SSmlHandle
));
if
(
NULL
==
info
)
{
return
NULL
;
}
...
...
@@ -1476,7 +1476,7 @@ static SSmlHandle *smlBuildSmlInfo(TAOS *taos, SRequestObj *request, SMLProtocol
}
((
SVnodeModifOpStmt
*
)(
info
->
pQuery
->
pRoot
))
->
payloadType
=
PAYLOAD_TYPE_KV
;
info
->
taos
=
(
STscObj
*
)
taos
;
info
->
taos
=
pTscObj
;
code
=
catalogGetHandle
(
info
->
taos
->
pAppInfo
->
clusterId
,
&
info
->
pCatalog
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
uError
(
"SML:0x%"
PRIx64
" get catalog error %d"
,
info
->
id
,
code
);
...
...
@@ -2433,14 +2433,22 @@ static void smlInsertCallback(void *param, void *res, int32_t code) {
*
*/
TAOS_RES
*
taos_schemaless_insert
(
TAOS
*
taos
,
char
*
lines
[],
int
numLines
,
int
protocol
,
int
precision
)
{
SRequestObj
*
request
=
(
SRequestObj
*
)
createRequest
((
STscObj
*
)
taos
,
TSDB_SQL_INSERT
);
if
(
!
request
)
{
TAOS_RES
*
taos_schemaless_insert
(
TAOS
*
taos
,
char
*
lines
[],
int
numLines
,
int
protocol
,
int
precision
)
{
STscObj
*
pTscObj
=
acquireTscObj
((
int64_t
)
taos
);
if
(
NULL
==
pTscObj
)
{
terrno
=
TSDB_CODE_TSC_DISCONNECTED
;
uError
(
"SML:taos_schemaless_insert invalid taos"
);
return
NULL
;
}
SRequestObj
*
request
=
(
SRequestObj
*
)
createRequest
(
pTscObj
,
TSDB_SQL_INSERT
);
if
(
!
request
){
releaseTscObj
((
int64_t
)
taos
);
uError
(
"SML:taos_schemaless_insert error request is null"
);
return
NULL
;
}
((
STscObj
*
)
taos
)
->
schemalessType
=
1
;
pTscObj
->
schemalessType
=
1
;
SSmlMsgBuf
msg
=
{
ERROR_MSG_BUF_DEFAULT_SIZE
,
request
->
msgBuf
};
int
cnt
=
ceil
(((
double
)
numLines
)
/
LINE_BATCH
);
...
...
@@ -2455,7 +2463,7 @@ TAOS_RES *taos_schemaless_insert(TAOS *taos, char *lines[], int numLines, int pr
goto
end
;
}
if
(
isSchemalessDb
(((
STscObj
*
)
taos
),
request
)
!=
TSDB_CODE_SUCCESS
)
{
if
(
isSchemalessDb
(
pTscObj
,
request
)
!=
TSDB_CODE_SUCCESS
)
{
request
->
code
=
TSDB_CODE_SML_INVALID_DB_CONF
;
smlBuildInvalidDataMsg
(
&
msg
,
"Cannot write data to a non schemaless database"
,
NULL
);
goto
end
;
...
...
@@ -2481,14 +2489,14 @@ TAOS_RES *taos_schemaless_insert(TAOS *taos, char *lines[], int numLines, int pr
}
for
(
int
i
=
0
;
i
<
cnt
;
++
i
)
{
SRequestObj
*
req
=
(
SRequestObj
*
)
createRequest
((
STscObj
*
)
taos
,
TSDB_SQL_INSERT
);
if
(
!
req
)
{
SRequestObj
*
req
=
(
SRequestObj
*
)
createRequest
(
pTscObj
,
TSDB_SQL_INSERT
);
if
(
!
req
)
{
request
->
code
=
TSDB_CODE_OUT_OF_MEMORY
;
uError
(
"SML:taos_schemaless_insert error request is null"
);
goto
end
;
}
SSmlHandle
*
info
=
smlBuildSmlInfo
(
taos
,
req
,
(
SMLProtocolType
)
protocol
,
precision
);
if
(
!
info
)
{
SSmlHandle
*
info
=
smlBuildSmlInfo
(
pTscObj
,
req
,
(
SMLProtocolType
)
protocol
,
precision
);
if
(
!
info
)
{
request
->
code
=
TSDB_CODE_OUT_OF_MEMORY
;
uError
(
"SML:taos_schemaless_insert error SSmlHandle is null"
);
goto
end
;
...
...
@@ -2520,8 +2528,9 @@ TAOS_RES *taos_schemaless_insert(TAOS *taos, char *lines[], int numLines, int pr
end:
taosThreadSpinDestroy
(
&
params
.
lock
);
tsem_destroy
(
&
params
.
sem
);
// ((STscObj *)taos)->schemalessType = 0;
((
STscObj
*
)
taos
)
->
schemalessType
=
1
;
// ((STscObj *)taos)->schemalessType = 0;
pTscObj
->
schemalessType
=
1
;
uDebug
(
"resultend:%s"
,
request
->
msgBuf
);
return
(
TAOS_RES
*
)
request
;
releaseTscObj
((
int64_t
)
taos
);
return
(
TAOS_RES
*
)
request
;
}
source/client/src/clientStmt.c
浏览文件 @
e52429e3
...
...
@@ -478,7 +478,7 @@ int32_t stmtResetStmt(STscStmt* pStmt) {
return
TSDB_CODE_SUCCESS
;
}
TAOS_STMT
*
stmtInit
(
TAOS
*
taos
)
{
TAOS_STMT
*
stmtInit
(
STscObj
*
taos
)
{
STscObj
*
pObj
=
(
STscObj
*
)
taos
;
STscStmt
*
pStmt
=
NULL
;
...
...
source/client/src/tmq.c
浏览文件 @
e52429e3
...
...
@@ -992,6 +992,90 @@ CREATE_MSG_FAIL:
return
-
1
;
}
bool
tmqUpdateEp2
(
tmq_t
*
tmq
,
int32_t
epoch
,
SMqAskEpRsp
*
pRsp
)
{
bool
set
=
false
;
int32_t
topicNumGet
=
taosArrayGetSize
(
pRsp
->
topics
);
char
vgKey
[
TSDB_TOPIC_FNAME_LEN
+
22
];
tscDebug
(
"consumer %ld update ep epoch %d to epoch %d, topic num: %d"
,
tmq
->
consumerId
,
tmq
->
epoch
,
epoch
,
topicNumGet
);
SArray
*
newTopics
=
taosArrayInit
(
topicNumGet
,
sizeof
(
SMqClientTopic
));
if
(
newTopics
==
NULL
)
{
return
false
;
}
SHashObj
*
pHash
=
taosHashInit
(
64
,
MurmurHash3_32
,
false
,
HASH_NO_LOCK
);
if
(
pHash
==
NULL
)
{
taosArrayDestroy
(
newTopics
);
return
false
;
}
int32_t
topicNumCur
=
taosArrayGetSize
(
tmq
->
clientTopics
);
for
(
int32_t
i
=
0
;
i
<
topicNumCur
;
i
++
)
{
// find old topic
SMqClientTopic
*
pTopicCur
=
taosArrayGet
(
tmq
->
clientTopics
,
i
);
if
(
pTopicCur
->
vgs
)
{
int32_t
vgNumCur
=
taosArrayGetSize
(
pTopicCur
->
vgs
);
tscDebug
(
"consumer %ld new vg num: %d"
,
tmq
->
consumerId
,
vgNumCur
);
if
(
vgNumCur
==
0
)
break
;
for
(
int32_t
j
=
0
;
j
<
vgNumCur
;
j
++
)
{
SMqClientVg
*
pVgCur
=
taosArrayGet
(
pTopicCur
->
vgs
,
j
);
sprintf
(
vgKey
,
"%s:%d"
,
pTopicCur
->
topicName
,
pVgCur
->
vgId
);
tscDebug
(
"consumer %ld epoch %d vg %d build %s"
,
tmq
->
consumerId
,
epoch
,
pVgCur
->
vgId
,
vgKey
);
taosHashPut
(
pHash
,
vgKey
,
strlen
(
vgKey
),
&
pVgCur
->
currentOffset
,
sizeof
(
int64_t
));
}
break
;
}
}
for
(
int32_t
i
=
0
;
i
<
topicNumGet
;
i
++
)
{
SMqClientTopic
topic
=
{
0
};
SMqSubTopicEp
*
pTopicEp
=
taosArrayGet
(
pRsp
->
topics
,
i
);
topic
.
schema
=
pTopicEp
->
schema
;
taosHashClear
(
pHash
);
topic
.
topicName
=
strdup
(
pTopicEp
->
topic
);
tstrncpy
(
topic
.
db
,
pTopicEp
->
db
,
TSDB_DB_FNAME_LEN
);
tscDebug
(
"consumer %ld update topic: %s"
,
tmq
->
consumerId
,
topic
.
topicName
);
int32_t
vgNumGet
=
taosArrayGetSize
(
pTopicEp
->
vgs
);
topic
.
vgs
=
taosArrayInit
(
vgNumGet
,
sizeof
(
SMqClientVg
));
for
(
int32_t
j
=
0
;
j
<
vgNumGet
;
j
++
)
{
SMqSubVgEp
*
pVgEp
=
taosArrayGet
(
pTopicEp
->
vgs
,
j
);
sprintf
(
vgKey
,
"%s:%d"
,
topic
.
topicName
,
pVgEp
->
vgId
);
int64_t
*
pOffset
=
taosHashGet
(
pHash
,
vgKey
,
strlen
(
vgKey
));
int64_t
offset
=
tmq
->
resetOffsetCfg
;
if
(
pOffset
!=
NULL
)
{
offset
=
*
pOffset
;
}
tscDebug
(
"consumer %ld(epoch %d) offset of vg %d updated to %ld"
,
tmq
->
consumerId
,
epoch
,
pVgEp
->
vgId
,
offset
);
SMqClientVg
clientVg
=
{
.
pollCnt
=
0
,
.
currentOffset
=
offset
,
.
vgId
=
pVgEp
->
vgId
,
.
epSet
=
pVgEp
->
epSet
,
.
vgStatus
=
TMQ_VG_STATUS__IDLE
,
.
vgSkipCnt
=
0
,
};
taosArrayPush
(
topic
.
vgs
,
&
clientVg
);
set
=
true
;
}
taosArrayPush
(
newTopics
,
&
topic
);
}
if
(
tmq
->
clientTopics
)
taosArrayDestroy
(
tmq
->
clientTopics
);
taosHashCleanup
(
pHash
);
tmq
->
clientTopics
=
newTopics
;
if
(
taosArrayGetSize
(
tmq
->
clientTopics
)
==
0
)
atomic_store_8
(
&
tmq
->
status
,
TMQ_CONSUMER_STATUS__NO_TOPIC
);
else
atomic_store_8
(
&
tmq
->
status
,
TMQ_CONSUMER_STATUS__READY
);
atomic_store_32
(
&
tmq
->
epoch
,
epoch
);
return
set
;
}
bool
tmqUpdateEp
(
tmq_t
*
tmq
,
int32_t
epoch
,
SMqAskEpRsp
*
pRsp
)
{
/*printf("call update ep %d\n", epoch);*/
bool
set
=
false
;
...
...
source/common/src/systable.c
浏览文件 @
e52429e3
...
...
@@ -170,7 +170,9 @@ static const SSysDbTableSchema userTblDistSchema[] = {
static
const
SSysDbTableSchema
userUsersSchema
[]
=
{
{.
name
=
"name"
,
.
bytes
=
TSDB_USER_LEN
+
VARSTR_HEADER_SIZE
,
.
type
=
TSDB_DATA_TYPE_VARCHAR
},
{.
name
=
"privilege"
,
.
bytes
=
10
+
VARSTR_HEADER_SIZE
,
.
type
=
TSDB_DATA_TYPE_VARCHAR
},
{.
name
=
"super"
,
.
bytes
=
1
,
.
type
=
TSDB_DATA_TYPE_TINYINT
},
{.
name
=
"enable"
,
.
bytes
=
1
,
.
type
=
TSDB_DATA_TYPE_TINYINT
},
{.
name
=
"sysinfo"
,
.
bytes
=
1
,
.
type
=
TSDB_DATA_TYPE_TINYINT
},
{.
name
=
"create_time"
,
.
bytes
=
8
,
.
type
=
TSDB_DATA_TYPE_TIMESTAMP
},
};
...
...
@@ -255,8 +257,8 @@ static const SSysTableMeta infosMeta[] = {
static
const
SSysDbTableSchema
connectionsSchema
[]
=
{
{.
name
=
"conn_id"
,
.
bytes
=
4
,
.
type
=
TSDB_DATA_TYPE_UINT
},
{.
name
=
"user"
,
.
bytes
=
TSDB_USER_LEN
+
VARSTR_HEADER_SIZE
,
.
type
=
TSDB_DATA_TYPE_BINARY
},
{.
name
=
"
program
"
,
.
bytes
=
TSDB_APP_NAME_LEN
+
VARSTR_HEADER_SIZE
,
.
type
=
TSDB_DATA_TYPE_BINARY
},
{.
name
=
"pid"
,
.
bytes
=
4
,
.
type
=
TSDB_DATA_TYPE_INT
},
{.
name
=
"
app
"
,
.
bytes
=
TSDB_APP_NAME_LEN
+
VARSTR_HEADER_SIZE
,
.
type
=
TSDB_DATA_TYPE_BINARY
},
{.
name
=
"pid"
,
.
bytes
=
4
,
.
type
=
TSDB_DATA_TYPE_
U
INT
},
{.
name
=
"end_point"
,
.
bytes
=
TSDB_EP_LEN
+
VARSTR_HEADER_SIZE
,
.
type
=
TSDB_DATA_TYPE_BINARY
},
{.
name
=
"login_time"
,
.
bytes
=
8
,
.
type
=
TSDB_DATA_TYPE_TIMESTAMP
},
{.
name
=
"last_access"
,
.
bytes
=
8
,
.
type
=
TSDB_DATA_TYPE_TIMESTAMP
},
...
...
@@ -300,19 +302,18 @@ static const SSysDbTableSchema offsetSchema[] = {
};
static
const
SSysDbTableSchema
querySchema
[]
=
{
{.
name
=
"query_id"
,
.
bytes
=
4
,
.
type
=
TSDB_DATA_TYPE_INT
},
{.
name
=
"connId"
,
.
bytes
=
4
,
.
type
=
TSDB_DATA_TYPE_INT
},
{.
name
=
"query_id"
,
.
bytes
=
26
+
VARSTR_HEADER_SIZE
,
.
type
=
TSDB_DATA_TYPE_VARCHAR
},
{.
name
=
"req_id"
,
.
bytes
=
8
,
.
type
=
TSDB_DATA_TYPE_UBIGINT
},
{.
name
=
"connId"
,
.
bytes
=
4
,
.
type
=
TSDB_DATA_TYPE_UINT
},
{.
name
=
"app"
,
.
bytes
=
TSDB_APP_NAME_LEN
+
VARSTR_HEADER_SIZE
,
.
type
=
TSDB_DATA_TYPE_VARCHAR
},
{.
name
=
"pid"
,
.
bytes
=
4
,
.
type
=
TSDB_DATA_TYPE_INT
},
{.
name
=
"user"
,
.
bytes
=
TSDB_USER_LEN
+
VARSTR_HEADER_SIZE
,
.
type
=
TSDB_DATA_TYPE_VARCHAR
},
{.
name
=
"end_point"
,
.
bytes
=
TSDB_IPv4ADDR_LEN
+
6
+
VARSTR_HEADER_SIZE
,
.
type
=
TSDB_DATA_TYPE_VARCHAR
},
{.
name
=
"qid"
,
.
bytes
=
22
+
VARSTR_HEADER_SIZE
,
.
type
=
TSDB_DATA_TYPE_VARCHAR
},
{.
name
=
"create_time"
,
.
bytes
=
8
,
.
type
=
TSDB_DATA_TYPE_TIMESTAMP
},
{.
name
=
"time"
,
.
bytes
=
8
,
.
type
=
TSDB_DATA_TYPE_BIGINT
},
{.
name
=
"sql_obj_id"
,
.
bytes
=
QUERY_OBJ_ID_SIZE
+
VARSTR_HEADER_SIZE
,
.
type
=
TSDB_DATA_TYPE_VARCHAR
},
{.
name
=
"pid"
,
.
bytes
=
4
,
.
type
=
TSDB_DATA_TYPE_INT
},
{.
name
=
"ep"
,
.
bytes
=
TSDB_EP_LEN
+
VARSTR_HEADER_SIZE
,
.
type
=
TSDB_DATA_TYPE_VARCHAR
},
{.
name
=
"exec_usec"
,
.
bytes
=
8
,
.
type
=
TSDB_DATA_TYPE_BIGINT
},
{.
name
=
"stable_query"
,
.
bytes
=
1
,
.
type
=
TSDB_DATA_TYPE_BOOL
},
{.
name
=
"sub_
queries
"
,
.
bytes
=
4
,
.
type
=
TSDB_DATA_TYPE_INT
},
{.
name
=
"sub_
query_info
"
,
.
bytes
=
TSDB_SHOW_SUBQUERY_LEN
+
VARSTR_HEADER_SIZE
,
.
type
=
TSDB_DATA_TYPE_VARCHAR
},
{.
name
=
"sub_
num
"
,
.
bytes
=
4
,
.
type
=
TSDB_DATA_TYPE_INT
},
{.
name
=
"sub_
status
"
,
.
bytes
=
TSDB_SHOW_SUBQUERY_LEN
+
VARSTR_HEADER_SIZE
,
.
type
=
TSDB_DATA_TYPE_VARCHAR
},
{.
name
=
"sql"
,
.
bytes
=
TSDB_SHOW_SQL_LEN
+
VARSTR_HEADER_SIZE
,
.
type
=
TSDB_DATA_TYPE_VARCHAR
},
};
...
...
source/common/src/tmsg.c
浏览文件 @
e52429e3
...
...
@@ -210,6 +210,7 @@ static int32_t tSerializeSClientHbReq(SEncoder *pEncoder, const SClientHbReq *pR
if
(
tEncodeI64
(
pEncoder
,
desc
->
stime
)
<
0
)
return
-
1
;
if
(
tEncodeI64
(
pEncoder
,
desc
->
reqRid
)
<
0
)
return
-
1
;
if
(
tEncodeI32
(
pEncoder
,
desc
->
pid
)
<
0
)
return
-
1
;
if
(
tEncodeI8
(
pEncoder
,
desc
->
stableQuery
)
<
0
)
return
-
1
;
if
(
tEncodeCStr
(
pEncoder
,
desc
->
fqdn
)
<
0
)
return
-
1
;
if
(
tEncodeI32
(
pEncoder
,
desc
->
subPlanNum
)
<
0
)
return
-
1
;
...
...
@@ -218,7 +219,7 @@ static int32_t tSerializeSClientHbReq(SEncoder *pEncoder, const SClientHbReq *pR
for
(
int32_t
m
=
0
;
m
<
snum
;
++
m
)
{
SQuerySubDesc
*
sDesc
=
taosArrayGet
(
desc
->
subDesc
,
m
);
if
(
tEncodeI64
(
pEncoder
,
sDesc
->
tid
)
<
0
)
return
-
1
;
if
(
tEncode
I32
(
pEncoder
,
sDesc
->
status
)
<
0
)
return
-
1
;
if
(
tEncode
CStr
(
pEncoder
,
sDesc
->
status
)
<
0
)
return
-
1
;
}
}
}
else
{
...
...
@@ -265,6 +266,7 @@ static int32_t tDeserializeSClientHbReq(SDecoder *pDecoder, SClientHbReq *pReq)
if
(
tDecodeI64
(
pDecoder
,
&
desc
.
stime
)
<
0
)
return
-
1
;
if
(
tDecodeI64
(
pDecoder
,
&
desc
.
reqRid
)
<
0
)
return
-
1
;
if
(
tDecodeI32
(
pDecoder
,
&
desc
.
pid
)
<
0
)
return
-
1
;
if
(
tDecodeI8
(
pDecoder
,
(
int8_t
*
)
&
desc
.
stableQuery
)
<
0
)
return
-
1
;
if
(
tDecodeCStrTo
(
pDecoder
,
desc
.
fqdn
)
<
0
)
return
-
1
;
if
(
tDecodeI32
(
pDecoder
,
&
desc
.
subPlanNum
)
<
0
)
return
-
1
;
...
...
@@ -277,7 +279,7 @@ static int32_t tDeserializeSClientHbReq(SDecoder *pDecoder, SClientHbReq *pReq)
for
(
int32_t
m
=
0
;
m
<
snum
;
++
m
)
{
SQuerySubDesc
sDesc
=
{
0
};
if
(
tDecodeI64
(
pDecoder
,
&
sDesc
.
tid
)
<
0
)
return
-
1
;
if
(
tDecode
I32
(
pDecoder
,
&
sDesc
.
status
)
<
0
)
return
-
1
;
if
(
tDecode
CStrTo
(
pDecoder
,
sDesc
.
status
)
<
0
)
return
-
1
;
taosArrayPush
(
desc
.
subDesc
,
&
sDesc
);
}
}
...
...
@@ -1160,6 +1162,8 @@ int32_t tSerializeSCreateUserReq(void *buf, int32_t bufLen, SCreateUserReq *pReq
if
(
tStartEncode
(
&
encoder
)
<
0
)
return
-
1
;
if
(
tEncodeI8
(
&
encoder
,
pReq
->
createType
)
<
0
)
return
-
1
;
if
(
tEncodeI8
(
&
encoder
,
pReq
->
superUser
)
<
0
)
return
-
1
;
if
(
tEncodeI8
(
&
encoder
,
pReq
->
sysInfo
)
<
0
)
return
-
1
;
if
(
tEncodeI8
(
&
encoder
,
pReq
->
enable
)
<
0
)
return
-
1
;
if
(
tEncodeCStr
(
&
encoder
,
pReq
->
user
)
<
0
)
return
-
1
;
if
(
tEncodeCStr
(
&
encoder
,
pReq
->
pass
)
<
0
)
return
-
1
;
tEndEncode
(
&
encoder
);
...
...
@@ -1176,6 +1180,8 @@ int32_t tDeserializeSCreateUserReq(void *buf, int32_t bufLen, SCreateUserReq *pR
if
(
tStartDecode
(
&
decoder
)
<
0
)
return
-
1
;
if
(
tDecodeI8
(
&
decoder
,
&
pReq
->
createType
)
<
0
)
return
-
1
;
if
(
tDecodeI8
(
&
decoder
,
&
pReq
->
superUser
)
<
0
)
return
-
1
;
if
(
tDecodeI8
(
&
decoder
,
&
pReq
->
sysInfo
)
<
0
)
return
-
1
;
if
(
tDecodeI8
(
&
decoder
,
&
pReq
->
enable
)
<
0
)
return
-
1
;
if
(
tDecodeCStrTo
(
&
decoder
,
pReq
->
user
)
<
0
)
return
-
1
;
if
(
tDecodeCStrTo
(
&
decoder
,
pReq
->
pass
)
<
0
)
return
-
1
;
tEndDecode
(
&
decoder
);
...
...
@@ -1191,6 +1197,8 @@ int32_t tSerializeSAlterUserReq(void *buf, int32_t bufLen, SAlterUserReq *pReq)
if
(
tStartEncode
(
&
encoder
)
<
0
)
return
-
1
;
if
(
tEncodeI8
(
&
encoder
,
pReq
->
alterType
)
<
0
)
return
-
1
;
if
(
tEncodeI8
(
&
encoder
,
pReq
->
superUser
)
<
0
)
return
-
1
;
if
(
tEncodeI8
(
&
encoder
,
pReq
->
sysInfo
)
<
0
)
return
-
1
;
if
(
tEncodeI8
(
&
encoder
,
pReq
->
enable
)
<
0
)
return
-
1
;
if
(
tEncodeCStr
(
&
encoder
,
pReq
->
user
)
<
0
)
return
-
1
;
if
(
tEncodeCStr
(
&
encoder
,
pReq
->
pass
)
<
0
)
return
-
1
;
if
(
tEncodeCStr
(
&
encoder
,
pReq
->
dbname
)
<
0
)
return
-
1
;
...
...
@@ -1208,6 +1216,8 @@ int32_t tDeserializeSAlterUserReq(void *buf, int32_t bufLen, SAlterUserReq *pReq
if
(
tStartDecode
(
&
decoder
)
<
0
)
return
-
1
;
if
(
tDecodeI8
(
&
decoder
,
&
pReq
->
alterType
)
<
0
)
return
-
1
;
if
(
tDecodeI8
(
&
decoder
,
&
pReq
->
superUser
)
<
0
)
return
-
1
;
if
(
tDecodeI8
(
&
decoder
,
&
pReq
->
sysInfo
)
<
0
)
return
-
1
;
if
(
tDecodeI8
(
&
decoder
,
&
pReq
->
enable
)
<
0
)
return
-
1
;
if
(
tDecodeCStrTo
(
&
decoder
,
pReq
->
user
)
<
0
)
return
-
1
;
if
(
tDecodeCStrTo
(
&
decoder
,
pReq
->
pass
)
<
0
)
return
-
1
;
if
(
tDecodeCStrTo
(
&
decoder
,
pReq
->
dbname
)
<
0
)
return
-
1
;
...
...
@@ -1245,6 +1255,9 @@ int32_t tDeserializeSGetUserAuthReq(void *buf, int32_t bufLen, SGetUserAuthReq *
int32_t
tSerializeSGetUserAuthRspImpl
(
SEncoder
*
pEncoder
,
SGetUserAuthRsp
*
pRsp
)
{
if
(
tEncodeCStr
(
pEncoder
,
pRsp
->
user
)
<
0
)
return
-
1
;
if
(
tEncodeI8
(
pEncoder
,
pRsp
->
superAuth
)
<
0
)
return
-
1
;
if
(
tEncodeI8
(
pEncoder
,
pRsp
->
sysInfo
)
<
0
)
return
-
1
;
if
(
tEncodeI8
(
pEncoder
,
pRsp
->
enable
)
<
0
)
return
-
1
;
if
(
tEncodeI8
(
pEncoder
,
pRsp
->
reserve
)
<
0
)
return
-
1
;
if
(
tEncodeI32
(
pEncoder
,
pRsp
->
version
)
<
0
)
return
-
1
;
int32_t
numOfCreatedDbs
=
taosHashGetSize
(
pRsp
->
createdDbs
);
...
...
@@ -1300,6 +1313,9 @@ int32_t tDeserializeSGetUserAuthRspImpl(SDecoder *pDecoder, SGetUserAuthRsp *pRs
if
(
tDecodeCStrTo
(
pDecoder
,
pRsp
->
user
)
<
0
)
return
-
1
;
if
(
tDecodeI8
(
pDecoder
,
&
pRsp
->
superAuth
)
<
0
)
return
-
1
;
if
(
tDecodeI8
(
pDecoder
,
&
pRsp
->
sysInfo
)
<
0
)
return
-
1
;
if
(
tDecodeI8
(
pDecoder
,
&
pRsp
->
enable
)
<
0
)
return
-
1
;
if
(
tDecodeI8
(
pDecoder
,
&
pRsp
->
reserve
)
<
0
)
return
-
1
;
if
(
tDecodeI32
(
pDecoder
,
&
pRsp
->
version
)
<
0
)
return
-
1
;
int32_t
numOfCreatedDbs
=
0
;
...
...
source/dnode/mgmt/mgmt_mnode/src/mmHandle.c
浏览文件 @
e52429e3
...
...
@@ -215,6 +215,7 @@ SArray *mmGetMsgHandles() {
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_VND_MQ_VG_DELETE_RSP
,
mmPutMsgToWriteQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_VND_DROP_TASK
,
mmPutMsgToQueryQueue
,
1
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_STREAM_TASK_DEPLOY_RSP
,
mmPutMsgToWriteQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_VND_STREAM_TASK_DROP_RSP
,
mmPutMsgToWriteQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_VND_ALTER_CONFIG_RSP
,
mmPutMsgToWriteQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_VND_ALTER_REPLICA_RSP
,
mmPutMsgToWriteQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_VND_ALTER_CONFIRM_RSP
,
mmPutMsgToWriteQueue
,
0
)
==
NULL
)
goto
_OVER
;
...
...
source/dnode/mgmt/mgmt_vnode/src/vmHandle.c
浏览文件 @
e52429e3
...
...
@@ -350,6 +350,7 @@ SArray *vmGetMsgHandles() {
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_VND_QUERY_HEARTBEAT
,
vmPutMsgToFetchQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_VND_STREAM_TRIGGER
,
vmPutMsgToFetchQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_VND_STREAM_TASK_DROP
,
vmPutMsgToWriteQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_STREAM_TASK_DEPLOY
,
vmPutMsgToWriteQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_STREAM_TASK_RUN
,
vmPutMsgToFetchQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_STREAM_TASK_DISPATCH
,
vmPutMsgToFetchQueue
,
0
)
==
NULL
)
goto
_OVER
;
...
...
source/dnode/mnode/impl/inc/mndAuth.h
浏览文件 @
e52429e3
...
...
@@ -22,23 +22,42 @@
extern
"C"
{
#endif
typedef
enum
{
MND_OPER_CREATE_USER
=
1
,
MND_OPER_DROP_USER
,
MND_OPER_ALTER_USER
,
MND_OPER_CREATE_BNODE
,
MND_OPER_DROP_BNODE
,
MND_OPER_CREATE_DNODE
,
MND_OPER_DROP_DNODE
,
MND_OPER_CREATE_MNODE
,
MND_OPER_DROP_MNODE
,
MND_OPER_CREATE_QNODE
,
MND_OPER_DROP_QNODE
,
MND_OPER_CREATE_SNODE
,
MND_OPER_DROP_SNODE
,
MND_OPER_REDISTRIBUTE_VGROUP
,
MND_OPER_SPLIT_VGROUP
,
MND_OPER_BALANCE_VGROUP
,
MND_OPER_CREATE_FUNC
,
MND_OPER_DROP_FUNC
,
MND_OPER_KILL_TRANS
,
MND_OPER_CREATE_DB
,
MND_OPER_ALTER_DB
,
MND_OPER_DROP_DB
,
MND_OPER_COMPACT_DB
,
MND_OPER_USE_DB
,
MND_OPER_WRITE_DB
,
MND_OPER_READ_DB
,
}
EOperType
;
int32_t
mndInitAuth
(
SMnode
*
pMnode
);
void
mndCleanupAuth
(
SMnode
*
pMnode
);
int32_t
mndCheckCreateUserAuth
(
SUserObj
*
pOperUser
);
int32_t
mndCheckOperAuth
(
SMnode
*
pMnode
,
const
char
*
user
,
EOperType
operType
);
int32_t
mndCheckDbAuth
(
SMnode
*
pMnode
,
const
char
*
user
,
EOperType
operType
,
SDbObj
*
pDb
);
int32_t
mndCheckShowAuth
(
SMnode
*
pMnode
,
const
char
*
user
,
int32_t
showType
);
int32_t
mndCheckAlterUserAuth
(
SUserObj
*
pOperUser
,
SUserObj
*
pUser
,
SAlterUserReq
*
pAlter
);
int32_t
mndCheckDropUserAuth
(
SUserObj
*
pOperUser
);
int32_t
mndCheckNodeAuth
(
SUserObj
*
pOperUser
);
int32_t
mndCheckFuncAuth
(
SUserObj
*
pOperUser
);
int32_t
mndCheckTransAuth
(
SUserObj
*
pOperUser
);
int32_t
mndCheckCreateDbAuth
(
SUserObj
*
pOperUser
);
int32_t
mndCheckAlterDropCompactDbAuth
(
SUserObj
*
pOperUser
,
SDbObj
*
pDb
);
int32_t
mndCheckUseDbAuth
(
SUserObj
*
pOperUser
,
SDbObj
*
pDb
);
int32_t
mndCheckWriteAuth
(
SUserObj
*
pOperUser
,
SDbObj
*
pDb
);
int32_t
mndCheckReadAuth
(
SUserObj
*
pOperUser
,
SDbObj
*
pDb
);
#ifdef __cplusplus
}
...
...
source/dnode/mnode/impl/inc/mndDef.h
浏览文件 @
e52429e3
...
...
@@ -226,6 +226,9 @@ typedef struct {
int64_t
createdTime
;
int64_t
updateTime
;
int8_t
superUser
;
int8_t
sysInfo
;
int8_t
enable
;
int8_t
reserve
;
int32_t
acctId
;
int32_t
authVersion
;
SHashObj
*
readDbs
;
...
...
@@ -554,8 +557,8 @@ typedef struct {
SVgObj
fixedSinkVg
;
int64_t
smaId
;
// 0 for unused
int8_t
trigger
;
int
32
_t
triggerParam
;
int64_t
water
M
ark
;
int
64
_t
triggerParam
;
int64_t
water
m
ark
;
char
*
sql
;
char
*
physicalPlan
;
SArray
*
tasks
;
// SArray<SArray<SStreamTask>>
...
...
source/dnode/mnode/impl/inc/mndStream.h
浏览文件 @
e52429e3
...
...
@@ -31,7 +31,7 @@ void mndReleaseStream(SMnode *pMnode, SStreamObj *pStream);
SSdbRaw
*
mndStreamActionEncode
(
SStreamObj
*
pStream
);
SSdbRow
*
mndStreamActionDecode
(
SSdbRaw
*
pRaw
);
int32_t
mndAddStreamToTrans
(
SMnode
*
pMnode
,
SStreamObj
*
pStream
,
const
char
*
ast
,
int8_t
triggerType
,
int64_t
watermark
,
STrans
*
pTrans
);
int32_t
mndAddStreamToTrans
(
SMnode
*
pMnode
,
SStreamObj
*
pStream
,
const
char
*
ast
,
STrans
*
pTrans
);
#ifdef __cplusplus
}
...
...
source/dnode/mnode/impl/src/mndAuth.c
浏览文件 @
e52429e3
...
...
@@ -73,29 +73,44 @@ static int32_t mndProcessAuthReq(SRpcMsg *pReq) {
return
code
;
}
int32_t
mndCheckCreateUserAuth
(
SUserObj
*
pOperUser
)
{
if
(
pOperUser
->
superUser
)
return
0
;
int32_t
mndCheckOperAuth
(
SMnode
*
pMnode
,
const
char
*
user
,
EOperType
operType
)
{
int32_t
code
=
0
;
SUserObj
*
pUser
=
mndAcquireUser
(
pMnode
,
user
);
if
(
pUser
==
NULL
)
{
terrno
=
TSDB_CODE_MND_NO_USER_FROM_CONN
;
code
=
-
1
;
goto
_OVER
;
}
if
(
pUser
->
superUser
)
{
goto
_OVER
;
}
if
(
!
pUser
->
enable
)
{
terrno
=
TSDB_CODE_MND_USER_DISABLED
;
code
=
-
1
;
goto
_OVER
;
}
terrno
=
TSDB_CODE_MND_NO_RIGHTS
;
return
-
1
;
code
=
-
1
;
_OVER:
mndReleaseUser
(
pMnode
,
pUser
);
return
code
;
}
int32_t
mndCheckAlterUserAuth
(
SUserObj
*
pOperUser
,
SUserObj
*
pUser
,
SAlterUserReq
*
pAlter
)
{
if
(
pAlter
->
alterType
==
TSDB_ALTER_USER_PASSWD
)
{
if
(
pOperUser
->
superUser
||
strcmp
(
pUser
->
user
,
pOperUser
->
user
)
==
0
)
{
return
0
;
}
}
else
if
(
pAlter
->
alterType
==
TSDB_ALTER_USER_SUPERUSER
)
{
if
(
strcmp
(
pUser
->
user
,
TSDB_DEFAULT_USER
)
==
0
)
{
terrno
=
TSDB_CODE_MND_NO_RIGHTS
;
return
-
1
;
}
if
(
pOperUser
->
superUser
)
return
0
;
if
(
!
pOperUser
->
enable
)
{
terrno
=
TSDB_CODE_MND_USER_DISABLED
;
return
-
1
;
}
if
(
pOperUser
->
superUser
)
{
return
0
;
}
}
else
{
if
(
pOperUser
->
superUser
)
{
return
0
;
if
(
pAlter
->
alterType
==
TSDB_ALTER_USER_PASSWD
)
{
if
(
strcmp
(
pUser
->
user
,
pOperUser
->
user
)
==
0
)
{
if
(
pOperUser
->
sysInfo
)
return
0
;
}
}
...
...
@@ -103,65 +118,92 @@ int32_t mndCheckAlterUserAuth(SUserObj *pOperUser, SUserObj *pUser, SAlterUserRe
return
-
1
;
}
int32_t
mndCheckDropUserAuth
(
SUserObj
*
pOperUser
)
{
if
(
pOperUser
->
superUser
)
return
0
;
terrno
=
TSDB_CODE_MND_NO_RIGHTS
;
return
-
1
;
}
int32_t
mndCheckShowAuth
(
SMnode
*
pMnode
,
const
char
*
user
,
int32_t
showType
)
{
int32_t
code
=
0
;
SUserObj
*
pUser
=
mndAcquireUser
(
pMnode
,
user
);
int32_t
mndCheckNodeAuth
(
SUserObj
*
pOperUser
)
{
if
(
pOperUser
->
superUser
)
return
0
;
terrno
=
TSDB_CODE_MND_NO_RIGHTS
;
return
-
1
;
}
if
(
pUser
==
NULL
)
{
code
=
-
1
;
goto
_OVER
;
}
int32_t
mndCheckFuncAuth
(
SUserObj
*
pOperUser
)
{
if
(
pOperUser
->
superUser
)
return
0
;
terrno
=
TSDB_CODE_MND_NO_RIGHTS
;
return
-
1
;
}
if
(
pUser
->
superUser
)
{
goto
_OVER
;
}
if
(
!
pUser
->
enable
)
{
terrno
=
TSDB_CODE_MND_USER_DISABLED
;
code
=
-
1
;
goto
_OVER
;
}
if
(
!
pUser
->
sysInfo
)
{
terrno
=
TSDB_CODE_MND_NO_RIGHTS
;
code
=
-
1
;
goto
_OVER
;
}
int32_t
mndCheckTransAuth
(
SUserObj
*
pOperUser
)
{
if
(
pOperUser
->
superUser
)
return
0
;
terrno
=
TSDB_CODE_MND_NO_RIGHTS
;
return
-
1
;
code
=
-
1
;
_OVER:
mndReleaseUser
(
pMnode
,
pUser
);
return
code
;
}
int32_t
mndCheckCreateDbAuth
(
SUserObj
*
pOperUser
)
{
return
0
;
}
int32_t
mndCheckDbAuth
(
SMnode
*
pMnode
,
const
char
*
user
,
EOperType
operType
,
SDbObj
*
pDb
)
{
int32_t
code
=
0
;
SUserObj
*
pUser
=
mndAcquireUser
(
pMnode
,
user
);
int32_t
mndCheckAlterDropCompactDbAuth
(
SUserObj
*
pOperUser
,
SDbObj
*
pDb
)
{
if
(
pOperUser
->
superUser
||
strcmp
(
pOperUser
->
user
,
pDb
->
createUser
)
==
0
)
{
return
0
;
if
(
pUser
==
NULL
)
{
code
=
-
1
;
goto
_OVER
;
}
terrno
=
TSDB_CODE_MND_NO_RIGHTS
;
return
-
1
;
}
if
(
pUser
->
superUser
)
goto
_OVER
;
int32_t
mndCheckUseDbAuth
(
SUserObj
*
pOperUser
,
SDbObj
*
pDb
)
{
return
0
;
}
if
(
!
pUser
->
enable
)
{
terrno
=
TSDB_CODE_MND_USER_DISABLED
;
code
=
-
1
;
goto
_OVER
;
}
int32_t
mndCheckWriteAuth
(
SUserObj
*
pOperUser
,
SDbObj
*
pDb
)
{
if
(
pOperUser
->
superUser
||
strcmp
(
pOperUser
->
user
,
pDb
->
createUser
)
==
0
)
{
return
0
;
if
(
operType
==
MND_OPER_CREATE_DB
)
{
if
(
pUser
->
sysInfo
)
goto
_OVER
;
}
if
(
taosHashGet
(
pOperUser
->
writeDbs
,
pDb
->
name
,
strlen
(
pDb
->
name
)
+
1
)
!=
NULL
)
{
return
0
;
if
(
operType
==
MND_OPER_ALTER_DB
)
{
if
(
strcmp
(
pUser
->
user
,
pDb
->
createUser
)
==
0
&&
pUser
->
sysInfo
)
goto
_OVER
;
}
terrno
=
TSDB_CODE_MND_NO_RIGHTS
;
return
-
1
;
}
if
(
operType
==
MND_OPER_DROP_DB
)
{
if
(
strcmp
(
pUser
->
user
,
pDb
->
createUser
)
==
0
&&
pUser
->
sysInfo
)
goto
_OVER
;
}
int32_t
mndCheckReadAuth
(
SUserObj
*
pOperUser
,
SDbObj
*
pDb
)
{
if
(
pOperUser
->
superUser
||
strcmp
(
pOperUser
->
user
,
pDb
->
createUser
)
==
0
)
{
return
0
;
if
(
operType
==
MND_OPER_COMPACT_DB
)
{
if
(
strcmp
(
pUser
->
user
,
pDb
->
createUser
)
==
0
&&
pUser
->
sysInfo
)
goto
_OVER
;
}
if
(
taosHashGet
(
pOperUser
->
readDbs
,
pDb
->
name
,
strlen
(
pDb
->
name
)
+
1
)
!=
NULL
)
{
return
0
;
if
(
operType
==
MND_OPER_USE_DB
)
{
if
(
strcmp
(
pUser
->
user
,
pDb
->
createUser
)
==
0
)
goto
_OVER
;
if
(
taosHashGet
(
pUser
->
readDbs
,
pDb
->
name
,
strlen
(
pDb
->
name
)
+
1
)
!=
NULL
)
goto
_OVER
;
if
(
taosHashGet
(
pUser
->
writeDbs
,
pDb
->
name
,
strlen
(
pDb
->
name
)
+
1
)
!=
NULL
)
goto
_OVER
;
}
if
(
operType
==
MND_OPER_WRITE_DB
)
{
if
(
strcmp
(
pUser
->
user
,
pDb
->
createUser
)
==
0
)
goto
_OVER
;
if
(
taosHashGet
(
pUser
->
writeDbs
,
pDb
->
name
,
strlen
(
pDb
->
name
)
+
1
)
!=
NULL
)
goto
_OVER
;
}
if
(
operType
==
MND_OPER_READ_DB
)
{
if
(
strcmp
(
pUser
->
user
,
pDb
->
createUser
)
==
0
)
goto
_OVER
;
if
(
taosHashGet
(
pUser
->
readDbs
,
pDb
->
name
,
strlen
(
pDb
->
name
)
+
1
)
!=
NULL
)
goto
_OVER
;
}
terrno
=
TSDB_CODE_MND_NO_RIGHTS
;
return
-
1
;
code
=
-
1
;
_OVER:
mndReleaseUser
(
pMnode
,
pUser
);
return
code
;
}
source/dnode/mnode/impl/src/mndBnode.c
浏览文件 @
e52429e3
...
...
@@ -269,7 +269,6 @@ static int32_t mndProcessCreateBnodeReq(SRpcMsg *pReq) {
int32_t
code
=
-
1
;
SBnodeObj
*
pObj
=
NULL
;
SDnodeObj
*
pDnode
=
NULL
;
SUserObj
*
pUser
=
NULL
;
SMCreateBnodeReq
createReq
=
{
0
};
if
(
tDeserializeSCreateDropMQSBNodeReq
(
pReq
->
pCont
,
pReq
->
contLen
,
&
createReq
)
!=
0
)
{
...
...
@@ -293,13 +292,7 @@ static int32_t mndProcessCreateBnodeReq(SRpcMsg *pReq) {
goto
_OVER
;
}
pUser
=
mndAcquireUser
(
pMnode
,
pReq
->
conn
.
user
);
if
(
pUser
==
NULL
)
{
terrno
=
TSDB_CODE_MND_NO_USER_FROM_CONN
;
goto
_OVER
;
}
if
(
mndCheckNodeAuth
(
pUser
)
!=
0
)
{
if
(
mndCheckOperAuth
(
pMnode
,
pReq
->
conn
.
user
,
MND_OPER_CREATE_BNODE
)
!=
0
)
{
goto
_OVER
;
}
...
...
@@ -313,7 +306,6 @@ _OVER:
mndReleaseBnode
(
pMnode
,
pObj
);
mndReleaseDnode
(
pMnode
,
pDnode
);
mndReleaseUser
(
pMnode
,
pUser
);
return
code
;
}
...
...
@@ -382,7 +374,6 @@ _OVER:
static
int32_t
mndProcessDropBnodeReq
(
SRpcMsg
*
pReq
)
{
SMnode
*
pMnode
=
pReq
->
info
.
node
;
int32_t
code
=
-
1
;
SUserObj
*
pUser
=
NULL
;
SBnodeObj
*
pObj
=
NULL
;
SMDropBnodeReq
dropReq
=
{
0
};
...
...
@@ -403,13 +394,7 @@ static int32_t mndProcessDropBnodeReq(SRpcMsg *pReq) {
goto
_OVER
;
}
pUser
=
mndAcquireUser
(
pMnode
,
pReq
->
conn
.
user
);
if
(
pUser
==
NULL
)
{
terrno
=
TSDB_CODE_MND_NO_USER_FROM_CONN
;
goto
_OVER
;
}
if
(
mndCheckNodeAuth
(
pUser
)
!=
0
)
{
if
(
mndCheckOperAuth
(
pMnode
,
pReq
->
conn
.
user
,
MND_OPER_DROP_BNODE
)
!=
0
)
{
goto
_OVER
;
}
...
...
@@ -422,8 +407,6 @@ _OVER:
}
mndReleaseBnode
(
pMnode
,
pObj
);
mndReleaseUser
(
pMnode
,
pUser
);
return
code
;
}
...
...
source/dnode/mnode/impl/src/mndDb.c
浏览文件 @
e52429e3
...
...
@@ -526,7 +526,7 @@ static int32_t mndProcessCreateDbReq(SRpcMsg *pReq) {
goto
_OVER
;
}
if
(
mndCheck
CreateDbAuth
(
pUser
)
!=
0
)
{
if
(
mndCheck
DbAuth
(
pMnode
,
pReq
->
conn
.
user
,
MND_OPER_CREATE_DB
,
NULL
)
!=
0
)
{
goto
_OVER
;
}
...
...
@@ -684,7 +684,6 @@ static int32_t mndProcessAlterDbReq(SRpcMsg *pReq) {
SMnode
*
pMnode
=
pReq
->
info
.
node
;
int32_t
code
=
-
1
;
SDbObj
*
pDb
=
NULL
;
SUserObj
*
pUser
=
NULL
;
SAlterDbReq
alterReq
=
{
0
};
SDbObj
dbObj
=
{
0
};
...
...
@@ -701,12 +700,7 @@ static int32_t mndProcessAlterDbReq(SRpcMsg *pReq) {
goto
_OVER
;
}
pUser
=
mndAcquireUser
(
pMnode
,
pReq
->
conn
.
user
);
if
(
pUser
==
NULL
)
{
goto
_OVER
;
}
if
(
mndCheckAlterDropCompactDbAuth
(
pUser
,
pDb
)
!=
0
)
{
if
(
mndCheckDbAuth
(
pMnode
,
pReq
->
conn
.
user
,
MND_OPER_ALTER_DB
,
pDb
)
!=
0
)
{
goto
_OVER
;
}
...
...
@@ -733,7 +727,6 @@ _OVER:
}
mndReleaseDb
(
pMnode
,
pDb
);
mndReleaseUser
(
pMnode
,
pUser
);
taosArrayDestroy
(
dbObj
.
cfg
.
pRetensions
);
return
code
;
...
...
@@ -967,7 +960,6 @@ static int32_t mndProcessDropDbReq(SRpcMsg *pReq) {
SMnode
*
pMnode
=
pReq
->
info
.
node
;
int32_t
code
=
-
1
;
SDbObj
*
pDb
=
NULL
;
SUserObj
*
pUser
=
NULL
;
SDropDbReq
dropReq
=
{
0
};
if
(
tDeserializeSDropDbReq
(
pReq
->
pCont
,
pReq
->
contLen
,
&
dropReq
)
!=
0
)
{
...
...
@@ -988,12 +980,7 @@ static int32_t mndProcessDropDbReq(SRpcMsg *pReq) {
}
}
pUser
=
mndAcquireUser
(
pMnode
,
pReq
->
conn
.
user
);
if
(
pUser
==
NULL
)
{
goto
_OVER
;
}
if
(
mndCheckAlterDropCompactDbAuth
(
pUser
,
pDb
)
!=
0
)
{
if
(
mndCheckDbAuth
(
pMnode
,
pReq
->
conn
.
user
,
MND_OPER_DROP_DB
,
pDb
)
!=
0
)
{
goto
_OVER
;
}
...
...
@@ -1006,8 +993,6 @@ _OVER:
}
mndReleaseDb
(
pMnode
,
pDb
);
mndReleaseUser
(
pMnode
,
pUser
);
return
code
;
}
...
...
@@ -1103,7 +1088,6 @@ static int32_t mndProcessUseDbReq(SRpcMsg *pReq) {
SMnode
*
pMnode
=
pReq
->
info
.
node
;
int32_t
code
=
-
1
;
SDbObj
*
pDb
=
NULL
;
SUserObj
*
pUser
=
NULL
;
SUseDbReq
usedbReq
=
{
0
};
SUseDbRsp
usedbRsp
=
{
0
};
...
...
@@ -1143,12 +1127,7 @@ static int32_t mndProcessUseDbReq(SRpcMsg *pReq) {
mError
(
"db:%s, failed to process use db req since %s"
,
usedbReq
.
db
,
terrstr
());
}
else
{
pUser
=
mndAcquireUser
(
pMnode
,
pReq
->
conn
.
user
);
if
(
pUser
==
NULL
)
{
goto
_OVER
;
}
if
(
mndCheckUseDbAuth
(
pUser
,
pDb
)
!=
0
)
{
if
(
mndCheckDbAuth
(
pMnode
,
pReq
->
conn
.
user
,
MND_OPER_USE_DB
,
pDb
)
!=
0
)
{
goto
_OVER
;
}
...
...
@@ -1179,7 +1158,6 @@ _OVER:
}
mndReleaseDb
(
pMnode
,
pDb
);
mndReleaseUser
(
pMnode
,
pUser
);
tFreeSUsedbRsp
(
&
usedbRsp
);
return
code
;
...
...
@@ -1260,7 +1238,6 @@ static int32_t mndProcessCompactDbReq(SRpcMsg *pReq) {
SMnode
*
pMnode
=
pReq
->
info
.
node
;
int32_t
code
=
-
1
;
SDbObj
*
pDb
=
NULL
;
SUserObj
*
pUser
=
NULL
;
SCompactDbReq
compactReq
=
{
0
};
if
(
tDeserializeSCompactDbReq
(
pReq
->
pCont
,
pReq
->
contLen
,
&
compactReq
)
!=
0
)
{
...
...
@@ -1275,12 +1252,7 @@ static int32_t mndProcessCompactDbReq(SRpcMsg *pReq) {
goto
_OVER
;
}
pUser
=
mndAcquireUser
(
pMnode
,
pReq
->
conn
.
user
);
if
(
pUser
==
NULL
)
{
goto
_OVER
;
}
if
(
mndCheckAlterDropCompactDbAuth
(
pUser
,
pDb
)
!=
0
)
{
if
(
mndCheckDbAuth
(
pMnode
,
pReq
->
conn
.
user
,
MND_OPER_COMPACT_DB
,
pDb
)
!=
0
)
{
goto
_OVER
;
}
...
...
@@ -1292,8 +1264,6 @@ _OVER:
}
mndReleaseDb
(
pMnode
,
pDb
);
mndReleaseUser
(
pMnode
,
pUser
);
return
code
;
}
...
...
source/dnode/mnode/impl/src/mndDef.c
浏览文件 @
e52429e3
...
...
@@ -33,8 +33,8 @@ int32_t tEncodeSStreamObj(SEncoder *pEncoder, const SStreamObj *pObj) {
if
(
tEncodeI8
(
pEncoder
,
pObj
->
status
)
<
0
)
return
-
1
;
if
(
tEncodeI8
(
pEncoder
,
pObj
->
createdBy
)
<
0
)
return
-
1
;
if
(
tEncodeI8
(
pEncoder
,
pObj
->
trigger
)
<
0
)
return
-
1
;
if
(
tEncodeI
32
(
pEncoder
,
pObj
->
triggerParam
)
<
0
)
return
-
1
;
if
(
tEncodeI64
(
pEncoder
,
pObj
->
water
M
ark
)
<
0
)
return
-
1
;
if
(
tEncodeI
64
(
pEncoder
,
pObj
->
triggerParam
)
<
0
)
return
-
1
;
if
(
tEncodeI64
(
pEncoder
,
pObj
->
water
m
ark
)
<
0
)
return
-
1
;
if
(
tEncodeI32
(
pEncoder
,
pObj
->
fixedSinkVgId
)
<
0
)
return
-
1
;
if
(
tEncodeI64
(
pEncoder
,
pObj
->
smaId
)
<
0
)
return
-
1
;
if
(
tEncodeCStr
(
pEncoder
,
pObj
->
sql
)
<
0
)
return
-
1
;
...
...
@@ -85,8 +85,8 @@ int32_t tDecodeSStreamObj(SDecoder *pDecoder, SStreamObj *pObj) {
if
(
tDecodeI8
(
pDecoder
,
&
pObj
->
status
)
<
0
)
return
-
1
;
if
(
tDecodeI8
(
pDecoder
,
&
pObj
->
createdBy
)
<
0
)
return
-
1
;
if
(
tDecodeI8
(
pDecoder
,
&
pObj
->
trigger
)
<
0
)
return
-
1
;
if
(
tDecodeI
32
(
pDecoder
,
&
pObj
->
triggerParam
)
<
0
)
return
-
1
;
if
(
tDecodeI64
(
pDecoder
,
&
pObj
->
water
M
ark
)
<
0
)
return
-
1
;
if
(
tDecodeI
64
(
pDecoder
,
&
pObj
->
triggerParam
)
<
0
)
return
-
1
;
if
(
tDecodeI64
(
pDecoder
,
&
pObj
->
water
m
ark
)
<
0
)
return
-
1
;
if
(
tDecodeI32
(
pDecoder
,
&
pObj
->
fixedSinkVgId
)
<
0
)
return
-
1
;
if
(
tDecodeI64
(
pDecoder
,
&
pObj
->
smaId
)
<
0
)
return
-
1
;
if
(
tDecodeCStrAlloc
(
pDecoder
,
&
pObj
->
sql
)
<
0
)
return
-
1
;
...
...
source/dnode/mnode/impl/src/mndDnode.c
浏览文件 @
e52429e3
...
...
@@ -499,7 +499,6 @@ _OVER:
static
int32_t
mndProcessCreateDnodeReq
(
SRpcMsg
*
pReq
)
{
SMnode
*
pMnode
=
pReq
->
info
.
node
;
int32_t
code
=
-
1
;
SUserObj
*
pUser
=
NULL
;
SDnodeObj
*
pDnode
=
NULL
;
SCreateDnodeReq
createReq
=
{
0
};
...
...
@@ -522,13 +521,7 @@ static int32_t mndProcessCreateDnodeReq(SRpcMsg *pReq) {
goto
_OVER
;
}
pUser
=
mndAcquireUser
(
pMnode
,
pReq
->
conn
.
user
);
if
(
pUser
==
NULL
)
{
terrno
=
TSDB_CODE_MND_NO_USER_FROM_CONN
;
goto
_OVER
;
}
if
(
mndCheckNodeAuth
(
pUser
)
!=
0
)
{
if
(
mndCheckOperAuth
(
pMnode
,
pReq
->
conn
.
user
,
MND_OPER_CREATE_DNODE
)
!=
0
)
{
goto
_OVER
;
}
...
...
@@ -541,7 +534,6 @@ _OVER:
}
mndReleaseDnode
(
pMnode
,
pDnode
);
mndReleaseUser
(
pMnode
,
pUser
);
return
code
;
}
...
...
@@ -586,7 +578,6 @@ _OVER:
static
int32_t
mndProcessDropDnodeReq
(
SRpcMsg
*
pReq
)
{
SMnode
*
pMnode
=
pReq
->
info
.
node
;
int32_t
code
=
-
1
;
SUserObj
*
pUser
=
NULL
;
SDnodeObj
*
pDnode
=
NULL
;
SMnodeObj
*
pMObj
=
NULL
;
SMDropMnodeReq
dropReq
=
{
0
};
...
...
@@ -631,13 +622,7 @@ static int32_t mndProcessDropDnodeReq(SRpcMsg *pReq) {
}
}
pUser
=
mndAcquireUser
(
pMnode
,
pReq
->
conn
.
user
);
if
(
pUser
==
NULL
)
{
terrno
=
TSDB_CODE_MND_NO_USER_FROM_CONN
;
goto
_OVER
;
}
if
(
mndCheckNodeAuth
(
pUser
)
!=
0
)
{
if
(
mndCheckOperAuth
(
pMnode
,
pReq
->
conn
.
user
,
MND_OPER_DROP_MNODE
)
!=
0
)
{
goto
_OVER
;
}
...
...
@@ -650,7 +635,6 @@ _OVER:
}
mndReleaseDnode
(
pMnode
,
pDnode
);
mndReleaseUser
(
pMnode
,
pUser
);
mndReleaseMnode
(
pMnode
,
pMObj
);
return
code
;
}
...
...
source/dnode/mnode/impl/src/mndFunc.c
浏览文件 @
e52429e3
...
...
@@ -274,7 +274,6 @@ _OVER:
static
int32_t
mndProcessCreateFuncReq
(
SRpcMsg
*
pReq
)
{
SMnode
*
pMnode
=
pReq
->
info
.
node
;
int32_t
code
=
-
1
;
SUserObj
*
pUser
=
NULL
;
SFuncObj
*
pFunc
=
NULL
;
SCreateFuncReq
createReq
=
{
0
};
...
...
@@ -309,23 +308,17 @@ static int32_t mndProcessCreateFuncReq(SRpcMsg *pReq) {
goto
_OVER
;
}
if
(
createReq
.
codeLen
<=
1
)
{
terrno
=
TSDB_CODE_MND_INVALID_FUNC_CODE
;
goto
_OVER
;
}
if
(
createReq
.
bufSize
<
0
||
createReq
.
bufSize
>
TSDB_FUNC_BUF_SIZE
)
{
terrno
=
TSDB_CODE_MND_INVALID_FUNC_BUFSIZE
;
if
(
createReq
.
codeLen
<=
1
)
{
terrno
=
TSDB_CODE_MND_INVALID_FUNC_CODE
;
goto
_OVER
;
}
pUser
=
mndAcquireUser
(
pMnode
,
pReq
->
conn
.
user
);
if
(
pUser
==
NULL
)
{
terrno
=
TSDB_CODE_MND_NO_USER_FROM_CONN
;
if
(
createReq
.
bufSize
<
0
||
createReq
.
bufSize
>
TSDB_FUNC_BUF_SIZE
)
{
terrno
=
TSDB_CODE_MND_INVALID_FUNC_BUFSIZE
;
goto
_OVER
;
}
if
(
mndCheck
FuncAuth
(
pUser
)
)
{
if
(
mndCheck
OperAuth
(
pMnode
,
pReq
->
conn
.
user
,
MND_OPER_CREATE_FUNC
)
!=
0
)
{
goto
_OVER
;
}
...
...
@@ -338,16 +331,13 @@ _OVER:
}
mndReleaseFunc
(
pMnode
,
pFunc
);
mndReleaseUser
(
pMnode
,
pUser
);
tFreeSCreateFuncReq
(
&
createReq
);
return
code
;
}
static
int32_t
mndProcessDropFuncReq
(
SRpcMsg
*
pReq
)
{
SMnode
*
pMnode
=
pReq
->
info
.
node
;
int32_t
code
=
-
1
;
SUserObj
*
pUser
=
NULL
;
SFuncObj
*
pFunc
=
NULL
;
SDropFuncReq
dropReq
=
{
0
};
...
...
@@ -375,13 +365,7 @@ static int32_t mndProcessDropFuncReq(SRpcMsg *pReq) {
}
}
pUser
=
mndAcquireUser
(
pMnode
,
pReq
->
conn
.
user
);
if
(
pUser
==
NULL
)
{
terrno
=
TSDB_CODE_MND_NO_USER_FROM_CONN
;
goto
_OVER
;
}
if
(
mndCheckFuncAuth
(
pUser
))
{
if
(
mndCheckOperAuth
(
pMnode
,
pReq
->
conn
.
user
,
MND_OPER_DROP_FUNC
)
!=
0
)
{
goto
_OVER
;
}
...
...
@@ -394,8 +378,6 @@ _OVER:
}
mndReleaseFunc
(
pMnode
,
pFunc
);
mndReleaseUser
(
pMnode
,
pUser
);
return
code
;
}
...
...
source/dnode/mnode/impl/src/mndMain.c
浏览文件 @
e52429e3
...
...
@@ -380,17 +380,19 @@ void mndStop(SMnode *pMnode) {
int32_t
mndProcessSyncMsg
(
SRpcMsg
*
pMsg
)
{
SMnode
*
pMnode
=
pMsg
->
info
.
node
;
SSyncMgmt
*
pMgmt
=
&
pMnode
->
syncMgmt
;
int32_t
code
=
TAOS_SYNC_OTHER_ERROR
;
int32_t
code
=
0
;
if
(
!
syncEnvIsStart
())
{
mError
(
"failed to process sync msg:%p type:%s since syncEnv stop"
,
pMsg
,
TMSG_INFO
(
pMsg
->
msgType
));
return
TAOS_SYNC_OTHER_ERROR
;
terrno
=
TSDB_CODE_SYN_INTERNAL_ERROR
;
return
-
1
;
}
SSyncNode
*
pSyncNode
=
syncNodeAcquire
(
pMgmt
->
sync
);
if
(
pSyncNode
==
NULL
)
{
mError
(
"failed to process sync msg:%p type:%s since syncNode is null"
,
pMsg
,
TMSG_INFO
(
pMsg
->
msgType
));
return
TAOS_SYNC_OTHER_ERROR
;
terrno
=
TSDB_CODE_SYN_INTERNAL_ERROR
;
return
-
1
;
}
char
logBuf
[
512
]
=
{
0
};
...
...
@@ -451,7 +453,7 @@ int32_t mndProcessSyncMsg(SRpcMsg *pMsg) {
tmsgSendRsp
(
&
rsp
);
}
else
{
mError
(
"failed to process msg:%p since invalid type:%s"
,
pMsg
,
TMSG_INFO
(
pMsg
->
msgType
));
code
=
TAOS_SYNC_OTHER_ERROR
;
code
=
-
1
;
}
}
else
{
if
(
pMsg
->
msgType
==
TDMT_SYNC_TIMEOUT
)
{
...
...
@@ -492,10 +494,13 @@ int32_t mndProcessSyncMsg(SRpcMsg *pMsg) {
tmsgSendRsp
(
&
rsp
);
}
else
{
mError
(
"failed to process msg:%p since invalid type:%s"
,
pMsg
,
TMSG_INFO
(
pMsg
->
msgType
));
code
=
TAOS_SYNC_OTHER_ERROR
;
code
=
-
1
;
}
}
if
(
code
!=
0
)
{
terrno
=
TSDB_CODE_SYN_INTERNAL_ERROR
;
}
return
code
;
}
...
...
source/dnode/mnode/impl/src/mndMnode.c
浏览文件 @
e52429e3
...
...
@@ -381,7 +381,6 @@ static int32_t mndProcessCreateMnodeReq(SRpcMsg *pReq) {
int32_t
code
=
-
1
;
SMnodeObj
*
pObj
=
NULL
;
SDnodeObj
*
pDnode
=
NULL
;
SUserObj
*
pUser
=
NULL
;
SMCreateMnodeReq
createReq
=
{
0
};
if
(
tDeserializeSCreateDropMQSBNodeReq
(
pReq
->
pCont
,
pReq
->
contLen
,
&
createReq
)
!=
0
)
{
...
...
@@ -415,13 +414,7 @@ static int32_t mndProcessCreateMnodeReq(SRpcMsg *pReq) {
goto
_OVER
;
}
pUser
=
mndAcquireUser
(
pMnode
,
pReq
->
conn
.
user
);
if
(
pUser
==
NULL
)
{
terrno
=
TSDB_CODE_MND_NO_USER_FROM_CONN
;
goto
_OVER
;
}
if
(
mndCheckNodeAuth
(
pUser
)
!=
0
)
{
if
(
mndCheckOperAuth
(
pMnode
,
pReq
->
conn
.
user
,
MND_OPER_CREATE_MNODE
)
!=
0
)
{
goto
_OVER
;
}
...
...
@@ -435,7 +428,6 @@ _OVER:
mndReleaseMnode
(
pMnode
,
pObj
);
mndReleaseDnode
(
pMnode
,
pDnode
);
mndReleaseUser
(
pMnode
,
pUser
);
return
code
;
}
...
...
@@ -594,7 +586,6 @@ _OVER:
static
int32_t
mndProcessDropMnodeReq
(
SRpcMsg
*
pReq
)
{
SMnode
*
pMnode
=
pReq
->
info
.
node
;
int32_t
code
=
-
1
;
SUserObj
*
pUser
=
NULL
;
SMnodeObj
*
pObj
=
NULL
;
SMDropMnodeReq
dropReq
=
{
0
};
...
...
@@ -630,13 +621,7 @@ static int32_t mndProcessDropMnodeReq(SRpcMsg *pReq) {
goto
_OVER
;
}
pUser
=
mndAcquireUser
(
pMnode
,
pReq
->
conn
.
user
);
if
(
pUser
==
NULL
)
{
terrno
=
TSDB_CODE_MND_NO_USER_FROM_CONN
;
goto
_OVER
;
}
if
(
mndCheckNodeAuth
(
pUser
)
!=
0
)
{
if
(
mndCheckOperAuth
(
pMnode
,
pReq
->
conn
.
user
,
MND_OPER_DROP_MNODE
)
!=
0
)
{
goto
_OVER
;
}
...
...
@@ -649,8 +634,6 @@ _OVER:
}
mndReleaseMnode
(
pMnode
,
pObj
);
mndReleaseUser
(
pMnode
,
pUser
);
return
code
;
}
...
...
source/dnode/mnode/impl/src/mndProfile.c
浏览文件 @
e52429e3
...
...
@@ -39,6 +39,7 @@ typedef struct {
int64_t
lastAccessTimeMs
;
uint64_t
killId
;
int32_t
numOfQueries
;
SRWLatch
queryLock
;
SArray
*
pQueries
;
// SArray<SQueryDesc>
}
SConnObj
;
...
...
@@ -53,8 +54,8 @@ static int32_t mndProcessHeartBeatReq(SRpcMsg *pReq);
static
int32_t
mndProcessConnectReq
(
SRpcMsg
*
pReq
);
static
int32_t
mndProcessKillQueryReq
(
SRpcMsg
*
pReq
);
static
int32_t
mndProcessKillConnReq
(
SRpcMsg
*
pReq
);
static
int32_t
mndRetrieveConns
(
SRpcMsg
*
pReq
,
SShowObj
*
pShow
,
char
*
data
,
int32_t
rows
);
static
int32_t
mndRetrieveQueries
(
SRpcMsg
*
pReq
,
SShowObj
*
pShow
,
char
*
data
,
int32_t
rows
);
static
int32_t
mndRetrieveConns
(
SRpcMsg
*
pReq
,
SShowObj
*
pShow
,
SSDataBlock
*
pBlock
,
int32_t
rows
);
static
int32_t
mndRetrieveQueries
(
SRpcMsg
*
pReq
,
SShowObj
*
pShow
,
SSDataBlock
*
pBlock
,
int32_t
rows
);
static
void
mndCancelGetNextQuery
(
SMnode
*
pMnode
,
void
*
pIter
);
int32_t
mndInitProfile
(
SMnode
*
pMnode
)
{
...
...
@@ -74,9 +75,9 @@ int32_t mndInitProfile(SMnode *pMnode) {
mndSetMsgHandle
(
pMnode
,
TDMT_MND_KILL_QUERY
,
mndProcessKillQueryReq
);
mndSetMsgHandle
(
pMnode
,
TDMT_MND_KILL_CONN
,
mndProcessKillConnReq
);
//
mndAddShowRetrieveHandle(pMnode, TSDB_MGMT_TABLE_CONNS, mndRetrieveConns);
mndAddShowRetrieveHandle
(
pMnode
,
TSDB_MGMT_TABLE_CONNS
,
mndRetrieveConns
);
mndAddShowFreeIterHandle
(
pMnode
,
TSDB_MGMT_TABLE_CONNS
,
mndCancelGetNextConn
);
//
mndAddShowRetrieveHandle(pMnode, TSDB_MGMT_TABLE_QUERIES, mndRetrieveQueries);
mndAddShowRetrieveHandle
(
pMnode
,
TSDB_MGMT_TABLE_QUERIES
,
mndRetrieveQueries
);
mndAddShowFreeIterHandle
(
pMnode
,
TSDB_MGMT_TABLE_QUERIES
,
mndCancelGetNextQuery
);
return
0
;
...
...
@@ -129,7 +130,9 @@ static SConnObj *mndCreateConn(SMnode *pMnode, const char *user, int8_t connType
}
static
void
mndFreeConn
(
SConnObj
*
pConn
)
{
taosWLockLatch
(
&
pConn
->
queryLock
);
taosArrayDestroyEx
(
pConn
->
pQueries
,
tFreeClientHbQueryDesc
);
taosWUnLockLatch
(
&
pConn
->
queryLock
);
mTrace
(
"conn:%u, is destroyed, data:%p"
,
pConn
->
id
,
pConn
);
}
...
...
@@ -222,8 +225,6 @@ static int32_t mndProcessConnectReq(SRpcMsg *pReq) {
goto
CONN_OVER
;
}
mndAcquireConn
(
pMnode
,
pConn
->
id
);
SConnectRsp
connectRsp
=
{
0
};
connectRsp
.
acctId
=
pUser
->
acctId
;
connectRsp
.
superUser
=
pUser
->
superUser
;
...
...
@@ -259,12 +260,17 @@ CONN_OVER:
}
static
int32_t
mndSaveQueryList
(
SConnObj
*
pConn
,
SQueryHbReqBasic
*
pBasic
)
{
taosWLockLatch
(
&
pConn
->
queryLock
);
taosArrayDestroyEx
(
pConn
->
pQueries
,
tFreeClientHbQueryDesc
);
pConn
->
pQueries
=
pBasic
->
queryDesc
;
pConn
->
numOfQueries
=
pBasic
->
queryDesc
?
taosArrayGetSize
(
pBasic
->
queryDesc
)
:
0
;
pBasic
->
queryDesc
=
NULL
;
pConn
->
numOfQueries
=
pBasic
->
queryDesc
?
taosArrayGetSize
(
pBasic
->
queryDesc
)
:
0
;
mDebug
(
"queries updated in conn %d, num:%d"
,
pConn
->
id
,
pConn
->
numOfQueries
);
taosWUnLockLatch
(
&
pConn
->
queryLock
);
return
TSDB_CODE_SUCCESS
;
}
...
...
@@ -354,13 +360,8 @@ static int32_t mndProcessQueryHeartBeat(SMnode *pMnode, SRpcMsg *pMsg, SClientHb
}
else
{
mDebug
(
"user:%s, conn:%u is freed and create a new conn:%u"
,
connInfo
.
user
,
pBasic
->
connId
,
pConn
->
id
);
}
}
else
if
(
pConn
->
killed
)
{
mError
(
"user:%s, conn:%u is already killed"
,
connInfo
.
user
,
pConn
->
id
);
mndReleaseConn
(
pMnode
,
pConn
);
terrno
=
TSDB_CODE_MND_INVALID_CONNECTION
;
return
-
1
;
}
SQueryHbRspBasic
*
rspBasic
=
taosMemoryCalloc
(
1
,
sizeof
(
SQueryHbRspBasic
));
if
(
rspBasic
==
NULL
)
{
mndReleaseConn
(
pMnode
,
pConn
);
...
...
@@ -389,6 +390,8 @@ static int32_t mndProcessQueryHeartBeat(SMnode *pMnode, SRpcMsg *pMsg, SClientHb
mndReleaseConn
(
pMnode
,
pConn
);
hbRsp
.
query
=
rspBasic
;
}
else
{
mDebug
(
"no query info in hb msg"
);
}
int32_t
kvNum
=
taosHashGetSize
(
pHbReq
->
info
);
...
...
@@ -559,14 +562,13 @@ static int32_t mndProcessKillConnReq(SRpcMsg *pReq) {
}
}
static
int32_t
mndRetrieveConns
(
SRpcMsg
*
pReq
,
SShowObj
*
pShow
,
char
*
data
,
int32_t
rows
)
{
SMnode
*
pMnode
=
pReq
->
info
.
node
;
int32_t
numOfRows
=
0
;
SConnObj
*
pConn
=
NULL
;
int32_t
cols
=
0
;
char
*
pWrite
;
char
ipStr
[
TSDB_IPv4ADDR_LEN
+
6
];
static
int32_t
mndRetrieveConns
(
SRpcMsg
*
pReq
,
SShowObj
*
pShow
,
SSDataBlock
*
pBlock
,
int32_t
rows
)
{
SMnode
*
pMnode
=
pReq
->
info
.
node
;
SSdb
*
pSdb
=
pMnode
->
pSdb
;
int32_t
numOfRows
=
0
;
int32_t
cols
=
0
;
SConnObj
*
pConn
=
NULL
;
if
(
pShow
->
pIter
==
NULL
)
{
SProfileMgmt
*
pMgmt
=
&
pMnode
->
profileMgmt
;
pShow
->
pIter
=
taosCacheCreateIter
(
pMgmt
->
cache
);
...
...
@@ -574,61 +576,55 @@ static int32_t mndRetrieveConns(SRpcMsg *pReq, SShowObj *pShow, char *data, int3
while
(
numOfRows
<
rows
)
{
pConn
=
mndGetNextConn
(
pMnode
,
pShow
->
pIter
);
if
(
pConn
==
NULL
)
break
;
if
(
pConn
==
NULL
)
{
pShow
->
pIter
=
NULL
;
break
;
}
cols
=
0
;
#if 0
pWrite = data + pShow->offset[cols] * rows + pShow->pMeta->pSchemas[cols].bytes * numOfRows;
*(uint32_t *)pWrite = pConn->id;
cols++;
pWrite = data + pShow->offset[cols] * rows + pShow->pMeta->pSchemas[cols].bytes * numOfRows;
STR_WITH_MAXSIZE_TO_VARSTR(pWrite, pConn->user, pShow->pMeta->pSchemas[cols].bytes);
cols++;
// app name
pWrite = data + pShow->offset[cols] * rows + pShow->pMeta->pSchemas[cols].bytes * numOfRows;
STR_WITH_MAXSIZE_TO_VARSTR(pWrite, pConn->app, pShow->pMeta->pSchemas[cols].bytes);
cols++;
// app pid
pWrite = data + pShow->offset[cols] * rows + pShow->pMeta->pSchemas[cols].bytes * numOfRows;
*(int32_t *)pWrite = pConn->pid;
cols++;
pWrite = data + pShow->offset[cols] * rows + pShow->pMeta->pSchemas[cols].bytes * numOfRows;
taosIpPort2String(pConn->ip, pConn->port, ipStr);
STR_WITH_MAXSIZE_TO_VARSTR(pWrite, ipStr, pShow->pMeta->pSchemas[cols].bytes);
cols++;
pWrite = data + pShow->offset[cols] * rows + pShow->pMeta->pSchemas[cols].bytes * numOfRows;
*(int64_t *)pWrite = pConn->loginTimeMs;
cols++;
pWrite = data + pShow->offset[cols] * rows + pShow->pMeta->pSchemas[cols].bytes * numOfRows;
if (pConn->lastAccessTimeMs < pConn->loginTimeMs) pConn->lastAccessTimeMs = pConn->loginTimeMs;
*(int64_t *)pWrite = pConn->lastAccessTimeMs;
cols++;
#endif
SColumnInfoData
*
pColInfo
=
taosArrayGet
(
pBlock
->
pDataBlock
,
cols
++
);
colDataAppend
(
pColInfo
,
numOfRows
,
(
const
char
*
)
&
pConn
->
id
,
false
);
char
user
[
TSDB_USER_LEN
+
VARSTR_HEADER_SIZE
]
=
{
0
};
STR_TO_VARSTR
(
user
,
pConn
->
user
);
pColInfo
=
taosArrayGet
(
pBlock
->
pDataBlock
,
cols
++
);
colDataAppend
(
pColInfo
,
numOfRows
,
(
const
char
*
)
user
,
false
);
char
app
[
TSDB_APP_NAME_LEN
+
VARSTR_HEADER_SIZE
];
STR_TO_VARSTR
(
app
,
pConn
->
app
);
pColInfo
=
taosArrayGet
(
pBlock
->
pDataBlock
,
cols
++
);
colDataAppend
(
pColInfo
,
numOfRows
,
(
const
char
*
)
app
,
false
);
pColInfo
=
taosArrayGet
(
pBlock
->
pDataBlock
,
cols
++
);
colDataAppend
(
pColInfo
,
numOfRows
,
(
const
char
*
)
&
pConn
->
pid
,
false
);
char
endpoint
[
TSDB_IPv4ADDR_LEN
+
6
+
VARSTR_HEADER_SIZE
]
=
{
0
};
sprintf
(
&
endpoint
[
VARSTR_HEADER_SIZE
],
"%s:%d"
,
taosIpStr
(
pConn
->
ip
),
pConn
->
port
);
varDataLen
(
endpoint
)
=
strlen
(
&
endpoint
[
VARSTR_HEADER_SIZE
]);
pColInfo
=
taosArrayGet
(
pBlock
->
pDataBlock
,
cols
++
);
colDataAppend
(
pColInfo
,
numOfRows
,
(
const
char
*
)
endpoint
,
false
);
pColInfo
=
taosArrayGet
(
pBlock
->
pDataBlock
,
cols
++
);
colDataAppend
(
pColInfo
,
numOfRows
,
(
const
char
*
)
&
pConn
->
loginTimeMs
,
false
);
pColInfo
=
taosArrayGet
(
pBlock
->
pDataBlock
,
cols
++
);
colDataAppend
(
pColInfo
,
numOfRows
,
(
const
char
*
)
&
pConn
->
lastAccessTimeMs
,
false
);
numOfRows
++
;
}
pShow
->
numOfRows
+=
numOfRows
;
return
numOfRows
;
}
static
int32_t
mndRetrieveQueries
(
SRpcMsg
*
pReq
,
SShowObj
*
pShow
,
char
*
data
,
int32_t
rows
)
{
SMnode
*
pMnode
=
pReq
->
info
.
node
;
int32_t
numOfRows
=
0
;
#if 0
SConnObj *pConn = NULL;
int32_t cols = 0;
char *pWrite;
void *pIter;
char str[TSDB_IPv4ADDR_LEN + 6] = {0};
static
int32_t
mndRetrieveQueries
(
SRpcMsg
*
pReq
,
SShowObj
*
pShow
,
SSDataBlock
*
pBlock
,
int32_t
rows
)
{
SMnode
*
pMnode
=
pReq
->
info
.
node
;
SSdb
*
pSdb
=
pMnode
->
pSdb
;
int32_t
numOfRows
=
0
;
int32_t
cols
=
0
;
SConnObj
*
pConn
=
NULL
;
if
(
pShow
->
pIter
==
NULL
)
{
SProfileMgmt
*
pMgmt
=
&
pMnode
->
profileMgmt
;
pShow
->
pIter
=
taosCacheCreateIter
(
pMgmt
->
cache
);
...
...
@@ -641,85 +637,86 @@ static int32_t mndRetrieveQueries(SRpcMsg *pReq, SShowObj *pShow, char *data, in
break
;
}
if (numOfRows + pConn->numOfQueries >= rows) {
taosCacheDestroyIter(pShow->pIter);
pShow->pIter = NULL
;
break
;
taosRLockLatch
(
&
pConn
->
queryLock
);
if
(
NULL
==
pConn
->
pQueries
||
taosArrayGetSize
(
pConn
->
pQueries
)
<=
0
)
{
taosRUnLockLatch
(
&
pConn
->
queryLock
)
;
continue
;
}
for (int32_t i = 0; i < pConn->numOfQueries; ++i) {
SQueryDesc *pDesc = pConn->pQueries + i;
int32_t
numOfQueries
=
taosArrayGetSize
(
pConn
->
pQueries
);
for
(
int32_t
i
=
0
;
i
<
numOfQueries
;
++
i
)
{
SQueryDesc
*
pQuery
=
taosArrayGet
(
pConn
->
pQueries
,
i
);
cols
=
0
;
pWrite = data + pShow->offset[cols] * rows + pShow->pMeta->pSchemas[cols].bytes * numOfRows;
*(int64_t *)pWrite = htobe64(pDesc->queryId);
cols++;
pWrite = data + pShow->offset[cols] * rows + pShow->pMeta->pSchemas[cols].bytes * numOfRows;
*(int64_t *)pWrite = htobe64(pConn->id);
cols++;
char
queryId
[
26
+
VARSTR_HEADER_SIZE
]
=
{
0
};
sprintf
(
&
queryId
[
VARSTR_HEADER_SIZE
],
"%x:%"
PRIx64
,
pConn
->
id
,
pQuery
->
reqRid
);
varDataLen
(
queryId
)
=
strlen
(
&
queryId
[
VARSTR_HEADER_SIZE
]);
SColumnInfoData
*
pColInfo
=
taosArrayGet
(
pBlock
->
pDataBlock
,
cols
++
);
colDataAppend
(
pColInfo
,
numOfRows
,
(
const
char
*
)
queryId
,
false
);
pWrite = data + pShow->offset[cols] * rows + pShow->pMeta->pSchemas[cols].bytes * numOfRows;
STR_WITH_MAXSIZE_TO_VARSTR(pWrite, pConn->user, pShow->pMeta->pSchemas[cols].bytes);
cols++;
pColInfo
=
taosArrayGet
(
pBlock
->
pDataBlock
,
cols
++
);
colDataAppend
(
pColInfo
,
numOfRows
,
(
const
char
*
)
&
pQuery
->
queryId
,
false
);
pWrite = data + pShow->offset[cols] * rows + pShow->pMeta->pSchemas[cols].bytes * numOfRows;
snprintf(str, tListLen(str), "%s:%u", taosIpStr(pConn->ip), pConn->port);
STR_WITH_MAXSIZE_TO_VARSTR(pWrite, str, pShow->pMeta->pSchemas[cols].bytes);
cols++;
pColInfo
=
taosArrayGet
(
pBlock
->
pDataBlock
,
cols
++
);
colDataAppend
(
pColInfo
,
numOfRows
,
(
const
char
*
)
&
pConn
->
id
,
false
);
char handleBuf[24] = {0};
snprintf(handleBuf, tListLen(handleBuf), "%" PRIu64, htobe64(pDesc->qId));
pWrite = data + pShow->offset[cols] * rows + pShow->pMeta->pSchemas[cols].bytes * numOfRows;
char
app
[
TSDB_APP_NAME_LEN
+
VARSTR_HEADER_SIZE
];
STR_TO_VARSTR
(
app
,
pConn
->
app
);
pColInfo
=
taosArrayGet
(
pBlock
->
pDataBlock
,
cols
++
);
colDataAppend
(
pColInfo
,
numOfRows
,
(
const
char
*
)
app
,
false
);
STR_WITH_MAXSIZE_TO_VARSTR(pWrite, handleBuf, pShow->pMeta->pSchemas[cols].bytes
);
col
s++
;
pColInfo
=
taosArrayGet
(
pBlock
->
pDataBlock
,
cols
++
);
col
DataAppend
(
pColInfo
,
numOfRows
,
(
const
char
*
)
&
pQuery
->
pid
,
false
)
;
pWrite = data + pShow->offset[cols] * rows + pShow->pMeta->pSchemas[cols].bytes * numOfRows;
*(int64_t *)pWrite = htobe64(pDesc->stime);
cols++;
char
user
[
TSDB_USER_LEN
+
VARSTR_HEADER_SIZE
]
=
{
0
};
STR_TO_VARSTR
(
user
,
pConn
->
user
);
pColInfo
=
taosArrayGet
(
pBlock
->
pDataBlock
,
cols
++
);
colDataAppend
(
pColInfo
,
numOfRows
,
(
const
char
*
)
user
,
false
);
pWrite = data + pShow->offset[cols] * rows + pShow->pMeta->pSchemas[cols].bytes * numOfRows;
*(int64_t *)pWrite = htobe64(pDesc->useconds);
cols++;
char
endpoint
[
TSDB_IPv4ADDR_LEN
+
6
+
VARSTR_HEADER_SIZE
]
=
{
0
};
sprintf
(
&
endpoint
[
VARSTR_HEADER_SIZE
],
"%s:%d"
,
taosIpStr
(
pConn
->
ip
),
pConn
->
port
);
varDataLen
(
endpoint
)
=
strlen
(
&
endpoint
[
VARSTR_HEADER_SIZE
]);
pColInfo
=
taosArrayGet
(
pBlock
->
pDataBlock
,
cols
++
);
colDataAppend
(
pColInfo
,
numOfRows
,
(
const
char
*
)
endpoint
,
false
);
snprintf(str, tListLen(str), "0x%" PRIx64, htobe64(pDesc->sqlObjId));
pWrite = data + pShow->offset[cols] * rows + pShow->pMeta->pSchemas[cols].bytes * numOfRows;
STR_WITH_MAXSIZE_TO_VARSTR(pWrite, str, pShow->pMeta->pSchemas[cols].bytes);
cols++;
pColInfo
=
taosArrayGet
(
pBlock
->
pDataBlock
,
cols
++
);
colDataAppend
(
pColInfo
,
numOfRows
,
(
const
char
*
)
&
pQuery
->
stime
,
false
);
pWrite = data + pShow->offset[cols] * rows + pShow->pMeta->pSchemas[cols].bytes * numOfRows;
*(int32_t *)pWrite = htonl(pDesc->pid);
cols++;
pColInfo
=
taosArrayGet
(
pBlock
->
pDataBlock
,
cols
++
);
colDataAppend
(
pColInfo
,
numOfRows
,
(
const
char
*
)
&
pQuery
->
useconds
,
false
);
char epBuf[TSDB_EP_LEN + 1] = {0};
snprintf(epBuf, tListLen(epBuf), "%s:%u", pDesc->fqdn, pConn->port);
pWrite = data + pShow->offset[cols] * rows + pShow->pMeta->pSchemas[cols].bytes * numOfRows;
STR_WITH_MAXSIZE_TO_VARSTR(pWrite, epBuf, pShow->pMeta->pSchemas[cols].bytes);
cols++;
pColInfo
=
taosArrayGet
(
pBlock
->
pDataBlock
,
cols
++
);
colDataAppend
(
pColInfo
,
numOfRows
,
(
const
char
*
)
&
pQuery
->
stableQuery
,
false
);
pWrite = data + pShow->offset[cols] * rows + pShow->pMeta->pSchemas[cols].bytes * numOfRows;
*(bool *)pWrite = pDesc->stableQuery;
cols++;
pColInfo
=
taosArrayGet
(
pBlock
->
pDataBlock
,
cols
++
);
colDataAppend
(
pColInfo
,
numOfRows
,
(
const
char
*
)
&
pQuery
->
subPlanNum
,
false
);
pWrite = data + pShow->offset[cols] * rows + pShow->pMeta->pSchemas[cols].bytes * numOfRows;
*(int32_t *)pWrite = htonl(pDesc->numOfSub);
cols++;
pWrite = data + pShow->offset[cols] * rows + pShow->pMeta->pSchemas[cols].bytes * numOfRows;
STR_WITH_MAXSIZE_TO_VARSTR(pWrite, pDesc->subSqlInfo, pShow->pMeta->pSchemas[cols].bytes);
cols++;
char
subStatus
[
TSDB_SHOW_SUBQUERY_LEN
+
VARSTR_HEADER_SIZE
]
=
{
0
};
int32_t
strSize
=
sizeof
(
subStatus
);
int32_t
offset
=
VARSTR_HEADER_SIZE
;
for
(
int32_t
i
=
0
;
i
<
pQuery
->
subPlanNum
&&
offset
<
strSize
;
++
i
)
{
if
(
i
)
{
offset
+=
snprintf
(
subStatus
+
offset
,
strSize
-
offset
-
1
,
","
);
}
SQuerySubDesc
*
pDesc
=
taosArrayGet
(
pQuery
->
subDesc
,
i
);
offset
+=
snprintf
(
subStatus
+
offset
,
strSize
-
offset
-
1
,
"%"
PRIu64
":%s"
,
pDesc
->
tid
,
pDesc
->
status
);
}
varDataLen
(
subStatus
)
=
strlen
(
&
subStatus
[
VARSTR_HEADER_SIZE
]);
pColInfo
=
taosArrayGet
(
pBlock
->
pDataBlock
,
cols
++
);
colDataAppend
(
pColInfo
,
numOfRows
,
subStatus
,
false
);
pWrite = data + pShow->offset[cols] * rows + pShow->pMeta->pSchemas[cols].bytes * numOfRows;
STR_WITH_MAXSIZE_TO_VARSTR(pWrite, pDesc->sql, pShow->pMeta->pSchemas[cols].bytes);
cols++;
char
sql
[
TSDB_SHOW_SQL_LEN
+
VARSTR_HEADER_SIZE
]
=
{
0
};
STR_TO_VARSTR
(
sql
,
pQuery
->
sql
);
pColInfo
=
taosArrayGet
(
pBlock
->
pDataBlock
,
cols
++
);
colDataAppend
(
pColInfo
,
numOfRows
,
(
const
char
*
)
sql
,
false
);
numOfRows
++
;
}
taosRUnLockLatch
(
&
pConn
->
queryLock
);
}
pShow
->
numOfRows
+=
numOfRows
;
#endif
return
numOfRows
;
}
...
...
source/dnode/mnode/impl/src/mndQnode.c
浏览文件 @
e52429e3
...
...
@@ -271,7 +271,6 @@ static int32_t mndProcessCreateQnodeReq(SRpcMsg *pReq) {
int32_t
code
=
-
1
;
SQnodeObj
*
pObj
=
NULL
;
SDnodeObj
*
pDnode
=
NULL
;
SUserObj
*
pUser
=
NULL
;
SMCreateQnodeReq
createReq
=
{
0
};
if
(
tDeserializeSCreateDropMQSBNodeReq
(
pReq
->
pCont
,
pReq
->
contLen
,
&
createReq
)
!=
0
)
{
...
...
@@ -295,13 +294,7 @@ static int32_t mndProcessCreateQnodeReq(SRpcMsg *pReq) {
goto
_OVER
;
}
pUser
=
mndAcquireUser
(
pMnode
,
pReq
->
conn
.
user
);
if
(
pUser
==
NULL
)
{
terrno
=
TSDB_CODE_MND_NO_USER_FROM_CONN
;
goto
_OVER
;
}
if
(
mndCheckNodeAuth
(
pUser
)
!=
0
)
{
if
(
mndCheckOperAuth
(
pMnode
,
pReq
->
conn
.
user
,
MND_OPER_CREATE_QNODE
)
!=
0
)
{
goto
_OVER
;
}
...
...
@@ -315,7 +308,6 @@ _OVER:
mndReleaseQnode
(
pMnode
,
pObj
);
mndReleaseDnode
(
pMnode
,
pDnode
);
mndReleaseUser
(
pMnode
,
pUser
);
return
code
;
}
...
...
@@ -384,7 +376,6 @@ _OVER:
static
int32_t
mndProcessDropQnodeReq
(
SRpcMsg
*
pReq
)
{
SMnode
*
pMnode
=
pReq
->
info
.
node
;
int32_t
code
=
-
1
;
SUserObj
*
pUser
=
NULL
;
SQnodeObj
*
pObj
=
NULL
;
SMDropQnodeReq
dropReq
=
{
0
};
...
...
@@ -405,13 +396,7 @@ static int32_t mndProcessDropQnodeReq(SRpcMsg *pReq) {
goto
_OVER
;
}
pUser
=
mndAcquireUser
(
pMnode
,
pReq
->
conn
.
user
);
if
(
pUser
==
NULL
)
{
terrno
=
TSDB_CODE_MND_NO_USER_FROM_CONN
;
goto
_OVER
;
}
if
(
mndCheckNodeAuth
(
pUser
)
!=
0
)
{
if
(
mndCheckOperAuth
(
pMnode
,
pReq
->
conn
.
user
,
MND_OPER_DROP_QNODE
)
!=
0
)
{
goto
_OVER
;
}
...
...
@@ -424,8 +409,6 @@ _OVER:
}
mndReleaseQnode
(
pMnode
,
pObj
);
mndReleaseUser
(
pMnode
,
pUser
);
return
code
;
}
...
...
source/dnode/mnode/impl/src/mndScheduler.c
浏览文件 @
e52429e3
...
...
@@ -63,10 +63,11 @@ int32_t mndConvertRsmaTask(char** pDst, int32_t* pDstLen, const char* ast, int64
.
topicQuery
=
false
,
.
streamQuery
=
true
,
.
rSmaQuery
=
true
,
.
triggerType
=
triggerType
,
.
triggerType
=
STREAM_TRIGGER_AT_ONCE
,
.
watermark
=
watermark
,
.
filesFactor
=
filesFactor
,
/*.filesFactor = filesFactor,*/
};
if
(
qCreateQueryPlan
(
&
cxt
,
&
pPlan
,
NULL
)
<
0
)
{
terrno
=
TSDB_CODE_QRY_INVALID_INPUT
;
goto
END
;
...
...
@@ -387,6 +388,9 @@ int32_t mndScheduleStream(SMnode* pMnode, STrans* pTrans, SStreamObj* pStream) {
// input
pFinalTask
->
inputType
=
TASK_INPUT_TYPE__DATA_BLOCK
;
// trigger
pFinalTask
->
triggerParam
=
pStream
->
triggerParam
;
// dispatch
if
(
mndAddDispatcherToInnerTask
(
pMnode
,
pTrans
,
pStream
,
pFinalTask
)
<
0
)
{
qDestroyQueryPlan
(
pPlan
);
...
...
source/dnode/mnode/impl/src/mndShow.c
浏览文件 @
e52429e3
...
...
@@ -16,6 +16,7 @@
#define _DEFAULT_SOURCE
#include "mndShow.h"
#include "systable.h"
#include "mndAuth.h"
#define SHOW_STEP_SIZE 100
...
...
@@ -228,6 +229,8 @@ static int32_t mndProcessRetrieveSysTableReq(SRpcMsg *pReq) {
mDebug
(
"show:0x%"
PRIx64
", start retrieve data, type:%d"
,
pShow
->
id
,
pShow
->
type
);
// if (mndCheckShowAuth(pMnode, pReq->conn.user, pShow->type) != 0) return -1;
int32_t
numOfCols
=
pShow
->
pMeta
->
numOfColumns
;
SSDataBlock
*
pBlock
=
taosMemoryCalloc
(
1
,
sizeof
(
SSDataBlock
));
pBlock
->
pDataBlock
=
taosArrayInit
(
numOfCols
,
sizeof
(
SColumnInfoData
));
...
...
source/dnode/mnode/impl/src/mndSma.c
浏览文件 @
e52429e3
...
...
@@ -561,6 +561,8 @@ static int32_t mndCreateSma(SMnode *pMnode, SRpcMsg *pReq, SMCreateSmaReq *pCrea
streamObj
.
sql
=
pCreate
->
sql
;
streamObj
.
createdBy
=
STREAM_CREATED_BY__SMA
;
streamObj
.
smaId
=
smaObj
.
uid
;
streamObj
.
watermark
=
0
;
streamObj
.
trigger
=
STREAM_TRIGGER_AT_ONCE
;
if
(
mndAllocSmaVgroup
(
pMnode
,
pDb
,
&
streamObj
.
fixedSinkVg
)
!=
0
)
{
mError
(
"sma:%s, failed to create since %s"
,
smaObj
.
name
,
terrstr
());
...
...
@@ -583,7 +585,7 @@ static int32_t mndCreateSma(SMnode *pMnode, SRpcMsg *pReq, SMCreateSmaReq *pCrea
if
(
mndSetUpdateSmaStbCommitLogs
(
pMnode
,
pTrans
,
pStb
)
!=
0
)
goto
_OVER
;
// if (mndSetCreateSmaRedoActions(pMnode, pTrans, pDb, &smaObj) != 0) goto _OVER;
if
(
mndSetCreateSmaVgroupRedoActions
(
pMnode
,
pTrans
,
pDb
,
&
streamObj
.
fixedSinkVg
,
&
smaObj
)
!=
0
)
goto
_OVER
;
if
(
mndAddStreamToTrans
(
pMnode
,
&
streamObj
,
pCreate
->
ast
,
STREAM_TRIGGER_AT_ONCE
,
0
,
pTrans
)
!=
0
)
goto
_OVER
;
if
(
mndAddStreamToTrans
(
pMnode
,
&
streamObj
,
pCreate
->
ast
,
pTrans
)
!=
0
)
goto
_OVER
;
if
(
mndTransPrepare
(
pMnode
,
pTrans
)
!=
0
)
goto
_OVER
;
code
=
0
;
...
...
@@ -629,7 +631,6 @@ static int32_t mndProcessCreateSmaReq(SRpcMsg *pReq) {
SSmaObj
*
pSma
=
NULL
;
SStreamObj
*
pStream
=
NULL
;
SDbObj
*
pDb
=
NULL
;
SUserObj
*
pUser
=
NULL
;
SMCreateSmaReq
createReq
=
{
0
};
if
(
tDeserializeSMCreateSmaReq
(
pReq
->
pCont
,
pReq
->
contLen
,
&
createReq
)
!=
0
)
{
...
...
@@ -673,12 +674,7 @@ static int32_t mndProcessCreateSmaReq(SRpcMsg *pReq) {
goto
_OVER
;
}
pUser
=
mndAcquireUser
(
pMnode
,
pReq
->
conn
.
user
);
if
(
pUser
==
NULL
)
{
goto
_OVER
;
}
if
(
mndCheckWriteAuth
(
pUser
,
pDb
)
!=
0
)
{
if
(
mndCheckDbAuth
(
pMnode
,
pReq
->
conn
.
user
,
MND_OPER_WRITE_DB
,
pDb
)
!=
0
)
{
goto
_OVER
;
}
...
...
@@ -694,7 +690,6 @@ _OVER:
mndReleaseSma
(
pMnode
,
pSma
);
mndReleaseStream
(
pMnode
,
pStream
);
mndReleaseDb
(
pMnode
,
pDb
);
mndReleaseUser
(
pMnode
,
pUser
);
tFreeSMCreateSmaReq
(
&
createReq
);
return
code
;
...
...
@@ -911,7 +906,6 @@ _OVER:
static
int32_t
mndProcessDropSmaReq
(
SRpcMsg
*
pReq
)
{
SMnode
*
pMnode
=
pReq
->
info
.
node
;
int32_t
code
=
-
1
;
SUserObj
*
pUser
=
NULL
;
SDbObj
*
pDb
=
NULL
;
SSmaObj
*
pSma
=
NULL
;
SMDropSmaReq
dropReq
=
{
0
};
...
...
@@ -941,12 +935,7 @@ static int32_t mndProcessDropSmaReq(SRpcMsg *pReq) {
goto
_OVER
;
}
pUser
=
mndAcquireUser
(
pMnode
,
pReq
->
conn
.
user
);
if
(
pUser
==
NULL
)
{
goto
_OVER
;
}
if
(
mndCheckWriteAuth
(
pUser
,
pDb
)
!=
0
)
{
if
(
mndCheckDbAuth
(
pMnode
,
pReq
->
conn
.
user
,
MND_OPER_WRITE_DB
,
pDb
)
!=
0
)
{
goto
_OVER
;
}
...
...
@@ -959,9 +948,6 @@ _OVER:
}
mndReleaseDb
(
pMnode
,
pDb
);
mndReleaseSma
(
pMnode
,
pSma
);
mndReleaseUser
(
pMnode
,
pUser
);
return
code
;
}
...
...
source/dnode/mnode/impl/src/mndSnode.c
浏览文件 @
e52429e3
...
...
@@ -277,7 +277,6 @@ static int32_t mndProcessCreateSnodeReq(SRpcMsg *pReq) {
int32_t
code
=
-
1
;
SSnodeObj
*
pObj
=
NULL
;
SDnodeObj
*
pDnode
=
NULL
;
SUserObj
*
pUser
=
NULL
;
SMCreateSnodeReq
createReq
=
{
0
};
if
(
tDeserializeSCreateDropMQSBNodeReq
(
pReq
->
pCont
,
pReq
->
contLen
,
&
createReq
)
!=
0
)
{
...
...
@@ -301,13 +300,7 @@ static int32_t mndProcessCreateSnodeReq(SRpcMsg *pReq) {
goto
_OVER
;
}
pUser
=
mndAcquireUser
(
pMnode
,
pReq
->
conn
.
user
);
if
(
pUser
==
NULL
)
{
terrno
=
TSDB_CODE_MND_NO_USER_FROM_CONN
;
goto
_OVER
;
}
if
(
mndCheckNodeAuth
(
pUser
)
!=
0
)
{
if
(
mndCheckOperAuth
(
pMnode
,
pReq
->
conn
.
user
,
MND_OPER_CREATE_SNODE
)
!=
0
)
{
goto
_OVER
;
}
...
...
@@ -322,7 +315,6 @@ _OVER:
mndReleaseSnode
(
pMnode
,
pObj
);
mndReleaseDnode
(
pMnode
,
pDnode
);
mndReleaseUser
(
pMnode
,
pUser
);
return
code
;
}
...
...
@@ -392,7 +384,6 @@ _OVER:
static
int32_t
mndProcessDropSnodeReq
(
SRpcMsg
*
pReq
)
{
SMnode
*
pMnode
=
pReq
->
info
.
node
;
int32_t
code
=
-
1
;
SUserObj
*
pUser
=
NULL
;
SSnodeObj
*
pObj
=
NULL
;
SMDropSnodeReq
dropReq
=
{
0
};
...
...
@@ -413,13 +404,7 @@ static int32_t mndProcessDropSnodeReq(SRpcMsg *pReq) {
goto
_OVER
;
}
pUser
=
mndAcquireUser
(
pMnode
,
pReq
->
conn
.
user
);
if
(
pUser
==
NULL
)
{
terrno
=
TSDB_CODE_MND_NO_USER_FROM_CONN
;
goto
_OVER
;
}
if
(
mndCheckNodeAuth
(
pUser
)
!=
0
)
{
if
(
mndCheckOperAuth
(
pMnode
,
pReq
->
conn
.
user
,
MND_OPER_DROP_SNODE
)
!=
0
)
{
goto
_OVER
;
}
...
...
@@ -432,8 +417,6 @@ _OVER:
}
mndReleaseSnode
(
pMnode
,
pObj
);
mndReleaseUser
(
pMnode
,
pUser
);
return
code
;
}
...
...
source/dnode/mnode/impl/src/mndStb.c
浏览文件 @
e52429e3
...
...
@@ -773,7 +773,6 @@ static int32_t mndProcessCreateStbReq(SRpcMsg *pReq) {
int32_t
code
=
-
1
;
SStbObj
*
pStb
=
NULL
;
SDbObj
*
pDb
=
NULL
;
SUserObj
*
pUser
=
NULL
;
SMCreateStbReq
createReq
=
{
0
};
if
(
tDeserializeSMCreateStbReq
(
pReq
->
pCont
,
pReq
->
contLen
,
&
createReq
)
!=
0
)
{
...
...
@@ -807,12 +806,7 @@ static int32_t mndProcessCreateStbReq(SRpcMsg *pReq) {
goto
_OVER
;
}
pUser
=
mndAcquireUser
(
pMnode
,
pReq
->
conn
.
user
);
if
(
pUser
==
NULL
)
{
goto
_OVER
;
}
if
(
mndCheckWriteAuth
(
pUser
,
pDb
)
!=
0
)
{
if
(
mndCheckDbAuth
(
pMnode
,
pReq
->
conn
.
user
,
MND_OPER_WRITE_DB
,
pDb
)
!=
0
)
{
goto
_OVER
;
}
...
...
@@ -836,7 +830,6 @@ _OVER:
mndReleaseStb
(
pMnode
,
pStb
);
mndReleaseDb
(
pMnode
,
pDb
);
mndReleaseUser
(
pMnode
,
pUser
);
tFreeSMCreateStbReq
(
&
createReq
);
return
code
;
...
...
@@ -1291,7 +1284,7 @@ static int32_t mndBuildStbSchema(SMnode *pMnode, const char *dbFName, const char
SStbObj
*
pStb
=
mndAcquireStb
(
pMnode
,
tbFName
);
if
(
pStb
==
NULL
)
{
mndReleaseDb
(
pMnode
,
pDb
);
terrno
=
TSDB_CODE_
MND_INVALID_STB
;
terrno
=
TSDB_CODE_
PAR_TABLE_NOT_EXIST
;
return
-
1
;
}
...
...
@@ -1431,7 +1424,6 @@ static int32_t mndProcessAlterStbReq(SRpcMsg *pReq) {
int32_t
code
=
-
1
;
SDbObj
*
pDb
=
NULL
;
SStbObj
*
pStb
=
NULL
;
SUserObj
*
pUser
=
NULL
;
SMAlterStbReq
alterReq
=
{
0
};
if
(
tDeserializeSMAlterStbReq
(
pReq
->
pCont
,
pReq
->
contLen
,
&
alterReq
)
!=
0
)
{
...
...
@@ -1462,12 +1454,7 @@ static int32_t mndProcessAlterStbReq(SRpcMsg *pReq) {
goto
_OVER
;
}
pUser
=
mndAcquireUser
(
pMnode
,
pReq
->
conn
.
user
);
if
(
pUser
==
NULL
)
{
goto
_OVER
;
}
if
(
mndCheckWriteAuth
(
pUser
,
pDb
)
!=
0
)
{
if
(
mndCheckDbAuth
(
pMnode
,
pReq
->
conn
.
user
,
MND_OPER_WRITE_DB
,
pDb
)
!=
0
)
{
goto
_OVER
;
}
...
...
@@ -1481,7 +1468,6 @@ _OVER:
mndReleaseStb
(
pMnode
,
pStb
);
mndReleaseDb
(
pMnode
,
pDb
);
mndReleaseUser
(
pMnode
,
pUser
);
taosArrayDestroy
(
alterReq
.
pFields
);
return
code
;
...
...
@@ -1569,7 +1555,6 @@ _OVER:
static
int32_t
mndProcessDropStbReq
(
SRpcMsg
*
pReq
)
{
SMnode
*
pMnode
=
pReq
->
info
.
node
;
int32_t
code
=
-
1
;
SUserObj
*
pUser
=
NULL
;
SDbObj
*
pDb
=
NULL
;
SStbObj
*
pStb
=
NULL
;
SMDropStbReq
dropReq
=
{
0
};
...
...
@@ -1599,12 +1584,7 @@ static int32_t mndProcessDropStbReq(SRpcMsg *pReq) {
goto
_OVER
;
}
pUser
=
mndAcquireUser
(
pMnode
,
pReq
->
conn
.
user
);
if
(
pUser
==
NULL
)
{
goto
_OVER
;
}
if
(
mndCheckWriteAuth
(
pUser
,
pDb
)
!=
0
)
{
if
(
mndCheckDbAuth
(
pMnode
,
pReq
->
conn
.
user
,
MND_OPER_WRITE_DB
,
pDb
)
!=
0
)
{
goto
_OVER
;
}
...
...
@@ -1618,8 +1598,6 @@ _OVER:
mndReleaseDb
(
pMnode
,
pDb
);
mndReleaseStb
(
pMnode
,
pStb
);
mndReleaseUser
(
pMnode
,
pUser
);
return
code
;
}
...
...
source/dnode/mnode/impl/src/mndStream.c
浏览文件 @
e52429e3
...
...
@@ -35,7 +35,7 @@ static int32_t mndStreamActionInsert(SSdb *pSdb, SStreamObj *pStream);
static
int32_t
mndStreamActionDelete
(
SSdb
*
pSdb
,
SStreamObj
*
pStream
);
static
int32_t
mndStreamActionUpdate
(
SSdb
*
pSdb
,
SStreamObj
*
pStream
,
SStreamObj
*
pNewStream
);
static
int32_t
mndProcessCreateStreamReq
(
SRpcMsg
*
pReq
);
/*static int32_t mndProcessDropStreamReq(SRpcMsg *pReq);*/
static
int32_t
mndProcessDropStreamReq
(
SRpcMsg
*
pReq
);
/*static int32_t mndProcessDropStreamInRsp(SRpcMsg *pRsp);*/
static
int32_t
mndProcessStreamMetaReq
(
SRpcMsg
*
pReq
);
static
int32_t
mndGetStreamMeta
(
SRpcMsg
*
pReq
,
SShowObj
*
pShow
,
STableMetaRsp
*
pMeta
);
...
...
@@ -55,9 +55,8 @@ int32_t mndInitStream(SMnode *pMnode) {
mndSetMsgHandle
(
pMnode
,
TDMT_MND_CREATE_STREAM
,
mndProcessCreateStreamReq
);
mndSetMsgHandle
(
pMnode
,
TDMT_STREAM_TASK_DEPLOY_RSP
,
mndTransProcessRsp
);
/*mndSetMsgHandle(pMnode, TDMT_SND_TASK_DEPLOY_RSP, mndTransProcessRsp);*/
/*mndSetMsgHandle(pMnode, TDMT_MND_DROP_STREAM, mndProcessDropStreamReq);*/
/*mndSetMsgHandle(pMnode, TDMT_MND_DROP_STREAM_RSP, mndProcessDropStreamInRsp);*/
mndSetMsgHandle
(
pMnode
,
TDMT_MND_DROP_STREAM
,
mndProcessDropStreamReq
);
mndSetMsgHandle
(
pMnode
,
TDMT_MND_DROP_STREAM_RSP
,
mndTransProcessRsp
);
mndAddShowRetrieveHandle
(
pMnode
,
TSDB_MGMT_TABLE_STREAMS
,
mndRetrieveStream
);
mndAddShowFreeIterHandle
(
pMnode
,
TSDB_MGMT_TABLE_STREAMS
,
mndCancelGetNextStream
);
...
...
@@ -196,16 +195,6 @@ void mndReleaseStream(SMnode *pMnode, SStreamObj *pStream) {
sdbRelease
(
pSdb
,
pStream
);
}
static
SDbObj
*
mndAcquireDbByStream
(
SMnode
*
pMnode
,
char
*
streamName
)
{
SName
name
=
{
0
};
tNameFromString
(
&
name
,
streamName
,
T_NAME_ACCT
|
T_NAME_DB
|
T_NAME_TABLE
);
char
db
[
TSDB_STREAM_FNAME_LEN
]
=
{
0
};
tNameGetFullDbName
(
&
name
,
db
);
return
mndAcquireDb
(
pMnode
,
db
);
}
static
int32_t
mndCheckCreateStreamReq
(
SCMCreateStreamReq
*
pCreate
)
{
if
(
pCreate
->
name
[
0
]
==
0
||
pCreate
->
sql
==
NULL
||
pCreate
->
sql
[
0
]
==
0
)
{
terrno
=
TSDB_CODE_MND_INVALID_STREAM_OPTION
;
...
...
@@ -228,23 +217,22 @@ static int32_t mndStreamGetPlanString(const char *ast, int8_t triggerType, int64
.
pAstRoot
=
pAst
,
.
topicQuery
=
false
,
.
streamQuery
=
true
,
.
triggerType
=
triggerType
,
.
triggerType
=
triggerType
==
STREAM_TRIGGER_MAX_DELAY
?
STREAM_TRIGGER_WINDOW_CLOSE
:
triggerType
,
.
watermark
=
watermark
,
};
code
=
qCreateQueryPlan
(
&
cxt
,
&
pPlan
,
NULL
);
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
nodesNodeToString
((
SNode
*
)
pPlan
,
false
,
pStr
,
NULL
);
code
=
nodesNodeToString
((
SNode
*
)
pPlan
,
false
,
pStr
,
NULL
);
}
nodesDestroyNode
(
pAst
);
nodesDestroyNode
((
SNode
*
)
pPlan
);
nodesDestroyNode
((
SNode
*
)
pPlan
);
terrno
=
code
;
return
code
;
}
int32_t
mndAddStreamToTrans
(
SMnode
*
pMnode
,
SStreamObj
*
pStream
,
const
char
*
ast
,
int8_t
triggerType
,
int64_t
watermark
,
STrans
*
pTrans
)
{
int32_t
mndAddStreamToTrans
(
SMnode
*
pMnode
,
SStreamObj
*
pStream
,
const
char
*
ast
,
STrans
*
pTrans
)
{
SNode
*
pAst
=
NULL
;
if
(
nodesStringToNode
(
ast
,
&
pAst
)
<
0
)
{
...
...
@@ -258,7 +246,6 @@ int32_t mndAddStreamToTrans(SMnode *pMnode, SStreamObj *pStream, const char *ast
// free
nodesDestroyNode
(
pAst
);
#if 0
printf("|");
for (int i = 0; i < pStream->outputSchema.nCols; i++) {
...
...
@@ -268,7 +255,7 @@ int32_t mndAddStreamToTrans(SMnode *pMnode, SStreamObj *pStream, const char *ast
#endif
if
(
TSDB_CODE_SUCCESS
!=
mndStreamGetPlanString
(
ast
,
triggerType
,
watermark
,
&
pStream
->
physicalPlan
))
{
if
(
TSDB_CODE_SUCCESS
!=
mndStreamGetPlanString
(
ast
,
pStream
->
trigger
,
pStream
->
watermark
,
&
pStream
->
physicalPlan
))
{
mError
(
"topic:%s, failed to get plan since %s"
,
pStream
->
name
,
terrstr
());
return
-
1
;
}
...
...
@@ -293,7 +280,6 @@ int32_t mndAddStreamToTrans(SMnode *pMnode, SStreamObj *pStream, const char *ast
static
int32_t
mndCreateStbForStream
(
SMnode
*
pMnode
,
STrans
*
pTrans
,
const
SStreamObj
*
pStream
,
const
char
*
user
)
{
SStbObj
*
pStb
=
NULL
;
SDbObj
*
pDb
=
NULL
;
SUserObj
*
pUser
=
NULL
;
SMCreateStbReq
createReq
=
{
0
};
tstrncpy
(
createReq
.
name
,
pStream
->
targetSTbName
,
TSDB_TABLE_FNAME_LEN
);
...
...
@@ -335,12 +321,8 @@ static int32_t mndCreateStbForStream(SMnode *pMnode, STrans *pTrans, const SStre
goto
_OVER
;
}
pUser
=
mndAcquireUser
(
pMnode
,
user
);
if
(
pUser
==
NULL
)
{
goto
_OVER
;
}
if
(
mndCheck
WriteAuth
(
pUser
,
pDb
)
!=
0
)
{
if
(
mndCheck
DbAuth
(
pMnode
,
user
,
MND_OPER_WRITE_DB
,
pDb
)
!=
0
)
{
goto
_OVER
;
}
...
...
@@ -368,10 +350,50 @@ static int32_t mndCreateStbForStream(SMnode *pMnode, STrans *pTrans, const SStre
_OVER:
mndReleaseStb
(
pMnode
,
pStb
);
mndReleaseDb
(
pMnode
,
pDb
);
mndReleaseUser
(
pMnode
,
pUser
);
return
-
1
;
}
static
int32_t
mndPersistTaskDropReq
(
STrans
*
pTrans
,
SStreamTask
*
pTask
)
{
ASSERT
(
pTask
->
nodeId
!=
0
);
// vnode
if
(
pTask
->
nodeId
>
0
)
{
SVDropStreamTaskReq
*
pReq
=
taosMemoryCalloc
(
1
,
sizeof
(
SVDropStreamTaskReq
));
if
(
pReq
==
NULL
)
{
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
return
-
1
;
}
pReq
->
head
.
vgId
=
htonl
(
pTask
->
nodeId
);
pReq
->
taskId
=
pTask
->
taskId
;
STransAction
action
=
{
0
};
memcpy
(
&
action
.
epSet
,
&
pTask
->
epSet
,
sizeof
(
SEpSet
));
action
.
pCont
=
pReq
;
action
.
contLen
=
sizeof
(
SVDropStreamTaskReq
);
action
.
msgType
=
TDMT_VND_STREAM_TASK_DROP
;
if
(
mndTransAppendRedoAction
(
pTrans
,
&
action
)
!=
0
)
{
taosMemoryFree
(
pReq
);
return
-
1
;
}
}
return
0
;
}
static
int32_t
mndDropStreamTasks
(
SMnode
*
pMnode
,
STrans
*
pTrans
,
SStreamObj
*
pStream
)
{
int32_t
lv
=
taosArrayGetSize
(
pStream
->
tasks
);
for
(
int32_t
i
=
0
;
i
<
lv
;
i
++
)
{
SArray
*
pTasks
=
taosArrayGetP
(
pStream
->
tasks
,
i
);
int32_t
sz
=
taosArrayGetSize
(
pTasks
);
for
(
int32_t
j
=
0
;
j
<
sz
;
j
++
)
{
SStreamTask
*
pTask
=
taosArrayGetP
(
pTasks
,
j
);
if
(
mndPersistTaskDropReq
(
pTrans
,
pTask
)
<
0
)
{
return
-
1
;
}
}
}
return
0
;
}
static
int32_t
mndCreateStream
(
SMnode
*
pMnode
,
SRpcMsg
*
pReq
,
SCMCreateStreamReq
*
pCreate
,
SDbObj
*
pDb
)
{
mDebug
(
"stream:%s to create"
,
pCreate
->
name
);
SStreamObj
streamObj
=
{
0
};
...
...
@@ -391,7 +413,8 @@ static int32_t mndCreateStream(SMnode *pMnode, SRpcMsg *pReq, SCMCreateStreamReq
streamObj
.
smaId
=
0
;
/*streamObj.physicalPlan = "";*/
streamObj
.
trigger
=
pCreate
->
triggerType
;
streamObj
.
waterMark
=
pCreate
->
watermark
;
streamObj
.
watermark
=
pCreate
->
watermark
;
streamObj
.
triggerParam
=
pCreate
->
maxDelay
;
if
(
streamObj
.
targetSTbName
[
0
])
{
pDb
=
mndAcquireDbByStb
(
pMnode
,
streamObj
.
targetSTbName
);
...
...
@@ -409,7 +432,7 @@ static int32_t mndCreateStream(SMnode *pMnode, SRpcMsg *pReq, SCMCreateStreamReq
}
mDebug
(
"trans:%d, used to create stream:%s"
,
pTrans
->
id
,
pCreate
->
name
);
if
(
mndAddStreamToTrans
(
pMnode
,
&
streamObj
,
pCreate
->
ast
,
p
Create
->
triggerType
,
pCreate
->
watermark
,
p
Trans
)
!=
0
)
{
if
(
mndAddStreamToTrans
(
pMnode
,
&
streamObj
,
pCreate
->
ast
,
pTrans
)
!=
0
)
{
mError
(
"trans:%d, failed to add stream since %s"
,
pTrans
->
id
,
terrstr
());
mndTransDrop
(
pTrans
);
return
-
1
;
...
...
@@ -436,19 +459,18 @@ static int32_t mndProcessCreateStreamReq(SRpcMsg *pReq) {
int32_t
code
=
-
1
;
SStreamObj
*
pStream
=
NULL
;
SDbObj
*
pDb
=
NULL
;
SUserObj
*
pUser
=
NULL
;
SCMCreateStreamReq
createStreamReq
=
{
0
};
if
(
tDeserializeSCMCreateStreamReq
(
pReq
->
pCont
,
pReq
->
contLen
,
&
createStreamReq
)
!=
0
)
{
terrno
=
TSDB_CODE_INVALID_MSG
;
goto
CREATE_STREAM
_OVER
;
goto
_OVER
;
}
mDebug
(
"stream:%s, start to create, sql:%s"
,
createStreamReq
.
name
,
createStreamReq
.
sql
);
if
(
mndCheckCreateStreamReq
(
&
createStreamReq
)
!=
0
)
{
mError
(
"stream:%s, failed to create since %s"
,
createStreamReq
.
name
,
terrstr
());
goto
CREATE_STREAM
_OVER
;
goto
_OVER
;
}
pStream
=
mndAcquireStream
(
pMnode
,
createStreamReq
.
name
);
...
...
@@ -456,46 +478,82 @@ static int32_t mndProcessCreateStreamReq(SRpcMsg *pReq) {
if
(
createStreamReq
.
igExists
)
{
mDebug
(
"stream:%s, already exist, ignore exist is set"
,
createStreamReq
.
name
);
code
=
0
;
goto
CREATE_STREAM
_OVER
;
goto
_OVER
;
}
else
{
terrno
=
TSDB_CODE_MND_STREAM_ALREADY_EXIST
;
goto
CREATE_STREAM
_OVER
;
goto
_OVER
;
}
}
else
if
(
terrno
!=
TSDB_CODE_MND_STREAM_NOT_EXIST
)
{
goto
CREATE_STREAM
_OVER
;
goto
_OVER
;
}
// TODO check auth
pDb
=
mndAcquireDb
(
pMnode
,
createStreamReq
.
sourceDB
);
if
(
pDb
==
NULL
)
{
terrno
=
TSDB_CODE_MND_DB_NOT_SELECTED
;
goto
CREATE_STREAM_OVER
;
}
pUser
=
mndAcquireUser
(
pMnode
,
pReq
->
conn
.
user
);
if
(
pUser
==
NULL
)
{
goto
CREATE_STREAM_OVER
;
goto
_OVER
;
}
if
(
mndCheck
WriteAuth
(
pUser
,
pDb
)
!=
0
)
{
goto
CREATE_STREAM
_OVER
;
if
(
mndCheck
DbAuth
(
pMnode
,
pReq
->
conn
.
user
,
MND_OPER_WRITE_DB
,
pDb
)
!=
0
)
{
goto
_OVER
;
}
code
=
mndCreateStream
(
pMnode
,
pReq
,
&
createStreamReq
,
pDb
);
if
(
code
==
0
)
code
=
TSDB_CODE_ACTION_IN_PROGRESS
;
CREATE_STREAM
_OVER:
_OVER:
if
(
code
!=
0
&&
code
!=
TSDB_CODE_ACTION_IN_PROGRESS
)
{
mError
(
"stream:%s, failed to create since %s"
,
createStreamReq
.
name
,
terrstr
());
}
mndReleaseStream
(
pMnode
,
pStream
);
mndReleaseDb
(
pMnode
,
pDb
);
mndReleaseUser
(
pMnode
,
pUser
);
tFreeSCMCreateStreamReq
(
&
createStreamReq
);
return
code
;
}
static
int32_t
mndProcessDropStreamReq
(
SRpcMsg
*
pReq
)
{
SMnode
*
pMnode
=
pReq
->
info
.
node
;
int32_t
code
=
-
1
;
SStreamObj
*
pStream
=
NULL
;
/*SDbObj *pDb = NULL;*/
/*SUserObj *pUser = NULL;*/
SMDropStreamTaskReq
dropStreamReq
=
*
(
SMDropStreamTaskReq
*
)
pReq
->
pCont
;
pStream
=
mndAcquireStream
(
pMnode
,
dropStreamReq
.
name
);
if
(
pStream
==
NULL
)
{
terrno
=
TSDB_CODE_MND_STREAM_NOT_EXIST
;
return
-
1
;
}
#if 0
// todo check auth
pUser = mndAcquireUser(pMnode, pReq->conn.user);
if (pUser == NULL) {
goto DROP_STREAM_OVER;
}
#endif
STrans
*
pTrans
=
mndTransCreate
(
pMnode
,
TRN_POLICY_RETRY
,
TRN_CONFLICT_NOTHING
,
pReq
);
if
(
pTrans
==
NULL
)
{
mError
(
"stream:%s, failed to drop since %s"
,
dropStreamReq
.
name
,
terrstr
());
return
-
1
;
}
mDebug
(
"trans:%d, used to drop stream:%s"
,
pTrans
->
id
,
dropStreamReq
.
name
);
// drop all tasks
if
(
mndDropStreamTasks
(
pMnode
,
pTrans
,
pStream
)
<
0
)
{
mError
(
"stream:%s, failed to drop task since %s"
,
dropStreamReq
.
name
,
terrstr
());
return
-
1
;
}
DROP_STREAM_OVER:
return
0
;
}
static
int32_t
mndGetNumOfStreams
(
SMnode
*
pMnode
,
char
*
dbName
,
int32_t
*
pNumOfStreams
)
{
SSdb
*
pSdb
=
pMnode
->
pSdb
;
SDbObj
*
pDb
=
mndAcquireDb
(
pMnode
,
dbName
);
...
...
@@ -566,7 +624,7 @@ static int32_t mndRetrieveStream(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pB
colDataAppend
(
pColInfo
,
numOfRows
,
(
const
char
*
)
&
pStream
->
targetSTbName
,
true
);
pColInfo
=
taosArrayGet
(
pBlock
->
pDataBlock
,
cols
++
);
colDataAppend
(
pColInfo
,
numOfRows
,
(
const
char
*
)
&
pStream
->
water
M
ark
,
false
);
colDataAppend
(
pColInfo
,
numOfRows
,
(
const
char
*
)
&
pStream
->
water
m
ark
,
false
);
pColInfo
=
taosArrayGet
(
pBlock
->
pDataBlock
,
cols
++
);
colDataAppend
(
pColInfo
,
numOfRows
,
(
const
char
*
)
&
pStream
->
trigger
,
false
);
...
...
source/dnode/mnode/impl/src/mndSync.c
浏览文件 @
e52429e3
...
...
@@ -234,9 +234,9 @@ int32_t mndSyncPropose(SMnode *pMnode, SSdbRaw *pRaw, int32_t transId) {
int32_t
code
=
syncPropose
(
pMgmt
->
sync
,
&
rsp
,
isWeak
);
if
(
code
==
0
)
{
tsem_wait
(
&
pMgmt
->
syncSem
);
}
else
if
(
code
==
TAOS_SYNC_PROPOSE
_NOT_LEADER
)
{
}
else
if
(
code
==
-
1
&&
terrno
==
TSDB_CODE_SYN
_NOT_LEADER
)
{
terrno
=
TSDB_CODE_APP_NOT_READY
;
}
else
if
(
code
==
TAOS_SYNC_OTHER
_ERROR
)
{
}
else
if
(
code
==
-
1
&&
terrno
==
TSDB_CODE_SYN_INTERNAL
_ERROR
)
{
terrno
=
TSDB_CODE_SYN_INTERNAL_ERROR
;
}
else
{
terrno
=
TSDB_CODE_APP_ERROR
;
...
...
@@ -257,13 +257,13 @@ void mndSyncStart(SMnode *pMnode) {
syncStart
(
pMgmt
->
sync
);
mDebug
(
"mnode sync started, id:%"
PRId64
" standby:%d"
,
pMgmt
->
sync
,
pMgmt
->
standby
);
/*
if (pMgmt->standby) {
syncStartStandBy(pMgmt->sync);
} else {
syncStart(pMgmt->sync);
}
*/
/*
if (pMgmt->standby) {
syncStartStandBy(pMgmt->sync);
} else {
syncStart(pMgmt->sync);
}
*/
}
void
mndSyncStop
(
SMnode
*
pMnode
)
{}
...
...
source/dnode/mnode/impl/src/mndTopic.c
浏览文件 @
e52429e3
...
...
@@ -387,7 +387,7 @@ static int32_t mndCreateTopic(SMnode *pMnode, SRpcMsg *pReq, SCMCreateTopicReq *
return
-
1
;
}
if
(
nodesNodeToString
((
SNode
*
)
pPlan
,
false
,
&
topicObj
.
physicalPlan
,
NULL
)
!=
0
)
{
if
(
nodesNodeToString
((
SNode
*
)
pPlan
,
false
,
&
topicObj
.
physicalPlan
,
NULL
)
!=
0
)
{
mError
(
"topic:%s, failed to create since %s"
,
pCreate
->
name
,
terrstr
());
taosMemoryFree
(
topicObj
.
ast
);
taosMemoryFree
(
topicObj
.
sql
);
...
...
@@ -440,19 +440,18 @@ static int32_t mndProcessCreateTopicReq(SRpcMsg *pReq) {
int32_t
code
=
-
1
;
SMqTopicObj
*
pTopic
=
NULL
;
SDbObj
*
pDb
=
NULL
;
SUserObj
*
pUser
=
NULL
;
SCMCreateTopicReq
createTopicReq
=
{
0
};
if
(
tDeserializeSCMCreateTopicReq
(
pReq
->
pCont
,
pReq
->
contLen
,
&
createTopicReq
)
!=
0
)
{
terrno
=
TSDB_CODE_INVALID_MSG
;
goto
CREATE_TOPIC
_OVER
;
goto
_OVER
;
}
mDebug
(
"topic:%s, start to create, sql:%s"
,
createTopicReq
.
name
,
createTopicReq
.
sql
);
if
(
mndCheckCreateTopicReq
(
&
createTopicReq
)
!=
0
)
{
mError
(
"topic:%s, failed to create since %s"
,
createTopicReq
.
name
,
terrstr
());
goto
CREATE_TOPIC
_OVER
;
goto
_OVER
;
}
pTopic
=
mndAcquireTopic
(
pMnode
,
createTopicReq
.
name
);
...
...
@@ -460,41 +459,35 @@ static int32_t mndProcessCreateTopicReq(SRpcMsg *pReq) {
if
(
createTopicReq
.
igExists
)
{
mDebug
(
"topic:%s, already exist, ignore exist is set"
,
createTopicReq
.
name
);
code
=
0
;
goto
CREATE_TOPIC
_OVER
;
goto
_OVER
;
}
else
{
terrno
=
TSDB_CODE_MND_TOPIC_ALREADY_EXIST
;
goto
CREATE_TOPIC
_OVER
;
goto
_OVER
;
}
}
else
if
(
terrno
!=
TSDB_CODE_MND_TOPIC_NOT_EXIST
)
{
goto
CREATE_TOPIC
_OVER
;
goto
_OVER
;
}
pDb
=
mndAcquireDb
(
pMnode
,
createTopicReq
.
subDbName
);
if
(
pDb
==
NULL
)
{
terrno
=
TSDB_CODE_MND_DB_NOT_SELECTED
;
goto
CREATE_TOPIC
_OVER
;
goto
_OVER
;
}
pUser
=
mndAcquireUser
(
pMnode
,
pReq
->
conn
.
user
);
if
(
pUser
==
NULL
)
{
goto
CREATE_TOPIC_OVER
;
}
if
(
mndCheckWriteAuth
(
pUser
,
pDb
)
!=
0
)
{
goto
CREATE_TOPIC_OVER
;
if
(
mndCheckDbAuth
(
pMnode
,
pReq
->
conn
.
user
,
MND_OPER_WRITE_DB
,
pDb
)
!=
0
)
{
goto
_OVER
;
}
code
=
mndCreateTopic
(
pMnode
,
pReq
,
&
createTopicReq
,
pDb
);
if
(
code
==
0
)
code
=
TSDB_CODE_ACTION_IN_PROGRESS
;
CREATE_TOPIC
_OVER:
_OVER:
if
(
code
!=
0
&&
code
!=
TSDB_CODE_ACTION_IN_PROGRESS
)
{
mError
(
"topic:%s, failed to create since %s"
,
createTopicReq
.
name
,
terrstr
());
}
mndReleaseTopic
(
pMnode
,
pTopic
);
mndReleaseDb
(
pMnode
,
pDb
);
mndReleaseUser
(
pMnode
,
pUser
);
tFreeSCMCreateTopicReq
(
&
createTopicReq
);
return
code
;
...
...
source/dnode/mnode/impl/src/mndTrans.c
浏览文件 @
e52429e3
...
...
@@ -1362,7 +1362,6 @@ static int32_t mndProcessKillTransReq(SRpcMsg *pReq) {
SMnode
*
pMnode
=
pReq
->
info
.
node
;
SKillTransReq
killReq
=
{
0
};
int32_t
code
=
-
1
;
SUserObj
*
pUser
=
NULL
;
STrans
*
pTrans
=
NULL
;
if
(
tDeserializeSKillTransReq
(
pReq
->
pCont
,
pReq
->
contLen
,
&
killReq
)
!=
0
)
{
...
...
@@ -1372,12 +1371,7 @@ static int32_t mndProcessKillTransReq(SRpcMsg *pReq) {
mInfo
(
"trans:%d, start to kill"
,
killReq
.
transId
);
pUser
=
mndAcquireUser
(
pMnode
,
pReq
->
conn
.
user
);
if
(
pUser
==
NULL
)
{
goto
_OVER
;
}
if
(
mndCheckTransAuth
(
pUser
)
!=
0
)
{
if
(
mndCheckOperAuth
(
pMnode
,
pReq
->
conn
.
user
,
MND_OPER_KILL_TRANS
)
!=
0
)
{
goto
_OVER
;
}
...
...
@@ -1393,7 +1387,6 @@ _OVER:
mError
(
"trans:%d, failed to kill since %s"
,
killReq
.
transId
,
terrstr
());
}
mndReleaseUser
(
pMnode
,
pUser
);
mndReleaseTrans
(
pMnode
,
pTrans
);
return
code
;
}
...
...
source/dnode/mnode/impl/src/mndUser.c
浏览文件 @
e52429e3
...
...
@@ -68,6 +68,8 @@ static int32_t mndCreateDefaultUser(SMnode *pMnode, char *acct, char *user, char
tstrncpy
(
userObj
.
acct
,
acct
,
TSDB_USER_LEN
);
userObj
.
createdTime
=
taosGetTimestampMs
();
userObj
.
updateTime
=
userObj
.
createdTime
;
userObj
.
sysInfo
=
1
;
userObj
.
enable
=
1
;
if
(
strcmp
(
user
,
TSDB_DEFAULT_USER
)
==
0
)
{
userObj
.
superUser
=
1
;
...
...
@@ -128,6 +130,9 @@ SSdbRaw *mndUserActionEncode(SUserObj *pUser) {
SDB_SET_INT64
(
pRaw
,
dataPos
,
pUser
->
createdTime
,
_OVER
)
SDB_SET_INT64
(
pRaw
,
dataPos
,
pUser
->
updateTime
,
_OVER
)
SDB_SET_INT8
(
pRaw
,
dataPos
,
pUser
->
superUser
,
_OVER
)
SDB_SET_INT8
(
pRaw
,
dataPos
,
pUser
->
sysInfo
,
_OVER
)
SDB_SET_INT8
(
pRaw
,
dataPos
,
pUser
->
enable
,
_OVER
)
SDB_SET_INT8
(
pRaw
,
dataPos
,
pUser
->
reserve
,
_OVER
)
SDB_SET_INT32
(
pRaw
,
dataPos
,
pUser
->
authVersion
,
_OVER
)
SDB_SET_INT32
(
pRaw
,
dataPos
,
numOfReadDbs
,
_OVER
)
SDB_SET_INT32
(
pRaw
,
dataPos
,
numOfWriteDbs
,
_OVER
)
...
...
@@ -184,6 +189,9 @@ static SSdbRow *mndUserActionDecode(SSdbRaw *pRaw) {
SDB_GET_INT64
(
pRaw
,
dataPos
,
&
pUser
->
createdTime
,
_OVER
)
SDB_GET_INT64
(
pRaw
,
dataPos
,
&
pUser
->
updateTime
,
_OVER
)
SDB_GET_INT8
(
pRaw
,
dataPos
,
&
pUser
->
superUser
,
_OVER
)
SDB_GET_INT8
(
pRaw
,
dataPos
,
&
pUser
->
sysInfo
,
_OVER
)
SDB_GET_INT8
(
pRaw
,
dataPos
,
&
pUser
->
enable
,
_OVER
)
SDB_GET_INT8
(
pRaw
,
dataPos
,
&
pUser
->
reserve
,
_OVER
)
SDB_GET_INT32
(
pRaw
,
dataPos
,
&
pUser
->
authVersion
,
_OVER
)
int32_t
numOfReadDbs
=
0
;
...
...
@@ -256,6 +264,8 @@ static int32_t mndUserActionUpdate(SSdb *pSdb, SUserObj *pOld, SUserObj *pNew) {
taosWLockLatch
(
&
pOld
->
lock
);
pOld
->
updateTime
=
pNew
->
updateTime
;
pOld
->
authVersion
=
pNew
->
authVersion
;
pOld
->
sysInfo
=
pNew
->
sysInfo
;
pOld
->
enable
=
pNew
->
enable
;
memcpy
(
pOld
->
pass
,
pNew
->
pass
,
TSDB_PASSWORD_LEN
);
TSWAP
(
pOld
->
readDbs
,
pNew
->
readDbs
);
TSWAP
(
pOld
->
writeDbs
,
pNew
->
writeDbs
);
...
...
@@ -286,6 +296,8 @@ static int32_t mndCreateUser(SMnode *pMnode, char *acct, SCreateUserReq *pCreate
userObj
.
createdTime
=
taosGetTimestampMs
();
userObj
.
updateTime
=
userObj
.
createdTime
;
userObj
.
superUser
=
pCreate
->
superUser
;
userObj
.
sysInfo
=
pCreate
->
sysInfo
;
userObj
.
enable
=
pCreate
->
enable
;
STrans
*
pTrans
=
mndTransCreate
(
pMnode
,
TRN_POLICY_ROLLBACK
,
TRN_CONFLICT_NOTHING
,
pReq
);
if
(
pTrans
==
NULL
)
{
...
...
@@ -348,7 +360,7 @@ static int32_t mndProcessCreateUserReq(SRpcMsg *pReq) {
goto
_OVER
;
}
if
(
mndCheck
CreateUserAuth
(
pOperUser
)
!=
0
)
{
if
(
mndCheck
OperAuth
(
pMnode
,
pReq
->
conn
.
user
,
MND_OPER_CREATE_USER
)
!=
0
)
{
goto
_OVER
;
}
...
...
@@ -481,6 +493,14 @@ static int32_t mndProcessAlterUserReq(SRpcMsg *pReq) {
newUser
.
superUser
=
alterReq
.
superUser
;
}
if
(
alterReq
.
alterType
==
TSDB_ALTER_USER_ENABLE
)
{
newUser
.
enable
=
alterReq
.
enable
;
}
if
(
alterReq
.
alterType
==
TSDB_ALTER_USER_SYSINFO
)
{
newUser
.
sysInfo
=
alterReq
.
sysInfo
;
}
if
(
alterReq
.
alterType
==
TSDB_ALTER_USER_ADD_READ_DB
||
alterReq
.
alterType
==
TSDB_ALTER_USER_ADD_ALL_DB
)
{
if
(
strcmp
(
alterReq
.
dbname
,
"1.*"
)
!=
0
)
{
int32_t
len
=
strlen
(
alterReq
.
dbname
)
+
1
;
...
...
@@ -603,7 +623,6 @@ static int32_t mndProcessDropUserReq(SRpcMsg *pReq) {
SMnode
*
pMnode
=
pReq
->
info
.
node
;
int32_t
code
=
-
1
;
SUserObj
*
pUser
=
NULL
;
SUserObj
*
pOperUser
=
NULL
;
SDropUserReq
dropReq
=
{
0
};
if
(
tDeserializeSDropUserReq
(
pReq
->
pCont
,
pReq
->
contLen
,
&
dropReq
)
!=
0
)
{
...
...
@@ -624,13 +643,7 @@ static int32_t mndProcessDropUserReq(SRpcMsg *pReq) {
goto
_OVER
;
}
pOperUser
=
mndAcquireUser
(
pMnode
,
pReq
->
conn
.
user
);
if
(
pOperUser
==
NULL
)
{
terrno
=
TSDB_CODE_MND_NO_USER_FROM_CONN
;
goto
_OVER
;
}
if
(
mndCheckDropUserAuth
(
pOperUser
)
!=
0
)
{
if
(
mndCheckOperAuth
(
pMnode
,
pReq
->
conn
.
user
,
MND_OPER_DROP_USER
)
!=
0
)
{
goto
_OVER
;
}
...
...
@@ -642,9 +655,7 @@ _OVER:
mError
(
"user:%s, failed to drop since %s"
,
dropReq
.
user
,
terrstr
());
}
mndReleaseUser
(
pMnode
,
pOperUser
);
mndReleaseUser
(
pMnode
,
pUser
);
return
code
;
}
...
...
@@ -740,19 +751,21 @@ static int32_t mndRetrieveUsers(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pBl
cols
=
0
;
SColumnInfoData
*
pColInfo
=
taosArrayGet
(
pBlock
->
pDataBlock
,
cols
);
char
name
[
TSDB_USER_LEN
+
VARSTR_HEADER_SIZE
]
=
{
0
};
char
name
[
TSDB_USER_LEN
+
VARSTR_HEADER_SIZE
]
=
{
0
};
STR_WITH_MAXSIZE_TO_VARSTR
(
name
,
pUser
->
user
,
pShow
->
pMeta
->
pSchemas
[
cols
].
bytes
);
colDataAppend
(
pColInfo
,
numOfRows
,
(
const
char
*
)
name
,
false
);
cols
++
;
pColInfo
=
taosArrayGet
(
pBlock
->
pDataBlock
,
cols
);
colDataAppend
(
pColInfo
,
numOfRows
,
(
const
char
*
)
&
pUser
->
superUser
,
false
);
const
char
*
src
=
pUser
->
superUser
?
"super"
:
"normal"
;
char
b
[
10
+
VARSTR_HEADER_SIZE
]
=
{
0
};
STR_WITH_SIZE_TO_VARSTR
(
b
,
src
,
strlen
(
src
));
colDataAppend
(
pColInfo
,
numOfRows
,
(
const
char
*
)
b
,
false
);
cols
++
;
pColInfo
=
taosArrayGet
(
pBlock
->
pDataBlock
,
cols
);
colDataAppend
(
pColInfo
,
numOfRows
,
(
const
char
*
)
&
pUser
->
enable
,
false
);
cols
++
;
pColInfo
=
taosArrayGet
(
pBlock
->
pDataBlock
,
cols
);
colDataAppend
(
pColInfo
,
numOfRows
,
(
const
char
*
)
&
pUser
->
sysInfo
,
false
);
cols
++
;
pColInfo
=
taosArrayGet
(
pBlock
->
pDataBlock
,
cols
);
...
...
source/dnode/mnode/impl/src/mndVgroup.c
浏览文件 @
e52429e3
...
...
@@ -1177,7 +1177,6 @@ _OVER:
static
int32_t
mndProcessRedistributeVgroupMsg
(
SRpcMsg
*
pReq
)
{
SMnode
*
pMnode
=
pReq
->
info
.
node
;
SUserObj
*
pUser
=
NULL
;
SDnodeObj
*
pNew1
=
NULL
;
SDnodeObj
*
pNew2
=
NULL
;
SDnodeObj
*
pNew3
=
NULL
;
...
...
@@ -1200,13 +1199,8 @@ static int32_t mndProcessRedistributeVgroupMsg(SRpcMsg *pReq) {
}
mInfo
(
"vgId:%d, start to redistribute to dnode %d:%d:%d"
,
req
.
vgId
,
req
.
dnodeId1
,
req
.
dnodeId2
,
req
.
dnodeId3
);
pUser
=
mndAcquireUser
(
pMnode
,
pReq
->
conn
.
user
);
if
(
pUser
==
NULL
)
{
terrno
=
TSDB_CODE_MND_NO_USER_FROM_CONN
;
goto
_OVER
;
}
if
(
mndCheck
NodeAuth
(
pUser
)
!=
0
)
goto
_OVER
;
if
(
mndCheck
OperAuth
(
pMnode
,
pReq
->
conn
.
user
,
MND_OPER_REDISTRIBUTE_VGROUP
)
!=
0
)
goto
_OVER
;
pVgroup
=
mndAcquireVgroup
(
pMnode
,
req
.
vgId
);
if
(
pVgroup
==
NULL
)
goto
_OVER
;
...
...
@@ -1368,7 +1362,6 @@ _OVER:
mndReleaseDnode
(
pMnode
,
pOld1
);
mndReleaseDnode
(
pMnode
,
pOld2
);
mndReleaseDnode
(
pMnode
,
pOld3
);
mndReleaseUser
(
pMnode
,
pUser
);
mndReleaseVgroup
(
pMnode
,
pVgroup
);
mndReleaseDb
(
pMnode
,
pDb
);
...
...
@@ -1493,12 +1486,11 @@ _OVER:
}
static
int32_t
mndProcessSplitVgroupMsg
(
SRpcMsg
*
pReq
)
{
SMnode
*
pMnode
=
pReq
->
info
.
node
;
int32_t
code
=
-
1
;
int32_t
vgId
=
2
;
SUserObj
*
pUser
=
NULL
;
SVgObj
*
pVgroup
=
NULL
;
SDbObj
*
pDb
=
NULL
;
SMnode
*
pMnode
=
pReq
->
info
.
node
;
int32_t
code
=
-
1
;
int32_t
vgId
=
2
;
SVgObj
*
pVgroup
=
NULL
;
SDbObj
*
pDb
=
NULL
;
mDebug
(
"vgId:%d, start to split"
,
vgId
);
...
...
@@ -1508,19 +1500,12 @@ static int32_t mndProcessSplitVgroupMsg(SRpcMsg *pReq) {
pDb
=
mndAcquireDb
(
pMnode
,
pVgroup
->
dbName
);
if
(
pDb
==
NULL
)
goto
_OVER
;
pUser
=
mndAcquireUser
(
pMnode
,
pReq
->
conn
.
user
);
if
(
pUser
==
NULL
)
{
terrno
=
TSDB_CODE_MND_NO_USER_FROM_CONN
;
goto
_OVER
;
}
if
(
mndCheckNodeAuth
(
pUser
)
!=
0
)
goto
_OVER
;
if
(
mndCheckOperAuth
(
pMnode
,
pReq
->
conn
.
user
,
MND_OPER_SPLIT_VGROUP
)
!=
0
)
goto
_OVER
;
code
=
mndSplitVgroup
(
pMnode
,
pReq
,
pDb
,
pVgroup
);
if
(
code
==
0
)
code
=
TSDB_CODE_ACTION_IN_PROGRESS
;
_OVER:
mndReleaseUser
(
pMnode
,
pUser
);
mndReleaseVgroup
(
pMnode
,
pVgroup
);
mndReleaseDb
(
pMnode
,
pDb
);
return
code
;
...
...
@@ -1631,21 +1616,15 @@ _OVER:
}
static
int32_t
mndProcessBalanceVgroupMsg
(
SRpcMsg
*
pReq
)
{
SMnode
*
pMnode
=
pReq
->
info
.
node
;
int32_t
code
=
-
1
;
SUserObj
*
pUser
=
NULL
;
SArray
*
pArray
=
NULL
;
void
*
pIter
=
NULL
;
int64_t
curMs
=
taosGetTimestampMs
();
SMnode
*
pMnode
=
pReq
->
info
.
node
;
int32_t
code
=
-
1
;
SArray
*
pArray
=
NULL
;
void
*
pIter
=
NULL
;
int64_t
curMs
=
taosGetTimestampMs
();
mDebug
(
"start to balance vgroup"
);
pUser
=
mndAcquireUser
(
pMnode
,
pReq
->
conn
.
user
);
if
(
pUser
==
NULL
)
{
terrno
=
TSDB_CODE_MND_NO_USER_FROM_CONN
;
goto
_OVER
;
}
if
(
mndCheck
NodeAuth
(
pUser
)
!=
0
)
goto
_OVER
;
if
(
mndCheck
OperAuth
(
pMnode
,
pReq
->
conn
.
user
,
MND_OPER_BALANCE_VGROUP
)
!=
0
)
goto
_OVER
;
while
(
1
)
{
SDnodeObj
*
pDnode
=
NULL
;
...
...
@@ -1676,7 +1655,6 @@ _OVER:
mError
(
"failed to balance vgroup since %s"
,
terrstr
());
}
mndReleaseUser
(
pMnode
,
pUser
);
taosArrayDestroy
(
pArray
);
return
code
;
}
\ No newline at end of file
source/dnode/mnode/impl/test/profile/profile.cpp
浏览文件 @
e52429e3
...
...
@@ -88,7 +88,7 @@ TEST_F(MndTestProfile, 02_ConnectMsg_InvalidDB) {
TEST_F
(
MndTestProfile
,
03
_ConnectMsg_Show
)
{
test
.
SendShowReq
(
TSDB_MGMT_TABLE_CONNS
,
"connections"
,
""
);
EXPECT_EQ
(
test
.
GetShowRows
(),
0
);
EXPECT_EQ
(
test
.
GetShowRows
(),
1
);
}
TEST_F
(
MndTestProfile
,
04
_HeartBeatMsg
)
{
...
...
source/dnode/vnode/src/inc/vnodeInt.h
浏览文件 @
e52429e3
...
...
@@ -140,6 +140,7 @@ int32_t tqProcessVgDeleteReq(STQ* pTq, char* msg, int32_t msgLen);
int32_t
tqProcessOffsetCommitReq
(
STQ
*
pTq
,
char
*
msg
,
int32_t
msgLen
);
int32_t
tqProcessPollReq
(
STQ
*
pTq
,
SRpcMsg
*
pMsg
,
int32_t
workerId
);
int32_t
tqProcessTaskDeploy
(
STQ
*
pTq
,
char
*
msg
,
int32_t
msgLen
);
int32_t
tqProcessTaskDropReq
(
STQ
*
pTq
,
char
*
msg
,
int32_t
msgLen
);
int32_t
tqProcessStreamTrigger
(
STQ
*
pTq
,
SSubmitReq
*
data
);
int32_t
tqProcessTaskRunReq
(
STQ
*
pTq
,
SRpcMsg
*
pMsg
);
int32_t
tqProcessTaskDispatchReq
(
STQ
*
pTq
,
SRpcMsg
*
pMsg
);
...
...
source/dnode/vnode/src/tq/tq.c
浏览文件 @
e52429e3
...
...
@@ -375,6 +375,8 @@ int32_t tqProcessTaskDeploy(STQ* pTq, char* msg, int32_t msgLen) {
if
(
pTask
->
inputQueue
==
NULL
||
pTask
->
outputQueue
==
NULL
)
goto
FAIL
;
pTask
->
pMsgCb
=
&
pTq
->
pVnode
->
msgCb
;
// exec
if
(
pTask
->
execType
!=
TASK_EXEC__NONE
)
{
// expand runners
...
...
@@ -406,9 +408,12 @@ int32_t tqProcessTaskDeploy(STQ* pTq, char* msg, int32_t msgLen) {
tdGetSTSChemaFromSSChema
(
&
pTask
->
tbSink
.
pSchemaWrapper
->
pSchema
,
pTask
->
tbSink
.
pSchemaWrapper
->
nCols
);
ASSERT
(
pTask
->
tbSink
.
pTSchema
);
}
streamSetupTrigger
(
pTask
);
tqInfo
(
"deploy stream task id %d child id %d on vg %d"
,
pTask
->
taskId
,
pTask
->
childId
,
pTq
->
pVnode
->
config
.
vgId
);
taosHashPut
(
pTq
->
pStreamTasks
,
&
pTask
->
taskId
,
sizeof
(
int32_t
),
pTask
,
sizeof
(
SStreamTask
));
taosHashPut
(
pTq
->
pStreamTasks
,
&
pTask
->
taskId
,
sizeof
(
int32_t
),
&
pTask
,
sizeof
(
void
*
));
return
0
;
FAIL:
...
...
@@ -431,7 +436,7 @@ int32_t tqProcessStreamTrigger(STQ* pTq, SSubmitReq* pReq) {
while
(
1
)
{
pIter
=
taosHashIterate
(
pTq
->
pStreamTasks
,
pIter
);
if
(
pIter
==
NULL
)
break
;
SStreamTask
*
pTask
=
(
SStreamTask
*
)
pIter
;
SStreamTask
*
pTask
=
*
(
SStreamTask
*
*
)
pIter
;
if
(
pTask
->
inputType
!=
STREAM_INPUT__DATA_SUBMIT
)
continue
;
if
(
!
failed
)
{
...
...
@@ -439,7 +444,7 @@ int32_t tqProcessStreamTrigger(STQ* pTq, SSubmitReq* pReq) {
continue
;
}
if
(
stream
Trigger
ByWrite
(
pTask
,
pTq
->
pVnode
->
config
.
vgId
,
&
pTq
->
pVnode
->
msgCb
)
<
0
)
{
if
(
stream
Launch
ByWrite
(
pTask
,
pTq
->
pVnode
->
config
.
vgId
,
&
pTq
->
pVnode
->
msgCb
)
<
0
)
{
continue
;
}
}
else
{
...
...
@@ -459,7 +464,7 @@ int32_t tqProcessTaskRunReq(STQ* pTq, SRpcMsg* pMsg) {
//
SStreamTaskRunReq
*
pReq
=
pMsg
->
pCont
;
int32_t
taskId
=
pReq
->
taskId
;
SStreamTask
*
pTask
=
taosHashGet
(
pTq
->
pStreamTasks
,
&
taskId
,
sizeof
(
int32_t
));
SStreamTask
*
pTask
=
*
(
SStreamTask
**
)
taosHashGet
(
pTq
->
pStreamTasks
,
&
taskId
,
sizeof
(
int32_t
));
streamTaskProcessRunReq
(
pTask
,
&
pTq
->
pVnode
->
msgCb
);
return
0
;
}
...
...
@@ -473,7 +478,7 @@ int32_t tqProcessTaskDispatchReq(STQ* pTq, SRpcMsg* pMsg) {
tDecoderInit
(
&
decoder
,
msgBody
,
msgLen
);
tDecodeStreamDispatchReq
(
&
decoder
,
&
req
);
int32_t
taskId
=
req
.
taskId
;
SStreamTask
*
pTask
=
taosHashGet
(
pTq
->
pStreamTasks
,
&
taskId
,
sizeof
(
int32_t
));
SStreamTask
*
pTask
=
*
(
SStreamTask
**
)
taosHashGet
(
pTq
->
pStreamTasks
,
&
taskId
,
sizeof
(
int32_t
));
SRpcMsg
rsp
=
{
.
info
=
pMsg
->
info
,
.
code
=
0
,
...
...
@@ -485,7 +490,7 @@ int32_t tqProcessTaskDispatchReq(STQ* pTq, SRpcMsg* pMsg) {
int32_t
tqProcessTaskRecoverReq
(
STQ
*
pTq
,
SRpcMsg
*
pMsg
)
{
SStreamTaskRecoverReq
*
pReq
=
pMsg
->
pCont
;
int32_t
taskId
=
pReq
->
taskId
;
SStreamTask
*
pTask
=
taosHashGet
(
pTq
->
pStreamTasks
,
&
taskId
,
sizeof
(
int32_t
));
SStreamTask
*
pTask
=
*
(
SStreamTask
**
)
taosHashGet
(
pTq
->
pStreamTasks
,
&
taskId
,
sizeof
(
int32_t
));
streamProcessRecoverReq
(
pTask
,
&
pTq
->
pVnode
->
msgCb
,
pReq
,
pMsg
);
return
0
;
}
...
...
@@ -493,7 +498,7 @@ int32_t tqProcessTaskRecoverReq(STQ* pTq, SRpcMsg* pMsg) {
int32_t
tqProcessTaskDispatchRsp
(
STQ
*
pTq
,
SRpcMsg
*
pMsg
)
{
SStreamDispatchRsp
*
pRsp
=
POINTER_SHIFT
(
pMsg
->
pCont
,
sizeof
(
SMsgHead
));
int32_t
taskId
=
pRsp
->
taskId
;
SStreamTask
*
pTask
=
taosHashGet
(
pTq
->
pStreamTasks
,
&
taskId
,
sizeof
(
int32_t
));
SStreamTask
*
pTask
=
*
(
SStreamTask
**
)
taosHashGet
(
pTq
->
pStreamTasks
,
&
taskId
,
sizeof
(
int32_t
));
streamProcessDispatchRsp
(
pTask
,
&
pTq
->
pVnode
->
msgCb
,
pRsp
);
return
0
;
}
...
...
@@ -501,7 +506,17 @@ int32_t tqProcessTaskDispatchRsp(STQ* pTq, SRpcMsg* pMsg) {
int32_t
tqProcessTaskRecoverRsp
(
STQ
*
pTq
,
SRpcMsg
*
pMsg
)
{
SStreamTaskRecoverRsp
*
pRsp
=
pMsg
->
pCont
;
int32_t
taskId
=
pRsp
->
taskId
;
SStreamTask
*
pTask
=
taosHashGet
(
pTq
->
pStreamTasks
,
&
taskId
,
sizeof
(
int32_t
));
SStreamTask
*
pTask
=
*
(
SStreamTask
**
)
taosHashGet
(
pTq
->
pStreamTasks
,
&
taskId
,
sizeof
(
int32_t
));
streamProcessRecoverRsp
(
pTask
,
pRsp
);
return
0
;
}
int32_t
tqProcessTaskDropReq
(
STQ
*
pTq
,
char
*
msg
,
int32_t
msgLen
)
{
SVDropStreamTaskReq
*
pReq
=
(
SVDropStreamTaskReq
*
)
msg
;
int32_t
code
=
taosHashRemove
(
pTq
->
pStreamTasks
,
&
pReq
->
taskId
,
sizeof
(
int32_t
));
if
(
code
==
0
)
{
// sendrsp
}
ASSERT
(
code
==
0
);
return
code
;
}
source/dnode/vnode/src/vnd/vnodeSvr.c
浏览文件 @
e52429e3
...
...
@@ -168,6 +168,11 @@ int32_t vnodeProcessWriteReq(SVnode *pVnode, SRpcMsg *pMsg, int64_t version, SRp
goto
_err
;
}
}
break
;
case
TDMT_VND_STREAM_TASK_DROP
:
{
if
(
tqProcessTaskDropReq
(
pVnode
->
pTq
,
pMsg
->
pCont
,
pMsg
->
contLen
)
<
0
)
{
goto
_err
;
}
}
break
;
case
TDMT_VND_ALTER_CONFIRM
:
vnodeProcessAlterConfirmReq
(
pVnode
,
version
,
pReq
,
len
,
pRsp
);
break
;
...
...
@@ -296,7 +301,7 @@ void vnodeUpdateMetaRsp(SVnode *pVnode, STableMetaRsp *pMetaRsp) {
}
int32_t
vnodeProcessSyncReq
(
SVnode
*
pVnode
,
SRpcMsg
*
pMsg
,
SRpcMsg
**
pRsp
)
{
int32_t
ret
=
TAOS_SYNC_OTHER_ERROR
;
int32_t
ret
=
0
;
if
(
syncEnvIsStart
())
{
SSyncNode
*
pSyncNode
=
syncNodeAcquire
(
pVnode
->
sync
);
...
...
@@ -375,21 +380,25 @@ int32_t vnodeProcessSyncReq(SVnode *pVnode, SRpcMsg *pMsg, SRpcMsg **pRsp) {
ret
=
syncNodeOnAppendEntriesReplyCb
(
pSyncNode
,
pSyncMsg
);
syncAppendEntriesReplyDestroy
(
pSyncMsg
);
}
else
if
(
pRpcMsg
->
msgType
==
TDMT_SYNC_SET_
M
NODE_STANDBY
)
{
}
else
if
(
pRpcMsg
->
msgType
==
TDMT_SYNC_SET_
V
NODE_STANDBY
)
{
ret
=
syncSetStandby
(
pVnode
->
sync
);
vInfo
(
"vgId:%d, set standby result:0x%x rid:%"
PRId64
,
pVnode
->
config
.
vgId
,
ret
,
pVnode
->
sync
);
SRpcMsg
rsp
=
{.
code
=
ret
,
.
info
=
pMsg
->
info
};
tmsgSendRsp
(
&
rsp
);
}
else
{
vError
(
"==vnodeProcessSyncReq== error msg type:%d"
,
pRpcMsg
->
msgType
);
ret
=
TAOS_SYNC_OTHER_ERROR
;
ret
=
-
1
;
}
syncNodeRelease
(
pSyncNode
);
}
else
{
vError
(
"==vnodeProcessSyncReq== error syncEnv stop"
);
ret
=
TAOS_SYNC_OTHER_ERROR
;
ret
=
-
1
;
}
if
(
ret
!=
0
)
{
terrno
=
TSDB_CODE_SYN_INTERNAL_ERROR
;
}
return
ret
;
}
...
...
source/dnode/vnode/src/vnd/vnodeSync.c
浏览文件 @
e52429e3
...
...
@@ -98,7 +98,8 @@ void vnodeProposeMsg(SQueueInfo *pInfo, STaosQall *qall, int32_t numOfMsgs) {
if
(
code
==
0
)
{
vnodeAccumBlockMsg
(
pVnode
,
pMsg
->
msgType
);
}
else
if
(
code
==
TAOS_SYNC_PROPOSE_NOT_LEADER
)
{
}
else
if
(
code
==
-
1
&&
terrno
==
TSDB_CODE_SYN_NOT_LEADER
)
{
SEpSet
newEpSet
=
{
0
};
syncGetEpSet
(
pVnode
->
sync
,
&
newEpSet
);
SEp
*
pEp
=
&
newEpSet
.
eps
[
newEpSet
.
inUse
];
...
...
@@ -247,29 +248,17 @@ static void vnodeSyncRollBackMsg(SSyncFSM *pFsm, const SRpcMsg *pMsg, SFsmCbMeta
syncRpcMsgLog2
(
logBuf
,
(
SRpcMsg
*
)
pMsg
);
}
int32_t
vnodeSnapshotStartRead
(
struct
SSyncFSM
*
pFsm
,
void
**
ppReader
)
{
return
0
;
}
int32_t
vnodeSnapshotStartRead
(
struct
SSyncFSM
*
pFsm
,
void
**
ppReader
)
{
return
0
;
}
int32_t
vnodeSnapshotStopRead
(
struct
SSyncFSM
*
pFsm
,
void
*
pReader
)
{
return
0
;
}
int32_t
vnodeSnapshotStopRead
(
struct
SSyncFSM
*
pFsm
,
void
*
pReader
)
{
return
0
;
}
int32_t
vnodeSnapshotDoRead
(
struct
SSyncFSM
*
pFsm
,
void
*
pReader
,
void
**
ppBuf
,
int32_t
*
len
)
{
return
0
;
}
int32_t
vnodeSnapshotDoRead
(
struct
SSyncFSM
*
pFsm
,
void
*
pReader
,
void
**
ppBuf
,
int32_t
*
len
)
{
return
0
;
}
int32_t
vnodeSnapshotStartWrite
(
struct
SSyncFSM
*
pFsm
,
void
**
ppWriter
)
{
return
0
;
}
int32_t
vnodeSnapshotStartWrite
(
struct
SSyncFSM
*
pFsm
,
void
**
ppWriter
)
{
return
0
;
}
int32_t
vnodeSnapshotStopWrite
(
struct
SSyncFSM
*
pFsm
,
void
*
pWriter
,
bool
isApply
)
{
return
0
;
}
int32_t
vnodeSnapshotStopWrite
(
struct
SSyncFSM
*
pFsm
,
void
*
pWriter
,
bool
isApply
)
{
return
0
;
}
int32_t
vnodeSnapshotDoWrite
(
struct
SSyncFSM
*
pFsm
,
void
*
pWriter
,
void
*
pBuf
,
int32_t
len
)
{
return
0
;
}
int32_t
vnodeSnapshotDoWrite
(
struct
SSyncFSM
*
pFsm
,
void
*
pWriter
,
void
*
pBuf
,
int32_t
len
)
{
return
0
;
}
static
SSyncFSM
*
vnodeSyncMakeFsm
(
SVnode
*
pVnode
)
{
SSyncFSM
*
pFsm
=
taosMemoryCalloc
(
1
,
sizeof
(
SSyncFSM
));
...
...
source/libs/catalog/src/ctgCache.c
浏览文件 @
e52429e3
...
...
@@ -1899,7 +1899,7 @@ _return:
void
ctgUpdateThreadUnexpectedStopped
(
void
)
{
if
(
CTG_IS_LOCKED
(
&
gCtgMgmt
.
lock
)
>
0
)
CTG_UNLOCK
(
CTG_READ
,
&
gCtgMgmt
.
lock
);
if
(
!
atomic_load_8
((
int8_t
*
)
&
gCtgMgmt
.
exit
)
&&
CTG_IS_LOCKED
(
&
gCtgMgmt
.
lock
)
>
0
)
CTG_UNLOCK
(
CTG_READ
,
&
gCtgMgmt
.
lock
);
}
void
ctgCleanupCacheQueue
(
void
)
{
...
...
source/libs/executor/inc/executil.h
浏览文件 @
e52429e3
...
...
@@ -44,7 +44,6 @@
typedef
struct
SGroupResInfo
{
int32_t
index
;
SArray
*
pRows
;
// SArray<SResKeyPos>
int32_t
position
;
}
SGroupResInfo
;
typedef
struct
SResultRow
{
...
...
@@ -56,7 +55,7 @@ typedef struct SResultRow {
uint32_t
numOfRows
;
// number of rows of current time window
STimeWindow
win
;
struct
SResultRowEntryInfo
pEntryInfo
[];
// For each result column, there is a resultInfo
// char *key;
// start key of current result row
// char *key; // start key of current result row
}
SResultRow
;
typedef
struct
SResultRowPosition
{
...
...
@@ -71,9 +70,7 @@ typedef struct SResKeyPos {
}
SResKeyPos
;
typedef
struct
SResultRowInfo
{
SResultRowPosition
*
pPosition
;
// todo remove this
int32_t
size
;
// number of result set
int32_t
capacity
;
// max capacity
SResultRowPosition
cur
;
SList
*
openWindow
;
}
SResultRowInfo
;
...
...
source/libs/executor/inc/executorInt.h
浏览文件 @
e52429e3
...
...
@@ -20,6 +20,8 @@
extern
"C"
{
#endif
extern
int32_t
exchangeObjRefPool
;
typedef
struct
{
char
*
pData
;
bool
isNull
;
...
...
source/libs/executor/inc/executorimpl.h
浏览文件 @
e52429e3
...
...
@@ -181,7 +181,6 @@ typedef struct SExecTaskInfo {
STaskCostInfo
cost
;
int64_t
owner
;
// if it is in execution
int32_t
code
;
// uint64_t totalRows; // total number of rows
struct
{
char
*
tablename
;
char
*
dbname
;
...
...
@@ -222,10 +221,10 @@ typedef struct STaskRuntimeEnv {
}
STaskRuntimeEnv
;
enum
{
OP_NOT_OPENED
=
0x0
,
OP_OPENED
=
0x1
,
OP_NOT_OPENED
=
0x0
,
OP_OPENED
=
0x1
,
OP_RES_TO_RETURN
=
0x5
,
OP_EXEC_DONE
=
0x9
,
OP_EXEC_DONE
=
0x9
,
};
typedef
struct
SOperatorFpSet
{
...
...
@@ -262,12 +261,12 @@ typedef enum {
}
EX_SOURCE_STATUS
;
typedef
struct
SSourceDataInfo
{
struct
SExchangeInfo
*
pEx
;
int32_t
index
;
SRetrieveTableRsp
*
pRsp
;
uint64_t
totalRows
;
int32_t
code
;
EX_SOURCE_STATUS
status
;
const
char
*
taskId
;
}
SSourceDataInfo
;
typedef
struct
SLoadRemoteDataInfo
{
...
...
@@ -285,6 +284,7 @@ typedef struct SExchangeInfo {
bool
seqLoadData
;
// sequential load data or not, false by default
int32_t
current
;
SLoadRemoteDataInfo
loadInfo
;
uint64_t
self
;
}
SExchangeInfo
;
#define COL_MATCH_FROM_COL_ID 0x1
...
...
@@ -365,7 +365,9 @@ typedef struct SCatchSupporter {
}
SCatchSupporter
;
typedef
struct
SStreamAggSupporter
{
SArray
*
pResultRows
;
SHashObj
*
pResultRows
;
SArray
*
pCurWins
;
int32_t
valueSize
;
int32_t
keySize
;
char
*
pKeyBuf
;
// window key buffer
SDiskbasedBuf
*
pResultBuf
;
// query result buffer based on blocked-wised disk file
...
...
@@ -468,10 +470,8 @@ typedef struct SIntervalAggOperatorInfo {
bool
timeWindowInterpo
;
// interpolation needed or not
char
**
pRow
;
// previous row/tuple of already processed datablock
SArray
*
pInterpCols
;
// interpolation columns
STableQueryInfo
*
pCurrent
;
// current tableQueryInfo struct
int32_t
order
;
// current SSDataBlock scan order
EOPTR_EXEC_MODEL
execModel
;
// operator execution model [batch model|stream model]
SArray
*
pUpdatedWindow
;
// updated time window due to the input data block from the downstream operator.
STimeWindowAggSupp
twAggSup
;
bool
invertible
;
SArray
*
pPrevValues
;
// SArray<SGroupKeys> used to keep the previous not null value for interpolation.
...
...
@@ -500,8 +500,6 @@ typedef struct SAggOperatorInfo {
STableQueryInfo
*
current
;
uint64_t
groupId
;
SGroupResInfo
groupResInfo
;
STableQueryInfo
*
pTableQueryInfo
;
SExprInfo
*
pScalarExprInfo
;
int32_t
numOfScalarExpr
;
// the number of scalar expression before the aggregate function can be applied
SqlFunctionCtx
*
pScalarCtx
;
// scalar function requried sql function struct.
...
...
@@ -637,8 +635,13 @@ typedef struct SStreamSessionAggOperatorInfo {
typedef
struct
STimeSliceOperatorInfo
{
SOptrBasicInfo
binfo
;
STimeWindow
win
;
SInterval
interval
;
SGroupResInfo
groupResInfo
;
// multiple results build supporter
int64_t
current
;
SArray
*
pPrevRow
;
// SArray<SGroupValue>
SArray
*
pCols
;
// SArray<SColumn>
int32_t
fillType
;
// fill type
struct
SFillColInfo
*
pFillColInfo
;
// fill column info
}
STimeSliceOperatorInfo
;
typedef
struct
SStateWindowOperatorInfo
{
...
...
@@ -731,6 +734,8 @@ typedef struct SJoinOperatorInfo {
#define OPTR_IS_OPENED(_optr) (((_optr)->status & OP_OPENED) == OP_OPENED)
#define OPTR_SET_OPENED(_optr) ((_optr)->status |= OP_OPENED)
void
doDestroyExchangeOperatorInfo
(
void
*
param
);
SOperatorFpSet
createOperatorFpSet
(
__optr_open_fn_t
openFn
,
__optr_fn_t
nextFn
,
__optr_fn_t
streamFn
,
__optr_fn_t
cleanup
,
__optr_close_fn_t
closeFn
,
__optr_encode_fn_t
encode
,
__optr_decode_fn_t
decode
,
__optr_explain_fn_t
explain
);
...
...
@@ -838,7 +843,7 @@ SOperatorInfo* createPartitionOperatorInfo(SOperatorInfo* downstream, SExprInfo*
SSDataBlock
*
pResultBlock
,
SArray
*
pGroupColList
,
SExecTaskInfo
*
pTaskInfo
);
SOperatorInfo
*
createTimeSliceOperatorInfo
(
SOperatorInfo
*
downstream
,
SExprInfo
*
pExprInfo
,
int32_t
numOfCols
,
SSDataBlock
*
pResultBlock
,
SExecTaskInfo
*
pTaskInfo
);
SSDataBlock
*
pResultBlock
,
const
SNodeListNode
*
pValNode
,
SExecTaskInfo
*
pTaskInfo
);
SOperatorInfo
*
createMergeJoinOperatorInfo
(
SOperatorInfo
**
pDownstream
,
int32_t
numOfDownstream
,
SExprInfo
*
pExprInfo
,
int32_t
numOfCols
,
SSDataBlock
*
pResBlock
,
SNode
*
pOnCondition
,
SExecTaskInfo
*
pTaskInfo
);
...
...
@@ -899,9 +904,9 @@ int32_t getNumOfRowsInTimeWindow(SDataBlockInfo* pDataBlockInfo, TSKEY* pPrimary
__block_search_fn_t
searchFn
,
STableQueryInfo
*
item
,
int32_t
order
);
int32_t
binarySearchForKey
(
char
*
pValue
,
int
num
,
TSKEY
key
,
int
order
);
int32_t
initStreamAggSupporter
(
SStreamAggSupporter
*
pSup
,
const
char
*
pKey
,
SqlFunctionCtx
*
pCtx
,
int32_t
numOfOutput
,
size
_t
size
);
SqlFunctionCtx
*
pCtx
,
int32_t
numOfOutput
,
int32
_t
size
);
SResultRow
*
getNewResultRow
(
SDiskbasedBuf
*
pResultBuf
,
int64_t
tableGroupId
,
int32_t
interBufSize
);
SResultWindowInfo
*
getSessionTimeWindow
(
S
Array
*
pWinInfos
,
TSKEY
ts
,
int64_t
gap
,
int32_t
*
pIndex
);
SResultWindowInfo
*
getSessionTimeWindow
(
S
StreamAggSupporter
*
pAggSup
,
TSKEY
ts
,
uint64_t
groupId
,
int64_t
gap
,
int32_t
*
pIndex
);
int32_t
updateSessionWindowInfo
(
SResultWindowInfo
*
pWinInfo
,
TSKEY
*
pTs
,
int32_t
rows
,
int32_t
start
,
int64_t
gap
,
SHashObj
*
pStDeleted
);
bool
functionNeedToExecute
(
SqlFunctionCtx
*
pCtx
);
...
...
@@ -910,6 +915,15 @@ int32_t compareTimeWindow(const void* p1, const void* p2, const void* param);
int32_t
finalizeResultRowIntoResultDataBlock
(
SDiskbasedBuf
*
pBuf
,
SResultRowPosition
*
resultRowPosition
,
SqlFunctionCtx
*
pCtx
,
SExprInfo
*
pExprInfo
,
int32_t
numOfExprs
,
const
int32_t
*
rowCellOffset
,
SSDataBlock
*
pBlock
,
SExecTaskInfo
*
pTaskInfo
);
int32_t
getTableList
(
void
*
metaHandle
,
int32_t
tableType
,
uint64_t
tableUid
,
STableListInfo
*
pListInfo
,
SNode
*
pTagCond
);
int32_t
createMultipleDataReaders
(
STableScanPhysiNode
*
pTableScanNode
,
SReadHandle
*
pHandle
,
STableListInfo
*
pTableListInfo
,
SArray
*
arrayReader
,
uint64_t
queryId
,
uint64_t
taskId
,
SNode
*
pTagCond
);
SOperatorInfo
*
createTableMergeScanOperatorInfo
(
STableScanPhysiNode
*
pTableScanNode
,
SArray
*
dataReaders
,
SReadHandle
*
readHandle
,
SExecTaskInfo
*
pTaskInfo
);
void
copyUpdateDataBlock
(
SSDataBlock
*
pDest
,
SSDataBlock
*
pSource
,
int32_t
tsColIndex
);
#ifdef __cplusplus
...
...
source/libs/executor/inc/tfill.h
浏览文件 @
e52429e3
...
...
@@ -28,8 +28,6 @@ struct SSDataBlock;
typedef
struct
SFillColInfo
{
SExprInfo
*
pExpr
;
// SResSchema schema;
// int16_t functionId; // sql function id
int16_t
flag
;
// column flag: TAG COLUMN|NORMAL COLUMN
int16_t
tagIndex
;
// index of current tag in SFillTagColInfo array list
SVariant
fillVal
;
...
...
source/libs/executor/src/executil.c
浏览文件 @
e52429e3
...
...
@@ -41,13 +41,7 @@ int32_t getOutputInterResultBufSize(STaskAttr* pQueryAttr) {
int32_t
initResultRowInfo
(
SResultRowInfo
*
pResultRowInfo
,
int32_t
size
)
{
pResultRowInfo
->
size
=
0
;
pResultRowInfo
->
capacity
=
size
;
pResultRowInfo
->
cur
.
pageId
=
-
1
;
pResultRowInfo
->
pPosition
=
taosMemoryCalloc
(
pResultRowInfo
->
capacity
,
sizeof
(
SResultRowPosition
));
if
(
pResultRowInfo
->
pPosition
==
NULL
)
{
return
TSDB_CODE_QRY_OUT_OF_MEMORY
;
}
return
TSDB_CODE_SUCCESS
;
}
...
...
@@ -56,25 +50,14 @@ void cleanupResultRowInfo(SResultRowInfo *pResultRowInfo) {
return
;
}
if
(
pResultRowInfo
->
capacity
==
0
)
{
// assert(pResultRowInfo->pResult == NULL);
return
;
}
for
(
int32_t
i
=
0
;
i
<
pResultRowInfo
->
size
;
++
i
)
{
// if (pResultRowInfo->pResult[i]) {
// taosMemoryFreeClear(pResultRowInfo->pResult[i]->key);
// }
}
taosMemoryFreeClear
(
pResultRowInfo
->
pPosition
);
}
void
resetResultRowInfo
(
STaskRuntimeEnv
*
pRuntimeEnv
,
SResultRowInfo
*
pResultRowInfo
)
{
if
(
pResultRowInfo
==
NULL
||
pResultRowInfo
->
capacity
==
0
)
{
return
;
}
for
(
int32_t
i
=
0
;
i
<
pResultRowInfo
->
size
;
++
i
)
{
// SResultRow *pWindowRes = pResultRowInfo->pResult[i];
// clearResultRow(pRuntimeEnv, pWindowRes);
...
...
@@ -288,232 +271,3 @@ void orderTheResultRows(STaskRuntimeEnv* pRuntimeEnv) {
taosArraySort
(
pRuntimeEnv
->
pResultRowArrayList
,
fn
);
}
static
int32_t
mergeIntoGroupResultImplRv
(
STaskRuntimeEnv
*
pRuntimeEnv
,
SGroupResInfo
*
pGroupResInfo
,
uint64_t
groupId
,
int32_t
*
rowCellInfoOffset
)
{
if
(
pGroupResInfo
->
pRows
==
NULL
)
{
pGroupResInfo
->
pRows
=
taosArrayInit
(
100
,
POINTER_BYTES
);
}
size_t
len
=
taosArrayGetSize
(
pRuntimeEnv
->
pResultRowArrayList
);
for
(;
pGroupResInfo
->
position
<
len
;
++
pGroupResInfo
->
position
)
{
SResultRowCell
*
pResultRowCell
=
taosArrayGet
(
pRuntimeEnv
->
pResultRowArrayList
,
pGroupResInfo
->
position
);
if
(
pResultRowCell
->
groupId
!=
groupId
)
{
break
;
}
int64_t
num
=
0
;
//getNumOfResultWindowRes(pRuntimeEnv, &pResultRowCell->pos, rowCellInfoOffset);
if
(
num
<=
0
)
{
continue
;
}
taosArrayPush
(
pGroupResInfo
->
pRows
,
&
pResultRowCell
->
pos
);
// pResultRowCell->pRow->numOfRows = (uint32_t) num;
}
return
TSDB_CODE_SUCCESS
;
}
static
UNUSED_FUNC
int32_t
mergeIntoGroupResultImpl
(
STaskRuntimeEnv
*
pRuntimeEnv
,
SGroupResInfo
*
pGroupResInfo
,
SArray
*
pTableList
,
int32_t
*
rowCellInfoOffset
)
{
bool
ascQuery
=
true
;
#if 0
int32_t code = TSDB_CODE_SUCCESS;
int32_t *posList = NULL;
SMultiwayMergeTreeInfo *pTree = NULL;
STableQueryInfo **pTableQueryInfoList = NULL;
size_t size = taosArrayGetSize(pTableList);
if (pGroupResInfo->pRows == NULL) {
pGroupResInfo->pRows = taosArrayInit(100, POINTER_BYTES);
}
posList = taosMemoryCalloc(size, sizeof(int32_t));
pTableQueryInfoList = taosMemoryMalloc(POINTER_BYTES * size);
if (pTableQueryInfoList == NULL || posList == NULL || pGroupResInfo->pRows == NULL || pGroupResInfo->pRows == NULL) {
// qError("QInfo:%"PRIu64" failed alloc memory", GET_TASKID(pRuntimeEnv));
code = TSDB_CODE_QRY_OUT_OF_MEMORY;
goto _end;
}
int32_t numOfTables = 0;
for (int32_t i = 0; i < size; ++i) {
STableQueryInfo *item = taosArrayGetP(pTableList, i);
// if (item->resInfo.size > 0) {
// pTableQueryInfoList[numOfTables++] = item;
// }
}
// there is no data in current group
// no need to merge results since only one table in each group
// if (numOfTables == 0) {
// goto _end;
// }
int32_t order = TSDB_ORDER_ASC;
SCompSupporter cs = {pTableQueryInfoList, posList, order};
int32_t ret = tMergeTreeCreate(&pTree, numOfTables, &cs, tableResultComparFn);
if (ret != TSDB_CODE_SUCCESS) {
code = TSDB_CODE_QRY_OUT_OF_MEMORY;
goto _end;
}
int64_t lastTimestamp = ascQuery? INT64_MIN:INT64_MAX;
int64_t startt = taosGetTimestampMs();
while (1) {
int32_t tableIndex = tMergeTreeGetChosenIndex(pTree);
SResultRowInfo *pWindowResInfo = &pTableQueryInfoList[tableIndex]->resInfo;
ASSERT(0);
SResultRow *pWindowRes = NULL;//getResultRow(pBuf, pWindowResInfo, cs.rowIndex[tableIndex]);
int64_t num = 0;//getNumOfResultWindowRes(pRuntimeEnv, pWindowRes, rowCellInfoOffset);
if (num <= 0) {
cs.rowIndex[tableIndex] += 1;
if (cs.rowIndex[tableIndex] >= pWindowResInfo->size) {
cs.rowIndex[tableIndex] = -1;
if (--numOfTables == 0) { // all input sources are exhausted
break;
}
}
} else {
assert((pWindowRes->win.skey >= lastTimestamp && ascQuery) || (pWindowRes->win.skey <= lastTimestamp && !ascQuery));
if (pWindowRes->win.skey != lastTimestamp) {
taosArrayPush(pGroupResInfo->pRows, &pWindowRes);
pWindowRes->numOfRows = (uint32_t) num;
}
lastTimestamp = pWindowRes->win.skey;
// move to the next row of current entry
if ((++cs.rowIndex[tableIndex]) >= pWindowResInfo->size) {
cs.rowIndex[tableIndex] = -1;
// all input sources are exhausted
if ((--numOfTables) == 0) {
break;
}
}
}
tMergeTreeAdjust(pTree, tMergeTreeGetAdjustIndex(pTree));
}
int64_t endt = taosGetTimestampMs();
// qDebug("QInfo:%"PRIx64" result merge completed for group:%d, elapsed time:%" PRId64 " ms", GET_TASKID(pRuntimeEnv),
// pGroupResInfo->currentGroup, endt - startt);
_end:
taosMemoryFreeClear(pTableQueryInfoList);
taosMemoryFreeClear(posList);
taosMemoryFreeClear(pTree);
return code;
}
int32_t mergeIntoGroupResult(SGroupResInfo* pGroupResInfo, STaskRuntimeEnv* pRuntimeEnv, int32_t* offset) {
int64_t st = taosGetTimestampUs();
while (pGroupResInfo->currentGroup < pGroupResInfo->totalGroup) {
mergeIntoGroupResultImplRv(pRuntimeEnv, pGroupResInfo, pGroupResInfo->currentGroup, offset);
// this group generates at least one result, return results
if (taosArrayGetSize(pGroupResInfo->pRows) > 0) {
break;
}
// qDebug("QInfo:%"PRIu64" no result in group %d, continue", GET_TASKID(pRuntimeEnv), pGroupResInfo->currentGroup);
cleanupGroupResInfo(pGroupResInfo);
incNextGroup(pGroupResInfo);
}
// int64_t elapsedTime = taosGetTimestampUs() - st;
// qDebug("QInfo:%"PRIu64" merge res data into group, index:%d, total group:%d, elapsed time:%" PRId64 "us", GET_TASKID(pRuntimeEnv),
// pGroupResInfo->currentGroup, pGroupResInfo->totalGroup, elapsedTime);
#endif
return
TSDB_CODE_SUCCESS
;
}
//void blockDistInfoToBinary(STableBlockDist* pDist, struct SBufferWriter* bw) {
// tbufWriteUint32(bw, pDist->numOfTables);
// tbufWriteUint16(bw, pDist->numOfFiles);
// tbufWriteUint64(bw, pDist->totalSize);
// tbufWriteUint64(bw, pDist->totalRows);
// tbufWriteInt32(bw, pDist->maxRows);
// tbufWriteInt32(bw, pDist->minRows);
// tbufWriteUint32(bw, pDist->numOfInmemRows);
// tbufWriteUint32(bw, pDist->numOfSmallBlocks);
// tbufWriteUint64(bw, taosArrayGetSize(pDist->dataBlockInfos));
//
// // compress the binary string
// char* p = TARRAY_GET_START(pDist->dataBlockInfos);
//
// // compress extra bytes
// size_t x = taosArrayGetSize(pDist->dataBlockInfos) * pDist->dataBlockInfos->elemSize;
// char* tmp = taosMemoryMalloc(x + 2);
//
// bool comp = false;
// int32_t len = tsCompressString(p, (int32_t)x, 1, tmp, (int32_t)x, ONE_STAGE_COMP, NULL, 0);
// if (len == -1 || len >= x) { // compress failed, do not compress this binary data
// comp = false;
// len = (int32_t)x;
// } else {
// comp = true;
// }
//
// tbufWriteUint8(bw, comp);
// tbufWriteUint32(bw, len);
// if (comp) {
// tbufWriteBinary(bw, tmp, len);
// } else {
// tbufWriteBinary(bw, p, len);
// }
// taosMemoryFreeClear(tmp);
//}
//void blockDistInfoFromBinary(const char* data, int32_t len, STableBlockDist* pDist) {
// SBufferReader br = tbufInitReader(data, len, false);
//
// pDist->numOfTables = tbufReadUint32(&br);
// pDist->numOfFiles = tbufReadUint16(&br);
// pDist->totalSize = tbufReadUint64(&br);
// pDist->totalRows = tbufReadUint64(&br);
// pDist->maxRows = tbufReadInt32(&br);
// pDist->minRows = tbufReadInt32(&br);
// pDist->numOfInmemRows = tbufReadUint32(&br);
// pDist->numOfSmallBlocks = tbufReadUint32(&br);
// int64_t numSteps = tbufReadUint64(&br);
//
// bool comp = tbufReadUint8(&br);
// uint32_t compLen = tbufReadUint32(&br);
//
// size_t originalLen = (size_t) (numSteps *sizeof(SFileBlockInfo));
//
// char* outputBuf = NULL;
// if (comp) {
// outputBuf = taosMemoryMalloc(originalLen);
//
// size_t actualLen = compLen;
// const char* compStr = tbufReadBinary(&br, &actualLen);
//
// int32_t orignalLen = tsDecompressString(compStr, compLen, 1, outputBuf,
// (int32_t)originalLen , ONE_STAGE_COMP, NULL, 0);
// assert(orignalLen == numSteps *sizeof(SFileBlockInfo));
// } else {
// outputBuf = (char*) tbufReadBinary(&br, &originalLen);
// }
//
// pDist->dataBlockInfos = taosArrayFromList(outputBuf, (uint32_t)numSteps, sizeof(SFileBlockInfo));
// if (comp) {
// taosMemoryFreeClear(outputBuf);
// }
//}
source/libs/executor/src/executor.c
浏览文件 @
e52429e3
...
...
@@ -19,7 +19,8 @@
#include "tdatablock.h"
#include "vnode.h"
static
int32_t
doSetStreamBlock
(
SOperatorInfo
*
pOperator
,
void
*
input
,
size_t
numOfBlocks
,
int32_t
type
,
bool
assignUid
,
char
*
id
)
{
static
int32_t
doSetStreamBlock
(
SOperatorInfo
*
pOperator
,
void
*
input
,
size_t
numOfBlocks
,
int32_t
type
,
bool
assignUid
,
char
*
id
)
{
ASSERT
(
pOperator
!=
NULL
);
if
(
pOperator
->
operatorType
!=
QUERY_NODE_PHYSICAL_PLAN_STREAM_SCAN
)
{
if
(
pOperator
->
numOfDownstream
==
0
)
{
...
...
@@ -43,6 +44,7 @@ static int32_t doSetStreamBlock(SOperatorInfo* pOperator, void* input, size_t nu
if
(
pInfo
->
blockType
==
0
)
{
pInfo
->
blockType
=
type
;
}
else
if
(
pInfo
->
blockType
!=
type
)
{
ASSERT
(
0
);
return
TSDB_CODE_QRY_APP_ERROR
;
}
...
...
@@ -51,7 +53,7 @@ static int32_t doSetStreamBlock(SOperatorInfo* pOperator, void* input, size_t nu
qError
(
"submit msg messed up when initing stream block, %s"
PRIx64
,
id
);
return
TSDB_CODE_QRY_APP_ERROR
;
}
}
else
{
}
else
if
(
type
==
STREAM_DATA_TYPE_SSDATA_BLOCK
)
{
for
(
int32_t
i
=
0
;
i
<
numOfBlocks
;
++
i
)
{
SSDataBlock
*
pDataBlock
=
&
((
SSDataBlock
*
)
input
)[
i
];
...
...
@@ -62,6 +64,8 @@ static int32_t doSetStreamBlock(SOperatorInfo* pOperator, void* input, size_t nu
taosArrayAddAll
(
p
->
pDataBlock
,
pDataBlock
->
pDataBlock
);
taosArrayPush
(
pInfo
->
pBlockLists
,
&
p
);
}
}
else
{
ASSERT
(
0
);
}
return
TSDB_CODE_SUCCESS
;
...
...
@@ -83,7 +87,8 @@ int32_t qSetMultiStreamInput(qTaskInfo_t tinfo, const void* pBlocks, size_t numO
SExecTaskInfo
*
pTaskInfo
=
(
SExecTaskInfo
*
)
tinfo
;
int32_t
code
=
doSetStreamBlock
(
pTaskInfo
->
pRoot
,
(
void
**
)
pBlocks
,
numOfBlocks
,
type
,
assignUid
,
GET_TASKID
(
pTaskInfo
));
int32_t
code
=
doSetStreamBlock
(
pTaskInfo
->
pRoot
,
(
void
**
)
pBlocks
,
numOfBlocks
,
type
,
assignUid
,
GET_TASKID
(
pTaskInfo
));
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
qError
(
"%s failed to set the stream block data"
,
GET_TASKID
(
pTaskInfo
));
}
else
{
...
...
@@ -162,7 +167,7 @@ int32_t qUpdateQualifiedTableId(qTaskInfo_t tinfo, const SArray* tableIdList, bo
pInfo
=
pInfo
->
pDownstream
[
0
];
}
int32_t
code
=
0
;
int32_t
code
=
0
;
SStreamBlockScanInfo
*
pScanInfo
=
pInfo
->
info
;
if
(
isAdd
)
{
// add new table id
SArray
*
qa
=
filterQualifiedChildTables
(
pScanInfo
,
tableIdList
);
...
...
@@ -178,9 +183,10 @@ int32_t qUpdateQualifiedTableId(qTaskInfo_t tinfo, const SArray* tableIdList, bo
return
code
;
}
int32_t
qGetQueriedTableSchemaVersion
(
qTaskInfo_t
tinfo
,
char
*
dbName
,
char
*
tableName
,
int32_t
*
sversion
,
int32_t
*
tversion
)
{
int32_t
qGetQueriedTableSchemaVersion
(
qTaskInfo_t
tinfo
,
char
*
dbName
,
char
*
tableName
,
int32_t
*
sversion
,
int32_t
*
tversion
)
{
ASSERT
(
tinfo
!=
NULL
&&
dbName
!=
NULL
&&
tableName
!=
NULL
);
SExecTaskInfo
*
pTaskInfo
=
(
SExecTaskInfo
*
)
tinfo
;
SExecTaskInfo
*
pTaskInfo
=
(
SExecTaskInfo
*
)
tinfo
;
*
sversion
=
pTaskInfo
->
schemaVer
.
sversion
;
*
tversion
=
pTaskInfo
->
schemaVer
.
tversion
;
...
...
@@ -196,4 +202,4 @@ int32_t qGetQueriedTableSchemaVersion(qTaskInfo_t tinfo, char* dbName, char* tab
}
return
0
;
}
\ No newline at end of file
}
source/libs/executor/src/executorMain.c
浏览文件 @
e52429e3
...
...
@@ -13,28 +13,30 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <vnode.h>
#include "dataSinkMgt.h"
#include "texception.h"
#include "os.h"
#include "tarray.h"
#include "tcache.h"
#include "tglobal.h"
#include "tref.h"
#include "dataSinkMgt.h"
#include "tmsg.h"
#include "tudf.h"
#include "executor.h"
#include "executorimpl.h"
#include "query.h"
#include "thash.h"
#include "tlosertree.h"
#include "ttypes.h"
static
TdThreadOnce
initPoolOnce
=
PTHREAD_ONCE_INIT
;
int32_t
exchangeObjRefPool
=
-
1
;
static
void
initRefPool
()
{
exchangeObjRefPool
=
taosOpenRef
(
1024
,
doDestroyExchangeOperatorInfo
);
}
int32_t
qCreateExecTask
(
SReadHandle
*
readHandle
,
int32_t
vgId
,
uint64_t
taskId
,
SSubplan
*
pSubplan
,
qTaskInfo_t
*
pTaskInfo
,
DataSinkHandle
*
handle
,
EOPTR_EXEC_MODEL
model
)
{
qTaskInfo_t
*
pTaskInfo
,
DataSinkHandle
*
handle
,
EOPTR_EXEC_MODEL
model
)
{
assert
(
readHandle
!=
NULL
&&
pSubplan
!=
NULL
);
SExecTaskInfo
**
pTask
=
(
SExecTaskInfo
**
)
pTaskInfo
;
taosThreadOnce
(
&
initPoolOnce
,
initRefPool
);
int32_t
code
=
createExecTaskInfoImpl
(
pSubplan
,
pTask
,
readHandle
,
taskId
,
model
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
goto
_error
;
...
...
source/libs/executor/src/executorimpl.c
浏览文件 @
e52429e3
...
...
@@ -20,6 +20,7 @@
#include "querynodes.h"
#include "tfill.h"
#include "tname.h"
#include "tref.h"
#include "tdatablock.h"
#include "tglobal.h"
...
...
@@ -37,9 +38,6 @@
#include "vnode.h"
#define IS_MAIN_SCAN(runtime) ((runtime)->scanFlag == MAIN_SCAN)
#define IS_REVERSE_SCAN(runtime) ((runtime)->scanFlag == REVERSE_SCAN)
#define IS_REPEAT_SCAN(runtime) ((runtime)->scanFlag == REPEAT_SCAN)
#define SET_MAIN_SCAN_FLAG(runtime) ((runtime)->scanFlag = MAIN_SCAN)
#define SET_REVERSE_SCAN_FLAG(runtime) ((runtime)->scanFlag = REVERSE_SCAN)
#define SDATA_BLOCK_INITIALIZER \
...
...
@@ -47,12 +45,6 @@
#define GET_FORWARD_DIRECTION_FACTOR(ord) (((ord) == TSDB_ORDER_ASC) ? QUERY_ASC_FORWARD_STEP : QUERY_DESC_FORWARD_STEP)
enum
{
TS_JOIN_TS_EQUAL
=
0
,
TS_JOIN_TS_NOT_EQUALS
=
1
,
TS_JOIN_TAG_NOT_EQUALS
=
2
,
};
#if 0
static UNUSED_FUNC void *u_malloc (size_t __size) {
uint32_t v = taosRand();
...
...
@@ -87,8 +79,7 @@ static UNUSED_FUNC void* u_realloc(void* p, size_t __size) {
#define realloc u_realloc
#endif
#define CLEAR_QUERY_STATUS(q, st) ((q)->status &= (~(st)))
//#define GET_NUM_OF_TABLEGROUP(q) taosArrayGetSize((q)->tableqinfoGroupInfo.pGroupList)
#define CLEAR_QUERY_STATUS(q, st) ((q)->status &= (~(st)))
#define QUERY_IS_INTERVAL_QUERY(_q) ((_q)->interval.interval > 0)
int32_t
getMaximumIdleDurationSec
()
{
return
tsShellActivityTimer
*
2
;
}
...
...
@@ -110,7 +101,6 @@ static void releaseQueryBuf(size_t numOfTables);
static
void
destroySFillOperatorInfo
(
void
*
param
,
int32_t
numOfOutput
);
static
void
destroyProjectOperatorInfo
(
void
*
param
,
int32_t
numOfOutput
);
static
void
destroyTagScanOperatorInfo
(
void
*
param
,
int32_t
numOfOutput
);
static
void
destroyOrderOperatorInfo
(
void
*
param
,
int32_t
numOfOutput
);
static
void
destroyAggOperatorInfo
(
void
*
param
,
int32_t
numOfOutput
);
...
...
@@ -118,7 +108,6 @@ static void destroyIntervalOperatorInfo(void* param, int32_t numOfOutput);
static
void
destroyExchangeOperatorInfo
(
void
*
param
,
int32_t
numOfOutput
);
static
void
destroyOperatorInfo
(
SOperatorInfo
*
pOperator
);
static
void
destroySysTableScannerOperatorInfo
(
void
*
param
,
int32_t
numOfOutput
);
void
doSetOperatorCompleted
(
SOperatorInfo
*
pOperator
)
{
pOperator
->
status
=
OP_EXEC_DONE
;
...
...
@@ -562,10 +551,6 @@ void doApplyFunctions(SExecTaskInfo* taskInfo, SqlFunctionCtx* pCtx, STimeWindow
pCtx
[
k
].
input
.
startRowIndex
=
offset
;
pCtx
[
k
].
input
.
numOfRows
=
forwardStep
;
if
(
tsCol
!=
NULL
)
{
pCtx
[
k
].
ptsList
=
tsCol
;
}
// not a whole block involved in query processing, statistics data can not be used
// NOTE: the original value of isSet have been changed here
if
(
pCtx
[
k
].
input
.
colDataAggIsSet
&&
forwardStep
<
numOfTotal
)
{
...
...
@@ -1133,40 +1118,6 @@ SqlFunctionCtx* createSqlFunctionCtx(SExprInfo* pExprInfo, int32_t numOfOutput,
pCtx
->
increase
=
false
;
pCtx
->
param
=
pFunct
->
pParam
;
// for (int32_t j = 0; j < pCtx->numOfParams; ++j) {
// // set the order information for top/bottom query
// int32_t functionId = pCtx->functionId;
// if (functionId == FUNCTION_TOP || functionId == FUNCTION_BOTTOM || functionId == FUNCTION_DIFF) {
// int32_t f = getExprFunctionId(&pExpr[0]);
// assert(f == FUNCTION_TS || f == FUNCTION_TS_DUMMY);
//
// // pCtx->param[2].i = pQueryAttr->order.order;
// // pCtx->param[2].nType = TSDB_DATA_TYPE_BIGINT;
// // pCtx->param[3].i = functionId;
// // pCtx->param[3].nType = TSDB_DATA_TYPE_BIGINT;
//
// // pCtx->param[1].i = pQueryAttr->order.col.info.colId;
// } else if (functionId == FUNCTION_INTERP) {
// // pCtx->param[2].i = (int8_t)pQueryAttr->fillType;
// // if (pQueryAttr->fillVal != NULL) {
// // if (isNull((const char *)&pQueryAttr->fillVal[i], pCtx->inputType)) {
// // pCtx->param[1].nType = TSDB_DATA_TYPE_NULL;
// // } else { // todo refactor, taosVariantCreateFromBinary should handle the NULL value
// // if (pCtx->inputType != TSDB_DATA_TYPE_BINARY && pCtx->inputType != TSDB_DATA_TYPE_NCHAR) {
// // taosVariantCreateFromBinary(&pCtx->param[1], (char *)&pQueryAttr->fillVal[i],
// pCtx->inputBytes, pCtx->inputType);
// // }
// // }
// // }
// } else if (functionId == FUNCTION_TWA) {
// // pCtx->param[1].i = pQueryAttr->window.skey;
// // pCtx->param[1].nType = TSDB_DATA_TYPE_BIGINT;
// // pCtx->param[2].i = pQueryAttr->window.ekey;
// // pCtx->param[2].nType = TSDB_DATA_TYPE_BIGINT;
// } else if (functionId == FUNCTION_ARITHM) {
// // pCtx->param[1].pz = (char*) getScalarFuncSupport(pRuntimeEnv->scalarSup, i);
// }
// }
}
for
(
int32_t
i
=
1
;
i
<
numOfOutput
;
++
i
)
{
...
...
@@ -2438,27 +2389,23 @@ static void doTableQueryInfoTimeWindowCheck(SExecTaskInfo* pTaskInfo, STableQuer
#endif
}
// static void updateTableIdInfo(STableQueryInfo* pTableQueryInfo, SSDataBlock* pBlock, SHashObj* pTableIdInfo, int32_t
// order) {
// int32_t step = GET_FORWARD_DIRECTION_FACTOR(order);
// pTableQueryInfo->lastKey = ((order == TSDB_ORDER_ASC)? pBlock->info.window.ekey:pBlock->info.window.skey) + step;
//
// if (pTableQueryInfo->pTable == NULL) {
// return;
// }
//
// STableIdInfo tidInfo = createTableIdInfo(pTableQueryInfo);
// STableIdInfo *idinfo = taosHashGet(pTableIdInfo, &tidInfo.tid, sizeof(tidInfo.tid));
// if (idinfo != NULL) {
// assert(idinfo->tid == tidInfo.tid && idinfo->uid == tidInfo.uid);
// idinfo->key = tidInfo.key;
// } else {
// taosHashPut(pTableIdInfo, &tidInfo.tid, sizeof(tidInfo.tid), &tidInfo, sizeof(STableIdInfo));
// }
// }
typedef
struct
SFetchRspHandleWrapper
{
uint32_t
exchangeId
;
int32_t
sourceIndex
;
}
SFetchRspHandleWrapper
;
int32_t
loadRemoteDataCallback
(
void
*
param
,
const
SDataBuf
*
pMsg
,
int32_t
code
)
{
SSourceDataInfo
*
pSourceDataInfo
=
(
SSourceDataInfo
*
)
param
;
SFetchRspHandleWrapper
*
pWrapper
=
(
SFetchRspHandleWrapper
*
)
param
;
SExchangeInfo
*
pExchangeInfo
=
taosAcquireRef
(
exchangeObjRefPool
,
pWrapper
->
exchangeId
);
if
(
pExchangeInfo
==
NULL
)
{
qWarn
(
"failed to acquire exchange operator, since it may have been released"
);
return
TSDB_CODE_SUCCESS
;
}
int32_t
index
=
pWrapper
->
sourceIndex
;
SSourceDataInfo
*
pSourceDataInfo
=
taosArrayGet
(
pExchangeInfo
->
pSourceDataInfo
,
index
);
if
(
code
==
TSDB_CODE_SUCCESS
)
{
pSourceDataInfo
->
pRsp
=
pMsg
->
pData
;
...
...
@@ -2468,14 +2415,18 @@ int32_t loadRemoteDataCallback(void* param, const SDataBuf* pMsg, int32_t code)
pRsp
->
numOfCols
=
htonl
(
pRsp
->
numOfCols
);
pRsp
->
useconds
=
htobe64
(
pRsp
->
useconds
);
ASSERT
(
p
SourceDataInfo
->
p
Rsp
!=
NULL
);
qDebug
(
"
fetch rsp received, index:%d, rows:%d"
,
pSourceDataInfo
->
index
,
pRsp
->
numOfRows
);
ASSERT
(
pRsp
!=
NULL
);
qDebug
(
"
%s fetch rsp received, index:%d, rows:%d"
,
pSourceDataInfo
->
taskId
,
index
,
pRsp
->
numOfRows
);
}
else
{
pSourceDataInfo
->
code
=
code
;
}
pSourceDataInfo
->
status
=
EX_SOURCE_DATA_READY
;
tsem_post
(
&
pSourceDataInfo
->
pEx
->
ready
);
tsem_post
(
&
pExchangeInfo
->
ready
);
taosReleaseRef
(
exchangeObjRefPool
,
pWrapper
->
exchangeId
);
taosMemoryFree
(
pWrapper
);
return
TSDB_CODE_SUCCESS
;
}
...
...
@@ -2537,7 +2488,11 @@ static int32_t doSendFetchDataRequest(SExchangeInfo* pExchangeInfo, SExecTaskInf
return
pTaskInfo
->
code
;
}
pMsgSendInfo
->
param
=
pDataInfo
;
SFetchRspHandleWrapper
*
pWrapper
=
taosMemoryCalloc
(
1
,
sizeof
(
SFetchRspHandleWrapper
));
pWrapper
->
exchangeId
=
pExchangeInfo
->
self
;
pWrapper
->
sourceIndex
=
sourceIndex
;
pMsgSendInfo
->
param
=
pWrapper
;
pMsgSendInfo
->
msgInfo
.
pData
=
pMsg
;
pMsgSendInfo
->
msgInfo
.
len
=
sizeof
(
SResFetchReq
);
pMsgSendInfo
->
msgType
=
TDMT_VND_FETCH
;
...
...
@@ -2689,10 +2644,10 @@ static SSDataBlock* concurrentlyLoadRemoteDataImpl(SOperatorInfo* pOperator, SEx
SSDataBlock
*
pRes
=
pExchangeInfo
->
pResult
;
SLoadRemoteDataInfo
*
pLoadInfo
=
&
pExchangeInfo
->
loadInfo
;
if
(
pRsp
->
numOfRows
==
0
)
{
qDebug
(
"%s vgId:%d, taskI
D
:0x%"
PRIx64
" index:%d completed, rowsOfSource:%"
PRIu64
", totalRows:%"
PRIu64
"
try next"
,
GET_TASKID
(
pTaskInfo
),
pSource
->
addr
.
nodeId
,
pSource
->
taskId
,
i
+
1
,
pDataInfo
->
totalRows
,
pExchangeInfo
->
loadInfo
.
totalRows
);
qDebug
(
"%s vgId:%d, taskI
d
:0x%"
PRIx64
" index:%d completed, rowsOfSource:%"
PRIu64
", totalRows:%"
PRIu64
"
, completed:%d try next %d/%"
PRIzu
,
GET_TASKID
(
pTaskInfo
),
pSource
->
addr
.
nodeId
,
pSource
->
taskId
,
i
,
pDataInfo
->
totalRows
,
pExchangeInfo
->
loadInfo
.
totalRows
,
completed
+
1
,
i
+
1
,
totalSources
);
pDataInfo
->
status
=
EX_SOURCE_DATA_EXHAUSTED
;
completed
+=
1
;
taosMemoryFreeClear
(
pDataInfo
->
pRsp
);
...
...
@@ -2708,10 +2663,12 @@ static SSDataBlock* concurrentlyLoadRemoteDataImpl(SOperatorInfo* pOperator, SEx
}
if
(
pRsp
->
completed
==
1
)
{
qDebug
(
"%s fetch msg rsp from vgId:%d, taskId:0x%"
PRIx64
" numOfRows:%d, rowsOfSource:%"
PRIu64
", totalRows:%"
PRIu64
", totalBytes:%"
PRIu64
" try next %d/%"
PRIzu
,
GET_TASKID
(
pTaskInfo
),
pSource
->
addr
.
nodeId
,
pSource
->
taskId
,
pRes
->
info
.
rows
,
pDataInfo
->
totalRows
,
pLoadInfo
->
totalRows
,
pLoadInfo
->
totalSize
,
i
+
1
,
totalSources
);
qDebug
(
"%s fetch msg rsp from vgId:%d, taskId:0x%"
PRIx64
" index:%d completed, numOfRows:%d, rowsOfSource:%"
PRIu64
", totalRows:%"
PRIu64
", totalBytes:%"
PRIu64
", completed:%d try next %d/%"
PRIzu
,
GET_TASKID
(
pTaskInfo
),
pSource
->
addr
.
nodeId
,
pSource
->
taskId
,
i
,
pRes
->
info
.
rows
,
pDataInfo
->
totalRows
,
pLoadInfo
->
totalRows
,
pLoadInfo
->
totalSize
,
completed
+
1
,
i
+
1
,
totalSources
);
completed
+=
1
;
pDataInfo
->
status
=
EX_SOURCE_DATA_EXHAUSTED
;
}
else
{
qDebug
(
"%s fetch msg rsp from vgId:%d, taskId:0x%"
PRIx64
" numOfRows:%d, totalRows:%"
PRIu64
...
...
@@ -2761,13 +2718,13 @@ static int32_t prepareConcurrentlyLoad(SOperatorInfo* pOperator) {
}
int64_t
endTs
=
taosGetTimestampUs
();
qDebug
(
"%s send all fetch requests to %"
PRIzu
" sources completed, elapsed:%
"
PRId64
,
GET_TASKID
(
pTaskInfo
),
totalSources
,
endTs
-
startTs
);
qDebug
(
"%s send all fetch requests to %"
PRIzu
" sources completed, elapsed:%
.2fms"
,
GET_TASKID
(
pTaskInfo
),
totalSources
,
(
endTs
-
startTs
)
/
1000
.
0
);
tsem_wait
(
&
pExchangeInfo
->
ready
);
pOperator
->
status
=
OP_RES_TO_RETURN
;
pOperator
->
cost
.
openCost
=
taosGetTimestampUs
()
-
startTs
;
tsem_wait
(
&
pExchangeInfo
->
ready
);
return
TSDB_CODE_SUCCESS
;
}
...
...
@@ -2883,7 +2840,7 @@ static SSDataBlock* doLoadRemoteData(SOperatorInfo* pOperator) {
}
}
static
int32_t
initDataSource
(
int32_t
numOfSources
,
SExchangeInfo
*
pInfo
)
{
static
int32_t
initDataSource
(
int32_t
numOfSources
,
SExchangeInfo
*
pInfo
,
const
char
*
id
)
{
pInfo
->
pSourceDataInfo
=
taosArrayInit
(
numOfSources
,
sizeof
(
SSourceDataInfo
));
if
(
pInfo
->
pSourceDataInfo
==
NULL
)
{
return
TSDB_CODE_OUT_OF_MEMORY
;
...
...
@@ -2892,11 +2849,10 @@ static int32_t initDataSource(int32_t numOfSources, SExchangeInfo* pInfo) {
for
(
int32_t
i
=
0
;
i
<
numOfSources
;
++
i
)
{
SSourceDataInfo
dataInfo
=
{
0
};
dataInfo
.
status
=
EX_SOURCE_DATA_NOT_READY
;
dataInfo
.
pEx
=
pInfo
;
dataInfo
.
taskId
=
id
;
dataInfo
.
index
=
i
;
void
*
ret
=
taosArrayPush
(
pInfo
->
pSourceDataInfo
,
&
dataInfo
);
if
(
ret
==
NULL
)
{
SSourceDataInfo
*
pDs
=
taosArrayPush
(
pInfo
->
pSourceDataInfo
,
&
dataInfo
);
if
(
pDs
==
NULL
)
{
taosArrayDestroy
(
pInfo
->
pSourceDataInfo
);
return
TSDB_CODE_OUT_OF_MEMORY
;
}
...
...
@@ -2924,7 +2880,9 @@ static int32_t initExchangeOperator(SExchangePhysiNode* pExNode, SExchangeInfo*
taosArrayPush
(
pInfo
->
pSources
,
pNode
);
}
return
initDataSource
(
numOfSources
,
pInfo
);
pInfo
->
self
=
taosAddRef
(
exchangeObjRefPool
,
pInfo
);
return
initDataSource
(
numOfSources
,
pInfo
,
id
);
}
SOperatorInfo
*
createExchangeOperatorInfo
(
void
*
pTransporter
,
SExchangePhysiNode
*
pExNode
,
SExecTaskInfo
*
pTaskInfo
)
{
...
...
@@ -2939,11 +2897,11 @@ SOperatorInfo* createExchangeOperatorInfo(void* pTransporter, SExchangePhysiNode
goto
_error
;
}
tsem_init
(
&
pInfo
->
ready
,
0
,
0
);
pInfo
->
seqLoadData
=
false
;
pInfo
->
pTransporter
=
pTransporter
;
pInfo
->
pResult
=
createResDataBlock
(
pExNode
->
node
.
pOutputDataBlockDesc
);
tsem_init
(
&
pInfo
->
ready
,
0
,
0
);
pOperator
->
name
=
"ExchangeOperator"
;
pOperator
->
operatorType
=
QUERY_NODE_PHYSICAL_PLAN_EXCHANGE
;
pOperator
->
blocking
=
false
;
...
...
@@ -2958,7 +2916,7 @@ SOperatorInfo* createExchangeOperatorInfo(void* pTransporter, SExchangePhysiNode
_error:
if
(
pInfo
!=
NULL
)
{
d
estroyExchangeOperatorInfo
(
pInfo
,
LIST_LENGTH
(
pExNode
->
pSrcEndPoints
)
);
d
oDestroyExchangeOperatorInfo
(
pInfo
);
}
taosMemoryFreeClear
(
pInfo
);
...
...
@@ -4105,6 +4063,12 @@ static void destroyIndefinitOperatorInfo(void* param, int32_t numOfOutput) {
void
destroyExchangeOperatorInfo
(
void
*
param
,
int32_t
numOfOutput
)
{
SExchangeInfo
*
pExInfo
=
(
SExchangeInfo
*
)
param
;
taosRemoveRef
(
exchangeObjRefPool
,
pExInfo
->
self
);
}
void
doDestroyExchangeOperatorInfo
(
void
*
param
)
{
SExchangeInfo
*
pExInfo
=
(
SExchangeInfo
*
)
param
;
taosArrayDestroy
(
pExInfo
->
pSources
);
taosArrayDestroy
(
pExInfo
->
pSourceDataInfo
);
if
(
pExInfo
->
pResult
!=
NULL
)
{
...
...
@@ -4322,6 +4286,8 @@ static int32_t initFillInfo(SFillOperatorInfo* pInfo, SExprInfo* pExpr, int32_t
pInfo
->
p
=
taosMemoryCalloc
(
numOfCols
,
POINTER_BYTES
);
if
(
pInfo
->
pFillInfo
==
NULL
||
pInfo
->
p
==
NULL
)
{
taosMemoryFree
(
pInfo
->
pFillInfo
);
taosMemoryFree
(
pInfo
->
p
);
return
TSDB_CODE_OUT_OF_MEMORY
;
}
else
{
return
TSDB_CODE_SUCCESS
;
...
...
@@ -4556,8 +4522,6 @@ static tsdbReaderT doCreateDataReader(STableScanPhysiNode* pTableScanNode, SRead
STableListInfo
*
pTableListInfo
,
uint64_t
queryId
,
uint64_t
taskId
,
SNode
*
pTagCond
);
static
int32_t
getTableList
(
void
*
metaHandle
,
int32_t
tableType
,
uint64_t
tableUid
,
STableListInfo
*
pListInfo
,
SNode
*
pTagCond
);
static
SArray
*
extractColumnInfo
(
SNodeList
*
pNodeList
);
static
SArray
*
createSortInfo
(
SNodeList
*
pNodeList
);
...
...
@@ -4698,11 +4662,22 @@ SOperatorInfo* createOperatorTree(SPhysiNode* pPhyNode, SExecTaskInfo* pTaskInfo
return
NULL
;
}
SOperatorInfo
*
pOperator
=
createTableScanOperatorInfo
(
pTableScanNode
,
pDataReader
,
pHandle
,
pTaskInfo
);
SOperatorInfo
*
pOperator
=
createTableScanOperatorInfo
(
pTableScanNode
,
pDataReader
,
pHandle
,
pTaskInfo
);
STableScanInfo
*
pScanInfo
=
pOperator
->
info
;
pTaskInfo
->
cost
.
pRecoder
=
&
pScanInfo
->
readRecorder
;
return
pOperator
;
}
else
if
(
QUERY_NODE_PHYSICAL_PLAN_TABLE_MERGE_SCAN
==
type
)
{
STableMergeScanPhysiNode
*
pTableScanNode
=
(
STableMergeScanPhysiNode
*
)
pPhyNode
;
SArray
*
dataReaders
=
taosArrayInit
(
8
,
POINTER_BYTES
);
createMultipleDataReaders
(
pTableScanNode
,
pHandle
,
pTableListInfo
,
dataReaders
,
queryId
,
taskId
,
pTagCond
);
extractTableSchemaVersion
(
pHandle
,
pTableScanNode
->
scan
.
uid
,
pTaskInfo
);
SArray
*
groupKeys
=
extractPartitionColInfo
(
pTableScanNode
->
pPartitionKeys
);
generateGroupIdMap
(
pTableListInfo
,
pHandle
,
groupKeys
);
// todo for json
taosArrayDestroy
(
groupKeys
);
SOperatorInfo
*
pOperator
=
createTableMergeScanOperatorInfo
(
pTableScanNode
,
dataReaders
,
pHandle
,
pTaskInfo
);
STableScanInfo
*
pScanInfo
=
pOperator
->
info
;
pTaskInfo
->
cost
.
pRecoder
=
&
pScanInfo
->
readRecorder
;
return
pOperator
;
}
else
if
(
QUERY_NODE_PHYSICAL_PLAN_EXCHANGE
==
type
)
{
return
createExchangeOperatorInfo
(
pHandle
->
pMsgCb
->
clientRpc
,
(
SExchangePhysiNode
*
)
pPhyNode
,
pTaskInfo
);
...
...
@@ -4813,6 +4788,7 @@ SOperatorInfo* createOperatorTree(SPhysiNode* pPhyNode, SExecTaskInfo* pTaskInfo
.
calTrigger
=
pIntervalPhyNode
->
window
.
triggerType
,
.
maxTs
=
INT64_MIN
,
};
ASSERT
(
as
.
calTrigger
!=
STREAM_TRIGGER_MAX_DELAY
);
int32_t
tsSlotId
=
((
SColumnNode
*
)
pIntervalPhyNode
->
window
.
pTspk
)
->
slotId
;
bool
isStream
=
(
QUERY_NODE_PHYSICAL_PLAN_STREAM_INTERVAL
==
type
);
...
...
@@ -4835,11 +4811,9 @@ SOperatorInfo* createOperatorTree(SPhysiNode* pPhyNode, SExecTaskInfo* pTaskInfo
int32_t
tsSlotId
=
((
SColumnNode
*
)
pIntervalPhyNode
->
window
.
pTspk
)
->
slotId
;
pOptr
=
createMergeIntervalOperatorInfo
(
ops
[
0
],
pExprInfo
,
num
,
pResBlock
,
&
interval
,
tsSlotId
,
pTaskInfo
);
}
else
if
(
QUERY_NODE_PHYSICAL_PLAN_STREAM_SEMI_INTERVAL
==
type
)
{
qDebug
(
"[******]create Semi"
);
int32_t
children
=
0
;
pOptr
=
createStreamFinalIntervalOperatorInfo
(
ops
[
0
],
pPhyNode
,
pTaskInfo
,
children
);
}
else
if
(
QUERY_NODE_PHYSICAL_PLAN_STREAM_FINAL_INTERVAL
==
type
)
{
qDebug
(
"[******]create Final"
);
int32_t
children
=
1
;
pOptr
=
createStreamFinalIntervalOperatorInfo
(
ops
[
0
],
pPhyNode
,
pTaskInfo
,
children
);
}
else
if
(
QUERY_NODE_PHYSICAL_PLAN_SORT
==
type
)
{
...
...
@@ -5497,14 +5471,16 @@ int32_t getOperatorExplainExecInfo(SOperatorInfo* operatorInfo, SExplainExecInfo
}
int32_t
initStreamAggSupporter
(
SStreamAggSupporter
*
pSup
,
const
char
*
pKey
,
SqlFunctionCtx
*
pCtx
,
int32_t
numOfOutput
,
size
_t
size
)
{
int32
_t
size
)
{
pSup
->
resultRowSize
=
getResultRowSize
(
pCtx
,
numOfOutput
);
pSup
->
keySize
=
sizeof
(
int64_t
)
+
sizeof
(
TSKEY
);
pSup
->
pKeyBuf
=
taosMemoryCalloc
(
1
,
pSup
->
keySize
);
pSup
->
pResultRows
=
taosArrayInit
(
1024
,
size
);
_hash_fn_t
hashFn
=
taosGetDefaultHashFunction
(
TSDB_DATA_TYPE_BINARY
);
pSup
->
pResultRows
=
taosHashInit
(
1024
,
hashFn
,
false
,
HASH_NO_LOCK
);
if
(
pSup
->
pKeyBuf
==
NULL
||
pSup
->
pResultRows
==
NULL
)
{
return
TSDB_CODE_OUT_OF_MEMORY
;
}
pSup
->
valueSize
=
size
;
pSup
->
pScanWindow
=
taosArrayInit
(
4
,
sizeof
(
STimeWindow
));
...
...
source/libs/executor/src/groupoperator.c
浏览文件 @
e52429e3
...
...
@@ -332,12 +332,7 @@ static SSDataBlock* hashGroupbyAggregate(SOperatorInfo* pOperator) {
pOperator
->
status
=
OP_RES_TO_RETURN
;
closeAllResultRows
(
&
pInfo
->
binfo
.
resultRowInfo
);
// if (!stableQuery) { // finalize include the update of result rows
// finalizeQueryResult(pInfo->binfo.pCtx, pOperator->numOfExprs);
// } else {
// updateNumOfRowsInResultRows(pInfo->binfo.pCtx, pOperator->numOfExprs, &pInfo->binfo.resultRowInfo,
// pInfo->binfo.rowCellInfoOffset);
// }
#if 0
if(pOperator->fpSet.encodeResultRow){
char *result = NULL;
...
...
@@ -378,8 +373,9 @@ static SSDataBlock* hashGroupbyAggregate(SOperatorInfo* pOperator) {
return
(
rows
==
0
)
?
NULL
:
pRes
;
}
SOperatorInfo
*
createGroupOperatorInfo
(
SOperatorInfo
*
downstream
,
SExprInfo
*
pExprInfo
,
int32_t
numOfCols
,
SSDataBlock
*
pResultBlock
,
SArray
*
pGroupColList
,
SNode
*
pCondition
,
SExprInfo
*
pScalarExprInfo
,
int32_t
numOfScalarExpr
,
SExecTaskInfo
*
pTaskInfo
)
{
SOperatorInfo
*
createGroupOperatorInfo
(
SOperatorInfo
*
downstream
,
SExprInfo
*
pExprInfo
,
int32_t
numOfCols
,
SSDataBlock
*
pResultBlock
,
SArray
*
pGroupColList
,
SNode
*
pCondition
,
SExprInfo
*
pScalarExprInfo
,
int32_t
numOfScalarExpr
,
SExecTaskInfo
*
pTaskInfo
)
{
SGroupbyOperatorInfo
*
pInfo
=
taosMemoryCalloc
(
1
,
sizeof
(
SGroupbyOperatorInfo
));
SOperatorInfo
*
pOperator
=
taosMemoryCalloc
(
1
,
sizeof
(
SOperatorInfo
));
if
(
pInfo
==
NULL
||
pOperator
==
NULL
)
{
...
...
@@ -407,7 +403,7 @@ SOperatorInfo* createGroupOperatorInfo(SOperatorInfo* downstream, SExprInfo* pEx
pOperator
->
status
=
OP_NOT_OPENED
;
// pOperator->operatorType = OP_Groupby;
pOperator
->
pExpr
=
pExprInfo
;
pOperator
->
numOfExprs
=
numOfCols
;
pOperator
->
numOfExprs
=
numOfCols
;
pOperator
->
info
=
pInfo
;
pOperator
->
pTaskInfo
=
pTaskInfo
;
...
...
@@ -669,8 +665,8 @@ static void destroyPartitionOperatorInfo(void* param, int32_t numOfOutput) {
taosMemoryFree
(
pInfo
->
columnOffset
);
}
SOperatorInfo
*
createPartitionOperatorInfo
(
SOperatorInfo
*
downstream
,
SExprInfo
*
pExprInfo
,
int32_t
numOfCols
,
SSDataBlock
*
pResultBlock
,
SArray
*
pGroupColList
,
SExecTaskInfo
*
pTaskInfo
)
{
SOperatorInfo
*
createPartitionOperatorInfo
(
SOperatorInfo
*
downstream
,
SExprInfo
*
pExprInfo
,
int32_t
numOfCols
,
S
SDataBlock
*
pResultBlock
,
SArray
*
pGroupColList
,
S
ExecTaskInfo
*
pTaskInfo
)
{
SPartitionOperatorInfo
*
pInfo
=
taosMemoryCalloc
(
1
,
sizeof
(
SPartitionOperatorInfo
));
SOperatorInfo
*
pOperator
=
taosMemoryCalloc
(
1
,
sizeof
(
SOperatorInfo
));
if
(
pInfo
==
NULL
||
pOperator
==
NULL
)
{
...
...
source/libs/executor/src/scanoperator.c
浏览文件 @
e52429e3
此差异已折叠。
点击以展开。
source/libs/executor/src/sortoperator.c
浏览文件 @
e52429e3
...
...
@@ -76,7 +76,9 @@ void appendOneRowToDataBlock(SSDataBlock* pBlock, STupleHandle* pTupleHandle) {
colDataAppendNULL
(
pColInfo
,
pBlock
->
info
.
rows
);
}
else
{
char
*
pData
=
tsortGetValue
(
pTupleHandle
,
i
);
colDataAppend
(
pColInfo
,
pBlock
->
info
.
rows
,
pData
,
false
);
if
(
pData
!=
NULL
)
{
colDataAppend
(
pColInfo
,
pBlock
->
info
.
rows
,
pData
,
false
);
}
}
}
...
...
@@ -427,7 +429,7 @@ SOperatorInfo* createMultiwaySortMergeOperatorInfo(SOperatorInfo** downStreams,
pInfo
->
pInputBlock
=
pInputBlock
;
pOperator
->
name
=
"MultiwaySortMerge"
;
pOperator
->
operatorType
=
QUERY_NODE_PHYSICAL_PLAN_MERGE
;
pOperator
->
blocking
=
tru
e
;
pOperator
->
blocking
=
fals
e
;
pOperator
->
status
=
OP_NOT_OPENED
;
pOperator
->
info
=
pInfo
;
...
...
source/libs/executor/src/timewindowoperator.c
浏览文件 @
e52429e3
此差异已折叠。
点击以展开。
source/libs/executor/src/tsort.c
浏览文件 @
e52429e3
...
...
@@ -738,7 +738,11 @@ bool tsortIsNullVal(STupleHandle* pVHandle, int32_t colIndex) {
void
*
tsortGetValue
(
STupleHandle
*
pVHandle
,
int32_t
colIndex
)
{
SColumnInfoData
*
pColInfo
=
TARRAY_GET_ELEM
(
pVHandle
->
pBlock
->
pDataBlock
,
colIndex
);
return
colDataGetData
(
pColInfo
,
pVHandle
->
rowIndex
);
if
(
pColInfo
->
pData
==
NULL
)
{
return
NULL
;
}
else
{
return
colDataGetData
(
pColInfo
,
pVHandle
->
rowIndex
);
}
}
uint64_t
tsortGetGroupId
(
STupleHandle
*
pVHandle
)
{
...
...
source/libs/function/inc/builtinsimpl.h
浏览文件 @
e52429e3
...
...
@@ -97,6 +97,10 @@ bool getDiffFuncEnv(struct SFunctionNode* pFunc, SFuncExecEnv* pEnv);
bool
diffFunctionSetup
(
SqlFunctionCtx
*
pCtx
,
SResultRowEntryInfo
*
pResInfo
);
int32_t
diffFunction
(
SqlFunctionCtx
*
pCtx
);
bool
getDerivativeFuncEnv
(
struct
SFunctionNode
*
pFunc
,
SFuncExecEnv
*
pEnv
);
bool
derivativeFuncSetup
(
SqlFunctionCtx
*
pCtx
,
SResultRowEntryInfo
*
pResInfo
);
int32_t
derivativeFunction
(
SqlFunctionCtx
*
pCtx
);
bool
getFirstLastFuncEnv
(
struct
SFunctionNode
*
pFunc
,
SFuncExecEnv
*
pEnv
);
int32_t
firstFunction
(
SqlFunctionCtx
*
pCtx
);
int32_t
firstFunctionMerge
(
SqlFunctionCtx
*
pCtx
);
...
...
source/libs/function/inc/functionMgtInt.h
浏览文件 @
e52429e3
...
...
@@ -42,7 +42,8 @@ extern "C" {
#define FUNC_MGT_SELECT_FUNC FUNC_MGT_FUNC_CLASSIFICATION_MASK(13)
#define FUNC_MGT_REPEAT_SCAN_FUNC FUNC_MGT_FUNC_CLASSIFICATION_MASK(14)
#define FUNC_MGT_FORBID_FILL_FUNC FUNC_MGT_FUNC_CLASSIFICATION_MASK(15)
#define FUNC_MGT_FORBID_STREAM_FUNC FUNC_MGT_FUNC_CLASSIFICATION_MASK(16)
#define FUNC_MGT_INTERVAL_INTERPO_FUNC FUNC_MGT_FUNC_CLASSIFICATION_MASK(16)
#define FUNC_MGT_FORBID_STREAM_FUNC FUNC_MGT_FUNC_CLASSIFICATION_MASK(17)
#define FUNC_MGT_TEST_MASK(val, mask) (((val) & (mask)) != 0)
...
...
source/libs/function/inc/texpr.h
浏览文件 @
e52429e3
...
...
@@ -60,12 +60,6 @@ typedef struct SExprTraverseSupp {
void
*
pExtInfo
;
}
SExprTraverseSupp
;
tExprNode
*
exprTreeFromTableName
(
const
char
*
tbnameCond
);
bool
exprTreeApplyFilter
(
tExprNode
*
pExpr
,
const
void
*
pItem
,
SExprTraverseSupp
*
param
);
void
buildFilterSetFromBinary
(
void
**
q
,
const
char
*
buf
,
int32_t
len
);
#ifdef __cplusplus
}
#endif
...
...
source/libs/function/inc/tunaryoperator.h
已删除
100644 → 0
浏览文件 @
7f78d4a7
/*
* 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/>.
*/
#ifndef _TD_COMMON_UNARY_SCALAR_OPERATOR_H_
#define _TD_COMMON_UNARY_SCALAR_OPERATOR_H_
#ifdef __cplusplus
extern
"C"
{
#endif
//#include "tscalarfunction.h"
//typedef void (*_unary_scalar_fn_t)(SScalarParam *pLeft, SScalarParam* pOutput);
//_unary_scalar_fn_t getUnaryScalarOperatorFn(int32_t binOperator);
#ifdef __cplusplus
}
#endif
#endif
/*_TD_COMMON_BIN_SCALAR_OPERATOR_H_*/
source/libs/function/src/builtins.c
浏览文件 @
e52429e3
...
...
@@ -997,6 +997,38 @@ static int32_t translateLastRow(SFunctionNode* pFunc, char* pErrBuf, int32_t len
return
TSDB_CODE_SUCCESS
;
}
static
int32_t
translateDerivative
(
SFunctionNode
*
pFunc
,
char
*
pErrBuf
,
int32_t
len
)
{
if
(
3
!=
LIST_LENGTH
(
pFunc
->
pParameterList
))
{
return
invaildFuncParaNumErrMsg
(
pErrBuf
,
len
,
pFunc
->
functionName
);
}
uint8_t
colType
=
((
SExprNode
*
)
nodesListGetNode
(
pFunc
->
pParameterList
,
0
))
->
resType
.
type
;
// param1
SNode
*
pParamNode1
=
nodesListGetNode
(
pFunc
->
pParameterList
,
1
);
if
(
QUERY_NODE_VALUE
!=
nodeType
(
pParamNode1
))
{
return
invaildFuncParaTypeErrMsg
(
pErrBuf
,
len
,
pFunc
->
functionName
);
}
SValueNode
*
pValue
=
(
SValueNode
*
)
pParamNode1
;
pValue
->
notReserved
=
true
;
if
(
!
IS_NUMERIC_TYPE
(
colType
))
{
return
invaildFuncParaTypeErrMsg
(
pErrBuf
,
len
,
pFunc
->
functionName
);
}
SNode
*
pParamNode2
=
nodesListGetNode
(
pFunc
->
pParameterList
,
2
);
SValueNode
*
pValue2
=
(
SValueNode
*
)
pParamNode2
;
pValue2
->
notReserved
=
true
;
if
(
pValue2
->
datum
.
i
!=
0
&&
pValue2
->
datum
.
i
!=
1
)
{
return
invaildFuncParaValueErrMsg
(
pErrBuf
,
len
,
pFunc
->
functionName
);
}
pFunc
->
node
.
resType
=
(
SDataType
){.
bytes
=
tDataTypes
[
TSDB_DATA_TYPE_DOUBLE
].
bytes
,
.
type
=
TSDB_DATA_TYPE_DOUBLE
};
return
TSDB_CODE_SUCCESS
;
}
static
int32_t
translateFirstLast
(
SFunctionNode
*
pFunc
,
char
*
pErrBuf
,
int32_t
len
)
{
// first(col_list) will be rewritten as first(col)
if
(
1
!=
LIST_LENGTH
(
pFunc
->
pParameterList
))
{
...
...
@@ -1596,6 +1628,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = {
.
type
=
FUNCTION_TYPE_AVG
,
.
classification
=
FUNC_MGT_AGG_FUNC
,
.
translateFunc
=
translateInNumOutDou
,
.
dataRequiredFunc
=
statisDataRequired
,
.
getEnvFunc
=
getAvgFuncEnv
,
.
initFunc
=
avgFunctionSetup
,
.
processFunc
=
avgFunction
,
...
...
@@ -1682,7 +1715,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = {
{
.
name
=
"top"
,
.
type
=
FUNCTION_TYPE_TOP
,
.
classification
=
FUNC_MGT_AGG_FUNC
|
FUNC_MGT_SELECT_FUNC
|
FUNC_MGT_INDEFINITE_ROWS_FUNC
,
.
classification
=
FUNC_MGT_AGG_FUNC
|
FUNC_MGT_SELECT_FUNC
|
FUNC_MGT_INDEFINITE_ROWS_FUNC
|
FUNC_MGT_FORBID_STREAM_FUNC
,
.
translateFunc
=
translateTopBot
,
.
getEnvFunc
=
getTopBotFuncEnv
,
.
initFunc
=
topBotFunctionSetup
,
...
...
@@ -1717,7 +1750,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = {
{
.
name
=
"bottom"
,
.
type
=
FUNCTION_TYPE_BOTTOM
,
.
classification
=
FUNC_MGT_AGG_FUNC
|
FUNC_MGT_SELECT_FUNC
|
FUNC_MGT_INDEFINITE_ROWS_FUNC
,
.
classification
=
FUNC_MGT_AGG_FUNC
|
FUNC_MGT_SELECT_FUNC
|
FUNC_MGT_INDEFINITE_ROWS_FUNC
|
FUNC_MGT_FORBID_STREAM_FUNC
,
.
translateFunc
=
translateTopBot
,
.
getEnvFunc
=
getTopBotFuncEnv
,
.
initFunc
=
topBotFunctionSetup
,
...
...
@@ -1793,7 +1826,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = {
{
.
name
=
"elapsed"
,
.
type
=
FUNCTION_TYPE_ELAPSED
,
.
classification
=
FUNC_MGT_AGG_FUNC
|
FUNC_MGT_FORBID_STREAM_FUNC
,
.
classification
=
FUNC_MGT_AGG_FUNC
|
FUNC_MGT_
TIMELINE_FUNC
|
FUNC_MGT_INTERVAL_INTERPO_FUNC
|
FUNC_MGT_
FORBID_STREAM_FUNC
,
.
dataRequiredFunc
=
statisDataRequired
,
.
translateFunc
=
translateElapsed
,
.
getEnvFunc
=
getElapsedFuncEnv
,
...
...
@@ -1831,6 +1864,26 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = {
.
invertFunc
=
NULL
,
.
combineFunc
=
elapsedCombine
,
},
{
.
name
=
"interp"
,
.
type
=
FUNCTION_TYPE_INTERP
,
.
classification
=
FUNC_MGT_AGG_FUNC
|
FUNC_MGT_TIMELINE_FUNC
|
FUNC_MGT_INTERVAL_INTERPO_FUNC
,
.
translateFunc
=
translateFirstLast
,
.
getEnvFunc
=
getSelectivityFuncEnv
,
.
initFunc
=
functionSetup
,
.
processFunc
=
NULL
,
.
finalizeFunc
=
NULL
},
{
.
name
=
"derivative"
,
.
type
=
FUNCTION_TYPE_DERIVATIVE
,
.
classification
=
FUNC_MGT_INDEFINITE_ROWS_FUNC
|
FUNC_MGT_TIMELINE_FUNC
,
.
translateFunc
=
translateDerivative
,
.
getEnvFunc
=
getDerivativeFuncEnv
,
.
initFunc
=
derivativeFuncSetup
,
.
processFunc
=
derivativeFunction
,
.
finalizeFunc
=
functionFinalize
},
{
.
name
=
"last_row"
,
.
type
=
FUNCTION_TYPE_LAST_ROW
,
...
...
@@ -1914,8 +1967,9 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = {
{
.
name
=
"twa"
,
.
type
=
FUNCTION_TYPE_TWA
,
.
classification
=
FUNC_MGT_AGG_FUNC
|
FUNC_MGT_TIMELINE_FUNC
|
FUNC_MGT_FORBID_STREAM_FUNC
,
.
classification
=
FUNC_MGT_AGG_FUNC
|
FUNC_MGT_TIMELINE_FUNC
|
FUNC_MGT_
INTERVAL_INTERPO_FUNC
|
FUNC_MGT_
FORBID_STREAM_FUNC
,
.
translateFunc
=
translateInNumOutDou
,
.
dataRequiredFunc
=
statisDataRequired
,
.
getEnvFunc
=
getTwaFuncEnv
,
.
initFunc
=
twaFunctionSetup
,
.
processFunc
=
twaFunction
,
...
...
source/libs/function/src/builtinsimpl.c
浏览文件 @
e52429e3
此差异已折叠。
点击以展开。
source/libs/function/src/functionMgt.c
浏览文件 @
e52429e3
...
...
@@ -161,6 +161,8 @@ bool fmIsUserDefinedFunc(int32_t funcId) { return funcId > FUNC_UDF_ID_START; }
bool
fmIsForbidFillFunc
(
int32_t
funcId
)
{
return
isSpecificClassifyFunc
(
funcId
,
FUNC_MGT_FORBID_FILL_FUNC
);
}
bool
fmIsIntervalInterpoFunc
(
int32_t
funcId
)
{
return
isSpecificClassifyFunc
(
funcId
,
FUNC_MGT_INTERVAL_INTERPO_FUNC
);
}
bool
fmIsForbidStreamFunc
(
int32_t
funcId
)
{
return
isSpecificClassifyFunc
(
funcId
,
FUNC_MGT_FORBID_STREAM_FUNC
);
}
void
fmFuncMgtDestroy
()
{
...
...
source/libs/function/src/taggfunction.c
浏览文件 @
e52429e3
...
...
@@ -161,13 +161,13 @@ typedef struct SRateInfo {
bool
isIRate
;
// true for IRate functions, false for Rate functions
}
SRateInfo
;
typedef
struct
SDerivInfo
{
double
prevValue
;
// previous value
TSKEY
prevTs
;
// previous timestamp
bool
ignoreNegative
;
// ignore the negative value
int64_t
tsWindow
;
// time window for derivative
bool
valueSet
;
// the value has been set already
}
SDerivInfo
;
//
typedef struct SDerivInfo {
//
double prevValue; // previous value
//
TSKEY prevTs; // previous timestamp
//
bool ignoreNegative;// ignore the negative value
//
int64_t tsWindow; // time window for derivative
//
bool valueSet; // the value has been set already
//
} SDerivInfo;
typedef
struct
SResPair
{
TSKEY
key
;
...
...
source/libs/function/src/texpr.c
浏览文件 @
e52429e3
此差异已折叠。
点击以展开。
source/libs/function/src/udfd.c
浏览文件 @
e52429e3
...
...
@@ -468,8 +468,8 @@ int32_t udfdConnectToMnode() {
char
pass
[
TSDB_PASSWORD_LEN
+
1
]
=
{
0
};
taosEncryptPass_c
((
uint8_t
*
)(
TSDB_DEFAULT_PASS
),
strlen
(
TSDB_DEFAULT_PASS
),
pass
);
tstrncpy
(
connReq
.
passwd
,
pass
,
sizeof
(
connReq
.
passwd
));
connReq
.
pid
=
htonl
(
taosGetPId
()
);
connReq
.
startTime
=
htobe64
(
taosGetTimestampMs
()
);
connReq
.
pid
=
taosGetPId
(
);
connReq
.
startTime
=
taosGetTimestampMs
(
);
int32_t
contLen
=
tSerializeSConnectReq
(
NULL
,
0
,
&
connReq
);
void
*
pReq
=
rpcMallocCont
(
contLen
);
...
...
source/libs/nodes/src/nodesUtilFuncs.c
浏览文件 @
e52429e3
...
...
@@ -199,6 +199,7 @@ SNode* nodesMakeNode(ENodeType type) {
case
QUERY_NODE_SHOW_SUBSCRIBES_STMT
:
case
QUERY_NODE_SHOW_SMAS_STMT
:
case
QUERY_NODE_SHOW_CONFIGS_STMT
:
case
QUERY_NODE_SHOW_CONNECTIONS_STMT
:
case
QUERY_NODE_SHOW_QUERIES_STMT
:
case
QUERY_NODE_SHOW_VNODES_STMT
:
case
QUERY_NODE_SHOW_APPS_STMT
:
...
...
source/libs/parser/src/parAstParser.c
浏览文件 @
e52429e3
...
...
@@ -377,6 +377,16 @@ static int32_t collectMetaKeyFromShowTopics(SCollectMetaKeyCxt* pCxt, SShowStmt*
pCxt
->
pMetaCache
);
}
static
int32_t
collectMetaKeyFromShowConnections
(
SCollectMetaKeyCxt
*
pCxt
,
SShowStmt
*
pStmt
)
{
return
reserveTableMetaInCache
(
pCxt
->
pParseCxt
->
acctId
,
TSDB_PERFORMANCE_SCHEMA_DB
,
TSDB_PERFS_TABLE_CONNECTIONS
,
pCxt
->
pMetaCache
);
}
static
int32_t
collectMetaKeyFromShowQueries
(
SCollectMetaKeyCxt
*
pCxt
,
SShowStmt
*
pStmt
)
{
return
reserveTableMetaInCache
(
pCxt
->
pParseCxt
->
acctId
,
TSDB_PERFORMANCE_SCHEMA_DB
,
TSDB_PERFS_TABLE_QUERIES
,
pCxt
->
pMetaCache
);
}
static
int32_t
collectMetaKeyFromShowTransactions
(
SCollectMetaKeyCxt
*
pCxt
,
SShowStmt
*
pStmt
)
{
return
reserveTableMetaInCache
(
pCxt
->
pParseCxt
->
acctId
,
TSDB_PERFORMANCE_SCHEMA_DB
,
TSDB_PERFS_TABLE_TRANS
,
pCxt
->
pMetaCache
);
...
...
@@ -447,6 +457,10 @@ static int32_t collectMetaKeyFromQuery(SCollectMetaKeyCxt* pCxt, SNode* pStmt) {
return
collectMetaKeyFromShowVgroups
(
pCxt
,
(
SShowStmt
*
)
pStmt
);
case
QUERY_NODE_SHOW_TOPICS_STMT
:
return
collectMetaKeyFromShowTopics
(
pCxt
,
(
SShowStmt
*
)
pStmt
);
case
QUERY_NODE_SHOW_CONNECTIONS_STMT
:
return
collectMetaKeyFromShowConnections
(
pCxt
,
(
SShowStmt
*
)
pStmt
);
case
QUERY_NODE_SHOW_QUERIES_STMT
:
return
collectMetaKeyFromShowQueries
(
pCxt
,
(
SShowStmt
*
)
pStmt
);
case
QUERY_NODE_SHOW_TRANSACTIONS_STMT
:
return
collectMetaKeyFromShowTransactions
(
pCxt
,
(
SShowStmt
*
)
pStmt
);
case
QUERY_NODE_DELETE_STMT
:
...
...
source/libs/parser/src/parTranslater.c
浏览文件 @
e52429e3
此差异已折叠。
点击以展开。
source/libs/planner/src/planLogicCreater.c
浏览文件 @
e52429e3
...
...
@@ -498,7 +498,7 @@ static int32_t createWindowLogicNodeFinalize(SLogicPlanContext* pCxt, SSelectStm
}
if
(
pCxt
->
pPlanCxt
->
rSmaQuery
)
{
pWindow
->
filesFactor
=
pCxt
->
pPlanCxt
->
filesFactor
;
/*pWindow->filesFactor = pCxt->pPlanCxt->filesFactor;*/
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
...
...
source/libs/planner/src/planPhysiCreater.c
浏览文件 @
e52429e3
...
...
@@ -470,8 +470,8 @@ static ENodeType getScanOperatorType(EScanType scanType) {
case
SCAN_TYPE_STREAM
:
return
QUERY_NODE_PHYSICAL_PLAN_STREAM_SCAN
;
case
SCAN_TYPE_TABLE_MERGE
:
return
QUERY_NODE_PHYSICAL_PLAN_TABLE_SCAN
;
//
return QUERY_NODE_PHYSICAL_PLAN_TABLE_MERGE_SCAN;
//
return QUERY_NODE_PHYSICAL_PLAN_TABLE_SCAN;
return
QUERY_NODE_PHYSICAL_PLAN_TABLE_MERGE_SCAN
;
default:
break
;
}
...
...
source/libs/scheduler/src/scheduler.c
浏览文件 @
e52429e3
此差异已折叠。
点击以展开。
source/libs/stream/inc/streamInc.h
浏览文件 @
e52429e3
此差异已折叠。
点击以展开。
source/libs/stream/src/stream.c
浏览文件 @
e52429e3
此差异已折叠。
点击以展开。
source/libs/stream/src/streamExec.c
浏览文件 @
e52429e3
此差异已折叠。
点击以展开。
source/libs/stream/src/streamTask.c
浏览文件 @
e52429e3
此差异已折叠。
点击以展开。
source/libs/sync/src/syncMain.c
浏览文件 @
e52429e3
此差异已折叠。
点击以展开。
source/libs/sync/test/syncConfigChangeSnapshotTest.cpp
浏览文件 @
e52429e3
此差异已折叠。
点击以展开。
source/libs/sync/test/syncConfigChangeTest.cpp
浏览文件 @
e52429e3
此差异已折叠。
点击以展开。
source/libs/sync/test/syncReplicateTest.cpp
浏览文件 @
e52429e3
此差异已折叠。
点击以展开。
source/libs/sync/test/syncTestTool.cpp
浏览文件 @
e52429e3
此差异已折叠。
点击以展开。
source/libs/wal/src/walRead.c
浏览文件 @
e52429e3
此差异已折叠。
点击以展开。
source/libs/wal/src/walWrite.c
浏览文件 @
e52429e3
此差异已折叠。
点击以展开。
source/util/src/tarray.c
浏览文件 @
e52429e3
此差异已折叠。
点击以展开。
source/util/src/tcache.c
浏览文件 @
e52429e3
此差异已折叠。
点击以展开。
source/util/src/terror.c
浏览文件 @
e52429e3
此差异已折叠。
点击以展开。
tests/pytest/util/dnodes.py
浏览文件 @
e52429e3
此差异已折叠。
点击以展开。
tests/pytest/util/sql.py
浏览文件 @
e52429e3
此差异已折叠。
点击以展开。
tests/system-test/0-others/user_control.py
浏览文件 @
e52429e3
此差异已折叠。
点击以展开。
tests/system-test/2-query/json_tag.py
浏览文件 @
e52429e3
此差异已折叠。
点击以展开。
tests/system-test/6-cluster/5dnode2mnode.py
浏览文件 @
e52429e3
此差异已折叠。
点击以展开。
tests/system-test/6-cluster/5dnode3mnodeDrop.py
浏览文件 @
e52429e3
此差异已折叠。
点击以展开。
tests/system-test/6-cluster/5dnode3mnodeStop.py
浏览文件 @
e52429e3
此差异已折叠。
点击以展开。
tests/system-test/6-cluster/5dnode3mnodeStopInsert.py
浏览文件 @
e52429e3
此差异已折叠。
点击以展开。
tests/system-test/7-tmq/basic5.py
浏览文件 @
e52429e3
此差异已折叠。
点击以展开。
tests/system-test/7-tmq/tmqError.py
浏览文件 @
e52429e3
此差异已折叠。
点击以展开。
tests/system-test/fulltest.sh
浏览文件 @
e52429e3
此差异已折叠。
点击以展开。
tests/system-test/test-all.bat
浏览文件 @
e52429e3
此差异已折叠。
点击以展开。
tests/system-test/test.py
浏览文件 @
e52429e3
此差异已折叠。
点击以展开。
taosadapter
@
9ce3f5c9
比较
9ce3f5c9
...
9ce3f5c9
此差异已折叠。
点击以展开。
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录