Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
4560b8f2
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看板
未验证
提交
4560b8f2
编写于
6月 07, 2022
作者:
wmmhello
提交者:
GitHub
6月 07, 2022
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #13539 from taosdata/3.0
3.0
上级
ca187f2e
1cffb8fd
变更
77
展开全部
隐藏空白更改
内联
并排
Showing
77 changed file
with
2266 addition
and
1270 deletion
+2266
-1270
include/common/tcommon.h
include/common/tcommon.h
+12
-10
include/libs/nodes/nodes.h
include/libs/nodes/nodes.h
+2
-0
include/libs/nodes/plannodes.h
include/libs/nodes/plannodes.h
+11
-0
include/libs/qcom/query.h
include/libs/qcom/query.h
+1
-1
include/libs/stream/tstream.h
include/libs/stream/tstream.h
+122
-49
include/util/taoserror.h
include/util/taoserror.h
+1
-0
source/client/inc/clientInt.h
source/client/inc/clientInt.h
+9
-5
source/client/src/clientEnv.c
source/client/src/clientEnv.c
+1
-4
source/client/src/clientImpl.c
source/client/src/clientImpl.c
+63
-25
source/client/src/clientMain.c
source/client/src/clientMain.c
+74
-54
source/client/src/clientMsgHandler.c
source/client/src/clientMsgHandler.c
+46
-26
source/client/src/clientSml.c
source/client/src/clientSml.c
+1
-1
source/client/test/clientTests.cpp
source/client/test/clientTests.cpp
+29
-1
source/client/test/smlTest.cpp
source/client/test/smlTest.cpp
+15
-15
source/dnode/mnode/impl/src/mndDb.c
source/dnode/mnode/impl/src/mndDb.c
+15
-9
source/dnode/mnode/impl/src/mndScheduler.c
source/dnode/mnode/impl/src/mndScheduler.c
+5
-5
source/dnode/mnode/impl/src/mndVgroup.c
source/dnode/mnode/impl/src/mndVgroup.c
+157
-1
source/dnode/vnode/src/inc/tq.h
source/dnode/vnode/src/inc/tq.h
+5
-5
source/dnode/vnode/src/tq/tq.c
source/dnode/vnode/src/tq/tq.c
+21
-46
source/dnode/vnode/src/tq/tqExec.c
source/dnode/vnode/src/tq/tqExec.c
+2
-2
source/dnode/vnode/src/tq/tqMeta.c
source/dnode/vnode/src/tq/tqMeta.c
+5
-6
source/dnode/vnode/src/tq/tqPush.c
source/dnode/vnode/src/tq/tqPush.c
+5
-5
source/dnode/vnode/src/tq/tqRead.c
source/dnode/vnode/src/tq/tqRead.c
+2
-2
source/libs/catalog/inc/catalogInt.h
source/libs/catalog/inc/catalogInt.h
+1
-0
source/libs/catalog/src/ctgAsync.c
source/libs/catalog/src/ctgAsync.c
+100
-17
source/libs/catalog/src/ctgRemote.c
source/libs/catalog/src/ctgRemote.c
+3
-3
source/libs/catalog/src/ctgUtil.c
source/libs/catalog/src/ctgUtil.c
+28
-0
source/libs/executor/inc/executorimpl.h
source/libs/executor/inc/executorimpl.h
+12
-0
source/libs/executor/src/executorimpl.c
source/libs/executor/src/executorimpl.c
+157
-22
source/libs/function/src/builtins.c
source/libs/function/src/builtins.c
+0
-86
source/libs/index/inc/indexInt.h
source/libs/index/inc/indexInt.h
+7
-7
source/libs/index/src/indexCache.c
source/libs/index/src/indexCache.c
+5
-2
source/libs/index/src/indexComm.c
source/libs/index/src/indexComm.c
+9
-2
source/libs/index/src/indexFilter.c
source/libs/index/src/indexFilter.c
+12
-7
source/libs/index/src/indexTfile.c
source/libs/index/src/indexTfile.c
+1
-6
source/libs/nodes/src/nodesCloneFuncs.c
source/libs/nodes/src/nodesCloneFuncs.c
+8
-0
source/libs/nodes/src/nodesCodeFuncs.c
source/libs/nodes/src/nodesCodeFuncs.c
+67
-0
source/libs/nodes/src/nodesTraverseFuncs.c
source/libs/nodes/src/nodesTraverseFuncs.c
+2
-0
source/libs/nodes/src/nodesUtilFuncs.c
source/libs/nodes/src/nodesUtilFuncs.c
+4
-0
source/libs/parser/src/parAstParser.c
source/libs/parser/src/parAstParser.c
+13
-0
source/libs/parser/src/parTokenizer.c
source/libs/parser/src/parTokenizer.c
+1
-1
source/libs/parser/src/parTranslater.c
source/libs/parser/src/parTranslater.c
+0
-1
source/libs/parser/test/mockCatalog.cpp
source/libs/parser/test/mockCatalog.cpp
+9
-0
source/libs/parser/test/parInitialDTest.cpp
source/libs/parser/test/parInitialDTest.cpp
+10
-2
source/libs/parser/test/parTestUtil.h
source/libs/parser/test/parTestUtil.h
+6
-4
source/libs/planner/src/planLogicCreater.c
source/libs/planner/src/planLogicCreater.c
+34
-0
source/libs/planner/src/planPhysiCreater.c
source/libs/planner/src/planPhysiCreater.c
+39
-0
source/libs/planner/test/planIntervalTest.cpp
source/libs/planner/test/planIntervalTest.cpp
+2
-0
source/libs/planner/test/planProjectTest.cpp
source/libs/planner/test/planProjectTest.cpp
+34
-0
source/libs/planner/test/planTestUtil.cpp
source/libs/planner/test/planTestUtil.cpp
+8
-1
source/libs/qcom/src/querymsg.c
source/libs/qcom/src/querymsg.c
+4
-0
source/libs/scheduler/src/schJob.c
source/libs/scheduler/src/schJob.c
+1
-1
source/libs/stream/inc/streamInc.h
source/libs/stream/inc/streamInc.h
+9
-3
source/libs/stream/src/stream.c
source/libs/stream/src/stream.c
+112
-0
source/libs/stream/src/streamData.c
source/libs/stream/src/streamData.c
+85
-0
source/libs/stream/src/streamExec.c
source/libs/stream/src/streamExec.c
+123
-0
source/libs/stream/src/streamMsg.c
source/libs/stream/src/streamMsg.c
+150
-0
source/libs/stream/src/streamQueue.c
source/libs/stream/src/streamQueue.c
+43
-0
source/libs/stream/src/streamSink.c
source/libs/stream/src/streamSink.c
+157
-0
source/libs/stream/src/streamTask.c
source/libs/stream/src/streamTask.c
+138
-0
source/libs/stream/src/streamUpdate.c
source/libs/stream/src/streamUpdate.c
+0
-0
source/libs/stream/src/tstream.c
source/libs/stream/src/tstream.c
+0
-594
source/util/src/terror.c
source/util/src/terror.c
+3
-1
source/util/src/tqueue.c
source/util/src/tqueue.c
+10
-8
tests/script/tsim/stable/column_drop.sim
tests/script/tsim/stable/column_drop.sim
+1
-0
tests/script/tsim/testsuit.sim
tests/script/tsim/testsuit.sim
+40
-40
tests/system-test/0-others/taosdMonitor.py
tests/system-test/0-others/taosdMonitor.py
+167
-165
tests/system-test/2-query/csum.py
tests/system-test/2-query/csum.py
+9
-1
tests/system-test/2-query/elapsed.py
tests/system-test/2-query/elapsed.py
+1
-1
tests/system-test/2-query/function_stateduration.py
tests/system-test/2-query/function_stateduration.py
+7
-2
tests/system-test/2-query/hyperloglog.py
tests/system-test/2-query/hyperloglog.py
+1
-1
tests/system-test/2-query/mavg.py
tests/system-test/2-query/mavg.py
+10
-2
tests/system-test/2-query/sample.py
tests/system-test/2-query/sample.py
+13
-13
tests/system-test/2-query/statecount.py
tests/system-test/2-query/statecount.py
+2
-2
tests/system-test/fulltest.bat
tests/system-test/fulltest.bat
+2
-2
tests/system-test/test.py
tests/system-test/test.py
+1
-0
tools/shell/src/shellEngine.c
tools/shell/src/shellEngine.c
+1
-1
未找到文件。
include/common/tcommon.h
浏览文件 @
4560b8f2
...
@@ -77,7 +77,9 @@ typedef struct SDataBlockInfo {
...
@@ -77,7 +77,9 @@ typedef struct SDataBlockInfo {
int16_t
numOfCols
;
int16_t
numOfCols
;
int16_t
hasVarCol
;
int16_t
hasVarCol
;
int32_t
capacity
;
int32_t
capacity
;
EStreamType
type
;
// TODO: optimize and remove following
int32_t
childId
;
// used for stream, do not serialize
EStreamType
type
;
// used for stream, do not serialize
}
SDataBlockInfo
;
}
SDataBlockInfo
;
typedef
struct
SSDataBlock
{
typedef
struct
SSDataBlock
{
...
@@ -105,14 +107,14 @@ typedef struct SColumnInfoData {
...
@@ -105,14 +107,14 @@ typedef struct SColumnInfoData {
}
SColumnInfoData
;
}
SColumnInfoData
;
typedef
struct
SQueryTableDataCond
{
typedef
struct
SQueryTableDataCond
{
//STimeWindow twindow;
//
STimeWindow twindow;
int32_t
order
;
// desc|asc order to iterate the data block
int32_t
order
;
// desc|asc order to iterate the data block
int32_t
numOfCols
;
int32_t
numOfCols
;
SColumnInfo
*
colList
;
SColumnInfo
*
colList
;
bool
loadExternalRows
;
// load external rows or not
bool
loadExternalRows
;
// load external rows or not
int32_t
type
;
// data block load type:
int32_t
type
;
// data block load type:
int32_t
numOfTWindows
;
int32_t
numOfTWindows
;
STimeWindow
*
twindows
;
STimeWindow
*
twindows
;
}
SQueryTableDataCond
;
}
SQueryTableDataCond
;
void
*
blockDataDestroy
(
SSDataBlock
*
pBlock
);
void
*
blockDataDestroy
(
SSDataBlock
*
pBlock
);
...
@@ -202,17 +204,17 @@ typedef struct SExprInfo {
...
@@ -202,17 +204,17 @@ typedef struct SExprInfo {
}
SExprInfo
;
}
SExprInfo
;
typedef
struct
{
typedef
struct
{
const
char
*
key
;
const
char
*
key
;
int32_t
keyLen
;
int32_t
keyLen
;
uint8_t
type
;
uint8_t
type
;
union
{
union
{
const
char
*
value
;
const
char
*
value
;
int64_t
i
;
int64_t
i
;
uint64_t
u
;
uint64_t
u
;
double
d
;
double
d
;
float
f
;
float
f
;
};
};
int32_t
length
;
int32_t
length
;
}
SSmlKv
;
}
SSmlKv
;
#define QUERY_ASC_FORWARD_STEP 1
#define QUERY_ASC_FORWARD_STEP 1
...
@@ -220,7 +222,7 @@ typedef struct {
...
@@ -220,7 +222,7 @@ typedef struct {
#define GET_FORWARD_DIRECTION_FACTOR(ord) (((ord) == TSDB_ORDER_ASC) ? QUERY_ASC_FORWARD_STEP : QUERY_DESC_FORWARD_STEP)
#define GET_FORWARD_DIRECTION_FACTOR(ord) (((ord) == TSDB_ORDER_ASC) ? QUERY_ASC_FORWARD_STEP : QUERY_DESC_FORWARD_STEP)
#define SORT_QSORT_T 0x1
#define SORT_QSORT_T
0x1
#define SORT_SPILLED_MERGE_SORT_T 0x2
#define SORT_SPILLED_MERGE_SORT_T 0x2
typedef
struct
SSortExecInfo
{
typedef
struct
SSortExecInfo
{
int32_t
sortMethod
;
int32_t
sortMethod
;
...
...
include/libs/nodes/nodes.h
浏览文件 @
4560b8f2
...
@@ -195,6 +195,7 @@ typedef enum ENodeType {
...
@@ -195,6 +195,7 @@ typedef enum ENodeType {
QUERY_NODE_LOGIC_PLAN_FILL
,
QUERY_NODE_LOGIC_PLAN_FILL
,
QUERY_NODE_LOGIC_PLAN_SORT
,
QUERY_NODE_LOGIC_PLAN_SORT
,
QUERY_NODE_LOGIC_PLAN_PARTITION
,
QUERY_NODE_LOGIC_PLAN_PARTITION
,
QUERY_NODE_LOGIC_PLAN_INDEF_ROWS_FUNC
,
QUERY_NODE_LOGIC_SUBPLAN
,
QUERY_NODE_LOGIC_SUBPLAN
,
QUERY_NODE_LOGIC_PLAN
,
QUERY_NODE_LOGIC_PLAN
,
...
@@ -222,6 +223,7 @@ typedef enum ENodeType {
...
@@ -222,6 +223,7 @@ typedef enum ENodeType {
QUERY_NODE_PHYSICAL_PLAN_STATE_WINDOW
,
QUERY_NODE_PHYSICAL_PLAN_STATE_WINDOW
,
QUERY_NODE_PHYSICAL_PLAN_STREAM_STATE_WINDOW
,
QUERY_NODE_PHYSICAL_PLAN_STREAM_STATE_WINDOW
,
QUERY_NODE_PHYSICAL_PLAN_PARTITION
,
QUERY_NODE_PHYSICAL_PLAN_PARTITION
,
QUERY_NODE_PHYSICAL_PLAN_INDEF_ROWS_FUNC
,
QUERY_NODE_PHYSICAL_PLAN_DISPATCH
,
QUERY_NODE_PHYSICAL_PLAN_DISPATCH
,
QUERY_NODE_PHYSICAL_PLAN_INSERT
,
QUERY_NODE_PHYSICAL_PLAN_INSERT
,
QUERY_NODE_PHYSICAL_PLAN_DELETE
,
QUERY_NODE_PHYSICAL_PLAN_DELETE
,
...
...
include/libs/nodes/plannodes.h
浏览文件 @
4560b8f2
...
@@ -87,6 +87,11 @@ typedef struct SProjectLogicNode {
...
@@ -87,6 +87,11 @@ typedef struct SProjectLogicNode {
int64_t
soffset
;
int64_t
soffset
;
}
SProjectLogicNode
;
}
SProjectLogicNode
;
typedef
struct
SIndefRowsFuncLogicNode
{
SLogicNode
node
;
SNodeList
*
pVectorFuncs
;
}
SIndefRowsFuncLogicNode
;
typedef
enum
EModifyTableType
{
MODIFY_TABLE_TYPE_INSERT
=
1
,
MODIFY_TABLE_TYPE_DELETE
}
EModifyTableType
;
typedef
enum
EModifyTableType
{
MODIFY_TABLE_TYPE_INSERT
=
1
,
MODIFY_TABLE_TYPE_DELETE
}
EModifyTableType
;
typedef
struct
SVnodeModifyLogicNode
{
typedef
struct
SVnodeModifyLogicNode
{
...
@@ -267,6 +272,12 @@ typedef struct SProjectPhysiNode {
...
@@ -267,6 +272,12 @@ typedef struct SProjectPhysiNode {
int64_t
soffset
;
int64_t
soffset
;
}
SProjectPhysiNode
;
}
SProjectPhysiNode
;
typedef
struct
SIndefRowsFuncPhysiNode
{
SPhysiNode
node
;
SNodeList
*
pExprs
;
SNodeList
*
pVectorFuncs
;
}
SIndefRowsFuncPhysiNode
;
typedef
struct
SJoinPhysiNode
{
typedef
struct
SJoinPhysiNode
{
SPhysiNode
node
;
SPhysiNode
node
;
EJoinType
joinType
;
EJoinType
joinType
;
...
...
include/libs/qcom/query.h
浏览文件 @
4560b8f2
...
@@ -224,7 +224,7 @@ extern int32_t (*queryProcessMsgRsp[TDMT_MAX])(void* output, char* msg, int32_t
...
@@ -224,7 +224,7 @@ extern int32_t (*queryProcessMsgRsp[TDMT_MAX])(void* output, char* msg, int32_t
#define NEED_SCHEDULER_RETRY_ERROR(_code) \
#define NEED_SCHEDULER_RETRY_ERROR(_code) \
((_code) == TSDB_CODE_RPC_REDIRECT || (_code) == TSDB_CODE_RPC_NETWORK_UNAVAIL || (_code) == TSDB_CODE_SCH_TIMEOUT_ERROR)
((_code) == TSDB_CODE_RPC_REDIRECT || (_code) == TSDB_CODE_RPC_NETWORK_UNAVAIL || (_code) == TSDB_CODE_SCH_TIMEOUT_ERROR)
#define REQUEST_
MAX_TRY_TIMES 1
#define REQUEST_
TOTAL_EXEC_TIMES 2
#define qFatal(...) \
#define qFatal(...) \
do { \
do { \
...
...
include/libs/stream/tstream.h
浏览文件 @
4560b8f2
...
@@ -24,8 +24,8 @@
...
@@ -24,8 +24,8 @@
extern
"C"
{
extern
"C"
{
#endif
#endif
#ifndef _
T
STREAM_H_
#ifndef _STREAM_H_
#define _
T
STREAM_H_
#define _STREAM_H_
typedef
struct
SStreamTask
SStreamTask
;
typedef
struct
SStreamTask
SStreamTask
;
...
@@ -39,6 +39,7 @@ enum {
...
@@ -39,6 +39,7 @@ enum {
TASK_INPUT_STATUS__NORMAL
=
1
,
TASK_INPUT_STATUS__NORMAL
=
1
,
TASK_INPUT_STATUS__BLOCKED
,
TASK_INPUT_STATUS__BLOCKED
,
TASK_INPUT_STATUS__RECOVER
,
TASK_INPUT_STATUS__RECOVER
,
TASK_INPUT_STATUS__PROCESSING
,
TASK_INPUT_STATUS__STOP
,
TASK_INPUT_STATUS__STOP
,
TASK_INPUT_STATUS__FAILED
,
TASK_INPUT_STATUS__FAILED
,
};
};
...
@@ -60,6 +61,10 @@ enum {
...
@@ -60,6 +61,10 @@ enum {
STREAM_INPUT__CHECKPOINT
,
STREAM_INPUT__CHECKPOINT
,
};
};
typedef
struct
{
int8_t
type
;
}
SStreamQueueItem
;
typedef
struct
{
typedef
struct
{
int8_t
type
;
int8_t
type
;
int64_t
ver
;
int64_t
ver
;
...
@@ -80,55 +85,51 @@ typedef struct {
...
@@ -80,55 +85,51 @@ typedef struct {
int8_t
type
;
int8_t
type
;
}
SStreamCheckpoint
;
}
SStreamCheckpoint
;
enum
{
STREAM_QUEUE__SUCESS
=
1
,
STREAM_QUEUE__FAILED
,
STREAM_QUEUE__PROCESSING
,
};
typedef
struct
{
typedef
struct
{
STaosQueue
*
queue
;
STaosQueue
*
queue
;
STaosQall
*
qall
;
STaosQall
*
qall
;
void
*
qItem
;
void
*
qItem
;
int8_t
failed
;
int8_t
status
;
}
SStreamQ
;
}
SStreamQ
ueue
;
static
FORCE_INLINE
void
*
streamQCurItem
(
SStreamQ
*
queue
)
{
SStreamQueue
*
streamQueueOpen
();
//
void
streamQueueClose
(
SStreamQueue
*
queue
);
return
queue
->
qItem
;
static
FORCE_INLINE
void
streamQueueProcessSuccess
(
SStreamQueue
*
queue
)
{
ASSERT
(
atomic_load_8
(
&
queue
->
status
)
==
STREAM_QUEUE__PROCESSING
);
queue
->
qItem
=
NULL
;
atomic_store_8
(
&
queue
->
status
,
STREAM_QUEUE__SUCESS
);
}
}
static
FORCE_INLINE
void
*
streamQNextItem
(
SStreamQ
*
queue
)
{
static
FORCE_INLINE
void
streamQueueProcessFail
(
SStreamQueue
*
queue
)
{
int8_t
failed
=
atomic_load_8
(
&
queue
->
failed
);
ASSERT
(
atomic_load_8
(
&
queue
->
status
)
==
STREAM_QUEUE__PROCESSING
);
if
(
failed
)
{
atomic_store_8
(
&
queue
->
status
,
STREAM_QUEUE__FAILED
);
}
static
FORCE_INLINE
void
*
streamQueueCurItem
(
SStreamQueue
*
queue
)
{
return
queue
->
qItem
;
}
static
FORCE_INLINE
void
*
streamQueueNextItem
(
SStreamQueue
*
queue
)
{
int8_t
dequeueFlag
=
atomic_exchange_8
(
&
queue
->
status
,
STREAM_QUEUE__PROCESSING
);
if
(
dequeueFlag
==
STREAM_QUEUE__FAILED
)
{
ASSERT
(
queue
->
qItem
!=
NULL
);
ASSERT
(
queue
->
qItem
!=
NULL
);
return
streamQCurItem
(
queue
);
return
streamQ
ueue
CurItem
(
queue
);
}
else
{
}
else
{
taosGetQitem
(
queue
->
qall
,
&
queue
->
qItem
);
taosGetQitem
(
queue
->
qall
,
&
queue
->
qItem
);
if
(
queue
->
qItem
==
NULL
)
{
if
(
queue
->
qItem
==
NULL
)
{
taosReadAllQitems
(
queue
->
queue
,
queue
->
qall
);
taosReadAllQitems
(
queue
->
queue
,
queue
->
qall
);
taosGetQitem
(
queue
->
qall
,
&
queue
->
qItem
);
taosGetQitem
(
queue
->
qall
,
&
queue
->
qItem
);
}
}
return
streamQCurItem
(
queue
);
return
streamQ
ueue
CurItem
(
queue
);
}
}
}
}
static
FORCE_INLINE
void
streamQSetFail
(
SStreamQ
*
queue
)
{
atomic_store_8
(
&
queue
->
failed
,
1
);
}
SStreamDataSubmit
*
streamDataSubmitNew
(
SSubmitReq
*
pReq
);
static
FORCE_INLINE
void
streamQSetSuccess
(
SStreamQ
*
queue
)
{
atomic_store_8
(
&
queue
->
failed
,
0
);
}
static
FORCE_INLINE
SStreamDataSubmit
*
streamDataSubmitNew
(
SSubmitReq
*
pReq
)
{
SStreamDataSubmit
*
pDataSubmit
=
(
SStreamDataSubmit
*
)
taosAllocateQitem
(
sizeof
(
SStreamDataSubmit
),
DEF_QITEM
);
if
(
pDataSubmit
==
NULL
)
return
NULL
;
pDataSubmit
->
dataRef
=
(
int32_t
*
)
taosMemoryMalloc
(
sizeof
(
int32_t
));
if
(
pDataSubmit
->
dataRef
==
NULL
)
goto
FAIL
;
pDataSubmit
->
data
=
pReq
;
*
pDataSubmit
->
dataRef
=
1
;
pDataSubmit
->
type
=
STREAM_INPUT__DATA_SUBMIT
;
return
pDataSubmit
;
FAIL:
taosFreeQitem
(
pDataSubmit
);
return
NULL
;
}
static
FORCE_INLINE
void
streamDataSubmitRefInc
(
SStreamDataSubmit
*
pDataSubmit
)
{
//
atomic_add_fetch_32
(
pDataSubmit
->
dataRef
,
1
);
}
static
FORCE_INLINE
void
streamDataSubmitRefDec
(
SStreamDataSubmit
*
pDataSubmit
)
{
static
FORCE_INLINE
void
streamDataSubmitRefDec
(
SStreamDataSubmit
*
pDataSubmit
)
{
int32_t
ref
=
atomic_sub_fetch_32
(
pDataSubmit
->
dataRef
,
1
);
int32_t
ref
=
atomic_sub_fetch_32
(
pDataSubmit
->
dataRef
,
1
);
...
@@ -141,9 +142,31 @@ static FORCE_INLINE void streamDataSubmitRefDec(SStreamDataSubmit* pDataSubmit)
...
@@ -141,9 +142,31 @@ static FORCE_INLINE void streamDataSubmitRefDec(SStreamDataSubmit* pDataSubmit)
SStreamDataSubmit
*
streamSubmitRefClone
(
SStreamDataSubmit
*
pSubmit
);
SStreamDataSubmit
*
streamSubmitRefClone
(
SStreamDataSubmit
*
pSubmit
);
#if 0
int32_t streamDataBlockEncode(void** buf, const SStreamDataBlock* pOutput);
int32_t streamDataBlockEncode(void** buf, const SStreamDataBlock* pOutput);
void* streamDataBlockDecode(const void* buf, SStreamDataBlock* pInput);
void* streamDataBlockDecode(const void* buf, SStreamDataBlock* pInput);
static FORCE_INLINE int32_t streamEnqueue1(SStreamQueue* queue, SStreamQueueItem* pItem) {
int8_t inputStatus = atomic_load_8(&queue->enqueueStatus);
if (inputStatus == TASK_INPUT_STATUS__NORMAL) {
if (pItem->type == STREAM_INPUT__DATA_SUBMIT) {
SStreamDataSubmit* pSubmitClone = streamSubmitRefClone((SStreamDataSubmit*)pItem);
if (pSubmitClone == NULL) {
atomic_store_8(&queue->enqueueStatus, TASK_INPUT_STATUS__FAILED);
return -1;
}
taosWriteQitem(queue->queue, pSubmitClone);
} else if (pItem->type == STREAM_INPUT__DATA_BLOCK) {
taosWriteQitem(queue->queue, pItem);
} else if (pItem->type == STREAM_INPUT__CHECKPOINT) {
taosWriteQitem(queue->queue, pItem);
}
return 0;
}
return 0;
}
#endif
typedef
struct
{
typedef
struct
{
int8_t
parallelizable
;
int8_t
parallelizable
;
char
*
qmsg
;
char
*
qmsg
;
...
@@ -236,13 +259,17 @@ struct SStreamTask {
...
@@ -236,13 +259,17 @@ struct SStreamTask {
int8_t
dispatchType
;
int8_t
dispatchType
;
int16_t
dispatchMsgType
;
int16_t
dispatchMsgType
;
// node info
int32_t
childId
;
int32_t
nodeId
;
int32_t
nodeId
;
SEpSet
epSet
;
SEpSet
epSet
;
// exec
// exec
STaskExec
exec
;
STaskExec
exec
;
// local sink
// TODO: merge sink and dispatch
// local sink
union
{
union
{
STaskSinkTb
tbSink
;
STaskSinkTb
tbSink
;
STaskSinkSma
smaSink
;
STaskSinkSma
smaSink
;
...
@@ -258,25 +285,61 @@ struct SStreamTask {
...
@@ -258,25 +285,61 @@ struct SStreamTask {
int8_t
inputStatus
;
int8_t
inputStatus
;
int8_t
outputStatus
;
int8_t
outputStatus
;
#if 0
STaosQueue* inputQ;
STaosQueue* inputQ;
STaosQall* inputQAll;
STaosQall* inputQAll;
STaosQueue* outputQ;
STaosQueue* outputQ;
STaosQall* outputQAll;
STaosQall* outputQAll;
#endif
SStreamQueue
*
inputQueue
;
SStreamQueue
*
outputQueue
;
// application storage
// application storage
void
*
ahandle
;
void
*
ahandle
;
};
};
SStreamTask
*
tNewSStreamTask
(
int64_t
streamId
);
SStreamTask
*
tNewSStreamTask
(
int64_t
streamId
,
int32_t
childId
);
int32_t
tEncodeSStreamTask
(
SEncoder
*
pEncoder
,
const
SStreamTask
*
pTask
);
int32_t
tEncodeSStreamTask
(
SEncoder
*
pEncoder
,
const
SStreamTask
*
pTask
);
int32_t
tDecodeSStreamTask
(
SDecoder
*
pDecoder
,
SStreamTask
*
pTask
);
int32_t
tDecodeSStreamTask
(
SDecoder
*
pDecoder
,
SStreamTask
*
pTask
);
void
tFreeSStreamTask
(
SStreamTask
*
pTask
);
void
tFreeSStreamTask
(
SStreamTask
*
pTask
);
typedef
struct
{
static
FORCE_INLINE
int32_t
streamTaskInput
(
SStreamTask
*
pTask
,
SStreamQueueItem
*
pItem
)
{
// SMsgHead head;
while
(
1
)
{
SStreamTask
*
task
;
int8_t
inputStatus
=
}
SStreamTaskDeployReq
;
atomic_val_compare_exchange_8
(
&
pTask
->
inputStatus
,
TASK_INPUT_STATUS__NORMAL
,
TASK_INPUT_STATUS__PROCESSING
);
if
(
inputStatus
==
TASK_INPUT_STATUS__NORMAL
)
{
break
;
}
ASSERT
(
0
);
}
if
(
pItem
->
type
==
STREAM_INPUT__DATA_SUBMIT
)
{
SStreamDataSubmit
*
pSubmitClone
=
streamSubmitRefClone
((
SStreamDataSubmit
*
)
pItem
);
if
(
pSubmitClone
==
NULL
)
{
atomic_store_8
(
&
pTask
->
inputStatus
,
TASK_INPUT_STATUS__FAILED
);
return
-
1
;
}
taosWriteQitem
(
pTask
->
inputQueue
->
queue
,
pSubmitClone
);
}
else
if
(
pItem
->
type
==
STREAM_INPUT__DATA_BLOCK
)
{
taosWriteQitem
(
pTask
->
inputQueue
->
queue
,
pItem
);
}
else
if
(
pItem
->
type
==
STREAM_INPUT__CHECKPOINT
)
{
taosWriteQitem
(
pTask
->
inputQueue
->
queue
,
pItem
);
}
// TODO: back pressure
atomic_store_8
(
&
pTask
->
inputStatus
,
TASK_INPUT_STATUS__NORMAL
);
return
0
;
}
static
FORCE_INLINE
void
streamTaskInputFail
(
SStreamTask
*
pTask
)
{
atomic_store_8
(
&
pTask
->
inputStatus
,
TASK_INPUT_STATUS__FAILED
);
}
static
FORCE_INLINE
int32_t
streamTaskOutput
(
SStreamTask
*
pTask
,
SStreamDataBlock
*
pBlock
)
{
taosWriteQitem
(
pTask
->
outputQueue
->
queue
,
pBlock
);
return
0
;
}
typedef
struct
{
typedef
struct
{
int32_t
reserved
;
int32_t
reserved
;
...
@@ -289,6 +352,11 @@ typedef struct {
...
@@ -289,6 +352,11 @@ typedef struct {
SArray
*
data
;
// SArray<SSDataBlock>
SArray
*
data
;
// SArray<SSDataBlock>
}
SStreamTaskExecReq
;
}
SStreamTaskExecReq
;
typedef
struct
{
// SMsgHead head;
SStreamTask
*
task
;
}
SStreamTaskDeployReq
;
int32_t
tEncodeSStreamTaskExecReq
(
void
**
buf
,
const
SStreamTaskExecReq
*
pReq
);
int32_t
tEncodeSStreamTaskExecReq
(
void
**
buf
,
const
SStreamTaskExecReq
*
pReq
);
void
*
tDecodeSStreamTaskExecReq
(
const
void
*
buf
,
SStreamTaskExecReq
*
pReq
);
void
*
tDecodeSStreamTaskExecReq
(
const
void
*
buf
,
SStreamTaskExecReq
*
pReq
);
void
tFreeSStreamTaskExecReq
(
SStreamTaskExecReq
*
pReq
);
void
tFreeSStreamTaskExecReq
(
SStreamTaskExecReq
*
pReq
);
...
@@ -297,6 +365,12 @@ typedef struct {
...
@@ -297,6 +365,12 @@ typedef struct {
int32_t
reserved
;
int32_t
reserved
;
}
SStreamTaskExecRsp
;
}
SStreamTaskExecRsp
;
typedef
struct
{
SMsgHead
head
;
int64_t
streamId
;
int32_t
taskId
;
}
SStreamTaskRunReq
;
typedef
struct
{
typedef
struct
{
// SMsgHead head;
// SMsgHead head;
int64_t
streamId
;
int64_t
streamId
;
...
@@ -304,21 +378,18 @@ typedef struct {
...
@@ -304,21 +378,18 @@ typedef struct {
SArray
*
res
;
// SArray<SSDataBlock>
SArray
*
res
;
// SArray<SSDataBlock>
}
SStreamSinkReq
;
}
SStreamSinkReq
;
typedef
struct
{
SMsgHead
head
;
int64_t
streamId
;
int32_t
taskId
;
}
SStreamTaskRunReq
;
typedef
struct
{
typedef
struct
{
int64_t
streamId
;
int64_t
streamId
;
int32_t
taskId
;
int32_t
taskId
;
int32_t
sourceTaskId
;
int32_t
sourceTaskId
;
int32_t
sourceVg
;
int32_t
sourceVg
;
int32_t
sourceChildId
;
#if 0
#if 0
int64_t sourceVer;
int64_t sourceVer;
#endif
#endif
SArray
*
data
;
// SArray<SSDataBlock>
int32_t
blockNum
;
SArray
*
dataLen
;
// SArray<int32_t>
SArray
*
data
;
// SArray<SRetrieveTableRsp*>
}
SStreamDispatchReq
;
}
SStreamDispatchReq
;
typedef
struct
{
typedef
struct
{
...
@@ -340,6 +411,8 @@ typedef struct {
...
@@ -340,6 +411,8 @@ typedef struct {
int8_t
inputStatus
;
int8_t
inputStatus
;
}
SStreamTaskRecoverRsp
;
}
SStreamTaskRecoverRsp
;
int32_t
streamTriggerByWrite
(
SStreamTask
*
pTask
,
int32_t
vgId
,
SMsgCb
*
pMsgCb
);
int32_t
streamEnqueueDataSubmit
(
SStreamTask
*
pTask
,
SStreamDataSubmit
*
input
);
int32_t
streamEnqueueDataSubmit
(
SStreamTask
*
pTask
,
SStreamDataSubmit
*
input
);
int32_t
streamEnqueueDataBlk
(
SStreamTask
*
pTask
,
SStreamDataBlock
*
input
);
int32_t
streamEnqueueDataBlk
(
SStreamTask
*
pTask
,
SStreamDataBlock
*
input
);
int32_t
streamDequeueOutput
(
SStreamTask
*
pTask
,
void
**
output
);
int32_t
streamDequeueOutput
(
SStreamTask
*
pTask
,
void
**
output
);
...
@@ -356,4 +429,4 @@ int32_t streamProcessRecoverRsp(SStreamTask* pTask, SStreamTaskRecoverRsp* pRsp)
...
@@ -356,4 +429,4 @@ int32_t streamProcessRecoverRsp(SStreamTask* pTask, SStreamTaskRecoverRsp* pRsp)
}
}
#endif
#endif
#endif
/* ifndef _
T
STREAM_H_ */
#endif
/* ifndef _STREAM_H_ */
include/util/taoserror.h
浏览文件 @
4560b8f2
...
@@ -219,6 +219,7 @@ int32_t* taosGetErrno();
...
@@ -219,6 +219,7 @@ int32_t* taosGetErrno();
#define TSDB_CODE_MND_VGROUP_NOT_IN_DNODE TAOS_DEF_ERROR_CODE(0, 0x0391)
#define TSDB_CODE_MND_VGROUP_NOT_IN_DNODE TAOS_DEF_ERROR_CODE(0, 0x0391)
#define TSDB_CODE_MND_VGROUP_ALREADY_IN_DNODE TAOS_DEF_ERROR_CODE(0, 0x0392)
#define TSDB_CODE_MND_VGROUP_ALREADY_IN_DNODE TAOS_DEF_ERROR_CODE(0, 0x0392)
#define TSDB_CODE_MND_VGROUP_UN_CHANGED TAOS_DEF_ERROR_CODE(0, 0x0393)
#define TSDB_CODE_MND_VGROUP_UN_CHANGED TAOS_DEF_ERROR_CODE(0, 0x0393)
#define TSDB_CODE_MND_HAS_OFFLINE_DNODE TAOS_DEF_ERROR_CODE(0, 0x0394)
// mnode-stable
// mnode-stable
#define TSDB_CODE_MND_STB_ALREADY_EXIST TAOS_DEF_ERROR_CODE(0, 0x03A0)
#define TSDB_CODE_MND_STB_ALREADY_EXIST TAOS_DEF_ERROR_CODE(0, 0x03A0)
...
...
source/client/inc/clientInt.h
浏览文件 @
4560b8f2
...
@@ -212,6 +212,9 @@ typedef struct SRequestObj {
...
@@ -212,6 +212,9 @@ typedef struct SRequestObj {
SArray
*
tableList
;
SArray
*
tableList
;
SQueryExecMetric
metric
;
SQueryExecMetric
metric
;
SRequestSendRecvBody
body
;
SRequestSendRecvBody
body
;
uint32_t
prevCode
;
//previous error code: todo refactor, add update flag for catalog
uint32_t
retry
;
}
SRequestObj
;
}
SRequestObj
;
typedef
struct
SSyncQueryParam
{
typedef
struct
SSyncQueryParam
{
...
@@ -263,8 +266,8 @@ extern SAppInfo appInfo;
...
@@ -263,8 +266,8 @@ extern SAppInfo appInfo;
extern
int32_t
clientReqRefPool
;
extern
int32_t
clientReqRefPool
;
extern
int32_t
clientConnRefPool
;
extern
int32_t
clientConnRefPool
;
extern
int
(
*
handleRequestRspFp
[
TDMT_MAX
])(
void
*
,
const
SDataBuf
*
pMsg
,
int32_t
cod
e
);
__async_send_cb_fn_t
getMsgRspHandle
(
int32_t
msgTyp
e
);
int
genericRspCallback
(
void
*
param
,
const
SDataBuf
*
pMsg
,
int32_t
code
);
SMsgSendInfo
*
buildMsgInfoImpl
(
SRequestObj
*
pReqObj
);
SMsgSendInfo
*
buildMsgInfoImpl
(
SRequestObj
*
pReqObj
);
void
*
createTscObj
(
const
char
*
user
,
const
char
*
auth
,
const
char
*
db
,
int32_t
connType
,
SAppInstInfo
*
pAppInfo
);
void
*
createTscObj
(
const
char
*
user
,
const
char
*
auth
,
const
char
*
db
,
int32_t
connType
,
SAppInstInfo
*
pAppInfo
);
...
@@ -274,7 +277,7 @@ int32_t releaseTscObj(int64_t rid);
...
@@ -274,7 +277,7 @@ int32_t releaseTscObj(int64_t rid);
uint64_t
generateRequestId
();
uint64_t
generateRequestId
();
void
*
createRequest
(
STscObj
*
pObj
,
void
*
param
,
int32_t
type
);
void
*
createRequest
(
STscObj
*
pObj
,
int32_t
type
);
void
destroyRequest
(
SRequestObj
*
pRequest
);
void
destroyRequest
(
SRequestObj
*
pRequest
);
SRequestObj
*
acquireRequest
(
int64_t
rid
);
SRequestObj
*
acquireRequest
(
int64_t
rid
);
int32_t
releaseRequest
(
int64_t
rid
);
int32_t
releaseRequest
(
int64_t
rid
);
...
@@ -290,8 +293,6 @@ void* openTransporter(const char* user, const char* auth, int32_t numOfThreads);
...
@@ -290,8 +293,6 @@ void* openTransporter(const char* user, const char* auth, int32_t numOfThreads);
bool
persistConnForSpecificMsg
(
void
*
parenct
,
tmsg_t
msgType
);
bool
persistConnForSpecificMsg
(
void
*
parenct
,
tmsg_t
msgType
);
void
processMsgFromServer
(
void
*
parent
,
SRpcMsg
*
pMsg
,
SEpSet
*
pEpSet
);
void
processMsgFromServer
(
void
*
parent
,
SRpcMsg
*
pMsg
,
SEpSet
*
pEpSet
);
void
initMsgHandleFp
();
TAOS
*
taos_connect_internal
(
const
char
*
ip
,
const
char
*
user
,
const
char
*
pass
,
const
char
*
auth
,
const
char
*
db
,
TAOS
*
taos_connect_internal
(
const
char
*
ip
,
const
char
*
user
,
const
char
*
pass
,
const
char
*
auth
,
const
char
*
db
,
uint16_t
port
,
int
connType
);
uint16_t
port
,
int
connType
);
...
@@ -325,6 +326,9 @@ int32_t scheduleQuery(SRequestObj* pRequest, SQueryPlan* pDag, SArray* pNod
...
@@ -325,6 +326,9 @@ int32_t scheduleQuery(SRequestObj* pRequest, SQueryPlan* pDag, SArray* pNod
void
launchAsyncQuery
(
SRequestObj
*
pRequest
,
SQuery
*
pQuery
);
void
launchAsyncQuery
(
SRequestObj
*
pRequest
,
SQuery
*
pQuery
);
int32_t
refreshMeta
(
STscObj
*
pTscObj
,
SRequestObj
*
pRequest
);
int32_t
refreshMeta
(
STscObj
*
pTscObj
,
SRequestObj
*
pRequest
);
int32_t
updateQnodeList
(
SAppInstInfo
*
pInfo
,
SArray
*
pNodeList
);
int32_t
updateQnodeList
(
SAppInstInfo
*
pInfo
,
SArray
*
pNodeList
);
void
doAsyncQuery
(
SRequestObj
*
pRequest
,
bool
forceUpdateMeta
);
int32_t
removeMeta
(
STscObj
*
pTscObj
,
SArray
*
tbList
);
// todo move to clientImpl.c and become a static function
int32_t
handleAlterTbExecRes
(
void
*
res
,
struct
SCatalog
*
pCatalog
);
// todo move to xxx
#ifdef __cplusplus
#ifdef __cplusplus
}
}
...
...
source/client/src/clientEnv.c
浏览文件 @
4560b8f2
...
@@ -177,7 +177,7 @@ STscObj *acquireTscObj(int64_t rid) { return (STscObj *)taosAcquireRef(clientCon
...
@@ -177,7 +177,7 @@ STscObj *acquireTscObj(int64_t rid) { return (STscObj *)taosAcquireRef(clientCon
int32_t
releaseTscObj
(
int64_t
rid
)
{
return
taosReleaseRef
(
clientConnRefPool
,
rid
);
}
int32_t
releaseTscObj
(
int64_t
rid
)
{
return
taosReleaseRef
(
clientConnRefPool
,
rid
);
}
void
*
createRequest
(
STscObj
*
pObj
,
void
*
param
,
int32_t
type
)
{
void
*
createRequest
(
STscObj
*
pObj
,
int32_t
type
)
{
assert
(
pObj
!=
NULL
);
assert
(
pObj
!=
NULL
);
SRequestObj
*
pRequest
=
(
SRequestObj
*
)
taosMemoryCalloc
(
1
,
sizeof
(
SRequestObj
));
SRequestObj
*
pRequest
=
(
SRequestObj
*
)
taosMemoryCalloc
(
1
,
sizeof
(
SRequestObj
));
...
@@ -191,8 +191,6 @@ void *createRequest(STscObj *pObj, void *param, int32_t type) {
...
@@ -191,8 +191,6 @@ void *createRequest(STscObj *pObj, void *param, int32_t type) {
pRequest
->
requestId
=
generateRequestId
();
pRequest
->
requestId
=
generateRequestId
();
pRequest
->
metric
.
start
=
taosGetTimestampUs
();
pRequest
->
metric
.
start
=
taosGetTimestampUs
();
pRequest
->
body
.
param
=
param
;
pRequest
->
type
=
type
;
pRequest
->
type
=
type
;
pRequest
->
pTscObj
=
pObj
;
pRequest
->
pTscObj
=
pObj
;
pRequest
->
msgBuf
=
taosMemoryCalloc
(
1
,
ERROR_MSG_BUF_DEFAULT_SIZE
);
pRequest
->
msgBuf
=
taosMemoryCalloc
(
1
,
ERROR_MSG_BUF_DEFAULT_SIZE
);
...
@@ -280,7 +278,6 @@ void taos_init_imp(void) {
...
@@ -280,7 +278,6 @@ void taos_init_imp(void) {
return
;
return
;
}
}
initMsgHandleFp
();
initQueryModuleMsgHandle
();
initQueryModuleMsgHandle
();
rpcInit
();
rpcInit
();
...
...
source/client/src/clientImpl.c
浏览文件 @
4560b8f2
...
@@ -133,7 +133,7 @@ TAOS* taos_connect_internal(const char* ip, const char* user, const char* pass,
...
@@ -133,7 +133,7 @@ TAOS* taos_connect_internal(const char* ip, const char* user, const char* pass,
}
}
int32_t
buildRequest
(
STscObj
*
pTscObj
,
const
char
*
sql
,
int
sqlLen
,
SRequestObj
**
pRequest
)
{
int32_t
buildRequest
(
STscObj
*
pTscObj
,
const
char
*
sql
,
int
sqlLen
,
SRequestObj
**
pRequest
)
{
*
pRequest
=
createRequest
(
pTscObj
,
NULL
,
TSDB_SQL_SELECT
);
*
pRequest
=
createRequest
(
pTscObj
,
TSDB_SQL_SELECT
);
if
(
*
pRequest
==
NULL
)
{
if
(
*
pRequest
==
NULL
)
{
tscError
(
"failed to malloc sqlObj"
);
tscError
(
"failed to malloc sqlObj"
);
return
TSDB_CODE_TSC_OUT_OF_MEMORY
;
return
TSDB_CODE_TSC_OUT_OF_MEMORY
;
...
@@ -207,6 +207,7 @@ int32_t execLocalCmd(SRequestObj* pRequest, SQuery* pQuery) {
...
@@ -207,6 +207,7 @@ int32_t execLocalCmd(SRequestObj* pRequest, SQuery* pQuery) {
if
(
TSDB_CODE_SUCCESS
==
code
&&
NULL
!=
pRsp
)
{
if
(
TSDB_CODE_SUCCESS
==
code
&&
NULL
!=
pRsp
)
{
code
=
setQueryResultFromRsp
(
&
pRequest
->
body
.
resInfo
,
pRsp
,
false
,
false
);
code
=
setQueryResultFromRsp
(
&
pRequest
->
body
.
resInfo
,
pRsp
,
false
,
false
);
}
}
return
code
;
return
code
;
}
}
...
@@ -235,6 +236,31 @@ static SAppInstInfo* getAppInfo(SRequestObj* pRequest) {
...
@@ -235,6 +236,31 @@ static SAppInstInfo* getAppInfo(SRequestObj* pRequest) {
return
pRequest
->
pTscObj
->
pAppInfo
;
return
pRequest
->
pTscObj
->
pAppInfo
;
}
}
void
asyncExecLocalCmd
(
SRequestObj
*
pRequest
,
SQuery
*
pQuery
)
{
SRetrieveTableRsp
*
pRsp
=
NULL
;
int32_t
code
=
qExecCommand
(
pQuery
->
pRoot
,
&
pRsp
);
if
(
TSDB_CODE_SUCCESS
==
code
&&
NULL
!=
pRsp
)
{
code
=
setQueryResultFromRsp
(
&
pRequest
->
body
.
resInfo
,
pRsp
,
false
,
false
);
}
SReqResultInfo
*
pResultInfo
=
&
pRequest
->
body
.
resInfo
;
if
(
pRequest
->
code
!=
TSDB_CODE_SUCCESS
)
{
pResultInfo
->
numOfRows
=
0
;
pRequest
->
code
=
code
;
tscError
(
"0x%"
PRIx64
" fetch results failed, code:%s, reqId:0x%"
PRIx64
,
pRequest
->
self
,
tstrerror
(
code
),
pRequest
->
requestId
);
}
else
{
tscDebug
(
"0x%"
PRIx64
" fetch results, numOfRows:%d total Rows:%"
PRId64
", complete:%d, reqId:0x%"
PRIx64
,
pRequest
->
self
,
pResultInfo
->
numOfRows
,
pResultInfo
->
totalRows
,
pResultInfo
->
completed
,
pRequest
->
requestId
);
}
pRequest
->
body
.
queryFp
(
pRequest
->
body
.
param
,
pRequest
,
0
);
// pRequest->body.fetchFp(pRequest->body.param, pRequest, pResultInfo->numOfRows);
}
int32_t
asyncExecDdlQuery
(
SRequestObj
*
pRequest
,
SQuery
*
pQuery
)
{
int32_t
asyncExecDdlQuery
(
SRequestObj
*
pRequest
,
SQuery
*
pQuery
)
{
// drop table if exists not_exists_table
// drop table if exists not_exists_table
if
(
NULL
==
pQuery
->
pCmdMsg
)
{
if
(
NULL
==
pQuery
->
pCmdMsg
)
{
...
@@ -509,19 +535,20 @@ int32_t handleAlterTbExecRes(void* res, SCatalog* pCatalog) {
...
@@ -509,19 +535,20 @@ int32_t handleAlterTbExecRes(void* res, SCatalog* pCatalog) {
return
catalogUpdateTableMeta
(
pCatalog
,
(
STableMetaRsp
*
)
res
);
return
catalogUpdateTableMeta
(
pCatalog
,
(
STableMetaRsp
*
)
res
);
}
}
int32_t
handle
ExecRes
(
SRequestObj
*
pRequest
)
{
int32_t
handle
QueryExecRsp
(
SRequestObj
*
pRequest
)
{
if
(
NULL
==
pRequest
->
body
.
resInfo
.
execRes
.
res
)
{
if
(
NULL
==
pRequest
->
body
.
resInfo
.
execRes
.
res
)
{
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
int32_t
code
=
0
;
SCatalog
*
pCatalog
=
NULL
;
SCatalog
*
pCatalog
=
NULL
;
code
=
catalogGetHandle
(
pRequest
->
pTscObj
->
pAppInfo
->
clusterId
,
&
pCatalog
);
SAppInstInfo
*
pAppInfo
=
getAppInfo
(
pRequest
);
int32_t
code
=
catalogGetHandle
(
pAppInfo
->
clusterId
,
&
pCatalog
);
if
(
code
)
{
if
(
code
)
{
return
code
;
return
code
;
}
}
SEpSet
epset
=
getEpSet_s
(
&
p
Request
->
pTscObj
->
p
AppInfo
->
mgmtEp
);
SEpSet
epset
=
getEpSet_s
(
&
pAppInfo
->
mgmtEp
);
SQueryExecRes
*
pRes
=
&
pRequest
->
body
.
resInfo
.
execRes
;
SQueryExecRes
*
pRes
=
&
pRequest
->
body
.
resInfo
.
execRes
;
switch
(
pRes
->
msgType
)
{
switch
(
pRes
->
msgType
)
{
...
@@ -539,8 +566,9 @@ int32_t handleExecRes(SRequestObj* pRequest) {
...
@@ -539,8 +566,9 @@ int32_t handleExecRes(SRequestObj* pRequest) {
break
;
break
;
}
}
default:
default:
tscError
(
"invalid exec result for request type %d"
,
pRequest
->
type
);
tscError
(
"0x%"
PRIx64
", invalid exec result for request type %d, reqId:0x%"
PRIx64
,
pRequest
->
self
,
return
TSDB_CODE_APP_ERROR
;
pRequest
->
type
,
pRequest
->
requestId
);
code
=
TSDB_CODE_APP_ERROR
;
}
}
return
code
;
return
code
;
...
@@ -548,6 +576,25 @@ int32_t handleExecRes(SRequestObj* pRequest) {
...
@@ -548,6 +576,25 @@ int32_t handleExecRes(SRequestObj* pRequest) {
void
schedulerExecCb
(
SQueryResult
*
pResult
,
void
*
param
,
int32_t
code
)
{
void
schedulerExecCb
(
SQueryResult
*
pResult
,
void
*
param
,
int32_t
code
)
{
SRequestObj
*
pRequest
=
(
SRequestObj
*
)
param
;
SRequestObj
*
pRequest
=
(
SRequestObj
*
)
param
;
pRequest
->
code
=
code
;
STscObj
*
pTscObj
=
pRequest
->
pTscObj
;
if
(
code
!=
TSDB_CODE_SUCCESS
&&
NEED_CLIENT_HANDLE_ERROR
(
code
))
{
tscDebug
(
"0x%"
PRIx64
" client retry to handle the error, code:%s, reqId:0x%"
PRIx64
,
pRequest
->
self
,
tstrerror
(
code
),
pRequest
->
requestId
);
pRequest
->
prevCode
=
code
;
doAsyncQuery
(
pRequest
,
true
);
return
;
}
if
(
code
==
TSDB_CODE_SUCCESS
)
{
code
=
handleQueryExecRsp
(
pRequest
);
ASSERT
(
pRequest
->
code
==
TSDB_CODE_SUCCESS
);
pRequest
->
code
=
code
;
}
if
(
NEED_CLIENT_RM_TBLMETA_REQ
(
pRequest
->
type
))
{
removeMeta
(
pTscObj
,
pRequest
->
tableList
);
}
// return to client
// return to client
pRequest
->
body
.
queryFp
(
pRequest
->
body
.
param
,
pRequest
,
code
);
pRequest
->
body
.
queryFp
(
pRequest
->
body
.
param
,
pRequest
,
code
);
...
@@ -583,7 +630,7 @@ SRequestObj* launchQueryImpl(SRequestObj* pRequest, SQuery* pQuery, bool keepQue
...
@@ -583,7 +630,7 @@ SRequestObj* launchQueryImpl(SRequestObj* pRequest, SQuery* pQuery, bool keepQue
qDestroyQuery
(
pQuery
);
qDestroyQuery
(
pQuery
);
}
}
handle
ExecRes
(
pRequest
);
handle
QueryExecRsp
(
pRequest
);
if
(
NULL
!=
pRequest
&&
TSDB_CODE_SUCCESS
!=
code
)
{
if
(
NULL
!=
pRequest
&&
TSDB_CODE_SUCCESS
!=
code
)
{
pRequest
->
code
=
terrno
;
pRequest
->
code
=
terrno
;
...
@@ -617,13 +664,12 @@ SRequestObj* launchQuery(STscObj* pTscObj, const char* sql, int sqlLen) {
...
@@ -617,13 +664,12 @@ SRequestObj* launchQuery(STscObj* pTscObj, const char* sql, int sqlLen) {
}
}
void
launchAsyncQuery
(
SRequestObj
*
pRequest
,
SQuery
*
pQuery
)
{
void
launchAsyncQuery
(
SRequestObj
*
pRequest
,
SQuery
*
pQuery
)
{
void
*
pRes
=
NULL
;
int32_t
code
=
0
;
int32_t
code
=
0
;
switch
(
pQuery
->
execMode
)
{
switch
(
pQuery
->
execMode
)
{
case
QUERY_EXEC_MODE_LOCAL
:
case
QUERY_EXEC_MODE_LOCAL
:
code
=
e
xecLocalCmd
(
pRequest
,
pQuery
);
asyncE
xecLocalCmd
(
pRequest
,
pQuery
);
break
;
return
;
case
QUERY_EXEC_MODE_RPC
:
case
QUERY_EXEC_MODE_RPC
:
code
=
asyncExecDdlQuery
(
pRequest
,
pQuery
);
code
=
asyncExecDdlQuery
(
pRequest
,
pQuery
);
break
;
break
;
...
@@ -649,11 +695,9 @@ void launchAsyncQuery(SRequestObj* pRequest, SQuery* pQuery) {
...
@@ -649,11 +695,9 @@ void launchAsyncQuery(SRequestObj* pRequest, SQuery* pQuery) {
if
(
TSDB_CODE_SUCCESS
==
code
)
{
if
(
TSDB_CODE_SUCCESS
==
code
)
{
schedulerAsyncExecJob
(
pAppInfo
->
pTransporter
,
pNodeList
,
pRequest
->
body
.
pDag
,
&
pRequest
->
body
.
queryJob
,
schedulerAsyncExecJob
(
pAppInfo
->
pTransporter
,
pNodeList
,
pRequest
->
body
.
pDag
,
&
pRequest
->
body
.
queryJob
,
pRequest
->
sqlstr
,
pRequest
->
metric
.
start
,
schedulerExecCb
,
pRequest
);
pRequest
->
sqlstr
,
pRequest
->
metric
.
start
,
schedulerExecCb
,
pRequest
);
// if (NULL != pRes) {
// code = validateSversion(pRequest, pRes);
// }
}
}
//todo not to be released here
taosArrayDestroy
(
pNodeList
);
taosArrayDestroy
(
pNodeList
);
break
;
break
;
}
}
...
@@ -671,12 +715,6 @@ void launchAsyncQuery(SRequestObj* pRequest, SQuery* pQuery) {
...
@@ -671,12 +715,6 @@ void launchAsyncQuery(SRequestObj* pRequest, SQuery* pQuery) {
if
(
NULL
!=
pRequest
&&
TSDB_CODE_SUCCESS
!=
code
)
{
if
(
NULL
!=
pRequest
&&
TSDB_CODE_SUCCESS
!=
code
)
{
pRequest
->
code
=
terrno
;
pRequest
->
code
=
terrno
;
}
}
// if (res) {
// *res = pRes;
// } else {
// freeRequestRes(pRequest, pRes);
// pRes = NULL;
}
}
int32_t
refreshMeta
(
STscObj
*
pTscObj
,
SRequestObj
*
pRequest
)
{
int32_t
refreshMeta
(
STscObj
*
pTscObj
,
SRequestObj
*
pRequest
)
{
...
@@ -750,7 +788,7 @@ SRequestObj* execQuery(STscObj* pTscObj, const char* sql, int sqlLen) {
...
@@ -750,7 +788,7 @@ SRequestObj* execQuery(STscObj* pTscObj, const char* sql, int sqlLen) {
pRequest
->
code
=
code
;
pRequest
->
code
=
code
;
break
;
break
;
}
}
}
while
(
retryNum
++
<
REQUEST_
MAX_TRY
_TIMES
);
}
while
(
retryNum
++
<
REQUEST_
TOTAL_EXEC
_TIMES
);
if
(
NEED_CLIENT_RM_TBLMETA_REQ
(
pRequest
->
type
))
{
if
(
NEED_CLIENT_RM_TBLMETA_REQ
(
pRequest
->
type
))
{
removeMeta
(
pTscObj
,
pRequest
->
tableList
);
removeMeta
(
pTscObj
,
pRequest
->
tableList
);
...
@@ -808,7 +846,7 @@ STscObj* taosConnectImpl(const char* user, const char* auth, const char* db, __t
...
@@ -808,7 +846,7 @@ STscObj* taosConnectImpl(const char* user, const char* auth, const char* db, __t
return
pTscObj
;
return
pTscObj
;
}
}
SRequestObj
*
pRequest
=
createRequest
(
pTscObj
,
param
,
TDMT_MND_CONNECT
);
SRequestObj
*
pRequest
=
createRequest
(
pTscObj
,
TDMT_MND_CONNECT
);
if
(
pRequest
==
NULL
)
{
if
(
pRequest
==
NULL
)
{
destroyTscObj
(
pTscObj
);
destroyTscObj
(
pTscObj
);
terrno
=
TSDB_CODE_TSC_OUT_OF_MEMORY
;
terrno
=
TSDB_CODE_TSC_OUT_OF_MEMORY
;
...
@@ -850,7 +888,7 @@ static SMsgSendInfo* buildConnectMsg(SRequestObj* pRequest) {
...
@@ -850,7 +888,7 @@ static SMsgSendInfo* buildConnectMsg(SRequestObj* pRequest) {
pMsgSendInfo
->
requestObjRefId
=
pRequest
->
self
;
pMsgSendInfo
->
requestObjRefId
=
pRequest
->
self
;
pMsgSendInfo
->
requestId
=
pRequest
->
requestId
;
pMsgSendInfo
->
requestId
=
pRequest
->
requestId
;
pMsgSendInfo
->
fp
=
handleRequestRspFp
[
TMSG_INDEX
(
pMsgSendInfo
->
msgType
)]
;
pMsgSendInfo
->
fp
=
getMsgRspHandle
(
pMsgSendInfo
->
msgType
)
;
pMsgSendInfo
->
param
=
pRequest
;
pMsgSendInfo
->
param
=
pRequest
;
SConnectReq
connectReq
=
{
0
};
SConnectReq
connectReq
=
{
0
};
...
@@ -1429,7 +1467,7 @@ TSDB_SERVER_STATUS taos_check_server_status(const char* fqdn, int port, char* de
...
@@ -1429,7 +1467,7 @@ TSDB_SERVER_STATUS taos_check_server_status(const char* fqdn, int port, char* de
}
}
code
=
statusRsp
.
statusCode
;
code
=
statusRsp
.
statusCode
;
if
(
details
!=
NULL
&&
statusRsp
.
details
!=
NULL
)
{
if
(
details
!=
NULL
)
{
tstrncpy
(
details
,
statusRsp
.
details
,
maxlen
);
tstrncpy
(
details
,
statusRsp
.
details
,
maxlen
);
}
}
...
...
source/client/src/clientMain.c
浏览文件 @
4560b8f2
...
@@ -30,6 +30,7 @@
...
@@ -30,6 +30,7 @@
#define TSC_VAR_RELEASED 0
#define TSC_VAR_RELEASED 0
static
int32_t
sentinel
=
TSC_VAR_NOT_RELEASE
;
static
int32_t
sentinel
=
TSC_VAR_NOT_RELEASE
;
static
int32_t
createParseContext
(
const
SRequestObj
*
pRequest
,
SParseContext
**
pCxt
);
int
taos_options
(
TSDB_OPTION
option
,
const
void
*
arg
,
...)
{
int
taos_options
(
TSDB_OPTION
option
,
const
void
*
arg
,
...)
{
static
int32_t
lock
=
0
;
static
int32_t
lock
=
0
;
...
@@ -192,7 +193,7 @@ TAOS_RES *taos_query(TAOS *taos, const char *sql) {
...
@@ -192,7 +193,7 @@ TAOS_RES *taos_query(TAOS *taos, const char *sql) {
STscObj
*
pTscObj
=
(
STscObj
*
)
taos
;
STscObj
*
pTscObj
=
(
STscObj
*
)
taos
;
#if SYNC_ON_TOP_OF_ASYNC
#if SYNC_ON_TOP_OF_ASYNC
SSyncQueryParam
*
param
=
taosMemoryCalloc
(
1
,
sizeof
(
struct
SSyncQueryParam
));
SSyncQueryParam
*
param
=
taosMemoryCalloc
(
1
,
sizeof
(
SSyncQueryParam
));
tsem_init
(
&
param
->
sem
,
0
,
0
);
tsem_init
(
&
param
->
sem
,
0
,
0
);
taos_query_a
(
pTscObj
,
sql
,
syncQueryFn
,
param
);
taos_query_a
(
pTscObj
,
sql
,
syncQueryFn
,
param
);
...
@@ -608,36 +609,38 @@ void retrieveMetaCallback(SMetaData* pResultMeta, void* param, int32_t code) {
...
@@ -608,36 +609,38 @@ void retrieveMetaCallback(SMetaData* pResultMeta, void* param, int32_t code) {
SQuery
*
pQuery
=
pWrapper
->
pQuery
;
SQuery
*
pQuery
=
pWrapper
->
pQuery
;
SRequestObj
*
pRequest
=
pWrapper
->
pRequest
;
SRequestObj
*
pRequest
=
pWrapper
->
pRequest
;
if
(
code
!
=
TSDB_CODE_SUCCESS
)
{
if
(
code
=
=
TSDB_CODE_SUCCESS
)
{
goto
_error
;
code
=
qAnalyseSqlSemantic
(
pWrapper
->
pCtx
,
&
pWrapper
->
catalogReq
,
pResultMeta
,
pQuery
)
;
}
}
code
=
qAnalyseSqlSemantic
(
pWrapper
->
pCtx
,
&
pWrapper
->
catalogReq
,
pResultMeta
,
pQuery
);
if
(
code
==
TSDB_CODE_SUCCESS
)
{
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
if
(
pQuery
->
haveResultSet
)
{
goto
_error
;
setResSchemaInfo
(
&
pRequest
->
body
.
resInfo
,
pQuery
->
pResSchema
,
pQuery
->
numOfResCols
);
}
setResPrecision
(
&
pRequest
->
body
.
resInfo
,
pQuery
->
precision
);
}
if
(
pQuery
->
haveResultSet
)
{
setResSchemaInfo
(
&
pRequest
->
body
.
resInfo
,
pQuery
->
pResSchema
,
(
pQuery
)
->
numOfResCols
);
setResPrecision
(
&
pRequest
->
body
.
resInfo
,
(
pQuery
)
->
precision
);
}
TSWAP
(
pRequest
->
dbList
,
(
pQuery
)
->
pDbList
);
TSWAP
(
pRequest
->
dbList
,
(
pQuery
)
->
pDbList
);
TSWAP
(
pRequest
->
tableList
,
(
pQuery
)
->
pTableList
);
TSWAP
(
pRequest
->
tableList
,
(
pQuery
)
->
pTableList
);
taosMemoryFree
(
pWrapper
);
taosMemoryFree
(
pWrapper
);
launchAsyncQuery
(
pRequest
,
pQuery
);
launchAsyncQuery
(
pRequest
,
pQuery
);
return
;
}
else
{
if
(
NEED_CLIENT_HANDLE_ERROR
(
code
))
{
tscDebug
(
"0x%"
PRIx64
" client retry to handle the error, code:%s, reqId:0x%"
PRIx64
,
pRequest
->
self
,
tstrerror
(
code
),
pRequest
->
requestId
);
pRequest
->
prevCode
=
code
;
doAsyncQuery
(
pRequest
,
true
);
return
;
}
_error:
// return to app directly
taosMemoryFree
(
pWrapper
);
taosMemoryFree
(
pWrapper
);
tscError
(
"0x%"
PRIx64
" error occurs, code:%s, return to user app, reqId:%"
PRIx64
,
pRequest
->
self
,
tstrerror
(
code
),
tscError
(
"0x%"
PRIx64
" error occurs, code:%s, return to user app, reqId:0x%"
PRIx64
,
pRequest
->
self
,
tstrerror
(
code
),
pRequest
->
requestId
);
pRequest
->
requestId
);
pRequest
->
code
=
code
;
pRequest
->
code
=
code
;
pRequest
->
body
.
queryFp
(
pRequest
->
body
.
param
,
pRequest
,
code
);
pRequest
->
body
.
queryFp
(
pRequest
->
body
.
param
,
pRequest
,
code
);
}
}
}
// todo add retry before return user's callback
void
taos_query_a
(
TAOS
*
taos
,
const
char
*
sql
,
__taos_async_fn_t
fp
,
void
*
param
)
{
void
taos_query_a
(
TAOS
*
taos
,
const
char
*
sql
,
__taos_async_fn_t
fp
,
void
*
param
)
{
ASSERT
(
fp
!=
NULL
);
ASSERT
(
fp
!=
NULL
);
...
@@ -657,24 +660,27 @@ void taos_query_a(TAOS *taos, const char *sql, __taos_async_fn_t fp, void *param
...
@@ -657,24 +660,27 @@ void taos_query_a(TAOS *taos, const char *sql, __taos_async_fn_t fp, void *param
}
}
SRequestObj
*
pRequest
=
NULL
;
SRequestObj
*
pRequest
=
NULL
;
int32_t
retryNum
=
0
;
int32_t
code
=
buildRequest
(
taos
,
sql
,
sqlLen
,
&
pRequest
);
int32_t
code
=
0
;
// while (retryNum++ < REQUEST_MAX_TRY_TIMES) {
code
=
buildRequest
(
taos
,
sql
,
sqlLen
,
&
pRequest
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
terrno
=
code
;
terrno
=
code
;
fp
(
param
,
NULL
,
code
);
fp
(
param
,
NULL
,
terrno
);
return
;
return
;
}
}
pRequest
->
body
.
queryFp
=
fp
;
pRequest
->
body
.
queryFp
=
fp
;
pRequest
->
body
.
param
=
param
;
pRequest
->
body
.
param
=
param
;
doAsyncQuery
(
pRequest
,
false
);
}
STscObj
*
pTscObj
=
pRequest
->
pTscObj
;
int32_t
createParseContext
(
const
SRequestObj
*
pRequest
,
SParseContext
**
pCxt
)
{
const
STscObj
*
pTscObj
=
pRequest
->
pTscObj
;
*
pCxt
=
taosMemoryCalloc
(
1
,
sizeof
(
SParseContext
));
if
(
*
pCxt
==
NULL
)
{
return
TSDB_CODE_OUT_OF_MEMORY
;
}
SParseContext
*
pCxt
=
taosMemoryCalloc
(
1
,
sizeof
(
SParseContext
));
**
pCxt
=
(
SParseContext
){.
requestId
=
pRequest
->
requestId
,
*
pCxt
=
(
SParseContext
){.
requestId
=
pRequest
->
requestId
,
.
acctId
=
pTscObj
->
acctId
,
.
acctId
=
pTscObj
->
acctId
,
.
db
=
pRequest
->
pDb
,
.
db
=
pRequest
->
pDb
,
.
topicQuery
=
false
,
.
topicQuery
=
false
,
...
@@ -687,6 +693,22 @@ void taos_query_a(TAOS *taos, const char *sql, __taos_async_fn_t fp, void *param
...
@@ -687,6 +693,22 @@ void taos_query_a(TAOS *taos, const char *sql, __taos_async_fn_t fp, void *param
.
pUser
=
pTscObj
->
user
,
.
pUser
=
pTscObj
->
user
,
.
isSuperUser
=
(
0
==
strcmp
(
pTscObj
->
user
,
TSDB_DEFAULT_USER
)),
.
isSuperUser
=
(
0
==
strcmp
(
pTscObj
->
user
,
TSDB_DEFAULT_USER
)),
.
async
=
true
,};
.
async
=
true
,};
return
TSDB_CODE_SUCCESS
;
}
void
doAsyncQuery
(
SRequestObj
*
pRequest
,
bool
updateMetaForce
)
{
SParseContext
*
pCxt
=
NULL
;
STscObj
*
pTscObj
=
pRequest
->
pTscObj
;
if
(
pRequest
->
retry
++
>
REQUEST_TOTAL_EXEC_TIMES
)
{
pRequest
->
code
=
pRequest
->
prevCode
;
goto
_error
;
}
int32_t
code
=
createParseContext
(
pRequest
,
&
pCxt
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
goto
_error
;
}
pCxt
->
mgmtEpSet
=
getEpSet_s
(
&
pTscObj
->
pAppInfo
->
mgmtEp
);
pCxt
->
mgmtEpSet
=
getEpSet_s
(
&
pTscObj
->
pAppInfo
->
mgmtEp
);
code
=
catalogGetHandle
(
pTscObj
->
pAppInfo
->
clusterId
,
&
pCxt
->
pCatalog
);
code
=
catalogGetHandle
(
pTscObj
->
pAppInfo
->
clusterId
,
&
pCxt
->
pCatalog
);
...
@@ -694,39 +716,36 @@ void taos_query_a(TAOS *taos, const char *sql, __taos_async_fn_t fp, void *param
...
@@ -694,39 +716,36 @@ void taos_query_a(TAOS *taos, const char *sql, __taos_async_fn_t fp, void *param
goto
_error
;
goto
_error
;
}
}
SQuery
*
pQuery
=
NULL
;
SQuery
*
pQuery
=
NULL
;
SCatalogReq
catalogReq
=
{
0
};
SCatalogReq
catalogReq
=
{.
forceUpdate
=
updateMetaForce
};
code
=
qParseSqlSyntax
(
pCxt
,
&
pQuery
,
&
catalogReq
);
code
=
qParseSqlSyntax
(
pCxt
,
&
pQuery
,
&
catalogReq
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
goto
_error
;
goto
_error
;
}
}
SqlParseWrapper
*
pWrapper
=
taosMemoryCalloc
(
1
,
sizeof
(
SqlParseWrapper
));
SqlParseWrapper
*
pWrapper
=
taosMemoryCalloc
(
1
,
sizeof
(
SqlParseWrapper
));
if
(
pWrapper
==
NULL
)
{
code
=
TSDB_CODE_OUT_OF_MEMORY
;
goto
_error
;
}
pWrapper
->
pCtx
=
pCxt
;
pWrapper
->
pCtx
=
pCxt
;
pWrapper
->
pQuery
=
pQuery
;
pWrapper
->
pQuery
=
pQuery
;
pWrapper
->
pRequest
=
pRequest
;
pWrapper
->
pRequest
=
pRequest
;
pWrapper
->
catalogReq
=
catalogReq
;
pWrapper
->
catalogReq
=
catalogReq
;
code
=
catalogAsyncGetAllMeta
(
pCxt
->
pCatalog
,
pCxt
->
pTransporter
,
&
pCxt
->
mgmtEpSet
,
pRequest
->
requestId
,
code
=
catalogAsyncGetAllMeta
(
pCxt
->
pCatalog
,
pCxt
->
pTransporter
,
&
pCxt
->
mgmtEpSet
,
pRequest
->
requestId
,
&
catalogReq
,
retrieveMetaCallback
,
pWrapper
,
&
pRequest
->
body
.
queryJob
);
&
catalogReq
,
retrieveMetaCallback
,
pWrapper
,
&
pRequest
->
body
.
queryJob
);
if
(
code
==
TSDB_CODE_SUCCESS
)
{
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
return
;
goto
_error
;
}
}
return
;
// todo handle the retry process
// if (TSDB_CODE_SUCCESS == code || NEED_CLIENT_HANDLE_ERROR(code)) {
// TSWAP(pRequest->dbList, (pQuery)->pDbList);
// TSWAP(pRequest->tableList, (pQuery)->pTableList);
// }
_error:
_error:
tscError
(
"0x%"
PRIx64
" error happens, code:%s, reqId:0x%"
PRIx64
,
pRequest
->
self
,
tstrerror
(
code
),
pRequest
->
requestId
);
terrno
=
code
;
terrno
=
code
;
pRequest
->
code
=
code
;
pRequest
->
code
=
code
;
fp
(
param
,
pRequest
,
code
);
pRequest
->
body
.
queryFp
(
pRequest
->
body
.
param
,
pRequest
,
code
);
}
}
static
void
fetchCallback
(
void
*
pResult
,
void
*
param
,
int32_t
code
)
{
static
void
fetchCallback
(
void
*
pResult
,
void
*
param
,
int32_t
code
)
{
...
@@ -751,14 +770,15 @@ static void fetchCallback(void* pResult, void* param, int32_t code) {
...
@@ -751,14 +770,15 @@ static void fetchCallback(void* pResult, void* param, int32_t code) {
pRequest
->
code
=
setQueryResultFromRsp
(
&
pRequest
->
body
.
resInfo
,
(
SRetrieveTableRsp
*
)
pResultInfo
->
pData
,
true
,
false
);
pRequest
->
code
=
setQueryResultFromRsp
(
&
pRequest
->
body
.
resInfo
,
(
SRetrieveTableRsp
*
)
pResultInfo
->
pData
,
true
,
false
);
if
(
pRequest
->
code
!=
TSDB_CODE_SUCCESS
)
{
if
(
pRequest
->
code
!=
TSDB_CODE_SUCCESS
)
{
pResultInfo
->
numOfRows
=
0
;
pResultInfo
->
numOfRows
=
0
;
pRequest
->
code
=
code
;
pRequest
->
code
=
code
;
pRequest
->
body
.
fetchFp
(
pRequest
->
body
.
param
,
pRequest
,
0
);
tscError
(
"0x%"
PRIx64
" fetch results failed, code:%s, reqId:0x%"
PRIx64
,
pRequest
->
self
,
tstrerror
(
code
),
pRequest
->
requestId
);
}
else
{
tscDebug
(
"0x%"
PRIx64
" fetch results, numOfRows:%d total Rows:%"
PRId64
", complete:%d, reqId:0x%"
PRIx64
,
pRequest
->
self
,
pResultInfo
->
numOfRows
,
pResultInfo
->
totalRows
,
pResultInfo
->
completed
,
pRequest
->
requestId
);
}
}
tscDebug
(
"0x%"
PRIx64
" fetch results, numOfRows:%d total Rows:%"
PRId64
", complete:%d, reqId:0x%"
PRIx64
,
pRequest
->
self
,
pResultInfo
->
numOfRows
,
pResultInfo
->
totalRows
,
pResultInfo
->
completed
,
pRequest
->
requestId
);
pRequest
->
body
.
fetchFp
(
pRequest
->
body
.
param
,
pRequest
,
pResultInfo
->
numOfRows
);
pRequest
->
body
.
fetchFp
(
pRequest
->
body
.
param
,
pRequest
,
pResultInfo
->
numOfRows
);
}
}
...
...
source/client/src/clientMsgHandler.c
浏览文件 @
4560b8f2
...
@@ -21,8 +21,6 @@
...
@@ -21,8 +21,6 @@
#include "tdef.h"
#include "tdef.h"
#include "tname.h"
#include "tname.h"
int32_t
(
*
handleRequestRspFp
[
TDMT_MAX
])(
void
*
,
const
SDataBuf
*
pMsg
,
int32_t
code
);
static
void
setErrno
(
SRequestObj
*
pRequest
,
int32_t
code
)
{
static
void
setErrno
(
SRequestObj
*
pRequest
,
int32_t
code
)
{
pRequest
->
code
=
code
;
pRequest
->
code
=
code
;
terrno
=
code
;
terrno
=
code
;
...
@@ -107,10 +105,7 @@ SMsgSendInfo* buildMsgInfoImpl(SRequestObj* pRequest) {
...
@@ -107,10 +105,7 @@ SMsgSendInfo* buildMsgInfoImpl(SRequestObj* pRequest) {
assert
(
pRequest
!=
NULL
);
assert
(
pRequest
!=
NULL
);
pMsgSendInfo
->
msgInfo
=
pRequest
->
body
.
requestMsg
;
pMsgSendInfo
->
msgInfo
=
pRequest
->
body
.
requestMsg
;
pMsgSendInfo
->
fp
=
getMsgRspHandle
(
pRequest
->
type
);
pMsgSendInfo
->
fp
=
(
handleRequestRspFp
[
TMSG_INDEX
(
pRequest
->
type
)]
==
NULL
)
?
genericRspCallback
:
handleRequestRspFp
[
TMSG_INDEX
(
pRequest
->
type
)];
return
pMsgSendInfo
;
return
pMsgSendInfo
;
}
}
...
@@ -209,7 +204,7 @@ int32_t processUseDbRsp(void* param, const SDataBuf* pMsg, int32_t code) {
...
@@ -209,7 +204,7 @@ int32_t processUseDbRsp(void* param, const SDataBuf* pMsg, int32_t code) {
return
0
;
return
0
;
}
}
int32_t
processCreateTableRsp
(
void
*
param
,
const
SDataBuf
*
pMsg
,
int32_t
code
)
{
int32_t
processCreate
S
TableRsp
(
void
*
param
,
const
SDataBuf
*
pMsg
,
int32_t
code
)
{
assert
(
pMsg
!=
NULL
&&
param
!=
NULL
);
assert
(
pMsg
!=
NULL
&&
param
!=
NULL
);
SRequestObj
*
pRequest
=
param
;
SRequestObj
*
pRequest
=
param
;
...
@@ -219,6 +214,7 @@ int32_t processCreateTableRsp(void* param, const SDataBuf* pMsg, int32_t code) {
...
@@ -219,6 +214,7 @@ int32_t processCreateTableRsp(void* param, const SDataBuf* pMsg, int32_t code) {
}
}
if
(
pRequest
->
body
.
queryFp
!=
NULL
)
{
if
(
pRequest
->
body
.
queryFp
!=
NULL
)
{
removeMeta
(
pRequest
->
pTscObj
,
pRequest
->
tableList
);
pRequest
->
body
.
queryFp
(
pRequest
->
body
.
param
,
pRequest
,
code
);
pRequest
->
body
.
queryFp
(
pRequest
->
body
.
param
,
pRequest
,
code
);
}
else
{
}
else
{
tsem_post
(
&
pRequest
->
body
.
rspSem
);
tsem_post
(
&
pRequest
->
body
.
rspSem
);
...
@@ -251,30 +247,54 @@ int32_t processAlterStbRsp(void* param, const SDataBuf* pMsg, int32_t code) {
...
@@ -251,30 +247,54 @@ int32_t processAlterStbRsp(void* param, const SDataBuf* pMsg, int32_t code) {
SRequestObj
*
pRequest
=
param
;
SRequestObj
*
pRequest
=
param
;
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
setErrno
(
pRequest
,
code
);
setErrno
(
pRequest
,
code
);
tsem_post
(
&
pRequest
->
body
.
rspSem
);
}
else
{
return
code
;
SMAlterStbRsp
alterRsp
=
{
0
};
SDecoder
coder
=
{
0
};
tDecoderInit
(
&
coder
,
pMsg
->
pData
,
pMsg
->
len
);
tDecodeSMAlterStbRsp
(
&
coder
,
&
alterRsp
);
tDecoderClear
(
&
coder
);
pRequest
->
body
.
resInfo
.
execRes
.
msgType
=
TDMT_MND_ALTER_STB
;
pRequest
->
body
.
resInfo
.
execRes
.
res
=
alterRsp
.
pMeta
;
}
}
SMAlterStbRsp
alterRsp
=
{
0
};
if
(
pRequest
->
body
.
queryFp
!=
NULL
)
{
SDecoder
coder
=
{
0
};
SQueryExecRes
*
pRes
=
&
pRequest
->
body
.
resInfo
.
execRes
;
tDecoderInit
(
&
coder
,
pMsg
->
pData
,
pMsg
->
len
);
tDecodeSMAlterStbRsp
(
&
coder
,
&
alterRsp
);
tDecoderClear
(
&
coder
);
pRequest
->
body
.
resInfo
.
execRes
.
msgType
=
TDMT_MND_ALTER_STB
;
if
(
code
==
TSDB_CODE_SUCCESS
)
{
pRequest
->
body
.
resInfo
.
execRes
.
res
=
alterRsp
.
pMeta
;
SCatalog
*
pCatalog
=
NULL
;
int32_t
ret
=
catalogGetHandle
(
pRequest
->
pTscObj
->
pAppInfo
->
clusterId
,
&
pCatalog
);
if
(
pRes
->
res
!=
NULL
)
{
ret
=
handleAlterTbExecRes
(
pRes
->
res
,
pCatalog
);
}
tsem_post
(
&
pRequest
->
body
.
rspSem
);
if
(
ret
!=
TSDB_CODE_SUCCESS
)
{
code
=
ret
;
}
}
pRequest
->
body
.
queryFp
(
pRequest
->
body
.
param
,
pRequest
,
code
);
}
else
{
tsem_post
(
&
pRequest
->
body
.
rspSem
);
}
return
code
;
return
code
;
}
}
__async_send_cb_fn_t
getMsgRspHandle
(
int32_t
msgType
)
{
// todo refactor: this arraylist is too large
switch
(
msgType
)
{
void
initMsgHandleFp
()
{
case
TDMT_MND_CONNECT
:
handleRequestRspFp
[
TMSG_INDEX
(
TDMT_MND_CONNECT
)]
=
processConnectRsp
;
return
processConnectRsp
;
handleRequestRspFp
[
TMSG_INDEX
(
TDMT_MND_CREATE_DB
)]
=
processCreateDbRsp
;
case
TDMT_MND_CREATE_DB
:
handleRequestRspFp
[
TMSG_INDEX
(
TDMT_MND_USE_DB
)]
=
processUseDbRsp
;
return
processCreateDbRsp
;
handleRequestRspFp
[
TMSG_INDEX
(
TDMT_MND_CREATE_STB
)]
=
processCreateTableRsp
;
case
TDMT_MND_USE_DB
:
handleRequestRspFp
[
TMSG_INDEX
(
TDMT_MND_DROP_DB
)]
=
processDropDbRsp
;
return
processUseDbRsp
;
handleRequestRspFp
[
TMSG_INDEX
(
TDMT_MND_ALTER_STB
)]
=
processAlterStbRsp
;
case
TDMT_MND_CREATE_STB
:
return
processCreateSTableRsp
;
case
TDMT_MND_DROP_DB
:
return
processDropDbRsp
;
case
TDMT_MND_ALTER_STB
:
return
processAlterStbRsp
;
default:
return
genericRspCallback
;
}
}
}
source/client/src/clientSml.c
浏览文件 @
4560b8f2
...
@@ -2364,7 +2364,7 @@ static int32_t isSchemalessDb(SSmlHandle* info){
...
@@ -2364,7 +2364,7 @@ static int32_t isSchemalessDb(SSmlHandle* info){
*/
*/
TAOS_RES
*
taos_schemaless_insert
(
TAOS
*
taos
,
char
*
lines
[],
int
numLines
,
int
protocol
,
int
precision
)
{
TAOS_RES
*
taos_schemaless_insert
(
TAOS
*
taos
,
char
*
lines
[],
int
numLines
,
int
protocol
,
int
precision
)
{
SRequestObj
*
request
=
(
SRequestObj
*
)
createRequest
((
STscObj
*
)
taos
,
NULL
,
TSDB_SQL_INSERT
);
SRequestObj
*
request
=
(
SRequestObj
*
)
createRequest
((
STscObj
*
)
taos
,
TSDB_SQL_INSERT
);
if
(
!
request
){
if
(
!
request
){
uError
(
"SML:taos_schemaless_insert error request is null"
);
uError
(
"SML:taos_schemaless_insert error request is null"
);
return
NULL
;
return
NULL
;
...
...
source/client/test/clientTests.cpp
浏览文件 @
4560b8f2
...
@@ -778,7 +778,35 @@ TEST(testCase, async_api_test) {
...
@@ -778,7 +778,35 @@ TEST(testCase, async_api_test) {
TAOS
*
pConn
=
taos_connect
(
"localhost"
,
"root"
,
"taosdata"
,
NULL
,
0
);
TAOS
*
pConn
=
taos_connect
(
"localhost"
,
"root"
,
"taosdata"
,
NULL
,
0
);
ASSERT_NE
(
pConn
,
nullptr
);
ASSERT_NE
(
pConn
,
nullptr
);
taos_query_a
(
pConn
,
"drop table test.tm0"
,
queryCallback
,
pConn
);
taos_query
(
pConn
,
"use test"
);
TAOS_RES
*
pRes
=
taos_query
(
pConn
,
"select * from t1"
);
taos_query
(
pConn
,
"alter table t1 add column b int"
);
pRes
=
taos_query
(
pConn
,
"insert into t1 values(now, 1, 2)"
);
if
(
taos_errno
(
pRes
)
!=
0
)
{
printf
(
"failed, reason:%s
\n
"
,
taos_errstr
(
pRes
));
}
// int32_t n = 0;
// TAOS_ROW pRow = NULL;
// TAOS_FIELD* pFields = taos_fetch_fields(pRes);
// int32_t numOfFields = taos_num_fields(pRes);
//
// char str[512] = {0};
// while ((pRow = taos_fetch_row(pRes)) != NULL) {
// int32_t* length = taos_fetch_lengths(pRes);
// for(int32_t i = 0; i < numOfFields; ++i) {
// printf("(%d):%d " , i, length[i]);
// }
// printf("\n");
//
// int32_t code = taos_print_row(str, pRow, pFields, numOfFields);
// printf("%s\n", str);
// memset(str, 0, sizeof(str));
// }
taos_query_a
(
pConn
,
"alter table test.m1 comment 'abcde' "
,
queryCallback
,
pConn
);
getchar
();
getchar
();
taos_close
(
pConn
);
taos_close
(
pConn
);
}
}
...
...
source/client/test/smlTest.cpp
浏览文件 @
4560b8f2
...
@@ -486,7 +486,7 @@ TEST(testCase, smlProcess_influx_Test) {
...
@@ -486,7 +486,7 @@ TEST(testCase, smlProcess_influx_Test) {
pRes
=
taos_query
(
taos
,
"use inflx_db"
);
pRes
=
taos_query
(
taos
,
"use inflx_db"
);
taos_free_result
(
pRes
);
taos_free_result
(
pRes
);
SRequestObj
*
request
=
(
SRequestObj
*
)
createRequest
((
STscObj
*
)
taos
,
NULL
,
TSDB_SQL_INSERT
);
SRequestObj
*
request
=
(
SRequestObj
*
)
createRequest
((
STscObj
*
)
taos
,
TSDB_SQL_INSERT
);
ASSERT_NE
(
request
,
nullptr
);
ASSERT_NE
(
request
,
nullptr
);
SSmlHandle
*
info
=
smlBuildSmlInfo
(
taos
,
request
,
TSDB_SML_LINE_PROTOCOL
,
TSDB_SML_TIMESTAMP_NANO_SECONDS
);
SSmlHandle
*
info
=
smlBuildSmlInfo
(
taos
,
request
,
TSDB_SML_LINE_PROTOCOL
,
TSDB_SML_TIMESTAMP_NANO_SECONDS
);
...
@@ -607,7 +607,7 @@ TEST(testCase, smlParseLine_error_Test) {
...
@@ -607,7 +607,7 @@ TEST(testCase, smlParseLine_error_Test) {
pRes
=
taos_query
(
taos
,
"use sml_db"
);
pRes
=
taos_query
(
taos
,
"use sml_db"
);
taos_free_result
(
pRes
);
taos_free_result
(
pRes
);
SRequestObj
*
request
=
(
SRequestObj
*
)
createRequest
((
STscObj
*
)
taos
,
NULL
,
TSDB_SQL_INSERT
);
SRequestObj
*
request
=
(
SRequestObj
*
)
createRequest
((
STscObj
*
)
taos
,
TSDB_SQL_INSERT
);
ASSERT_NE
(
request
,
nullptr
);
ASSERT_NE
(
request
,
nullptr
);
SSmlHandle
*
info
=
smlBuildSmlInfo
(
taos
,
request
,
TSDB_SML_LINE_PROTOCOL
,
TSDB_SML_TIMESTAMP_NANO_SECONDS
);
SSmlHandle
*
info
=
smlBuildSmlInfo
(
taos
,
request
,
TSDB_SML_LINE_PROTOCOL
,
TSDB_SML_TIMESTAMP_NANO_SECONDS
);
...
@@ -656,7 +656,7 @@ TEST(testCase, smlProcess_telnet_Test) {
...
@@ -656,7 +656,7 @@ TEST(testCase, smlProcess_telnet_Test) {
pRes
=
taos_query
(
taos
,
"use telnet_db"
);
pRes
=
taos_query
(
taos
,
"use telnet_db"
);
taos_free_result
(
pRes
);
taos_free_result
(
pRes
);
SRequestObj
*
request
=
(
SRequestObj
*
)
createRequest
((
STscObj
*
)
taos
,
NULL
,
TSDB_SQL_INSERT
);
SRequestObj
*
request
=
(
SRequestObj
*
)
createRequest
((
STscObj
*
)
taos
,
TSDB_SQL_INSERT
);
ASSERT_NE
(
request
,
nullptr
);
ASSERT_NE
(
request
,
nullptr
);
SSmlHandle
*
info
=
smlBuildSmlInfo
(
taos
,
request
,
TSDB_SML_TELNET_PROTOCOL
,
TSDB_SML_TIMESTAMP_NANO_SECONDS
);
SSmlHandle
*
info
=
smlBuildSmlInfo
(
taos
,
request
,
TSDB_SML_TELNET_PROTOCOL
,
TSDB_SML_TIMESTAMP_NANO_SECONDS
);
...
@@ -710,7 +710,7 @@ TEST(testCase, smlProcess_json1_Test) {
...
@@ -710,7 +710,7 @@ TEST(testCase, smlProcess_json1_Test) {
pRes
=
taos_query
(
taos
,
"use json_db"
);
pRes
=
taos_query
(
taos
,
"use json_db"
);
taos_free_result
(
pRes
);
taos_free_result
(
pRes
);
SRequestObj
*
request
=
(
SRequestObj
*
)
createRequest
((
STscObj
*
)
taos
,
NULL
,
TSDB_SQL_INSERT
);
SRequestObj
*
request
=
(
SRequestObj
*
)
createRequest
((
STscObj
*
)
taos
,
TSDB_SQL_INSERT
);
ASSERT_NE
(
request
,
nullptr
);
ASSERT_NE
(
request
,
nullptr
);
SSmlHandle
*
info
=
smlBuildSmlInfo
(
taos
,
request
,
TSDB_SML_JSON_PROTOCOL
,
TSDB_SML_TIMESTAMP_NANO_SECONDS
);
SSmlHandle
*
info
=
smlBuildSmlInfo
(
taos
,
request
,
TSDB_SML_JSON_PROTOCOL
,
TSDB_SML_TIMESTAMP_NANO_SECONDS
);
...
@@ -779,7 +779,7 @@ TEST(testCase, smlProcess_json2_Test) {
...
@@ -779,7 +779,7 @@ TEST(testCase, smlProcess_json2_Test) {
pRes
=
taos_query
(
taos
,
"use sml_db"
);
pRes
=
taos_query
(
taos
,
"use sml_db"
);
taos_free_result
(
pRes
);
taos_free_result
(
pRes
);
SRequestObj
*
request
=
(
SRequestObj
*
)
createRequest
((
STscObj
*
)
taos
,
NULL
,
TSDB_SQL_INSERT
);
SRequestObj
*
request
=
(
SRequestObj
*
)
createRequest
((
STscObj
*
)
taos
,
TSDB_SQL_INSERT
);
ASSERT_NE
(
request
,
nullptr
);
ASSERT_NE
(
request
,
nullptr
);
SSmlHandle
*
info
=
smlBuildSmlInfo
(
taos
,
request
,
TSDB_SML_JSON_PROTOCOL
,
TSDB_SML_TIMESTAMP_NANO_SECONDS
);
SSmlHandle
*
info
=
smlBuildSmlInfo
(
taos
,
request
,
TSDB_SML_JSON_PROTOCOL
,
TSDB_SML_TIMESTAMP_NANO_SECONDS
);
...
@@ -823,7 +823,7 @@ TEST(testCase, smlProcess_json3_Test) {
...
@@ -823,7 +823,7 @@ TEST(testCase, smlProcess_json3_Test) {
pRes
=
taos_query
(
taos
,
"use sml_db"
);
pRes
=
taos_query
(
taos
,
"use sml_db"
);
taos_free_result
(
pRes
);
taos_free_result
(
pRes
);
SRequestObj
*
request
=
(
SRequestObj
*
)
createRequest
((
STscObj
*
)
taos
,
NULL
,
TSDB_SQL_INSERT
);
SRequestObj
*
request
=
(
SRequestObj
*
)
createRequest
((
STscObj
*
)
taos
,
TSDB_SQL_INSERT
);
ASSERT_NE
(
request
,
nullptr
);
ASSERT_NE
(
request
,
nullptr
);
SSmlHandle
*
info
=
smlBuildSmlInfo
(
taos
,
request
,
TSDB_SML_JSON_PROTOCOL
,
TSDB_SML_TIMESTAMP_NANO_SECONDS
);
SSmlHandle
*
info
=
smlBuildSmlInfo
(
taos
,
request
,
TSDB_SML_JSON_PROTOCOL
,
TSDB_SML_TIMESTAMP_NANO_SECONDS
);
...
@@ -895,7 +895,7 @@ TEST(testCase, smlProcess_json4_Test) {
...
@@ -895,7 +895,7 @@ TEST(testCase, smlProcess_json4_Test) {
pRes
=
taos_query
(
taos
,
"use sml_db"
);
pRes
=
taos_query
(
taos
,
"use sml_db"
);
taos_free_result
(
pRes
);
taos_free_result
(
pRes
);
SRequestObj
*
request
=
(
SRequestObj
*
)
createRequest
((
STscObj
*
)
taos
,
NULL
,
TSDB_SQL_INSERT
);
SRequestObj
*
request
=
(
SRequestObj
*
)
createRequest
((
STscObj
*
)
taos
,
TSDB_SQL_INSERT
);
ASSERT_NE
(
request
,
nullptr
);
ASSERT_NE
(
request
,
nullptr
);
SSmlHandle
*
info
=
smlBuildSmlInfo
(
taos
,
request
,
TSDB_SML_JSON_PROTOCOL
,
TSDB_SML_TIMESTAMP_NANO_SECONDS
);
SSmlHandle
*
info
=
smlBuildSmlInfo
(
taos
,
request
,
TSDB_SML_JSON_PROTOCOL
,
TSDB_SML_TIMESTAMP_NANO_SECONDS
);
...
@@ -957,7 +957,7 @@ TEST(testCase, smlParseTelnetLine_error_Test) {
...
@@ -957,7 +957,7 @@ TEST(testCase, smlParseTelnetLine_error_Test) {
pRes
=
taos_query
(
taos
,
"use sml_db"
);
pRes
=
taos_query
(
taos
,
"use sml_db"
);
taos_free_result
(
pRes
);
taos_free_result
(
pRes
);
SRequestObj
*
request
=
(
SRequestObj
*
)
createRequest
((
STscObj
*
)
taos
,
NULL
,
TSDB_SQL_INSERT
);
SRequestObj
*
request
=
(
SRequestObj
*
)
createRequest
((
STscObj
*
)
taos
,
TSDB_SQL_INSERT
);
ASSERT_NE
(
request
,
nullptr
);
ASSERT_NE
(
request
,
nullptr
);
SSmlHandle
*
info
=
smlBuildSmlInfo
(
taos
,
request
,
TSDB_SML_TELNET_PROTOCOL
,
TSDB_SML_TIMESTAMP_NANO_SECONDS
);
SSmlHandle
*
info
=
smlBuildSmlInfo
(
taos
,
request
,
TSDB_SML_TELNET_PROTOCOL
,
TSDB_SML_TIMESTAMP_NANO_SECONDS
);
...
@@ -1006,7 +1006,7 @@ TEST(testCase, smlParseTelnetLine_diff_type_Test) {
...
@@ -1006,7 +1006,7 @@ TEST(testCase, smlParseTelnetLine_diff_type_Test) {
pRes
=
taos_query
(
taos
,
"use sml_db"
);
pRes
=
taos_query
(
taos
,
"use sml_db"
);
taos_free_result
(
pRes
);
taos_free_result
(
pRes
);
SRequestObj
*
request
=
(
SRequestObj
*
)
createRequest
((
STscObj
*
)
taos
,
NULL
,
TSDB_SQL_INSERT
);
SRequestObj
*
request
=
(
SRequestObj
*
)
createRequest
((
STscObj
*
)
taos
,
TSDB_SQL_INSERT
);
ASSERT_NE
(
request
,
nullptr
);
ASSERT_NE
(
request
,
nullptr
);
SSmlHandle
*
info
=
smlBuildSmlInfo
(
taos
,
request
,
TSDB_SML_TELNET_PROTOCOL
,
TSDB_SML_TIMESTAMP_NANO_SECONDS
);
SSmlHandle
*
info
=
smlBuildSmlInfo
(
taos
,
request
,
TSDB_SML_TELNET_PROTOCOL
,
TSDB_SML_TIMESTAMP_NANO_SECONDS
);
...
@@ -1033,7 +1033,7 @@ TEST(testCase, smlParseTelnetLine_json_error_Test) {
...
@@ -1033,7 +1033,7 @@ TEST(testCase, smlParseTelnetLine_json_error_Test) {
pRes
=
taos_query
(
taos
,
"use sml_db"
);
pRes
=
taos_query
(
taos
,
"use sml_db"
);
taos_free_result
(
pRes
);
taos_free_result
(
pRes
);
SRequestObj
*
request
=
(
SRequestObj
*
)
createRequest
((
STscObj
*
)
taos
,
NULL
,
TSDB_SQL_INSERT
);
SRequestObj
*
request
=
(
SRequestObj
*
)
createRequest
((
STscObj
*
)
taos
,
TSDB_SQL_INSERT
);
ASSERT_NE
(
request
,
nullptr
);
ASSERT_NE
(
request
,
nullptr
);
SSmlHandle
*
info
=
smlBuildSmlInfo
(
taos
,
request
,
TSDB_SML_TELNET_PROTOCOL
,
TSDB_SML_TIMESTAMP_NANO_SECONDS
);
SSmlHandle
*
info
=
smlBuildSmlInfo
(
taos
,
request
,
TSDB_SML_TELNET_PROTOCOL
,
TSDB_SML_TIMESTAMP_NANO_SECONDS
);
...
@@ -1101,7 +1101,7 @@ TEST(testCase, smlParseTelnetLine_diff_json_type1_Test) {
...
@@ -1101,7 +1101,7 @@ TEST(testCase, smlParseTelnetLine_diff_json_type1_Test) {
pRes
=
taos_query
(
taos
,
"use sml_db"
);
pRes
=
taos_query
(
taos
,
"use sml_db"
);
taos_free_result
(
pRes
);
taos_free_result
(
pRes
);
SRequestObj
*
request
=
(
SRequestObj
*
)
createRequest
((
STscObj
*
)
taos
,
NULL
,
TSDB_SQL_INSERT
);
SRequestObj
*
request
=
(
SRequestObj
*
)
createRequest
((
STscObj
*
)
taos
,
TSDB_SQL_INSERT
);
ASSERT_NE
(
request
,
nullptr
);
ASSERT_NE
(
request
,
nullptr
);
SSmlHandle
*
info
=
smlBuildSmlInfo
(
taos
,
request
,
TSDB_SML_TELNET_PROTOCOL
,
TSDB_SML_TIMESTAMP_NANO_SECONDS
);
SSmlHandle
*
info
=
smlBuildSmlInfo
(
taos
,
request
,
TSDB_SML_TELNET_PROTOCOL
,
TSDB_SML_TIMESTAMP_NANO_SECONDS
);
...
@@ -1146,7 +1146,7 @@ TEST(testCase, smlParseTelnetLine_diff_json_type2_Test) {
...
@@ -1146,7 +1146,7 @@ TEST(testCase, smlParseTelnetLine_diff_json_type2_Test) {
pRes
=
taos_query
(
taos
,
"use sml_db"
);
pRes
=
taos_query
(
taos
,
"use sml_db"
);
taos_free_result
(
pRes
);
taos_free_result
(
pRes
);
SRequestObj
*
request
=
(
SRequestObj
*
)
createRequest
((
STscObj
*
)
taos
,
NULL
,
TSDB_SQL_INSERT
);
SRequestObj
*
request
=
(
SRequestObj
*
)
createRequest
((
STscObj
*
)
taos
,
TSDB_SQL_INSERT
);
ASSERT_NE
(
request
,
nullptr
);
ASSERT_NE
(
request
,
nullptr
);
SSmlHandle
*
info
=
smlBuildSmlInfo
(
taos
,
request
,
TSDB_SML_TELNET_PROTOCOL
,
TSDB_SML_TIMESTAMP_NANO_SECONDS
);
SSmlHandle
*
info
=
smlBuildSmlInfo
(
taos
,
request
,
TSDB_SML_TELNET_PROTOCOL
,
TSDB_SML_TIMESTAMP_NANO_SECONDS
);
...
@@ -1191,7 +1191,7 @@ TEST(testCase, sml_TD15662_Test) {
...
@@ -1191,7 +1191,7 @@ TEST(testCase, sml_TD15662_Test) {
pRes
=
taos_query
(
taos
,
"use db_15662"
);
pRes
=
taos_query
(
taos
,
"use db_15662"
);
taos_free_result
(
pRes
);
taos_free_result
(
pRes
);
SRequestObj
*
request
=
(
SRequestObj
*
)
createRequest
((
STscObj
*
)
taos
,
NULL
,
TSDB_SQL_INSERT
);
SRequestObj
*
request
=
(
SRequestObj
*
)
createRequest
((
STscObj
*
)
taos
,
TSDB_SQL_INSERT
);
ASSERT_NE
(
request
,
nullptr
);
ASSERT_NE
(
request
,
nullptr
);
SSmlHandle
*
info
=
smlBuildSmlInfo
(
taos
,
request
,
TSDB_SML_LINE_PROTOCOL
,
TSDB_SML_TIMESTAMP_MILLI_SECONDS
);
SSmlHandle
*
info
=
smlBuildSmlInfo
(
taos
,
request
,
TSDB_SML_LINE_PROTOCOL
,
TSDB_SML_TIMESTAMP_MILLI_SECONDS
);
...
@@ -1218,7 +1218,7 @@ TEST(testCase, sml_TD15735_Test) {
...
@@ -1218,7 +1218,7 @@ TEST(testCase, sml_TD15735_Test) {
pRes
=
taos_query
(
taos
,
"use sml_db"
);
pRes
=
taos_query
(
taos
,
"use sml_db"
);
taos_free_result
(
pRes
);
taos_free_result
(
pRes
);
SRequestObj
*
request
=
(
SRequestObj
*
)
createRequest
((
STscObj
*
)
taos
,
NULL
,
TSDB_SQL_INSERT
);
SRequestObj
*
request
=
(
SRequestObj
*
)
createRequest
((
STscObj
*
)
taos
,
TSDB_SQL_INSERT
);
ASSERT_NE
(
request
,
nullptr
);
ASSERT_NE
(
request
,
nullptr
);
SSmlHandle
*
info
=
smlBuildSmlInfo
(
taos
,
request
,
TSDB_SML_TELNET_PROTOCOL
,
TSDB_SML_TIMESTAMP_NANO_SECONDS
);
SSmlHandle
*
info
=
smlBuildSmlInfo
(
taos
,
request
,
TSDB_SML_TELNET_PROTOCOL
,
TSDB_SML_TIMESTAMP_NANO_SECONDS
);
...
@@ -1244,7 +1244,7 @@ TEST(testCase, sml_TD15742_Test) {
...
@@ -1244,7 +1244,7 @@ TEST(testCase, sml_TD15742_Test) {
pRes
=
taos_query
(
taos
,
"use TD15742"
);
pRes
=
taos_query
(
taos
,
"use TD15742"
);
taos_free_result
(
pRes
);
taos_free_result
(
pRes
);
SRequestObj
*
request
=
(
SRequestObj
*
)
createRequest
((
STscObj
*
)
taos
,
NULL
,
TSDB_SQL_INSERT
);
SRequestObj
*
request
=
(
SRequestObj
*
)
createRequest
((
STscObj
*
)
taos
,
TSDB_SQL_INSERT
);
ASSERT_NE
(
request
,
nullptr
);
ASSERT_NE
(
request
,
nullptr
);
SSmlHandle
*
info
=
smlBuildSmlInfo
(
taos
,
request
,
TSDB_SML_LINE_PROTOCOL
,
TSDB_SML_TIMESTAMP_MILLI_SECONDS
);
SSmlHandle
*
info
=
smlBuildSmlInfo
(
taos
,
request
,
TSDB_SML_LINE_PROTOCOL
,
TSDB_SML_TIMESTAMP_MILLI_SECONDS
);
...
...
source/dnode/mnode/impl/src/mndDb.c
浏览文件 @
4560b8f2
...
@@ -1392,19 +1392,25 @@ char *buildRetension(SArray *pRetension) {
...
@@ -1392,19 +1392,25 @@ char *buildRetension(SArray *pRetension) {
int64_t
v1
=
getValOfDiffPrecision
(
p
->
freqUnit
,
p
->
freq
);
int64_t
v1
=
getValOfDiffPrecision
(
p
->
freqUnit
,
p
->
freq
);
int64_t
v2
=
getValOfDiffPrecision
(
p
->
keepUnit
,
p
->
keep
);
int64_t
v2
=
getValOfDiffPrecision
(
p
->
keepUnit
,
p
->
keep
);
len
+=
sprintf
(
p1
+
len
,
"%"
PRId64
"%c:%"
PRId64
"%c
,
"
,
v1
,
p
->
freqUnit
,
v2
,
p
->
keepUnit
);
len
+=
sprintf
(
p1
+
len
,
"%"
PRId64
"%c:%"
PRId64
"%c"
,
v1
,
p
->
freqUnit
,
v2
,
p
->
keepUnit
);
p
=
taosArrayGet
(
pRetension
,
1
);
if
(
size
>
1
)
{
len
+=
sprintf
(
p1
+
len
,
","
);
p
=
taosArrayGet
(
pRetension
,
1
);
v1
=
getValOfDiffPrecision
(
p
->
freqUnit
,
p
->
freq
);
v1
=
getValOfDiffPrecision
(
p
->
freqUnit
,
p
->
freq
);
v2
=
getValOfDiffPrecision
(
p
->
keepUnit
,
p
->
keep
);
v2
=
getValOfDiffPrecision
(
p
->
keepUnit
,
p
->
keep
);
len
+=
sprintf
(
p1
+
len
,
"%"
PRId64
"%c:%"
PRId64
"%c,"
,
v1
,
p
->
freqUnit
,
v2
,
p
->
keepUnit
);
len
+=
sprintf
(
p1
+
len
,
"%"
PRId64
"%c:%"
PRId64
"%c"
,
v1
,
p
->
freqUnit
,
v2
,
p
->
keepUnit
);
}
p
=
taosArrayGet
(
pRetension
,
2
);
if
(
size
>
2
)
{
len
+=
sprintf
(
p1
+
len
,
","
);
p
=
taosArrayGet
(
pRetension
,
2
);
v1
=
getValOfDiffPrecision
(
p
->
freqUnit
,
p
->
freq
);
v1
=
getValOfDiffPrecision
(
p
->
freqUnit
,
p
->
freq
);
v2
=
getValOfDiffPrecision
(
p
->
keepUnit
,
p
->
keep
);
v2
=
getValOfDiffPrecision
(
p
->
keepUnit
,
p
->
keep
);
len
+=
sprintf
(
p1
+
len
,
"%"
PRId64
"%c:%"
PRId64
"%c"
,
v1
,
p
->
freqUnit
,
v2
,
p
->
keepUnit
);
len
+=
sprintf
(
p1
+
len
,
"%"
PRId64
"%c:%"
PRId64
"%c"
,
v1
,
p
->
freqUnit
,
v2
,
p
->
keepUnit
);
}
varDataSetLen
(
p1
,
len
);
varDataSetLen
(
p1
,
len
);
return
p1
;
return
p1
;
...
...
source/dnode/mnode/impl/src/mndScheduler.c
浏览文件 @
4560b8f2
...
@@ -190,7 +190,7 @@ int32_t mndAddShuffledSinkToStream(SMnode* pMnode, STrans* pTrans, SStreamObj* p
...
@@ -190,7 +190,7 @@ int32_t mndAddShuffledSinkToStream(SMnode* pMnode, STrans* pTrans, SStreamObj* p
sdbRelease
(
pSdb
,
pVgroup
);
sdbRelease
(
pSdb
,
pVgroup
);
continue
;
continue
;
}
}
SStreamTask
*
pTask
=
tNewSStreamTask
(
pStream
->
uid
);
SStreamTask
*
pTask
=
tNewSStreamTask
(
pStream
->
uid
,
0
);
if
(
pTask
==
NULL
)
{
if
(
pTask
==
NULL
)
{
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
return
-
1
;
return
-
1
;
...
@@ -230,7 +230,7 @@ int32_t mndAddShuffledSinkToStream(SMnode* pMnode, STrans* pTrans, SStreamObj* p
...
@@ -230,7 +230,7 @@ int32_t mndAddShuffledSinkToStream(SMnode* pMnode, STrans* pTrans, SStreamObj* p
int32_t
mndAddFixedSinkToStream
(
SMnode
*
pMnode
,
STrans
*
pTrans
,
SStreamObj
*
pStream
)
{
int32_t
mndAddFixedSinkToStream
(
SMnode
*
pMnode
,
STrans
*
pTrans
,
SStreamObj
*
pStream
)
{
ASSERT
(
pStream
->
fixedSinkVgId
!=
0
);
ASSERT
(
pStream
->
fixedSinkVgId
!=
0
);
SArray
*
tasks
=
taosArrayGetP
(
pStream
->
tasks
,
0
);
SArray
*
tasks
=
taosArrayGetP
(
pStream
->
tasks
,
0
);
SStreamTask
*
pTask
=
tNewSStreamTask
(
pStream
->
uid
);
SStreamTask
*
pTask
=
tNewSStreamTask
(
pStream
->
uid
,
0
);
if
(
pTask
==
NULL
)
{
if
(
pTask
==
NULL
)
{
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
return
-
1
;
return
-
1
;
...
@@ -322,7 +322,7 @@ int32_t mndScheduleStream(SMnode* pMnode, STrans* pTrans, SStreamObj* pStream) {
...
@@ -322,7 +322,7 @@ int32_t mndScheduleStream(SMnode* pMnode, STrans* pTrans, SStreamObj* pStream) {
sdbRelease
(
pSdb
,
pVgroup
);
sdbRelease
(
pSdb
,
pVgroup
);
continue
;
continue
;
}
}
SStreamTask
*
pTask
=
tNewSStreamTask
(
pStream
->
uid
);
SStreamTask
*
pTask
=
tNewSStreamTask
(
pStream
->
uid
,
0
);
// source part
// source part
pTask
->
sourceType
=
TASK_SOURCE__SCAN
;
pTask
->
sourceType
=
TASK_SOURCE__SCAN
;
pTask
->
inputType
=
TASK_INPUT_TYPE__SUMBIT_BLOCK
;
pTask
->
inputType
=
TASK_INPUT_TYPE__SUMBIT_BLOCK
;
...
@@ -387,7 +387,7 @@ int32_t mndScheduleStream(SMnode* pMnode, STrans* pTrans, SStreamObj* pStream) {
...
@@ -387,7 +387,7 @@ int32_t mndScheduleStream(SMnode* pMnode, STrans* pTrans, SStreamObj* pStream) {
// else, assign to vnode
// else, assign to vnode
ASSERT
(
plan
->
subplanType
==
SUBPLAN_TYPE_MERGE
);
ASSERT
(
plan
->
subplanType
==
SUBPLAN_TYPE_MERGE
);
SStreamTask
*
pTask
=
tNewSStreamTask
(
pStream
->
uid
);
SStreamTask
*
pTask
=
tNewSStreamTask
(
pStream
->
uid
,
0
);
// source part, currently only support multi source
// source part, currently only support multi source
pTask
->
sourceType
=
TASK_SOURCE__PIPE
;
pTask
->
sourceType
=
TASK_SOURCE__PIPE
;
...
@@ -477,7 +477,7 @@ int32_t mndScheduleStream(SMnode* pMnode, STrans* pTrans, SStreamObj* pStream) {
...
@@ -477,7 +477,7 @@ int32_t mndScheduleStream(SMnode* pMnode, STrans* pTrans, SStreamObj* pStream) {
sdbRelease
(
pSdb
,
pVgroup
);
sdbRelease
(
pSdb
,
pVgroup
);
continue
;
continue
;
}
}
SStreamTask
*
pTask
=
tNewSStreamTask
(
pStream
->
uid
);
SStreamTask
*
pTask
=
tNewSStreamTask
(
pStream
->
uid
,
0
);
// source part
// source part
pTask
->
sourceType
=
TASK_SOURCE__MERGE
;
pTask
->
sourceType
=
TASK_SOURCE__MERGE
;
...
...
source/dnode/mnode/impl/src/mndVgroup.c
浏览文件 @
4560b8f2
...
@@ -38,6 +38,7 @@ static void mndCancelGetNextVnode(SMnode *pMnode, void *pIter);
...
@@ -38,6 +38,7 @@ static void mndCancelGetNextVnode(SMnode *pMnode, void *pIter);
static
int32_t
mndProcessRedistributeVgroupMsg
(
SRpcMsg
*
pReq
);
static
int32_t
mndProcessRedistributeVgroupMsg
(
SRpcMsg
*
pReq
);
static
int32_t
mndProcessSplitVgroupMsg
(
SRpcMsg
*
pReq
);
static
int32_t
mndProcessSplitVgroupMsg
(
SRpcMsg
*
pReq
);
static
int32_t
mndProcessBalanceVgroupMsg
(
SRpcMsg
*
pReq
);
int32_t
mndInitVgroup
(
SMnode
*
pMnode
)
{
int32_t
mndInitVgroup
(
SMnode
*
pMnode
)
{
SSdbTable
table
=
{
SSdbTable
table
=
{
...
@@ -1165,4 +1166,159 @@ _OVER:
...
@@ -1165,4 +1166,159 @@ _OVER:
return
code
;
return
code
;
}
}
static
int32_t
mndProcessSplitVgroupMsg
(
SRpcMsg
*
pReq
)
{
return
0
;
}
static
int32_t
mndProcessSplitVgroupMsg
(
SRpcMsg
*
pReq
)
{
return
0
;
}
\ No newline at end of file
static
int32_t
mndSetBalanceVgroupInfoToTrans
(
SMnode
*
pMnode
,
STrans
*
pTrans
,
SDbObj
*
pDb
,
SVgObj
*
pVgroup
,
SDnodeObj
*
pSrc
,
SDnodeObj
*
pDst
)
{
SVgObj
newVg
=
{
0
};
memcpy
(
&
newVg
,
pVgroup
,
sizeof
(
SVgObj
));
mInfo
(
"vgId:%d, vgroup info before balance, replica:%d"
,
newVg
.
vgId
,
newVg
.
replica
);
for
(
int32_t
i
=
0
;
i
<
newVg
.
replica
;
++
i
)
{
mInfo
(
"vgId:%d, vnode:%d dnode:%d"
,
newVg
.
vgId
,
i
,
newVg
.
vnodeGid
[
i
].
dnodeId
);
}
if
(
mndAddIncVgroupReplicaToTrans
(
pMnode
,
pTrans
,
pDb
,
&
newVg
,
pDst
->
id
)
!=
0
)
return
-
1
;
if
(
mndAddDecVgroupReplicaFromTrans
(
pMnode
,
pTrans
,
pDb
,
&
newVg
,
pSrc
->
id
)
!=
0
)
return
-
1
;
SSdbRaw
*
pRaw
=
mndVgroupActionEncode
(
&
newVg
);
if
(
pRaw
==
NULL
||
mndTransAppendCommitlog
(
pTrans
,
pRaw
)
!=
0
)
{
sdbFreeRaw
(
pRaw
);
return
-
1
;
}
sdbSetRawStatus
(
pRaw
,
SDB_STATUS_READY
);
mInfo
(
"vgId:%d, vgroup info after balance, replica:%d"
,
newVg
.
vgId
,
newVg
.
replica
);
for
(
int32_t
i
=
0
;
i
<
newVg
.
replica
;
++
i
)
{
mInfo
(
"vgId:%d, vnode:%d dnode:%d"
,
newVg
.
vgId
,
i
,
newVg
.
vnodeGid
[
i
].
dnodeId
);
}
return
0
;
}
static
int32_t
mndBalanceVgroupBetweenDnode
(
SMnode
*
pMnode
,
STrans
*
pTrans
,
SDnodeObj
*
pSrc
,
SDnodeObj
*
pDst
)
{
void
*
pIter
=
NULL
;
int32_t
code
=
-
1
;
while
(
1
)
{
SVgObj
*
pVgroup
=
NULL
;
pIter
=
sdbFetch
(
pMnode
->
pSdb
,
SDB_VGROUP
,
pIter
,
(
void
**
)
&
pVgroup
);
if
(
pIter
==
NULL
)
break
;
bool
existInSrc
=
false
;
bool
existInDst
=
false
;
for
(
int32_t
i
=
0
;
i
<
pVgroup
->
replica
;
++
i
)
{
SVnodeGid
*
pGid
=
&
pVgroup
->
vnodeGid
[
i
];
if
(
pGid
->
dnodeId
==
pSrc
->
id
)
existInSrc
=
true
;
if
(
pGid
->
dnodeId
==
pDst
->
id
)
existInDst
=
true
;
}
if
(
!
existInSrc
||
existInDst
)
{
sdbRelease
(
pMnode
->
pSdb
,
pVgroup
);
}
SDbObj
*
pDb
=
mndAcquireDb
(
pMnode
,
pVgroup
->
dbName
);
code
=
mndSetBalanceVgroupInfoToTrans
(
pMnode
,
pTrans
,
pDb
,
pVgroup
,
pSrc
,
pDst
);
mndReleaseDb
(
pMnode
,
pDb
);
sdbRelease
(
pMnode
->
pSdb
,
pVgroup
);
break
;
}
return
code
;
}
static
int32_t
mndBalanceVgroup
(
SMnode
*
pMnode
,
SRpcMsg
*
pReq
,
SArray
*
pArray
)
{
int32_t
code
=
-
1
;
int32_t
numOfVgroups
=
0
;
STrans
*
pTrans
=
NULL
;
pTrans
=
mndTransCreate
(
pMnode
,
TRN_POLICY_RETRY
,
TRN_CONFLICT_GLOBAL
,
pReq
);
if
(
pTrans
==
NULL
)
goto
_OVER
;
mndTransSetSerial
(
pTrans
);
mDebug
(
"trans:%d, used to balance vgroup"
,
pTrans
->
id
);
while
(
1
)
{
taosArraySort
(
pArray
,
(
__compar_fn_t
)
mndCompareDnodeVnodes
);
SDnodeObj
*
pSrc
=
taosArrayGet
(
pArray
,
0
);
SDnodeObj
*
pDst
=
taosArrayGet
(
pArray
,
taosArrayGetSize
(
pArray
)
-
1
);
float
srcScore
=
(
float
)(
pSrc
->
numOfVnodes
-
1
)
/
pSrc
->
numOfSupportVnodes
;
float
dstScore
=
(
float
)(
pDst
->
numOfVnodes
+
1
)
/
pDst
->
numOfSupportVnodes
;
if
(
srcScore
+
0
.
0001
<
dstScore
)
{
mDebug
(
"trans:%d, balance vgroup from dnode:%d to dnode:%d"
,
pTrans
->
id
,
pSrc
->
id
,
pDst
->
id
);
code
=
mndBalanceVgroupBetweenDnode
(
pMnode
,
pTrans
,
pSrc
,
pDst
);
if
(
code
==
0
)
{
numOfVgroups
++
;
continue
;
}
else
{
mError
(
"trans:%d, failed to balance vgroup from dnode:%d to dnode:%d"
,
pTrans
->
id
,
pSrc
->
id
,
pDst
->
id
);
return
-
1
;
}
}
else
{
mDebug
(
"trans:%d, no vgroup need to balance vgroup any more"
,
pTrans
->
id
);
break
;
}
}
if
(
numOfVgroups
<=
0
)
{
mDebug
(
"no need to balance vgroup"
);
code
=
0
;
}
else
{
mDebug
(
"start to balance vgroup, numOfVgroups:%d"
,
numOfVgroups
);
if
(
mndTransPrepare
(
pMnode
,
pTrans
)
!=
0
)
goto
_OVER
;
code
=
TSDB_CODE_ACTION_IN_PROGRESS
;
}
_OVER:
mndTransDrop
(
pTrans
);
return
code
;
}
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
();
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
(
mndCheckNodeAuth
(
pUser
)
!=
0
)
goto
_OVER
;
while
(
1
)
{
SDnodeObj
*
pDnode
=
NULL
;
pIter
=
sdbFetch
(
pMnode
->
pSdb
,
SDB_DNODE
,
pIter
,
(
void
**
)
&
pDnode
);
if
(
pIter
==
NULL
)
break
;
if
(
!
mndIsDnodeOnline
(
pDnode
,
curMs
))
{
terrno
=
TSDB_CODE_MND_HAS_OFFLINE_DNODE
;
mError
(
"failed to balance vgroup since %s, dnode:%d"
,
terrstr
(),
pDnode
->
id
);
sdbRelease
(
pMnode
->
pSdb
,
pDnode
);
goto
_OVER
;
}
sdbRelease
(
pMnode
->
pSdb
,
pDnode
);
}
pArray
=
mndBuildDnodesArray
(
pMnode
,
0
);
if
(
pArray
==
NULL
)
goto
_OVER
;
if
(
taosArrayGetSize
(
pArray
)
<
2
)
{
mDebug
(
"no need to balance vgroup since dnode num less than 2"
);
code
=
0
;
}
else
{
code
=
mndBalanceVgroup
(
pMnode
,
pReq
,
pArray
);
}
_OVER:
if
(
code
!=
0
&&
code
!=
TSDB_CODE_ACTION_IN_PROGRESS
)
{
mError
(
"failed to balance vgroup since %s"
,
terrstr
());
}
mndReleaseUser
(
pMnode
,
pUser
);
taosArrayDestroy
(
pArray
);
return
code
;
}
\ No newline at end of file
source/dnode/vnode/src/inc/tq.h
浏览文件 @
4560b8f2
...
@@ -78,10 +78,10 @@ typedef struct {
...
@@ -78,10 +78,10 @@ typedef struct {
tmr_h
timerId
;
tmr_h
timerId
;
int8_t
tmrStopped
;
int8_t
tmrStopped
;
// exec
// exec
int8_t
inputStatus
;
int8_t
inputStatus
;
int8_t
execStatus
;
int8_t
execStatus
;
SStreamQ
inputQ
;
SStreamQ
ueue
inputQ
;
SRWLatch
lock
;
SRWLatch
lock
;
}
STqPushHandle
;
}
STqPushHandle
;
// tqExec
// tqExec
...
@@ -107,7 +107,7 @@ typedef struct {
...
@@ -107,7 +107,7 @@ typedef struct {
STqExecCol
execCol
;
STqExecCol
execCol
;
STqExecTb
execTb
;
STqExecTb
execTb
;
STqExecDb
execDb
;
STqExecDb
execDb
;
}
exec
;
};
}
STqExecHandle
;
}
STqExecHandle
;
typedef
struct
{
typedef
struct
{
...
...
source/dnode/vnode/src/tq/tq.c
浏览文件 @
4560b8f2
...
@@ -266,7 +266,7 @@ int32_t tqProcessVgChangeReq(STQ* pTq, char* msg, int32_t msgLen) {
...
@@ -266,7 +266,7 @@ int32_t tqProcessVgChangeReq(STQ* pTq, char* msg, int32_t msgLen) {
pHandle
->
execHandle
.
pExecReader
[
i
]
=
tqInitSubmitMsgScanner
(
pTq
->
pVnode
->
pMeta
);
pHandle
->
execHandle
.
pExecReader
[
i
]
=
tqInitSubmitMsgScanner
(
pTq
->
pVnode
->
pMeta
);
}
}
if
(
pHandle
->
execHandle
.
subType
==
TOPIC_SUB_TYPE__COLUMN
)
{
if
(
pHandle
->
execHandle
.
subType
==
TOPIC_SUB_TYPE__COLUMN
)
{
pHandle
->
execHandle
.
exec
.
exec
Col
.
qmsg
=
req
.
qmsg
;
pHandle
->
execHandle
.
execCol
.
qmsg
=
req
.
qmsg
;
req
.
qmsg
=
NULL
;
req
.
qmsg
=
NULL
;
for
(
int32_t
i
=
0
;
i
<
5
;
i
++
)
{
for
(
int32_t
i
=
0
;
i
<
5
;
i
++
)
{
SReadHandle
handle
=
{
SReadHandle
handle
=
{
...
@@ -274,15 +274,14 @@ int32_t tqProcessVgChangeReq(STQ* pTq, char* msg, int32_t msgLen) {
...
@@ -274,15 +274,14 @@ int32_t tqProcessVgChangeReq(STQ* pTq, char* msg, int32_t msgLen) {
.
meta
=
pTq
->
pVnode
->
pMeta
,
.
meta
=
pTq
->
pVnode
->
pMeta
,
.
pMsgCb
=
&
pTq
->
pVnode
->
msgCb
,
.
pMsgCb
=
&
pTq
->
pVnode
->
msgCb
,
};
};
pHandle
->
execHandle
.
exec
.
execCol
.
task
[
i
]
=
pHandle
->
execHandle
.
execCol
.
task
[
i
]
=
qCreateStreamExecTaskInfo
(
pHandle
->
execHandle
.
execCol
.
qmsg
,
&
handle
);
qCreateStreamExecTaskInfo
(
pHandle
->
execHandle
.
exec
.
execCol
.
qmsg
,
&
handle
);
ASSERT
(
pHandle
->
execHandle
.
execCol
.
task
[
i
]);
ASSERT
(
pHandle
->
execHandle
.
exec
.
execCol
.
task
[
i
]);
}
}
}
else
if
(
pHandle
->
execHandle
.
subType
==
TOPIC_SUB_TYPE__DB
)
{
}
else
if
(
pHandle
->
execHandle
.
subType
==
TOPIC_SUB_TYPE__DB
)
{
pHandle
->
execHandle
.
exec
.
exec
Db
.
pFilterOutTbUid
=
pHandle
->
execHandle
.
execDb
.
pFilterOutTbUid
=
taosHashInit
(
64
,
taosGetDefaultHashFunction
(
TSDB_DATA_TYPE_BIGINT
),
false
,
HASH_NO_LOCK
);
taosHashInit
(
64
,
taosGetDefaultHashFunction
(
TSDB_DATA_TYPE_BIGINT
),
false
,
HASH_NO_LOCK
);
}
else
if
(
pHandle
->
execHandle
.
subType
==
TOPIC_SUB_TYPE__TABLE
)
{
}
else
if
(
pHandle
->
execHandle
.
subType
==
TOPIC_SUB_TYPE__TABLE
)
{
pHandle
->
execHandle
.
exec
.
exec
Tb
.
suid
=
req
.
suid
;
pHandle
->
execHandle
.
execTb
.
suid
=
req
.
suid
;
SArray
*
tbUidList
=
taosArrayInit
(
0
,
sizeof
(
int64_t
));
SArray
*
tbUidList
=
taosArrayInit
(
0
,
sizeof
(
int64_t
));
tsdbGetCtbIdList
(
pTq
->
pVnode
->
pMeta
,
req
.
suid
,
tbUidList
);
tsdbGetCtbIdList
(
pTq
->
pVnode
->
pMeta
,
req
.
suid
,
tbUidList
);
tqDebug
(
"vg %d, tq try get suid: %ld"
,
pTq
->
pVnode
->
config
.
vgId
,
req
.
suid
);
tqDebug
(
"vg %d, tq try get suid: %ld"
,
pTq
->
pVnode
->
config
.
vgId
,
req
.
suid
);
...
@@ -296,17 +295,20 @@ int32_t tqProcessVgChangeReq(STQ* pTq, char* msg, int32_t msgLen) {
...
@@ -296,17 +295,20 @@ int32_t tqProcessVgChangeReq(STQ* pTq, char* msg, int32_t msgLen) {
taosArrayDestroy
(
tbUidList
);
taosArrayDestroy
(
tbUidList
);
}
}
taosHashPut
(
pTq
->
handles
,
req
.
subKey
,
strlen
(
req
.
subKey
),
pHandle
,
sizeof
(
STqHandle
));
taosHashPut
(
pTq
->
handles
,
req
.
subKey
,
strlen
(
req
.
subKey
),
pHandle
,
sizeof
(
STqHandle
));
if
(
tqMetaSaveHandle
(
pTq
,
req
.
subKey
,
pHandle
)
<
0
)
{
// TODO
}
}
else
{
}
else
{
/*ASSERT(pExec->consumerId == req.oldConsumerId);*/
/*ASSERT(pExec->consumerId == req.oldConsumerId);*/
// TODO handle qmsg and exec modification
// TODO handle qmsg and exec modification
atomic_store_32
(
&
pHandle
->
epoch
,
-
1
);
atomic_store_32
(
&
pHandle
->
epoch
,
-
1
);
atomic_store_64
(
&
pHandle
->
consumerId
,
req
.
newConsumerId
);
atomic_store_64
(
&
pHandle
->
consumerId
,
req
.
newConsumerId
);
atomic_add_fetch_32
(
&
pHandle
->
epoch
,
1
);
atomic_add_fetch_32
(
&
pHandle
->
epoch
,
1
);
if
(
tqMetaSaveHandle
(
pTq
,
req
.
subKey
,
pHandle
)
<
0
)
{
// TODO
}
}
}
if
(
tqMetaSaveHandle
(
pTq
,
req
.
subKey
,
pHandle
)
<
0
)
{
// TODO
}
return
0
;
return
0
;
}
}
...
@@ -323,16 +325,13 @@ int32_t tqProcessTaskDeploy(STQ* pTq, char* msg, int32_t msgLen) {
...
@@ -323,16 +325,13 @@ int32_t tqProcessTaskDeploy(STQ* pTq, char* msg, int32_t msgLen) {
tDecoderClear
(
&
decoder
);
tDecoderClear
(
&
decoder
);
pTask
->
status
=
TASK_STATUS__IDLE
;
pTask
->
status
=
TASK_STATUS__IDLE
;
pTask
->
inputQueue
=
streamQueueOpen
();
pTask
->
outputQueue
=
streamQueueOpen
();
pTask
->
inputStatus
=
TASK_INPUT_STATUS__NORMAL
;
pTask
->
inputStatus
=
TASK_INPUT_STATUS__NORMAL
;
pTask
->
outputStatus
=
TASK_OUTPUT_STATUS__NORMAL
;
pTask
->
outputStatus
=
TASK_OUTPUT_STATUS__NORMAL
;
pTask
->
inputQ
=
taosOpenQueue
();
if
(
pTask
->
inputQueue
==
NULL
||
pTask
->
outputQueue
==
NULL
)
goto
FAIL
;
pTask
->
outputQ
=
taosOpenQueue
();
pTask
->
inputQAll
=
taosAllocateQall
();
pTask
->
outputQAll
=
taosAllocateQall
();
if
(
pTask
->
inputQ
==
NULL
||
pTask
->
outputQ
==
NULL
||
pTask
->
inputQAll
==
NULL
||
pTask
->
outputQAll
==
NULL
)
goto
FAIL
;
// exec
// exec
if
(
pTask
->
execType
!=
TASK_EXEC__NONE
)
{
if
(
pTask
->
execType
!=
TASK_EXEC__NONE
)
{
...
@@ -369,10 +368,8 @@ int32_t tqProcessTaskDeploy(STQ* pTq, char* msg, int32_t msgLen) {
...
@@ -369,10 +368,8 @@ int32_t tqProcessTaskDeploy(STQ* pTq, char* msg, int32_t msgLen) {
return
0
;
return
0
;
FAIL:
FAIL:
if
(
pTask
->
inputQ
)
taosCloseQueue
(
pTask
->
inputQ
);
if
(
pTask
->
inputQueue
)
streamQueueClose
(
pTask
->
inputQueue
);
if
(
pTask
->
outputQ
)
taosCloseQueue
(
pTask
->
outputQ
);
if
(
pTask
->
outputQueue
)
streamQueueClose
(
pTask
->
outputQueue
);
if
(
pTask
->
inputQAll
)
taosFreeQall
(
pTask
->
inputQAll
);
if
(
pTask
->
outputQAll
)
taosFreeQall
(
pTask
->
outputQAll
);
if
(
pTask
)
taosMemoryFree
(
pTask
);
if
(
pTask
)
taosMemoryFree
(
pTask
);
return
-
1
;
return
-
1
;
}
}
...
@@ -393,38 +390,16 @@ int32_t tqProcessStreamTrigger(STQ* pTq, SSubmitReq* pReq) {
...
@@ -393,38 +390,16 @@ int32_t tqProcessStreamTrigger(STQ* pTq, SSubmitReq* pReq) {
SStreamTask
*
pTask
=
(
SStreamTask
*
)
pIter
;
SStreamTask
*
pTask
=
(
SStreamTask
*
)
pIter
;
if
(
pTask
->
inputType
!=
STREAM_INPUT__DATA_SUBMIT
)
continue
;
if
(
pTask
->
inputType
!=
STREAM_INPUT__DATA_SUBMIT
)
continue
;
int8_t
inputStatus
=
atomic_load_8
(
&
pTask
->
inputStatus
);
if
(
!
failed
)
{
if
(
inputStatus
==
TASK_INPUT_STATUS__NORMAL
)
{
if
(
streamTaskInput
(
pTask
,
(
SStreamQueueItem
*
)
pSubmit
)
<
0
)
{
if
(
failed
)
{
atomic_store_8
(
&
pTask
->
inputStatus
,
TASK_INPUT_STATUS__FAILED
);
continue
;
continue
;
}
}
SStreamDataSubmit
*
pSubmitClone
=
streamSubmitRefClone
(
pSubmit
);
if
(
streamTriggerByWrite
(
pTask
,
pTq
->
pVnode
->
config
.
vgId
,
&
pTq
->
pVnode
->
msgCb
)
<
0
)
{
if
(
pSubmitClone
==
NULL
)
{
atomic_store_8
(
&
pTask
->
inputStatus
,
TASK_INPUT_STATUS__FAILED
);
continue
;
continue
;
}
}
taosWriteQitem
(
pTask
->
inputQ
,
pSubmitClone
);
int8_t
execStatus
=
atomic_load_8
(
&
pTask
->
status
);
if
(
execStatus
==
TASK_STATUS__IDLE
||
execStatus
==
TASK_STATUS__CLOSING
)
{
SStreamTaskRunReq
*
pRunReq
=
taosMemoryMalloc
(
sizeof
(
SStreamTaskRunReq
));
if
(
pRunReq
==
NULL
)
continue
;
// TODO: do we need htonl?
pRunReq
->
head
.
vgId
=
pTq
->
pVnode
->
config
.
vgId
;
pRunReq
->
streamId
=
pTask
->
streamId
;
pRunReq
->
taskId
=
pTask
->
taskId
;
SRpcMsg
msg
=
{
.
msgType
=
TDMT_VND_TASK_RUN
,
.
pCont
=
pRunReq
,
.
contLen
=
sizeof
(
SStreamTaskRunReq
),
};
tmsgPutToQueue
(
&
pTq
->
pVnode
->
msgCb
,
FETCH_QUEUE
,
&
msg
);
}
}
else
{
}
else
{
// blocked or stopped, do nothing
streamTaskInputFail
(
pTask
);
}
}
}
}
...
...
source/dnode/vnode/src/tq/tqExec.c
浏览文件 @
4560b8f2
...
@@ -59,7 +59,7 @@ static int32_t tqAddTbNameToRsp(const STQ* pTq, const STqExecHandle* pExec, SMqD
...
@@ -59,7 +59,7 @@ static int32_t tqAddTbNameToRsp(const STQ* pTq, const STqExecHandle* pExec, SMqD
int32_t
tqDataExec
(
STQ
*
pTq
,
STqExecHandle
*
pExec
,
SSubmitReq
*
pReq
,
SMqDataBlkRsp
*
pRsp
,
int32_t
workerId
)
{
int32_t
tqDataExec
(
STQ
*
pTq
,
STqExecHandle
*
pExec
,
SSubmitReq
*
pReq
,
SMqDataBlkRsp
*
pRsp
,
int32_t
workerId
)
{
if
(
pExec
->
subType
==
TOPIC_SUB_TYPE__COLUMN
)
{
if
(
pExec
->
subType
==
TOPIC_SUB_TYPE__COLUMN
)
{
qTaskInfo_t
task
=
pExec
->
exec
.
exec
Col
.
task
[
workerId
];
qTaskInfo_t
task
=
pExec
->
execCol
.
task
[
workerId
];
ASSERT
(
task
);
ASSERT
(
task
);
qSetStreamInput
(
task
,
pReq
,
STREAM_DATA_TYPE_SUBMIT_BLOCK
,
false
);
qSetStreamInput
(
task
,
pReq
,
STREAM_DATA_TYPE_SUBMIT_BLOCK
,
false
);
while
(
1
)
{
while
(
1
)
{
...
@@ -101,7 +101,7 @@ int32_t tqDataExec(STQ* pTq, STqExecHandle* pExec, SSubmitReq* pReq, SMqDataBlkR
...
@@ -101,7 +101,7 @@ int32_t tqDataExec(STQ* pTq, STqExecHandle* pExec, SSubmitReq* pReq, SMqDataBlkR
pRsp
->
withSchema
=
1
;
pRsp
->
withSchema
=
1
;
STqReadHandle
*
pReader
=
pExec
->
pExecReader
[
workerId
];
STqReadHandle
*
pReader
=
pExec
->
pExecReader
[
workerId
];
tqReadHandleSetMsg
(
pReader
,
pReq
,
0
);
tqReadHandleSetMsg
(
pReader
,
pReq
,
0
);
while
(
tqNextDataBlockFilterOut
(
pReader
,
pExec
->
exec
.
exec
Db
.
pFilterOutTbUid
))
{
while
(
tqNextDataBlockFilterOut
(
pReader
,
pExec
->
execDb
.
pFilterOutTbUid
))
{
SSDataBlock
block
=
{
0
};
SSDataBlock
block
=
{
0
};
if
(
tqRetrieveDataBlock
(
&
block
.
pDataBlock
,
pReader
,
&
block
.
info
.
groupId
,
&
block
.
info
.
uid
,
&
block
.
info
.
rows
,
if
(
tqRetrieveDataBlock
(
&
block
.
pDataBlock
,
pReader
,
&
block
.
info
.
groupId
,
&
block
.
info
.
uid
,
&
block
.
info
.
rows
,
&
block
.
info
.
numOfCols
)
<
0
)
{
&
block
.
info
.
numOfCols
)
<
0
)
{
...
...
source/dnode/vnode/src/tq/tqMeta.c
浏览文件 @
4560b8f2
...
@@ -22,7 +22,7 @@ static int32_t tEncodeSTqHandle(SEncoder* pEncoder, const STqHandle* pHandle) {
...
@@ -22,7 +22,7 @@ static int32_t tEncodeSTqHandle(SEncoder* pEncoder, const STqHandle* pHandle) {
if
(
tEncodeI32
(
pEncoder
,
pHandle
->
epoch
)
<
0
)
return
-
1
;
if
(
tEncodeI32
(
pEncoder
,
pHandle
->
epoch
)
<
0
)
return
-
1
;
if
(
tEncodeI8
(
pEncoder
,
pHandle
->
execHandle
.
subType
)
<
0
)
return
-
1
;
if
(
tEncodeI8
(
pEncoder
,
pHandle
->
execHandle
.
subType
)
<
0
)
return
-
1
;
if
(
pHandle
->
execHandle
.
subType
==
TOPIC_SUB_TYPE__COLUMN
)
{
if
(
pHandle
->
execHandle
.
subType
==
TOPIC_SUB_TYPE__COLUMN
)
{
if
(
tEncodeCStr
(
pEncoder
,
pHandle
->
execHandle
.
exec
.
exec
Col
.
qmsg
)
<
0
)
return
-
1
;
if
(
tEncodeCStr
(
pEncoder
,
pHandle
->
execHandle
.
execCol
.
qmsg
)
<
0
)
return
-
1
;
}
}
tEndEncode
(
pEncoder
);
tEndEncode
(
pEncoder
);
return
pEncoder
->
pos
;
return
pEncoder
->
pos
;
...
@@ -35,7 +35,7 @@ static int32_t tDecodeSTqHandle(SDecoder* pDecoder, STqHandle* pHandle) {
...
@@ -35,7 +35,7 @@ static int32_t tDecodeSTqHandle(SDecoder* pDecoder, STqHandle* pHandle) {
if
(
tDecodeI32
(
pDecoder
,
&
pHandle
->
epoch
)
<
0
)
return
-
1
;
if
(
tDecodeI32
(
pDecoder
,
&
pHandle
->
epoch
)
<
0
)
return
-
1
;
if
(
tDecodeI8
(
pDecoder
,
&
pHandle
->
execHandle
.
subType
)
<
0
)
return
-
1
;
if
(
tDecodeI8
(
pDecoder
,
&
pHandle
->
execHandle
.
subType
)
<
0
)
return
-
1
;
if
(
pHandle
->
execHandle
.
subType
==
TOPIC_SUB_TYPE__COLUMN
)
{
if
(
pHandle
->
execHandle
.
subType
==
TOPIC_SUB_TYPE__COLUMN
)
{
if
(
tDecodeCStrAlloc
(
pDecoder
,
&
pHandle
->
execHandle
.
exec
.
exec
Col
.
qmsg
)
<
0
)
return
-
1
;
if
(
tDecodeCStrAlloc
(
pDecoder
,
&
pHandle
->
execHandle
.
execCol
.
qmsg
)
<
0
)
return
-
1
;
}
}
tEndDecode
(
pDecoder
);
tEndDecode
(
pDecoder
);
return
0
;
return
0
;
...
@@ -88,12 +88,11 @@ int32_t tqMetaOpen(STQ* pTq) {
...
@@ -88,12 +88,11 @@ int32_t tqMetaOpen(STQ* pTq) {
.
meta
=
pTq
->
pVnode
->
pMeta
,
.
meta
=
pTq
->
pVnode
->
pMeta
,
.
pMsgCb
=
&
pTq
->
pVnode
->
msgCb
,
.
pMsgCb
=
&
pTq
->
pVnode
->
msgCb
,
};
};
handle
.
execHandle
.
exec
.
execCol
.
task
[
i
]
=
handle
.
execHandle
.
execCol
.
task
[
i
]
=
qCreateStreamExecTaskInfo
(
handle
.
execHandle
.
execCol
.
qmsg
,
&
reader
);
qCreateStreamExecTaskInfo
(
handle
.
execHandle
.
exec
.
execCol
.
qmsg
,
&
reader
);
ASSERT
(
handle
.
execHandle
.
execCol
.
task
[
i
]);
ASSERT
(
handle
.
execHandle
.
exec
.
execCol
.
task
[
i
]);
}
}
}
else
{
}
else
{
handle
.
execHandle
.
exec
.
exec
Db
.
pFilterOutTbUid
=
handle
.
execHandle
.
execDb
.
pFilterOutTbUid
=
taosHashInit
(
64
,
taosGetDefaultHashFunction
(
TSDB_DATA_TYPE_BIGINT
),
false
,
HASH_NO_LOCK
);
taosHashInit
(
64
,
taosGetDefaultHashFunction
(
TSDB_DATA_TYPE_BIGINT
),
false
,
HASH_NO_LOCK
);
}
}
taosHashPut
(
pTq
->
handles
,
pKey
,
kLen
,
&
handle
,
sizeof
(
STqHandle
));
taosHashPut
(
pTq
->
handles
,
pKey
,
kLen
,
&
handle
,
sizeof
(
STqHandle
));
...
...
source/dnode/vnode/src/tq/tqPush.c
浏览文件 @
4560b8f2
...
@@ -29,13 +29,13 @@ static int32_t tqLoopExecFromQueue(STQ* pTq, STqHandle* pHandle, SStreamDataSubm
...
@@ -29,13 +29,13 @@ static int32_t tqLoopExecFromQueue(STQ* pTq, STqHandle* pHandle, SStreamDataSubm
}
}
// update processed
// update processed
atomic_store_64
(
&
pHandle
->
pushHandle
.
processedVer
,
pSubmit
->
ver
);
atomic_store_64
(
&
pHandle
->
pushHandle
.
processedVer
,
pSubmit
->
ver
);
streamQ
Set
Success
(
&
pHandle
->
pushHandle
.
inputQ
);
streamQ
ueueProcess
Success
(
&
pHandle
->
pushHandle
.
inputQ
);
streamDataSubmitRefDec
(
pSubmit
);
streamDataSubmitRefDec
(
pSubmit
);
if
(
pRsp
->
blockNum
>
0
)
{
if
(
pRsp
->
blockNum
>
0
)
{
*
ppSubmit
=
pSubmit
;
*
ppSubmit
=
pSubmit
;
return
0
;
return
0
;
}
else
{
}
else
{
pSubmit
=
streamQNextItem
(
&
pHandle
->
pushHandle
.
inputQ
);
pSubmit
=
streamQ
ueue
NextItem
(
&
pHandle
->
pushHandle
.
inputQ
);
}
}
}
}
*
ppSubmit
=
pSubmit
;
*
ppSubmit
=
pSubmit
;
...
@@ -52,14 +52,14 @@ int32_t tqExecFromInputQ(STQ* pTq, STqHandle* pHandle) {
...
@@ -52,14 +52,14 @@ int32_t tqExecFromInputQ(STQ* pTq, STqHandle* pHandle) {
// 2. check processedVer
// 2. check processedVer
// 2.1. if not missed, get msg from queue
// 2.1. if not missed, get msg from queue
// 2.2. if missed, scan wal
// 2.2. if missed, scan wal
pSubmit
=
streamQNextItem
(
&
pHandle
->
pushHandle
.
inputQ
);
pSubmit
=
streamQ
ueue
NextItem
(
&
pHandle
->
pushHandle
.
inputQ
);
while
(
pHandle
->
pushHandle
.
processedVer
<=
pSubmit
->
ver
)
{
while
(
pHandle
->
pushHandle
.
processedVer
<=
pSubmit
->
ver
)
{
// read from wal
// read from wal
}
}
while
(
pHandle
->
pushHandle
.
processedVer
>
pSubmit
->
ver
+
1
)
{
while
(
pHandle
->
pushHandle
.
processedVer
>
pSubmit
->
ver
+
1
)
{
streamQ
Set
Success
(
&
pHandle
->
pushHandle
.
inputQ
);
streamQ
ueueProcess
Success
(
&
pHandle
->
pushHandle
.
inputQ
);
streamDataSubmitRefDec
(
pSubmit
);
streamDataSubmitRefDec
(
pSubmit
);
pSubmit
=
streamQNextItem
(
&
pHandle
->
pushHandle
.
inputQ
);
pSubmit
=
streamQ
ueue
NextItem
(
&
pHandle
->
pushHandle
.
inputQ
);
if
(
pSubmit
==
NULL
)
break
;
if
(
pSubmit
==
NULL
)
break
;
}
}
// 3. exec, after each success, update processed ver
// 3. exec, after each success, update processed ver
...
...
source/dnode/vnode/src/tq/tqRead.c
浏览文件 @
4560b8f2
...
@@ -307,7 +307,7 @@ int32_t tqUpdateTbUidList(STQ* pTq, const SArray* tbUidList, bool isAdd) {
...
@@ -307,7 +307,7 @@ int32_t tqUpdateTbUidList(STQ* pTq, const SArray* tbUidList, bool isAdd) {
STqHandle
*
pExec
=
(
STqHandle
*
)
pIter
;
STqHandle
*
pExec
=
(
STqHandle
*
)
pIter
;
if
(
pExec
->
execHandle
.
subType
==
TOPIC_SUB_TYPE__COLUMN
)
{
if
(
pExec
->
execHandle
.
subType
==
TOPIC_SUB_TYPE__COLUMN
)
{
for
(
int32_t
i
=
0
;
i
<
5
;
i
++
)
{
for
(
int32_t
i
=
0
;
i
<
5
;
i
++
)
{
int32_t
code
=
qUpdateQualifiedTableId
(
pExec
->
execHandle
.
exec
.
exec
Col
.
task
[
i
],
tbUidList
,
isAdd
);
int32_t
code
=
qUpdateQualifiedTableId
(
pExec
->
execHandle
.
execCol
.
task
[
i
],
tbUidList
,
isAdd
);
ASSERT
(
code
==
0
);
ASSERT
(
code
==
0
);
}
}
}
else
if
(
pExec
->
execHandle
.
subType
==
TOPIC_SUB_TYPE__DB
)
{
}
else
if
(
pExec
->
execHandle
.
subType
==
TOPIC_SUB_TYPE__DB
)
{
...
@@ -315,7 +315,7 @@ int32_t tqUpdateTbUidList(STQ* pTq, const SArray* tbUidList, bool isAdd) {
...
@@ -315,7 +315,7 @@ int32_t tqUpdateTbUidList(STQ* pTq, const SArray* tbUidList, bool isAdd) {
int32_t
sz
=
taosArrayGetSize
(
tbUidList
);
int32_t
sz
=
taosArrayGetSize
(
tbUidList
);
for
(
int32_t
i
=
0
;
i
<
sz
;
i
++
)
{
for
(
int32_t
i
=
0
;
i
<
sz
;
i
++
)
{
int64_t
tbUid
=
*
(
int64_t
*
)
taosArrayGet
(
tbUidList
,
i
);
int64_t
tbUid
=
*
(
int64_t
*
)
taosArrayGet
(
tbUidList
,
i
);
taosHashPut
(
pExec
->
execHandle
.
exec
.
exec
Db
.
pFilterOutTbUid
,
&
tbUid
,
sizeof
(
int64_t
),
NULL
,
0
);
taosHashPut
(
pExec
->
execHandle
.
execDb
.
pFilterOutTbUid
,
&
tbUid
,
sizeof
(
int64_t
),
NULL
,
0
);
}
}
}
}
}
else
{
}
else
{
...
...
source/libs/catalog/inc/catalogInt.h
浏览文件 @
4560b8f2
...
@@ -518,6 +518,7 @@ int32_t ctgStbVersionSearchCompare(const void* key1, const void* key2);
...
@@ -518,6 +518,7 @@ int32_t ctgStbVersionSearchCompare(const void* key1, const void* key2);
int32_t
ctgDbVgVersionSearchCompare
(
const
void
*
key1
,
const
void
*
key2
);
int32_t
ctgDbVgVersionSearchCompare
(
const
void
*
key1
,
const
void
*
key2
);
void
ctgFreeSTableMetaOutput
(
STableMetaOutput
*
pOutput
);
void
ctgFreeSTableMetaOutput
(
STableMetaOutput
*
pOutput
);
int32_t
ctgUpdateMsgCtx
(
SCtgMsgCtx
*
pCtx
,
int32_t
reqType
,
void
*
out
,
char
*
target
);
int32_t
ctgUpdateMsgCtx
(
SCtgMsgCtx
*
pCtx
,
int32_t
reqType
,
void
*
out
,
char
*
target
);
char
*
ctgTaskTypeStr
(
CTG_TASK_TYPE
type
);
extern
SCatalogMgmt
gCtgMgmt
;
extern
SCatalogMgmt
gCtgMgmt
;
...
...
source/libs/catalog/src/ctgAsync.c
浏览文件 @
4560b8f2
...
@@ -44,7 +44,7 @@ int32_t ctgInitGetTbMetaTask(SCtgJob *pJob, int32_t taskIdx, SName *name) {
...
@@ -44,7 +44,7 @@ int32_t ctgInitGetTbMetaTask(SCtgJob *pJob, int32_t taskIdx, SName *name) {
taosArrayPush
(
pJob
->
pTasks
,
&
task
);
taosArrayPush
(
pJob
->
pTasks
,
&
task
);
qDebug
(
"QID:0x%"
PRIx64
" t
ask %d type %d initialized, tableName:%s"
,
pJob
->
queryId
,
taskIdx
,
task
.
type
,
name
->
tname
);
qDebug
(
"QID:0x%"
PRIx64
" t
he %d task type %s initialized, tableName:%s"
,
pJob
->
queryId
,
taskIdx
,
ctgTaskTypeStr
(
task
.
type
)
,
name
->
tname
);
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
...
@@ -67,7 +67,7 @@ int32_t ctgInitGetDbVgTask(SCtgJob *pJob, int32_t taskIdx, char *dbFName) {
...
@@ -67,7 +67,7 @@ int32_t ctgInitGetDbVgTask(SCtgJob *pJob, int32_t taskIdx, char *dbFName) {
taosArrayPush
(
pJob
->
pTasks
,
&
task
);
taosArrayPush
(
pJob
->
pTasks
,
&
task
);
qDebug
(
"QID:
%"
PRIx64
" task %d type %d initialized, dbFName:%s"
,
pJob
->
queryId
,
taskIdx
,
task
.
type
,
dbFName
);
qDebug
(
"QID:
0x%"
PRIx64
" the %d task type %s initialized, dbFName:%s"
,
pJob
->
queryId
,
taskIdx
,
ctgTaskTypeStr
(
task
.
type
)
,
dbFName
);
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
...
@@ -90,7 +90,7 @@ int32_t ctgInitGetDbCfgTask(SCtgJob *pJob, int32_t taskIdx, char *dbFName) {
...
@@ -90,7 +90,7 @@ int32_t ctgInitGetDbCfgTask(SCtgJob *pJob, int32_t taskIdx, char *dbFName) {
taosArrayPush
(
pJob
->
pTasks
,
&
task
);
taosArrayPush
(
pJob
->
pTasks
,
&
task
);
qDebug
(
"QID:
%"
PRIx64
" task %d type %d initialized, dbFName:%s"
,
pJob
->
queryId
,
taskIdx
,
task
.
type
,
dbFName
);
qDebug
(
"QID:
0x%"
PRIx64
" the %d task type %s initialized, dbFName:%s"
,
pJob
->
queryId
,
taskIdx
,
ctgTaskTypeStr
(
task
.
type
)
,
dbFName
);
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
...
@@ -113,7 +113,7 @@ int32_t ctgInitGetDbInfoTask(SCtgJob *pJob, int32_t taskIdx, char *dbFName) {
...
@@ -113,7 +113,7 @@ int32_t ctgInitGetDbInfoTask(SCtgJob *pJob, int32_t taskIdx, char *dbFName) {
taosArrayPush
(
pJob
->
pTasks
,
&
task
);
taosArrayPush
(
pJob
->
pTasks
,
&
task
);
qDebug
(
"QID:
%"
PRIx64
" task %d type %d initialized, dbFName:%s"
,
pJob
->
queryId
,
taskIdx
,
task
.
type
,
dbFName
);
qDebug
(
"QID:
0x%"
PRIx64
" the %d task type %s initialized, dbFName:%s"
,
pJob
->
queryId
,
taskIdx
,
ctgTaskTypeStr
(
task
.
type
)
,
dbFName
);
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
...
@@ -143,7 +143,7 @@ int32_t ctgInitGetTbHashTask(SCtgJob *pJob, int32_t taskIdx, SName *name) {
...
@@ -143,7 +143,7 @@ int32_t ctgInitGetTbHashTask(SCtgJob *pJob, int32_t taskIdx, SName *name) {
taosArrayPush
(
pJob
->
pTasks
,
&
task
);
taosArrayPush
(
pJob
->
pTasks
,
&
task
);
qDebug
(
"QID:0x%"
PRIx64
" t
ask %d type %d initialized, tableName:%s"
,
pJob
->
queryId
,
taskIdx
,
task
.
type
,
name
->
tname
);
qDebug
(
"QID:0x%"
PRIx64
" t
he %d task type %s initialized, tableName:%s"
,
pJob
->
queryId
,
taskIdx
,
ctgTaskTypeStr
(
task
.
type
)
,
name
->
tname
);
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
...
@@ -158,7 +158,7 @@ int32_t ctgInitGetQnodeTask(SCtgJob *pJob, int32_t taskIdx) {
...
@@ -158,7 +158,7 @@ int32_t ctgInitGetQnodeTask(SCtgJob *pJob, int32_t taskIdx) {
taosArrayPush
(
pJob
->
pTasks
,
&
task
);
taosArrayPush
(
pJob
->
pTasks
,
&
task
);
qDebug
(
"QID:%"
PRIx64
" t
ask %d type %d initialized"
,
pJob
->
queryId
,
taskIdx
,
task
.
type
);
qDebug
(
"QID:%"
PRIx64
" t
he %d task type %s initialized"
,
pJob
->
queryId
,
taskIdx
,
ctgTaskTypeStr
(
task
.
type
)
);
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
...
@@ -181,7 +181,7 @@ int32_t ctgInitGetIndexTask(SCtgJob *pJob, int32_t taskIdx, char *name) {
...
@@ -181,7 +181,7 @@ int32_t ctgInitGetIndexTask(SCtgJob *pJob, int32_t taskIdx, char *name) {
taosArrayPush
(
pJob
->
pTasks
,
&
task
);
taosArrayPush
(
pJob
->
pTasks
,
&
task
);
qDebug
(
"QID:%"
PRIx64
" t
ask %d type %d initialized, indexFName:%s"
,
pJob
->
queryId
,
taskIdx
,
task
.
type
,
name
);
qDebug
(
"QID:%"
PRIx64
" t
he %d task type %s initialized, indexFName:%s"
,
pJob
->
queryId
,
taskIdx
,
ctgTaskTypeStr
(
task
.
type
)
,
name
);
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
...
@@ -204,7 +204,7 @@ int32_t ctgInitGetUdfTask(SCtgJob *pJob, int32_t taskIdx, char *name) {
...
@@ -204,7 +204,7 @@ int32_t ctgInitGetUdfTask(SCtgJob *pJob, int32_t taskIdx, char *name) {
taosArrayPush
(
pJob
->
pTasks
,
&
task
);
taosArrayPush
(
pJob
->
pTasks
,
&
task
);
qDebug
(
"QID:%"
PRIx64
" t
ask %d type %d initialized, udfName:%s"
,
pJob
->
queryId
,
taskIdx
,
task
.
type
,
name
);
qDebug
(
"QID:%"
PRIx64
" t
he %d task type %s initialized, udfName:%s"
,
pJob
->
queryId
,
taskIdx
,
ctgTaskTypeStr
(
task
.
type
)
,
name
);
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
...
@@ -227,11 +227,96 @@ int32_t ctgInitGetUserTask(SCtgJob *pJob, int32_t taskIdx, SUserAuthInfo *user)
...
@@ -227,11 +227,96 @@ int32_t ctgInitGetUserTask(SCtgJob *pJob, int32_t taskIdx, SUserAuthInfo *user)
taosArrayPush
(
pJob
->
pTasks
,
&
task
);
taosArrayPush
(
pJob
->
pTasks
,
&
task
);
qDebug
(
"QID:%"
PRIx64
" t
ask %d type %d initialized, user:%s"
,
pJob
->
queryId
,
taskIdx
,
task
.
type
,
user
->
user
);
qDebug
(
"QID:%"
PRIx64
" t
he %d task type %s initialized, user:%s"
,
pJob
->
queryId
,
taskIdx
,
ctgTaskTypeStr
(
task
.
type
)
,
user
->
user
);
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
int32_t
ctgHandleForceUpdate
(
SCatalog
*
pCtg
,
SCtgJob
*
pJob
,
const
SCatalogReq
*
pReq
)
{
int32_t
dbNum
=
pJob
->
dbCfgNum
+
pJob
->
dbVgNum
+
pJob
->
dbInfoNum
;
if
(
dbNum
>
0
)
{
if
(
dbNum
>
pJob
->
dbCfgNum
&&
dbNum
>
pJob
->
dbVgNum
&&
dbNum
>
pJob
->
dbInfoNum
)
{
SHashObj
*
pDb
=
taosHashInit
(
dbNum
,
taosGetDefaultHashFunction
(
TSDB_DATA_TYPE_BINARY
),
false
,
HASH_NO_LOCK
);
if
(
NULL
==
pDb
)
{
CTG_ERR_RET
(
TSDB_CODE_OUT_OF_MEMORY
);
}
for
(
int32_t
i
=
0
;
i
<
pJob
->
dbVgNum
;
++
i
)
{
char
*
dbFName
=
taosArrayGet
(
pReq
->
pDbVgroup
,
i
);
taosHashPut
(
pDb
,
dbFName
,
strlen
(
dbFName
),
dbFName
,
TSDB_DB_FNAME_LEN
);
}
for
(
int32_t
i
=
0
;
i
<
pJob
->
dbCfgNum
;
++
i
)
{
char
*
dbFName
=
taosArrayGet
(
pReq
->
pDbCfg
,
i
);
taosHashPut
(
pDb
,
dbFName
,
strlen
(
dbFName
),
dbFName
,
TSDB_DB_FNAME_LEN
);
}
for
(
int32_t
i
=
0
;
i
<
pJob
->
dbInfoNum
;
++
i
)
{
char
*
dbFName
=
taosArrayGet
(
pReq
->
pDbInfo
,
i
);
taosHashPut
(
pDb
,
dbFName
,
strlen
(
dbFName
),
dbFName
,
TSDB_DB_FNAME_LEN
);
}
char
*
dbFName
=
taosHashIterate
(
pDb
,
NULL
);
while
(
dbFName
)
{
ctgDropDbVgroupEnqueue
(
pCtg
,
dbFName
,
true
);
dbFName
=
taosHashIterate
(
pDb
,
dbFName
);
}
taosHashCleanup
(
pDb
);
}
else
{
for
(
int32_t
i
=
0
;
i
<
pJob
->
dbVgNum
;
++
i
)
{
char
*
dbFName
=
taosArrayGet
(
pReq
->
pDbVgroup
,
i
);
CTG_ERR_RET
(
ctgDropDbVgroupEnqueue
(
pCtg
,
dbFName
,
true
));
}
for
(
int32_t
i
=
0
;
i
<
pJob
->
dbCfgNum
;
++
i
)
{
char
*
dbFName
=
taosArrayGet
(
pReq
->
pDbCfg
,
i
);
CTG_ERR_RET
(
ctgDropDbVgroupEnqueue
(
pCtg
,
dbFName
,
true
));
}
for
(
int32_t
i
=
0
;
i
<
pJob
->
dbInfoNum
;
++
i
)
{
char
*
dbFName
=
taosArrayGet
(
pReq
->
pDbInfo
,
i
);
CTG_ERR_RET
(
ctgDropDbVgroupEnqueue
(
pCtg
,
dbFName
,
true
));
}
}
}
int32_t
tbNum
=
pJob
->
tbMetaNum
+
pJob
->
tbHashNum
;
if
(
tbNum
>
0
)
{
if
(
tbNum
>
pJob
->
tbMetaNum
&&
tbNum
>
pJob
->
tbHashNum
)
{
SHashObj
*
pTb
=
taosHashInit
(
tbNum
,
taosGetDefaultHashFunction
(
TSDB_DATA_TYPE_BINARY
),
false
,
HASH_NO_LOCK
);
for
(
int32_t
i
=
0
;
i
<
pJob
->
tbMetaNum
;
++
i
)
{
SName
*
name
=
taosArrayGet
(
pReq
->
pTableMeta
,
i
);
taosHashPut
(
pTb
,
name
,
sizeof
(
SName
),
name
,
sizeof
(
SName
));
}
for
(
int32_t
i
=
0
;
i
<
pJob
->
tbHashNum
;
++
i
)
{
SName
*
name
=
taosArrayGet
(
pReq
->
pTableHash
,
i
);
taosHashPut
(
pTb
,
name
,
sizeof
(
SName
),
name
,
sizeof
(
SName
));
}
SName
*
name
=
taosHashIterate
(
pTb
,
NULL
);
while
(
name
)
{
catalogRemoveTableMeta
(
pCtg
,
name
);
name
=
taosHashIterate
(
pTb
,
name
);
}
taosHashCleanup
(
pTb
);
}
else
{
for
(
int32_t
i
=
0
;
i
<
pJob
->
tbMetaNum
;
++
i
)
{
SName
*
name
=
taosArrayGet
(
pReq
->
pTableMeta
,
i
);
catalogRemoveTableMeta
(
pCtg
,
name
);
}
for
(
int32_t
i
=
0
;
i
<
pJob
->
tbHashNum
;
++
i
)
{
SName
*
name
=
taosArrayGet
(
pReq
->
pTableHash
,
i
);
catalogRemoveTableMeta
(
pCtg
,
name
);
}
}
}
return
TSDB_CODE_SUCCESS
;
}
int32_t
ctgInitJob
(
CTG_PARAMS
,
SCtgJob
**
job
,
uint64_t
reqId
,
const
SCatalogReq
*
pReq
,
catalogCallback
fp
,
void
*
param
,
int32_t
*
taskNum
)
{
int32_t
ctgInitJob
(
CTG_PARAMS
,
SCtgJob
**
job
,
uint64_t
reqId
,
const
SCatalogReq
*
pReq
,
catalogCallback
fp
,
void
*
param
,
int32_t
*
taskNum
)
{
int32_t
code
=
0
;
int32_t
code
=
0
;
...
@@ -283,12 +368,13 @@ int32_t ctgInitJob(CTG_PARAMS, SCtgJob** job, uint64_t reqId, const SCatalogReq*
...
@@ -283,12 +368,13 @@ int32_t ctgInitJob(CTG_PARAMS, SCtgJob** job, uint64_t reqId, const SCatalogReq*
CTG_ERR_JRET
(
TSDB_CODE_OUT_OF_MEMORY
);
CTG_ERR_JRET
(
TSDB_CODE_OUT_OF_MEMORY
);
}
}
if
(
pReq
->
forceUpdate
)
{
CTG_ERR_JRET
(
ctgHandleForceUpdate
(
pCtg
,
pJob
,
pReq
));
}
int32_t
taskIdx
=
0
;
int32_t
taskIdx
=
0
;
for
(
int32_t
i
=
0
;
i
<
dbVgNum
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
dbVgNum
;
++
i
)
{
char
*
dbFName
=
taosArrayGet
(
pReq
->
pDbVgroup
,
i
);
char
*
dbFName
=
taosArrayGet
(
pReq
->
pDbVgroup
,
i
);
if
(
pReq
->
forceUpdate
)
{
ctgDropDbVgroupEnqueue
(
pCtg
,
dbFName
,
true
);
}
CTG_ERR_JRET
(
ctgInitGetDbVgTask
(
pJob
,
taskIdx
++
,
dbFName
));
CTG_ERR_JRET
(
ctgInitGetDbVgTask
(
pJob
,
taskIdx
++
,
dbFName
));
}
}
...
@@ -304,9 +390,6 @@ int32_t ctgInitJob(CTG_PARAMS, SCtgJob** job, uint64_t reqId, const SCatalogReq*
...
@@ -304,9 +390,6 @@ int32_t ctgInitJob(CTG_PARAMS, SCtgJob** job, uint64_t reqId, const SCatalogReq*
for
(
int32_t
i
=
0
;
i
<
tbMetaNum
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
tbMetaNum
;
++
i
)
{
SName
*
name
=
taosArrayGet
(
pReq
->
pTableMeta
,
i
);
SName
*
name
=
taosArrayGet
(
pReq
->
pTableMeta
,
i
);
if
(
pReq
->
forceUpdate
)
{
catalogRemoveTableMeta
(
pCtg
,
name
);
}
CTG_ERR_JRET
(
ctgInitGetTbMetaTask
(
pJob
,
taskIdx
++
,
name
));
CTG_ERR_JRET
(
ctgInitGetTbMetaTask
(
pJob
,
taskIdx
++
,
name
));
}
}
...
@@ -342,7 +425,7 @@ int32_t ctgInitJob(CTG_PARAMS, SCtgJob** job, uint64_t reqId, const SCatalogReq*
...
@@ -342,7 +425,7 @@ int32_t ctgInitJob(CTG_PARAMS, SCtgJob** job, uint64_t reqId, const SCatalogReq*
taosAcquireRef
(
gCtgMgmt
.
jobPool
,
pJob
->
refId
);
taosAcquireRef
(
gCtgMgmt
.
jobPool
,
pJob
->
refId
);
qDebug
(
"QID:
%"
PRIx64
", job %"
PRIx64
" initialized, task num %d"
,
pJob
->
queryId
,
pJob
->
refId
,
*
taskNum
);
qDebug
(
"QID:
0x%"
PRIx64
", jobId: 0x%"
PRIx64
" initialized, task num %d, forceUpdate %d"
,
pJob
->
queryId
,
pJob
->
refId
,
*
taskNum
,
pReq
->
forceUpdate
);
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
...
@@ -1108,7 +1191,7 @@ int32_t ctgLaunchJob(SCtgJob *pJob) {
...
@@ -1108,7 +1191,7 @@ int32_t ctgLaunchJob(SCtgJob *pJob) {
for
(
int32_t
i
=
0
;
i
<
taskNum
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
taskNum
;
++
i
)
{
SCtgTask
*
pTask
=
taosArrayGet
(
pJob
->
pTasks
,
i
);
SCtgTask
*
pTask
=
taosArrayGet
(
pJob
->
pTasks
,
i
);
qDebug
(
"QID:
%"
PRIx64
" start to launch task %d"
,
pJob
->
queryId
,
pTask
->
taskId
);
qDebug
(
"QID:
0x%"
PRIx64
" start to launch task %d"
,
pJob
->
queryId
,
pTask
->
taskId
);
CTG_ERR_RET
((
*
gCtgAsyncFps
[
pTask
->
type
].
launchFp
)(
pTask
));
CTG_ERR_RET
((
*
gCtgAsyncFps
[
pTask
->
type
].
launchFp
)(
pTask
));
}
}
...
...
source/libs/catalog/src/ctgRemote.c
浏览文件 @
4560b8f2
...
@@ -177,7 +177,7 @@ int32_t ctgHandleMsgCallback(void *param, const SDataBuf *pMsg, int32_t rspCode)
...
@@ -177,7 +177,7 @@ int32_t ctgHandleMsgCallback(void *param, const SDataBuf *pMsg, int32_t rspCode)
SCtgTask
*
pTask
=
taosArrayGet
(
pJob
->
pTasks
,
cbParam
->
taskId
);
SCtgTask
*
pTask
=
taosArrayGet
(
pJob
->
pTasks
,
cbParam
->
taskId
);
qDebug
(
"QID:%"
PRIx64
" task %d start to handle rsp %s"
,
pJob
->
queryId
,
pTask
->
taskId
,
TMSG_INFO
(
cbParam
->
reqType
+
1
));
qDebug
(
"QID:
0x
%"
PRIx64
" task %d start to handle rsp %s"
,
pJob
->
queryId
,
pTask
->
taskId
,
TMSG_INFO
(
cbParam
->
reqType
+
1
));
CTG_ERR_JRET
((
*
gCtgAsyncFps
[
pTask
->
type
].
handleRspFp
)(
pTask
,
cbParam
->
reqType
,
pMsg
,
rspCode
));
CTG_ERR_JRET
((
*
gCtgAsyncFps
[
pTask
->
type
].
handleRspFp
)(
pTask
,
cbParam
->
reqType
,
pMsg
,
rspCode
));
...
@@ -244,7 +244,7 @@ int32_t ctgAsyncSendMsg(CTG_PARAMS, SCtgTask* pTask, int32_t msgType, void *msg,
...
@@ -244,7 +244,7 @@ int32_t ctgAsyncSendMsg(CTG_PARAMS, SCtgTask* pTask, int32_t msgType, void *msg,
CTG_ERR_JRET
(
code
);
CTG_ERR_JRET
(
code
);
}
}
ctgDebug
(
"req msg sent, reqId:%"
PRIx64
", msg type:%d, %s"
,
pTask
->
pJob
->
queryId
,
msgType
,
TMSG_INFO
(
msgType
));
ctgDebug
(
"req msg sent, reqId:
0x
%"
PRIx64
", msg type:%d, %s"
,
pTask
->
pJob
->
queryId
,
msgType
,
TMSG_INFO
(
msgType
));
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
_return:
_return:
...
@@ -565,7 +565,7 @@ int32_t ctgGetTbMetaFromVnode(CTG_PARAMS, const SName* pTableName, SVgroupInfo *
...
@@ -565,7 +565,7 @@ int32_t ctgGetTbMetaFromVnode(CTG_PARAMS, const SName* pTableName, SVgroupInfo *
}
}
CTG_ERR_RET
(
ctgUpdateMsgCtx
(
&
pTask
->
msgCtx
,
reqType
,
pOut
,
tbFName
));
CTG_ERR_RET
(
ctgUpdateMsgCtx
(
&
pTask
->
msgCtx
,
reqType
,
pOut
,
tbFName
));
CTG_RET
(
ctgAsyncSendMsg
(
CTG_PARAMS_LIST
()
,
pTask
,
reqType
,
msg
,
msgLen
));
CTG_RET
(
ctgAsyncSendMsg
(
pCtg
,
pTrans
,
&
vgroupInfo
->
epSet
,
pTask
,
reqType
,
msg
,
msgLen
));
}
}
SRpcMsg
rpcMsg
=
{
SRpcMsg
rpcMsg
=
{
...
...
source/libs/catalog/src/ctgUtil.c
浏览文件 @
4560b8f2
...
@@ -19,6 +19,31 @@
...
@@ -19,6 +19,31 @@
#include "catalogInt.h"
#include "catalogInt.h"
#include "systable.h"
#include "systable.h"
char
*
ctgTaskTypeStr
(
CTG_TASK_TYPE
type
)
{
switch
(
type
)
{
case
CTG_TASK_GET_QNODE
:
return
"[get qnode list]"
;
case
CTG_TASK_GET_DB_VGROUP
:
return
"[get db vgroup]"
;
case
CTG_TASK_GET_DB_CFG
:
return
"[get db cfg]"
;
case
CTG_TASK_GET_DB_INFO
:
return
"[get db info]"
;
case
CTG_TASK_GET_TB_META
:
return
"[get table meta]"
;
case
CTG_TASK_GET_TB_HASH
:
return
"[get table hash]"
;
case
CTG_TASK_GET_INDEX
:
return
"[get index]"
;
case
CTG_TASK_GET_UDF
:
return
"[get udf]"
;
case
CTG_TASK_GET_USER
:
return
"[get user]"
;
default:
return
"unknown"
;
}
}
void
ctgFreeSMetaData
(
SMetaData
*
pData
)
{
void
ctgFreeSMetaData
(
SMetaData
*
pData
)
{
taosArrayDestroy
(
pData
->
pTableMeta
);
taosArrayDestroy
(
pData
->
pTableMeta
);
pData
->
pTableMeta
=
NULL
;
pData
->
pTableMeta
=
NULL
;
...
@@ -477,6 +502,9 @@ int32_t ctgGetVgInfoFromHashValue(SCatalog *pCtg, SDBVgInfo *dbInfo, const SName
...
@@ -477,6 +502,9 @@ int32_t ctgGetVgInfoFromHashValue(SCatalog *pCtg, SDBVgInfo *dbInfo, const SName
*
pVgroup
=
*
vgInfo
;
*
pVgroup
=
*
vgInfo
;
ctgDebug
(
"Got tb %s hash vgroup, vgId %d, epNum %d, current %s port %d"
,
tbFullName
,
vgInfo
->
vgId
,
vgInfo
->
epSet
.
numOfEps
,
vgInfo
->
epSet
.
eps
[
vgInfo
->
epSet
.
inUse
].
fqdn
,
vgInfo
->
epSet
.
eps
[
vgInfo
->
epSet
.
inUse
].
port
);
CTG_RET
(
code
);
CTG_RET
(
code
);
}
}
...
...
source/libs/executor/inc/executorimpl.h
浏览文件 @
4560b8f2
...
@@ -524,6 +524,17 @@ typedef struct SProjectOperatorInfo {
...
@@ -524,6 +524,17 @@ typedef struct SProjectOperatorInfo {
int64_t
curOutput
;
int64_t
curOutput
;
}
SProjectOperatorInfo
;
}
SProjectOperatorInfo
;
typedef
struct
SIndefOperatorInfo
{
SOptrBasicInfo
binfo
;
SAggSupporter
aggSup
;
SArray
*
pPseudoColInfo
;
SExprInfo
*
pScalarExpr
;
int32_t
numOfScalarExpr
;
SqlFunctionCtx
*
pScalarCtx
;
int32_t
*
rowCellInfoOffset
;
}
SIndefOperatorInfo
;
typedef
struct
SFillOperatorInfo
{
typedef
struct
SFillOperatorInfo
{
struct
SFillInfo
*
pFillInfo
;
struct
SFillInfo
*
pFillInfo
;
SSDataBlock
*
pRes
;
SSDataBlock
*
pRes
;
...
@@ -770,6 +781,7 @@ SOperatorInfo* createSysTableScanOperatorInfo(void* readHandle, SSystemTableScan
...
@@ -770,6 +781,7 @@ SOperatorInfo* createSysTableScanOperatorInfo(void* readHandle, SSystemTableScan
SOperatorInfo
*
createAggregateOperatorInfo
(
SOperatorInfo
*
downstream
,
SExprInfo
*
pExprInfo
,
int32_t
numOfCols
,
SSDataBlock
*
pResultBlock
,
SExprInfo
*
pScalarExprInfo
,
SOperatorInfo
*
createAggregateOperatorInfo
(
SOperatorInfo
*
downstream
,
SExprInfo
*
pExprInfo
,
int32_t
numOfCols
,
SSDataBlock
*
pResultBlock
,
SExprInfo
*
pScalarExprInfo
,
int32_t
numOfScalarExpr
,
SExecTaskInfo
*
pTaskInfo
);
int32_t
numOfScalarExpr
,
SExecTaskInfo
*
pTaskInfo
);
SOperatorInfo
*
createIndefinitOutputOperatorInfo
(
SOperatorInfo
*
downstream
,
SPhysiNode
*
pNode
,
SExecTaskInfo
*
pTaskInfo
);
SOperatorInfo
*
createProjectOperatorInfo
(
SOperatorInfo
*
downstream
,
SExprInfo
*
pExprInfo
,
int32_t
num
,
SSDataBlock
*
pResBlock
,
SLimit
*
pLimit
,
SLimit
*
pSlimit
,
SNode
*
pCondition
,
SExecTaskInfo
*
pTaskInfo
);
SOperatorInfo
*
createProjectOperatorInfo
(
SOperatorInfo
*
downstream
,
SExprInfo
*
pExprInfo
,
int32_t
num
,
SSDataBlock
*
pResBlock
,
SLimit
*
pLimit
,
SLimit
*
pSlimit
,
SNode
*
pCondition
,
SExecTaskInfo
*
pTaskInfo
);
SOperatorInfo
*
createSortOperatorInfo
(
SOperatorInfo
*
downstream
,
SSDataBlock
*
pResBlock
,
SArray
*
pSortInfo
,
SExprInfo
*
pExprInfo
,
int32_t
numOfCols
,
SOperatorInfo
*
createSortOperatorInfo
(
SOperatorInfo
*
downstream
,
SSDataBlock
*
pResBlock
,
SArray
*
pSortInfo
,
SExprInfo
*
pExprInfo
,
int32_t
numOfCols
,
SArray
*
pIndexMap
,
SExecTaskInfo
*
pTaskInfo
);
SArray
*
pIndexMap
,
SExecTaskInfo
*
pTaskInfo
);
...
...
source/libs/executor/src/executorimpl.c
浏览文件 @
4560b8f2
...
@@ -108,8 +108,6 @@ static SColumnInfo* extractColumnFilterInfo(SExprInfo* pExpr, int32_t numOfOutpu
...
@@ -108,8 +108,6 @@ static SColumnInfo* extractColumnFilterInfo(SExprInfo* pExpr, int32_t numOfOutpu
static
void
releaseQueryBuf
(
size_t
numOfTables
);
static
void
releaseQueryBuf
(
size_t
numOfTables
);
static
int32_t
getNumOfScanTimes
(
STaskAttr
*
pQueryAttr
);
static
void
destroySFillOperatorInfo
(
void
*
param
,
int32_t
numOfOutput
);
static
void
destroySFillOperatorInfo
(
void
*
param
,
int32_t
numOfOutput
);
static
void
destroyProjectOperatorInfo
(
void
*
param
,
int32_t
numOfOutput
);
static
void
destroyProjectOperatorInfo
(
void
*
param
,
int32_t
numOfOutput
);
static
void
destroyTagScanOperatorInfo
(
void
*
param
,
int32_t
numOfOutput
);
static
void
destroyTagScanOperatorInfo
(
void
*
param
,
int32_t
numOfOutput
);
...
@@ -3636,18 +3634,6 @@ static SSDataBlock* doProjectOperation(SOperatorInfo* pOperator) {
...
@@ -3636,18 +3634,6 @@ static SSDataBlock* doProjectOperation(SOperatorInfo* pOperator) {
break
;
break
;
}
}
#if 0
// Return result of the previous group in the firstly.
if (false) {
if (pRes->info.rows > 0) {
pProjectInfo->existDataBlock = pBlock;
break;
} else { // init output buffer for a new group data
initCtxOutputBuffer(pInfo->pCtx, pOperator->numOfExprs);
}
}
#endif
// the pDataBlock are always the same one, no need to call this again
// the pDataBlock are always the same one, no need to call this again
int32_t
code
=
getTableScanInfo
(
pOperator
->
pDownstream
[
0
],
&
order
,
&
scanFlag
);
int32_t
code
=
getTableScanInfo
(
pOperator
->
pDownstream
[
0
],
&
order
,
&
scanFlag
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
...
@@ -3793,6 +3779,17 @@ static SSDataBlock* doFill(SOperatorInfo* pOperator) {
...
@@ -3793,6 +3779,17 @@ static SSDataBlock* doFill(SOperatorInfo* pOperator) {
}
}
}
}
static
void
destroyExprInfo
(
SExprInfo
*
pExpr
,
int32_t
numOfExprs
)
{
for
(
int32_t
i
=
0
;
i
<
numOfExprs
;
++
i
)
{
SExprInfo
*
pExprInfo
=
&
pExpr
[
i
];
if
(
pExprInfo
->
pExpr
->
nodeType
==
QUERY_NODE_COLUMN
)
{
taosMemoryFree
(
pExprInfo
->
base
.
pParam
[
0
].
pCol
);
}
taosMemoryFree
(
pExprInfo
->
base
.
pParam
);
taosMemoryFree
(
pExprInfo
->
pExpr
);
}
}
static
void
destroyOperatorInfo
(
SOperatorInfo
*
pOperator
)
{
static
void
destroyOperatorInfo
(
SOperatorInfo
*
pOperator
)
{
if
(
pOperator
==
NULL
)
{
if
(
pOperator
==
NULL
)
{
return
;
return
;
...
@@ -3812,14 +3809,7 @@ static void destroyOperatorInfo(SOperatorInfo* pOperator) {
...
@@ -3812,14 +3809,7 @@ static void destroyOperatorInfo(SOperatorInfo* pOperator) {
}
}
if
(
pOperator
->
pExpr
!=
NULL
)
{
if
(
pOperator
->
pExpr
!=
NULL
)
{
for
(
int32_t
i
=
0
;
i
<
pOperator
->
numOfExprs
;
++
i
)
{
destroyExprInfo
(
pOperator
->
pExpr
,
pOperator
->
numOfExprs
);
SExprInfo
*
pExprInfo
=
&
pOperator
->
pExpr
[
i
];
if
(
pExprInfo
->
pExpr
->
nodeType
==
QUERY_NODE_COLUMN
)
{
taosMemoryFree
(
pExprInfo
->
base
.
pParam
[
0
].
pCol
);
}
taosMemoryFree
(
pExprInfo
->
base
.
pParam
);
taosMemoryFree
(
pExprInfo
->
pExpr
);
}
}
}
taosMemoryFreeClear
(
pOperator
->
pExpr
);
taosMemoryFreeClear
(
pOperator
->
pExpr
);
...
@@ -4008,6 +3998,19 @@ static void destroyProjectOperatorInfo(void* param, int32_t numOfOutput) {
...
@@ -4008,6 +3998,19 @@ static void destroyProjectOperatorInfo(void* param, int32_t numOfOutput) {
taosArrayDestroy
(
pInfo
->
pPseudoColInfo
);
taosArrayDestroy
(
pInfo
->
pPseudoColInfo
);
}
}
static
void
destroyIndefinitOperatorInfo
(
void
*
param
,
int32_t
numOfOutput
)
{
SIndefOperatorInfo
*
pInfo
=
(
SIndefOperatorInfo
*
)
param
;
doDestroyBasicInfo
(
&
pInfo
->
binfo
,
numOfOutput
);
taosArrayDestroy
(
pInfo
->
pPseudoColInfo
);
cleanupAggSup
(
&
pInfo
->
aggSup
);
destroySqlFunctionCtx
(
pInfo
->
pScalarCtx
,
numOfOutput
);
destroyExprInfo
(
pInfo
->
pScalarExpr
,
pInfo
->
numOfScalarExpr
);
taosMemoryFree
(
pInfo
->
rowCellInfoOffset
);
}
void
destroyExchangeOperatorInfo
(
void
*
param
,
int32_t
numOfOutput
)
{
void
destroyExchangeOperatorInfo
(
void
*
param
,
int32_t
numOfOutput
)
{
SExchangeInfo
*
pExInfo
=
(
SExchangeInfo
*
)
param
;
SExchangeInfo
*
pExInfo
=
(
SExchangeInfo
*
)
param
;
taosArrayDestroy
(
pExInfo
->
pSources
);
taosArrayDestroy
(
pExInfo
->
pSources
);
...
@@ -4085,6 +4088,136 @@ _error:
...
@@ -4085,6 +4088,136 @@ _error:
return
NULL
;
return
NULL
;
}
}
static
SSDataBlock
*
doApplyIndefinitFunction
(
SOperatorInfo
*
pOperator
)
{
SIndefOperatorInfo
*
pIndefInfo
=
pOperator
->
info
;
SOptrBasicInfo
*
pInfo
=
&
pIndefInfo
->
binfo
;
SSDataBlock
*
pRes
=
pInfo
->
pRes
;
blockDataCleanup
(
pRes
);
SExecTaskInfo
*
pTaskInfo
=
pOperator
->
pTaskInfo
;
if
(
pOperator
->
status
==
OP_EXEC_DONE
)
{
return
NULL
;
}
int64_t
st
=
0
;
int32_t
order
=
0
;
int32_t
scanFlag
=
0
;
if
(
pOperator
->
cost
.
openCost
==
0
)
{
st
=
taosGetTimestampUs
();
}
SOperatorInfo
*
downstream
=
pOperator
->
pDownstream
[
0
];
while
(
1
)
{
// The downstream exec may change the value of the newgroup, so use a local variable instead.
SSDataBlock
*
pBlock
=
downstream
->
fpSet
.
getNextFn
(
downstream
);
if
(
pBlock
==
NULL
)
{
doSetOperatorCompleted
(
pOperator
);
break
;
}
// the pDataBlock are always the same one, no need to call this again
int32_t
code
=
getTableScanInfo
(
pOperator
->
pDownstream
[
0
],
&
order
,
&
scanFlag
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
longjmp
(
pTaskInfo
->
env
,
code
);
}
// there is an scalar expression that needs to be calculated before apply the group aggregation.
if
(
pIndefInfo
->
pScalarExpr
!=
NULL
)
{
code
=
projectApplyFunctions
(
pIndefInfo
->
pScalarExpr
,
pBlock
,
pBlock
,
pIndefInfo
->
pScalarCtx
,
pIndefInfo
->
numOfScalarExpr
,
pIndefInfo
->
pPseudoColInfo
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
longjmp
(
pTaskInfo
->
env
,
code
);
}
}
setInputDataBlock
(
pOperator
,
pInfo
->
pCtx
,
pBlock
,
order
,
scanFlag
,
false
);
blockDataEnsureCapacity
(
pInfo
->
pRes
,
pInfo
->
pRes
->
info
.
rows
+
pBlock
->
info
.
rows
);
code
=
projectApplyFunctions
(
pOperator
->
pExpr
,
pInfo
->
pRes
,
pBlock
,
pInfo
->
pCtx
,
pOperator
->
numOfExprs
,
pIndefInfo
->
pPseudoColInfo
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
longjmp
(
pTaskInfo
->
env
,
code
);
}
}
size_t
rows
=
pInfo
->
pRes
->
info
.
rows
;
pOperator
->
resultInfo
.
totalRows
+=
rows
;
if
(
pOperator
->
cost
.
openCost
==
0
)
{
pOperator
->
cost
.
openCost
=
(
taosGetTimestampUs
()
-
st
)
/
1000
.
0
;
}
return
(
rows
>
0
)
?
pInfo
->
pRes
:
NULL
;
}
SOperatorInfo
*
createIndefinitOutputOperatorInfo
(
SOperatorInfo
*
downstream
,
SPhysiNode
*
pNode
,
SExecTaskInfo
*
pTaskInfo
)
{
SIndefOperatorInfo
*
pInfo
=
taosMemoryCalloc
(
1
,
sizeof
(
SIndefOperatorInfo
));
SOperatorInfo
*
pOperator
=
taosMemoryCalloc
(
1
,
sizeof
(
SOperatorInfo
));
if
(
pInfo
==
NULL
||
pOperator
==
NULL
)
{
goto
_error
;
}
SIndefRowsFuncPhysiNode
*
pPhyNode
=
(
SIndefRowsFuncPhysiNode
*
)
pNode
;
int32_t
numOfExpr
=
0
;
SExprInfo
*
pExprInfo
=
createExprInfo
(
pPhyNode
->
pVectorFuncs
,
NULL
,
&
numOfExpr
);
int32_t
numOfScalarExpr
=
0
;
if
(
pPhyNode
->
pExprs
!=
NULL
)
{
pInfo
->
pScalarExpr
=
createExprInfo
(
pPhyNode
->
pExprs
,
NULL
,
&
numOfScalarExpr
);
pInfo
->
pScalarCtx
=
createSqlFunctionCtx
(
pInfo
->
pScalarExpr
,
numOfScalarExpr
,
&
pInfo
->
rowCellInfoOffset
);
}
SSDataBlock
*
pResBlock
=
createResDataBlock
(
pPhyNode
->
node
.
pOutputDataBlockDesc
);
;
int32_t
numOfRows
=
4096
;
size_t
keyBufSize
=
sizeof
(
int64_t
)
+
sizeof
(
int64_t
)
+
POINTER_BYTES
;
// Make sure the size of SSDataBlock will never exceed the size of 2MB.
int32_t
TWOMB
=
2
*
1024
*
1024
;
if
(
numOfRows
*
pResBlock
->
info
.
rowSize
>
TWOMB
)
{
numOfRows
=
TWOMB
/
pResBlock
->
info
.
rowSize
;
}
initResultSizeInfo
(
pOperator
,
numOfRows
);
initAggInfo
(
&
pInfo
->
binfo
,
&
pInfo
->
aggSup
,
pExprInfo
,
numOfExpr
,
pResBlock
,
keyBufSize
,
pTaskInfo
->
id
.
str
);
setFunctionResultOutput
(
&
pInfo
->
binfo
,
&
pInfo
->
aggSup
,
MAIN_SCAN
,
numOfExpr
,
pTaskInfo
);
pInfo
->
binfo
.
pRes
=
pResBlock
;
pInfo
->
numOfScalarExpr
=
numOfScalarExpr
;
pInfo
->
pPseudoColInfo
=
setRowTsColumnOutputInfo
(
pInfo
->
binfo
.
pCtx
,
numOfExpr
);
pOperator
->
name
=
"IndefinitOperator"
;
pOperator
->
operatorType
=
QUERY_NODE_PHYSICAL_PLAN_PROJECT
;
pOperator
->
blocking
=
false
;
pOperator
->
status
=
OP_NOT_OPENED
;
pOperator
->
info
=
pInfo
;
pOperator
->
pExpr
=
pExprInfo
;
pOperator
->
numOfExprs
=
numOfExpr
;
pOperator
->
pTaskInfo
=
pTaskInfo
;
pOperator
->
fpSet
=
createOperatorFpSet
(
operatorDummyOpenFn
,
doApplyIndefinitFunction
,
NULL
,
NULL
,
destroyIndefinitOperatorInfo
,
NULL
,
NULL
,
NULL
);
int32_t
code
=
appendDownstream
(
pOperator
,
&
downstream
,
1
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
goto
_error
;
}
return
pOperator
;
_error:
taosMemoryFree
(
pInfo
);
taosMemoryFree
(
pOperator
);
pTaskInfo
->
code
=
TSDB_CODE_OUT_OF_MEMORY
;
return
NULL
;
}
static
int32_t
initFillInfo
(
SFillOperatorInfo
*
pInfo
,
SExprInfo
*
pExpr
,
int32_t
numOfCols
,
SNodeListNode
*
pValNode
,
static
int32_t
initFillInfo
(
SFillOperatorInfo
*
pInfo
,
SExprInfo
*
pExpr
,
int32_t
numOfCols
,
SNodeListNode
*
pValNode
,
STimeWindow
win
,
int32_t
capacity
,
const
char
*
id
,
SInterval
*
pInterval
,
int32_t
fillType
)
{
STimeWindow
win
,
int32_t
capacity
,
const
char
*
id
,
SInterval
*
pInterval
,
int32_t
fillType
)
{
SFillColInfo
*
pColInfo
=
createFillColInfo
(
pExpr
,
numOfCols
,
pValNode
);
SFillColInfo
*
pColInfo
=
createFillColInfo
(
pExpr
,
numOfCols
,
pValNode
);
...
@@ -4589,6 +4722,8 @@ SOperatorInfo* createOperatorTree(SPhysiNode* pPhyNode, SExecTaskInfo* pTaskInfo
...
@@ -4589,6 +4722,8 @@ SOperatorInfo* createOperatorTree(SPhysiNode* pPhyNode, SExecTaskInfo* pTaskInfo
SInterval
*
pInterval
=
&
((
SIntervalAggOperatorInfo
*
)
ops
[
0
]
->
info
)
->
interval
;
SInterval
*
pInterval
=
&
((
SIntervalAggOperatorInfo
*
)
ops
[
0
]
->
info
)
->
interval
;
pOptr
=
createFillOperatorInfo
(
ops
[
0
],
pExprInfo
,
num
,
pInterval
,
&
pFillNode
->
timeRange
,
pResBlock
,
pFillNode
->
mode
,
pOptr
=
createFillOperatorInfo
(
ops
[
0
],
pExprInfo
,
num
,
pInterval
,
&
pFillNode
->
timeRange
,
pResBlock
,
pFillNode
->
mode
,
(
SNodeListNode
*
)
pFillNode
->
pValues
,
false
,
pTaskInfo
);
(
SNodeListNode
*
)
pFillNode
->
pValues
,
false
,
pTaskInfo
);
}
else
if
(
QUERY_NODE_PHYSICAL_PLAN_INDEF_ROWS_FUNC
==
type
)
{
pOptr
=
createIndefinitOutputOperatorInfo
(
ops
[
0
],
pPhyNode
,
pTaskInfo
);
}
else
{
}
else
{
ASSERT
(
0
);
ASSERT
(
0
);
}
}
...
...
source/libs/function/src/builtins.c
浏览文件 @
4560b8f2
...
@@ -177,13 +177,6 @@ static int32_t translatePercentile(SFunctionNode* pFunc, char* pErrBuf, int32_t
...
@@ -177,13 +177,6 @@ static int32_t translatePercentile(SFunctionNode* pFunc, char* pErrBuf, int32_t
return
invaildFuncParaNumErrMsg
(
pErrBuf
,
len
,
pFunc
->
functionName
);
return
invaildFuncParaNumErrMsg
(
pErrBuf
,
len
,
pFunc
->
functionName
);
}
}
// param0
SNode
*
pParamNode0
=
nodesListGetNode
(
pFunc
->
pParameterList
,
0
);
if
(
nodeType
(
pParamNode0
)
!=
QUERY_NODE_COLUMN
)
{
return
buildFuncErrMsg
(
pErrBuf
,
len
,
TSDB_CODE_FUNC_FUNTION_ERROR
,
"The first parameter of PERCENTILE function can only be column"
);
}
// param1
// param1
SValueNode
*
pValue
=
(
SValueNode
*
)
nodesListGetNode
(
pFunc
->
pParameterList
,
1
);
SValueNode
*
pValue
=
(
SValueNode
*
)
nodesListGetNode
(
pFunc
->
pParameterList
,
1
);
...
@@ -218,13 +211,6 @@ static int32_t translateApercentile(SFunctionNode* pFunc, char* pErrBuf, int32_t
...
@@ -218,13 +211,6 @@ static int32_t translateApercentile(SFunctionNode* pFunc, char* pErrBuf, int32_t
return
invaildFuncParaNumErrMsg
(
pErrBuf
,
len
,
pFunc
->
functionName
);
return
invaildFuncParaNumErrMsg
(
pErrBuf
,
len
,
pFunc
->
functionName
);
}
}
// param0
SNode
*
pParamNode0
=
nodesListGetNode
(
pFunc
->
pParameterList
,
0
);
if
(
nodeType
(
pParamNode0
)
!=
QUERY_NODE_COLUMN
)
{
return
buildFuncErrMsg
(
pErrBuf
,
len
,
TSDB_CODE_FUNC_FUNTION_ERROR
,
"The first parameter of APERCENTILE function can only be column"
);
}
// param1
// param1
SNode
*
pParamNode1
=
nodesListGetNode
(
pFunc
->
pParameterList
,
1
);
SNode
*
pParamNode1
=
nodesListGetNode
(
pFunc
->
pParameterList
,
1
);
if
(
nodeType
(
pParamNode1
)
!=
QUERY_NODE_VALUE
)
{
if
(
nodeType
(
pParamNode1
)
!=
QUERY_NODE_VALUE
)
{
...
@@ -284,13 +270,6 @@ static int32_t translateTop(SFunctionNode* pFunc, char* pErrBuf, int32_t len) {
...
@@ -284,13 +270,6 @@ static int32_t translateTop(SFunctionNode* pFunc, char* pErrBuf, int32_t len) {
return
invaildFuncParaTypeErrMsg
(
pErrBuf
,
len
,
pFunc
->
functionName
);
return
invaildFuncParaTypeErrMsg
(
pErrBuf
,
len
,
pFunc
->
functionName
);
}
}
// param0
SNode
*
pParamNode0
=
nodesListGetNode
(
pFunc
->
pParameterList
,
0
);
if
(
nodeType
(
pParamNode0
)
!=
QUERY_NODE_COLUMN
)
{
return
buildFuncErrMsg
(
pErrBuf
,
len
,
TSDB_CODE_FUNC_FUNTION_ERROR
,
"The first parameter of TOP/BOTTOM function can only be column"
);
}
// param1
// param1
SNode
*
pParamNode1
=
nodesListGetNode
(
pFunc
->
pParameterList
,
1
);
SNode
*
pParamNode1
=
nodesListGetNode
(
pFunc
->
pParameterList
,
1
);
if
(
nodeType
(
pParamNode1
)
!=
QUERY_NODE_VALUE
)
{
if
(
nodeType
(
pParamNode1
)
!=
QUERY_NODE_VALUE
)
{
...
@@ -338,13 +317,6 @@ static int32_t translateElapsed(SFunctionNode* pFunc, char* pErrBuf, int32_t len
...
@@ -338,13 +317,6 @@ static int32_t translateElapsed(SFunctionNode* pFunc, char* pErrBuf, int32_t len
return
invaildFuncParaNumErrMsg
(
pErrBuf
,
len
,
pFunc
->
functionName
);
return
invaildFuncParaNumErrMsg
(
pErrBuf
,
len
,
pFunc
->
functionName
);
}
}
// param0
SNode
*
pParaNode0
=
nodesListGetNode
(
pFunc
->
pParameterList
,
0
);
if
(
QUERY_NODE_COLUMN
!=
nodeType
(
pParaNode0
))
{
return
buildFuncErrMsg
(
pErrBuf
,
len
,
TSDB_CODE_FUNC_FUNTION_ERROR
,
"The first parameter of ELAPSED function can only be column"
);
}
uint8_t
paraType
=
((
SExprNode
*
)
nodesListGetNode
(
pFunc
->
pParameterList
,
0
))
->
resType
.
type
;
uint8_t
paraType
=
((
SExprNode
*
)
nodesListGetNode
(
pFunc
->
pParameterList
,
0
))
->
resType
.
type
;
if
(
TSDB_DATA_TYPE_TIMESTAMP
!=
paraType
)
{
if
(
TSDB_DATA_TYPE_TIMESTAMP
!=
paraType
)
{
return
invaildFuncParaTypeErrMsg
(
pErrBuf
,
len
,
pFunc
->
functionName
);
return
invaildFuncParaTypeErrMsg
(
pErrBuf
,
len
,
pFunc
->
functionName
);
...
@@ -410,13 +382,6 @@ static int32_t translateHistogram(SFunctionNode* pFunc, char* pErrBuf, int32_t l
...
@@ -410,13 +382,6 @@ static int32_t translateHistogram(SFunctionNode* pFunc, char* pErrBuf, int32_t l
return
invaildFuncParaNumErrMsg
(
pErrBuf
,
len
,
pFunc
->
functionName
);
return
invaildFuncParaNumErrMsg
(
pErrBuf
,
len
,
pFunc
->
functionName
);
}
}
// param0
SNode
*
pParaNode0
=
nodesListGetNode
(
pFunc
->
pParameterList
,
0
);
if
(
QUERY_NODE_COLUMN
!=
nodeType
(
pParaNode0
))
{
return
buildFuncErrMsg
(
pErrBuf
,
len
,
TSDB_CODE_FUNC_FUNTION_ERROR
,
"The first parameter of HISTOGRAM function can only be column"
);
}
uint8_t
colType
=
((
SExprNode
*
)
nodesListGetNode
(
pFunc
->
pParameterList
,
0
))
->
resType
.
type
;
uint8_t
colType
=
((
SExprNode
*
)
nodesListGetNode
(
pFunc
->
pParameterList
,
0
))
->
resType
.
type
;
if
(
!
IS_NUMERIC_TYPE
(
colType
))
{
if
(
!
IS_NUMERIC_TYPE
(
colType
))
{
return
invaildFuncParaTypeErrMsg
(
pErrBuf
,
len
,
pFunc
->
functionName
);
return
invaildFuncParaTypeErrMsg
(
pErrBuf
,
len
,
pFunc
->
functionName
);
...
@@ -449,12 +414,6 @@ static int32_t translateHLL(SFunctionNode* pFunc, char* pErrBuf, int32_t len) {
...
@@ -449,12 +414,6 @@ static int32_t translateHLL(SFunctionNode* pFunc, char* pErrBuf, int32_t len) {
return
invaildFuncParaNumErrMsg
(
pErrBuf
,
len
,
pFunc
->
functionName
);
return
invaildFuncParaNumErrMsg
(
pErrBuf
,
len
,
pFunc
->
functionName
);
}
}
SNode
*
pPara
=
nodesListGetNode
(
pFunc
->
pParameterList
,
0
);
if
(
QUERY_NODE_COLUMN
!=
nodeType
(
pPara
))
{
return
buildFuncErrMsg
(
pErrBuf
,
len
,
TSDB_CODE_FUNC_FUNTION_ERROR
,
"The input parameter of HYPERLOGLOG function can only be column"
);
}
pFunc
->
node
.
resType
=
(
SDataType
){.
bytes
=
tDataTypes
[
TSDB_DATA_TYPE_BIGINT
].
bytes
,
.
type
=
TSDB_DATA_TYPE_BIGINT
};
pFunc
->
node
.
resType
=
(
SDataType
){.
bytes
=
tDataTypes
[
TSDB_DATA_TYPE_BIGINT
].
bytes
,
.
type
=
TSDB_DATA_TYPE_BIGINT
};
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
...
@@ -474,12 +433,6 @@ static int32_t translateStateCount(SFunctionNode* pFunc, char* pErrBuf, int32_t
...
@@ -474,12 +433,6 @@ static int32_t translateStateCount(SFunctionNode* pFunc, char* pErrBuf, int32_t
return
invaildFuncParaNumErrMsg
(
pErrBuf
,
len
,
pFunc
->
functionName
);
return
invaildFuncParaNumErrMsg
(
pErrBuf
,
len
,
pFunc
->
functionName
);
}
}
// param0
SNode
*
pParaNode0
=
nodesListGetNode
(
pFunc
->
pParameterList
,
0
);
if
(
QUERY_NODE_COLUMN
!=
nodeType
(
pParaNode0
))
{
return
buildFuncErrMsg
(
pErrBuf
,
len
,
TSDB_CODE_FUNC_FUNTION_ERROR
,
"The input parameter of STATECOUNT function can only be column"
);
}
uint8_t
colType
=
((
SExprNode
*
)
nodesListGetNode
(
pFunc
->
pParameterList
,
0
))
->
resType
.
type
;
uint8_t
colType
=
((
SExprNode
*
)
nodesListGetNode
(
pFunc
->
pParameterList
,
0
))
->
resType
.
type
;
if
(
!
IS_NUMERIC_TYPE
(
colType
))
{
if
(
!
IS_NUMERIC_TYPE
(
colType
))
{
return
invaildFuncParaTypeErrMsg
(
pErrBuf
,
len
,
pFunc
->
functionName
);
return
invaildFuncParaTypeErrMsg
(
pErrBuf
,
len
,
pFunc
->
functionName
);
...
@@ -520,12 +473,6 @@ static int32_t translateStateDuration(SFunctionNode* pFunc, char* pErrBuf, int32
...
@@ -520,12 +473,6 @@ static int32_t translateStateDuration(SFunctionNode* pFunc, char* pErrBuf, int32
return
invaildFuncParaNumErrMsg
(
pErrBuf
,
len
,
pFunc
->
functionName
);
return
invaildFuncParaNumErrMsg
(
pErrBuf
,
len
,
pFunc
->
functionName
);
}
}
// param0
SNode
*
pParaNode0
=
nodesListGetNode
(
pFunc
->
pParameterList
,
0
);
if
(
QUERY_NODE_COLUMN
!=
nodeType
(
pParaNode0
))
{
return
buildFuncErrMsg
(
pErrBuf
,
len
,
TSDB_CODE_FUNC_FUNTION_ERROR
,
"The input parameter of STATEDURATION function can only be column"
);
}
uint8_t
colType
=
((
SExprNode
*
)
nodesListGetNode
(
pFunc
->
pParameterList
,
0
))
->
resType
.
type
;
uint8_t
colType
=
((
SExprNode
*
)
nodesListGetNode
(
pFunc
->
pParameterList
,
0
))
->
resType
.
type
;
if
(
!
IS_NUMERIC_TYPE
(
colType
))
{
if
(
!
IS_NUMERIC_TYPE
(
colType
))
{
return
invaildFuncParaTypeErrMsg
(
pErrBuf
,
len
,
pFunc
->
functionName
);
return
invaildFuncParaTypeErrMsg
(
pErrBuf
,
len
,
pFunc
->
functionName
);
...
@@ -573,12 +520,6 @@ static int32_t translateCsum(SFunctionNode* pFunc, char* pErrBuf, int32_t len) {
...
@@ -573,12 +520,6 @@ static int32_t translateCsum(SFunctionNode* pFunc, char* pErrBuf, int32_t len) {
return
invaildFuncParaNumErrMsg
(
pErrBuf
,
len
,
pFunc
->
functionName
);
return
invaildFuncParaNumErrMsg
(
pErrBuf
,
len
,
pFunc
->
functionName
);
}
}
SNode
*
pPara
=
nodesListGetNode
(
pFunc
->
pParameterList
,
0
);
if
(
QUERY_NODE_COLUMN
!=
nodeType
(
pPara
))
{
return
buildFuncErrMsg
(
pErrBuf
,
len
,
TSDB_CODE_FUNC_FUNTION_ERROR
,
"The input parameter of CSUM function can only be column"
);
}
uint8_t
colType
=
((
SExprNode
*
)
nodesListGetNode
(
pFunc
->
pParameterList
,
0
))
->
resType
.
type
;
uint8_t
colType
=
((
SExprNode
*
)
nodesListGetNode
(
pFunc
->
pParameterList
,
0
))
->
resType
.
type
;
uint8_t
resType
;
uint8_t
resType
;
if
(
!
IS_NUMERIC_TYPE
(
colType
))
{
if
(
!
IS_NUMERIC_TYPE
(
colType
))
{
...
@@ -604,13 +545,6 @@ static int32_t translateMavg(SFunctionNode* pFunc, char* pErrBuf, int32_t len) {
...
@@ -604,13 +545,6 @@ static int32_t translateMavg(SFunctionNode* pFunc, char* pErrBuf, int32_t len) {
return
invaildFuncParaNumErrMsg
(
pErrBuf
,
len
,
pFunc
->
functionName
);
return
invaildFuncParaNumErrMsg
(
pErrBuf
,
len
,
pFunc
->
functionName
);
}
}
// param0
SNode
*
pParaNode0
=
nodesListGetNode
(
pFunc
->
pParameterList
,
0
);
if
(
QUERY_NODE_COLUMN
!=
nodeType
(
pParaNode0
))
{
return
buildFuncErrMsg
(
pErrBuf
,
len
,
TSDB_CODE_FUNC_FUNTION_ERROR
,
"The first parameter of MAVG function can only be column"
);
}
uint8_t
colType
=
((
SExprNode
*
)
nodesListGetNode
(
pFunc
->
pParameterList
,
0
))
->
resType
.
type
;
uint8_t
colType
=
((
SExprNode
*
)
nodesListGetNode
(
pFunc
->
pParameterList
,
0
))
->
resType
.
type
;
// param1
// param1
...
@@ -640,13 +574,6 @@ static int32_t translateSample(SFunctionNode* pFunc, char* pErrBuf, int32_t len)
...
@@ -640,13 +574,6 @@ static int32_t translateSample(SFunctionNode* pFunc, char* pErrBuf, int32_t len)
return
invaildFuncParaNumErrMsg
(
pErrBuf
,
len
,
pFunc
->
functionName
);
return
invaildFuncParaNumErrMsg
(
pErrBuf
,
len
,
pFunc
->
functionName
);
}
}
// param0
SNode
*
pParamNode0
=
nodesListGetNode
(
pFunc
->
pParameterList
,
0
);
if
(
QUERY_NODE_COLUMN
!=
nodeType
(
pParamNode0
))
{
return
buildFuncErrMsg
(
pErrBuf
,
len
,
TSDB_CODE_FUNC_FUNTION_ERROR
,
"The first parameter of SAMPLE function can only be column"
);
}
SExprNode
*
pCol
=
(
SExprNode
*
)
nodesListGetNode
(
pFunc
->
pParameterList
,
0
);
SExprNode
*
pCol
=
(
SExprNode
*
)
nodesListGetNode
(
pFunc
->
pParameterList
,
0
);
uint8_t
colType
=
pCol
->
resType
.
type
;
uint8_t
colType
=
pCol
->
resType
.
type
;
...
@@ -684,12 +611,6 @@ static int32_t translateTail(SFunctionNode* pFunc, char* pErrBuf, int32_t len) {
...
@@ -684,12 +611,6 @@ static int32_t translateTail(SFunctionNode* pFunc, char* pErrBuf, int32_t len) {
return
invaildFuncParaNumErrMsg
(
pErrBuf
,
len
,
pFunc
->
functionName
);
return
invaildFuncParaNumErrMsg
(
pErrBuf
,
len
,
pFunc
->
functionName
);
}
}
// param0
SNode
*
pPara
=
nodesListGetNode
(
pFunc
->
pParameterList
,
0
);
if
(
QUERY_NODE_COLUMN
!=
nodeType
(
pPara
))
{
return
buildFuncErrMsg
(
pErrBuf
,
len
,
TSDB_CODE_FUNC_FUNTION_ERROR
,
"The first parameter of TAIL function can only be column"
);
}
SExprNode
*
pCol
=
(
SExprNode
*
)
nodesListGetNode
(
pFunc
->
pParameterList
,
0
);
SExprNode
*
pCol
=
(
SExprNode
*
)
nodesListGetNode
(
pFunc
->
pParameterList
,
0
);
uint8_t
colType
=
pCol
->
resType
.
type
;
uint8_t
colType
=
pCol
->
resType
.
type
;
...
@@ -766,13 +687,6 @@ static int32_t translateDiff(SFunctionNode* pFunc, char* pErrBuf, int32_t len) {
...
@@ -766,13 +687,6 @@ static int32_t translateDiff(SFunctionNode* pFunc, char* pErrBuf, int32_t len) {
return
invaildFuncParaNumErrMsg
(
pErrBuf
,
len
,
pFunc
->
functionName
);
return
invaildFuncParaNumErrMsg
(
pErrBuf
,
len
,
pFunc
->
functionName
);
}
}
// param0
SNode
*
pParamNode0
=
nodesListGetNode
(
pFunc
->
pParameterList
,
0
);
if
(
nodeType
(
pParamNode0
)
!=
QUERY_NODE_COLUMN
)
{
return
buildFuncErrMsg
(
pErrBuf
,
len
,
TSDB_CODE_FUNC_FUNTION_ERROR
,
"The first parameter of DIFF function can only be column"
);
}
uint8_t
colType
=
((
SExprNode
*
)
nodesListGetNode
(
pFunc
->
pParameterList
,
0
))
->
resType
.
type
;
uint8_t
colType
=
((
SExprNode
*
)
nodesListGetNode
(
pFunc
->
pParameterList
,
0
))
->
resType
.
type
;
if
(
!
IS_SIGNED_NUMERIC_TYPE
(
colType
)
&&
!
IS_FLOAT_TYPE
(
colType
)
&&
TSDB_DATA_TYPE_BOOL
!=
colType
)
{
if
(
!
IS_SIGNED_NUMERIC_TYPE
(
colType
)
&&
!
IS_FLOAT_TYPE
(
colType
)
&&
TSDB_DATA_TYPE_BOOL
!=
colType
)
{
return
invaildFuncParaTypeErrMsg
(
pErrBuf
,
len
,
pFunc
->
functionName
);
return
invaildFuncParaTypeErrMsg
(
pErrBuf
,
len
,
pFunc
->
functionName
);
...
...
source/libs/index/inc/indexInt.h
浏览文件 @
4560b8f2
...
@@ -35,15 +35,15 @@ extern "C" {
...
@@ -35,15 +35,15 @@ extern "C" {
#endif
#endif
// clang-format off
// clang-format off
#define indexFatal(...) do { if (idxDebugFlag & DEBUG_FATAL) { taosPrintLog("I
NDE
X FATAL ", DEBUG_FATAL, 255, __VA_ARGS__); }} while (0)
#define indexFatal(...) do { if (idxDebugFlag & DEBUG_FATAL) { taosPrintLog("I
D
X FATAL ", DEBUG_FATAL, 255, __VA_ARGS__); }} while (0)
#define indexError(...) do { if (idxDebugFlag & DEBUG_ERROR) { taosPrintLog("I
NDE
X ERROR ", DEBUG_ERROR, 255, __VA_ARGS__); }} while (0)
#define indexError(...) do { if (idxDebugFlag & DEBUG_ERROR) { taosPrintLog("I
D
X ERROR ", DEBUG_ERROR, 255, __VA_ARGS__); }} while (0)
#define indexWarn(...) do { if (idxDebugFlag & DEBUG_WARN) { taosPrintLog("I
NDE
X WARN ", DEBUG_WARN, 255, __VA_ARGS__); }} while (0)
#define indexWarn(...) do { if (idxDebugFlag & DEBUG_WARN) { taosPrintLog("I
D
X WARN ", DEBUG_WARN, 255, __VA_ARGS__); }} while (0)
#define indexInfo(...) do { if (idxDebugFlag & DEBUG_INFO) { taosPrintLog("I
NDE
X ", DEBUG_INFO, 255, __VA_ARGS__); } } while (0)
#define indexInfo(...) do { if (idxDebugFlag & DEBUG_INFO) { taosPrintLog("I
D
X ", DEBUG_INFO, 255, __VA_ARGS__); } } while (0)
#define indexDebug(...) do { if (idxDebugFlag & DEBUG_DEBUG) { taosPrintLog("I
NDEX ", DEBUG_DEBUG, s
DebugFlag, __VA_ARGS__);} } while (0)
#define indexDebug(...) do { if (idxDebugFlag & DEBUG_DEBUG) { taosPrintLog("I
DX ", DEBUG_DEBUG, idx
DebugFlag, __VA_ARGS__);} } while (0)
#define indexTrace(...) do { if (idxDebugFlag & DEBUG_TRACE) { taosPrintLog("I
NDEX ", DEBUG_TRACE, s
DebugFlag, __VA_ARGS__);} } while (0)
#define indexTrace(...) do { if (idxDebugFlag & DEBUG_TRACE) { taosPrintLog("I
DX", DEBUG_TRACE, idx
DebugFlag, __VA_ARGS__);} } while (0)
// clang-format on
// clang-format on
typedef
enum
{
LT
,
LE
,
GT
,
GE
}
RangeType
;
typedef
enum
{
LT
,
LE
,
GT
,
GE
,
CONTAINS
}
RangeType
;
typedef
enum
{
kTypeValue
,
kTypeDeletion
}
STermValueType
;
typedef
enum
{
kTypeValue
,
kTypeDeletion
}
STermValueType
;
typedef
struct
SIndexStat
{
typedef
struct
SIndexStat
{
...
...
source/libs/index/src/indexCache.c
浏览文件 @
4560b8f2
...
@@ -90,7 +90,7 @@ static int32_t cacheSearchTerm(void* cache, SIndexTerm* term, SIdxTRslt* tr, STe
...
@@ -90,7 +90,7 @@ static int32_t cacheSearchTerm(void* cache, SIndexTerm* term, SIdxTRslt* tr, STe
break
;
break
;
}
}
CacheTerm
*
c
=
(
CacheTerm
*
)
SL_GET_NODE_DATA
(
node
);
CacheTerm
*
c
=
(
CacheTerm
*
)
SL_GET_NODE_DATA
(
node
);
if
(
0
==
strcmp
(
c
->
colVal
,
pCt
->
colVal
))
{
if
(
0
==
strcmp
(
c
->
colVal
,
pCt
->
colVal
)
&&
strlen
(
pCt
->
colVal
)
==
strlen
(
c
->
colVal
)
)
{
if
(
c
->
operaType
==
ADD_VALUE
)
{
if
(
c
->
operaType
==
ADD_VALUE
)
{
INDEX_MERGE_ADD_DEL
(
tr
->
del
,
tr
->
add
,
c
->
uid
)
INDEX_MERGE_ADD_DEL
(
tr
->
del
,
tr
->
add
,
c
->
uid
)
// taosArrayPush(result, &c->uid);
// taosArrayPush(result, &c->uid);
...
@@ -222,7 +222,7 @@ static int32_t cacheSearchTerm_JSON(void* cache, SIndexTerm* term, SIdxTRslt* tr
...
@@ -222,7 +222,7 @@ static int32_t cacheSearchTerm_JSON(void* cache, SIndexTerm* term, SIdxTRslt* tr
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
static
int32_t
cacheSearchPrefix_JSON
(
void
*
cache
,
SIndexTerm
*
term
,
SIdxTRslt
*
tr
,
STermValueType
*
s
)
{
static
int32_t
cacheSearchPrefix_JSON
(
void
*
cache
,
SIndexTerm
*
term
,
SIdxTRslt
*
tr
,
STermValueType
*
s
)
{
return
TSDB_CODE_SUCCESS
;
return
cacheSearchCompareFunc_JSON
(
cache
,
term
,
tr
,
s
,
CONTAINS
)
;
}
}
static
int32_t
cacheSearchSuffix_JSON
(
void
*
cache
,
SIndexTerm
*
term
,
SIdxTRslt
*
tr
,
STermValueType
*
s
)
{
static
int32_t
cacheSearchSuffix_JSON
(
void
*
cache
,
SIndexTerm
*
term
,
SIdxTRslt
*
tr
,
STermValueType
*
s
)
{
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
...
@@ -242,6 +242,9 @@ static int32_t cacheSearchGreaterThan_JSON(void* cache, SIndexTerm* term, SIdxTR
...
@@ -242,6 +242,9 @@ static int32_t cacheSearchGreaterThan_JSON(void* cache, SIndexTerm* term, SIdxTR
static
int32_t
cacheSearchGreaterEqual_JSON
(
void
*
cache
,
SIndexTerm
*
term
,
SIdxTRslt
*
tr
,
STermValueType
*
s
)
{
static
int32_t
cacheSearchGreaterEqual_JSON
(
void
*
cache
,
SIndexTerm
*
term
,
SIdxTRslt
*
tr
,
STermValueType
*
s
)
{
return
cacheSearchCompareFunc_JSON
(
cache
,
term
,
tr
,
s
,
GE
);
return
cacheSearchCompareFunc_JSON
(
cache
,
term
,
tr
,
s
,
GE
);
}
}
static
int32_t
cacheSearchContain_JSON
(
void
*
cache
,
SIndexTerm
*
term
,
SIdxTRslt
*
tr
,
STermValueType
*
s
)
{
return
cacheSearchCompareFunc_JSON
(
cache
,
term
,
tr
,
s
,
CONTAINS
);
}
static
int32_t
cacheSearchRange_JSON
(
void
*
cache
,
SIndexTerm
*
term
,
SIdxTRslt
*
tr
,
STermValueType
*
s
)
{
static
int32_t
cacheSearchRange_JSON
(
void
*
cache
,
SIndexTerm
*
term
,
SIdxTRslt
*
tr
,
STermValueType
*
s
)
{
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
...
...
source/libs/index/src/indexComm.c
浏览文件 @
4560b8f2
...
@@ -97,6 +97,11 @@ static TExeCond tCompareGreaterEqual(void* a, void* b, int8_t type) {
...
@@ -97,6 +97,11 @@ static TExeCond tCompareGreaterEqual(void* a, void* b, int8_t type) {
__compar_fn_t
func
=
indexGetCompar
(
type
);
__compar_fn_t
func
=
indexGetCompar
(
type
);
return
tCompare
(
func
,
QUERY_GREATER_EQUAL
,
a
,
b
,
type
);
return
tCompare
(
func
,
QUERY_GREATER_EQUAL
,
a
,
b
,
type
);
}
}
static
TExeCond
tCompareContains
(
void
*
a
,
void
*
b
,
int8_t
type
)
{
__compar_fn_t
func
=
indexGetCompar
(
type
);
return
tCompare
(
func
,
QUERY_TERM
,
a
,
b
,
type
);
}
TExeCond
tCompare
(
__compar_fn_t
func
,
int8_t
cmptype
,
void
*
a
,
void
*
b
,
int8_t
dtype
)
{
TExeCond
tCompare
(
__compar_fn_t
func
,
int8_t
cmptype
,
void
*
a
,
void
*
b
,
int8_t
dtype
)
{
if
(
dtype
==
TSDB_DATA_TYPE_BINARY
||
dtype
==
TSDB_DATA_TYPE_NCHAR
||
dtype
==
TSDB_DATA_TYPE_VARBINARY
)
{
if
(
dtype
==
TSDB_DATA_TYPE_BINARY
||
dtype
==
TSDB_DATA_TYPE_NCHAR
||
dtype
==
TSDB_DATA_TYPE_VARBINARY
)
{
return
tDoCompare
(
func
,
cmptype
,
a
,
b
);
return
tDoCompare
(
func
,
cmptype
,
a
,
b
);
...
@@ -185,12 +190,14 @@ TExeCond tDoCompare(__compar_fn_t func, int8_t comparType, void* a, void* b) {
...
@@ -185,12 +190,14 @@ TExeCond tDoCompare(__compar_fn_t func, int8_t comparType, void* a, void* b) {
case
QUERY_TERM
:
{
case
QUERY_TERM
:
{
if
(
ret
==
0
)
return
MATCH
;
if
(
ret
==
0
)
return
MATCH
;
}
}
default:
return
BREAK
;
}
}
return
CONTINUE
;
return
CONTINUE
;
}
}
static
TExeCond
(
*
rangeCompare
[])(
void
*
a
,
void
*
b
,
int8_t
type
)
=
{
tCompareLessThan
,
tCompareLessEqual
,
static
TExeCond
(
*
rangeCompare
[])(
void
*
a
,
void
*
b
,
int8_t
type
)
=
{
tCompareGreaterThan
,
tCompareGreaterEqual
};
tCompareLessThan
,
tCompareLessEqual
,
tCompareGreaterThan
,
tCompareGreaterEqual
,
tCompareContains
};
_cache_range_compare
indexGetCompare
(
RangeType
ty
)
{
return
rangeCompare
[
ty
];
}
_cache_range_compare
indexGetCompare
(
RangeType
ty
)
{
return
rangeCompare
[
ty
];
}
...
...
source/libs/index/src/indexFilter.c
浏览文件 @
4560b8f2
...
@@ -64,6 +64,8 @@ static int32_t sifGetFuncFromSql(EOperatorType src, EIndexQueryType *dst) {
...
@@ -64,6 +64,8 @@ static int32_t sifGetFuncFromSql(EOperatorType src, EIndexQueryType *dst) {
*
dst
=
QUERY_TERM
;
*
dst
=
QUERY_TERM
;
}
else
if
(
src
==
OP_TYPE_LIKE
||
src
==
OP_TYPE_MATCH
||
src
==
OP_TYPE_NMATCH
)
{
}
else
if
(
src
==
OP_TYPE_LIKE
||
src
==
OP_TYPE_MATCH
||
src
==
OP_TYPE_NMATCH
)
{
*
dst
=
QUERY_REGEX
;
*
dst
=
QUERY_REGEX
;
}
else
if
(
src
==
OP_TYPE_JSON_CONTAINS
)
{
*
dst
=
QUERY_PREFIX
;
}
else
{
}
else
{
return
TSDB_CODE_QRY_INVALID_INPUT
;
return
TSDB_CODE_QRY_INVALID_INPUT
;
}
}
...
@@ -186,6 +188,7 @@ static int32_t sifInitParam(SNode *node, SIFParam *param, SIFCtx *ctx) {
...
@@ -186,6 +188,7 @@ static int32_t sifInitParam(SNode *node, SIFParam *param, SIFCtx *ctx) {
SIF_ERR_RET
(
sifGetValueFromNode
(
node
,
&
param
->
condValue
));
SIF_ERR_RET
(
sifGetValueFromNode
(
node
,
&
param
->
condValue
));
param
->
colId
=
-
1
;
param
->
colId
=
-
1
;
param
->
colValType
=
(
uint8_t
)(
vn
->
node
.
resType
.
type
);
param
->
colValType
=
(
uint8_t
)(
vn
->
node
.
resType
.
type
);
memcpy
(
param
->
colName
,
vn
->
literal
,
strlen
(
vn
->
literal
));
break
;
break
;
}
}
case
QUERY_NODE_COLUMN
:
{
case
QUERY_NODE_COLUMN
:
{
...
@@ -237,7 +240,7 @@ static int32_t sifInitOperParams(SIFParam **params, SOperatorNode *node, SIFCtx
...
@@ -237,7 +240,7 @@ static int32_t sifInitOperParams(SIFParam **params, SOperatorNode *node, SIFCtx
indexError
(
"invalid operation node, left: %p, rigth: %p"
,
node
->
pLeft
,
node
->
pRight
);
indexError
(
"invalid operation node, left: %p, rigth: %p"
,
node
->
pLeft
,
node
->
pRight
);
SIF_ERR_RET
(
TSDB_CODE_QRY_INVALID_INPUT
);
SIF_ERR_RET
(
TSDB_CODE_QRY_INVALID_INPUT
);
}
}
if
(
node
->
opType
==
OP_TYPE_JSON_GET_VALUE
||
node
->
opType
==
OP_TYPE_JSON_CONTAINS
)
{
if
(
node
->
opType
==
OP_TYPE_JSON_GET_VALUE
)
{
return
code
;
return
code
;
}
}
SIFParam
*
paramList
=
taosMemoryCalloc
(
nParam
,
sizeof
(
SIFParam
));
SIFParam
*
paramList
=
taosMemoryCalloc
(
nParam
,
sizeof
(
SIFParam
));
...
@@ -420,8 +423,8 @@ static int32_t sifNotMatchFunc(SIFParam *left, SIFParam *right, SIFParam *output
...
@@ -420,8 +423,8 @@ static int32_t sifNotMatchFunc(SIFParam *left, SIFParam *right, SIFParam *output
return
sifDoIndex
(
left
,
right
,
id
,
output
);
return
sifDoIndex
(
left
,
right
,
id
,
output
);
}
}
static
int32_t
sifJsonContains
(
SIFParam
*
left
,
SIFParam
*
right
,
SIFParam
*
output
)
{
static
int32_t
sifJsonContains
(
SIFParam
*
left
,
SIFParam
*
right
,
SIFParam
*
output
)
{
// return 0
int
id
=
OP_TYPE_JSON_CONTAINS
;
return
0
;
return
sifDoIndex
(
left
,
right
,
id
,
output
)
;
}
}
static
int32_t
sifJsonGetValue
(
SIFParam
*
left
,
SIFParam
*
rigth
,
SIFParam
*
output
)
{
static
int32_t
sifJsonGetValue
(
SIFParam
*
left
,
SIFParam
*
rigth
,
SIFParam
*
output
)
{
// return 0
// return 0
...
@@ -501,9 +504,11 @@ static int32_t sifExecOper(SOperatorNode *node, SIFCtx *ctx, SIFParam *output) {
...
@@ -501,9 +504,11 @@ static int32_t sifExecOper(SOperatorNode *node, SIFCtx *ctx, SIFParam *output) {
int32_t
code
=
0
;
int32_t
code
=
0
;
int32_t
nParam
=
sifGetOperParamNum
(
node
->
opType
);
int32_t
nParam
=
sifGetOperParamNum
(
node
->
opType
);
if
(
nParam
<=
1
)
{
if
(
nParam
<=
1
)
{
SIF_ERR_RET
(
TSDB_CODE_QRY_INVALID_INPUT
);
output
->
status
=
SFLT_NOT_INDEX
;
return
code
;
// SIF_ERR_RET(TSDB_CODE_QRY_INVALID_INPUT);
}
}
if
(
node
->
opType
==
OP_TYPE_JSON_GET_VALUE
||
node
->
opType
==
OP_TYPE_JSON_CONTAINS
)
{
if
(
node
->
opType
==
OP_TYPE_JSON_GET_VALUE
)
{
return
code
;
return
code
;
}
}
SIFParam
*
params
=
NULL
;
SIFParam
*
params
=
NULL
;
...
@@ -617,11 +622,11 @@ EDealRes sifCalcWalker(SNode *node, void *context) {
...
@@ -617,11 +622,11 @@ EDealRes sifCalcWalker(SNode *node, void *context) {
}
}
if
(
QUERY_NODE_OPERATOR
==
nodeType
(
node
))
{
if
(
QUERY_NODE_OPERATOR
==
nodeType
(
node
))
{
indexInfo
(
"node type for index filter, type: %d"
,
nodeType
(
node
));
//
indexInfo("node type for index filter, type: %d", nodeType(node));
return
sifWalkOper
(
node
,
ctx
);
return
sifWalkOper
(
node
,
ctx
);
}
}
indexError
(
"invalid node type for index filter calculating, type:%d"
,
nodeType
(
node
));
//
indexError("invalid node type for index filter calculating, type:%d", nodeType(node));
ctx
->
code
=
TSDB_CODE_QRY_INVALID_INPUT
;
ctx
->
code
=
TSDB_CODE_QRY_INVALID_INPUT
;
return
DEAL_RES_ERROR
;
return
DEAL_RES_ERROR
;
}
}
...
...
source/libs/index/src/indexTfile.c
浏览文件 @
4560b8f2
...
@@ -425,8 +425,7 @@ static int32_t tfSearchTerm_JSON(void* reader, SIndexTerm* tem, SIdxTRslt* tr) {
...
@@ -425,8 +425,7 @@ static int32_t tfSearchTerm_JSON(void* reader, SIndexTerm* tem, SIdxTRslt* tr) {
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
static
int32_t
tfSearchPrefix_JSON
(
void
*
reader
,
SIndexTerm
*
tem
,
SIdxTRslt
*
tr
)
{
static
int32_t
tfSearchPrefix_JSON
(
void
*
reader
,
SIndexTerm
*
tem
,
SIdxTRslt
*
tr
)
{
// impl later
return
tfSearchCompareFunc_JSON
(
reader
,
tem
,
tr
,
CONTAINS
);
return
TSDB_CODE_SUCCESS
;
}
}
static
int32_t
tfSearchSuffix_JSON
(
void
*
reader
,
SIndexTerm
*
tem
,
SIdxTRslt
*
tr
)
{
static
int32_t
tfSearchSuffix_JSON
(
void
*
reader
,
SIndexTerm
*
tem
,
SIdxTRslt
*
tr
)
{
// impl later
// impl later
...
@@ -466,10 +465,6 @@ static int32_t tfSearchCompareFunc_JSON(void* reader, SIndexTerm* tem, SIdxTRslt
...
@@ -466,10 +465,6 @@ static int32_t tfSearchCompareFunc_JSON(void* reader, SIndexTerm* tem, SIdxTRslt
AutomationCtx
*
ctx
=
automCtxCreate
((
void
*
)
p
,
AUTOMATION_PREFIX
);
AutomationCtx
*
ctx
=
automCtxCreate
((
void
*
)
p
,
AUTOMATION_PREFIX
);
FstStreamBuilder
*
sb
=
fstSearch
(((
TFileReader
*
)
reader
)
->
fst
,
ctx
);
FstStreamBuilder
*
sb
=
fstSearch
(((
TFileReader
*
)
reader
)
->
fst
,
ctx
);
// FstSlice h = fstSliceCreate((uint8_t*)p, skip);
// fstStreamBuilderSetRange(sb, &h, ctype);
// fstSliceDestroy(&h);
StreamWithState
*
st
=
streamBuilderIntoStream
(
sb
);
StreamWithState
*
st
=
streamBuilderIntoStream
(
sb
);
StreamWithStateResult
*
rt
=
NULL
;
StreamWithStateResult
*
rt
=
NULL
;
while
((
rt
=
streamWithStateNextWith
(
st
,
NULL
))
!=
NULL
)
{
while
((
rt
=
streamWithStateNextWith
(
st
,
NULL
))
!=
NULL
)
{
...
...
source/libs/nodes/src/nodesCloneFuncs.c
浏览文件 @
4560b8f2
...
@@ -434,6 +434,12 @@ static SNode* logicPartitionCopy(const SPartitionLogicNode* pSrc, SPartitionLogi
...
@@ -434,6 +434,12 @@ static SNode* logicPartitionCopy(const SPartitionLogicNode* pSrc, SPartitionLogi
return
(
SNode
*
)
pDst
;
return
(
SNode
*
)
pDst
;
}
}
static
SNode
*
logicIndefRowsFuncCopy
(
const
SIndefRowsFuncLogicNode
*
pSrc
,
SIndefRowsFuncLogicNode
*
pDst
)
{
COPY_BASE_OBJECT_FIELD
(
node
,
logicNodeCopy
);
CLONE_NODE_LIST_FIELD
(
pVectorFuncs
);
return
(
SNode
*
)
pDst
;
}
static
SNode
*
logicSubplanCopy
(
const
SLogicSubplan
*
pSrc
,
SLogicSubplan
*
pDst
)
{
static
SNode
*
logicSubplanCopy
(
const
SLogicSubplan
*
pSrc
,
SLogicSubplan
*
pDst
)
{
COPY_OBJECT_FIELD
(
id
,
sizeof
(
SSubplanId
));
COPY_OBJECT_FIELD
(
id
,
sizeof
(
SSubplanId
));
CLONE_NODE_FIELD
(
pNode
);
CLONE_NODE_FIELD
(
pNode
);
...
@@ -565,6 +571,8 @@ SNodeptr nodesCloneNode(const SNodeptr pNode) {
...
@@ -565,6 +571,8 @@ SNodeptr nodesCloneNode(const SNodeptr pNode) {
return
logicSortCopy
((
const
SSortLogicNode
*
)
pNode
,
(
SSortLogicNode
*
)
pDst
);
return
logicSortCopy
((
const
SSortLogicNode
*
)
pNode
,
(
SSortLogicNode
*
)
pDst
);
case
QUERY_NODE_LOGIC_PLAN_PARTITION
:
case
QUERY_NODE_LOGIC_PLAN_PARTITION
:
return
logicPartitionCopy
((
const
SPartitionLogicNode
*
)
pNode
,
(
SPartitionLogicNode
*
)
pDst
);
return
logicPartitionCopy
((
const
SPartitionLogicNode
*
)
pNode
,
(
SPartitionLogicNode
*
)
pDst
);
case
QUERY_NODE_LOGIC_PLAN_INDEF_ROWS_FUNC
:
return
logicIndefRowsFuncCopy
((
const
SIndefRowsFuncLogicNode
*
)
pNode
,
(
SIndefRowsFuncLogicNode
*
)
pDst
);
case
QUERY_NODE_LOGIC_SUBPLAN
:
case
QUERY_NODE_LOGIC_SUBPLAN
:
return
logicSubplanCopy
((
const
SLogicSubplan
*
)
pNode
,
(
SLogicSubplan
*
)
pDst
);
return
logicSubplanCopy
((
const
SLogicSubplan
*
)
pNode
,
(
SLogicSubplan
*
)
pDst
);
default:
default:
...
...
source/libs/nodes/src/nodesCodeFuncs.c
浏览文件 @
4560b8f2
...
@@ -202,6 +202,8 @@ const char* nodesNodeName(ENodeType type) {
...
@@ -202,6 +202,8 @@ const char* nodesNodeName(ENodeType type) {
return
"LogicSort"
;
return
"LogicSort"
;
case
QUERY_NODE_LOGIC_PLAN_PARTITION
:
case
QUERY_NODE_LOGIC_PLAN_PARTITION
:
return
"LogicPartition"
;
return
"LogicPartition"
;
case
QUERY_NODE_LOGIC_PLAN_INDEF_ROWS_FUNC
:
return
"LogicIndefRowsFunc"
;
case
QUERY_NODE_LOGIC_SUBPLAN
:
case
QUERY_NODE_LOGIC_SUBPLAN
:
return
"LogicSubplan"
;
return
"LogicSubplan"
;
case
QUERY_NODE_LOGIC_PLAN
:
case
QUERY_NODE_LOGIC_PLAN
:
...
@@ -250,6 +252,8 @@ const char* nodesNodeName(ENodeType type) {
...
@@ -250,6 +252,8 @@ const char* nodesNodeName(ENodeType type) {
return
"PhysiStreamStateWindow"
;
return
"PhysiStreamStateWindow"
;
case
QUERY_NODE_PHYSICAL_PLAN_PARTITION
:
case
QUERY_NODE_PHYSICAL_PLAN_PARTITION
:
return
"PhysiPartition"
;
return
"PhysiPartition"
;
case
QUERY_NODE_PHYSICAL_PLAN_INDEF_ROWS_FUNC
:
return
"PhysiIndefRowsFunc"
;
case
QUERY_NODE_PHYSICAL_PLAN_DISPATCH
:
case
QUERY_NODE_PHYSICAL_PLAN_DISPATCH
:
return
"PhysiDispatch"
;
return
"PhysiDispatch"
;
case
QUERY_NODE_PHYSICAL_PLAN_INSERT
:
case
QUERY_NODE_PHYSICAL_PLAN_INSERT
:
...
@@ -913,6 +917,30 @@ static int32_t jsonToLogicPartitionNode(const SJson* pJson, void* pObj) {
...
@@ -913,6 +917,30 @@ static int32_t jsonToLogicPartitionNode(const SJson* pJson, void* pObj) {
return
code
;
return
code
;
}
}
static
const
char
*
jkIndefRowsFuncLogicPlanVectorFuncs
=
"VectorFuncs"
;
static
int32_t
logicIndefRowsFuncNodeToJson
(
const
void
*
pObj
,
SJson
*
pJson
)
{
const
SIndefRowsFuncLogicNode
*
pNode
=
(
const
SIndefRowsFuncLogicNode
*
)
pObj
;
int32_t
code
=
logicPlanNodeToJson
(
pObj
,
pJson
);
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
nodeListToJson
(
pJson
,
jkIndefRowsFuncLogicPlanVectorFuncs
,
pNode
->
pVectorFuncs
);
}
return
code
;
}
static
int32_t
jsonToLogicIndefRowsFuncNode
(
const
SJson
*
pJson
,
void
*
pObj
)
{
SIndefRowsFuncLogicNode
*
pNode
=
(
SIndefRowsFuncLogicNode
*
)
pObj
;
int32_t
code
=
jsonToLogicPlanNode
(
pJson
,
pObj
);
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
jsonToNodeList
(
pJson
,
jkIndefRowsFuncLogicPlanVectorFuncs
,
&
pNode
->
pVectorFuncs
);
}
return
code
;
}
static
const
char
*
jkSubplanIdQueryId
=
"QueryId"
;
static
const
char
*
jkSubplanIdQueryId
=
"QueryId"
;
static
const
char
*
jkSubplanIdGroupId
=
"GroupId"
;
static
const
char
*
jkSubplanIdGroupId
=
"GroupId"
;
static
const
char
*
jkSubplanIdSubplanId
=
"SubplanId"
;
static
const
char
*
jkSubplanIdSubplanId
=
"SubplanId"
;
...
@@ -1995,6 +2023,37 @@ static int32_t jsonToPhysiPartitionNode(const SJson* pJson, void* pObj) {
...
@@ -1995,6 +2023,37 @@ static int32_t jsonToPhysiPartitionNode(const SJson* pJson, void* pObj) {
return
code
;
return
code
;
}
}
static
const
char
*
jkIndefRowsFuncPhysiPlanExprs
=
"Exprs"
;
static
const
char
*
jkIndefRowsFuncPhysiPlanVectorFuncs
=
"VectorFuncs"
;
static
int32_t
physiIndefRowsFuncNodeToJson
(
const
void
*
pObj
,
SJson
*
pJson
)
{
const
SIndefRowsFuncPhysiNode
*
pNode
=
(
const
SIndefRowsFuncPhysiNode
*
)
pObj
;
int32_t
code
=
physicPlanNodeToJson
(
pObj
,
pJson
);
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
nodeListToJson
(
pJson
,
jkIndefRowsFuncPhysiPlanExprs
,
pNode
->
pExprs
);
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
nodeListToJson
(
pJson
,
jkIndefRowsFuncPhysiPlanVectorFuncs
,
pNode
->
pVectorFuncs
);
}
return
code
;
}
static
int32_t
jsonToPhysiIndefRowsFuncNode
(
const
SJson
*
pJson
,
void
*
pObj
)
{
SIndefRowsFuncPhysiNode
*
pNode
=
(
SIndefRowsFuncPhysiNode
*
)
pObj
;
int32_t
code
=
jsonToPhysicPlanNode
(
pJson
,
pObj
);
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
jsonToNodeList
(
pJson
,
jkIndefRowsFuncPhysiPlanExprs
,
&
pNode
->
pExprs
);
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
jsonToNodeList
(
pJson
,
jkIndefRowsFuncPhysiPlanVectorFuncs
,
&
pNode
->
pVectorFuncs
);
}
return
code
;
}
static
const
char
*
jkDataSinkInputDataBlockDesc
=
"InputDataBlockDesc"
;
static
const
char
*
jkDataSinkInputDataBlockDesc
=
"InputDataBlockDesc"
;
static
int32_t
physicDataSinkNodeToJson
(
const
void
*
pObj
,
SJson
*
pJson
)
{
static
int32_t
physicDataSinkNodeToJson
(
const
void
*
pObj
,
SJson
*
pJson
)
{
...
@@ -3800,6 +3859,8 @@ static int32_t specificNodeToJson(const void* pObj, SJson* pJson) {
...
@@ -3800,6 +3859,8 @@ static int32_t specificNodeToJson(const void* pObj, SJson* pJson) {
return
logicSortNodeToJson
(
pObj
,
pJson
);
return
logicSortNodeToJson
(
pObj
,
pJson
);
case
QUERY_NODE_LOGIC_PLAN_PARTITION
:
case
QUERY_NODE_LOGIC_PLAN_PARTITION
:
return
logicPartitionNodeToJson
(
pObj
,
pJson
);
return
logicPartitionNodeToJson
(
pObj
,
pJson
);
case
QUERY_NODE_LOGIC_PLAN_INDEF_ROWS_FUNC
:
return
logicIndefRowsFuncNodeToJson
(
pObj
,
pJson
);
case
QUERY_NODE_LOGIC_SUBPLAN
:
case
QUERY_NODE_LOGIC_SUBPLAN
:
return
logicSubplanToJson
(
pObj
,
pJson
);
return
logicSubplanToJson
(
pObj
,
pJson
);
case
QUERY_NODE_LOGIC_PLAN
:
case
QUERY_NODE_LOGIC_PLAN
:
...
@@ -3840,6 +3901,8 @@ static int32_t specificNodeToJson(const void* pObj, SJson* pJson) {
...
@@ -3840,6 +3901,8 @@ static int32_t specificNodeToJson(const void* pObj, SJson* pJson) {
return
physiStateWindowNodeToJson
(
pObj
,
pJson
);
return
physiStateWindowNodeToJson
(
pObj
,
pJson
);
case
QUERY_NODE_PHYSICAL_PLAN_PARTITION
:
case
QUERY_NODE_PHYSICAL_PLAN_PARTITION
:
return
physiPartitionNodeToJson
(
pObj
,
pJson
);
return
physiPartitionNodeToJson
(
pObj
,
pJson
);
case
QUERY_NODE_PHYSICAL_PLAN_INDEF_ROWS_FUNC
:
return
physiIndefRowsFuncNodeToJson
(
pObj
,
pJson
);
case
QUERY_NODE_PHYSICAL_PLAN_DISPATCH
:
case
QUERY_NODE_PHYSICAL_PLAN_DISPATCH
:
return
physiDispatchNodeToJson
(
pObj
,
pJson
);
return
physiDispatchNodeToJson
(
pObj
,
pJson
);
case
QUERY_NODE_PHYSICAL_PLAN_INSERT
:
case
QUERY_NODE_PHYSICAL_PLAN_INSERT
:
...
@@ -3929,6 +3992,8 @@ static int32_t jsonToSpecificNode(const SJson* pJson, void* pObj) {
...
@@ -3929,6 +3992,8 @@ static int32_t jsonToSpecificNode(const SJson* pJson, void* pObj) {
return
jsonToLogicSortNode
(
pJson
,
pObj
);
return
jsonToLogicSortNode
(
pJson
,
pObj
);
case
QUERY_NODE_LOGIC_PLAN_PARTITION
:
case
QUERY_NODE_LOGIC_PLAN_PARTITION
:
return
jsonToLogicPartitionNode
(
pJson
,
pObj
);
return
jsonToLogicPartitionNode
(
pJson
,
pObj
);
case
QUERY_NODE_LOGIC_PLAN_INDEF_ROWS_FUNC
:
return
jsonToLogicIndefRowsFuncNode
(
pJson
,
pObj
);
case
QUERY_NODE_LOGIC_SUBPLAN
:
case
QUERY_NODE_LOGIC_SUBPLAN
:
return
jsonToLogicSubplan
(
pJson
,
pObj
);
return
jsonToLogicSubplan
(
pJson
,
pObj
);
case
QUERY_NODE_LOGIC_PLAN
:
case
QUERY_NODE_LOGIC_PLAN
:
...
@@ -3969,6 +4034,8 @@ static int32_t jsonToSpecificNode(const SJson* pJson, void* pObj) {
...
@@ -3969,6 +4034,8 @@ static int32_t jsonToSpecificNode(const SJson* pJson, void* pObj) {
return
jsonToPhysiStateWindowNode
(
pJson
,
pObj
);
return
jsonToPhysiStateWindowNode
(
pJson
,
pObj
);
case
QUERY_NODE_PHYSICAL_PLAN_PARTITION
:
case
QUERY_NODE_PHYSICAL_PLAN_PARTITION
:
return
jsonToPhysiPartitionNode
(
pJson
,
pObj
);
return
jsonToPhysiPartitionNode
(
pJson
,
pObj
);
case
QUERY_NODE_PHYSICAL_PLAN_INDEF_ROWS_FUNC
:
return
jsonToPhysiIndefRowsFuncNode
(
pJson
,
pObj
);
case
QUERY_NODE_PHYSICAL_PLAN_DISPATCH
:
case
QUERY_NODE_PHYSICAL_PLAN_DISPATCH
:
return
jsonToPhysiDispatchNode
(
pJson
,
pObj
);
return
jsonToPhysiDispatchNode
(
pJson
,
pObj
);
case
QUERY_NODE_PHYSICAL_PLAN_DELETE
:
case
QUERY_NODE_PHYSICAL_PLAN_DELETE
:
...
...
source/libs/nodes/src/nodesTraverseFuncs.c
浏览文件 @
4560b8f2
...
@@ -350,6 +350,7 @@ void nodesWalkSelectStmt(SSelectStmt* pSelect, ESqlClause clause, FNodeWalker wa
...
@@ -350,6 +350,7 @@ void nodesWalkSelectStmt(SSelectStmt* pSelect, ESqlClause clause, FNodeWalker wa
case
SQL_CLAUSE_GROUP_BY
:
case
SQL_CLAUSE_GROUP_BY
:
nodesWalkExpr
(
pSelect
->
pHaving
,
walker
,
pContext
);
nodesWalkExpr
(
pSelect
->
pHaving
,
walker
,
pContext
);
case
SQL_CLAUSE_HAVING
:
case
SQL_CLAUSE_HAVING
:
case
SQL_CLAUSE_SELECT
:
case
SQL_CLAUSE_DISTINCT
:
case
SQL_CLAUSE_DISTINCT
:
nodesWalkExprs
(
pSelect
->
pOrderByList
,
walker
,
pContext
);
nodesWalkExprs
(
pSelect
->
pOrderByList
,
walker
,
pContext
);
case
SQL_CLAUSE_ORDER_BY
:
case
SQL_CLAUSE_ORDER_BY
:
...
@@ -382,6 +383,7 @@ void nodesRewriteSelectStmt(SSelectStmt* pSelect, ESqlClause clause, FNodeRewrit
...
@@ -382,6 +383,7 @@ void nodesRewriteSelectStmt(SSelectStmt* pSelect, ESqlClause clause, FNodeRewrit
case
SQL_CLAUSE_GROUP_BY
:
case
SQL_CLAUSE_GROUP_BY
:
nodesRewriteExpr
(
&
(
pSelect
->
pHaving
),
rewriter
,
pContext
);
nodesRewriteExpr
(
&
(
pSelect
->
pHaving
),
rewriter
,
pContext
);
case
SQL_CLAUSE_HAVING
:
case
SQL_CLAUSE_HAVING
:
case
SQL_CLAUSE_SELECT
:
case
SQL_CLAUSE_DISTINCT
:
case
SQL_CLAUSE_DISTINCT
:
nodesRewriteExprs
(
pSelect
->
pOrderByList
,
rewriter
,
pContext
);
nodesRewriteExprs
(
pSelect
->
pOrderByList
,
rewriter
,
pContext
);
case
SQL_CLAUSE_ORDER_BY
:
case
SQL_CLAUSE_ORDER_BY
:
...
...
source/libs/nodes/src/nodesUtilFuncs.c
浏览文件 @
4560b8f2
...
@@ -232,6 +232,8 @@ SNodeptr nodesMakeNode(ENodeType type) {
...
@@ -232,6 +232,8 @@ SNodeptr nodesMakeNode(ENodeType type) {
return
makeNode
(
type
,
sizeof
(
SSortLogicNode
));
return
makeNode
(
type
,
sizeof
(
SSortLogicNode
));
case
QUERY_NODE_LOGIC_PLAN_PARTITION
:
case
QUERY_NODE_LOGIC_PLAN_PARTITION
:
return
makeNode
(
type
,
sizeof
(
SPartitionLogicNode
));
return
makeNode
(
type
,
sizeof
(
SPartitionLogicNode
));
case
QUERY_NODE_LOGIC_PLAN_INDEF_ROWS_FUNC
:
return
makeNode
(
type
,
sizeof
(
SIndefRowsFuncLogicNode
));
case
QUERY_NODE_LOGIC_SUBPLAN
:
case
QUERY_NODE_LOGIC_SUBPLAN
:
return
makeNode
(
type
,
sizeof
(
SLogicSubplan
));
return
makeNode
(
type
,
sizeof
(
SLogicSubplan
));
case
QUERY_NODE_LOGIC_PLAN
:
case
QUERY_NODE_LOGIC_PLAN
:
...
@@ -280,6 +282,8 @@ SNodeptr nodesMakeNode(ENodeType type) {
...
@@ -280,6 +282,8 @@ SNodeptr nodesMakeNode(ENodeType type) {
return
makeNode
(
type
,
sizeof
(
SStreamStateWinodwPhysiNode
));
return
makeNode
(
type
,
sizeof
(
SStreamStateWinodwPhysiNode
));
case
QUERY_NODE_PHYSICAL_PLAN_PARTITION
:
case
QUERY_NODE_PHYSICAL_PLAN_PARTITION
:
return
makeNode
(
type
,
sizeof
(
SPartitionPhysiNode
));
return
makeNode
(
type
,
sizeof
(
SPartitionPhysiNode
));
case
QUERY_NODE_PHYSICAL_PLAN_INDEF_ROWS_FUNC
:
return
makeNode
(
type
,
sizeof
(
SIndefRowsFuncPhysiNode
));
case
QUERY_NODE_PHYSICAL_PLAN_DISPATCH
:
case
QUERY_NODE_PHYSICAL_PLAN_DISPATCH
:
return
makeNode
(
type
,
sizeof
(
SDataDispatcherNode
));
return
makeNode
(
type
,
sizeof
(
SDataDispatcherNode
));
case
QUERY_NODE_PHYSICAL_PLAN_INSERT
:
case
QUERY_NODE_PHYSICAL_PLAN_INSERT
:
...
...
source/libs/parser/src/parAstParser.c
浏览文件 @
4560b8f2
...
@@ -258,6 +258,17 @@ static int32_t collectMetaKeyFromExplain(SCollectMetaKeyCxt* pCxt, SExplainStmt*
...
@@ -258,6 +258,17 @@ static int32_t collectMetaKeyFromExplain(SCollectMetaKeyCxt* pCxt, SExplainStmt*
return
collectMetaKeyFromQuery
(
pCxt
,
pStmt
->
pQuery
);
return
collectMetaKeyFromQuery
(
pCxt
,
pStmt
->
pQuery
);
}
}
static
int32_t
collectMetaKeyFromDescribe
(
SCollectMetaKeyCxt
*
pCxt
,
SDescribeStmt
*
pStmt
)
{
SName
name
=
{.
type
=
TSDB_TABLE_NAME_T
,
.
acctId
=
pCxt
->
pParseCxt
->
acctId
};
strcpy
(
name
.
dbname
,
pStmt
->
dbName
);
strcpy
(
name
.
tname
,
pStmt
->
tableName
);
int32_t
code
=
catalogRemoveTableMeta
(
pCxt
->
pParseCxt
->
pCatalog
,
&
name
);
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
reserveTableMetaInCache
(
pCxt
->
pParseCxt
->
acctId
,
pStmt
->
dbName
,
pStmt
->
tableName
,
pCxt
->
pMetaCache
);
}
return
code
;
}
static
int32_t
collectMetaKeyFromCreateStream
(
SCollectMetaKeyCxt
*
pCxt
,
SCreateStreamStmt
*
pStmt
)
{
static
int32_t
collectMetaKeyFromCreateStream
(
SCollectMetaKeyCxt
*
pCxt
,
SCreateStreamStmt
*
pStmt
)
{
return
collectMetaKeyFromQuery
(
pCxt
,
pStmt
->
pQuery
);
return
collectMetaKeyFromQuery
(
pCxt
,
pStmt
->
pQuery
);
}
}
...
@@ -381,6 +392,8 @@ static int32_t collectMetaKeyFromQuery(SCollectMetaKeyCxt* pCxt, SNode* pStmt) {
...
@@ -381,6 +392,8 @@ static int32_t collectMetaKeyFromQuery(SCollectMetaKeyCxt* pCxt, SNode* pStmt) {
return
collectMetaKeyFromCreateTopic
(
pCxt
,
(
SCreateTopicStmt
*
)
pStmt
);
return
collectMetaKeyFromCreateTopic
(
pCxt
,
(
SCreateTopicStmt
*
)
pStmt
);
case
QUERY_NODE_EXPLAIN_STMT
:
case
QUERY_NODE_EXPLAIN_STMT
:
return
collectMetaKeyFromExplain
(
pCxt
,
(
SExplainStmt
*
)
pStmt
);
return
collectMetaKeyFromExplain
(
pCxt
,
(
SExplainStmt
*
)
pStmt
);
case
QUERY_NODE_DESCRIBE_STMT
:
return
collectMetaKeyFromDescribe
(
pCxt
,
(
SDescribeStmt
*
)
pStmt
);
case
QUERY_NODE_CREATE_STREAM_STMT
:
case
QUERY_NODE_CREATE_STREAM_STMT
:
return
collectMetaKeyFromCreateStream
(
pCxt
,
(
SCreateStreamStmt
*
)
pStmt
);
return
collectMetaKeyFromCreateStream
(
pCxt
,
(
SCreateStreamStmt
*
)
pStmt
);
case
QUERY_NODE_SHOW_DNODES_STMT
:
case
QUERY_NODE_SHOW_DNODES_STMT
:
...
...
source/libs/parser/src/parTokenizer.c
浏览文件 @
4560b8f2
...
@@ -64,7 +64,7 @@ static SKeyword keywordTable[] = {
...
@@ -64,7 +64,7 @@ static SKeyword keywordTable[] = {
{
"CONSUMER"
,
TK_CONSUMER
},
{
"CONSUMER"
,
TK_CONSUMER
},
{
"COUNT"
,
TK_COUNT
},
{
"COUNT"
,
TK_COUNT
},
{
"CREATE"
,
TK_CREATE
},
{
"CREATE"
,
TK_CREATE
},
{
"CONTAINS"
,
TK_CONTAINS
},
{
"CONTAINS"
,
TK_CONTAINS
},
{
"DATABASE"
,
TK_DATABASE
},
{
"DATABASE"
,
TK_DATABASE
},
{
"DATABASES"
,
TK_DATABASES
},
{
"DATABASES"
,
TK_DATABASES
},
{
"DAYS"
,
TK_DAYS
},
{
"DAYS"
,
TK_DAYS
},
...
...
source/libs/parser/src/parTranslater.c
浏览文件 @
4560b8f2
...
@@ -2907,7 +2907,6 @@ static int32_t buildRollupAst(STranslateContext* pCxt, SCreateTableStmt* pStmt,
...
@@ -2907,7 +2907,6 @@ static int32_t buildRollupAst(STranslateContext* pCxt, SCreateTableStmt* pStmt,
}
}
}
}
taosArrayDestroy
(
dbCfg
.
pRetensions
);
return
code
;
return
code
;
}
}
...
...
source/libs/parser/test/mockCatalog.cpp
浏览文件 @
4560b8f2
...
@@ -207,6 +207,13 @@ int32_t __catalogGetUdfInfo(SCatalog* pCtg, void* pTrans, const SEpSet* pMgmtEps
...
@@ -207,6 +207,13 @@ int32_t __catalogGetUdfInfo(SCatalog* pCtg, void* pTrans, const SEpSet* pMgmtEps
return
g_mockCatalogService
->
catalogGetUdfInfo
(
funcName
,
pInfo
);
return
g_mockCatalogService
->
catalogGetUdfInfo
(
funcName
,
pInfo
);
}
}
int32_t
__catalogRefreshGetTableMeta
(
SCatalog
*
pCatalog
,
void
*
pTransporter
,
const
SEpSet
*
pMgmtEps
,
const
SName
*
pTableName
,
STableMeta
**
pTableMeta
,
int32_t
isSTable
)
{
return
g_mockCatalogService
->
catalogGetTableMeta
(
pTableName
,
pTableMeta
);
}
int32_t
__catalogRemoveTableMeta
(
SCatalog
*
pCtg
,
SName
*
pTableName
)
{
return
0
;
}
void
initMetaDataEnv
()
{
void
initMetaDataEnv
()
{
g_mockCatalogService
.
reset
(
new
MockCatalogService
());
g_mockCatalogService
.
reset
(
new
MockCatalogService
());
...
@@ -221,6 +228,8 @@ void initMetaDataEnv() {
...
@@ -221,6 +228,8 @@ void initMetaDataEnv() {
stub
.
set
(
catalogGetDBCfg
,
__catalogGetDBCfg
);
stub
.
set
(
catalogGetDBCfg
,
__catalogGetDBCfg
);
stub
.
set
(
catalogChkAuth
,
__catalogChkAuth
);
stub
.
set
(
catalogChkAuth
,
__catalogChkAuth
);
stub
.
set
(
catalogGetUdfInfo
,
__catalogGetUdfInfo
);
stub
.
set
(
catalogGetUdfInfo
,
__catalogGetUdfInfo
);
stub
.
set
(
catalogRefreshGetTableMeta
,
__catalogRefreshGetTableMeta
);
stub
.
set
(
catalogRemoveTableMeta
,
__catalogRemoveTableMeta
);
// {
// {
// AddrAny any("libcatalog.so");
// AddrAny any("libcatalog.so");
// std::map<std::string,void*> result;
// std::map<std::string,void*> result;
...
...
source/libs/parser/test/parInitialDTest.cpp
浏览文件 @
4560b8f2
...
@@ -21,7 +21,7 @@ namespace ParserTest {
...
@@ -21,7 +21,7 @@ namespace ParserTest {
class
ParserInitialDTest
:
public
ParserDdlTest
{};
class
ParserInitialDTest
:
public
ParserDdlTest
{};
// DELETE FROM t
b
_name [WHERE condition]
// DELETE FROM t
able
_name [WHERE condition]
TEST_F
(
ParserInitialDTest
,
delete
)
{
TEST_F
(
ParserInitialDTest
,
delete
)
{
useDb
(
"root"
,
"test"
);
useDb
(
"root"
,
"test"
);
...
@@ -40,7 +40,15 @@ TEST_F(ParserInitialDTest, deleteSemanticCheck) {
...
@@ -40,7 +40,15 @@ TEST_F(ParserInitialDTest, deleteSemanticCheck) {
run
(
"DELETE FROM t1 WHERE c1 > 10"
,
TSDB_CODE_PAR_INVALID_DELETE_WHERE
,
PARSER_STAGE_TRANSLATE
);
run
(
"DELETE FROM t1 WHERE c1 > 10"
,
TSDB_CODE_PAR_INVALID_DELETE_WHERE
,
PARSER_STAGE_TRANSLATE
);
}
}
// todo desc
// DESC table_name
TEST_F
(
ParserInitialDTest
,
describe
)
{
useDb
(
"root"
,
"test"
);
run
(
"DESC t1"
);
run
(
"DESCRIBE st1"
);
}
// todo describe
// todo describe
// todo DROP account
// todo DROP account
...
...
source/libs/parser/test/parTestUtil.h
浏览文件 @
4560b8f2
...
@@ -50,11 +50,13 @@ class ParserDdlTest : public ParserTestBase {
...
@@ -50,11 +50,13 @@ class ParserDdlTest : public ParserTestBase {
virtual
void
checkDdl
(
const
SQuery
*
pQuery
,
ParserStage
stage
)
{
virtual
void
checkDdl
(
const
SQuery
*
pQuery
,
ParserStage
stage
)
{
ASSERT_NE
(
pQuery
,
nullptr
);
ASSERT_NE
(
pQuery
,
nullptr
);
ASSERT_EQ
(
pQuery
->
haveResultSet
,
false
);
ASSERT_NE
(
pQuery
->
pRoot
,
nullptr
);
ASSERT_NE
(
pQuery
->
pRoot
,
nullptr
);
ASSERT_EQ
(
pQuery
->
numOfResCols
,
0
);
if
(
QUERY_EXEC_MODE_RPC
==
pQuery
->
execMode
)
{
ASSERT_EQ
(
pQuery
->
pResSchema
,
nullptr
);
ASSERT_EQ
(
pQuery
->
haveResultSet
,
false
);
ASSERT_EQ
(
pQuery
->
precision
,
0
);
ASSERT_EQ
(
pQuery
->
numOfResCols
,
0
);
ASSERT_EQ
(
pQuery
->
pResSchema
,
nullptr
);
ASSERT_EQ
(
pQuery
->
precision
,
0
);
}
if
(
nullptr
!=
checkDdl_
)
{
if
(
nullptr
!=
checkDdl_
)
{
checkDdl_
(
pQuery
,
stage
);
checkDdl_
(
pQuery
,
stage
);
}
}
...
...
source/libs/planner/src/planLogicCreater.c
浏览文件 @
4560b8f2
...
@@ -456,6 +456,37 @@ static int32_t createAggLogicNode(SLogicPlanContext* pCxt, SSelectStmt* pSelect,
...
@@ -456,6 +456,37 @@ static int32_t createAggLogicNode(SLogicPlanContext* pCxt, SSelectStmt* pSelect,
return
code
;
return
code
;
}
}
static
int32_t
createIndefRowsFuncLogicNode
(
SLogicPlanContext
*
pCxt
,
SSelectStmt
*
pSelect
,
SLogicNode
**
pLogicNode
)
{
// top/bottom are both an aggregate function and a indefinite rows function
if
(
!
pSelect
->
hasIndefiniteRowsFunc
||
pSelect
->
hasAggFuncs
||
NULL
!=
pSelect
->
pWindow
)
{
return
TSDB_CODE_SUCCESS
;
}
SIndefRowsFuncLogicNode
*
pIdfRowsFunc
=
(
SIndefRowsFuncLogicNode
*
)
nodesMakeNode
(
QUERY_NODE_LOGIC_PLAN_INDEF_ROWS_FUNC
);
if
(
NULL
==
pIdfRowsFunc
)
{
return
TSDB_CODE_OUT_OF_MEMORY
;
}
int32_t
code
=
nodesCollectFuncs
(
pSelect
,
SQL_CLAUSE_SELECT
,
fmIsVectorFunc
,
&
pIdfRowsFunc
->
pVectorFuncs
);
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
rewriteExprForSelect
(
pIdfRowsFunc
->
pVectorFuncs
,
pSelect
,
SQL_CLAUSE_SELECT
);
}
// set the output
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
createColumnByRewriteExps
(
pIdfRowsFunc
->
pVectorFuncs
,
&
pIdfRowsFunc
->
node
.
pTargets
);
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
*
pLogicNode
=
(
SLogicNode
*
)
pIdfRowsFunc
;
}
else
{
nodesDestroyNode
(
pIdfRowsFunc
);
}
return
code
;
}
static
int32_t
createWindowLogicNodeFinalize
(
SLogicPlanContext
*
pCxt
,
SSelectStmt
*
pSelect
,
SWindowLogicNode
*
pWindow
,
static
int32_t
createWindowLogicNodeFinalize
(
SLogicPlanContext
*
pCxt
,
SSelectStmt
*
pSelect
,
SWindowLogicNode
*
pWindow
,
SLogicNode
**
pLogicNode
)
{
SLogicNode
**
pLogicNode
)
{
int32_t
code
=
nodesCollectFuncs
(
pSelect
,
SQL_CLAUSE_WINDOW
,
fmIsWindowClauseFunc
,
&
pWindow
->
pFuncs
);
int32_t
code
=
nodesCollectFuncs
(
pSelect
,
SQL_CLAUSE_WINDOW
,
fmIsWindowClauseFunc
,
&
pWindow
->
pFuncs
);
...
@@ -772,6 +803,9 @@ static int32_t createSelectLogicNode(SLogicPlanContext* pCxt, SSelectStmt* pSele
...
@@ -772,6 +803,9 @@ static int32_t createSelectLogicNode(SLogicPlanContext* pCxt, SSelectStmt* pSele
if
(
TSDB_CODE_SUCCESS
==
code
)
{
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
createSelectRootLogicNode
(
pCxt
,
pSelect
,
createAggLogicNode
,
&
pRoot
);
code
=
createSelectRootLogicNode
(
pCxt
,
pSelect
,
createAggLogicNode
,
&
pRoot
);
}
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
createSelectRootLogicNode
(
pCxt
,
pSelect
,
createIndefRowsFuncLogicNode
,
&
pRoot
);
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
createSelectRootLogicNode
(
pCxt
,
pSelect
,
createDistinctLogicNode
,
&
pRoot
);
code
=
createSelectRootLogicNode
(
pCxt
,
pSelect
,
createDistinctLogicNode
,
&
pRoot
);
}
}
...
...
source/libs/planner/src/planPhysiCreater.c
浏览文件 @
4560b8f2
...
@@ -791,6 +791,43 @@ static int32_t createAggPhysiNode(SPhysiPlanContext* pCxt, SNodeList* pChildren,
...
@@ -791,6 +791,43 @@ static int32_t createAggPhysiNode(SPhysiPlanContext* pCxt, SNodeList* pChildren,
return
code
;
return
code
;
}
}
static
int32_t
createIndefRowsFuncPhysiNode
(
SPhysiPlanContext
*
pCxt
,
SNodeList
*
pChildren
,
SIndefRowsFuncLogicNode
*
pFuncLogicNode
,
SPhysiNode
**
pPhyNode
)
{
SIndefRowsFuncPhysiNode
*
pIdfRowsFunc
=
(
SIndefRowsFuncPhysiNode
*
)
makePhysiNode
(
pCxt
,
(
SLogicNode
*
)
pFuncLogicNode
,
QUERY_NODE_PHYSICAL_PLAN_INDEF_ROWS_FUNC
);
if
(
NULL
==
pIdfRowsFunc
)
{
return
TSDB_CODE_OUT_OF_MEMORY
;
}
SNodeList
*
pPrecalcExprs
=
NULL
;
SNodeList
*
pVectorFuncs
=
NULL
;
int32_t
code
=
rewritePrecalcExprs
(
pCxt
,
pFuncLogicNode
->
pVectorFuncs
,
&
pPrecalcExprs
,
&
pVectorFuncs
);
SDataBlockDescNode
*
pChildTupe
=
(((
SPhysiNode
*
)
nodesListGetNode
(
pChildren
,
0
))
->
pOutputDataBlockDesc
);
// push down expression to pOutputDataBlockDesc of child node
if
(
TSDB_CODE_SUCCESS
==
code
&&
NULL
!=
pPrecalcExprs
)
{
code
=
setListSlotId
(
pCxt
,
pChildTupe
->
dataBlockId
,
-
1
,
pPrecalcExprs
,
&
pIdfRowsFunc
->
pExprs
);
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
pushdownDataBlockSlots
(
pCxt
,
pIdfRowsFunc
->
pExprs
,
pChildTupe
);
}
}
if
(
TSDB_CODE_SUCCESS
==
code
&&
NULL
!=
pVectorFuncs
)
{
code
=
setListSlotId
(
pCxt
,
pChildTupe
->
dataBlockId
,
-
1
,
pVectorFuncs
,
&
pIdfRowsFunc
->
pVectorFuncs
);
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
addDataBlockSlots
(
pCxt
,
pIdfRowsFunc
->
pVectorFuncs
,
pIdfRowsFunc
->
node
.
pOutputDataBlockDesc
);
}
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
*
pPhyNode
=
(
SPhysiNode
*
)
pIdfRowsFunc
;
}
else
{
nodesDestroyNode
(
pIdfRowsFunc
);
}
return
code
;
}
static
int32_t
createProjectPhysiNode
(
SPhysiPlanContext
*
pCxt
,
SNodeList
*
pChildren
,
static
int32_t
createProjectPhysiNode
(
SPhysiPlanContext
*
pCxt
,
SNodeList
*
pChildren
,
SProjectLogicNode
*
pProjectLogicNode
,
SPhysiNode
**
pPhyNode
)
{
SProjectLogicNode
*
pProjectLogicNode
,
SPhysiNode
**
pPhyNode
)
{
SProjectPhysiNode
*
pProject
=
SProjectPhysiNode
*
pProject
=
...
@@ -1225,6 +1262,8 @@ static int32_t doCreatePhysiNode(SPhysiPlanContext* pCxt, SLogicNode* pLogicNode
...
@@ -1225,6 +1262,8 @@ static int32_t doCreatePhysiNode(SPhysiPlanContext* pCxt, SLogicNode* pLogicNode
return
createPartitionPhysiNode
(
pCxt
,
pChildren
,
(
SPartitionLogicNode
*
)
pLogicNode
,
pPhyNode
);
return
createPartitionPhysiNode
(
pCxt
,
pChildren
,
(
SPartitionLogicNode
*
)
pLogicNode
,
pPhyNode
);
case
QUERY_NODE_LOGIC_PLAN_FILL
:
case
QUERY_NODE_LOGIC_PLAN_FILL
:
return
createFillPhysiNode
(
pCxt
,
pChildren
,
(
SFillLogicNode
*
)
pLogicNode
,
pPhyNode
);
return
createFillPhysiNode
(
pCxt
,
pChildren
,
(
SFillLogicNode
*
)
pLogicNode
,
pPhyNode
);
case
QUERY_NODE_LOGIC_PLAN_INDEF_ROWS_FUNC
:
return
createIndefRowsFuncPhysiNode
(
pCxt
,
pChildren
,
(
SIndefRowsFuncLogicNode
*
)
pLogicNode
,
pPhyNode
);
case
QUERY_NODE_LOGIC_PLAN_MERGE
:
case
QUERY_NODE_LOGIC_PLAN_MERGE
:
return
createMergePhysiNode
(
pCxt
,
(
SMergeLogicNode
*
)
pLogicNode
,
pPhyNode
);
return
createMergePhysiNode
(
pCxt
,
(
SMergeLogicNode
*
)
pLogicNode
,
pPhyNode
);
default:
default:
...
...
source/libs/planner/test/planIntervalTest.cpp
浏览文件 @
4560b8f2
...
@@ -50,6 +50,8 @@ TEST_F(PlanIntervalTest, selectFunc) {
...
@@ -50,6 +50,8 @@ TEST_F(PlanIntervalTest, selectFunc) {
run
(
"SELECT MAX(c1), MIN(c1) FROM t1 INTERVAL(10s)"
);
run
(
"SELECT MAX(c1), MIN(c1) FROM t1 INTERVAL(10s)"
);
// select function along with the columns of select row, and with INTERVAL clause
// select function along with the columns of select row, and with INTERVAL clause
run
(
"SELECT MAX(c1), c2 FROM t1 INTERVAL(10s)"
);
run
(
"SELECT MAX(c1), c2 FROM t1 INTERVAL(10s)"
);
run
(
"SELECT TOP(c1, 1) FROM t1 INTERVAL(10s) ORDER BY c1"
);
}
}
TEST_F
(
PlanIntervalTest
,
stable
)
{
TEST_F
(
PlanIntervalTest
,
stable
)
{
...
...
source/libs/planner/test/planProjectTest.cpp
0 → 100644
浏览文件 @
4560b8f2
/*
* Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
*
* This program is free software: you can use, redistribute, and/or modify
* it under the terms of the GNU Affero General Public License, version 3
* or later ("AGPL"), as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "planTestUtil.h"
using
namespace
std
;
class
PlanProjectTest
:
public
PlannerTestBase
{};
TEST_F
(
PlanProjectTest
,
basic
)
{
useDb
(
"root"
,
"test"
);
run
(
"SELECT CEIL(c1) FROM t1"
);
}
TEST_F
(
PlanProjectTest
,
indefiniteRowsFunc
)
{
useDb
(
"root"
,
"test"
);
run
(
"SELECT MAVG(c1, 10) FROM t1"
);
run
(
"SELECT MAVG(CEIL(c1), 20) + 2 FROM t1"
);
}
source/libs/planner/test/planTestUtil.cpp
浏览文件 @
4560b8f2
...
@@ -81,6 +81,8 @@ int32_t getLogLevel() { return g_logLevel; }
...
@@ -81,6 +81,8 @@ int32_t getLogLevel() { return g_logLevel; }
class
PlannerTestBaseImpl
{
class
PlannerTestBaseImpl
{
public:
public:
PlannerTestBaseImpl
()
:
sqlNo_
(
0
)
{}
void
useDb
(
const
string
&
acctId
,
const
string
&
db
)
{
void
useDb
(
const
string
&
acctId
,
const
string
&
db
)
{
caseEnv_
.
acctId_
=
acctId
;
caseEnv_
.
acctId_
=
acctId
;
caseEnv_
.
db_
=
db
;
caseEnv_
.
db_
=
db
;
...
@@ -88,6 +90,7 @@ class PlannerTestBaseImpl {
...
@@ -88,6 +90,7 @@ class PlannerTestBaseImpl {
}
}
void
run
(
const
string
&
sql
)
{
void
run
(
const
string
&
sql
)
{
++
sqlNo_
;
if
(
caseEnv_
.
nsql_
>
0
)
{
if
(
caseEnv_
.
nsql_
>
0
)
{
--
(
caseEnv_
.
nsql_
);
--
(
caseEnv_
.
nsql_
);
return
;
return
;
...
@@ -187,6 +190,8 @@ class PlannerTestBaseImpl {
...
@@ -187,6 +190,8 @@ class PlannerTestBaseImpl {
string
acctId_
;
string
acctId_
;
string
db_
;
string
db_
;
int32_t
nsql_
;
int32_t
nsql_
;
caseEnv
()
:
nsql_
(
0
)
{}
};
};
struct
stmtEnv
{
struct
stmtEnv
{
...
@@ -194,6 +199,7 @@ class PlannerTestBaseImpl {
...
@@ -194,6 +199,7 @@ class PlannerTestBaseImpl {
array
<
char
,
1024
>
msgBuf_
;
array
<
char
,
1024
>
msgBuf_
;
SQuery
*
pQuery_
;
SQuery
*
pQuery_
;
stmtEnv
()
:
pQuery_
(
nullptr
)
{}
~
stmtEnv
()
{
qDestroyQuery
(
pQuery_
);
}
~
stmtEnv
()
{
qDestroyQuery
(
pQuery_
);
}
};
};
...
@@ -229,7 +235,7 @@ class PlannerTestBaseImpl {
...
@@ -229,7 +235,7 @@ class PlannerTestBaseImpl {
return
;
return
;
}
}
cout
<<
"==========================================sql : ["
<<
stmtEnv_
.
sql_
<<
"]"
<<
endl
;
cout
<<
"==========================================
"
<<
sqlNo_
<<
"
sql : ["
<<
stmtEnv_
.
sql_
<<
"]"
<<
endl
;
if
(
DUMP_MODULE_ALL
==
module
||
DUMP_MODULE_PARSER
==
module
)
{
if
(
DUMP_MODULE_ALL
==
module
||
DUMP_MODULE_PARSER
==
module
)
{
if
(
res_
.
prepareAst_
.
empty
())
{
if
(
res_
.
prepareAst_
.
empty
())
{
...
@@ -382,6 +388,7 @@ class PlannerTestBaseImpl {
...
@@ -382,6 +388,7 @@ class PlannerTestBaseImpl {
caseEnv
caseEnv_
;
caseEnv
caseEnv_
;
stmtEnv
stmtEnv_
;
stmtEnv
stmtEnv_
;
stmtRes
res_
;
stmtRes
res_
;
int32_t
sqlNo_
;
};
};
PlannerTestBase
::
PlannerTestBase
()
:
impl_
(
new
PlannerTestBaseImpl
())
{}
PlannerTestBase
::
PlannerTestBase
()
:
impl_
(
new
PlannerTestBaseImpl
())
{}
...
...
source/libs/qcom/src/querymsg.c
浏览文件 @
4560b8f2
...
@@ -37,6 +37,8 @@ int32_t queryBuildUseDbOutput(SUseDbOutput *pOut, SUseDbRsp *usedbRsp) {
...
@@ -37,6 +37,8 @@ int32_t queryBuildUseDbOutput(SUseDbOutput *pOut, SUseDbRsp *usedbRsp) {
pOut
->
dbVgroup
->
vgVersion
=
usedbRsp
->
vgVersion
;
pOut
->
dbVgroup
->
vgVersion
=
usedbRsp
->
vgVersion
;
pOut
->
dbVgroup
->
hashMethod
=
usedbRsp
->
hashMethod
;
pOut
->
dbVgroup
->
hashMethod
=
usedbRsp
->
hashMethod
;
qDebug
(
"Got %d vgroup for db %s"
,
usedbRsp
->
vgNum
,
usedbRsp
->
db
);
if
(
usedbRsp
->
vgNum
<=
0
)
{
if
(
usedbRsp
->
vgNum
<=
0
)
{
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
...
@@ -50,6 +52,8 @@ int32_t queryBuildUseDbOutput(SUseDbOutput *pOut, SUseDbRsp *usedbRsp) {
...
@@ -50,6 +52,8 @@ int32_t queryBuildUseDbOutput(SUseDbOutput *pOut, SUseDbRsp *usedbRsp) {
for
(
int32_t
i
=
0
;
i
<
usedbRsp
->
vgNum
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
usedbRsp
->
vgNum
;
++
i
)
{
SVgroupInfo
*
pVgInfo
=
taosArrayGet
(
usedbRsp
->
pVgroupInfos
,
i
);
SVgroupInfo
*
pVgInfo
=
taosArrayGet
(
usedbRsp
->
pVgroupInfos
,
i
);
pOut
->
dbVgroup
->
numOfTable
+=
pVgInfo
->
numOfTable
;
pOut
->
dbVgroup
->
numOfTable
+=
pVgInfo
->
numOfTable
;
qDebug
(
"the %dth vgroup, id %d, epNum %d, current %s port %d"
,
i
,
pVgInfo
->
vgId
,
pVgInfo
->
epSet
.
numOfEps
,
pVgInfo
->
epSet
.
eps
[
pVgInfo
->
epSet
.
inUse
].
fqdn
,
pVgInfo
->
epSet
.
eps
[
pVgInfo
->
epSet
.
inUse
].
port
);
if
(
0
!=
taosHashPut
(
pOut
->
dbVgroup
->
vgHash
,
&
pVgInfo
->
vgId
,
sizeof
(
int32_t
),
pVgInfo
,
sizeof
(
SVgroupInfo
)))
{
if
(
0
!=
taosHashPut
(
pOut
->
dbVgroup
->
vgHash
,
&
pVgInfo
->
vgId
,
sizeof
(
int32_t
),
pVgInfo
,
sizeof
(
SVgroupInfo
)))
{
return
TSDB_CODE_TSC_OUT_OF_MEMORY
;
return
TSDB_CODE_TSC_OUT_OF_MEMORY
;
}
}
...
...
source/libs/scheduler/src/schJob.c
浏览文件 @
4560b8f2
...
@@ -108,7 +108,7 @@ int32_t schInitJob(SSchJob **pSchJob, SQueryPlan *pDag, void *pTrans, SArray *pN
...
@@ -108,7 +108,7 @@ int32_t schInitJob(SSchJob **pSchJob, SQueryPlan *pDag, void *pTrans, SArray *pN
pJob
->
refId
=
refId
;
pJob
->
refId
=
refId
;
SCH_JOB_DLOG
(
"job refId:
%"
PRIx64
,
pJob
->
refId
);
SCH_JOB_DLOG
(
"job refId:
0x%"
PRIx64
" created"
,
pJob
->
refId
);
pJob
->
status
=
JOB_TASK_STATUS_NOT_START
;
pJob
->
status
=
JOB_TASK_STATUS_NOT_START
;
...
...
source/libs/stream/inc/
t
streamInc.h
→
source/libs/stream/inc/streamInc.h
浏览文件 @
4560b8f2
...
@@ -13,15 +13,21 @@
...
@@ -13,15 +13,21 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
*/
#ifndef _STREAM_INC_H_
#define _STREAM_INC_H_
#include "executor.h"
#include "tstream.h"
#ifdef __cplusplus
#ifdef __cplusplus
extern
"C"
{
extern
"C"
{
#endif
#endif
#ifndef _TSTREAM_H_
int32_t
streamExec
(
SStreamTask
*
pTask
,
SMsgCb
*
pMsgCb
);
#define _TSTREAM_H_
int32_t
streamSink1
(
SStreamTask
*
pTask
,
SMsgCb
*
pMsgCb
);
#ifdef __cplusplus
#ifdef __cplusplus
}
}
#endif
#endif
#endif
/* ifndef _
TSTREAM
_H_ */
#endif
/* ifndef _
STREAM_INC
_H_ */
source/libs/stream/src/stream.c
0 → 100644
浏览文件 @
4560b8f2
/*
* Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
*
* This program is free software: you can use, redistribute, and/or modify
* it under the terms of the GNU Affero General Public License, version 3
* or later ("AGPL"), as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "streamInc.h"
int32_t
streamTriggerByWrite
(
SStreamTask
*
pTask
,
int32_t
vgId
,
SMsgCb
*
pMsgCb
)
{
int8_t
execStatus
=
atomic_load_8
(
&
pTask
->
status
);
if
(
execStatus
==
TASK_STATUS__IDLE
||
execStatus
==
TASK_STATUS__CLOSING
)
{
SStreamTaskRunReq
*
pRunReq
=
rpcMallocCont
(
sizeof
(
SStreamTaskRunReq
));
if
(
pRunReq
==
NULL
)
return
-
1
;
// TODO: do we need htonl?
pRunReq
->
head
.
vgId
=
vgId
;
pRunReq
->
streamId
=
pTask
->
streamId
;
pRunReq
->
taskId
=
pTask
->
taskId
;
SRpcMsg
msg
=
{
.
msgType
=
TDMT_VND_TASK_RUN
,
.
pCont
=
pRunReq
,
.
contLen
=
sizeof
(
SStreamTaskRunReq
),
};
tmsgPutToQueue
(
pMsgCb
,
FETCH_QUEUE
,
&
msg
);
}
return
0
;
}
#if 1
int32_t
streamTaskEnqueue
(
SStreamTask
*
pTask
,
SStreamDispatchReq
*
pReq
,
SRpcMsg
*
pRsp
)
{
SStreamDataBlock
*
pBlock
=
taosAllocateQitem
(
sizeof
(
SStreamDataBlock
),
DEF_QITEM
);
int8_t
status
;
// enqueue
if
(
pBlock
!=
NULL
)
{
pBlock
->
type
=
STREAM_DATA_TYPE_SSDATA_BLOCK
;
pBlock
->
sourceVg
=
pReq
->
sourceVg
;
pBlock
->
blocks
=
pReq
->
data
;
/*pBlock->sourceVer = pReq->sourceVer;*/
if
(
streamTaskInput
(
pTask
,
(
SStreamQueueItem
*
)
pBlock
)
==
0
)
{
status
=
TASK_INPUT_STATUS__NORMAL
;
}
else
{
status
=
TASK_INPUT_STATUS__FAILED
;
}
}
else
{
streamTaskInputFail
(
pTask
);
status
=
TASK_INPUT_STATUS__FAILED
;
}
// rsp by input status
SStreamDispatchRsp
*
pCont
=
rpcMallocCont
(
sizeof
(
SStreamDispatchRsp
));
pCont
->
inputStatus
=
status
;
pCont
->
streamId
=
pReq
->
streamId
;
pCont
->
taskId
=
pReq
->
sourceTaskId
;
pRsp
->
pCont
=
pCont
;
pRsp
->
contLen
=
sizeof
(
SStreamDispatchRsp
);
tmsgSendRsp
(
pRsp
);
return
status
==
TASK_INPUT_STATUS__NORMAL
?
0
:
-
1
;
}
#endif
int32_t
streamProcessDispatchReq
(
SStreamTask
*
pTask
,
SMsgCb
*
pMsgCb
,
SStreamDispatchReq
*
pReq
,
SRpcMsg
*
pRsp
)
{
// 1. handle input
streamTaskEnqueue
(
pTask
,
pReq
,
pRsp
);
// 2. try exec
// 2.1. idle: exec
// 2.2. executing: return
// 2.3. closing: keep trying
streamExec
(
pTask
,
pMsgCb
);
// 3. handle output
// 3.1 check and set status
// 3.2 dispatch / sink
streamSink1
(
pTask
,
pMsgCb
);
return
0
;
}
int32_t
streamProcessDispatchRsp
(
SStreamTask
*
pTask
,
SMsgCb
*
pMsgCb
,
SStreamDispatchRsp
*
pRsp
)
{
if
(
pRsp
->
inputStatus
==
TASK_INPUT_STATUS__BLOCKED
)
{
// TODO: init recover timer
}
// continue dispatch
streamSink1
(
pTask
,
pMsgCb
);
return
0
;
}
int32_t
streamTaskProcessRunReq
(
SStreamTask
*
pTask
,
SMsgCb
*
pMsgCb
)
{
streamExec
(
pTask
,
pMsgCb
);
streamSink1
(
pTask
,
pMsgCb
);
return
0
;
}
int32_t
streamProcessRecoverReq
(
SStreamTask
*
pTask
,
SMsgCb
*
pMsgCb
,
SStreamTaskRecoverReq
*
pReq
,
SRpcMsg
*
pMsg
)
{
//
return
0
;
}
int32_t
streamProcessRecoverRsp
(
SStreamTask
*
pTask
,
SStreamTaskRecoverRsp
*
pRsp
)
{
//
return
0
;
}
source/libs/stream/src/streamData.c
0 → 100644
浏览文件 @
4560b8f2
/*
* Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
*
* This program is free software: you can use, redistribute, and/or modify
* it under the terms of the GNU Affero General Public License, version 3
* or later ("AGPL"), as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "tstream.h"
#if 0
int32_t streamDataBlockEncode(void** buf, const SStreamDataBlock* pOutput) {
int32_t tlen = 0;
tlen += taosEncodeFixedI8(buf, pOutput->type);
tlen += taosEncodeFixedI32(buf, pOutput->sourceVg);
tlen += taosEncodeFixedI64(buf, pOutput->sourceVer);
ASSERT(pOutput->type == STREAM_INPUT__DATA_BLOCK);
tlen += tEncodeDataBlocks(buf, pOutput->blocks);
return tlen;
}
void* streamDataBlockDecode(const void* buf, SStreamDataBlock* pInput) {
buf = taosDecodeFixedI8(buf, &pInput->type);
buf = taosDecodeFixedI32(buf, &pInput->sourceVg);
buf = taosDecodeFixedI64(buf, &pInput->sourceVer);
ASSERT(pInput->type == STREAM_INPUT__DATA_BLOCK);
buf = tDecodeDataBlocks(buf, &pInput->blocks);
return (void*)buf;
}
#endif
SStreamDataSubmit
*
streamDataSubmitNew
(
SSubmitReq
*
pReq
)
{
SStreamDataSubmit
*
pDataSubmit
=
(
SStreamDataSubmit
*
)
taosAllocateQitem
(
sizeof
(
SStreamDataSubmit
),
DEF_QITEM
);
if
(
pDataSubmit
==
NULL
)
return
NULL
;
pDataSubmit
->
dataRef
=
(
int32_t
*
)
taosMemoryMalloc
(
sizeof
(
int32_t
));
if
(
pDataSubmit
->
dataRef
==
NULL
)
goto
FAIL
;
pDataSubmit
->
data
=
pReq
;
*
pDataSubmit
->
dataRef
=
1
;
pDataSubmit
->
type
=
STREAM_INPUT__DATA_SUBMIT
;
return
pDataSubmit
;
FAIL:
taosFreeQitem
(
pDataSubmit
);
return
NULL
;
}
static
FORCE_INLINE
void
streamDataSubmitRefInc
(
SStreamDataSubmit
*
pDataSubmit
)
{
//
atomic_add_fetch_32
(
pDataSubmit
->
dataRef
,
1
);
}
SStreamDataSubmit
*
streamSubmitRefClone
(
SStreamDataSubmit
*
pSubmit
)
{
SStreamDataSubmit
*
pSubmitClone
=
taosAllocateQitem
(
sizeof
(
SStreamDataSubmit
),
DEF_QITEM
);
if
(
pSubmitClone
==
NULL
)
{
return
NULL
;
}
streamDataSubmitRefInc
(
pSubmit
);
memcpy
(
pSubmitClone
,
pSubmit
,
sizeof
(
SStreamDataSubmit
));
return
pSubmitClone
;
}
#if 0
int32_t tEncodeSStreamTaskExecReq(void** buf, const SStreamTaskExecReq* pReq) {
int32_t tlen = 0;
tlen += taosEncodeFixedI64(buf, pReq->streamId);
tlen += taosEncodeFixedI32(buf, pReq->taskId);
tlen += tEncodeDataBlocks(buf, pReq->data);
return tlen;
}
void* tDecodeSStreamTaskExecReq(const void* buf, SStreamTaskExecReq* pReq) {
buf = taosDecodeFixedI64(buf, &pReq->streamId);
buf = taosDecodeFixedI32(buf, &pReq->taskId);
buf = tDecodeDataBlocks(buf, &pReq->data);
return (void*)buf;
}
void tFreeSStreamTaskExecReq(SStreamTaskExecReq* pReq) { taosArrayDestroy(pReq->data); }
#endif
source/libs/stream/src/streamExec.c
0 → 100644
浏览文件 @
4560b8f2
/*
* Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
*
* This program is free software: you can use, redistribute, and/or modify
* it under the terms of the GNU Affero General Public License, version 3
* or later ("AGPL"), as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "executor.h"
#include "tstream.h"
static
int32_t
streamTaskExecImpl
(
SStreamTask
*
pTask
,
void
*
data
,
SArray
*
pRes
)
{
void
*
exec
=
pTask
->
exec
.
executor
;
// set input
if
(
pTask
->
inputType
==
STREAM_INPUT__DATA_SUBMIT
)
{
SStreamDataSubmit
*
pSubmit
=
(
SStreamDataSubmit
*
)
data
;
ASSERT
(
pSubmit
->
type
==
STREAM_INPUT__DATA_SUBMIT
);
qSetStreamInput
(
exec
,
pSubmit
->
data
,
STREAM_DATA_TYPE_SUBMIT_BLOCK
,
false
);
}
else
if
(
pTask
->
inputType
==
STREAM_INPUT__DATA_BLOCK
)
{
SStreamDataBlock
*
pBlock
=
(
SStreamDataBlock
*
)
data
;
ASSERT
(
pBlock
->
type
==
STREAM_INPUT__DATA_BLOCK
);
SArray
*
blocks
=
pBlock
->
blocks
;
qSetMultiStreamInput
(
exec
,
blocks
->
pData
,
blocks
->
size
,
STREAM_DATA_TYPE_SSDATA_BLOCK
,
false
);
}
// exec
while
(
1
)
{
SSDataBlock
*
output
=
NULL
;
uint64_t
ts
=
0
;
if
(
qExecTask
(
exec
,
&
output
,
&
ts
)
<
0
)
{
ASSERT
(
false
);
}
if
(
output
==
NULL
)
break
;
// TODO: do we need free memory?
SSDataBlock
*
outputCopy
=
createOneDataBlock
(
output
,
true
);
taosArrayPush
(
pRes
,
outputCopy
);
}
return
0
;
}
static
SArray
*
streamExecForQall
(
SStreamTask
*
pTask
,
SArray
*
pRes
)
{
while
(
1
)
{
void
*
data
=
streamQueueNextItem
(
pTask
->
inputQueue
);
if
(
data
==
NULL
)
break
;
streamTaskExecImpl
(
pTask
,
data
,
pRes
);
if
(
taosArrayGetSize
(
pRes
)
!=
0
)
{
SStreamDataBlock
*
qRes
=
taosAllocateQitem
(
sizeof
(
SStreamDataBlock
),
DEF_QITEM
);
if
(
qRes
==
NULL
)
{
streamQueueProcessFail
(
pTask
->
inputQueue
);
taosArrayDestroy
(
pRes
);
return
NULL
;
}
qRes
->
type
=
STREAM_INPUT__DATA_BLOCK
;
qRes
->
blocks
=
pRes
;
if
(
streamTaskOutput
(
pTask
,
qRes
)
<
0
)
{
streamQueueProcessFail
(
pTask
->
inputQueue
);
taosArrayDestroy
(
pRes
);
taosFreeQitem
(
qRes
);
return
NULL
;
}
if
(
pTask
->
inputType
==
STREAM_INPUT__DATA_SUBMIT
)
{
streamDataSubmitRefDec
((
SStreamDataSubmit
*
)
data
);
taosFreeQitem
(
data
);
}
else
{
taosArrayDestroyEx
(((
SStreamDataBlock
*
)
data
)
->
blocks
,
(
FDelete
)
tDeleteSSDataBlock
);
taosFreeQitem
(
data
);
}
streamQueueProcessSuccess
(
pTask
->
inputQueue
);
return
taosArrayInit
(
0
,
sizeof
(
SSDataBlock
));
}
}
return
pRes
;
}
// TODO: handle version
int32_t
streamExec
(
SStreamTask
*
pTask
,
SMsgCb
*
pMsgCb
)
{
SArray
*
pRes
=
taosArrayInit
(
0
,
sizeof
(
SSDataBlock
));
if
(
pRes
==
NULL
)
return
-
1
;
while
(
1
)
{
int8_t
execStatus
=
atomic_val_compare_exchange_8
(
&
pTask
->
status
,
TASK_STATUS__IDLE
,
TASK_STATUS__EXECUTING
);
if
(
execStatus
==
TASK_STATUS__IDLE
)
{
// first run
pRes
=
streamExecForQall
(
pTask
,
pRes
);
if
(
pRes
==
NULL
)
goto
FAIL
;
// set status closing
atomic_store_8
(
&
pTask
->
status
,
TASK_STATUS__CLOSING
);
// second run, make sure inputQ and qall are cleared
pRes
=
streamExecForQall
(
pTask
,
pRes
);
if
(
pRes
==
NULL
)
goto
FAIL
;
break
;
}
else
if
(
execStatus
==
TASK_STATUS__CLOSING
)
{
continue
;
}
else
if
(
execStatus
==
TASK_STATUS__EXECUTING
)
{
break
;
}
else
{
ASSERT
(
0
);
}
}
if
(
pRes
)
taosArrayDestroy
(
pRes
);
atomic_store_8
(
&
pTask
->
status
,
TASK_STATUS__IDLE
);
return
0
;
FAIL:
if
(
pRes
)
taosArrayDestroy
(
pRes
);
atomic_store_8
(
&
pTask
->
status
,
TASK_STATUS__IDLE
);
return
-
1
;
}
source/libs/stream/src/streamMsg.c
0 → 100644
浏览文件 @
4560b8f2
/*
* Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
*
* This program is free software: you can use, redistribute, and/or modify
* it under the terms of the GNU Affero General Public License, version 3
* or later ("AGPL"), as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "tstream.h"
int32_t
tEncodeStreamDispatchReq
(
SEncoder
*
pEncoder
,
const
SStreamDispatchReq
*
pReq
)
{
if
(
tStartEncode
(
pEncoder
)
<
0
)
return
-
1
;
if
(
tEncodeI64
(
pEncoder
,
pReq
->
streamId
)
<
0
)
return
-
1
;
if
(
tEncodeI32
(
pEncoder
,
pReq
->
taskId
)
<
0
)
return
-
1
;
if
(
tEncodeI32
(
pEncoder
,
pReq
->
sourceTaskId
)
<
0
)
return
-
1
;
if
(
tEncodeI32
(
pEncoder
,
pReq
->
sourceVg
)
<
0
)
return
-
1
;
if
(
tEncodeI32
(
pEncoder
,
pReq
->
sourceChildId
)
<
0
)
return
-
1
;
if
(
tEncodeI32
(
pEncoder
,
pReq
->
blockNum
)
<
0
)
return
-
1
;
ASSERT
(
taosArrayGetSize
(
pReq
->
data
)
==
pReq
->
blockNum
);
ASSERT
(
taosArrayGetSize
(
pReq
->
dataLen
)
==
pReq
->
blockNum
);
for
(
int32_t
i
=
0
;
i
<
pReq
->
blockNum
;
i
++
)
{
int32_t
len
=
*
(
int32_t
*
)
taosArrayGet
(
pReq
->
dataLen
,
i
);
void
*
data
=
taosArrayGetP
(
pReq
->
data
,
i
);
if
(
tEncodeI32
(
pEncoder
,
len
)
<
0
)
return
-
1
;
if
(
tEncodeBinary
(
pEncoder
,
data
,
len
)
<
0
)
return
-
1
;
}
tEndEncode
(
pEncoder
);
return
0
;
}
int32_t
tDecodeStreamDispatchReq
(
SDecoder
*
pDecoder
,
SStreamDispatchReq
*
pReq
)
{
if
(
tStartDecode
(
pDecoder
)
<
0
)
return
-
1
;
if
(
tDecodeI64
(
pDecoder
,
&
pReq
->
streamId
)
<
0
)
return
-
1
;
if
(
tDecodeI32
(
pDecoder
,
&
pReq
->
taskId
)
<
0
)
return
-
1
;
if
(
tDecodeI32
(
pDecoder
,
&
pReq
->
sourceTaskId
)
<
0
)
return
-
1
;
if
(
tDecodeI32
(
pDecoder
,
&
pReq
->
sourceVg
)
<
0
)
return
-
1
;
if
(
tDecodeI32
(
pDecoder
,
&
pReq
->
sourceChildId
)
<
0
)
return
-
1
;
if
(
tDecodeI32
(
pDecoder
,
&
pReq
->
blockNum
)
<
0
)
return
-
1
;
ASSERT
(
pReq
->
blockNum
>
0
);
pReq
->
data
=
taosArrayInit
(
pReq
->
blockNum
,
sizeof
(
void
*
));
pReq
->
dataLen
=
taosArrayInit
(
pReq
->
blockNum
,
sizeof
(
int32_t
));
for
(
int32_t
i
=
0
;
i
<
pReq
->
blockNum
;
i
++
)
{
int32_t
len1
;
uint64_t
len2
;
void
*
data
;
if
(
tDecodeI32
(
pDecoder
,
&
len1
)
<
0
)
return
-
1
;
if
(
tDecodeBinaryAlloc
(
pDecoder
,
&
data
,
&
len2
)
<
0
)
return
-
1
;
ASSERT
(
len1
==
len2
);
taosArrayPush
(
pReq
->
dataLen
,
&
len1
);
taosArrayPush
(
pReq
->
data
,
&
data
);
}
tEndDecode
(
pDecoder
);
return
0
;
}
int32_t
streamBuildDispatchMsg
(
SStreamTask
*
pTask
,
SArray
*
data
,
SRpcMsg
*
pMsg
,
SEpSet
**
ppEpSet
)
{
SStreamDispatchReq
req
=
{
.
streamId
=
pTask
->
streamId
,
.
data
=
data
,
};
return
0
;
}
static
int32_t
streamBuildExecMsg
(
SStreamTask
*
pTask
,
SArray
*
data
,
SRpcMsg
*
pMsg
,
SEpSet
**
ppEpSet
)
{
SStreamTaskExecReq
req
=
{
.
streamId
=
pTask
->
streamId
,
.
data
=
data
,
};
int32_t
tlen
=
sizeof
(
SMsgHead
)
+
tEncodeSStreamTaskExecReq
(
NULL
,
&
req
);
void
*
buf
=
rpcMallocCont
(
tlen
);
if
(
buf
==
NULL
)
{
return
-
1
;
}
if
(
pTask
->
dispatchType
==
TASK_DISPATCH__INPLACE
)
{
((
SMsgHead
*
)
buf
)
->
vgId
=
0
;
req
.
taskId
=
pTask
->
inplaceDispatcher
.
taskId
;
}
else
if
(
pTask
->
dispatchType
==
TASK_DISPATCH__FIXED
)
{
((
SMsgHead
*
)
buf
)
->
vgId
=
htonl
(
pTask
->
fixedEpDispatcher
.
nodeId
);
*
ppEpSet
=
&
pTask
->
fixedEpDispatcher
.
epSet
;
req
.
taskId
=
pTask
->
fixedEpDispatcher
.
taskId
;
}
else
if
(
pTask
->
dispatchType
==
TASK_DISPATCH__SHUFFLE
)
{
// TODO use general name rule of schemaless
char
ctbName
[
TSDB_TABLE_FNAME_LEN
+
22
]
=
{
0
};
// all groupId must be the same in an array
SSDataBlock
*
pBlock
=
taosArrayGet
(
data
,
0
);
sprintf
(
ctbName
,
"%s:%ld"
,
pTask
->
shuffleDispatcher
.
stbFullName
,
pBlock
->
info
.
groupId
);
// TODO: get hash function by hashMethod
// get groupId, compute hash value
uint32_t
hashValue
=
MurmurHash3_32
(
ctbName
,
strlen
(
ctbName
));
// get node
// TODO: optimize search process
SArray
*
vgInfo
=
pTask
->
shuffleDispatcher
.
dbInfo
.
pVgroupInfos
;
int32_t
sz
=
taosArrayGetSize
(
vgInfo
);
int32_t
nodeId
=
0
;
for
(
int32_t
i
=
0
;
i
<
sz
;
i
++
)
{
SVgroupInfo
*
pVgInfo
=
taosArrayGet
(
vgInfo
,
i
);
if
(
hashValue
>=
pVgInfo
->
hashBegin
&&
hashValue
<=
pVgInfo
->
hashEnd
)
{
nodeId
=
pVgInfo
->
vgId
;
req
.
taskId
=
pVgInfo
->
taskId
;
*
ppEpSet
=
&
pVgInfo
->
epSet
;
break
;
}
}
ASSERT
(
nodeId
!=
0
);
((
SMsgHead
*
)
buf
)
->
vgId
=
htonl
(
nodeId
);
}
void
*
abuf
=
POINTER_SHIFT
(
buf
,
sizeof
(
SMsgHead
));
tEncodeSStreamTaskExecReq
(
&
abuf
,
&
req
);
pMsg
->
pCont
=
buf
;
pMsg
->
contLen
=
tlen
;
pMsg
->
code
=
0
;
pMsg
->
msgType
=
pTask
->
dispatchMsgType
;
pMsg
->
info
.
noResp
=
1
;
return
0
;
}
static
int32_t
streamShuffleDispatch
(
SStreamTask
*
pTask
,
SMsgCb
*
pMsgCb
,
SHashObj
*
data
)
{
void
*
pIter
=
NULL
;
while
(
1
)
{
pIter
=
taosHashIterate
(
data
,
pIter
);
if
(
pIter
==
NULL
)
return
0
;
SArray
*
pData
=
*
(
SArray
**
)
pIter
;
SRpcMsg
dispatchMsg
=
{
0
};
SEpSet
*
pEpSet
;
if
(
streamBuildExecMsg
(
pTask
,
pData
,
&
dispatchMsg
,
&
pEpSet
)
<
0
)
{
ASSERT
(
0
);
return
-
1
;
}
tmsgSendReq
(
pEpSet
,
&
dispatchMsg
);
}
return
0
;
}
source/libs/stream/src/streamQueue.c
0 → 100644
浏览文件 @
4560b8f2
/*
* Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
*
* This program is free software: you can use, redistribute, and/or modify
* it under the terms of the GNU Affero General Public License, version 3
* or later ("AGPL"), as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "tstream.h"
SStreamQueue
*
streamQueueOpen
()
{
SStreamQueue
*
pQueue
=
taosMemoryCalloc
(
1
,
sizeof
(
SStreamQueue
));
if
(
pQueue
==
NULL
)
return
NULL
;
pQueue
->
queue
=
taosOpenQueue
();
pQueue
->
qall
=
taosAllocateQall
();
if
(
pQueue
->
queue
==
NULL
||
pQueue
->
qall
==
NULL
)
{
goto
FAIL
;
}
pQueue
->
status
=
STREAM_QUEUE__SUCESS
;
return
pQueue
;
FAIL:
if
(
pQueue
->
queue
)
taosCloseQueue
(
pQueue
->
queue
);
if
(
pQueue
->
qall
)
taosFreeQall
(
pQueue
->
qall
);
taosMemoryFree
(
pQueue
);
return
NULL
;
}
void
streamQueueClose
(
SStreamQueue
*
queue
)
{
while
(
1
)
{
void
*
qItem
=
streamQueueNextItem
(
queue
);
if
(
qItem
)
taosFreeQitem
(
qItem
);
else
return
;
}
}
source/libs/stream/src/streamSink.c
0 → 100644
浏览文件 @
4560b8f2
/*
* Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
*
* This program is free software: you can use, redistribute, and/or modify
* it under the terms of the GNU Affero General Public License, version 3
* or later ("AGPL"), as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "executor.h"
#include "tstream.h"
int32_t
streamSink1
(
SStreamTask
*
pTask
,
SMsgCb
*
pMsgCb
)
{
SStreamQueue
*
queue
;
if
(
pTask
->
execType
==
TASK_EXEC__NONE
)
{
queue
=
pTask
->
inputQueue
;
}
else
{
queue
=
pTask
->
outputQueue
;
}
/*if (streamDequeueBegin(queue) == true) {*/
/*return -1;*/
/*}*/
if
(
pTask
->
sinkType
==
TASK_SINK__TABLE
||
pTask
->
sinkType
==
TASK_SINK__SMA
)
{
ASSERT
(
pTask
->
dispatchType
==
TASK_DISPATCH__NONE
);
while
(
1
)
{
SStreamDataBlock
*
pBlock
=
streamQueueNextItem
(
queue
);
if
(
pBlock
==
NULL
)
break
;
ASSERT
(
pBlock
->
type
==
STREAM_DATA_TYPE_SSDATA_BLOCK
);
// local sink
if
(
pTask
->
sinkType
==
TASK_SINK__TABLE
)
{
pTask
->
tbSink
.
tbSinkFunc
(
pTask
,
pTask
->
tbSink
.
vnode
,
0
,
pBlock
->
blocks
);
}
else
if
(
pTask
->
sinkType
==
TASK_SINK__SMA
)
{
pTask
->
smaSink
.
smaSink
(
pTask
->
ahandle
,
pTask
->
smaSink
.
smaId
,
pBlock
->
blocks
);
}
if
(
pTask
->
dispatchType
==
TASK_DISPATCH__INPLACE
)
{
ASSERT
(
queue
==
pTask
->
outputQueue
);
}
else
if
(
pTask
->
dispatchType
==
TASK_DISPATCH__SHUFFLE
)
{
ASSERT
(
queue
==
pTask
->
outputQueue
);
}
else
if
(
pTask
->
dispatchType
==
TASK_DISPATCH__FIXED
)
{
ASSERT
(
queue
==
pTask
->
outputQueue
);
}
streamQueueProcessSuccess
(
queue
);
}
}
return
0
;
}
#if 0
int32_t streamSink(SStreamTask* pTask, SMsgCb* pMsgCb) {
bool firstRun = 1;
while (1) {
SStreamDataBlock* pBlock = NULL;
if (!firstRun) {
taosReadAllQitems(pTask->outputQ, pTask->outputQAll);
}
taosGetQitem(pTask->outputQAll, (void**)&pBlock);
if (pBlock == NULL) {
if (firstRun) {
firstRun = 0;
continue;
} else {
break;
}
}
SArray* pRes = pBlock->blocks;
// sink
if (pTask->sinkType == TASK_SINK__TABLE) {
// blockDebugShowData(pRes);
pTask->tbSink.tbSinkFunc(pTask, pTask->tbSink.vnode, 0, pRes);
} else if (pTask->sinkType == TASK_SINK__SMA) {
pTask->smaSink.smaSink(pTask->ahandle, pTask->smaSink.smaId, pRes);
//
} else if (pTask->sinkType == TASK_SINK__FETCH) {
//
} else {
ASSERT(pTask->sinkType == TASK_SINK__NONE);
}
// dispatch
// TODO dispatch guard
int8_t outputStatus = atomic_load_8(&pTask->outputStatus);
if (outputStatus == TASK_OUTPUT_STATUS__NORMAL) {
if (pTask->dispatchType == TASK_DISPATCH__INPLACE) {
SRpcMsg dispatchMsg = {0};
if (streamBuildExecMsg(pTask, pRes, &dispatchMsg, NULL) < 0) {
ASSERT(0);
return -1;
}
int32_t qType;
if (pTask->dispatchMsgType == TDMT_VND_TASK_DISPATCH || pTask->dispatchMsgType == TDMT_SND_TASK_DISPATCH) {
qType = FETCH_QUEUE;
/*} else if (pTask->dispatchMsgType == TDMT_VND_TASK_MERGE_EXEC ||*/
/*pTask->dispatchMsgType == TDMT_SND_TASK_MERGE_EXEC) {*/
/*qType = MERGE_QUEUE;*/
/*} else if (pTask->dispatchMsgType == TDMT_VND_TASK_WRITE_EXEC) {*/
/*qType = WRITE_QUEUE;*/
} else {
ASSERT(0);
}
tmsgPutToQueue(pMsgCb, qType, &dispatchMsg);
} else if (pTask->dispatchType == TASK_DISPATCH__FIXED) {
SRpcMsg dispatchMsg = {0};
SEpSet* pEpSet = NULL;
if (streamBuildExecMsg(pTask, pRes, &dispatchMsg, &pEpSet) < 0) {
ASSERT(0);
return -1;
}
tmsgSendReq(pEpSet, &dispatchMsg);
} else if (pTask->dispatchType == TASK_DISPATCH__SHUFFLE) {
SHashObj* pShuffleRes = taosHashInit(64, taosGetDefaultHashFunction(TSDB_DATA_TYPE_INT), false, HASH_NO_LOCK);
if (pShuffleRes == NULL) {
return -1;
}
int32_t sz = taosArrayGetSize(pRes);
for (int32_t i = 0; i < sz; i++) {
SSDataBlock* pDataBlock = taosArrayGet(pRes, i);
SArray* pArray = taosHashGet(pShuffleRes, &pDataBlock->info.groupId, sizeof(int64_t));
if (pArray == NULL) {
pArray = taosArrayInit(0, sizeof(SSDataBlock));
if (pArray == NULL) {
return -1;
}
taosHashPut(pShuffleRes, &pDataBlock->info.groupId, sizeof(int64_t), &pArray, sizeof(void*));
}
taosArrayPush(pArray, pDataBlock);
}
if (streamShuffleDispatch(pTask, pMsgCb, pShuffleRes) < 0) {
return -1;
}
} else {
ASSERT(pTask->dispatchType == TASK_DISPATCH__NONE);
}
}
}
return 0;
}
#endif
source/libs/stream/src/streamTask.c
0 → 100644
浏览文件 @
4560b8f2
/*
* Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
*
* This program is free software: you can use, redistribute, and/or modify
* it under the terms of the GNU Affero General Public License, version 3
* or later ("AGPL"), as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "executor.h"
#include "tstream.h"
SStreamTask
*
tNewSStreamTask
(
int64_t
streamId
,
int32_t
childId
)
{
SStreamTask
*
pTask
=
(
SStreamTask
*
)
taosMemoryCalloc
(
1
,
sizeof
(
SStreamTask
));
if
(
pTask
==
NULL
)
{
return
NULL
;
}
pTask
->
taskId
=
tGenIdPI32
();
pTask
->
streamId
=
streamId
;
pTask
->
childId
=
childId
;
pTask
->
status
=
TASK_STATUS__IDLE
;
pTask
->
inputStatus
=
TASK_INPUT_STATUS__NORMAL
;
pTask
->
outputStatus
=
TASK_OUTPUT_STATUS__NORMAL
;
return
pTask
;
}
int32_t
tEncodeSStreamTask
(
SEncoder
*
pEncoder
,
const
SStreamTask
*
pTask
)
{
/*if (tStartEncode(pEncoder) < 0) return -1;*/
if
(
tEncodeI64
(
pEncoder
,
pTask
->
streamId
)
<
0
)
return
-
1
;
if
(
tEncodeI32
(
pEncoder
,
pTask
->
taskId
)
<
0
)
return
-
1
;
if
(
tEncodeI8
(
pEncoder
,
pTask
->
inputType
)
<
0
)
return
-
1
;
if
(
tEncodeI8
(
pEncoder
,
pTask
->
status
)
<
0
)
return
-
1
;
if
(
tEncodeI8
(
pEncoder
,
pTask
->
sourceType
)
<
0
)
return
-
1
;
if
(
tEncodeI8
(
pEncoder
,
pTask
->
execType
)
<
0
)
return
-
1
;
if
(
tEncodeI8
(
pEncoder
,
pTask
->
sinkType
)
<
0
)
return
-
1
;
if
(
tEncodeI8
(
pEncoder
,
pTask
->
dispatchType
)
<
0
)
return
-
1
;
if
(
tEncodeI16
(
pEncoder
,
pTask
->
dispatchMsgType
)
<
0
)
return
-
1
;
if
(
tEncodeI32
(
pEncoder
,
pTask
->
childId
)
<
0
)
return
-
1
;
if
(
tEncodeI32
(
pEncoder
,
pTask
->
nodeId
)
<
0
)
return
-
1
;
if
(
tEncodeSEpSet
(
pEncoder
,
&
pTask
->
epSet
)
<
0
)
return
-
1
;
if
(
pTask
->
execType
!=
TASK_EXEC__NONE
)
{
if
(
tEncodeI8
(
pEncoder
,
pTask
->
exec
.
parallelizable
)
<
0
)
return
-
1
;
if
(
tEncodeCStr
(
pEncoder
,
pTask
->
exec
.
qmsg
)
<
0
)
return
-
1
;
}
if
(
pTask
->
sinkType
==
TASK_SINK__TABLE
)
{
if
(
tEncodeI64
(
pEncoder
,
pTask
->
tbSink
.
stbUid
)
<
0
)
return
-
1
;
if
(
tEncodeCStr
(
pEncoder
,
pTask
->
tbSink
.
stbFullName
)
<
0
)
return
-
1
;
if
(
tEncodeSSchemaWrapper
(
pEncoder
,
pTask
->
tbSink
.
pSchemaWrapper
)
<
0
)
return
-
1
;
}
else
if
(
pTask
->
sinkType
==
TASK_SINK__SMA
)
{
if
(
tEncodeI64
(
pEncoder
,
pTask
->
smaSink
.
smaId
)
<
0
)
return
-
1
;
}
else
if
(
pTask
->
sinkType
==
TASK_SINK__FETCH
)
{
if
(
tEncodeI8
(
pEncoder
,
pTask
->
fetchSink
.
reserved
)
<
0
)
return
-
1
;
}
else
{
ASSERT
(
pTask
->
sinkType
==
TASK_SINK__NONE
);
}
if
(
pTask
->
dispatchType
==
TASK_DISPATCH__INPLACE
)
{
if
(
tEncodeI32
(
pEncoder
,
pTask
->
inplaceDispatcher
.
taskId
)
<
0
)
return
-
1
;
}
else
if
(
pTask
->
dispatchType
==
TASK_DISPATCH__FIXED
)
{
if
(
tEncodeI32
(
pEncoder
,
pTask
->
fixedEpDispatcher
.
taskId
)
<
0
)
return
-
1
;
if
(
tEncodeI32
(
pEncoder
,
pTask
->
fixedEpDispatcher
.
nodeId
)
<
0
)
return
-
1
;
if
(
tEncodeSEpSet
(
pEncoder
,
&
pTask
->
fixedEpDispatcher
.
epSet
)
<
0
)
return
-
1
;
}
else
if
(
pTask
->
dispatchType
==
TASK_DISPATCH__SHUFFLE
)
{
if
(
tSerializeSUseDbRspImp
(
pEncoder
,
&
pTask
->
shuffleDispatcher
.
dbInfo
)
<
0
)
return
-
1
;
/*if (tEncodeI8(pEncoder, pTask->shuffleDispatcher.hashMethod) < 0) return -1;*/
}
/*tEndEncode(pEncoder);*/
return
pEncoder
->
pos
;
}
int32_t
tDecodeSStreamTask
(
SDecoder
*
pDecoder
,
SStreamTask
*
pTask
)
{
/*if (tStartDecode(pDecoder) < 0) return -1;*/
if
(
tDecodeI64
(
pDecoder
,
&
pTask
->
streamId
)
<
0
)
return
-
1
;
if
(
tDecodeI32
(
pDecoder
,
&
pTask
->
taskId
)
<
0
)
return
-
1
;
if
(
tDecodeI8
(
pDecoder
,
&
pTask
->
inputType
)
<
0
)
return
-
1
;
if
(
tDecodeI8
(
pDecoder
,
&
pTask
->
status
)
<
0
)
return
-
1
;
if
(
tDecodeI8
(
pDecoder
,
&
pTask
->
sourceType
)
<
0
)
return
-
1
;
if
(
tDecodeI8
(
pDecoder
,
&
pTask
->
execType
)
<
0
)
return
-
1
;
if
(
tDecodeI8
(
pDecoder
,
&
pTask
->
sinkType
)
<
0
)
return
-
1
;
if
(
tDecodeI8
(
pDecoder
,
&
pTask
->
dispatchType
)
<
0
)
return
-
1
;
if
(
tDecodeI16
(
pDecoder
,
&
pTask
->
dispatchMsgType
)
<
0
)
return
-
1
;
if
(
tDecodeI32
(
pDecoder
,
&
pTask
->
childId
)
<
0
)
return
-
1
;
if
(
tDecodeI32
(
pDecoder
,
&
pTask
->
nodeId
)
<
0
)
return
-
1
;
if
(
tDecodeSEpSet
(
pDecoder
,
&
pTask
->
epSet
)
<
0
)
return
-
1
;
if
(
pTask
->
execType
!=
TASK_EXEC__NONE
)
{
if
(
tDecodeI8
(
pDecoder
,
&
pTask
->
exec
.
parallelizable
)
<
0
)
return
-
1
;
if
(
tDecodeCStrAlloc
(
pDecoder
,
&
pTask
->
exec
.
qmsg
)
<
0
)
return
-
1
;
}
if
(
pTask
->
sinkType
==
TASK_SINK__TABLE
)
{
if
(
tDecodeI64
(
pDecoder
,
&
pTask
->
tbSink
.
stbUid
)
<
0
)
return
-
1
;
if
(
tDecodeCStrTo
(
pDecoder
,
pTask
->
tbSink
.
stbFullName
)
<
0
)
return
-
1
;
pTask
->
tbSink
.
pSchemaWrapper
=
taosMemoryCalloc
(
1
,
sizeof
(
SSchemaWrapper
));
if
(
pTask
->
tbSink
.
pSchemaWrapper
==
NULL
)
return
-
1
;
if
(
tDecodeSSchemaWrapper
(
pDecoder
,
pTask
->
tbSink
.
pSchemaWrapper
)
<
0
)
return
-
1
;
}
else
if
(
pTask
->
sinkType
==
TASK_SINK__SMA
)
{
if
(
tDecodeI64
(
pDecoder
,
&
pTask
->
smaSink
.
smaId
)
<
0
)
return
-
1
;
}
else
if
(
pTask
->
sinkType
==
TASK_SINK__FETCH
)
{
if
(
tDecodeI8
(
pDecoder
,
&
pTask
->
fetchSink
.
reserved
)
<
0
)
return
-
1
;
}
else
{
ASSERT
(
pTask
->
sinkType
==
TASK_SINK__NONE
);
}
if
(
pTask
->
dispatchType
==
TASK_DISPATCH__INPLACE
)
{
if
(
tDecodeI32
(
pDecoder
,
&
pTask
->
inplaceDispatcher
.
taskId
)
<
0
)
return
-
1
;
}
else
if
(
pTask
->
dispatchType
==
TASK_DISPATCH__FIXED
)
{
if
(
tDecodeI32
(
pDecoder
,
&
pTask
->
fixedEpDispatcher
.
taskId
)
<
0
)
return
-
1
;
if
(
tDecodeI32
(
pDecoder
,
&
pTask
->
fixedEpDispatcher
.
nodeId
)
<
0
)
return
-
1
;
if
(
tDecodeSEpSet
(
pDecoder
,
&
pTask
->
fixedEpDispatcher
.
epSet
)
<
0
)
return
-
1
;
}
else
if
(
pTask
->
dispatchType
==
TASK_DISPATCH__SHUFFLE
)
{
/*if (tDecodeI8(pDecoder, &pTask->shuffleDispatcher.hashMethod) < 0) return -1;*/
if
(
tDeserializeSUseDbRspImp
(
pDecoder
,
&
pTask
->
shuffleDispatcher
.
dbInfo
)
<
0
)
return
-
1
;
}
/*tEndDecode(pDecoder);*/
return
0
;
}
void
tFreeSStreamTask
(
SStreamTask
*
pTask
)
{
streamQueueClose
(
pTask
->
inputQueue
);
streamQueueClose
(
pTask
->
outputQueue
);
if
(
pTask
->
exec
.
qmsg
)
taosMemoryFree
(
pTask
->
exec
.
qmsg
);
qDestroyTask
(
pTask
->
exec
.
executor
);
taosMemoryFree
(
pTask
);
}
source/libs/stream/src/
t
streamUpdate.c
→
source/libs/stream/src/streamUpdate.c
浏览文件 @
4560b8f2
文件已移动
source/libs/stream/src/tstream.c
已删除
100644 → 0
浏览文件 @
ca187f2e
此差异已折叠。
点击以展开。
source/util/src/terror.c
浏览文件 @
4560b8f2
...
@@ -222,7 +222,9 @@ TAOS_DEFINE_ERROR(TSDB_CODE_MND_DB_INDEX_NOT_EXIST, "Index not exist")
...
@@ -222,7 +222,9 @@ TAOS_DEFINE_ERROR(TSDB_CODE_MND_DB_INDEX_NOT_EXIST, "Index not exist")
// mnode-vgroup
// mnode-vgroup
TAOS_DEFINE_ERROR
(
TSDB_CODE_MND_VGROUP_ALREADY_IN_DNODE
,
"Vgroup already in dnode"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_MND_VGROUP_ALREADY_IN_DNODE
,
"Vgroup already in dnode"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_MND_VGROUP_NOT_IN_DNODE
,
"Vgroup not in dnode"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_MND_VGROUP_NOT_IN_DNODE
,
"Vgroup not in dnode"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_MND_VGROUP_NOT_EXIST
,
"VGroup does not exist"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_MND_VGROUP_NOT_EXIST
,
"Vgroup does not exist"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_MND_VGROUP_UN_CHANGED
,
"Vgroup distribution has not changed"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_MND_HAS_OFFLINE_DNODE
,
"Offline dnode exists"
)
// mnode-stable
// mnode-stable
TAOS_DEFINE_ERROR
(
TSDB_CODE_MND_STB_ALREADY_EXIST
,
"STable already exists"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_MND_STB_ALREADY_EXIST
,
"STable already exists"
)
...
...
source/util/src/tqueue.c
浏览文件 @
4560b8f2
...
@@ -34,11 +34,11 @@ typedef struct STaosQnode {
...
@@ -34,11 +34,11 @@ typedef struct STaosQnode {
}
STaosQnode
;
}
STaosQnode
;
typedef
struct
STaosQueue
{
typedef
struct
STaosQueue
{
STaosQnode
*
head
;
STaosQnode
*
head
;
STaosQnode
*
tail
;
STaosQnode
*
tail
;
STaosQueue
*
next
;
// for queue set
STaosQueue
*
next
;
// for queue set
STaosQset
*
qset
;
// for queue set
STaosQset
*
qset
;
// for queue set
void
*
ahandle
;
// for queue set
void
*
ahandle
;
// for queue set
FItem
itemFp
;
FItem
itemFp
;
FItems
itemsFp
;
FItems
itemsFp
;
TdThreadMutex
mutex
;
TdThreadMutex
mutex
;
...
@@ -47,8 +47,8 @@ typedef struct STaosQueue {
...
@@ -47,8 +47,8 @@ typedef struct STaosQueue {
}
STaosQueue
;
}
STaosQueue
;
typedef
struct
STaosQset
{
typedef
struct
STaosQset
{
STaosQueue
*
head
;
STaosQueue
*
head
;
STaosQueue
*
current
;
STaosQueue
*
current
;
TdThreadMutex
mutex
;
TdThreadMutex
mutex
;
tsem_t
sem
;
tsem_t
sem
;
int32_t
numOfQueues
;
int32_t
numOfQueues
;
...
@@ -86,7 +86,7 @@ void taosSetQueueFp(STaosQueue *queue, FItem itemFp, FItems itemsFp) {
...
@@ -86,7 +86,7 @@ void taosSetQueueFp(STaosQueue *queue, FItem itemFp, FItems itemsFp) {
void
taosCloseQueue
(
STaosQueue
*
queue
)
{
void
taosCloseQueue
(
STaosQueue
*
queue
)
{
if
(
queue
==
NULL
)
return
;
if
(
queue
==
NULL
)
return
;
STaosQnode
*
pTemp
;
STaosQnode
*
pTemp
;
STaosQset
*
qset
;
STaosQset
*
qset
;
taosThreadMutexLock
(
&
queue
->
mutex
);
taosThreadMutexLock
(
&
queue
->
mutex
);
STaosQnode
*
pNode
=
queue
->
head
;
STaosQnode
*
pNode
=
queue
->
head
;
...
@@ -282,6 +282,8 @@ int32_t taosGetQitem(STaosQall *qall, void **ppItem) {
...
@@ -282,6 +282,8 @@ int32_t taosGetQitem(STaosQall *qall, void **ppItem) {
*
ppItem
=
pNode
->
item
;
*
ppItem
=
pNode
->
item
;
num
=
1
;
num
=
1
;
uTrace
(
"item:%p is fetched"
,
*
ppItem
);
uTrace
(
"item:%p is fetched"
,
*
ppItem
);
}
else
{
*
ppItem
=
NULL
;
}
}
return
num
;
return
num
;
...
...
tests/script/tsim/stable/column_drop.sim
浏览文件 @
4560b8f2
...
@@ -118,6 +118,7 @@ if $data[0][5] != 5 then
...
@@ -118,6 +118,7 @@ if $data[0][5] != 5 then
return -1
return -1
endi
endi
if $data[0][6] != 101 then
if $data[0][6] != 101 then
print expect 101, actual: $data06
return -1
return -1
endi
endi
...
...
tests/script/tsim/testsuit.sim
浏览文件 @
4560b8f2
...
@@ -7,57 +7,57 @@
...
@@ -7,57 +7,57 @@
#run tsim/table/basic1.sim
#run tsim/table/basic1.sim
#run tsim/trans/lossdata1.sim
#run tsim/trans/lossdata1.sim
#run tsim/trans/create_db.sim
#run tsim/trans/create_db.sim
#
#
run tsim/stable/alter_metrics.sim
#run tsim/stable/alter_metrics.sim
#
#
run tsim/stable/tag_modify.sim
#run tsim/stable/tag_modify.sim
#
#
run tsim/stable/alter_comment.sim
#run tsim/stable/alter_comment.sim
#
#
run tsim/stable/column_drop.sim
#run tsim/stable/column_drop.sim
#
#
run tsim/stable/column_modify.sim
#run tsim/stable/column_modify.sim
#
#
run tsim/stable/tag_rename.sim
#run tsim/stable/tag_rename.sim
#run tsim/stable/vnode3.sim
#run tsim/stable/vnode3.sim
#run tsim/stable/metrics.sim
#run tsim/stable/metrics.sim
#
#
run tsim/stable/alter_insert2.sim
#run tsim/stable/alter_insert2.sim
#run tsim/stable/show.sim
#run tsim/stable/show.sim
#run tsim/stable/alter_import.sim
#run tsim/stable/alter_import.sim
#
#
run tsim/stable/tag_add.sim
#run tsim/stable/tag_add.sim
#run tsim/stable/tag_drop.sim
#run tsim/stable/tag_drop.sim
#run tsim/stable/column_add.sim
#run tsim/stable/column_add.sim
#run tsim/stable/alter_count.sim
#run tsim/stable/alter_count.sim
#run tsim/stable/values.sim
#run tsim/stable/values.sim
#
run tsim/stable/dnode3.sim
run tsim/stable/dnode3.sim
#run tsim/stable/alter_insert1.sim
#run tsim/stable/alter_insert1.sim
#run tsim/stable/refcount.sim
#run tsim/stable/refcount.sim
#run tsim/stable/disk.sim
#run tsim/stable/disk.sim
#
run tsim/db/basic1.sim
run tsim/db/basic1.sim
#
run tsim/db/basic3.sim
run tsim/db/basic3.sim
#
#
run tsim/db/basic7.sim
#run tsim/db/basic7.sim
#
run tsim/db/basic6.sim
run tsim/db/basic6.sim
#
run tsim/db/create_all_options.sim
run tsim/db/create_all_options.sim
#
run tsim/db/basic2.sim
run tsim/db/basic2.sim
#
run tsim/db/error1.sim
run tsim/db/error1.sim
#
run tsim/db/taosdlog.sim
run tsim/db/taosdlog.sim
#
run tsim/db/alter_option.sim
run tsim/db/alter_option.sim
#
run tsim/mnode/basic1.sim
run tsim/mnode/basic1.sim
#
run tsim/mnode/basic3.sim
run tsim/mnode/basic3.sim
#
run tsim/mnode/basic2.sim
run tsim/mnode/basic2.sim
#
run tsim/parser/fourArithmetic-basic.sim
run tsim/parser/fourArithmetic-basic.sim
#
run tsim/parser/groupby-basic.sim
run tsim/parser/groupby-basic.sim
#
run tsim/snode/basic1.sim
run tsim/snode/basic1.sim
#
run tsim/query/time_process.sim
run tsim/query/time_process.sim
#
run tsim/query/stddev.sim
run tsim/query/stddev.sim
#
run tsim/query/interval-offset.sim
run tsim/query/interval-offset.sim
#
run tsim/query/charScalarFunction.sim
run tsim/query/charScalarFunction.sim
#
run tsim/query/complex_select.sim
run tsim/query/complex_select.sim
#
run tsim/query/explain.sim
run tsim/query/explain.sim
#
run tsim/query/crash_sql.sim
run tsim/query/crash_sql.sim
#
run tsim/query/diff.sim
run tsim/query/diff.sim
#
run tsim/query/complex_limit.sim
run tsim/query/complex_limit.sim
#
run tsim/query/complex_having.sim
run tsim/query/complex_having.sim
#
run tsim/query/udf.sim
run tsim/query/udf.sim
#
run tsim/query/complex_group.sim
run tsim/query/complex_group.sim
#
run tsim/query/interval.sim
run tsim/query/interval.sim
#
run tsim/query/session.sim
run tsim/query/session.sim
#
run tsim/query/scalarFunction.sim
run tsim/query/scalarFunction.sim
#
#
run tsim/query/scalarNull.sim
#run tsim/query/scalarNull.sim
run tsim/query/complex_where.sim
run tsim/query/complex_where.sim
run tsim/tmq/basic1.sim
run tsim/tmq/basic1.sim
run tsim/tmq/basic4.sim
run tsim/tmq/basic4.sim
...
...
tests/system-test/0-others/taosdMonitor.py
浏览文件 @
4560b8f2
此差异已折叠。
点击以展开。
tests/system-test/2-query/csum.py
浏览文件 @
4560b8f2
...
@@ -240,7 +240,7 @@ class TDTestCase:
...
@@ -240,7 +240,7 @@ class TDTestCase:
tdSql
.
error
(
"select csum(c1) t1"
)
# no from
tdSql
.
error
(
"select csum(c1) t1"
)
# no from
tdSql
.
error
(
"select csum( c1 ) from "
)
# no table_expr
tdSql
.
error
(
"select csum( c1 ) from "
)
# no table_expr
# tdSql.error(self.csum_query_form(col="st1")) # tag col
# tdSql.error(self.csum_query_form(col="st1")) # tag col
tdSql
.
error
(
self
.
csum_query_form
(
col
=
1
))
# col is a value
#
tdSql.error(self.csum_query_form(col=1)) # col is a value
tdSql
.
error
(
self
.
csum_query_form
(
col
=
"'c1'"
))
# col is a string
tdSql
.
error
(
self
.
csum_query_form
(
col
=
"'c1'"
))
# col is a string
tdSql
.
error
(
self
.
csum_query_form
(
col
=
None
))
# col is NULL 1
tdSql
.
error
(
self
.
csum_query_form
(
col
=
None
))
# col is NULL 1
tdSql
.
error
(
self
.
csum_query_form
(
col
=
"NULL"
))
# col is NULL 2
tdSql
.
error
(
self
.
csum_query_form
(
col
=
"NULL"
))
# col is NULL 2
...
@@ -407,6 +407,14 @@ class TDTestCase:
...
@@ -407,6 +407,14 @@ class TDTestCase:
tdDnodes
.
start
(
index
)
tdDnodes
.
start
(
index
)
self
.
csum_current_query
()
self
.
csum_current_query
()
self
.
csum_error_query
()
self
.
csum_error_query
()
tdSql
.
query
(
"select csum(1) from t1 "
)
tdSql
.
checkRows
(
7
)
tdSql
.
checkData
(
0
,
0
,
1
)
tdSql
.
checkData
(
1
,
0
,
2
)
tdSql
.
checkData
(
2
,
0
,
3
)
tdSql
.
checkData
(
3
,
0
,
4
)
tdSql
.
query
(
"select csum(abs(c1))+2 from t1 "
)
tdSql
.
checkRows
(
4
)
def
run
(
self
):
def
run
(
self
):
import
traceback
import
traceback
...
...
tests/system-test/2-query/elapsed.py
浏览文件 @
4560b8f2
...
@@ -141,7 +141,7 @@ class TDTestCase:
...
@@ -141,7 +141,7 @@ class TDTestCase:
tablenames
=
[
"sub_table1_1"
,
"sub_table1_2"
,
"sub_table1_3"
,
"sub_table2_1"
,
"sub_table2_2"
,
"sub_table2_3"
,
"regular_table_1"
,
"regular_table_2"
,
"regular_table_3"
]
tablenames
=
[
"sub_table1_1"
,
"sub_table1_2"
,
"sub_table1_3"
,
"sub_table2_1"
,
"sub_table2_2"
,
"sub_table2_3"
,
"regular_table_1"
,
"regular_table_2"
,
"regular_table_3"
]
abnormal_list
=
[
"()"
,
"(NULL)"
,
"(*)"
,
"(abc)"
,
"( , )"
,
"(NULL,*)"
,
"( ,NULL)"
,
"(%)"
,
"(+)"
,
"(*,)"
,
"(*, /)"
,
"(ts,*)"
"(ts,tbname*10)"
,
"(ts,tagname)"
,
abnormal_list
=
[
"()"
,
"(NULL)"
,
"(*)"
,
"(abc)"
,
"( , )"
,
"(NULL,*)"
,
"( ,NULL)"
,
"(%)"
,
"(+)"
,
"(*,)"
,
"(*, /)"
,
"(ts,*)"
"(ts,tbname*10)"
,
"(ts,tagname)"
,
"(ts,2d+3m-2s,NULL)"
,
"(ts+1
d,10s)"
,
"(ts+10d,NULL)"
,
"(ts,now -1m%1d)"
,
"(ts+10
d)"
,
"(ts+10d,_c0)"
,
"(ts+10d,)"
,
"(ts,%)"
,
"(ts, , m)"
,
"(ts,abc)"
,
"(ts,/)"
,
"(ts,*)"
,
"(ts,1s,100)"
,
"(ts,2d+3m-2s,NULL)"
,
"(ts+1
0d,NULL)"
,
"(ts,now -1m%1
d)"
,
"(ts+10d,_c0)"
,
"(ts+10d,)"
,
"(ts,%)"
,
"(ts, , m)"
,
"(ts,abc)"
,
"(ts,/)"
,
"(ts,*)"
,
"(ts,1s,100)"
,
"(ts,1s,abc)"
,
"(ts,1s,_c0)"
,
"(ts,1s,*)"
,
"(ts,1s,NULL)"
,
"(ts,,_c0)"
,
"(ts,tbname,ts)"
,
"(ts,0,tbname)"
,
"('2021-11-18 00:00:10')"
,
"('2021-11-18 00:00:10', 1s)"
,
"(ts,1s,abc)"
,
"(ts,1s,_c0)"
,
"(ts,1s,*)"
,
"(ts,1s,NULL)"
,
"(ts,,_c0)"
,
"(ts,tbname,ts)"
,
"(ts,0,tbname)"
,
"('2021-11-18 00:00:10')"
,
"('2021-11-18 00:00:10', 1s)"
,
"('2021-11-18T00:00:10+0800', '1s')"
,
"('2021-11-18T00:00:10Z', '1s')"
,
"('2021-11-18T00:00:10+0800', 10000000d,)"
,
"('ts', ,2021-11-18T00:00:10+0800, )"
]
"('2021-11-18T00:00:10+0800', '1s')"
,
"('2021-11-18T00:00:10Z', '1s')"
,
"('2021-11-18T00:00:10+0800', 10000000d,)"
,
"('ts', ,2021-11-18T00:00:10+0800, )"
]
...
...
tests/system-test/2-query/function_stateduration.py
浏览文件 @
4560b8f2
...
@@ -85,8 +85,8 @@ class TDTestCase:
...
@@ -85,8 +85,8 @@ class TDTestCase:
"select stateduration(c1 ,'GT','*',1s) from t1"
,
"select stateduration(c1 ,'GT','*',1s) from t1"
,
"select stateduration(c1 ,'GT',ts,1s) from t1"
,
"select stateduration(c1 ,'GT',ts,1s) from t1"
,
"select stateduration(c1 ,'GT',max(c1),1s) from t1"
,
"select stateduration(c1 ,'GT',max(c1),1s) from t1"
,
"select stateduration(abs(c1) ,'GT',1,1s) from t1"
,
#
"select stateduration(abs(c1) ,'GT',1,1s) from t1",
"select stateduration(c1+2 ,'GT',1,1s) from t1"
,
#
"select stateduration(c1+2 ,'GT',1,1s) from t1",
"select stateduration(c1 ,'GT',1,1u) from t1"
,
"select stateduration(c1 ,'GT',1,1u) from t1"
,
"select stateduration(c1 ,'GT',1,now) from t1"
,
"select stateduration(c1 ,'GT',1,now) from t1"
,
"select stateduration(c1 ,'GT','1',1s) from t1"
,
"select stateduration(c1 ,'GT','1',1s) from t1"
,
...
@@ -323,6 +323,11 @@ class TDTestCase:
...
@@ -323,6 +323,11 @@ class TDTestCase:
tdSql
.
checkData
(
0
,
0
,
None
)
tdSql
.
checkData
(
0
,
0
,
None
)
tdSql
.
checkData
(
1
,
0
,
0.000000000
)
tdSql
.
checkData
(
1
,
0
,
0.000000000
)
tdSql
.
checkData
(
3
,
0
,
-
86404.000000000
)
tdSql
.
checkData
(
3
,
0
,
-
86404.000000000
)
tdSql
.
query
(
"select stateduration(abs(c1) ,'GT',1,1s) from t1"
)
tdSql
.
checkRows
(
12
)
tdSql
.
query
(
"select stateduration(c1+2 ,'GT',1,1s) from t1"
)
tdSql
.
checkRows
(
12
)
# bug for stable
# bug for stable
...
...
tests/system-test/2-query/hyperloglog.py
浏览文件 @
4560b8f2
...
@@ -223,7 +223,7 @@ class TDTestCase:
...
@@ -223,7 +223,7 @@ class TDTestCase:
tdLog
.
printNoPrefix
(
"===step 0: err case, must return err"
)
tdLog
.
printNoPrefix
(
"===step 0: err case, must return err"
)
tdSql
.
error
(
"select hyperloglog() from ct1"
)
tdSql
.
error
(
"select hyperloglog() from ct1"
)
tdSql
.
error
(
"select hyperloglog(c1, c2) from ct2"
)
tdSql
.
error
(
"select hyperloglog(c1, c2) from ct2"
)
tdSql
.
error
(
"select hyperloglog(1) from ct2"
)
#
tdSql.error( "select hyperloglog(1) from ct2" )
tdSql
.
error
(
f
"select hyperloglog(
{
NUM_COL
[
0
]
}
,
{
NUM_COL
[
1
]
}
) from ct4"
)
tdSql
.
error
(
f
"select hyperloglog(
{
NUM_COL
[
0
]
}
,
{
NUM_COL
[
1
]
}
) from ct4"
)
tdSql
.
error
(
''' select hyperloglog(['c1 + c1', 'c1 + c2', 'c1 + c3', 'c1 + c4', 'c1 + c5', 'c1 + c6', 'c1 + c7', 'c1 + c8', 'c1 + c9', 'c1 + c10'])
tdSql
.
error
(
''' select hyperloglog(['c1 + c1', 'c1 + c2', 'c1 + c3', 'c1 + c4', 'c1 + c5', 'c1 + c6', 'c1 + c7', 'c1 + c8', 'c1 + c9', 'c1 + c10'])
from ct1
from ct1
...
...
tests/system-test/2-query/mavg.py
浏览文件 @
4560b8f2
此差异已折叠。
点击以展开。
tests/system-test/2-query/sample.py
浏览文件 @
4560b8f2
此差异已折叠。
点击以展开。
tests/system-test/2-query/statecount.py
浏览文件 @
4560b8f2
...
@@ -85,8 +85,8 @@ class TDTestCase:
...
@@ -85,8 +85,8 @@ class TDTestCase:
"select statecount(c1 ,'GT','*') from t1"
,
"select statecount(c1 ,'GT','*') from t1"
,
"select statecount(c1 ,'GT',ts) from t1"
,
"select statecount(c1 ,'GT',ts) from t1"
,
"select statecount(c1 ,'GT',max(c1)) from t1"
,
"select statecount(c1 ,'GT',max(c1)) from t1"
,
"select statecount(abs(c1) ,'GT',1) from t1"
,
#
"select statecount(abs(c1) ,'GT',1) from t1",
"select statecount(c1+2 ,'GT',1) from t1"
,
#
"select statecount(c1+2 ,'GT',1) from t1",
"select statecount(c1 ,'GT',1,1u) from t1"
,
"select statecount(c1 ,'GT',1,1u) from t1"
,
"select statecount(c1 ,'GT',1,now) from t1"
,
"select statecount(c1 ,'GT',1,now) from t1"
,
"select statecount(c1 ,'GT','1') from t1"
,
"select statecount(c1 ,'GT','1') from t1"
,
...
...
tests/system-test/fulltest.bat
浏览文件 @
4560b8f2
@REM
python3 .\test.py -f 0-others\taosShell.py
python3
.\test.py
-f
0
-others
\taosShell.py
python3
.\test.py
-f
0
-others
\taosShellError.py
python3
.\test.py
-f
0
-others
\taosShellError.py
python3
.\test.py
-f
0
-others
\taosShellNetChk.py
python3
.\test.py
-f
0
-others
\taosShellNetChk.py
python3
.\test.py
-f
0
-others
\telemetry.py
python3
.\test.py
-f
0
-others
\telemetry.py
@REM
python3 .\test.py -f 0-others\taosdMonitor.py
python3
.\test.py
-f
0
-others
\taosdMonitor.py
python3
.\test.py
-f
0
-others
\udfTest.py
python3
.\test.py
-f
0
-others
\udfTest.py
python3
.\test.py
-f
0
-others
\udf_create.py
python3
.\test.py
-f
0
-others
\udf_create.py
python3
.\test.py
-f
0
-others
\udf_restart_taosd.py
python3
.\test.py
-f
0
-others
\udf_restart_taosd.py
...
...
tests/system-test/test.py
浏览文件 @
4560b8f2
此差异已折叠。
点击以展开。
tools/shell/src/shellEngine.c
浏览文件 @
4560b8f2
此差异已折叠。
点击以展开。
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录