Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
2e590c30
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看板
提交
2e590c30
编写于
6月 18, 2022
作者:
H
Hongze Cheng
浏览文件
操作
浏览文件
下载
差异文件
Merge branch '3.0' of
https://github.com/taosdata/TDengine
into feat/tsdb_refact
上级
a200ea85
ffd69aa3
变更
75
展开全部
隐藏空白更改
内联
并排
Showing
75 changed file
with
5277 addition
and
2459 deletion
+5277
-2459
examples/c/stream_demo.c
examples/c/stream_demo.c
+10
-3
include/client/taos.h
include/client/taos.h
+5
-16
include/libs/executor/executor.h
include/libs/executor/executor.h
+4
-1
include/libs/sync/sync.h
include/libs/sync/sync.h
+2
-0
include/os/osTime.h
include/os/osTime.h
+14
-14
include/util/taoserror.h
include/util/taoserror.h
+0
-102
source/common/src/systable.c
source/common/src/systable.c
+2
-1
source/common/src/tdatablock.c
source/common/src/tdatablock.c
+1
-0
source/dnode/mnode/impl/inc/mndDef.h
source/dnode/mnode/impl/inc/mndDef.h
+2
-1
source/dnode/mnode/impl/inc/mndTrans.h
source/dnode/mnode/impl/inc/mndTrans.h
+1
-1
source/dnode/mnode/impl/src/mndDb.c
source/dnode/mnode/impl/src/mndDb.c
+3
-3
source/dnode/mnode/impl/src/mndScheduler.c
source/dnode/mnode/impl/src/mndScheduler.c
+3
-1
source/dnode/mnode/impl/src/mndSma.c
source/dnode/mnode/impl/src/mndSma.c
+2
-2
source/dnode/mnode/impl/src/mndStb.c
source/dnode/mnode/impl/src/mndStb.c
+3
-3
source/dnode/mnode/impl/src/mndStream.c
source/dnode/mnode/impl/src/mndStream.c
+2
-2
source/dnode/mnode/impl/src/mndSubscribe.c
source/dnode/mnode/impl/src/mndSubscribe.c
+1
-1
source/dnode/mnode/impl/src/mndSync.c
source/dnode/mnode/impl/src/mndSync.c
+7
-23
source/dnode/mnode/impl/src/mndTopic.c
source/dnode/mnode/impl/src/mndTopic.c
+1
-1
source/dnode/mnode/impl/src/mndTrans.c
source/dnode/mnode/impl/src/mndTrans.c
+63
-49
source/dnode/mnode/impl/test/sdb/sdbTest.cpp
source/dnode/mnode/impl/test/sdb/sdbTest.cpp
+16
-8
source/dnode/mnode/impl/test/trans/trans2.cpp
source/dnode/mnode/impl/test/trans/trans2.cpp
+2
-2
source/dnode/mnode/sdb/inc/sdb.h
source/dnode/mnode/sdb/inc/sdb.h
+11
-14
source/dnode/mnode/sdb/src/sdb.c
source/dnode/mnode/sdb/src/sdb.c
+22
-24
source/dnode/mnode/sdb/src/sdbFile.c
source/dnode/mnode/sdb/src/sdbFile.c
+39
-30
source/dnode/vnode/src/vnd/vnodeSync.c
source/dnode/vnode/src/vnd/vnodeSync.c
+4
-4
source/libs/executor/inc/executil.h
source/libs/executor/inc/executil.h
+25
-5
source/libs/executor/inc/executorimpl.h
source/libs/executor/inc/executorimpl.h
+13
-31
source/libs/executor/inc/tsort.h
source/libs/executor/inc/tsort.h
+1
-1
source/libs/executor/src/executil.c
source/libs/executor/src/executil.c
+514
-72
source/libs/executor/src/executorMain.c
source/libs/executor/src/executorMain.c
+19
-0
source/libs/executor/src/executorimpl.c
source/libs/executor/src/executorimpl.c
+99
-693
source/libs/executor/src/groupoperator.c
source/libs/executor/src/groupoperator.c
+20
-4
source/libs/executor/src/joinoperator.c
source/libs/executor/src/joinoperator.c
+17
-12
source/libs/executor/src/scanoperator.c
source/libs/executor/src/scanoperator.c
+25
-40
source/libs/executor/src/sortoperator.c
source/libs/executor/src/sortoperator.c
+25
-14
source/libs/executor/src/timewindowoperator.c
source/libs/executor/src/timewindowoperator.c
+24
-22
source/libs/executor/src/tsort.c
source/libs/executor/src/tsort.c
+1
-1
source/libs/executor/test/sortTests.cpp
source/libs/executor/test/sortTests.cpp
+3
-3
source/libs/stream/src/streamDispatch.c
source/libs/stream/src/streamDispatch.c
+1
-0
source/libs/stream/src/streamTask.c
source/libs/stream/src/streamTask.c
+2
-2
source/libs/sync/inc/syncInt.h
source/libs/sync/inc/syncInt.h
+2
-1
source/libs/sync/inc/syncRaftCfg.h
source/libs/sync/inc/syncRaftCfg.h
+5
-4
source/libs/sync/src/syncAppendEntries.c
source/libs/sync/src/syncAppendEntries.c
+10
-5
source/libs/sync/src/syncMain.c
source/libs/sync/src/syncMain.c
+26
-4
source/libs/sync/src/syncRaftCfg.c
source/libs/sync/src/syncRaftCfg.c
+7
-0
source/libs/sync/src/syncSnapshot.c
source/libs/sync/src/syncSnapshot.c
+8
-3
source/libs/transport/src/transComm.c
source/libs/transport/src/transComm.c
+4
-2
tests/system-test/1-insert/alter_stable.py
tests/system-test/1-insert/alter_stable.py
+6
-0
tests/system-test/1-insert/alter_table.py
tests/system-test/1-insert/alter_table.py
+23
-8
tests/system-test/1-insert/insertWithMoreVgroup.py
tests/system-test/1-insert/insertWithMoreVgroup.py
+78
-17
tests/system-test/1-insert/manyVgroups.json
tests/system-test/1-insert/manyVgroups.json
+9
-9
tests/system-test/2-query/bottom.py
tests/system-test/2-query/bottom.py
+79
-66
tests/system-test/2-query/distribute_agg_apercentile.py
tests/system-test/2-query/distribute_agg_apercentile.py
+198
-0
tests/system-test/2-query/distribute_agg_count.py
tests/system-test/2-query/distribute_agg_count.py
+296
-0
tests/system-test/2-query/distribute_agg_max.py
tests/system-test/2-query/distribute_agg_max.py
+293
-0
tests/system-test/2-query/distribute_agg_min.py
tests/system-test/2-query/distribute_agg_min.py
+294
-0
tests/system-test/2-query/distribute_agg_spread.py
tests/system-test/2-query/distribute_agg_spread.py
+281
-0
tests/system-test/2-query/distribute_agg_sum.py
tests/system-test/2-query/distribute_agg_sum.py
+278
-0
tests/system-test/2-query/first.py
tests/system-test/2-query/first.py
+151
-113
tests/system-test/2-query/histogram.py
tests/system-test/2-query/histogram.py
+67
-2
tests/system-test/2-query/hyperloglog.py
tests/system-test/2-query/hyperloglog.py
+77
-0
tests/system-test/2-query/last.py
tests/system-test/2-query/last.py
+235
-390
tests/system-test/2-query/max.py
tests/system-test/2-query/max.py
+185
-170
tests/system-test/2-query/top.py
tests/system-test/2-query/top.py
+80
-70
tests/system-test/6-cluster/5dnode3mnodeDrop.py
tests/system-test/6-cluster/5dnode3mnodeDrop.py
+2
-1
tests/system-test/6-cluster/5dnode3mnodeDropInsert.py
tests/system-test/6-cluster/5dnode3mnodeDropInsert.py
+428
-0
tests/system-test/6-cluster/5dnode3mnodeSeperate1VnodeStopInsert.py
...em-test/6-cluster/5dnode3mnodeSeperate1VnodeStopInsert.py
+377
-0
tests/system-test/7-tmq/basic5.py
tests/system-test/7-tmq/basic5.py
+2
-2
tests/system-test/7-tmq/subscribeDb0.py
tests/system-test/7-tmq/subscribeDb0.py
+0
-172
tests/system-test/7-tmq/subscribeDb1.py
tests/system-test/7-tmq/subscribeDb1.py
+68
-210
tests/system-test/7-tmq/subscribeDb2.py
tests/system-test/7-tmq/subscribeDb2.py
+347
-0
tests/system-test/7-tmq/subscribeDb3.py
tests/system-test/7-tmq/subscribeDb3.py
+337
-0
tests/system-test/fulltest.sh
tests/system-test/fulltest.sh
+9
-1
tests/test/c/sdbDump.c
tests/test/c/sdbDump.c
+5
-3
tools/taosadapter
tools/taosadapter
+1
-0
未找到文件。
examples/c/stream_demo.c
浏览文件 @
2e590c30
...
@@ -32,6 +32,13 @@ int32_t init_env() {
...
@@ -32,6 +32,13 @@ int32_t init_env() {
}
}
taos_free_result
(
pRes
);
taos_free_result
(
pRes
);
pRes
=
taos_query
(
pConn
,
"create database if not exists abc2 vgroups 20"
);
if
(
taos_errno
(
pRes
)
!=
0
)
{
printf
(
"error in create db, reason:%s
\n
"
,
taos_errstr
(
pRes
));
return
-
1
;
}
taos_free_result
(
pRes
);
pRes
=
taos_query
(
pConn
,
"use abc1"
);
pRes
=
taos_query
(
pConn
,
"use abc1"
);
if
(
taos_errno
(
pRes
)
!=
0
)
{
if
(
taos_errno
(
pRes
)
!=
0
)
{
printf
(
"error in use db, reason:%s
\n
"
,
taos_errstr
(
pRes
));
printf
(
"error in use db, reason:%s
\n
"
,
taos_errstr
(
pRes
));
...
@@ -81,9 +88,9 @@ int32_t create_stream() {
...
@@ -81,9 +88,9 @@ int32_t create_stream() {
/*const char* sql = "select min(k), max(k), sum(k) as sum_of_k from st1";*/
/*const char* sql = "select min(k), max(k), sum(k) as sum_of_k from st1";*/
/*const char* sql = "select sum(k) from tu1 interval(10m)";*/
/*const char* sql = "select sum(k) from tu1 interval(10m)";*/
/*pRes = tmq_create_stream(pConn, "stream1", "out1", sql);*/
/*pRes = tmq_create_stream(pConn, "stream1", "out1", sql);*/
pRes
=
taos_query
(
pRes
=
taos_query
(
pConn
,
pConn
,
"create stream stream1 trigger at_once into abc2.outstb as select _wstartts, sum(k) from st1 "
"create stream stream1 trigger max_delay 10s into outstb as select _wstartts, sum(k) from st1 interval(10m)
"
);
"partition by tbname interval(10m)
"
);
if
(
taos_errno
(
pRes
)
!=
0
)
{
if
(
taos_errno
(
pRes
)
!=
0
)
{
printf
(
"failed to create stream stream1, reason:%s
\n
"
,
taos_errstr
(
pRes
));
printf
(
"failed to create stream stream1, reason:%s
\n
"
,
taos_errstr
(
pRes
));
return
-
1
;
return
-
1
;
...
...
include/client/taos.h
浏览文件 @
2e590c30
...
@@ -209,15 +209,6 @@ DLL_EXPORT TAOS_RES *taos_schemaless_insert(TAOS *taos, char *lines[], int numLi
...
@@ -209,15 +209,6 @@ DLL_EXPORT TAOS_RES *taos_schemaless_insert(TAOS *taos, char *lines[], int numLi
/* --------------------------TMQ INTERFACE------------------------------- */
/* --------------------------TMQ INTERFACE------------------------------- */
#if 0
enum {
TMQ_RESP_ERR__FAIL = -1,
TMQ_RESP_ERR__SUCCESS = 0,
};
typedef int32_t tmq_resp_err_t;
#endif
typedef
struct
tmq_t
tmq_t
;
typedef
struct
tmq_t
tmq_t
;
typedef
struct
tmq_conf_t
tmq_conf_t
;
typedef
struct
tmq_conf_t
tmq_conf_t
;
typedef
struct
tmq_list_t
tmq_list_t
;
typedef
struct
tmq_list_t
tmq_list_t
;
...
@@ -236,15 +227,13 @@ DLL_EXPORT const char *tmq_err2str(int32_t code);
...
@@ -236,15 +227,13 @@ DLL_EXPORT const char *tmq_err2str(int32_t code);
/* ------------------------TMQ CONSUMER INTERFACE------------------------ */
/* ------------------------TMQ CONSUMER INTERFACE------------------------ */
DLL_EXPORT
int32_t
tmq_subscribe
(
tmq_t
*
tmq
,
const
tmq_list_t
*
topic_list
);
DLL_EXPORT
int32_t
tmq_subscribe
(
tmq_t
*
tmq
,
const
tmq_list_t
*
topic_list
);
DLL_EXPORT
int32_t
tmq_unsubscribe
(
tmq_t
*
tmq
);
DLL_EXPORT
int32_t
tmq_unsubscribe
(
tmq_t
*
tmq
);
DLL_EXPORT
int32_t
tmq_subscription
(
tmq_t
*
tmq
,
tmq_list_t
**
topics
);
DLL_EXPORT
int32_t
tmq_subscription
(
tmq_t
*
tmq
,
tmq_list_t
**
topics
);
// timeout: -1 means infinitely waiting
DLL_EXPORT
TAOS_RES
*
tmq_consumer_poll
(
tmq_t
*
tmq
,
int64_t
timeout
);
DLL_EXPORT
TAOS_RES
*
tmq_consumer_poll
(
tmq_t
*
tmq
,
int64_t
timeout
);
DLL_EXPORT
int32_t
tmq_consumer_close
(
tmq_t
*
tmq
);
DLL_EXPORT
int32_t
tmq_consumer_close
(
tmq_t
*
tmq
);
DLL_EXPORT
int32_t
tmq_commit_sync
(
tmq_t
*
tmq
,
const
TAOS_RES
*
msg
);
DLL_EXPORT
int32_t
tmq_commit_sync
(
tmq_t
*
tmq
,
const
TAOS_RES
*
msg
);
DLL_EXPORT
void
tmq_commit_async
(
tmq_t
*
tmq
,
const
TAOS_RES
*
msg
,
tmq_commit_cb
*
cb
,
void
*
param
);
DLL_EXPORT
void
tmq_commit_async
(
tmq_t
*
tmq
,
const
TAOS_RES
*
msg
,
tmq_commit_cb
*
cb
,
void
*
param
);
/* ----------------------TMQ CONFIGURATION INTERFACE---------------------- */
/* ----------------------TMQ CONFIGURATION INTERFACE---------------------- */
...
...
include/libs/executor/executor.h
浏览文件 @
2e590c30
...
@@ -159,11 +159,14 @@ int64_t qGetQueriedTableUid(qTaskInfo_t tinfo);
...
@@ -159,11 +159,14 @@ int64_t qGetQueriedTableUid(qTaskInfo_t tinfo);
*/
*/
int32_t
qGetQualifiedTableIdList
(
void
*
pTableList
,
const
char
*
tagCond
,
int32_t
tagCondLen
,
SArray
*
pTableIdList
);
int32_t
qGetQualifiedTableIdList
(
void
*
pTableList
,
const
char
*
tagCond
,
int32_t
tagCondLen
,
SArray
*
pTableIdList
);
void
qProcessFetchRsp
(
void
*
parent
,
struct
SRpcMsg
*
pMsg
,
struct
SEpSet
*
pEpSet
);
void
qProcessFetchRsp
(
void
*
parent
,
struct
SRpcMsg
*
pMsg
,
struct
SEpSet
*
pEpSet
);
int32_t
qGetExplainExecInfo
(
qTaskInfo_t
tinfo
,
int32_t
*
resNum
,
SExplainExecInfo
**
pRes
);
int32_t
qGetExplainExecInfo
(
qTaskInfo_t
tinfo
,
int32_t
*
resNum
,
SExplainExecInfo
**
pRes
);
int32_t
qSerializeTaskStatus
(
qTaskInfo_t
tinfo
,
char
**
pOutput
,
int32_t
*
len
);
int32_t
qDeserializeTaskStatus
(
qTaskInfo_t
tinfo
,
const
char
*
pInput
,
int32_t
len
);
#ifdef __cplusplus
#ifdef __cplusplus
}
}
#endif
#endif
...
...
include/libs/sync/sync.h
浏览文件 @
2e590c30
...
@@ -62,6 +62,7 @@ typedef struct SSyncCfg {
...
@@ -62,6 +62,7 @@ typedef struct SSyncCfg {
typedef
struct
SFsmCbMeta
{
typedef
struct
SFsmCbMeta
{
SyncIndex
index
;
SyncIndex
index
;
SyncIndex
lastConfigIndex
;
bool
isWeak
;
bool
isWeak
;
int32_t
code
;
int32_t
code
;
ESyncState
state
;
ESyncState
state
;
...
@@ -75,6 +76,7 @@ typedef struct SReConfigCbMeta {
...
@@ -75,6 +76,7 @@ typedef struct SReConfigCbMeta {
int32_t
code
;
int32_t
code
;
SyncIndex
index
;
SyncIndex
index
;
SyncTerm
term
;
SyncTerm
term
;
SyncIndex
lastConfigIndex
;
SyncTerm
currentTerm
;
SyncTerm
currentTerm
;
SSyncCfg
oldCfg
;
SSyncCfg
oldCfg
;
SSyncCfg
newCfg
;
SSyncCfg
newCfg
;
...
...
include/os/osTime.h
浏览文件 @
2e590c30
...
@@ -23,22 +23,22 @@ extern "C" {
...
@@ -23,22 +23,22 @@ extern "C" {
// If the error is in a third-party library, place this header file under the third-party library header file.
// If the error is in a third-party library, place this header file under the third-party library header file.
// When you want to use this feature, you should find or add the same function in the following section.
// When you want to use this feature, you should find or add the same function in the following section.
#ifndef ALLOW_FORBID_FUNC
#ifndef ALLOW_FORBID_FUNC
#define strptime
STRPTIME_FUNC_TAOS_FORBID
#define strptime
STRPTIME_FUNC_TAOS_FORBID
#define gettimeofday GETTIMEOFDAY_FUNC_TAOS_FORBID
#define gettimeofday GETTIMEOFDAY_FUNC_TAOS_FORBID
#define localtime
LOCALTIME_FUNC_TAOS_FORBID
#define localtime
LOCALTIME_FUNC_TAOS_FORBID
#define localtime_s
LOCALTIMES_FUNC_TAOS_FORBID
#define localtime_s
LOCALTIMES_FUNC_TAOS_FORBID
#define localtime_r
LOCALTIMER_FUNC_TAOS_FORBID
#define localtime_r
LOCALTIMER_FUNC_TAOS_FORBID
#define time
TIME_FUNC_TAOS_FORBID
#define time
TIME_FUNC_TAOS_FORBID
#define mktime
MKTIME_FUNC_TAOS_FORBID
#define mktime
MKTIME_FUNC_TAOS_FORBID
#endif
#endif
#ifdef WINDOWS
#ifdef WINDOWS
#define CLOCK_REALTIME
0
#define CLOCK_REALTIME
0
#define MILLISECOND_PER_SECOND (1000i64)
#define MILLISECOND_PER_SECOND (1000i64)
#else
#else
#define MILLISECOND_PER_SECOND ((int64_t)1000L)
#define MILLISECOND_PER_SECOND ((int64_t)1000L)
#endif
#endif
#define MILLISECOND_PER_MINUTE (MILLISECOND_PER_SECOND * 60)
#define MILLISECOND_PER_MINUTE (MILLISECOND_PER_SECOND * 60)
...
@@ -82,13 +82,13 @@ static FORCE_INLINE int64_t taosGetTimestampNs() {
...
@@ -82,13 +82,13 @@ static FORCE_INLINE int64_t taosGetTimestampNs() {
return
(
int64_t
)
systemTime
.
tv_sec
*
1000000000L
+
(
int64_t
)
systemTime
.
tv_nsec
;
return
(
int64_t
)
systemTime
.
tv_sec
*
1000000000L
+
(
int64_t
)
systemTime
.
tv_nsec
;
}
}
char
*
taosStrpTime
(
const
char
*
buf
,
const
char
*
fmt
,
struct
tm
*
tm
);
char
*
taosStrpTime
(
const
char
*
buf
,
const
char
*
fmt
,
struct
tm
*
tm
);
struct
tm
*
taosLocalTime
(
const
time_t
*
timep
,
struct
tm
*
result
);
struct
tm
*
taosLocalTime
(
const
time_t
*
timep
,
struct
tm
*
result
);
time_t
taosTime
(
time_t
*
t
);
time_t
taosTime
(
time_t
*
t
);
time_t
taosMktime
(
struct
tm
*
timep
);
time_t
taosMktime
(
struct
tm
*
timep
);
#ifdef __cplusplus
#ifdef __cplusplus
}
}
#endif
#endif
#endif
/*_TD_OS_TIME_H_*/
#endif
/*_TD_OS_TIME_H_*/
include/util/taoserror.h
浏览文件 @
2e590c30
...
@@ -442,108 +442,6 @@ int32_t* taosGetErrno();
...
@@ -442,108 +442,6 @@ int32_t* taosGetErrno();
#define TSDB_CODE_WAL_OUT_OF_MEMORY TAOS_DEF_ERROR_CODE(0, 0x1004)
#define TSDB_CODE_WAL_OUT_OF_MEMORY TAOS_DEF_ERROR_CODE(0, 0x1004)
#define TSDB_CODE_WAL_LOG_NOT_EXIST TAOS_DEF_ERROR_CODE(0, 0x1005)
#define TSDB_CODE_WAL_LOG_NOT_EXIST TAOS_DEF_ERROR_CODE(0, 0x1005)
// http
#define TSDB_CODE_HTTP_SERVER_OFFLINE TAOS_DEF_ERROR_CODE(0, 0x1100) //"http server is not online"
#define TSDB_CODE_HTTP_UNSUPPORT_URL TAOS_DEF_ERROR_CODE(0, 0x1101) //"url is not support"
#define TSDB_CODE_HTTP_INVALID_URL TAOS_DEF_ERROR_CODE(0, 0x1102) //invalid url format"
#define TSDB_CODE_HTTP_NO_ENOUGH_MEMORY TAOS_DEF_ERROR_CODE(0, 0x1103) //"no enough memory"
#define TSDB_CODE_HTTP_REQUSET_TOO_BIG TAOS_DEF_ERROR_CODE(0, 0x1104) //"request size is too big"
#define TSDB_CODE_HTTP_NO_AUTH_INFO TAOS_DEF_ERROR_CODE(0, 0x1105) //"no auth info input"
#define TSDB_CODE_HTTP_NO_MSG_INPUT TAOS_DEF_ERROR_CODE(0, 0x1106) //"request is empty"
#define TSDB_CODE_HTTP_NO_SQL_INPUT TAOS_DEF_ERROR_CODE(0, 0x1107) //"no sql input"
#define TSDB_CODE_HTTP_NO_EXEC_USEDB TAOS_DEF_ERROR_CODE(0, 0x1108) //"no need to execute use db cmd"
#define TSDB_CODE_HTTP_SESSION_FULL TAOS_DEF_ERROR_CODE(0, 0x1109) //"session list was full"
#define TSDB_CODE_HTTP_GEN_TAOSD_TOKEN_ERR TAOS_DEF_ERROR_CODE(0, 0x110A) //"generate taosd token error"
#define TSDB_CODE_HTTP_INVALID_MULTI_REQUEST TAOS_DEF_ERROR_CODE(0, 0x110B) //"size of multi request is 0"
#define TSDB_CODE_HTTP_CREATE_GZIP_FAILED TAOS_DEF_ERROR_CODE(0, 0x110C) //"failed to create gzip"
#define TSDB_CODE_HTTP_FINISH_GZIP_FAILED TAOS_DEF_ERROR_CODE(0, 0x110D) //"failed to finish gzip"
#define TSDB_CODE_HTTP_LOGIN_FAILED TAOS_DEF_ERROR_CODE(0, 0x110E) //"failed to login"
#define TSDB_CODE_HTTP_INVALID_VERSION TAOS_DEF_ERROR_CODE(0, 0x1120) //"invalid http version"
#define TSDB_CODE_HTTP_INVALID_CONTENT_LENGTH TAOS_DEF_ERROR_CODE(0, 0x1121) //"invalid content length"
#define TSDB_CODE_HTTP_INVALID_AUTH_TYPE TAOS_DEF_ERROR_CODE(0, 0x1122) //"invalid type of Authorization"
#define TSDB_CODE_HTTP_INVALID_AUTH_FORMAT TAOS_DEF_ERROR_CODE(0, 0x1123) //"invalid format of Authorization"
#define TSDB_CODE_HTTP_INVALID_BASIC_AUTH TAOS_DEF_ERROR_CODE(0, 0x1124) //"invalid basic Authorization"
#define TSDB_CODE_HTTP_INVALID_TAOSD_AUTH TAOS_DEF_ERROR_CODE(0, 0x1125) //"invalid taosd Authorization"
#define TSDB_CODE_HTTP_PARSE_METHOD_FAILED TAOS_DEF_ERROR_CODE(0, 0x1126) //"failed to parse method"
#define TSDB_CODE_HTTP_PARSE_TARGET_FAILED TAOS_DEF_ERROR_CODE(0, 0x1127) //"failed to parse target"
#define TSDB_CODE_HTTP_PARSE_VERSION_FAILED TAOS_DEF_ERROR_CODE(0, 0x1128) //"failed to parse http version"
#define TSDB_CODE_HTTP_PARSE_SP_FAILED TAOS_DEF_ERROR_CODE(0, 0x1129) //"failed to parse sp"
#define TSDB_CODE_HTTP_PARSE_STATUS_FAILED TAOS_DEF_ERROR_CODE(0, 0x112A) //"failed to parse status"
#define TSDB_CODE_HTTP_PARSE_PHRASE_FAILED TAOS_DEF_ERROR_CODE(0, 0x112B) //"failed to parse phrase"
#define TSDB_CODE_HTTP_PARSE_CRLF_FAILED TAOS_DEF_ERROR_CODE(0, 0x112C) //"failed to parse crlf"
#define TSDB_CODE_HTTP_PARSE_HEADER_FAILED TAOS_DEF_ERROR_CODE(0, 0x112D) //"failed to parse header"
#define TSDB_CODE_HTTP_PARSE_HEADER_KEY_FAILED TAOS_DEF_ERROR_CODE(0, 0x112E) //"failed to parse header key"
#define TSDB_CODE_HTTP_PARSE_HEADER_VAL_FAILED TAOS_DEF_ERROR_CODE(0, 0x112F) //"failed to parse header val"
#define TSDB_CODE_HTTP_PARSE_CHUNK_SIZE_FAILED TAOS_DEF_ERROR_CODE(0, 0x1130) //"failed to parse chunk size"
#define TSDB_CODE_HTTP_PARSE_CHUNK_FAILED TAOS_DEF_ERROR_CODE(0, 0x1131) //"failed to parse chunk"
#define TSDB_CODE_HTTP_PARSE_END_FAILED TAOS_DEF_ERROR_CODE(0, 0x1132) //"failed to parse end section"
#define TSDB_CODE_HTTP_PARSE_INVALID_STATE TAOS_DEF_ERROR_CODE(0, 0x1134) //"invalid parse state"
#define TSDB_CODE_HTTP_PARSE_ERROR_STATE TAOS_DEF_ERROR_CODE(0, 0x1135) //"failed to parse error section"
#define TSDB_CODE_HTTP_GC_QUERY_NULL TAOS_DEF_ERROR_CODE(0, 0x1150) //"query size is 0"
#define TSDB_CODE_HTTP_GC_QUERY_SIZE TAOS_DEF_ERROR_CODE(0, 0x1151) //"query size can not more than 100"
#define TSDB_CODE_HTTP_GC_REQ_PARSE_ERROR TAOS_DEF_ERROR_CODE(0, 0x1152) //"parse grafana json error"
#define TSDB_CODE_HTTP_TG_DB_NOT_INPUT TAOS_DEF_ERROR_CODE(0, 0x1160) //"database name can not be null"
#define TSDB_CODE_HTTP_TG_DB_TOO_LONG TAOS_DEF_ERROR_CODE(0, 0x1161) //"database name too long"
#define TSDB_CODE_HTTP_TG_INVALID_JSON TAOS_DEF_ERROR_CODE(0, 0x1162) //"invalid telegraf json fromat"
#define TSDB_CODE_HTTP_TG_METRICS_NULL TAOS_DEF_ERROR_CODE(0, 0x1163) //"metrics size is 0"
#define TSDB_CODE_HTTP_TG_METRICS_SIZE TAOS_DEF_ERROR_CODE(0, 0x1164) //"metrics size can not more than 1K"
#define TSDB_CODE_HTTP_TG_METRIC_NULL TAOS_DEF_ERROR_CODE(0, 0x1165) //"metric name not find"
#define TSDB_CODE_HTTP_TG_METRIC_TYPE TAOS_DEF_ERROR_CODE(0, 0x1166) //"metric name type should be string"
#define TSDB_CODE_HTTP_TG_METRIC_NAME_NULL TAOS_DEF_ERROR_CODE(0, 0x1167) //"metric name length is 0"
#define TSDB_CODE_HTTP_TG_METRIC_NAME_LONG TAOS_DEF_ERROR_CODE(0, 0x1168) //"metric name length too long"
#define TSDB_CODE_HTTP_TG_TIMESTAMP_NULL TAOS_DEF_ERROR_CODE(0, 0x1169) //"timestamp not find"
#define TSDB_CODE_HTTP_TG_TIMESTAMP_TYPE TAOS_DEF_ERROR_CODE(0, 0x116A) //"timestamp type should be integer"
#define TSDB_CODE_HTTP_TG_TIMESTAMP_VAL_NULL TAOS_DEF_ERROR_CODE(0, 0x116B) //"timestamp value smaller than 0"
#define TSDB_CODE_HTTP_TG_TAGS_NULL TAOS_DEF_ERROR_CODE(0, 0x116C) //"tags not find"
#define TSDB_CODE_HTTP_TG_TAGS_SIZE_0 TAOS_DEF_ERROR_CODE(0, 0x116D) //"tags size is 0"
#define TSDB_CODE_HTTP_TG_TAGS_SIZE_LONG TAOS_DEF_ERROR_CODE(0, 0x116E) //"tags size too long"
#define TSDB_CODE_HTTP_TG_TAG_NULL TAOS_DEF_ERROR_CODE(0, 0x116F) //"tag is null"
#define TSDB_CODE_HTTP_TG_TAG_NAME_NULL TAOS_DEF_ERROR_CODE(0, 0x1170) //"tag name is null"
#define TSDB_CODE_HTTP_TG_TAG_NAME_SIZE TAOS_DEF_ERROR_CODE(0, 0x1171) //"tag name length too long"
#define TSDB_CODE_HTTP_TG_TAG_VALUE_TYPE TAOS_DEF_ERROR_CODE(0, 0x1172) //"tag value type should be number or string"
#define TSDB_CODE_HTTP_TG_TAG_VALUE_NULL TAOS_DEF_ERROR_CODE(0, 0x1173) //"tag value is null"
#define TSDB_CODE_HTTP_TG_TABLE_NULL TAOS_DEF_ERROR_CODE(0, 0x1174) //"table is null"
#define TSDB_CODE_HTTP_TG_TABLE_SIZE TAOS_DEF_ERROR_CODE(0, 0x1175) //"table name length too long"
#define TSDB_CODE_HTTP_TG_FIELDS_NULL TAOS_DEF_ERROR_CODE(0, 0x1176) //"fields not find"
#define TSDB_CODE_HTTP_TG_FIELDS_SIZE_0 TAOS_DEF_ERROR_CODE(0, 0x1177) //"fields size is 0"
#define TSDB_CODE_HTTP_TG_FIELDS_SIZE_LONG TAOS_DEF_ERROR_CODE(0, 0x1178) //"fields size too long"
#define TSDB_CODE_HTTP_TG_FIELD_NULL TAOS_DEF_ERROR_CODE(0, 0x1179) //"field is null"
#define TSDB_CODE_HTTP_TG_FIELD_NAME_NULL TAOS_DEF_ERROR_CODE(0, 0x117A) //"field name is null"
#define TSDB_CODE_HTTP_TG_FIELD_NAME_SIZE TAOS_DEF_ERROR_CODE(0, 0x117B) //"field name length too long"
#define TSDB_CODE_HTTP_TG_FIELD_VALUE_TYPE TAOS_DEF_ERROR_CODE(0, 0x117C) //"field value type should be number or string"
#define TSDB_CODE_HTTP_TG_FIELD_VALUE_NULL TAOS_DEF_ERROR_CODE(0, 0x117D) //"field value is null"
#define TSDB_CODE_HTTP_TG_HOST_NOT_STRING TAOS_DEF_ERROR_CODE(0, 0x117E) //"host type should be string"
#define TSDB_CODE_HTTP_TG_STABLE_NOT_EXIST TAOS_DEF_ERROR_CODE(0, 0x117F) //"stable not exist"
#define TSDB_CODE_HTTP_OP_DB_NOT_INPUT TAOS_DEF_ERROR_CODE(0, 0x1190) //"database name can not be null"
#define TSDB_CODE_HTTP_OP_DB_TOO_LONG TAOS_DEF_ERROR_CODE(0, 0x1191) //"database name too long"
#define TSDB_CODE_HTTP_OP_INVALID_JSON TAOS_DEF_ERROR_CODE(0, 0x1192) //"invalid opentsdb json fromat"
#define TSDB_CODE_HTTP_OP_METRICS_NULL TAOS_DEF_ERROR_CODE(0, 0x1193) //"metrics size is 0"
#define TSDB_CODE_HTTP_OP_METRICS_SIZE TAOS_DEF_ERROR_CODE(0, 0x1194) //"metrics size can not more than 10K"
#define TSDB_CODE_HTTP_OP_METRIC_NULL TAOS_DEF_ERROR_CODE(0, 0x1195) //"metric name not find"
#define TSDB_CODE_HTTP_OP_METRIC_TYPE TAOS_DEF_ERROR_CODE(0, 0x1196) //"metric name type should be string"
#define TSDB_CODE_HTTP_OP_METRIC_NAME_NULL TAOS_DEF_ERROR_CODE(0, 0x1197) //"metric name length is 0"
#define TSDB_CODE_HTTP_OP_METRIC_NAME_LONG TAOS_DEF_ERROR_CODE(0, 0x1198) //"metric name length can not more than 22"
#define TSDB_CODE_HTTP_OP_TIMESTAMP_NULL TAOS_DEF_ERROR_CODE(0, 0x1199) //"timestamp not find"
#define TSDB_CODE_HTTP_OP_TIMESTAMP_TYPE TAOS_DEF_ERROR_CODE(0, 0x119A) //"timestamp type should be integer"
#define TSDB_CODE_HTTP_OP_TIMESTAMP_VAL_NULL TAOS_DEF_ERROR_CODE(0, 0x119B) //"timestamp value smaller than 0"
#define TSDB_CODE_HTTP_OP_TAGS_NULL TAOS_DEF_ERROR_CODE(0, 0x119C) //"tags not find"
#define TSDB_CODE_HTTP_OP_TAGS_SIZE_0 TAOS_DEF_ERROR_CODE(0, 0x119D) //"tags size is 0"
#define TSDB_CODE_HTTP_OP_TAGS_SIZE_LONG TAOS_DEF_ERROR_CODE(0, 0x119E) //"tags size too long"
#define TSDB_CODE_HTTP_OP_TAG_NULL TAOS_DEF_ERROR_CODE(0, 0x119F) //"tag is null"
#define TSDB_CODE_HTTP_OP_TAG_NAME_NULL TAOS_DEF_ERROR_CODE(0, 0x11A0) //"tag name is null"
#define TSDB_CODE_HTTP_OP_TAG_NAME_SIZE TAOS_DEF_ERROR_CODE(0, 0x11A1) //"tag name length too long"
#define TSDB_CODE_HTTP_OP_TAG_VALUE_TYPE TAOS_DEF_ERROR_CODE(0, 0x11A2) //"tag value type should be boolean number or string"
#define TSDB_CODE_HTTP_OP_TAG_VALUE_NULL TAOS_DEF_ERROR_CODE(0, 0x11A3) //"tag value is null"
#define TSDB_CODE_HTTP_OP_TAG_VALUE_TOO_LONG TAOS_DEF_ERROR_CODE(0, 0x11A4) //"tag value can not more than 64"
#define TSDB_CODE_HTTP_OP_VALUE_NULL TAOS_DEF_ERROR_CODE(0, 0x11A5) //"value not find"
#define TSDB_CODE_HTTP_OP_VALUE_TYPE TAOS_DEF_ERROR_CODE(0, 0x11A6) //"value type should be boolean number or string"
#define TSDB_CODE_HTTP_REQUEST_JSON_ERROR TAOS_DEF_ERROR_CODE(0, 0x1F00) //"http request json error"
// tfs
// tfs
#define TSDB_CODE_FS_APP_ERROR TAOS_DEF_ERROR_CODE(0, 0x2200)
#define TSDB_CODE_FS_APP_ERROR TAOS_DEF_ERROR_CODE(0, 0x2200)
#define TSDB_CODE_FS_INVLD_CFG TAOS_DEF_ERROR_CODE(0, 0x2201)
#define TSDB_CODE_FS_INVLD_CFG TAOS_DEF_ERROR_CODE(0, 0x2201)
...
...
source/common/src/systable.c
浏览文件 @
2e590c30
...
@@ -220,7 +220,8 @@ static const SSysDbTableSchema transSchema[] = {
...
@@ -220,7 +220,8 @@ static const SSysDbTableSchema transSchema[] = {
{.
name
=
"id"
,
.
bytes
=
4
,
.
type
=
TSDB_DATA_TYPE_INT
},
{.
name
=
"id"
,
.
bytes
=
4
,
.
type
=
TSDB_DATA_TYPE_INT
},
{.
name
=
"create_time"
,
.
bytes
=
8
,
.
type
=
TSDB_DATA_TYPE_TIMESTAMP
},
{.
name
=
"create_time"
,
.
bytes
=
8
,
.
type
=
TSDB_DATA_TYPE_TIMESTAMP
},
{.
name
=
"stage"
,
.
bytes
=
TSDB_TRANS_STAGE_LEN
+
VARSTR_HEADER_SIZE
,
.
type
=
TSDB_DATA_TYPE_VARCHAR
},
{.
name
=
"stage"
,
.
bytes
=
TSDB_TRANS_STAGE_LEN
+
VARSTR_HEADER_SIZE
,
.
type
=
TSDB_DATA_TYPE_VARCHAR
},
{.
name
=
"db"
,
.
bytes
=
SYSTABLE_SCH_DB_NAME_LEN
,
.
type
=
TSDB_DATA_TYPE_VARCHAR
},
{.
name
=
"db1"
,
.
bytes
=
SYSTABLE_SCH_DB_NAME_LEN
,
.
type
=
TSDB_DATA_TYPE_VARCHAR
},
{.
name
=
"db2"
,
.
bytes
=
SYSTABLE_SCH_DB_NAME_LEN
,
.
type
=
TSDB_DATA_TYPE_VARCHAR
},
{.
name
=
"failed_times"
,
.
bytes
=
4
,
.
type
=
TSDB_DATA_TYPE_INT
},
{.
name
=
"failed_times"
,
.
bytes
=
4
,
.
type
=
TSDB_DATA_TYPE_INT
},
{.
name
=
"last_exec_time"
,
.
bytes
=
8
,
.
type
=
TSDB_DATA_TYPE_TIMESTAMP
},
{.
name
=
"last_exec_time"
,
.
bytes
=
8
,
.
type
=
TSDB_DATA_TYPE_TIMESTAMP
},
{.
name
=
"last_action_info"
,
{.
name
=
"last_action_info"
,
...
...
source/common/src/tdatablock.c
浏览文件 @
2e590c30
...
@@ -1713,6 +1713,7 @@ int32_t buildSubmitReqFromDataBlock(SSubmitReq** pReq, const SArray* pDataBlocks
...
@@ -1713,6 +1713,7 @@ int32_t buildSubmitReqFromDataBlock(SSubmitReq** pReq, const SArray* pDataBlocks
}
}
char
*
buildCtbNameByGroupId
(
const
char
*
stbName
,
uint64_t
groupId
)
{
char
*
buildCtbNameByGroupId
(
const
char
*
stbName
,
uint64_t
groupId
)
{
ASSERT
(
stbName
[
0
]
!=
0
);
SArray
*
tags
=
taosArrayInit
(
0
,
sizeof
(
void
*
));
SArray
*
tags
=
taosArrayInit
(
0
,
sizeof
(
void
*
));
SSmlKv
*
pTag
=
taosMemoryCalloc
(
1
,
sizeof
(
SSmlKv
));
SSmlKv
*
pTag
=
taosMemoryCalloc
(
1
,
sizeof
(
SSmlKv
));
pTag
->
key
=
"group_id"
;
pTag
->
key
=
"group_id"
;
...
...
source/dnode/mnode/impl/inc/mndDef.h
浏览文件 @
2e590c30
...
@@ -124,7 +124,8 @@ typedef struct {
...
@@ -124,7 +124,8 @@ typedef struct {
int32_t
lastErrorNo
;
int32_t
lastErrorNo
;
tmsg_t
lastMsgType
;
tmsg_t
lastMsgType
;
SEpSet
lastEpset
;
SEpSet
lastEpset
;
char
dbname
[
TSDB_DB_FNAME_LEN
];
char
dbname1
[
TSDB_DB_FNAME_LEN
];
char
dbname2
[
TSDB_DB_FNAME_LEN
];
int32_t
startFunc
;
int32_t
startFunc
;
int32_t
stopFunc
;
int32_t
stopFunc
;
int32_t
paramLen
;
int32_t
paramLen
;
...
...
source/dnode/mnode/impl/inc/mndTrans.h
浏览文件 @
2e590c30
...
@@ -68,7 +68,7 @@ int32_t mndTransAppendRedoAction(STrans *pTrans, STransAction *pAction);
...
@@ -68,7 +68,7 @@ int32_t mndTransAppendRedoAction(STrans *pTrans, STransAction *pAction);
int32_t
mndTransAppendUndoAction
(
STrans
*
pTrans
,
STransAction
*
pAction
);
int32_t
mndTransAppendUndoAction
(
STrans
*
pTrans
,
STransAction
*
pAction
);
void
mndTransSetRpcRsp
(
STrans
*
pTrans
,
void
*
pCont
,
int32_t
contLen
);
void
mndTransSetRpcRsp
(
STrans
*
pTrans
,
void
*
pCont
,
int32_t
contLen
);
void
mndTransSetCb
(
STrans
*
pTrans
,
ETrnFunc
startFunc
,
ETrnFunc
stopFunc
,
void
*
param
,
int32_t
paramLen
);
void
mndTransSetCb
(
STrans
*
pTrans
,
ETrnFunc
startFunc
,
ETrnFunc
stopFunc
,
void
*
param
,
int32_t
paramLen
);
void
mndTransSetDbName
(
STrans
*
pTrans
,
const
char
*
dbname
);
void
mndTransSetDbName
(
STrans
*
pTrans
,
const
char
*
dbname
1
,
const
char
*
dbname2
);
void
mndTransSetSerial
(
STrans
*
pTrans
);
void
mndTransSetSerial
(
STrans
*
pTrans
);
int32_t
mndTransPrepare
(
SMnode
*
pMnode
,
STrans
*
pTrans
);
int32_t
mndTransPrepare
(
SMnode
*
pMnode
,
STrans
*
pTrans
);
...
...
source/dnode/mnode/impl/src/mndDb.c
浏览文件 @
2e590c30
...
@@ -477,7 +477,7 @@ static int32_t mndCreateDb(SMnode *pMnode, SRpcMsg *pReq, SCreateDbReq *pCreate,
...
@@ -477,7 +477,7 @@ static int32_t mndCreateDb(SMnode *pMnode, SRpcMsg *pReq, SCreateDbReq *pCreate,
mDebug
(
"trans:%d, used to create db:%s"
,
pTrans
->
id
,
pCreate
->
db
);
mDebug
(
"trans:%d, used to create db:%s"
,
pTrans
->
id
,
pCreate
->
db
);
mndTransSetDbName
(
pTrans
,
dbObj
.
name
);
mndTransSetDbName
(
pTrans
,
dbObj
.
name
,
NULL
);
if
(
mndSetCreateDbRedoLogs
(
pMnode
,
pTrans
,
&
dbObj
,
pVgroups
)
!=
0
)
goto
_OVER
;
if
(
mndSetCreateDbRedoLogs
(
pMnode
,
pTrans
,
&
dbObj
,
pVgroups
)
!=
0
)
goto
_OVER
;
if
(
mndSetCreateDbUndoLogs
(
pMnode
,
pTrans
,
&
dbObj
,
pVgroups
)
!=
0
)
goto
_OVER
;
if
(
mndSetCreateDbUndoLogs
(
pMnode
,
pTrans
,
&
dbObj
,
pVgroups
)
!=
0
)
goto
_OVER
;
if
(
mndSetCreateDbCommitLogs
(
pMnode
,
pTrans
,
&
dbObj
,
pVgroups
)
!=
0
)
goto
_OVER
;
if
(
mndSetCreateDbCommitLogs
(
pMnode
,
pTrans
,
&
dbObj
,
pVgroups
)
!=
0
)
goto
_OVER
;
...
@@ -668,7 +668,7 @@ static int32_t mndAlterDb(SMnode *pMnode, SRpcMsg *pReq, SDbObj *pOld, SDbObj *p
...
@@ -668,7 +668,7 @@ static int32_t mndAlterDb(SMnode *pMnode, SRpcMsg *pReq, SDbObj *pOld, SDbObj *p
mDebug
(
"trans:%d, used to alter db:%s"
,
pTrans
->
id
,
pOld
->
name
);
mDebug
(
"trans:%d, used to alter db:%s"
,
pTrans
->
id
,
pOld
->
name
);
int32_t
code
=
-
1
;
int32_t
code
=
-
1
;
mndTransSetDbName
(
pTrans
,
pOld
->
name
);
mndTransSetDbName
(
pTrans
,
pOld
->
name
,
NULL
);
if
(
mndSetAlterDbRedoLogs
(
pMnode
,
pTrans
,
pOld
,
pNew
)
!=
0
)
goto
_OVER
;
if
(
mndSetAlterDbRedoLogs
(
pMnode
,
pTrans
,
pOld
,
pNew
)
!=
0
)
goto
_OVER
;
if
(
mndSetAlterDbCommitLogs
(
pMnode
,
pTrans
,
pOld
,
pNew
)
!=
0
)
goto
_OVER
;
if
(
mndSetAlterDbCommitLogs
(
pMnode
,
pTrans
,
pOld
,
pNew
)
!=
0
)
goto
_OVER
;
if
(
mndSetAlterDbRedoActions
(
pMnode
,
pTrans
,
pOld
,
pNew
)
!=
0
)
goto
_OVER
;
if
(
mndSetAlterDbRedoActions
(
pMnode
,
pTrans
,
pOld
,
pNew
)
!=
0
)
goto
_OVER
;
...
@@ -921,7 +921,7 @@ static int32_t mndDropDb(SMnode *pMnode, SRpcMsg *pReq, SDbObj *pDb) {
...
@@ -921,7 +921,7 @@ static int32_t mndDropDb(SMnode *pMnode, SRpcMsg *pReq, SDbObj *pDb) {
if
(
pTrans
==
NULL
)
goto
_OVER
;
if
(
pTrans
==
NULL
)
goto
_OVER
;
mDebug
(
"trans:%d, used to drop db:%s"
,
pTrans
->
id
,
pDb
->
name
);
mDebug
(
"trans:%d, used to drop db:%s"
,
pTrans
->
id
,
pDb
->
name
);
mndTransSetDbName
(
pTrans
,
pDb
->
name
);
mndTransSetDbName
(
pTrans
,
pDb
->
name
,
NULL
);
if
(
mndSetDropDbRedoLogs
(
pMnode
,
pTrans
,
pDb
)
!=
0
)
goto
_OVER
;
if
(
mndSetDropDbRedoLogs
(
pMnode
,
pTrans
,
pDb
)
!=
0
)
goto
_OVER
;
if
(
mndSetDropDbCommitLogs
(
pMnode
,
pTrans
,
pDb
)
!=
0
)
goto
_OVER
;
if
(
mndSetDropDbCommitLogs
(
pMnode
,
pTrans
,
pDb
)
!=
0
)
goto
_OVER
;
...
...
source/dnode/mnode/impl/src/mndScheduler.c
浏览文件 @
2e590c30
...
@@ -105,7 +105,7 @@ int32_t mndPersistTaskDeployReq(STrans* pTrans, SStreamTask* pTask, const SEpSet
...
@@ -105,7 +105,7 @@ int32_t mndPersistTaskDeployReq(STrans* pTrans, SStreamTask* pTask, const SEpSet
int32_t
size
=
encoder
.
pos
;
int32_t
size
=
encoder
.
pos
;
int32_t
tlen
=
sizeof
(
SMsgHead
)
+
size
;
int32_t
tlen
=
sizeof
(
SMsgHead
)
+
size
;
tEncoderClear
(
&
encoder
);
tEncoderClear
(
&
encoder
);
void
*
buf
=
taosMemory
Malloc
(
tlen
);
void
*
buf
=
taosMemory
Calloc
(
1
,
tlen
);
if
(
buf
==
NULL
)
{
if
(
buf
==
NULL
)
{
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
return
-
1
;
return
-
1
;
...
@@ -157,6 +157,7 @@ int32_t mndAddDispatcherToInnerTask(SMnode* pMnode, STrans* pTrans, SStreamObj*
...
@@ -157,6 +157,7 @@ int32_t mndAddDispatcherToInnerTask(SMnode* pMnode, STrans* pTrans, SStreamObj*
}
}
sdbRelease
(
pMnode
->
pSdb
,
pDb
);
sdbRelease
(
pMnode
->
pSdb
,
pDb
);
memcpy
(
pTask
->
shuffleDispatcher
.
stbFullName
,
pStream
->
targetSTbName
,
TSDB_TABLE_FNAME_LEN
);
SArray
*
pVgs
=
pTask
->
shuffleDispatcher
.
dbInfo
.
pVgroupInfos
;
SArray
*
pVgs
=
pTask
->
shuffleDispatcher
.
dbInfo
.
pVgroupInfos
;
int32_t
sz
=
taosArrayGetSize
(
pVgs
);
int32_t
sz
=
taosArrayGetSize
(
pVgs
);
SArray
*
sinkLv
=
taosArrayGetP
(
pStream
->
tasks
,
0
);
SArray
*
sinkLv
=
taosArrayGetP
(
pStream
->
tasks
,
0
);
...
@@ -166,6 +167,7 @@ int32_t mndAddDispatcherToInnerTask(SMnode* pMnode, STrans* pTrans, SStreamObj*
...
@@ -166,6 +167,7 @@ int32_t mndAddDispatcherToInnerTask(SMnode* pMnode, STrans* pTrans, SStreamObj*
for
(
int32_t
j
=
0
;
j
<
sinkLvSize
;
j
++
)
{
for
(
int32_t
j
=
0
;
j
<
sinkLvSize
;
j
++
)
{
SStreamTask
*
pLastLevelTask
=
taosArrayGetP
(
sinkLv
,
j
);
SStreamTask
*
pLastLevelTask
=
taosArrayGetP
(
sinkLv
,
j
);
if
(
pLastLevelTask
->
nodeId
==
pVgInfo
->
vgId
)
{
if
(
pLastLevelTask
->
nodeId
==
pVgInfo
->
vgId
)
{
ASSERT
(
pVgInfo
->
vgId
>
0
);
pVgInfo
->
taskId
=
pLastLevelTask
->
taskId
;
pVgInfo
->
taskId
=
pLastLevelTask
->
taskId
;
ASSERT
(
pVgInfo
->
taskId
!=
0
);
ASSERT
(
pVgInfo
->
taskId
!=
0
);
break
;
break
;
...
...
source/dnode/mnode/impl/src/mndSma.c
浏览文件 @
2e590c30
...
@@ -609,7 +609,7 @@ static int32_t mndCreateSma(SMnode *pMnode, SRpcMsg *pReq, SMCreateSmaReq *pCrea
...
@@ -609,7 +609,7 @@ static int32_t mndCreateSma(SMnode *pMnode, SRpcMsg *pReq, SMCreateSmaReq *pCrea
int32_t
code
=
-
1
;
int32_t
code
=
-
1
;
STrans
*
pTrans
=
mndTransCreate
(
pMnode
,
TRN_POLICY_RETRY
,
TRN_CONFLICT_DB
,
pReq
);
STrans
*
pTrans
=
mndTransCreate
(
pMnode
,
TRN_POLICY_RETRY
,
TRN_CONFLICT_DB
,
pReq
);
if
(
pTrans
==
NULL
)
goto
_OVER
;
if
(
pTrans
==
NULL
)
goto
_OVER
;
mndTransSetDbName
(
pTrans
,
pDb
->
name
);
mndTransSetDbName
(
pTrans
,
pDb
->
name
,
NULL
);
mndTransSetSerial
(
pTrans
);
mndTransSetSerial
(
pTrans
);
mDebug
(
"trans:%d, used to create sma:%s"
,
pTrans
->
id
,
pCreate
->
name
);
mDebug
(
"trans:%d, used to create sma:%s"
,
pTrans
->
id
,
pCreate
->
name
);
...
@@ -852,7 +852,7 @@ static int32_t mndDropSma(SMnode *pMnode, SRpcMsg *pReq, SDbObj *pDb, SSmaObj *p
...
@@ -852,7 +852,7 @@ static int32_t mndDropSma(SMnode *pMnode, SRpcMsg *pReq, SDbObj *pDb, SSmaObj *p
if
(
pTrans
==
NULL
)
goto
_OVER
;
if
(
pTrans
==
NULL
)
goto
_OVER
;
mDebug
(
"trans:%d, used to drop sma:%s"
,
pTrans
->
id
,
pSma
->
name
);
mDebug
(
"trans:%d, used to drop sma:%s"
,
pTrans
->
id
,
pSma
->
name
);
mndTransSetDbName
(
pTrans
,
pDb
->
name
);
mndTransSetDbName
(
pTrans
,
pDb
->
name
,
NULL
);
if
(
mndSetDropSmaRedoLogs
(
pMnode
,
pTrans
,
pSma
)
!=
0
)
goto
_OVER
;
if
(
mndSetDropSmaRedoLogs
(
pMnode
,
pTrans
,
pSma
)
!=
0
)
goto
_OVER
;
if
(
mndSetDropSmaVgroupRedoLogs
(
pMnode
,
pTrans
,
pVgroup
)
!=
0
)
goto
_OVER
;
if
(
mndSetDropSmaVgroupRedoLogs
(
pMnode
,
pTrans
,
pVgroup
)
!=
0
)
goto
_OVER
;
...
...
source/dnode/mnode/impl/src/mndStb.c
浏览文件 @
2e590c30
...
@@ -758,7 +758,7 @@ _OVER:
...
@@ -758,7 +758,7 @@ _OVER:
}
}
int32_t
mndAddStbToTrans
(
SMnode
*
pMnode
,
STrans
*
pTrans
,
SDbObj
*
pDb
,
SStbObj
*
pStb
)
{
int32_t
mndAddStbToTrans
(
SMnode
*
pMnode
,
STrans
*
pTrans
,
SDbObj
*
pDb
,
SStbObj
*
pStb
)
{
mndTransSetDbName
(
pTrans
,
pDb
->
name
);
mndTransSetDbName
(
pTrans
,
pDb
->
name
,
NULL
);
if
(
mndSetCreateStbRedoLogs
(
pMnode
,
pTrans
,
pDb
,
pStb
)
!=
0
)
return
-
1
;
if
(
mndSetCreateStbRedoLogs
(
pMnode
,
pTrans
,
pDb
,
pStb
)
!=
0
)
return
-
1
;
if
(
mndSetCreateStbUndoLogs
(
pMnode
,
pTrans
,
pDb
,
pStb
)
!=
0
)
return
-
1
;
if
(
mndSetCreateStbUndoLogs
(
pMnode
,
pTrans
,
pDb
,
pStb
)
!=
0
)
return
-
1
;
if
(
mndSetCreateStbCommitLogs
(
pMnode
,
pTrans
,
pDb
,
pStb
)
!=
0
)
return
-
1
;
if
(
mndSetCreateStbCommitLogs
(
pMnode
,
pTrans
,
pDb
,
pStb
)
!=
0
)
return
-
1
;
...
@@ -1396,7 +1396,7 @@ static int32_t mndAlterStb(SMnode *pMnode, SRpcMsg *pReq, const SMAlterStbReq *p
...
@@ -1396,7 +1396,7 @@ static int32_t mndAlterStb(SMnode *pMnode, SRpcMsg *pReq, const SMAlterStbReq *p
if
(
pTrans
==
NULL
)
goto
_OVER
;
if
(
pTrans
==
NULL
)
goto
_OVER
;
mDebug
(
"trans:%d, used to alter stb:%s"
,
pTrans
->
id
,
pAlter
->
name
);
mDebug
(
"trans:%d, used to alter stb:%s"
,
pTrans
->
id
,
pAlter
->
name
);
mndTransSetDbName
(
pTrans
,
pDb
->
name
);
mndTransSetDbName
(
pTrans
,
pDb
->
name
,
NULL
);
if
(
needRsp
)
{
if
(
needRsp
)
{
void
*
pCont
=
NULL
;
void
*
pCont
=
NULL
;
...
@@ -1537,7 +1537,7 @@ static int32_t mndDropStb(SMnode *pMnode, SRpcMsg *pReq, SDbObj *pDb, SStbObj *p
...
@@ -1537,7 +1537,7 @@ static int32_t mndDropStb(SMnode *pMnode, SRpcMsg *pReq, SDbObj *pDb, SStbObj *p
if
(
pTrans
==
NULL
)
goto
_OVER
;
if
(
pTrans
==
NULL
)
goto
_OVER
;
mDebug
(
"trans:%d, used to drop stb:%s"
,
pTrans
->
id
,
pStb
->
name
);
mDebug
(
"trans:%d, used to drop stb:%s"
,
pTrans
->
id
,
pStb
->
name
);
mndTransSetDbName
(
pTrans
,
pDb
->
name
);
mndTransSetDbName
(
pTrans
,
pDb
->
name
,
NULL
);
if
(
mndSetDropStbRedoLogs
(
pMnode
,
pTrans
,
pStb
)
!=
0
)
goto
_OVER
;
if
(
mndSetDropStbRedoLogs
(
pMnode
,
pTrans
,
pStb
)
!=
0
)
goto
_OVER
;
if
(
mndSetDropStbCommitLogs
(
pMnode
,
pTrans
,
pStb
)
!=
0
)
goto
_OVER
;
if
(
mndSetDropStbCommitLogs
(
pMnode
,
pTrans
,
pStb
)
!=
0
)
goto
_OVER
;
...
...
source/dnode/mnode/impl/src/mndStream.c
浏览文件 @
2e590c30
...
@@ -613,9 +613,9 @@ static int32_t mndProcessCreateStreamReq(SRpcMsg *pReq) {
...
@@ -613,9 +613,9 @@ static int32_t mndProcessCreateStreamReq(SRpcMsg *pReq) {
goto
_OVER
;
goto
_OVER
;
}
}
mndTransSetDbName
(
pTrans
,
createStreamReq
.
sourceDB
);
mndTransSetDbName
(
pTrans
,
createStreamReq
.
sourceDB
,
NULL
);
// TODO
// TODO
/*mndTransSetDbName(pTrans, streamObj.targetDb);*/
/*mndTransSetDbName(pTrans, streamObj.targetDb
, NULL
);*/
mDebug
(
"trans:%d, used to create stream:%s"
,
pTrans
->
id
,
createStreamReq
.
name
);
mDebug
(
"trans:%d, used to create stream:%s"
,
pTrans
->
id
,
createStreamReq
.
name
);
// build stream obj from request
// build stream obj from request
...
...
source/dnode/mnode/impl/src/mndSubscribe.c
浏览文件 @
2e590c30
...
@@ -403,7 +403,7 @@ static int32_t mndDoRebalance(SMnode *pMnode, const SMqRebInputObj *pInput, SMqR
...
@@ -403,7 +403,7 @@ static int32_t mndDoRebalance(SMnode *pMnode, const SMqRebInputObj *pInput, SMqR
static
int32_t
mndPersistRebResult
(
SMnode
*
pMnode
,
SRpcMsg
*
pMsg
,
const
SMqRebOutputObj
*
pOutput
)
{
static
int32_t
mndPersistRebResult
(
SMnode
*
pMnode
,
SRpcMsg
*
pMsg
,
const
SMqRebOutputObj
*
pOutput
)
{
STrans
*
pTrans
=
mndTransCreate
(
pMnode
,
TRN_POLICY_ROLLBACK
,
TRN_CONFLICT_DB_INSIDE
,
pMsg
);
STrans
*
pTrans
=
mndTransCreate
(
pMnode
,
TRN_POLICY_ROLLBACK
,
TRN_CONFLICT_DB_INSIDE
,
pMsg
);
mndTransSetDbName
(
pTrans
,
pOutput
->
pSub
->
dbName
);
mndTransSetDbName
(
pTrans
,
pOutput
->
pSub
->
dbName
,
NULL
);
if
(
pTrans
==
NULL
)
return
-
1
;
if
(
pTrans
==
NULL
)
return
-
1
;
// make txn:
// make txn:
...
...
source/dnode/mnode/impl/src/mndSync.c
浏览文件 @
2e590c30
...
@@ -46,13 +46,14 @@ void mndSyncCommitMsg(struct SSyncFSM *pFsm, const SRpcMsg *pMsg, SFsmCbMeta cbM
...
@@ -46,13 +46,14 @@ void mndSyncCommitMsg(struct SSyncFSM *pFsm, const SRpcMsg *pMsg, SFsmCbMeta cbM
int32_t
transId
=
sdbGetIdFromRaw
(
pMnode
->
pSdb
,
pRaw
);
int32_t
transId
=
sdbGetIdFromRaw
(
pMnode
->
pSdb
,
pRaw
);
pMgmt
->
errCode
=
cbMeta
.
code
;
pMgmt
->
errCode
=
cbMeta
.
code
;
mDebug
(
"trans:%d, is proposed, saved:%d code:0x%x, index:%"
PRId64
" term:%"
PRId64
" role:%s raw:%p"
,
transId
,
mDebug
(
"trans:%d, is proposed, saved:%d code:0x%x, apply index:%"
PRId64
" term:%"
PRIu64
" config:%"
PRId64
pMgmt
->
transId
,
cbMeta
.
code
,
cbMeta
.
index
,
cbMeta
.
term
,
syncStr
(
cbMeta
.
state
),
pRaw
);
" role:%s raw:%p"
,
transId
,
pMgmt
->
transId
,
cbMeta
.
code
,
cbMeta
.
index
,
cbMeta
.
term
,
cbMeta
.
lastConfigIndex
,
syncStr
(
cbMeta
.
state
),
pRaw
);
if
(
pMgmt
->
errCode
==
0
)
{
if
(
pMgmt
->
errCode
==
0
)
{
sdbWriteWithoutFree
(
pMnode
->
pSdb
,
pRaw
);
sdbWriteWithoutFree
(
pMnode
->
pSdb
,
pRaw
);
sdbSetApplyIndex
(
pMnode
->
pSdb
,
cbMeta
.
index
);
sdbSetApplyInfo
(
pMnode
->
pSdb
,
cbMeta
.
index
,
cbMeta
.
term
,
cbMeta
.
lastConfigIndex
);
sdbSetApplyTerm
(
pMnode
->
pSdb
,
cbMeta
.
term
);
}
}
if
(
pMgmt
->
transId
==
transId
)
{
if
(
pMgmt
->
transId
==
transId
)
{
...
@@ -68,36 +69,19 @@ void mndSyncCommitMsg(struct SSyncFSM *pFsm, const SRpcMsg *pMsg, SFsmCbMeta cbM
...
@@ -68,36 +69,19 @@ void mndSyncCommitMsg(struct SSyncFSM *pFsm, const SRpcMsg *pMsg, SFsmCbMeta cbM
mndReleaseTrans
(
pMnode
,
pTrans
);
mndReleaseTrans
(
pMnode
,
pTrans
);
}
}
if
(
cbMeta
.
index
-
sdbGetApplyIndex
(
pMnode
->
pSdb
)
>
100
)
{
sdbWriteFile
(
pMnode
->
pSdb
,
SDB_WRITE_DELTA
);
SSnapshotMeta
sMeta
=
{
0
};
// if (syncGetSnapshotMeta(pMnode->syncMgmt.sync, &sMeta) == 0) {
if
(
syncGetSnapshotMetaByIndex
(
pMnode
->
syncMgmt
.
sync
,
cbMeta
.
index
,
&
sMeta
)
==
0
)
{
sdbSetCurConfig
(
pMnode
->
pSdb
,
sMeta
.
lastConfigIndex
);
}
sdbWriteFile
(
pMnode
->
pSdb
);
}
}
}
}
}
int32_t
mndSyncGetSnapshot
(
struct
SSyncFSM
*
pFsm
,
SSnapshot
*
pSnapshot
)
{
int32_t
mndSyncGetSnapshot
(
struct
SSyncFSM
*
pFsm
,
SSnapshot
*
pSnapshot
)
{
SMnode
*
pMnode
=
pFsm
->
data
;
SMnode
*
pMnode
=
pFsm
->
data
;
pSnapshot
->
lastApplyIndex
=
sdbGetCommitIndex
(
pMnode
->
pSdb
);
sdbGetCommitInfo
(
pMnode
->
pSdb
,
&
pSnapshot
->
lastApplyIndex
,
&
pSnapshot
->
lastApplyTerm
,
&
pSnapshot
->
lastConfigIndex
);
pSnapshot
->
lastApplyTerm
=
sdbGetCommitTerm
(
pMnode
->
pSdb
);
pSnapshot
->
lastConfigIndex
=
sdbGetCurConfig
(
pMnode
->
pSdb
);
return
0
;
return
0
;
}
}
void
mndRestoreFinish
(
struct
SSyncFSM
*
pFsm
)
{
void
mndRestoreFinish
(
struct
SSyncFSM
*
pFsm
)
{
SMnode
*
pMnode
=
pFsm
->
data
;
SMnode
*
pMnode
=
pFsm
->
data
;
SSnapshotMeta
sMeta
=
{
0
};
// if (syncGetSnapshotMeta(pMnode->syncMgmt.sync, &sMeta) == 0) {
SyncIndex
snapshotIndex
=
sdbGetApplyIndex
(
pMnode
->
pSdb
);
if
(
syncGetSnapshotMetaByIndex
(
pMnode
->
syncMgmt
.
sync
,
snapshotIndex
,
&
sMeta
)
==
0
)
{
sdbSetCurConfig
(
pMnode
->
pSdb
,
sMeta
.
lastConfigIndex
);
}
if
(
!
pMnode
->
deploy
)
{
if
(
!
pMnode
->
deploy
)
{
mInfo
(
"mnode sync restore finished, and will handle outstanding transactions"
);
mInfo
(
"mnode sync restore finished, and will handle outstanding transactions"
);
mndTransPullup
(
pMnode
);
mndTransPullup
(
pMnode
);
...
...
source/dnode/mnode/impl/src/mndTopic.c
浏览文件 @
2e590c30
...
@@ -566,7 +566,7 @@ static int32_t mndProcessDropTopicReq(SRpcMsg *pReq) {
...
@@ -566,7 +566,7 @@ static int32_t mndProcessDropTopicReq(SRpcMsg *pReq) {
#endif
#endif
STrans
*
pTrans
=
mndTransCreate
(
pMnode
,
TRN_POLICY_ROLLBACK
,
TRN_CONFLICT_DB_INSIDE
,
pReq
);
STrans
*
pTrans
=
mndTransCreate
(
pMnode
,
TRN_POLICY_ROLLBACK
,
TRN_CONFLICT_DB_INSIDE
,
pReq
);
mndTransSetDbName
(
pTrans
,
pTopic
->
db
);
mndTransSetDbName
(
pTrans
,
pTopic
->
db
,
NULL
);
if
(
pTrans
==
NULL
)
{
if
(
pTrans
==
NULL
)
{
mError
(
"topic:%s, failed to drop since %s"
,
pTopic
->
name
,
terrstr
());
mError
(
"topic:%s, failed to drop since %s"
,
pTopic
->
name
,
terrstr
());
return
-
1
;
return
-
1
;
...
...
source/dnode/mnode/impl/src/mndTrans.c
浏览文件 @
2e590c30
...
@@ -22,8 +22,8 @@
...
@@ -22,8 +22,8 @@
#include "mndSync.h"
#include "mndSync.h"
#include "mndUser.h"
#include "mndUser.h"
#define TRANS_VER_NUMBER 1
#define TRANS_VER_NUMBER
1
#define TRANS_ARRAY_SIZE 8
#define TRANS_ARRAY_SIZE
8
#define TRANS_RESERVE_SIZE 64
#define TRANS_RESERVE_SIZE 64
static
SSdbRaw
*
mndTransActionEncode
(
STrans
*
pTrans
);
static
SSdbRaw
*
mndTransActionEncode
(
STrans
*
pTrans
);
...
@@ -52,7 +52,7 @@ static bool mndTransPerformCommitActionStage(SMnode *pMnode, STrans *pTrans);
...
@@ -52,7 +52,7 @@ static bool mndTransPerformCommitActionStage(SMnode *pMnode, STrans *pTrans);
static
bool
mndTransPerformCommitStage
(
SMnode
*
pMnode
,
STrans
*
pTrans
);
static
bool
mndTransPerformCommitStage
(
SMnode
*
pMnode
,
STrans
*
pTrans
);
static
bool
mndTransPerformRollbackStage
(
SMnode
*
pMnode
,
STrans
*
pTrans
);
static
bool
mndTransPerformRollbackStage
(
SMnode
*
pMnode
,
STrans
*
pTrans
);
static
bool
mndTransPerfromFinishedStage
(
SMnode
*
pMnode
,
STrans
*
pTrans
);
static
bool
mndTransPerfromFinishedStage
(
SMnode
*
pMnode
,
STrans
*
pTrans
);
static
bool
mndCantExecuteTransAction
(
SMnode
*
pMnode
)
{
return
!
pMnode
->
deploy
&&
!
mndIsMaster
(
pMnode
);
}
static
bool
mndCan
no
tExecuteTransAction
(
SMnode
*
pMnode
)
{
return
!
pMnode
->
deploy
&&
!
mndIsMaster
(
pMnode
);
}
static
void
mndTransSendRpcRsp
(
SMnode
*
pMnode
,
STrans
*
pTrans
);
static
void
mndTransSendRpcRsp
(
SMnode
*
pMnode
,
STrans
*
pTrans
);
static
int32_t
mndProcessTransReq
(
SRpcMsg
*
pReq
);
static
int32_t
mndProcessTransReq
(
SRpcMsg
*
pReq
);
...
@@ -122,7 +122,8 @@ static SSdbRaw *mndTransActionEncode(STrans *pTrans) {
...
@@ -122,7 +122,8 @@ static SSdbRaw *mndTransActionEncode(STrans *pTrans) {
SDB_SET_INT8
(
pRaw
,
dataPos
,
pTrans
->
conflict
,
_OVER
)
SDB_SET_INT8
(
pRaw
,
dataPos
,
pTrans
->
conflict
,
_OVER
)
SDB_SET_INT8
(
pRaw
,
dataPos
,
pTrans
->
exec
,
_OVER
)
SDB_SET_INT8
(
pRaw
,
dataPos
,
pTrans
->
exec
,
_OVER
)
SDB_SET_INT64
(
pRaw
,
dataPos
,
pTrans
->
createdTime
,
_OVER
)
SDB_SET_INT64
(
pRaw
,
dataPos
,
pTrans
->
createdTime
,
_OVER
)
SDB_SET_BINARY
(
pRaw
,
dataPos
,
pTrans
->
dbname
,
TSDB_DB_FNAME_LEN
,
_OVER
)
SDB_SET_BINARY
(
pRaw
,
dataPos
,
pTrans
->
dbname1
,
TSDB_DB_FNAME_LEN
,
_OVER
)
SDB_SET_BINARY
(
pRaw
,
dataPos
,
pTrans
->
dbname2
,
TSDB_DB_FNAME_LEN
,
_OVER
)
SDB_SET_INT32
(
pRaw
,
dataPos
,
pTrans
->
redoActionPos
,
_OVER
)
SDB_SET_INT32
(
pRaw
,
dataPos
,
pTrans
->
redoActionPos
,
_OVER
)
int32_t
redoActionNum
=
taosArrayGetSize
(
pTrans
->
redoActions
);
int32_t
redoActionNum
=
taosArrayGetSize
(
pTrans
->
redoActions
);
...
@@ -270,7 +271,8 @@ static SSdbRow *mndTransActionDecode(SSdbRaw *pRaw) {
...
@@ -270,7 +271,8 @@ static SSdbRow *mndTransActionDecode(SSdbRaw *pRaw) {
pTrans
->
conflict
=
conflict
;
pTrans
->
conflict
=
conflict
;
pTrans
->
exec
=
exec
;
pTrans
->
exec
=
exec
;
SDB_GET_INT64
(
pRaw
,
dataPos
,
&
pTrans
->
createdTime
,
_OVER
)
SDB_GET_INT64
(
pRaw
,
dataPos
,
&
pTrans
->
createdTime
,
_OVER
)
SDB_GET_BINARY
(
pRaw
,
dataPos
,
pTrans
->
dbname
,
TSDB_DB_FNAME_LEN
,
_OVER
)
SDB_GET_BINARY
(
pRaw
,
dataPos
,
pTrans
->
dbname1
,
TSDB_DB_FNAME_LEN
,
_OVER
)
SDB_GET_BINARY
(
pRaw
,
dataPos
,
pTrans
->
dbname2
,
TSDB_DB_FNAME_LEN
,
_OVER
)
SDB_GET_INT32
(
pRaw
,
dataPos
,
&
pTrans
->
redoActionPos
,
_OVER
)
SDB_GET_INT32
(
pRaw
,
dataPos
,
&
pTrans
->
redoActionPos
,
_OVER
)
SDB_GET_INT32
(
pRaw
,
dataPos
,
&
redoActionNum
,
_OVER
)
SDB_GET_INT32
(
pRaw
,
dataPos
,
&
redoActionNum
,
_OVER
)
SDB_GET_INT32
(
pRaw
,
dataPos
,
&
undoActionNum
,
_OVER
)
SDB_GET_INT32
(
pRaw
,
dataPos
,
&
undoActionNum
,
_OVER
)
...
@@ -521,9 +523,10 @@ static int32_t mndTransActionUpdate(SSdb *pSdb, STrans *pOld, STrans *pNew) {
...
@@ -521,9 +523,10 @@ static int32_t mndTransActionUpdate(SSdb *pSdb, STrans *pOld, STrans *pNew) {
}
}
if
(
pOld
->
stage
==
TRN_STAGE_ROLLBACK
)
{
if
(
pOld
->
stage
==
TRN_STAGE_ROLLBACK
)
{
pOld
->
stage
=
TRN_STAGE_
FINISHED
;
pOld
->
stage
=
TRN_STAGE_
REDO_ACTION
;
mTrace
(
"trans:%d, stage from rollback to
finished
since perform update action"
,
pNew
->
id
);
mTrace
(
"trans:%d, stage from rollback to
undoAction
since perform update action"
,
pNew
->
id
);
}
}
return
0
;
return
0
;
}
}
...
@@ -649,7 +652,14 @@ void mndTransSetCb(STrans *pTrans, ETrnFunc startFunc, ETrnFunc stopFunc, void *
...
@@ -649,7 +652,14 @@ void mndTransSetCb(STrans *pTrans, ETrnFunc startFunc, ETrnFunc stopFunc, void *
pTrans
->
paramLen
=
paramLen
;
pTrans
->
paramLen
=
paramLen
;
}
}
void
mndTransSetDbName
(
STrans
*
pTrans
,
const
char
*
dbname
)
{
memcpy
(
pTrans
->
dbname
,
dbname
,
TSDB_DB_FNAME_LEN
);
}
void
mndTransSetDbName
(
STrans
*
pTrans
,
const
char
*
dbname1
,
const
char
*
dbname2
)
{
if
(
dbname1
!=
NULL
)
{
memcpy
(
pTrans
->
dbname1
,
dbname1
,
TSDB_DB_FNAME_LEN
);
}
if
(
dbname2
!=
NULL
)
{
memcpy
(
pTrans
->
dbname2
,
dbname2
,
TSDB_DB_FNAME_LEN
);
}
}
void
mndTransSetSerial
(
STrans
*
pTrans
)
{
pTrans
->
exec
=
TRN_EXEC_SERIAL
;
}
void
mndTransSetSerial
(
STrans
*
pTrans
)
{
pTrans
->
exec
=
TRN_EXEC_SERIAL
;
}
...
@@ -674,6 +684,12 @@ static int32_t mndTransSync(SMnode *pMnode, STrans *pTrans) {
...
@@ -674,6 +684,12 @@ static int32_t mndTransSync(SMnode *pMnode, STrans *pTrans) {
return
0
;
return
0
;
}
}
static
bool
mndCheckDbConflict
(
const
char
*
db
,
STrans
*
pTrans
)
{
if
(
db
[
0
]
==
0
)
return
false
;
if
(
strcmp
(
db
,
pTrans
->
dbname1
)
==
0
||
strcmp
(
db
,
pTrans
->
dbname2
)
==
0
)
return
true
;
return
false
;
}
static
bool
mndCheckTransConflict
(
SMnode
*
pMnode
,
STrans
*
pNew
)
{
static
bool
mndCheckTransConflict
(
SMnode
*
pMnode
,
STrans
*
pNew
)
{
STrans
*
pTrans
=
NULL
;
STrans
*
pTrans
=
NULL
;
void
*
pIter
=
NULL
;
void
*
pIter
=
NULL
;
...
@@ -688,14 +704,21 @@ static bool mndCheckTransConflict(SMnode *pMnode, STrans *pNew) {
...
@@ -688,14 +704,21 @@ static bool mndCheckTransConflict(SMnode *pMnode, STrans *pNew) {
if
(
pNew
->
conflict
==
TRN_CONFLICT_GLOBAL
)
conflict
=
true
;
if
(
pNew
->
conflict
==
TRN_CONFLICT_GLOBAL
)
conflict
=
true
;
if
(
pNew
->
conflict
==
TRN_CONFLICT_DB
)
{
if
(
pNew
->
conflict
==
TRN_CONFLICT_DB
)
{
if
(
pTrans
->
conflict
==
TRN_CONFLICT_GLOBAL
)
conflict
=
true
;
if
(
pTrans
->
conflict
==
TRN_CONFLICT_GLOBAL
)
conflict
=
true
;
if
(
pTrans
->
conflict
==
TRN_CONFLICT_DB
&&
strcmp
(
pNew
->
dbname
,
pTrans
->
dbname
)
==
0
)
conflict
=
true
;
if
(
pTrans
->
conflict
==
TRN_CONFLICT_DB
||
pTrans
->
conflict
==
TRN_CONFLICT_DB_INSIDE
)
{
if
(
pTrans
->
conflict
==
TRN_CONFLICT_DB_INSIDE
&&
strcmp
(
pNew
->
dbname
,
pTrans
->
dbname
)
==
0
)
conflict
=
true
;
if
(
mndCheckDbConflict
(
pNew
->
dbname1
,
pTrans
))
conflict
=
true
;
if
(
mndCheckDbConflict
(
pNew
->
dbname2
,
pTrans
))
conflict
=
true
;
}
}
}
if
(
pNew
->
conflict
==
TRN_CONFLICT_DB_INSIDE
)
{
if
(
pNew
->
conflict
==
TRN_CONFLICT_DB_INSIDE
)
{
if
(
pTrans
->
conflict
==
TRN_CONFLICT_GLOBAL
)
conflict
=
true
;
if
(
pTrans
->
conflict
==
TRN_CONFLICT_GLOBAL
)
conflict
=
true
;
if
(
pTrans
->
conflict
==
TRN_CONFLICT_DB
&&
strcmp
(
pNew
->
dbname
,
pTrans
->
dbname
)
==
0
)
conflict
=
true
;
if
(
pTrans
->
conflict
==
TRN_CONFLICT_DB
)
{
if
(
mndCheckDbConflict
(
pNew
->
dbname1
,
pTrans
))
conflict
=
true
;
if
(
mndCheckDbConflict
(
pNew
->
dbname2
,
pTrans
))
conflict
=
true
;
}
}
}
mError
(
"trans:%d, can't execute since conflict with trans:%d, db:%s"
,
pNew
->
id
,
pTrans
->
id
,
pTrans
->
dbname
);
mError
(
"trans:%d, can't execute since conflict with trans:%d, db1:%s db2:%s"
,
pNew
->
id
,
pTrans
->
id
,
pTrans
->
dbname1
,
pTrans
->
dbname2
);
sdbRelease
(
pMnode
->
pSdb
,
pTrans
);
sdbRelease
(
pMnode
->
pSdb
,
pTrans
);
}
}
...
@@ -704,7 +727,7 @@ static bool mndCheckTransConflict(SMnode *pMnode, STrans *pNew) {
...
@@ -704,7 +727,7 @@ static bool mndCheckTransConflict(SMnode *pMnode, STrans *pNew) {
int32_t
mndTransPrepare
(
SMnode
*
pMnode
,
STrans
*
pTrans
)
{
int32_t
mndTransPrepare
(
SMnode
*
pMnode
,
STrans
*
pTrans
)
{
if
(
pTrans
->
conflict
==
TRN_CONFLICT_DB
||
pTrans
->
conflict
==
TRN_CONFLICT_DB_INSIDE
)
{
if
(
pTrans
->
conflict
==
TRN_CONFLICT_DB
||
pTrans
->
conflict
==
TRN_CONFLICT_DB_INSIDE
)
{
if
(
strlen
(
pTrans
->
dbname
)
==
0
)
{
if
(
strlen
(
pTrans
->
dbname
1
)
==
0
&&
strlen
(
pTrans
->
dbname2
)
==
0
)
{
terrno
=
TSDB_CODE_MND_TRANS_CONFLICT
;
terrno
=
TSDB_CODE_MND_TRANS_CONFLICT
;
mError
(
"trans:%d, failed to prepare conflict db not set"
,
pTrans
->
id
);
mError
(
"trans:%d, failed to prepare conflict db not set"
,
pTrans
->
id
);
return
-
1
;
return
-
1
;
...
@@ -915,7 +938,7 @@ static int32_t mndTransWriteSingleLog(SMnode *pMnode, STrans *pTrans, STransActi
...
@@ -915,7 +938,7 @@ static int32_t mndTransWriteSingleLog(SMnode *pMnode, STrans *pTrans, STransActi
static
int32_t
mndTransSendSingleMsg
(
SMnode
*
pMnode
,
STrans
*
pTrans
,
STransAction
*
pAction
)
{
static
int32_t
mndTransSendSingleMsg
(
SMnode
*
pMnode
,
STrans
*
pTrans
,
STransAction
*
pAction
)
{
if
(
pAction
->
msgSent
)
return
0
;
if
(
pAction
->
msgSent
)
return
0
;
if
(
mndCantExecuteTransAction
(
pMnode
))
return
-
1
;
if
(
mndCan
no
tExecuteTransAction
(
pMnode
))
return
-
1
;
int64_t
signature
=
pTrans
->
id
;
int64_t
signature
=
pTrans
->
id
;
signature
=
(
signature
<<
32
);
signature
=
(
signature
<<
32
);
...
@@ -1115,7 +1138,7 @@ static int32_t mndTransExecuteRedoActionsSerial(SMnode *pMnode, STrans *pTrans)
...
@@ -1115,7 +1138,7 @@ static int32_t mndTransExecuteRedoActionsSerial(SMnode *pMnode, STrans *pTrans)
pTrans
->
lastEpset
=
pAction
->
epSet
;
pTrans
->
lastEpset
=
pAction
->
epSet
;
}
}
if
(
mndCantExecuteTransAction
(
pMnode
))
break
;
if
(
mndCan
no
tExecuteTransAction
(
pMnode
))
break
;
if
(
code
==
0
)
{
if
(
code
==
0
)
{
pTrans
->
code
=
0
;
pTrans
->
code
=
0
;
...
@@ -1158,7 +1181,7 @@ static bool mndTransPerformRedoActionStage(SMnode *pMnode, STrans *pTrans) {
...
@@ -1158,7 +1181,7 @@ static bool mndTransPerformRedoActionStage(SMnode *pMnode, STrans *pTrans) {
code
=
mndTransExecuteRedoActions
(
pMnode
,
pTrans
);
code
=
mndTransExecuteRedoActions
(
pMnode
,
pTrans
);
}
}
if
(
mndCantExecuteTransAction
(
pMnode
))
return
false
;
if
(
mndCan
no
tExecuteTransAction
(
pMnode
))
return
false
;
if
(
code
==
0
)
{
if
(
code
==
0
)
{
pTrans
->
code
=
0
;
pTrans
->
code
=
0
;
...
@@ -1171,8 +1194,8 @@ static bool mndTransPerformRedoActionStage(SMnode *pMnode, STrans *pTrans) {
...
@@ -1171,8 +1194,8 @@ static bool mndTransPerformRedoActionStage(SMnode *pMnode, STrans *pTrans) {
}
else
{
}
else
{
pTrans
->
code
=
terrno
;
pTrans
->
code
=
terrno
;
if
(
pTrans
->
policy
==
TRN_POLICY_ROLLBACK
)
{
if
(
pTrans
->
policy
==
TRN_POLICY_ROLLBACK
)
{
pTrans
->
stage
=
TRN_STAGE_
UNDO_ACTION
;
pTrans
->
stage
=
TRN_STAGE_
ROLLBACK
;
mError
(
"trans:%d, stage from redoAction to
undoAction
since %s"
,
pTrans
->
id
,
terrstr
());
mError
(
"trans:%d, stage from redoAction to
rollback
since %s"
,
pTrans
->
id
,
terrstr
());
continueExec
=
true
;
continueExec
=
true
;
}
else
{
}
else
{
pTrans
->
failedTimes
++
;
pTrans
->
failedTimes
++
;
...
@@ -1185,7 +1208,7 @@ static bool mndTransPerformRedoActionStage(SMnode *pMnode, STrans *pTrans) {
...
@@ -1185,7 +1208,7 @@ static bool mndTransPerformRedoActionStage(SMnode *pMnode, STrans *pTrans) {
}
}
static
bool
mndTransPerformCommitStage
(
SMnode
*
pMnode
,
STrans
*
pTrans
)
{
static
bool
mndTransPerformCommitStage
(
SMnode
*
pMnode
,
STrans
*
pTrans
)
{
if
(
mndCantExecuteTransAction
(
pMnode
))
return
false
;
if
(
mndCan
no
tExecuteTransAction
(
pMnode
))
return
false
;
bool
continueExec
=
true
;
bool
continueExec
=
true
;
int32_t
code
=
mndTransCommit
(
pMnode
,
pTrans
);
int32_t
code
=
mndTransCommit
(
pMnode
,
pTrans
);
...
@@ -1197,16 +1220,9 @@ static bool mndTransPerformCommitStage(SMnode *pMnode, STrans *pTrans) {
...
@@ -1197,16 +1220,9 @@ static bool mndTransPerformCommitStage(SMnode *pMnode, STrans *pTrans) {
continueExec
=
true
;
continueExec
=
true
;
}
else
{
}
else
{
pTrans
->
code
=
terrno
;
pTrans
->
code
=
terrno
;
if
(
pTrans
->
policy
==
TRN_POLICY_ROLLBACK
)
{
pTrans
->
failedTimes
++
;
pTrans
->
stage
=
TRN_STAGE_UNDO_ACTION
;
mError
(
"trans:%d, stage keep on commit since %s, failedTimes:%d"
,
pTrans
->
id
,
terrstr
(),
pTrans
->
failedTimes
);
mError
(
"trans:%d, stage from commit to undoAction since %s, failedTimes:%d"
,
pTrans
->
id
,
terrstr
(),
continueExec
=
false
;
pTrans
->
failedTimes
);
continueExec
=
true
;
}
else
{
pTrans
->
failedTimes
++
;
mError
(
"trans:%d, stage keep on commit since %s, failedTimes:%d"
,
pTrans
->
id
,
terrstr
(),
pTrans
->
failedTimes
);
continueExec
=
false
;
}
}
}
return
continueExec
;
return
continueExec
;
...
@@ -1235,11 +1251,9 @@ static bool mndTransPerformUndoActionStage(SMnode *pMnode, STrans *pTrans) {
...
@@ -1235,11 +1251,9 @@ static bool mndTransPerformUndoActionStage(SMnode *pMnode, STrans *pTrans) {
bool
continueExec
=
true
;
bool
continueExec
=
true
;
int32_t
code
=
mndTransExecuteUndoActions
(
pMnode
,
pTrans
);
int32_t
code
=
mndTransExecuteUndoActions
(
pMnode
,
pTrans
);
if
(
mndCantExecuteTransAction
(
pMnode
))
return
false
;
if
(
code
==
0
)
{
if
(
code
==
0
)
{
pTrans
->
stage
=
TRN_STAGE_
ROLLBACK
;
pTrans
->
stage
=
TRN_STAGE_
FINISHED
;
mDebug
(
"trans:%d, stage from undoAction to
rollback
"
,
pTrans
->
id
);
mDebug
(
"trans:%d, stage from undoAction to
finished
"
,
pTrans
->
id
);
continueExec
=
true
;
continueExec
=
true
;
}
else
if
(
code
==
TSDB_CODE_ACTION_IN_PROGRESS
)
{
}
else
if
(
code
==
TSDB_CODE_ACTION_IN_PROGRESS
)
{
mDebug
(
"trans:%d, stage keep on undoAction since %s"
,
pTrans
->
id
,
tstrerror
(
code
));
mDebug
(
"trans:%d, stage keep on undoAction since %s"
,
pTrans
->
id
,
tstrerror
(
code
));
...
@@ -1254,14 +1268,14 @@ static bool mndTransPerformUndoActionStage(SMnode *pMnode, STrans *pTrans) {
...
@@ -1254,14 +1268,14 @@ static bool mndTransPerformUndoActionStage(SMnode *pMnode, STrans *pTrans) {
}
}
static
bool
mndTransPerformRollbackStage
(
SMnode
*
pMnode
,
STrans
*
pTrans
)
{
static
bool
mndTransPerformRollbackStage
(
SMnode
*
pMnode
,
STrans
*
pTrans
)
{
if
(
mndCantExecuteTransAction
(
pMnode
))
return
false
;
if
(
mndCan
no
tExecuteTransAction
(
pMnode
))
return
false
;
bool
continueExec
=
true
;
bool
continueExec
=
true
;
int32_t
code
=
mndTransRollback
(
pMnode
,
pTrans
);
int32_t
code
=
mndTransRollback
(
pMnode
,
pTrans
);
if
(
code
==
0
)
{
if
(
code
==
0
)
{
pTrans
->
stage
=
TRN_STAGE_
FINISHED
;
pTrans
->
stage
=
TRN_STAGE_
UNDO_ACTION
;
mDebug
(
"trans:%d, stage from rollback to
finished
"
,
pTrans
->
id
);
mDebug
(
"trans:%d, stage from rollback to
undoAction
"
,
pTrans
->
id
);
continueExec
=
true
;
continueExec
=
true
;
}
else
{
}
else
{
pTrans
->
failedTimes
++
;
pTrans
->
failedTimes
++
;
...
@@ -1309,12 +1323,12 @@ void mndTransExecute(SMnode *pMnode, STrans *pTrans) {
...
@@ -1309,12 +1323,12 @@ void mndTransExecute(SMnode *pMnode, STrans *pTrans) {
case
TRN_STAGE_COMMIT_ACTION
:
case
TRN_STAGE_COMMIT_ACTION
:
continueExec
=
mndTransPerformCommitActionStage
(
pMnode
,
pTrans
);
continueExec
=
mndTransPerformCommitActionStage
(
pMnode
,
pTrans
);
break
;
break
;
case
TRN_STAGE_UNDO_ACTION
:
continueExec
=
mndTransPerformUndoActionStage
(
pMnode
,
pTrans
);
break
;
case
TRN_STAGE_ROLLBACK
:
case
TRN_STAGE_ROLLBACK
:
continueExec
=
mndTransPerformRollbackStage
(
pMnode
,
pTrans
);
continueExec
=
mndTransPerformRollbackStage
(
pMnode
,
pTrans
);
break
;
break
;
case
TRN_STAGE_UNDO_ACTION
:
continueExec
=
mndTransPerformUndoActionStage
(
pMnode
,
pTrans
);
break
;
case
TRN_STAGE_FINISHED
:
case
TRN_STAGE_FINISHED
:
continueExec
=
mndTransPerfromFinishedStage
(
pMnode
,
pTrans
);
continueExec
=
mndTransPerfromFinishedStage
(
pMnode
,
pTrans
);
break
;
break
;
...
@@ -1416,13 +1430,8 @@ void mndTransPullup(SMnode *pMnode) {
...
@@ -1416,13 +1430,8 @@ void mndTransPullup(SMnode *pMnode) {
mndReleaseTrans
(
pMnode
,
pTrans
);
mndReleaseTrans
(
pMnode
,
pTrans
);
}
}
SSnapshotMeta
sMeta
=
{
0
};
// todo, set to SDB_WRITE_DELTA
// if (syncGetSnapshotMeta(pMnode->syncMgmt.sync, &sMeta) == 0) {
sdbWriteFile
(
pMnode
->
pSdb
,
0
);
SyncIndex
snapshotIndex
=
sdbGetApplyIndex
(
pMnode
->
pSdb
);
if
(
syncGetSnapshotMetaByIndex
(
pMnode
->
syncMgmt
.
sync
,
snapshotIndex
,
&
sMeta
)
==
0
)
{
sdbSetCurConfig
(
pMnode
->
pSdb
,
sMeta
.
lastConfigIndex
);
}
sdbWriteFile
(
pMnode
->
pSdb
);
taosArrayDestroy
(
pArray
);
taosArrayDestroy
(
pArray
);
}
}
...
@@ -1451,10 +1460,15 @@ static int32_t mndRetrieveTrans(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pBl
...
@@ -1451,10 +1460,15 @@ static int32_t mndRetrieveTrans(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pBl
pColInfo
=
taosArrayGet
(
pBlock
->
pDataBlock
,
cols
++
);
pColInfo
=
taosArrayGet
(
pBlock
->
pDataBlock
,
cols
++
);
colDataAppend
(
pColInfo
,
numOfRows
,
(
const
char
*
)
stage
,
false
);
colDataAppend
(
pColInfo
,
numOfRows
,
(
const
char
*
)
stage
,
false
);
char
dbname
[
TSDB_DB_NAME_LEN
+
VARSTR_HEADER_SIZE
]
=
{
0
};
char
dbname1
[
TSDB_DB_NAME_LEN
+
VARSTR_HEADER_SIZE
]
=
{
0
};
STR_WITH_MAXSIZE_TO_VARSTR
(
dbname
,
mndGetDbStr
(
pTrans
->
dbname
),
pShow
->
pMeta
->
pSchemas
[
cols
].
bytes
);
STR_WITH_MAXSIZE_TO_VARSTR
(
dbname1
,
mndGetDbStr
(
pTrans
->
dbname1
),
pShow
->
pMeta
->
pSchemas
[
cols
].
bytes
);
pColInfo
=
taosArrayGet
(
pBlock
->
pDataBlock
,
cols
++
);
colDataAppend
(
pColInfo
,
numOfRows
,
(
const
char
*
)
dbname1
,
false
);
char
dbname2
[
TSDB_DB_NAME_LEN
+
VARSTR_HEADER_SIZE
]
=
{
0
};
STR_WITH_MAXSIZE_TO_VARSTR
(
dbname2
,
mndGetDbStr
(
pTrans
->
dbname2
),
pShow
->
pMeta
->
pSchemas
[
cols
].
bytes
);
pColInfo
=
taosArrayGet
(
pBlock
->
pDataBlock
,
cols
++
);
pColInfo
=
taosArrayGet
(
pBlock
->
pDataBlock
,
cols
++
);
colDataAppend
(
pColInfo
,
numOfRows
,
(
const
char
*
)
dbname
,
false
);
colDataAppend
(
pColInfo
,
numOfRows
,
(
const
char
*
)
dbname
2
,
false
);
pColInfo
=
taosArrayGet
(
pBlock
->
pDataBlock
,
cols
++
);
pColInfo
=
taosArrayGet
(
pBlock
->
pDataBlock
,
cols
++
);
colDataAppend
(
pColInfo
,
numOfRows
,
(
const
char
*
)
&
pTrans
->
failedTimes
,
false
);
colDataAppend
(
pColInfo
,
numOfRows
,
(
const
char
*
)
&
pTrans
->
failedTimes
,
false
);
...
...
source/dnode/mnode/impl/test/sdb/sdbTest.cpp
浏览文件 @
2e590c30
...
@@ -493,8 +493,11 @@ TEST_F(MndTestSdb, 01_Write_Str) {
...
@@ -493,8 +493,11 @@ TEST_F(MndTestSdb, 01_Write_Str) {
ASSERT_EQ
(
sdbGetSize
(
pSdb
,
SDB_USER
),
2
);
ASSERT_EQ
(
sdbGetSize
(
pSdb
,
SDB_USER
),
2
);
ASSERT_EQ
(
sdbGetMaxId
(
pSdb
,
SDB_USER
),
-
1
);
ASSERT_EQ
(
sdbGetMaxId
(
pSdb
,
SDB_USER
),
-
1
);
ASSERT_EQ
(
sdbGetTableVer
(
pSdb
,
SDB_USER
),
2
);
ASSERT_EQ
(
sdbGetTableVer
(
pSdb
,
SDB_USER
),
2
);
sdbSetApplyIndex
(
pSdb
,
-
1
);
sdbSetApplyInfo
(
pSdb
,
-
1
,
-
1
,
-
1
);
ASSERT_EQ
(
sdbGetApplyIndex
(
pSdb
),
-
1
);
// int64_t index, config;
// int64_t term;
// sdbGetCommitInfo(pSdb, &index, &term, &config);
// ASSERT_EQ(index, -1);
ASSERT_EQ
(
mnode
.
insertTimes
,
2
);
ASSERT_EQ
(
mnode
.
insertTimes
,
2
);
ASSERT_EQ
(
mnode
.
deleteTimes
,
0
);
ASSERT_EQ
(
mnode
.
deleteTimes
,
0
);
...
@@ -700,11 +703,12 @@ TEST_F(MndTestSdb, 01_Write_Str) {
...
@@ -700,11 +703,12 @@ TEST_F(MndTestSdb, 01_Write_Str) {
}
}
// write version
// write version
sdbSetApplyIndex
(
pSdb
,
0
);
sdbSetApplyInfo
(
pSdb
,
0
,
0
,
0
);
sdbSetApplyIndex
(
pSdb
,
1
);
sdbSetApplyInfo
(
pSdb
,
1
,
0
,
0
);
ASSERT_EQ
(
sdbGetApplyIndex
(
pSdb
),
1
);
// sdbGetApplyInfo(pSdb, &index, &term, &config);
ASSERT_EQ
(
sdbWriteFile
(
pSdb
),
0
);
// ASSERT_EQ(index, 1);
ASSERT_EQ
(
sdbWriteFile
(
pSdb
),
0
);
ASSERT_EQ
(
sdbWriteFile
(
pSdb
,
0
),
0
);
ASSERT_EQ
(
sdbWriteFile
(
pSdb
,
0
),
0
);
sdbCleanup
(
pSdb
);
sdbCleanup
(
pSdb
);
ASSERT_EQ
(
mnode
.
insertTimes
,
7
);
ASSERT_EQ
(
mnode
.
insertTimes
,
7
);
...
@@ -772,7 +776,11 @@ TEST_F(MndTestSdb, 01_Read_Str) {
...
@@ -772,7 +776,11 @@ TEST_F(MndTestSdb, 01_Read_Str) {
ASSERT_EQ
(
sdbGetSize
(
pSdb
,
SDB_USER
),
2
);
ASSERT_EQ
(
sdbGetSize
(
pSdb
,
SDB_USER
),
2
);
ASSERT_EQ
(
sdbGetMaxId
(
pSdb
,
SDB_USER
),
-
1
);
ASSERT_EQ
(
sdbGetMaxId
(
pSdb
,
SDB_USER
),
-
1
);
ASSERT_EQ
(
sdbGetTableVer
(
pSdb
,
SDB_USER
),
5
);
ASSERT_EQ
(
sdbGetTableVer
(
pSdb
,
SDB_USER
),
5
);
ASSERT_EQ
(
sdbGetApplyIndex
(
pSdb
),
1
);
int64_t
index
,
config
;
int64_t
term
;
sdbGetCommitInfo
(
pSdb
,
&
index
,
&
term
,
&
config
);
ASSERT_EQ
(
index
,
1
);
ASSERT_EQ
(
mnode
.
insertTimes
,
4
);
ASSERT_EQ
(
mnode
.
insertTimes
,
4
);
ASSERT_EQ
(
mnode
.
deleteTimes
,
0
);
ASSERT_EQ
(
mnode
.
deleteTimes
,
0
);
...
...
source/dnode/mnode/impl/test/trans/trans2.cpp
浏览文件 @
2e590c30
...
@@ -128,7 +128,7 @@ class MndTestTrans2 : public ::testing::Test {
...
@@ -128,7 +128,7 @@ class MndTestTrans2 : public ::testing::Test {
mndTransSetCb(pTrans, TRANS_START_FUNC_TEST, TRANS_STOP_FUNC_TEST, param, strlen(param) + 1);
mndTransSetCb(pTrans, TRANS_START_FUNC_TEST, TRANS_STOP_FUNC_TEST, param, strlen(param) + 1);
if (pDb != NULL) {
if (pDb != NULL) {
mndTransSetDbName(pTrans, pDb->name);
mndTransSetDbName(pTrans, pDb->name
, NULL
);
}
}
int32_t code = mndTransPrepare(pMnode, pTrans);
int32_t code = mndTransPrepare(pMnode, pTrans);
...
@@ -201,7 +201,7 @@ class MndTestTrans2 : public ::testing::Test {
...
@@ -201,7 +201,7 @@ class MndTestTrans2 : public ::testing::Test {
}
}
if (pDb != NULL) {
if (pDb != NULL) {
mndTransSetDbName(pTrans, pDb->name);
mndTransSetDbName(pTrans, pDb->name
, NULL
);
}
}
int32_t code = mndTransPrepare(pMnode, pTrans);
int32_t code = mndTransPrepare(pMnode, pTrans);
...
...
source/dnode/mnode/sdb/inc/sdb.h
浏览文件 @
2e590c30
...
@@ -37,6 +37,8 @@ extern "C" {
...
@@ -37,6 +37,8 @@ extern "C" {
#define mTrace(...) { if (mDebugFlag & DEBUG_TRACE) { taosPrintLog("MND ", DEBUG_TRACE, mDebugFlag, __VA_ARGS__); }}
#define mTrace(...) { if (mDebugFlag & DEBUG_TRACE) { taosPrintLog("MND ", DEBUG_TRACE, mDebugFlag, __VA_ARGS__); }}
// clang-format on
// clang-format on
#define SDB_WRITE_DELTA 100
#define SDB_GET_VAL(pData, dataPos, val, pos, func, type) \
#define SDB_GET_VAL(pData, dataPos, val, pos, func, type) \
{ \
{ \
if (func(pRaw, dataPos, val) != 0) { \
if (func(pRaw, dataPos, val) != 0) { \
...
@@ -169,11 +171,12 @@ typedef struct SSdb {
...
@@ -169,11 +171,12 @@ typedef struct SSdb {
SWal
*
pWal
;
SWal
*
pWal
;
char
*
currDir
;
char
*
currDir
;
char
*
tmpDir
;
char
*
tmpDir
;
int64_t
lastCommitVer
;
int64_t
commitIndex
;
int64_t
lastCommitTerm
;
int64_t
commitTerm
;
int64_t
curVer
;
int64_t
commitConfig
;
int64_t
curTerm
;
int64_t
applyIndex
;
int64_t
curConfig
;
int64_t
applyTerm
;
int64_t
applyConfig
;
int64_t
tableVer
[
SDB_MAX
];
int64_t
tableVer
[
SDB_MAX
];
int64_t
maxId
[
SDB_MAX
];
int64_t
maxId
[
SDB_MAX
];
EKeyType
keyTypes
[
SDB_MAX
];
EKeyType
keyTypes
[
SDB_MAX
];
...
@@ -257,7 +260,7 @@ int32_t sdbReadFile(SSdb *pSdb);
...
@@ -257,7 +260,7 @@ int32_t sdbReadFile(SSdb *pSdb);
* @param pSdb The sdb object.
* @param pSdb The sdb object.
* @return int32_t 0 for success, -1 for failure.
* @return int32_t 0 for success, -1 for failure.
*/
*/
int32_t
sdbWriteFile
(
SSdb
*
pSdb
);
int32_t
sdbWriteFile
(
SSdb
*
pSdb
,
int32_t
delta
);
/**
/**
* @brief Parse and write raw data to sdb, then free the pRaw object
* @brief Parse and write raw data to sdb, then free the pRaw object
...
@@ -361,14 +364,8 @@ int64_t sdbGetTableVer(SSdb *pSdb, ESdbType type);
...
@@ -361,14 +364,8 @@ int64_t sdbGetTableVer(SSdb *pSdb, ESdbType type);
* @param index The update value of the apply index.
* @param index The update value of the apply index.
* @return int32_t The current index of sdb
* @return int32_t The current index of sdb
*/
*/
void
sdbSetApplyIndex
(
SSdb
*
pSdb
,
int64_t
index
);
void
sdbSetApplyInfo
(
SSdb
*
pSdb
,
int64_t
index
,
int64_t
term
,
int64_t
config
);
void
sdbSetApplyTerm
(
SSdb
*
pSdb
,
int64_t
term
);
void
sdbGetCommitInfo
(
SSdb
*
pSdb
,
int64_t
*
index
,
int64_t
*
term
,
int64_t
*
config
);
void
sdbSetCurConfig
(
SSdb
*
pSdb
,
int64_t
config
);
int64_t
sdbGetApplyIndex
(
SSdb
*
pSdb
);
int64_t
sdbGetApplyTerm
(
SSdb
*
pSdb
);
int64_t
sdbGetCommitIndex
(
SSdb
*
pSdb
);
int64_t
sdbGetCommitTerm
(
SSdb
*
pSdb
);
int64_t
sdbGetCurConfig
(
SSdb
*
pSdb
);
SSdbRaw
*
sdbAllocRaw
(
ESdbType
type
,
int8_t
sver
,
int32_t
dataLen
);
SSdbRaw
*
sdbAllocRaw
(
ESdbType
type
,
int8_t
sver
,
int32_t
dataLen
);
void
sdbFreeRaw
(
SSdbRaw
*
pRaw
);
void
sdbFreeRaw
(
SSdbRaw
*
pRaw
);
...
...
source/dnode/mnode/sdb/src/sdb.c
浏览文件 @
2e590c30
...
@@ -53,11 +53,12 @@ SSdb *sdbInit(SSdbOpt *pOption) {
...
@@ -53,11 +53,12 @@ SSdb *sdbInit(SSdbOpt *pOption) {
}
}
pSdb
->
pWal
=
pOption
->
pWal
;
pSdb
->
pWal
=
pOption
->
pWal
;
pSdb
->
curVer
=
-
1
;
pSdb
->
applyIndex
=
-
1
;
pSdb
->
curTerm
=
-
1
;
pSdb
->
applyTerm
=
-
1
;
pSdb
->
lastCommitVer
=
-
1
;
pSdb
->
applyConfig
=
-
1
;
pSdb
->
lastCommitTerm
=
-
1
;
pSdb
->
commitIndex
=
-
1
;
pSdb
->
curConfig
=
-
1
;
pSdb
->
commitTerm
=
-
1
;
pSdb
->
commitConfig
=
-
1
;
pSdb
->
pMnode
=
pOption
->
pMnode
;
pSdb
->
pMnode
=
pOption
->
pMnode
;
taosThreadMutexInit
(
&
pSdb
->
filelock
,
NULL
);
taosThreadMutexInit
(
&
pSdb
->
filelock
,
NULL
);
mDebug
(
"sdb init successfully"
);
mDebug
(
"sdb init successfully"
);
...
@@ -67,7 +68,7 @@ SSdb *sdbInit(SSdbOpt *pOption) {
...
@@ -67,7 +68,7 @@ SSdb *sdbInit(SSdbOpt *pOption) {
void
sdbCleanup
(
SSdb
*
pSdb
)
{
void
sdbCleanup
(
SSdb
*
pSdb
)
{
mDebug
(
"start to cleanup sdb"
);
mDebug
(
"start to cleanup sdb"
);
sdbWriteFile
(
pSdb
);
sdbWriteFile
(
pSdb
,
0
);
if
(
pSdb
->
currDir
!=
NULL
)
{
if
(
pSdb
->
currDir
!=
NULL
)
{
taosMemoryFreeClear
(
pSdb
->
currDir
);
taosMemoryFreeClear
(
pSdb
->
currDir
);
...
@@ -159,23 +160,20 @@ static int32_t sdbCreateDir(SSdb *pSdb) {
...
@@ -159,23 +160,20 @@ static int32_t sdbCreateDir(SSdb *pSdb) {
return
0
;
return
0
;
}
}
void
sdbSetApplyIndex
(
SSdb
*
pSdb
,
int64_t
index
)
{
pSdb
->
curVer
=
index
;
}
void
sdbSetApplyInfo
(
SSdb
*
pSdb
,
int64_t
index
,
int64_t
term
,
int64_t
config
)
{
mTrace
(
"mnode apply info changed, from index:%"
PRId64
" term:%"
PRId64
" config:%"
PRId64
", to index:%"
PRId64
void
sdbSetApplyTerm
(
SSdb
*
pSdb
,
int64_t
term
)
{
pSdb
->
curTerm
=
term
;
}
" term:%"
PRId64
" config:%"
PRId64
,
pSdb
->
applyIndex
,
pSdb
->
applyTerm
,
pSdb
->
applyConfig
,
index
,
term
,
config
);
void
sdbSetCurConfig
(
SSdb
*
pSdb
,
int64_t
config
)
{
pSdb
->
applyIndex
=
index
;
if
(
pSdb
->
curConfig
!=
config
)
{
pSdb
->
applyTerm
=
term
;
mDebug
(
"mnode sync config set from %"
PRId64
" to %"
PRId64
,
pSdb
->
curConfig
,
config
);
pSdb
->
applyConfig
=
config
;
pSdb
->
curConfig
=
config
;
}
}
}
int64_t
sdbGetApplyIndex
(
SSdb
*
pSdb
)
{
return
pSdb
->
curVer
;
}
void
sdbGetCommitInfo
(
SSdb
*
pSdb
,
int64_t
*
index
,
int64_t
*
term
,
int64_t
*
config
)
{
*
index
=
pSdb
->
commitIndex
;
int64_t
sdbGetApplyTerm
(
SSdb
*
pSdb
)
{
return
pSdb
->
curTerm
;
}
*
term
=
pSdb
->
commitTerm
;
*
config
=
pSdb
->
commitConfig
;
int64_t
sdbGetCommitIndex
(
SSdb
*
pSdb
)
{
return
pSdb
->
lastCommitVer
;
}
mTrace
(
"mnode current info, apply index:%"
PRId64
" term:%"
PRId64
" config:%"
PRId64
", commit index:%"
PRId64
" term:%"
PRId64
" config:%"
PRId64
,
int64_t
sdbGetCommitTerm
(
SSdb
*
pSdb
)
{
return
pSdb
->
lastCommitTerm
;
}
pSdb
->
applyIndex
,
pSdb
->
applyTerm
,
pSdb
->
applyConfig
,
*
index
,
*
term
,
*
config
);
}
int64_t
sdbGetCurConfig
(
SSdb
*
pSdb
)
{
return
pSdb
->
curConfig
;
}
\ No newline at end of file
source/dnode/mnode/sdb/src/sdbFile.c
浏览文件 @
2e590c30
...
@@ -67,10 +67,12 @@ static void sdbResetData(SSdb *pSdb) {
...
@@ -67,10 +67,12 @@ static void sdbResetData(SSdb *pSdb) {
mDebug
(
"sdb:%s is reset"
,
sdbTableName
(
i
));
mDebug
(
"sdb:%s is reset"
,
sdbTableName
(
i
));
}
}
pSdb
->
curVer
=
-
1
;
pSdb
->
applyIndex
=
-
1
;
pSdb
->
curTerm
=
-
1
;
pSdb
->
applyTerm
=
-
1
;
pSdb
->
lastCommitVer
=
-
1
;
pSdb
->
applyConfig
=
-
1
;
pSdb
->
lastCommitTerm
=
-
1
;
pSdb
->
commitIndex
=
-
1
;
pSdb
->
commitTerm
=
-
1
;
pSdb
->
commitConfig
=
-
1
;
mDebug
(
"sdb reset successfully"
);
mDebug
(
"sdb reset successfully"
);
}
}
...
@@ -90,7 +92,7 @@ static int32_t sdbReadFileHead(SSdb *pSdb, TdFilePtr pFile) {
...
@@ -90,7 +92,7 @@ static int32_t sdbReadFileHead(SSdb *pSdb, TdFilePtr pFile) {
return
-
1
;
return
-
1
;
}
}
ret
=
taosReadFile
(
pFile
,
&
pSdb
->
curVer
,
sizeof
(
int64_t
));
ret
=
taosReadFile
(
pFile
,
&
pSdb
->
applyIndex
,
sizeof
(
int64_t
));
if
(
ret
<
0
)
{
if
(
ret
<
0
)
{
terrno
=
TAOS_SYSTEM_ERROR
(
errno
);
terrno
=
TAOS_SYSTEM_ERROR
(
errno
);
return
-
1
;
return
-
1
;
...
@@ -100,7 +102,7 @@ static int32_t sdbReadFileHead(SSdb *pSdb, TdFilePtr pFile) {
...
@@ -100,7 +102,7 @@ static int32_t sdbReadFileHead(SSdb *pSdb, TdFilePtr pFile) {
return
-
1
;
return
-
1
;
}
}
ret
=
taosReadFile
(
pFile
,
&
pSdb
->
cur
Term
,
sizeof
(
int64_t
));
ret
=
taosReadFile
(
pFile
,
&
pSdb
->
apply
Term
,
sizeof
(
int64_t
));
if
(
ret
<
0
)
{
if
(
ret
<
0
)
{
terrno
=
TAOS_SYSTEM_ERROR
(
errno
);
terrno
=
TAOS_SYSTEM_ERROR
(
errno
);
return
-
1
;
return
-
1
;
...
@@ -110,7 +112,7 @@ static int32_t sdbReadFileHead(SSdb *pSdb, TdFilePtr pFile) {
...
@@ -110,7 +112,7 @@ static int32_t sdbReadFileHead(SSdb *pSdb, TdFilePtr pFile) {
return
-
1
;
return
-
1
;
}
}
ret
=
taosReadFile
(
pFile
,
&
pSdb
->
cur
Config
,
sizeof
(
int64_t
));
ret
=
taosReadFile
(
pFile
,
&
pSdb
->
apply
Config
,
sizeof
(
int64_t
));
if
(
ret
<
0
)
{
if
(
ret
<
0
)
{
terrno
=
TAOS_SYSTEM_ERROR
(
errno
);
terrno
=
TAOS_SYSTEM_ERROR
(
errno
);
return
-
1
;
return
-
1
;
...
@@ -173,17 +175,17 @@ static int32_t sdbWriteFileHead(SSdb *pSdb, TdFilePtr pFile) {
...
@@ -173,17 +175,17 @@ static int32_t sdbWriteFileHead(SSdb *pSdb, TdFilePtr pFile) {
return
-
1
;
return
-
1
;
}
}
if
(
taosWriteFile
(
pFile
,
&
pSdb
->
curVer
,
sizeof
(
int64_t
))
!=
sizeof
(
int64_t
))
{
if
(
taosWriteFile
(
pFile
,
&
pSdb
->
applyIndex
,
sizeof
(
int64_t
))
!=
sizeof
(
int64_t
))
{
terrno
=
TAOS_SYSTEM_ERROR
(
errno
);
terrno
=
TAOS_SYSTEM_ERROR
(
errno
);
return
-
1
;
return
-
1
;
}
}
if
(
taosWriteFile
(
pFile
,
&
pSdb
->
cur
Term
,
sizeof
(
int64_t
))
!=
sizeof
(
int64_t
))
{
if
(
taosWriteFile
(
pFile
,
&
pSdb
->
apply
Term
,
sizeof
(
int64_t
))
!=
sizeof
(
int64_t
))
{
terrno
=
TAOS_SYSTEM_ERROR
(
errno
);
terrno
=
TAOS_SYSTEM_ERROR
(
errno
);
return
-
1
;
return
-
1
;
}
}
if
(
taosWriteFile
(
pFile
,
&
pSdb
->
cur
Config
,
sizeof
(
int64_t
))
!=
sizeof
(
int64_t
))
{
if
(
taosWriteFile
(
pFile
,
&
pSdb
->
apply
Config
,
sizeof
(
int64_t
))
!=
sizeof
(
int64_t
))
{
terrno
=
TAOS_SYSTEM_ERROR
(
errno
);
terrno
=
TAOS_SYSTEM_ERROR
(
errno
);
return
-
1
;
return
-
1
;
}
}
...
@@ -300,11 +302,12 @@ static int32_t sdbReadFileImp(SSdb *pSdb) {
...
@@ -300,11 +302,12 @@ static int32_t sdbReadFileImp(SSdb *pSdb) {
}
}
code
=
0
;
code
=
0
;
pSdb
->
lastCommitVer
=
pSdb
->
curVer
;
pSdb
->
commitIndex
=
pSdb
->
applyIndex
;
pSdb
->
lastCommitTerm
=
pSdb
->
curTerm
;
pSdb
->
commitTerm
=
pSdb
->
applyTerm
;
pSdb
->
commitConfig
=
pSdb
->
applyConfig
;
memcpy
(
pSdb
->
tableVer
,
tableVer
,
sizeof
(
tableVer
));
memcpy
(
pSdb
->
tableVer
,
tableVer
,
sizeof
(
tableVer
));
mDebug
(
"read sdb file:%s successfully,
index:%"
PRId64
" term:%"
PRId64
" config:%"
PRId64
,
file
,
pSdb
->
lastCommitVer
,
mDebug
(
"read sdb file:%s successfully,
commit index:%"
PRId64
" term:%"
PRId64
" config:%"
PRId64
,
file
,
pSdb
->
lastCommitTerm
,
pSdb
->
cur
Config
);
pSdb
->
commitIndex
,
pSdb
->
commitTerm
,
pSdb
->
commit
Config
);
_OVER:
_OVER:
taosCloseFile
(
&
pFile
);
taosCloseFile
(
&
pFile
);
...
@@ -336,9 +339,10 @@ static int32_t sdbWriteFileImp(SSdb *pSdb) {
...
@@ -336,9 +339,10 @@ static int32_t sdbWriteFileImp(SSdb *pSdb) {
char
curfile
[
PATH_MAX
]
=
{
0
};
char
curfile
[
PATH_MAX
]
=
{
0
};
snprintf
(
curfile
,
sizeof
(
curfile
),
"%s%ssdb.data"
,
pSdb
->
currDir
,
TD_DIRSEP
);
snprintf
(
curfile
,
sizeof
(
curfile
),
"%s%ssdb.data"
,
pSdb
->
currDir
,
TD_DIRSEP
);
mDebug
(
"start to write sdb file, current ver:%"
PRId64
" term:%"
PRId64
", commit ver:%"
PRId64
" term:%"
PRId64
mDebug
(
"start to write sdb file, apply index:%"
PRId64
" term:%"
PRId64
" config:%"
PRId64
", commit index:%"
PRId64
" file:%s"
,
" term:%"
PRId64
" config:%"
PRId64
", file:%s"
,
pSdb
->
curVer
,
pSdb
->
curTerm
,
pSdb
->
lastCommitVer
,
pSdb
->
lastCommitTerm
,
curfile
);
pSdb
->
applyIndex
,
pSdb
->
applyTerm
,
pSdb
->
applyConfig
,
pSdb
->
commitIndex
,
pSdb
->
commitTerm
,
pSdb
->
commitConfig
,
curfile
);
TdFilePtr
pFile
=
taosOpenFile
(
tmpfile
,
TD_FILE_CREATE
|
TD_FILE_WRITE
|
TD_FILE_TRUNC
);
TdFilePtr
pFile
=
taosOpenFile
(
tmpfile
,
TD_FILE_CREATE
|
TD_FILE_WRITE
|
TD_FILE_TRUNC
);
if
(
pFile
==
NULL
)
{
if
(
pFile
==
NULL
)
{
...
@@ -430,25 +434,30 @@ static int32_t sdbWriteFileImp(SSdb *pSdb) {
...
@@ -430,25 +434,30 @@ static int32_t sdbWriteFileImp(SSdb *pSdb) {
if
(
code
!=
0
)
{
if
(
code
!=
0
)
{
mError
(
"failed to write sdb file:%s since %s"
,
curfile
,
tstrerror
(
code
));
mError
(
"failed to write sdb file:%s since %s"
,
curfile
,
tstrerror
(
code
));
}
else
{
}
else
{
pSdb
->
lastCommitVer
=
pSdb
->
curVer
;
pSdb
->
commitIndex
=
pSdb
->
applyIndex
;
pSdb
->
lastCommitTerm
=
pSdb
->
curTerm
;
pSdb
->
commitTerm
=
pSdb
->
applyTerm
;
mDebug
(
"write sdb file successfully, index:%"
PRId64
" term:%"
PRId64
" config:%"
PRId64
" file:%s"
,
pSdb
->
commitConfig
=
pSdb
->
applyConfig
;
pSdb
->
lastCommitVer
,
pSdb
->
lastCommitTerm
,
pSdb
->
curConfig
,
curfile
);
mDebug
(
"write sdb file successfully, commit index:%"
PRId64
" term:%"
PRId64
" config:%"
PRId64
" file:%s"
,
pSdb
->
commitIndex
,
pSdb
->
commitTerm
,
pSdb
->
commitConfig
,
curfile
);
}
}
terrno
=
code
;
terrno
=
code
;
return
code
;
return
code
;
}
}
int32_t
sdbWriteFile
(
SSdb
*
pSdb
)
{
int32_t
sdbWriteFile
(
SSdb
*
pSdb
,
int32_t
delta
)
{
int32_t
code
=
0
;
int32_t
code
=
0
;
if
(
pSdb
->
curVer
==
pSdb
->
lastCommitVer
)
{
if
(
pSdb
->
applyIndex
==
pSdb
->
commitIndex
)
{
return
0
;
}
if
(
pSdb
->
applyIndex
-
pSdb
->
commitIndex
<
delta
)
{
return
0
;
return
0
;
}
}
taosThreadMutexLock
(
&
pSdb
->
filelock
);
taosThreadMutexLock
(
&
pSdb
->
filelock
);
if
(
pSdb
->
pWal
!=
NULL
)
{
if
(
pSdb
->
pWal
!=
NULL
)
{
code
=
walBeginSnapshot
(
pSdb
->
pWal
,
pSdb
->
curVer
);
code
=
walBeginSnapshot
(
pSdb
->
pWal
,
pSdb
->
applyIndex
);
}
}
if
(
code
==
0
)
{
if
(
code
==
0
)
{
code
=
sdbWriteFileImp
(
pSdb
);
code
=
sdbWriteFileImp
(
pSdb
);
...
@@ -470,7 +479,7 @@ int32_t sdbDeploy(SSdb *pSdb) {
...
@@ -470,7 +479,7 @@ int32_t sdbDeploy(SSdb *pSdb) {
return
-
1
;
return
-
1
;
}
}
if
(
sdbWriteFile
(
pSdb
)
!=
0
)
{
if
(
sdbWriteFile
(
pSdb
,
0
)
!=
0
)
{
return
-
1
;
return
-
1
;
}
}
...
@@ -522,9 +531,9 @@ int32_t sdbStartRead(SSdb *pSdb, SSdbIter **ppIter) {
...
@@ -522,9 +531,9 @@ int32_t sdbStartRead(SSdb *pSdb, SSdbIter **ppIter) {
snprintf
(
datafile
,
sizeof
(
datafile
),
"%s%ssdb.data"
,
pSdb
->
currDir
,
TD_DIRSEP
);
snprintf
(
datafile
,
sizeof
(
datafile
),
"%s%ssdb.data"
,
pSdb
->
currDir
,
TD_DIRSEP
);
taosThreadMutexLock
(
&
pSdb
->
filelock
);
taosThreadMutexLock
(
&
pSdb
->
filelock
);
int64_t
commitIndex
=
pSdb
->
lastCommitVer
;
int64_t
commitIndex
=
pSdb
->
commitIndex
;
int64_t
commitTerm
=
pSdb
->
lastC
ommitTerm
;
int64_t
commitTerm
=
pSdb
->
c
ommitTerm
;
int64_t
c
urConfig
=
pSdb
->
cur
Config
;
int64_t
c
ommitConfig
=
pSdb
->
commit
Config
;
if
(
taosCopyFile
(
datafile
,
pIter
->
name
)
<
0
)
{
if
(
taosCopyFile
(
datafile
,
pIter
->
name
)
<
0
)
{
taosThreadMutexUnlock
(
&
pSdb
->
filelock
);
taosThreadMutexUnlock
(
&
pSdb
->
filelock
);
terrno
=
TAOS_SYSTEM_ERROR
(
errno
);
terrno
=
TAOS_SYSTEM_ERROR
(
errno
);
...
@@ -543,8 +552,8 @@ int32_t sdbStartRead(SSdb *pSdb, SSdbIter **ppIter) {
...
@@ -543,8 +552,8 @@ int32_t sdbStartRead(SSdb *pSdb, SSdbIter **ppIter) {
}
}
*
ppIter
=
pIter
;
*
ppIter
=
pIter
;
mInfo
(
"sdbiter:%p, is created to read snapshot,
index:%"
PRId64
" term:%"
PRId64
" config:%"
PRId64
" file:%s"
,
pIter
,
mInfo
(
"sdbiter:%p, is created to read snapshot,
commit index:%"
PRId64
" term:%"
PRId64
" config:%"
PRId64
" file:%s"
,
commitIndex
,
commitTerm
,
cur
Config
,
pIter
->
name
);
pIter
,
commitIndex
,
commitTerm
,
commit
Config
,
pIter
->
name
);
return
0
;
return
0
;
}
}
...
...
source/dnode/vnode/src/vnd/vnodeSync.c
浏览文件 @
2e590c30
...
@@ -180,8 +180,8 @@ void vnodeApplyMsg(SQueueInfo *pInfo, STaosQall *qall, int32_t numOfMsgs) {
...
@@ -180,8 +180,8 @@ void vnodeApplyMsg(SQueueInfo *pInfo, STaosQall *qall, int32_t numOfMsgs) {
for
(
int32_t
i
=
0
;
i
<
numOfMsgs
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
numOfMsgs
;
++
i
)
{
if
(
taosGetQitem
(
qall
,
(
void
**
)
&
pMsg
)
==
0
)
continue
;
if
(
taosGetQitem
(
qall
,
(
void
**
)
&
pMsg
)
==
0
)
continue
;
vTrace
(
"vgId:%d, msg:%p get from vnode-apply queue,
type:%s handle:%p"
,
vgId
,
pMsg
,
TMSG_INFO
(
pMsg
->
msgType
)
,
vTrace
(
"vgId:%d, msg:%p get from vnode-apply queue,
index:%"
PRId64
" type:%s handle:%p"
,
vgId
,
pMsg
,
pMsg
->
info
.
handle
);
pMsg
->
info
.
conn
.
applyIndex
,
TMSG_INFO
(
pMsg
->
msgType
),
pMsg
->
info
.
handle
);
SRpcMsg
rsp
=
{.
code
=
pMsg
->
code
,
.
info
=
pMsg
->
info
};
SRpcMsg
rsp
=
{.
code
=
pMsg
->
code
,
.
info
=
pMsg
->
info
};
if
(
rsp
.
code
==
0
)
{
if
(
rsp
.
code
==
0
)
{
...
@@ -334,8 +334,8 @@ static void vnodeSyncReconfig(struct SSyncFSM *pFsm, const SRpcMsg *pMsg, SReCon
...
@@ -334,8 +334,8 @@ static void vnodeSyncReconfig(struct SSyncFSM *pFsm, const SRpcMsg *pMsg, SReCon
syncGetAndDelRespRpc
(
pVnode
->
sync
,
cbMeta
.
seqNum
,
&
rpcMsg
.
info
);
syncGetAndDelRespRpc
(
pVnode
->
sync
,
cbMeta
.
seqNum
,
&
rpcMsg
.
info
);
rpcMsg
.
info
.
conn
.
applyIndex
=
cbMeta
.
index
;
rpcMsg
.
info
.
conn
.
applyIndex
=
cbMeta
.
index
;
vInfo
(
"vgId:%d, alter vnode replica is confirmed, type:%s contLen:%d seq:%"
PRIu64
"
handle:%p"
,
TD_VID
(
pVnode
)
,
vInfo
(
"vgId:%d, alter vnode replica is confirmed, type:%s contLen:%d seq:%"
PRIu64
"
index:%"
PRId64
" handle:%p"
,
T
MSG_INFO
(
pMsg
->
msgType
),
pMsg
->
contLen
,
cbMeta
.
seqNum
,
rpcMsg
.
info
.
handle
);
T
D_VID
(
pVnode
),
TMSG_INFO
(
pMsg
->
msgType
),
pMsg
->
contLen
,
cbMeta
.
seqNum
,
cbMeta
.
index
,
rpcMsg
.
info
.
handle
);
if
(
rpcMsg
.
info
.
handle
!=
NULL
)
{
if
(
rpcMsg
.
info
.
handle
!=
NULL
)
{
tmsgSendRsp
(
&
rpcMsg
);
tmsgSendRsp
(
&
rpcMsg
);
}
}
...
...
source/libs/executor/inc/executil.h
浏览文件 @
2e590c30
...
@@ -15,7 +15,9 @@
...
@@ -15,7 +15,9 @@
#ifndef TDENGINE_QUERYUTIL_H
#ifndef TDENGINE_QUERYUTIL_H
#define TDENGINE_QUERYUTIL_H
#define TDENGINE_QUERYUTIL_H
#include <libs/function/function.h>
#include "function.h"
#include "nodes.h"
#include "plannodes.h"
#include "tbuffer.h"
#include "tbuffer.h"
#include "tcommon.h"
#include "tcommon.h"
#include "tpagedbuf.h"
#include "tpagedbuf.h"
...
@@ -77,7 +79,7 @@ typedef struct SResultRowInfo {
...
@@ -77,7 +79,7 @@ typedef struct SResultRowInfo {
struct
SqlFunctionCtx
;
struct
SqlFunctionCtx
;
size_t
getResultRowSize
(
struct
SqlFunctionCtx
*
pCtx
,
int32_t
numOfOutput
);
size_t
getResultRowSize
(
struct
SqlFunctionCtx
*
pCtx
,
int32_t
numOfOutput
);
int32_t
initResultRowInfo
(
SResultRowInfo
*
pResultRowInfo
,
int32_t
size
);
void
initResultRowInfo
(
SResultRowInfo
*
pResultRowInfo
);
void
cleanupResultRowInfo
(
SResultRowInfo
*
pResultRowInfo
);
void
cleanupResultRowInfo
(
SResultRowInfo
*
pResultRowInfo
);
void
closeAllResultRows
(
SResultRowInfo
*
pResultRowInfo
);
void
closeAllResultRows
(
SResultRowInfo
*
pResultRowInfo
);
...
@@ -86,7 +88,7 @@ void initResultRow(SResultRow *pResultRow);
...
@@ -86,7 +88,7 @@ void initResultRow(SResultRow *pResultRow);
void
closeResultRow
(
SResultRow
*
pResultRow
);
void
closeResultRow
(
SResultRow
*
pResultRow
);
bool
isResultRowClosed
(
SResultRow
*
pResultRow
);
bool
isResultRowClosed
(
SResultRow
*
pResultRow
);
struct
SResultRowEntryInfo
*
getResult
Cell
(
const
SResultRow
*
pRow
,
int32_t
index
,
const
int32_t
*
offset
);
struct
SResultRowEntryInfo
*
getResult
EntryInfo
(
const
SResultRow
*
pRow
,
int32_t
index
,
const
int32_t
*
offset
);
static
FORCE_INLINE
SResultRow
*
getResultRowByPos
(
SDiskbasedBuf
*
pBuf
,
SResultRowPosition
*
pos
)
{
static
FORCE_INLINE
SResultRow
*
getResultRowByPos
(
SDiskbasedBuf
*
pBuf
,
SResultRowPosition
*
pos
)
{
SFilePage
*
bufPage
=
(
SFilePage
*
)
getBufPage
(
pBuf
,
pos
->
pageId
);
SFilePage
*
bufPage
=
(
SFilePage
*
)
getBufPage
(
pBuf
,
pos
->
pageId
);
...
@@ -98,9 +100,27 @@ void initGroupedResultInfo(SGroupResInfo* pGroupResInfo, SHashObj* pHashmap,
...
@@ -98,9 +100,27 @@ void initGroupedResultInfo(SGroupResInfo* pGroupResInfo, SHashObj* pHashmap,
void
initMultiResInfoFromArrayList
(
SGroupResInfo
*
pGroupResInfo
,
SArray
*
pArrayList
);
void
initMultiResInfoFromArrayList
(
SGroupResInfo
*
pGroupResInfo
,
SArray
*
pArrayList
);
void
cleanupGroupResInfo
(
SGroupResInfo
*
pGroupResInfo
);
void
cleanupGroupResInfo
(
SGroupResInfo
*
pGroupResInfo
);
bool
has
hRemain
DataInGroupInfo
(
SGroupResInfo
*
pGroupResInfo
);
bool
hasDataInGroupInfo
(
SGroupResInfo
*
pGroupResInfo
);
bool
incNextGroup
(
SGroupResInfo
*
pGroupResInfo
);
int32_t
getNumOfTotalRes
(
SGroupResInfo
*
pGroupResInfo
);
int32_t
getNumOfTotalRes
(
SGroupResInfo
*
pGroupResInfo
);
SSDataBlock
*
createResDataBlock
(
SDataBlockDescNode
*
pNode
);
int32_t
getTableList
(
void
*
metaHandle
,
SScanPhysiNode
*
pScanNode
,
STableListInfo
*
pListInfo
,
SNode
*
pTagCond
);
SArray
*
createSortInfo
(
SNodeList
*
pNodeList
);
SArray
*
extractPartitionColInfo
(
SNodeList
*
pNodeList
);
SArray
*
extractColMatchInfo
(
SNodeList
*
pNodeList
,
SDataBlockDescNode
*
pOutputNodeList
,
int32_t
*
numOfOutputCols
,
int32_t
type
);
SExprInfo
*
createExprInfo
(
SNodeList
*
pNodeList
,
SNodeList
*
pGroupKeys
,
int32_t
*
numOfExprs
);
SqlFunctionCtx
*
createSqlFunctionCtx
(
SExprInfo
*
pExprInfo
,
int32_t
numOfOutput
,
int32_t
**
rowCellInfoOffset
);
void
relocateColumnData
(
SSDataBlock
*
pBlock
,
const
SArray
*
pColMatchInfo
,
SArray
*
pCols
);
void
initExecTimeWindowInfo
(
SColumnInfoData
*
pColData
,
STimeWindow
*
pQueryWindow
);
SInterval
extractIntervalInfo
(
const
STableScanPhysiNode
*
pTableScanNode
);
SColumn
extractColumnFromColumnNode
(
SColumnNode
*
pColNode
);
int32_t
initQueryTableDataCond
(
SQueryTableDataCond
*
pCond
,
const
STableScanPhysiNode
*
pTableScanNode
);
void
cleanupQueryTableDataCond
(
SQueryTableDataCond
*
pCond
);
#endif // TDENGINE_QUERYUTIL_H
#endif // TDENGINE_QUERYUTIL_H
source/libs/executor/inc/executorimpl.h
浏览文件 @
2e590c30
...
@@ -747,43 +747,27 @@ void doBuildResultDatablock(SOperatorInfo* pOperator, SOptrBasicInfo* pbInfo,
...
@@ -747,43 +747,27 @@ void doBuildResultDatablock(SOperatorInfo* pOperator, SOptrBasicInfo* pbInfo,
void
doApplyFunctions
(
SExecTaskInfo
*
taskInfo
,
SqlFunctionCtx
*
pCtx
,
STimeWindow
*
pWin
,
SColumnInfoData
*
pTimeWindowData
,
int32_t
offset
,
void
doApplyFunctions
(
SExecTaskInfo
*
taskInfo
,
SqlFunctionCtx
*
pCtx
,
STimeWindow
*
pWin
,
SColumnInfoData
*
pTimeWindowData
,
int32_t
offset
,
int32_t
forwardStep
,
TSKEY
*
tsCol
,
int32_t
numOfTotal
,
int32_t
numOfOutput
,
int32_t
order
);
int32_t
forwardStep
,
TSKEY
*
tsCol
,
int32_t
numOfTotal
,
int32_t
numOfOutput
,
int32_t
order
);
int32_t
setGroupResultOutputBuf
(
SOptrBasicInfo
*
binfo
,
int32_t
numOfCols
,
char
*
pData
,
int16_t
type
,
int16_t
bytes
,
int32_t
groupId
,
SDiskbasedBuf
*
pBuf
,
SExecTaskInfo
*
pTaskInfo
,
SAggSupporter
*
pAggSup
);
void
doDestroyBasicInfo
(
SOptrBasicInfo
*
pInfo
,
int32_t
numOfOutput
);
void
doDestroyBasicInfo
(
SOptrBasicInfo
*
pInfo
,
int32_t
numOfOutput
);
int32_t
se
tDataBlockFromFetchRsp
(
SSDataBlock
*
pRes
,
SLoadRemoteDataInfo
*
pLoadInfo
,
int32_t
numOfRows
,
char
*
pData
,
int32_t
extrac
tDataBlockFromFetchRsp
(
SSDataBlock
*
pRes
,
SLoadRemoteDataInfo
*
pLoadInfo
,
int32_t
numOfRows
,
char
*
pData
,
int32_t
compLen
,
int32_t
numOfOutput
,
int64_t
startTs
,
uint64_t
*
total
,
int32_t
compLen
,
int32_t
numOfOutput
,
int64_t
startTs
,
uint64_t
*
total
,
SArray
*
pColList
);
SArray
*
pColList
);
void
getAlignQueryTimeWindow
(
SInterval
*
pInterval
,
int32_t
precision
,
int64_t
key
,
STimeWindow
*
win
);
void
getAlignQueryTimeWindow
(
SInterval
*
pInterval
,
int32_t
precision
,
int64_t
key
,
STimeWindow
*
win
);
int32_t
getTableScanInfo
(
SOperatorInfo
*
pOperator
,
int32_t
*
order
,
int32_t
*
scanFlag
);
int32_t
getTableScanInfo
(
SOperatorInfo
*
pOperator
,
int32_t
*
order
,
int32_t
*
scanFlag
);
int32_t
getBufferPgSize
(
int32_t
rowSize
,
uint32_t
*
defaultPgsz
,
uint32_t
*
defaultBufsz
);
int32_t
getBufferPgSize
(
int32_t
rowSize
,
uint32_t
*
defaultPgsz
,
uint32_t
*
defaultBufsz
);
SArray
*
extractPartitionColInfo
(
SNodeList
*
pNodeList
);
void
doSetOperatorCompleted
(
SOperatorInfo
*
pOperator
);
void
doSetOperatorCompleted
(
SOperatorInfo
*
pOperator
);
void
doFilter
(
const
SNode
*
pFilterNode
,
SSDataBlock
*
pBlock
);
void
doFilter
(
const
SNode
*
pFilterNode
,
SSDataBlock
*
pBlock
);
SqlFunctionCtx
*
createSqlFunctionCtx
(
SExprInfo
*
pExprInfo
,
int32_t
numOfOutput
,
int32_t
**
rowCellInfoOffset
);
void
relocateColumnData
(
SSDataBlock
*
pBlock
,
const
SArray
*
pColMatchInfo
,
SArray
*
pCols
);
void
initExecTimeWindowInfo
(
SColumnInfoData
*
pColData
,
STimeWindow
*
pQueryWindow
);
void
cleanupAggSup
(
SAggSupporter
*
pAggSup
);
void
cleanupAggSup
(
SAggSupporter
*
pAggSup
);
void
destroyBasicOperatorInfo
(
void
*
param
,
int32_t
numOfOutput
);
void
destroyBasicOperatorInfo
(
void
*
param
,
int32_t
numOfOutput
);
void
appendOneRowToDataBlock
(
SSDataBlock
*
pBlock
,
STupleHandle
*
pTupleHandle
);
void
appendOneRowToDataBlock
(
SSDataBlock
*
pBlock
,
STupleHandle
*
pTupleHandle
);
void
setTbNameColData
(
void
*
pMeta
,
const
SSDataBlock
*
pBlock
,
SColumnInfoData
*
pColInfoData
,
int32_t
functionId
);
void
setTbNameColData
(
void
*
pMeta
,
const
SSDataBlock
*
pBlock
,
SColumnInfoData
*
pColInfoData
,
int32_t
functionId
);
SInterval
extractIntervalInfo
(
const
STableScanPhysiNode
*
pTableScanNode
);
SColumn
extractColumnFromColumnNode
(
SColumnNode
*
pColNode
);
SSDataBlock
*
getSortedBlockData
(
SSortHandle
*
pHandle
,
SSDataBlock
*
pDataBlock
,
int32_t
capacity
,
SArray
*
pColMatchInfo
,
SSortOperatorInfo
*
pInfo
);
SSDataBlock
*
loadNextDataBlock
(
void
*
param
);
SSDataBlock
*
loadNextDataBlock
(
void
*
param
);
void
setResultRowInitCtx
(
SResultRow
*
pResult
,
SqlFunctionCtx
*
pCtx
,
int32_t
numOfOutput
,
int32_t
*
rowCellInfoOffset
);
void
setResultRowInitCtx
(
SResultRow
*
pResult
,
SqlFunctionCtx
*
pCtx
,
int32_t
numOfOutput
,
int32_t
*
rowCellInfoOffset
);
SArray
*
extractColMatchInfo
(
SNodeList
*
pNodeList
,
SDataBlockDescNode
*
pOutputNodeList
,
int32_t
*
numOfOutputCols
,
SExecTaskInfo
*
pTaskInfo
,
int32_t
type
);
SExprInfo
*
createExprInfo
(
SNodeList
*
pNodeList
,
SNodeList
*
pGroupKeys
,
int32_t
*
numOfExprs
);
SSDataBlock
*
createResDataBlock
(
SDataBlockDescNode
*
pNode
);
int32_t
initQueryTableDataCond
(
SQueryTableDataCond
*
pCond
,
const
STableScanPhysiNode
*
pTableScanNode
);
void
clearupQueryTableDataCond
(
SQueryTableDataCond
*
pCond
);
SResultRow
*
doSetResultOutBufByKey
(
SDiskbasedBuf
*
pResultBuf
,
SResultRowInfo
*
pResultRowInfo
,
SResultRow
*
doSetResultOutBufByKey
(
SDiskbasedBuf
*
pResultBuf
,
SResultRowInfo
*
pResultRowInfo
,
char
*
pData
,
int16_t
bytes
,
bool
masterscan
,
uint64_t
groupId
,
char
*
pData
,
int16_t
bytes
,
bool
masterscan
,
uint64_t
groupId
,
SExecTaskInfo
*
pTaskInfo
,
bool
isIntervalQuery
,
SAggSupporter
*
pSup
);
SExecTaskInfo
*
pTaskInfo
,
bool
isIntervalQuery
,
SAggSupporter
*
pSup
);
...
@@ -799,9 +783,9 @@ SOperatorInfo* createAggregateOperatorInfo(SOperatorInfo* downstream, SExprInfo*
...
@@ -799,9 +783,9 @@ SOperatorInfo* createAggregateOperatorInfo(SOperatorInfo* downstream, SExprInfo*
int32_t
numOfScalarExpr
,
SExecTaskInfo
*
pTaskInfo
);
int32_t
numOfScalarExpr
,
SExecTaskInfo
*
pTaskInfo
);
SOperatorInfo
*
createIndefinitOutputOperatorInfo
(
SOperatorInfo
*
downstream
,
SPhysiNode
*
pNode
,
SExecTaskInfo
*
pTaskInfo
);
SOperatorInfo
*
createIndefinitOutputOperatorInfo
(
SOperatorInfo
*
downstream
,
SPhysiNode
*
pNode
,
SExecTaskInfo
*
pTaskInfo
);
SOperatorInfo
*
createProjectOperatorInfo
(
SOperatorInfo
*
downstream
,
S
ExprInfo
*
pExprInfo
,
int32_t
num
,
SSDataBlock
*
pResBlock
,
SLimit
*
pLimit
,
SLimit
*
pSlimit
,
SNode
*
pCondition
,
SExecTaskInfo
*
pTaskInfo
);
SOperatorInfo
*
createProjectOperatorInfo
(
SOperatorInfo
*
downstream
,
S
ProjectPhysiNode
*
pProjPhyNode
,
SExecTaskInfo
*
pTaskInfo
);
SOperatorInfo
*
createSortOperatorInfo
(
SOperatorInfo
*
downstream
,
SSDataBlock
*
pResBlock
,
SArray
*
pSortInfo
,
SExprInfo
*
pExprInfo
,
int32_t
numOfCols
,
SOperatorInfo
*
createSortOperatorInfo
(
SOperatorInfo
*
downstream
,
SSortPhysiNode
*
pSortPhyNode
,
SExecTaskInfo
*
pTaskInfo
);
SArray
*
pIndexMap
,
SExecTaskInfo
*
pTaskInfo
);
SOperatorInfo
*
createMultiwaySortMergeOperatorInfo
(
SOperatorInfo
**
downStreams
,
int32_t
numStreams
,
SSDataBlock
*
pInputBlock
,
SOperatorInfo
*
createMultiwaySortMergeOperatorInfo
(
SOperatorInfo
**
downStreams
,
int32_t
numStreams
,
SSDataBlock
*
pInputBlock
,
SSDataBlock
*
pResBlock
,
SArray
*
pSortInfo
,
SArray
*
pColMatchColInfo
,
SSDataBlock
*
pResBlock
,
SArray
*
pSortInfo
,
SArray
*
pColMatchColInfo
,
SExecTaskInfo
*
pTaskInfo
);
SExecTaskInfo
*
pTaskInfo
);
...
@@ -831,10 +815,9 @@ SOperatorInfo* createDataBlockInfoScanOperator(void* dataReader, SExecTaskInfo*
...
@@ -831,10 +815,9 @@ SOperatorInfo* createDataBlockInfoScanOperator(void* dataReader, SExecTaskInfo*
SOperatorInfo
*
createStreamScanOperatorInfo
(
void
*
pDataReader
,
SReadHandle
*
pHandle
,
SOperatorInfo
*
createStreamScanOperatorInfo
(
void
*
pDataReader
,
SReadHandle
*
pHandle
,
STableScanPhysiNode
*
pTableScanNode
,
SExecTaskInfo
*
pTaskInfo
,
STimeWindowAggSupp
*
pTwSup
);
STableScanPhysiNode
*
pTableScanNode
,
SExecTaskInfo
*
pTaskInfo
,
STimeWindowAggSupp
*
pTwSup
);
SOperatorInfo
*
createFillOperatorInfo
(
SOperatorInfo
*
downstream
,
SFillPhysiNode
*
pPhyFillNode
,
bool
multigroupResult
,
SExecTaskInfo
*
pTaskInfo
);
SOperatorInfo
*
createFillOperatorInfo
(
SOperatorInfo
*
downstream
,
SExprInfo
*
pExpr
,
int32_t
numOfCols
,
SInterval
*
pInterval
,
STimeWindow
*
pWindow
,
SSDataBlock
*
pResBlock
,
int32_t
fillType
,
SNodeListNode
*
fillVal
,
bool
multigroupResult
,
SExecTaskInfo
*
pTaskInfo
);
SOperatorInfo
*
createStatewindowOperatorInfo
(
SOperatorInfo
*
downstream
,
SExprInfo
*
pExpr
,
int32_t
numOfCols
,
SOperatorInfo
*
createStatewindowOperatorInfo
(
SOperatorInfo
*
downstream
,
SExprInfo
*
pExpr
,
int32_t
numOfCols
,
SSDataBlock
*
pResBlock
,
STimeWindowAggSupp
*
pTwAggSupp
,
int32_t
tsSlotId
,
SColumn
*
pStateKeyCol
,
SExecTaskInfo
*
pTaskInfo
);
SSDataBlock
*
pResBlock
,
STimeWindowAggSupp
*
pTwAggSupp
,
int32_t
tsSlotId
,
SColumn
*
pStateKeyCol
,
SExecTaskInfo
*
pTaskInfo
);
...
@@ -843,7 +826,8 @@ SOperatorInfo* createPartitionOperatorInfo(SOperatorInfo* downstream, SPartition
...
@@ -843,7 +826,8 @@ SOperatorInfo* createPartitionOperatorInfo(SOperatorInfo* downstream, SPartition
SOperatorInfo
*
createTimeSliceOperatorInfo
(
SOperatorInfo
*
downstream
,
SExprInfo
*
pExprInfo
,
int32_t
numOfCols
,
SOperatorInfo
*
createTimeSliceOperatorInfo
(
SOperatorInfo
*
downstream
,
SExprInfo
*
pExprInfo
,
int32_t
numOfCols
,
SSDataBlock
*
pResultBlock
,
const
SNodeListNode
*
pValNode
,
SExecTaskInfo
*
pTaskInfo
);
SSDataBlock
*
pResultBlock
,
const
SNodeListNode
*
pValNode
,
SExecTaskInfo
*
pTaskInfo
);
SOperatorInfo
*
createMergeJoinOperatorInfo
(
SOperatorInfo
**
pDownstream
,
int32_t
numOfDownstream
,
SExprInfo
*
pExprInfo
,
int32_t
numOfCols
,
SSDataBlock
*
pResBlock
,
SNode
*
pOnCondition
,
SExecTaskInfo
*
pTaskInfo
);
SOperatorInfo
*
createMergeJoinOperatorInfo
(
SOperatorInfo
**
pDownstream
,
int32_t
numOfDownstream
,
SJoinPhysiNode
*
pJoinNode
,
SExecTaskInfo
*
pTaskInfo
);
SOperatorInfo
*
createStreamSessionAggOperatorInfo
(
SOperatorInfo
*
downstream
,
SOperatorInfo
*
createStreamSessionAggOperatorInfo
(
SOperatorInfo
*
downstream
,
SPhysiNode
*
pPhyNode
,
SExecTaskInfo
*
pTaskInfo
);
SPhysiNode
*
pPhyNode
,
SExecTaskInfo
*
pTaskInfo
);
...
@@ -864,8 +848,8 @@ void setInputDataBlock(SOperatorInfo* pOperator, SqlFunctionCtx* pCtx, SSDataBlo
...
@@ -864,8 +848,8 @@ void setInputDataBlock(SOperatorInfo* pOperator, SqlFunctionCtx* pCtx, SSDataBlo
bool
isTaskKilled
(
SExecTaskInfo
*
pTaskInfo
);
bool
isTaskKilled
(
SExecTaskInfo
*
pTaskInfo
);
int32_t
checkForQueryBuf
(
size_t
numOfTables
);
int32_t
checkForQueryBuf
(
size_t
numOfTables
);
void
setTaskKilled
(
SExecTaskInfo
*
pTaskInfo
);
void
setTaskKilled
(
SExecTaskInfo
*
pTaskInfo
);
void
queryCostStatis
(
SExecTaskInfo
*
pTaskInfo
);
void
queryCostStatis
(
SExecTaskInfo
*
pTaskInfo
);
void
doDestroyTask
(
SExecTaskInfo
*
pTaskInfo
);
void
doDestroyTask
(
SExecTaskInfo
*
pTaskInfo
);
int32_t
getMaximumIdleDurationSec
();
int32_t
getMaximumIdleDurationSec
();
...
@@ -884,7 +868,7 @@ int32_t encodeOperator(SOperatorInfo* ops, char** data, int32_t *length);
...
@@ -884,7 +868,7 @@ int32_t encodeOperator(SOperatorInfo* ops, char** data, int32_t *length);
* length: the length of data
* length: the length of data
* return: result code, 0 means success
* return: result code, 0 means success
*/
*/
int32_t
decodeOperator
(
SOperatorInfo
*
ops
,
char
*
data
,
int32_t
length
);
int32_t
decodeOperator
(
SOperatorInfo
*
ops
,
c
onst
c
har
*
data
,
int32_t
length
);
void
setTaskStatus
(
SExecTaskInfo
*
pTaskInfo
,
int8_t
status
);
void
setTaskStatus
(
SExecTaskInfo
*
pTaskInfo
,
int8_t
status
);
int32_t
createExecTaskInfoImpl
(
SSubplan
*
pPlan
,
SExecTaskInfo
**
pTaskInfo
,
SReadHandle
*
pHandle
,
uint64_t
taskId
,
int32_t
createExecTaskInfoImpl
(
SSubplan
*
pPlan
,
SExecTaskInfo
**
pTaskInfo
,
SReadHandle
*
pHandle
,
uint64_t
taskId
,
...
@@ -914,8 +898,6 @@ int32_t finalizeResultRowIntoResultDataBlock(SDiskbasedBuf* pBuf, SResultRowPosi
...
@@ -914,8 +898,6 @@ int32_t finalizeResultRowIntoResultDataBlock(SDiskbasedBuf* pBuf, SResultRowPosi
SqlFunctionCtx
*
pCtx
,
SExprInfo
*
pExprInfo
,
int32_t
numOfExprs
,
const
int32_t
*
rowCellOffset
,
SqlFunctionCtx
*
pCtx
,
SExprInfo
*
pExprInfo
,
int32_t
numOfExprs
,
const
int32_t
*
rowCellOffset
,
SSDataBlock
*
pBlock
,
SExecTaskInfo
*
pTaskInfo
);
SSDataBlock
*
pBlock
,
SExecTaskInfo
*
pTaskInfo
);
int32_t
getTableList
(
void
*
metaHandle
,
int32_t
tableType
,
uint64_t
tableUid
,
STableListInfo
*
pListInfo
,
SNode
*
pTagCond
);
int32_t
createMultipleDataReaders
(
STableScanPhysiNode
*
pTableScanNode
,
SReadHandle
*
pHandle
,
int32_t
createMultipleDataReaders
(
STableScanPhysiNode
*
pTableScanNode
,
SReadHandle
*
pHandle
,
STableListInfo
*
pTableListInfo
,
SArray
*
arrayReader
,
uint64_t
queryId
,
STableListInfo
*
pTableListInfo
,
SArray
*
arrayReader
,
uint64_t
queryId
,
uint64_t
taskId
,
SNode
*
pTagCond
);
uint64_t
taskId
,
SNode
*
pTagCond
);
...
...
source/libs/executor/inc/tsort.h
浏览文件 @
2e590c30
...
@@ -63,7 +63,7 @@ typedef int32_t (*_sort_merge_compar_fn_t)(const void* p1, const void* p2, void*
...
@@ -63,7 +63,7 @@ typedef int32_t (*_sort_merge_compar_fn_t)(const void* p1, const void* p2, void*
* @param type
* @param type
* @return
* @return
*/
*/
SSortHandle
*
tsortCreateSortHandle
(
SArray
*
pOrderInfo
,
SArray
*
pIndexMap
,
int32_t
type
,
int32_t
pageSize
,
int32_t
numOfPages
,
SSDataBlock
*
pBlock
,
const
char
*
idstr
);
SSortHandle
*
tsortCreateSortHandle
(
SArray
*
pOrderInfo
,
int32_t
type
,
int32_t
pageSize
,
int32_t
numOfPages
,
SSDataBlock
*
pBlock
,
const
char
*
idstr
);
/**
/**
*
*
...
...
source/libs/executor/src/executil.c
浏览文件 @
2e590c30
此差异已折叠。
点击以展开。
source/libs/executor/src/executorMain.c
浏览文件 @
2e590c30
...
@@ -219,4 +219,23 @@ int32_t qGetExplainExecInfo(qTaskInfo_t tinfo, int32_t *resNum, SExplainExecInfo
...
@@ -219,4 +219,23 @@ int32_t qGetExplainExecInfo(qTaskInfo_t tinfo, int32_t *resNum, SExplainExecInfo
return
getOperatorExplainExecInfo
(
pTaskInfo
->
pRoot
,
pRes
,
&
capacity
,
resNum
);
return
getOperatorExplainExecInfo
(
pTaskInfo
->
pRoot
,
pRes
,
&
capacity
,
resNum
);
}
}
int32_t
qSerializeTaskStatus
(
qTaskInfo_t
tinfo
,
char
**
pOutput
,
int32_t
*
len
)
{
SExecTaskInfo
*
pTaskInfo
=
(
struct
SExecTaskInfo
*
)
tinfo
;
if
(
pTaskInfo
->
pRoot
==
NULL
)
{
return
TSDB_CODE_INVALID_PARA
;
}
return
encodeOperator
(
pTaskInfo
->
pRoot
,
pOutput
,
len
);
}
int32_t
qDeserializeTaskStatus
(
qTaskInfo_t
tinfo
,
const
char
*
pInput
,
int32_t
len
)
{
SExecTaskInfo
*
pTaskInfo
=
(
struct
SExecTaskInfo
*
)
tinfo
;
if
(
pTaskInfo
==
NULL
||
pInput
==
NULL
||
len
==
0
)
{
return
TSDB_CODE_INVALID_PARA
;
}
return
decodeOperator
(
pTaskInfo
->
pRoot
,
pInput
,
len
);
}
source/libs/executor/src/executorimpl.c
浏览文件 @
2e590c30
此差异已折叠。
点击以展开。
source/libs/executor/src/groupoperator.c
浏览文件 @
2e590c30
...
@@ -26,8 +26,10 @@
...
@@ -26,8 +26,10 @@
#include "ttypes.h"
#include "ttypes.h"
#include "executorInt.h"
#include "executorInt.h"
static
void
*
getCurrentDataGroupInfo
(
const
SPartitionOperatorInfo
*
pInfo
,
SDataGroupInfo
**
pGroupInfo
,
int32_t
len
);
static
int32_t
*
setupColumnOffset
(
const
SSDataBlock
*
pBlock
,
int32_t
rowCapacity
);
static
int32_t
*
setupColumnOffset
(
const
SSDataBlock
*
pBlock
,
int32_t
rowCapacity
);
static
void
*
getCurrentDataGroupInfo
(
const
SPartitionOperatorInfo
*
pInfo
,
SDataGroupInfo
**
pGroupInfo
,
int32_t
len
);
static
int32_t
setGroupResultOutputBuf
(
SOptrBasicInfo
*
binfo
,
int32_t
numOfCols
,
char
*
pData
,
int16_t
type
,
int16_t
bytes
,
int32_t
groupId
,
SDiskbasedBuf
*
pBuf
,
SExecTaskInfo
*
pTaskInfo
,
SAggSupporter
*
pAggSup
);
static
void
destroyGroupOperatorInfo
(
void
*
param
,
int32_t
numOfOutput
)
{
static
void
destroyGroupOperatorInfo
(
void
*
param
,
int32_t
numOfOutput
)
{
SGroupbyOperatorInfo
*
pInfo
=
(
SGroupbyOperatorInfo
*
)
param
;
SGroupbyOperatorInfo
*
pInfo
=
(
SGroupbyOperatorInfo
*
)
param
;
...
@@ -291,7 +293,7 @@ static SSDataBlock* hashGroupbyAggregate(SOperatorInfo* pOperator) {
...
@@ -291,7 +293,7 @@ static SSDataBlock* hashGroupbyAggregate(SOperatorInfo* pOperator) {
doBuildResultDatablock
(
pOperator
,
&
pInfo
->
binfo
,
&
pInfo
->
groupResInfo
,
pInfo
->
aggSup
.
pResultBuf
);
doBuildResultDatablock
(
pOperator
,
&
pInfo
->
binfo
,
&
pInfo
->
groupResInfo
,
pInfo
->
aggSup
.
pResultBuf
);
size_t
rows
=
pRes
->
info
.
rows
;
size_t
rows
=
pRes
->
info
.
rows
;
if
(
rows
==
0
||
!
has
hRemain
DataInGroupInfo
(
&
pInfo
->
groupResInfo
))
{
if
(
rows
==
0
||
!
hasDataInGroupInfo
(
&
pInfo
->
groupResInfo
))
{
doSetOperatorCompleted
(
pOperator
);
doSetOperatorCompleted
(
pOperator
);
}
}
...
@@ -355,7 +357,7 @@ static SSDataBlock* hashGroupbyAggregate(SOperatorInfo* pOperator) {
...
@@ -355,7 +357,7 @@ static SSDataBlock* hashGroupbyAggregate(SOperatorInfo* pOperator) {
doBuildResultDatablock
(
pOperator
,
&
pInfo
->
binfo
,
&
pInfo
->
groupResInfo
,
pInfo
->
aggSup
.
pResultBuf
);
doBuildResultDatablock
(
pOperator
,
&
pInfo
->
binfo
,
&
pInfo
->
groupResInfo
,
pInfo
->
aggSup
.
pResultBuf
);
doFilter
(
pInfo
->
pCondition
,
pRes
);
doFilter
(
pInfo
->
pCondition
,
pRes
);
bool
hasRemain
=
has
hRemain
DataInGroupInfo
(
&
pInfo
->
groupResInfo
);
bool
hasRemain
=
hasDataInGroupInfo
(
&
pInfo
->
groupResInfo
);
if
(
!
hasRemain
)
{
if
(
!
hasRemain
)
{
doSetOperatorCompleted
(
pOperator
);
doSetOperatorCompleted
(
pOperator
);
break
;
break
;
...
@@ -395,7 +397,7 @@ SOperatorInfo* createGroupOperatorInfo(SOperatorInfo* downstream, SExprInfo* pEx
...
@@ -395,7 +397,7 @@ SOperatorInfo* createGroupOperatorInfo(SOperatorInfo* downstream, SExprInfo* pEx
initResultSizeInfo
(
pOperator
,
4096
);
initResultSizeInfo
(
pOperator
,
4096
);
initAggInfo
(
&
pInfo
->
binfo
,
&
pInfo
->
aggSup
,
pExprInfo
,
numOfCols
,
pResultBlock
,
pInfo
->
groupKeyLen
,
pTaskInfo
->
id
.
str
);
initAggInfo
(
&
pInfo
->
binfo
,
&
pInfo
->
aggSup
,
pExprInfo
,
numOfCols
,
pResultBlock
,
pInfo
->
groupKeyLen
,
pTaskInfo
->
id
.
str
);
initResultRowInfo
(
&
pInfo
->
binfo
.
resultRowInfo
,
8
);
initResultRowInfo
(
&
pInfo
->
binfo
.
resultRowInfo
);
pOperator
->
name
=
"GroupbyAggOperator"
;
pOperator
->
name
=
"GroupbyAggOperator"
;
pOperator
->
blocking
=
true
;
pOperator
->
blocking
=
true
;
...
@@ -738,4 +740,18 @@ SOperatorInfo* createPartitionOperatorInfo(SOperatorInfo* downstream, SPartition
...
@@ -738,4 +740,18 @@ SOperatorInfo* createPartitionOperatorInfo(SOperatorInfo* downstream, SPartition
taosMemoryFreeClear
(
pInfo
);
taosMemoryFreeClear
(
pInfo
);
taosMemoryFreeClear
(
pOperator
);
taosMemoryFreeClear
(
pOperator
);
return
NULL
;
return
NULL
;
}
int32_t
setGroupResultOutputBuf
(
SOptrBasicInfo
*
binfo
,
int32_t
numOfCols
,
char
*
pData
,
int16_t
type
,
int16_t
bytes
,
int32_t
groupId
,
SDiskbasedBuf
*
pBuf
,
SExecTaskInfo
*
pTaskInfo
,
SAggSupporter
*
pAggSup
)
{
SResultRowInfo
*
pResultRowInfo
=
&
binfo
->
resultRowInfo
;
SqlFunctionCtx
*
pCtx
=
binfo
->
pCtx
;
SResultRow
*
pResultRow
=
doSetResultOutBufByKey
(
pBuf
,
pResultRowInfo
,
(
char
*
)
pData
,
bytes
,
true
,
groupId
,
pTaskInfo
,
false
,
pAggSup
);
assert
(
pResultRow
!=
NULL
);
setResultRowInitCtx
(
pResultRow
,
pCtx
,
numOfCols
,
binfo
->
rowCellInfoOffset
);
return
TSDB_CODE_SUCCESS
;
}
}
\ No newline at end of file
source/libs/executor/src/joinoperator.c
浏览文件 @
2e590c30
...
@@ -28,27 +28,32 @@ static SSDataBlock* doMergeJoin(struct SOperatorInfo* pOperator);
...
@@ -28,27 +28,32 @@ static SSDataBlock* doMergeJoin(struct SOperatorInfo* pOperator);
static
void
destroyMergeJoinOperator
(
void
*
param
,
int32_t
numOfOutput
);
static
void
destroyMergeJoinOperator
(
void
*
param
,
int32_t
numOfOutput
);
static
void
extractTimeCondition
(
SJoinOperatorInfo
*
Info
,
SLogicConditionNode
*
pLogicConditionNode
);
static
void
extractTimeCondition
(
SJoinOperatorInfo
*
Info
,
SLogicConditionNode
*
pLogicConditionNode
);
SOperatorInfo
*
createMergeJoinOperatorInfo
(
SOperatorInfo
**
pDownstream
,
int32_t
numOfDownstream
,
SExprInfo
*
pExprInfo
,
SOperatorInfo
*
createMergeJoinOperatorInfo
(
SOperatorInfo
**
pDownstream
,
int32_t
numOfDownstream
,
SJoinPhysiNode
*
pJoinNode
,
int32_t
numOfCols
,
SSDataBlock
*
pResBlock
,
SNode
*
pOnCondition
,
SExecTaskInfo
*
pTaskInfo
)
{
SExecTaskInfo
*
pTaskInfo
)
{
SJoinOperatorInfo
*
pInfo
=
taosMemoryCalloc
(
1
,
sizeof
(
SJoinOperatorInfo
));
SJoinOperatorInfo
*
pInfo
=
taosMemoryCalloc
(
1
,
sizeof
(
SJoinOperatorInfo
));
SOperatorInfo
*
pOperator
=
taosMemoryCalloc
(
1
,
sizeof
(
SOperatorInfo
));
SOperatorInfo
*
pOperator
=
taosMemoryCalloc
(
1
,
sizeof
(
SOperatorInfo
));
if
(
pOperator
==
NULL
||
pInfo
==
NULL
)
{
if
(
pOperator
==
NULL
||
pInfo
==
NULL
)
{
goto
_error
;
goto
_error
;
}
}
SSDataBlock
*
pResBlock
=
createResDataBlock
(
pJoinNode
->
node
.
pOutputDataBlockDesc
);
int32_t
numOfCols
=
0
;
SExprInfo
*
pExprInfo
=
createExprInfo
(
pJoinNode
->
pTargets
,
NULL
,
&
numOfCols
);
initResultSizeInfo
(
pOperator
,
4096
);
initResultSizeInfo
(
pOperator
,
4096
);
pInfo
->
pRes
=
pResBlock
;
pInfo
->
pRes
=
pResBlock
;
pOperator
->
name
=
"MergeJoinOperator"
;
pOperator
->
name
=
"MergeJoinOperator"
;
pOperator
->
operatorType
=
QUERY_NODE_PHYSICAL_PLAN_MERGE_JOIN
;
pOperator
->
operatorType
=
QUERY_NODE_PHYSICAL_PLAN_MERGE_JOIN
;
pOperator
->
blocking
=
false
;
pOperator
->
blocking
=
false
;
pOperator
->
status
=
OP_NOT_OPENED
;
pOperator
->
status
=
OP_NOT_OPENED
;
pOperator
->
pExpr
=
pExprInfo
;
pOperator
->
pExpr
=
pExprInfo
;
pOperator
->
numOfExprs
=
numOfCols
;
pOperator
->
numOfExprs
=
numOfCols
;
pOperator
->
info
=
pInfo
;
pOperator
->
info
=
pInfo
;
pOperator
->
pTaskInfo
=
pTaskInfo
;
pOperator
->
pTaskInfo
=
pTaskInfo
;
SNode
*
pOnCondition
=
pJoinNode
->
pOnConditions
;
if
(
nodeType
(
pOnCondition
)
==
QUERY_NODE_OPERATOR
)
{
if
(
nodeType
(
pOnCondition
)
==
QUERY_NODE_OPERATOR
)
{
SOperatorNode
*
pNode
=
(
SOperatorNode
*
)
pOnCondition
;
SOperatorNode
*
pNode
=
(
SOperatorNode
*
)
pOnCondition
;
setJoinColumnInfo
(
&
pInfo
->
leftCol
,
(
SColumnNode
*
)
pNode
->
pLeft
);
setJoinColumnInfo
(
&
pInfo
->
leftCol
,
(
SColumnNode
*
)
pNode
->
pLeft
);
...
...
source/libs/executor/src/scanoperator.c
浏览文件 @
2e590c30
...
@@ -496,18 +496,6 @@ static SSDataBlock* doTableScan(SOperatorInfo* pOperator) {
...
@@ -496,18 +496,6 @@ static SSDataBlock* doTableScan(SOperatorInfo* pOperator) {
return
NULL
;
return
NULL
;
}
}
SInterval
extractIntervalInfo
(
const
STableScanPhysiNode
*
pTableScanNode
)
{
SInterval
interval
=
{
.
interval
=
pTableScanNode
->
interval
,
.
sliding
=
pTableScanNode
->
sliding
,
.
intervalUnit
=
pTableScanNode
->
intervalUnit
,
.
slidingUnit
=
pTableScanNode
->
slidingUnit
,
.
offset
=
pTableScanNode
->
offset
,
};
return
interval
;
}
static
int32_t
getTableScannerExecInfo
(
struct
SOperatorInfo
*
pOptr
,
void
**
pOptrExplain
,
uint32_t
*
len
)
{
static
int32_t
getTableScannerExecInfo
(
struct
SOperatorInfo
*
pOptr
,
void
**
pOptrExplain
,
uint32_t
*
len
)
{
SFileBlockLoadRecorder
*
pRecorder
=
taosMemoryCalloc
(
1
,
sizeof
(
SFileBlockLoadRecorder
));
SFileBlockLoadRecorder
*
pRecorder
=
taosMemoryCalloc
(
1
,
sizeof
(
SFileBlockLoadRecorder
));
STableScanInfo
*
pTableScanInfo
=
pOptr
->
info
;
STableScanInfo
*
pTableScanInfo
=
pOptr
->
info
;
...
@@ -520,7 +508,7 @@ static int32_t getTableScannerExecInfo(struct SOperatorInfo* pOptr, void** pOptr
...
@@ -520,7 +508,7 @@ static int32_t getTableScannerExecInfo(struct SOperatorInfo* pOptr, void** pOptr
static
void
destroyTableScanOperatorInfo
(
void
*
param
,
int32_t
numOfOutput
)
{
static
void
destroyTableScanOperatorInfo
(
void
*
param
,
int32_t
numOfOutput
)
{
STableScanInfo
*
pTableScanInfo
=
(
STableScanInfo
*
)
param
;
STableScanInfo
*
pTableScanInfo
=
(
STableScanInfo
*
)
param
;
blockDataDestroy
(
pTableScanInfo
->
pResBlock
);
blockDataDestroy
(
pTableScanInfo
->
pResBlock
);
clea
r
upQueryTableDataCond
(
&
pTableScanInfo
->
cond
);
clea
n
upQueryTableDataCond
(
&
pTableScanInfo
->
cond
);
tsdbReaderClose
(
pTableScanInfo
->
dataReader
);
tsdbReaderClose
(
pTableScanInfo
->
dataReader
);
...
@@ -542,8 +530,7 @@ SOperatorInfo* createTableScanOperatorInfo(STableScanPhysiNode* pTableScanNode,
...
@@ -542,8 +530,7 @@ SOperatorInfo* createTableScanOperatorInfo(STableScanPhysiNode* pTableScanNode,
SDataBlockDescNode
*
pDescNode
=
pTableScanNode
->
scan
.
node
.
pOutputDataBlockDesc
;
SDataBlockDescNode
*
pDescNode
=
pTableScanNode
->
scan
.
node
.
pOutputDataBlockDesc
;
int32_t
numOfCols
=
0
;
int32_t
numOfCols
=
0
;
SArray
*
pColList
=
SArray
*
pColList
=
extractColMatchInfo
(
pTableScanNode
->
scan
.
pScanCols
,
pDescNode
,
&
numOfCols
,
COL_MATCH_FROM_COL_ID
);
extractColMatchInfo
(
pTableScanNode
->
scan
.
pScanCols
,
pDescNode
,
&
numOfCols
,
pTaskInfo
,
COL_MATCH_FROM_COL_ID
);
int32_t
code
=
initQueryTableDataCond
(
&
pInfo
->
cond
,
pTableScanNode
);
int32_t
code
=
initQueryTableDataCond
(
&
pInfo
->
cond
,
pTableScanNode
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
...
@@ -1066,8 +1053,7 @@ SOperatorInfo* createStreamScanOperatorInfo(void* pDataReader, SReadHandle* pHan
...
@@ -1066,8 +1053,7 @@ SOperatorInfo* createStreamScanOperatorInfo(void* pDataReader, SReadHandle* pHan
STableScanInfo
*
pSTInfo
=
(
STableScanInfo
*
)
pTableScanDummy
->
info
;
STableScanInfo
*
pSTInfo
=
(
STableScanInfo
*
)
pTableScanDummy
->
info
;
int32_t
numOfCols
=
0
;
int32_t
numOfCols
=
0
;
pInfo
->
pColMatchInfo
=
pInfo
->
pColMatchInfo
=
extractColMatchInfo
(
pScanPhyNode
->
pScanCols
,
pDescNode
,
&
numOfCols
,
COL_MATCH_FROM_COL_ID
);
extractColMatchInfo
(
pScanPhyNode
->
pScanCols
,
pDescNode
,
&
numOfCols
,
pTaskInfo
,
COL_MATCH_FROM_COL_ID
);
int32_t
numOfOutput
=
taosArrayGetSize
(
pInfo
->
pColMatchInfo
);
int32_t
numOfOutput
=
taosArrayGetSize
(
pInfo
->
pColMatchInfo
);
SArray
*
pColIds
=
taosArrayInit
(
numOfOutput
,
sizeof
(
int16_t
));
SArray
*
pColIds
=
taosArrayInit
(
numOfOutput
,
sizeof
(
int16_t
));
...
@@ -1525,7 +1511,7 @@ static SSDataBlock* doSysTableScan(SOperatorInfo* pOperator) {
...
@@ -1525,7 +1511,7 @@ static SSDataBlock* doSysTableScan(SOperatorInfo* pOperator) {
}
}
}
}
se
tDataBlockFromFetchRsp
(
pInfo
->
pRes
,
&
pInfo
->
loadInfo
,
pRsp
->
numOfRows
,
pRsp
->
data
,
pRsp
->
compLen
,
extrac
tDataBlockFromFetchRsp
(
pInfo
->
pRes
,
&
pInfo
->
loadInfo
,
pRsp
->
numOfRows
,
pRsp
->
data
,
pRsp
->
compLen
,
pOperator
->
numOfExprs
,
startTs
,
NULL
,
pInfo
->
scanCols
);
pOperator
->
numOfExprs
,
startTs
,
NULL
,
pInfo
->
scanCols
);
// todo log the filter info
// todo log the filter info
...
@@ -1614,7 +1600,7 @@ SOperatorInfo* createSysTableScanOperatorInfo(void* readHandle, SSystemTableScan
...
@@ -1614,7 +1600,7 @@ SOperatorInfo* createSysTableScanOperatorInfo(void* readHandle, SSystemTableScan
SSDataBlock
*
pResBlock
=
createResDataBlock
(
pDescNode
);
SSDataBlock
*
pResBlock
=
createResDataBlock
(
pDescNode
);
int32_t
num
=
0
;
int32_t
num
=
0
;
SArray
*
colList
=
extractColMatchInfo
(
pScanNode
->
pScanCols
,
pDescNode
,
&
num
,
pTaskInfo
,
COL_MATCH_FROM_COL_ID
);
SArray
*
colList
=
extractColMatchInfo
(
pScanNode
->
pScanCols
,
pDescNode
,
&
num
,
COL_MATCH_FROM_COL_ID
);
pInfo
->
accountId
=
pScanPhyNode
->
accountId
;
pInfo
->
accountId
=
pScanPhyNode
->
accountId
;
pInfo
->
showRewrite
=
pScanPhyNode
->
showRewrite
;
pInfo
->
showRewrite
=
pScanPhyNode
->
showRewrite
;
...
@@ -1820,27 +1806,26 @@ SOperatorInfo* createTagScanOperatorInfo(SReadHandle* pReadHandle, STagScanPhysi
...
@@ -1820,27 +1806,26 @@ SOperatorInfo* createTagScanOperatorInfo(SReadHandle* pReadHandle, STagScanPhysi
SDataBlockDescNode
*
pDescNode
=
pPhyNode
->
node
.
pOutputDataBlockDesc
;
SDataBlockDescNode
*
pDescNode
=
pPhyNode
->
node
.
pOutputDataBlockDesc
;
int32_t
num
=
0
;
int32_t
numOfExprs
=
0
;
int32_t
numOfExprs
=
0
;
SExprInfo
*
pExprInfo
=
createExprInfo
(
pPhyNode
->
pScanPseudoCols
,
NULL
,
&
numOfExprs
);
SExprInfo
*
pExprInfo
=
createExprInfo
(
pPhyNode
->
pScanPseudoCols
,
NULL
,
&
numOfExprs
);
SArray
*
colList
=
extractColMatchInfo
(
pPhyNode
->
pScanPseudoCols
,
pDescNode
,
&
num
,
COL_MATCH_FROM_COL_ID
);
int32_t
num
=
0
;
pInfo
->
pTableList
=
pTableListInfo
;
SArray
*
colList
=
extractColMatchInfo
(
pPhyNode
->
pScanPseudoCols
,
pDescNode
,
&
num
,
pTaskInfo
,
COL_MATCH_FROM_COL_ID
);
pInfo
->
pColMatchInfo
=
colList
;
pInfo
->
pRes
=
createResDataBlock
(
pDescNode
);
pInfo
->
readHandle
=
*
pReadHandle
;
pInfo
->
curPos
=
0
;
pInfo
->
pFilterNode
=
pPhyNode
->
node
.
pConditions
;
pInfo
->
pTableList
=
pTableListInfo
;
pOperator
->
name
=
"TagScanOperator"
;
pInfo
->
pColMatchInfo
=
colList
;
pInfo
->
pRes
=
createResDataBlock
(
pDescNode
);
;
pInfo
->
readHandle
=
*
pReadHandle
;
pInfo
->
curPos
=
0
;
pInfo
->
pFilterNode
=
pPhyNode
->
node
.
pConditions
;
pOperator
->
name
=
"TagScanOperator"
;
pOperator
->
operatorType
=
QUERY_NODE_PHYSICAL_PLAN_TAG_SCAN
;
pOperator
->
operatorType
=
QUERY_NODE_PHYSICAL_PLAN_TAG_SCAN
;
pOperator
->
blocking
=
false
;
pOperator
->
blocking
=
false
;
pOperator
->
status
=
OP_NOT_OPENED
;
pOperator
->
status
=
OP_NOT_OPENED
;
pOperator
->
info
=
pInfo
;
pOperator
->
info
=
pInfo
;
pOperator
->
pExpr
=
pExprInfo
;
pOperator
->
pExpr
=
pExprInfo
;
pOperator
->
numOfExprs
=
numOfExprs
;
pOperator
->
numOfExprs
=
numOfExprs
;
pOperator
->
pTaskInfo
=
pTaskInfo
;
pOperator
->
pTaskInfo
=
pTaskInfo
;
initResultSizeInfo
(
pOperator
,
4096
);
initResultSizeInfo
(
pOperator
,
4096
);
blockDataEnsureCapacity
(
pInfo
->
pRes
,
pOperator
->
resultInfo
.
capacity
);
blockDataEnsureCapacity
(
pInfo
->
pRes
,
pOperator
->
resultInfo
.
capacity
);
...
@@ -1910,7 +1895,7 @@ int32_t createMultipleDataReaders(STableScanPhysiNode* pTableScanNode, SReadHand
...
@@ -1910,7 +1895,7 @@ int32_t createMultipleDataReaders(STableScanPhysiNode* pTableScanNode, SReadHand
STableListInfo
*
pTableListInfo
,
SArray
*
arrayReader
,
uint64_t
queryId
,
STableListInfo
*
pTableListInfo
,
SArray
*
arrayReader
,
uint64_t
queryId
,
uint64_t
taskId
,
SNode
*
pTagCond
)
{
uint64_t
taskId
,
SNode
*
pTagCond
)
{
int32_t
code
=
int32_t
code
=
getTableList
(
pHandle
->
meta
,
pTableScanNode
->
scan
.
tableType
,
pTableScanNode
->
scan
.
uid
,
pTableListInfo
,
pTagCond
);
getTableList
(
pHandle
->
meta
,
&
pTableScanNode
->
scan
,
pTableListInfo
,
pTagCond
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
goto
_error
;
goto
_error
;
}
}
...
@@ -1938,7 +1923,7 @@ int32_t createMultipleDataReaders(STableScanPhysiNode* pTableScanNode, SReadHand
...
@@ -1938,7 +1923,7 @@ int32_t createMultipleDataReaders(STableScanPhysiNode* pTableScanNode, SReadHand
taosArrayDestroy
(
subListInfo
->
pTableList
);
taosArrayDestroy
(
subListInfo
->
pTableList
);
taosMemoryFree
(
subListInfo
);
taosMemoryFree
(
subListInfo
);
}
}
clea
r
upQueryTableDataCond
(
&
cond
);
clea
n
upQueryTableDataCond
(
&
cond
);
return
0
;
return
0
;
...
@@ -2136,7 +2121,7 @@ int32_t doOpenTableMergeScanOperator(SOperatorInfo* pOperator) {
...
@@ -2136,7 +2121,7 @@ int32_t doOpenTableMergeScanOperator(SOperatorInfo* pOperator) {
int32_t
numOfBufPage
=
pInfo
->
sortBufSize
/
pInfo
->
bufPageSize
;
int32_t
numOfBufPage
=
pInfo
->
sortBufSize
/
pInfo
->
bufPageSize
;
pInfo
->
pSortHandle
=
pInfo
->
pSortHandle
=
tsortCreateSortHandle
(
pInfo
->
pSortInfo
,
pInfo
->
pColMatchInfo
,
SORT_MULTISOURCE_MERGE
,
pInfo
->
bufPageSize
,
tsortCreateSortHandle
(
pInfo
->
pSortInfo
,
SORT_MULTISOURCE_MERGE
,
pInfo
->
bufPageSize
,
numOfBufPage
,
pInfo
->
pSortInputBlock
,
pTaskInfo
->
id
.
str
);
numOfBufPage
,
pInfo
->
pSortInputBlock
,
pTaskInfo
->
id
.
str
);
tsortSetFetchRawDataFp
(
pInfo
->
pSortHandle
,
getTableDataBlock
,
NULL
,
NULL
);
tsortSetFetchRawDataFp
(
pInfo
->
pSortHandle
,
getTableDataBlock
,
NULL
,
NULL
);
...
@@ -2213,7 +2198,7 @@ SSDataBlock* doTableMergeScan(SOperatorInfo* pOperator) {
...
@@ -2213,7 +2198,7 @@ SSDataBlock* doTableMergeScan(SOperatorInfo* pOperator) {
void
destroyTableMergeScanOperatorInfo
(
void
*
param
,
int32_t
numOfOutput
)
{
void
destroyTableMergeScanOperatorInfo
(
void
*
param
,
int32_t
numOfOutput
)
{
STableMergeScanInfo
*
pTableScanInfo
=
(
STableMergeScanInfo
*
)
param
;
STableMergeScanInfo
*
pTableScanInfo
=
(
STableMergeScanInfo
*
)
param
;
clea
r
upQueryTableDataCond
(
&
pTableScanInfo
->
cond
);
clea
n
upQueryTableDataCond
(
&
pTableScanInfo
->
cond
);
for
(
int32_t
i
=
0
;
i
<
taosArrayGetSize
(
pTableScanInfo
->
dataReaders
);
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
taosArrayGetSize
(
pTableScanInfo
->
dataReaders
);
++
i
)
{
STsdbReader
*
reader
=
taosArrayGetP
(
pTableScanInfo
->
dataReaders
,
i
);
STsdbReader
*
reader
=
taosArrayGetP
(
pTableScanInfo
->
dataReaders
,
i
);
...
@@ -2263,7 +2248,7 @@ SOperatorInfo* createTableMergeScanOperatorInfo(STableScanPhysiNode* pTableScanN
...
@@ -2263,7 +2248,7 @@ SOperatorInfo* createTableMergeScanOperatorInfo(STableScanPhysiNode* pTableScanN
int32_t
numOfCols
=
0
;
int32_t
numOfCols
=
0
;
SArray
*
pColList
=
SArray
*
pColList
=
extractColMatchInfo
(
pTableScanNode
->
scan
.
pScanCols
,
pDescNode
,
&
numOfCols
,
pTaskInfo
,
COL_MATCH_FROM_COL_ID
);
extractColMatchInfo
(
pTableScanNode
->
scan
.
pScanCols
,
pDescNode
,
&
numOfCols
,
COL_MATCH_FROM_COL_ID
);
int32_t
code
=
initQueryTableDataCond
(
&
pInfo
->
cond
,
pTableScanNode
);
int32_t
code
=
initQueryTableDataCond
(
&
pInfo
->
cond
,
pTableScanNode
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
...
...
source/libs/executor/src/sortoperator.c
浏览文件 @
2e590c30
...
@@ -22,41 +22,52 @@ static int32_t getExplainExecInfo(SOperatorInfo* pOptr, void** pOptrExplain
...
@@ -22,41 +22,52 @@ static int32_t getExplainExecInfo(SOperatorInfo* pOptr, void** pOptrExplain
static
void
destroyOrderOperatorInfo
(
void
*
param
,
int32_t
numOfOutput
);
static
void
destroyOrderOperatorInfo
(
void
*
param
,
int32_t
numOfOutput
);
SOperatorInfo
*
createSortOperatorInfo
(
SOperatorInfo
*
downstream
,
SSDataBlock
*
pResBlock
,
SArray
*
pSortInfo
,
SOperatorInfo
*
createSortOperatorInfo
(
SOperatorInfo
*
downstream
,
SSortPhysiNode
*
pSortPhyNode
,
SExecTaskInfo
*
pTaskInfo
)
{
SExprInfo
*
pExprInfo
,
int32_t
numOfCols
,
SArray
*
pColMatchColInfo
,
SExecTaskInfo
*
pTaskInfo
)
{
SSortOperatorInfo
*
pInfo
=
taosMemoryCalloc
(
1
,
sizeof
(
SSortOperatorInfo
));
SSortOperatorInfo
*
pInfo
=
taosMemoryCalloc
(
1
,
sizeof
(
SSortOperatorInfo
));
SOperatorInfo
*
pOperator
=
taosMemoryCalloc
(
1
,
sizeof
(
SOperatorInfo
));
SOperatorInfo
*
pOperator
=
taosMemoryCalloc
(
1
,
sizeof
(
SOperatorInfo
));
int32_t
rowSize
=
pResBlock
->
info
.
rowSize
;
if
(
pInfo
==
NULL
||
pOperator
==
NULL
/* || rowSize > 100 * 1024 * 1024*/
)
{
if
(
pInfo
==
NULL
||
pOperator
==
NULL
||
rowSize
>
100
*
1024
*
1024
)
{
goto
_error
;
goto
_error
;
}
}
pOperator
->
pExpr
=
pExprInfo
;
SDataBlockDescNode
*
pDescNode
=
pSortPhyNode
->
node
.
pOutputDataBlockDesc
;
pOperator
->
numOfExprs
=
numOfCols
;
int32_t
numOfCols
=
0
;
SSDataBlock
*
pResBlock
=
createResDataBlock
(
pDescNode
);
SExprInfo
*
pExprInfo
=
createExprInfo
(
pSortPhyNode
->
pExprs
,
NULL
,
&
numOfCols
);
int32_t
numOfOutputCols
=
0
;
SArray
*
pColMatchColInfo
=
extractColMatchInfo
(
pSortPhyNode
->
pTargets
,
pDescNode
,
&
numOfOutputCols
,
COL_MATCH_FROM_SLOT_ID
);
pInfo
->
binfo
.
pCtx
=
createSqlFunctionCtx
(
pExprInfo
,
numOfCols
,
&
pInfo
->
binfo
.
rowCellInfoOffset
);
pInfo
->
binfo
.
pCtx
=
createSqlFunctionCtx
(
pExprInfo
,
numOfCols
,
&
pInfo
->
binfo
.
rowCellInfoOffset
);
pInfo
->
binfo
.
pRes
=
pResBlock
;
pInfo
->
binfo
.
pRes
=
pResBlock
;
initResultSizeInfo
(
pOperator
,
1024
);
initResultSizeInfo
(
pOperator
,
1024
);
pInfo
->
pSortInfo
=
pSortInfo
;
pInfo
->
pSortInfo
=
createSortInfo
(
pSortPhyNode
->
pSortKeys
);
;
pInfo
->
pColMatchInfo
=
pColMatchColInfo
;
pInfo
->
pColMatchInfo
=
pColMatchColInfo
;
pOperator
->
name
=
"SortOperator"
;
pOperator
->
name
=
"SortOperator"
;
pOperator
->
operatorType
=
QUERY_NODE_PHYSICAL_PLAN_SORT
;
pOperator
->
operatorType
=
QUERY_NODE_PHYSICAL_PLAN_SORT
;
pOperator
->
blocking
=
true
;
pOperator
->
blocking
=
true
;
pOperator
->
status
=
OP_NOT_OPENED
;
pOperator
->
status
=
OP_NOT_OPENED
;
pOperator
->
info
=
pInfo
;
pOperator
->
info
=
pInfo
;
pOperator
->
pExpr
=
pExprInfo
;
pOperator
->
numOfExprs
=
numOfCols
;
pOperator
->
pTaskInfo
=
pTaskInfo
;
// lazy evaluation for the following parameter since the input datablock is not known till now.
// lazy evaluation for the following parameter since the input datablock is not known till now.
// pInfo->bufPageSize = rowSize < 1024 ? 1024 * 2 : rowSize * 2; // there are headers, so pageSize = rowSize +
// pInfo->bufPageSize = rowSize < 1024 ? 1024 * 2 : rowSize * 2;
// header pInfo->sortBufSize = pInfo->bufPageSize * 16; // TODO dynamic set the available sort buffer
// there are headers, so pageSize = rowSize + header pInfo->sortBufSize = pInfo->bufPageSize * 16;
// TODO dynamic set the available sort buffer
pOperator
->
pTaskInfo
=
pTaskInfo
;
pOperator
->
fpSet
=
createOperatorFpSet
(
doOpenSortOperator
,
doSort
,
NULL
,
NULL
,
destroyOrderOperatorInfo
,
NULL
,
NULL
,
pOperator
->
fpSet
=
createOperatorFpSet
(
doOpenSortOperator
,
doSort
,
NULL
,
NULL
,
destroyOrderOperatorInfo
,
NULL
,
NULL
,
getExplainExecInfo
);
getExplainExecInfo
);
int32_t
code
=
appendDownstream
(
pOperator
,
&
downstream
,
1
);
int32_t
code
=
appendDownstream
(
pOperator
,
&
downstream
,
1
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
goto
_error
;
}
return
pOperator
;
return
pOperator
;
_error:
_error:
...
@@ -154,7 +165,7 @@ int32_t doOpenSortOperator(SOperatorInfo* pOperator) {
...
@@ -154,7 +165,7 @@ int32_t doOpenSortOperator(SOperatorInfo* pOperator) {
pInfo
->
startTs
=
taosGetTimestampUs
();
pInfo
->
startTs
=
taosGetTimestampUs
();
// pInfo->binfo.pRes is not equalled to the input datablock.
// pInfo->binfo.pRes is not equalled to the input datablock.
pInfo
->
pSortHandle
=
tsortCreateSortHandle
(
pInfo
->
pSortInfo
,
pInfo
->
pColMatchInfo
,
SORT_SINGLESOURCE_SORT
,
-
1
,
-
1
,
pInfo
->
pSortHandle
=
tsortCreateSortHandle
(
pInfo
->
pSortInfo
,
SORT_SINGLESOURCE_SORT
,
-
1
,
-
1
,
NULL
,
pTaskInfo
->
id
.
str
);
NULL
,
pTaskInfo
->
id
.
str
);
tsortSetFetchRawDataFp
(
pInfo
->
pSortHandle
,
loadNextDataBlock
,
applyScalarFunction
,
pOperator
);
tsortSetFetchRawDataFp
(
pInfo
->
pSortHandle
,
loadNextDataBlock
,
applyScalarFunction
,
pOperator
);
...
@@ -248,7 +259,7 @@ int32_t doOpenMultiwaySortMergeOperator(SOperatorInfo* pOperator) {
...
@@ -248,7 +259,7 @@ int32_t doOpenMultiwaySortMergeOperator(SOperatorInfo* pOperator) {
int32_t
numOfBufPage
=
pInfo
->
sortBufSize
/
pInfo
->
bufPageSize
;
int32_t
numOfBufPage
=
pInfo
->
sortBufSize
/
pInfo
->
bufPageSize
;
pInfo
->
pSortHandle
=
tsortCreateSortHandle
(
pInfo
->
pSortInfo
,
pInfo
->
pColMatchInfo
,
SORT_MULTISOURCE_MERGE
,
pInfo
->
pSortHandle
=
tsortCreateSortHandle
(
pInfo
->
pSortInfo
,
SORT_MULTISOURCE_MERGE
,
pInfo
->
bufPageSize
,
numOfBufPage
,
pInfo
->
pInputBlock
,
pTaskInfo
->
id
.
str
);
pInfo
->
bufPageSize
,
numOfBufPage
,
pInfo
->
pInputBlock
,
pTaskInfo
->
id
.
str
);
tsortSetFetchRawDataFp
(
pInfo
->
pSortHandle
,
loadNextDataBlock
,
NULL
,
NULL
);
tsortSetFetchRawDataFp
(
pInfo
->
pSortHandle
,
loadNextDataBlock
,
NULL
,
NULL
);
...
...
source/libs/executor/src/timewindowoperator.c
浏览文件 @
2e590c30
...
@@ -1090,7 +1090,7 @@ static SSDataBlock* doStateWindowAgg(SOperatorInfo* pOperator) {
...
@@ -1090,7 +1090,7 @@ static SSDataBlock* doStateWindowAgg(SOperatorInfo* pOperator) {
if
(
pOperator
->
status
==
OP_RES_TO_RETURN
)
{
if
(
pOperator
->
status
==
OP_RES_TO_RETURN
)
{
doBuildResultDatablock
(
pOperator
,
pBInfo
,
&
pInfo
->
groupResInfo
,
pInfo
->
aggSup
.
pResultBuf
);
doBuildResultDatablock
(
pOperator
,
pBInfo
,
&
pInfo
->
groupResInfo
,
pInfo
->
aggSup
.
pResultBuf
);
if
(
pBInfo
->
pRes
->
info
.
rows
==
0
||
!
has
hRemain
DataInGroupInfo
(
&
pInfo
->
groupResInfo
))
{
if
(
pBInfo
->
pRes
->
info
.
rows
==
0
||
!
hasDataInGroupInfo
(
&
pInfo
->
groupResInfo
))
{
doSetOperatorCompleted
(
pOperator
);
doSetOperatorCompleted
(
pOperator
);
return
NULL
;
return
NULL
;
}
}
...
@@ -1122,7 +1122,7 @@ static SSDataBlock* doStateWindowAgg(SOperatorInfo* pOperator) {
...
@@ -1122,7 +1122,7 @@ static SSDataBlock* doStateWindowAgg(SOperatorInfo* pOperator) {
initGroupedResultInfo
(
&
pInfo
->
groupResInfo
,
pInfo
->
aggSup
.
pResultRowHashTable
,
TSDB_ORDER_ASC
);
initGroupedResultInfo
(
&
pInfo
->
groupResInfo
,
pInfo
->
aggSup
.
pResultRowHashTable
,
TSDB_ORDER_ASC
);
blockDataEnsureCapacity
(
pBInfo
->
pRes
,
pOperator
->
resultInfo
.
capacity
);
blockDataEnsureCapacity
(
pBInfo
->
pRes
,
pOperator
->
resultInfo
.
capacity
);
doBuildResultDatablock
(
pOperator
,
pBInfo
,
&
pInfo
->
groupResInfo
,
pInfo
->
aggSup
.
pResultBuf
);
doBuildResultDatablock
(
pOperator
,
pBInfo
,
&
pInfo
->
groupResInfo
,
pInfo
->
aggSup
.
pResultBuf
);
if
(
pBInfo
->
pRes
->
info
.
rows
==
0
||
!
has
hRemain
DataInGroupInfo
(
&
pInfo
->
groupResInfo
))
{
if
(
pBInfo
->
pRes
->
info
.
rows
==
0
||
!
hasDataInGroupInfo
(
&
pInfo
->
groupResInfo
))
{
doSetOperatorCompleted
(
pOperator
);
doSetOperatorCompleted
(
pOperator
);
}
}
...
@@ -1153,7 +1153,7 @@ static SSDataBlock* doBuildIntervalResult(SOperatorInfo* pOperator) {
...
@@ -1153,7 +1153,7 @@ static SSDataBlock* doBuildIntervalResult(SOperatorInfo* pOperator) {
blockDataEnsureCapacity
(
pBlock
,
pOperator
->
resultInfo
.
capacity
);
blockDataEnsureCapacity
(
pBlock
,
pOperator
->
resultInfo
.
capacity
);
doBuildResultDatablock
(
pOperator
,
&
pInfo
->
binfo
,
&
pInfo
->
groupResInfo
,
pInfo
->
aggSup
.
pResultBuf
);
doBuildResultDatablock
(
pOperator
,
&
pInfo
->
binfo
,
&
pInfo
->
groupResInfo
,
pInfo
->
aggSup
.
pResultBuf
);
if
(
pBlock
->
info
.
rows
==
0
||
!
has
hRemain
DataInGroupInfo
(
&
pInfo
->
groupResInfo
))
{
if
(
pBlock
->
info
.
rows
==
0
||
!
hasDataInGroupInfo
(
&
pInfo
->
groupResInfo
))
{
doSetOperatorCompleted
(
pOperator
);
doSetOperatorCompleted
(
pOperator
);
}
}
...
@@ -1176,7 +1176,7 @@ static void finalizeUpdatedResult(int32_t numOfOutput, SDiskbasedBuf* pBuf, SArr
...
@@ -1176,7 +1176,7 @@ static void finalizeUpdatedResult(int32_t numOfOutput, SDiskbasedBuf* pBuf, SArr
SResultRow
*
pRow
=
(
SResultRow
*
)((
char
*
)
bufPage
+
pPos
->
pos
.
offset
);
SResultRow
*
pRow
=
(
SResultRow
*
)((
char
*
)
bufPage
+
pPos
->
pos
.
offset
);
for
(
int32_t
j
=
0
;
j
<
numOfOutput
;
++
j
)
{
for
(
int32_t
j
=
0
;
j
<
numOfOutput
;
++
j
)
{
SResultRowEntryInfo
*
pEntry
=
getResult
Cell
(
pRow
,
j
,
rowCellInfoOffset
);
SResultRowEntryInfo
*
pEntry
=
getResult
EntryInfo
(
pRow
,
j
,
rowCellInfoOffset
);
if
(
pRow
->
numOfRows
<
pEntry
->
numOfRes
)
{
if
(
pRow
->
numOfRows
<
pEntry
->
numOfRes
)
{
pRow
->
numOfRows
=
pEntry
->
numOfRes
;
pRow
->
numOfRows
=
pEntry
->
numOfRes
;
}
}
...
@@ -1199,7 +1199,7 @@ void doClearWindowImpl(SResultRowPosition* p1, SDiskbasedBuf* pResultBuf, SOptrB
...
@@ -1199,7 +1199,7 @@ void doClearWindowImpl(SResultRowPosition* p1, SDiskbasedBuf* pResultBuf, SOptrB
SResultRow
*
pResult
=
getResultRowByPos
(
pResultBuf
,
p1
);
SResultRow
*
pResult
=
getResultRowByPos
(
pResultBuf
,
p1
);
SqlFunctionCtx
*
pCtx
=
pBinfo
->
pCtx
;
SqlFunctionCtx
*
pCtx
=
pBinfo
->
pCtx
;
for
(
int32_t
i
=
0
;
i
<
numOfOutput
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
numOfOutput
;
++
i
)
{
pCtx
[
i
].
resultInfo
=
getResult
Cell
(
pResult
,
i
,
pBinfo
->
rowCellInfoOffset
);
pCtx
[
i
].
resultInfo
=
getResult
EntryInfo
(
pResult
,
i
,
pBinfo
->
rowCellInfoOffset
);
struct
SResultRowEntryInfo
*
pResInfo
=
pCtx
[
i
].
resultInfo
;
struct
SResultRowEntryInfo
*
pResInfo
=
pCtx
[
i
].
resultInfo
;
if
(
fmIsWindowPseudoColumnFunc
(
pCtx
[
i
].
functionId
))
{
if
(
fmIsWindowPseudoColumnFunc
(
pCtx
[
i
].
functionId
))
{
continue
;
continue
;
...
@@ -1301,7 +1301,7 @@ static SSDataBlock* doStreamIntervalAgg(SOperatorInfo* pOperator) {
...
@@ -1301,7 +1301,7 @@ static SSDataBlock* doStreamIntervalAgg(SOperatorInfo* pOperator) {
if
(
pOperator
->
status
==
OP_RES_TO_RETURN
)
{
if
(
pOperator
->
status
==
OP_RES_TO_RETURN
)
{
doBuildResultDatablock
(
pOperator
,
&
pInfo
->
binfo
,
&
pInfo
->
groupResInfo
,
pInfo
->
aggSup
.
pResultBuf
);
doBuildResultDatablock
(
pOperator
,
&
pInfo
->
binfo
,
&
pInfo
->
groupResInfo
,
pInfo
->
aggSup
.
pResultBuf
);
if
(
pInfo
->
binfo
.
pRes
->
info
.
rows
==
0
||
!
has
hRemain
DataInGroupInfo
(
&
pInfo
->
groupResInfo
))
{
if
(
pInfo
->
binfo
.
pRes
->
info
.
rows
==
0
||
!
hasDataInGroupInfo
(
&
pInfo
->
groupResInfo
))
{
pOperator
->
status
=
OP_EXEC_DONE
;
pOperator
->
status
=
OP_EXEC_DONE
;
}
}
return
pInfo
->
binfo
.
pRes
->
info
.
rows
==
0
?
NULL
:
pInfo
->
binfo
.
pRes
;
return
pInfo
->
binfo
.
pRes
->
info
.
rows
==
0
?
NULL
:
pInfo
->
binfo
.
pRes
;
...
@@ -1476,7 +1476,7 @@ SOperatorInfo* createIntervalOperatorInfo(SOperatorInfo* downstream, SExprInfo*
...
@@ -1476,7 +1476,7 @@ SOperatorInfo* createIntervalOperatorInfo(SOperatorInfo* downstream, SExprInfo*
}
}
}
}
initResultRowInfo
(
&
pInfo
->
binfo
.
resultRowInfo
,
(
int32_t
)
1
);
initResultRowInfo
(
&
pInfo
->
binfo
.
resultRowInfo
);
pOperator
->
name
=
"TimeIntervalAggOperator"
;
pOperator
->
name
=
"TimeIntervalAggOperator"
;
pOperator
->
operatorType
=
QUERY_NODE_PHYSICAL_PLAN_HASH_INTERVAL
;
pOperator
->
operatorType
=
QUERY_NODE_PHYSICAL_PLAN_HASH_INTERVAL
;
...
@@ -1533,7 +1533,7 @@ SOperatorInfo* createStreamIntervalOperatorInfo(SOperatorInfo* downstream, SExpr
...
@@ -1533,7 +1533,7 @@ SOperatorInfo* createStreamIntervalOperatorInfo(SOperatorInfo* downstream, SExpr
goto
_error
;
goto
_error
;
}
}
initResultRowInfo
(
&
pInfo
->
binfo
.
resultRowInfo
,
(
int32_t
)
1
);
initResultRowInfo
(
&
pInfo
->
binfo
.
resultRowInfo
);
pOperator
->
name
=
"StreamTimeIntervalAggOperator"
;
pOperator
->
name
=
"StreamTimeIntervalAggOperator"
;
pOperator
->
operatorType
=
QUERY_NODE_PHYSICAL_PLAN_HASH_INTERVAL
;
pOperator
->
operatorType
=
QUERY_NODE_PHYSICAL_PLAN_HASH_INTERVAL
;
...
@@ -1643,7 +1643,7 @@ static SSDataBlock* doSessionWindowAgg(SOperatorInfo* pOperator) {
...
@@ -1643,7 +1643,7 @@ static SSDataBlock* doSessionWindowAgg(SOperatorInfo* pOperator) {
if
(
pOperator
->
status
==
OP_RES_TO_RETURN
)
{
if
(
pOperator
->
status
==
OP_RES_TO_RETURN
)
{
doBuildResultDatablock
(
pOperator
,
pBInfo
,
&
pInfo
->
groupResInfo
,
pInfo
->
aggSup
.
pResultBuf
);
doBuildResultDatablock
(
pOperator
,
pBInfo
,
&
pInfo
->
groupResInfo
,
pInfo
->
aggSup
.
pResultBuf
);
if
(
pBInfo
->
pRes
->
info
.
rows
==
0
||
!
has
hRemain
DataInGroupInfo
(
&
pInfo
->
groupResInfo
))
{
if
(
pBInfo
->
pRes
->
info
.
rows
==
0
||
!
hasDataInGroupInfo
(
&
pInfo
->
groupResInfo
))
{
doSetOperatorCompleted
(
pOperator
);
doSetOperatorCompleted
(
pOperator
);
return
NULL
;
return
NULL
;
}
}
...
@@ -1678,7 +1678,7 @@ static SSDataBlock* doSessionWindowAgg(SOperatorInfo* pOperator) {
...
@@ -1678,7 +1678,7 @@ static SSDataBlock* doSessionWindowAgg(SOperatorInfo* pOperator) {
initGroupedResultInfo
(
&
pInfo
->
groupResInfo
,
pInfo
->
aggSup
.
pResultRowHashTable
,
TSDB_ORDER_ASC
);
initGroupedResultInfo
(
&
pInfo
->
groupResInfo
,
pInfo
->
aggSup
.
pResultRowHashTable
,
TSDB_ORDER_ASC
);
blockDataEnsureCapacity
(
pBInfo
->
pRes
,
pOperator
->
resultInfo
.
capacity
);
blockDataEnsureCapacity
(
pBInfo
->
pRes
,
pOperator
->
resultInfo
.
capacity
);
doBuildResultDatablock
(
pOperator
,
pBInfo
,
&
pInfo
->
groupResInfo
,
pInfo
->
aggSup
.
pResultBuf
);
doBuildResultDatablock
(
pOperator
,
pBInfo
,
&
pInfo
->
groupResInfo
,
pInfo
->
aggSup
.
pResultBuf
);
if
(
pBInfo
->
pRes
->
info
.
rows
==
0
||
!
has
hRemain
DataInGroupInfo
(
&
pInfo
->
groupResInfo
))
{
if
(
pBInfo
->
pRes
->
info
.
rows
==
0
||
!
hasDataInGroupInfo
(
&
pInfo
->
groupResInfo
))
{
doSetOperatorCompleted
(
pOperator
);
doSetOperatorCompleted
(
pOperator
);
}
}
...
@@ -1714,7 +1714,7 @@ static SSDataBlock* doTimeslice(SOperatorInfo* pOperator) {
...
@@ -1714,7 +1714,7 @@ static SSDataBlock* doTimeslice(SOperatorInfo* pOperator) {
// if (pOperator->status == OP_RES_TO_RETURN) {
// if (pOperator->status == OP_RES_TO_RETURN) {
// // doBuildResultDatablock(&pRuntimeEnv->groupResInfo, pRuntimeEnv, pIntervalInfo->pRes);
// // doBuildResultDatablock(&pRuntimeEnv->groupResInfo, pRuntimeEnv, pIntervalInfo->pRes);
// if (pResBlock->info.rows == 0 || !has
hRemain
DataInGroupInfo(&pSliceInfo->groupResInfo)) {
// if (pResBlock->info.rows == 0 || !hasDataInGroupInfo(&pSliceInfo->groupResInfo)) {
// doSetOperatorCompleted(pOperator);
// doSetOperatorCompleted(pOperator);
// }
// }
//
//
...
@@ -1908,7 +1908,7 @@ SOperatorInfo* createTimeSliceOperatorInfo(SOperatorInfo* downstream, SExprInfo*
...
@@ -1908,7 +1908,7 @@ SOperatorInfo* createTimeSliceOperatorInfo(SOperatorInfo* downstream, SExprInfo*
goto
_error
;
goto
_error
;
}
}
initResultRowInfo
(
&
pInfo
->
binfo
.
resultRowInfo
,
8
);
initResultRowInfo
(
&
pInfo
->
binfo
.
resultRowInfo
);
pInfo
->
pFillColInfo
=
createFillColInfo
(
pExprInfo
,
numOfCols
,
pValNode
);
pInfo
->
pFillColInfo
=
createFillColInfo
(
pExprInfo
,
numOfCols
,
pValNode
);
pInfo
->
binfo
.
pRes
=
pResultBlock
;
pInfo
->
binfo
.
pRes
=
pResultBlock
;
...
@@ -1956,7 +1956,7 @@ SOperatorInfo* createStatewindowOperatorInfo(SOperatorInfo* downstream, SExprInf
...
@@ -1956,7 +1956,7 @@ SOperatorInfo* createStatewindowOperatorInfo(SOperatorInfo* downstream, SExprInf
initResultSizeInfo
(
pOperator
,
4096
);
initResultSizeInfo
(
pOperator
,
4096
);
initAggInfo
(
&
pInfo
->
binfo
,
&
pInfo
->
aggSup
,
pExpr
,
numOfCols
,
pResBlock
,
keyBufSize
,
pTaskInfo
->
id
.
str
);
initAggInfo
(
&
pInfo
->
binfo
,
&
pInfo
->
aggSup
,
pExpr
,
numOfCols
,
pResBlock
,
keyBufSize
,
pTaskInfo
->
id
.
str
);
initResultRowInfo
(
&
pInfo
->
binfo
.
resultRowInfo
,
8
);
initResultRowInfo
(
&
pInfo
->
binfo
.
resultRowInfo
);
pInfo
->
twAggSup
=
*
pTwAggSup
;
pInfo
->
twAggSup
=
*
pTwAggSup
;
initExecTimeWindowInfo
(
&
pInfo
->
twAggSup
.
timeWindowData
,
&
pTaskInfo
->
window
);
initExecTimeWindowInfo
(
&
pInfo
->
twAggSup
.
timeWindowData
,
&
pTaskInfo
->
window
);
...
@@ -2006,7 +2006,7 @@ SOperatorInfo* createSessionAggOperatorInfo(SOperatorInfo* downstream, SExprInfo
...
@@ -2006,7 +2006,7 @@ SOperatorInfo* createSessionAggOperatorInfo(SOperatorInfo* downstream, SExprInfo
}
}
pInfo
->
twAggSup
=
*
pTwAggSupp
;
pInfo
->
twAggSup
=
*
pTwAggSupp
;
initResultRowInfo
(
&
pInfo
->
binfo
.
resultRowInfo
,
8
);
initResultRowInfo
(
&
pInfo
->
binfo
.
resultRowInfo
);
initExecTimeWindowInfo
(
&
pInfo
->
twAggSup
.
timeWindowData
,
&
pTaskInfo
->
window
);
initExecTimeWindowInfo
(
&
pInfo
->
twAggSup
.
timeWindowData
,
&
pTaskInfo
->
window
);
pInfo
->
tsSlotId
=
tsSlotId
;
pInfo
->
tsSlotId
=
tsSlotId
;
...
@@ -2153,7 +2153,7 @@ static void clearStreamIntervalOperator(SStreamFinalIntervalOperatorInfo* pInfo)
...
@@ -2153,7 +2153,7 @@ static void clearStreamIntervalOperator(SStreamFinalIntervalOperatorInfo* pInfo)
taosHashClear
(
pInfo
->
aggSup
.
pResultRowHashTable
);
taosHashClear
(
pInfo
->
aggSup
.
pResultRowHashTable
);
clearDiskbasedBuf
(
pInfo
->
aggSup
.
pResultBuf
);
clearDiskbasedBuf
(
pInfo
->
aggSup
.
pResultBuf
);
cleanupResultRowInfo
(
&
pInfo
->
binfo
.
resultRowInfo
);
cleanupResultRowInfo
(
&
pInfo
->
binfo
.
resultRowInfo
);
initResultRowInfo
(
&
pInfo
->
binfo
.
resultRowInfo
,
1
);
initResultRowInfo
(
&
pInfo
->
binfo
.
resultRowInfo
);
}
}
static
void
clearUpdateDataBlock
(
SSDataBlock
*
pBlock
)
{
static
void
clearUpdateDataBlock
(
SSDataBlock
*
pBlock
)
{
...
@@ -2319,7 +2319,7 @@ SOperatorInfo* createStreamFinalIntervalOperatorInfo(SOperatorInfo* downstream,
...
@@ -2319,7 +2319,7 @@ SOperatorInfo* createStreamFinalIntervalOperatorInfo(SOperatorInfo* downstream,
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
goto
_error
;
goto
_error
;
}
}
initResultRowInfo
(
&
pInfo
->
binfo
.
resultRowInfo
,
(
int32_t
)
1
);
initResultRowInfo
(
&
pInfo
->
binfo
.
resultRowInfo
);
pInfo
->
pChildren
=
NULL
;
pInfo
->
pChildren
=
NULL
;
if
(
numOfChild
>
0
)
{
if
(
numOfChild
>
0
)
{
pInfo
->
pChildren
=
taosArrayInit
(
numOfChild
,
sizeof
(
SOperatorInfo
));
pInfo
->
pChildren
=
taosArrayInit
(
numOfChild
,
sizeof
(
SOperatorInfo
));
...
@@ -2456,10 +2456,12 @@ SOperatorInfo* createStreamSessionAggOperatorInfo(SOperatorInfo* downstream, SPh
...
@@ -2456,10 +2456,12 @@ SOperatorInfo* createStreamSessionAggOperatorInfo(SOperatorInfo* downstream, SPh
}
}
initDummyFunction
(
pInfo
->
pDummyCtx
,
pInfo
->
binfo
.
pCtx
,
numOfCols
);
initDummyFunction
(
pInfo
->
pDummyCtx
,
pInfo
->
binfo
.
pCtx
,
numOfCols
);
pInfo
->
twAggSup
=
(
STimeWindowAggSupp
)
{.
waterMark
=
pSessionNode
->
window
.
watermark
,
pInfo
->
twAggSup
=
(
STimeWindowAggSupp
)
{
.
waterMark
=
pSessionNode
->
window
.
watermark
,
.
calTrigger
=
pSessionNode
->
window
.
triggerType
,
.
calTrigger
=
pSessionNode
->
window
.
triggerType
,
.
maxTs
=
INT64_MIN
};
.
maxTs
=
INT64_MIN
};
initResultRowInfo
(
&
pInfo
->
binfo
.
resultRowInfo
,
8
);
initResultRowInfo
(
&
pInfo
->
binfo
.
resultRowInfo
);
initExecTimeWindowInfo
(
&
pInfo
->
twAggSup
.
timeWindowData
,
&
pTaskInfo
->
window
);
initExecTimeWindowInfo
(
&
pInfo
->
twAggSup
.
timeWindowData
,
&
pTaskInfo
->
window
);
pInfo
->
primaryTsIndex
=
tsSlotId
;
pInfo
->
primaryTsIndex
=
tsSlotId
;
...
@@ -2901,7 +2903,7 @@ static SSDataBlock* doStreamSessionAgg(SOperatorInfo* pOperator) {
...
@@ -2901,7 +2903,7 @@ static SSDataBlock* doStreamSessionAgg(SOperatorInfo* pOperator) {
return
pInfo
->
pDelRes
;
return
pInfo
->
pDelRes
;
}
}
doBuildResultDatablock
(
pOperator
,
pBInfo
,
&
pInfo
->
groupResInfo
,
pInfo
->
streamAggSup
.
pResultBuf
);
doBuildResultDatablock
(
pOperator
,
pBInfo
,
&
pInfo
->
groupResInfo
,
pInfo
->
streamAggSup
.
pResultBuf
);
if
(
pBInfo
->
pRes
->
info
.
rows
==
0
||
!
has
hRemain
DataInGroupInfo
(
&
pInfo
->
groupResInfo
))
{
if
(
pBInfo
->
pRes
->
info
.
rows
==
0
||
!
hasDataInGroupInfo
(
&
pInfo
->
groupResInfo
))
{
doSetOperatorCompleted
(
pOperator
);
doSetOperatorCompleted
(
pOperator
);
}
}
return
pBInfo
->
pRes
->
info
.
rows
==
0
?
NULL
:
pBInfo
->
pRes
;
return
pBInfo
->
pRes
->
info
.
rows
==
0
?
NULL
:
pBInfo
->
pRes
;
...
@@ -3269,7 +3271,7 @@ static SSDataBlock* doStreamStateAgg(SOperatorInfo* pOperator) {
...
@@ -3269,7 +3271,7 @@ static SSDataBlock* doStreamStateAgg(SOperatorInfo* pOperator) {
return
pInfo
->
pDelRes
;
return
pInfo
->
pDelRes
;
}
}
doBuildResultDatablock
(
pOperator
,
pBInfo
,
&
pInfo
->
groupResInfo
,
pInfo
->
streamAggSup
.
pResultBuf
);
doBuildResultDatablock
(
pOperator
,
pBInfo
,
&
pInfo
->
groupResInfo
,
pInfo
->
streamAggSup
.
pResultBuf
);
if
(
pBInfo
->
pRes
->
info
.
rows
==
0
||
!
has
hRemain
DataInGroupInfo
(
&
pInfo
->
groupResInfo
))
{
if
(
pBInfo
->
pRes
->
info
.
rows
==
0
||
!
hasDataInGroupInfo
(
&
pInfo
->
groupResInfo
))
{
doSetOperatorCompleted
(
pOperator
);
doSetOperatorCompleted
(
pOperator
);
}
}
return
pBInfo
->
pRes
->
info
.
rows
==
0
?
NULL
:
pBInfo
->
pRes
;
return
pBInfo
->
pRes
->
info
.
rows
==
0
?
NULL
:
pBInfo
->
pRes
;
...
@@ -3342,7 +3344,7 @@ SOperatorInfo* createStreamStateAggOperatorInfo(SOperatorInfo* downstream, SPhys
...
@@ -3342,7 +3344,7 @@ SOperatorInfo* createStreamStateAggOperatorInfo(SOperatorInfo* downstream, SPhys
pInfo
->
stateCol
=
extractColumnFromColumnNode
(
pColNode
);
pInfo
->
stateCol
=
extractColumnFromColumnNode
(
pColNode
);
initResultSizeInfo
(
pOperator
,
4096
);
initResultSizeInfo
(
pOperator
,
4096
);
initResultRowInfo
(
&
pInfo
->
binfo
.
resultRowInfo
,
8
);
initResultRowInfo
(
&
pInfo
->
binfo
.
resultRowInfo
);
pInfo
->
twAggSup
=
(
STimeWindowAggSupp
){
pInfo
->
twAggSup
=
(
STimeWindowAggSupp
){
.
waterMark
=
pStateNode
->
window
.
watermark
,
.
waterMark
=
pStateNode
->
window
.
watermark
,
.
calTrigger
=
pStateNode
->
window
.
triggerType
,
.
calTrigger
=
pStateNode
->
window
.
triggerType
,
...
@@ -3590,7 +3592,7 @@ SOperatorInfo* createMergeIntervalOperatorInfo(SOperatorInfo* downstream, SExprI
...
@@ -3590,7 +3592,7 @@ SOperatorInfo* createMergeIntervalOperatorInfo(SOperatorInfo* downstream, SExprI
goto
_error
;
goto
_error
;
}
}
initResultRowInfo
(
&
iaInfo
->
binfo
.
resultRowInfo
,
(
int32_t
)
1
);
initResultRowInfo
(
&
iaInfo
->
binfo
.
resultRowInfo
);
pOperator
->
name
=
"TimeMergeIntervalAggOperator"
;
pOperator
->
name
=
"TimeMergeIntervalAggOperator"
;
pOperator
->
operatorType
=
QUERY_NODE_PHYSICAL_PLAN_MERGE_INTERVAL
;
pOperator
->
operatorType
=
QUERY_NODE_PHYSICAL_PLAN_MERGE_INTERVAL
;
...
...
source/libs/executor/src/tsort.c
浏览文件 @
2e590c30
...
@@ -71,7 +71,7 @@ SSDataBlock* tsortGetSortedDataBlock(const SSortHandle* pSortHandle) {
...
@@ -71,7 +71,7 @@ SSDataBlock* tsortGetSortedDataBlock(const SSortHandle* pSortHandle) {
* @param type
* @param type
* @return
* @return
*/
*/
SSortHandle
*
tsortCreateSortHandle
(
SArray
*
pSortInfo
,
SArray
*
pIndexMap
,
int32_t
type
,
int32_t
pageSize
,
int32_t
numOfPages
,
SSDataBlock
*
pBlock
,
const
char
*
idstr
)
{
SSortHandle
*
tsortCreateSortHandle
(
SArray
*
pSortInfo
,
int32_t
type
,
int32_t
pageSize
,
int32_t
numOfPages
,
SSDataBlock
*
pBlock
,
const
char
*
idstr
)
{
SSortHandle
*
pSortHandle
=
taosMemoryCalloc
(
1
,
sizeof
(
SSortHandle
));
SSortHandle
*
pSortHandle
=
taosMemoryCalloc
(
1
,
sizeof
(
SSortHandle
));
pSortHandle
->
type
=
type
;
pSortHandle
->
type
=
type
;
...
...
source/libs/executor/test/sortTests.cpp
浏览文件 @
2e590c30
...
@@ -209,7 +209,7 @@ TEST(testCase, inMem_sort_Test) {
...
@@ -209,7 +209,7 @@ TEST(testCase, inMem_sort_Test) {
SArray
*
orderInfo
=
taosArrayInit
(
1
,
sizeof
(
SBlockOrderInfo
));
SArray
*
orderInfo
=
taosArrayInit
(
1
,
sizeof
(
SBlockOrderInfo
));
taosArrayPush
(
orderInfo
,
&
oi
);
taosArrayPush
(
orderInfo
,
&
oi
);
SSortHandle
*
phandle
=
tsortCreateSortHandle
(
orderInfo
,
NULL
,
SORT_SINGLESOURCE_SORT
,
1024
,
5
,
NULL
,
"test_abc"
);
SSortHandle
*
phandle
=
tsortCreateSortHandle
(
orderInfo
,
SORT_SINGLESOURCE_SORT
,
1024
,
5
,
NULL
,
"test_abc"
);
tsortSetFetchRawDataFp
(
phandle
,
getSingleColDummyBlock
,
NULL
,
NULL
);
tsortSetFetchRawDataFp
(
phandle
,
getSingleColDummyBlock
,
NULL
,
NULL
);
_info
*
pInfo
=
(
_info
*
)
taosMemoryCalloc
(
1
,
sizeof
(
_info
));
_info
*
pInfo
=
(
_info
*
)
taosMemoryCalloc
(
1
,
sizeof
(
_info
));
...
@@ -298,7 +298,7 @@ TEST(testCase, external_mem_sort_Test) {
...
@@ -298,7 +298,7 @@ TEST(testCase, external_mem_sort_Test) {
SArray
*
orderInfo
=
taosArrayInit
(
1
,
sizeof
(
SBlockOrderInfo
));
SArray
*
orderInfo
=
taosArrayInit
(
1
,
sizeof
(
SBlockOrderInfo
));
taosArrayPush
(
orderInfo
,
&
oi
);
taosArrayPush
(
orderInfo
,
&
oi
);
SSortHandle
*
phandle
=
tsortCreateSortHandle
(
orderInfo
,
NULL
,
SORT_SINGLESOURCE_SORT
,
128
,
3
,
NULL
,
"test_abc"
);
SSortHandle
*
phandle
=
tsortCreateSortHandle
(
orderInfo
,
SORT_SINGLESOURCE_SORT
,
128
,
3
,
NULL
,
"test_abc"
);
tsortSetFetchRawDataFp
(
phandle
,
getSingleColDummyBlock
,
NULL
,
NULL
);
tsortSetFetchRawDataFp
(
phandle
,
getSingleColDummyBlock
,
NULL
,
NULL
);
SSortSource
*
ps
=
static_cast
<
SSortSource
*>
(
taosMemoryCalloc
(
1
,
sizeof
(
SSortSource
)));
SSortSource
*
ps
=
static_cast
<
SSortSource
*>
(
taosMemoryCalloc
(
1
,
sizeof
(
SSortSource
)));
...
@@ -365,7 +365,7 @@ TEST(testCase, ordered_merge_sort_Test) {
...
@@ -365,7 +365,7 @@ TEST(testCase, ordered_merge_sort_Test) {
taosArrayPush
(
pBlock
->
pDataBlock
,
&
colInfo
);
taosArrayPush
(
pBlock
->
pDataBlock
,
&
colInfo
);
}
}
SSortHandle
*
phandle
=
tsortCreateSortHandle
(
orderInfo
,
NULL
,
SORT_MULTISOURCE_MERGE
,
1024
,
5
,
pBlock
,
"test_abc"
);
SSortHandle
*
phandle
=
tsortCreateSortHandle
(
orderInfo
,
SORT_MULTISOURCE_MERGE
,
1024
,
5
,
pBlock
,
"test_abc"
);
tsortSetFetchRawDataFp
(
phandle
,
getSingleColDummyBlock
,
NULL
,
NULL
);
tsortSetFetchRawDataFp
(
phandle
,
getSingleColDummyBlock
,
NULL
,
NULL
);
tsortSetComparFp
(
phandle
,
docomp
);
tsortSetComparFp
(
phandle
,
docomp
);
...
...
source/libs/stream/src/streamDispatch.c
浏览文件 @
2e590c30
...
@@ -134,6 +134,7 @@ int32_t streamBuildDispatchMsg(SStreamTask* pTask, SStreamDataBlock* data, SRpcM
...
@@ -134,6 +134,7 @@ int32_t streamBuildDispatchMsg(SStreamTask* pTask, SStreamDataBlock* data, SRpcM
int32_t
sz
=
taosArrayGetSize
(
vgInfo
);
int32_t
sz
=
taosArrayGetSize
(
vgInfo
);
for
(
int32_t
i
=
0
;
i
<
sz
;
i
++
)
{
for
(
int32_t
i
=
0
;
i
<
sz
;
i
++
)
{
SVgroupInfo
*
pVgInfo
=
taosArrayGet
(
vgInfo
,
i
);
SVgroupInfo
*
pVgInfo
=
taosArrayGet
(
vgInfo
,
i
);
ASSERT
(
pVgInfo
->
vgId
>
0
);
if
(
hashValue
>=
pVgInfo
->
hashBegin
&&
hashValue
<=
pVgInfo
->
hashEnd
)
{
if
(
hashValue
>=
pVgInfo
->
hashBegin
&&
hashValue
<=
pVgInfo
->
hashEnd
)
{
vgId
=
pVgInfo
->
vgId
;
vgId
=
pVgInfo
->
vgId
;
downstreamTaskId
=
pVgInfo
->
taskId
;
downstreamTaskId
=
pVgInfo
->
taskId
;
...
...
source/libs/stream/src/streamTask.c
浏览文件 @
2e590c30
...
@@ -70,7 +70,7 @@ int32_t tEncodeSStreamTask(SEncoder* pEncoder, const SStreamTask* pTask) {
...
@@ -70,7 +70,7 @@ int32_t tEncodeSStreamTask(SEncoder* pEncoder, const SStreamTask* pTask) {
if
(
tEncodeSEpSet
(
pEncoder
,
&
pTask
->
fixedEpDispatcher
.
epSet
)
<
0
)
return
-
1
;
if
(
tEncodeSEpSet
(
pEncoder
,
&
pTask
->
fixedEpDispatcher
.
epSet
)
<
0
)
return
-
1
;
}
else
if
(
pTask
->
dispatchType
==
TASK_DISPATCH__SHUFFLE
)
{
}
else
if
(
pTask
->
dispatchType
==
TASK_DISPATCH__SHUFFLE
)
{
if
(
tSerializeSUseDbRspImp
(
pEncoder
,
&
pTask
->
shuffleDispatcher
.
dbInfo
)
<
0
)
return
-
1
;
if
(
tSerializeSUseDbRspImp
(
pEncoder
,
&
pTask
->
shuffleDispatcher
.
dbInfo
)
<
0
)
return
-
1
;
/*if (tEncodeI8(pEncoder, pTask->shuffleDispatcher.hashMethod) < 0) return -1;*/
if
(
tEncodeCStr
(
pEncoder
,
pTask
->
shuffleDispatcher
.
stbFullName
)
<
0
)
return
-
1
;
}
}
if
(
tEncodeI64
(
pEncoder
,
pTask
->
triggerParam
)
<
0
)
return
-
1
;
if
(
tEncodeI64
(
pEncoder
,
pTask
->
triggerParam
)
<
0
)
return
-
1
;
...
@@ -119,8 +119,8 @@ int32_t tDecodeSStreamTask(SDecoder* pDecoder, SStreamTask* pTask) {
...
@@ -119,8 +119,8 @@ int32_t tDecodeSStreamTask(SDecoder* pDecoder, SStreamTask* pTask) {
if
(
tDecodeI32
(
pDecoder
,
&
pTask
->
fixedEpDispatcher
.
nodeId
)
<
0
)
return
-
1
;
if
(
tDecodeI32
(
pDecoder
,
&
pTask
->
fixedEpDispatcher
.
nodeId
)
<
0
)
return
-
1
;
if
(
tDecodeSEpSet
(
pDecoder
,
&
pTask
->
fixedEpDispatcher
.
epSet
)
<
0
)
return
-
1
;
if
(
tDecodeSEpSet
(
pDecoder
,
&
pTask
->
fixedEpDispatcher
.
epSet
)
<
0
)
return
-
1
;
}
else
if
(
pTask
->
dispatchType
==
TASK_DISPATCH__SHUFFLE
)
{
}
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
;
if
(
tDeserializeSUseDbRspImp
(
pDecoder
,
&
pTask
->
shuffleDispatcher
.
dbInfo
)
<
0
)
return
-
1
;
if
(
tDecodeCStrTo
(
pDecoder
,
pTask
->
shuffleDispatcher
.
stbFullName
)
<
0
)
return
-
1
;
}
}
if
(
tDecodeI64
(
pDecoder
,
&
pTask
->
triggerParam
)
<
0
)
return
-
1
;
if
(
tDecodeI64
(
pDecoder
,
&
pTask
->
triggerParam
)
<
0
)
return
-
1
;
...
...
source/libs/sync/inc/syncInt.h
浏览文件 @
2e590c30
...
@@ -171,7 +171,8 @@ void syncNodeClose(SSyncNode* pSyncNode);
...
@@ -171,7 +171,8 @@ void syncNodeClose(SSyncNode* pSyncNode);
int32_t
syncNodePropose
(
SSyncNode
*
pSyncNode
,
const
SRpcMsg
*
pMsg
,
bool
isWeak
);
int32_t
syncNodePropose
(
SSyncNode
*
pSyncNode
,
const
SRpcMsg
*
pMsg
,
bool
isWeak
);
// option
// option
bool
syncNodeSnapshotEnable
(
SSyncNode
*
pSyncNode
);
bool
syncNodeSnapshotEnable
(
SSyncNode
*
pSyncNode
);
SyncIndex
syncNodeGetSnapshotConfigIndex
(
SSyncNode
*
pSyncNode
,
SyncIndex
snapshotLastApplyIndex
);
// ping --------------
// ping --------------
int32_t
syncNodePing
(
SSyncNode
*
pSyncNode
,
const
SRaftId
*
destRaftId
,
SyncPing
*
pMsg
);
int32_t
syncNodePing
(
SSyncNode
*
pSyncNode
,
const
SRaftId
*
destRaftId
,
SyncPing
*
pMsg
);
...
...
source/libs/sync/inc/syncRaftCfg.h
浏览文件 @
2e590c30
...
@@ -47,14 +47,15 @@ typedef struct SRaftCfg {
...
@@ -47,14 +47,15 @@ typedef struct SRaftCfg {
SRaftCfg
*
raftCfgOpen
(
const
char
*
path
);
SRaftCfg
*
raftCfgOpen
(
const
char
*
path
);
int32_t
raftCfgClose
(
SRaftCfg
*
pRaftCfg
);
int32_t
raftCfgClose
(
SRaftCfg
*
pRaftCfg
);
int32_t
raftCfgPersist
(
SRaftCfg
*
pRaftCfg
);
int32_t
raftCfgPersist
(
SRaftCfg
*
pRaftCfg
);
int32_t
raftCfgAddConfigIndex
(
SRaftCfg
*
pRaftCfg
,
SyncIndex
configIndex
);
cJSON
*
syncCfg2Json
(
SSyncCfg
*
pSyncCfg
);
cJSON
*
syncCfg2Json
(
SSyncCfg
*
pSyncCfg
);
char
*
syncCfg2Str
(
SSyncCfg
*
pSyncCfg
);
char
*
syncCfg2Str
(
SSyncCfg
*
pSyncCfg
);
int32_t
syncCfgFromJson
(
const
cJSON
*
pRoot
,
SSyncCfg
*
pSyncCfg
);
int32_t
syncCfgFromJson
(
const
cJSON
*
pRoot
,
SSyncCfg
*
pSyncCfg
);
int32_t
syncCfgFromStr
(
const
char
*
s
,
SSyncCfg
*
pSyncCfg
);
int32_t
syncCfgFromStr
(
const
char
*
s
,
SSyncCfg
*
pSyncCfg
);
cJSON
*
raftCfg2Json
(
SRaftCfg
*
pRaftCfg
);
cJSON
*
raftCfg2Json
(
SRaftCfg
*
pRaftCfg
);
char
*
raftCfg2Str
(
SRaftCfg
*
pRaftCfg
);
char
*
raftCfg2Str
(
SRaftCfg
*
pRaftCfg
);
int32_t
raftCfgFromJson
(
const
cJSON
*
pRoot
,
SRaftCfg
*
pRaftCfg
);
int32_t
raftCfgFromJson
(
const
cJSON
*
pRoot
,
SRaftCfg
*
pRaftCfg
);
int32_t
raftCfgFromStr
(
const
char
*
s
,
SRaftCfg
*
pRaftCfg
);
int32_t
raftCfgFromStr
(
const
char
*
s
,
SRaftCfg
*
pRaftCfg
);
...
...
source/libs/sync/src/syncAppendEntries.c
浏览文件 @
2e590c30
...
@@ -208,8 +208,9 @@ int32_t syncNodeOnAppendEntriesCb(SSyncNode* ths, SyncAppendEntries* pMsg) {
...
@@ -208,8 +208,9 @@ int32_t syncNodeOnAppendEntriesCb(SSyncNode* ths, SyncAppendEntries* pMsg) {
SRpcMsg
rpcMsg
;
SRpcMsg
rpcMsg
;
syncEntry2OriginalRpc
(
pRollBackEntry
,
&
rpcMsg
);
syncEntry2OriginalRpc
(
pRollBackEntry
,
&
rpcMsg
);
SFsmCbMeta
cbMeta
;
SFsmCbMeta
cbMeta
=
{
0
}
;
cbMeta
.
index
=
pRollBackEntry
->
index
;
cbMeta
.
index
=
pRollBackEntry
->
index
;
cbMeta
.
lastConfigIndex
=
syncNodeGetSnapshotConfigIndex
(
ths
,
cbMeta
.
index
);
cbMeta
.
isWeak
=
pRollBackEntry
->
isWeak
;
cbMeta
.
isWeak
=
pRollBackEntry
->
isWeak
;
cbMeta
.
code
=
0
;
cbMeta
.
code
=
0
;
cbMeta
.
state
=
ths
->
state
;
cbMeta
.
state
=
ths
->
state
;
...
@@ -234,8 +235,9 @@ int32_t syncNodeOnAppendEntriesCb(SSyncNode* ths, SyncAppendEntries* pMsg) {
...
@@ -234,8 +235,9 @@ int32_t syncNodeOnAppendEntriesCb(SSyncNode* ths, SyncAppendEntries* pMsg) {
if
(
ths
->
pFsm
!=
NULL
)
{
if
(
ths
->
pFsm
!=
NULL
)
{
// if (ths->pFsm->FpPreCommitCb != NULL && pAppendEntry->originalRpcType != TDMT_SYNC_NOOP) {
// if (ths->pFsm->FpPreCommitCb != NULL && pAppendEntry->originalRpcType != TDMT_SYNC_NOOP) {
if
(
ths
->
pFsm
->
FpPreCommitCb
!=
NULL
&&
syncUtilUserPreCommit
(
pAppendEntry
->
originalRpcType
))
{
if
(
ths
->
pFsm
->
FpPreCommitCb
!=
NULL
&&
syncUtilUserPreCommit
(
pAppendEntry
->
originalRpcType
))
{
SFsmCbMeta
cbMeta
;
SFsmCbMeta
cbMeta
=
{
0
}
;
cbMeta
.
index
=
pAppendEntry
->
index
;
cbMeta
.
index
=
pAppendEntry
->
index
;
cbMeta
.
lastConfigIndex
=
syncNodeGetSnapshotConfigIndex
(
ths
,
cbMeta
.
index
);
cbMeta
.
isWeak
=
pAppendEntry
->
isWeak
;
cbMeta
.
isWeak
=
pAppendEntry
->
isWeak
;
cbMeta
.
code
=
2
;
cbMeta
.
code
=
2
;
cbMeta
.
state
=
ths
->
state
;
cbMeta
.
state
=
ths
->
state
;
...
@@ -266,8 +268,9 @@ int32_t syncNodeOnAppendEntriesCb(SSyncNode* ths, SyncAppendEntries* pMsg) {
...
@@ -266,8 +268,9 @@ int32_t syncNodeOnAppendEntriesCb(SSyncNode* ths, SyncAppendEntries* pMsg) {
if
(
ths
->
pFsm
!=
NULL
)
{
if
(
ths
->
pFsm
!=
NULL
)
{
// if (ths->pFsm->FpPreCommitCb != NULL && pAppendEntry->originalRpcType != TDMT_SYNC_NOOP) {
// if (ths->pFsm->FpPreCommitCb != NULL && pAppendEntry->originalRpcType != TDMT_SYNC_NOOP) {
if
(
ths
->
pFsm
->
FpPreCommitCb
!=
NULL
&&
syncUtilUserPreCommit
(
pAppendEntry
->
originalRpcType
))
{
if
(
ths
->
pFsm
->
FpPreCommitCb
!=
NULL
&&
syncUtilUserPreCommit
(
pAppendEntry
->
originalRpcType
))
{
SFsmCbMeta
cbMeta
;
SFsmCbMeta
cbMeta
=
{
0
}
;
cbMeta
.
index
=
pAppendEntry
->
index
;
cbMeta
.
index
=
pAppendEntry
->
index
;
cbMeta
.
lastConfigIndex
=
syncNodeGetSnapshotConfigIndex
(
ths
,
cbMeta
.
index
);
cbMeta
.
isWeak
=
pAppendEntry
->
isWeak
;
cbMeta
.
isWeak
=
pAppendEntry
->
isWeak
;
cbMeta
.
code
=
3
;
cbMeta
.
code
=
3
;
cbMeta
.
state
=
ths
->
state
;
cbMeta
.
state
=
ths
->
state
;
...
@@ -696,8 +699,9 @@ static int32_t syncNodeMakeLogSame(SSyncNode* ths, SyncAppendEntries* pMsg) {
...
@@ -696,8 +699,9 @@ static int32_t syncNodeMakeLogSame(SSyncNode* ths, SyncAppendEntries* pMsg) {
SRpcMsg
rpcMsg
;
SRpcMsg
rpcMsg
;
syncEntry2OriginalRpc
(
pRollBackEntry
,
&
rpcMsg
);
syncEntry2OriginalRpc
(
pRollBackEntry
,
&
rpcMsg
);
SFsmCbMeta
cbMeta
;
SFsmCbMeta
cbMeta
=
{
0
}
;
cbMeta
.
index
=
pRollBackEntry
->
index
;
cbMeta
.
index
=
pRollBackEntry
->
index
;
cbMeta
.
lastConfigIndex
=
syncNodeGetSnapshotConfigIndex
(
ths
,
cbMeta
.
index
);
cbMeta
.
isWeak
=
pRollBackEntry
->
isWeak
;
cbMeta
.
isWeak
=
pRollBackEntry
->
isWeak
;
cbMeta
.
code
=
0
;
cbMeta
.
code
=
0
;
cbMeta
.
state
=
ths
->
state
;
cbMeta
.
state
=
ths
->
state
;
...
@@ -725,8 +729,9 @@ static int32_t syncNodePreCommit(SSyncNode* ths, SSyncRaftEntry* pEntry) {
...
@@ -725,8 +729,9 @@ static int32_t syncNodePreCommit(SSyncNode* ths, SSyncRaftEntry* pEntry) {
syncEntry2OriginalRpc
(
pEntry
,
&
rpcMsg
);
syncEntry2OriginalRpc
(
pEntry
,
&
rpcMsg
);
if
(
ths
->
pFsm
!=
NULL
)
{
if
(
ths
->
pFsm
!=
NULL
)
{
if
(
ths
->
pFsm
->
FpPreCommitCb
!=
NULL
&&
syncUtilUserPreCommit
(
pEntry
->
originalRpcType
))
{
if
(
ths
->
pFsm
->
FpPreCommitCb
!=
NULL
&&
syncUtilUserPreCommit
(
pEntry
->
originalRpcType
))
{
SFsmCbMeta
cbMeta
;
SFsmCbMeta
cbMeta
=
{
0
}
;
cbMeta
.
index
=
pEntry
->
index
;
cbMeta
.
index
=
pEntry
->
index
;
cbMeta
.
lastConfigIndex
=
syncNodeGetSnapshotConfigIndex
(
ths
,
cbMeta
.
index
);
cbMeta
.
isWeak
=
pEntry
->
isWeak
;
cbMeta
.
isWeak
=
pEntry
->
isWeak
;
cbMeta
.
code
=
2
;
cbMeta
.
code
=
2
;
cbMeta
.
state
=
ths
->
state
;
cbMeta
.
state
=
ths
->
state
;
...
...
source/libs/sync/src/syncMain.c
浏览文件 @
2e590c30
...
@@ -444,6 +444,21 @@ int32_t syncGetSnapshotMetaByIndex(int64_t rid, SyncIndex snapshotIndex, struct
...
@@ -444,6 +444,21 @@ int32_t syncGetSnapshotMetaByIndex(int64_t rid, SyncIndex snapshotIndex, struct
return
0
;
return
0
;
}
}
SyncIndex
syncNodeGetSnapshotConfigIndex
(
SSyncNode
*
pSyncNode
,
SyncIndex
snapshotLastApplyIndex
)
{
ASSERT
(
pSyncNode
->
pRaftCfg
->
configIndexCount
>=
1
);
SyncIndex
lastIndex
=
(
pSyncNode
->
pRaftCfg
->
configIndexArr
)[
0
];
for
(
int
i
=
0
;
i
<
pSyncNode
->
pRaftCfg
->
configIndexCount
;
++
i
)
{
if
((
pSyncNode
->
pRaftCfg
->
configIndexArr
)[
i
]
>
lastIndex
&&
(
pSyncNode
->
pRaftCfg
->
configIndexArr
)[
i
]
<=
snapshotLastApplyIndex
)
{
lastIndex
=
(
pSyncNode
->
pRaftCfg
->
configIndexArr
)[
i
];
}
}
sTrace
(
"sync syncNodeGetSnapshotConfigIndex index:%ld lastConfigIndex:%ld"
,
snapshotLastApplyIndex
,
lastIndex
);
return
lastIndex
;
}
const
char
*
syncGetMyRoleStr
(
int64_t
rid
)
{
const
char
*
syncGetMyRoleStr
(
int64_t
rid
)
{
const
char
*
s
=
syncUtilState2String
(
syncGetMyRole
(
rid
));
const
char
*
s
=
syncUtilState2String
(
syncGetMyRole
(
rid
));
return
s
;
return
s
;
...
@@ -2068,8 +2083,9 @@ int32_t syncNodeOnClientRequestCb(SSyncNode* ths, SyncClientRequest* pMsg) {
...
@@ -2068,8 +2083,9 @@ int32_t syncNodeOnClientRequestCb(SSyncNode* ths, SyncClientRequest* pMsg) {
if
(
ths
->
pFsm
!=
NULL
)
{
if
(
ths
->
pFsm
!=
NULL
)
{
// if (ths->pFsm->FpPreCommitCb != NULL && pEntry->originalRpcType != TDMT_SYNC_NOOP) {
// if (ths->pFsm->FpPreCommitCb != NULL && pEntry->originalRpcType != TDMT_SYNC_NOOP) {
if
(
ths
->
pFsm
->
FpPreCommitCb
!=
NULL
&&
syncUtilUserPreCommit
(
pEntry
->
originalRpcType
))
{
if
(
ths
->
pFsm
->
FpPreCommitCb
!=
NULL
&&
syncUtilUserPreCommit
(
pEntry
->
originalRpcType
))
{
SFsmCbMeta
cbMeta
;
SFsmCbMeta
cbMeta
=
{
0
}
;
cbMeta
.
index
=
pEntry
->
index
;
cbMeta
.
index
=
pEntry
->
index
;
cbMeta
.
lastConfigIndex
=
syncNodeGetSnapshotConfigIndex
(
ths
,
cbMeta
.
index
);
cbMeta
.
isWeak
=
pEntry
->
isWeak
;
cbMeta
.
isWeak
=
pEntry
->
isWeak
;
cbMeta
.
code
=
0
;
cbMeta
.
code
=
0
;
cbMeta
.
state
=
ths
->
state
;
cbMeta
.
state
=
ths
->
state
;
...
@@ -2090,8 +2106,9 @@ int32_t syncNodeOnClientRequestCb(SSyncNode* ths, SyncClientRequest* pMsg) {
...
@@ -2090,8 +2106,9 @@ int32_t syncNodeOnClientRequestCb(SSyncNode* ths, SyncClientRequest* pMsg) {
if
(
ths
->
pFsm
!=
NULL
)
{
if
(
ths
->
pFsm
!=
NULL
)
{
// if (ths->pFsm->FpPreCommitCb != NULL && pEntry->originalRpcType != TDMT_SYNC_NOOP) {
// if (ths->pFsm->FpPreCommitCb != NULL && pEntry->originalRpcType != TDMT_SYNC_NOOP) {
if
(
ths
->
pFsm
->
FpPreCommitCb
!=
NULL
&&
syncUtilUserPreCommit
(
pEntry
->
originalRpcType
))
{
if
(
ths
->
pFsm
->
FpPreCommitCb
!=
NULL
&&
syncUtilUserPreCommit
(
pEntry
->
originalRpcType
))
{
SFsmCbMeta
cbMeta
;
SFsmCbMeta
cbMeta
=
{
0
}
;
cbMeta
.
index
=
pEntry
->
index
;
cbMeta
.
index
=
pEntry
->
index
;
cbMeta
.
lastConfigIndex
=
syncNodeGetSnapshotConfigIndex
(
ths
,
cbMeta
.
index
);
cbMeta
.
isWeak
=
pEntry
->
isWeak
;
cbMeta
.
isWeak
=
pEntry
->
isWeak
;
cbMeta
.
code
=
1
;
cbMeta
.
code
=
1
;
cbMeta
.
state
=
ths
->
state
;
cbMeta
.
state
=
ths
->
state
;
...
@@ -2155,11 +2172,12 @@ static int32_t syncDoLeaderTransfer(SSyncNode* ths, SRpcMsg* pRpcMsg, SSyncRaftE
...
@@ -2155,11 +2172,12 @@ static int32_t syncDoLeaderTransfer(SSyncNode* ths, SRpcMsg* pRpcMsg, SSyncRaftE
}
}
*/
*/
if
(
ths
->
pFsm
->
FpLeaderTransferCb
!=
NULL
)
{
if
(
ths
->
pFsm
->
FpLeaderTransferCb
!=
NULL
)
{
SFsmCbMeta
cbMeta
;
SFsmCbMeta
cbMeta
=
{
0
}
;
cbMeta
.
code
=
0
;
cbMeta
.
code
=
0
;
cbMeta
.
currentTerm
=
ths
->
pRaftStore
->
currentTerm
;
cbMeta
.
currentTerm
=
ths
->
pRaftStore
->
currentTerm
;
cbMeta
.
flag
=
0
;
cbMeta
.
flag
=
0
;
cbMeta
.
index
=
pEntry
->
index
;
cbMeta
.
index
=
pEntry
->
index
;
cbMeta
.
lastConfigIndex
=
syncNodeGetSnapshotConfigIndex
(
ths
,
cbMeta
.
index
);
cbMeta
.
isWeak
=
pEntry
->
isWeak
;
cbMeta
.
isWeak
=
pEntry
->
isWeak
;
cbMeta
.
seqNum
=
pEntry
->
seqNum
;
cbMeta
.
seqNum
=
pEntry
->
seqNum
;
cbMeta
.
state
=
ths
->
state
;
cbMeta
.
state
=
ths
->
state
;
...
@@ -2261,6 +2279,7 @@ static int32_t syncNodeConfigChange(SSyncNode* ths, SRpcMsg* pRpcMsg, SSyncRaftE
...
@@ -2261,6 +2279,7 @@ static int32_t syncNodeConfigChange(SSyncNode* ths, SRpcMsg* pRpcMsg, SSyncRaftE
cbMeta
.
code
=
0
;
cbMeta
.
code
=
0
;
cbMeta
.
currentTerm
=
ths
->
pRaftStore
->
currentTerm
;
cbMeta
.
currentTerm
=
ths
->
pRaftStore
->
currentTerm
;
cbMeta
.
index
=
pEntry
->
index
;
cbMeta
.
index
=
pEntry
->
index
;
cbMeta
.
lastConfigIndex
=
syncNodeGetSnapshotConfigIndex
(
ths
,
pEntry
->
index
);
cbMeta
.
term
=
pEntry
->
term
;
cbMeta
.
term
=
pEntry
->
term
;
cbMeta
.
newCfg
=
newSyncCfg
;
cbMeta
.
newCfg
=
newSyncCfg
;
cbMeta
.
oldCfg
=
oldSyncCfg
;
cbMeta
.
oldCfg
=
oldSyncCfg
;
...
@@ -2295,8 +2314,9 @@ int32_t syncNodeCommit(SSyncNode* ths, SyncIndex beginIndex, SyncIndex endIndex,
...
@@ -2295,8 +2314,9 @@ int32_t syncNodeCommit(SSyncNode* ths, SyncIndex beginIndex, SyncIndex endIndex,
// user commit
// user commit
if
(
ths
->
pFsm
->
FpCommitCb
!=
NULL
&&
syncUtilUserCommit
(
pEntry
->
originalRpcType
))
{
if
(
ths
->
pFsm
->
FpCommitCb
!=
NULL
&&
syncUtilUserCommit
(
pEntry
->
originalRpcType
))
{
SFsmCbMeta
cbMeta
;
SFsmCbMeta
cbMeta
=
{
0
}
;
cbMeta
.
index
=
pEntry
->
index
;
cbMeta
.
index
=
pEntry
->
index
;
cbMeta
.
lastConfigIndex
=
syncNodeGetSnapshotConfigIndex
(
ths
,
cbMeta
.
index
);
cbMeta
.
isWeak
=
pEntry
->
isWeak
;
cbMeta
.
isWeak
=
pEntry
->
isWeak
;
cbMeta
.
code
=
0
;
cbMeta
.
code
=
0
;
cbMeta
.
state
=
ths
->
state
;
cbMeta
.
state
=
ths
->
state
;
...
@@ -2310,6 +2330,8 @@ int32_t syncNodeCommit(SSyncNode* ths, SyncIndex beginIndex, SyncIndex endIndex,
...
@@ -2310,6 +2330,8 @@ int32_t syncNodeCommit(SSyncNode* ths, SyncIndex beginIndex, SyncIndex endIndex,
// config change
// config change
if
(
pEntry
->
originalRpcType
==
TDMT_SYNC_CONFIG_CHANGE
)
{
if
(
pEntry
->
originalRpcType
==
TDMT_SYNC_CONFIG_CHANGE
)
{
raftCfgAddConfigIndex
(
ths
->
pRaftCfg
,
pEntry
->
index
);
raftCfgPersist
(
ths
->
pRaftCfg
);
code
=
syncNodeConfigChange
(
ths
,
&
rpcMsg
,
pEntry
);
code
=
syncNodeConfigChange
(
ths
,
&
rpcMsg
,
pEntry
);
ASSERT
(
code
==
0
);
ASSERT
(
code
==
0
);
}
}
...
...
source/libs/sync/src/syncRaftCfg.c
浏览文件 @
2e590c30
...
@@ -66,6 +66,13 @@ int32_t raftCfgPersist(SRaftCfg *pRaftCfg) {
...
@@ -66,6 +66,13 @@ int32_t raftCfgPersist(SRaftCfg *pRaftCfg) {
return
0
;
return
0
;
}
}
int32_t
raftCfgAddConfigIndex
(
SRaftCfg
*
pRaftCfg
,
SyncIndex
configIndex
)
{
ASSERT
(
pRaftCfg
->
configIndexCount
<=
MAX_CONFIG_INDEX_COUNT
);
(
pRaftCfg
->
configIndexArr
)[
pRaftCfg
->
configIndexCount
]
=
configIndex
;
++
(
pRaftCfg
->
configIndexCount
);
return
0
;
}
cJSON
*
syncCfg2Json
(
SSyncCfg
*
pSyncCfg
)
{
cJSON
*
syncCfg2Json
(
SSyncCfg
*
pSyncCfg
)
{
char
u64buf
[
128
]
=
{
0
};
char
u64buf
[
128
]
=
{
0
};
cJSON
*
pRoot
=
cJSON_CreateObject
();
cJSON
*
pRoot
=
cJSON_CreateObject
();
...
...
source/libs/sync/src/syncSnapshot.c
浏览文件 @
2e590c30
...
@@ -50,6 +50,7 @@ SSyncSnapshotSender *snapshotSenderCreate(SSyncNode *pSyncNode, int32_t replicaI
...
@@ -50,6 +50,7 @@ SSyncSnapshotSender *snapshotSenderCreate(SSyncNode *pSyncNode, int32_t replicaI
}
else
{
}
else
{
sError
(
"snapshotSenderCreate cannot create sender"
);
sError
(
"snapshotSenderCreate cannot create sender"
);
}
}
return
pSender
;
return
pSender
;
}
}
...
@@ -84,6 +85,10 @@ void snapshotSenderStart(SSyncSnapshotSender *pSender) {
...
@@ -84,6 +85,10 @@ void snapshotSenderStart(SSyncSnapshotSender *pSender) {
// get current snapshot info
// get current snapshot info
pSender
->
pSyncNode
->
pFsm
->
FpGetSnapshot
(
pSender
->
pSyncNode
->
pFsm
,
&
(
pSender
->
snapshot
));
pSender
->
pSyncNode
->
pFsm
->
FpGetSnapshot
(
pSender
->
pSyncNode
->
pFsm
,
&
(
pSender
->
snapshot
));
sTrace
(
"snapshotSenderStart lastApplyIndex:%ld, lastApplyTerm:%lu, lastConfigIndex:%ld"
,
pSender
->
snapshot
.
lastApplyIndex
,
pSender
->
snapshot
.
lastApplyTerm
,
pSender
->
snapshot
.
lastConfigIndex
);
if
(
pSender
->
snapshot
.
lastConfigIndex
!=
SYNC_INDEX_INVALID
)
{
if
(
pSender
->
snapshot
.
lastConfigIndex
!=
SYNC_INDEX_INVALID
)
{
/*
/*
SSyncRaftEntry *pEntry = NULL;
SSyncRaftEntry *pEntry = NULL;
...
@@ -421,7 +426,7 @@ cJSON *snapshotSender2Json(SSyncSnapshotSender *pSender) {
...
@@ -421,7 +426,7 @@ cJSON *snapshotSender2Json(SSyncSnapshotSender *pSender) {
char
*
snapshotSender2Str
(
SSyncSnapshotSender
*
pSender
)
{
char
*
snapshotSender2Str
(
SSyncSnapshotSender
*
pSender
)
{
cJSON
*
pJson
=
snapshotSender2Json
(
pSender
);
cJSON
*
pJson
=
snapshotSender2Json
(
pSender
);
char
*
serialized
=
cJSON_Print
(
pJson
);
char
*
serialized
=
cJSON_Print
(
pJson
);
cJSON_Delete
(
pJson
);
cJSON_Delete
(
pJson
);
return
serialized
;
return
serialized
;
}
}
...
@@ -542,7 +547,7 @@ cJSON *snapshotReceiver2Json(SSyncSnapshotReceiver *pReceiver) {
...
@@ -542,7 +547,7 @@ cJSON *snapshotReceiver2Json(SSyncSnapshotReceiver *pReceiver) {
cJSON_AddStringToObject
(
pFromId
,
"addr"
,
u64buf
);
cJSON_AddStringToObject
(
pFromId
,
"addr"
,
u64buf
);
{
{
uint64_t
u64
=
pReceiver
->
fromId
.
addr
;
uint64_t
u64
=
pReceiver
->
fromId
.
addr
;
cJSON
*
pTmp
=
pFromId
;
cJSON
*
pTmp
=
pFromId
;
char
host
[
128
]
=
{
0
};
char
host
[
128
]
=
{
0
};
uint16_t
port
;
uint16_t
port
;
syncUtilU642Addr
(
u64
,
host
,
sizeof
(
host
),
&
port
);
syncUtilU642Addr
(
u64
,
host
,
sizeof
(
host
),
&
port
);
...
@@ -566,7 +571,7 @@ cJSON *snapshotReceiver2Json(SSyncSnapshotReceiver *pReceiver) {
...
@@ -566,7 +571,7 @@ cJSON *snapshotReceiver2Json(SSyncSnapshotReceiver *pReceiver) {
char
*
snapshotReceiver2Str
(
SSyncSnapshotReceiver
*
pReceiver
)
{
char
*
snapshotReceiver2Str
(
SSyncSnapshotReceiver
*
pReceiver
)
{
cJSON
*
pJson
=
snapshotReceiver2Json
(
pReceiver
);
cJSON
*
pJson
=
snapshotReceiver2Json
(
pReceiver
);
char
*
serialized
=
cJSON_Print
(
pJson
);
char
*
serialized
=
cJSON_Print
(
pJson
);
cJSON_Delete
(
pJson
);
cJSON_Delete
(
pJson
);
return
serialized
;
return
serialized
;
}
}
...
...
source/libs/transport/src/transComm.c
浏览文件 @
2e590c30
...
@@ -376,17 +376,19 @@ static void transDQTimeout(uv_timer_t* timer) {
...
@@ -376,17 +376,19 @@ static void transDQTimeout(uv_timer_t* timer) {
SDelayQueue
*
queue
=
timer
->
data
;
SDelayQueue
*
queue
=
timer
->
data
;
tTrace
(
"timer %p timeout"
,
timer
);
tTrace
(
"timer %p timeout"
,
timer
);
uint64_t
timeout
=
0
;
uint64_t
timeout
=
0
;
int64_t
current
=
taosGetTimestampMs
();
do
{
do
{
HeapNode
*
minNode
=
heapMin
(
queue
->
heap
);
HeapNode
*
minNode
=
heapMin
(
queue
->
heap
);
if
(
minNode
==
NULL
)
break
;
if
(
minNode
==
NULL
)
break
;
SDelayTask
*
task
=
container_of
(
minNode
,
SDelayTask
,
node
);
SDelayTask
*
task
=
container_of
(
minNode
,
SDelayTask
,
node
);
if
(
task
->
execTime
<=
taosGetTimestampMs
())
{
if
(
task
->
execTime
<=
current
)
{
heapRemove
(
queue
->
heap
,
minNode
);
heapRemove
(
queue
->
heap
,
minNode
);
task
->
func
(
task
->
arg
);
task
->
func
(
task
->
arg
);
taosMemoryFree
(
task
);
taosMemoryFree
(
task
);
timeout
=
0
;
timeout
=
0
;
}
else
{
}
else
{
timeout
=
task
->
execTime
-
taosGetTimestampMs
()
;
timeout
=
task
->
execTime
-
current
;
break
;
break
;
}
}
}
while
(
1
);
}
while
(
1
);
...
...
tests/system-test/1-insert/alter_stable.py
浏览文件 @
2e590c30
...
@@ -77,6 +77,7 @@ class TDTestCase:
...
@@ -77,6 +77,7 @@ class TDTestCase:
tdSql
.
error
(
f
'alter stable
{
stbname
}
modify column c9 double'
)
tdSql
.
error
(
f
'alter stable
{
stbname
}
modify column c9 double'
)
tdSql
.
error
(
f
'alter stable
{
stbname
}
modify column c10 float'
)
tdSql
.
error
(
f
'alter stable
{
stbname
}
modify column c10 float'
)
tdSql
.
error
(
f
'alter stable
{
stbname
}
modify column c11 int'
)
tdSql
.
error
(
f
'alter stable
{
stbname
}
modify column c11 int'
)
tdSql
.
error
(
f
'alter stable
{
stbname
}
drop tag t0'
)
tdSql
.
execute
(
f
'drop database
{
dbname
}
'
)
tdSql
.
execute
(
f
'drop database
{
dbname
}
'
)
def
alter_stable_tag_check
(
self
,
dbname
,
stbname
,
tbname
):
def
alter_stable_tag_check
(
self
,
dbname
,
stbname
,
tbname
):
...
@@ -126,6 +127,11 @@ class TDTestCase:
...
@@ -126,6 +127,11 @@ class TDTestCase:
for
i
in
[
'int'
,
'unsigned int'
,
'float'
,
'binary(10)'
,
'nchar(10)'
]:
for
i
in
[
'int'
,
'unsigned int'
,
'float'
,
'binary(10)'
,
'nchar(10)'
]:
tdSql
.
error
(
f
'alter stable
{
stbname
}
modify tag t8
{
i
}
'
)
tdSql
.
error
(
f
'alter stable
{
stbname
}
modify tag t8
{
i
}
'
)
tdSql
.
error
(
f
'alter stable
{
stbname
}
modify tag t4 int'
)
tdSql
.
error
(
f
'alter stable
{
stbname
}
modify tag t4 int'
)
tdSql
.
error
(
f
'alter stable
{
stbname
}
drop column t0'
)
#!bug TD-16410
# tdSql.error(f'alter stable {tbname} set tag t1=100 ')
# tdSql.execute(f'create table ntb (ts timestamp,c0 int)')
tdSql
.
error
(
f
'alter stable ntb add column c2 '
)
tdSql
.
execute
(
f
'drop database
{
dbname
}
'
)
tdSql
.
execute
(
f
'drop database
{
dbname
}
'
)
def
run
(
self
):
def
run
(
self
):
...
...
tests/system-test/1-insert/alter_table.py
浏览文件 @
2e590c30
...
@@ -52,8 +52,6 @@ class TDTestCase:
...
@@ -52,8 +52,6 @@ class TDTestCase:
tdSql
.
execute
(
f
'create database if not exists
{
dbname
}
'
)
tdSql
.
execute
(
f
'create database if not exists
{
dbname
}
'
)
stbname
=
self
.
get_long_name
(
length
=
3
,
mode
=
"letters"
)
stbname
=
self
.
get_long_name
(
length
=
3
,
mode
=
"letters"
)
tbname
=
self
.
get_long_name
(
length
=
3
,
mode
=
"letters"
)
tbname
=
self
.
get_long_name
(
length
=
3
,
mode
=
"letters"
)
tdLog
.
info
(
'--------------------------child table tag check--------------------------------------'
)
tdLog
.
info
(
f
'-----------------create stable
{
stbname
}
and child table
{
tbname
}
-------------------'
)
tdSql
.
execute
(
f
'create stable if not exists
{
dbname
}
.
{
stbname
}
(col_ts timestamp, c1 int) tags (tag_ts timestamp, t1 tinyint, t2 smallint, t3 int,
\
tdSql
.
execute
(
f
'create stable if not exists
{
dbname
}
.
{
stbname
}
(col_ts timestamp, c1 int) tags (tag_ts timestamp, t1 tinyint, t2 smallint, t3 int,
\
t4 bigint, t5 tinyint unsigned, t6 smallint unsigned, t7 int unsigned, t8 bigint unsigned, t9 float, t10 double, t11 bool,t12 binary(20),t13 nchar(20))'
)
t4 bigint, t5 tinyint unsigned, t6 smallint unsigned, t7 int unsigned, t8 bigint unsigned, t9 float, t10 double, t11 bool,t12 binary(20),t13 nchar(20))'
)
tdSql
.
execute
(
f
'create table if not exists
{
dbname
}
.
{
tbname
}
using
{
dbname
}
.
{
stbname
}
tags(now, 1, 2, 3, 4, 5, 6, 7, 8, 9.9, 10.1, True,"abc123","涛思数据")'
)
tdSql
.
execute
(
f
'create table if not exists
{
dbname
}
.
{
tbname
}
using
{
dbname
}
.
{
stbname
}
tags(now, 1, 2, 3, 4, 5, 6, 7, 8, 9.9, 10.1, True,"abc123","涛思数据")'
)
...
@@ -90,13 +88,16 @@ class TDTestCase:
...
@@ -90,13 +88,16 @@ class TDTestCase:
tdSql
.
checkData
(
0
,
15
,
tag_nchar
)
tdSql
.
checkData
(
0
,
15
,
tag_nchar
)
# bug TD-16211 insert length more than setting binary and nchar
# bug TD-16211 insert length more than setting binary and nchar
# tag_binary = self.get_long_name(length=21, mode="letters")
# error_tag_binary = self.get_long_name(length=21, mode="letters")
# tag_nchar = self.get_long_name(length=21, mode="letters")
# error_tag_nchar = self.get_long_name(length=21, mode="letters")
# tdSql.error(f'alter table {dbname}.{tbname} set tag t12 = "{tag_binary}"')
# tdSql.error(f'alter table {dbname}.{tbname} set tag t12 = "{error_tag_binary}"')
# tdSql.error(f'alter table {dbname}.{tbname} set tag t13 = "{tag_nchar}"')
# tdSql.error(f'alter table {dbname}.{tbname} set tag t13 = "{error_tag_nchar}"')
error_tag_binary
=
self
.
get_long_name
(
length
=
25
,
mode
=
"letters"
)
error_tag_nchar
=
self
.
get_long_name
(
length
=
25
,
mode
=
"letters"
)
tdSql
.
error
(
f
'alter table
{
dbname
}
.
{
tbname
}
set tag t12 = "
{
error_tag_binary
}
"'
)
tdSql
.
error
(
f
'alter table
{
dbname
}
.
{
tbname
}
set tag t13 = "
{
error_tag_nchar
}
"'
)
# bug TD-16210 modify binary to nchar
# bug TD-16210 modify binary to nchar
#
tdSql.error(f'alter table {dbname}.{tbname} modify tag t12 nchar(10)')
tdSql
.
error
(
f
'alter table
{
dbname
}
.
{
tbname
}
modify tag t12 nchar(10)'
)
tdSql
.
execute
(
f
"drop database
{
dbname
}
"
)
tdSql
.
execute
(
f
"drop database
{
dbname
}
"
)
def
alter_ntb_column_check
(
self
):
def
alter_ntb_column_check
(
self
):
'''
'''
...
@@ -125,6 +126,20 @@ class TDTestCase:
...
@@ -125,6 +126,20 @@ class TDTestCase:
tdSql
.
execute
(
f
'alter table
{
dbname
}
.
{
tbname
}
drop column `c15`'
)
tdSql
.
execute
(
f
'alter table
{
dbname
}
.
{
tbname
}
drop column `c15`'
)
tdSql
.
query
(
f
'describe
{
dbname
}
.
{
tbname
}
'
)
tdSql
.
query
(
f
'describe
{
dbname
}
.
{
tbname
}
'
)
tdSql
.
checkRows
(
14
)
tdSql
.
checkRows
(
14
)
#! TD-16422
# tdSql.execute(f'alter table {dbname}.{tbname} add column c16 binary(10)')
# tdSql.query(f'describe {dbname}.{tbname}')
# tdSql.checkRows(15)
# tdSql.checkEqual(tdSql.queryResult[14][2],10)
# tdSql.execute(f'alter table {dbname}.{tbname} drop column c16')
# tdSql.execute(f'alter table {dbname}.{tbname} add column c16 nchar(10)')
# tdSql.query(f'describe {dbname}.{tbname}')
# tdSql.checkRows(15)
# tdSql.checkEqual(tdSql.queryResult[14][2],10)
# tdSql.execute(f'alter table {dbname}.{tbname} drop column c16')
tdSql
.
execute
(
f
'alter table
{
dbname
}
.
{
tbname
}
modify column c12 binary(30)'
)
tdSql
.
execute
(
f
'alter table
{
dbname
}
.
{
tbname
}
modify column c12 binary(30)'
)
tdSql
.
query
(
f
'describe
{
dbname
}
.
{
tbname
}
'
)
tdSql
.
query
(
f
'describe
{
dbname
}
.
{
tbname
}
'
)
tdSql
.
checkData
(
12
,
2
,
30
)
tdSql
.
checkData
(
12
,
2
,
30
)
...
...
tests/system-test/1-insert/insertWithMoreVgroup.py
浏览文件 @
2e590c30
...
@@ -119,7 +119,7 @@ class TDTestCase:
...
@@ -119,7 +119,7 @@ class TDTestCase:
# tdLog.debug("spent %.2fs to create 1 stable and %d table, create speed is %.2f table/s... [OK]"% (spendTime,count,speedCreate))
# tdLog.debug("spent %.2fs to create 1 stable and %d table, create speed is %.2f table/s... [OK]"% (spendTime,count,speedCreate))
return
return
def
mutiThread_create_tables
(
self
,
host
,
dbname
,
stbname
,
vgroups
,
threadNumbers
,
child
row
count
):
def
mutiThread_create_tables
(
self
,
host
,
dbname
,
stbname
,
vgroups
,
threadNumbers
,
childcount
):
buildPath
=
self
.
getBuildPath
()
buildPath
=
self
.
getBuildPath
()
config
=
buildPath
+
"../sim/dnode1/cfg/"
config
=
buildPath
+
"../sim/dnode1/cfg/"
...
@@ -128,7 +128,7 @@ class TDTestCase:
...
@@ -128,7 +128,7 @@ class TDTestCase:
tsql
.
execute
(
"drop database if exists %s"
%
dbname
)
tsql
.
execute
(
"drop database if exists %s"
%
dbname
)
tsql
.
execute
(
"create database %s vgroups %d"
%
(
dbname
,
vgroups
))
tsql
.
execute
(
"create database %s vgroups %d"
%
(
dbname
,
vgroups
))
tsql
.
execute
(
"use %s"
%
dbname
)
tsql
.
execute
(
"use %s"
%
dbname
)
count
=
int
(
child
row
count
)
count
=
int
(
childcount
)
threads
=
[]
threads
=
[]
for
i
in
range
(
threadNumbers
):
for
i
in
range
(
threadNumbers
):
tsql
.
execute
(
"create stable %s%d(ts timestamp, c1 int, c2 binary(10)) tags(t1 int)"
%
(
stbname
,
i
))
tsql
.
execute
(
"create stable %s%d(ts timestamp, c1 int, c2 binary(10)) tags(t1 int)"
%
(
stbname
,
i
))
...
@@ -264,19 +264,88 @@ class TDTestCase:
...
@@ -264,19 +264,88 @@ class TDTestCase:
speedCreate
=
count
/
spendTime
speedCreate
=
count
/
spendTime
tdLog
.
debug
(
"spent %.2fs to create 1 stable and %d table, create speed is %.2f table/s... [OK]"
%
(
spendTime
,
count
,
speedCreate
))
tdLog
.
debug
(
"spent %.2fs to create 1 stable and %d table, create speed is %.2f table/s... [OK]"
%
(
spendTime
,
count
,
speedCreate
))
return
return
def
checkData
(
self
,
dbname
,
stbname
,
stableCount
,
CtableCount
,
rowsPerSTable
,):
tdSql
.
execute
(
"use %s"
%
dbname
)
tdSql
.
query
(
"show stables"
)
tdSql
.
checkRows
(
stableCount
)
tdSql
.
query
(
"show tables"
)
tdSql
.
checkRows
(
CtableCount
)
for
i
in
range
(
stableCount
):
tdSql
.
query
(
"select count(*) from %s%d"
%
(
stbname
,
i
))
tdSql
.
checkData
(
0
,
0
,
rowsPerSTable
)
return
# test case1 base
# test case1 base
def
test_case1
(
self
):
def
test_case1
(
self
):
#stableCount=threadNumbersCtb
parameterDict
=
{
'vgroups'
:
1
,
\
'threadNumbersCtb'
:
5
,
\
'threadNumbersIda'
:
5
,
\
'stableCount'
:
5
,
\
'tablesPerStb'
:
50
,
\
'rowsPerTable'
:
10
,
\
'dbname'
:
'db'
,
\
'stbname'
:
'stb'
,
\
'host'
:
'localhost'
,
\
'startTs'
:
1640966400000
}
# 2022-01-01 00:00:00.000
tdLog
.
debug
(
"-----create database and muti-thread create tables test------- "
)
tdLog
.
debug
(
"-----create database and muti-thread create tables test------- "
)
#host,dbname,stbname,vgroups,threadNumbers,tcountStart,tcountStop
#host,dbname,stbname,vgroups,threadNumbers,tcountStart,tcountStop
#host, dbname, stbname, threadNumbers, chilCount, ts_start, childrowcount
#host, dbname, stbname, threadNumbers, chilCount, ts_start, childrowcount
self
.
mutiThread_create_tables
(
host
=
"localhost"
,
dbname
=
"db"
,
stbname
=
"stb"
,
vgroups
=
1
,
threadNumbers
=
5
,
childrowcount
=
50
)
self
.
mutiThread_create_tables
(
self
.
mutiThread_insert_data
(
host
=
"localhost"
,
dbname
=
"db"
,
stbname
=
"stb"
,
threadNumbers
=
5
,
chilCount
=
50
,
ts_start
=
self
.
ts
,
childrowcount
=
10
)
host
=
parameterDict
[
'host'
],
dbname
=
parameterDict
[
'dbname'
],
return
stbname
=
parameterDict
[
'stbname'
],
vgroups
=
parameterDict
[
'vgroups'
],
threadNumbers
=
parameterDict
[
'threadNumbersCtb'
],
childcount
=
parameterDict
[
'tablesPerStb'
])
self
.
mutiThread_insert_data
(
host
=
parameterDict
[
'host'
],
dbname
=
parameterDict
[
'dbname'
],
stbname
=
parameterDict
[
'stbname'
],
threadNumbers
=
parameterDict
[
'threadNumbersIda'
],
chilCount
=
parameterDict
[
'tablesPerStb'
],
ts_start
=
parameterDict
[
'startTs'
],
childrowcount
=
parameterDict
[
'rowsPerTable'
])
tableCount
=
parameterDict
[
'threadNumbersCtb'
]
*
parameterDict
[
'tablesPerStb'
]
rowsPerStable
=
parameterDict
[
'rowsPerTable'
]
*
parameterDict
[
'tablesPerStb'
]
self
.
checkData
(
dbname
=
parameterDict
[
'dbname'
],
stbname
=
parameterDict
[
'stbname'
],
stableCount
=
parameterDict
[
'threadNumbersCtb'
],
CtableCount
=
tableCount
,
rowsPerSTable
=
rowsPerStable
)
def
test_case3
(
self
):
def
test_case3
(
self
):
self
.
taosBenchCreate
(
"127.0.0.1"
,
"no"
,
"db1"
,
"stb1"
,
1
,
8
,
1
*
10
)
#stableCount=threadNumbersCtb
parameterDict
=
{
'vgroups'
:
1
,
\
'threadNumbersCtb'
:
8
,
\
'stableCount'
:
5
,
\
'tablesPerStb'
:
10
,
\
'rowsPerTable'
:
100
,
\
'dbname'
:
'db1'
,
\
'stbname'
:
'stb1'
,
\
'host'
:
'localhost'
,
\
'startTs'
:
1640966400000
}
# 2022-01-01 00:00:00.000
self
.
taosBenchCreate
(
parameterDict
[
'host'
],
"no"
,
parameterDict
[
'dbname'
],
parameterDict
[
'stbname'
],
parameterDict
[
'vgroups'
],
parameterDict
[
'threadNumbersCtb'
],
parameterDict
[
'tablesPerStb'
])
tableCount
=
parameterDict
[
'threadNumbersCtb'
]
*
parameterDict
[
'tablesPerStb'
]
rowsPerStable
=
parameterDict
[
'rowsPerTable'
]
*
parameterDict
[
'tablesPerStb'
]
self
.
checkData
(
dbname
=
parameterDict
[
'dbname'
],
stbname
=
parameterDict
[
'stbname'
],
stableCount
=
parameterDict
[
'threadNumbersCtb'
],
CtableCount
=
tableCount
,
rowsPerSTable
=
rowsPerStable
)
# self.taosBenchCreate("test209","no","db2", "stb2", 1, 8, 1*10000)
# self.taosBenchCreate("test209","no","db2", "stb2", 1, 8, 1*10000)
# self.taosBenchCreate("chenhaoran02","no","db1", "stb1", 1, 8, 1*10000)
# self.taosBenchCreate("chenhaoran02","no","db1", "stb1", 1, 8, 1*10000)
...
@@ -320,14 +389,6 @@ class TDTestCase:
...
@@ -320,14 +389,6 @@ class TDTestCase:
# tdSql.execute("create qnode on dnode %s"%dnodeId)
# tdSql.execute("create qnode on dnode %s"%dnodeId)
# self.taosBenchCreate("test209","no","db2", "stb2", 1, 8, 1*10000)
# self.taosBenchCreate("chenhaoran02","no","db1", "stb1", 1, 8, 1*10000)
# self.taosBenchCreate("db1", "stb1", 4, 5, 100*10000)
# self.taosBenchCreate("db1", "stb1", 1, 5, 100*10000)
# run case
# run case
def
run
(
self
):
def
run
(
self
):
...
...
tests/system-test/1-insert/manyVgroups.json
浏览文件 @
2e590c30
...
@@ -11,7 +11,7 @@
...
@@ -11,7 +11,7 @@
"confirm_parameter_prompt"
:
"no"
,
"confirm_parameter_prompt"
:
"no"
,
"insert_interval"
:
0
,
"insert_interval"
:
0
,
"interlace_rows"
:
0
,
"interlace_rows"
:
0
,
"num_of_records_per_req"
:
100
,
"num_of_records_per_req"
:
100
000
,
"databases"
:
[
"databases"
:
[
{
{
"dbinfo"
:
{
"dbinfo"
:
{
...
@@ -29,7 +29,7 @@
...
@@ -29,7 +29,7 @@
"batch_create_tbl_num"
:
50000
,
"batch_create_tbl_num"
:
50000
,
"data_source"
:
"rand"
,
"data_source"
:
"rand"
,
"insert_mode"
:
"taosc"
,
"insert_mode"
:
"taosc"
,
"insert_rows"
:
1
,
"insert_rows"
:
1
00
,
"interlace_rows"
:
0
,
"interlace_rows"
:
0
,
"insert_interval"
:
0
,
"insert_interval"
:
0
,
"max_sql_len"
:
10000000
,
"max_sql_len"
:
10000000
,
...
@@ -45,28 +45,28 @@
...
@@ -45,28 +45,28 @@
},
},
{
{
"type"
:
"DOUBLE"
,
"type"
:
"DOUBLE"
,
"count"
:
1
00
"count"
:
1
},
},
{
{
"type"
:
"BINARY"
,
"type"
:
"BINARY"
,
"len"
:
40
0
,
"len"
:
40
,
"count"
:
1
0
"count"
:
1
},
},
{
{
"type"
:
"nchar"
,
"type"
:
"nchar"
,
"len"
:
20
0
,
"len"
:
20
,
"count"
:
20
"count"
:
1
}
}
],
],
"tags"
:
[
"tags"
:
[
{
{
"type"
:
"TINYINT"
,
"type"
:
"TINYINT"
,
"count"
:
2
"count"
:
1
},
},
{
{
"type"
:
"BINARY"
,
"type"
:
"BINARY"
,
"len"
:
16
,
"len"
:
16
,
"count"
:
2
"count"
:
1
}
}
]
]
}
}
...
...
tests/system-test/2-query/bottom.py
浏览文件 @
2e590c30
...
@@ -11,9 +11,12 @@
...
@@ -11,9 +11,12 @@
# -*- coding: utf-8 -*-
# -*- coding: utf-8 -*-
import
random
import
string
from
util.log
import
*
from
util.log
import
*
from
util.cases
import
*
from
util.cases
import
*
from
util.sql
import
*
from
util.sql
import
*
from
util.common
import
*
...
@@ -23,79 +26,89 @@ class TDTestCase:
...
@@ -23,79 +26,89 @@ class TDTestCase:
tdSql
.
init
(
conn
.
cursor
())
tdSql
.
init
(
conn
.
cursor
())
self
.
rowNum
=
10
self
.
rowNum
=
10
self
.
tbnum
=
20
self
.
ts
=
1537146000000
self
.
ts
=
1537146000000
self
.
binary_str
=
'taosdata'
def
run
(
self
):
self
.
nchar_str
=
'涛思数据'
def
bottom_check_base
(
self
):
tdSql
.
prepare
()
tdSql
.
prepare
()
tdSql
.
execute
(
'''create table stb(ts timestamp, col1 tinyint, col2 smallint, col3 int, col4 bigint, col5 tinyint unsigned, col6 smallint unsigned,
tdSql
.
execute
(
'''create table test(ts timestamp, col1 tinyint, col2 smallint, col3 int, col4 bigint, col5 float, col6 double,
col7 int unsigned, col8 bigint unsigned, col9 float, col10 double, col11 bool, col12 binary(20), col13 nchar(20)) tags(loc nchar(20))'''
)
col7 bool, col8 binary(20), col9 nchar(20), col11 tinyint unsigned, col12 smallint unsigned, col13 int unsigned, col14 bigint unsigned) tags(loc nchar(20))'''
)
tdSql
.
execute
(
"create table stb_1 using stb tags('beijing')"
)
tdSql
.
execute
(
"create table test1 using test tags('beijing')"
)
column_list
=
[
'col1'
,
'col2'
,
'col3'
,
'col4'
,
'col5'
,
'col6'
,
'col7'
,
'col8'
]
error_column_list
=
[
'col11'
,
'col12'
,
'col13'
]
error_param_list
=
[
0
,
101
]
for
i
in
range
(
self
.
rowNum
):
for
i
in
range
(
self
.
rowNum
):
tdSql
.
execute
(
"insert into test1 values(%d, %d, %d, %d, %d, %f, %f, %d, 'taosdata%d', '涛思数据%d', %d, %d, %d, %d)"
tdSql
.
execute
(
f
"insert into stb_1 values(%d, %d, %d, %d, %d, %d, %d, %d, %d, %f, %f, %d, '
{
self
.
binary_str
}
%d', '
{
self
.
nchar_str
}
%d')"
%
(
self
.
ts
+
i
,
i
+
1
,
i
+
1
,
i
+
1
,
i
+
1
,
i
+
0.1
,
i
+
0.1
,
i
%
2
,
i
+
1
,
i
+
1
,
i
+
1
,
i
+
1
,
i
+
1
,
i
+
1
))
%
(
self
.
ts
+
i
,
i
+
1
,
i
+
1
,
i
+
1
,
i
+
1
,
i
+
1
,
i
+
1
,
i
+
1
,
i
+
1
,
i
+
0.1
,
i
+
0.1
,
i
%
2
,
i
+
1
,
i
+
1
))
# bottom verifacation
for
i
in
column_list
:
tdSql
.
error
(
"select bottom(ts, 10) from test"
)
tdSql
.
query
(
f
'select bottom(
{
i
}
,2) from stb_1'
)
tdSql
.
error
(
"select bottom(col1, 0) from test"
)
tdSql
.
checkRows
(
2
)
tdSql
.
error
(
"select bottom(col1, 101) from test"
)
tdSql
.
checkEqual
(
tdSql
.
queryResult
,[(
2
,),(
1
,)])
tdSql
.
error
(
"select bottom(col2, 0) from test"
)
for
j
in
error_param_list
:
tdSql
.
error
(
"select bottom(col2, 101) from test"
)
tdSql
.
error
(
f
'select bottom(
{
i
}
,
{
j
}
) from stb_1'
)
tdSql
.
error
(
"select bottom(col3, 0) from test"
)
for
i
in
error_column_list
:
tdSql
.
error
(
"select bottom(col3, 101) from test"
)
tdSql
.
error
(
f
'select bottom(
{
i
}
,10) from stb_1'
)
tdSql
.
error
(
"select bottom(col4, 0) from test"
)
tdSql
.
query
(
"select ts,bottom(col1, 2),ts from stb_1 group by tbname"
)
tdSql
.
error
(
"select bottom(col4, 101) from test"
)
tdSql
.
error
(
"select bottom(col5, 0) from test"
)
tdSql
.
error
(
"select bottom(col5, 101) from test"
)
tdSql
.
error
(
"select bottom(col6, 0) from test"
)
tdSql
.
error
(
"select bottom(col6, 101) from test"
)
tdSql
.
error
(
"select bottom(col7, 10) from test"
)
tdSql
.
error
(
"select bottom(col8, 10) from test"
)
tdSql
.
error
(
"select bottom(col9, 10) from test"
)
tdSql
.
query
(
"select bottom(col1, 2) from test"
)
tdSql
.
checkRows
(
2
)
tdSql
.
checkEqual
(
tdSql
.
queryResult
,[(
2
,),(
1
,)])
tdSql
.
query
(
"select bottom(col2, 2) from test"
)
tdSql
.
checkRows
(
2
)
tdSql
.
checkEqual
(
tdSql
.
queryResult
,[(
2
,),(
1
,)])
tdSql
.
query
(
"select bottom(col3, 2) from test"
)
tdSql
.
checkRows
(
2
)
tdSql
.
checkEqual
(
tdSql
.
queryResult
,[(
2
,),(
1
,)])
tdSql
.
query
(
"select bottom(col4, 2) from test"
)
tdSql
.
checkRows
(
2
)
tdSql
.
checkEqual
(
tdSql
.
queryResult
,[(
2
,),(
1
,)])
tdSql
.
query
(
"select bottom(col11, 2) from test"
)
tdSql
.
checkRows
(
2
)
tdSql
.
checkEqual
(
tdSql
.
queryResult
,[(
2
,),(
1
,)])
tdSql
.
query
(
"select bottom(col12, 2) from test"
)
tdSql
.
checkRows
(
2
)
tdSql
.
checkEqual
(
tdSql
.
queryResult
,[(
2
,),(
1
,)])
tdSql
.
query
(
"select bottom(col13, 2) from test"
)
tdSql
.
checkRows
(
2
)
tdSql
.
checkEqual
(
tdSql
.
queryResult
,[(
2
,),(
1
,)])
tdSql
.
query
(
"select bottom(col13,50) from test"
)
tdSql
.
checkRows
(
10
)
tdSql
.
query
(
"select bottom(col14, 2) from test"
)
tdSql
.
checkRows
(
2
)
tdSql
.
checkEqual
(
tdSql
.
queryResult
,[(
2
,),(
1
,)])
tdSql
.
query
(
"select ts,bottom(col1, 2) from test1"
)
tdSql
.
checkRows
(
2
)
tdSql
.
query
(
"select ts,bottom(col1, 2),ts from test group by tbname"
)
tdSql
.
checkRows
(
2
)
tdSql
.
checkRows
(
2
)
tdSql
.
query
(
'select bottom(col2,1) from stb_1 interval(1y) order by col2'
)
tdSql
.
query
(
'select bottom(col2,1) from test interval(1y) order by col2'
)
tdSql
.
checkData
(
0
,
0
,
1
)
tdSql
.
checkData
(
0
,
0
,
1
)
tdSql
.
error
(
'select * from stb_1 where bottom(col2,1)=1'
)
tdSql
.
execute
(
'drop database db'
)
def
bottom_check_distribute
(
self
):
# prepare data for vgroup 4
dbname
=
tdCom
.
getLongName
(
5
,
"letters"
)
stbname
=
tdCom
.
getLongName
(
5
,
"letters"
)
vgroup_num
=
2
child_table_num
=
20
tdSql
.
execute
(
f
"create database if not exists
{
dbname
}
vgroups
{
vgroup_num
}
"
)
tdSql
.
execute
(
f
'use
{
dbname
}
'
)
# build 20 child tables,every table insert 10 rows
tdSql
.
execute
(
f
'''create table
{
stbname
}
(ts timestamp, col1 tinyint, col2 smallint, col3 int, col4 bigint, col5 tinyint unsigned, col6 smallint unsigned,
col7 int unsigned, col8 bigint unsigned, col9 float, col10 double, col11 bool, col12 binary(20), col13 nchar(20)) tags(loc nchar(20))'''
)
for
i
in
range
(
child_table_num
):
tdSql
.
execute
(
f
"create table
{
stbname
}
_
{
i
}
using
{
stbname
}
tags('beijing')"
)
tdSql
.
execute
(
f
"insert into
{
stbname
}
_
{
i
}
(ts) values(%d)"
%
(
self
.
ts
-
1
-
i
))
column_list
=
[
'col1'
,
'col2'
,
'col3'
,
'col4'
,
'col5'
,
'col6'
,
'col7'
,
'col8'
]
error_column_list
=
[
'col11'
,
'col12'
,
'col13'
]
error_param_list
=
[
0
,
101
]
for
i
in
[
f
'
{
stbname
}
'
,
f
'
{
dbname
}
.
{
stbname
}
'
]:
for
j
in
column_list
:
tdSql
.
query
(
f
"select bottom(
{
j
}
,1) from
{
i
}
"
)
tdSql
.
checkRows
(
0
)
tdSql
.
query
(
'show tables'
)
vgroup_list
=
[]
for
i
in
range
(
len
(
tdSql
.
queryResult
)):
vgroup_list
.
append
(
tdSql
.
queryResult
[
i
][
6
])
vgroup_list_set
=
set
(
vgroup_list
)
for
i
in
vgroup_list_set
:
vgroups_num
=
vgroup_list
.
count
(
i
)
if
vgroups_num
>=
2
:
tdLog
.
info
(
f
'This scene with
{
vgroups_num
}
vgroups is ok!'
)
continue
else
:
tdLog
.
exit
(
f
'This scene does not meet the requirements with
{
vgroups_num
}
vgroup!
\n
'
)
for
i
in
range
(
self
.
rowNum
):
for
j
in
range
(
child_table_num
):
tdSql
.
execute
(
f
"insert into
{
stbname
}
_
{
j
}
values(%d, %d, %d, %d, %d, %d, %d, %d, %d, %f, %f, %d, '
{
self
.
binary_str
}
%d', '
{
self
.
nchar_str
}
%d')"
%
(
self
.
ts
+
i
,
i
+
1
,
i
+
1
,
i
+
1
,
i
+
1
,
i
+
1
,
i
+
1
,
i
+
1
,
i
+
1
,
i
+
0.1
,
i
+
0.1
,
i
%
2
,
i
+
1
,
i
+
1
))
for
i
in
column_list
:
tdSql
.
query
(
f
'select bottom(
{
i
}
,2) from
{
stbname
}
'
)
tdSql
.
checkRows
(
2
)
tdSql
.
checkEqual
(
tdSql
.
queryResult
,[(
1
,),(
1
,)])
for
j
in
error_param_list
:
tdSql
.
error
(
f
'select bottom(
{
i
}
,
{
j
}
) from
{
stbname
}
'
)
for
i
in
error_column_list
:
tdSql
.
error
(
f
'select bottom(
{
i
}
,10) from
{
stbname
}
'
)
tdSql
.
execute
(
f
'drop database
{
dbname
}
'
)
def
run
(
self
):
tdSql
.
error
(
'select * from test where bottom(col2,1)=1'
)
self
.
bottom_check_base
()
self
.
bottom_check_distribute
()
def
stop
(
self
):
def
stop
(
self
):
...
...
tests/system-test/2-query/distribute_agg_apercentile.py
0 → 100644
浏览文件 @
2e590c30
from
util.log
import
*
from
util.cases
import
*
from
util.sql
import
*
import
numpy
as
np
import
random
class
TDTestCase
:
updatecfgDict
=
{
'debugFlag'
:
143
,
"cDebugFlag"
:
143
,
"uDebugFlag"
:
143
,
"rpcDebugFlag"
:
143
,
"tmrDebugFlag"
:
143
,
"jniDebugFlag"
:
143
,
"simDebugFlag"
:
143
,
"dDebugFlag"
:
143
,
"dDebugFlag"
:
143
,
"vDebugFlag"
:
143
,
"mDebugFlag"
:
143
,
"qDebugFlag"
:
143
,
"wDebugFlag"
:
143
,
"sDebugFlag"
:
143
,
"tsdbDebugFlag"
:
143
,
"tqDebugFlag"
:
143
,
"fsDebugFlag"
:
143
,
"fnDebugFlag"
:
143
,
"maxTablesPerVnode"
:
2
,
"minTablesPerVnode"
:
2
,
"tableIncStepPerVnode"
:
2
}
def
init
(
self
,
conn
,
logSql
):
tdLog
.
debug
(
"start to execute %s"
%
__file__
)
tdSql
.
init
(
conn
.
cursor
())
self
.
vnode_disbutes
=
None
self
.
ts
=
1537146000000
def
prepare_datas_of_distribute
(
self
):
# prepate datas for 20 tables distributed at different vgroups
tdSql
.
execute
(
"create database if not exists testdb keep 3650 duration 1000 vgroups 5"
)
tdSql
.
execute
(
" use testdb "
)
tdSql
.
execute
(
'''create table stb1
(ts timestamp, c1 int, c2 bigint, c3 smallint, c4 tinyint, c5 float, c6 double, c7 bool, c8 binary(16),c9 nchar(32), c10 timestamp)
tags (t0 timestamp, t1 int, t2 bigint, t3 smallint, t4 tinyint, t5 float, t6 double, t7 bool, t8 binary(16),t9 nchar(32))
'''
)
tdSql
.
execute
(
'''
create table t1
(ts timestamp, c1 int, c2 bigint, c3 smallint, c4 tinyint, c5 float, c6 double, c7 bool, c8 binary(16),c9 nchar(32), c10 timestamp)
'''
)
for
i
in
range
(
20
):
tdSql
.
execute
(
f
'create table ct
{
i
+
1
}
using stb1 tags ( now(),
{
1
*
i
}
,
{
11111
*
i
}
,
{
111
*
i
}
,
{
11
*
i
}
,
{
1.11
*
i
}
,
{
11.11
*
i
}
,
{
i
%
2
}
, "binary
{
i
}
", "nchar
{
i
}
" )'
)
for
i
in
range
(
9
):
tdSql
.
execute
(
f
"insert into ct1 values ( now()-
{
i
*
10
}
s,
{
1
*
i
}
,
{
11111
*
i
}
,
{
111
*
i
}
,
{
11
*
i
}
,
{
1.11
*
i
}
,
{
11.11
*
i
}
,
{
i
%
2
}
, 'binary
{
i
}
', 'nchar
{
i
}
', now()+
{
1
*
i
}
a )"
)
tdSql
.
execute
(
f
"insert into ct4 values ( now()-
{
i
*
90
}
d,
{
1
*
i
}
,
{
11111
*
i
}
,
{
111
*
i
}
,
{
11
*
i
}
,
{
1.11
*
i
}
,
{
11.11
*
i
}
,
{
i
%
2
}
, 'binary
{
i
}
', 'nchar
{
i
}
', now()+
{
1
*
i
}
a )"
)
for
i
in
range
(
1
,
21
):
if
i
==
1
or
i
==
4
:
continue
else
:
tbname
=
"ct"
+
f
'
{
i
}
'
for
j
in
range
(
9
):
tdSql
.
execute
(
f
"insert into
{
tbname
}
values ( now()-
{
(
i
+
j
)
*
10
}
s,
{
1
*
(
j
+
i
)
}
,
{
11111
*
(
j
+
i
)
}
,
{
111
*
(
j
+
i
)
}
,
{
11
*
(
j
)
}
,
{
1.11
*
(
j
+
i
)
}
,
{
11.11
*
(
j
+
i
)
}
,
{
(
j
+
i
)
%
2
}
, 'binary
{
j
}
', 'nchar
{
j
}
', now()+
{
1
*
j
}
a )"
)
tdSql
.
execute
(
"insert into ct1 values (now()-45s, 0, 0, 0, 0, 0, 0, 0, 'binary0', 'nchar0', now()+8a )"
)
tdSql
.
execute
(
"insert into ct1 values (now()+10s, 9, -99999, -999, -99, -9.99, -99.99, 1, 'binary9', 'nchar9', now()+9a )"
)
tdSql
.
execute
(
"insert into ct1 values (now()+15s, 9, -99999, -999, -99, -9.99, NULL, 1, 'binary9', 'nchar9', now()+9a )"
)
tdSql
.
execute
(
"insert into ct1 values (now()+20s, 9, -99999, -999, NULL, -9.99, -99.99, 1, 'binary9', 'nchar9', now()+9a )"
)
tdSql
.
execute
(
"insert into ct4 values (now()-810d, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) "
)
tdSql
.
execute
(
"insert into ct4 values (now()-400d, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) "
)
tdSql
.
execute
(
"insert into ct4 values (now()+90d, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) "
)
tdSql
.
execute
(
f
'''insert into t1 values
( '2020-04-21 01:01:01.000', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL )
( '2020-10-21 01:01:01.000', 1, 11111, 111, 11, 1.11, 11.11, 1, "binary1", "nchar1", now()+1a )
( '2020-12-31 01:01:01.000', 2, 22222, 222, 22, 2.22, 22.22, 0, "binary2", "nchar2", now()+2a )
( '2021-01-01 01:01:06.000', 3, 33333, 333, 33, 3.33, 33.33, 0, "binary3", "nchar3", now()+3a )
( '2021-05-07 01:01:10.000', 4, 44444, 444, 44, 4.44, 44.44, 1, "binary4", "nchar4", now()+4a )
( '2021-07-21 01:01:01.000', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL )
( '2021-09-30 01:01:16.000', 5, 55555, 555, 55, 5.55, 55.55, 0, "binary5", "nchar5", now()+5a )
( '2022-02-01 01:01:20.000', 6, 66666, 666, 66, 6.66, 66.66, 1, "binary6", "nchar6", now()+6a )
( '2022-10-28 01:01:26.000', 7, 00000, 000, 00, 0.00, 00.00, 1, "binary7", "nchar7", "1970-01-01 08:00:00.000" )
( '2022-12-01 01:01:30.000', 8, -88888, -888, -88, -8.88, -88.88, 0, "binary8", "nchar8", "1969-01-01 01:00:00.000" )
( '2022-12-31 01:01:36.000', 9, -99999999999999999, -999, -99, -9.99, -999999999999999999999.99, 1, "binary9", "nchar9", "1900-01-01 00:00:00.000" )
( '2023-02-21 01:01:01.000', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL )
'''
)
tdLog
.
info
(
" prepare data for distributed_aggregate done! "
)
def
check_distribute_datas
(
self
):
# get vgroup_ids of all
tdSql
.
query
(
"show vgroups "
)
vgroups
=
tdSql
.
queryResult
vnode_tables
=
{}
for
vgroup_id
in
vgroups
:
vnode_tables
[
vgroup_id
[
0
]]
=
[]
# check sub_table of per vnode ,make sure sub_table has been distributed
tdSql
.
query
(
"show tables like 'ct%'"
)
table_names
=
tdSql
.
queryResult
tablenames
=
[]
for
table_name
in
table_names
:
vnode_tables
[
table_name
[
6
]].
append
(
table_name
[
0
])
self
.
vnode_disbutes
=
vnode_tables
count
=
0
for
k
,
v
in
vnode_tables
.
items
():
if
len
(
v
)
>=
2
:
count
+=
1
if
count
<
2
:
tdLog
.
exit
(
" the datas of all not satisfy sub_table has been distributed "
)
def
distribute_agg_query
(
self
):
# basic filter
tdSql
.
query
(
"select apercentile(c1 , 20) from stb1 where c1 is null"
)
tdSql
.
checkRows
(
0
)
tdSql
.
query
(
"select apercentile(c1 , 20) from stb1 where t1=1"
)
tdSql
.
checkData
(
0
,
0
,
2.800000000
)
tdSql
.
query
(
"select apercentile(c1+c2 ,100) from stb1 where c1 =1 "
)
tdSql
.
checkData
(
0
,
0
,
11112.000000000
)
tdSql
.
query
(
"select apercentile(c1 ,10 ) from stb1 where tbname=
\"
ct2
\"
"
)
tdSql
.
checkData
(
0
,
0
,
2.000000000
)
tdSql
.
query
(
"select apercentile(c1,20) from stb1 partition by tbname"
)
tdSql
.
checkRows
(
20
)
tdSql
.
query
(
"select apercentile(c1,20) from stb1 where t1> 4 partition by tbname"
)
tdSql
.
checkRows
(
15
)
# union all
tdSql
.
query
(
"select apercentile(c1,20) from stb1 union all select apercentile(c1,20) from stb1 "
)
tdSql
.
checkRows
(
2
)
tdSql
.
checkData
(
0
,
0
,
7.389181281
)
# join
tdSql
.
execute
(
" create database if not exists db "
)
tdSql
.
execute
(
" use db "
)
tdSql
.
execute
(
" create stable st (ts timestamp , c1 int ,c2 float) tags(t1 int) "
)
tdSql
.
execute
(
" create table tb1 using st tags(1) "
)
tdSql
.
execute
(
" create table tb2 using st tags(2) "
)
for
i
in
range
(
10
):
ts
=
i
*
10
+
self
.
ts
tdSql
.
execute
(
f
" insert into tb1 values(
{
ts
}
,
{
i
}
,
{
i
}
.0)"
)
tdSql
.
execute
(
f
" insert into tb2 values(
{
ts
}
,
{
i
}
,
{
i
}
.0)"
)
tdSql
.
query
(
"select apercentile(tb1.c1,100), apercentile(tb2.c2,100) from tb1, tb2 where tb1.ts=tb2.ts"
)
tdSql
.
checkRows
(
1
)
tdSql
.
checkData
(
0
,
0
,
9.000000000
)
tdSql
.
checkData
(
0
,
0
,
9.000000000
)
# group by
tdSql
.
execute
(
" use testdb "
)
tdSql
.
query
(
" select max(c1),c1 from stb1 group by t1 "
)
tdSql
.
checkRows
(
20
)
tdSql
.
query
(
" select max(c1),c1 from stb1 group by c1 "
)
tdSql
.
checkRows
(
30
)
tdSql
.
query
(
" select max(c1),c2 from stb1 group by c2 "
)
tdSql
.
checkRows
(
31
)
# partition by tbname or partition by tag
tdSql
.
query
(
"select apercentile(c1 ,10)from stb1 partition by tbname"
)
query_data
=
tdSql
.
queryResult
# nest query for support max
tdSql
.
query
(
"select apercentile(c2+2,10)+1 from (select max(c1) c2 from stb1)"
)
tdSql
.
checkData
(
0
,
0
,
31.000000000
)
tdSql
.
query
(
"select apercentile(c1+2,10)+1 as c2 from (select ts ,c1 ,c2 from stb1)"
)
tdSql
.
checkData
(
0
,
0
,
7.560701700
)
tdSql
.
query
(
"select apercentile(a+2,10)+1 as c2 from (select ts ,abs(c1) a ,c2 from stb1)"
)
tdSql
.
checkData
(
0
,
0
,
7.560701700
)
# mixup with other functions
tdSql
.
query
(
"select max(c1),count(c1),last(c2,c3),spread(c1), apercentile(c1,10) from stb1"
)
tdSql
.
checkData
(
0
,
0
,
28
)
tdSql
.
checkData
(
0
,
1
,
184
)
tdSql
.
checkData
(
0
,
2
,
-
99999
)
tdSql
.
checkData
(
0
,
3
,
-
999
)
tdSql
.
checkData
(
0
,
4
,
28.000000000
)
tdSql
.
checkData
(
0
,
5
,
4.560701700
)
def
run
(
self
):
self
.
prepare_datas_of_distribute
()
self
.
check_distribute_datas
()
self
.
distribute_agg_query
()
def
stop
(
self
):
tdSql
.
close
()
tdLog
.
success
(
"%s successfully executed"
%
__file__
)
tdCases
.
addWindows
(
__file__
,
TDTestCase
())
tdCases
.
addLinux
(
__file__
,
TDTestCase
())
tests/system-test/2-query/distribute_agg_count.py
0 → 100644
浏览文件 @
2e590c30
from
util.log
import
*
from
util.cases
import
*
from
util.sql
import
*
import
numpy
as
np
import
random
class
TDTestCase
:
updatecfgDict
=
{
'debugFlag'
:
143
,
"cDebugFlag"
:
143
,
"uDebugFlag"
:
143
,
"rpcDebugFlag"
:
143
,
"tmrDebugFlag"
:
143
,
"jniDebugFlag"
:
143
,
"simDebugFlag"
:
143
,
"dDebugFlag"
:
143
,
"dDebugFlag"
:
143
,
"vDebugFlag"
:
143
,
"mDebugFlag"
:
143
,
"qDebugFlag"
:
143
,
"wDebugFlag"
:
143
,
"sDebugFlag"
:
143
,
"tsdbDebugFlag"
:
143
,
"tqDebugFlag"
:
143
,
"fsDebugFlag"
:
143
,
"fnDebugFlag"
:
143
,
"maxTablesPerVnode"
:
2
,
"minTablesPerVnode"
:
2
,
"tableIncStepPerVnode"
:
2
}
def
init
(
self
,
conn
,
logSql
):
tdLog
.
debug
(
"start to execute %s"
%
__file__
)
tdSql
.
init
(
conn
.
cursor
())
self
.
vnode_disbutes
=
None
self
.
ts
=
1537146000000
def
check_count_functions
(
self
,
tbname
,
col_name
):
max_sql
=
f
"select count(
{
col_name
}
) from
{
tbname
}
;"
same_sql
=
f
"select sum(c) from (select
{
col_name
}
,1 as c from
{
tbname
}
where
{
col_name
}
is not null) "
tdSql
.
query
(
max_sql
)
max_result
=
tdSql
.
queryResult
tdSql
.
query
(
same_sql
)
same_result
=
tdSql
.
queryResult
if
max_result
!=
same_result
:
tdLog
.
exit
(
" count function work not as expected, sql : %s "
%
max_sql
)
else
:
tdLog
.
info
(
" count function work as expected, sql : %s "
%
max_sql
)
def
prepare_datas_of_distribute
(
self
):
# prepate datas for 20 tables distributed at different vgroups
tdSql
.
execute
(
"create database if not exists testdb keep 3650 duration 1000 vgroups 5"
)
tdSql
.
execute
(
" use testdb "
)
tdSql
.
execute
(
'''create table stb1
(ts timestamp, c1 int, c2 bigint, c3 smallint, c4 tinyint, c5 float, c6 double, c7 bool, c8 binary(16),c9 nchar(32), c10 timestamp)
tags (t0 timestamp, t1 int, t2 bigint, t3 smallint, t4 tinyint, t5 float, t6 double, t7 bool, t8 binary(16),t9 nchar(32))
'''
)
tdSql
.
execute
(
'''
create table t1
(ts timestamp, c1 int, c2 bigint, c3 smallint, c4 tinyint, c5 float, c6 double, c7 bool, c8 binary(16),c9 nchar(32), c10 timestamp)
'''
)
for
i
in
range
(
20
):
tdSql
.
execute
(
f
'create table ct
{
i
+
1
}
using stb1 tags ( now(),
{
1
*
i
}
,
{
11111
*
i
}
,
{
111
*
i
}
,
{
11
*
i
}
,
{
1.11
*
i
}
,
{
11.11
*
i
}
,
{
i
%
2
}
, "binary
{
i
}
", "nchar
{
i
}
" )'
)
for
i
in
range
(
9
):
tdSql
.
execute
(
f
"insert into ct1 values ( now()-
{
i
*
10
}
s,
{
1
*
i
}
,
{
11111
*
i
}
,
{
111
*
i
}
,
{
11
*
i
}
,
{
1.11
*
i
}
,
{
11.11
*
i
}
,
{
i
%
2
}
, 'binary
{
i
}
', 'nchar
{
i
}
', now()+
{
1
*
i
}
a )"
)
tdSql
.
execute
(
f
"insert into ct4 values ( now()-
{
i
*
90
}
d,
{
1
*
i
}
,
{
11111
*
i
}
,
{
111
*
i
}
,
{
11
*
i
}
,
{
1.11
*
i
}
,
{
11.11
*
i
}
,
{
i
%
2
}
, 'binary
{
i
}
', 'nchar
{
i
}
', now()+
{
1
*
i
}
a )"
)
for
i
in
range
(
1
,
21
):
if
i
==
1
or
i
==
4
:
continue
else
:
tbname
=
"ct"
+
f
'
{
i
}
'
for
j
in
range
(
9
):
tdSql
.
execute
(
f
"insert into
{
tbname
}
values ( now()-
{
(
i
+
j
)
*
10
}
s,
{
1
*
(
j
+
i
)
}
,
{
11111
*
(
j
+
i
)
}
,
{
111
*
(
j
+
i
)
}
,
{
11
*
(
j
)
}
,
{
1.11
*
(
j
+
i
)
}
,
{
11.11
*
(
j
+
i
)
}
,
{
(
j
+
i
)
%
2
}
, 'binary
{
j
}
', 'nchar
{
j
}
', now()+
{
1
*
j
}
a )"
)
tdSql
.
execute
(
"insert into ct1 values (now()-45s, 0, 0, 0, 0, 0, 0, 0, 'binary0', 'nchar0', now()+8a )"
)
tdSql
.
execute
(
"insert into ct1 values (now()+10s, 9, -99999, -999, -99, -9.99, -99.99, 1, 'binary9', 'nchar9', now()+9a )"
)
tdSql
.
execute
(
"insert into ct1 values (now()+15s, 9, -99999, -999, -99, -9.99, NULL, 1, 'binary9', 'nchar9', now()+9a )"
)
tdSql
.
execute
(
"insert into ct1 values (now()+20s, 9, -99999, -999, NULL, -9.99, -99.99, 1, 'binary9', 'nchar9', now()+9a )"
)
tdSql
.
execute
(
"insert into ct4 values (now()-810d, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) "
)
tdSql
.
execute
(
"insert into ct4 values (now()-400d, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) "
)
tdSql
.
execute
(
"insert into ct4 values (now()+90d, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) "
)
tdSql
.
execute
(
f
'''insert into t1 values
( '2020-04-21 01:01:01.000', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL )
( '2020-10-21 01:01:01.000', 1, 11111, 111, 11, 1.11, 11.11, 1, "binary1", "nchar1", now()+1a )
( '2020-12-31 01:01:01.000', 2, 22222, 222, 22, 2.22, 22.22, 0, "binary2", "nchar2", now()+2a )
( '2021-01-01 01:01:06.000', 3, 33333, 333, 33, 3.33, 33.33, 0, "binary3", "nchar3", now()+3a )
( '2021-05-07 01:01:10.000', 4, 44444, 444, 44, 4.44, 44.44, 1, "binary4", "nchar4", now()+4a )
( '2021-07-21 01:01:01.000', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL )
( '2021-09-30 01:01:16.000', 5, 55555, 555, 55, 5.55, 55.55, 0, "binary5", "nchar5", now()+5a )
( '2022-02-01 01:01:20.000', 6, 66666, 666, 66, 6.66, 66.66, 1, "binary6", "nchar6", now()+6a )
( '2022-10-28 01:01:26.000', 7, 00000, 000, 00, 0.00, 00.00, 1, "binary7", "nchar7", "1970-01-01 08:00:00.000" )
( '2022-12-01 01:01:30.000', 8, -88888, -888, -88, -8.88, -88.88, 0, "binary8", "nchar8", "1969-01-01 01:00:00.000" )
( '2022-12-31 01:01:36.000', 9, -99999999999999999, -999, -99, -9.99, -999999999999999999999.99, 1, "binary9", "nchar9", "1900-01-01 00:00:00.000" )
( '2023-02-21 01:01:01.000', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL )
'''
)
tdLog
.
info
(
" prepare data for distributed_aggregate done! "
)
def
check_distribute_datas
(
self
):
# get vgroup_ids of all
tdSql
.
query
(
"show vgroups "
)
vgroups
=
tdSql
.
queryResult
vnode_tables
=
{}
for
vgroup_id
in
vgroups
:
vnode_tables
[
vgroup_id
[
0
]]
=
[]
# check sub_table of per vnode ,make sure sub_table has been distributed
tdSql
.
query
(
"show tables like 'ct%'"
)
table_names
=
tdSql
.
queryResult
tablenames
=
[]
for
table_name
in
table_names
:
vnode_tables
[
table_name
[
6
]].
append
(
table_name
[
0
])
self
.
vnode_disbutes
=
vnode_tables
count
=
0
for
k
,
v
in
vnode_tables
.
items
():
if
len
(
v
)
>=
2
:
count
+=
1
if
count
<
2
:
tdLog
.
exit
(
" the datas of all not satisfy sub_table has been distributed "
)
def
check_count_distribute_diff_vnode
(
self
,
col_name
):
vgroup_ids
=
[]
for
k
,
v
in
self
.
vnode_disbutes
.
items
():
if
len
(
v
)
>=
2
:
vgroup_ids
.
append
(
k
)
distribute_tbnames
=
[]
for
vgroup_id
in
vgroup_ids
:
vnode_tables
=
self
.
vnode_disbutes
[
vgroup_id
]
distribute_tbnames
.
append
(
random
.
sample
(
vnode_tables
,
1
)[
0
])
tbname_ins
=
""
for
tbname
in
distribute_tbnames
:
tbname_ins
+=
"'%s' ,"
%
tbname
tbname_filters
=
tbname_ins
[:
-
1
]
max_sql
=
f
"select count(
{
col_name
}
) from stb1 where tbname in (
{
tbname_filters
}
);"
same_sql
=
f
"select sum(c) from (select
{
col_name
}
,1 as c from stb1 where tbname in (
{
tbname_filters
}
) and
{
col_name
}
is not null) "
tdSql
.
query
(
max_sql
)
max_result
=
tdSql
.
queryResult
tdSql
.
query
(
same_sql
)
same_result
=
tdSql
.
queryResult
if
max_result
!=
same_result
:
tdLog
.
exit
(
" count function work not as expected, sql : %s "
%
max_sql
)
else
:
tdLog
.
info
(
" count function work as expected, sql : %s "
%
max_sql
)
def
check_count_status
(
self
):
# check max function work status
tdSql
.
query
(
"show tables like 'ct%'"
)
table_names
=
tdSql
.
queryResult
tablenames
=
[]
for
table_name
in
table_names
:
tablenames
.
append
(
table_name
[
0
])
tdSql
.
query
(
"desc stb1"
)
col_names
=
tdSql
.
queryResult
colnames
=
[]
for
col_name
in
col_names
:
if
col_name
[
1
]
in
[
"INT"
,
"BIGINT"
,
"SMALLINT"
,
"TINYINT"
,
"FLOAT"
,
"DOUBLE"
]:
colnames
.
append
(
col_name
[
0
])
for
tablename
in
tablenames
:
for
colname
in
colnames
:
self
.
check_count_functions
(
tablename
,
colname
)
# check max function for different vnode
for
colname
in
colnames
:
if
colname
.
startswith
(
"c"
):
self
.
check_count_distribute_diff_vnode
(
colname
)
else
:
# self.check_count_distribute_diff_vnode(colname) # bug for tag
pass
def
distribute_agg_query
(
self
):
# basic filter
tdSql
.
query
(
"select count(c1) from stb1 "
)
tdSql
.
checkData
(
0
,
0
,
184
)
tdSql
.
query
(
"select count(c1) from stb1 where t1=1"
)
tdSql
.
checkData
(
0
,
0
,
9
)
tdSql
.
query
(
"select count(c1+c2) from stb1 where c1 =1 "
)
tdSql
.
checkData
(
0
,
0
,
2
)
tdSql
.
query
(
"select count(c1) from stb1 where tbname=
\"
ct2
\"
"
)
tdSql
.
checkData
(
0
,
0
,
9
)
tdSql
.
query
(
"select count(c1) from stb1 partition by tbname"
)
tdSql
.
checkRows
(
20
)
tdSql
.
query
(
"select count(c1) from stb1 where t1> 4 partition by tbname"
)
tdSql
.
checkRows
(
15
)
# union all
tdSql
.
query
(
"select count(c1) from stb1 union all select count(c1) from stb1 "
)
tdSql
.
checkRows
(
2
)
tdSql
.
checkData
(
0
,
0
,
184
)
# join
tdSql
.
execute
(
" create database if not exists db "
)
tdSql
.
execute
(
" use db "
)
tdSql
.
execute
(
" create stable st (ts timestamp , c1 int ,c2 float) tags(t1 int) "
)
tdSql
.
execute
(
" create table tb1 using st tags(1) "
)
tdSql
.
execute
(
" create table tb2 using st tags(2) "
)
for
i
in
range
(
10
):
ts
=
i
*
10
+
self
.
ts
tdSql
.
execute
(
f
" insert into tb1 values(
{
ts
}
,
{
i
}
,
{
i
}
.0)"
)
tdSql
.
execute
(
f
" insert into tb2 values(
{
ts
}
,
{
i
}
,
{
i
}
.0)"
)
tdSql
.
query
(
"select count(tb1.c1), count(tb2.c2) from tb1, tb2 where tb1.ts=tb2.ts"
)
tdSql
.
checkRows
(
1
)
tdSql
.
checkData
(
0
,
0
,
10
)
tdSql
.
checkData
(
0
,
1
,
10
)
# group by
tdSql
.
execute
(
" use testdb "
)
tdSql
.
query
(
" select count(*) from stb1 "
)
tdSql
.
checkData
(
0
,
0
,
187
)
tdSql
.
query
(
" select count(*) from stb1 group by t1 "
)
tdSql
.
checkRows
(
20
)
tdSql
.
query
(
" select count(*) from stb1 group by c1 "
)
tdSql
.
checkRows
(
30
)
tdSql
.
query
(
" select count(*) from stb1 group by c2 "
)
tdSql
.
checkRows
(
31
)
# partition by tbname or partition by tag
tdSql
.
query
(
"select max(c1),tbname from stb1 partition by tbname"
)
query_data
=
tdSql
.
queryResult
for
row
in
query_data
:
tbname
=
row
[
1
]
tdSql
.
query
(
" select max(c1) from %s "
%
tbname
)
tdSql
.
checkData
(
0
,
0
,
row
[
0
])
tdSql
.
query
(
"select max(c1),tbname from stb1 partition by t1"
)
query_data
=
tdSql
.
queryResult
for
row
in
query_data
:
tbname
=
row
[
1
]
tdSql
.
query
(
" select max(c1) from %s "
%
tbname
)
tdSql
.
checkData
(
0
,
0
,
row
[
0
])
# nest query for support max
tdSql
.
query
(
"select abs(c2+2)+1 from (select count(c1) c2 from stb1)"
)
tdSql
.
checkData
(
0
,
0
,
187.000000000
)
tdSql
.
query
(
"select count(c1+2) as c2 from (select ts ,c1 ,c2 from stb1)"
)
tdSql
.
checkData
(
0
,
0
,
184
)
tdSql
.
query
(
"select count(a+2) as c2 from (select ts ,abs(c1) a ,c2 from stb1)"
)
tdSql
.
checkData
(
0
,
0
,
184
)
# mixup with other functions
tdSql
.
query
(
"select max(c1),count(c1),last(c2,c3) from stb1"
)
tdSql
.
checkData
(
0
,
0
,
28
)
tdSql
.
checkData
(
0
,
1
,
184
)
tdSql
.
checkData
(
0
,
2
,
-
99999
)
tdSql
.
checkData
(
0
,
3
,
-
999
)
def
run
(
self
):
self
.
prepare_datas_of_distribute
()
self
.
check_distribute_datas
()
self
.
check_count_status
()
self
.
distribute_agg_query
()
def
stop
(
self
):
tdSql
.
close
()
tdLog
.
success
(
"%s successfully executed"
%
__file__
)
tdCases
.
addWindows
(
__file__
,
TDTestCase
())
tdCases
.
addLinux
(
__file__
,
TDTestCase
())
tests/system-test/2-query/distribute_agg_max.py
0 → 100644
浏览文件 @
2e590c30
from
util.log
import
*
from
util.cases
import
*
from
util.sql
import
*
import
numpy
as
np
import
random
class
TDTestCase
:
updatecfgDict
=
{
'debugFlag'
:
143
,
"cDebugFlag"
:
143
,
"uDebugFlag"
:
143
,
"rpcDebugFlag"
:
143
,
"tmrDebugFlag"
:
143
,
"jniDebugFlag"
:
143
,
"simDebugFlag"
:
143
,
"dDebugFlag"
:
143
,
"dDebugFlag"
:
143
,
"vDebugFlag"
:
143
,
"mDebugFlag"
:
143
,
"qDebugFlag"
:
143
,
"wDebugFlag"
:
143
,
"sDebugFlag"
:
143
,
"tsdbDebugFlag"
:
143
,
"tqDebugFlag"
:
143
,
"fsDebugFlag"
:
143
,
"fnDebugFlag"
:
143
,
"maxTablesPerVnode"
:
2
,
"minTablesPerVnode"
:
2
,
"tableIncStepPerVnode"
:
2
}
def
init
(
self
,
conn
,
logSql
):
tdLog
.
debug
(
"start to execute %s"
%
__file__
)
tdSql
.
init
(
conn
.
cursor
())
self
.
vnode_disbutes
=
None
self
.
ts
=
1537146000000
def
check_max_functions
(
self
,
tbname
,
col_name
):
max_sql
=
f
"select max(
{
col_name
}
) from
{
tbname
}
;"
same_sql
=
f
"select
{
col_name
}
from
{
tbname
}
order by
{
col_name
}
desc limit 1"
tdSql
.
query
(
max_sql
)
max_result
=
tdSql
.
queryResult
tdSql
.
query
(
same_sql
)
same_result
=
tdSql
.
queryResult
if
max_result
!=
same_result
:
tdLog
.
exit
(
" max function work not as expected, sql : %s "
%
max_sql
)
else
:
tdLog
.
info
(
" max function work as expected, sql : %s "
%
max_sql
)
def
prepare_datas_of_distribute
(
self
):
# prepate datas for 20 tables distributed at different vgroups
tdSql
.
execute
(
"create database if not exists testdb keep 3650 duration 1000 vgroups 5"
)
tdSql
.
execute
(
" use testdb "
)
tdSql
.
execute
(
'''create table stb1
(ts timestamp, c1 int, c2 bigint, c3 smallint, c4 tinyint, c5 float, c6 double, c7 bool, c8 binary(16),c9 nchar(32), c10 timestamp)
tags (t0 timestamp, t1 int, t2 bigint, t3 smallint, t4 tinyint, t5 float, t6 double, t7 bool, t8 binary(16),t9 nchar(32))
'''
)
tdSql
.
execute
(
'''
create table t1
(ts timestamp, c1 int, c2 bigint, c3 smallint, c4 tinyint, c5 float, c6 double, c7 bool, c8 binary(16),c9 nchar(32), c10 timestamp)
'''
)
for
i
in
range
(
20
):
tdSql
.
execute
(
f
'create table ct
{
i
+
1
}
using stb1 tags ( now(),
{
1
*
i
}
,
{
11111
*
i
}
,
{
111
*
i
}
,
{
11
*
i
}
,
{
1.11
*
i
}
,
{
11.11
*
i
}
,
{
i
%
2
}
, "binary
{
i
}
", "nchar
{
i
}
" )'
)
for
i
in
range
(
9
):
tdSql
.
execute
(
f
"insert into ct1 values ( now()-
{
i
*
10
}
s,
{
1
*
i
}
,
{
11111
*
i
}
,
{
111
*
i
}
,
{
11
*
i
}
,
{
1.11
*
i
}
,
{
11.11
*
i
}
,
{
i
%
2
}
, 'binary
{
i
}
', 'nchar
{
i
}
', now()+
{
1
*
i
}
a )"
)
tdSql
.
execute
(
f
"insert into ct4 values ( now()-
{
i
*
90
}
d,
{
1
*
i
}
,
{
11111
*
i
}
,
{
111
*
i
}
,
{
11
*
i
}
,
{
1.11
*
i
}
,
{
11.11
*
i
}
,
{
i
%
2
}
, 'binary
{
i
}
', 'nchar
{
i
}
', now()+
{
1
*
i
}
a )"
)
for
i
in
range
(
1
,
21
):
if
i
==
1
or
i
==
4
:
continue
else
:
tbname
=
"ct"
+
f
'
{
i
}
'
for
j
in
range
(
9
):
tdSql
.
execute
(
f
"insert into
{
tbname
}
values ( now()-
{
(
i
+
j
)
*
10
}
s,
{
1
*
(
j
+
i
)
}
,
{
11111
*
(
j
+
i
)
}
,
{
111
*
(
j
+
i
)
}
,
{
11
*
(
j
)
}
,
{
1.11
*
(
j
+
i
)
}
,
{
11.11
*
(
j
+
i
)
}
,
{
(
j
+
i
)
%
2
}
, 'binary
{
j
}
', 'nchar
{
j
}
', now()+
{
1
*
j
}
a )"
)
tdSql
.
execute
(
"insert into ct1 values (now()-45s, 0, 0, 0, 0, 0, 0, 0, 'binary0', 'nchar0', now()+8a )"
)
tdSql
.
execute
(
"insert into ct1 values (now()+10s, 9, -99999, -999, -99, -9.99, -99.99, 1, 'binary9', 'nchar9', now()+9a )"
)
tdSql
.
execute
(
"insert into ct1 values (now()+15s, 9, -99999, -999, -99, -9.99, NULL, 1, 'binary9', 'nchar9', now()+9a )"
)
tdSql
.
execute
(
"insert into ct1 values (now()+20s, 9, -99999, -999, NULL, -9.99, -99.99, 1, 'binary9', 'nchar9', now()+9a )"
)
tdSql
.
execute
(
"insert into ct4 values (now()-810d, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) "
)
tdSql
.
execute
(
"insert into ct4 values (now()-400d, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) "
)
tdSql
.
execute
(
"insert into ct4 values (now()+90d, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) "
)
tdSql
.
execute
(
f
'''insert into t1 values
( '2020-04-21 01:01:01.000', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL )
( '2020-10-21 01:01:01.000', 1, 11111, 111, 11, 1.11, 11.11, 1, "binary1", "nchar1", now()+1a )
( '2020-12-31 01:01:01.000', 2, 22222, 222, 22, 2.22, 22.22, 0, "binary2", "nchar2", now()+2a )
( '2021-01-01 01:01:06.000', 3, 33333, 333, 33, 3.33, 33.33, 0, "binary3", "nchar3", now()+3a )
( '2021-05-07 01:01:10.000', 4, 44444, 444, 44, 4.44, 44.44, 1, "binary4", "nchar4", now()+4a )
( '2021-07-21 01:01:01.000', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL )
( '2021-09-30 01:01:16.000', 5, 55555, 555, 55, 5.55, 55.55, 0, "binary5", "nchar5", now()+5a )
( '2022-02-01 01:01:20.000', 6, 66666, 666, 66, 6.66, 66.66, 1, "binary6", "nchar6", now()+6a )
( '2022-10-28 01:01:26.000', 7, 00000, 000, 00, 0.00, 00.00, 1, "binary7", "nchar7", "1970-01-01 08:00:00.000" )
( '2022-12-01 01:01:30.000', 8, -88888, -888, -88, -8.88, -88.88, 0, "binary8", "nchar8", "1969-01-01 01:00:00.000" )
( '2022-12-31 01:01:36.000', 9, -99999999999999999, -999, -99, -9.99, -999999999999999999999.99, 1, "binary9", "nchar9", "1900-01-01 00:00:00.000" )
( '2023-02-21 01:01:01.000', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL )
'''
)
tdLog
.
info
(
" prepare data for distributed_aggregate done! "
)
def
check_distribute_datas
(
self
):
# get vgroup_ids of all
tdSql
.
query
(
"show vgroups "
)
vgroups
=
tdSql
.
queryResult
vnode_tables
=
{}
for
vgroup_id
in
vgroups
:
vnode_tables
[
vgroup_id
[
0
]]
=
[]
# check sub_table of per vnode ,make sure sub_table has been distributed
tdSql
.
query
(
"show tables like 'ct%'"
)
table_names
=
tdSql
.
queryResult
tablenames
=
[]
for
table_name
in
table_names
:
vnode_tables
[
table_name
[
6
]].
append
(
table_name
[
0
])
self
.
vnode_disbutes
=
vnode_tables
count
=
0
for
k
,
v
in
vnode_tables
.
items
():
if
len
(
v
)
>=
2
:
count
+=
1
if
count
<
2
:
tdLog
.
exit
(
" the datas of all not satisfy sub_table has been distributed "
)
def
check_max_distribute_diff_vnode
(
self
,
col_name
):
vgroup_ids
=
[]
for
k
,
v
in
self
.
vnode_disbutes
.
items
():
if
len
(
v
)
>=
2
:
vgroup_ids
.
append
(
k
)
distribute_tbnames
=
[]
for
vgroup_id
in
vgroup_ids
:
vnode_tables
=
self
.
vnode_disbutes
[
vgroup_id
]
distribute_tbnames
.
append
(
random
.
sample
(
vnode_tables
,
1
)[
0
])
tbname_ins
=
""
for
tbname
in
distribute_tbnames
:
tbname_ins
+=
"'%s' ,"
%
tbname
tbname_filters
=
tbname_ins
[:
-
1
]
max_sql
=
f
"select max(
{
col_name
}
) from stb1 where tbname in (
{
tbname_filters
}
);"
same_sql
=
f
"select
{
col_name
}
from stb1 where tbname in (
{
tbname_filters
}
) order by
{
col_name
}
desc limit 1"
tdSql
.
query
(
max_sql
)
max_result
=
tdSql
.
queryResult
tdSql
.
query
(
same_sql
)
same_result
=
tdSql
.
queryResult
if
max_result
!=
same_result
:
tdLog
.
exit
(
" max function work not as expected, sql : %s "
%
max_sql
)
else
:
tdLog
.
info
(
" max function work as expected, sql : %s "
%
max_sql
)
def
check_max_status
(
self
):
# check max function work status
tdSql
.
query
(
"show tables like 'ct%'"
)
table_names
=
tdSql
.
queryResult
tablenames
=
[]
for
table_name
in
table_names
:
tablenames
.
append
(
table_name
[
0
])
tdSql
.
query
(
"desc stb1"
)
col_names
=
tdSql
.
queryResult
colnames
=
[]
for
col_name
in
col_names
:
if
col_name
[
1
]
in
[
"INT"
,
"BIGINT"
,
"SMALLINT"
,
"TINYINT"
,
"FLOAT"
,
"DOUBLE"
]:
colnames
.
append
(
col_name
[
0
])
for
tablename
in
tablenames
:
for
colname
in
colnames
:
self
.
check_max_functions
(
tablename
,
colname
)
# check max function for different vnode
for
colname
in
colnames
:
if
colname
.
startswith
(
"c"
):
self
.
check_max_distribute_diff_vnode
(
colname
)
else
:
# self.check_max_distribute_diff_vnode(colname) # bug for tag
pass
def
distribute_agg_query
(
self
):
# basic filter
tdSql
.
query
(
"select max(c1) from stb1 where c1 is null"
)
tdSql
.
checkRows
(
0
)
tdSql
.
query
(
"select max(c1) from stb1 where t1=1"
)
tdSql
.
checkData
(
0
,
0
,
10
)
tdSql
.
query
(
"select max(c1+c2) from stb1 where c1 =1 "
)
tdSql
.
checkData
(
0
,
0
,
11112.000000000
)
tdSql
.
query
(
"select max(c1) from stb1 where tbname=
\"
ct2
\"
"
)
tdSql
.
checkData
(
0
,
0
,
10
)
tdSql
.
query
(
"select max(c1) from stb1 partition by tbname"
)
tdSql
.
checkRows
(
20
)
tdSql
.
query
(
"select max(c1) from stb1 where t1> 4 partition by tbname"
)
tdSql
.
checkRows
(
15
)
# union all
tdSql
.
query
(
"select max(c1) from stb1 union all select max(c1) from stb1 "
)
tdSql
.
checkRows
(
2
)
tdSql
.
checkData
(
0
,
0
,
28
)
# join
tdSql
.
execute
(
" create database if not exists db "
)
tdSql
.
execute
(
" use db "
)
tdSql
.
execute
(
" create stable st (ts timestamp , c1 int ,c2 float) tags(t1 int) "
)
tdSql
.
execute
(
" create table tb1 using st tags(1) "
)
tdSql
.
execute
(
" create table tb2 using st tags(2) "
)
for
i
in
range
(
10
):
ts
=
i
*
10
+
self
.
ts
tdSql
.
execute
(
f
" insert into tb1 values(
{
ts
}
,
{
i
}
,
{
i
}
.0)"
)
tdSql
.
execute
(
f
" insert into tb2 values(
{
ts
}
,
{
i
}
,
{
i
}
.0)"
)
tdSql
.
query
(
"select max(tb1.c1), tb2.c2 from tb1, tb2 where tb1.ts=tb2.ts"
)
tdSql
.
checkRows
(
1
)
tdSql
.
checkData
(
0
,
0
,
9
)
tdSql
.
checkData
(
0
,
0
,
9.00000
)
# group by
tdSql
.
execute
(
" use testdb "
)
tdSql
.
query
(
" select max(c1),c1 from stb1 group by t1 "
)
tdSql
.
checkRows
(
20
)
tdSql
.
query
(
" select max(c1),c1 from stb1 group by c1 "
)
tdSql
.
checkRows
(
30
)
tdSql
.
query
(
" select max(c1),c2 from stb1 group by c2 "
)
tdSql
.
checkRows
(
31
)
# partition by tbname or partition by tag
tdSql
.
query
(
"select max(c1),tbname from stb1 partition by tbname"
)
query_data
=
tdSql
.
queryResult
for
row
in
query_data
:
tbname
=
row
[
1
]
tdSql
.
query
(
" select max(c1) from %s "
%
tbname
)
tdSql
.
checkData
(
0
,
0
,
row
[
0
])
tdSql
.
query
(
"select max(c1),tbname from stb1 partition by t1"
)
query_data
=
tdSql
.
queryResult
for
row
in
query_data
:
tbname
=
row
[
1
]
tdSql
.
query
(
" select max(c1) from %s "
%
tbname
)
tdSql
.
checkData
(
0
,
0
,
row
[
0
])
# nest query for support max
tdSql
.
query
(
"select abs(c2+2)+1 from (select max(c1) c2 from stb1)"
)
tdSql
.
checkData
(
0
,
0
,
31.000000000
)
tdSql
.
query
(
"select max(c1+2)+1 as c2 from (select ts ,c1 ,c2 from stb1)"
)
tdSql
.
checkData
(
0
,
0
,
31.000000000
)
tdSql
.
query
(
"select max(a+2)+1 as c2 from (select ts ,abs(c1) a ,c2 from stb1)"
)
tdSql
.
checkData
(
0
,
0
,
31.000000000
)
# mixup with other functions
tdSql
.
query
(
"select max(c1),count(c1),last(c2,c3) from stb1"
)
tdSql
.
checkData
(
0
,
0
,
28
)
tdSql
.
checkData
(
0
,
1
,
184
)
tdSql
.
checkData
(
0
,
2
,
-
99999
)
tdSql
.
checkData
(
0
,
3
,
-
999
)
def
run
(
self
):
self
.
prepare_datas_of_distribute
()
self
.
check_distribute_datas
()
self
.
check_max_status
()
self
.
distribute_agg_query
()
def
stop
(
self
):
tdSql
.
close
()
tdLog
.
success
(
"%s successfully executed"
%
__file__
)
tdCases
.
addWindows
(
__file__
,
TDTestCase
())
tdCases
.
addLinux
(
__file__
,
TDTestCase
())
tests/system-test/2-query/distribute_agg_min.py
0 → 100644
浏览文件 @
2e590c30
此差异已折叠。
点击以展开。
tests/system-test/2-query/distribute_agg_spread.py
0 → 100644
浏览文件 @
2e590c30
此差异已折叠。
点击以展开。
tests/system-test/2-query/distribute_agg_sum.py
0 → 100644
浏览文件 @
2e590c30
此差异已折叠。
点击以展开。
tests/system-test/2-query/first.py
浏览文件 @
2e590c30
此差异已折叠。
点击以展开。
tests/system-test/2-query/histogram.py
浏览文件 @
2e590c30
...
@@ -44,8 +44,7 @@ class TDTestCase:
...
@@ -44,8 +44,7 @@ class TDTestCase:
buildPath
=
root
[:
len
(
root
)
-
len
(
"/build/bin"
)]
buildPath
=
root
[:
len
(
root
)
-
len
(
"/build/bin"
)]
break
break
return
buildPath
return
buildPath
def
histogram_check_base
(
self
):
def
run
(
self
):
print
(
"running {}"
.
format
(
__file__
))
print
(
"running {}"
.
format
(
__file__
))
tdSql
.
execute
(
"drop database if exists db"
)
tdSql
.
execute
(
"drop database if exists db"
)
tdSql
.
execute
(
"create database if not exists db"
)
tdSql
.
execute
(
"create database if not exists db"
)
...
@@ -3183,6 +3182,72 @@ class TDTestCase:
...
@@ -3183,6 +3182,72 @@ class TDTestCase:
tdSql
.
execute
(
'drop database db'
)
tdSql
.
execute
(
'drop database db'
)
def
histogram_check_distribute
(
self
):
dbname
=
"db"
stbname
=
"stb"
row_num
=
10
child_table_num
=
20
vgroups
=
2
user_input_json
=
"[1,3,5,7]"
ts
=
1537146000000
binary_str
=
'taosdata'
nchar_str
=
'涛思数据'
column_dict
=
{
'ts'
:
'timestamp'
,
'col1'
:
'tinyint'
,
'col2'
:
'smallint'
,
'col3'
:
'int'
,
'col4'
:
'bigint'
,
'col5'
:
'tinyint unsigned'
,
'col6'
:
'smallint unsigned'
,
'col7'
:
'int unsigned'
,
'col8'
:
'bigint unsigned'
,
'col9'
:
'float'
,
'col10'
:
'double'
,
'col11'
:
'bool'
,
'col12'
:
'binary(20)'
,
'col13'
:
'nchar(20)'
}
tdSql
.
execute
(
f
"create database if not exists
{
dbname
}
vgroups
{
vgroups
}
"
)
tdSql
.
execute
(
f
'use
{
dbname
}
'
)
# build 20 child tables,every table insert 10 rows
tdSql
.
execute
(
f
'''create table
{
stbname
}
(ts timestamp, col1 tinyint, col2 smallint, col3 int, col4 bigint, col5 tinyint unsigned, col6 smallint unsigned,
col7 int unsigned, col8 bigint unsigned, col9 float, col10 double, col11 bool, col12 binary(20), col13 nchar(20)) tags(loc nchar(20))'''
)
for
i
in
range
(
child_table_num
):
tdSql
.
execute
(
f
"create table
{
stbname
}
_
{
i
}
using
{
stbname
}
tags('beijing')"
)
tdSql
.
query
(
'show tables'
)
vgroup_list
=
[]
for
i
in
range
(
len
(
tdSql
.
queryResult
)):
vgroup_list
.
append
(
tdSql
.
queryResult
[
i
][
6
])
vgroup_list_set
=
set
(
vgroup_list
)
for
i
in
vgroup_list_set
:
vgroups_num
=
vgroup_list
.
count
(
i
)
if
vgroups_num
>=
2
:
tdLog
.
info
(
f
'This scene with
{
vgroups_num
}
vgroups is ok!'
)
continue
else
:
tdLog
.
exit
(
f
'This scene does not meet the requirements with
{
vgroups_num
}
vgroup!
\n
'
)
for
i
in
range
(
child_table_num
):
for
j
in
range
(
row_num
):
tdSql
.
execute
(
f
"insert into
{
stbname
}
_
{
i
}
values(%d, %d, %d, %d, %d, %d, %d, %d, %d, %f, %f, %d, '
{
binary_str
}
%d', '
{
nchar_str
}
%d')"
%
(
ts
+
j
+
i
,
j
+
1
,
j
+
1
,
j
+
1
,
j
+
1
,
j
+
1
,
j
+
1
,
j
+
1
,
j
+
1
,
j
+
0.1
,
j
+
0.1
,
j
%
2
,
j
+
1
,
j
+
1
))
# user_input
for
k
,
v
in
column_dict
.
items
():
if
v
.
lower
()
==
'tinyint'
or
v
.
lower
()
==
'smallint'
or
v
.
lower
()
==
'int'
or
v
.
lower
()
==
'bigint'
or
v
.
lower
()
==
'float'
or
v
.
lower
()
==
'double'
\
or
v
.
lower
()
==
'tinyint unsigned'
or
v
.
lower
()
==
'smallint unsigned'
or
v
.
lower
()
==
'int unsigned'
or
v
.
lower
()
==
'bigint unsigned'
:
tdSql
.
query
(
f
'select histogram(
{
k
}
, "user_input", "
{
user_input_json
}
", 0) from
{
stbname
}
'
)
tdSql
.
checkRows
(
len
(
user_input_json
[
1
:
-
1
].
split
(
','
))
-
1
)
elif
'binary'
in
v
.
lower
()
or
'nchar'
in
v
.
lower
()
or
'bool'
==
v
.
lower
():
tdSql
.
error
(
f
'select histogram(
{
k
}
, "user_input", "
{
user_input_json
}
", 0) from
{
stbname
}
'
)
tdSql
.
execute
(
f
'drop database
{
dbname
}
'
)
def
run
(
self
):
self
.
histogram_check_base
()
self
.
histogram_check_distribute
()
def
stop
(
self
):
def
stop
(
self
):
tdSql
.
close
()
tdSql
.
close
()
tdLog
.
success
(
"%s successfully executed"
%
__file__
)
tdLog
.
success
(
"%s successfully executed"
%
__file__
)
...
...
tests/system-test/2-query/hyperloglog.py
浏览文件 @
2e590c30
此差异已折叠。
点击以展开。
tests/system-test/2-query/last.py
浏览文件 @
2e590c30
此差异已折叠。
点击以展开。
tests/system-test/2-query/max.py
浏览文件 @
2e590c30
此差异已折叠。
点击以展开。
tests/system-test/2-query/top.py
浏览文件 @
2e590c30
此差异已折叠。
点击以展开。
tests/system-test/6-cluster/5dnode3mnodeDrop.py
浏览文件 @
2e590c30
...
@@ -269,7 +269,8 @@ class TDTestCase:
...
@@ -269,7 +269,8 @@ class TDTestCase:
tdSql
.
query
(
"show dnodes;"
)
tdSql
.
query
(
"show dnodes;"
)
print
(
tdSql
.
queryResult
)
print
(
tdSql
.
queryResult
)
# drop and follower of mnode
# drop follower of mnode
dropcount
=
0
dropcount
=
0
while
dropcount
<=
10
:
while
dropcount
<=
10
:
for
i
in
range
(
1
,
3
):
for
i
in
range
(
1
,
3
):
...
...
tests/system-test/6-cluster/5dnode3mnodeDropInsert.py
0 → 100644
浏览文件 @
2e590c30
此差异已折叠。
点击以展开。
tests/system-test/6-cluster/5dnode3mnodeSeperate1VnodeStopInsert.py
0 → 100644
浏览文件 @
2e590c30
此差异已折叠。
点击以展开。
tests/system-test/7-tmq/basic5.py
浏览文件 @
2e590c30
此差异已折叠。
点击以展开。
tests/system-test/7-tmq/subscribeDb0.py
浏览文件 @
2e590c30
此差异已折叠。
点击以展开。
tests/system-test/7-tmq/subscribeDb1.py
浏览文件 @
2e590c30
此差异已折叠。
点击以展开。
tests/system-test/7-tmq/subscribeDb2.py
0 → 100644
浏览文件 @
2e590c30
此差异已折叠。
点击以展开。
tests/system-test/7-tmq/subscribeDb3.py
0 → 100644
浏览文件 @
2e590c30
此差异已折叠。
点击以展开。
tests/system-test/fulltest.sh
浏览文件 @
2e590c30
此差异已折叠。
点击以展开。
tests/test/c/sdbDump.c
浏览文件 @
2e590c30
此差异已折叠。
点击以展开。
taosadapter
@
9ce3f5c9
Subproject commit 9ce3f5c98ef95d9c7c596c4ed7302b0ed69a92b2
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录