Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
1b4ed84a
T
TDengine
项目概览
taosdata
/
TDengine
大约 2 年 前同步成功
通知
1193
Star
22018
Fork
4786
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
未验证
提交
1b4ed84a
编写于
7月 18, 2022
作者:
W
wenzhouwww
提交者:
GitHub
7月 18, 2022
浏览文件
操作
浏览文件
下载
差异文件
Merge branch '3.0' into test/bug_fix_update
上级
aeb7f0d9
595daef8
变更
47
显示空白变更内容
内联
并排
Showing
47 changed file
with
1142 addition
and
390 deletion
+1142
-390
cmake/cmake.platform
cmake/cmake.platform
+9
-0
include/common/tmsg.h
include/common/tmsg.h
+4
-3
include/common/ttime.h
include/common/ttime.h
+6
-5
include/libs/nodes/plannodes.h
include/libs/nodes/plannodes.h
+10
-1
source/client/src/tmq.c
source/client/src/tmq.c
+5
-1
source/common/src/tdatablock.c
source/common/src/tdatablock.c
+5
-8
source/common/src/ttime.c
source/common/src/ttime.c
+4
-4
source/dnode/mgmt/mgmt_vnode/src/vmWorker.c
source/dnode/mgmt/mgmt_vnode/src/vmWorker.c
+10
-0
source/dnode/vnode/src/inc/sma.h
source/dnode/vnode/src/inc/sma.h
+18
-9
source/dnode/vnode/src/meta/metaTable.c
source/dnode/vnode/src/meta/metaTable.c
+1
-1
source/dnode/vnode/src/sma/smaCommit.c
source/dnode/vnode/src/sma/smaCommit.c
+3
-1
source/dnode/vnode/src/sma/smaEnv.c
source/dnode/vnode/src/sma/smaEnv.c
+20
-0
source/dnode/vnode/src/sma/smaRollup.c
source/dnode/vnode/src/sma/smaRollup.c
+94
-32
source/dnode/vnode/src/tq/tqExec.c
source/dnode/vnode/src/tq/tqExec.c
+2
-2
source/dnode/vnode/src/tq/tqPush.c
source/dnode/vnode/src/tq/tqPush.c
+1
-1
source/dnode/vnode/src/vnd/vnodeSvr.c
source/dnode/vnode/src/vnd/vnodeSvr.c
+2
-1
source/dnode/vnode/src/vnd/vnodeSync.c
source/dnode/vnode/src/vnd/vnodeSync.c
+18
-31
source/libs/executor/src/timewindowoperator.c
source/libs/executor/src/timewindowoperator.c
+0
-1
source/libs/function/src/builtins.c
source/libs/function/src/builtins.c
+3
-10
source/libs/nodes/src/nodesCodeFuncs.c
source/libs/nodes/src/nodesCodeFuncs.c
+14
-26
source/libs/parser/src/parCalcConst.c
source/libs/parser/src/parCalcConst.c
+2
-1
source/libs/parser/src/parTranslater.c
source/libs/parser/src/parTranslater.c
+4
-1
source/libs/planner/src/planLogicCreater.c
source/libs/planner/src/planLogicCreater.c
+11
-15
source/libs/planner/src/planPhysiCreater.c
source/libs/planner/src/planPhysiCreater.c
+17
-10
source/libs/scalar/src/sclfunc.c
source/libs/scalar/src/sclfunc.c
+3
-2
source/libs/sync/inc/syncInt.h
source/libs/sync/inc/syncInt.h
+1
-0
source/libs/sync/src/syncMain.c
source/libs/sync/src/syncMain.c
+6
-0
source/libs/tdb/src/db/tdbBtree.c
source/libs/tdb/src/db/tdbBtree.c
+1
-4
source/libs/tdb/src/db/tdbPager.c
source/libs/tdb/src/db/tdbPager.c
+0
-22
source/os/src/osTime.c
source/os/src/osTime.c
+76
-2
tests/pytest/crash_gen/crash_gen_main.py
tests/pytest/crash_gen/crash_gen_main.py
+9
-2
tests/script/jenkins/basic.txt
tests/script/jenkins/basic.txt
+1
-0
tests/script/tsim/db/alter_replica_31.sim
tests/script/tsim/db/alter_replica_31.sim
+9
-0
tests/script/tsim/valgrind/checkError5.sim
tests/script/tsim/valgrind/checkError5.sim
+31
-2
tests/script/tsim/valgrind/checkError6.sim
tests/script/tsim/valgrind/checkError6.sim
+1
-1
tests/system-test/0-others/cachemodel.py
tests/system-test/0-others/cachemodel.py
+51
-39
tests/system-test/1-insert/delete_data.py
tests/system-test/1-insert/delete_data.py
+190
-0
tests/system-test/1-insert/update_data.py
tests/system-test/1-insert/update_data.py
+229
-0
tests/system-test/2-query/last_row.py
tests/system-test/2-query/last_row.py
+48
-47
tests/system-test/7-tmq/stbTagFilter.py
tests/system-test/7-tmq/stbTagFilter.py
+203
-56
tests/system-test/99-TDcase/TD-17255.py
tests/system-test/99-TDcase/TD-17255.py
+1
-1
tests/system-test/fulltest.sh
tests/system-test/fulltest.sh
+4
-1
tests/test/c/tmqDemo.c
tests/test/c/tmqDemo.c
+2
-1
tests/test/c/tmqSim.c
tests/test/c/tmqSim.c
+5
-15
tests/tsim/src/simExe.c
tests/tsim/src/simExe.c
+3
-14
tests/tsim/src/simParse.c
tests/tsim/src/simParse.c
+2
-3
tools/shell/src/shellEngine.c
tools/shell/src/shellEngine.c
+3
-14
未找到文件。
cmake/cmake.platform
浏览文件 @
1b4ed84a
...
@@ -76,15 +76,19 @@ IF ("${CPUTYPE}" STREQUAL "")
...
@@ -76,15 +76,19 @@ IF ("${CPUTYPE}" STREQUAL "")
IF (CMAKE_SYSTEM_PROCESSOR MATCHES "(amd64)|(AMD64)")
IF (CMAKE_SYSTEM_PROCESSOR MATCHES "(amd64)|(AMD64)")
MESSAGE(STATUS "The current platform is amd64")
MESSAGE(STATUS "The current platform is amd64")
SET(PLATFORM_ARCH_STR "amd64")
SET(PLATFORM_ARCH_STR "amd64")
SET(TD_INTEL_64 TRUE)
ELSEIF (CMAKE_SYSTEM_PROCESSOR MATCHES "(x86)|(X86)")
ELSEIF (CMAKE_SYSTEM_PROCESSOR MATCHES "(x86)|(X86)")
MESSAGE(STATUS "The current platform is x86")
MESSAGE(STATUS "The current platform is x86")
SET(PLATFORM_ARCH_STR "i386")
SET(PLATFORM_ARCH_STR "i386")
SET(TD_INTEL_32 TRUE)
ELSEIF (CMAKE_SYSTEM_PROCESSOR MATCHES "armv7l")
ELSEIF (CMAKE_SYSTEM_PROCESSOR MATCHES "armv7l")
MESSAGE(STATUS "The current platform is aarch32")
MESSAGE(STATUS "The current platform is aarch32")
SET(PLATFORM_ARCH_STR "arm")
SET(PLATFORM_ARCH_STR "arm")
SET(TD_ARM_32 TRUE)
ELSEIF (CMAKE_SYSTEM_PROCESSOR MATCHES "aarch64")
ELSEIF (CMAKE_SYSTEM_PROCESSOR MATCHES "aarch64")
MESSAGE(STATUS "The current platform is aarch64")
MESSAGE(STATUS "The current platform is aarch64")
SET(PLATFORM_ARCH_STR "arm64")
SET(PLATFORM_ARCH_STR "arm64")
SET(TD_ARM_64 TRUE)
ENDIF ()
ENDIF ()
ELSE ()
ELSE ()
# if generate ARM version:
# if generate ARM version:
...
@@ -92,18 +96,23 @@ ELSE ()
...
@@ -92,18 +96,23 @@ ELSE ()
IF (${CPUTYPE} MATCHES "aarch32")
IF (${CPUTYPE} MATCHES "aarch32")
SET(PLATFORM_ARCH_STR "arm")
SET(PLATFORM_ARCH_STR "arm")
MESSAGE(STATUS "input cpuType: aarch32")
MESSAGE(STATUS "input cpuType: aarch32")
SET(TD_ARM_32 TRUE)
ELSEIF (${CPUTYPE} MATCHES "aarch64")
ELSEIF (${CPUTYPE} MATCHES "aarch64")
SET(PLATFORM_ARCH_STR "arm64")
SET(PLATFORM_ARCH_STR "arm64")
MESSAGE(STATUS "input cpuType: aarch64")
MESSAGE(STATUS "input cpuType: aarch64")
SET(TD_ARM_64 TRUE)
ELSEIF (${CPUTYPE} MATCHES "mips64")
ELSEIF (${CPUTYPE} MATCHES "mips64")
SET(PLATFORM_ARCH_STR "mips")
SET(PLATFORM_ARCH_STR "mips")
MESSAGE(STATUS "input cpuType: mips64")
MESSAGE(STATUS "input cpuType: mips64")
SET(TD_MIPS_64 TRUE)
ELSEIF (${CPUTYPE} MATCHES "x64")
ELSEIF (${CPUTYPE} MATCHES "x64")
SET(PLATFORM_ARCH_STR "amd64")
SET(PLATFORM_ARCH_STR "amd64")
MESSAGE(STATUS "input cpuType: x64")
MESSAGE(STATUS "input cpuType: x64")
SET(TD_INTEL_64 TRUE)
ELSEIF (${CPUTYPE} MATCHES "x86")
ELSEIF (${CPUTYPE} MATCHES "x86")
SET(PLATFORM_ARCH_STR "i386")
SET(PLATFORM_ARCH_STR "i386")
MESSAGE(STATUS "input cpuType: x86")
MESSAGE(STATUS "input cpuType: x86")
SET(TD_INTEL_32 TRUE)
ELSE ()
ELSE ()
MESSAGE(STATUS "input cpuType unknown " ${CPUTYPE})
MESSAGE(STATUS "input cpuType unknown " ${CPUTYPE})
ENDIF ()
ENDIF ()
...
...
include/common/tmsg.h
浏览文件 @
1b4ed84a
...
@@ -2074,6 +2074,7 @@ typedef struct {
...
@@ -2074,6 +2074,7 @@ typedef struct {
char
*
tbName
;
char
*
tbName
;
int8_t
action
;
int8_t
action
;
char
*
colName
;
char
*
colName
;
int32_t
colId
;
// TSDB_ALTER_TABLE_ADD_COLUMN
// TSDB_ALTER_TABLE_ADD_COLUMN
int8_t
type
;
int8_t
type
;
int8_t
flags
;
int8_t
flags
;
...
...
include/common/ttime.h
浏览文件 @
1b4ed84a
...
@@ -63,12 +63,13 @@ static FORCE_INLINE int64_t taosGetTimestampToday(int32_t precision) {
...
@@ -63,12 +63,13 @@ static FORCE_INLINE int64_t taosGetTimestampToday(int32_t precision) {
:
(
precision
==
TSDB_TIME_PRECISION_MICRO
)
?
1000000
:
(
precision
==
TSDB_TIME_PRECISION_MICRO
)
?
1000000
:
1000000000
;
:
1000000000
;
time_t
t
=
taosTime
(
NULL
);
time_t
t
=
taosTime
(
NULL
);
struct
tm
*
tm
=
taosLocalTime
(
&
t
,
NULL
);
struct
tm
tm
;
tm
->
tm_hour
=
0
;
taosLocalTime
(
&
t
,
&
tm
);
tm
->
tm_min
=
0
;
tm
.
tm_hour
=
0
;
tm
->
tm_sec
=
0
;
tm
.
tm_min
=
0
;
tm
.
tm_sec
=
0
;
return
(
int64_t
)
taosMktime
(
tm
)
*
factor
;
return
(
int64_t
)
taosMktime
(
&
tm
)
*
factor
;
}
}
int64_t
taosTimeAdd
(
int64_t
t
,
int64_t
duration
,
char
unit
,
int32_t
precision
);
int64_t
taosTimeAdd
(
int64_t
t
,
int64_t
duration
,
char
unit
,
int32_t
precision
);
...
...
include/libs/nodes/plannodes.h
浏览文件 @
1b4ed84a
...
@@ -26,6 +26,12 @@ extern "C" {
...
@@ -26,6 +26,12 @@ extern "C" {
#define SLOT_NAME_LEN TSDB_TABLE_NAME_LEN + TSDB_COL_NAME_LEN
#define SLOT_NAME_LEN TSDB_TABLE_NAME_LEN + TSDB_COL_NAME_LEN
typedef
enum
EDataOrderLevel
{
DATA_ORDER_LEVEL_NONE
=
1
,
DATA_ORDER_LEVEL_IN_BLOCK
,
DATA_ORDER_LEVEL_IN_GROUP
}
EDataOrderLevel
;
typedef
struct
SLogicNode
{
typedef
struct
SLogicNode
{
ENodeType
type
;
ENodeType
type
;
SNodeList
*
pTargets
;
// SColumnNode
SNodeList
*
pTargets
;
// SColumnNode
...
@@ -36,6 +42,8 @@ typedef struct SLogicNode {
...
@@ -36,6 +42,8 @@ typedef struct SLogicNode {
uint8_t
precision
;
uint8_t
precision
;
SNode
*
pLimit
;
SNode
*
pLimit
;
SNode
*
pSlimit
;
SNode
*
pSlimit
;
EDataOrderLevel
requireDataOrder
;
// requirements for input data
EDataOrderLevel
resultDataOrder
;
// properties of the output data
}
SLogicNode
;
}
SLogicNode
;
typedef
enum
EScanType
{
typedef
enum
EScanType
{
...
@@ -317,6 +325,7 @@ typedef STableScanPhysiNode SStreamScanPhysiNode;
...
@@ -317,6 +325,7 @@ typedef STableScanPhysiNode SStreamScanPhysiNode;
typedef
struct
SProjectPhysiNode
{
typedef
struct
SProjectPhysiNode
{
SPhysiNode
node
;
SPhysiNode
node
;
SNodeList
*
pProjections
;
SNodeList
*
pProjections
;
bool
mergeDataBlock
;
}
SProjectPhysiNode
;
}
SProjectPhysiNode
;
typedef
struct
SIndefRowsFuncPhysiNode
{
typedef
struct
SIndefRowsFuncPhysiNode
{
...
...
source/client/src/tmq.c
浏览文件 @
1b4ed84a
...
@@ -363,7 +363,11 @@ tmq_list_t* tmq_list_new() {
...
@@ -363,7 +363,11 @@ tmq_list_t* tmq_list_new() {
int32_t
tmq_list_append
(
tmq_list_t
*
list
,
const
char
*
src
)
{
int32_t
tmq_list_append
(
tmq_list_t
*
list
,
const
char
*
src
)
{
SArray
*
container
=
&
list
->
container
;
SArray
*
container
=
&
list
->
container
;
if
(
src
==
NULL
||
src
[
0
]
==
0
)
return
-
1
;
char
*
topic
=
strdup
(
src
);
char
*
topic
=
strdup
(
src
);
if
(
topic
[
0
]
!=
'`'
)
{
strtolower
(
topic
,
src
);
}
if
(
taosArrayPush
(
container
,
&
topic
)
==
NULL
)
return
-
1
;
if
(
taosArrayPush
(
container
,
&
topic
)
==
NULL
)
return
-
1
;
return
0
;
return
0
;
}
}
...
...
source/common/src/tdatablock.c
浏览文件 @
1b4ed84a
...
@@ -228,7 +228,7 @@ int32_t colDataMergeCol(SColumnInfoData* pColumnInfoData, uint32_t numOfRow1, ui
...
@@ -228,7 +228,7 @@ int32_t colDataMergeCol(SColumnInfoData* pColumnInfoData, uint32_t numOfRow1, ui
uint32_t
finalNumOfRows
=
numOfRow1
+
numOfRow2
;
uint32_t
finalNumOfRows
=
numOfRow1
+
numOfRow2
;
if
(
IS_VAR_DATA_TYPE
(
pColumnInfoData
->
info
.
type
))
{
if
(
IS_VAR_DATA_TYPE
(
pColumnInfoData
->
info
.
type
))
{
// Handle the bitmap
// Handle the bitmap
if
(
finalNumOfRows
>
*
capacity
||
numOfRow1
==
0
)
{
if
(
finalNumOfRows
>
*
capacity
||
(
numOfRow1
==
0
&&
pColumnInfoData
->
info
.
bytes
!=
0
)
)
{
char
*
p
=
taosMemoryRealloc
(
pColumnInfoData
->
varmeta
.
offset
,
sizeof
(
int32_t
)
*
(
numOfRow1
+
numOfRow2
));
char
*
p
=
taosMemoryRealloc
(
pColumnInfoData
->
varmeta
.
offset
,
sizeof
(
int32_t
)
*
(
numOfRow1
+
numOfRow2
));
if
(
p
==
NULL
)
{
if
(
p
==
NULL
)
{
return
TSDB_CODE_OUT_OF_MEMORY
;
return
TSDB_CODE_OUT_OF_MEMORY
;
...
@@ -262,7 +262,7 @@ int32_t colDataMergeCol(SColumnInfoData* pColumnInfoData, uint32_t numOfRow1, ui
...
@@ -262,7 +262,7 @@ int32_t colDataMergeCol(SColumnInfoData* pColumnInfoData, uint32_t numOfRow1, ui
memcpy
(
pColumnInfoData
->
pData
+
oldLen
,
pSource
->
pData
,
len
);
memcpy
(
pColumnInfoData
->
pData
+
oldLen
,
pSource
->
pData
,
len
);
pColumnInfoData
->
varmeta
.
length
=
len
+
oldLen
;
pColumnInfoData
->
varmeta
.
length
=
len
+
oldLen
;
}
else
{
}
else
{
if
(
finalNumOfRows
>
*
capacity
||
numOfRow1
==
0
)
{
if
(
finalNumOfRows
>
*
capacity
||
(
numOfRow1
==
0
&&
pColumnInfoData
->
info
.
bytes
!=
0
)
)
{
ASSERT
(
finalNumOfRows
*
pColumnInfoData
->
info
.
bytes
);
ASSERT
(
finalNumOfRows
*
pColumnInfoData
->
info
.
bytes
);
char
*
tmp
=
taosMemoryRealloc
(
pColumnInfoData
->
pData
,
finalNumOfRows
*
pColumnInfoData
->
info
.
bytes
);
char
*
tmp
=
taosMemoryRealloc
(
pColumnInfoData
->
pData
,
finalNumOfRows
*
pColumnInfoData
->
info
.
bytes
);
if
(
tmp
==
NULL
)
{
if
(
tmp
==
NULL
)
{
...
@@ -1661,9 +1661,6 @@ static char* formatTimestamp(char* buf, int64_t val, int precision) {
...
@@ -1661,9 +1661,6 @@ static char* formatTimestamp(char* buf, int64_t val, int precision) {
}
}
*/
*/
#ifdef WINDOWS
if
(
tt
<
0
)
tt
=
0
;
#endif
if
(
tt
<=
0
&&
ms
<
0
)
{
if
(
tt
<=
0
&&
ms
<
0
)
{
tt
--
;
tt
--
;
if
(
precision
==
TSDB_TIME_PRECISION_NANO
)
{
if
(
precision
==
TSDB_TIME_PRECISION_NANO
)
{
...
@@ -1674,9 +1671,9 @@ static char* formatTimestamp(char* buf, int64_t val, int precision) {
...
@@ -1674,9 +1671,9 @@ static char* formatTimestamp(char* buf, int64_t val, int precision) {
ms
+=
1000
;
ms
+=
1000
;
}
}
}
}
struct
tm
ptm
=
{
0
};
struct
tm
*
ptm
=
taosLocalTime
(
&
tt
,
NULL
);
taosLocalTime
(
&
tt
,
&
ptm
);
size_t
pos
=
strftime
(
buf
,
35
,
"%Y-%m-%d %H:%M:%S"
,
ptm
);
size_t
pos
=
strftime
(
buf
,
35
,
"%Y-%m-%d %H:%M:%S"
,
&
ptm
);
if
(
precision
==
TSDB_TIME_PRECISION_NANO
)
{
if
(
precision
==
TSDB_TIME_PRECISION_NANO
)
{
sprintf
(
buf
+
pos
,
".%09d"
,
ms
);
sprintf
(
buf
+
pos
,
".%09d"
,
ms
);
...
...
source/common/src/ttime.c
浏览文件 @
1b4ed84a
...
@@ -902,7 +902,7 @@ const char* fmtts(int64_t ts) {
...
@@ -902,7 +902,7 @@ const char* fmtts(int64_t ts) {
void
taosFormatUtcTime
(
char
*
buf
,
int32_t
bufLen
,
int64_t
t
,
int32_t
precision
)
{
void
taosFormatUtcTime
(
char
*
buf
,
int32_t
bufLen
,
int64_t
t
,
int32_t
precision
)
{
char
ts
[
40
]
=
{
0
};
char
ts
[
40
]
=
{
0
};
struct
tm
*
ptm
;
struct
tm
ptm
;
int32_t
fractionLen
;
int32_t
fractionLen
;
char
*
format
=
NULL
;
char
*
format
=
NULL
;
...
@@ -939,10 +939,10 @@ void taosFormatUtcTime(char* buf, int32_t bufLen, int64_t t, int32_t precision)
...
@@ -939,10 +939,10 @@ void taosFormatUtcTime(char* buf, int32_t bufLen, int64_t t, int32_t precision)
assert
(
false
);
assert
(
false
);
}
}
ptm
=
taosLocalTime
(
&
quot
,
NULL
);
taosLocalTime
(
&
quot
,
&
ptm
);
int32_t
length
=
(
int32_t
)
strftime
(
ts
,
40
,
"%Y-%m-%dT%H:%M:%S"
,
ptm
);
int32_t
length
=
(
int32_t
)
strftime
(
ts
,
40
,
"%Y-%m-%dT%H:%M:%S"
,
&
ptm
);
length
+=
snprintf
(
ts
+
length
,
fractionLen
,
format
,
mod
);
length
+=
snprintf
(
ts
+
length
,
fractionLen
,
format
,
mod
);
length
+=
(
int32_t
)
strftime
(
ts
+
length
,
40
-
length
,
"%z"
,
ptm
);
length
+=
(
int32_t
)
strftime
(
ts
+
length
,
40
-
length
,
"%z"
,
&
ptm
);
tstrncpy
(
buf
,
ts
,
bufLen
);
tstrncpy
(
buf
,
ts
,
bufLen
);
}
}
source/dnode/mgmt/mgmt_vnode/src/vmWorker.c
浏览文件 @
1b4ed84a
...
@@ -179,6 +179,16 @@ static int32_t vmPutMsgToQueue(SVnodeMgmt *pMgmt, SRpcMsg *pMsg, EQueueType qtyp
...
@@ -179,6 +179,16 @@ static int32_t vmPutMsgToQueue(SVnodeMgmt *pMgmt, SRpcMsg *pMsg, EQueueType qtyp
}
else
{
}
else
{
dGTrace
(
"vgId:%d, msg:%p put into vnode-write queue"
,
pVnode
->
vgId
,
pMsg
);
dGTrace
(
"vgId:%d, msg:%p put into vnode-write queue"
,
pVnode
->
vgId
,
pMsg
);
taosWriteQitem
(
pVnode
->
pWriteQ
,
pMsg
);
taosWriteQitem
(
pVnode
->
pWriteQ
,
pMsg
);
#if 0 // tests for batch writes
if (pMsg->msgType == TDMT_VND_CREATE_TABLE) {
SRpcMsg *pDup = taosAllocateQitem(sizeof(SRpcMsg), RPC_QITEM);
memcpy(pDup, pMsg, sizeof(SRpcMsg));
pDup->pCont = rpcMallocCont(pMsg->contLen);
memcpy(pDup->pCont, pMsg->pCont, pMsg->contLen);
pDup->info.handle = NULL;
taosWriteQitem(pVnode->pWriteQ, pDup);
}
#endif
}
}
break
;
break
;
case
SYNC_QUEUE
:
case
SYNC_QUEUE
:
...
...
source/dnode/vnode/src/inc/sma.h
浏览文件 @
1b4ed84a
...
@@ -105,8 +105,13 @@ struct SRSmaInfoItem {
...
@@ -105,8 +105,13 @@ struct SRSmaInfoItem {
struct
SRSmaInfo
{
struct
SRSmaInfo
{
STSchema
*
pTSchema
;
STSchema
*
pTSchema
;
int64_t
suid
;
int64_t
suid
;
int8_t
delFlag
;
T_REF_DECLARE
()
SRSmaInfoItem
items
[
TSDB_RETENTION_L2
];
SRSmaInfoItem
items
[
TSDB_RETENTION_L2
];
};
};
#define RSMA_INFO_HEAD_LEN 24
#define RSMA_INFO_IS_DEL(r) ((r)->delFlag == 1)
#define RSMA_INFO_SET_DEL(r) ((r)->delFlag = 1)
enum
{
enum
{
TASK_TRIGGER_STAT_INIT
=
0
,
TASK_TRIGGER_STAT_INIT
=
0
,
...
@@ -120,8 +125,8 @@ enum {
...
@@ -120,8 +125,8 @@ enum {
enum
{
enum
{
RSMA_ROLE_CREATE
=
0
,
RSMA_ROLE_CREATE
=
0
,
RSMA_ROLE_DROP
=
1
,
RSMA_ROLE_DROP
=
1
,
RSMA_ROLE_
FETCH
=
2
,
RSMA_ROLE_
SUBMIT
=
2
,
RSMA_ROLE_
SUBMIT
=
3
,
RSMA_ROLE_
FETCH
=
3
,
RSMA_ROLE_ITERATE
=
4
,
RSMA_ROLE_ITERATE
=
4
,
};
};
...
@@ -134,6 +139,8 @@ int32_t tdInsertRSmaData(SSma *pSma, char *msg);
...
@@ -134,6 +139,8 @@ int32_t tdInsertRSmaData(SSma *pSma, char *msg);
int32_t
tdRefSmaStat
(
SSma
*
pSma
,
SSmaStat
*
pStat
);
int32_t
tdRefSmaStat
(
SSma
*
pSma
,
SSmaStat
*
pStat
);
int32_t
tdUnRefSmaStat
(
SSma
*
pSma
,
SSmaStat
*
pStat
);
int32_t
tdUnRefSmaStat
(
SSma
*
pSma
,
SSmaStat
*
pStat
);
int32_t
tdRefRSmaInfo
(
SSma
*
pSma
,
SRSmaInfo
*
pRSmaInfo
);
int32_t
tdUnRefRSmaInfo
(
SSma
*
pSma
,
SRSmaInfo
*
pRSmaInfo
);
void
*
tdAcquireSmaRef
(
int32_t
rsetId
,
int64_t
refId
,
const
char
*
tags
,
int32_t
ln
);
void
*
tdAcquireSmaRef
(
int32_t
rsetId
,
int64_t
refId
,
const
char
*
tags
,
int32_t
ln
);
int32_t
tdReleaseSmaRef
(
int32_t
rsetId
,
int64_t
refId
,
const
char
*
tags
,
int32_t
ln
);
int32_t
tdReleaseSmaRef
(
int32_t
rsetId
,
int64_t
refId
,
const
char
*
tags
,
int32_t
ln
);
...
@@ -193,6 +200,7 @@ void tdFreeQTaskInfo(qTaskInfo_t *taskHandle, int32_t vgId, int32_t le
...
@@ -193,6 +200,7 @@ void tdFreeQTaskInfo(qTaskInfo_t *taskHandle, int32_t vgId, int32_t le
static
int32_t
tdDestroySmaState
(
SSmaStat
*
pSmaStat
,
int8_t
smaType
);
static
int32_t
tdDestroySmaState
(
SSmaStat
*
pSmaStat
,
int8_t
smaType
);
void
*
tdFreeSmaState
(
SSmaStat
*
pSmaStat
,
int8_t
smaType
);
void
*
tdFreeSmaState
(
SSmaStat
*
pSmaStat
,
int8_t
smaType
);
void
*
tdFreeRSmaInfo
(
SSma
*
pSma
,
SRSmaInfo
*
pInfo
,
bool
isDeepFree
);
void
*
tdFreeRSmaInfo
(
SSma
*
pSma
,
SRSmaInfo
*
pInfo
,
bool
isDeepFree
);
void
tdRemoveRSmaInfoBySuid
(
SSma
*
pSma
,
int64_t
suid
);
int32_t
tdRSmaPersistExecImpl
(
SRSmaStat
*
pRSmaStat
,
SHashObj
*
pInfoHash
);
int32_t
tdRSmaPersistExecImpl
(
SRSmaStat
*
pRSmaStat
,
SHashObj
*
pInfoHash
);
int32_t
tdProcessRSmaCreateImpl
(
SSma
*
pSma
,
SRSmaParam
*
param
,
int64_t
suid
,
const
char
*
tbName
);
int32_t
tdProcessRSmaCreateImpl
(
SSma
*
pSma
,
SRSmaParam
*
param
,
int64_t
suid
,
const
char
*
tbName
);
...
@@ -258,8 +266,9 @@ void tdUpdateTFileMagic(STFile *pTFile, void *pCksm);
...
@@ -258,8 +266,9 @@ void tdUpdateTFileMagic(STFile *pTFile, void *pCksm);
void
tdCloseTFile
(
STFile
*
pTFile
);
void
tdCloseTFile
(
STFile
*
pTFile
);
void
tdDestroyTFile
(
STFile
*
pTFile
);
void
tdDestroyTFile
(
STFile
*
pTFile
);
void
tdGetVndFileName
(
int32_t
vgId
,
const
char
*
pdname
,
const
char
*
dname
,
const
char
*
fname
,
int64_t
version
,
char
*
outputName
);
void
tdGetVndFileName
(
int32_t
vgId
,
const
char
*
pdname
,
const
char
*
dname
,
const
char
*
fname
,
int64_t
version
,
void
tdGetVndDirName
(
int32_t
vgId
,
const
char
*
pdname
,
const
char
*
dname
,
bool
endWithSep
,
char
*
outputName
);
char
*
outputName
);
void
tdGetVndDirName
(
int32_t
vgId
,
const
char
*
pdname
,
const
char
*
dname
,
bool
endWithSep
,
char
*
outputName
);
#ifdef __cplusplus
#ifdef __cplusplus
}
}
...
...
source/dnode/vnode/src/meta/metaTable.c
浏览文件 @
1b4ed84a
source/dnode/vnode/src/sma/smaCommit.c
浏览文件 @
1b4ed84a
...
@@ -191,7 +191,7 @@ static int32_t tdCleanupQTaskInfoFiles(SSma *pSma, SRSmaStat *pRSmaStat) {
...
@@ -191,7 +191,7 @@ static int32_t tdCleanupQTaskInfoFiles(SSma *pSma, SRSmaStat *pRSmaStat) {
if
((
pDir
=
taosOpenDir
(
dir
))
==
NULL
)
{
if
((
pDir
=
taosOpenDir
(
dir
))
==
NULL
)
{
regfree
(
&
regex
);
regfree
(
&
regex
);
terrno
=
TAOS_SYSTEM_ERROR
(
errno
);
terrno
=
TAOS_SYSTEM_ERROR
(
errno
);
sma
Warn
(
"vgId:%d, rsma post commit, open dir %s failed since %s"
,
TD_VID
(
pVnode
),
dir
,
terrstr
());
sma
Debug
(
"vgId:%d, rsma post commit, open dir %s failed since %s"
,
TD_VID
(
pVnode
),
dir
,
terrstr
());
return
TSDB_CODE_FAILED
;
return
TSDB_CODE_FAILED
;
}
}
...
@@ -392,5 +392,7 @@ static int32_t tdProcessRSmaAsyncPostCommitImpl(SSma *pSma) {
...
@@ -392,5 +392,7 @@ static int32_t tdProcessRSmaAsyncPostCommitImpl(SSma *pSma) {
// step 2: cleanup outdated qtaskinfo files
// step 2: cleanup outdated qtaskinfo files
tdCleanupQTaskInfoFiles
(
pSma
,
pRSmaStat
);
tdCleanupQTaskInfoFiles
(
pSma
,
pRSmaStat
);
atomic_store_8
(
RSMA_COMMIT_STAT
(
pRSmaStat
),
0
);
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
source/dnode/vnode/src/sma/smaEnv.c
浏览文件 @
1b4ed84a
...
@@ -169,6 +169,26 @@ int32_t tdUnRefSmaStat(SSma *pSma, SSmaStat *pStat) {
...
@@ -169,6 +169,26 @@ int32_t tdUnRefSmaStat(SSma *pSma, SSmaStat *pStat) {
return
0
;
return
0
;
}
}
int32_t
tdRefRSmaInfo
(
SSma
*
pSma
,
SRSmaInfo
*
pRSmaInfo
)
{
if
(
!
pRSmaInfo
)
return
0
;
int
ref
=
T_REF_INC
(
pRSmaInfo
);
smaDebug
(
"vgId:%d, ref rsma info:%p, val:%d"
,
SMA_VID
(
pSma
),
pRSmaInfo
,
ref
);
return
0
;
}
int32_t
tdUnRefRSmaInfo
(
SSma
*
pSma
,
SRSmaInfo
*
pRSmaInfo
)
{
if
(
!
pRSmaInfo
)
return
0
;
int
ref
=
T_REF_DEC
(
pRSmaInfo
);
smaDebug
(
"vgId:%d, unref rsma info:%p, val:%d"
,
SMA_VID
(
pSma
),
pRSmaInfo
,
ref
);
if
(
ref
==
0
)
{
tdRemoveRSmaInfoBySuid
(
pSma
,
pRSmaInfo
->
suid
);
}
return
0
;
}
static
int32_t
tdInitSmaStat
(
SSmaStat
**
pSmaStat
,
int8_t
smaType
,
const
SSma
*
pSma
)
{
static
int32_t
tdInitSmaStat
(
SSmaStat
**
pSmaStat
,
int8_t
smaType
,
const
SSma
*
pSma
)
{
ASSERT
(
pSmaStat
!=
NULL
);
ASSERT
(
pSmaStat
!=
NULL
);
...
...
source/dnode/vnode/src/sma/smaRollup.c
浏览文件 @
1b4ed84a
...
@@ -24,6 +24,7 @@ SSmaMgmt smaMgmt = {
...
@@ -24,6 +24,7 @@ SSmaMgmt smaMgmt = {
};
};
#define TD_QTASKINFO_FNAME_PREFIX "qtaskinfo.ver"
#define TD_QTASKINFO_FNAME_PREFIX "qtaskinfo.ver"
#define TD_RSMAINFO_DEL_FILE "rsmainfo.del"
typedef
struct
SRSmaQTaskInfoItem
SRSmaQTaskInfoItem
;
typedef
struct
SRSmaQTaskInfoItem
SRSmaQTaskInfoItem
;
typedef
struct
SRSmaQTaskInfoIter
SRSmaQTaskInfoIter
;
typedef
struct
SRSmaQTaskInfoIter
SRSmaQTaskInfoIter
;
...
@@ -48,14 +49,11 @@ static int32_t tdRSmaRestoreQTaskInfoInit(SSma *pSma, int64_t *nTables);
...
@@ -48,14 +49,11 @@ static int32_t tdRSmaRestoreQTaskInfoInit(SSma *pSma, int64_t *nTables);
static
int32_t
tdRSmaRestoreQTaskInfoReload
(
SSma
*
pSma
,
int64_t
*
committed
);
static
int32_t
tdRSmaRestoreQTaskInfoReload
(
SSma
*
pSma
,
int64_t
*
committed
);
static
int32_t
tdRSmaRestoreTSDataReload
(
SSma
*
pSma
,
int64_t
committed
);
static
int32_t
tdRSmaRestoreTSDataReload
(
SSma
*
pSma
,
int64_t
committed
);
static
SRSmaInfo
*
tdGetRSmaInfoByItem
(
SRSmaInfoItem
*
pItem
)
{
static
SRSmaInfo
*
tdGetRSmaInfoByItem
(
SRSmaInfoItem
*
pItem
)
{
// adapt accordingly if definition of SRSmaInfo update
// adapt accordingly if definition of SRSmaInfo update
SRSmaInfo
*
pResult
=
NULL
;
SRSmaInfo
*
pResult
=
NULL
;
int32_t
rsmaInfoHeadLen
=
sizeof
(
int64_t
)
+
sizeof
(
STSchema
*
);
ASSERT
(
pItem
->
level
==
TSDB_RETENTION_L1
||
pItem
->
level
==
TSDB_RETENTION_L2
);
ASSERT
(
pItem
->
level
==
TSDB_RETENTION_L1
||
pItem
->
level
==
TSDB_RETENTION_L2
);
pResult
=
(
SRSmaInfo
*
)
POINTER_SHIFT
(
pItem
,
-
(
sizeof
(
SRSmaInfoItem
)
*
(
pItem
->
level
-
1
)
+
rsmaInfoHeadLen
));
pResult
=
(
SRSmaInfo
*
)
POINTER_SHIFT
(
pItem
,
-
(
sizeof
(
SRSmaInfoItem
)
*
(
pItem
->
level
-
1
)
+
RSMA_INFO_HEAD_LEN
));
ASSERT
(
pResult
->
pTSchema
->
numOfCols
>
1
);
ASSERT
(
pResult
->
pTSchema
->
numOfCols
>
1
);
return
pResult
;
return
pResult
;
}
}
...
@@ -116,8 +114,8 @@ void *tdFreeRSmaInfo(SSma *pSma, SRSmaInfo *pInfo, bool isDeepFree) {
...
@@ -116,8 +114,8 @@ void *tdFreeRSmaInfo(SSma *pSma, SRSmaInfo *pInfo, bool isDeepFree) {
SRSmaInfoItem
*
pItem
=
&
pInfo
->
items
[
i
];
SRSmaInfoItem
*
pItem
=
&
pInfo
->
items
[
i
];
if
(
pItem
->
taskInfo
)
{
if
(
pItem
->
taskInfo
)
{
if
(
isDeepFree
&&
pItem
->
tmrId
)
{
if
(
isDeepFree
&&
pItem
->
tmrId
)
{
smaDebug
(
"vgId:%d,
table %"
PRIi64
" stop fetch timer %p level %d"
,
SMA_VID
(
pSma
),
pInfo
->
suid
,
pItem
->
tmrI
d
,
smaDebug
(
"vgId:%d,
stop fetch timer %p for table %"
PRIi64
" level %d"
,
SMA_VID
(
pSma
),
pInfo
->
sui
d
,
i
+
1
);
pItem
->
tmrId
,
i
+
1
);
taosTmrStopA
(
&
pItem
->
tmrId
);
taosTmrStopA
(
&
pItem
->
tmrId
);
}
}
tdFreeQTaskInfo
(
&
pItem
->
taskInfo
,
SMA_VID
(
pSma
),
i
+
1
);
tdFreeQTaskInfo
(
&
pItem
->
taskInfo
,
SMA_VID
(
pSma
),
i
+
1
);
...
@@ -337,6 +335,7 @@ int32_t tdProcessRSmaCreateImpl(SSma *pSma, SRSmaParam *param, int64_t suid, con
...
@@ -337,6 +335,7 @@ int32_t tdProcessRSmaCreateImpl(SSma *pSma, SRSmaParam *param, int64_t suid, con
}
}
pRSmaInfo
->
pTSchema
=
pTSchema
;
pRSmaInfo
->
pTSchema
=
pTSchema
;
pRSmaInfo
->
suid
=
suid
;
pRSmaInfo
->
suid
=
suid
;
T_REF_INIT_VAL
(
pRSmaInfo
,
1
);
if
(
tdSetRSmaInfoItemParams
(
pSma
,
param
,
pStat
,
pRSmaInfo
,
0
)
<
0
)
{
if
(
tdSetRSmaInfoItemParams
(
pSma
,
param
,
pStat
,
pRSmaInfo
,
0
)
<
0
)
{
goto
_err
;
goto
_err
;
...
@@ -392,11 +391,33 @@ int32_t tdProcessRSmaCreate(SSma *pSma, SVCreateStbReq *pReq) {
...
@@ -392,11 +391,33 @@ int32_t tdProcessRSmaCreate(SSma *pSma, SVCreateStbReq *pReq) {
int32_t
tdProcessRSmaDrop
(
SSma
*
pSma
,
SVDropStbReq
*
pReq
)
{
int32_t
tdProcessRSmaDrop
(
SSma
*
pSma
,
SVDropStbReq
*
pReq
)
{
SVnode
*
pVnode
=
pSma
->
pVnode
;
SVnode
*
pVnode
=
pSma
->
pVnode
;
if
(
!
VND_IS_RSMA
(
pVnode
))
{
if
(
!
VND_IS_RSMA
(
pVnode
))
{
smaTrace
(
"vgId:%d, not
create
rsma for stable %s %"
PRIi64
" since vnd is not rsma"
,
TD_VID
(
pVnode
),
pReq
->
name
,
smaTrace
(
"vgId:%d, not
drop
rsma for stable %s %"
PRIi64
" since vnd is not rsma"
,
TD_VID
(
pVnode
),
pReq
->
name
,
pReq
->
suid
);
pReq
->
suid
);
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
SSmaEnv
*
pSmaEnv
=
SMA_RSMA_ENV
(
pSma
);
if
(
!
pSmaEnv
)
{
return
TSDB_CODE_SUCCESS
;
}
SSmaStat
*
pStat
=
SMA_ENV_STAT
(
pSmaEnv
);
SRSmaStat
*
pRSmaStat
=
SMA_RSMA_STAT
(
pStat
);
SRSmaInfo
*
pRSmaInfo
=
tdGetRSmaInfoBySuid
(
pSma
,
pReq
->
suid
);
if
(
!
pRSmaInfo
)
{
smaWarn
(
"vgId:%d, drop rsma for stable %s %"
PRIi64
" failed no rsma in hash"
,
TD_VID
(
pVnode
),
pReq
->
name
,
pReq
->
suid
);
return
TSDB_CODE_SUCCESS
;
}
// set del flag for data in mem
RSMA_INFO_SET_DEL
(
pRSmaInfo
);
tdUnRefRSmaInfo
(
pSma
,
pRSmaInfo
);
// save to file
smaDebug
(
"vgId:%d, drop rsma for table %"
PRIi64
" succeed"
,
TD_VID
(
pVnode
),
pReq
->
suid
);
smaDebug
(
"vgId:%d, drop rsma for table %"
PRIi64
" succeed"
,
TD_VID
(
pVnode
),
pReq
->
suid
);
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
...
@@ -661,7 +682,6 @@ static SRSmaInfo *tdGetRSmaInfoBySuid(SSma *pSma, int64_t suid) {
...
@@ -661,7 +682,6 @@ static SRSmaInfo *tdGetRSmaInfoBySuid(SSma *pSma, int64_t suid) {
SRSmaInfo
*
pRSmaInfo
=
NULL
;
SRSmaInfo
*
pRSmaInfo
=
NULL
;
if
(
!
pEnv
)
{
if
(
!
pEnv
)
{
// only applicable when rsma env exists
return
NULL
;
return
NULL
;
}
}
...
@@ -683,6 +703,7 @@ static SRSmaInfo *tdGetRSmaInfoBySuid(SSma *pSma, int64_t suid) {
...
@@ -683,6 +703,7 @@ static SRSmaInfo *tdGetRSmaInfoBySuid(SSma *pSma, int64_t suid) {
SRSmaInfo
*
pCowRSmaInfo
=
NULL
;
SRSmaInfo
*
pCowRSmaInfo
=
NULL
;
// lock
// lock
taosWLockLatch
(
SMA_ENV_LOCK
(
pEnv
));
taosWLockLatch
(
SMA_ENV_LOCK
(
pEnv
));
if
(
!
taosHashGet
(
RSMA_INFO_HASH
(
pStat
),
&
suid
,
sizeof
(
tb_uid_t
)))
{
// 2-phase lock
void
*
iRSmaInfo
=
taosHashGet
(
RSMA_IMU_INFO_HASH
(
pStat
),
&
suid
,
sizeof
(
tb_uid_t
));
void
*
iRSmaInfo
=
taosHashGet
(
RSMA_IMU_INFO_HASH
(
pStat
),
&
suid
,
sizeof
(
tb_uid_t
));
if
(
iRSmaInfo
)
{
if
(
iRSmaInfo
)
{
SRSmaInfo
*
pIRSmaInfo
=
*
(
SRSmaInfo
**
)
iRSmaInfo
;
SRSmaInfo
*
pIRSmaInfo
=
*
(
SRSmaInfo
**
)
iRSmaInfo
;
...
@@ -692,32 +713,69 @@ static SRSmaInfo *tdGetRSmaInfoBySuid(SSma *pSma, int64_t suid) {
...
@@ -692,32 +713,69 @@ static SRSmaInfo *tdGetRSmaInfoBySuid(SSma *pSma, int64_t suid) {
smaError
(
"vgId:%d, clone rsma info failed for suid:%"
PRIu64
" since %s"
,
SMA_VID
(
pSma
),
suid
,
terrstr
());
smaError
(
"vgId:%d, clone rsma info failed for suid:%"
PRIu64
" since %s"
,
SMA_VID
(
pSma
),
suid
,
terrstr
());
return
NULL
;
return
NULL
;
}
}
smaDebug
(
"vgId:%d, clone rsma info succeed for suid:%"
PRIu64
,
SMA_VID
(
pSma
),
suid
);
if
(
taosHashPut
(
RSMA_INFO_HASH
(
pStat
),
&
suid
,
sizeof
(
tb_uid_t
),
&
pCowRSmaInfo
,
sizeof
(
pCowRSmaInfo
))
<
0
)
{
if
(
taosHashPut
(
RSMA_INFO_HASH
(
pStat
),
&
suid
,
sizeof
(
tb_uid_t
),
&
pCowRSmaInfo
,
sizeof
(
pCowRSmaInfo
))
<
0
)
{
taosWUnLockLatch
(
SMA_ENV_LOCK
(
pEnv
));
taosWUnLockLatch
(
SMA_ENV_LOCK
(
pEnv
));
return
NULL
;
return
NULL
;
}
}
}
}
}
}
}
// unlock
// unlock
taosWUnLockLatch
(
SMA_ENV_LOCK
(
pEnv
));
taosWUnLockLatch
(
SMA_ENV_LOCK
(
pEnv
));
return
pCowRSmaInfo
;
return
pCowRSmaInfo
;
}
}
/**
* @brief During the drop procedure, only need to delete the object in rsmaInfoHash.
*
* @param pSma
* @param suid
* @return SRSmaInfo*
*/
void
tdRemoveRSmaInfoBySuid
(
SSma
*
pSma
,
int64_t
suid
)
{
SSmaEnv
*
pEnv
=
SMA_RSMA_ENV
(
pSma
);
SRSmaStat
*
pStat
=
NULL
;
SRSmaInfo
*
pRSmaInfo
=
NULL
;
if
(
!
pEnv
)
{
return
;
}
pStat
=
(
SRSmaStat
*
)
SMA_ENV_STAT
(
pEnv
);
if
(
!
pStat
||
!
RSMA_INFO_HASH
(
pStat
))
{
return
;
}
pRSmaInfo
=
taosHashGet
(
RSMA_INFO_HASH
(
pStat
),
&
suid
,
sizeof
(
tb_uid_t
));
if
(
pRSmaInfo
)
{
if
((
pRSmaInfo
=
*
(
SRSmaInfo
**
)
pRSmaInfo
))
{
tdFreeRSmaInfo
(
pSma
,
pRSmaInfo
,
true
);
}
taosHashRemove
(
RSMA_INFO_HASH
(
pStat
),
&
suid
,
sizeof
(
tb_uid_t
));
smaDebug
(
"vgId:%d, remove from infoHash for table:%"
PRIu64
" succeed"
,
SMA_VID
(
pSma
),
suid
);
}
}
static
int32_t
tdExecuteRSma
(
SSma
*
pSma
,
const
void
*
pMsg
,
int32_t
inputType
,
tb_uid_t
suid
)
{
static
int32_t
tdExecuteRSma
(
SSma
*
pSma
,
const
void
*
pMsg
,
int32_t
inputType
,
tb_uid_t
suid
)
{
SRSmaInfo
*
pRSmaInfo
=
tdGetRSmaInfoBySuid
(
pSma
,
suid
);
SRSmaInfo
*
pRSmaInfo
=
tdGetRSmaInfoBySuid
(
pSma
,
suid
);
if
(
!
pRSmaInfo
)
{
if
(
!
pRSmaInfo
)
{
smaDebug
(
"vgId:%d,
return as
no rsma info for suid:%"
PRIu64
,
SMA_VID
(
pSma
),
suid
);
smaDebug
(
"vgId:%d,
execute rsma,
no rsma info for suid:%"
PRIu64
,
SMA_VID
(
pSma
),
suid
);
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
if
(
!
pRSmaInfo
->
items
[
0
].
taskInfo
)
{
if
(
!
pRSmaInfo
->
items
[
0
].
taskInfo
)
{
smaDebug
(
"vgId:%d,
return as
no rsma qTaskInfo for suid:%"
PRIu64
,
SMA_VID
(
pSma
),
suid
);
smaDebug
(
"vgId:%d,
execute rsma,
no rsma qTaskInfo for suid:%"
PRIu64
,
SMA_VID
(
pSma
),
suid
);
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
if
(
inputType
==
STREAM_INPUT__DATA_SUBMIT
)
{
if
(
inputType
==
STREAM_INPUT__DATA_SUBMIT
)
{
tdRefRSmaInfo
(
pSma
,
pRSmaInfo
);
tdExecuteRSmaImpl
(
pSma
,
pMsg
,
inputType
,
&
pRSmaInfo
->
items
[
0
],
pRSmaInfo
->
pTSchema
,
suid
,
TSDB_RETENTION_L1
);
tdExecuteRSmaImpl
(
pSma
,
pMsg
,
inputType
,
&
pRSmaInfo
->
items
[
0
],
pRSmaInfo
->
pTSchema
,
suid
,
TSDB_RETENTION_L1
);
tdExecuteRSmaImpl
(
pSma
,
pMsg
,
inputType
,
&
pRSmaInfo
->
items
[
1
],
pRSmaInfo
->
pTSchema
,
suid
,
TSDB_RETENTION_L2
);
tdExecuteRSmaImpl
(
pSma
,
pMsg
,
inputType
,
&
pRSmaInfo
->
items
[
1
],
pRSmaInfo
->
pTSchema
,
suid
,
TSDB_RETENTION_L2
);
tdUnRefRSmaInfo
(
pSma
,
pRSmaInfo
);
}
}
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
...
@@ -1271,6 +1329,9 @@ static void tdRSmaFetchTrigger(void *param, void *tmrId) {
...
@@ -1271,6 +1329,9 @@ static void tdRSmaFetchTrigger(void *param, void *tmrId) {
}
}
SRSmaInfo
*
pRSmaInfo
=
tdGetRSmaInfoByItem
(
pItem
);
SRSmaInfo
*
pRSmaInfo
=
tdGetRSmaInfoByItem
(
pItem
);
if
(
RSMA_INFO_IS_DEL
(
pRSmaInfo
))
{
goto
_end
;
}
int8_t
fetchTriggerStat
=
int8_t
fetchTriggerStat
=
atomic_val_compare_exchange_8
(
&
pItem
->
triggerStat
,
TASK_TRIGGER_STAT_ACTIVE
,
TASK_TRIGGER_STAT_INACTIVE
);
atomic_val_compare_exchange_8
(
&
pItem
->
triggerStat
,
TASK_TRIGGER_STAT_ACTIVE
,
TASK_TRIGGER_STAT_INACTIVE
);
...
@@ -1279,13 +1340,14 @@ static void tdRSmaFetchTrigger(void *param, void *tmrId) {
...
@@ -1279,13 +1340,14 @@ static void tdRSmaFetchTrigger(void *param, void *tmrId) {
smaDebug
(
"vgId:%d, fetch rsma level %"
PRIi8
" data for table:%"
PRIi64
" since stat is active"
,
SMA_VID
(
pSma
),
smaDebug
(
"vgId:%d, fetch rsma level %"
PRIi8
" data for table:%"
PRIi64
" since stat is active"
,
SMA_VID
(
pSma
),
pItem
->
level
,
pRSmaInfo
->
suid
);
pItem
->
level
,
pRSmaInfo
->
suid
);
tdRefSmaStat
(
pSma
,
(
SSmaStat
*
)
pStat
);
// sync procedure => async process
tdRefRSmaInfo
(
pSma
,
pRSmaInfo
);
SSDataBlock
dataBlock
=
{.
info
.
type
=
STREAM_GET_ALL
};
SSDataBlock
dataBlock
=
{.
info
.
type
=
STREAM_GET_ALL
};
qSetStreamInput
(
pItem
->
taskInfo
,
&
dataBlock
,
STREAM_INPUT__DATA_BLOCK
,
false
);
qSetStreamInput
(
pItem
->
taskInfo
,
&
dataBlock
,
STREAM_INPUT__DATA_BLOCK
,
false
);
tdRSmaFetchAndSubmitResult
(
pItem
,
pRSmaInfo
->
pTSchema
,
pRSmaInfo
->
suid
,
pStat
,
STREAM_INPUT__DATA_BLOCK
);
tdRSmaFetchAndSubmitResult
(
pItem
,
pRSmaInfo
->
pTSchema
,
pRSmaInfo
->
suid
,
pStat
,
STREAM_INPUT__DATA_BLOCK
);
tdUnRef
SmaStat
(
pSma
,
(
SSmaStat
*
)
pStat
);
tdUnRef
RSmaInfo
(
pSma
,
pRSmaInfo
);
}
break
;
}
break
;
case
TASK_TRIGGER_STAT_PAUSED
:
{
case
TASK_TRIGGER_STAT_PAUSED
:
{
smaDebug
(
"vgId:%d, not fetch rsma level %"
PRIi8
" data for table:%"
PRIi64
" since stat is paused"
,
smaDebug
(
"vgId:%d, not fetch rsma level %"
PRIi8
" data for table:%"
PRIi64
" since stat is paused"
,
...
...
source/dnode/vnode/src/tq/tqExec.c
浏览文件 @
1b4ed84a
...
@@ -68,7 +68,7 @@ int64_t tqScan(STQ* pTq, const STqHandle* pHandle, SMqDataRsp* pRsp, STqOffsetVa
...
@@ -68,7 +68,7 @@ int64_t tqScan(STQ* pTq, const STqHandle* pHandle, SMqDataRsp* pRsp, STqOffsetVa
pRsp
->
rspOffset
=
*
pOffset
;
pRsp
->
rspOffset
=
*
pOffset
;
return
0
;
return
0
;
}
else
{
}
else
{
tqOffsetResetToLog
(
pOffset
,
pHandle
->
snapshotVer
+
1
);
tqOffsetResetToLog
(
pOffset
,
pHandle
->
snapshotVer
);
if
(
qStreamPrepareScan
(
task
,
pOffset
)
<
0
)
{
if
(
qStreamPrepareScan
(
task
,
pOffset
)
<
0
)
{
pRsp
->
rspOffset
=
*
pOffset
;
pRsp
->
rspOffset
=
*
pOffset
;
return
0
;
return
0
;
...
@@ -106,7 +106,7 @@ int64_t tqScan(STQ* pTq, const STqHandle* pHandle, SMqDataRsp* pRsp, STqOffsetVa
...
@@ -106,7 +106,7 @@ int64_t tqScan(STQ* pTq, const STqHandle* pHandle, SMqDataRsp* pRsp, STqOffsetVa
}
}
if
(
pRsp
->
blockNum
==
0
&&
pOffset
->
type
==
TMQ_OFFSET__SNAPSHOT_DATA
)
{
if
(
pRsp
->
blockNum
==
0
&&
pOffset
->
type
==
TMQ_OFFSET__SNAPSHOT_DATA
)
{
tqOffsetResetToLog
(
pOffset
,
pHandle
->
snapshotVer
+
1
);
tqOffsetResetToLog
(
pOffset
,
pHandle
->
snapshotVer
);
qStreamPrepareScan
(
task
,
pOffset
);
qStreamPrepareScan
(
task
,
pOffset
);
continue
;
continue
;
}
}
...
...
source/dnode/vnode/src/tq/tqPush.c
浏览文件 @
1b4ed84a
...
@@ -243,7 +243,7 @@ int tqPushMsg(STQ* pTq, void* msg, int32_t msgLen, tmsg_t msgType, int64_t ver)
...
@@ -243,7 +243,7 @@ int tqPushMsg(STQ* pTq, void* msg, int32_t msgLen, tmsg_t msgType, int64_t ver)
void
*
data
=
taosMemoryMalloc
(
msgLen
);
void
*
data
=
taosMemoryMalloc
(
msgLen
);
if
(
data
==
NULL
)
{
if
(
data
==
NULL
)
{
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
qError
(
"failed to copy data for stream since out of memory"
);
t
qError
(
"failed to copy data for stream since out of memory"
);
return
-
1
;
return
-
1
;
}
}
memcpy
(
data
,
msg
,
msgLen
);
memcpy
(
data
,
msg
,
msgLen
);
...
...
source/dnode/vnode/src/vnd/vnodeSvr.c
浏览文件 @
1b4ed84a
...
@@ -53,6 +53,7 @@ int32_t vnodePreProcessWriteMsg(SVnode *pVnode, SRpcMsg *pMsg) {
...
@@ -53,6 +53,7 @@ int32_t vnodePreProcessWriteMsg(SVnode *pVnode, SRpcMsg *pMsg) {
*
(
int64_t
*
)(
dc
.
data
+
dc
.
pos
)
=
uid
;
*
(
int64_t
*
)(
dc
.
data
+
dc
.
pos
)
=
uid
;
*
(
int64_t
*
)(
dc
.
data
+
dc
.
pos
+
8
)
=
ctime
;
*
(
int64_t
*
)(
dc
.
data
+
dc
.
pos
+
8
)
=
ctime
;
vTrace
(
"vgId:%d, table:%s uid:%"
PRId64
" is generated"
,
pVnode
->
config
.
vgId
,
name
,
uid
);
tEndDecode
(
&
dc
);
tEndDecode
(
&
dc
);
}
}
...
@@ -381,7 +382,7 @@ static int32_t vnodeProcessDropTtlTbReq(SVnode *pVnode, int64_t version, void *p
...
@@ -381,7 +382,7 @@ static int32_t vnodeProcessDropTtlTbReq(SVnode *pVnode, int64_t version, void *p
goto
end
;
goto
end
;
}
}
v
Info
(
"vgId:%d, drop ttl table req will be processed, time:%d"
,
pVnode
->
config
.
vgId
,
ttlReq
.
timestamp
);
v
Debug
(
"vgId:%d, drop ttl table req will be processed, time:%d"
,
pVnode
->
config
.
vgId
,
ttlReq
.
timestamp
);
int32_t
ret
=
metaTtlDropTable
(
pVnode
->
pMeta
,
ttlReq
.
timestamp
,
tbUids
);
int32_t
ret
=
metaTtlDropTable
(
pVnode
->
pMeta
,
ttlReq
.
timestamp
,
tbUids
);
if
(
ret
!=
0
)
{
if
(
ret
!=
0
)
{
goto
end
;
goto
end
;
...
...
source/dnode/vnode/src/vnd/vnodeSync.c
浏览文件 @
1b4ed84a
...
@@ -17,35 +17,22 @@
...
@@ -17,35 +17,22 @@
#include "vnd.h"
#include "vnd.h"
static
inline
bool
vnodeIsMsgBlock
(
tmsg_t
type
)
{
static
inline
bool
vnodeIsMsgBlock
(
tmsg_t
type
)
{
return
(
type
==
TDMT_VND_CREATE_TABLE
)
||
(
type
==
TDMT_VND_ALTER_CONFIRM
)
||
(
type
==
TDMT_VND_ALTER_REPLICA
);
return
(
type
==
TDMT_VND_CREATE_TABLE
)
||
(
type
==
TDMT_VND_CREATE_TABLE
)
||
(
type
==
TDMT_VND_CREATE_TABLE
)
||
(
type
==
TDMT_VND_ALTER_TABLE
)
||
(
type
==
TDMT_VND_DROP_TABLE
)
||
(
type
==
TDMT_VND_UPDATE_TAG_VAL
);
}
}
static
inline
bool
vnodeIsMsgWeak
(
tmsg_t
type
)
{
return
false
;
}
static
inline
bool
vnodeIsMsgWeak
(
tmsg_t
type
)
{
return
false
;
}
static
inline
void
vnodeAccumBlockMsg
(
SVnode
*
pVnode
,
tmsg_t
type
)
{
static
inline
void
vnodeWaitBlockMsg
(
SVnode
*
pVnode
,
const
SRpcMsg
*
pMsg
)
{
if
(
!
vnodeIsMsgBlock
(
type
))
return
;
if
(
vnodeIsMsgBlock
(
pMsg
->
msgType
))
{
vTrace
(
"vgId:%d, msg:%p wait block, type:%s"
,
pVnode
->
config
.
vgId
,
pMsg
,
TMSG_INFO
(
pMsg
->
msgType
));
int32_t
count
=
atomic_add_fetch_32
(
&
pVnode
->
blockCount
,
1
);
vTrace
(
"vgId:%d, accum block, count:%d type:%s"
,
pVnode
->
config
.
vgId
,
count
,
TMSG_INFO
(
type
));
}
static
inline
void
vnodeWaitBlockMsg
(
SVnode
*
pVnode
)
{
int32_t
count
=
atomic_load_32
(
&
pVnode
->
blockCount
);
if
(
count
<=
0
)
return
;
vTrace
(
"vgId:%d, wait block finish, count:%d"
,
pVnode
->
config
.
vgId
,
count
);
tsem_wait
(
&
pVnode
->
syncSem
);
tsem_wait
(
&
pVnode
->
syncSem
);
}
}
}
static
inline
void
vnodePostBlockMsg
(
SVnode
*
pVnode
,
tmsg_t
type
)
{
static
inline
void
vnodePostBlockMsg
(
SVnode
*
pVnode
,
const
SRpcMsg
*
pMsg
)
{
if
(
!
vnodeIsMsgBlock
(
type
))
return
;
if
(
vnodeIsMsgBlock
(
pMsg
->
msgType
))
{
vTrace
(
"vgId:%d, msg:%p post block, type:%s"
,
pVnode
->
config
.
vgId
,
pMsg
,
TMSG_INFO
(
pMsg
->
msgType
));
int32_t
count
=
atomic_load_32
(
&
pVnode
->
blockCount
);
if
(
count
<=
0
)
return
;
count
=
atomic_sub_fetch_32
(
&
pVnode
->
blockCount
,
1
);
vTrace
(
"vgId:%d, post block, count:%d type:%s"
,
pVnode
->
config
.
vgId
,
count
,
TMSG_INFO
(
type
));
if
(
count
<=
0
)
{
tsem_post
(
&
pVnode
->
syncSem
);
tsem_post
(
&
pVnode
->
syncSem
);
}
}
}
}
...
@@ -143,6 +130,8 @@ void vnodeProposeWriteMsg(SQueueInfo *pInfo, STaosQall *qall, int32_t numOfMsgs)
...
@@ -143,6 +130,8 @@ void vnodeProposeWriteMsg(SQueueInfo *pInfo, STaosQall *qall, int32_t numOfMsgs)
int32_t
code
=
0
;
int32_t
code
=
0
;
SRpcMsg
*
pMsg
=
NULL
;
SRpcMsg
*
pMsg
=
NULL
;
vTrace
(
"vgId:%d, get %d msgs from vnode-write queue"
,
vgId
,
numOfMsgs
);
for
(
int32_t
m
=
0
;
m
<
numOfMsgs
;
m
++
)
{
for
(
int32_t
m
=
0
;
m
<
numOfMsgs
;
m
++
)
{
if
(
taosGetQitem
(
qall
,
(
void
**
)
&
pMsg
)
==
0
)
continue
;
if
(
taosGetQitem
(
qall
,
(
void
**
)
&
pMsg
)
==
0
)
continue
;
const
STraceId
*
trace
=
&
pMsg
->
info
.
traceId
;
const
STraceId
*
trace
=
&
pMsg
->
info
.
traceId
;
...
@@ -165,13 +154,14 @@ void vnodeProposeWriteMsg(SQueueInfo *pInfo, STaosQall *qall, int32_t numOfMsgs)
...
@@ -165,13 +154,14 @@ void vnodeProposeWriteMsg(SQueueInfo *pInfo, STaosQall *qall, int32_t numOfMsgs)
if
(
rsp
.
info
.
handle
!=
NULL
)
{
if
(
rsp
.
info
.
handle
!=
NULL
)
{
tmsgSendRsp
(
&
rsp
);
tmsgSendRsp
(
&
rsp
);
}
}
}
else
if
(
code
==
0
)
{
vnodeWaitBlockMsg
(
pVnode
,
pMsg
);
}
else
{
}
}
}
}
}
}
if
(
code
==
0
)
{
if
(
code
<
0
)
{
vnodeAccumBlockMsg
(
pVnode
,
pMsg
->
msgType
);
}
else
if
(
code
<
0
)
{
if
(
terrno
==
TSDB_CODE_SYN_NOT_LEADER
)
{
if
(
terrno
==
TSDB_CODE_SYN_NOT_LEADER
)
{
vnodeRedirectRpcMsg
(
pVnode
,
pMsg
);
vnodeRedirectRpcMsg
(
pVnode
,
pMsg
);
}
else
{
}
else
{
...
@@ -182,15 +172,12 @@ void vnodeProposeWriteMsg(SQueueInfo *pInfo, STaosQall *qall, int32_t numOfMsgs)
...
@@ -182,15 +172,12 @@ void vnodeProposeWriteMsg(SQueueInfo *pInfo, STaosQall *qall, int32_t numOfMsgs)
tmsgSendRsp
(
&
rsp
);
tmsgSendRsp
(
&
rsp
);
}
}
}
}
}
else
{
}
}
vGTrace
(
"vgId:%d, msg:%p is freed, code:0x%x"
,
vgId
,
pMsg
,
code
);
vGTrace
(
"vgId:%d, msg:%p is freed, code:0x%x"
,
vgId
,
pMsg
,
code
);
rpcFreeCont
(
pMsg
->
pCont
);
rpcFreeCont
(
pMsg
->
pCont
);
taosFreeQitem
(
pMsg
);
taosFreeQitem
(
pMsg
);
}
}
vnodeWaitBlockMsg
(
pVnode
);
}
}
void
vnodeApplyWriteMsg
(
SQueueInfo
*
pInfo
,
STaosQall
*
qall
,
int32_t
numOfMsgs
)
{
void
vnodeApplyWriteMsg
(
SQueueInfo
*
pInfo
,
STaosQall
*
qall
,
int32_t
numOfMsgs
)
{
...
@@ -213,7 +200,7 @@ void vnodeApplyWriteMsg(SQueueInfo *pInfo, STaosQall *qall, int32_t numOfMsgs) {
...
@@ -213,7 +200,7 @@ void vnodeApplyWriteMsg(SQueueInfo *pInfo, STaosQall *qall, int32_t numOfMsgs) {
}
}
}
}
vnodePostBlockMsg
(
pVnode
,
pMsg
->
msgType
);
vnodePostBlockMsg
(
pVnode
,
pMsg
);
if
(
rsp
.
info
.
handle
!=
NULL
)
{
if
(
rsp
.
info
.
handle
!=
NULL
)
{
tmsgSendRsp
(
&
rsp
);
tmsgSendRsp
(
&
rsp
);
}
}
...
@@ -418,7 +405,7 @@ static void vnodeSyncReconfig(struct SSyncFSM *pFsm, const SRpcMsg *pMsg, SReCon
...
@@ -418,7 +405,7 @@ static void vnodeSyncReconfig(struct SSyncFSM *pFsm, const SRpcMsg *pMsg, SReCon
tmsgSendRsp
(
&
rpcMsg
);
tmsgSendRsp
(
&
rpcMsg
);
}
}
vnodePostBlockMsg
(
pVnode
,
TDMT_VND_ALTER_REPLICA
);
vnodePostBlockMsg
(
pVnode
,
pMsg
);
}
}
static
void
vnodeSyncCommitMsg
(
SSyncFSM
*
pFsm
,
const
SRpcMsg
*
pMsg
,
SFsmCbMeta
cbMeta
)
{
static
void
vnodeSyncCommitMsg
(
SSyncFSM
*
pFsm
,
const
SRpcMsg
*
pMsg
,
SFsmCbMeta
cbMeta
)
{
...
...
source/libs/executor/src/timewindowoperator.c
浏览文件 @
1b4ed84a
...
@@ -63,7 +63,6 @@ static int32_t setTimeWindowOutputBuf(SResultRowInfo* pResultRowInfo, STimeWindo
...
@@ -63,7 +63,6 @@ static int32_t setTimeWindowOutputBuf(SResultRowInfo* pResultRowInfo, STimeWindo
SResultRow
**
pResult
,
int64_t
tableGroupId
,
SqlFunctionCtx
*
pCtx
,
SResultRow
**
pResult
,
int64_t
tableGroupId
,
SqlFunctionCtx
*
pCtx
,
int32_t
numOfOutput
,
int32_t
*
rowEntryInfoOffset
,
SAggSupporter
*
pAggSup
,
int32_t
numOfOutput
,
int32_t
*
rowEntryInfoOffset
,
SAggSupporter
*
pAggSup
,
SExecTaskInfo
*
pTaskInfo
)
{
SExecTaskInfo
*
pTaskInfo
)
{
assert
(
win
->
skey
<=
win
->
ekey
);
SResultRow
*
pResultRow
=
doSetResultOutBufByKey
(
pAggSup
->
pResultBuf
,
pResultRowInfo
,
(
char
*
)
&
win
->
skey
,
TSDB_KEYSIZE
,
SResultRow
*
pResultRow
=
doSetResultOutBufByKey
(
pAggSup
->
pResultBuf
,
pResultRowInfo
,
(
char
*
)
&
win
->
skey
,
TSDB_KEYSIZE
,
masterscan
,
tableGroupId
,
pTaskInfo
,
true
,
pAggSup
);
masterscan
,
tableGroupId
,
pTaskInfo
,
true
,
pAggSup
);
...
...
source/libs/function/src/builtins.c
浏览文件 @
1b4ed84a
...
@@ -194,8 +194,9 @@ static bool validateTimezoneFormat(const SValueNode* pVal) {
...
@@ -194,8 +194,9 @@ static bool validateTimezoneFormat(const SValueNode* pVal) {
void
static
addTimezoneParam
(
SNodeList
*
pList
)
{
void
static
addTimezoneParam
(
SNodeList
*
pList
)
{
char
buf
[
6
]
=
{
0
};
char
buf
[
6
]
=
{
0
};
time_t
t
=
taosTime
(
NULL
);
time_t
t
=
taosTime
(
NULL
);
struct
tm
*
tmInfo
=
taosLocalTime
(
&
t
,
NULL
);
struct
tm
tmInfo
;
strftime
(
buf
,
sizeof
(
buf
),
"%z"
,
tmInfo
);
taosLocalTime
(
&
t
,
&
tmInfo
);
strftime
(
buf
,
sizeof
(
buf
),
"%z"
,
&
tmInfo
);
int32_t
len
=
(
int32_t
)
strlen
(
buf
);
int32_t
len
=
(
int32_t
)
strlen
(
buf
);
SValueNode
*
pVal
=
(
SValueNode
*
)
nodesMakeNode
(
QUERY_NODE_VALUE
);
SValueNode
*
pVal
=
(
SValueNode
*
)
nodesMakeNode
(
QUERY_NODE_VALUE
);
...
@@ -1422,14 +1423,6 @@ static int32_t translateIrate(SFunctionNode* pFunc, char* pErrBuf, int32_t len)
...
@@ -1422,14 +1423,6 @@ static int32_t translateIrate(SFunctionNode* pFunc, char* pErrBuf, int32_t len)
}
}
static
int32_t
translateFirstLast
(
SFunctionNode
*
pFunc
,
char
*
pErrBuf
,
int32_t
len
)
{
static
int32_t
translateFirstLast
(
SFunctionNode
*
pFunc
,
char
*
pErrBuf
,
int32_t
len
)
{
int32_t
numOfParams
=
LIST_LENGTH
(
pFunc
->
pParameterList
);
for
(
int32_t
i
=
0
;
i
<
numOfParams
;
++
i
)
{
SNode
*
pParamNode
=
nodesListGetNode
(
pFunc
->
pParameterList
,
i
);
if
(
QUERY_NODE_VALUE
==
nodeType
(
pParamNode
))
{
return
invaildFuncParaValueErrMsg
(
pErrBuf
,
len
,
pFunc
->
functionName
);
}
}
pFunc
->
node
.
resType
=
((
SExprNode
*
)
nodesListGetNode
(
pFunc
->
pParameterList
,
0
))
->
resType
;
pFunc
->
node
.
resType
=
((
SExprNode
*
)
nodesListGetNode
(
pFunc
->
pParameterList
,
0
))
->
resType
;
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
...
...
source/libs/nodes/src/nodesCodeFuncs.c
浏览文件 @
1b4ed84a
...
@@ -548,37 +548,12 @@ static const char* jkScanLogicPlanScanPseudoCols = "ScanPseudoCols";
...
@@ -548,37 +548,12 @@ static const char* jkScanLogicPlanScanPseudoCols = "ScanPseudoCols";
static
const
char
*
jkScanLogicPlanTableType
=
"TableType"
;
static
const
char
*
jkScanLogicPlanTableType
=
"TableType"
;
static
const
char
*
jkScanLogicPlanTableId
=
"TableId"
;
static
const
char
*
jkScanLogicPlanTableId
=
"TableId"
;
static
const
char
*
jkScanLogicPlanStableId
=
"StableId"
;
static
const
char
*
jkScanLogicPlanStableId
=
"StableId"
;
static
const
char
*
jkScanLogicPlanScanType
=
"ScanType"
;
static
const
char
*
jkScanLogicPlanScanCount
=
"ScanCount"
;
static
const
char
*
jkScanLogicPlanScanCount
=
"ScanCount"
;
static
const
char
*
jkScanLogicPlanReverseScanCount
=
"ReverseScanCount"
;
static
const
char
*
jkScanLogicPlanReverseScanCount
=
"ReverseScanCount"
;
static
const
char
*
jkScanLogicPlanTagCond
=
"TagCond"
;
static
const
char
*
jkScanLogicPlanTagCond
=
"TagCond"
;
static
const
char
*
jkScanLogicPlanGroupTags
=
"GroupTags"
;
static
const
char
*
jkScanLogicPlanGroupTags
=
"GroupTags"
;
// typedef struct SScanLogicNode {
// uint64_t stableId;
// SVgroupsInfo* pVgroupList;
// EScanType scanType;
// uint8_t scanSeq[2]; // first is scan count, and second is reverse scan count
// STimeWindow scanRange;
// SName tableName;
// bool showRewrite;
// double ratio;
// SNodeList* pDynamicScanFuncs;
// int32_t dataRequired;
// int64_t interval;
// int64_t offset;
// int64_t sliding;
// int8_t intervalUnit;
// int8_t slidingUnit;
// SNode* pTagCond;
// SNode* pTagIndexCond;
// int8_t triggerType;
// int64_t watermark;
// int8_t igExpired;
// SArray* pSmaIndexes;
// SNodeList* pGroupTags;
// bool groupSort;
// } SScanLogicNode;
static
int32_t
logicScanNodeToJson
(
const
void
*
pObj
,
SJson
*
pJson
)
{
static
int32_t
logicScanNodeToJson
(
const
void
*
pObj
,
SJson
*
pJson
)
{
const
SScanLogicNode
*
pNode
=
(
const
SScanLogicNode
*
)
pObj
;
const
SScanLogicNode
*
pNode
=
(
const
SScanLogicNode
*
)
pObj
;
...
@@ -598,6 +573,9 @@ static int32_t logicScanNodeToJson(const void* pObj, SJson* pJson) {
...
@@ -598,6 +573,9 @@ static int32_t logicScanNodeToJson(const void* pObj, SJson* pJson) {
if
(
TSDB_CODE_SUCCESS
==
code
)
{
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
tjsonAddIntegerToObject
(
pJson
,
jkScanLogicPlanStableId
,
pNode
->
stableId
);
code
=
tjsonAddIntegerToObject
(
pJson
,
jkScanLogicPlanStableId
,
pNode
->
stableId
);
}
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
tjsonAddIntegerToObject
(
pJson
,
jkScanLogicPlanScanType
,
pNode
->
scanType
);
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
tjsonAddIntegerToObject
(
pJson
,
jkScanLogicPlanScanCount
,
pNode
->
scanSeq
[
0
]);
code
=
tjsonAddIntegerToObject
(
pJson
,
jkScanLogicPlanScanCount
,
pNode
->
scanSeq
[
0
]);
}
}
...
@@ -634,6 +612,9 @@ static int32_t jsonToLogicScanNode(const SJson* pJson, void* pObj) {
...
@@ -634,6 +612,9 @@ static int32_t jsonToLogicScanNode(const SJson* pJson, void* pObj) {
if
(
TSDB_CODE_SUCCESS
==
code
)
{
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
tjsonGetUBigIntValue
(
pJson
,
jkScanLogicPlanStableId
,
&
pNode
->
stableId
);
code
=
tjsonGetUBigIntValue
(
pJson
,
jkScanLogicPlanStableId
,
&
pNode
->
stableId
);
}
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
tjsonGetNumberValue
(
pJson
,
jkScanLogicPlanScanType
,
pNode
->
scanType
,
code
);
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
tjsonGetUTinyIntValue
(
pJson
,
jkScanLogicPlanScanCount
,
&
pNode
->
scanSeq
[
0
]);
code
=
tjsonGetUTinyIntValue
(
pJson
,
jkScanLogicPlanScanCount
,
&
pNode
->
scanSeq
[
0
]);
}
}
...
@@ -1677,6 +1658,7 @@ static int32_t jsonToPhysiSysTableScanNode(const SJson* pJson, void* pObj) {
...
@@ -1677,6 +1658,7 @@ static int32_t jsonToPhysiSysTableScanNode(const SJson* pJson, void* pObj) {
}
}
static
const
char
*
jkProjectPhysiPlanProjections
=
"Projections"
;
static
const
char
*
jkProjectPhysiPlanProjections
=
"Projections"
;
static
const
char
*
jkProjectPhysiPlanMergeDataBlock
=
"MergeDataBlock"
;
static
int32_t
physiProjectNodeToJson
(
const
void
*
pObj
,
SJson
*
pJson
)
{
static
int32_t
physiProjectNodeToJson
(
const
void
*
pObj
,
SJson
*
pJson
)
{
const
SProjectPhysiNode
*
pNode
=
(
const
SProjectPhysiNode
*
)
pObj
;
const
SProjectPhysiNode
*
pNode
=
(
const
SProjectPhysiNode
*
)
pObj
;
...
@@ -1685,6 +1667,9 @@ static int32_t physiProjectNodeToJson(const void* pObj, SJson* pJson) {
...
@@ -1685,6 +1667,9 @@ static int32_t physiProjectNodeToJson(const void* pObj, SJson* pJson) {
if
(
TSDB_CODE_SUCCESS
==
code
)
{
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
nodeListToJson
(
pJson
,
jkProjectPhysiPlanProjections
,
pNode
->
pProjections
);
code
=
nodeListToJson
(
pJson
,
jkProjectPhysiPlanProjections
,
pNode
->
pProjections
);
}
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
tjsonAddBoolToObject
(
pJson
,
jkProjectPhysiPlanMergeDataBlock
,
pNode
->
mergeDataBlock
);
}
return
code
;
return
code
;
}
}
...
@@ -1696,6 +1681,9 @@ static int32_t jsonToPhysiProjectNode(const SJson* pJson, void* pObj) {
...
@@ -1696,6 +1681,9 @@ static int32_t jsonToPhysiProjectNode(const SJson* pJson, void* pObj) {
if
(
TSDB_CODE_SUCCESS
==
code
)
{
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
jsonToNodeList
(
pJson
,
jkProjectPhysiPlanProjections
,
&
pNode
->
pProjections
);
code
=
jsonToNodeList
(
pJson
,
jkProjectPhysiPlanProjections
,
&
pNode
->
pProjections
);
}
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
tjsonGetBoolValue
(
pJson
,
jkProjectPhysiPlanMergeDataBlock
,
&
pNode
->
mergeDataBlock
);
}
return
code
;
return
code
;
}
}
...
...
source/libs/parser/src/parCalcConst.c
浏览文件 @
1b4ed84a
...
@@ -201,7 +201,8 @@ static int32_t calcConstProject(SNode* pProject, bool dual, SNode** pNew) {
...
@@ -201,7 +201,8 @@ static int32_t calcConstProject(SNode* pProject, bool dual, SNode** pNew) {
}
}
static
bool
isUselessCol
(
SExprNode
*
pProj
)
{
static
bool
isUselessCol
(
SExprNode
*
pProj
)
{
if
(
QUERY_NODE_FUNCTION
==
nodeType
(
pProj
)
&&
!
fmIsScalarFunc
(((
SFunctionNode
*
)
pProj
)
->
funcId
))
{
if
(
QUERY_NODE_FUNCTION
==
nodeType
(
pProj
)
&&
!
fmIsScalarFunc
(((
SFunctionNode
*
)
pProj
)
->
funcId
)
&&
!
fmIsPseudoColumnFunc
(((
SFunctionNode
*
)
pProj
)
->
funcId
))
{
return
false
;
return
false
;
}
}
return
NULL
==
((
SExprNode
*
)
pProj
)
->
pAssociation
;
return
NULL
==
((
SExprNode
*
)
pProj
)
->
pAssociation
;
...
...
source/libs/parser/src/parTranslater.c
浏览文件 @
1b4ed84a
...
@@ -5968,6 +5968,7 @@ static int32_t buildUpdateTagValReq(STranslateContext* pCxt, SAlterTableStmt* pS
...
@@ -5968,6 +5968,7 @@ static int32_t buildUpdateTagValReq(STranslateContext* pCxt, SAlterTableStmt* pS
if
(
NULL
==
pReq
->
tagName
)
{
if
(
NULL
==
pReq
->
tagName
)
{
return
TSDB_CODE_OUT_OF_MEMORY
;
return
TSDB_CODE_OUT_OF_MEMORY
;
}
}
pReq
->
colId
=
pSchema
->
colId
;
SDataType
targetDt
=
schemaToDataType
(
pTableMeta
->
tableInfo
.
precision
,
pSchema
);
SDataType
targetDt
=
schemaToDataType
(
pTableMeta
->
tableInfo
.
precision
,
pSchema
);
if
(
DEAL_RES_ERROR
==
translateValueImpl
(
pCxt
,
pStmt
->
pVal
,
targetDt
,
true
))
{
if
(
DEAL_RES_ERROR
==
translateValueImpl
(
pCxt
,
pStmt
->
pVal
,
targetDt
,
true
))
{
...
@@ -6051,6 +6052,7 @@ static int32_t buildDropColReq(STranslateContext* pCxt, SAlterTableStmt* pStmt,
...
@@ -6051,6 +6052,7 @@ static int32_t buildDropColReq(STranslateContext* pCxt, SAlterTableStmt* pStmt,
if
(
NULL
==
pReq
->
colName
)
{
if
(
NULL
==
pReq
->
colName
)
{
return
TSDB_CODE_OUT_OF_MEMORY
;
return
TSDB_CODE_OUT_OF_MEMORY
;
}
}
pReq
->
colId
=
pSchema
->
colId
;
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
...
@@ -6071,6 +6073,7 @@ static int32_t buildUpdateColReq(STranslateContext* pCxt, SAlterTableStmt* pStmt
...
@@ -6071,6 +6073,7 @@ static int32_t buildUpdateColReq(STranslateContext* pCxt, SAlterTableStmt* pStmt
if
(
NULL
==
pReq
->
colName
)
{
if
(
NULL
==
pReq
->
colName
)
{
return
TSDB_CODE_OUT_OF_MEMORY
;
return
TSDB_CODE_OUT_OF_MEMORY
;
}
}
pReq
->
colId
=
pSchema
->
colId
;
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
...
...
source/libs/planner/src/planLogicCreater.c
浏览文件 @
1b4ed84a
...
@@ -20,6 +20,7 @@
...
@@ -20,6 +20,7 @@
typedef
struct
SLogicPlanContext
{
typedef
struct
SLogicPlanContext
{
SPlanContext
*
pPlanCxt
;
SPlanContext
*
pPlanCxt
;
SLogicNode
*
pCurrRoot
;
SLogicNode
*
pCurrRoot
;
bool
hasScan
;
}
SLogicPlanContext
;
}
SLogicPlanContext
;
typedef
int32_t
(
*
FCreateLogicNode
)(
SLogicPlanContext
*
,
void
*
,
SLogicNode
**
);
typedef
int32_t
(
*
FCreateLogicNode
)(
SLogicPlanContext
*
,
void
*
,
SLogicNode
**
);
...
@@ -161,6 +162,10 @@ static EScanType getScanType(SLogicPlanContext* pCxt, SNodeList* pScanPseudoCols
...
@@ -161,6 +162,10 @@ static EScanType getScanType(SLogicPlanContext* pCxt, SNodeList* pScanPseudoCols
return
SCAN_TYPE_STREAM
;
return
SCAN_TYPE_STREAM
;
}
}
if
(
TSDB_SYSTEM_TABLE
==
tableType
)
{
return
SCAN_TYPE_SYSTEM_TABLE
;
}
if
(
NULL
==
pScanCols
)
{
if
(
NULL
==
pScanCols
)
{
return
NULL
==
pScanPseudoCols
return
NULL
==
pScanPseudoCols
?
SCAN_TYPE_TABLE
?
SCAN_TYPE_TABLE
...
@@ -169,17 +174,6 @@ static EScanType getScanType(SLogicPlanContext* pCxt, SNodeList* pScanPseudoCols
...
@@ -169,17 +174,6 @@ static EScanType getScanType(SLogicPlanContext* pCxt, SNodeList* pScanPseudoCols
:
SCAN_TYPE_TABLE
);
:
SCAN_TYPE_TABLE
);
}
}
if
(
TSDB_SYSTEM_TABLE
==
tableType
)
{
return
SCAN_TYPE_SYSTEM_TABLE
;
}
SNode
*
pCol
=
NULL
;
FOREACH
(
pCol
,
pScanCols
)
{
if
(
COLUMN_TYPE_COLUMN
==
((
SColumnNode
*
)
pCol
)
->
colType
)
{
return
SCAN_TYPE_TABLE
;
}
}
return
SCAN_TYPE_TABLE
;
return
SCAN_TYPE_TABLE
;
}
}
...
@@ -300,6 +294,8 @@ static int32_t createScanLogicNode(SLogicPlanContext* pCxt, SSelectStmt* pSelect
...
@@ -300,6 +294,8 @@ static int32_t createScanLogicNode(SLogicPlanContext* pCxt, SSelectStmt* pSelect
nodesDestroyNode
((
SNode
*
)
pScan
);
nodesDestroyNode
((
SNode
*
)
pScan
);
}
}
pCxt
->
hasScan
=
true
;
return
code
;
return
code
;
}
}
...
@@ -1339,9 +1335,9 @@ static void doSetLogicNodeParent(SLogicNode* pNode, SLogicNode* pParent) {
...
@@ -1339,9 +1335,9 @@ static void doSetLogicNodeParent(SLogicNode* pNode, SLogicNode* pParent) {
static
void
setLogicNodeParent
(
SLogicNode
*
pNode
)
{
doSetLogicNodeParent
(
pNode
,
NULL
);
}
static
void
setLogicNodeParent
(
SLogicNode
*
pNode
)
{
doSetLogicNodeParent
(
pNode
,
NULL
);
}
static
void
setLogicSubplanType
(
SLogicSubplan
*
pSubplan
)
{
static
void
setLogicSubplanType
(
bool
hasScan
,
SLogicSubplan
*
pSubplan
)
{
if
(
QUERY_NODE_LOGIC_PLAN_VNODE_MODIFY
!=
nodeType
(
pSubplan
->
pNode
))
{
if
(
QUERY_NODE_LOGIC_PLAN_VNODE_MODIFY
!=
nodeType
(
pSubplan
->
pNode
))
{
pSubplan
->
subplanType
=
SUBPLAN_TYPE_SCAN
;
pSubplan
->
subplanType
=
hasScan
?
SUBPLAN_TYPE_SCAN
:
SUBPLAN_TYPE_MERGE
;
}
else
{
}
else
{
SVnodeModifyLogicNode
*
pModify
=
(
SVnodeModifyLogicNode
*
)
pSubplan
->
pNode
;
SVnodeModifyLogicNode
*
pModify
=
(
SVnodeModifyLogicNode
*
)
pSubplan
->
pNode
;
pSubplan
->
subplanType
=
(
MODIFY_TABLE_TYPE_INSERT
==
pModify
->
modifyType
&&
NULL
!=
pModify
->
node
.
pChildren
)
pSubplan
->
subplanType
=
(
MODIFY_TABLE_TYPE_INSERT
==
pModify
->
modifyType
&&
NULL
!=
pModify
->
node
.
pChildren
)
...
@@ -1351,7 +1347,7 @@ static void setLogicSubplanType(SLogicSubplan* pSubplan) {
...
@@ -1351,7 +1347,7 @@ static void setLogicSubplanType(SLogicSubplan* pSubplan) {
}
}
int32_t
createLogicPlan
(
SPlanContext
*
pCxt
,
SLogicSubplan
**
pLogicSubplan
)
{
int32_t
createLogicPlan
(
SPlanContext
*
pCxt
,
SLogicSubplan
**
pLogicSubplan
)
{
SLogicPlanContext
cxt
=
{.
pPlanCxt
=
pCxt
};
SLogicPlanContext
cxt
=
{.
pPlanCxt
=
pCxt
,
.
pCurrRoot
=
NULL
,
.
hasScan
=
false
};
SLogicSubplan
*
pSubplan
=
(
SLogicSubplan
*
)
nodesMakeNode
(
QUERY_NODE_LOGIC_SUBPLAN
);
SLogicSubplan
*
pSubplan
=
(
SLogicSubplan
*
)
nodesMakeNode
(
QUERY_NODE_LOGIC_SUBPLAN
);
if
(
NULL
==
pSubplan
)
{
if
(
NULL
==
pSubplan
)
{
...
@@ -1364,7 +1360,7 @@ int32_t createLogicPlan(SPlanContext* pCxt, SLogicSubplan** pLogicSubplan) {
...
@@ -1364,7 +1360,7 @@ int32_t createLogicPlan(SPlanContext* pCxt, SLogicSubplan** pLogicSubplan) {
int32_t
code
=
createQueryLogicNode
(
&
cxt
,
pCxt
->
pAstRoot
,
&
pSubplan
->
pNode
);
int32_t
code
=
createQueryLogicNode
(
&
cxt
,
pCxt
->
pAstRoot
,
&
pSubplan
->
pNode
);
if
(
TSDB_CODE_SUCCESS
==
code
)
{
if
(
TSDB_CODE_SUCCESS
==
code
)
{
setLogicNodeParent
(
pSubplan
->
pNode
);
setLogicNodeParent
(
pSubplan
->
pNode
);
setLogicSubplanType
(
pSubplan
);
setLogicSubplanType
(
cxt
.
hasScan
,
pSubplan
);
}
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
if
(
TSDB_CODE_SUCCESS
==
code
)
{
...
...
source/libs/planner/src/planPhysiCreater.c
浏览文件 @
1b4ed84a
...
@@ -35,7 +35,8 @@ typedef struct SPhysiPlanContext {
...
@@ -35,7 +35,8 @@ typedef struct SPhysiPlanContext {
int32_t
errCode
;
int32_t
errCode
;
int16_t
nextDataBlockId
;
int16_t
nextDataBlockId
;
SArray
*
pLocationHelper
;
SArray
*
pLocationHelper
;
SArray
*
pExecNodeList
;
// SArray<SQueryNodeLoad>
bool
hasScan
;
bool
hasSysScan
;
}
SPhysiPlanContext
;
}
SPhysiPlanContext
;
static
int32_t
getSlotKey
(
SNode
*
pNode
,
const
char
*
pStmtName
,
char
*
pKey
)
{
static
int32_t
getSlotKey
(
SNode
*
pNode
,
const
char
*
pStmtName
,
char
*
pKey
)
{
...
@@ -495,8 +496,6 @@ static int32_t createSimpleScanPhysiNode(SPhysiPlanContext* pCxt, SSubplan* pSub
...
@@ -495,8 +496,6 @@ static int32_t createSimpleScanPhysiNode(SPhysiPlanContext* pCxt, SSubplan* pSub
return
TSDB_CODE_OUT_OF_MEMORY
;
return
TSDB_CODE_OUT_OF_MEMORY
;
}
}
vgroupInfoToNodeAddr
(
pScanLogicNode
->
pVgroupList
->
vgroups
,
&
pSubplan
->
execNode
);
vgroupInfoToNodeAddr
(
pScanLogicNode
->
pVgroupList
->
vgroups
,
&
pSubplan
->
execNode
);
SQueryNodeLoad
node
=
{.
addr
=
pSubplan
->
execNode
,
.
load
=
0
};
taosArrayPush
(
pCxt
->
pExecNodeList
,
&
node
);
return
createScanPhysiNodeFinalize
(
pCxt
,
pSubplan
,
pScanLogicNode
,
pScan
,
pPhyNode
);
return
createScanPhysiNodeFinalize
(
pCxt
,
pSubplan
,
pScanLogicNode
,
pScan
,
pPhyNode
);
}
}
...
@@ -577,8 +576,6 @@ static int32_t createSystemTableScanPhysiNode(SPhysiPlanContext* pCxt, SSubplan*
...
@@ -577,8 +576,6 @@ static int32_t createSystemTableScanPhysiNode(SPhysiPlanContext* pCxt, SSubplan*
pSubplan
->
execNode
.
nodeId
=
MNODE_HANDLE
;
pSubplan
->
execNode
.
nodeId
=
MNODE_HANDLE
;
pSubplan
->
execNode
.
epSet
=
pCxt
->
pPlanCxt
->
mgmtEpSet
;
pSubplan
->
execNode
.
epSet
=
pCxt
->
pPlanCxt
->
mgmtEpSet
;
}
}
SQueryNodeLoad
node
=
{.
addr
=
{.
nodeId
=
MNODE_HANDLE
,
.
epSet
=
pCxt
->
pPlanCxt
->
mgmtEpSet
},
.
load
=
0
};
taosArrayPush
(
pCxt
->
pExecNodeList
,
&
node
);
if
(
0
==
strcmp
(
pScanLogicNode
->
tableName
.
tname
,
TSDB_INS_TABLE_DNODE_VARIABLES
))
{
if
(
0
==
strcmp
(
pScanLogicNode
->
tableName
.
tname
,
TSDB_INS_TABLE_DNODE_VARIABLES
))
{
pScan
->
mgmtEpSet
=
pScanLogicNode
->
pVgroupList
->
vgroups
->
epSet
;
pScan
->
mgmtEpSet
=
pScanLogicNode
->
pVgroupList
->
vgroups
->
epSet
;
}
else
{
}
else
{
...
@@ -586,6 +583,7 @@ static int32_t createSystemTableScanPhysiNode(SPhysiPlanContext* pCxt, SSubplan*
...
@@ -586,6 +583,7 @@ static int32_t createSystemTableScanPhysiNode(SPhysiPlanContext* pCxt, SSubplan*
}
}
tNameGetFullDbName
(
&
pScanLogicNode
->
tableName
,
pSubplan
->
dbFName
);
tNameGetFullDbName
(
&
pScanLogicNode
->
tableName
,
pSubplan
->
dbFName
);
pCxt
->
hasSysScan
=
true
;
return
createScanPhysiNodeFinalize
(
pCxt
,
pSubplan
,
pScanLogicNode
,
(
SScanPhysiNode
*
)
pScan
,
pPhyNode
);
return
createScanPhysiNodeFinalize
(
pCxt
,
pSubplan
,
pScanLogicNode
,
(
SScanPhysiNode
*
)
pScan
,
pPhyNode
);
}
}
...
@@ -601,6 +599,7 @@ static int32_t createTableMergeScanPhysiNode(SPhysiPlanContext* pCxt, SSubplan*
...
@@ -601,6 +599,7 @@ static int32_t createTableMergeScanPhysiNode(SPhysiPlanContext* pCxt, SSubplan*
static
int32_t
createScanPhysiNode
(
SPhysiPlanContext
*
pCxt
,
SSubplan
*
pSubplan
,
SScanLogicNode
*
pScanLogicNode
,
static
int32_t
createScanPhysiNode
(
SPhysiPlanContext
*
pCxt
,
SSubplan
*
pSubplan
,
SScanLogicNode
*
pScanLogicNode
,
SPhysiNode
**
pPhyNode
)
{
SPhysiNode
**
pPhyNode
)
{
pCxt
->
hasScan
=
true
;
switch
(
pScanLogicNode
->
scanType
)
{
switch
(
pScanLogicNode
->
scanType
)
{
case
SCAN_TYPE_TAG
:
case
SCAN_TYPE_TAG
:
case
SCAN_TYPE_BLOCK_INFO
:
case
SCAN_TYPE_BLOCK_INFO
:
...
@@ -1806,23 +1805,31 @@ static void setExplainInfo(SPlanContext* pCxt, SQueryPlan* pPlan) {
...
@@ -1806,23 +1805,31 @@ static void setExplainInfo(SPlanContext* pCxt, SQueryPlan* pPlan) {
}
}
}
}
static
void
setExecNodeList
(
SPhysiPlanContext
*
pCxt
,
SArray
*
pExecNodeList
)
{
if
(
NULL
==
pExecNodeList
)
{
return
;
}
if
(
pCxt
->
hasSysScan
||
!
pCxt
->
hasScan
)
{
SQueryNodeLoad
node
=
{.
addr
=
{.
nodeId
=
MNODE_HANDLE
,
.
epSet
=
pCxt
->
pPlanCxt
->
mgmtEpSet
},
.
load
=
0
};
taosArrayPush
(
pExecNodeList
,
&
node
);
}
}
int32_t
createPhysiPlan
(
SPlanContext
*
pCxt
,
SQueryLogicPlan
*
pLogicPlan
,
SQueryPlan
**
pPlan
,
SArray
*
pExecNodeList
)
{
int32_t
createPhysiPlan
(
SPlanContext
*
pCxt
,
SQueryLogicPlan
*
pLogicPlan
,
SQueryPlan
**
pPlan
,
SArray
*
pExecNodeList
)
{
SPhysiPlanContext
cxt
=
{.
pPlanCxt
=
pCxt
,
SPhysiPlanContext
cxt
=
{.
pPlanCxt
=
pCxt
,
.
errCode
=
TSDB_CODE_SUCCESS
,
.
errCode
=
TSDB_CODE_SUCCESS
,
.
nextDataBlockId
=
0
,
.
nextDataBlockId
=
0
,
.
pLocationHelper
=
taosArrayInit
(
32
,
POINTER_BYTES
),
.
pLocationHelper
=
taosArrayInit
(
32
,
POINTER_BYTES
),
.
pExecNodeList
=
pExecNodeList
};
.
hasScan
=
false
,
.
hasSysScan
=
false
};
if
(
NULL
==
cxt
.
pLocationHelper
)
{
if
(
NULL
==
cxt
.
pLocationHelper
)
{
return
TSDB_CODE_OUT_OF_MEMORY
;
return
TSDB_CODE_OUT_OF_MEMORY
;
}
}
if
(
QUERY_POLICY_VNODE
==
tsQueryPolicy
)
{
taosArrayClear
(
pExecNodeList
);
}
int32_t
code
=
doCreatePhysiPlan
(
&
cxt
,
pLogicPlan
,
pPlan
);
int32_t
code
=
doCreatePhysiPlan
(
&
cxt
,
pLogicPlan
,
pPlan
);
if
(
TSDB_CODE_SUCCESS
==
code
)
{
if
(
TSDB_CODE_SUCCESS
==
code
)
{
setExplainInfo
(
pCxt
,
*
pPlan
);
setExplainInfo
(
pCxt
,
*
pPlan
);
setExecNodeList
(
&
cxt
,
pExecNodeList
);
}
}
destoryPhysiPlanContext
(
&
cxt
);
destoryPhysiPlanContext
(
&
cxt
);
...
...
source/libs/scalar/src/sclfunc.c
浏览文件 @
1b4ed84a
...
@@ -1062,8 +1062,9 @@ int32_t toISO8601Function(SScalarParam *pInput, int32_t inputNum, SScalarParam *
...
@@ -1062,8 +1062,9 @@ int32_t toISO8601Function(SScalarParam *pInput, int32_t inputNum, SScalarParam *
memmove
(
fraction
,
fraction
+
TSDB_TIME_PRECISION_SEC_DIGITS
,
TSDB_TIME_PRECISION_SEC_DIGITS
);
memmove
(
fraction
,
fraction
+
TSDB_TIME_PRECISION_SEC_DIGITS
,
TSDB_TIME_PRECISION_SEC_DIGITS
);
}
}
struct
tm
*
tmInfo
=
taosLocalTime
((
const
time_t
*
)
&
timeVal
,
NULL
);
struct
tm
tmInfo
;
strftime
(
buf
,
sizeof
(
buf
),
"%Y-%m-%dT%H:%M:%S"
,
tmInfo
);
taosLocalTime
((
const
time_t
*
)
&
timeVal
,
&
tmInfo
);
strftime
(
buf
,
sizeof
(
buf
),
"%Y-%m-%dT%H:%M:%S"
,
&
tmInfo
);
int32_t
len
=
(
int32_t
)
strlen
(
buf
);
int32_t
len
=
(
int32_t
)
strlen
(
buf
);
//add timezone string
//add timezone string
...
...
source/libs/sync/inc/syncInt.h
浏览文件 @
1b4ed84a
...
@@ -192,6 +192,7 @@ int32_t syncNodeRestartElectTimer(SSyncNode* pSyncNode, int32_t ms);
...
@@ -192,6 +192,7 @@ int32_t syncNodeRestartElectTimer(SSyncNode* pSyncNode, int32_t ms);
int32_t
syncNodeResetElectTimer
(
SSyncNode
*
pSyncNode
);
int32_t
syncNodeResetElectTimer
(
SSyncNode
*
pSyncNode
);
int32_t
syncNodeStartHeartbeatTimer
(
SSyncNode
*
pSyncNode
);
int32_t
syncNodeStartHeartbeatTimer
(
SSyncNode
*
pSyncNode
);
int32_t
syncNodeStopHeartbeatTimer
(
SSyncNode
*
pSyncNode
);
int32_t
syncNodeStopHeartbeatTimer
(
SSyncNode
*
pSyncNode
);
int32_t
syncNodeRestartHeartbeatTimer
(
SSyncNode
*
pSyncNode
);
// utils --------------
// utils --------------
int32_t
syncNodeSendMsgById
(
const
SRaftId
*
destRaftId
,
SSyncNode
*
pSyncNode
,
SRpcMsg
*
pMsg
);
int32_t
syncNodeSendMsgById
(
const
SRaftId
*
destRaftId
,
SSyncNode
*
pSyncNode
,
SRpcMsg
*
pMsg
);
...
...
source/libs/sync/src/syncMain.c
浏览文件 @
1b4ed84a
...
@@ -1298,6 +1298,12 @@ int32_t syncNodeStopHeartbeatTimer(SSyncNode* pSyncNode) {
...
@@ -1298,6 +1298,12 @@ int32_t syncNodeStopHeartbeatTimer(SSyncNode* pSyncNode) {
return
ret
;
return
ret
;
}
}
int32_t
syncNodeRestartHeartbeatTimer
(
SSyncNode
*
pSyncNode
)
{
syncNodeStopHeartbeatTimer
(
pSyncNode
);
syncNodeStartHeartbeatTimer
(
pSyncNode
);
return
0
;
}
// utils --------------
// utils --------------
int32_t
syncNodeSendMsgById
(
const
SRaftId
*
destRaftId
,
SSyncNode
*
pSyncNode
,
SRpcMsg
*
pMsg
)
{
int32_t
syncNodeSendMsgById
(
const
SRaftId
*
destRaftId
,
SSyncNode
*
pSyncNode
,
SRpcMsg
*
pMsg
)
{
SEpSet
epSet
;
SEpSet
epSet
;
...
...
source/libs/tdb/src/db/tdbBtree.c
浏览文件 @
1b4ed84a
...
@@ -103,10 +103,9 @@ int tdbBtreeOpen(int keyLen, int valLen, SPager *pPager, char const *tbname, SPg
...
@@ -103,10 +103,9 @@ int tdbBtreeOpen(int keyLen, int valLen, SPager *pPager, char const *tbname, SPg
// if pgno == 0 fetch new btree root leaf page
// if pgno == 0 fetch new btree root leaf page
if
(
pgno
==
0
)
{
if
(
pgno
==
0
)
{
// fetch page & insert into main db
// fetch page & insert into main db
// allocate a new child page
SPage
*
pPage
;
SPage
*
pPage
;
TXN
txn
;
TXN
txn
;
tdbTxnOpen
(
&
txn
,
0
,
tdbDefaultMalloc
,
tdbDefaultFree
,
NULL
,
0
);
tdbTxnOpen
(
&
txn
,
0
,
tdbDefaultMalloc
,
tdbDefaultFree
,
NULL
,
TDB_TXN_WRITE
|
TDB_TXN_READ_UNCOMMITTED
);
pPager
->
inTran
=
1
;
pPager
->
inTran
=
1
;
...
@@ -118,8 +117,6 @@ int tdbBtreeOpen(int keyLen, int valLen, SPager *pPager, char const *tbname, SPg
...
@@ -118,8 +117,6 @@ int tdbBtreeOpen(int keyLen, int valLen, SPager *pPager, char const *tbname, SPg
return
-
1
;
return
-
1
;
}
}
// TODO: Need to zero the page
ret
=
tdbPagerWrite
(
pPager
,
pPage
);
ret
=
tdbPagerWrite
(
pPager
,
pPage
);
if
(
ret
<
0
)
{
if
(
ret
<
0
)
{
return
-
1
;
return
-
1
;
...
...
source/libs/tdb/src/db/tdbPager.c
浏览文件 @
1b4ed84a
...
@@ -473,12 +473,6 @@ int tdbPagerRestore(SPager *pPager, SBTree *pBt) {
...
@@ -473,12 +473,6 @@ int tdbPagerRestore(SPager *pPager, SBTree *pBt) {
return
-
1
;
return
-
1
;
}
}
TXN
txn
;
tdbTxnOpen
(
&
txn
,
0
,
tdbDefaultMalloc
,
tdbDefaultFree
,
NULL
,
TDB_TXN_WRITE
|
TDB_TXN_READ_UNCOMMITTED
);
SBtreeInitPageArg
iArg
;
iArg
.
pBt
=
pBt
;
iArg
.
flags
=
0
;
for
(
int
pgIndex
=
0
;
pgIndex
<
journalSize
;
++
pgIndex
)
{
for
(
int
pgIndex
=
0
;
pgIndex
<
journalSize
;
++
pgIndex
)
{
// read pgno & the page from journal
// read pgno & the page from journal
SPgno
pgno
;
SPgno
pgno
;
...
@@ -494,20 +488,6 @@ int tdbPagerRestore(SPager *pPager, SBTree *pBt) {
...
@@ -494,20 +488,6 @@ int tdbPagerRestore(SPager *pPager, SBTree *pBt) {
return
-
1
;
return
-
1
;
}
}
/*
ret = tdbPagerFetchPage(pPager, &pgno, &pPage, tdbBtreeInitPage, &iArg, &txn);
if (ret < 0) {
return -1;
}
// write the page to db
ret = tdbPagerWritePageToDB(pPager, pPage);
if (ret < 0) {
return -1;
}
tdbPCacheRelease(pPager->pCache, pPage, &txn);
*/
i64
offset
=
pPager
->
pageSize
*
(
pgno
-
1
);
i64
offset
=
pPager
->
pageSize
*
(
pgno
-
1
);
if
(
tdbOsLSeek
(
pPager
->
fd
,
offset
,
SEEK_SET
)
<
0
)
{
if
(
tdbOsLSeek
(
pPager
->
fd
,
offset
,
SEEK_SET
)
<
0
)
{
ASSERT
(
0
);
ASSERT
(
0
);
...
@@ -523,8 +503,6 @@ int tdbPagerRestore(SPager *pPager, SBTree *pBt) {
...
@@ -523,8 +503,6 @@ int tdbPagerRestore(SPager *pPager, SBTree *pBt) {
tdbOsFSync
(
pPager
->
fd
);
tdbOsFSync
(
pPager
->
fd
);
tdbTxnClose
(
&
txn
);
tdbOsFree
(
pageBuf
);
tdbOsFree
(
pageBuf
);
tdbOsClose
(
jfd
);
tdbOsClose
(
jfd
);
...
...
source/os/src/osTime.c
浏览文件 @
1b4ed84a
...
@@ -357,14 +357,88 @@ FORCE_INLINE int32_t taosGetTimeOfDay(struct timeval *tv) {
...
@@ -357,14 +357,88 @@ FORCE_INLINE int32_t taosGetTimeOfDay(struct timeval *tv) {
time_t
taosTime
(
time_t
*
t
)
{
return
time
(
t
);
}
time_t
taosTime
(
time_t
*
t
)
{
return
time
(
t
);
}
time_t
taosMktime
(
struct
tm
*
timep
)
{
return
mktime
(
timep
);
}
time_t
taosMktime
(
struct
tm
*
timep
)
{
#ifdef WINDOWS
struct
tm
tm1
=
{
0
};
LARGE_INTEGER
t
;
FILETIME
f
;
SYSTEMTIME
s
;
FILETIME
ff
;
SYSTEMTIME
ss
;
LARGE_INTEGER
offset
;
time_t
tt
=
0
;
localtime_s
(
&
tm1
,
&
tt
);
ss
.
wYear
=
tm1
.
tm_year
+
1900
;
ss
.
wMonth
=
tm1
.
tm_mon
+
1
;
ss
.
wDay
=
tm1
.
tm_wday
;
ss
.
wHour
=
tm1
.
tm_hour
;
ss
.
wMinute
=
tm1
.
tm_min
;
ss
.
wSecond
=
tm1
.
tm_sec
;
ss
.
wMilliseconds
=
0
;
SystemTimeToFileTime
(
&
ss
,
&
ff
);
offset
.
QuadPart
=
ff
.
dwHighDateTime
;
offset
.
QuadPart
<<=
32
;
offset
.
QuadPart
|=
ff
.
dwLowDateTime
;
s
.
wYear
=
timep
->
tm_year
+
1900
;
s
.
wMonth
=
timep
->
tm_mon
+
1
;
s
.
wDay
=
timep
->
tm_wday
;
s
.
wHour
=
timep
->
tm_hour
;
s
.
wMinute
=
timep
->
tm_min
;
s
.
wSecond
=
timep
->
tm_sec
;
s
.
wMilliseconds
=
0
;
SystemTimeToFileTime
(
&
s
,
&
f
);
t
.
QuadPart
=
f
.
dwHighDateTime
;
t
.
QuadPart
<<=
32
;
t
.
QuadPart
|=
f
.
dwLowDateTime
;
t
.
QuadPart
-=
offset
.
QuadPart
;
return
(
time_t
)(
t
.
QuadPart
/
10000000
);
#else
return
mktime
(
timep
);
#endif
}
struct
tm
*
taosLocalTime
(
const
time_t
*
timep
,
struct
tm
*
result
)
{
struct
tm
*
taosLocalTime
(
const
time_t
*
timep
,
struct
tm
*
result
)
{
if
(
result
==
NULL
)
{
if
(
result
==
NULL
)
{
return
localtime
(
timep
);
return
localtime
(
timep
);
}
}
#ifdef WINDOWS
#ifdef WINDOWS
if
(
*
timep
<
0
)
{
SYSTEMTIME
ss
,
s
;
FILETIME
ff
,
f
;
LARGE_INTEGER
offset
;
struct
tm
tm1
;
time_t
tt
=
0
;
localtime_s
(
&
tm1
,
&
tt
);
ss
.
wYear
=
tm1
.
tm_year
+
1900
;
ss
.
wMonth
=
tm1
.
tm_mon
+
1
;
ss
.
wDay
=
tm1
.
tm_mday
;
ss
.
wHour
=
tm1
.
tm_hour
;
ss
.
wMinute
=
tm1
.
tm_min
;
ss
.
wSecond
=
tm1
.
tm_sec
;
ss
.
wMilliseconds
=
0
;
SystemTimeToFileTime
(
&
ss
,
&
ff
);
offset
.
QuadPart
=
ff
.
dwHighDateTime
;
offset
.
QuadPart
<<=
32
;
offset
.
QuadPart
|=
ff
.
dwLowDateTime
;
offset
.
QuadPart
+=
*
timep
*
10000000
;
f
.
dwLowDateTime
=
offset
.
QuadPart
&
0xffffffff
;
f
.
dwHighDateTime
=
(
offset
.
QuadPart
>>
32
)
&
0xffffffff
;
FileTimeToSystemTime
(
&
f
,
&
s
);
result
->
tm_sec
=
s
.
wSecond
;
result
->
tm_min
=
s
.
wMinute
;
result
->
tm_hour
=
s
.
wHour
;
result
->
tm_mday
=
s
.
wDay
;
result
->
tm_mon
=
s
.
wMonth
-
1
;
result
->
tm_year
=
s
.
wYear
-
1900
;
result
->
tm_wday
=
s
.
wDayOfWeek
;
result
->
tm_yday
=
0
;
result
->
tm_isdst
=
0
;
}
else
{
localtime_s
(
result
,
timep
);
localtime_s
(
result
,
timep
);
}
#else
#else
localtime_r
(
timep
,
result
);
localtime_r
(
timep
,
result
);
#endif
#endif
...
...
tests/pytest/crash_gen/crash_gen_main.py
浏览文件 @
1b4ed84a
...
@@ -30,6 +30,7 @@ import argparse
...
@@ -30,6 +30,7 @@ import argparse
import
sys
import
sys
import
os
import
os
import
io
import
io
import
datetime
import
signal
import
signal
import
traceback
import
traceback
import
requests
import
requests
...
@@ -1107,14 +1108,20 @@ class Database:
...
@@ -1107,14 +1108,20 @@ class Database:
# TODO: fix the error as result of above: "tsdb timestamp is out of range"
# TODO: fix the error as result of above: "tsdb timestamp is out of range"
@
classmethod
@
classmethod
def
setupLastTick
(
cls
):
def
setupLastTick
(
cls
):
t1
=
datetime
.
datetime
(
2020
,
6
,
1
)
# start time will be auto generated , start at 10 years ago local time
local_time
=
datetime
.
datetime
.
utcnow
().
strftime
(
'%Y-%m-%d %H:%M:%S.%f'
)[:
-
16
]
local_epoch_time
=
[
int
(
i
)
for
i
in
local_time
.
split
(
"-"
)]
#local_epoch_time will be such as : [2022, 7, 18]
t1
=
datetime
.
datetime
(
local_epoch_time
[
0
]
-
5
,
local_epoch_time
[
1
],
local_epoch_time
[
2
])
t2
=
datetime
.
datetime
.
now
()
t2
=
datetime
.
datetime
.
now
()
# maybe a very large number, takes 69 years to exceed Python int range
# maybe a very large number, takes 69 years to exceed Python int range
elSec
=
int
(
t2
.
timestamp
()
-
t1
.
timestamp
())
elSec
=
int
(
t2
.
timestamp
()
-
t1
.
timestamp
())
elSec2
=
(
elSec
%
(
8
*
12
*
30
*
24
*
60
*
60
/
500
))
*
\
elSec2
=
(
elSec
%
(
8
*
12
*
30
*
24
*
60
*
60
/
500
))
*
\
500
# a number representing seconds within 10 years
500
# a number representing seconds within 10 years
# print("elSec = {}".format(elSec))
# print("elSec = {}".format(elSec))
t3
=
datetime
.
datetime
(
2012
,
1
,
1
)
# default "keep" is 10 years
t3
=
datetime
.
datetime
(
local_epoch_time
[
0
]
-
10
,
local_epoch_time
[
1
],
local_epoch_time
[
2
])
# default "keep" is 10 years
t4
=
datetime
.
datetime
.
fromtimestamp
(
t4
=
datetime
.
datetime
.
fromtimestamp
(
t3
.
timestamp
()
+
elSec2
)
# see explanation above
t3
.
timestamp
()
+
elSec2
)
# see explanation above
Logging
.
debug
(
"Setting up TICKS to start from: {}"
.
format
(
t4
))
Logging
.
debug
(
"Setting up TICKS to start from: {}"
.
format
(
t4
))
...
...
tests/script/jenkins/basic.txt
浏览文件 @
1b4ed84a
...
@@ -312,6 +312,7 @@
...
@@ -312,6 +312,7 @@
./test.sh -f tsim/valgrind/checkError3.sim
./test.sh -f tsim/valgrind/checkError3.sim
./test.sh -f tsim/valgrind/checkError4.sim
./test.sh -f tsim/valgrind/checkError4.sim
./test.sh -f tsim/valgrind/checkError5.sim
./test.sh -f tsim/valgrind/checkError5.sim
./test.sh -f tsim/valgrind/checkError6.sim
# --- vnode
# --- vnode
# unsupport ./test.sh -f tsim/vnode/replica3_basic.sim
# unsupport ./test.sh -f tsim/vnode/replica3_basic.sim
...
...
tests/script/tsim/db/alter_replica_31.sim
浏览文件 @
1b4ed84a
...
@@ -111,6 +111,15 @@ if $hasleader != 1 then
...
@@ -111,6 +111,15 @@ if $hasleader != 1 then
goto step2
goto step2
endi
endi
# sql use db;
# sql create table stb (ts timestamp, c int) tags (t int);
# sql create table t0 using stb tags (0);
# sql insert into t0 values(now, 1);
# sql show db.stables;
# sql show db.tables;
# sql show db.vgroups;
return
sql create table db.stb (ts timestamp, c1 int, c2 binary(4)) tags(t1 int, t2 binary(16)) comment "abd"
sql create table db.stb (ts timestamp, c1 int, c2 binary(4)) tags(t1 int, t2 binary(16)) comment "abd"
sql create table db.ctb using db.stb tags(101, "102")
sql create table db.ctb using db.stb tags(101, "102")
sql insert into db.ctb values(now, 1, "2")
sql insert into db.ctb values(now, 1, "2")
...
...
tests/script/tsim/valgrind/checkError5.sim
浏览文件 @
1b4ed84a
...
@@ -26,6 +26,7 @@ print =============== step2: create db
...
@@ -26,6 +26,7 @@ print =============== step2: create db
sql create database db
sql create database db
sql use db
sql use db
sql create table db.stb (ts timestamp, c1 int, c2 binary(4)) tags(t1 int, t2 float, t3 binary(16)) comment "abd"
sql create table db.stb (ts timestamp, c1 int, c2 binary(4)) tags(t1 int, t2 float, t3 binary(16)) comment "abd"
sql create table db.c1 using db.stb tags(101, 102, "103")
print =============== step3: alter stb
print =============== step3: alter stb
sql_error alter table db.stb add column ts int
sql_error alter table db.stb add column ts int
...
@@ -42,9 +43,8 @@ sql alter table db.stb drop tag c1
...
@@ -42,9 +43,8 @@ sql alter table db.stb drop tag c1
sql alter table db.stb drop tag t5
sql alter table db.stb drop tag t5
sql alter table db.stb MODIFY tag t3 binary(32)
sql alter table db.stb MODIFY tag t3 binary(32)
sql alter table db.stb rename tag t1 tx
sql alter table db.stb rename tag t1 tx
sql alter table db.stb comment 'abcde' ;
sql alter table db.stb comment 'abcde' ;
goto _OVER
sql drop table db.stb
print =============== step4: alter tb
print =============== step4: alter tb
sql create table tb (ts timestamp, a int)
sql create table tb (ts timestamp, a int)
...
@@ -66,6 +66,35 @@ sql alter table tb add column h binary(10)
...
@@ -66,6 +66,35 @@ sql alter table tb add column h binary(10)
sql select count(a), count(b), count(c), count(d), count(e), count(f), count(g), count(h) from tb
sql select count(a), count(b), count(c), count(d), count(e), count(f), count(g), count(h) from tb
sql select * from tb order by ts desc
sql select * from tb order by ts desc
print =============== step5: alter stb and insert data
sql create table stb (ts timestamp, c1 int, c2 binary(4)) tags(t1 int, t2 float, t3 binary(16)) comment "abd"
sql show db.stables
sql describe stb
sql_error alter table stb add column ts int
sql create table db.ctb using db.stb tags(101, 102, "103")
sql insert into db.ctb values(now, 1, "2")
sql show db.tables
sql select * from db.stb
sql select * from tb
sql alter table stb add column c3 int
sql describe stb
sql select * from db.stb
sql select * from tb
sql insert into db.ctb values(now+1s, 1, 2, 3)
sql select * from db.stb
sql alter table db.stb add column c4 bigint
sql select * from db.stb
sql insert into db.ctb values(now+2s, 1, 2, 3, 4)
sql alter table db.stb drop column c1
sql reset query cache
sql select * from tb
sql insert into db.ctb values(now+3s, 2, 3, 4)
sql select * from db.stb
_OVER:
_OVER:
system sh/exec.sh -n dnode1 -s stop -x SIGINT
system sh/exec.sh -n dnode1 -s stop -x SIGINT
print =============== check
print =============== check
...
...
tests/script/tsim/valgrind/checkError6.sim
浏览文件 @
1b4ed84a
...
@@ -68,7 +68,7 @@ $null=
...
@@ -68,7 +68,7 @@ $null=
system_content sh/checkValgrind.sh -n dnode1
system_content sh/checkValgrind.sh -n dnode1
print cmd return result ----> [ $system_content ]
print cmd return result ----> [ $system_content ]
if $system_content >
0
then
if $system_content >
3
then
return -1
return -1
endi
endi
...
...
tests/system-test/0-others/cache
last
.py
→
tests/system-test/0-others/cache
model
.py
浏览文件 @
1b4ed84a
...
@@ -56,6 +56,16 @@ class TDTestCase:
...
@@ -56,6 +56,16 @@ class TDTestCase:
}
}
return
numbers
.
get
(
value
,
'other'
)
return
numbers
.
get
(
value
,
'other'
)
def
getCacheModelNum
(
self
,
str
):
numbers
=
{
"none"
:
0
,
"last_row"
:
1
,
"last_value"
:
2
,
"both"
:
3
}
return
numbers
.
get
(
str
,
'other'
)
def
prepare_datas
(
self
):
def
prepare_datas
(
self
):
for
i
in
range
(
4
):
for
i
in
range
(
4
):
str
=
self
.
getCacheModelStr
(
i
)
str
=
self
.
getCacheModelStr
(
i
)
...
@@ -69,7 +79,7 @@ class TDTestCase:
...
@@ -69,7 +79,7 @@ class TDTestCase:
tdSql
.
execute
(
" insert into tb1 values(now , %d, %f)"
%
(
k
,
k
*
10
)
)
tdSql
.
execute
(
" insert into tb1 values(now , %d, %f)"
%
(
k
,
k
*
10
)
)
tdSql
.
execute
(
" insert into tb2 values(now , %d, %f)"
%
(
k
,
k
*
10
)
)
tdSql
.
execute
(
" insert into tb2 values(now , %d, %f)"
%
(
k
,
k
*
10
)
)
def
check_cache
_last
_sets
(
self
):
def
check_cache
model
_sets
(
self
):
# check cache_last value for database
# check cache_last value for database
...
@@ -84,52 +94,54 @@ class TDTestCase:
...
@@ -84,52 +94,54 @@ class TDTestCase:
# print(cache_last_value)
# print(cache_last_value)
if
dbname
in
[
"information_schema"
,
"performance_schema"
]:
if
dbname
in
[
"information_schema"
,
"performance_schema"
]:
continue
continue
cache_lasts
[
dbname
]
=
cache_last_value
cache_lasts
[
dbname
]
=
self
.
getCacheModelNum
(
cache_last_value
)
# cache_last_set value
# cache_last_set value
for
k
,
v
in
cache_lasts
.
items
():
for
k
,
v
in
cache_lasts
.
items
():
if
k
==
"testdb_"
+
str
(
v
):
if
k
==
"testdb_"
+
str
(
self
.
getCacheModelStr
(
v
)
):
tdLog
.
info
(
" database %s cache_last value check pass, value is %s "
%
(
k
,
v
)
)
tdLog
.
info
(
" database %s cache_last value check pass, value is %s "
%
(
k
,
self
.
getCacheModelStr
(
v
)
)
)
else
:
else
:
tdLog
.
exit
(
" database %s cache_last value check fail, value is %s "
%
(
k
,
v
)
)
tdLog
.
exit
(
" database %s cache_last value check fail, value is %s "
%
(
k
,
self
.
getCacheModelStr
(
v
)
)
)
# # check storage layer implementation
# # check storage layer implementation
#
buildPath = self.getBuildPath()
buildPath
=
self
.
getBuildPath
()
#
if (buildPath == ""):
if
(
buildPath
==
""
):
#
tdLog.exit("taosd not found!")
tdLog
.
exit
(
"taosd not found!"
)
#
else:
else
:
#
tdLog.info("taosd found in %s" % buildPath)
tdLog
.
info
(
"taosd found in %s"
%
buildPath
)
#
dataPath = buildPath + "/../sim/dnode1/data"
dataPath
=
buildPath
+
"/../sim/dnode1/data"
#
abs_vnodePath = os.path.abspath(dataPath)+"/vnode/"
abs_vnodePath
=
os
.
path
.
abspath
(
dataPath
)
+
"/vnode/"
#
tdLog.info("abs_vnodePath: %s" % abs_vnodePath)
tdLog
.
info
(
"abs_vnodePath: %s"
%
abs_vnodePath
)
#
tdSql.query(" show dnodes ")
tdSql
.
query
(
" show dnodes "
)
#
dnode_id = tdSql.queryResult[0][0]
dnode_id
=
tdSql
.
queryResult
[
0
][
0
]
#
for dbname in cache_lasts.keys():
for
dbname
in
cache_lasts
.
keys
():
# print(dbname)
# print(dbname)
# tdSql.execute(" use %s" % dbname)
tdSql
.
execute
(
" use %s"
%
dbname
)
# tdSql.query(" show vgroups ")
tdSql
.
query
(
" show vgroups "
)
# vgroups_infos = tdSql.queryResult
vgroups_infos
=
tdSql
.
queryResult
# for vgroup_info in vgroups_infos:
for
vgroup_info
in
vgroups_infos
:
# vnode_json = abs_vnodePath + "/vnode" +f"{vgroup_info[0]}/" + "vnode.json"
vnode_json
=
abs_vnodePath
+
"/vnode"
+
f
"
{
vgroup_info
[
0
]
}
/"
+
"vnode.json"
# vnode_info_of_db = f"cat {vnode_json}"
vnode_info_of_db
=
f
"cat
{
vnode_json
}
"
# vnode_info = subprocess.check_output(vnode_info_of_db, shell=True).decode("utf-8")
vnode_info
=
subprocess
.
check_output
(
vnode_info_of_db
,
shell
=
True
).
decode
(
"utf-8"
)
# infoDict = json.loads(vnode_info)
infoDict
=
json
.
loads
(
vnode_info
)
# vnode_json_of_dbname = f"{dnode_id}."+ dbname
vnode_json_of_dbname
=
f
"
{
dnode_id
}
."
+
dbname
# config = infoDict["config"]
config
=
infoDict
[
"config"
]
# if infoDict["config"]["dbname"] == vnode_json_of_dbname:
if
infoDict
[
"config"
][
"dbname"
]
==
vnode_json_of_dbname
:
# if "cachelast" in infoDict["config"]:
if
"cacheLast"
in
infoDict
[
"config"
]:
# if int(infoDict["config"]["cachelast"]) != cache_lasts[dbname]:
if
int
(
infoDict
[
"config"
][
"cacheLast"
])
!=
cache_lasts
[
dbname
]:
# tdLog.exit("cachelast value is error in vnode.json of vnode%d "%(vgroup_info[0]))
tdLog
.
exit
(
"cachemodel value is error in vnode.json of vnode%d "
%
(
vgroup_info
[
0
]))
# else:
else
:
# tdLog.exit("cachelast not found in vnode.json of vnode%d "%(vgroup_info[0]))
tdLog
.
info
(
"cachemodel value is success in vnode.json of vnode%d "
%
(
vgroup_info
[
0
]))
else
:
def
restart_check_cache_last_sets
(
self
):
tdLog
.
exit
(
"cacheLast not found in vnode.json of vnode%d "
%
(
vgroup_info
[
0
]))
def
restart_check_cachemodel_sets
(
self
):
for
i
in
range
(
3
):
for
i
in
range
(
3
):
tdSql
.
query
(
"show dnodes"
)
tdSql
.
query
(
"show dnodes"
)
...
@@ -137,14 +149,14 @@ class TDTestCase:
...
@@ -137,14 +149,14 @@ class TDTestCase:
tdDnodes
.
stop
(
index
)
tdDnodes
.
stop
(
index
)
tdDnodes
.
start
(
index
)
tdDnodes
.
start
(
index
)
time
.
sleep
(
3
)
time
.
sleep
(
3
)
self
.
check_cache
_last
_sets
()
self
.
check_cache
model
_sets
()
def
run
(
self
):
# sourcery skip: extract-duplicate-method, remove-redundant-fstring
def
run
(
self
):
# sourcery skip: extract-duplicate-method, remove-redundant-fstring
self
.
illegal_params
()
self
.
illegal_params
()
self
.
prepare_datas
()
self
.
prepare_datas
()
self
.
check_cache
_last
_sets
()
self
.
check_cache
model
_sets
()
self
.
restart_check_cache
_last
_sets
()
self
.
restart_check_cache
model
_sets
()
def
stop
(
self
):
def
stop
(
self
):
tdSql
.
close
()
tdSql
.
close
()
...
...
tests/system-test/1-insert/delete_data.py
0 → 100644
浏览文件 @
1b4ed84a
###################################################################
# Copyright (c) 2016 by TAOS Technologies, Inc.
# All rights reserved.
#
# This file is proprietary and confidential to TAOS Technologies.
# No part of this file may be reproduced, stored, transmitted,
# disclosed or used in any form or by any means other than as
# expressly provided by the written permission from Jianhui Tao
#
###################################################################
# -*- coding: utf-8 -*-
import
random
import
string
from
numpy
import
logspace
from
util
import
constant
from
util.log
import
*
from
util.cases
import
*
from
util.sql
import
*
from
util.common
import
*
from
util.sqlset
import
TDSetSql
class
TDTestCase
:
def
init
(
self
,
conn
,
logSql
):
tdLog
.
debug
(
"start to execute %s"
%
__file__
)
tdSql
.
init
(
conn
.
cursor
(),
logSql
)
self
.
dbname
=
'db_test'
self
.
setsql
=
TDSetSql
()
self
.
ntbname
=
'ntb'
self
.
rowNum
=
10
self
.
tbnum
=
20
self
.
ts
=
1537146000000
self
.
binary_str
=
'taosdata'
self
.
nchar_str
=
'涛思数据'
self
.
str_length
=
20
self
.
column_dict
=
{
'col1'
:
'tinyint'
,
'col2'
:
'smallint'
,
'col3'
:
'int'
,
'col4'
:
'bigint'
,
'col5'
:
'tinyint unsigned'
,
'col6'
:
'smallint unsigned'
,
'col7'
:
'int unsigned'
,
'col8'
:
'bigint unsigned'
,
'col9'
:
'float'
,
'col10'
:
'double'
,
'col11'
:
'bool'
,
'col12'
:
f
'binary(
{
self
.
str_length
}
)'
,
'col13'
:
f
'nchar(
{
self
.
str_length
}
)'
,
}
self
.
tinyint_val
=
random
.
randint
(
constant
.
TINYINT_MIN
,
constant
.
TINYINT_MAX
)
self
.
smallint_val
=
random
.
randint
(
constant
.
SMALLINT_MIN
,
constant
.
SMALLINT_MAX
)
self
.
int_val
=
random
.
randint
(
constant
.
INT_MIN
,
constant
.
INT_MAX
)
self
.
bigint_val
=
random
.
randint
(
constant
.
BIGINT_MIN
,
constant
.
BIGINT_MAX
)
self
.
untingint_val
=
random
.
randint
(
constant
.
TINYINT_UN_MIN
,
constant
.
TINYINT_UN_MAX
)
self
.
unsmallint_val
=
random
.
randint
(
constant
.
SMALLINT_UN_MIN
,
constant
.
SMALLINT_UN_MAX
)
self
.
unint_val
=
random
.
randint
(
constant
.
INT_UN_MIN
,
constant
.
INT_MAX
)
self
.
unbigint_val
=
random
.
randint
(
constant
.
BIGINT_UN_MIN
,
constant
.
BIGINT_UN_MAX
)
self
.
float_val
=
random
.
uniform
(
constant
.
FLOAT_MIN
,
constant
.
FLOAT_MAX
)
self
.
double_val
=
random
.
uniform
(
constant
.
DOUBLE_MIN
*
(
1E-300
),
constant
.
DOUBLE_MAX
*
(
1E-300
))
self
.
bool_val
=
random
.
randint
(
0
,
100
)
%
2
self
.
binary_val
=
tdCom
.
getLongName
(
random
.
randint
(
0
,
self
.
str_length
))
self
.
nchar_val
=
tdCom
.
getLongName
(
random
.
randint
(
0
,
self
.
str_length
))
self
.
base_data
=
{
'tinyint'
:
self
.
tinyint_val
,
'smallint'
:
self
.
smallint_val
,
'int'
:
self
.
int_val
,
'bigint'
:
self
.
bigint_val
,
'tinyint unsigned'
:
self
.
untingint_val
,
'smallint unsigned'
:
self
.
unsmallint_val
,
'int unsigned'
:
self
.
unint_val
,
'bigint unsigned'
:
self
.
unbigint_val
,
'bool'
:
self
.
bool_val
,
'float'
:
self
.
float_val
,
'double'
:
self
.
double_val
,
'binary'
:
self
.
binary_val
,
'nchar'
:
self
.
nchar_val
}
def
insert_base_data
(
self
,
col_type
,
tbname
,
rows
,
base_data
):
for
i
in
range
(
rows
):
if
col_type
.
lower
()
==
'tinyint'
:
tdSql
.
execute
(
f
'insert into
{
tbname
}
values(
{
self
.
ts
+
i
}
,
{
base_data
[
"tinyint"
]
}
)'
)
elif
col_type
.
lower
()
==
'smallint'
:
tdSql
.
execute
(
f
'insert into
{
tbname
}
values(
{
self
.
ts
+
i
}
,
{
base_data
[
"smallint"
]
}
)'
)
elif
col_type
.
lower
()
==
'int'
:
tdSql
.
execute
(
f
'insert into
{
tbname
}
values(
{
self
.
ts
+
i
}
,
{
base_data
[
"int"
]
}
)'
)
elif
col_type
.
lower
()
==
'bigint'
:
tdSql
.
execute
(
f
'insert into
{
tbname
}
values(
{
self
.
ts
+
i
}
,
{
base_data
[
"bigint"
]
}
)'
)
elif
col_type
.
lower
()
==
'tinyint unsigned'
:
tdSql
.
execute
(
f
'insert into
{
tbname
}
values(
{
self
.
ts
+
i
}
,
{
base_data
[
"tinyint unsigned"
]
}
)'
)
elif
col_type
.
lower
()
==
'smallint unsigned'
:
tdSql
.
execute
(
f
'insert into
{
tbname
}
values(
{
self
.
ts
+
i
}
,
{
base_data
[
"smallint unsigned"
]
}
)'
)
elif
col_type
.
lower
()
==
'int unsigned'
:
tdSql
.
execute
(
f
'insert into
{
tbname
}
values(
{
self
.
ts
+
i
}
,
{
base_data
[
"int unsigned"
]
}
)'
)
elif
col_type
.
lower
()
==
'bigint unsigned'
:
tdSql
.
execute
(
f
'insert into
{
tbname
}
values(
{
self
.
ts
+
i
}
,
{
base_data
[
"bigint unsigned"
]
}
)'
)
elif
col_type
.
lower
()
==
'bool'
:
tdSql
.
execute
(
f
'insert into
{
tbname
}
values(
{
self
.
ts
+
i
}
,
{
base_data
[
"bool"
]
}
)'
)
elif
col_type
.
lower
()
==
'float'
:
tdSql
.
execute
(
f
'insert into
{
tbname
}
values(
{
self
.
ts
+
i
}
,
{
base_data
[
"float"
]
}
)'
)
elif
col_type
.
lower
()
==
'double'
:
tdSql
.
execute
(
f
'insert into
{
tbname
}
values(
{
self
.
ts
+
i
}
,
{
base_data
[
"double"
]
}
)'
)
elif
'binary'
in
col_type
.
lower
():
tdSql
.
execute
(
f
'''insert into
{
tbname
}
values(
{
self
.
ts
+
i
}
,"
{
base_data
[
'binary'
]
}
")'''
)
elif
'nchar'
in
col_type
.
lower
():
tdSql
.
execute
(
f
'''insert into
{
tbname
}
values(
{
self
.
ts
+
i
}
,"
{
base_data
[
'nchar'
]
}
")'''
)
def
delete_all_data
(
self
,
tbname
,
col_type
,
row_num
,
base_data
,
dbname
):
tdSql
.
execute
(
f
'delete from
{
tbname
}
'
)
tdSql
.
execute
(
f
'flush database
{
dbname
}
'
)
tdSql
.
execute
(
'reset query cache'
)
tdSql
.
query
(
f
'select * from
{
tbname
}
'
)
tdSql
.
checkRows
(
0
)
self
.
insert_base_data
(
col_type
,
tbname
,
row_num
,
base_data
)
tdSql
.
execute
(
f
'flush database
{
dbname
}
'
)
tdSql
.
execute
(
'reset query cache'
)
tdSql
.
query
(
f
'select * from
{
tbname
}
'
)
tdSql
.
checkRows
(
row_num
)
def
delete_one_row
(
self
,
tbname
,
column_type
,
column_name
,
base_data
,
dbname
):
tdSql
.
execute
(
f
'delete from
{
tbname
}
where ts=
{
self
.
ts
}
'
)
tdSql
.
execute
(
f
'flush database
{
dbname
}
'
)
tdSql
.
execute
(
'reset query cache'
)
tdSql
.
query
(
f
'select
{
column_name
}
from
{
tbname
}
'
)
tdSql
.
checkRows
(
self
.
rowNum
-
1
)
tdSql
.
query
(
f
'select
{
column_name
}
from
{
tbname
}
where ts=
{
self
.
ts
}
'
)
tdSql
.
checkRows
(
0
)
if
'binary'
in
column_type
.
lower
():
tdSql
.
execute
(
f
'''insert into
{
tbname
}
values(
{
self
.
ts
}
,"
{
base_data
[
'binary'
]
}
")'''
)
elif
'nchar'
in
column_type
.
lower
():
tdSql
.
execute
(
f
'''insert into
{
tbname
}
values(
{
self
.
ts
}
,"
{
base_data
[
'nchar'
]
}
")'''
)
else
:
tdSql
.
execute
(
f
'insert into
{
tbname
}
values(
{
self
.
ts
}
,
{
base_data
[
column_type
]
}
)'
)
tdSql
.
query
(
f
'select
{
column_name
}
from
{
tbname
}
where ts=
{
self
.
ts
}
'
)
if
column_type
.
lower
()
==
'float'
or
column_type
.
lower
()
==
'double'
:
if
abs
(
tdSql
.
queryResult
[
0
][
0
]
-
base_data
[
column_type
])
/
base_data
[
column_type
]
<=
0.0001
:
tdSql
.
checkEqual
(
tdSql
.
queryResult
[
0
][
0
],
tdSql
.
queryResult
[
0
][
0
])
else
:
tdLog
.
exit
(
f
'
{
column_type
}
data check failure'
)
elif
'binary'
in
column_type
.
lower
():
tdSql
.
checkEqual
(
tdSql
.
queryResult
[
0
][
0
],
base_data
[
'binary'
])
elif
'nchar'
in
column_type
.
lower
():
tdSql
.
checkEqual
(
tdSql
.
queryResult
[
0
][
0
],
base_data
[
'nchar'
])
else
:
tdSql
.
checkEqual
(
tdSql
.
queryResult
[
0
][
0
],
base_data
[
column_type
])
def
delete_rows
(
self
):
pass
def
delete_error
(
self
,
tbname
,
column_name
,
column_type
,
base_data
):
for
error_list
in
[
''
,
f
'ts =
{
self
.
ts
}
and'
,
f
'ts =
{
self
.
ts
}
or'
]:
if
'binary'
in
column_type
.
lower
():
tdSql
.
error
(
f
'''delete from
{
tbname
}
where
{
error_list
}
{
column_name
}
="
{
base_data
[
'binary'
]
}
"'''
)
elif
'nchar'
in
column_type
.
lower
():
tdSql
.
error
(
f
'''delete from
{
tbname
}
where
{
error_list
}
{
column_name
}
="
{
base_data
[
'nchar'
]
}
"'''
)
else
:
tdSql
.
error
(
'delete from {tbname} where {error_list} {column_name} = {base_data[column_type]}'
)
def
delete_data_ntb
(
self
):
tdSql
.
execute
(
f
'create database if not exists
{
self
.
dbname
}
'
)
tdSql
.
execute
(
f
'use
{
self
.
dbname
}
'
)
for
col_name
,
col_type
in
self
.
column_dict
.
items
():
tdSql
.
execute
(
f
'create table
{
self
.
ntbname
}
(ts timestamp,
{
col_name
}
{
col_type
}
)'
)
self
.
insert_base_data
(
col_type
,
self
.
ntbname
,
self
.
rowNum
,
self
.
base_data
)
self
.
delete_one_row
(
self
.
ntbname
,
col_type
,
col_name
,
self
.
base_data
,
self
.
dbname
)
self
.
delete_all_data
(
self
.
ntbname
,
col_type
,
self
.
rowNum
,
self
.
base_data
,
self
.
dbname
)
self
.
delete_error
(
self
.
ntbname
,
col_name
,
col_type
,
self
.
base_data
)
for
i
in
range
(
self
.
rowNum
):
tdSql
.
execute
(
f
'delete from
{
self
.
ntbname
}
where ts>
{
self
.
ts
+
i
}
'
)
tdSql
.
execute
(
f
'flush database
{
self
.
dbname
}
'
)
tdSql
.
execute
(
'reset query cache'
)
tdSql
.
query
(
f
'select
{
col_name
}
from
{
self
.
ntbname
}
'
)
tdSql
.
checkRows
(
i
+
1
)
self
.
insert_base_data
(
col_type
,
self
.
ntbname
,
self
.
rowNum
,
self
.
base_data
)
tdSql
.
execute
(
f
'drop table
{
self
.
ntbname
}
'
)
def
run
(
self
):
self
.
delete_data_ntb
()
def
stop
(
self
):
tdSql
.
close
()
tdLog
.
success
(
"%s successfully executed"
%
__file__
)
tdCases
.
addWindows
(
__file__
,
TDTestCase
())
tdCases
.
addLinux
(
__file__
,
TDTestCase
())
\ No newline at end of file
tests/system-test/1-insert/update_data.py
0 → 100644
浏览文件 @
1b4ed84a
###################################################################
# Copyright (c) 2016 by TAOS Technologies, Inc.
# All rights reserved.
#
# This file is proprietary and confidential to TAOS Technologies.
# No part of this file may be reproduced, stored, transmitted,
# disclosed or used in any form or by any means other than as
# expressly provided by the written permission from Jianhui Tao
#
###################################################################
# -*- coding: utf-8 -*-
import
random
import
string
from
util
import
constant
from
util.log
import
*
from
util.cases
import
*
from
util.sql
import
*
from
util.common
import
*
from
util.sqlset
import
TDSetSql
class
TDTestCase
:
def
init
(
self
,
conn
,
logSql
):
tdLog
.
debug
(
"start to execute %s"
%
__file__
)
tdSql
.
init
(
conn
.
cursor
(),
logSql
)
self
.
setsql
=
TDSetSql
()
self
.
dbname
=
'db_test'
self
.
ntbname
=
'ntb'
self
.
stbname
=
'stb'
self
.
ctbname
=
'ctb'
self
.
ts
=
1537146000000
self
.
str_length
=
20
self
.
column_dict
=
{
'col1'
:
'tinyint'
,
'col2'
:
'smallint'
,
'col3'
:
'int'
,
'col4'
:
'bigint'
,
'col5'
:
'tinyint unsigned'
,
'col6'
:
'smallint unsigned'
,
'col7'
:
'int unsigned'
,
'col8'
:
'bigint unsigned'
,
'col9'
:
'float'
,
'col10'
:
'double'
,
'col11'
:
'bool'
,
'col12'
:
f
'binary(
{
self
.
str_length
}
)'
,
'col13'
:
f
'nchar(
{
self
.
str_length
}
)'
,
'col_ts'
:
'timestamp'
}
def
data_check
(
self
,
tbname
,
col_name
,
col_type
,
value
):
tdSql
.
query
(
f
'select
{
col_name
}
from
{
tbname
}
'
)
if
col_type
.
lower
()
==
'float'
or
col_type
.
lower
()
==
'double'
:
if
abs
(
tdSql
.
queryResult
[
0
][
0
]
-
value
)
/
value
<=
0.0001
:
tdSql
.
checkEqual
(
tdSql
.
queryResult
[
0
][
0
],
tdSql
.
queryResult
[
0
][
0
])
else
:
tdLog
.
exit
(
f
'
{
col_name
}
data check failure'
)
elif
col_type
.
lower
()
==
'timestamp'
:
tdSql
.
checkEqual
(
str
(
tdSql
.
queryResult
[
0
][
0
]),
str
(
datetime
.
datetime
.
fromtimestamp
(
value
/
1000
).
strftime
(
"%Y-%m-%d %H:%M:%S.%f"
)))
else
:
tdSql
.
checkEqual
(
tdSql
.
queryResult
[
0
][
0
],
value
)
def
update_and_check_data
(
self
,
tbname
,
col_name
,
col_type
,
value
,
dbname
):
if
'binary'
in
col_type
.
lower
()
or
'nchar'
in
col_type
.
lower
():
tdSql
.
execute
(
f
'insert into
{
tbname
}
values(
{
self
.
ts
}
,"
{
value
}
")'
)
else
:
tdSql
.
execute
(
f
'insert into
{
tbname
}
values(
{
self
.
ts
}
,
{
value
}
)'
)
self
.
data_check
(
tbname
,
col_name
,
col_type
,
value
)
tdSql
.
execute
(
f
'flush database
{
dbname
}
'
)
tdSql
.
execute
(
'reset query cache'
)
self
.
data_check
(
tbname
,
col_name
,
col_type
,
value
)
for
func
in
[
'first'
,
'last'
]:
tdSql
.
execute
(
f
'select
{
func
}
(
{
col_name
}
) from
{
tbname
}
'
)
def
error_check
(
self
,
tbname
,
column_dict
,
tb_type
=
None
,
stbname
=
None
):
str_length
=
self
.
str_length
+
1
for
col_name
,
col_type
in
column_dict
.
items
():
if
tb_type
==
'ntb'
:
tdSql
.
execute
(
f
'create table
{
tbname
}
(ts timestamp,
{
col_name
}
{
col_type
}
)'
)
elif
tb_type
==
'ctb'
:
tdSql
.
execute
(
f
'create table
{
stbname
}
(ts timestamp,
{
col_name
}
{
col_type
}
) tags(t0 int)'
)
tdSql
.
execute
(
f
'create table
{
tbname
}
using
{
stbname
}
tags(1)'
)
tdSql
.
execute
(
f
'insert into
{
tbname
}
values(
{
self
.
ts
}
,null)'
)
if
col_type
.
lower
()
==
'double'
:
for
error_value
in
[
tdCom
.
getLongName
(
self
.
str_length
),
True
,
False
,
1.1
*
constant
.
DOUBLE_MIN
,
1.1
*
constant
.
DOUBLE_MAX
]:
tdSql
.
error
(
f
'insert into
{
tbname
}
values(
{
self
.
ts
}
,
{
error_value
}
)'
)
elif
col_type
.
lower
()
==
'float'
:
for
error_value
in
[
tdCom
.
getLongName
(
self
.
str_length
),
True
,
False
,
1.1
*
constant
.
FLOAT_MIN
,
1.1
*
constant
.
FLOAT_MAX
]:
tdSql
.
error
(
f
'insert into
{
tbname
}
values(
{
self
.
ts
}
,
{
error_value
}
)'
)
elif
'binary'
in
col_type
.
lower
()
or
'nchar'
in
col_type
.
lower
():
for
error_value
in
[
tdCom
.
getLongName
(
str_length
)]:
tdSql
.
error
(
f
'insert into
{
tbname
}
values(
{
self
.
ts
}
,"
{
error_value
}
")'
)
elif
col_type
.
lower
()
==
'bool'
:
for
error_value
in
[
tdCom
.
getLongName
(
self
.
str_length
)]:
tdSql
.
error
(
f
'insert into
{
tbname
}
values(
{
self
.
ts
}
,
{
error_value
}
)'
)
elif
col_type
.
lower
()
==
'tinyint'
:
for
error_value
in
[
constant
.
TINYINT_MIN
-
1
,
constant
.
TINYINT_MAX
+
1
,
random
.
uniform
(
constant
.
FLOAT_MIN
,
constant
.
FLOAT_MAX
),
tdCom
.
getLongName
(
self
.
str_length
),
True
,
False
]:
tdSql
.
error
(
f
'insert into
{
tbname
}
values(
{
self
.
ts
}
,
{
error_value
}
)'
)
elif
col_type
.
lower
()
==
'smallint'
:
for
error_value
in
[
constant
.
SMALLINT_MIN
-
1
,
constant
.
SMALLINT_MAX
+
1
,
random
.
uniform
(
constant
.
FLOAT_MIN
,
constant
.
FLOAT_MAX
),
tdCom
.
getLongName
(
self
.
str_length
),
True
,
False
]:
tdSql
.
error
(
f
'insert into
{
tbname
}
values(
{
self
.
ts
}
,
{
error_value
}
)'
)
elif
col_type
.
lower
()
==
'int'
:
for
error_value
in
[
constant
.
INT_MIN
-
1
,
constant
.
INT_MAX
+
1
,
random
.
uniform
(
constant
.
FLOAT_MIN
,
constant
.
FLOAT_MAX
),
tdCom
.
getLongName
(
self
.
str_length
),
True
,
False
]:
tdSql
.
error
(
f
'insert into
{
tbname
}
values(
{
self
.
ts
}
,
{
error_value
}
)'
)
elif
col_type
.
lower
()
==
'bigint'
:
for
error_value
in
[
constant
.
BIGINT_MIN
-
1
,
constant
.
BIGINT_MAX
+
1
,
random
.
uniform
(
constant
.
FLOAT_MIN
,
constant
.
FLOAT_MAX
),
tdCom
.
getLongName
(
self
.
str_length
),
True
,
False
]:
tdSql
.
error
(
f
'insert into
{
tbname
}
values(
{
self
.
ts
}
,
{
error_value
}
)'
)
elif
col_type
.
lower
()
==
'tinyint unsigned'
:
for
error_value
in
[
constant
.
TINYINT_UN_MIN
-
1
,
constant
.
TINYINT_UN_MAX
+
1
,
random
.
uniform
(
constant
.
FLOAT_MIN
,
constant
.
FLOAT_MAX
),
tdCom
.
getLongName
(
self
.
str_length
),
True
,
False
]:
tdSql
.
error
(
f
'insert into
{
tbname
}
values(
{
self
.
ts
}
,
{
error_value
}
)'
)
elif
col_type
.
lower
()
==
'smallint unsigned'
:
for
error_value
in
[
constant
.
SMALLINT_UN_MIN
-
1
,
constant
.
SMALLINT_UN_MAX
+
1
,
random
.
uniform
(
constant
.
FLOAT_MIN
,
constant
.
FLOAT_MAX
),
tdCom
.
getLongName
(
self
.
str_length
),
True
,
False
]:
tdSql
.
error
(
f
'insert into
{
tbname
}
values(
{
self
.
ts
}
,
{
error_value
}
)'
)
elif
col_type
.
lower
()
==
'int unsigned'
:
for
error_value
in
[
constant
.
INT_UN_MIN
-
1
,
constant
.
INT_UN_MAX
+
1
,
random
.
uniform
(
constant
.
FLOAT_MIN
,
constant
.
FLOAT_MAX
),
tdCom
.
getLongName
(
self
.
str_length
),
True
,
False
]:
tdSql
.
error
(
f
'insert into
{
tbname
}
values(
{
self
.
ts
}
,
{
error_value
}
)'
)
elif
col_type
.
lower
()
==
'bigint unsigned'
:
for
error_value
in
[
constant
.
BIGINT_UN_MIN
-
1
,
constant
.
BIGINT_UN_MAX
+
1
,
random
.
uniform
(
constant
.
FLOAT_MIN
,
constant
.
FLOAT_MAX
),
tdCom
.
getLongName
(
self
.
str_length
),
True
,
False
]:
tdSql
.
error
(
f
'insert into
{
tbname
}
values(
{
self
.
ts
}
,
{
error_value
}
)'
)
tdSql
.
execute
(
f
'drop table
{
tbname
}
'
)
if
tb_type
==
'ctb'
:
tdSql
.
execute
(
f
'drop table
{
stbname
}
'
)
def
update_data_check
(
self
,
tbname
,
column_dict
,
dbname
,
tb_type
=
None
,
stbname
=
None
):
up_tinyint
=
random
.
randint
(
constant
.
TINYINT_MIN
,
constant
.
TINYINT_MAX
)
up_smallint
=
random
.
randint
(
constant
.
SMALLINT_MIN
,
constant
.
SMALLINT_MAX
)
up_int
=
random
.
randint
(
constant
.
INT_MIN
,
constant
.
INT_MAX
)
up_bigint
=
random
.
randint
(
constant
.
BIGINT_MIN
,
constant
.
BIGINT_MAX
)
up_untinyint
=
random
.
randint
(
constant
.
TINYINT_UN_MIN
,
constant
.
TINYINT_UN_MAX
)
up_unsmallint
=
random
.
randint
(
constant
.
SMALLINT_UN_MIN
,
constant
.
SMALLINT_UN_MAX
)
up_unint
=
random
.
randint
(
constant
.
INT_UN_MIN
,
constant
.
INT_MAX
)
up_unbigint
=
random
.
randint
(
constant
.
BIGINT_UN_MIN
,
constant
.
BIGINT_UN_MAX
)
up_bool
=
random
.
randint
(
0
,
100
)
%
2
up_float
=
random
.
uniform
(
constant
.
FLOAT_MIN
,
constant
.
FLOAT_MAX
)
up_double
=
random
.
uniform
(
constant
.
DOUBLE_MIN
*
(
1E-300
),
constant
.
DOUBLE_MAX
*
(
1E-300
))
binary_length
=
random
.
randint
(
0
,
self
.
str_length
)
nchar_length
=
random
.
randint
(
0
,
self
.
str_length
)
up_binary
=
tdCom
.
getLongName
(
binary_length
)
up_nchar
=
tdCom
.
getLongName
(
nchar_length
)
for
col_name
,
col_type
in
column_dict
.
items
():
if
tb_type
==
'ntb'
:
tdSql
.
execute
(
f
'create table
{
tbname
}
(ts timestamp,
{
col_name
}
{
col_type
}
)'
)
elif
tb_type
==
'ctb'
:
tdSql
.
execute
(
f
'create table
{
stbname
}
(ts timestamp,
{
col_name
}
{
col_type
}
) tags(t0 int)'
)
tdSql
.
execute
(
f
'create table
{
tbname
}
using
{
stbname
}
tags(1)'
)
tdSql
.
execute
(
f
'insert into
{
tbname
}
values(
{
self
.
ts
}
,null)'
)
if
col_type
.
lower
()
==
'tinyint'
:
self
.
update_and_check_data
(
tbname
,
col_name
,
col_type
,
up_tinyint
,
dbname
)
elif
col_type
.
lower
()
==
'smallint'
:
self
.
update_and_check_data
(
tbname
,
col_name
,
col_type
,
up_smallint
,
dbname
)
elif
col_type
.
lower
()
==
'int'
:
self
.
update_and_check_data
(
tbname
,
col_name
,
col_type
,
up_int
,
dbname
)
elif
col_type
.
lower
()
==
'bigint'
:
self
.
update_and_check_data
(
tbname
,
col_name
,
col_type
,
up_bigint
,
dbname
)
elif
col_type
.
lower
()
==
'tinyint unsigned'
:
self
.
update_and_check_data
(
tbname
,
col_name
,
col_type
,
up_untinyint
,
dbname
)
elif
col_type
.
lower
()
==
'smallint unsigned'
:
self
.
update_and_check_data
(
tbname
,
col_name
,
col_type
,
up_unsmallint
,
dbname
)
elif
col_type
.
lower
()
==
'int unsigned'
:
self
.
update_and_check_data
(
tbname
,
col_name
,
col_type
,
up_unint
,
dbname
)
elif
col_type
.
lower
()
==
'bigint unsigned'
:
self
.
update_and_check_data
(
tbname
,
col_name
,
col_type
,
up_unbigint
,
dbname
)
elif
col_type
.
lower
()
==
'bool'
:
self
.
update_and_check_data
(
tbname
,
col_name
,
col_type
,
up_bool
,
dbname
)
elif
col_type
.
lower
()
==
'float'
:
self
.
update_and_check_data
(
tbname
,
col_name
,
col_type
,
up_float
,
dbname
)
elif
col_type
.
lower
()
==
'double'
:
self
.
update_and_check_data
(
tbname
,
col_name
,
col_type
,
up_double
,
dbname
)
elif
'binary'
in
col_type
.
lower
():
self
.
update_and_check_data
(
tbname
,
col_name
,
col_type
,
up_binary
,
dbname
)
elif
'nchar'
in
col_type
.
lower
():
self
.
update_and_check_data
(
tbname
,
col_name
,
col_type
,
up_nchar
,
dbname
)
elif
col_type
.
lower
()
==
'timestamp'
:
self
.
update_and_check_data
(
tbname
,
col_name
,
col_type
,
self
.
ts
+
1
,
dbname
)
tdSql
.
execute
(
f
'insert into
{
tbname
}
values(
{
self
.
ts
}
,null)'
)
tdSql
.
query
(
f
'select
{
col_name
}
from
{
tbname
}
'
)
tdSql
.
checkEqual
(
tdSql
.
queryResult
[
0
][
0
],
None
)
tdSql
.
execute
(
f
'flush database
{
self
.
dbname
}
'
)
tdSql
.
execute
(
'reset query cache'
)
tdSql
.
query
(
f
'select
{
col_name
}
from
{
tbname
}
'
)
tdSql
.
checkEqual
(
tdSql
.
queryResult
[
0
][
0
],
None
)
tdSql
.
execute
(
f
'drop table
{
tbname
}
'
)
if
tb_type
==
'ctb'
:
tdSql
.
execute
(
f
'drop table
{
stbname
}
'
)
def
update_check
(
self
):
tdSql
.
execute
(
f
'drop database if exists
{
self
.
dbname
}
'
)
tdSql
.
execute
(
f
'create database
{
self
.
dbname
}
'
)
tdSql
.
execute
(
f
'use
{
self
.
dbname
}
'
)
self
.
update_data_check
(
self
.
ntbname
,
self
.
column_dict
,
self
.
dbname
,
'ntb'
)
for
col_name
,
col_type
in
self
.
column_dict
.
items
():
tdSql
.
execute
(
f
'create table
{
self
.
ntbname
}
(ts timestamp,
{
col_name
}
{
col_type
}
)'
)
tdSql
.
execute
(
f
'insert into
{
self
.
ntbname
}
values(
{
self
.
ts
}
,null)'
)
if
'binary'
in
col_type
.
lower
():
up_binary
=
tdCom
.
getLongName
(
self
.
str_length
+
1
)
tdSql
.
execute
(
f
'alter table
{
self
.
ntbname
}
modify column
{
col_name
}
binary(
{
self
.
str_length
+
1
}
)'
)
self
.
update_and_check_data
(
self
.
ntbname
,
col_name
,
col_type
,
up_binary
,
self
.
dbname
)
elif
'nchar'
in
col_type
.
lower
():
up_nchar
=
tdCom
.
getLongName
(
self
.
str_length
+
1
)
tdSql
.
execute
(
f
'alter table
{
self
.
ntbname
}
modify column
{
col_name
}
nchar(
{
self
.
str_length
+
1
}
)'
)
self
.
update_and_check_data
(
self
.
ntbname
,
col_name
,
col_type
,
up_nchar
,
self
.
dbname
)
tdSql
.
execute
(
f
'drop table
{
self
.
ntbname
}
'
)
self
.
update_data_check
(
self
.
ctbname
,
self
.
column_dict
,
self
.
dbname
,
'ctb'
,
self
.
stbname
)
for
col_name
,
col_type
in
self
.
column_dict
.
items
():
tdSql
.
execute
(
f
'create table
{
self
.
stbname
}
(ts timestamp,
{
col_name
}
{
col_type
}
) tags(t0 int)'
)
tdSql
.
execute
(
f
'create table
{
self
.
ctbname
}
using
{
self
.
stbname
}
tags(1)'
)
tdSql
.
execute
(
f
'insert into
{
self
.
ctbname
}
values(
{
self
.
ts
}
,null)'
)
if
'binary'
in
col_type
.
lower
():
up_binary
=
tdCom
.
getLongName
(
self
.
str_length
+
1
)
tdSql
.
execute
(
f
'alter table
{
self
.
stbname
}
modify column
{
col_name
}
binary(
{
self
.
str_length
+
1
}
)'
)
self
.
update_and_check_data
(
self
.
ctbname
,
col_name
,
col_type
,
up_binary
,
self
.
dbname
)
elif
'nchar'
in
col_type
.
lower
():
up_nchar
=
tdCom
.
getLongName
(
self
.
str_length
+
1
)
tdSql
.
execute
(
f
'alter table
{
self
.
stbname
}
modify column
{
col_name
}
nchar(
{
self
.
str_length
+
1
}
)'
)
self
.
update_and_check_data
(
self
.
ctbname
,
col_name
,
col_type
,
up_nchar
,
self
.
dbname
)
tdSql
.
execute
(
f
'drop table
{
self
.
stbname
}
'
)
def
update_check_error
(
self
):
tdSql
.
execute
(
f
'drop database if exists
{
self
.
dbname
}
'
)
tdSql
.
execute
(
f
'create database
{
self
.
dbname
}
'
)
tdSql
.
execute
(
f
'use
{
self
.
dbname
}
'
)
self
.
error_check
(
self
.
ntbname
,
self
.
column_dict
,
'ntb'
)
self
.
error_check
(
self
.
ctbname
,
self
.
column_dict
,
'ctb'
,
self
.
stbname
)
def
run
(
self
):
self
.
update_check
()
self
.
update_check_error
()
def
stop
(
self
):
tdSql
.
close
()
tdLog
.
success
(
"%s successfully executed"
%
__file__
)
tdCases
.
addWindows
(
__file__
,
TDTestCase
())
tdCases
.
addLinux
(
__file__
,
TDTestCase
())
\ No newline at end of file
tests/system-test/2-query/last_row.py
浏览文件 @
1b4ed84a
...
@@ -221,21 +221,21 @@ class TDTestCase:
...
@@ -221,21 +221,21 @@ class TDTestCase:
tdSql
.
execute
(
"use testdb"
)
tdSql
.
execute
(
"use testdb"
)
# bug need fix
# bug need fix
tdSql
.
error
(
"select last_row(c1 ,NULL) from testdb.t1"
)
tdSql
.
query
(
"select last_row(c1 ,NULL) from testdb.t1"
)
error_sql_lists
=
[
error_sql_lists
=
[
"select last_row from testdb.t1"
,
"select last_row from testdb.t1"
,
"select last_row(-+--+c1) from testdb.t1"
,
"select last_row(-+--+c1) from testdb.t1"
,
"select last_row(123--123)==1 from testdb.t1"
,
"select last_row(123--123)==1 from testdb.t1"
,
"select last_row(c1) as 'd1' from testdb.t1"
,
"select last_row(c1) as 'd1' from testdb.t1"
,
"select last_row(c1 ,NULL) from testdb.t1"
,
#
"select last_row(c1 ,NULL) from testdb.t1",
"select last_row(,) from testdb.t1;"
,
"select last_row(,) from testdb.t1;"
,
"select last_row(abs(c1) ab from testdb.t1)"
,
"select last_row(abs(c1) ab from testdb.t1)"
,
"select last_row(c1) as int from testdb.t1"
,
"select last_row(c1) as int from testdb.t1"
,
"select last_row from testdb.stb1"
,
"select last_row from testdb.stb1"
,
"select last_row(123--123)==1 from testdb.stb1"
,
"select last_row(123--123)==1 from testdb.stb1"
,
"select last_row(c1) as 'd1' from testdb.stb1"
,
"select last_row(c1) as 'd1' from testdb.stb1"
,
"select last_row(c1 ,NULL) from testdb.stb1"
,
#
"select last_row(c1 ,NULL) from testdb.stb1",
"select last_row(,) from testdb.stb1;"
,
"select last_row(,) from testdb.stb1;"
,
"select last_row(abs(c1) ab from testdb.stb1)"
,
"select last_row(abs(c1) ab from testdb.stb1)"
,
"select last_row(c1) as int from testdb.stb1"
"select last_row(c1) as int from testdb.stb1"
...
@@ -722,13 +722,14 @@ class TDTestCase:
...
@@ -722,13 +722,14 @@ class TDTestCase:
tdSql
.
query
(
"select last_row(ceil(c1-2)) , abs(floor(t1+1)) ,floor(c2-c1) from testdb.stb1 partition by abs(floor(c1)) order by abs(c1)"
)
tdSql
.
query
(
"select last_row(ceil(c1-2)) , abs(floor(t1+1)) ,floor(c2-c1) from testdb.stb1 partition by abs(floor(c1)) order by abs(c1)"
)
tdSql
.
checkRows
(
11
)
tdSql
.
checkRows
(
11
)
# interval
tdSql
.
query
(
"select max(c1) from stb1 interval(50s) sliding(30s)"
)
tdSql
.
query
(
"select max(c1) from stb1 interval(50s) sliding(30s)"
)
tdSql
.
checkRows
(
13
)
tdSql
.
checkRows
(
13
)
tdSql
.
query
(
"select unique(c1) from stb1 partition by tbname"
)
tdSql
.
query
(
"select unique(c1) from stb1 partition by tbname"
)
# interval
tdSql
.
query
(
"select last_row(c1) from testdb.stb1 interval(50s) sliding(30s)"
)
tdSql
.
query
(
"select last_row(c1) from testdb.stb1 interval(50s) sliding(30s)"
)
tdSql
.
checkRows
(
27
)
tdSql
.
checkRows
(
27
)
...
...
tests/system-test/7-tmq/stbTagFilter.py
浏览文件 @
1b4ed84a
...
@@ -5,103 +5,250 @@ import time
...
@@ -5,103 +5,250 @@ import time
import
socket
import
socket
import
os
import
os
import
threading
import
threading
from
enum
import
Enum
from
util.log
import
*
from
util.log
import
*
from
util.sql
import
*
from
util.sql
import
*
from
util.cases
import
*
from
util.cases
import
*
from
util.dnodes
import
*
from
util.dnodes
import
*
from
util.common
import
*
sys
.
path
.
append
(
"./7-tmq"
)
sys
.
path
.
append
(
"./7-tmq"
)
from
tmqCommon
import
*
from
tmqCommon
import
*
class
TDTestCase
:
class
TDTestCase
:
def
__init__
(
self
):
self
.
snapshot
=
0
self
.
vgroups
=
4
self
.
ctbNum
=
1
self
.
rowsPerTbl
=
10000
def
init
(
self
,
conn
,
logSql
):
def
init
(
self
,
conn
,
logSql
):
tdLog
.
debug
(
f
"start to excute
{
__file__
}
"
)
tdLog
.
debug
(
f
"start to excute
{
__file__
}
"
)
tdSql
.
init
(
conn
.
cursor
())
tdSql
.
init
(
conn
.
cursor
(),
False
)
#tdSql.init(conn.cursor(), logSql) # output sql.txt file
def
tmqCase1
(
self
):
def
prepareTestEnv
(
self
):
tdLog
.
printNoPrefix
(
"========
test case 1
: "
)
tdLog
.
printNoPrefix
(
"========
prepare test env include database, stable, ctables, and insert data
: "
)
paraDict
=
{
'dbName'
:
'db
2
'
,
paraDict
=
{
'dbName'
:
'db
t
'
,
'dropFlag'
:
1
,
'dropFlag'
:
1
,
'event'
:
''
,
'event'
:
''
,
'vgroups'
:
1
,
'vgroups'
:
4
,
'stbName'
:
'stb'
,
'stbName'
:
'stb'
,
'colPrefix'
:
'c'
,
'colPrefix'
:
'c'
,
'tagPrefix'
:
't'
,
'tagPrefix'
:
't'
,
'colSchema'
:
[{
'type'
:
'INT'
,
'count'
:
2
},
{
'type'
:
'binary'
,
'len'
:
20
,
'count'
:
1
},{
'type'
:
'TIMESTAMP'
,
'count'
:
1
}],
'colSchema'
:
[{
'type'
:
'INT'
,
'count'
:
1
},{
'type'
:
'BIGINT'
,
'count'
:
1
},{
'type'
:
'DOUBLE'
,
'count'
:
1
},{
'type'
:
'BINARY'
,
'len'
:
32
,
'count'
:
1
},{
'type'
:
'NCHAR'
,
'len'
:
32
,
'count'
:
1
},{
'type'
:
'TIMESTAMP'
,
'count'
:
1
}],
'tagSchema'
:
[{
'type'
:
'INT'
,
'count'
:
1
},
{
'type'
:
'binary'
,
'len'
:
20
,
'count'
:
1
}],
'tagSchema'
:
[{
'type'
:
'INT'
,
'count'
:
1
},
{
'type'
:
'BIGINT'
,
'count'
:
1
},{
'type'
:
'DOUBLE'
,
'count'
:
1
},{
'type'
:
'BINARY'
,
'len'
:
32
,
'count'
:
1
},{
'type'
:
'NCHAR'
,
'len'
:
32
,
'count'
:
1
}],
'ctbPrefix'
:
'ctb'
,
'ctbPrefix'
:
'ctb'
,
'ctbStartIdx'
:
0
,
'ctbStartIdx'
:
0
,
'ctbNum'
:
1
0
,
'ctbNum'
:
1
,
'rowsPerTbl'
:
1000
,
'rowsPerTbl'
:
1000
00
,
'batchNum'
:
10
,
'batchNum'
:
1
20
0
,
'startTs'
:
1640966400000
,
# 2022-01-01 00:00:00.000
'startTs'
:
1640966400000
,
# 2022-01-01 00:00:00.000
'pollDelay'
:
10
,
'pollDelay'
:
3
,
'showMsg'
:
1
,
'showMsg'
:
1
,
'showRow'
:
1
}
'showRow'
:
1
,
'snapshot'
:
0
}
paraDict
[
'vgroups'
]
=
self
.
vgroups
paraDict
[
'ctbNum'
]
=
self
.
ctbNum
paraDict
[
'rowsPerTbl'
]
=
self
.
rowsPerTbl
topicNameList
=
[
'topic1'
]
expectRowsList
=
[]
tmqCom
.
initConsumerTable
()
tmqCom
.
initConsumerTable
()
tdCom
.
create_database
(
tdSql
,
paraDict
[
"dbName"
],
paraDict
[
"dropFlag"
],
vgroups
=
1
,
replica
=
1
)
tdCom
.
create_database
(
tdSql
,
paraDict
[
"dbName"
],
paraDict
[
"dropFlag"
],
vgroups
=
paraDict
[
"vgroups"
]
,
replica
=
1
)
tdLog
.
info
(
"create stb"
)
tdLog
.
info
(
"create stb"
)
t
dCom
.
create_stable
(
tdSql
,
dbname
=
paraDict
[
"dbName"
],
stbname
=
paraDict
[
"stbName"
],
column_elm_list
=
paraDict
[
'colSchema'
],
tag_elm_list
=
paraDict
[
'tagSchema'
])
t
mqCom
.
create_stable
(
tdSql
,
dbName
=
paraDict
[
"dbName"
],
stbName
=
paraDict
[
"stbName"
])
tdLog
.
info
(
"create ctb"
)
tdLog
.
info
(
"create ctb"
)
tmqCom
.
create_ctable
(
tdSql
,
dbName
=
paraDict
[
"dbName"
],
stbName
=
paraDict
[
"stbName"
],
ctbPrefix
=
paraDict
[
'ctbPrefix'
],
ctbNum
=
paraDict
[
'ctbNum'
],
ctbStartIdx
=
paraDict
[
'ctbStartIdx'
])
tmqCom
.
create_ctable
(
tdSql
,
dbName
=
paraDict
[
"dbName"
],
stbName
=
paraDict
[
"stbName"
],
ctbPrefix
=
paraDict
[
'ctbPrefix'
],
ctbNum
=
paraDict
[
"ctbNum"
],
ctbStartIdx
=
paraDict
[
'ctbStartIdx'
])
tdLog
.
info
(
"insert data"
)
tdLog
.
info
(
"insert data"
)
tmqCom
.
asyncInsertData
(
paraDict
)
tmqCom
.
insert_data_interlaceByMultiTbl
(
tsql
=
tdSql
,
dbName
=
paraDict
[
"dbName"
],
ctbPrefix
=
paraDict
[
"ctbPrefix"
],
ctbNum
=
paraDict
[
"ctbNum"
],
rowsPerTbl
=
paraDict
[
"rowsPerTbl"
],
batchNum
=
paraDict
[
"batchNum"
],
startTs
=
paraDict
[
"startTs"
],
ctbStartIdx
=
paraDict
[
'ctbStartIdx'
])
# tmqCom.insert_data_with_autoCreateTbl(tsql=tdSql,dbName=paraDict["dbName"],stbName=paraDict["stbName"],ctbPrefix="ctbx",
# ctbNum=paraDict["ctbNum"],rowsPerTbl=paraDict["rowsPerTbl"],batchNum=paraDict["batchNum"],
# startTs=paraDict["startTs"],ctbStartIdx=paraDict['ctbStartIdx'])
# tdLog.info("restart taosd to ensure that the data falls into the disk")
# tdSql.query("flush database %s"%(paraDict['dbName']))
return
def
tmqCase1
(
self
):
tdLog
.
printNoPrefix
(
"======== test case 1: "
)
paraDict
=
{
'dbName'
:
'dbt'
,
'dropFlag'
:
1
,
'event'
:
''
,
'vgroups'
:
4
,
'stbName'
:
'stb'
,
'colPrefix'
:
'c'
,
'tagPrefix'
:
't'
,
'colSchema'
:
[{
'type'
:
'INT'
,
'count'
:
1
},{
'type'
:
'BIGINT'
,
'count'
:
1
},{
'type'
:
'DOUBLE'
,
'count'
:
1
},{
'type'
:
'BINARY'
,
'len'
:
32
,
'count'
:
1
},{
'type'
:
'NCHAR'
,
'len'
:
32
,
'count'
:
1
},{
'type'
:
'TIMESTAMP'
,
'count'
:
1
}],
'tagSchema'
:
[{
'type'
:
'INT'
,
'count'
:
1
},{
'type'
:
'BIGINT'
,
'count'
:
1
},{
'type'
:
'DOUBLE'
,
'count'
:
1
},{
'type'
:
'BINARY'
,
'len'
:
32
,
'count'
:
1
},{
'type'
:
'NCHAR'
,
'len'
:
32
,
'count'
:
1
}],
'ctbPrefix'
:
'ctb'
,
'ctbStartIdx'
:
0
,
'ctbNum'
:
1
,
'rowsPerTbl'
:
100000
,
'batchNum'
:
3000
,
'startTs'
:
1640966400000
,
# 2022-01-01 00:00:00.000
'pollDelay'
:
5
,
'showMsg'
:
1
,
'showRow'
:
1
,
'snapshot'
:
0
}
paraDict
[
'snapshot'
]
=
self
.
snapshot
paraDict
[
'vgroups'
]
=
self
.
vgroups
paraDict
[
'ctbNum'
]
=
self
.
ctbNum
paraDict
[
'rowsPerTbl'
]
=
self
.
rowsPerTbl
# update to half tables
# paraDict['rowsPerTbl'] = int(self.rowsPerTbl / 2)
# tmqCom.insert_data_with_autoCreateTbl(tsql=tdSql,dbName=paraDict["dbName"],stbName=paraDict["stbName"],ctbPrefix="ctbx",
# ctbNum=paraDict["ctbNum"],rowsPerTbl=paraDict["rowsPerTbl"],batchNum=paraDict["batchNum"],
# startTs=paraDict["startTs"],ctbStartIdx=paraDict['ctbStartIdx'])
# tmqCom.insert_data_interlaceByMultiTbl(tsql=tdSql,dbName=paraDict["dbName"],ctbPrefix=paraDict["ctbPrefix"],
# ctbNum=paraDict["ctbNum"],rowsPerTbl=paraDict["rowsPerTbl"],batchNum=paraDict["batchNum"],
# startTs=paraDict["startTs"],ctbStartIdx=paraDict['ctbStartIdx'])
tdLog
.
info
(
"create topics from stb with filter"
)
tdLog
.
info
(
"create topics from stb1"
)
# queryString = "select ts, sin(c1), pow(c2,3) from %s.%s where t2 == 'beijing' or t2 == 'changsha'" %(paraDict['dbName'], paraDict['stbName'])
topicFromStb1
=
'topic_stb1'
queryString
=
"select * from %s.%s where t2 == 'beijing' or t2 == 'changsha'"
%
(
paraDict
[
'dbName'
],
paraDict
[
'stbName'
])
queryString
=
"select ts, c1, c2 from %s.%s where t4 == 'shanghai' or t4 == 'changsha'"
%
(
paraDict
[
'dbName'
],
paraDict
[
'stbName'
])
sqlString
=
"create topic %s as %s"
%
(
topicNameList
[
0
],
queryString
)
# queryString = "select ts, c1, c2, t4 from %s.%s where t4 == 'shanghai' or t4 == 'changsha'"%(paraDict['dbName'], paraDict['stbName'])
sqlString
=
"create topic %s as %s"
%
(
topicFromStb1
,
queryString
)
tdLog
.
info
(
"create topic sql: %s"
%
sqlString
)
tdLog
.
info
(
"create topic sql: %s"
%
sqlString
)
tdSql
.
execute
(
sqlString
)
tdSql
.
execute
(
sqlString
)
#
start tmq consume processor
#
paraDict['ctbNum'] = self.ctbNum
tdLog
.
info
(
"insert consume info to consume processor"
)
paraDict
[
'rowsPerTbl'
]
=
self
.
rowsPerTbl
consumerId
=
0
consumerId
=
0
expectrowcnt
=
paraDict
[
"rowsPerTbl"
]
*
paraDict
[
"ctbNum"
]
*
2
expectrowcnt
=
int
(
paraDict
[
"rowsPerTbl"
]
*
paraDict
[
"ctbNum"
]
*
2
)
topicList
=
topicNameList
[
0
]
topicList
=
topicFromStb1
ifcheckdata
=
0
ifcheckdata
=
1
ifManualCommit
=
1
ifManualCommit
=
1
keyList
=
'group.id:cgrp1, enable.auto.commit:false, auto.commit.interval.ms:2000, auto.offset.reset:earliest'
keyList
=
'group.id:cgrp1,\
enable.auto.commit:true,\
auto.commit.interval.ms:1000,\
auto.offset.reset:earliest'
tmqCom
.
insertConsumerInfo
(
consumerId
,
expectrowcnt
,
topicList
,
keyList
,
ifcheckdata
,
ifManualCommit
)
tmqCom
.
insertConsumerInfo
(
consumerId
,
expectrowcnt
,
topicList
,
keyList
,
ifcheckdata
,
ifManualCommit
)
tdLog
.
info
(
"start consume processor"
)
tdLog
.
info
(
"start consume processor"
)
tmqCom
.
startTmqSimProcess
(
paraDict
[
'pollDelay'
],
paraDict
[
"dbName"
],
paraDict
[
'showMsg'
],
paraDict
[
'showRow'
])
tmqCom
.
startTmqSimProcess
(
pollDelay
=
paraDict
[
'pollDelay'
],
dbName
=
paraDict
[
"dbName"
],
showMsg
=
paraDict
[
'showMsg'
],
showRow
=
paraDict
[
'showRow'
],
snapshot
=
paraDict
[
'snapshot'
])
# tmqCom.getStartCommitNotifyFromTmqsim()
tmqCom
.
getStartConsumeNotifyFromTmqsim
()
tdLog
.
info
(
"create some new ctb"
)
paraDict
[
'ctbStartIdx'
]
=
paraDict
[
'ctbStartIdx'
]
+
paraDict
[
'ctbNum'
]
tmqCom
.
create_ctable
(
tdSql
,
dbName
=
paraDict
[
"dbName"
],
stbName
=
paraDict
[
"stbName"
],
ctbPrefix
=
paraDict
[
'ctbPrefix'
],
ctbNum
=
paraDict
[
'ctbNum'
],
ctbStartIdx
=
paraDict
[
'ctbStartIdx'
])
tdLog
.
info
(
"insert data into new ctb"
)
pThread
=
tmqCom
.
asyncInsertData
(
paraDict
)
pThread
.
join
()
tdLog
.
info
(
"wait insert end"
)
tdSql
.
query
(
queryString
)
expectRowsList
.
append
(
tdSql
.
getRows
())
tdLog
.
info
(
"
wait the consume result"
)
tdLog
.
info
(
"
insert process end, and start to check consume result"
)
expectRows
=
1
expectRows
=
1
resultList
=
tmqCom
.
selectConsumeResult
(
expectRows
)
resultList
=
tmqCom
.
selectConsumeResult
(
expectRows
)
totalConsumeRows
=
0
for
i
in
range
(
expectRows
):
totalConsumeRows
+=
resultList
[
i
]
tdLog
.
info
(
"run select sql from db"
)
tdSql
.
query
(
queryString
)
expectrowcnt
=
tdSql
.
getRows
()
if
expectRowsList
[
0
]
!=
resultList
[
0
]:
tdLog
.
info
(
"act consume rows: %d, expect consume rows: %d"
%
(
totalConsumeRows
,
expectrowcnt
))
tdLog
.
info
(
"expect consume rows: %d, act consume rows: %d"
%
(
expectRowsList
[
0
],
resultList
[
0
]))
if
totalConsumeRows
!=
expectrowcnt
:
tdLog
.
exit
(
"
0
tmq consume rows error!"
)
tdLog
.
exit
(
"tmq consume rows error!"
)
time
.
sleep
(
10
)
tmqCom
.
checkFileContent
(
consumerId
,
queryString
)
for
i
in
range
(
len
(
topicNameList
)):
tdSql
.
query
(
"drop topic %s"
%
topicNameList
[
i
])
tdSql
.
query
(
"drop topic %s"
%
topicFromStb1
)
tdLog
.
printNoPrefix
(
"======== test case 1 end ...... "
)
tdLog
.
printNoPrefix
(
"======== test case 1 end ...... "
)
def
tmqCase2
(
self
):
tdLog
.
printNoPrefix
(
"======== test case 2: "
)
paraDict
=
{
'dbName'
:
'dbt'
,
'dropFlag'
:
1
,
'event'
:
''
,
'vgroups'
:
4
,
'stbName'
:
'stb'
,
'colPrefix'
:
'c'
,
'tagPrefix'
:
't'
,
'colSchema'
:
[{
'type'
:
'INT'
,
'count'
:
1
},{
'type'
:
'BIGINT'
,
'count'
:
1
},{
'type'
:
'DOUBLE'
,
'count'
:
1
},{
'type'
:
'BINARY'
,
'len'
:
32
,
'count'
:
1
},{
'type'
:
'NCHAR'
,
'len'
:
32
,
'count'
:
1
},{
'type'
:
'TIMESTAMP'
,
'count'
:
1
}],
'tagSchema'
:
[{
'type'
:
'INT'
,
'count'
:
1
},{
'type'
:
'BIGINT'
,
'count'
:
1
},{
'type'
:
'DOUBLE'
,
'count'
:
1
},{
'type'
:
'BINARY'
,
'len'
:
32
,
'count'
:
1
},{
'type'
:
'NCHAR'
,
'len'
:
32
,
'count'
:
1
}],
'ctbPrefix'
:
'ctb'
,
'ctbStartIdx'
:
0
,
'ctbNum'
:
1
,
'rowsPerTbl'
:
10000
,
'batchNum'
:
5000
,
'startTs'
:
1640966400000
,
# 2022-01-01 00:00:00.000
'pollDelay'
:
5
,
'showMsg'
:
1
,
'showRow'
:
1
,
'snapshot'
:
0
}
paraDict
[
'snapshot'
]
=
self
.
snapshot
paraDict
[
'vgroups'
]
=
self
.
vgroups
paraDict
[
'ctbNum'
]
=
self
.
ctbNum
paraDict
[
'rowsPerTbl'
]
=
self
.
rowsPerTbl
tdLog
.
info
(
"restart taosd to ensure that the data falls into the disk"
)
tdSql
.
query
(
"flush database %s"
%
(
paraDict
[
'dbName'
]))
# update to half tables
paraDict
[
'startTs'
]
=
paraDict
[
'startTs'
]
+
int
(
self
.
rowsPerTbl
/
2
)
paraDict
[
'rowsPerTbl'
]
=
int
(
self
.
rowsPerTbl
/
2
)
tmqCom
.
insert_data_with_autoCreateTbl
(
tsql
=
tdSql
,
dbName
=
paraDict
[
"dbName"
],
stbName
=
paraDict
[
"stbName"
],
ctbPrefix
=
paraDict
[
"ctbPrefix"
],
ctbNum
=
paraDict
[
"ctbNum"
],
rowsPerTbl
=
paraDict
[
"rowsPerTbl"
],
batchNum
=
paraDict
[
"batchNum"
],
startTs
=
paraDict
[
"startTs"
],
ctbStartIdx
=
paraDict
[
'ctbStartIdx'
])
# tmqCom.insert_data_interlaceByMultiTbl(tsql=tdSql,dbName=paraDict["dbName"],ctbPrefix=paraDict["ctbPrefix"],
# ctbNum=paraDict["ctbNum"],rowsPerTbl=paraDict["rowsPerTbl"],batchNum=paraDict["batchNum"],
# startTs=paraDict["startTs"],ctbStartIdx=paraDict['ctbStartIdx'])
tmqCom
.
initConsumerTable
()
tdLog
.
info
(
"create topics from stb1"
)
topicFromStb1
=
'topic_stb1'
queryString
=
"select ts, c1, c2 from %s.%s"
%
(
paraDict
[
'dbName'
],
paraDict
[
'stbName'
])
sqlString
=
"create topic %s as %s"
%
(
topicFromStb1
,
queryString
)
tdLog
.
info
(
"create topic sql: %s"
%
sqlString
)
tdSql
.
execute
(
sqlString
)
# paraDict['ctbNum'] = self.ctbNum
paraDict
[
'rowsPerTbl'
]
=
self
.
rowsPerTbl
consumerId
=
1
expectrowcnt
=
int
(
paraDict
[
"rowsPerTbl"
]
*
paraDict
[
"ctbNum"
]
*
2
)
topicList
=
topicFromStb1
ifcheckdata
=
1
ifManualCommit
=
1
keyList
=
'group.id:cgrp1,\
enable.auto.commit:true,\
auto.commit.interval.ms:1000,\
auto.offset.reset:earliest'
tmqCom
.
insertConsumerInfo
(
consumerId
,
expectrowcnt
,
topicList
,
keyList
,
ifcheckdata
,
ifManualCommit
)
tdLog
.
info
(
"start consume processor"
)
tmqCom
.
startTmqSimProcess
(
pollDelay
=
paraDict
[
'pollDelay'
],
dbName
=
paraDict
[
"dbName"
],
showMsg
=
paraDict
[
'showMsg'
],
showRow
=
paraDict
[
'showRow'
],
snapshot
=
paraDict
[
'snapshot'
])
tdLog
.
info
(
"insert process end, and start to check consume result"
)
expectRows
=
1
resultList
=
tmqCom
.
selectConsumeResult
(
expectRows
)
totalConsumeRows
=
0
for
i
in
range
(
expectRows
):
totalConsumeRows
+=
resultList
[
i
]
tdSql
.
query
(
queryString
)
totalRowsInserted
=
tdSql
.
getRows
()
tdLog
.
info
(
"act consume rows: %d, act insert rows: %d, expect consume rows: %d, "
%
(
totalConsumeRows
,
totalRowsInserted
,
expectrowcnt
))
if
totalConsumeRows
!=
expectrowcnt
:
tdLog
.
exit
(
"tmq consume rows error!"
)
# tmqCom.checkFileContent(consumerId, queryString)
tdSql
.
query
(
"drop topic %s"
%
topicFromStb1
)
tdLog
.
printNoPrefix
(
"======== test case 2 end ...... "
)
def
run
(
self
):
def
run
(
self
):
tdSql
.
prepare
()
tdSql
.
prepare
()
self
.
prepareTestEnv
()
tdLog
.
printNoPrefix
(
"============================================="
)
tdLog
.
printNoPrefix
(
"======== snapshot is 0: only consume from wal"
)
self
.
tmqCase1
()
self
.
tmqCase1
()
# self.tmqCase2()
# self.prepareTestEnv()
# tdLog.printNoPrefix("====================================================================")
# tdLog.printNoPrefix("======== snapshot is 1: firstly consume from tsbs, and then from wal")
# self.snapshot = 1
# self.tmqCase1()
# self.tmqCase2()
def
stop
(
self
):
def
stop
(
self
):
tdSql
.
close
()
tdSql
.
close
()
...
...
tests/system-test/99-TDcase/TD-17255.py
浏览文件 @
1b4ed84a
...
@@ -320,7 +320,7 @@ class TDTestCase:
...
@@ -320,7 +320,7 @@ class TDTestCase:
tdSql
.
prepare
()
tdSql
.
prepare
()
self
.
tmqCase1
()
self
.
tmqCase1
()
#
self.tmqCase2()
self
.
tmqCase2
()
self
.
tmqCase3
()
self
.
tmqCase3
()
def
stop
(
self
):
def
stop
(
self
):
...
...
tests/system-test/fulltest.sh
浏览文件 @
1b4ed84a
...
@@ -10,7 +10,7 @@ python3 ./test.py -f 0-others/taosdMonitor.py
...
@@ -10,7 +10,7 @@ python3 ./test.py -f 0-others/taosdMonitor.py
python3 ./test.py
-f
0-others/udfTest.py
python3 ./test.py
-f
0-others/udfTest.py
python3 ./test.py
-f
0-others/udf_create.py
python3 ./test.py
-f
0-others/udf_create.py
python3 ./test.py
-f
0-others/udf_restart_taosd.py
python3 ./test.py
-f
0-others/udf_restart_taosd.py
python3 ./test.py
-f
0-others/cache
last
.py
python3 ./test.py
-f
0-others/cache
model
.py
python3 ./test.py
-f
0-others/udf_cfg1.py
python3 ./test.py
-f
0-others/udf_cfg1.py
python3 ./test.py
-f
0-others/udf_cfg2.py
python3 ./test.py
-f
0-others/udf_cfg2.py
...
@@ -32,7 +32,10 @@ python3 ./test.py -f 1-insert/block_wise.py
...
@@ -32,7 +32,10 @@ python3 ./test.py -f 1-insert/block_wise.py
python3 ./test.py
-f
1-insert/create_retentions.py
python3 ./test.py
-f
1-insert/create_retentions.py
python3 ./test.py
-f
1-insert/table_param_ttl.py
python3 ./test.py
-f
1-insert/table_param_ttl.py
python3 ./test.py
-f
1-insert/update_data.py
python3 ./test.py
-f
2-query/db.py
python3 ./test.py
-f
2-query/db.py
python3 ./test.py
-f
2-query/between.py
python3 ./test.py
-f
2-query/between.py
python3 ./test.py
-f
2-query/distinct.py
python3 ./test.py
-f
2-query/distinct.py
python3 ./test.py
-f
2-query/varchar.py
python3 ./test.py
-f
2-query/varchar.py
...
...
tests/test/c/tmqDemo.c
浏览文件 @
1b4ed84a
...
@@ -596,7 +596,8 @@ void printParaIntoFile() {
...
@@ -596,7 +596,8 @@ void printParaIntoFile() {
g_fp
=
pFile
;
g_fp
=
pFile
;
time_t
tTime
=
taosGetTimestampSec
();
time_t
tTime
=
taosGetTimestampSec
();
struct
tm
tm
=
*
taosLocalTime
(
&
tTime
,
NULL
);
struct
tm
tm
;
taosLocalTime
(
&
tTime
,
&
tm
);
taosFprintfFile
(
pFile
,
"###################################################################
\n
"
);
taosFprintfFile
(
pFile
,
"###################################################################
\n
"
);
taosFprintfFile
(
pFile
,
"# configDir: %s
\n
"
,
configDir
);
taosFprintfFile
(
pFile
,
"# configDir: %s
\n
"
,
configDir
);
...
...
tests/test/c/tmqSim.c
浏览文件 @
1b4ed84a
...
@@ -171,7 +171,8 @@ static void printHelp() {
...
@@ -171,7 +171,8 @@ static void printHelp() {
char
*
getCurrentTimeString
(
char
*
timeString
)
{
char
*
getCurrentTimeString
(
char
*
timeString
)
{
time_t
tTime
=
taosGetTimestampSec
();
time_t
tTime
=
taosGetTimestampSec
();
struct
tm
tm
=
*
taosLocalTime
(
&
tTime
,
NULL
);
struct
tm
tm
;
taosLocalTime
(
&
tTime
,
&
tm
);
sprintf
(
timeString
,
"%d-%02d-%02d %02d:%02d:%02d"
,
tm
.
tm_year
+
1900
,
tm
.
tm_mon
+
1
,
tm
.
tm_mday
,
tm
.
tm_hour
,
sprintf
(
timeString
,
"%d-%02d-%02d %02d:%02d:%02d"
,
tm
.
tm_year
+
1900
,
tm
.
tm_mon
+
1
,
tm
.
tm_mday
,
tm
.
tm_hour
,
tm
.
tm_min
,
tm
.
tm_sec
);
tm
.
tm_min
,
tm
.
tm_sec
);
...
@@ -420,18 +421,6 @@ static char* shellFormatTimestamp(char* buf, int64_t val, int32_t precision) {
...
@@ -420,18 +421,6 @@ static char* shellFormatTimestamp(char* buf, int64_t val, int32_t precision) {
ms
=
val
%
1000
;
ms
=
val
%
1000
;
}
}
/*
comment out as it make testcases like select_with_tags.sim fail.
but in windows, this may cause the call to localtime crash if tt < 0,
need to find a better solution.
if (tt < 0) {
tt = 0;
}
*/
#ifdef WINDOWS
if
(
tt
<
0
)
tt
=
0
;
#endif
if
(
tt
<=
0
&&
ms
<
0
)
{
if
(
tt
<=
0
&&
ms
<
0
)
{
tt
--
;
tt
--
;
if
(
precision
==
TSDB_TIME_PRECISION_NANO
)
{
if
(
precision
==
TSDB_TIME_PRECISION_NANO
)
{
...
@@ -443,8 +432,9 @@ static char* shellFormatTimestamp(char* buf, int64_t val, int32_t precision) {
...
@@ -443,8 +432,9 @@ static char* shellFormatTimestamp(char* buf, int64_t val, int32_t precision) {
}
}
}
}
struct
tm
*
ptm
=
taosLocalTime
(
&
tt
,
NULL
);
struct
tm
ptm
;
size_t
pos
=
strftime
(
buf
,
35
,
"%Y-%m-%d %H:%M:%S"
,
ptm
);
taosLocalTime
(
&
tt
,
&
ptm
);
size_t
pos
=
strftime
(
buf
,
35
,
"%Y-%m-%d %H:%M:%S"
,
&
ptm
);
if
(
precision
==
TSDB_TIME_PRECISION_NANO
)
{
if
(
precision
==
TSDB_TIME_PRECISION_NANO
)
{
sprintf
(
buf
+
pos
,
".%09d"
,
ms
);
sprintf
(
buf
+
pos
,
".%09d"
,
ms
);
...
...
tests/tsim/src/simExe.c
浏览文件 @
1b4ed84a
...
@@ -635,7 +635,7 @@ bool simCreateTaosdConnect(SScript *script, char *rest) {
...
@@ -635,7 +635,7 @@ bool simCreateTaosdConnect(SScript *script, char *rest) {
bool
simExecuteNativeSqlCommand
(
SScript
*
script
,
char
*
rest
,
bool
isSlow
)
{
bool
simExecuteNativeSqlCommand
(
SScript
*
script
,
char
*
rest
,
bool
isSlow
)
{
char
timeStr
[
30
]
=
{
0
};
char
timeStr
[
30
]
=
{
0
};
time_t
tt
;
time_t
tt
;
struct
tm
*
tp
;
struct
tm
tp
;
SCmdLine
*
line
=
&
script
->
lines
[
script
->
linePos
];
SCmdLine
*
line
=
&
script
->
lines
[
script
->
linePos
];
int32_t
ret
=
-
1
;
int32_t
ret
=
-
1
;
...
@@ -768,20 +768,9 @@ bool simExecuteNativeSqlCommand(SScript *script, char *rest, bool isSlow) {
...
@@ -768,20 +768,9 @@ bool simExecuteNativeSqlCommand(SScript *script, char *rest, bool isSlow) {
}
else
{
}
else
{
tt
=
(
*
(
int64_t
*
)
row
[
i
])
/
1000000000
;
tt
=
(
*
(
int64_t
*
)
row
[
i
])
/
1000000000
;
}
}
/* comment out as it make testcases like select_with_tags.sim fail.
but in windows, this may cause the call to localtime crash if tt < 0,
need to find a better solution.
if (tt < 0) {
tt = 0;
}
*/
#ifdef WINDOWS
if
(
tt
<
0
)
tt
=
0
;
#endif
t
p
=
taosLocalTime
(
&
tt
,
NULL
);
t
aosLocalTime
(
&
tt
,
&
tp
);
strftime
(
timeStr
,
64
,
"%y-%m-%d %H:%M:%S"
,
tp
);
strftime
(
timeStr
,
64
,
"%y-%m-%d %H:%M:%S"
,
&
tp
);
if
(
precision
==
TSDB_TIME_PRECISION_MILLI
)
{
if
(
precision
==
TSDB_TIME_PRECISION_MILLI
)
{
sprintf
(
value
,
"%s.%03d"
,
timeStr
,
(
int32_t
)(
*
((
int64_t
*
)
row
[
i
])
%
1000
));
sprintf
(
value
,
"%s.%03d"
,
timeStr
,
(
int32_t
)(
*
((
int64_t
*
)
row
[
i
])
%
1000
));
}
else
if
(
precision
==
TSDB_TIME_PRECISION_MICRO
)
{
}
else
if
(
precision
==
TSDB_TIME_PRECISION_MICRO
)
{
...
...
tests/tsim/src/simParse.c
浏览文件 @
1b4ed84a
...
@@ -175,7 +175,7 @@ SScript *simBuildScriptObj(char *fileName) {
...
@@ -175,7 +175,7 @@ SScript *simBuildScriptObj(char *fileName) {
SScript
*
simParseScript
(
char
*
fileName
)
{
SScript
*
simParseScript
(
char
*
fileName
)
{
TdFilePtr
pFile
;
TdFilePtr
pFile
;
int32_t
tokenLen
,
lineNum
=
0
;
int32_t
tokenLen
,
lineNum
=
0
;
char
*
buffer
=
NULL
,
name
[
128
],
*
token
,
*
rest
;
char
buffer
[
10
*
1024
]
,
name
[
128
],
*
token
,
*
rest
;
SCommand
*
pCmd
;
SCommand
*
pCmd
;
SScript
*
script
;
SScript
*
script
;
...
@@ -195,7 +195,7 @@ SScript *simParseScript(char *fileName) {
...
@@ -195,7 +195,7 @@ SScript *simParseScript(char *fileName) {
simResetParser
();
simResetParser
();
while
(
!
taosEOFFile
(
pFile
))
{
while
(
!
taosEOFFile
(
pFile
))
{
if
(
taosGet
LineFile
(
pFile
,
&
buffer
)
==
-
1
)
continue
;
if
(
taosGet
sFile
(
pFile
,
sizeof
(
buffer
)
-
1
,
buffer
)
==
-
1
)
continue
;
lineNum
++
;
lineNum
++
;
int32_t
cmdlen
=
(
int32_t
)
strlen
(
buffer
);
int32_t
cmdlen
=
(
int32_t
)
strlen
(
buffer
);
...
@@ -240,7 +240,6 @@ SScript *simParseScript(char *fileName) {
...
@@ -240,7 +240,6 @@ SScript *simParseScript(char *fileName) {
return
NULL
;
return
NULL
;
}
}
}
}
if
(
buffer
!=
NULL
)
taosMemoryFree
(
buffer
);
taosCloseFile
(
&
pFile
);
taosCloseFile
(
&
pFile
);
script
=
simBuildScriptObj
(
fileName
);
script
=
simBuildScriptObj
(
fileName
);
...
...
tools/shell/src/shellEngine.c
浏览文件 @
1b4ed84a
...
@@ -231,18 +231,6 @@ char *shellFormatTimestamp(char *buf, int64_t val, int32_t precision) {
...
@@ -231,18 +231,6 @@ char *shellFormatTimestamp(char *buf, int64_t val, int32_t precision) {
ms
=
val
%
1000
;
ms
=
val
%
1000
;
}
}
/*
comment out as it make testcases like select_with_tags.sim fail.
but in windows, this may cause the call to localtime crash if tt < 0,
need to find a better solution.
if (tt < 0) {
tt = 0;
}
*/
#ifdef WINDOWS
if
(
tt
<
0
)
tt
=
0
;
#endif
if
(
tt
<=
0
&&
ms
<
0
)
{
if
(
tt
<=
0
&&
ms
<
0
)
{
tt
--
;
tt
--
;
if
(
precision
==
TSDB_TIME_PRECISION_NANO
)
{
if
(
precision
==
TSDB_TIME_PRECISION_NANO
)
{
...
@@ -254,8 +242,9 @@ char *shellFormatTimestamp(char *buf, int64_t val, int32_t precision) {
...
@@ -254,8 +242,9 @@ char *shellFormatTimestamp(char *buf, int64_t val, int32_t precision) {
}
}
}
}
struct
tm
*
ptm
=
taosLocalTime
(
&
tt
,
NULL
);
struct
tm
ptm
=
{
0
};
size_t
pos
=
strftime
(
buf
,
35
,
"%Y-%m-%d %H:%M:%S"
,
ptm
);
taosLocalTime
(
&
tt
,
&
ptm
);
size_t
pos
=
strftime
(
buf
,
35
,
"%Y-%m-%d %H:%M:%S"
,
&
ptm
);
if
(
precision
==
TSDB_TIME_PRECISION_NANO
)
{
if
(
precision
==
TSDB_TIME_PRECISION_NANO
)
{
sprintf
(
buf
+
pos
,
".%09d"
,
ms
);
sprintf
(
buf
+
pos
,
".%09d"
,
ms
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录