Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
ed4b2dec
TDengine
项目概览
taosdata
/
TDengine
大约 2 年 前同步成功
通知
1192
Star
22018
Fork
4786
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
ed4b2dec
编写于
6月 28, 2022
作者:
X
Xiaoyu Wang
浏览文件
操作
浏览文件
下载
差异文件
Merge remote-tracking branch 'origin/3.0' into feature/3.0_wxy
上级
aa9d3ac5
b391a834
变更
41
显示空白变更内容
内联
并排
Showing
41 changed file
with
1731 addition
and
2289 deletion
+1731
-2289
include/libs/nodes/plannodes.h
include/libs/nodes/plannodes.h
+1
-0
include/libs/nodes/querynodes.h
include/libs/nodes/querynodes.h
+1
-0
include/libs/planner/planner.h
include/libs/planner/planner.h
+2
-0
include/libs/qcom/query.h
include/libs/qcom/query.h
+3
-3
source/dnode/vnode/src/inc/sma.h
source/dnode/vnode/src/inc/sma.h
+10
-10
source/dnode/vnode/src/inc/vnodeInt.h
source/dnode/vnode/src/inc/vnodeInt.h
+1
-1
source/dnode/vnode/src/sma/smaOpen.c
source/dnode/vnode/src/sma/smaOpen.c
+1
-7
source/dnode/vnode/src/sma/smaRollup.c
source/dnode/vnode/src/sma/smaRollup.c
+293
-280
source/dnode/vnode/src/sma/smaUtil.c
source/dnode/vnode/src/sma/smaUtil.c
+23
-19
source/dnode/vnode/src/vnd/vnodeOpen.c
source/dnode/vnode/src/vnd/vnodeOpen.c
+2
-2
source/libs/function/src/builtins.c
source/libs/function/src/builtins.c
+15
-14
source/libs/nodes/src/nodesCloneFuncs.c
source/libs/nodes/src/nodesCloneFuncs.c
+1
-0
source/libs/nodes/src/nodesUtilFuncs.c
source/libs/nodes/src/nodesUtilFuncs.c
+2
-1
source/libs/parser/src/parTranslater.c
source/libs/parser/src/parTranslater.c
+8
-93
source/libs/parser/test/parSelectTest.cpp
source/libs/parser/test/parSelectTest.cpp
+0
-2
source/libs/planner/src/planLogicCreater.c
source/libs/planner/src/planLogicCreater.c
+41
-4
source/libs/planner/src/planOptimizer.c
source/libs/planner/src/planOptimizer.c
+284
-14
source/libs/planner/src/planSpliter.c
source/libs/planner/src/planSpliter.c
+1
-1
source/libs/planner/src/planner.c
source/libs/planner/src/planner.c
+5
-0
source/libs/planner/test/planBasicTest.cpp
source/libs/planner/test/planBasicTest.cpp
+14
-0
source/libs/planner/test/planOptimizeTest.cpp
source/libs/planner/test/planOptimizeTest.cpp
+5
-3
tests/script/jenkins/basic.txt
tests/script/jenkins/basic.txt
+5
-0
tests/script/tsim/dnode/balance1.sim
tests/script/tsim/dnode/balance1.sim
+101
-141
tests/script/tsim/dnode/balance2.sim
tests/script/tsim/dnode/balance2.sim
+280
-0
tests/script/tsim/dnode/balance3.sim
tests/script/tsim/dnode/balance3.sim
+340
-0
tests/script/tsim/dnode/balancex.sim
tests/script/tsim/dnode/balancex.sim
+111
-94
tests/script/tsim/dnode/offline_reason.sim
tests/script/tsim/dnode/offline_reason.sim
+161
-0
tests/script/unique/dnode/alternativeRole.sim
tests/script/unique/dnode/alternativeRole.sim
+0
-97
tests/script/unique/dnode/balance2.sim
tests/script/unique/dnode/balance2.sim
+0
-306
tests/script/unique/dnode/balancex.sim
tests/script/unique/dnode/balancex.sim
+0
-215
tests/script/unique/dnode/m2.sim
tests/script/unique/dnode/m2.sim
+0
-367
tests/script/unique/dnode/monitor_bug.sim
tests/script/unique/dnode/monitor_bug.sim
+0
-77
tests/script/unique/dnode/offline1.sim
tests/script/unique/dnode/offline1.sim
+0
-77
tests/script/unique/dnode/offline2.sim
tests/script/unique/dnode/offline2.sim
+0
-126
tests/script/unique/dnode/offline3.sim
tests/script/unique/dnode/offline3.sim
+0
-111
tests/script/unique/dnode/remove2.sim
tests/script/unique/dnode/remove2.sim
+0
-204
tests/system-test/0-others/udfTest.py
tests/system-test/0-others/udfTest.py
+6
-6
tests/system-test/0-others/udf_create.py
tests/system-test/0-others/udf_create.py
+6
-6
tests/system-test/0-others/udf_restart_taosd.py
tests/system-test/0-others/udf_restart_taosd.py
+6
-6
tests/system-test/2-query/unique.py
tests/system-test/2-query/unique.py
+1
-1
tools/taos-tools
tools/taos-tools
+1
-1
未找到文件。
include/libs/nodes/plannodes.h
浏览文件 @
ed4b2dec
...
...
@@ -103,6 +103,7 @@ typedef struct SIndefRowsFuncLogicNode {
SLogicNode
node
;
SNodeList
*
pFuncs
;
bool
isTailFunc
;
bool
isUniqueFunc
;
}
SIndefRowsFuncLogicNode
;
typedef
struct
SInterpFuncLogicNode
{
...
...
include/libs/nodes/querynodes.h
浏览文件 @
ed4b2dec
...
...
@@ -50,6 +50,7 @@ typedef struct SExprNode {
char
aliasName
[
TSDB_COL_NAME_LEN
];
char
userAlias
[
TSDB_COL_NAME_LEN
];
SArray
*
pAssociation
;
bool
orderAlias
;
}
SExprNode
;
typedef
enum
EColumnType
{
COLUMN_TYPE_COLUMN
=
1
,
COLUMN_TYPE_TAG
,
COLUMN_TYPE_TBNAME
}
EColumnType
;
...
...
include/libs/planner/planner.h
浏览文件 @
ed4b2dec
...
...
@@ -48,6 +48,8 @@ int32_t qCreateQueryPlan(SPlanContext* pCxt, SQueryPlan** pPlan, SArray* pExecNo
// @pSource one execution location of this group of datasource subplans
int32_t
qSetSubplanExecutionNode
(
SSubplan
*
pSubplan
,
int32_t
groupId
,
SDownstreamSourceNode
*
pSource
);
int32_t
qClearSubplanExecutionNode
(
SSubplan
*
pSubplan
,
int32_t
groupId
);
// Convert to subplan to string for the scheduler to send to the executor
int32_t
qSubPlanToString
(
const
SSubplan
*
pSubplan
,
char
**
pStr
,
int32_t
*
pLen
);
int32_t
qStringToSubplan
(
const
char
*
pStr
,
SSubplan
**
pSubplan
);
...
...
include/libs/qcom/query.h
浏览文件 @
ed4b2dec
...
...
@@ -271,19 +271,19 @@ extern int32_t (*queryProcessMsgRsp[TDMT_MAX])(void* output, char* msg, int32_t
#define qDebug(...) \
do { \
if (qDebugFlag & DEBUG_DEBUG) { \
taosPrintLog("QRY ", DEBUG_DEBUG,
qDebugFlag, __VA_ARGS__);
\
taosPrintLog("QRY ", DEBUG_DEBUG,
tsLogEmbedded ? 255 : qDebugFlag, __VA_ARGS__);
\
} \
} while (0)
#define qTrace(...) \
do { \
if (qDebugFlag & DEBUG_TRACE) { \
taosPrintLog("QRY ", DEBUG_TRACE,
qDebugFlag, __VA_ARGS__);
\
taosPrintLog("QRY ", DEBUG_TRACE,
tsLogEmbedded ? 255 : qDebugFlag, __VA_ARGS__);
\
} \
} while (0)
#define qDebugL(...) \
do { \
if (qDebugFlag & DEBUG_DEBUG) { \
taosPrintLongString("QRY ", DEBUG_DEBUG,
qDebugFlag, __VA_ARGS__);
\
taosPrintLongString("QRY ", DEBUG_DEBUG,
tsLogEmbedded ? 255 : qDebugFlag, __VA_ARGS__);
\
} \
} while (0)
...
...
source/dnode/vnode/src/inc/sma.h
浏览文件 @
ed4b2dec
...
...
@@ -205,16 +205,16 @@ struct STFile {
uint8_t
state
;
};
#define TD_FILE_F(tf) (&((tf)->f))
#define TD_FILE_PFILE(tf) ((tf)->pFile)
#define TD_
FILE_OPENED(tf) (TD_
FILE_PFILE(tf) != NULL)
#define TD_
FILE_FULL_NAME(tf) (TD_
FILE_F(tf)->aname)
#define TD_
FILE_REL_NAME(tf) (TD_
FILE_F(tf)->rname)
#define TD_
FILE_OPENED(tf) (TD_
FILE_PFILE(tf) != NULL)
#define TD_
FILE_CLOSED(tf) (!TD_
FILE_OPENED(tf))
#define TD_
FILE_SET_CLOSED(f) (TD_
FILE_PFILE(f) = NULL)
#define TD_FILE_SET_STATE(tf, s) ((tf)->state = (s))
#define TD_
FILE_DID(tf) (TD_
FILE_F(tf)->did)
#define TD_
T
FILE_F(tf) (&((tf)->f))
#define TD_
T
FILE_PFILE(tf) ((tf)->pFile)
#define TD_
TFILE_OPENED(tf) (TD_T
FILE_PFILE(tf) != NULL)
#define TD_
TFILE_FULL_NAME(tf) (TD_T
FILE_F(tf)->aname)
#define TD_
TFILE_REL_NAME(tf) (TD_T
FILE_F(tf)->rname)
#define TD_
TFILE_OPENED(tf) (TD_T
FILE_PFILE(tf) != NULL)
#define TD_
TFILE_CLOSED(tf) (!TD_T
FILE_OPENED(tf))
#define TD_
TFILE_SET_CLOSED(f) (TD_T
FILE_PFILE(f) = NULL)
#define TD_
T
FILE_SET_STATE(tf, s) ((tf)->state = (s))
#define TD_
TFILE_DID(tf) (TD_T
FILE_F(tf)->did)
int32_t
tdInitTFile
(
STFile
*
pTFile
,
STfs
*
pTfs
,
const
char
*
fname
);
int32_t
tdCreateTFile
(
STFile
*
pTFile
,
STfs
*
pTfs
,
bool
updateHeader
,
int8_t
fType
);
...
...
source/dnode/vnode/src/inc/vnodeInt.h
浏览文件 @
ed4b2dec
...
...
@@ -64,6 +64,7 @@ typedef struct STsdbSnapshotReader STsdbSnapshotReader;
#define VNODE_TQ_DIR "tq"
#define VNODE_WAL_DIR "wal"
#define VNODE_TSMA_DIR "tsma"
#define VNODE_RSMA_DIR "rsma"
#define VNODE_RSMA0_DIR "tsdb"
#define VNODE_RSMA1_DIR "rsma1"
#define VNODE_RSMA2_DIR "rsma2"
...
...
@@ -161,7 +162,6 @@ SSubmitReq* tdBlockToSubmit(const SArray* pBlocks, const STSchema* pSchema, bool
// sma
int32_t
smaOpen
(
SVnode
*
pVnode
);
int32_t
smaClose
(
SSma
*
pSma
);
int32_t
smaCloseEnv
(
SSma
*
pSma
);
int32_t
smaCloseEx
(
SSma
*
pSma
);
...
...
source/dnode/vnode/src/sma/smaOpen.c
浏览文件 @
ed4b2dec
...
...
@@ -123,7 +123,7 @@ int32_t smaOpen(SVnode *pVnode) {
}
// restore the rsma
#if
0
#if
1
if
(
rsmaRestore
(
pSma
)
<
0
)
{
goto
_err
;
}
...
...
@@ -154,12 +154,6 @@ int32_t smaCloseEx(SSma *pSma) {
return
0
;
}
int32_t
smaClose
(
SSma
*
pSma
)
{
smaCloseEnv
(
pSma
);
smaCloseEx
(
pSma
);
return
0
;
}
/**
* @brief rsma env restore
*
...
...
source/dnode/vnode/src/sma/smaRollup.c
浏览文件 @
ed4b2dec
...
...
@@ -17,11 +17,12 @@
#define RSMA_QTASKINFO_PERSIST_MS 7200000
#define RSMA_QTASKINFO_BUFSIZE 32768
#define RSMA_QTASKINFO_HEAD_LEN (sizeof(int32_t) + sizeof(int8_t) + sizeof(int64_t)) // len + type + suid
typedef
enum
{
TD_QTASK_TMP_FILE
=
0
,
TD_QTASK_CUR_FILE
}
TD_QTASK_FILE_T
;
static
const
char
*
tdQTaskInfoFname
[]
=
{
"qtaskinfo.t"
,
"qtaskinfo"
};
typedef
struct
SRSmaQTaskInfoItem
SRSmaQTaskInfoItem
;
typedef
struct
SRSmaQTask
FIter
SRSmaQTaskF
Iter
;
typedef
struct
SRSmaQTask
InfoIter
SRSmaQTaskInfo
Iter
;
static
int32_t
tdUidStorePut
(
STbUidStore
*
pStore
,
tb_uid_t
suid
,
tb_uid_t
*
uid
);
static
int32_t
tdUpdateTbUidListImpl
(
SSma
*
pSma
,
tb_uid_t
*
suid
,
SArray
*
tbUids
);
...
...
@@ -32,11 +33,11 @@ static int32_t tdExecuteRSmaImpl(SSma *pSma, const void *pMsg, int32_t inputType
static
void
tdRSmaFetchTrigger
(
void
*
param
,
void
*
tmrId
);
static
void
tdRSmaPersistTrigger
(
void
*
param
,
void
*
tmrId
);
static
void
*
tdRSmaPersistExec
(
void
*
param
);
static
void
tdRSmaQTaskGetFName
(
int32_t
vid
,
int8_t
ftype
,
char
*
outputName
);
static
void
tdRSmaQTask
Info
GetFName
(
int32_t
vid
,
int8_t
ftype
,
char
*
outputName
);
static
int32_t
tdRSmaQTaskInfoIterInit
(
SRSmaQTask
F
Iter
*
pIter
,
STFile
*
pTFile
);
static
int32_t
tdRSmaQTaskInfoIterNextBlock
(
SRSmaQTask
F
Iter
*
pIter
,
bool
*
isFinish
);
static
int32_t
tdRSmaQTaskInfo
IterNext
(
SRSmaQTaskFIter
*
pIter
,
SRSmaQTaskInfoItem
*
pItem
,
bool
*
isEnd
);
static
int32_t
tdRSmaQTaskInfoIterInit
(
SRSmaQTask
Info
Iter
*
pIter
,
STFile
*
pTFile
);
static
int32_t
tdRSmaQTaskInfoIterNextBlock
(
SRSmaQTask
Info
Iter
*
pIter
,
bool
*
isFinish
);
static
int32_t
tdRSmaQTaskInfo
Restore
(
SSma
*
pSma
,
SRSmaQTaskInfoIter
*
pIter
);
static
int32_t
tdRSmaQTaskInfoItemRestore
(
SSma
*
pSma
,
const
SRSmaQTaskInfoItem
*
infoItem
);
struct
SRSmaInfoItem
{
...
...
@@ -63,22 +64,23 @@ struct SRSmaQTaskInfoItem {
void
*
qTaskInfo
;
};
struct
SRSmaQTask
F
Iter
{
struct
SRSmaQTask
Info
Iter
{
STFile
*
pTFile
;
int64_t
offset
;
int64_t
fsize
;
int32_t
nBytes
;
int32_t
nAlloc
;
char
*
b
uf
;
char
*
pB
uf
;
// ------------
char
*
qBuf
;
// for iterator
int32_t
nBufPos
;
};
static
FORCE_INLINE
int32_t
tdRSmaQTaskInfoContLen
(
int32_t
lenWithHead
)
{
return
lenWithHead
-
sizeof
(
int32_t
)
-
sizeof
(
int8_t
)
-
sizeof
(
int64_t
)
;
return
lenWithHead
-
RSMA_QTASKINFO_HEAD_LEN
;
}
static
FORCE_INLINE
void
tdRSmaQTaskInfoIterDestroy
(
SRSmaQTask
FIter
*
pIter
)
{
taosMemoryFreeClear
(
pIter
->
b
uf
);
}
static
FORCE_INLINE
void
tdRSmaQTaskInfoIterDestroy
(
SRSmaQTask
InfoIter
*
pIter
)
{
taosMemoryFreeClear
(
pIter
->
pB
uf
);
}
static
FORCE_INLINE
void
tdFreeTaskHandle
(
qTaskInfo_t
*
taskHandle
,
int32_t
vgId
,
int32_t
level
)
{
// Note: free/kill may in RC
...
...
@@ -294,7 +296,7 @@ int32_t tdProcessRSmaCreateImpl(SSma *pSma, SRSmaParam *param, int64_t suid, con
pRSmaInfo
=
taosHashGet
(
RSMA_INFO_HASH
(
pStat
),
&
suid
,
sizeof
(
tb_uid_t
));
if
(
pRSmaInfo
)
{
ASSERT
(
0
);
// TODO: free original pRSmaInfo i
s
exists abnormally
ASSERT
(
0
);
// TODO: free original pRSmaInfo i
f
exists abnormally
smaDebug
(
"vgId:%d, rsma info already exists for table %s, %"
PRIi64
,
SMA_VID
(
pSma
),
tbName
,
suid
);
return
TSDB_CODE_SUCCESS
;
}
...
...
@@ -338,10 +340,10 @@ int32_t tdProcessRSmaCreateImpl(SSma *pSma, SRSmaParam *param, int64_t suid, con
if
(
taosHashPut
(
RSMA_INFO_HASH
(
pStat
),
&
suid
,
sizeof
(
tb_uid_t
),
&
pRSmaInfo
,
sizeof
(
pRSmaInfo
))
<
0
)
{
goto
_err
;
}
else
{
smaDebug
(
"vgId:%d, register rsma info succeed for suid:%"
PRIi64
,
SMA_VID
(
pSma
),
suid
);
}
smaDebug
(
"vgId:%d, register rsma info succeed for suid:%"
PRIi64
,
SMA_VID
(
pSma
),
suid
);
// start the persist timer
if
(
TASK_TRIGGER_STAT_INIT
==
atomic_val_compare_exchange_8
(
RSMA_TRIGGER_STAT
(
pStat
),
TASK_TRIGGER_STAT_INIT
,
TASK_TRIGGER_STAT_ACTIVE
))
{
...
...
@@ -356,10 +358,9 @@ _err:
}
/**
* @brief Check and init qTaskInfo_t, only applicable to stable with SRSmaParam
.
* @brief Check and init qTaskInfo_t, only applicable to stable with SRSmaParam
currently
*
* @param pTsdb
* @param pMeta
* @param pVnode
* @param pReq
* @return int32_t
*/
...
...
@@ -695,331 +696,127 @@ int32_t tdProcessRSmaSubmit(SSma *pSma, void *pMsg, int32_t inputType) {
return
TSDB_CODE_SUCCESS
;
}
static
void
tdRSmaQTaskGetFName
(
int32_t
vid
,
int8_t
ftype
,
char
*
outputName
)
{
tdGetVndFileName
(
vid
,
"rsma"
,
tdQTaskInfoFname
[
ftype
],
outputName
);
}
static
void
*
tdRSmaPersistExec
(
void
*
param
)
{
setThreadName
(
"rsma-task-persist"
);
SRSmaStat
*
pRSmaStat
=
param
;
SSma
*
pSma
=
pRSmaStat
->
pSma
;
STfs
*
pTfs
=
pSma
->
pVnode
->
pTfs
;
int64_t
toffset
=
0
;
bool
isFileCreated
=
false
;
if
(
TASK_TRIGGER_STAT_CANCELLED
==
atomic_load_8
(
RSMA_TRIGGER_STAT
(
pRSmaStat
)))
{
goto
_end
;
}
void
*
infoHash
=
taosHashIterate
(
RSMA_INFO_HASH
(
pRSmaStat
),
NULL
);
if
(
!
infoHash
)
{
goto
_end
;
}
STFile
tFile
=
{
0
};
int32_t
vid
=
SMA_VID
(
pSma
);
while
(
infoHash
)
{
SRSmaInfo
*
pRSmaInfo
=
*
(
SRSmaInfo
**
)
infoHash
;
#if 0
smaDebug("table %" PRIi64 " sleep 15s start ...", pRSmaInfo->items[0].pRsmaInfo->suid);
for (int32_t i = 15; i > 0; --i) {
taosSsleep(1);
smaDebug("table %" PRIi64 " countdown %d", pRSmaInfo->items[0].pRsmaInfo->suid, i);
}
smaDebug("table %" PRIi64 " sleep 15s end ...", pRSmaInfo->items[0].pRsmaInfo->suid);
#endif
for
(
int32_t
i
=
0
;
i
<
TSDB_RETENTION_L2
;
++
i
)
{
qTaskInfo_t
taskInfo
=
pRSmaInfo
->
items
[
i
].
taskInfo
;
if
(
!
taskInfo
)
{
smaDebug
(
"vgId:%d, table %"
PRIi64
" level %d qTaskInfo is NULL"
,
vid
,
pRSmaInfo
->
suid
,
i
+
1
);
continue
;
}
char
*
pOutput
=
NULL
;
int32_t
len
=
0
;
int8_t
type
=
(
int8_t
)(
i
+
1
);
if
(
qSerializeTaskStatus
(
taskInfo
,
&
pOutput
,
&
len
)
<
0
)
{
smaError
(
"vgId:%d, table %"
PRIi64
" level %d serialize rsma task failed since %s"
,
vid
,
pRSmaInfo
->
suid
,
i
+
1
,
terrstr
(
terrno
));
goto
_err
;
}
else
{
if
(
!
pOutput
)
{
smaDebug
(
"vgId:%d, table %"
PRIi64
" level %d serialize rsma task success but no output(len %d) and no need to persist"
,
vid
,
pRSmaInfo
->
suid
,
i
+
1
,
len
);
continue
;
}
else
if
(
len
<=
0
)
{
smaDebug
(
"vgId:%d, table %"
PRIi64
" level %d serialize rsma task success with len %d and no need to persist"
,
vid
,
pRSmaInfo
->
suid
,
i
+
1
,
len
);
taosMemoryFree
(
pOutput
);
}
smaDebug
(
"vgId:%d, table %"
PRIi64
" level %d serialize rsma task success with len %d and need persist"
,
vid
,
pRSmaInfo
->
suid
,
i
+
1
,
len
);
#if 1
if
(
qDeserializeTaskStatus
(
taskInfo
,
pOutput
,
len
)
<
0
)
{
smaError
(
"vgId:%d, table %"
PRIi64
"level %d deserialize rsma task failed since %s"
,
vid
,
pRSmaInfo
->
suid
,
i
+
1
,
terrstr
(
terrno
));
}
else
{
smaDebug
(
"vgId:%d, table %"
PRIi64
" level %d deserialize rsma task success"
,
vid
,
pRSmaInfo
->
suid
,
i
+
1
);
}
#endif
}
if
(
!
isFileCreated
)
{
char
qTaskInfoFName
[
TSDB_FILENAME_LEN
];
tdRSmaQTaskGetFName
(
vid
,
TD_QTASK_TMP_FILE
,
qTaskInfoFName
);
tdInitTFile
(
&
tFile
,
pTfs
,
qTaskInfoFName
);
tdCreateTFile
(
&
tFile
,
pTfs
,
true
,
-
1
);
isFileCreated
=
true
;
}
len
+=
(
sizeof
(
len
)
+
sizeof
(
type
)
+
sizeof
(
pRSmaInfo
->
suid
));
tdAppendTFile
(
&
tFile
,
&
len
,
sizeof
(
len
),
&
toffset
);
tdAppendTFile
(
&
tFile
,
&
type
,
sizeof
(
type
),
&
toffset
);
tdAppendTFile
(
&
tFile
,
&
pRSmaInfo
->
suid
,
sizeof
(
pRSmaInfo
->
suid
),
&
toffset
);
tdAppendTFile
(
&
tFile
,
pOutput
,
len
,
&
toffset
);
taosMemoryFree
(
pOutput
);
}
infoHash
=
taosHashIterate
(
RSMA_INFO_HASH
(
pRSmaStat
),
infoHash
);
}
_normal:
if
(
isFileCreated
)
{
if
(
tdUpdateTFileHeader
(
&
tFile
)
<
0
)
{
smaError
(
"vgId:%d, failed to update tfile %s header since %s"
,
vid
,
TD_FILE_FULL_NAME
(
&
tFile
),
tstrerror
(
terrno
));
tdCloseTFile
(
&
tFile
);
tdRemoveTFile
(
&
tFile
);
goto
_err
;
}
else
{
smaDebug
(
"vgId:%d, succeed to update tfile %s header"
,
vid
,
TD_FILE_FULL_NAME
(
&
tFile
));
}
tdCloseTFile
(
&
tFile
);
char
newFName
[
TSDB_FILENAME_LEN
];
strncpy
(
newFName
,
TD_FILE_FULL_NAME
(
&
tFile
),
TSDB_FILENAME_LEN
);
char
*
pos
=
strstr
(
newFName
,
tdQTaskInfoFname
[
TD_QTASK_TMP_FILE
]);
strncpy
(
pos
,
tdQTaskInfoFname
[
TD_QTASK_CUR_FILE
],
TSDB_FILENAME_LEN
-
POINTER_DISTANCE
(
pos
,
newFName
));
if
(
taosRenameFile
(
TD_FILE_FULL_NAME
(
&
tFile
),
newFName
)
!=
0
)
{
smaError
(
"vgId:%d, failed to rename %s to %s"
,
vid
,
TD_FILE_FULL_NAME
(
&
tFile
),
newFName
);
goto
_err
;
}
else
{
smaDebug
(
"vgId:%d, succeed to rename %s to %s"
,
vid
,
TD_FILE_FULL_NAME
(
&
tFile
),
newFName
);
}
}
goto
_end
;
_err:
if
(
isFileCreated
)
{
tdRemoveTFile
(
&
tFile
);
}
_end:
if
(
TASK_TRIGGER_STAT_INACTIVE
==
atomic_val_compare_exchange_8
(
RSMA_TRIGGER_STAT
(
pRSmaStat
),
TASK_TRIGGER_STAT_INACTIVE
,
TASK_TRIGGER_STAT_ACTIVE
))
{
smaDebug
(
"vgId:%d, persist task is active again"
,
vid
);
}
else
if
(
TASK_TRIGGER_STAT_CANCELLED
==
atomic_val_compare_exchange_8
(
RSMA_TRIGGER_STAT
(
pRSmaStat
),
TASK_TRIGGER_STAT_CANCELLED
,
TASK_TRIGGER_STAT_FINISHED
))
{
smaDebug
(
"vgId:%d, persist task is cancelled"
,
vid
);
}
else
{
smaWarn
(
"vgId:%d, persist task in abnormal stat %"
PRIi8
,
vid
,
atomic_load_8
(
RSMA_TRIGGER_STAT
(
pRSmaStat
)));
ASSERT
(
0
);
}
atomic_store_8
(
RSMA_RUNNING_STAT
(
pRSmaStat
),
0
);
taosThreadExit
(
NULL
);
return
NULL
;
}
static
void
tdRSmaPersistTask
(
SRSmaStat
*
pRSmaStat
)
{
TdThreadAttr
thAttr
;
taosThreadAttrInit
(
&
thAttr
);
taosThreadAttrSetDetachState
(
&
thAttr
,
PTHREAD_CREATE_DETACHED
);
TdThread
tid
;
if
(
taosThreadCreate
(
&
tid
,
&
thAttr
,
tdRSmaPersistExec
,
pRSmaStat
)
!=
0
)
{
if
(
TASK_TRIGGER_STAT_INACTIVE
==
atomic_val_compare_exchange_8
(
RSMA_TRIGGER_STAT
(
pRSmaStat
),
TASK_TRIGGER_STAT_INACTIVE
,
TASK_TRIGGER_STAT_ACTIVE
))
{
smaDebug
(
"persist task is active again"
);
}
else
if
(
TASK_TRIGGER_STAT_CANCELLED
==
atomic_val_compare_exchange_8
(
RSMA_TRIGGER_STAT
(
pRSmaStat
),
TASK_TRIGGER_STAT_CANCELLED
,
TASK_TRIGGER_STAT_FINISHED
))
{
smaDebug
(
" persist task is cancelled and set finished"
);
}
else
{
smaWarn
(
"persist task in abnormal stat %"
PRIi8
,
atomic_load_8
(
RSMA_TRIGGER_STAT
(
pRSmaStat
)));
ASSERT
(
0
);
}
atomic_store_8
(
RSMA_RUNNING_STAT
(
pRSmaStat
),
0
);
}
taosThreadAttrDestroy
(
&
thAttr
);
}
/**
* @brief trigger to persist rsma qTaskInfo
*
* @param param
* @param tmrId
*/
static
void
tdRSmaPersistTrigger
(
void
*
param
,
void
*
tmrId
)
{
SRSmaStat
*
pRSmaStat
=
param
;
int8_t
tmrStat
=
atomic_val_compare_exchange_8
(
RSMA_TRIGGER_STAT
(
pRSmaStat
),
TASK_TRIGGER_STAT_ACTIVE
,
TASK_TRIGGER_STAT_INACTIVE
);
switch
(
tmrStat
)
{
case
TASK_TRIGGER_STAT_ACTIVE
:
{
atomic_store_8
(
RSMA_RUNNING_STAT
(
pRSmaStat
),
1
);
if
(
TASK_TRIGGER_STAT_CANCELLED
!=
atomic_val_compare_exchange_8
(
RSMA_TRIGGER_STAT
(
pRSmaStat
),
TASK_TRIGGER_STAT_CANCELLED
,
TASK_TRIGGER_STAT_FINISHED
))
{
smaDebug
(
"rsma persistence start since active"
);
// start persist task
tdRSmaPersistTask
(
pRSmaStat
);
taosTmrReset
(
tdRSmaPersistTrigger
,
RSMA_QTASKINFO_PERSIST_MS
,
pRSmaStat
,
pRSmaStat
->
tmrHandle
,
&
pRSmaStat
->
tmrId
);
}
else
{
atomic_store_8
(
RSMA_RUNNING_STAT
(
pRSmaStat
),
0
);
}
}
break
;
case
TASK_TRIGGER_STAT_CANCELLED
:
{
atomic_store_8
(
RSMA_TRIGGER_STAT
(
pRSmaStat
),
TASK_TRIGGER_STAT_FINISHED
);
smaDebug
(
"rsma persistence not start since cancelled and finished"
);
}
break
;
case
TASK_TRIGGER_STAT_INACTIVE
:
{
smaDebug
(
"rsma persistence not start since inactive"
);
}
break
;
case
TASK_TRIGGER_STAT_INIT
:
{
smaDebug
(
"rsma persistence not start since init"
);
}
break
;
default:
{
smaWarn
(
"rsma persistence not start since unknown stat %"
PRIi8
,
tmrStat
);
ASSERT
(
0
);
}
break
;
}
}
int32_t
tdProcessRSmaRestoreImpl
(
SSma
*
pSma
)
{
SVnode
*
pVnode
=
pSma
->
pVnode
;
// step 1: iterate all stables to restore the rsma env
SArray
*
suidList
=
taosArrayInit
(
1
,
sizeof
(
tb_uid_t
));
if
(
tsdbGetStbIdList
(
SMA_META
(
pSma
),
0
,
suidList
)
<
0
)
{
smaError
(
"vgId:%d, failed to restore rsma since get stb id list error: %s"
,
TD_VID
(
pVnode
),
terrstr
());
taosArrayDestroy
(
suidList
);
smaError
(
"vgId:%d, failed to restore rsma env since get stb id list error: %s"
,
TD_VID
(
pVnode
),
terrstr
());
return
TSDB_CODE_FAILED
;
}
if
(
taosArrayGetSize
(
suidList
)
==
0
)
{
smaDebug
(
"vgId:%d no need to restore rsma since empty stb id list"
,
TD_VID
(
pVnode
));
int32_t
arrSize
=
taosArrayGetSize
(
suidList
);
if
(
arrSize
==
0
)
{
taosArrayDestroy
(
suidList
);
smaDebug
(
"vgId:%d, no need to restore rsma env since empty stb id list"
,
TD_VID
(
pVnode
));
return
TSDB_CODE_SUCCESS
;
}
SMetaReader
mr
=
{
0
};
metaReaderInit
(
&
mr
,
SMA_META
(
pSma
),
0
);
for
(
int32_t
i
=
0
;
i
<
taosArrayGetSize
(
suidList
)
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
arrSize
;
++
i
)
{
tb_uid_t
suid
=
*
(
tb_uid_t
*
)
taosArrayGet
(
suidList
,
i
);
smaDebug
(
"
suid [%d] is %"
PRIi64
,
i
,
suid
);
smaDebug
(
"
vgId:%d, rsma restore, suid[%d] is %"
PRIi64
,
TD_VID
(
pVnode
)
,
i
,
suid
);
if
(
metaGetTableEntryByUid
(
&
mr
,
suid
)
<
0
)
{
smaError
(
"vgId:%d failed to get table meta for %"
PRIi64
" since %s"
,
TD_VID
(
pVnode
),
suid
,
terrstr
());
smaError
(
"vgId:%d, rsma restore, failed to get table meta for %"
PRIi64
" since %s"
,
TD_VID
(
pVnode
),
suid
,
terrstr
());
goto
_err
;
}
ASSERT
(
mr
.
me
.
type
==
TSDB_SUPER_TABLE
);
ASSERT
(
mr
.
me
.
uid
==
suid
);
if
(
TABLE_IS_ROLLUP
(
mr
.
me
.
flags
))
{
SRSmaParam
*
param
=
&
mr
.
me
.
stbEntry
.
rsmaParam
;
for
(
int
i
=
0
;
i
<
2
;
++
i
)
{
smaDebug
(
"vgId: %d table:%"
PRIi64
" maxdelay[%d]:%"
PRIi64
" watermark[%d]:%"
PRIi64
,
TD_VID
(
pSma
->
pVnode
),
suid
,
i
,
param
->
maxdelay
[
i
],
i
,
param
->
watermark
[
i
]);
for
(
int
i
=
0
;
i
<
TSDB_RETENTION_L2
;
++
i
)
{
smaDebug
(
"vgId:%d, rsma restore, table:%"
PRIi64
" level:%d, maxdelay:%"
PRIi64
" watermark:%"
PRIi64
" qmsgLen:%"
PRIi32
,
TD_VID
(
pVnode
),
suid
,
i
,
param
->
maxdelay
[
i
],
param
->
watermark
[
i
],
param
->
qmsgLen
[
i
]);
}
if
(
tdProcessRSmaCreateImpl
(
pSma
,
&
mr
.
me
.
stbEntry
.
rsmaParam
,
suid
,
mr
.
me
.
name
)
<
0
)
{
smaError
(
"vgId:%d
failed to retore rsma env
for %"
PRIi64
" since %s"
,
TD_VID
(
pVnode
),
suid
,
terrstr
());
smaError
(
"vgId:%d
, rsma restore env failed
for %"
PRIi64
" since %s"
,
TD_VID
(
pVnode
),
suid
,
terrstr
());
goto
_err
;
}
smaDebug
(
"vgId:%d, rsma restore env success for %"
PRIi64
,
TD_VID
(
pVnode
),
suid
);
}
}
// step 2: retrieve qtaskinfo
object from the rsma/qtaskinfo file
and restore
// step 2: retrieve qtaskinfo
items from the persistence file(rsma/qtaskinfo)
and restore
STFile
tFile
=
{
0
};
char
qTaskInfoFName
[
TSDB_FILENAME_LEN
];
tdRSmaQTaskGetFName
(
TD_VID
(
pVnode
),
TD_QTASK_CUR_FILE
,
qTaskInfoFName
);
tdRSmaQTask
Info
GetFName
(
TD_VID
(
pVnode
),
TD_QTASK_CUR_FILE
,
qTaskInfoFName
);
if
(
tdInitTFile
(
&
tFile
,
pVnode
->
pTfs
,
qTaskInfoFName
)
<
0
)
{
goto
_err
;
}
if
(
!
taosCheckExistFile
(
TD_TFILE_FULL_NAME
(
&
tFile
)))
{
metaReaderClear
(
&
mr
);
taosArrayDestroy
(
suidList
);
return
TSDB_CODE_SUCCESS
;
}
if
(
tdOpenTFile
(
&
tFile
,
TD_FILE_READ
)
<
0
)
{
goto
_err
;
}
SRSmaQTaskFIter
fIter
=
{
0
};
SRSmaQTaskInfoIter
fIter
=
{
0
};
if
(
tdRSmaQTaskInfoIterInit
(
&
fIter
,
&
tFile
)
<
0
)
{
goto
_err
;
}
SRSmaQTaskInfoItem
infoItem
=
{
0
};
bool
isEnd
=
false
;
int32_t
code
=
0
;
while
((
code
=
tdRSmaQTaskInfoIterNext
(
&
fIter
,
&
infoItem
,
&
isEnd
))
==
0
)
{
if
(
isEnd
)
{
break
;
}
if
((
code
=
tdRSmaQTaskInfoItemRestore
(
pSma
,
&
infoItem
))
<
0
)
{
break
;
}
}
if
(
tdRSmaQTaskInfoRestore
(
pSma
,
&
fIter
)
<
0
)
{
tdRSmaQTaskInfoIterDestroy
(
&
fIter
);
if
(
code
<
0
)
{
goto
_err
;
}
tdRSmaQTaskInfoIterDestroy
(
&
fIter
);
metaReaderClear
(
&
mr
);
taosArrayDestroy
(
suidList
);
return
TSDB_CODE_SUCCESS
;
_err:
ASSERT
(
0
);
metaReaderClear
(
&
mr
);
taosArrayDestroy
(
suidList
);
smaError
(
"failed to restore rsma
info
since %s"
,
terrstr
());
smaError
(
"failed to restore rsma
task
since %s"
,
terrstr
());
return
TSDB_CODE_FAILED
;
}
static
int32_t
tdRSmaQTaskInfoItemRestore
(
SSma
*
pSma
,
const
SRSmaQTaskInfoItem
*
info
Item
)
{
static
int32_t
tdRSmaQTaskInfoItemRestore
(
SSma
*
pSma
,
const
SRSmaQTaskInfoItem
*
p
Item
)
{
SRSmaStat
*
pStat
=
(
SRSmaStat
*
)
SMA_ENV_STAT
((
SSmaEnv
*
)
pSma
->
pRSmaEnv
);
SRSmaInfo
*
pRSmaInfo
=
NULL
;
void
*
qTaskInfo
=
NULL
;
pRSmaInfo
=
taosHashGet
(
RSMA_INFO_HASH
(
pStat
),
&
infoItem
->
suid
,
sizeof
(
info
Item
->
suid
));
pRSmaInfo
=
taosHashGet
(
RSMA_INFO_HASH
(
pStat
),
&
pItem
->
suid
,
sizeof
(
p
Item
->
suid
));
if
(
!
pRSmaInfo
||
!
(
pRSmaInfo
=
*
(
SRSmaInfo
**
)
pRSmaInfo
))
{
smaDebug
(
"vgId:%d, no restore as no rsma info for
suid:%"
PRIu64
,
SMA_VID
(
pSma
),
info
Item
->
suid
);
smaDebug
(
"vgId:%d, no restore as no rsma info for
table:%"
PRIu64
,
SMA_VID
(
pSma
),
p
Item
->
suid
);
return
TSDB_CODE_SUCCESS
;
}
if
(
info
Item
->
type
==
1
)
{
if
(
p
Item
->
type
==
1
)
{
qTaskInfo
=
pRSmaInfo
->
items
[
0
].
taskInfo
;
}
else
if
(
info
Item
->
type
==
2
)
{
}
else
if
(
p
Item
->
type
==
2
)
{
qTaskInfo
=
pRSmaInfo
->
items
[
1
].
taskInfo
;
}
else
{
ASSERT
(
0
);
}
if
(
!
qTaskInfo
)
{
smaDebug
(
"vgId:%d, no restore as NULL rsma qTaskInfo for
suid:%"
PRIu64
,
SMA_VID
(
pSma
),
info
Item
->
suid
);
smaDebug
(
"vgId:%d, no restore as NULL rsma qTaskInfo for
table:%"
PRIu64
,
SMA_VID
(
pSma
),
p
Item
->
suid
);
return
TSDB_CODE_SUCCESS
;
}
if
(
qDeserializeTaskStatus
(
qTaskInfo
,
infoItem
->
qTaskInfo
,
info
Item
->
len
)
<
0
)
{
smaError
(
"vgId:%d, restore rsma
failed for suid:%"
PRIi64
" level %d since %s"
,
SMA_VID
(
pSma
),
info
Item
->
suid
,
info
Item
->
type
,
terrstr
(
terrno
));
if
(
qDeserializeTaskStatus
(
qTaskInfo
,
pItem
->
qTaskInfo
,
p
Item
->
len
)
<
0
)
{
smaError
(
"vgId:%d, restore rsma
task failed for table:%"
PRIi64
" level %d since %s"
,
SMA_VID
(
pSma
),
p
Item
->
suid
,
p
Item
->
type
,
terrstr
(
terrno
));
return
TSDB_CODE_FAILED
;
}
smaDebug
(
"vgId:%d, restore rsma success for suid:%"
PRIi64
" level %d"
,
SMA_VID
(
pSma
),
infoItem
->
suid
,
infoItem
->
type
);
smaDebug
(
"vgId:%d, restore rsma task success for table:%"
PRIi64
" level %d"
,
SMA_VID
(
pSma
),
pItem
->
suid
,
pItem
->
type
);
return
TSDB_CODE_SUCCESS
;
}
static
int32_t
tdRSmaQTaskInfoIterInit
(
SRSmaQTask
F
Iter
*
pIter
,
STFile
*
pTFile
)
{
static
int32_t
tdRSmaQTaskInfoIterInit
(
SRSmaQTask
Info
Iter
*
pIter
,
STFile
*
pTFile
)
{
memset
(
pIter
,
0
,
sizeof
(
*
pIter
));
pIter
->
pTFile
=
pTFile
;
pIter
->
offset
=
TD_FILE_HEAD_SIZE
;
...
...
@@ -1038,16 +835,17 @@ static int32_t tdRSmaQTaskInfoIterInit(SRSmaQTaskFIter *pIter, STFile *pTFile) {
pIter
->
nAlloc
=
TD_FILE_HEAD_SIZE
;
}
pIter
->
b
uf
=
taosMemoryMalloc
(
pIter
->
nAlloc
);
if
(
!
pIter
->
b
uf
)
{
pIter
->
pB
uf
=
taosMemoryMalloc
(
pIter
->
nAlloc
);
if
(
!
pIter
->
pB
uf
)
{
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
return
TSDB_CODE_FAILED
;
}
pIter
->
qBuf
=
pIter
->
pBuf
;
return
TSDB_CODE_SUCCESS
;
}
static
int32_t
tdRSmaQTaskInfoIterNextBlock
(
SRSmaQTask
F
Iter
*
pIter
,
bool
*
isFinish
)
{
static
int32_t
tdRSmaQTaskInfoIterNextBlock
(
SRSmaQTask
Info
Iter
*
pIter
,
bool
*
isFinish
)
{
STFile
*
pTFile
=
pIter
->
pTFile
;
int64_t
nBytes
=
RSMA_QTASKINFO_BUFSIZE
;
...
...
@@ -1065,22 +863,23 @@ static int32_t tdRSmaQTaskInfoIterNextBlock(SRSmaQTaskFIter *pIter, bool *isFini
return
TSDB_CODE_FAILED
;
}
if
(
tdReadTFile
(
pTFile
,
pIter
->
b
uf
,
nBytes
)
!=
nBytes
)
{
if
(
tdReadTFile
(
pTFile
,
pIter
->
qB
uf
,
nBytes
)
!=
nBytes
)
{
ASSERT
(
0
);
return
TSDB_CODE_FAILED
;
}
int32_t
infoLen
=
0
;
taosDecodeFixedI32
(
pIter
->
b
uf
,
&
infoLen
);
taosDecodeFixedI32
(
pIter
->
qB
uf
,
&
infoLen
);
if
(
infoLen
>
nBytes
)
{
ASSERT
(
infoLen
>
RSMA_QTASKINFO_BUFSIZE
);
pIter
->
nAlloc
=
infoLen
;
void
*
pBuf
=
taosMemoryRealloc
(
pIter
->
b
uf
,
infoLen
);
void
*
pBuf
=
taosMemoryRealloc
(
pIter
->
pB
uf
,
infoLen
);
if
(
!
pBuf
)
{
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
return
TSDB_CODE_FAILED
;
}
pIter
->
buf
=
pBuf
;
pIter
->
pBuf
=
pBuf
;
pIter
->
qBuf
=
pIter
->
pBuf
;
nBytes
=
infoLen
;
if
(
tdSeekTFile
(
pTFile
,
pIter
->
offset
,
SEEK_SET
))
{
...
...
@@ -1088,7 +887,7 @@ static int32_t tdRSmaQTaskInfoIterNextBlock(SRSmaQTaskFIter *pIter, bool *isFini
return
TSDB_CODE_FAILED
;
}
if
(
tdReadTFile
(
pTFile
,
pIter
->
b
uf
,
nBytes
)
!=
nBytes
)
{
if
(
tdReadTFile
(
pTFile
,
pIter
->
pB
uf
,
nBytes
)
!=
nBytes
)
{
ASSERT
(
0
);
return
TSDB_CODE_FAILED
;
}
...
...
@@ -1101,7 +900,7 @@ static int32_t tdRSmaQTaskInfoIterNextBlock(SRSmaQTaskFIter *pIter, bool *isFini
return
TSDB_CODE_SUCCESS
;
}
static
int32_t
tdRSmaQTaskInfo
IterNext
(
SRSmaQTaskFIter
*
pIter
,
SRSmaQTaskInfoItem
*
pItem
,
bool
*
isEnd
)
{
static
int32_t
tdRSmaQTaskInfo
Restore
(
SSma
*
pSma
,
SRSmaQTaskInfoIter
*
pIter
)
{
while
(
1
)
{
// block iter
bool
isFinish
=
false
;
...
...
@@ -1110,30 +909,39 @@ static int32_t tdRSmaQTaskInfoIterNext(SRSmaQTaskFIter *pIter, SRSmaQTaskInfoIte
return
TSDB_CODE_FAILED
;
}
if
(
isFinish
)
{
*
isEnd
=
true
;
return
TSDB_CODE_SUCCESS
;
}
// consume the block
int32_t
qTaskInfoLenWithHead
=
0
;
pIter
->
buf
=
taosDecodeFixedI32
(
pIter
->
b
uf
,
&
qTaskInfoLenWithHead
);
if
(
qTaskInfoLenWithHead
<
0
)
{
pIter
->
qBuf
=
taosDecodeFixedI32
(
pIter
->
qB
uf
,
&
qTaskInfoLenWithHead
);
if
(
qTaskInfoLenWithHead
<
RSMA_QTASKINFO_HEAD_LEN
)
{
terrno
=
TSDB_CODE_TDB_FILE_CORRUPTED
;
return
TSDB_CODE_FAILED
;
}
while
(
1
)
{
if
((
pIter
->
nBufPos
+
qTaskInfoLenWithHead
)
<=
pIter
->
nBytes
)
{
pIter
->
buf
=
taosDecodeFixedI8
(
pIter
->
buf
,
&
pItem
->
type
);
pIter
->
buf
=
taosDecodeFixedI64
(
pIter
->
buf
,
&
pItem
->
suid
);
pItem
->
qTaskInfo
=
pIter
->
buf
;
pItem
->
len
=
tdRSmaQTaskInfoContLen
(
qTaskInfoLenWithHead
);
SRSmaQTaskInfoItem
infoItem
=
{
0
};
pIter
->
qBuf
=
taosDecodeFixedI8
(
pIter
->
qBuf
,
&
infoItem
.
type
);
pIter
->
qBuf
=
taosDecodeFixedI64
(
pIter
->
qBuf
,
&
infoItem
.
suid
);
infoItem
.
qTaskInfo
=
pIter
->
qBuf
;
infoItem
.
len
=
tdRSmaQTaskInfoContLen
(
qTaskInfoLenWithHead
);
// do the restore job
printf
(
"%s:%d ###### restore the qtask info offset:%"
PRIi64
"
\n
"
,
__func__
,
__LINE__
,
pIter
->
offset
);
smaDebug
(
"vgId:%d, restore the qtask info %s offset:%"
PRIi64
"
\n
"
,
SMA_VID
(
pSma
),
TD_TFILE_FULL_NAME
(
pIter
->
pTFile
),
pIter
->
offset
-
pIter
->
nBytes
+
pIter
->
nBufPos
);
tdRSmaQTaskInfoItemRestore
(
pSma
,
&
infoItem
);
pIter
->
buf
=
POINTER_SHIFT
(
pIter
->
buf
,
pItem
->
len
);
pIter
->
qBuf
=
POINTER_SHIFT
(
pIter
->
qBuf
,
infoItem
.
len
);
pIter
->
nBufPos
+=
qTaskInfoLenWithHead
;
pIter
->
buf
=
taosDecodeFixedI32
(
pIter
->
buf
,
&
qTaskInfoLenWithHead
);
if
((
pIter
->
nBufPos
+
RSMA_QTASKINFO_HEAD_LEN
)
>=
pIter
->
nBytes
)
{
// prepare and load next block in the file
pIter
->
offset
-=
(
pIter
->
nBytes
-
pIter
->
nBufPos
);
break
;
}
pIter
->
qBuf
=
taosDecodeFixedI32
(
pIter
->
qBuf
,
&
qTaskInfoLenWithHead
);
continue
;
}
// prepare and load next block in the file
...
...
@@ -1144,3 +952,208 @@ static int32_t tdRSmaQTaskInfoIterNext(SRSmaQTaskFIter *pIter, SRSmaQTaskInfoIte
return
TSDB_CODE_SUCCESS
;
}
static
void
tdRSmaQTaskInfoGetFName
(
int32_t
vid
,
int8_t
ftype
,
char
*
outputName
)
{
tdGetVndFileName
(
vid
,
VNODE_RSMA_DIR
,
tdQTaskInfoFname
[
ftype
],
outputName
);
}
static
void
*
tdRSmaPersistExec
(
void
*
param
)
{
setThreadName
(
"rsma-task-persist"
);
SRSmaStat
*
pRSmaStat
=
param
;
SSma
*
pSma
=
pRSmaStat
->
pSma
;
STfs
*
pTfs
=
pSma
->
pVnode
->
pTfs
;
int32_t
vid
=
SMA_VID
(
pSma
);
int64_t
toffset
=
0
;
bool
isFileCreated
=
false
;
if
(
TASK_TRIGGER_STAT_CANCELLED
==
atomic_load_8
(
RSMA_TRIGGER_STAT
(
pRSmaStat
)))
{
goto
_end
;
}
void
*
infoHash
=
taosHashIterate
(
RSMA_INFO_HASH
(
pRSmaStat
),
NULL
);
if
(
!
infoHash
)
{
goto
_end
;
}
STFile
tFile
=
{
0
};
while
(
infoHash
)
{
SRSmaInfo
*
pRSmaInfo
=
*
(
SRSmaInfo
**
)
infoHash
;
for
(
int32_t
i
=
0
;
i
<
TSDB_RETENTION_L2
;
++
i
)
{
qTaskInfo_t
taskInfo
=
pRSmaInfo
->
items
[
i
].
taskInfo
;
if
(
!
taskInfo
)
{
smaDebug
(
"vgId:%d, table %"
PRIi64
" level %d qTaskInfo is NULL"
,
vid
,
pRSmaInfo
->
suid
,
i
+
1
);
continue
;
}
char
*
pOutput
=
NULL
;
int32_t
len
=
0
;
int8_t
type
=
(
int8_t
)(
i
+
1
);
if
(
qSerializeTaskStatus
(
taskInfo
,
&
pOutput
,
&
len
)
<
0
)
{
smaError
(
"vgId:%d, table %"
PRIi64
" level %d serialize rsma task failed since %s"
,
vid
,
pRSmaInfo
->
suid
,
i
+
1
,
terrstr
(
terrno
));
goto
_err
;
}
if
(
!
pOutput
||
len
<=
0
)
{
smaDebug
(
"vgId:%d, table %"
PRIi64
" level %d serialize rsma task success but no output(len %d), not persist"
,
vid
,
pRSmaInfo
->
suid
,
i
+
1
,
len
);
taosMemoryFreeClear
(
pOutput
);
continue
;
}
smaDebug
(
"vgId:%d, table %"
PRIi64
" level %d serialize rsma task success with len %d, need persist"
,
vid
,
pRSmaInfo
->
suid
,
i
+
1
,
len
);
#if 0
if (qDeserializeTaskStatus(taskInfo, pOutput, len) < 0) {
smaError("vgId:%d, table %" PRIi64 "level %d deserialize rsma task failed since %s", vid, pRSmaInfo->suid,
i + 1, terrstr(terrno));
} else {
smaDebug("vgId:%d, table %" PRIi64 " level %d deserialize rsma task success", vid, pRSmaInfo->suid, i + 1);
}
#endif
if
(
!
isFileCreated
)
{
char
qTaskInfoFName
[
TSDB_FILENAME_LEN
];
tdRSmaQTaskInfoGetFName
(
vid
,
TD_QTASK_TMP_FILE
,
qTaskInfoFName
);
tdInitTFile
(
&
tFile
,
pTfs
,
qTaskInfoFName
);
tdCreateTFile
(
&
tFile
,
pTfs
,
true
,
-
1
);
isFileCreated
=
true
;
}
char
tmpBuf
[
RSMA_QTASKINFO_HEAD_LEN
]
=
{
0
};
void
*
pTmpBuf
=
&
tmpBuf
;
int32_t
headLen
=
0
;
headLen
+=
taosEncodeFixedI32
(
&
pTmpBuf
,
len
+
RSMA_QTASKINFO_HEAD_LEN
);
headLen
+=
taosEncodeFixedI8
(
&
pTmpBuf
,
type
);
headLen
+=
taosEncodeFixedI64
(
&
pTmpBuf
,
pRSmaInfo
->
suid
);
ASSERT
(
headLen
<=
RSMA_QTASKINFO_HEAD_LEN
);
tdAppendTFile
(
&
tFile
,
(
void
*
)
&
tmpBuf
,
headLen
,
&
toffset
);
smaDebug
(
"vgId:%d, table %"
PRIi64
" level %d head part len:%d appended to offset:%"
PRIi64
,
vid
,
pRSmaInfo
->
suid
,
i
+
1
,
headLen
,
toffset
);
tdAppendTFile
(
&
tFile
,
pOutput
,
len
,
&
toffset
);
smaDebug
(
"vgId:%d, table %"
PRIi64
" level %d body part len:%d appended to offset:%"
PRIi64
,
vid
,
pRSmaInfo
->
suid
,
i
+
1
,
len
,
toffset
);
taosMemoryFree
(
pOutput
);
}
infoHash
=
taosHashIterate
(
RSMA_INFO_HASH
(
pRSmaStat
),
infoHash
);
}
_normal:
if
(
isFileCreated
)
{
if
(
tdUpdateTFileHeader
(
&
tFile
)
<
0
)
{
smaError
(
"vgId:%d, failed to update tfile %s header since %s"
,
vid
,
TD_TFILE_FULL_NAME
(
&
tFile
),
tstrerror
(
terrno
));
tdCloseTFile
(
&
tFile
);
tdRemoveTFile
(
&
tFile
);
goto
_err
;
}
else
{
smaDebug
(
"vgId:%d, succeed to update tfile %s header"
,
vid
,
TD_TFILE_FULL_NAME
(
&
tFile
));
}
tdCloseTFile
(
&
tFile
);
char
newFName
[
TSDB_FILENAME_LEN
];
strncpy
(
newFName
,
TD_TFILE_FULL_NAME
(
&
tFile
),
TSDB_FILENAME_LEN
);
char
*
pos
=
strstr
(
newFName
,
tdQTaskInfoFname
[
TD_QTASK_TMP_FILE
]);
strncpy
(
pos
,
tdQTaskInfoFname
[
TD_QTASK_CUR_FILE
],
TSDB_FILENAME_LEN
-
POINTER_DISTANCE
(
pos
,
newFName
));
if
(
taosRenameFile
(
TD_TFILE_FULL_NAME
(
&
tFile
),
newFName
)
!=
0
)
{
smaError
(
"vgId:%d, failed to rename %s to %s"
,
vid
,
TD_TFILE_FULL_NAME
(
&
tFile
),
newFName
);
goto
_err
;
}
else
{
smaDebug
(
"vgId:%d, succeed to rename %s to %s"
,
vid
,
TD_TFILE_FULL_NAME
(
&
tFile
),
newFName
);
}
}
goto
_end
;
_err:
if
(
isFileCreated
)
{
tdRemoveTFile
(
&
tFile
);
}
_end:
if
(
TASK_TRIGGER_STAT_INACTIVE
==
atomic_val_compare_exchange_8
(
RSMA_TRIGGER_STAT
(
pRSmaStat
),
TASK_TRIGGER_STAT_INACTIVE
,
TASK_TRIGGER_STAT_ACTIVE
))
{
smaDebug
(
"vgId:%d, persist task is active again"
,
vid
);
}
else
if
(
TASK_TRIGGER_STAT_CANCELLED
==
atomic_val_compare_exchange_8
(
RSMA_TRIGGER_STAT
(
pRSmaStat
),
TASK_TRIGGER_STAT_CANCELLED
,
TASK_TRIGGER_STAT_FINISHED
))
{
smaDebug
(
"vgId:%d, persist task is cancelled"
,
vid
);
}
else
{
smaWarn
(
"vgId:%d, persist task in abnormal stat %"
PRIi8
,
vid
,
atomic_load_8
(
RSMA_TRIGGER_STAT
(
pRSmaStat
)));
ASSERT
(
0
);
}
atomic_store_8
(
RSMA_RUNNING_STAT
(
pRSmaStat
),
0
);
taosThreadExit
(
NULL
);
return
NULL
;
}
static
void
tdRSmaPersistTask
(
SRSmaStat
*
pRSmaStat
)
{
TdThreadAttr
thAttr
;
taosThreadAttrInit
(
&
thAttr
);
taosThreadAttrSetDetachState
(
&
thAttr
,
PTHREAD_CREATE_DETACHED
);
TdThread
tid
;
if
(
taosThreadCreate
(
&
tid
,
&
thAttr
,
tdRSmaPersistExec
,
pRSmaStat
)
!=
0
)
{
if
(
TASK_TRIGGER_STAT_INACTIVE
==
atomic_val_compare_exchange_8
(
RSMA_TRIGGER_STAT
(
pRSmaStat
),
TASK_TRIGGER_STAT_INACTIVE
,
TASK_TRIGGER_STAT_ACTIVE
))
{
smaDebug
(
"vgId:%d, persist task is active again"
,
SMA_VID
(
pRSmaStat
->
pSma
));
}
else
if
(
TASK_TRIGGER_STAT_CANCELLED
==
atomic_val_compare_exchange_8
(
RSMA_TRIGGER_STAT
(
pRSmaStat
),
TASK_TRIGGER_STAT_CANCELLED
,
TASK_TRIGGER_STAT_FINISHED
))
{
smaDebug
(
"vgId:%d, persist task is cancelled and set finished"
,
SMA_VID
(
pRSmaStat
->
pSma
));
}
else
{
smaWarn
(
"vgId:%d, persist task in abnormal stat %"
PRIi8
,
atomic_load_8
(
RSMA_TRIGGER_STAT
(
pRSmaStat
)),
SMA_VID
(
pRSmaStat
->
pSma
));
ASSERT
(
0
);
}
atomic_store_8
(
RSMA_RUNNING_STAT
(
pRSmaStat
),
0
);
}
taosThreadAttrDestroy
(
&
thAttr
);
}
/**
* @brief trigger to persist rsma qTaskInfo
*
* @param param
* @param tmrId
*/
static
void
tdRSmaPersistTrigger
(
void
*
param
,
void
*
tmrId
)
{
SRSmaStat
*
pRSmaStat
=
param
;
int8_t
tmrStat
=
atomic_val_compare_exchange_8
(
RSMA_TRIGGER_STAT
(
pRSmaStat
),
TASK_TRIGGER_STAT_ACTIVE
,
TASK_TRIGGER_STAT_INACTIVE
);
switch
(
tmrStat
)
{
case
TASK_TRIGGER_STAT_ACTIVE
:
{
atomic_store_8
(
RSMA_RUNNING_STAT
(
pRSmaStat
),
1
);
if
(
TASK_TRIGGER_STAT_CANCELLED
!=
atomic_val_compare_exchange_8
(
RSMA_TRIGGER_STAT
(
pRSmaStat
),
TASK_TRIGGER_STAT_CANCELLED
,
TASK_TRIGGER_STAT_FINISHED
))
{
smaDebug
(
"vgId:%d, rsma persistence start since active"
,
SMA_VID
(
pRSmaStat
->
pSma
));
// start persist task
tdRSmaPersistTask
(
pRSmaStat
);
taosTmrReset
(
tdRSmaPersistTrigger
,
RSMA_QTASKINFO_PERSIST_MS
,
pRSmaStat
,
pRSmaStat
->
tmrHandle
,
&
pRSmaStat
->
tmrId
);
}
else
{
atomic_store_8
(
RSMA_RUNNING_STAT
(
pRSmaStat
),
0
);
}
}
break
;
case
TASK_TRIGGER_STAT_CANCELLED
:
{
atomic_store_8
(
RSMA_TRIGGER_STAT
(
pRSmaStat
),
TASK_TRIGGER_STAT_FINISHED
);
smaDebug
(
"rsma persistence not start since cancelled and finished"
);
}
break
;
case
TASK_TRIGGER_STAT_INACTIVE
:
{
smaDebug
(
"rsma persistence not start since inactive"
);
}
break
;
case
TASK_TRIGGER_STAT_INIT
:
{
smaDebug
(
"rsma persistence not start since init"
);
}
break
;
default:
{
smaWarn
(
"rsma persistence not start since unknown stat %"
PRIi8
,
tmrStat
);
}
break
;
}
}
source/dnode/vnode/src/sma/smaUtil.c
浏览文件 @
ed4b2dec
...
...
@@ -22,7 +22,6 @@
#define TD_FILE_INIT_MAGIC 0xFFFFFFFF
static
int32_t
tdEncodeTFInfo
(
void
**
buf
,
STFInfo
*
pInfo
);
static
void
*
tdDecodeTFInfo
(
void
*
buf
,
STFInfo
*
pInfo
);
...
...
@@ -46,7 +45,7 @@ static void *tdDecodeTFInfo(void *buf, STFInfo *pInfo) {
}
int64_t
tdWriteTFile
(
STFile
*
pTFile
,
void
*
buf
,
int64_t
nbyte
)
{
ASSERT
(
TD_FILE_OPENED
(
pTFile
));
ASSERT
(
TD_
T
FILE_OPENED
(
pTFile
));
int64_t
nwrite
=
taosWriteFile
(
pTFile
->
pFile
,
buf
,
nbyte
);
if
(
nwrite
<
nbyte
)
{
...
...
@@ -58,9 +57,9 @@ int64_t tdWriteTFile(STFile *pTFile, void *buf, int64_t nbyte) {
}
int64_t
tdSeekTFile
(
STFile
*
pTFile
,
int64_t
offset
,
int
whence
)
{
ASSERT
(
TD_FILE_OPENED
(
pTFile
));
ASSERT
(
TD_
T
FILE_OPENED
(
pTFile
));
int64_t
loffset
=
taosLSeekFile
(
TD_FILE_PFILE
(
pTFile
),
offset
,
whence
);
int64_t
loffset
=
taosLSeekFile
(
TD_
T
FILE_PFILE
(
pTFile
),
offset
,
whence
);
if
(
loffset
<
0
)
{
terrno
=
TAOS_SYSTEM_ERROR
(
errno
);
return
-
1
;
...
...
@@ -70,12 +69,12 @@ int64_t tdSeekTFile(STFile *pTFile, int64_t offset, int whence) {
}
int64_t
tdGetTFileSize
(
STFile
*
pTFile
,
int64_t
*
size
)
{
ASSERT
(
TD_FILE_OPENED
(
pTFile
));
ASSERT
(
TD_
T
FILE_OPENED
(
pTFile
));
return
taosFStatFile
(
pTFile
->
pFile
,
size
,
NULL
);
}
int64_t
tdReadTFile
(
STFile
*
pTFile
,
void
*
buf
,
int64_t
nbyte
)
{
ASSERT
(
TD_FILE_OPENED
(
pTFile
));
ASSERT
(
TD_
T
FILE_OPENED
(
pTFile
));
int64_t
nread
=
taosReadFile
(
pTFile
->
pFile
,
buf
,
nbyte
);
if
(
nread
<
0
)
{
...
...
@@ -108,7 +107,7 @@ int32_t tdLoadTFileHeader(STFile *pTFile, STFInfo *pInfo) {
char
buf
[
TD_FILE_HEAD_SIZE
]
=
"
\0
"
;
uint32_t
_version
;
ASSERT
(
TD_FILE_OPENED
(
pTFile
));
ASSERT
(
TD_
T
FILE_OPENED
(
pTFile
));
if
(
tdSeekTFile
(
pTFile
,
0
,
SEEK_SET
)
<
0
)
{
return
-
1
;
...
...
@@ -133,7 +132,7 @@ void tdUpdateTFileMagic(STFile *pTFile, void *pCksm) {
}
int64_t
tdAppendTFile
(
STFile
*
pTFile
,
void
*
buf
,
int64_t
nbyte
,
int64_t
*
offset
)
{
ASSERT
(
TD_FILE_OPENED
(
pTFile
));
ASSERT
(
TD_
T
FILE_OPENED
(
pTFile
));
int64_t
toffset
;
...
...
@@ -141,6 +140,11 @@ int64_t tdAppendTFile(STFile *pTFile, void *buf, int64_t nbyte, int64_t *offset)
return
-
1
;
}
#if 1
smaDebug
(
"append to file %s, offset:%"
PRIi64
" + nbyte:%"
PRIi64
" =%"
PRIi64
,
TD_TFILE_FULL_NAME
(
pTFile
),
toffset
,
nbyte
,
toffset
+
nbyte
);
#endif
ASSERT
(
pTFile
->
info
.
fsize
==
toffset
);
if
(
offset
)
{
...
...
@@ -157,9 +161,9 @@ int64_t tdAppendTFile(STFile *pTFile, void *buf, int64_t nbyte, int64_t *offset)
}
int32_t
tdOpenTFile
(
STFile
*
pTFile
,
int
flags
)
{
ASSERT
(
!
TD_FILE_OPENED
(
pTFile
));
ASSERT
(
!
TD_
T
FILE_OPENED
(
pTFile
));
pTFile
->
pFile
=
taosOpenFile
(
TD_FILE_FULL_NAME
(
pTFile
),
flags
);
pTFile
->
pFile
=
taosOpenFile
(
TD_
T
FILE_FULL_NAME
(
pTFile
),
flags
);
if
(
pTFile
->
pFile
==
NULL
)
{
terrno
=
TAOS_SYSTEM_ERROR
(
errno
);
return
-
1
;
...
...
@@ -169,9 +173,9 @@ int32_t tdOpenTFile(STFile *pTFile, int flags) {
}
void
tdCloseTFile
(
STFile
*
pTFile
)
{
if
(
TD_FILE_OPENED
(
pTFile
))
{
if
(
TD_
T
FILE_OPENED
(
pTFile
))
{
taosCloseFile
(
&
pTFile
->
pFile
);
TD_FILE_SET_CLOSED
(
pTFile
);
TD_
T
FILE_SET_CLOSED
(
pTFile
);
}
}
...
...
@@ -183,8 +187,8 @@ int32_t tdInitTFile(STFile *pTFile, STfs *pTfs, const char *fname) {
char
fullname
[
TSDB_FILENAME_LEN
];
SDiskID
did
=
{
0
};
TD_FILE_SET_STATE
(
pTFile
,
TD_FILE_STATE_OK
);
TD_FILE_SET_CLOSED
(
pTFile
);
TD_
T
FILE_SET_STATE
(
pTFile
,
TD_FILE_STATE_OK
);
TD_
T
FILE_SET_CLOSED
(
pTFile
);
memset
(
&
(
pTFile
->
info
),
0
,
sizeof
(
pTFile
->
info
));
pTFile
->
info
.
magic
=
TD_FILE_INIT_MAGIC
;
...
...
@@ -202,18 +206,18 @@ int32_t tdInitTFile(STFile *pTFile, STfs *pTfs, const char *fname) {
int32_t
tdCreateTFile
(
STFile
*
pTFile
,
STfs
*
pTfs
,
bool
updateHeader
,
int8_t
fType
)
{
ASSERT
(
pTFile
->
info
.
fsize
==
0
&&
pTFile
->
info
.
magic
==
TD_FILE_INIT_MAGIC
);
pTFile
->
pFile
=
taosOpenFile
(
TD_FILE_FULL_NAME
(
pTFile
),
TD_FILE_CREATE
|
TD_FILE_WRITE
|
TD_FILE_TRUNC
);
pTFile
->
pFile
=
taosOpenFile
(
TD_
T
FILE_FULL_NAME
(
pTFile
),
TD_FILE_CREATE
|
TD_FILE_WRITE
|
TD_FILE_TRUNC
);
if
(
pTFile
->
pFile
==
NULL
)
{
if
(
errno
==
ENOENT
)
{
// Try to create directory recursively
char
*
s
=
strdup
(
TD_FILE_REL_NAME
(
pTFile
));
if
(
tfsMkdirRecurAt
(
pTfs
,
taosDirName
(
s
),
TD_FILE_DID
(
pTFile
))
<
0
)
{
char
*
s
=
strdup
(
TD_
T
FILE_REL_NAME
(
pTFile
));
if
(
tfsMkdirRecurAt
(
pTfs
,
taosDirName
(
s
),
TD_
T
FILE_DID
(
pTFile
))
<
0
)
{
taosMemoryFreeClear
(
s
);
return
-
1
;
}
taosMemoryFreeClear
(
s
);
pTFile
->
pFile
=
taosOpenFile
(
TD_FILE_FULL_NAME
(
pTFile
),
TD_FILE_CREATE
|
TD_FILE_WRITE
|
TD_FILE_TRUNC
);
pTFile
->
pFile
=
taosOpenFile
(
TD_
T
FILE_FULL_NAME
(
pTFile
),
TD_FILE_CREATE
|
TD_FILE_WRITE
|
TD_FILE_TRUNC
);
if
(
pTFile
->
pFile
==
NULL
)
{
terrno
=
TAOS_SYSTEM_ERROR
(
errno
);
return
-
1
;
...
...
@@ -240,7 +244,7 @@ int32_t tdCreateTFile(STFile *pTFile, STfs *pTfs, bool updateHeader, int8_t fTyp
return
0
;
}
int32_t
tdRemoveTFile
(
STFile
*
pTFile
)
{
return
tfsRemoveFile
(
TD_FILE_F
(
pTFile
));
}
int32_t
tdRemoveTFile
(
STFile
*
pTFile
)
{
return
tfsRemoveFile
(
TD_
T
FILE_F
(
pTFile
));
}
// smaXXXUtil ================
// ...
\ No newline at end of file
source/dnode/vnode/src/vnd/vnodeOpen.c
浏览文件 @
ed4b2dec
...
...
@@ -152,14 +152,14 @@ SVnode *vnodeOpen(const char *path, STfs *pTfs, SMsgCb msgCb) {
return
pVnode
;
_err:
if
(
pVnode
->
pSma
)
smaClose
(
pVnode
->
pSma
);
if
(
pVnode
->
pSma
)
smaClose
Env
(
pVnode
->
pSma
);
if
(
pVnode
->
pQuery
)
vnodeQueryClose
(
pVnode
);
if
(
pVnode
->
pTq
)
tqClose
(
pVnode
->
pTq
);
if
(
pVnode
->
pWal
)
walClose
(
pVnode
->
pWal
);
if
(
pVnode
->
pTsdb
)
tsdbClose
(
&
pVnode
->
pTsdb
);
if
(
pVnode
->
pSma
)
smaCloseEx
(
pVnode
->
pSma
);
if
(
pVnode
->
pMeta
)
metaClose
(
pVnode
->
pMeta
);
tsem_destroy
(
&
(
pVnode
->
canCommit
));
taosMemoryFree
(
pVnode
);
return
NULL
;
...
...
source/libs/function/src/builtins.c
浏览文件 @
ed4b2dec
...
...
@@ -1052,7 +1052,8 @@ static int32_t translateUniqueMode(SFunctionNode* pFunc, char* pErrBuf, int32_t
SNode
*
pPara
=
nodesListGetNode
(
pFunc
->
pParameterList
,
0
);
if
(
!
nodesExprHasColumn
(
pPara
))
{
return
buildFuncErrMsg
(
pErrBuf
,
len
,
TSDB_CODE_FUNC_FUNTION_ERROR
,
"The parameters of %s must contain columns"
,
isUnique
?
"UNIQUE"
:
"MODE"
);
return
buildFuncErrMsg
(
pErrBuf
,
len
,
TSDB_CODE_FUNC_FUNTION_ERROR
,
"The parameters of %s must contain columns"
,
isUnique
?
"UNIQUE"
:
"MODE"
);
}
pFunc
->
node
.
resType
=
((
SExprNode
*
)
pPara
)
->
resType
;
...
...
@@ -1228,19 +1229,19 @@ static int32_t translateSubstr(SFunctionNode* pFunc, char* pErrBuf, int32_t len)
static
int32_t
translateCast
(
SFunctionNode
*
pFunc
,
char
*
pErrBuf
,
int32_t
len
)
{
// The number of parameters has been limited by the syntax definition
//uint8_t para1Type = ((SExprNode*)nodesListGetNode(pFunc->pParameterList, 0))->resType.type;
//
uint8_t para1Type = ((SExprNode*)nodesListGetNode(pFunc->pParameterList, 0))->resType.type;
// The function return type has been set during syntax parsing
uint8_t
para2Type
=
pFunc
->
node
.
resType
.
type
;
//if (para2Type != TSDB_DATA_TYPE_BIGINT && para2Type != TSDB_DATA_TYPE_UBIGINT &&
//
if (para2Type != TSDB_DATA_TYPE_BIGINT && para2Type != TSDB_DATA_TYPE_UBIGINT &&
// para2Type != TSDB_DATA_TYPE_VARCHAR && para2Type != TSDB_DATA_TYPE_NCHAR &&
// para2Type != TSDB_DATA_TYPE_TIMESTAMP) {
// return invaildFuncParaTypeErrMsg(pErrBuf, len, pFunc->functionName);
//}
//if ((para2Type == TSDB_DATA_TYPE_TIMESTAMP && IS_VAR_DATA_TYPE(para1Type)) ||
//
}
//
if ((para2Type == TSDB_DATA_TYPE_TIMESTAMP && IS_VAR_DATA_TYPE(para1Type)) ||
// (para2Type == TSDB_DATA_TYPE_BINARY && para1Type == TSDB_DATA_TYPE_NCHAR)) {
// return invaildFuncParaTypeErrMsg(pErrBuf, len, pFunc->functionName);
//}
//
}
int32_t
para2Bytes
=
pFunc
->
node
.
resType
.
bytes
;
if
(
IS_VAR_DATA_TYPE
(
para2Type
))
{
...
...
@@ -1890,7 +1891,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = {
{
.
name
=
"first"
,
.
type
=
FUNCTION_TYPE_FIRST
,
.
classification
=
FUNC_MGT_AGG_FUNC
|
FUNC_MGT_MULTI_RES_FUNC
|
FUNC_MGT_TIMELINE_FUNC
,
.
classification
=
FUNC_MGT_AGG_FUNC
|
FUNC_MGT_
SELECT_FUNC
|
FUNC_MGT_
MULTI_RES_FUNC
|
FUNC_MGT_TIMELINE_FUNC
,
.
translateFunc
=
translateFirstLast
,
.
getEnvFunc
=
getFirstLastFuncEnv
,
.
initFunc
=
functionSetup
,
...
...
@@ -1925,7 +1926,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = {
{
.
name
=
"last"
,
.
type
=
FUNCTION_TYPE_LAST
,
.
classification
=
FUNC_MGT_AGG_FUNC
|
FUNC_MGT_MULTI_RES_FUNC
|
FUNC_MGT_TIMELINE_FUNC
,
.
classification
=
FUNC_MGT_AGG_FUNC
|
FUNC_MGT_
SELECT_FUNC
|
FUNC_MGT_
MULTI_RES_FUNC
|
FUNC_MGT_TIMELINE_FUNC
,
.
translateFunc
=
translateFirstLast
,
.
getEnvFunc
=
getFirstLastFuncEnv
,
.
initFunc
=
functionSetup
,
...
...
@@ -2117,7 +2118,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = {
{
.
name
=
"unique"
,
.
type
=
FUNCTION_TYPE_UNIQUE
,
.
classification
=
FUNC_MGT_
AGG_FUNC
|
FUNC_MGT_SELECT_FUNC
|
FUNC_MGT_INDEFINITE_ROWS_FUNC
|
FUNC_MGT_TIMELINE_FUNC
|
.
classification
=
FUNC_MGT_
SELECT_FUNC
|
FUNC_MGT_INDEFINITE_ROWS_FUNC
|
FUNC_MGT_TIMELINE_FUNC
|
FUNC_MGT_FORBID_STREAM_FUNC
|
FUNC_MGT_FORBID_WINDOW_FUNC
|
FUNC_MGT_FORBID_GROUP_BY_FUNC
,
.
translateFunc
=
translateUnique
,
.
getEnvFunc
=
getUniqueFuncEnv
,
...
...
source/libs/nodes/src/nodesCloneFuncs.c
浏览文件 @
ed4b2dec
...
...
@@ -100,6 +100,7 @@ static int32_t exprNodeCopy(const SExprNode* pSrc, SExprNode* pDst) {
COPY_OBJECT_FIELD
(
resType
,
sizeof
(
SDataType
));
COPY_CHAR_ARRAY_FIELD
(
aliasName
);
COPY_CHAR_ARRAY_FIELD
(
userAlias
);
COPY_SCALAR_FIELD
(
orderAlias
);
return
TSDB_CODE_SUCCESS
;
}
...
...
source/libs/nodes/src/nodesUtilFuncs.c
浏览文件 @
ed4b2dec
...
...
@@ -1500,7 +1500,8 @@ typedef struct SCollectFuncsCxt {
static
EDealRes
collectFuncs
(
SNode
*
pNode
,
void
*
pContext
)
{
SCollectFuncsCxt
*
pCxt
=
(
SCollectFuncsCxt
*
)
pContext
;
if
(
QUERY_NODE_FUNCTION
==
nodeType
(
pNode
)
&&
pCxt
->
classifier
(((
SFunctionNode
*
)
pNode
)
->
funcId
))
{
if
(
QUERY_NODE_FUNCTION
==
nodeType
(
pNode
)
&&
pCxt
->
classifier
(((
SFunctionNode
*
)
pNode
)
->
funcId
)
&&
!
(((
SExprNode
*
)
pNode
)
->
orderAlias
))
{
pCxt
->
errCode
=
nodesListStrictAppend
(
pCxt
->
pFuncs
,
nodesCloneNode
(
pNode
));
return
(
TSDB_CODE_SUCCESS
==
pCxt
->
errCode
?
DEAL_RES_IGNORE_CHILD
:
DEAL_RES_ERROR
);
}
...
...
source/libs/parser/src/parTranslater.c
浏览文件 @
ed4b2dec
...
...
@@ -1355,25 +1355,6 @@ static EDealRes rewriteColToSelectValFunc(STranslateContext* pCxt, SNode** pNode
return
TSDB_CODE_SUCCESS
==
pCxt
->
errCode
?
DEAL_RES_IGNORE_CHILD
:
DEAL_RES_ERROR
;
}
static
EDealRes
rewriteExprToGroupKeyFunc
(
STranslateContext
*
pCxt
,
SNode
**
pNode
)
{
SFunctionNode
*
pFunc
=
(
SFunctionNode
*
)
nodesMakeNode
(
QUERY_NODE_FUNCTION
);
if
(
NULL
==
pFunc
)
{
pCxt
->
errCode
=
TSDB_CODE_OUT_OF_MEMORY
;
return
DEAL_RES_ERROR
;
}
strcpy
(
pFunc
->
functionName
,
"_group_key"
);
strcpy
(
pFunc
->
node
.
aliasName
,
((
SExprNode
*
)
*
pNode
)
->
aliasName
);
pCxt
->
errCode
=
nodesListMakeAppend
(
&
pFunc
->
pParameterList
,
*
pNode
);
if
(
TSDB_CODE_SUCCESS
==
pCxt
->
errCode
)
{
*
pNode
=
(
SNode
*
)
pFunc
;
pCxt
->
errCode
=
fmGetFuncInfo
(
pFunc
,
pCxt
->
msgBuf
.
buf
,
pCxt
->
msgBuf
.
len
);
}
pCxt
->
pCurrSelectStmt
->
hasAggFuncs
=
true
;
return
(
TSDB_CODE_SUCCESS
==
pCxt
->
errCode
?
DEAL_RES_IGNORE_CHILD
:
DEAL_RES_ERROR
);
}
static
EDealRes
doCheckExprForGroupBy
(
SNode
**
pNode
,
void
*
pContext
)
{
SCheckExprForGroupByCxt
*
pCxt
=
(
SCheckExprForGroupByCxt
*
)
pContext
;
if
(
!
nodesIsExprNode
(
*
pNode
)
||
isAliasColumn
(
*
pNode
))
{
...
...
@@ -1393,7 +1374,13 @@ static EDealRes doCheckExprForGroupBy(SNode** pNode, void* pContext) {
SNode
*
pGroupNode
=
NULL
;
FOREACH
(
pGroupNode
,
getGroupByList
(
pCxt
->
pTranslateCxt
))
{
if
(
nodesEqualNode
(
getGroupByNode
(
pGroupNode
),
*
pNode
))
{
return
rewriteExprToGroupKeyFunc
(
pCxt
->
pTranslateCxt
,
pNode
);
return
DEAL_RES_IGNORE_CHILD
;
}
}
SNode
*
pPartKey
=
NULL
;
FOREACH
(
pPartKey
,
pCxt
->
pTranslateCxt
->
pCurrSelectStmt
->
pPartitionByList
)
{
if
(
nodesEqualNode
(
pPartKey
,
*
pNode
))
{
return
DEAL_RES_IGNORE_CHILD
;
}
}
if
(
isScanPseudoColumnFunc
(
*
pNode
)
||
QUERY_NODE_COLUMN
==
nodeType
(
*
pNode
))
{
...
...
@@ -1451,25 +1438,6 @@ static int32_t rewriteColsToSelectValFunc(STranslateContext* pCxt, SSelectStmt*
return
pCxt
->
errCode
;
}
static
EDealRes
rewriteExprsToGroupKeyFuncImpl
(
SNode
**
pNode
,
void
*
pContext
)
{
STranslateContext
*
pCxt
=
pContext
;
SNode
*
pPartKey
=
NULL
;
FOREACH
(
pPartKey
,
pCxt
->
pCurrSelectStmt
->
pPartitionByList
)
{
if
(
nodesEqualNode
(
pPartKey
,
*
pNode
))
{
return
rewriteExprToGroupKeyFunc
(
pCxt
,
pNode
);
}
}
return
DEAL_RES_CONTINUE
;
}
static
int32_t
rewriteExprsToGroupKeyFunc
(
STranslateContext
*
pCxt
,
SSelectStmt
*
pSelect
)
{
nodesRewriteExprs
(
pSelect
->
pProjectionList
,
rewriteExprsToGroupKeyFuncImpl
,
pCxt
);
if
(
TSDB_CODE_SUCCESS
==
pCxt
->
errCode
&&
!
pSelect
->
isDistinct
)
{
nodesRewriteExprs
(
pSelect
->
pOrderByList
,
rewriteExprsToGroupKeyFuncImpl
,
pCxt
);
}
return
pCxt
->
errCode
;
}
typedef
struct
CheckAggColCoexistCxt
{
STranslateContext
*
pTranslateCxt
;
bool
existAggFunc
;
...
...
@@ -1529,9 +1497,6 @@ static int32_t checkAggColCoexist(STranslateContext* pCxt, SSelectStmt* pSelect)
if
(
cxt
.
existIndefiniteRowsFunc
&&
cxt
.
existCol
)
{
return
generateSyntaxErrMsg
(
&
pCxt
->
msgBuf
,
TSDB_CODE_PAR_NOT_ALLOWED_FUNC
);
}
if
(
cxt
.
existAggFunc
&&
NULL
!=
pSelect
->
pPartitionByList
)
{
return
rewriteExprsToGroupKeyFunc
(
pCxt
,
pSelect
);
}
return
TSDB_CODE_SUCCESS
;
}
...
...
@@ -2408,54 +2373,6 @@ static EDealRes rewriteSeletcValueFunc(STranslateContext* pCxt, SNode** pNode) {
return
TSDB_CODE_SUCCESS
==
pCxt
->
errCode
?
DEAL_RES_IGNORE_CHILD
:
DEAL_RES_ERROR
;
}
static
EDealRes
rewriteUniqueFunc
(
SNode
**
pNode
,
void
*
pContext
)
{
SRwriteUniqueCxt
*
pCxt
=
pContext
;
if
(
QUERY_NODE_FUNCTION
==
nodeType
(
*
pNode
))
{
SFunctionNode
*
pFunc
=
(
SFunctionNode
*
)
*
pNode
;
if
(
FUNCTION_TYPE_UNIQUE
==
pFunc
->
funcType
)
{
SNode
*
pExpr
=
nodesListGetNode
(
pFunc
->
pParameterList
,
0
);
NODES_CLEAR_LIST
(
pFunc
->
pParameterList
);
strcpy
(((
SExprNode
*
)
pExpr
)
->
aliasName
,
((
SExprNode
*
)
*
pNode
)
->
aliasName
);
nodesDestroyNode
(
*
pNode
);
*
pNode
=
pExpr
;
pCxt
->
pExpr
=
pExpr
;
return
DEAL_RES_IGNORE_CHILD
;
}
else
if
(
FUNCTION_TYPE_SELECT_VALUE
==
pFunc
->
funcType
)
{
return
rewriteSeletcValueFunc
(
pCxt
->
pTranslateCxt
,
pNode
);
}
}
return
DEAL_RES_CONTINUE
;
}
static
SNode
*
createGroupingSet
(
SNode
*
pExpr
)
{
SGroupingSetNode
*
pGroupingSet
=
(
SGroupingSetNode
*
)
nodesMakeNode
(
QUERY_NODE_GROUPING_SET
);
if
(
NULL
==
pGroupingSet
)
{
return
NULL
;
}
pGroupingSet
->
groupingSetType
=
GP_TYPE_NORMAL
;
if
(
TSDB_CODE_SUCCESS
!=
nodesListMakeStrictAppend
(
&
pGroupingSet
->
pParameterList
,
nodesCloneNode
(
pExpr
)))
{
nodesDestroyNode
((
SNode
*
)
pGroupingSet
);
return
NULL
;
}
return
(
SNode
*
)
pGroupingSet
;
}
// from: select unique(expr), col1 + col2 from t where_clause partition_by_clause order_by_clause ...
// to: select expr, first(col1) + first(col2) from t where_clause partition_by_clause group by expr order_by_clause ...
static
int32_t
rewriteUniqueStmt
(
STranslateContext
*
pCxt
,
SSelectStmt
*
pSelect
)
{
if
(
!
pSelect
->
hasUniqueFunc
)
{
return
TSDB_CODE_SUCCESS
;
}
SRwriteUniqueCxt
cxt
=
{.
pTranslateCxt
=
pCxt
,
.
pExpr
=
NULL
};
nodesRewriteExprs
(
pSelect
->
pProjectionList
,
rewriteUniqueFunc
,
&
cxt
);
if
(
TSDB_CODE_SUCCESS
==
cxt
.
pTranslateCxt
->
errCode
)
{
cxt
.
pTranslateCxt
->
errCode
=
nodesListMakeStrictAppend
(
&
pSelect
->
pGroupByList
,
createGroupingSet
(
cxt
.
pExpr
));
}
pSelect
->
hasIndefiniteRowsFunc
=
false
;
return
cxt
.
pTranslateCxt
->
errCode
;
}
typedef
struct
SReplaceOrderByAliasCxt
{
STranslateContext
*
pTranslateCxt
;
SNodeList
*
pProjectionList
;
...
...
@@ -2474,6 +2391,7 @@ static EDealRes replaceOrderByAliasImpl(SNode** pNode, void* pContext) {
pCxt
->
pTranslateCxt
->
errCode
=
TSDB_CODE_OUT_OF_MEMORY
;
return
DEAL_RES_ERROR
;
}
((
SExprNode
*
)
pNew
)
->
orderAlias
=
true
;
nodesDestroyNode
(
*
pNode
);
*
pNode
=
pNew
;
return
DEAL_RES_CONTINUE
;
...
...
@@ -2529,9 +2447,6 @@ static int32_t translateSelectFrom(STranslateContext* pCxt, SSelectStmt* pSelect
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
translateInterp
(
pCxt
,
pSelect
);
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
rewriteUniqueStmt
(
pCxt
,
pSelect
);
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
rewriteTimelineFunc
(
pCxt
,
pSelect
);
}
...
...
source/libs/parser/test/parSelectTest.cpp
浏览文件 @
ed4b2dec
...
...
@@ -232,8 +232,6 @@ TEST_F(ParserSelectTest, groupBySemanticCheck) {
run
(
"SELECT COUNT(*) cnt, c1 FROM t1 WHERE c1 > 0"
,
TSDB_CODE_PAR_NOT_SINGLE_GROUP
);
run
(
"SELECT COUNT(*) cnt, c2 FROM t1 WHERE c1 > 0 GROUP BY c1"
,
TSDB_CODE_PAR_GROUPBY_LACK_EXPRESSION
);
run
(
"SELECT COUNT(*) cnt, c2 FROM t1 WHERE c1 > 0 PARTITION BY c2 GROUP BY c1"
,
TSDB_CODE_PAR_GROUPBY_LACK_EXPRESSION
);
}
TEST_F
(
ParserSelectTest
,
orderBy
)
{
...
...
source/libs/planner/src/planLogicCreater.c
浏览文件 @
ed4b2dec
...
...
@@ -437,6 +437,33 @@ static SColumnNode* createColumnByExpr(const char* pStmtName, SExprNode* pExpr)
return
pCol
;
}
static
SNode
*
createGroupingSetNode
(
SNode
*
pExpr
)
{
SGroupingSetNode
*
pGroupingSet
=
(
SGroupingSetNode
*
)
nodesMakeNode
(
QUERY_NODE_GROUPING_SET
);
if
(
NULL
==
pGroupingSet
)
{
return
NULL
;
}
pGroupingSet
->
groupingSetType
=
GP_TYPE_NORMAL
;
if
(
TSDB_CODE_SUCCESS
!=
nodesListMakeStrictAppend
(
&
pGroupingSet
->
pParameterList
,
nodesCloneNode
(
pExpr
)))
{
nodesDestroyNode
((
SNode
*
)
pGroupingSet
);
return
NULL
;
}
return
(
SNode
*
)
pGroupingSet
;
}
static
int32_t
createGroupKeysFromPartKeys
(
SNodeList
*
pPartKeys
,
SNodeList
**
pOutput
)
{
SNodeList
*
pGroupKeys
=
NULL
;
SNode
*
pPartKey
=
NULL
;
FOREACH
(
pPartKey
,
pPartKeys
)
{
int32_t
code
=
nodesListMakeStrictAppend
(
&
pGroupKeys
,
createGroupingSetNode
(
pPartKey
));
if
(
TSDB_CODE_SUCCESS
!=
code
)
{
nodesDestroyList
(
pGroupKeys
);
return
code
;
}
}
*
pOutput
=
pGroupKeys
;
return
TSDB_CODE_SUCCESS
;
}
static
int32_t
createAggLogicNode
(
SLogicPlanContext
*
pCxt
,
SSelectStmt
*
pSelect
,
SLogicNode
**
pLogicNode
)
{
if
(
!
pSelect
->
hasAggFuncs
&&
NULL
==
pSelect
->
pGroupByList
)
{
return
TSDB_CODE_SUCCESS
;
...
...
@@ -459,12 +486,20 @@ static int32_t createAggLogicNode(SLogicPlanContext* pCxt, SSelectStmt* pSelect,
code
=
rewriteExprsForSelect
(
pAgg
->
pAggFuncs
,
pSelect
,
SQL_CLAUSE_GROUP_BY
);
}
if
(
NULL
!=
pSelect
->
pPartitionByList
)
{
code
=
createGroupKeysFromPartKeys
(
pSelect
->
pPartitionByList
,
&
pAgg
->
pGroupKeys
);
}
if
(
NULL
!=
pSelect
->
pGroupByList
)
{
if
(
NULL
!=
pAgg
->
pGroupKeys
)
{
code
=
nodesListStrictAppendList
(
pAgg
->
pGroupKeys
,
nodesCloneList
(
pSelect
->
pGroupByList
));
}
else
{
pAgg
->
pGroupKeys
=
nodesCloneList
(
pSelect
->
pGroupByList
);
if
(
NULL
==
pAgg
->
pGroupKeys
)
{
code
=
TSDB_CODE_OUT_OF_MEMORY
;
}
}
}
// rewrite the expression in subsequent clauses
if
(
TSDB_CODE_SUCCESS
==
code
)
{
...
...
@@ -508,6 +543,7 @@ static int32_t createIndefRowsFuncLogicNode(SLogicPlanContext* pCxt, SSelectStmt
}
pIdfRowsFunc
->
isTailFunc
=
pSelect
->
hasTailFunc
;
pIdfRowsFunc
->
isUniqueFunc
=
pSelect
->
hasUniqueFunc
;
// indefinite rows functions and _select_values functions
int32_t
code
=
nodesCollectFuncs
(
pSelect
,
SQL_CLAUSE_SELECT
,
fmIsVectorFunc
,
&
pIdfRowsFunc
->
pFuncs
);
...
...
@@ -809,7 +845,8 @@ static int32_t createProjectLogicNode(SLogicPlanContext* pCxt, SSelectStmt* pSel
}
static
int32_t
createPartitionLogicNode
(
SLogicPlanContext
*
pCxt
,
SSelectStmt
*
pSelect
,
SLogicNode
**
pLogicNode
)
{
if
(
NULL
==
pSelect
->
pPartitionByList
)
{
if
(
NULL
==
pSelect
->
pPartitionByList
||
(
pSelect
->
hasAggFuncs
&&
NULL
==
pSelect
->
pWindow
)
||
NULL
!=
pSelect
->
pGroupByList
)
{
return
TSDB_CODE_SUCCESS
;
}
...
...
source/libs/planner/src/planOptimizer.c
浏览文件 @
ed4b2dec
...
...
@@ -987,6 +987,7 @@ static int32_t smaIndexOptimizeImpl(SOptimizeContext* pCxt, SLogicSubplan* pLogi
code
=
smaIndexOptApplyIndex
(
pLogicSubplan
,
pScan
,
pIndex
,
pSmaCols
,
wstrartIndex
);
taosArrayDestroyEx
(
pScan
->
pSmaIndexes
,
smaIndexOptDestroySmaIndex
);
pScan
->
pSmaIndexes
=
NULL
;
pCxt
->
optimized
=
true
;
break
;
}
}
...
...
@@ -1033,12 +1034,30 @@ static SNodeList* partTagsGetPartKeys(SLogicNode* pNode) {
}
}
static
SNodeList
*
partTagsGetFuncs
(
SLogicNode
*
pNode
)
{
if
(
QUERY_NODE_LOGIC_PLAN_PARTITION
==
nodeType
(
pNode
))
{
return
NULL
;
}
else
{
return
((
SAggLogicNode
*
)
pNode
)
->
pAggFuncs
;
}
}
static
bool
partTagsOptAreSupportedFuncs
(
SNodeList
*
pFuncs
)
{
SNode
*
pFunc
=
NULL
;
FOREACH
(
pFunc
,
pFuncs
)
{
if
(
fmIsIndefiniteRowsFunc
(((
SFunctionNode
*
)
pFunc
)
->
funcId
)
&&
!
fmIsSelectFunc
(((
SFunctionNode
*
)
pFunc
)
->
funcId
))
{
return
false
;
}
}
return
true
;
}
static
bool
partTagsOptMayBeOptimized
(
SLogicNode
*
pNode
)
{
if
(
!
partTagsIsOptimizableNode
(
pNode
))
{
return
false
;
}
return
!
partTagsOptHasCol
(
partTagsGetPartKeys
(
pNode
));
return
!
partTagsOptHasCol
(
partTagsGetPartKeys
(
pNode
))
&&
partTagsOptAreSupportedFuncs
(
partTagsGetFuncs
(
pNode
))
;
}
static
EDealRes
partTagsOptRebuildTbanmeImpl
(
SNode
**
pNode
,
void
*
pContext
)
{
...
...
@@ -1064,6 +1083,59 @@ static int32_t partTagsOptRebuildTbanme(SNodeList* pPartKeys) {
return
code
;
}
static
SNode
*
partTagsCreateWrapperFunc
(
const
char
*
pFuncName
,
SNode
*
pNode
)
{
SFunctionNode
*
pFunc
=
(
SFunctionNode
*
)
nodesMakeNode
(
QUERY_NODE_FUNCTION
);
if
(
NULL
==
pFunc
)
{
return
NULL
;
}
strcpy
(
pFunc
->
functionName
,
pFuncName
);
if
(
QUERY_NODE_COLUMN
==
nodeType
(
pNode
))
{
SColumnNode
*
pCol
=
(
SColumnNode
*
)
pNode
;
sprintf
(
pFunc
->
node
.
aliasName
,
"%s.%s"
,
pCol
->
tableAlias
,
pCol
->
colName
);
}
else
{
strcpy
(
pFunc
->
node
.
aliasName
,
((
SExprNode
*
)
pNode
)
->
aliasName
);
}
int32_t
code
=
nodesListMakeStrictAppend
(
&
pFunc
->
pParameterList
,
nodesCloneNode
(
pNode
));
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
fmGetFuncInfo
(
pFunc
,
NULL
,
0
);
}
if
(
TSDB_CODE_SUCCESS
!=
code
)
{
nodesDestroyNode
((
SNode
*
)
pFunc
);
return
NULL
;
}
return
(
SNode
*
)
pFunc
;
}
static
bool
partTagsHasIndefRowsSelectFunc
(
SNodeList
*
pFuncs
)
{
SNode
*
pFunc
=
NULL
;
FOREACH
(
pFunc
,
pFuncs
)
{
if
(
fmIsIndefiniteRowsFunc
(((
SFunctionNode
*
)
pFunc
)
->
funcId
))
{
return
true
;
}
}
return
false
;
}
static
int32_t
partTagsRewriteGroupTagsToFuncs
(
SNodeList
*
pGroupTags
,
SNodeList
*
pAggFuncs
)
{
bool
hasIndefRowsSelectFunc
=
partTagsHasIndefRowsSelectFunc
(
pAggFuncs
);
int32_t
code
=
TSDB_CODE_SUCCESS
;
SNode
*
pNode
=
NULL
;
FOREACH
(
pNode
,
pGroupTags
)
{
if
(
hasIndefRowsSelectFunc
)
{
code
=
nodesListStrictAppend
(
pAggFuncs
,
partTagsCreateWrapperFunc
(
"_select_value"
,
pNode
));
}
else
{
code
=
nodesListStrictAppend
(
pAggFuncs
,
partTagsCreateWrapperFunc
(
"_group_key"
,
pNode
));
}
if
(
TSDB_CODE_SUCCESS
!=
code
)
{
break
;
}
}
return
code
;
}
static
int32_t
partTagsOptimize
(
SOptimizeContext
*
pCxt
,
SLogicSubplan
*
pLogicSubplan
)
{
SLogicNode
*
pNode
=
optFindPossibleNode
(
pLogicSubplan
->
pNode
,
partTagsOptMayBeOptimized
);
if
(
NULL
==
pNode
)
{
...
...
@@ -1080,15 +1152,17 @@ static int32_t partTagsOptimize(SOptimizeContext* pCxt, SLogicSubplan* pLogicSub
nodesDestroyNode
((
SNode
*
)
pNode
);
}
}
else
{
SAggLogicNode
*
pAgg
=
(
SAggLogicNode
*
)
pNode
;
SNode
*
pGroupKey
=
NULL
;
FOREACH
(
pGroupKey
,
((
SAggLogicNode
*
)
pNode
)
->
pGroupKeys
)
{
FOREACH
(
pGroupKey
,
pAgg
->
pGroupKeys
)
{
code
=
nodesListMakeStrictAppend
(
&
pScan
->
pGroupTags
,
nodesCloneNode
(
nodesListGetNode
(((
SGroupingSetNode
*
)
pGroupKey
)
->
pParameterList
,
0
)));
if
(
TSDB_CODE_SUCCESS
!=
code
)
{
break
;
}
}
NODES_DESTORY_LIST
(((
SAggLogicNode
*
)
pNode
)
->
pGroupKeys
);
NODES_DESTORY_LIST
(
pAgg
->
pGroupKeys
);
code
=
partTagsRewriteGroupTagsToFuncs
(
pScan
->
pGroupTags
,
pAgg
->
pAggFuncs
);
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
partTagsOptRebuildTbanme
(
pScan
->
pGroupTags
);
...
...
@@ -1125,7 +1199,8 @@ static bool eliminateProjOptMayBeOptimized(SLogicNode* pNode) {
}
SProjectLogicNode
*
pProjectNode
=
(
SProjectLogicNode
*
)
pNode
;
if
(
NULL
!=
pProjectNode
->
node
.
pLimit
||
NULL
!=
pProjectNode
->
node
.
pSlimit
)
{
if
(
NULL
!=
pProjectNode
->
node
.
pLimit
||
NULL
!=
pProjectNode
->
node
.
pSlimit
||
NULL
!=
pProjectNode
->
node
.
pConditions
)
{
return
false
;
}
...
...
@@ -1163,6 +1238,7 @@ static int32_t eliminateProjOptimizeImpl(SOptimizeContext* pCxt, SLogicSubplan*
NODES_CLEAR_LIST
(
pProjectNode
->
node
.
pChildren
);
nodesDestroyNode
((
SNode
*
)
pProjectNode
);
}
pCxt
->
optimized
=
true
;
return
code
;
}
...
...
@@ -1306,6 +1382,7 @@ static int32_t rewriteTailOptimizeImpl(SOptimizeContext* pCxt, SLogicSubplan* pL
nodesDestroyNode
((
SNode
*
)
pSort
);
nodesDestroyNode
((
SNode
*
)
pProject
);
}
pCxt
->
optimized
=
true
;
return
code
;
}
...
...
@@ -1344,6 +1421,7 @@ static int32_t eliminateSetOpOptimizeImpl(SOptimizeContext* pCxt, SLogicSubplan*
pSetOpNode
->
pChildren
=
NULL
;
ERASE_NODE
(
pSetOpNode
->
pParent
->
pChildren
);
pCxt
->
optimized
=
true
;
return
TSDB_CODE_SUCCESS
;
}
}
...
...
@@ -1360,15 +1438,192 @@ static int32_t eliminateSetOpOptimize(SOptimizeContext* pCxt, SLogicSubplan* pLo
return
eliminateSetOpOptimizeImpl
(
pCxt
,
pLogicSubplan
,
pSetOpNode
);
}
//===================================================================================================================
static
bool
rewriteUniqueOptMayBeOptimized
(
SLogicNode
*
pNode
)
{
return
QUERY_NODE_LOGIC_PLAN_INDEF_ROWS_FUNC
==
nodeType
(
pNode
)
&&
((
SIndefRowsFuncLogicNode
*
)
pNode
)
->
isUniqueFunc
;
}
static
SNode
*
rewriteUniqueOptCreateGroupingSet
(
SNode
*
pExpr
)
{
SGroupingSetNode
*
pGroupingSet
=
(
SGroupingSetNode
*
)
nodesMakeNode
(
QUERY_NODE_GROUPING_SET
);
if
(
NULL
==
pGroupingSet
)
{
return
NULL
;
}
pGroupingSet
->
groupingSetType
=
GP_TYPE_NORMAL
;
SExprNode
*
pGroupExpr
=
(
SExprNode
*
)
nodesCloneNode
(
pExpr
);
if
(
TSDB_CODE_SUCCESS
!=
nodesListMakeStrictAppend
(
&
pGroupingSet
->
pParameterList
,
(
SNode
*
)
pGroupExpr
))
{
nodesDestroyNode
((
SNode
*
)
pGroupingSet
);
return
NULL
;
}
return
(
SNode
*
)
pGroupingSet
;
}
static
SNode
*
rewriteUniqueOptCreateFirstFunc
(
SFunctionNode
*
pSelectValue
,
SNode
*
pCol
)
{
SFunctionNode
*
pFunc
=
(
SFunctionNode
*
)
nodesMakeNode
(
QUERY_NODE_FUNCTION
);
if
(
NULL
==
pFunc
)
{
return
NULL
;
}
strcpy
(
pFunc
->
functionName
,
"first"
);
if
(
NULL
!=
pSelectValue
)
{
sprintf
(
pFunc
->
node
.
aliasName
,
"%s"
,
pSelectValue
->
node
.
aliasName
);
}
else
{
sprintf
(
pFunc
->
node
.
aliasName
,
"%s.%p"
,
pFunc
->
functionName
,
pFunc
);
}
int32_t
code
=
nodesListMakeStrictAppend
(
&
pFunc
->
pParameterList
,
nodesCloneNode
(
pCol
));
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
fmGetFuncInfo
(
pFunc
,
NULL
,
0
);
}
if
(
TSDB_CODE_SUCCESS
!=
code
)
{
nodesDestroyNode
((
SNode
*
)
pFunc
);
return
NULL
;
}
return
(
SNode
*
)
pFunc
;
}
static
int32_t
rewriteUniqueOptCreateAgg
(
SIndefRowsFuncLogicNode
*
pIndef
,
SLogicNode
**
pOutput
)
{
SAggLogicNode
*
pAgg
=
(
SAggLogicNode
*
)
nodesMakeNode
(
QUERY_NODE_LOGIC_PLAN_AGG
);
if
(
NULL
==
pAgg
)
{
return
TSDB_CODE_OUT_OF_MEMORY
;
}
TSWAP
(
pAgg
->
node
.
pChildren
,
pIndef
->
node
.
pChildren
);
pAgg
->
node
.
precision
=
pIndef
->
node
.
precision
;
int32_t
code
=
TSDB_CODE_SUCCESS
;
bool
hasSelectPrimaryKey
=
false
;
SNode
*
pPrimaryKey
=
NULL
;
SNode
*
pNode
=
NULL
;
FOREACH
(
pNode
,
pIndef
->
pFuncs
)
{
SFunctionNode
*
pFunc
=
(
SFunctionNode
*
)
pNode
;
SNode
*
pExpr
=
nodesListGetNode
(
pFunc
->
pParameterList
,
0
);
if
(
FUNCTION_TYPE_UNIQUE
==
pFunc
->
funcType
)
{
pPrimaryKey
=
nodesListGetNode
(
pFunc
->
pParameterList
,
1
);
code
=
nodesListMakeStrictAppend
(
&
pAgg
->
pGroupKeys
,
rewriteUniqueOptCreateGroupingSet
(
pExpr
));
}
else
if
(
PRIMARYKEY_TIMESTAMP_COL_ID
==
((
SColumnNode
*
)
pExpr
)
->
colId
)
{
// _select_value(ts) => first(ts)
hasSelectPrimaryKey
=
true
;
code
=
nodesListMakeStrictAppend
(
&
pAgg
->
pAggFuncs
,
rewriteUniqueOptCreateFirstFunc
(
pFunc
,
pExpr
));
}
else
{
// _select_value(other_col)
code
=
nodesListMakeStrictAppend
(
&
pAgg
->
pAggFuncs
,
nodesCloneNode
(
pNode
));
}
if
(
TSDB_CODE_SUCCESS
!=
code
)
{
break
;
}
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
createColumnByRewriteExprs
(
pAgg
->
pGroupKeys
,
&
pAgg
->
node
.
pTargets
);
}
if
(
TSDB_CODE_SUCCESS
==
code
&&
NULL
!=
pAgg
->
pAggFuncs
)
{
code
=
createColumnByRewriteExprs
(
pAgg
->
pAggFuncs
,
&
pAgg
->
node
.
pTargets
);
}
if
(
TSDB_CODE_SUCCESS
==
code
&&
!
hasSelectPrimaryKey
&&
NULL
!=
pAgg
->
pAggFuncs
)
{
code
=
nodesListMakeStrictAppend
(
&
pAgg
->
pAggFuncs
,
rewriteUniqueOptCreateFirstFunc
(
NULL
,
pPrimaryKey
));
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
*
pOutput
=
(
SLogicNode
*
)
pAgg
;
}
else
{
nodesDestroyNode
((
SNode
*
)
pAgg
);
}
return
code
;
}
static
SNode
*
rewriteUniqueOptCreateProjectCol
(
SFunctionNode
*
pFunc
)
{
SColumnNode
*
pCol
=
(
SColumnNode
*
)
nodesMakeNode
(
QUERY_NODE_COLUMN
);
if
(
NULL
==
pCol
)
{
return
NULL
;
}
pCol
->
node
.
resType
=
pFunc
->
node
.
resType
;
if
(
FUNCTION_TYPE_UNIQUE
==
pFunc
->
funcType
)
{
SExprNode
*
pExpr
=
(
SExprNode
*
)
nodesListGetNode
(
pFunc
->
pParameterList
,
0
);
if
(
QUERY_NODE_COLUMN
==
nodeType
(
pExpr
))
{
strcpy
(
pCol
->
tableAlias
,
((
SColumnNode
*
)
pExpr
)
->
tableAlias
);
strcpy
(
pCol
->
colName
,
((
SColumnNode
*
)
pExpr
)
->
colName
);
}
else
{
strcpy
(
pCol
->
colName
,
pExpr
->
aliasName
);
}
}
else
{
strcpy
(
pCol
->
colName
,
pFunc
->
node
.
aliasName
);
}
strcpy
(
pCol
->
node
.
aliasName
,
pFunc
->
node
.
aliasName
);
return
(
SNode
*
)
pCol
;
}
static
int32_t
rewriteUniqueOptCreateProject
(
SIndefRowsFuncLogicNode
*
pIndef
,
SLogicNode
**
pOutput
)
{
SProjectLogicNode
*
pProject
=
(
SProjectLogicNode
*
)
nodesMakeNode
(
QUERY_NODE_LOGIC_PLAN_PROJECT
);
if
(
NULL
==
pProject
)
{
return
TSDB_CODE_OUT_OF_MEMORY
;
}
TSWAP
(
pProject
->
node
.
pTargets
,
pIndef
->
node
.
pTargets
);
pProject
->
node
.
precision
=
pIndef
->
node
.
precision
;
int32_t
code
=
TSDB_CODE_SUCCESS
;
SNode
*
pNode
=
NULL
;
FOREACH
(
pNode
,
pIndef
->
pFuncs
)
{
code
=
nodesListMakeStrictAppend
(
&
pProject
->
pProjections
,
rewriteUniqueOptCreateProjectCol
((
SFunctionNode
*
)
pNode
));
if
(
TSDB_CODE_SUCCESS
!=
code
)
{
break
;
}
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
*
pOutput
=
(
SLogicNode
*
)
pProject
;
}
else
{
nodesDestroyNode
((
SNode
*
)
pProject
);
}
return
code
;
}
static
int32_t
rewriteUniqueOptimizeImpl
(
SOptimizeContext
*
pCxt
,
SLogicSubplan
*
pLogicSubplan
,
SIndefRowsFuncLogicNode
*
pIndef
)
{
SLogicNode
*
pAgg
=
NULL
;
SLogicNode
*
pProject
=
NULL
;
int32_t
code
=
rewriteUniqueOptCreateAgg
(
pIndef
,
&
pAgg
);
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
rewriteUniqueOptCreateProject
(
pIndef
,
&
pProject
);
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
nodesListMakeAppend
(
&
pProject
->
pChildren
,
(
SNode
*
)
pAgg
);
pAgg
->
pParent
=
pProject
;
pAgg
=
NULL
;
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
replaceLogicNode
(
pLogicSubplan
,
(
SLogicNode
*
)
pIndef
,
pProject
);
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
nodesDestroyNode
((
SNode
*
)
pIndef
);
}
else
{
nodesDestroyNode
((
SNode
*
)
pAgg
);
nodesDestroyNode
((
SNode
*
)
pProject
);
}
pCxt
->
optimized
=
true
;
return
code
;
}
static
int32_t
rewriteUniqueOptimize
(
SOptimizeContext
*
pCxt
,
SLogicSubplan
*
pLogicSubplan
)
{
SIndefRowsFuncLogicNode
*
pIndef
=
(
SIndefRowsFuncLogicNode
*
)
optFindPossibleNode
(
pLogicSubplan
->
pNode
,
rewriteUniqueOptMayBeOptimized
);
if
(
NULL
==
pIndef
)
{
return
TSDB_CODE_SUCCESS
;
}
return
rewriteUniqueOptimizeImpl
(
pCxt
,
pLogicSubplan
,
pIndef
);
}
// merge projects
static
bool
mergeProjectsMayBeOptimized
(
SLogicNode
*
pNode
)
{
if
(
QUERY_NODE_LOGIC_PLAN_PROJECT
!=
nodeType
(
pNode
)
||
1
!=
LIST_LENGTH
(
pNode
->
pChildren
))
{
return
false
;
}
SLogicNode
*
pChild
=
(
SLogicNode
*
)
nodesListGetNode
(
pNode
->
pChildren
,
0
);
SLogicNode
*
pChild
=
(
SLogicNode
*
)
nodesListGetNode
(
pNode
->
pChildren
,
0
);
if
(
QUERY_NODE_LOGIC_PLAN_PROJECT
!=
nodeType
(
pChild
)
||
1
<
LIST_LENGTH
(
pChild
->
pChildren
)
||
NULL
!=
pChild
->
pConditions
||
NULL
!=
p
Node
->
pLimit
||
NULL
!=
pNode
->
pSlimit
)
{
NULL
!=
pChild
->
pConditions
||
NULL
!=
p
Child
->
pLimit
||
NULL
!=
pChild
->
pSlimit
)
{
return
false
;
}
return
true
;
...
...
@@ -1425,6 +1680,7 @@ static int32_t mergeProjectsOptimizeImpl(SOptimizeContext* pCxt, SLogicSubplan*
NODES_CLEAR_LIST
(
pChild
->
pChildren
);
}
nodesDestroyNode
((
SNode
*
)
pChild
);
pCxt
->
optimized
=
true
;
return
code
;
}
...
...
@@ -1447,23 +1703,37 @@ static const SOptimizeRule optimizeRuleSet[] = {
{.
pName
=
"MergeProjects"
,
.
optimizeFunc
=
mergeProjectsOptimize
},
{.
pName
=
"EliminateProject"
,
.
optimizeFunc
=
eliminateProjOptimize
},
{.
pName
=
"EliminateSetOperator"
,
.
optimizeFunc
=
eliminateSetOpOptimize
},
{.
pName
=
"RewriteTail"
,
.
optimizeFunc
=
rewriteTailOptimize
}
{.
pName
=
"RewriteTail"
,
.
optimizeFunc
=
rewriteTailOptimize
},
{.
pName
=
"RewriteUnique"
,
.
optimizeFunc
=
rewriteUniqueOptimize
}
};
// clang-format on
static
const
int32_t
optimizeRuleNum
=
(
sizeof
(
optimizeRuleSet
)
/
sizeof
(
SOptimizeRule
));
static
void
dumpLogicSubplan
(
const
char
*
pRuleName
,
SLogicSubplan
*
pSubplan
)
{
char
*
pStr
=
NULL
;
nodesNodeToString
((
SNode
*
)
pSubplan
,
false
,
&
pStr
,
NULL
);
qDebugL
(
"apply optimize %s rule: %s"
,
pRuleName
,
pStr
);
taosMemoryFree
(
pStr
);
}
static
int32_t
applyOptimizeRule
(
SPlanContext
*
pCxt
,
SLogicSubplan
*
pLogicSubplan
)
{
SOptimizeContext
cxt
=
{.
pPlanCxt
=
pCxt
,
.
optimized
=
false
};
bool
optimized
=
false
;
do
{
cxt
.
optimized
=
false
;
optimized
=
false
;
for
(
int32_t
i
=
0
;
i
<
optimizeRuleNum
;
++
i
)
{
cxt
.
optimized
=
false
;
int32_t
code
=
optimizeRuleSet
[
i
].
optimizeFunc
(
&
cxt
,
pLogicSubplan
);
if
(
TSDB_CODE_SUCCESS
!=
code
)
{
return
code
;
}
if
(
cxt
.
optimized
)
{
optimized
=
true
;
dumpLogicSubplan
(
optimizeRuleSet
[
i
].
pName
,
pLogicSubplan
);
}
}
}
while
(
cxt
.
optimized
);
}
while
(
optimized
);
return
TSDB_CODE_SUCCESS
;
}
...
...
source/libs/planner/src/planSpliter.c
浏览文件 @
ed4b2dec
...
...
@@ -1237,7 +1237,7 @@ static const int32_t splitRuleNum = (sizeof(splitRuleSet) / sizeof(SSplitRule));
static
void
dumpLogicSubplan
(
const
char
*
pRuleName
,
SLogicSubplan
*
pSubplan
)
{
char
*
pStr
=
NULL
;
nodesNodeToString
((
SNode
*
)
pSubplan
,
false
,
&
pStr
,
NULL
);
qDebugL
(
"apply %s rule: %s"
,
pRuleName
,
pStr
);
qDebugL
(
"apply
split
%s rule: %s"
,
pRuleName
,
pStr
);
taosMemoryFree
(
pStr
);
}
...
...
source/libs/planner/src/planner.c
浏览文件 @
ed4b2dec
...
...
@@ -85,6 +85,11 @@ int32_t qSetSubplanExecutionNode(SSubplan* subplan, int32_t groupId, SDownstream
return
setSubplanExecutionNode
(
subplan
->
pNode
,
groupId
,
pSource
);
}
int32_t
qClearSubplanExecutionNode
(
SSubplan
*
pSubplan
,
int32_t
groupId
)
{
// todo
return
TSDB_CODE_FAILED
;
}
int32_t
qSubPlanToString
(
const
SSubplan
*
pSubplan
,
char
**
pStr
,
int32_t
*
pLen
)
{
if
(
SUBPLAN_TYPE_MODIFY
==
pSubplan
->
subplanType
&&
NULL
==
pSubplan
->
pNode
)
{
SDataInserterNode
*
insert
=
(
SDataInserterNode
*
)
pSubplan
->
pDataSink
;
...
...
source/libs/planner/test/planBasicTest.cpp
浏览文件 @
ed4b2dec
...
...
@@ -56,6 +56,8 @@ TEST_F(PlanBasicTest, uniqueFunc) {
run
(
"SELECT UNIQUE(c2 + 10) FROM t1 WHERE c1 > 10"
);
run
(
"SELECT UNIQUE(c2 + 10), c2 FROM t1 WHERE c1 > 10"
);
run
(
"SELECT UNIQUE(c2 + 10), ts, c2 FROM t1 WHERE c1 > 10"
);
run
(
"SELECT UNIQUE(c1) a FROM t1 ORDER BY a"
);
...
...
@@ -75,6 +77,8 @@ TEST_F(PlanBasicTest, tailFunc) {
run
(
"SELECT TAIL(c2 + 10, 10, 80) FROM t1 WHERE c1 > 10 LIMIT 5"
);
run
(
"SELECT TAIL(c2 + 10, 10, 80) FROM t1 WHERE c1 > 10 PARTITION BY c1 LIMIT 5"
);
run
(
"SELECT TAIL(c1, 2, 1) FROM st1s1 UNION ALL SELECT c1 FROM st1s2"
);
}
TEST_F
(
PlanBasicTest
,
interpFunc
)
{
...
...
@@ -97,6 +101,16 @@ TEST_F(PlanBasicTest, lastRowFunc) {
run
(
"SELECT LAST_ROW(c1) FROM st1"
);
}
TEST_F
(
PlanBasicTest
,
sampleFunc
)
{
useDb
(
"root"
,
"test"
);
run
(
"SELECT SAMPLE(c1, 10) FROM t1"
);
run
(
"SELECT SAMPLE(c1, 10) FROM st1"
);
run
(
"SELECT SAMPLE(c1, 10) FROM st1 PARTITION BY TBNAME"
);
}
TEST_F
(
PlanBasicTest
,
withoutFrom
)
{
useDb
(
"root"
,
"test"
);
...
...
source/libs/planner/test/planOptimizeTest.cpp
浏览文件 @
ed4b2dec
...
...
@@ -20,7 +20,7 @@ using namespace std;
class
PlanOptimizeTest
:
public
PlannerTestBase
{};
TEST_F
(
PlanOptimizeTest
,
optimizeScanData
)
{
TEST_F
(
PlanOptimizeTest
,
scanPath
)
{
useDb
(
"root"
,
"test"
);
run
(
"SELECT COUNT(*) FROM t1"
);
...
...
@@ -32,7 +32,7 @@ TEST_F(PlanOptimizeTest, optimizeScanData) {
run
(
"SELECT PERCENTILE(c1, 40), COUNT(*) FROM t1"
);
}
TEST_F
(
PlanOptimizeTest
,
ConditionPushDow
n
)
{
TEST_F
(
PlanOptimizeTest
,
pushDownConditio
n
)
{
useDb
(
"root"
,
"test"
);
run
(
"SELECT ts, c1 FROM st1 WHERE tag1 > 4"
);
...
...
@@ -42,9 +42,11 @@ TEST_F(PlanOptimizeTest, ConditionPushDown) {
run
(
"SELECT ts, c1 FROM st1 WHERE tag1 > 4 AND tag2 = 'hello'"
);
run
(
"SELECT ts, c1 FROM st1 WHERE tag1 > 4 AND tag2 = 'hello' AND c1 > 10"
);
run
(
"SELECT ts, c1 FROM (SELECT * FROM st1) WHERE tag1 > 4"
);
}
TEST_F
(
PlanOptimizeTest
,
orderBy
PrimaryKey
)
{
TEST_F
(
PlanOptimizeTest
,
sort
PrimaryKey
)
{
useDb
(
"root"
,
"test"
);
run
(
"SELECT c1 FROM t1 ORDER BY ts"
);
...
...
tests/script/jenkins/basic.txt
浏览文件 @
ed4b2dec
...
...
@@ -23,6 +23,10 @@
# ---- dnode
./test.sh -f tsim/dnode/balance_replica1.sim
./test.sh -f tsim/dnode/balance_replica3.sim
./test.sh -f tsim/dnode/balance1.sim
./test.sh -f tsim/dnode/balance2.sim
./test.sh -f tsim/dnode/balance3.sim
./test.sh -f tsim/dnode/balancex.sim
./test.sh -f tsim/dnode/create_dnode.sim
./test.sh -f tsim/dnode/drop_dnode_has_mnode.sim
./test.sh -f tsim/dnode/drop_dnode_has_qnode_snode.sim
...
...
@@ -30,6 +34,7 @@
./test.sh -f tsim/dnode/drop_dnode_has_vnode_replica3.sim
./test.sh -f tsim/dnode/drop_dnode_has_multi_vnode_replica1.sim
./test.sh -f tsim/dnode/drop_dnode_has_multi_vnode_replica3.sim
./test.sh -f tsim/dnode/offline_reason.sim
./test.sh -f tsim/dnode/redistribute_vgroup_replica1.sim
./test.sh -f tsim/dnode/redistribute_vgroup_replica3_v1_leader.sim
./test.sh -f tsim/dnode/redistribute_vgroup_replica3_v1_follower.sim
...
...
tests/script/
unique
/dnode/balance1.sim
→
tests/script/
tsim
/dnode/balance1.sim
浏览文件 @
ed4b2dec
system sh/stop_dnodes.sh
system sh/deploy.sh -n dnode1 -i 1
system sh/deploy.sh -n dnode2 -i 2
system sh/deploy.sh -n dnode3 -i 3
system sh/deploy.sh -n dnode4 -i 4
system sh/cfg.sh -n dnode1 -c balanceInterval -v 10
system sh/cfg.sh -n dnode2 -c balanceInterval -v 10
system sh/cfg.sh -n dnode3 -c balanceInterval -v 10
system sh/cfg.sh -n dnode4 -c balanceInterval -v 10
system sh/cfg.sh -n dnode1 -c mnodeEqualVnodeNum -v 4
system sh/cfg.sh -n dnode2 -c mnodeEqualVnodeNum -v 4
system sh/cfg.sh -n dnode3 -c mnodeEqualVnodeNum -v 4
system sh/cfg.sh -n dnode4 -c mnodeEqualVnodeNum -v 4
system sh/cfg.sh -n dnode1 -c wallevel -v 2
system sh/cfg.sh -n dnode2 -c wallevel -v 2
system sh/cfg.sh -n dnode3 -c wallevel -v 2
system sh/cfg.sh -n dnode4 -c wallevel -v 2
system sh/cfg.sh -n dnode1 -c wallevel -v 2
system sh/cfg.sh -n dnode2 -c wallevel -v 2
system sh/cfg.sh -n dnode3 -c wallevel -v 2
system sh/cfg.sh -n dnode4 -c wallevel -v 2
system sh/cfg.sh -n dnode1 -c maxTablesPerVnode -v 4
system sh/cfg.sh -n dnode2 -c maxTablesPerVnode -v 4
system sh/cfg.sh -n dnode3 -c maxTablesPerVnode -v 4
system sh/cfg.sh -n dnode4 -c maxTablesPerVnode -v 4
system sh/cfg.sh -n dnode1 -c supportVnodes -v 4
system sh/cfg.sh -n dnode2 -c supportVnodes -v 4
system sh/cfg.sh -n dnode3 -c supportVnodes -v 4
system sh/cfg.sh -n dnode4 -c supportVnodes -v 4
print ========== step1
system sh/exec.sh -n dnode1 -s start
sql connect
sql create database d1
sql create database d1
vgroups 1
sql create table d1.t1 (t timestamp, i int)
sql insert into d1.t1 values(now+1s, 15)
sql insert into d1.t1 values(now+2s, 14)
...
...
@@ -43,35 +21,49 @@ sql insert into d1.t1 values(now+4s, 12)
sql insert into d1.t1 values(now+5s, 11)
sql show dnodes
print dnode1 openVnodes $data
2_1
if $data
2_1
!= 1 then
print dnode1 openVnodes $data
(1)[2]
if $data
(1)[2]
!= 1 then
return -1
endi
print ========== step2
sql create dnode $hostname
2
sql create dnode $hostname
port 7200
system sh/exec.sh -n dnode2 -s start
$x = 0
s
how2:
s
tep2:
$x = $x + 1
sleep 1000
if $x == 20 then
if $x == 10 then
print ====> dnode not ready!
return -1
endi
sql show dnodes
print ===> $data00 $data01 $data02 $data03 $data04 $data05
print ===> $data10 $data11 $data12 $data13 $data14 $data15
if $rows != 2 then
return -1
endi
if $data(1)[4] != ready then
goto step2
endi
if $data(2)[4] != ready then
goto step2
endi
sql balance vgroup
sql show dnodes
print dnode1 openVnodes $data
2_1
print dnode2 openVnodes $data
2_2
if $data
2_1
!= 0 then
goto show2
print dnode1 openVnodes $data
(1)[2]
print dnode2 openVnodes $data
(2)[2]
if $data
(1)[2]
!= 0 then
return -1
endi
if $data
2_2
!= 1 then
goto show2
if $data
(2)[2]
!= 1 then
return -1
endi
print ========== step3
sql create database d2
sql create database d2
vgroups 1
sql create table d2.t2 (t timestamp, i int)
sql insert into d2.t2 values(now+1s, 25)
sql insert into d2.t2 values(now+2s, 24)
...
...
@@ -80,69 +72,67 @@ sql insert into d2.t2 values(now+4s, 22)
sql insert into d2.t2 values(now+5s, 21)
sql show dnodes
print dnode1 openVnodes $data
2_1
print dnode2 openVnodes $data
2_2
if $data
2_1
!= 0 then
print dnode1 openVnodes $data
(1)[2]
print dnode2 openVnodes $data
(2)[2]
if $data
(1)[2]
!= 0 then
return -1
endi
if $data
2_2
!= 2 then
if $data
(2)[2]
!= 2 then
return -1
endi
print ========== step4
sql drop dnode $hostname2
$x = 0
show4:
$x = $x + 1
sleep 2000
if $x == 10 then
return -1
endi
sql drop dnode 2
sql show dnodes
print dnode1 openVnodes $data2_1
print dnode2 openVnodes $data2_2
if $data2_1 != 2 then
goto show4
endi
if $data2_2 != null then
goto show4
print dnode1 openVnodes $data(1)[2]
print dnode2 openVnodes $data(2)[2]
if $data(1)[2] != 2 then
return -1
endi
if $
rows != 1
then
goto show4
if $
data(2)[2] != null
then
return -1
endi
system sh/exec.sh -n dnode2 -s stop -x SIGINT
print ========== step5
sql create dnode $hostname
3
sql create dnode $hostname
port 7300
system sh/exec.sh -n dnode3 -s start
$x = 0
s
how5:
s
tep5:
$x = $x + 1
sleep 1000
if $x == 30 then
if $x == 10 then
print ====> dnode not ready!
return -1
endi
sql show dnodes
print dnode1 openVnodes $data2_1
print dnode2 openVnodes $data2_2
print dnode3 openVnodes $data2_3
if $data2_1 != 0 then
goto show5
print ===> $data00 $data01 $data02 $data03 $data04 $data05
print ===> $data10 $data11 $data12 $data13 $data14 $data15
if $rows != 2 then
return -1
endi
if $data
2_2 != null
then
goto s
how
5
if $data
(1)[4] != ready
then
goto s
tep
5
endi
if $data2_3 != 2 then
goto show5
if $data(3)[4] != ready then
goto step5
endi
sql balance vgroup
sql show dnodes
print dnode1 openVnodes $data(1)[2]
print dnode2 openVnodes $data(3)[2]
if $data(1)[2] != 1 then
return -1
endi
if $data(3)[2] != 1 then
return -1
endi
print ========== step6
sql create database d3
sql create database d3
vgroups 1
sql create table d3.t3 (t timestamp, i int)
sql insert into d3.t3 values(now+1s, 35)
sql insert into d3.t3 values(now+2s, 34)
...
...
@@ -151,52 +141,46 @@ sql insert into d3.t3 values(now+4s, 32)
sql insert into d3.t3 values(now+5s, 31)
sql show dnodes
print dnode1 openVnodes $data2_1
print dnode2 openVnodes $data2_2
print dnode3 openVnodes $data2_3
if $data2_1 != 0 then
return -1
endi
if $data2_2 != null then
print dnode1 openVnodes $data(1)[2]
print dnode2 openVnodes $data(3)[2]
if $data(1)[2] != 1 then
return -1
endi
if $data
2_3 != 3
then
if $data
(3)[2] != 2
then
return -1
endi
print ========== step7
sql create dnode $hostname
4
sql create dnode $hostname
port 7400
system sh/exec.sh -n dnode4 -s start
$x = 0
s
how7:
s
tep7:
$x = $x + 1
sleep 1000
if $x == 20 then
if $x == 10 then
print ====> dnode not ready!
return -1
endi
sql show dnodes
print dnode1 openVnodes $data2_1
print dnode2 openVnodes $data2_2
print dnode3 openVnodes $data2_3
print dnode4 openVnodes $data2_4
if $data2_1 != 0 then
goto show7
print ===> $data00 $data01 $data02 $data03 $data04 $data05
print ===> $data10 $data11 $data12 $data13 $data14 $data15
print ===> $data20 $data21 $data22 $data23 $data24 $data25
if $rows != 3 then
return -1
endi
if $data
2_2 != null
then
goto s
how
7
if $data
(1)[4] != ready
then
goto s
tep
7
endi
if $data
2_3 != 2
then
goto s
how
7
if $data
(3)[4] != ready
then
goto s
tep
7
endi
if $data
2_4 != 1
then
goto s
how
7
if $data
(4)[4] != ready
then
goto s
tep
7
endi
print ========== step8
sql create database d4
sql create database d4
vgroups 1
sql create table d4.t4 (t timestamp, i int)
sql insert into d4.t4 values(now+1s, 45)
sql insert into d4.t4 values(now+2s, 44)
...
...
@@ -205,56 +189,32 @@ sql insert into d4.t4 values(now+4s, 42)
sql insert into d4.t4 values(now+5s, 41)
sql show dnodes
print dnode1 openVnodes $data2_1
print dnode2 openVnodes $data2_2
print dnode3 openVnodes $data2_3
print dnode4 openVnodes $data2_4
if $data2_1 != 0 then
return -1
endi
if $data2_2 != null then
print dnode1 openVnodes $data(1)[2]
print dnode2 openVnodes $data(3)[2]
print dnode2 openVnodes $data(4)[2]
if $data(1)[2] != 1 then
return -1
endi
if $data
2_3
!= 2 then
if $data
(3)[2]
!= 2 then
return -1
endi
if $data
2_4 != 2
then
if $data
(4)[2] != 1
then
return -1
endi
print ========== step9
sql drop dnode $hostname3
$x = 0
show9:
$x = $x + 1
sleep 2000
if $x == 10 then
return -1
endi
sql drop dnode 3
sql show dnodes
print dnode1 openVnodes $data2_1
print dnode2 openVnodes $data2_2
print dnode3 openVnodes $data2_3
print dnode4 openVnodes $data2_4
if $data2_1 != 0 then
goto show9
endi
if $data2_2 != null then
goto show9
endi
if $data2_3 != null then
goto show9
print dnode1 openVnodes $data(1)[2]
print dnode2 openVnodes $data(4)[2]
if $data(1)[2] != 2 then
return -1
endi
if $data
2_4 != 4
then
goto show9
if $data
(4)[2] != 2
then
return -1
endi
system sh/exec.sh -n dnode3 -s stop -x SIGINT
sql reset query cache
sleep 100
...
...
tests/script/
unique/dnode/m3
.sim
→
tests/script/
tsim/dnode/balance2
.sim
浏览文件 @
ed4b2dec
system sh/stop_dnodes.sh
system sh/deploy.sh -n dnode1 -i 1
system sh/deploy.sh -n dnode2 -i 2
system sh/deploy.sh -n dnode3 -i 3
system sh/deploy.sh -n dnode4 -i 4
system sh/deploy.sh -n dnode5 -i 5
system sh/cfg.sh -n dnode1 -c balanceInterval -v 10
system sh/cfg.sh -n dnode2 -c balanceInterval -v 10
system sh/cfg.sh -n dnode3 -c balanceInterval -v 10
system sh/cfg.sh -n dnode4 -c balanceInterval -v 10
system sh/cfg.sh -n dnode5 -c balanceInterval -v 10
system sh/cfg.sh -n dnode1 -c mnodeEqualVnodeNum -v 4
system sh/cfg.sh -n dnode2 -c mnodeEqualVnodeNum -v 4
system sh/cfg.sh -n dnode3 -c mnodeEqualVnodeNum -v 4
system sh/cfg.sh -n dnode4 -c mnodeEqualVnodeNum -v 4
system sh/cfg.sh -n dnode5 -c mnodeEqualVnodeNum -v 4
system sh/cfg.sh -n dnode1 -c maxTablesPerVnode -v 4
system sh/cfg.sh -n dnode2 -c maxTablesPerVnode -v 4
system sh/cfg.sh -n dnode3 -c maxTablesPerVnode -v 4
system sh/cfg.sh -n dnode4 -c maxTablesPerVnode -v 4
system sh/cfg.sh -n dnode5 -c maxTablesPerVnode -v 4
system sh/cfg.sh -n dnode1 -c supportVnodes -v 4
system sh/cfg.sh -n dnode2 -c supportVnodes -v 4
system sh/cfg.sh -n dnode3 -c supportVnodes -v 4
system sh/cfg.sh -n dnode4 -c supportVnodes -v 4
system sh/cfg.sh -n dnode5 -c supportVnodes -v 4
print ========== step1
system sh/exec.sh -n dnode1 -s start
sql connect
sql create dnode $hostname2
sql create dnode $hostname3
sql create dnode $hostname4
sql create dnode $hostname port 7200
sql create dnode $hostname port 7300
system sh/exec.sh -n dnode2 -s start
system sh/exec.sh -n dnode3 -s start
system sh/exec.sh -n dnode4 -s start
$x = 0
step1:
$x = $x + 1
sleep 1000
if $x == 10 then
print ====> dnode not ready!
return -1
endi
sql show dnodes
print dnode1 $data4_1
print dnode2 $data4_2
print dnode3 $data4_3
print dnode4 $data4_4
if $data4_1 != ready then
goto step1
print ===> $data00 $data01 $data02 $data03 $data04 $data05
print ===> $data10 $data11 $data12 $data13 $data14 $data15
print ===> $data20 $data21 $data22 $data23 $data24 $data25
if $rows != 3 then
return -1
endi
if $data
4_2
!= ready then
if $data
(1)[4]
!= ready then
goto step1
endi
if $data
4_3
!= ready then
if $data
(2)[4]
!= ready then
goto step1
endi
if $data
4_4
!= ready then
if $data
(3)[4]
!= ready then
goto step1
endi
print ========== step2
sql create database d1 replica 3
sql create database d1 replica 3 vgroups 1
sql create table d1.t1 (t timestamp, i int)
sql insert into d1.t1 values(now+1s, 15)
sql insert into d1.t1 values(now+2s, 14)
...
...
@@ -71,7 +53,7 @@ sql insert into d1.t1 values(now+3s, 13)
sql insert into d1.t1 values(now+4s, 12)
sql insert into d1.t1 values(now+5s, 11)
sql create database d2 replica 3
sql create database d2 replica 3
vgroups 1
sql create table d2.t2 (t timestamp, i int)
sql insert into d2.t2 values(now+1s, 25)
sql insert into d2.t2 values(now+2s, 24)
...
...
@@ -79,7 +61,7 @@ sql insert into d2.t2 values(now+3s, 23)
sql insert into d2.t2 values(now+4s, 22)
sql insert into d2.t2 values(now+5s, 21)
sql create database d3 replica 3
sql create database d3 replica 3
vgroups 1
sql create table d3.t3 (t timestamp, i int)
sql insert into d3.t3 values(now+1s, 35)
sql insert into d3.t3 values(now+2s, 34)
...
...
@@ -87,7 +69,7 @@ sql insert into d3.t3 values(now+3s, 33)
sql insert into d3.t3 values(now+4s, 32)
sql insert into d3.t3 values(now+5s, 31)
sql create database d4 replica 3
sql create database d4 replica 3
vgroups 1
sql create table d4.t4 (t timestamp, i int)
sql insert into d4.t4 values(now+1s, 45)
sql insert into d4.t4 values(now+2s, 44)
...
...
@@ -96,190 +78,129 @@ sql insert into d4.t4 values(now+4s, 42)
sql insert into d4.t4 values(now+5s, 41)
print ========== step2.1
sql show dnodes
print dnode1 openVnodes $data2_1
print dnode2 openVnodes $data2_2
print dnode3 openVnodes $data2_3
print dnode4 openVnodes $data2_4
if $data2_1 != 0 then
print dnode1 openVnodes $data(1)[2]
print dnode2 openVnodes $data(2)[2]
print dnode3 openVnodes $data(3)[2]
if $data(1)[2] != 4 then
return -1
endi
if $data
2_2
!= 4 then
if $data
(2)[2]
!= 4 then
return -1
endi
if $data2_3 != 4 then
return -1
endi
if $data2_4 != 4 then
return -1
endi
sql show d1.vgroups;
print d1.vgroups $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09
if $data04 != 4 then
return -1
endi
sql show d2.vgroups;
print d2.vgroups $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09
if $data04 != 3 then
return -1
endi
sql show d3.vgroups;
print d3.vgroups $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09
if $data04 != 2 then
return -1
endi
sql show d4.vgroups;
print d4.vgroups $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09
if $data04 != 4 then
if $data(3)[2] != 4 then
return -1
endi
print ========== step3
sql create dnode $hostname5
sql create dnode $hostname port 7400
sql create dnode $hostname port 7500
system sh/exec.sh -n dnode4 -s start
system sh/exec.sh -n dnode5 -s start
$x = 0
s
how3:
s
tep3:
$x = $x + 1
sleep 1000
if $x == 40 then
if $x == 10 then
print ====> dnode not ready!
return -1
endi
sql show dnodes
print dnode1 openVnodes $data2_1
print dnode2 openVnodes $data2_2
print dnode3 openVnodes $data2_3
print dnode4 openVnodes $data2_4
print dnode5 openVnodes $data2_5
if $data2_2 != 3 then
goto show3
print ===> $data00 $data01 $data02 $data03 $data04 $data05
print ===> $data10 $data11 $data12 $data13 $data14 $data15
print ===> $data20 $data21 $data22 $data23 $data24 $data25
print ===> $data30 $data31 $data32 $data33 $data34 $data35
print ===> $data40 $data41 $data42 $data43 $data44 $data45
if $rows != 5 then
return -1
endi
if $data
2_3 != 3
then
goto show
3
if $data
(1)[4] != ready
then
goto step
3
endi
if $data
2_4 != 3
then
goto show
3
if $data
(2)[4] != ready
then
goto step
3
endi
if $data
2_5 != 3
then
goto show
3
if $data
(3)[4] != ready
then
goto step
3
endi
sql show d1.vgroups;
print d1.vgroups $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09
if $data04 != 5 then
return -1
if $data(4)[4] != ready then
goto step3
endi
if $data
03 != 3
then
goto show
3
if $data
(5)[4] != ready
then
goto step
3
endi
sql show d2.vgroups;
print d2.vgroups $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09
if $data04 != 5 then
sql balance vgroup
sql show dnodes
print dnode1 openVnodes $data(1)[2]
print dnode3 openVnodes $data(2)[2]
print dnode3 openVnodes $data(3)[2]
print dnode4 openVnodes $data(4)[2]
print dnode5 openVnodes $data(5)[2]
if $data(1)[2] != 2 then
return -1
endi
if $data03 != 3 then
goto show3
endi
sql show d3.vgroups;
print d3.vgroups $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09
if $data04 != 2 then
if $data(2)[2] != 3 then
return -1
endi
if $data
03
!= 3 then
goto show3
if $data
(3)[2]
!= 3 then
return -1
endi
sql show d4.vgroups;
print d4.vgroups $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09
if $data04 != 4 then
if $data(4)[2] != 2 then
return -1
endi
if $data
03 != 3
then
goto show3
if $data
(5)[2] != 2
then
return -1
endi
print ========== step4
sql drop dnode $hostname2
$x = 0
show4:
$x = $x + 1
sleep 1000
if $x == 40 then
return -1
endi
sql drop dnode 2
sql show dnodes
print dnode1 openVnodes $data2_1
print dnode2 openVnodes $data2_2
print dnode3 openVnodes $data2_3
print dnode4 openVnodes $data2_4
print dnode5 openVnodes $data2_5
if $data2_2 != null then
goto show4
endi
if $data2_3 != 4 then
goto show4
endi
if $data2_4 != 4 then
goto show4
endi
if $data2_5 != 4 then
goto show4
endi
sql show d1.vgroups;
print d1.vgroups $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09
if $data04 != 5 then
print dnode1 openVnodes $data(1)[2]
print dnode3 openVnodes $data(3)[2]
print dnode4 openVnodes $data(4)[2]
print dnode5 openVnodes $data(5)[2]
if $data(1)[2] != 2 then
return -1
endi
if $data
03
!= 3 then
goto show4
if $data
(3)[2]
!= 3 then
return -1
endi
sql show d2.vgroups;
print d2.vgroups $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09
if $data04 != 3 then
if $data(4)[2] != 4 then
return -1
endi
if $data
03
!= 3 then
goto show4
if $data
(5)[2]
!= 3 then
return -1
endi
sql show d3.vgroups;
print d3.vgroups $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09
if $data04 != 4 then
system sh/exec.sh -n dnode2 -s stop -x SIGINT
print ========== step5
sql drop dnode 3
sql show dnodes
print dnode1 openVnodes $data(1)[2]
print dnode3 openVnodes $data(3)[2]
print dnode4 openVnodes $data(4)[2]
print dnode5 openVnodes $data(5)[2]
if $data(1)[2] != 4 then
return -1
endi
if $data
03 != 3
then
goto show4
if $data
(3)[2] != null
then
return -1
endi
sql show d4.vgroups;
print d4.vgroups $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09
if $data04 != 4 then
if $data(4)[2] != 4 then
return -1
endi
if $data
03 != 3
then
goto show4
if $data
(5)[2] != 4
then
return -1
endi
sql reset query cache
sleep 100
system sh/exec.sh -n dnode3 -s stop -x SIGINT
print ========== step
5
print ========== step
6
sql select * from d1.t1 order by t desc
print $data01 $data11 $data21 $data31 $data41
if $data01 != 11 then
...
...
tests/script/
unique
/dnode/balance3.sim
→
tests/script/
tsim
/dnode/balance3.sim
浏览文件 @
ed4b2dec
system sh/stop_dnodes.sh
system sh/deploy.sh -n dnode1 -i 1
system sh/deploy.sh -n dnode2 -i 2
system sh/deploy.sh -n dnode3 -i 3
system sh/deploy.sh -n dnode4 -i 4
system sh/deploy.sh -n dnode5 -i 5
system sh/deploy.sh -n dnode6 -i 6
system sh/cfg.sh -n dnode1 -c mnodeEqualVnodeNum -v 4
system sh/cfg.sh -n dnode2 -c mnodeEqualVnodeNum -v 4
system sh/cfg.sh -n dnode3 -c mnodeEqualVnodeNum -v 4
system sh/cfg.sh -n dnode4 -c mnodeEqualVnodeNum -v 4
system sh/cfg.sh -n dnode5 -c mnodeEqualVnodeNum -v 4
system sh/cfg.sh -n dnode6 -c mnodeEqualVnodeNum -v 4
system sh/cfg.sh -n dnode1 -c wallevel -v 1
system sh/cfg.sh -n dnode2 -c wallevel -v 1
system sh/cfg.sh -n dnode3 -c wallevel -v 1
system sh/cfg.sh -n dnode4 -c wallevel -v 1
system sh/cfg.sh -n dnode5 -c wallevel -v 1
system sh/cfg.sh -n dnode6 -c wallevel -v 1
system sh/cfg.sh -n dnode1 -c maxTablesPerVnode -v 4
system sh/cfg.sh -n dnode2 -c maxTablesPerVnode -v 4
system sh/cfg.sh -n dnode3 -c maxTablesPerVnode -v 4
system sh/cfg.sh -n dnode4 -c maxTablesPerVnode -v 4
system sh/cfg.sh -n dnode5 -c maxTablesPerVnode -v 4
system sh/cfg.sh -n dnode6 -c maxTablesPerVnode -v 4
system sh/cfg.sh -n dnode1 -c supportVnodes -v 4
system sh/cfg.sh -n dnode2 -c supportVnodes -v 4
system sh/cfg.sh -n dnode3 -c supportVnodes -v 4
system sh/cfg.sh -n dnode4 -c supportVnodes -v 4
system sh/cfg.sh -n dnode5 -c supportVnodes -v 4
system sh/cfg.sh -n dnode6 -c supportVnodes -v 4
print ========== step1
system sh/exec.sh -n dnode1 -s start
sql connect
sql create dnode $hostname
2
sql create dnode $hostname
3
sql create dnode $hostname
4
sql create dnode $hostname
port 7200
sql create dnode $hostname
port 7300
sql create dnode $hostname
port 7400
system sh/exec.sh -n dnode2 -s start
system sh/exec.sh -n dnode3 -s start
system sh/exec.sh -n dnode4 -s start
$x = 0
step1:
$x = $x + 1
sleep 1000
if $x == 10 then
print ====> dnode not ready!
return -1
endi
sql show dnodes
print dnode1 $data4_1
print dnode2 $data4_2
print dnode3 $data4_3
print dnode4 $data4_4
if $data4_1 != ready then
print ===> $data00 $data01 $data02 $data03 $data04 $data05
print ===> $data10 $data11 $data12 $data13 $data14 $data15
print ===> $data20 $data21 $data22 $data23 $data24 $data25
print ===> $data30 $data31 $data32 $data33 $data34 $data35
if $rows != 4 then
return -1
endi
if $data(1)[4] != ready then
goto step1
endi
if $data
4_2
!= ready then
if $data
(2)[4]
!= ready then
goto step1
endi
if $data
4_3
!= ready then
if $data
(3)[4]
!= ready then
goto step1
endi
if $data
4_4
!= ready then
if $data
(4)[4]
!= ready then
goto step1
endi
sql create database d1 replica 3
sql create database d1 replica 3
vgroups 1
sql create table d1.t1 (t timestamp, i int)
sql insert into d1.t1 values(now+1s, 15)
sql insert into d1.t1 values(now+2s, 14)
...
...
@@ -73,7 +60,7 @@ sql insert into d1.t1 values(now+3s, 13)
sql insert into d1.t1 values(now+4s, 12)
sql insert into d1.t1 values(now+5s, 11)
sql create database d2 replica 3
sql create database d2 replica 3
vgroups 1
sql create table d2.t2 (t timestamp, i int)
sql insert into d2.t2 values(now+1s, 25)
sql insert into d2.t2 values(now+2s, 24)
...
...
@@ -82,92 +69,99 @@ sql insert into d2.t2 values(now+4s, 22)
sql insert into d2.t2 values(now+5s, 21)
sql show dnodes
print dnode1 openVnodes $data2_1
print dnode2 openVnodes $data2_2
print dnode3 openVnodes $data2_3
print dnode4 openVnodes $data2_4
if $data2_1 != 0 then
print dnode1 openVnodes $data(1)[2]
print dnode2 openVnodes $data(2)[2]
print dnode3 openVnodes $data(3)[2]
print dnode4 openVnodes $data(4)[2]
if $data(1)[2] != 0 then
return -1
endi
if $data
2_2
!= 2 then
if $data
(2)[2]
!= 2 then
return -1
endi
if $data
2_3
!= 2 then
if $data
(3)[2]
!= 2 then
return -1
endi
if $data
2_4
!= 2 then
if $data
(4)[2]
!= 2 then
return -1
endi
print ========== step2
sql drop dnode $hostname2
$x = 0
show2:
$x = $x + 1
sleep 1000
if $x == 20 then
return -1
endi
sql drop dnode 2
sql show dnodes
print dnode1 openVnodes $data2_1
print dnode2 openVnodes $data2_2
print dnode3 openVnodes $data2_3
print dnode4 openVnodes $data2_4
if $data2_1 != 2 then
goto show2
print dnode1 openVnodes $data(1)[2]
print dnode2 openVnodes $data(2)[2]
print dnode3 openVnodes $data(3)[2]
print dnode4 openVnodes $data(4)[2]
if $data(1)[2] != 2 then
return -1
endi
if $data
2_2
!= null then
goto show2
if $data
(2)[2]
!= null then
return -1
endi
if $data
2_3
!= 2 then
goto show2
if $data
(3)[2]
!= 2 then
return -1
endi
if $data
2_4
!= 2 then
goto show2
if $data
(4)[2]
!= 2 then
return -1
endi
system sh/exec.sh -n dnode2 -s stop -x SIGINT
print ========== step
sql create dnode $hostname5
print ========== step3
sql create dnode $hostname port 7500
system sh/exec.sh -n dnode5 -s start
$x = 0
s
how3:
s
tep3:
$x = $x + 1
sleep 1000
if $x == 60 then
if $x == 10 then
print ====> dnode not ready!
return -1
endi
sql show dnodes
print dnode1 openVnodes $data2_1
print dnode2 openVnodes $data2_2
print dnode3 openVnodes $data2_3
print dnode4 openVnodes $data2_4
print dnode5 openVnodes $data2_5
if $data2_1 != 0 then
goto show3
print ===> $data00 $data01 $data02 $data03 $data04 $data05
print ===> $data10 $data11 $data12 $data13 $data14 $data15
print ===> $data20 $data21 $data22 $data23 $data24 $data25
print ===> $data30 $data31 $data32 $data33 $data34 $data35
if $rows != 4 then
return -1
endi
if $data(1)[4] != ready then
goto step3
endi
if $data(3)[4] != ready then
goto step3
endi
if $data(4)[4] != ready then
goto step3
endi
if $data(5)[4] != ready then
goto step3
endi
if $data2_2 != null then
goto show3
sql balance vgroup
sql show dnodes
print dnode1 openVnodes $data(1)[2]
print dnode3 openVnodes $data(3)[2]
print dnode4 openVnodes $data(4)[2]
print dnode5 openVnodes $data(5)[2]
if $data(1)[2] != 1 then
return -1
endi
if $data
2_3
!= 2 then
goto show3
if $data
(3)[2]
!= 2 then
return -1
endi
if $data
2_4
!= 2 then
goto show3
if $data
(4)[2]
!= 2 then
return -1
endi
if $data
2_5 != 2
then
goto show3
if $data
(5)[2] != 1
then
return -1
endi
print ========== step4
sql create database d3 replica 3
sql create database d3 replica 3
vgroups 1
sql create table d3.t3 (t timestamp, i int)
sql insert into d3.t3 values(now+1s, 35)
sql insert into d3.t3 values(now+2s, 34)
...
...
@@ -175,97 +169,106 @@ sql insert into d3.t3 values(now+3s, 33)
sql insert into d3.t3 values(now+4s, 32)
sql insert into d3.t3 values(now+5s, 31)
$x = 0
show4:
$x = $x + 1
sleep 1000
if $x == 30 then
return -1
endi
sql show dnodes
print dnode1 openVnodes $data2_1
print dnode2 openVnodes $data2_2
print dnode3 openVnodes $data2_3
print dnode4 openVnodes $data2_4
print dnode5 openVnodes $data2_5
if $data2_1 != 0 then
goto show4
endi
if $data2_2 != null then
goto show4
print dnode1 openVnodes $data(1)[2]
print dnode3 openVnodes $data(3)[2]
print dnode4 openVnodes $data(4)[2]
print dnode5 openVnodes $data(5)[2]
if $data(1)[2] != 1 then
return -1
endi
if $data
2_3
!= 3 then
goto show4
if $data
(3)[2]
!= 3 then
return -1
endi
if $data
2_4
!= 3 then
goto show4
if $data
(4)[2]
!= 3 then
return -1
endi
if $data
2_5 != 3
then
goto show4
if $data
(5)[2] != 2
then
return -1
endi
print ========== step5
sql create dnode $hostname
6
sql create dnode $hostname
port 7600
system sh/exec.sh -n dnode6 -s start
$x = 0
s
how5:
s
tep5:
$x = $x + 1
sleep 1000
if $x == 20 then
if $x == 10 then
print ====> dnode not ready!
return -1
endi
sql show dnodes
print dnode1 openVnodes $data2_1
print dnode6 openVnodes $data2_6
print dnode3 openVnodes $data2_3
print dnode4 openVnodes $data2_4
print dnode5 openVnodes $data2_5
if $data2_1 != 0 then
goto show5
print ===> $data00 $data01 $data02 $data03 $data04 $data05
print ===> $data10 $data11 $data12 $data13 $data14 $data15
print ===> $data20 $data21 $data22 $data23 $data24 $data25
print ===> $data30 $data31 $data32 $data33 $data34 $data35
print ===> $data40 $data41 $data42 $data43 $data44 $data45
if $rows != 5 then
return -1
endi
if $data2_6 != 2 then
goto show5
if $data(1)[4] != ready then
goto step5
endi
if $data(3)[4] != ready then
goto step5
endi
if $data(4)[4] != ready then
goto step5
endi
if $data(5)[4] != ready then
goto step5
endi
if $data(6)[4] != ready then
goto step5
endi
sleep 8000
print ========== step6
sql drop dnode $hostname3
$x = 0
show6:
$x = $x + 1
sleep 1000
if $x == 30 then
sql balance vgroup
sql show dnodes
print dnode1 openVnodes $data(1)[2]
print dnode3 openVnodes $data(3)[2]
print dnode4 openVnodes $data(4)[2]
print dnode5 openVnodes $data(5)[2]
print dnode5 openVnodes $data(6)[2]
if $data(1)[2] != 1 then
return -1
endi
endi
if $data(3)[2] != 2 then
return -1
endi
if $data(4)[2] != 2 then
return -1
endi
if $data(5)[2] != 2 then
return -1
endi
if $data(6)[2] != 2 then
return -1
endi
print ========== step6
sql drop dnode 3
sql show dnodes
print dnode1 openVnodes $data2_1
print dnode6 openVnodes $data2_6
print dnode3 openVnodes $data2_3
print dnode4 openVnodes $data2_4
print dnode5 openVnodes $data2_5
if $data2_1 != 0 then
goto show6
print dnode1 openVnodes $data(1)[2]
print dnode3 openVnodes $data(3)[2]
print dnode4 openVnodes $data(4)[2]
print dnode5 openVnodes $data(5)[2]
print dnode5 openVnodes $data(6)[2]
if $data(1)[2] != 2 then
return -1
endi
if $data
2_6 != 3
then
goto show6
if $data
(3)[2] != null
then
return -1
endi
if $data
2_3 != null
then
goto show6
if $data
(4)[2] != 2
then
return -1
endi
if $data
2_4
!= 3 then
goto show6
if $data
(5)[2]
!= 3 then
return -1
endi
if $data
2_5 != 3
then
goto show6
if $data
(6)[2] != 2
then
return -1
endi
system sh/exec.sh -n dnode3 -s stop -x SIGINT
...
...
tests/script/
unique/dnode/remove1
.sim
→
tests/script/
tsim/dnode/balancex
.sim
浏览文件 @
ed4b2dec
system sh/stop_dnodes.sh
system sh/deploy.sh -n dnode1 -i 1
system sh/deploy.sh -n dnode2 -i 2
system sh/deploy.sh -n dnode3 -i 3
system sh/deploy.sh -n dnode4 -i 4
system sh/cfg.sh -n dnode1 -c mnodeEqualVnodeNum -v 4
system sh/cfg.sh -n dnode2 -c mnodeEqualVnodeNum -v 4
system sh/cfg.sh -n dnode3 -c mnodeEqualVnodeNum -v 4
system sh/cfg.sh -n dnode4 -c mnodeEqualVnodeNum -v 4
system sh/cfg.sh -n dnode1 -c wallevel -v 1
system sh/cfg.sh -n dnode2 -c wallevel -v 1
system sh/cfg.sh -n dnode3 -c wallevel -v 1
system sh/cfg.sh -n dnode4 -c wallevel -v 1
system sh/cfg.sh -n dnode1 -c maxTablesPerVnode -v 4
system sh/cfg.sh -n dnode2 -c maxTablesPerVnode -v 4
system sh/cfg.sh -n dnode3 -c maxTablesPerVnode -v 4
system sh/cfg.sh -n dnode4 -c maxTablesPerVnode -v 4
system sh/cfg.sh -n dnode1 -c supportVnodes -v 4
system sh/cfg.sh -n dnode2 -c supportVnodes -v 4
system sh/cfg.sh -n dnode3 -c supportVnodes -v 4
system sh/cfg.sh -n dnode4 -c supportVnodes -v 4
print ========== step1
system sh/exec.sh -n dnode1 -s start
sql connect
sql create database d1
sql create database d1
vgroups 1
sql create table d1.t1 (t timestamp, i int)
sql insert into d1.t1 values(now+1s, 15)
sql insert into d1.t1 values(now+2s, 14)
...
...
@@ -32,7 +20,7 @@ sql insert into d1.t1 values(now+3s, 13)
sql insert into d1.t1 values(now+4s, 12)
sql insert into d1.t1 values(now+5s, 11)
sql create database d2
sql create database d2
vgroups 1
sql create table d2.t2 (t timestamp, i int)
sql insert into d2.t2 values(now+1s, 25)
sql insert into d2.t2 values(now+2s, 24)
...
...
@@ -41,36 +29,59 @@ sql insert into d2.t2 values(now+4s, 22)
sql insert into d2.t2 values(now+5s, 21)
sql show dnodes
print dnode1 openVnodes $data
2_1
if $data
2_1
!= 2 then
print dnode1 openVnodes $data
(1)[2]
if $data
(1)[2]
!= 2 then
return -1
endi
print ========== step2
sql create dnode $hostname2
sql create dnode $hostname port 7200
sql create dnode $hostname port 7300
system sh/exec.sh -n dnode2 -s start
system sh/exec.sh -n dnode3 -s start
$x = 0
step2:
$x = $x + 1
sleep 1000
if $x == 10 then
print ====> dnode not ready!
return -1
endi
sql show dnodes
print dnode1 $data4_1
print dnode2 $data4_2
print dnode3 $data4_3
print dnode4 $data4_4
if $data4_1 != ready then
print ===> $data00 $data01 $data02 $data03 $data04 $data05
print ===> $data10 $data11 $data12 $data13 $data14 $data15
print ===> $data20 $data21 $data22 $data23 $data24 $data25
if $rows != 3 then
return -1
endi
if $data(1)[4] != ready then
goto step2
endi
if $data(2)[4] != ready then
goto step2
endi
if $data
4_2
!= ready then
if $data
(3)[4]
!= ready then
goto step2
endi
sql create database d3 replica 2
sql balance vgroup
sql show dnodes
print dnode1 openVnodes $data(1)[2]
print dnode2 openVnodes $data(2)[2]
print dnode2 openVnodes $data(3)[2]
if $data(1)[2] != 0 then
return -1
endi
if $data(2)[2] != 1 then
return -1
endi
if $data(3)[2] != 1 then
return -1
endi
print ========== step3
sql create database d3 replica 3 vgroups 1
sql create table d3.t3 (t timestamp, i int)
sql insert into d3.t3 values(now+1s, 35)
sql insert into d3.t3 values(now+2s, 34)
...
...
@@ -78,90 +89,96 @@ sql insert into d3.t3 values(now+3s, 33)
sql insert into d3.t3 values(now+4s, 32)
sql insert into d3.t3 values(now+5s, 31)
$x = 0
show2:
$x = $x + 1
sleep 2000
if $x == 10 then
return -1
endi
sql show dnodes
print dnode1 openVnodes $data2_1
print dnode2 openVnodes $data2_2
if $data2_1 != 1 then
goto show2
print dnode1 openVnodes $data(1)[2]
print dnode2 openVnodes $data(2)[2]
print dnode2 openVnodes $data(3)[2]
if $data(1)[2] != 1 then
return -1
endi
if $data(2)[2] != 2 then
return -1
endi
if $data
2_2 != 3
then
goto show2
if $data
(3)[2] != 2
then
return -1
endi
print ========== step3
sql create dnode $hostname port 7400
system sh/exec.sh -n dnode4 -s start
$x = 0
s
how3:
s
tep3:
$x = $x + 1
sleep 1000
if $x == 20 then
if $x == 10 then
print ====> dnode not ready!
return -1
endi
sql show dnodes
print dnode1 openVnodes $data2_1
print dnode2 openVnodes $data2_2
print ========== step4
sql create dnode $hostname3
system sh/exec.sh -n dnode3 -s start
sql drop dnode $hostname2
$x = 0
show4:
$x = $x + 1
sleep 1000
if $x == 20 then
print ===> $data00 $data01 $data02 $data03 $data04 $data05
print ===> $data10 $data11 $data12 $data13 $data14 $data15
print ===> $data20 $data21 $data22 $data23 $data24 $data25
print ===> $data30 $data31 $data32 $data33 $data34 $data35
if $rows != 4 then
return -1
endi
endi
if $data(1)[4] != ready then
goto step3
endi
if $data(2)[4] != ready then
goto step3
endi
if $data(3)[4] != ready then
goto step3
endi
if $data(4)[4] != ready then
goto step3
endi
sql balance vgroup
sql show dnodes
print dnode1 openVnodes $data2_1
print dnode2 openVnodes $data2_2
print dnode3 openVnodes $data2_3
if $data2_2 != null then
goto show4
print dnode1 openVnodes $data(1)[2]
print dnode2 openVnodes $data(2)[2]
print dnode2 openVnodes $data(3)[2]
print dnode2 openVnodes $data(4)[2]
if $data(1)[2] != 0 then
return -1
endi
if $data(2)[2] != 2 then
return -1
endi
if $data(3)[2] != 2 then
return -1
endi
if $data(4)[2] != 1 then
return -1
endi
system sh/exec.sh -n dnode2 -s stop -x SIGINT
print ========== step5
sql create dnode $hostname4
system sh/exec.sh -n dnode4 -s start
$x = 0
show5:
$x = $x + 1
sleep 1000
if $x == 20 then
return -1
endi
sql drop dnode 2
sql show dnodes
print dnode1 openVnodes $data
2_1
print dnode2 openVnodes $data
2_2
print dnode
3 openVnodes $data2_3
print dnode
4 openVnodes $data2_4
if $data
2_1 != 0
then
goto show5
print dnode1 openVnodes $data
(1)[2]
print dnode2 openVnodes $data
(2)[2]
print dnode
2 openVnodes $data(3)[2]
print dnode
2 openVnodes $data(4)[2]
if $data
(1)[2] != 1
then
return -1
endi
if $data
2_2
!= null then
goto show5
if $data
(2)[2]
!= null then
return -1
endi
if $data
2_3
!= 2 then
goto show5
if $data
(3)[2]
!= 2 then
return -1
endi
if $data
2_4
!= 2 then
goto show5
if $data
(4)[2]
!= 2 then
return -1
endi
system sh/exec.sh -n dnode2 -s stop -x SIGINT
sql reset query cache
sleep 100
print ========== step6
sql select * from d1.t1 order by t desc
print $data01 $data11 $data21 $data31 $data41
...
...
tests/script/
unique/dnode/
reason.sim
→
tests/script/
tsim/dnode/offline_
reason.sim
浏览文件 @
ed4b2dec
system sh/stop_dnodes.sh
system sh/deploy.sh -n dnode1 -i 1
system sh/deploy.sh -n dnode2 -i 2
print ========== step1
system sh/exec.sh -n dnode1 -s start
sql connect
sql create dnode $hostname
2
sql create dnode $hostname
port 7200
sql show dnodes
print dnode1 off: $data7_1
print dnode2 off: $data7_2
if $data7_2 != @status not received@ then
print dnode1 off: $data(1)[6]
print dnode2 off: $data(2)[6]
if $data(2)[6] != @status not received@ then
return -1
endi
...
...
@@ -19,22 +19,24 @@ print ========== step2
system sh/exec.sh -n dnode2 -s start
$x = 0
step
1:
step
2:
$x = $x + 1
sleep 1000
if $x == 10 then
print ====> dnode not ready!
return -1
endi
sql show dnodes
print dnode1 $data4_1
print dnode2 $data4_2
if $data4_1 != ready then
goto step1
print ===> $data00 $data01 $data02 $data03 $data04 $data05
print ===> $data10 $data11 $data12 $data13 $data14 $data15
if $rows != 2 then
return -1
endi
if $data4_2 != ready then
goto step1
if $data(1)[4] != ready then
goto step2
endi
if $data(2)[4] != ready then
goto step2
endi
print ========== step3
...
...
@@ -48,30 +50,22 @@ step3:
return -1
endi
sql show dnodes
print dnode1 off: $data
7_1
print dnode2 off: $data
7_2
if $data
7_2
!= @status msg timeout@ then
print dnode1 off: $data
(1)[6]
print dnode2 off: $data
(2)[6]
if $data
(2)[6]
!= @status msg timeout@ then
goto step3
endi
print ========== step4
sql drop dnode $hostname2
$x = 0
step4:
$x = $x + 1
sleep 1000
if $x == 10 then
return -1
endi
sql drop dnode 2
sql show dnodes
if $rows != 1 then
goto step4
return -1
endi
print ========== step5
system sh/exec.sh -n dnode2 -s start
sql create dnode $hostname
2
sql create dnode $hostname
port 7200
$x = 0
step5:
...
...
@@ -82,17 +76,17 @@ step5:
endi
sql show dnodes
print dnode1 off: $data
7_1
print dnode2 off: $data
7_3
if $data
7_3
!= @dnodeId not match@ then
print dnode1 off: $data
(1)[6]
print dnode2 off: $data
(3)[6]
if $data
(3)[6]
!= @dnodeId not match@ then
goto step5
endi
print ========== step6
system sh/deploy.sh -n dnode4 -i 4
system sh/cfg.sh -n dnode4 -c
mnodeEqualVnodeNum -v 3
system sh/cfg.sh -n dnode4 -c
statusInterval -v 4
system sh/exec.sh -n dnode4 -s start
sql create dnode $hostname
4
sql create dnode $hostname
port 7400
$x = 0
step6:
...
...
@@ -103,17 +97,18 @@ step6:
endi
sql show dnodes
print dnode1 off: $data7_1
print dnode4 off: $data7_4
if $data7_4 != @mnEqualVn not match@ then
print dnode1 off: $data(1)[6]
print dnode2 off: $data(3)[6]
print dnode3 off: $data(4)[6]
if $data(4)[6] != @interval not match@ then
goto step6
endi
print ========== step7
system sh/deploy.sh -n dnode5 -i 5
system sh/cfg.sh -n dnode5 -c
statusInterval -v 3
system sh/cfg.sh -n dnode5 -c
locale -v zn_CH.UTF-8
system sh/exec.sh -n dnode5 -s start
sql create dnode $hostname
5
sql create dnode $hostname
port 7500
$x = 0
step7:
...
...
@@ -124,17 +119,19 @@ step7:
endi
sql show dnodes
print dnode1 off: $data7_1
print dnode5 off: $data7_5
if $data7_5 != @interval not match@ then
print dnode1 off: $data(1)[6]
print dnode3 off: $data(3)[6]
print dnode4 off: $data(4)[6]
print dnode5 off: $data(5)[6]
if $data(5)[6] != @locale not match@ then
goto step7
endi
print ========== step8
system sh/deploy.sh -n dnode6 -i 6
system sh/cfg.sh -n dnode6 -c
balance -v 0
system sh/cfg.sh -n dnode6 -c
charset -v UTF-16
system sh/exec.sh -n dnode6 -s start
sql create dnode $hostname
6
sql create dnode $hostname
port 7600
$x = 0
step8:
...
...
@@ -145,54 +142,15 @@ step8:
endi
sql show dnodes
print dnode1 off: $data7_1
print dnode6 off: $data7_6
if $data7_6 != @balance not match@ then
print dnode1 off: $data(1)[6]
print dnode3 off: $data(3)[6]
print dnode4 off: $data(4)[6]
print dnode5 off: $data(5)[6]
print dnode6 off: $data(6)[6]
if $data(6)[6] != @charset not match@ then
goto step8
endi
print ========== step9
system sh/deploy.sh -n dnode7 -i 7
system sh/cfg.sh -n dnode7 -c maxTablesPerVnode -v 3000
system sh/exec.sh -n dnode7 -s start
sql create dnode $hostname7
$x = 0
step9:
$x = $x + 1
sleep 1000
if $x == 10 then
return -1
endi
sql show dnodes
print dnode1 off: $data7_1
print dnode7 off: $data7_7
if $data7_7 != @maxTabPerVn not match@ then
goto step9
endi
print ========== step10
system sh/deploy.sh -n dnode8 -i 8
system sh/cfg.sh -n dnode8 -c maxVgroupsPerDb -v 3
system sh/exec.sh -n dnode8 -s start
sql create dnode $hostname8
$x = 0
step10:
$x = $x + 1
sleep 1000
if $x == 10 then
return -1
endi
sql show dnodes
print dnode1 off: $data7_1
print dnode8 off: $data7_8
if $data7_8 != @maxVgPerDb not match@ then
goto step10
endi
system sh/exec.sh -n dnode1 -s stop -x SIGINT
system sh/exec.sh -n dnode2 -s stop -x SIGINT
system sh/exec.sh -n dnode3 -s stop -x SIGINT
...
...
tests/script/unique/dnode/alternativeRole.sim
已删除
100644 → 0
浏览文件 @
aa9d3ac5
system sh/stop_dnodes.sh
system sh/deploy.sh -n dnode1 -i 1
system sh/deploy.sh -n dnode2 -i 2
system sh/deploy.sh -n dnode3 -i 3
system sh/cfg.sh -n dnode1 -c role -v 1
system sh/cfg.sh -n dnode2 -c role -v 2
system sh/cfg.sh -n dnode3 -c role -v 0
system sh/cfg.sh -n dnode1 -c wallevel -v 1
system sh/cfg.sh -n dnode2 -c wallevel -v 1
system sh/cfg.sh -n dnode3 -c wallevel -v 1
system sh/cfg.sh -n dnode1 -c numOfMnodes -v 3
system sh/cfg.sh -n dnode2 -c numOfMnodes -v 3
system sh/cfg.sh -n dnode3 -c numOfMnodes -v 3
system sh/cfg.sh -n dnode1 -c maxTablesPerVnode -v 4
system sh/cfg.sh -n dnode2 -c maxTablesPerVnode -v 4
system sh/cfg.sh -n dnode3 -c maxTablesPerVnode -v 4
print ========== step1
system sh/exec.sh -n dnode1 -s start
sleep 2000
sql connect
sql create dnode $hostname2
system sh/exec.sh -n dnode2 -s start
sql create dnode $hostname3
system sh/exec.sh -n dnode3 -s start
sleep 5000
sql show dnodes
print dnode1 $data5_1
print dnode1 $data5_2
print dnode1 $data5_3
if $data5_1 != mnode then
return -1
endi
if $data5_2 != vnode then
return -1
endi
if $data5_3 != any then
return -1
endi
sql show mnodes
print dnode1 ==> $data2_1
print dnode2 ==> $data2_2
print dnode3 ==> $data2_3
if $data2_1 != master then
return -1
endi
if $data2_2 != null then
return -1
endi
if $data2_3 != slave then
return -1
endi
print ========== step2
sql create database d1
sql create table d1.t1 (ts timestamp, i int)
sql create table d1.t2 (ts timestamp, i int)
sql create table d1.t3 (ts timestamp, i int)
sql create table d1.t4 (ts timestamp, i int)
sql create table d1.t5 (ts timestamp, i int)
sql create table d1.t6 (ts timestamp, i int)
sql create table d1.t7 (ts timestamp, i int)
sql create table d1.t8 (ts timestamp, i int)
sql show dnodes
print dnode1 $data2_1
print dnode2 $data2_2
print dnode3 $data2_3
if $data2_1 != 0 then
return -1
endi
if $data2_2 != 1 then
return -1
endi
if $data2_3 != 1 then
return -1
endi
system sh/exec.sh -n dnode1 -s stop -x SIGINT
system sh/exec.sh -n dnode2 -s stop -x SIGINT
system sh/exec.sh -n dnode3 -s stop -x SIGINT
system sh/exec.sh -n dnode4 -s stop -x SIGINT
system sh/exec.sh -n dnode5 -s stop -x SIGINT
system sh/exec.sh -n dnode6 -s stop -x SIGINT
system sh/exec.sh -n dnode7 -s stop -x SIGINT
system sh/exec.sh -n dnode8 -s stop -x SIGINT
\ No newline at end of file
tests/script/unique/dnode/balance2.sim
已删除
100644 → 0
浏览文件 @
aa9d3ac5
system sh/stop_dnodes.sh
system sh/deploy.sh -n dnode1 -i 1
system sh/deploy.sh -n dnode2 -i 2
system sh/deploy.sh -n dnode3 -i 3
system sh/deploy.sh -n dnode4 -i 4
system sh/deploy.sh -n dnode5 -i 5
system sh/cfg.sh -n dnode1 -c mnodeEqualVnodeNum -v 4
system sh/cfg.sh -n dnode2 -c mnodeEqualVnodeNum -v 4
system sh/cfg.sh -n dnode3 -c mnodeEqualVnodeNum -v 4
system sh/cfg.sh -n dnode4 -c mnodeEqualVnodeNum -v 4
system sh/cfg.sh -n dnode5 -c mnodeEqualVnodeNum -v 4
system sh/cfg.sh -n dnode1 -c maxTablesPerVnode -v 4
system sh/cfg.sh -n dnode2 -c maxTablesPerVnode -v 4
system sh/cfg.sh -n dnode3 -c maxTablesPerVnode -v 4
system sh/cfg.sh -n dnode4 -c maxTablesPerVnode -v 4
system sh/cfg.sh -n dnode5 -c maxTablesPerVnode -v 4
system sh/cfg.sh -n dnode1 -c wallevel -v 1
system sh/cfg.sh -n dnode2 -c wallevel -v 1
system sh/cfg.sh -n dnode3 -c wallevel -v 1
system sh/cfg.sh -n dnode4 -c wallevel -v 1
system sh/cfg.sh -n dnode5 -c wallevel -v 1
print ========== step1
system sh/exec.sh -n dnode1 -s start
sql connect
sql create dnode $hostname2
sql create dnode $hostname3
system sh/exec.sh -n dnode2 -s start
system sh/exec.sh -n dnode3 -s start
$x = 0
step1:
$x = $x + 1
sleep 1000
if $x == 10 then
return -1
endi
sql show dnodes
print dnode1 $data4_1
print dnode2 $data4_2
print dnode3 $data4_3
print dnode4 $data4_4
if $data4_1 != ready then
goto step1
endi
if $data4_2 != ready then
goto step1
endi
if $data4_3 != ready then
goto step1
endi
sql create database d1 replica 2
sql create table d1.t1 (t timestamp, i int)
sql insert into d1.t1 values(now+1s, 15)
sql insert into d1.t1 values(now+2s, 14)
sql insert into d1.t1 values(now+3s, 13)
sql insert into d1.t1 values(now+4s, 12)
sql insert into d1.t1 values(now+5s, 11)
sql create database d2 replica 2
sql create table d2.t2 (t timestamp, i int)
sql insert into d2.t2 values(now+1s, 25)
sql insert into d2.t2 values(now+2s, 24)
sql insert into d2.t2 values(now+3s, 23)
sql insert into d2.t2 values(now+4s, 22)
sql insert into d2.t2 values(now+5s, 21)
sql show dnodes
print dnode1 openVnodes $data2_1
print dnode2 openVnodes $data2_2
print dnode3 openVnodes $data2_3
if $data2_1 != 0 then
return -1
endi
if $data2_2 != 2 then
return -1
endi
if $data2_3 != 2 then
return -1
endi
print ========== step2
sql drop dnode $hostname2
$x = 0
show2:
$x = $x + 1
sleep 1000
if $x == 20 then
return -1
endi
sql show dnodes
print dnode1 openVnodes $data2_1
print dnode2 openVnodes $data2_2
print dnode3 openVnodes $data2_3
if $data2_1 != 2 then
goto show2
endi
if $data2_2 != null then
goto show2
endi
if $data2_3 != 2 then
goto show2
endi
system sh/exec.sh -n dnode2 -s stop -x SIGINT
print ========== step3
sql create dnode $hostname4
system sh/exec.sh -n dnode4 -s start
$x = 0
show3:
$x = $x + 1
sleep 2000
if $x == 20 then
return -1
endi
sql show dnodes
print dnode1 openVnodes $data2_1
print dnode2 openVnodes $data2_2
print dnode3 openVnodes $data2_3
print dnode4 openVnodes $data2_4
if $data2_1 != 0 then
goto show3
endi
if $data2_2 != null then
goto show3
endi
if $data2_3 != 2 then
goto show3
endi
if $data2_4 != 2 then
goto show3
endi
print ========== step4
sql create database d3 replica 2
sql create table d3.t3 (t timestamp, i int)
sql insert into d3.t3 values(now+1s, 35)
sql insert into d3.t3 values(now+2s, 34)
sql insert into d3.t3 values(now+3s, 33)
sql insert into d3.t3 values(now+4s, 32)
sql insert into d3.t3 values(now+5s, 31)
sql show dnodes
print dnode1 openVnodes $data2_1
print dnode2 openVnodes $data2_2
print dnode3 openVnodes $data2_3
print dnode4 openVnodes $data2_4
if $data2_1 != 0 then
return -1
endi
if $data2_2 != null then
return -1
endi
if $data2_3 != 3 then
return -1
endi
if $data2_4 != 3 then
return -1
endi
print ========== step5
sql create dnode $hostname5
system sh/exec.sh -n dnode5 -s start
$x = 0
show5:
$x = $x + 1
sleep 1000
if $x == 20 then
return -1
endi
sql show dnodes
print dnode1 openVnodes $data2_1
print dnode2 openVnodes $data2_2
print dnode3 openVnodes $data2_3
print dnode4 openVnodes $data2_4
print dnode5 openVnodes $data2_5
if $data2_1 != 0 then
goto show5
endi
if $data2_2 != null then
goto show5
endi
if $data2_3 != 2 then
goto show5
endi
if $data2_4 != 2 then
goto show5
endi
if $data2_5 != 2 then
goto show5
endi
print ========== step6
sql drop dnode $hostname3
$x = 0
show6:
$x = $x + 1
sleep 1000
if $x == 20 then
return -1
endi
sql show dnodes
print dnode1 openVnodes $data2_1
print dnode2 openVnodes $data2_2
print dnode3 openVnodes $data2_3
print dnode4 openVnodes $data2_4
print dnode5 openVnodes $data2_5
if $data2_1 != 0 then
goto show6
endi
if $data2_2 != null then
goto show6
endi
if $data2_3 != null then
goto show6
endi
if $data2_4 != 3 then
goto show6
endi
if $data2_5 != 3 then
goto show6
endi
system sh/exec.sh -n dnode2 -s stop -x SIGINT
sql reset query cache
sleep 100
print ========== step7
sql select * from d1.t1 order by t desc
print $data01 $data11 $data21 $data31 $data41
if $data01 != 11 then
return -1
endi
if $data11 != 12 then
return -1
endi
if $data21 != 13 then
return -1
endi
if $data31 != 14 then
return -1
endi
if $data41 != 15 then
return -1
endi
sql select * from d2.t2 order by t desc
print $data01 $data11 $data21 $data31 $data41
if $data01 != 21 then
return -1
endi
if $data11 != 22 then
return -1
endi
if $data21 != 23 then
return -1
endi
if $data31 != 24 then
return -1
endi
if $data41 != 25 then
return -1
endi
sql select * from d3.t3 order by t desc
print $data01 $data11 $data21 $data31 $data41
if $data01 != 31 then
return -1
endi
if $data11 != 32 then
return -1
endi
if $data21 != 33 then
return -1
endi
if $data31 != 34 then
return -1
endi
if $data41 != 35 then
return -1
endi
system sh/exec.sh -n dnode1 -s stop -x SIGINT
system sh/exec.sh -n dnode2 -s stop -x SIGINT
system sh/exec.sh -n dnode3 -s stop -x SIGINT
system sh/exec.sh -n dnode4 -s stop -x SIGINT
system sh/exec.sh -n dnode5 -s stop -x SIGINT
system sh/exec.sh -n dnode6 -s stop -x SIGINT
system sh/exec.sh -n dnode7 -s stop -x SIGINT
system sh/exec.sh -n dnode8 -s stop -x SIGINT
\ No newline at end of file
tests/script/unique/dnode/balancex.sim
已删除
100644 → 0
浏览文件 @
aa9d3ac5
system sh/stop_dnodes.sh
system sh/deploy.sh -n dnode1 -i 1
system sh/deploy.sh -n dnode2 -i 2
system sh/deploy.sh -n dnode3 -i 3
system sh/deploy.sh -n dnode4 -i 4
system sh/cfg.sh -n dnode1 -c mnodeEqualVnodeNum -v 4
system sh/cfg.sh -n dnode2 -c mnodeEqualVnodeNum -v 4
system sh/cfg.sh -n dnode3 -c mnodeEqualVnodeNum -v 4
system sh/cfg.sh -n dnode4 -c mnodeEqualVnodeNum -v 4
system sh/cfg.sh -n dnode1 -c wallevel -v 1
system sh/cfg.sh -n dnode2 -c wallevel -v 1
system sh/cfg.sh -n dnode3 -c wallevel -v 1
system sh/cfg.sh -n dnode4 -c wallevel -v 1
system sh/cfg.sh -n dnode1 -c maxTablesPerVnode -v 4
system sh/cfg.sh -n dnode2 -c maxTablesPerVnode -v 4
system sh/cfg.sh -n dnode3 -c maxTablesPerVnode -v 4
system sh/cfg.sh -n dnode4 -c maxTablesPerVnode -v 4
print ========== step1
system sh/exec.sh -n dnode1 -s start
sql connect
sleep 2000
sql create database d1
sql create table d1.t1 (t timestamp, i int)
sql insert into d1.t1 values(now+1s, 15)
sql insert into d1.t1 values(now+2s, 14)
sql insert into d1.t1 values(now+3s, 13)
sql insert into d1.t1 values(now+4s, 12)
sql insert into d1.t1 values(now+5s, 11)
sql create database d2
sql create table d2.t2 (t timestamp, i int)
sql insert into d2.t2 values(now+1s, 25)
sql insert into d2.t2 values(now+2s, 24)
sql insert into d2.t2 values(now+3s, 23)
sql insert into d2.t2 values(now+4s, 22)
sql insert into d2.t2 values(now+5s, 21)
sql show dnodes
print dnode1 openVnodes $data2_1
if $data2_1 != 2 then
return -1
endi
print ========== step2
sql create dnode $hostname2
system sh/exec.sh -n dnode2 -s start
$x = 0
show2:
$x = $x + 1
sleep 2000
if $x == 10 then
return -1
endi
sql show dnodes
print dnode1 openVnodes $data2_1
print dnode2 openVnodes $data2_2
if $data2_1 != 0 then
goto show2
endi
if $data2_2 != 2 then
goto show2
endi
print ========== step3
sql create database d3 replica 2
sql create table d3.t3 (t timestamp, i int)
sql insert into d3.t3 values(now+1s, 35)
sql insert into d3.t3 values(now+2s, 34)
sql insert into d3.t3 values(now+3s, 33)
sql insert into d3.t3 values(now+4s, 32)
sql insert into d3.t3 values(now+5s, 31)
$x = 0
show3:
$x = $x + 1
sleep 2000
if $x == 10 then
return -1
endi
sql show dnodes
print dnode1 openVnodes $data2_1
print dnode2 openVnodes $data2_2
if $data2_1 != 1 then
goto show3
endi
if $data2_2 != 3 then
goto show3
endi
print ========== step3
sql create dnode $hostname3
system sh/exec.sh -n dnode3 -s start
$x = 0
show4:
$x = $x + 1
sleep 2000
if $x == 20 then
return -1
endi
sql show dnodes
print dnode1 openVnodes $data2_1
print dnode2 openVnodes $data2_2
print dnode3 openVnodes $data2_3
if $data2_1 != 0 then
goto show4
endi
if $data2_2 != 2 then
goto show4
endi
if $data2_3 != 2 then
goto show4
endi
print ========== step5
sql drop dnode $hostname2
$x = 0
show5:
$x = $x + 1
sleep 2000
if $x == 10 then
return -1
endi
sql show dnodes
print dnode1 openVnodes $data2_1
print dnode2 openVnodes $data2_2
print dnode3 openVnodes $data2_3
if $data2_1 != 1 then
goto show5
endi
if $data2_2 != null then
goto show5
endi
if $data2_3 != 3 then
goto show5
endi
system sh/exec.sh -n dnode2 -s stop -x SIGINT
sleep 3000
sql reset query cache
sleep 1000
print ========== step6
sql select * from d1.t1 order by t desc
print $data01 $data11 $data21 $data31 $data41
if $data01 != 11 then
return -1
endi
if $data11 != 12 then
return -1
endi
if $data21 != 13 then
return -1
endi
if $data31 != 14 then
return -1
endi
if $data41 != 15 then
return -1
endi
sql select * from d2.t2 order by t desc
print $data01 $data11 $data21 $data31 $data41
if $data01 != 21 then
return -1
endi
if $data11 != 22 then
return -1
endi
if $data21 != 23 then
return -1
endi
if $data31 != 24 then
return -1
endi
if $data41 != 25 then
return -1
endi
sql select * from d3.t3 order by t desc
print $data01 $data11 $data21 $data31 $data41
if $data01 != 31 then
return -1
endi
if $data11 != 32 then
return -1
endi
if $data21 != 33 then
return -1
endi
if $data31 != 34 then
return -1
endi
if $data41 != 35 then
return -1
endi
system sh/exec.sh -n dnode1 -s stop -x SIGINT
system sh/exec.sh -n dnode2 -s stop -x SIGINT
system sh/exec.sh -n dnode3 -s stop -x SIGINT
system sh/exec.sh -n dnode4 -s stop -x SIGINT
system sh/exec.sh -n dnode5 -s stop -x SIGINT
system sh/exec.sh -n dnode6 -s stop -x SIGINT
system sh/exec.sh -n dnode7 -s stop -x SIGINT
system sh/exec.sh -n dnode8 -s stop -x SIGINT
\ No newline at end of file
tests/script/unique/dnode/m2.sim
已删除
100644 → 0
浏览文件 @
aa9d3ac5
system sh/stop_dnodes.sh
system sh/deploy.sh -n dnode1 -i 1
system sh/deploy.sh -n dnode2 -i 2
system sh/deploy.sh -n dnode3 -i 3
system sh/deploy.sh -n dnode4 -i 4
system sh/deploy.sh -n dnode5 -i 5
system sh/cfg.sh -n dnode1 -c balanceInterval -v 10
system sh/cfg.sh -n dnode2 -c balanceInterval -v 10
system sh/cfg.sh -n dnode3 -c balanceInterval -v 10
system sh/cfg.sh -n dnode4 -c balanceInterval -v 10
system sh/cfg.sh -n dnode5 -c balanceInterval -v 10
system sh/cfg.sh -n dnode1 -c mnodeEqualVnodeNum -v 4
system sh/cfg.sh -n dnode2 -c mnodeEqualVnodeNum -v 4
system sh/cfg.sh -n dnode3 -c mnodeEqualVnodeNum -v 4
system sh/cfg.sh -n dnode4 -c mnodeEqualVnodeNum -v 4
system sh/cfg.sh -n dnode5 -c mnodeEqualVnodeNum -v 4
system sh/cfg.sh -n dnode1 -c maxTablesPerVnode -v 4
system sh/cfg.sh -n dnode2 -c maxTablesPerVnode -v 4
system sh/cfg.sh -n dnode3 -c maxTablesPerVnode -v 4
system sh/cfg.sh -n dnode4 -c maxTablesPerVnode -v 4
system sh/cfg.sh -n dnode5 -c maxTablesPerVnode -v 4
print ========== step1
system sh/exec.sh -n dnode1 -s start
sql connect
sql create dnode $hostname2
sql create dnode $hostname3
system sh/exec.sh -n dnode2 -s start
system sh/exec.sh -n dnode3 -s start
$x = 0
step1:
$x = $x + 1
sleep 1000
if $x == 10 then
return -1
endi
sql show dnodes
print dnode1 $data4_1
print dnode2 $data4_2
print dnode3 $data4_3
if $data4_1 != ready then
goto step1
endi
if $data4_2 != ready then
goto step1
endi
if $data4_3 != ready then
goto step1
endi
print ========== step2
sql create database d1 replica 2
sql create table d1.t1 (t timestamp, i int)
sql insert into d1.t1 values(now+1s, 15)
sql insert into d1.t1 values(now+2s, 14)
sql insert into d1.t1 values(now+3s, 13)
sql insert into d1.t1 values(now+4s, 12)
sql insert into d1.t1 values(now+5s, 11)
sql create database d2 replica 2
sql create table d2.t2 (t timestamp, i int)
sql insert into d2.t2 values(now+1s, 25)
sql insert into d2.t2 values(now+2s, 24)
sql insert into d2.t2 values(now+3s, 23)
sql insert into d2.t2 values(now+4s, 22)
sql insert into d2.t2 values(now+5s, 21)
sql create database d3 replica 2
sql create table d3.t3 (t timestamp, i int)
sql insert into d3.t3 values(now+1s, 35)
sql insert into d3.t3 values(now+2s, 34)
sql insert into d3.t3 values(now+3s, 33)
sql insert into d3.t3 values(now+4s, 32)
sql insert into d3.t3 values(now+5s, 31)
sql create database d4 replica 2
sql create table d4.t4 (t timestamp, i int)
sql insert into d4.t4 values(now+1s, 45)
sql insert into d4.t4 values(now+2s, 44)
sql insert into d4.t4 values(now+3s, 43)
sql insert into d4.t4 values(now+4s, 42)
sql insert into d4.t4 values(now+5s, 41)
print ========== step2.1
sql show dnodes
print dnode1 openVnodes $data2_1
print dnode2 openVnodes $data2_2
print dnode3 openVnodes $data2_3
if $data2_1 != 0 then
return -1
endi
if $data2_2 != 4 then
return -1
endi
if $data2_3 != 4 then
return -1
endi
sql show d1.vgroups;
print d1.vgroups $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09
sql show d2.vgroups;
print d2.vgroups $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09
sql show d3.vgroups;
print d3.vgroups $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09
sql show d4.vgroups;
print d4.vgroups $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09
print ========== step3
sql create dnode $hostname4
system sh/exec.sh -n dnode4 -s start
sql create dnode $hostname5
system sh/exec.sh -n dnode5 -s start
$x = 0
show3:
$x = $x + 1
sleep 1000
if $x == 40 then
return -1
endi
sql show dnodes
print dnode1 openVnodes $data2_1
print dnode2 openVnodes $data2_2
print dnode3 openVnodes $data2_3
print dnode4 openVnodes $data2_4
print dnode5 openVnodes $data2_5
if $data2_2 != 2 then
goto show3
endi
if $data2_3 != 2 then
goto show3
endi
if $data2_4 != 2 then
goto show3
endi
if $data2_5 != 2 then
goto show3
endi
sql show d1.vgroups;
print d1.vgroups $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09
if $data03 != 2 then
goto show3
endi
sql show d2.vgroups;
print d2.vgroups $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09
if $data03 != 2 then
goto show3
endi
sql show d3.vgroups;
print d3.vgroups $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09
if $data03 != 2 then
goto show3
endi
sql show d4.vgroups;
print d4.vgroups $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09
if $data03 != 2 then
goto show3
endi
print ========== step4
sql drop dnode $hostname2
$x = 0
show4:
$x = $x + 1
sleep 1000
if $x == 40 then
return -1
endi
sql show dnodes
print dnode1 openVnodes $data2_1
print dnode2 openVnodes $data2_2
print dnode3 openVnodes $data2_3
print dnode4 openVnodes $data2_4
print dnode5 openVnodes $data2_5
if $data2_2 != null then
goto show4
endi
sql show d1.vgroups;
print d1.vgroups $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09
if $data03 != 2 then
goto show4
endi
sql show d2.vgroups;
print d2.vgroups $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09
if $data03 != 2 then
goto show4
endi
sql show d3.vgroups;
print d3.vgroups $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09
if $data03 != 2 then
goto show4
endi
sql show d4.vgroups;
print d4.vgroups $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09
if $data03 != 2 then
goto show4
endi
sql reset query cache
sleep 100
system sh/exec.sh -n dnode2 -s stop -x SIGINT
print ========== step5
sql drop dnode $hostname3
$x = 0
show5:
$x = $x + 1
sleep 1000
if $x == 40 then
return -1
endi
sql show dnodes
print dnode1 openVnodes $data2_1
print dnode2 openVnodes $data2_2
print dnode3 openVnodes $data2_3
print dnode4 openVnodes $data2_4
print dnode5 openVnodes $data2_5
if $data2_2 != null then
goto show5
endi
if $data2_3 != null then
goto show5
endi
if $data2_4 != 4 then
goto show5
endi
if $data2_5 != 4 then
goto show4
endi
sql show d1.vgroups;
print d1.vgroups $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09
if $data03 != 2 then
goto show5
endi
sql show d2.vgroups;
print d2.vgroups $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09
if $data03 != 2 then
goto show5
endi
sql show d3.vgroups;
print d3.vgroups $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09
if $data03 != 2 then
goto show5
endi
sql show d4.vgroups;
print d4.vgroups $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09
if $data03 != 2 then
goto show5
endi
sql reset query cache
sleep 100
system sh/exec.sh -n dnode3 -s stop -x SIGINT
print ========== step6
sql select * from d1.t1 order by t desc
print $data01 $data11 $data21 $data31 $data41
if $data01 != 11 then
return -1
endi
if $data11 != 12 then
return -1
endi
if $data21 != 13 then
return -1
endi
if $data31 != 14 then
return -1
endi
if $data41 != 15 then
return -1
endi
sql select * from d2.t2 order by t desc
print $data01 $data11 $data21 $data31 $data41
if $data01 != 21 then
return -1
endi
if $data11 != 22 then
return -1
endi
if $data21 != 23 then
return -1
endi
if $data31 != 24 then
return -1
endi
if $data41 != 25 then
return -1
endi
sql select * from d3.t3 order by t desc
print $data01 $data11 $data21 $data31 $data41
if $data01 != 31 then
return -1
endi
if $data11 != 32 then
return -1
endi
if $data21 != 33 then
return -1
endi
if $data31 != 34 then
return -1
endi
if $data41 != 35 then
return -1
endi
sql select * from d4.t4 order by t desc
print $data01 $data11 $data21 $data31 $data41
if $data01 != 41 then
return -1
endi
if $data11 != 42 then
return -1
endi
if $data21 != 43 then
return -1
endi
if $data31 != 44 then
return -1
endi
if $data41 != 45 then
return -1
endi
system sh/exec.sh -n dnode1 -s stop -x SIGINT
system sh/exec.sh -n dnode2 -s stop -x SIGINT
system sh/exec.sh -n dnode3 -s stop -x SIGINT
system sh/exec.sh -n dnode4 -s stop -x SIGINT
system sh/exec.sh -n dnode5 -s stop -x SIGINT
\ No newline at end of file
tests/script/unique/dnode/monitor_bug.sim
已删除
100644 → 0
浏览文件 @
aa9d3ac5
system sh/stop_dnodes.sh
system sh/deploy.sh -n dnode1 -i 1
system sh/deploy.sh -n dnode2 -i 2
system sh/cfg.sh -n dnode1 -c mnodeEqualVnodeNum -v 4
system sh/cfg.sh -n dnode2 -c mnodeEqualVnodeNum -v 4
system sh/cfg.sh -n dnode1 -c wallevel -v 1
system sh/cfg.sh -n dnode2 -c wallevel -v 1
system sh/cfg.sh -n dnode1 -c monitor -v 1
system sh/cfg.sh -n dnode2 -c monitor -v 0
print ========== step1
system sh/exec.sh -n dnode1 -s start
sql connect
sleep 3000
sql show dnodes
print dnode1 openVnodes $data2_1
if $data2_1 > 2 then
return -1
endi
print ========== step2
sql create dnode $hostname2
system sh/exec.sh -n dnode2 -s start
$x = 0
show2:
$x = $x + 1
sleep 2000
if $x == 10 then
return -1
endi
sql show dnodes
print dnode1 openVnodes $data2_1
print dnode2 openVnodes $data2_2
if $data2_1 != 0 then
goto show2
endi
if $data2_2 > 2 then
goto show2
endi
print ========== step3
sql show log.tables
print $data00
print $data10
print $data20
print $data30
print $data40
print $data50
if $rows > 5 then
return -1
endi
print ========== step4
sql select * from log.dn1
print $rows
$rows1 = $rows
sleep 2000
sql select * from log.dn1
print $rows
$rows2 = $rows
if $rows2 <= $rows1 then
return -1
endi
system sh/exec.sh -n dnode1 -s stop -x SIGINT
system sh/exec.sh -n dnode2 -s stop -x SIGINT
\ No newline at end of file
tests/script/unique/dnode/offline1.sim
已删除
100644 → 0
浏览文件 @
aa9d3ac5
system sh/stop_dnodes.sh
system sh/deploy.sh -n dnode1 -i 1
system sh/deploy.sh -n dnode2 -i 2
system sh/deploy.sh -n dnode3 -i 3
system sh/cfg.sh -n dnode1 -c offlineThreshold -v 10
system sh/cfg.sh -n dnode2 -c offlineThreshold -v 10
system sh/cfg.sh -n dnode3 -c offlineThreshold -v 10
system sh/cfg.sh -n dnode1 -c balanceInterval -v 5
system sh/cfg.sh -n dnode2 -c balanceInterval -v 5
system sh/cfg.sh -n dnode3 -c balanceInterval -v 5
system sh/cfg.sh -n dnode1 -c mnodeEqualVnodeNum -v 4
system sh/cfg.sh -n dnode2 -c mnodeEqualVnodeNum -v 4
system sh/cfg.sh -n dnode3 -c mnodeEqualVnodeNum -v 4
system sh/cfg.sh -n dnode1 -c wallevel -v 1
system sh/cfg.sh -n dnode2 -c wallevel -v 1
system sh/cfg.sh -n dnode3 -c wallevel -v 1
print ========== step1
system sh/exec.sh -n dnode1 -s start
sql connect
sql create dnode $hostname2
system sh/exec.sh -n dnode2 -s start
sleep 2000
sql show dnodes
print dnode1 $data4_1
print dnode1 $data4_2
if $data4_1 != ready then
return -1
endi
if $data4_2 != ready then
return -1
endi
print ========== step2
system sh/exec.sh -n dnode2 -s stop -x SIGINT
sleep 8000
sql show dnodes
print dnode1 $data4_1
print dnode1 $data4_2
if $data4_1 != ready then
return -1
endi
if $data4_2 == ready then
return -1
endi
print ========== step3
sleep 10000
sql show dnodes
print dnode1 $data4_1
print dnode1 $data4_2
if $data4_1 != ready then
return -1
endi
if $data4_2 != null then
return -1
endi
system sh/exec.sh -n dnode1 -s stop -x SIGINT
system sh/exec.sh -n dnode2 -s stop -x SIGINT
system sh/exec.sh -n dnode3 -s stop -x SIGINT
system sh/exec.sh -n dnode4 -s stop -x SIGINT
system sh/exec.sh -n dnode5 -s stop -x SIGINT
system sh/exec.sh -n dnode6 -s stop -x SIGINT
system sh/exec.sh -n dnode7 -s stop -x SIGINT
system sh/exec.sh -n dnode8 -s stop -x SIGINT
\ No newline at end of file
tests/script/unique/dnode/offline2.sim
已删除
100644 → 0
浏览文件 @
aa9d3ac5
system sh/stop_dnodes.sh
system sh/deploy.sh -n dnode1 -i 1
system sh/deploy.sh -n dnode2 -i 2
system sh/deploy.sh -n dnode3 -i 3
system sh/cfg.sh -n dnode1 -c offlineThreshold -v 10
system sh/cfg.sh -n dnode2 -c offlineThreshold -v 10
system sh/cfg.sh -n dnode3 -c offlineThreshold -v 10
system sh/cfg.sh -n dnode1 -c balanceInterval -v 5
system sh/cfg.sh -n dnode2 -c balanceInterval -v 5
system sh/cfg.sh -n dnode3 -c balanceInterval -v 5
system sh/cfg.sh -n dnode1 -c mnodeEqualVnodeNum -v 4
system sh/cfg.sh -n dnode2 -c mnodeEqualVnodeNum -v 4
system sh/cfg.sh -n dnode3 -c mnodeEqualVnodeNum -v 4
system sh/cfg.sh -n dnode1 -c maxTablesPerVnode -v 4
system sh/cfg.sh -n dnode2 -c maxTablesPerVnode -v 4
system sh/cfg.sh -n dnode3 -c maxTablesPerVnode -v 4
system sh/cfg.sh -n dnode4 -c maxTablesPerVnode -v 4
system sh/cfg.sh -n dnode1 -c wallevel -v 1
system sh/cfg.sh -n dnode2 -c wallevel -v 1
system sh/cfg.sh -n dnode3 -c wallevel -v 1
print ========== step1
system sh/exec.sh -n dnode1 -s start
sql connect
sql create dnode $hostname2
system sh/exec.sh -n dnode2 -s start
sleep 2000
sql create database d1 replica 2
sql create table d1.t1(ts timestamp, i int)
sql insert into d1.t1 values(1588262400001, 1)
sql show dnodes
print dnode1 $data4_1
print dnode1 $data4_2
if $data4_1 != ready then
return -1
endi
if $data4_2 != ready then
return -1
endi
print ========== step2
system sh/exec.sh -n dnode2 -s stop -x SIGINT
sleep 8000
sql show dnodes
print dnode1 $data4_1
print dnode1 $data4_2
if $data4_1 != ready then
return -1
endi
if $data4_2 == ready then
return -1
endi
print ========== step3
sleep 10000
sql show dnodes
print dnode1 $data4_1
print dnode1 $data4_2
if $data4_1 != ready then
return -1
endi
if $data4_2 != dropping then
return -1
endi
print ========== step4
sql create dnode $hostname3
system sh/exec.sh -n dnode3 -s start
system sh/exec.sh -n dnode2 -s start
sql drop dnode $hostname2
sleep 3000
$x = 0
show4:
$x = $x + 1
sleep 3000
if $x == 10 then
return -1
endi
sql show dnodes
print dnode1 $data4_1
print dnode2 $data4_2
print dnode3 $data4_3
if $data4_1 != ready then
goto show4
endi
if $data4_2 != null then
goto show4
endi
if $data4_3 != ready then
goto show4
endi
print ======================== step5
sql reset query cache
sleep 1000
sql select * from d1.t1
if $rows != 1 then
return -1
endi
system sh/exec.sh -n dnode1 -s stop -x SIGINT
system sh/exec.sh -n dnode2 -s stop -x SIGINT
system sh/exec.sh -n dnode3 -s stop -x SIGINT
system sh/exec.sh -n dnode4 -s stop -x SIGINT
system sh/exec.sh -n dnode5 -s stop -x SIGINT
system sh/exec.sh -n dnode6 -s stop -x SIGINT
system sh/exec.sh -n dnode7 -s stop -x SIGINT
system sh/exec.sh -n dnode8 -s stop -x SIGINT
\ No newline at end of file
tests/script/unique/dnode/offline3.sim
已删除
100644 → 0
浏览文件 @
aa9d3ac5
system sh/stop_dnodes.sh
system sh/deploy.sh -n dnode1 -i 1
system sh/deploy.sh -n dnode2 -i 2
system sh/deploy.sh -n dnode3 -i 3
system sh/deploy.sh -n dnode4 -i 4
system sh/cfg.sh -n dnode1 -c offlineThreshold -v 3
system sh/cfg.sh -n dnode2 -c offlineThreshold -v 3
system sh/cfg.sh -n dnode3 -c offlineThreshold -v 3
system sh/cfg.sh -n dnode4 -c offlineThreshold -v 3
system sh/cfg.sh -n dnode1 -c balanceInterval -v 300
system sh/cfg.sh -n dnode2 -c balanceInterval -v 300
system sh/cfg.sh -n dnode3 -c balanceInterval -v 300
system sh/cfg.sh -n dnode4 -c balanceInterval -v 300
system sh/cfg.sh -n dnode1 -c mnodeEqualVnodeNum -v 4
system sh/cfg.sh -n dnode2 -c mnodeEqualVnodeNum -v 4
system sh/cfg.sh -n dnode3 -c mnodeEqualVnodeNum -v 4
system sh/cfg.sh -n dnode4 -c mnodeEqualVnodeNum -v 4
print ========== step1
system sh/exec.sh -n dnode1 -s start
sql connect
sql create dnode $hostname2
system sh/exec.sh -n dnode2 -s start
sql create dnode $hostname3
system sh/exec.sh -n dnode3 -s start
sql create dnode $hostname4
system sh/exec.sh -n dnode4 -s start
$x = 0
step1:
$x = $x + 1
sleep 1000
if $x == 10 then
return -1
endi
sql show dnodes
print dnode1 $data4_1
print dnode2 $data4_2
print dnode3 $data4_3
print dnode4 $data4_4
if $data4_1 != ready then
goto step1
endi
if $data4_2 != ready then
goto step1
endi
if $data4_3 != ready then
goto step1
endi
if $data4_4 != ready then
goto step1
endi
sql show mnodes
print mnode1 $data2_1
if $data2_1 != master then
goto step1
endi
print ========== step2
sql create database db replica 3
sql use db
sql create table tb (ts timestamp, value int)
sql insert into tb values (now, 1)
sql insert into tb values (now, 2)
sql show vgroups;
print $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09
print ========== step2
system sh/exec.sh -n dnode4 -s stop -x SIGINT
$x = 0
step2:
$x = $x + 1
sleep 1000
if $x == 20 then
return -1
endi
sql show vgroups;
print $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09
sql show dnodes
print dnode1 $data4_1
print dnode2 $data4_2
print dnode3 $data4_3
print dnode4 $data4_4
if $data4_1 != ready then
goto step2
endi
if $data4_2 != ready then
goto step2
endi
if $data4_3 != ready then
goto step2
endi
if $data4_4 != null then
goto step2
endi
system sh/exec.sh -n dnode1 -s stop -x SIGINT
system sh/exec.sh -n dnode2 -s stop -x SIGINT
system sh/exec.sh -n dnode3 -s stop -x SIGINT
\ No newline at end of file
tests/script/unique/dnode/remove2.sim
已删除
100644 → 0
浏览文件 @
aa9d3ac5
system sh/stop_dnodes.sh
system sh/deploy.sh -n dnode1 -i 1
system sh/deploy.sh -n dnode2 -i 2
system sh/deploy.sh -n dnode3 -i 3
system sh/deploy.sh -n dnode4 -i 4
system sh/cfg.sh -n dnode1 -c mnodeEqualVnodeNum -v 4
system sh/cfg.sh -n dnode2 -c mnodeEqualVnodeNum -v 4
system sh/cfg.sh -n dnode3 -c mnodeEqualVnodeNum -v 4
system sh/cfg.sh -n dnode4 -c mnodeEqualVnodeNum -v 4
system sh/cfg.sh -n dnode1 -c wallevel -v 2
system sh/cfg.sh -n dnode2 -c wallevel -v 2
system sh/cfg.sh -n dnode3 -c wallevel -v 2
system sh/cfg.sh -n dnode4 -c wallevel -v 2
system sh/cfg.sh -n dnode1 -c maxTablesPerVnode -v 4
system sh/cfg.sh -n dnode2 -c maxTablesPerVnode -v 4
system sh/cfg.sh -n dnode3 -c maxTablesPerVnode -v 4
system sh/cfg.sh -n dnode4 -c maxTablesPerVnode -v 4
print ========== step1
system sh/exec.sh -n dnode1 -s start
sql connect
sql create database d1
sql create table d1.t1 (t timestamp, i int)
sql insert into d1.t1 values(1588262400001, 15)
sql insert into d1.t1 values(1588262400002, 14)
sql insert into d1.t1 values(1588262400003, 13)
sql insert into d1.t1 values(1588262400004, 12)
sql insert into d1.t1 values(1588262400005, 11)
sql create database d2
sql create table d2.t2 (t timestamp, i int)
sql insert into d2.t2 values(1588262400001, 25)
sql insert into d2.t2 values(1588262400002, 24)
sql insert into d2.t2 values(1588262400003, 23)
sql insert into d2.t2 values(1588262400004, 22)
sql insert into d2.t2 values(1588262400005, 21)
sql show dnodes
print dnode1 openVnodes $data2_1
if $data2_1 != 2 then
return -1
endi
print ========== step2
sql create dnode $hostname2
system sh/exec.sh -n dnode2 -s start
$x = 0
step2:
$x = $x + 1
sleep 1000
if $x == 10 then
return -1
endi
sql show dnodes
print dnode1 $data4_1
print dnode2 $data4_2
print dnode3 $data4_3
print dnode4 $data4_4
if $data4_1 != ready then
goto step2
endi
if $data4_2 != ready then
goto step2
endi
sql create database d3 replica 2
sql create table d3.t3 (t timestamp, i int)
sql insert into d3.t3 values(1588262400001, 35)
sql insert into d3.t3 values(1588262400002, 34)
sql insert into d3.t3 values(1588262400003, 33)
sql insert into d3.t3 values(1588262400004, 32)
sql insert into d3.t3 values(1588262400005, 31)
$x = 0
show2:
$x = $x + 1
sleep 2000
if $x == 10 then
return -1
endi
sql show dnodes
print dnode1 openVnodes $data2_1
print dnode2 openVnodes $data2_2
if $data2_1 != 1 then
goto show2
endi
if $data2_2 != 3 then
goto show2
endi
print ========== step3
system sh/exec.sh -n dnode2 -s stop -x SIGINT
sql show dnodes
print dnode1 openVnodes $data2_1
print dnode2 openVnodes $data2_2
print ========== step4
sql create dnode $hostname3
system sh/exec.sh -n dnode3 -s start
$x = 0
step4:
$x = $x + 1
sleep 1000
if $x == 20 then
return -1
endi
sql show dnodes
print dnode1 openVnodes $data2_1
print dnode2 openVnodes $data2_2
print dnode3 openVnodes $data2_3
# wait dnode3 create first vgroup in dnode-status msg
if $data2_3 != 1 then
goto step4
endi
print ============ step 4.1
system sh/exec.sh -n dnode2 -s start
$x = 0
step4.1:
$x = $x + 1
sleep 1000
if $x == 10 then
return -1
endi
sql show dnodes
print dnode1 $data4_1
print dnode2 $data4_2
print dnode3 $data4_3
print dnode4 $data4_4
if $data4_2 != ready then
goto step4.1
endi
sql drop dnode $hostname2
$x = 0
show4:
$x = $x + 1
sleep 1000
if $x == 20 then
return -1
endi
sql show dnodes
print dnode1 openVnodes $data2_1
print dnode2 openVnodes $data2_2
print dnode3 openVnodes $data2_3
if $data2_1 != 1 then
goto show4
endi
if $data2_2 != null then
goto show4
endi
if $data2_3 != 3 then
goto show4
endi
print ========== step5
sql select * from d1.t1 order by t desc
print $data01 $data11 $data21 $data31 $data41
sql select * from d2.t2 order by t desc
print $data01 $data11 $data21 $data31 $data41
sql select * from d3.t3 order by t desc
print $data01 $data11 $data21 $data31 $data41
if $data01 != 31 then
return -1
endi
if $data11 != 32 then
return -1
endi
if $data21 != 33 then
return -1
endi
if $data31 != 34 then
return -1
endi
if $data41 != 35 then
return -1
endi
system sh/exec.sh -n dnode1 -s stop -x SIGINT
system sh/exec.sh -n dnode2 -s stop -x SIGINT
system sh/exec.sh -n dnode3 -s stop -x SIGINT
system sh/exec.sh -n dnode4 -s stop -x SIGINT
system sh/exec.sh -n dnode5 -s stop -x SIGINT
system sh/exec.sh -n dnode6 -s stop -x SIGINT
system sh/exec.sh -n dnode7 -s stop -x SIGINT
system sh/exec.sh -n dnode8 -s stop -x SIGINT
tests/system-test/0-others/udfTest.py
浏览文件 @
ed4b2dec
...
...
@@ -301,13 +301,13 @@ class TDTestCase:
tdSql
.
checkRows
(
1
)
tdSql
.
query
(
"select ceil(num1) , min(num1) from tb;"
)
tdSql
.
checkRows
(
1
)
tdSql
.
error
(
"select udf1(num1) , first(num1) from tb;"
)
tdSql
.
query
(
"select udf1(num1) , first(num1) from tb;"
)
tdSql
.
error
(
"select abs(num1) , first(num1) from tb;"
)
tdSql
.
query
(
"select abs(num1) , first(num1) from tb;"
)
tdSql
.
error
(
"select udf1(num1) , last(num1) from tb;"
)
tdSql
.
query
(
"select udf1(num1) , last(num1) from tb;"
)
tdSql
.
error
(
"select round(num1) , last(num1) from tb;"
)
tdSql
.
query
(
"select round(num1) , last(num1) from tb;"
)
tdSql
.
query
(
"select udf1(num1) , top(num1,1) from tb;"
)
tdSql
.
checkRows
(
1
)
...
...
@@ -327,9 +327,9 @@ class TDTestCase:
tdSql
.
checkRows
(
1
)
tdSql
.
query
(
"select floor(c1) , min(c1) from stb1;"
)
tdSql
.
checkRows
(
1
)
tdSql
.
error
(
"select udf1(c1) , first(c1) from stb1;"
)
tdSql
.
query
(
"select udf1(c1) , first(c1) from stb1;"
)
tdSql
.
error
(
"select udf1(c1) , last(c1) from stb1;"
)
tdSql
.
query
(
"select udf1(c1) , last(c1) from stb1;"
)
tdSql
.
query
(
"select udf1(c1) , top(c1 ,1) from stb1;"
)
tdSql
.
checkRows
(
1
)
...
...
tests/system-test/0-others/udf_create.py
浏览文件 @
ed4b2dec
...
...
@@ -303,13 +303,13 @@ class TDTestCase:
tdSql
.
checkRows
(
1
)
tdSql
.
query
(
"select ceil(num1) , min(num1) from tb;"
)
tdSql
.
checkRows
(
1
)
tdSql
.
error
(
"select udf1(num1) , first(num1) from tb;"
)
tdSql
.
query
(
"select udf1(num1) , first(num1) from tb;"
)
tdSql
.
error
(
"select abs(num1) , first(num1) from tb;"
)
tdSql
.
query
(
"select abs(num1) , first(num1) from tb;"
)
tdSql
.
error
(
"select udf1(num1) , last(num1) from tb;"
)
tdSql
.
query
(
"select udf1(num1) , last(num1) from tb;"
)
tdSql
.
error
(
"select round(num1) , last(num1) from tb;"
)
tdSql
.
query
(
"select round(num1) , last(num1) from tb;"
)
tdSql
.
query
(
"select udf1(num1) , top(num1,1) from tb;"
)
tdSql
.
checkRows
(
1
)
...
...
@@ -329,9 +329,9 @@ class TDTestCase:
tdSql
.
checkRows
(
1
)
tdSql
.
query
(
"select floor(c1) , min(c1) from stb1;"
)
tdSql
.
checkRows
(
1
)
tdSql
.
error
(
"select udf1(c1) , first(c1) from stb1;"
)
tdSql
.
query
(
"select udf1(c1) , first(c1) from stb1;"
)
tdSql
.
error
(
"select udf1(c1) , last(c1) from stb1;"
)
tdSql
.
query
(
"select udf1(c1) , last(c1) from stb1;"
)
tdSql
.
query
(
"select udf1(c1) , top(c1 ,1) from stb1;"
)
tdSql
.
checkRows
(
1
)
...
...
tests/system-test/0-others/udf_restart_taosd.py
浏览文件 @
ed4b2dec
...
...
@@ -300,13 +300,13 @@ class TDTestCase:
tdSql
.
checkRows
(
1
)
tdSql
.
query
(
"select ceil(num1) , min(num1) from tb;"
)
tdSql
.
checkRows
(
1
)
tdSql
.
error
(
"select udf1(num1) , first(num1) from tb;"
)
tdSql
.
query
(
"select udf1(num1) , first(num1) from tb;"
)
tdSql
.
error
(
"select abs(num1) , first(num1) from tb;"
)
tdSql
.
query
(
"select abs(num1) , first(num1) from tb;"
)
tdSql
.
error
(
"select udf1(num1) , last(num1) from tb;"
)
tdSql
.
query
(
"select udf1(num1) , last(num1) from tb;"
)
tdSql
.
error
(
"select round(num1) , last(num1) from tb;"
)
tdSql
.
query
(
"select round(num1) , last(num1) from tb;"
)
tdSql
.
query
(
"select udf1(num1) , top(num1,1) from tb;"
)
tdSql
.
checkRows
(
1
)
...
...
@@ -326,9 +326,9 @@ class TDTestCase:
tdSql
.
checkRows
(
1
)
tdSql
.
query
(
"select floor(c1) , min(c1) from stb1;"
)
tdSql
.
checkRows
(
1
)
tdSql
.
error
(
"select udf1(c1) , first(c1) from stb1;"
)
tdSql
.
query
(
"select udf1(c1) , first(c1) from stb1;"
)
tdSql
.
error
(
"select udf1(c1) , last(c1) from stb1;"
)
tdSql
.
query
(
"select udf1(c1) , last(c1) from stb1;"
)
tdSql
.
query
(
"select udf1(c1) , top(c1 ,1) from stb1;"
)
tdSql
.
checkRows
(
1
)
...
...
tests/system-test/2-query/unique.py
浏览文件 @
ed4b2dec
...
...
@@ -266,7 +266,7 @@ class TDTestCase:
tdSql
.
query
(
"select unique(c1) from ct4"
)
tdSql
.
checkRows
(
10
)
tdSql
.
error
(
"select unique(c1),tbname from ct1"
)
#tdSql.error("select unique(c1),tbname from ct1") #support
#tdSql.error("select unique(c1),t1 from ct1") #support
# unique with common col
...
...
taos-tools
@
28a49b44
比较
a875a057
...
28a49b44
Subproject commit
a875a057d1225d85c6323b9edaccc2b1a9641987
Subproject commit
28a49b447f71c4f014ebbac858b7215b897d57fd
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录