Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
64c06c95
T
TDengine
项目概览
taosdata
/
TDengine
大约 2 年 前同步成功
通知
1192
Star
22018
Fork
4786
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
未验证
提交
64c06c95
编写于
4月 06, 2021
作者:
S
Shengliang Guan
提交者:
GitHub
4月 06, 2021
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #5683 from taosdata/develop
Merge from develop into master
上级
acaf5f25
25396ed6
变更
46
展开全部
显示空白变更内容
内联
并排
Showing
46 changed file
with
1164 addition
and
821 deletion
+1164
-821
cmake/version.inc
cmake/version.inc
+1
-1
documentation20/cn/02.getting-started/docs.md
documentation20/cn/02.getting-started/docs.md
+5
-5
documentation20/cn/08.connector/docs.md
documentation20/cn/08.connector/docs.md
+2
-2
snap/snapcraft.yaml
snap/snapcraft.yaml
+2
-2
src/client/inc/tscUtil.h
src/client/inc/tscUtil.h
+4
-13
src/client/inc/tsclient.h
src/client/inc/tsclient.h
+17
-0
src/client/src/tscLocalMerge.c
src/client/src/tscLocalMerge.c
+19
-4
src/client/src/tscParseInsert.c
src/client/src/tscParseInsert.c
+250
-284
src/client/src/tscUtil.c
src/client/src/tscUtil.c
+79
-21
src/cq/src/cqMain.c
src/cq/src/cqMain.c
+6
-2
src/cq/test/cqtest.c
src/cq/test/cqtest.c
+1
-1
src/dnode/src/dnodeVWrite.c
src/dnode/src/dnodeVWrite.c
+1
-1
src/inc/tcq.h
src/inc/tcq.h
+1
-1
src/inc/tsdb.h
src/inc/tsdb.h
+1
-1
src/kit/taosdemo/taosdemo.c
src/kit/taosdemo/taosdemo.c
+317
-272
src/kit/taosdump/taosdump.c
src/kit/taosdump/taosdump.c
+186
-127
src/mnode/src/mnodeDnode.c
src/mnode/src/mnodeDnode.c
+5
-0
src/mnode/src/mnodeMnode.c
src/mnode/src/mnodeMnode.c
+2
-0
src/query/inc/qExecutor.h
src/query/inc/qExecutor.h
+2
-1
src/query/src/qExecutor.c
src/query/src/qExecutor.c
+23
-5
src/query/src/qTokenizer.c
src/query/src/qTokenizer.c
+5
-1
src/query/src/qUtil.c
src/query/src/qUtil.c
+4
-7
src/query/tests/resultBufferTest.cpp
src/query/tests/resultBufferTest.cpp
+3
-3
src/sync/inc/syncInt.h
src/sync/inc/syncInt.h
+1
-1
src/sync/src/syncMain.c
src/sync/src/syncMain.c
+7
-2
src/tsdb/src/tsdbMain.c
src/tsdb/src/tsdbMain.c
+2
-2
src/tsdb/src/tsdbMeta.c
src/tsdb/src/tsdbMeta.c
+2
-2
src/util/inc/tstoken.h
src/util/inc/tstoken.h
+1
-3
src/vnode/src/vnodeWrite.c
src/vnode/src/vnodeWrite.c
+5
-1
tests/pytest/fulltest.sh
tests/pytest/fulltest.sh
+1
-1
tests/pytest/insert/metadataUpdate.py
tests/pytest/insert/metadataUpdate.py
+20
-27
tests/pytest/tools/insert-tblimit-tboffset-createdb.json
tests/pytest/tools/insert-tblimit-tboffset-createdb.json
+57
-0
tests/pytest/tools/insert-tblimit-tboffset-insertrec.json
tests/pytest/tools/insert-tblimit-tboffset-insertrec.json
+59
-0
tests/pytest/tools/insert-tblimit-tboffset0.json
tests/pytest/tools/insert-tblimit-tboffset0.json
+2
-2
tests/pytest/tools/insert-tblimit1-tboffset.json
tests/pytest/tools/insert-tblimit1-tboffset.json
+2
-2
tests/pytest/tools/taosdemo-sampledata.json
tests/pytest/tools/taosdemo-sampledata.json
+0
-2
tests/pytest/tools/taosdemoTestLimitOffset.py
tests/pytest/tools/taosdemoTestLimitOffset.py
+4
-1
tests/pytest/tools/taosdemoTestSampleData.py
tests/pytest/tools/taosdemoTestSampleData.py
+1
-1
tests/script/general/parser/alter.sim
tests/script/general/parser/alter.sim
+13
-6
tests/script/general/parser/gendata.sh
tests/script/general/parser/gendata.sh
+6
-0
tests/script/general/parser/import_file.sim
tests/script/general/parser/import_file.sim
+7
-11
tests/script/general/parser/select_with_tags.sim
tests/script/general/parser/select_with_tags.sim
+9
-0
tests/tsim/inc/sim.h
tests/tsim/inc/sim.h
+1
-0
tests/tsim/src/simExe.c
tests/tsim/src/simExe.c
+10
-1
tests/tsim/src/simMain.c
tests/tsim/src/simMain.c
+9
-1
tests/tsim/src/simSystem.c
tests/tsim/src/simSystem.c
+9
-1
未找到文件。
cmake/version.inc
浏览文件 @
64c06c95
...
@@ -4,7 +4,7 @@ PROJECT(TDengine)
...
@@ -4,7 +4,7 @@ PROJECT(TDengine)
IF
(
DEFINED
VERNUMBER
)
IF
(
DEFINED
VERNUMBER
)
SET
(
TD_VER_NUMBER
$
{
VERNUMBER
})
SET
(
TD_VER_NUMBER
$
{
VERNUMBER
})
ELSE
()
ELSE
()
SET
(
TD_VER_NUMBER
"2.0.1
8
.0"
)
SET
(
TD_VER_NUMBER
"2.0.1
9
.0"
)
ENDIF
()
ENDIF
()
IF
(
DEFINED
VERCOMPATIBLE
)
IF
(
DEFINED
VERCOMPATIBLE
)
...
...
documentation20/cn/02.getting-started/docs.md
浏览文件 @
64c06c95
...
@@ -101,7 +101,7 @@ $ taos -h 192.168.0.1 -s "use db; show tables;"
...
@@ -101,7 +101,7 @@ $ taos -h 192.168.0.1 -s "use db; show tables;"
### 运行SQL命令脚本
### 运行SQL命令脚本
TDengine
终端可以通过
`source`
命令来运行SQL
命令脚本.
TDengine
终端可以通过
`source`
命令来运行 SQL
命令脚本.
```
mysql
```
mysql
taos> source <filename>;
taos> source <filename>;
...
@@ -109,10 +109,10 @@ taos> source <filename>;
...
@@ -109,10 +109,10 @@ taos> source <filename>;
### Shell小技巧
### Shell小技巧
-
可以使用上下光标键查看
已经历史输入的命
令
-
可以使用上下光标键查看
历史输入的指
令
-
修改用户密码。在
shell中使用alter user命
令
-
修改用户密码。在
shell 中使用 alter user 指
令
-
ctrl+c 中止正在进行中的查询
-
ctrl+c 中止正在进行中的查询
-
执行
`RESET QUERY CACHE`
清空本地缓存的表的
schema
-
执行
`RESET QUERY CACHE`
清空本地缓存的表
schema
## <a class="anchor" id="demo"></a>TDengine 极速体验
## <a class="anchor" id="demo"></a>TDengine 极速体验
...
@@ -212,7 +212,7 @@ taos> select avg(f1), max(f2), min(f3) from test.t10 interval(10s);
...
@@ -212,7 +212,7 @@ taos> select avg(f1), max(f2), min(f3) from test.t10 interval(10s);
|
**Python**
| ● | ● | ● | ○ | ● | ● | ● | -- | ● |
|
**Python**
| ● | ● | ● | ○ | ● | ● | ● | -- | ● |
|
**Go**
| ● | ● | ● | ○ | ● | ● | ○ | -- | -- |
|
**Go**
| ● | ● | ● | ○ | ● | ● | ○ | -- | -- |
|
**NodeJs**
| ● | ● | ○ | ○ | ● | ● | ○ | -- | -- |
|
**NodeJs**
| ● | ● | ○ | ○ | ● | ● | ○ | -- | -- |
|
**C#**
|
○ | ● | ●
| ○ | ○ | ○ | ○ | -- | -- |
|
**C#**
|
● | ● | ○
| ○ | ○ | ○ | ○ | -- | -- |
|
**RESTful**
| ● | ● | ● | ● | ● | ● | ● | ● | ● |
|
**RESTful**
| ● | ● | ● | ● | ● | ● | ● | ● | ● |
注: ● 表示经过官方测试验证, ○ 表示非官方测试验证。
注: ● 表示经过官方测试验证, ○ 表示非官方测试验证。
...
...
documentation20/cn/08.connector/docs.md
浏览文件 @
64c06c95
...
@@ -14,7 +14,7 @@ TDengine提供了丰富的应用程序开发接口,其中包括C/C++、Java、
...
@@ -14,7 +14,7 @@ TDengine提供了丰富的应用程序开发接口,其中包括C/C++、Java、
|
**Python**
| ● | ● | ● | ○ | ● | ● | ○ | -- | ○ |
|
**Python**
| ● | ● | ● | ○ | ● | ● | ○ | -- | ○ |
|
**Go**
| ● | ● | ● | ○ | ● | ● | ○ | -- | -- |
|
**Go**
| ● | ● | ● | ○ | ● | ● | ○ | -- | -- |
|
**NodeJs**
| ● | ● | ○ | ○ | ● | ● | ○ | -- | -- |
|
**NodeJs**
| ● | ● | ○ | ○ | ● | ● | ○ | -- | -- |
|
**C#**
|
○ | ● | ●
| ○ | ○ | ○ | ○ | -- | -- |
|
**C#**
|
● | ● | ○
| ○ | ○ | ○ | ○ | -- | -- |
|
**RESTful**
| ● | ● | ● | ● | ● | ● | ○ | ○ | ○ |
|
**RESTful**
| ● | ● | ● | ● | ● | ● | ○ | ○ | ○ |
其中 ● 表示经过官方测试验证, ○ 表示非官方测试验证。
其中 ● 表示经过官方测试验证, ○ 表示非官方测试验证。
...
@@ -23,7 +23,7 @@ TDengine提供了丰富的应用程序开发接口,其中包括C/C++、Java、
...
@@ -23,7 +23,7 @@ TDengine提供了丰富的应用程序开发接口,其中包括C/C++、Java、
*
在没有安装TDengine服务端软件的系统中使用连接器(除RESTful外)访问 TDengine 数据库,需要安装相应版本的客户端安装包来使应用驱动(Linux系统中文件名为libtaos.so,Windows系统中为taos.dll)被安装在系统中,否则会产生无法找到相应库文件的错误。
*
在没有安装TDengine服务端软件的系统中使用连接器(除RESTful外)访问 TDengine 数据库,需要安装相应版本的客户端安装包来使应用驱动(Linux系统中文件名为libtaos.so,Windows系统中为taos.dll)被安装在系统中,否则会产生无法找到相应库文件的错误。
*
所有执行 SQL 语句的 API,例如 C/C++ Connector 中的
`tao_query`
、
`taos_query_a`
、
`taos_subscribe`
等,以及其它语言中与它们对应的API,每次都只能执行一条 SQL 语句,如果实际参数中包含了多条语句,它们的行为是未定义的。
*
所有执行 SQL 语句的 API,例如 C/C++ Connector 中的
`tao_query`
、
`taos_query_a`
、
`taos_subscribe`
等,以及其它语言中与它们对应的API,每次都只能执行一条 SQL 语句,如果实际参数中包含了多条语句,它们的行为是未定义的。
*
升级到TDengine到2.0.8.0版本的用户,必须更新JDBC连接TDengine必须升级taos-jdbcdriver到2.0.12及以上。
*
升级到TDengine到2.0.8.0版本的用户,必须更新JDBC连接TDengine必须升级taos-jdbcdriver到2.0.12及以上。
详细的版本依赖关系请参见
[
taos-jdbcdriver 文档
](
https://www.taosdata.com/cn/documentation/connector/java#version
)
。
*
无论选用何种编程语言的连接器,2.0 及以上版本的 TDengine 推荐数据库应用的每个线程都建立一个独立的连接,或基于线程建立连接池,以避免连接内的“USE statement”状态量在线程之间相互干扰(但连接的查询和写入操作都是线程安全的)。
*
无论选用何种编程语言的连接器,2.0 及以上版本的 TDengine 推荐数据库应用的每个线程都建立一个独立的连接,或基于线程建立连接池,以避免连接内的“USE statement”状态量在线程之间相互干扰(但连接的查询和写入操作都是线程安全的)。
## <a class="anchor" id="driver"></a>安装连接器驱动步骤
## <a class="anchor" id="driver"></a>安装连接器驱动步骤
...
...
snap/snapcraft.yaml
浏览文件 @
64c06c95
name
:
tdengine
name
:
tdengine
base
:
core18
base
:
core18
version
:
'
2.0.1
8
.0'
version
:
'
2.0.1
9
.0'
icon
:
snap/gui/t-dengine.svg
icon
:
snap/gui/t-dengine.svg
summary
:
an open-source big data platform designed and optimized for IoT.
summary
:
an open-source big data platform designed and optimized for IoT.
description
:
|
description
:
|
...
@@ -72,7 +72,7 @@ parts:
...
@@ -72,7 +72,7 @@ parts:
-
usr/bin/taosd
-
usr/bin/taosd
-
usr/bin/taos
-
usr/bin/taos
-
usr/bin/taosdemo
-
usr/bin/taosdemo
-
usr/lib/libtaos.so.2.0.1
8
.0
-
usr/lib/libtaos.so.2.0.1
9
.0
-
usr/lib/libtaos.so.1
-
usr/lib/libtaos.so.1
-
usr/lib/libtaos.so
-
usr/lib/libtaos.so
...
...
src/client/inc/tscUtil.h
浏览文件 @
64c06c95
...
@@ -36,19 +36,6 @@ extern "C" {
...
@@ -36,19 +36,6 @@ extern "C" {
#define UTIL_TABLE_IS_NORMAL_TABLE(metaInfo)\
#define UTIL_TABLE_IS_NORMAL_TABLE(metaInfo)\
(!(UTIL_TABLE_IS_SUPER_TABLE(metaInfo) || UTIL_TABLE_IS_CHILD_TABLE(metaInfo)))
(!(UTIL_TABLE_IS_SUPER_TABLE(metaInfo) || UTIL_TABLE_IS_CHILD_TABLE(metaInfo)))
typedef
struct
SParsedColElem
{
int16_t
colIndex
;
uint16_t
offset
;
}
SParsedColElem
;
typedef
struct
SParsedDataColInfo
{
int16_t
numOfCols
;
int16_t
numOfAssignedCols
;
SParsedColElem
elems
[
TSDB_MAX_COLUMNS
];
bool
hasVal
[
TSDB_MAX_COLUMNS
];
}
SParsedDataColInfo
;
#pragma pack(push,1)
#pragma pack(push,1)
// this struct is transfered as binary, padding two bytes to avoid
// this struct is transfered as binary, padding two bytes to avoid
// an 'uid' whose low bytes is 0xff being recoginized as NULL,
// an 'uid' whose low bytes is 0xff being recoginized as NULL,
...
@@ -118,6 +105,8 @@ int32_t tscCreateDataBlock(size_t initialSize, int32_t rowSize, int32_t startOff
...
@@ -118,6 +105,8 @@ int32_t tscCreateDataBlock(size_t initialSize, int32_t rowSize, int32_t startOff
void
tscDestroyDataBlock
(
STableDataBlocks
*
pDataBlock
,
bool
removeMeta
);
void
tscDestroyDataBlock
(
STableDataBlocks
*
pDataBlock
,
bool
removeMeta
);
void
tscSortRemoveDataBlockDupRows
(
STableDataBlocks
*
dataBuf
);
void
tscSortRemoveDataBlockDupRows
(
STableDataBlocks
*
dataBuf
);
void
tscDestroyBoundColumnInfo
(
SParsedDataColInfo
*
pColInfo
);
SParamInfo
*
tscAddParamToDataBlock
(
STableDataBlocks
*
pDataBlock
,
char
type
,
uint8_t
timePrec
,
int16_t
bytes
,
SParamInfo
*
tscAddParamToDataBlock
(
STableDataBlocks
*
pDataBlock
,
char
type
,
uint8_t
timePrec
,
int16_t
bytes
,
uint32_t
offset
);
uint32_t
offset
);
...
@@ -140,6 +129,8 @@ bool tscIsPointInterpQuery(SQueryInfo* pQueryInfo);
...
@@ -140,6 +129,8 @@ bool tscIsPointInterpQuery(SQueryInfo* pQueryInfo);
bool
tscIsTWAQuery
(
SQueryInfo
*
pQueryInfo
);
bool
tscIsTWAQuery
(
SQueryInfo
*
pQueryInfo
);
bool
tscIsSecondStageQuery
(
SQueryInfo
*
pQueryInfo
);
bool
tscIsSecondStageQuery
(
SQueryInfo
*
pQueryInfo
);
bool
tscGroupbyColumn
(
SQueryInfo
*
pQueryInfo
);
bool
tscGroupbyColumn
(
SQueryInfo
*
pQueryInfo
);
bool
tscIsTopbotQuery
(
SQueryInfo
*
pQueryInfo
);
int32_t
tscGetTopbotQueryParam
(
SQueryInfo
*
pQueryInfo
);
bool
tscNonOrderedProjectionQueryOnSTable
(
SQueryInfo
*
pQueryInfo
,
int32_t
tableIndex
);
bool
tscNonOrderedProjectionQueryOnSTable
(
SQueryInfo
*
pQueryInfo
,
int32_t
tableIndex
);
bool
tscOrderedProjectionQueryOnSTable
(
SQueryInfo
*
pQueryInfo
,
int32_t
tableIndex
);
bool
tscOrderedProjectionQueryOnSTable
(
SQueryInfo
*
pQueryInfo
,
int32_t
tableIndex
);
...
...
src/client/inc/tsclient.h
浏览文件 @
64c06c95
...
@@ -175,6 +175,19 @@ typedef struct SParamInfo {
...
@@ -175,6 +175,19 @@ typedef struct SParamInfo {
uint32_t
offset
;
uint32_t
offset
;
}
SParamInfo
;
}
SParamInfo
;
typedef
struct
SBoundColumn
{
bool
hasVal
;
// denote if current column has bound or not
int32_t
offset
;
// all column offset value
}
SBoundColumn
;
typedef
struct
SParsedDataColInfo
{
int16_t
numOfCols
;
int16_t
numOfBound
;
int32_t
*
boundedColumns
;
SBoundColumn
*
cols
;
}
SParsedDataColInfo
;
typedef
struct
STableDataBlocks
{
typedef
struct
STableDataBlocks
{
SName
tableName
;
SName
tableName
;
int8_t
tsSource
;
// where does the UNIX timestamp come from, server or client
int8_t
tsSource
;
// where does the UNIX timestamp come from, server or client
...
@@ -189,6 +202,8 @@ typedef struct STableDataBlocks {
...
@@ -189,6 +202,8 @@ typedef struct STableDataBlocks {
STableMeta
*
pTableMeta
;
// the tableMeta of current table, the table meta will be used during submit, keep a ref to avoid to be removed from cache
STableMeta
*
pTableMeta
;
// the tableMeta of current table, the table meta will be used during submit, keep a ref to avoid to be removed from cache
char
*
pData
;
char
*
pData
;
SParsedDataColInfo
boundColumnInfo
;
// for parameter ('?') binding
// for parameter ('?') binding
uint32_t
numOfAllocedParams
;
uint32_t
numOfAllocedParams
;
uint32_t
numOfParams
;
uint32_t
numOfParams
;
...
@@ -425,6 +440,7 @@ void tscRestoreFuncForSTableQuery(SQueryInfo *pQueryInfo);
...
@@ -425,6 +440,7 @@ void tscRestoreFuncForSTableQuery(SQueryInfo *pQueryInfo);
int32_t
tscCreateResPointerInfo
(
SSqlRes
*
pRes
,
SQueryInfo
*
pQueryInfo
);
int32_t
tscCreateResPointerInfo
(
SSqlRes
*
pRes
,
SQueryInfo
*
pQueryInfo
);
void
tscSetResRawPtr
(
SSqlRes
*
pRes
,
SQueryInfo
*
pQueryInfo
);
void
tscSetResRawPtr
(
SSqlRes
*
pRes
,
SQueryInfo
*
pQueryInfo
);
void
destroyTableNameList
(
SSqlCmd
*
pCmd
);
void
tscResetSqlCmd
(
SSqlCmd
*
pCmd
,
bool
removeMeta
);
void
tscResetSqlCmd
(
SSqlCmd
*
pCmd
,
bool
removeMeta
);
...
@@ -462,6 +478,7 @@ char* tscGetSqlStr(SSqlObj* pSql);
...
@@ -462,6 +478,7 @@ char* tscGetSqlStr(SSqlObj* pSql);
bool
tscIsQueryWithLimit
(
SSqlObj
*
pSql
);
bool
tscIsQueryWithLimit
(
SSqlObj
*
pSql
);
bool
tscHasReachLimitation
(
SQueryInfo
*
pQueryInfo
,
SSqlRes
*
pRes
);
bool
tscHasReachLimitation
(
SQueryInfo
*
pQueryInfo
,
SSqlRes
*
pRes
);
void
tscSetBoundColumnInfo
(
SParsedDataColInfo
*
pColInfo
,
SSchema
*
pSchema
,
int32_t
numOfCols
);
char
*
tscGetErrorMsgPayload
(
SSqlCmd
*
pCmd
);
char
*
tscGetErrorMsgPayload
(
SSqlCmd
*
pCmd
);
...
...
src/client/src/tscLocalMerge.c
浏览文件 @
64c06c95
...
@@ -338,11 +338,20 @@ void tscCreateLocalMerger(tExtMemBuffer **pMemBuffer, int32_t numOfBuffer, tOrde
...
@@ -338,11 +338,20 @@ void tscCreateLocalMerger(tExtMemBuffer **pMemBuffer, int32_t numOfBuffer, tOrde
pReducer
->
resColModel
->
capacity
=
pReducer
->
nResultBufSize
;
pReducer
->
resColModel
->
capacity
=
pReducer
->
nResultBufSize
;
pReducer
->
finalModel
=
pFFModel
;
pReducer
->
finalModel
=
pFFModel
;
int32_t
expandFactor
=
1
;
if
(
finalmodel
->
rowSize
>
0
)
{
if
(
finalmodel
->
rowSize
>
0
)
{
bool
topBotQuery
=
tscIsTopbotQuery
(
pQueryInfo
);
if
(
topBotQuery
)
{
expandFactor
=
tscGetTopbotQueryParam
(
pQueryInfo
);
pReducer
->
resColModel
->
capacity
/=
(
finalmodel
->
rowSize
*
expandFactor
);
pReducer
->
resColModel
->
capacity
*=
expandFactor
;
}
else
{
pReducer
->
resColModel
->
capacity
/=
finalmodel
->
rowSize
;
pReducer
->
resColModel
->
capacity
/=
finalmodel
->
rowSize
;
}
}
}
assert
(
finalmodel
->
rowSize
>
0
&&
finalmodel
->
rowSize
<=
pReducer
->
rowSize
);
assert
(
finalmodel
->
rowSize
>
0
&&
finalmodel
->
rowSize
<=
pReducer
->
rowSize
);
pReducer
->
pFinalRes
=
calloc
(
1
,
pReducer
->
rowSize
*
pReducer
->
resColModel
->
capacity
);
pReducer
->
pFinalRes
=
calloc
(
1
,
pReducer
->
rowSize
*
pReducer
->
resColModel
->
capacity
);
if
(
pReducer
->
pTempBuffer
==
NULL
||
pReducer
->
discardData
==
NULL
||
pReducer
->
pResultBuf
==
NULL
||
if
(
pReducer
->
pTempBuffer
==
NULL
||
pReducer
->
discardData
==
NULL
||
pReducer
->
pResultBuf
==
NULL
||
...
@@ -1150,9 +1159,10 @@ static void fillMultiRowsOfTagsVal(SQueryInfo *pQueryInfo, int32_t numOfRes, SLo
...
@@ -1150,9 +1159,10 @@ static void fillMultiRowsOfTagsVal(SQueryInfo *pQueryInfo, int32_t numOfRes, SLo
memset
(
buf
,
0
,
(
size_t
)
maxBufSize
);
memset
(
buf
,
0
,
(
size_t
)
maxBufSize
);
memcpy
(
buf
,
pCtx
->
pOutput
,
(
size_t
)
pCtx
->
outputBytes
);
memcpy
(
buf
,
pCtx
->
pOutput
,
(
size_t
)
pCtx
->
outputBytes
);
char
*
next
=
pCtx
->
pOutput
;
for
(
int32_t
i
=
0
;
i
<
inc
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
inc
;
++
i
)
{
pCtx
->
pOutpu
t
+=
pCtx
->
outputBytes
;
nex
t
+=
pCtx
->
outputBytes
;
memcpy
(
pCtx
->
pOutpu
t
,
buf
,
(
size_t
)
pCtx
->
outputBytes
);
memcpy
(
nex
t
,
buf
,
(
size_t
)
pCtx
->
outputBytes
);
}
}
}
}
...
@@ -1440,6 +1450,11 @@ int32_t tscDoLocalMerge(SSqlObj *pSql) {
...
@@ -1440,6 +1450,11 @@ int32_t tscDoLocalMerge(SSqlObj *pSql) {
SQueryInfo
*
pQueryInfo
=
tscGetQueryInfoDetail
(
pCmd
,
pCmd
->
clauseIndex
);
SQueryInfo
*
pQueryInfo
=
tscGetQueryInfoDetail
(
pCmd
,
pCmd
->
clauseIndex
);
tFilePage
*
tmpBuffer
=
pLocalMerge
->
pTempBuffer
;
tFilePage
*
tmpBuffer
=
pLocalMerge
->
pTempBuffer
;
int32_t
remain
=
1
;
if
(
tscIsTopbotQuery
(
pQueryInfo
))
{
remain
=
tscGetTopbotQueryParam
(
pQueryInfo
);
}
if
(
doHandleLastRemainData
(
pSql
))
{
if
(
doHandleLastRemainData
(
pSql
))
{
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
...
@@ -1528,7 +1543,7 @@ int32_t tscDoLocalMerge(SSqlObj *pSql) {
...
@@ -1528,7 +1543,7 @@ int32_t tscDoLocalMerge(SSqlObj *pSql) {
* if the previous group does NOT generate any result (pResBuf->num == 0),
* if the previous group does NOT generate any result (pResBuf->num == 0),
* continue to process results instead of return results.
* continue to process results instead of return results.
*/
*/
if
((
!
sameGroup
&&
pResBuf
->
num
>
0
)
||
(
pResBuf
->
num
=
=
pLocalMerge
->
resColModel
->
capacity
))
{
if
((
!
sameGroup
&&
pResBuf
->
num
>
0
)
||
(
pResBuf
->
num
+
remain
>
=
pLocalMerge
->
resColModel
->
capacity
))
{
// does not belong to the same group
// does not belong to the same group
bool
notSkipped
=
genFinalResults
(
pSql
,
pLocalMerge
,
!
sameGroup
);
bool
notSkipped
=
genFinalResults
(
pSql
,
pLocalMerge
,
!
sameGroup
);
...
...
src/client/src/tscParseInsert.c
浏览文件 @
64c06c95
此差异已折叠。
点击以展开。
src/client/src/tscUtil.c
浏览文件 @
64c06c95
...
@@ -271,6 +271,41 @@ bool tscIsTWAQuery(SQueryInfo* pQueryInfo) {
...
@@ -271,6 +271,41 @@ bool tscIsTWAQuery(SQueryInfo* pQueryInfo) {
return
false
;
return
false
;
}
}
bool
tscIsTopbotQuery
(
SQueryInfo
*
pQueryInfo
)
{
size_t
numOfExprs
=
tscSqlExprNumOfExprs
(
pQueryInfo
);
for
(
int32_t
i
=
0
;
i
<
numOfExprs
;
++
i
)
{
SSqlExpr
*
pExpr
=
tscSqlExprGet
(
pQueryInfo
,
i
);
if
(
pExpr
==
NULL
)
{
continue
;
}
int32_t
functionId
=
pExpr
->
functionId
;
if
(
functionId
==
TSDB_FUNC_TOP
||
functionId
==
TSDB_FUNC_BOTTOM
)
{
return
true
;
}
}
return
false
;
}
int32_t
tscGetTopbotQueryParam
(
SQueryInfo
*
pQueryInfo
)
{
size_t
numOfExprs
=
tscSqlExprNumOfExprs
(
pQueryInfo
);
for
(
int32_t
i
=
0
;
i
<
numOfExprs
;
++
i
)
{
SSqlExpr
*
pExpr
=
tscSqlExprGet
(
pQueryInfo
,
i
);
if
(
pExpr
==
NULL
)
{
continue
;
}
int32_t
functionId
=
pExpr
->
functionId
;
if
(
functionId
==
TSDB_FUNC_TOP
||
functionId
==
TSDB_FUNC_BOTTOM
)
{
return
(
int32_t
)
pExpr
->
param
[
0
].
i64
;
}
}
return
0
;
}
void
tscClearInterpInfo
(
SQueryInfo
*
pQueryInfo
)
{
void
tscClearInterpInfo
(
SQueryInfo
*
pQueryInfo
)
{
if
(
!
tscIsPointInterpQuery
(
pQueryInfo
))
{
if
(
!
tscIsPointInterpQuery
(
pQueryInfo
))
{
return
;
return
;
...
@@ -415,6 +450,20 @@ void tscFreeQueryInfo(SSqlCmd* pCmd, bool removeMeta) {
...
@@ -415,6 +450,20 @@ void tscFreeQueryInfo(SSqlCmd* pCmd, bool removeMeta) {
tfree
(
pCmd
->
pQueryInfo
);
tfree
(
pCmd
->
pQueryInfo
);
}
}
void
destroyTableNameList
(
SSqlCmd
*
pCmd
)
{
if
(
pCmd
->
numOfTables
==
0
)
{
assert
(
pCmd
->
pTableNameList
==
NULL
);
return
;
}
for
(
int32_t
i
=
0
;
i
<
pCmd
->
numOfTables
;
++
i
)
{
tfree
(
pCmd
->
pTableNameList
[
i
]);
}
pCmd
->
numOfTables
=
0
;
tfree
(
pCmd
->
pTableNameList
);
}
void
tscResetSqlCmd
(
SSqlCmd
*
pCmd
,
bool
removeMeta
)
{
void
tscResetSqlCmd
(
SSqlCmd
*
pCmd
,
bool
removeMeta
)
{
pCmd
->
command
=
0
;
pCmd
->
command
=
0
;
pCmd
->
numOfCols
=
0
;
pCmd
->
numOfCols
=
0
;
...
@@ -424,14 +473,7 @@ void tscResetSqlCmd(SSqlCmd* pCmd, bool removeMeta) {
...
@@ -424,14 +473,7 @@ void tscResetSqlCmd(SSqlCmd* pCmd, bool removeMeta) {
pCmd
->
parseFinished
=
0
;
pCmd
->
parseFinished
=
0
;
pCmd
->
autoCreated
=
0
;
pCmd
->
autoCreated
=
0
;
for
(
int32_t
i
=
0
;
i
<
pCmd
->
numOfTables
;
++
i
)
{
destroyTableNameList
(
pCmd
);
if
(
pCmd
->
pTableNameList
&&
pCmd
->
pTableNameList
[
i
])
{
tfree
(
pCmd
->
pTableNameList
[
i
]);
}
}
pCmd
->
numOfTables
=
0
;
tfree
(
pCmd
->
pTableNameList
);
pCmd
->
pTableBlockHashList
=
tscDestroyBlockHashTable
(
pCmd
->
pTableBlockHashList
,
removeMeta
);
pCmd
->
pTableBlockHashList
=
tscDestroyBlockHashTable
(
pCmd
->
pTableBlockHashList
,
removeMeta
);
pCmd
->
pDataBlocks
=
tscDestroyBlockArrayList
(
pCmd
->
pDataBlocks
);
pCmd
->
pDataBlocks
=
tscDestroyBlockArrayList
(
pCmd
->
pDataBlocks
);
...
@@ -548,6 +590,11 @@ void tscFreeSqlObj(SSqlObj* pSql) {
...
@@ -548,6 +590,11 @@ void tscFreeSqlObj(SSqlObj* pSql) {
free
(
pSql
);
free
(
pSql
);
}
}
void
tscDestroyBoundColumnInfo
(
SParsedDataColInfo
*
pColInfo
)
{
tfree
(
pColInfo
->
boundedColumns
);
tfree
(
pColInfo
->
cols
);
}
void
tscDestroyDataBlock
(
STableDataBlocks
*
pDataBlock
,
bool
removeMeta
)
{
void
tscDestroyDataBlock
(
STableDataBlocks
*
pDataBlock
,
bool
removeMeta
)
{
if
(
pDataBlock
==
NULL
)
{
if
(
pDataBlock
==
NULL
)
{
return
;
return
;
...
@@ -568,6 +615,7 @@ void tscDestroyDataBlock(STableDataBlocks* pDataBlock, bool removeMeta) {
...
@@ -568,6 +615,7 @@ void tscDestroyDataBlock(STableDataBlocks* pDataBlock, bool removeMeta) {
taosHashRemove
(
tscTableMetaInfo
,
name
,
strnlen
(
name
,
TSDB_TABLE_FNAME_LEN
));
taosHashRemove
(
tscTableMetaInfo
,
name
,
strnlen
(
name
,
TSDB_TABLE_FNAME_LEN
));
}
}
tscDestroyBoundColumnInfo
(
&
pDataBlock
->
boundColumnInfo
);
tfree
(
pDataBlock
);
tfree
(
pDataBlock
);
}
}
...
@@ -678,7 +726,7 @@ int32_t tscCopyDataBlockToPayload(SSqlObj* pSql, STableDataBlocks* pDataBlock) {
...
@@ -678,7 +726,7 @@ int32_t tscCopyDataBlockToPayload(SSqlObj* pSql, STableDataBlocks* pDataBlock) {
* @param dataBlocks
* @param dataBlocks
* @return
* @return
*/
*/
int32_t
tscCreateDataBlock
(
size_t
initial
Size
,
int32_t
rowSize
,
int32_t
startOffset
,
SName
*
name
,
int32_t
tscCreateDataBlock
(
size_t
default
Size
,
int32_t
rowSize
,
int32_t
startOffset
,
SName
*
name
,
STableMeta
*
pTableMeta
,
STableDataBlocks
**
dataBlocks
)
{
STableMeta
*
pTableMeta
,
STableDataBlocks
**
dataBlocks
)
{
STableDataBlocks
*
dataBuf
=
(
STableDataBlocks
*
)
calloc
(
1
,
sizeof
(
STableDataBlocks
));
STableDataBlocks
*
dataBuf
=
(
STableDataBlocks
*
)
calloc
(
1
,
sizeof
(
STableDataBlocks
));
if
(
dataBuf
==
NULL
)
{
if
(
dataBuf
==
NULL
)
{
...
@@ -686,10 +734,12 @@ int32_t tscCreateDataBlock(size_t initialSize, int32_t rowSize, int32_t startOff
...
@@ -686,10 +734,12 @@ int32_t tscCreateDataBlock(size_t initialSize, int32_t rowSize, int32_t startOff
return
TSDB_CODE_TSC_OUT_OF_MEMORY
;
return
TSDB_CODE_TSC_OUT_OF_MEMORY
;
}
}
dataBuf
->
nAllocSize
=
(
uint32_t
)
initialSize
;
dataBuf
->
nAllocSize
=
(
uint32_t
)
defaultSize
;
dataBuf
->
headerSize
=
startOffset
;
// the header size will always be the startOffset value, reserved for the subumit block header
dataBuf
->
headerSize
=
startOffset
;
// the header size will always be the startOffset value, reserved for the subumit block header
if
(
dataBuf
->
nAllocSize
<=
dataBuf
->
headerSize
)
{
if
(
dataBuf
->
nAllocSize
<=
dataBuf
->
headerSize
)
{
dataBuf
->
nAllocSize
=
dataBuf
->
headerSize
*
2
;
dataBuf
->
nAllocSize
=
dataBuf
->
headerSize
*
2
;
}
}
dataBuf
->
pData
=
calloc
(
1
,
dataBuf
->
nAllocSize
);
dataBuf
->
pData
=
calloc
(
1
,
dataBuf
->
nAllocSize
);
...
@@ -699,25 +749,31 @@ int32_t tscCreateDataBlock(size_t initialSize, int32_t rowSize, int32_t startOff
...
@@ -699,25 +749,31 @@ int32_t tscCreateDataBlock(size_t initialSize, int32_t rowSize, int32_t startOff
return
TSDB_CODE_TSC_OUT_OF_MEMORY
;
return
TSDB_CODE_TSC_OUT_OF_MEMORY
;
}
}
//Here we keep the tableMeta to avoid it to be remove by other threads.
dataBuf
->
pTableMeta
=
tscTableMetaDup
(
pTableMeta
);
SParsedDataColInfo
*
pColInfo
=
&
dataBuf
->
boundColumnInfo
;
SSchema
*
pSchema
=
tscGetTableSchema
(
dataBuf
->
pTableMeta
);
tscSetBoundColumnInfo
(
pColInfo
,
pSchema
,
dataBuf
->
pTableMeta
->
tableInfo
.
numOfColumns
);
dataBuf
->
ordered
=
true
;
dataBuf
->
ordered
=
true
;
dataBuf
->
prevTS
=
INT64_MIN
;
dataBuf
->
prevTS
=
INT64_MIN
;
dataBuf
->
rowSize
=
rowSize
;
dataBuf
->
rowSize
=
rowSize
;
dataBuf
->
size
=
startOffset
;
dataBuf
->
size
=
startOffset
;
dataBuf
->
tsSource
=
-
1
;
dataBuf
->
tsSource
=
-
1
;
dataBuf
->
vgId
=
dataBuf
->
pTableMeta
->
vgId
;
tNameAssign
(
&
dataBuf
->
tableName
,
name
);
tNameAssign
(
&
dataBuf
->
tableName
,
name
);
//Here we keep the tableMeta to avoid it to be remove by other threads.
assert
(
defaultSize
>
0
&&
pTableMeta
!=
NULL
&&
dataBuf
->
pTableMeta
!=
NULL
);
dataBuf
->
pTableMeta
=
tscTableMetaDup
(
pTableMeta
);
assert
(
initialSize
>
0
&&
pTableMeta
!=
NULL
&&
dataBuf
->
pTableMeta
!=
NULL
);
*
dataBlocks
=
dataBuf
;
*
dataBlocks
=
dataBuf
;
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
int32_t
tscGetDataBlockFromList
(
SHashObj
*
pHashList
,
int64_t
id
,
int32_t
size
,
int32_t
startOffset
,
int32_t
rowSize
,
int32_t
tscGetDataBlockFromList
(
SHashObj
*
pHashList
,
int64_t
id
,
int32_t
size
,
int32_t
startOffset
,
int32_t
rowSize
,
SName
*
name
,
STableMeta
*
pTableMeta
,
STableDataBlocks
**
dataBlocks
,
SArray
*
pBlockList
)
{
SName
*
name
,
STableMeta
*
pTableMeta
,
STableDataBlocks
**
dataBlocks
,
SArray
*
pBlockList
)
{
*
dataBlocks
=
NULL
;
*
dataBlocks
=
NULL
;
STableDataBlocks
**
t1
=
(
STableDataBlocks
**
)
taosHashGet
(
pHashList
,
(
const
char
*
)
&
id
,
sizeof
(
id
));
STableDataBlocks
**
t1
=
(
STableDataBlocks
**
)
taosHashGet
(
pHashList
,
(
const
char
*
)
&
id
,
sizeof
(
id
));
if
(
t1
!=
NULL
)
{
if
(
t1
!=
NULL
)
{
...
@@ -826,6 +882,8 @@ static void extractTableNameList(SSqlCmd* pCmd, bool freeBlockMap) {
...
@@ -826,6 +882,8 @@ static void extractTableNameList(SSqlCmd* pCmd, bool freeBlockMap) {
int32_t
i
=
0
;
int32_t
i
=
0
;
while
(
p1
)
{
while
(
p1
)
{
STableDataBlocks
*
pBlocks
=
*
p1
;
STableDataBlocks
*
pBlocks
=
*
p1
;
tfree
(
pCmd
->
pTableNameList
[
i
]);
pCmd
->
pTableNameList
[
i
++
]
=
tNameDup
(
&
pBlocks
->
tableName
);
pCmd
->
pTableNameList
[
i
++
]
=
tNameDup
(
&
pBlocks
->
tableName
);
p1
=
taosHashIterate
(
pCmd
->
pTableBlockHashList
,
p1
);
p1
=
taosHashIterate
(
pCmd
->
pTableBlockHashList
,
p1
);
}
}
...
@@ -942,7 +1000,7 @@ bool tscIsInsertData(char* sqlstr) {
...
@@ -942,7 +1000,7 @@ bool tscIsInsertData(char* sqlstr) {
int32_t
index
=
0
;
int32_t
index
=
0
;
do
{
do
{
SStrToken
t0
=
tStrGetToken
(
sqlstr
,
&
index
,
false
,
0
,
NULL
);
SStrToken
t0
=
tStrGetToken
(
sqlstr
,
&
index
,
false
);
if
(
t0
.
type
!=
TK_LP
)
{
if
(
t0
.
type
!=
TK_LP
)
{
return
t0
.
type
==
TK_INSERT
||
t0
.
type
==
TK_IMPORT
;
return
t0
.
type
==
TK_INSERT
||
t0
.
type
==
TK_IMPORT
;
}
}
...
...
src/cq/src/cqMain.c
浏览文件 @
64c06c95
...
@@ -294,7 +294,7 @@ void cqStop(void *handle) {
...
@@ -294,7 +294,7 @@ void cqStop(void *handle) {
pthread_mutex_unlock
(
&
pContext
->
mutex
);
pthread_mutex_unlock
(
&
pContext
->
mutex
);
}
}
void
*
cqCreate
(
void
*
handle
,
uint64_t
uid
,
int32_t
sid
,
const
char
*
dstTable
,
char
*
sqlStr
,
STSchema
*
pSchema
)
{
void
*
cqCreate
(
void
*
handle
,
uint64_t
uid
,
int32_t
sid
,
const
char
*
dstTable
,
char
*
sqlStr
,
STSchema
*
pSchema
,
int
start
)
{
if
(
tsEnableStream
==
0
)
{
if
(
tsEnableStream
==
0
)
{
return
NULL
;
return
NULL
;
}
}
...
@@ -326,7 +326,11 @@ void *cqCreate(void *handle, uint64_t uid, int32_t sid, const char* dstTable, ch
...
@@ -326,7 +326,11 @@ void *cqCreate(void *handle, uint64_t uid, int32_t sid, const char* dstTable, ch
pObj
->
rid
=
taosAddRef
(
cqObjRef
,
pObj
);
pObj
->
rid
=
taosAddRef
(
cqObjRef
,
pObj
);
if
(
start
&&
pContext
->
master
)
{
cqCreateStream
(
pContext
,
pObj
);
cqCreateStream
(
pContext
,
pObj
);
}
else
{
pObj
->
pContext
=
pContext
;
}
rid
=
pObj
->
rid
;
rid
=
pObj
->
rid
;
...
...
src/cq/test/cqtest.c
浏览文件 @
64c06c95
...
@@ -70,7 +70,7 @@ int main(int argc, char *argv[]) {
...
@@ -70,7 +70,7 @@ int main(int argc, char *argv[]) {
tdDestroyTSchemaBuilder
(
&
schemaBuilder
);
tdDestroyTSchemaBuilder
(
&
schemaBuilder
);
for
(
int
sid
=
1
;
sid
<
10
;
++
sid
)
{
for
(
int
sid
=
1
;
sid
<
10
;
++
sid
)
{
cqCreate
(
pCq
,
sid
,
sid
,
NULL
,
"select avg(speed) from demo.t1 sliding(1s) interval(5s)"
,
pSchema
);
cqCreate
(
pCq
,
sid
,
sid
,
NULL
,
"select avg(speed) from demo.t1 sliding(1s) interval(5s)"
,
pSchema
,
1
);
}
}
tdFreeSchema
(
pSchema
);
tdFreeSchema
(
pSchema
);
...
...
src/dnode/src/dnodeVWrite.c
浏览文件 @
64c06c95
...
@@ -222,7 +222,7 @@ static void *dnodeProcessVWriteQueue(void *wparam) {
...
@@ -222,7 +222,7 @@ static void *dnodeProcessVWriteQueue(void *wparam) {
dnodeSendRpcVWriteRsp
(
pVnode
,
pWrite
,
pWrite
->
code
);
dnodeSendRpcVWriteRsp
(
pVnode
,
pWrite
,
pWrite
->
code
);
}
else
{
}
else
{
if
(
qtype
==
TAOS_QTYPE_FWD
)
{
if
(
qtype
==
TAOS_QTYPE_FWD
)
{
vnodeConfirmForward
(
pVnode
,
pWrite
->
pHead
.
version
,
0
,
pWrite
->
pHead
.
msgType
!=
TSDB_MSG_TYPE_SUBMIT
);
vnodeConfirmForward
(
pVnode
,
pWrite
->
pHead
.
version
,
pWrite
->
code
,
pWrite
->
pHead
.
msgType
!=
TSDB_MSG_TYPE_SUBMIT
);
}
}
if
(
pWrite
->
rspRet
.
rsp
)
{
if
(
pWrite
->
rspRet
.
rsp
)
{
rpcFreeCont
(
pWrite
->
rspRet
.
rsp
);
rpcFreeCont
(
pWrite
->
rspRet
.
rsp
);
...
...
src/inc/tcq.h
浏览文件 @
64c06c95
...
@@ -42,7 +42,7 @@ void cqStart(void *handle);
...
@@ -42,7 +42,7 @@ void cqStart(void *handle);
void
cqStop
(
void
*
handle
);
void
cqStop
(
void
*
handle
);
// cqCreate is called by TSDB to start an instance of CQ
// cqCreate is called by TSDB to start an instance of CQ
void
*
cqCreate
(
void
*
handle
,
uint64_t
uid
,
int32_t
sid
,
const
char
*
dstTable
,
char
*
sqlStr
,
STSchema
*
pSchema
);
void
*
cqCreate
(
void
*
handle
,
uint64_t
uid
,
int32_t
sid
,
const
char
*
dstTable
,
char
*
sqlStr
,
STSchema
*
pSchema
,
int
start
);
// cqDrop is called by TSDB to stop an instance of CQ, handle is the return value of cqCreate
// cqDrop is called by TSDB to stop an instance of CQ, handle is the return value of cqCreate
void
cqDrop
(
void
*
handle
);
void
cqDrop
(
void
*
handle
);
...
...
src/inc/tsdb.h
浏览文件 @
64c06c95
...
@@ -51,7 +51,7 @@ typedef struct {
...
@@ -51,7 +51,7 @@ typedef struct {
void
*
cqH
;
void
*
cqH
;
int
(
*
notifyStatus
)(
void
*
,
int
status
,
int
eno
);
int
(
*
notifyStatus
)(
void
*
,
int
status
,
int
eno
);
int
(
*
eventCallBack
)(
void
*
);
int
(
*
eventCallBack
)(
void
*
);
void
*
(
*
cqCreateFunc
)(
void
*
handle
,
uint64_t
uid
,
int32_t
sid
,
const
char
*
dstTable
,
char
*
sqlStr
,
STSchema
*
pSchema
);
void
*
(
*
cqCreateFunc
)(
void
*
handle
,
uint64_t
uid
,
int32_t
sid
,
const
char
*
dstTable
,
char
*
sqlStr
,
STSchema
*
pSchema
,
int
start
);
void
(
*
cqDropFunc
)(
void
*
handle
);
void
(
*
cqDropFunc
)(
void
*
handle
);
}
STsdbAppH
;
}
STsdbAppH
;
...
...
src/kit/taosdemo/taosdemo.c
浏览文件 @
64c06c95
此差异已折叠。
点击以展开。
src/kit/taosdump/taosdump.c
浏览文件 @
64c06c95
...
@@ -39,6 +39,22 @@ typedef struct {
...
@@ -39,6 +39,22 @@ typedef struct {
int8_t
type
;
int8_t
type
;
}
SOColInfo
;
}
SOColInfo
;
#define debugPrint(fmt, ...) \
do { if (g_args.debug_print || g_args.verbose_print) \
fprintf(stderr, "DEBG: "fmt, __VA_ARGS__); } while(0)
#define verbosePrint(fmt, ...) \
do { if (g_args.verbose_print) \
fprintf(stderr, "VERB: "fmt, __VA_ARGS__); } while(0)
#define performancePrint(fmt, ...) \
do { if (g_args.performance_print) \
fprintf(stderr, "VERB: "fmt, __VA_ARGS__); } while(0)
#define errorPrint(fmt, ...) \
do { fprintf(stderr, "ERROR: "fmt, __VA_ARGS__); } while(0)
// -------------------------- SHOW DATABASE INTERFACE-----------------------
// -------------------------- SHOW DATABASE INTERFACE-----------------------
enum
_show_db_index
{
enum
_show_db_index
{
TSDB_SHOW_DB_NAME_INDEX
,
TSDB_SHOW_DB_NAME_INDEX
,
...
@@ -199,16 +215,18 @@ static struct argp_option options[] = {
...
@@ -199,16 +215,18 @@ static struct argp_option options[] = {
{
"schemaonly"
,
's'
,
0
,
0
,
"Only dump schema."
,
3
},
{
"schemaonly"
,
's'
,
0
,
0
,
"Only dump schema."
,
3
},
{
"with-property"
,
'M'
,
0
,
0
,
"Dump schema with properties."
,
3
},
{
"with-property"
,
'M'
,
0
,
0
,
"Dump schema with properties."
,
3
},
{
"start-time"
,
'S'
,
"START_TIME"
,
0
,
"Start time to dump."
,
3
},
{
"start-time"
,
'S'
,
"START_TIME"
,
0
,
"Start time to dump."
,
3
},
{
"end-time"
,
'E'
,
"END_TIME"
,
0
,
"End time to dump.
"
,
3
},
{
"end-time"
,
'E'
,
"END_TIME"
,
0
,
"End time to dump.
Epoch or ISO8601/RFC3339 format is acceptable. For example: 2017-10-01T18:00:00+0800"
,
3
},
{
"data-batch"
,
'N'
,
"DATA_BATCH"
,
0
,
"Number of data point per insert statement. Default is 1."
,
3
},
{
"data-batch"
,
'N'
,
"DATA_BATCH"
,
0
,
"Number of data point per insert statement. Default is 1."
,
3
},
{
"max-sql-len"
,
'L'
,
"SQL_LEN"
,
0
,
"Max length of one sql. Default is 65480."
,
3
},
{
"max-sql-len"
,
'L'
,
"SQL_LEN"
,
0
,
"Max length of one sql. Default is 65480."
,
3
},
{
"table-batch"
,
't'
,
"TABLE_BATCH"
,
0
,
"Number of table dumpout into one output file. Default is 1."
,
3
},
{
"table-batch"
,
't'
,
"TABLE_BATCH"
,
0
,
"Number of table dumpout into one output file. Default is 1."
,
3
},
{
"thread_num"
,
'T'
,
"THREAD_NUM"
,
0
,
"Number of thread for dump in file. Default is 5."
,
3
},
{
"thread_num"
,
'T'
,
"THREAD_NUM"
,
0
,
"Number of thread for dump in file. Default is 5."
,
3
},
{
"allow-sys"
,
'a'
,
0
,
0
,
"Allow to dump sys database"
,
3
},
{
"allow-sys"
,
'a'
,
0
,
0
,
"Allow to dump sys database"
,
3
},
{
"debug"
,
'g'
,
0
,
0
,
"Print debug info."
,
1
},
{
"verbose"
,
'v'
,
0
,
0
,
"Print verbose debug info."
,
1
},
{
0
}};
{
0
}};
/* Used by main to communicate with parse_opt. */
/* Used by main to communicate with parse_opt. */
struct
arguments
{
typedef
struct
arguments
{
// connection option
// connection option
char
*
host
;
char
*
host
;
char
*
user
;
char
*
user
;
...
@@ -240,7 +258,10 @@ struct arguments {
...
@@ -240,7 +258,10 @@ struct arguments {
char
**
arg_list
;
char
**
arg_list
;
int
arg_list_len
;
int
arg_list_len
;
bool
isDumpIn
;
bool
isDumpIn
;
};
bool
debug_print
;
bool
verbose_print
;
bool
performance_print
;
}
SArguments
;
/* Parse a single option. */
/* Parse a single option. */
static
error_t
parse_opt
(
int
key
,
char
*
arg
,
struct
argp_state
*
state
)
{
static
error_t
parse_opt
(
int
key
,
char
*
arg
,
struct
argp_state
*
state
)
{
...
@@ -286,6 +307,9 @@ static error_t parse_opt(int key, char *arg, struct argp_state *state) {
...
@@ -286,6 +307,9 @@ static error_t parse_opt(int key, char *arg, struct argp_state *state) {
tstrncpy
(
arguments
->
outpath
,
full_path
.
we_wordv
[
0
],
TSDB_FILENAME_LEN
);
tstrncpy
(
arguments
->
outpath
,
full_path
.
we_wordv
[
0
],
TSDB_FILENAME_LEN
);
wordfree
(
&
full_path
);
wordfree
(
&
full_path
);
break
;
break
;
case
'g'
:
arguments
->
debug_print
=
true
;
break
;
case
'i'
:
case
'i'
:
arguments
->
isDumpIn
=
true
;
arguments
->
isDumpIn
=
true
;
if
(
wordexp
(
arg
,
&
full_path
,
0
)
!=
0
)
{
if
(
wordexp
(
arg
,
&
full_path
,
0
)
!=
0
)
{
...
@@ -387,7 +411,7 @@ int taosCheckParam(struct arguments *arguments);
...
@@ -387,7 +411,7 @@ int taosCheckParam(struct arguments *arguments);
void
taosFreeDbInfos
();
void
taosFreeDbInfos
();
static
void
taosStartDumpOutWorkThreads
(
void
*
taosCon
,
struct
arguments
*
args
,
int32_t
numOfThread
,
char
*
dbName
);
static
void
taosStartDumpOutWorkThreads
(
void
*
taosCon
,
struct
arguments
*
args
,
int32_t
numOfThread
,
char
*
dbName
);
struct
arguments
tsArgument
s
=
{
struct
arguments
g_arg
s
=
{
// connection option
// connection option
NULL
,
NULL
,
"root"
,
"root"
,
...
@@ -421,7 +445,10 @@ struct arguments tsArguments = {
...
@@ -421,7 +445,10 @@ struct arguments tsArguments = {
0
,
0
,
NULL
,
NULL
,
0
,
0
,
false
false
,
false
,
// debug_print
false
,
// verbose_print
false
// performance_print
};
};
static
int
queryDbImpl
(
TAOS
*
taos
,
char
*
command
)
{
static
int
queryDbImpl
(
TAOS
*
taos
,
char
*
command
)
{
...
@@ -453,13 +480,44 @@ static int queryDbImpl(TAOS *taos, char *command) {
...
@@ -453,13 +480,44 @@ static int queryDbImpl(TAOS *taos, char *command) {
return
0
;
return
0
;
}
}
static
void
parse_args
(
int
argc
,
char
*
argv
[],
SArguments
*
arguments
)
{
for
(
int
i
=
1
;
i
<
argc
;
i
++
)
{
if
(
strcmp
(
argv
[
i
],
"-E"
)
==
0
)
{
if
(
argv
[
i
+
1
])
{
char
*
tmp
=
argv
[
++
i
];
int64_t
tmpEpoch
;
if
(
strchr
(
tmp
,
':'
)
&&
strchr
(
tmp
,
'-'
))
{
if
(
TSDB_CODE_SUCCESS
!=
taosParseTime
(
tmp
,
&
tmpEpoch
,
strlen
(
tmp
),
TSDB_TIME_PRECISION_MILLI
,
0
))
{
fprintf
(
stderr
,
"Input end time error!
\n
"
);
return
;
}
}
else
{
tmpEpoch
=
atoll
(
tmp
);
}
sprintf
(
argv
[
i
],
"%"
PRId64
""
,
tmpEpoch
);
debugPrint
(
"%s() LN%d, tmp is: %s, argv[%d]: %s
\n
"
,
__func__
,
__LINE__
,
tmp
,
i
,
argv
[
i
]);
}
else
{
fprintf
(
stderr
,
"Input end time error!
\n
"
);
return
;
}
}
else
if
(
strcmp
(
argv
[
i
],
"-g"
)
==
0
)
{
arguments
->
debug_print
=
true
;
}
}
}
int
main
(
int
argc
,
char
*
argv
[])
{
int
main
(
int
argc
,
char
*
argv
[])
{
/* Parse our arguments; every option seen by parse_opt will be
/* Parse our arguments; every option seen by parse_opt will be
reflected in arguments. */
reflected in arguments. */
argp_parse
(
&
argp
,
argc
,
argv
,
0
,
0
,
&
tsArguments
);
parse_args
(
argc
,
argv
,
&
g_args
);
argp_parse
(
&
argp
,
argc
,
argv
,
0
,
0
,
&
g_args
);
if
(
tsArgument
s
.
abort
)
{
if
(
g_arg
s
.
abort
)
{
#ifndef _ALPINE
#ifndef _ALPINE
error
(
10
,
0
,
"ABORTED"
);
error
(
10
,
0
,
"ABORTED"
);
#else
#else
...
@@ -469,81 +527,82 @@ int main(int argc, char *argv[]) {
...
@@ -469,81 +527,82 @@ int main(int argc, char *argv[]) {
printf
(
"====== arguments config ======
\n
"
);
printf
(
"====== arguments config ======
\n
"
);
{
{
printf
(
"host: %s
\n
"
,
tsArguments
.
host
);
printf
(
"host: %s
\n
"
,
g_args
.
host
);
printf
(
"user: %s
\n
"
,
tsArguments
.
user
);
printf
(
"user: %s
\n
"
,
g_args
.
user
);
printf
(
"password: %s
\n
"
,
tsArguments
.
password
);
printf
(
"password: %s
\n
"
,
g_args
.
password
);
printf
(
"port: %u
\n
"
,
tsArguments
.
port
);
printf
(
"port: %u
\n
"
,
g_args
.
port
);
printf
(
"cversion: %s
\n
"
,
tsArguments
.
cversion
);
printf
(
"cversion: %s
\n
"
,
g_args
.
cversion
);
printf
(
"mysqlFlag: %d
\n
"
,
tsArguments
.
mysqlFlag
);
printf
(
"mysqlFlag: %d
\n
"
,
g_args
.
mysqlFlag
);
printf
(
"outpath: %s
\n
"
,
tsArguments
.
outpath
);
printf
(
"outpath: %s
\n
"
,
g_args
.
outpath
);
printf
(
"inpath: %s
\n
"
,
tsArguments
.
inpath
);
printf
(
"inpath: %s
\n
"
,
g_args
.
inpath
);
printf
(
"resultFile: %s
\n
"
,
tsArguments
.
resultFile
);
printf
(
"resultFile: %s
\n
"
,
g_args
.
resultFile
);
printf
(
"encode: %s
\n
"
,
tsArguments
.
encode
);
printf
(
"encode: %s
\n
"
,
g_args
.
encode
);
printf
(
"all_databases: %d
\n
"
,
tsArguments
.
all_databases
);
printf
(
"all_databases: %d
\n
"
,
g_args
.
all_databases
);
printf
(
"databases: %d
\n
"
,
tsArguments
.
databases
);
printf
(
"databases: %d
\n
"
,
g_args
.
databases
);
printf
(
"schemaonly: %d
\n
"
,
tsArguments
.
schemaonly
);
printf
(
"schemaonly: %d
\n
"
,
g_args
.
schemaonly
);
printf
(
"with_property: %d
\n
"
,
tsArguments
.
with_property
);
printf
(
"with_property: %d
\n
"
,
g_args
.
with_property
);
printf
(
"start_time: %"
PRId64
"
\n
"
,
tsArguments
.
start_time
);
printf
(
"start_time: %"
PRId64
"
\n
"
,
g_args
.
start_time
);
printf
(
"end_time: %"
PRId64
"
\n
"
,
tsArguments
.
end_time
);
printf
(
"end_time: %"
PRId64
"
\n
"
,
g_args
.
end_time
);
printf
(
"data_batch: %d
\n
"
,
tsArguments
.
data_batch
);
printf
(
"data_batch: %d
\n
"
,
g_args
.
data_batch
);
printf
(
"max_sql_len: %d
\n
"
,
tsArguments
.
max_sql_len
);
printf
(
"max_sql_len: %d
\n
"
,
g_args
.
max_sql_len
);
printf
(
"table_batch: %d
\n
"
,
tsArguments
.
table_batch
);
printf
(
"table_batch: %d
\n
"
,
g_args
.
table_batch
);
printf
(
"thread_num: %d
\n
"
,
tsArguments
.
thread_num
);
printf
(
"thread_num: %d
\n
"
,
g_args
.
thread_num
);
printf
(
"allow_sys: %d
\n
"
,
tsArguments
.
allow_sys
);
printf
(
"allow_sys: %d
\n
"
,
g_args
.
allow_sys
);
printf
(
"abort: %d
\n
"
,
tsArguments
.
abort
);
printf
(
"abort: %d
\n
"
,
g_args
.
abort
);
printf
(
"isDumpIn: %d
\n
"
,
tsArguments
.
isDumpIn
);
printf
(
"isDumpIn: %d
\n
"
,
g_args
.
isDumpIn
);
printf
(
"arg_list_len: %d
\n
"
,
tsArguments
.
arg_list_len
);
printf
(
"arg_list_len: %d
\n
"
,
g_args
.
arg_list_len
);
printf
(
"debug_print: %d
\n
"
,
g_args
.
debug_print
);
for
(
int32_t
i
=
0
;
i
<
tsArguments
.
arg_list_len
;
i
++
)
{
printf
(
"arg_list[%d]: %s
\n
"
,
i
,
tsArguments
.
arg_list
[
i
]);
for
(
int32_t
i
=
0
;
i
<
g_args
.
arg_list_len
;
i
++
)
{
printf
(
"arg_list[%d]: %s
\n
"
,
i
,
g_args
.
arg_list
[
i
]);
}
}
}
}
printf
(
"==============================
\n
"
);
printf
(
"==============================
\n
"
);
if
(
tsArgument
s
.
cversion
[
0
]
!=
0
){
if
(
g_arg
s
.
cversion
[
0
]
!=
0
){
tstrncpy
(
version
,
tsArgument
s
.
cversion
,
11
);
tstrncpy
(
version
,
g_arg
s
.
cversion
,
11
);
}
}
if
(
taosCheckParam
(
&
tsArgument
s
)
<
0
)
{
if
(
taosCheckParam
(
&
g_arg
s
)
<
0
)
{
exit
(
EXIT_FAILURE
);
exit
(
EXIT_FAILURE
);
}
}
g_fpOfResult
=
fopen
(
tsArgument
s
.
resultFile
,
"a"
);
g_fpOfResult
=
fopen
(
g_arg
s
.
resultFile
,
"a"
);
if
(
NULL
==
g_fpOfResult
)
{
if
(
NULL
==
g_fpOfResult
)
{
fprintf
(
stderr
,
"Failed to open %s for save result
\n
"
,
tsArgument
s
.
resultFile
);
fprintf
(
stderr
,
"Failed to open %s for save result
\n
"
,
g_arg
s
.
resultFile
);
return
1
;
return
1
;
};
};
fprintf
(
g_fpOfResult
,
"#############################################################################
\n
"
);
fprintf
(
g_fpOfResult
,
"#############################################################################
\n
"
);
fprintf
(
g_fpOfResult
,
"============================== arguments config =============================
\n
"
);
fprintf
(
g_fpOfResult
,
"============================== arguments config =============================
\n
"
);
{
{
fprintf
(
g_fpOfResult
,
"host: %s
\n
"
,
tsArgument
s
.
host
);
fprintf
(
g_fpOfResult
,
"host: %s
\n
"
,
g_arg
s
.
host
);
fprintf
(
g_fpOfResult
,
"user: %s
\n
"
,
tsArgument
s
.
user
);
fprintf
(
g_fpOfResult
,
"user: %s
\n
"
,
g_arg
s
.
user
);
fprintf
(
g_fpOfResult
,
"password: %s
\n
"
,
tsArgument
s
.
password
);
fprintf
(
g_fpOfResult
,
"password: %s
\n
"
,
g_arg
s
.
password
);
fprintf
(
g_fpOfResult
,
"port: %u
\n
"
,
tsArgument
s
.
port
);
fprintf
(
g_fpOfResult
,
"port: %u
\n
"
,
g_arg
s
.
port
);
fprintf
(
g_fpOfResult
,
"cversion: %s
\n
"
,
tsArguments
.
cversion
);
fprintf
(
g_fpOfResult
,
"cversion: %s
\n
"
,
g_args
.
cversion
);
fprintf
(
g_fpOfResult
,
"mysqlFlag: %d
\n
"
,
tsArguments
.
mysqlFlag
);
fprintf
(
g_fpOfResult
,
"mysqlFlag: %d
\n
"
,
g_args
.
mysqlFlag
);
fprintf
(
g_fpOfResult
,
"outpath: %s
\n
"
,
tsArgument
s
.
outpath
);
fprintf
(
g_fpOfResult
,
"outpath: %s
\n
"
,
g_arg
s
.
outpath
);
fprintf
(
g_fpOfResult
,
"inpath: %s
\n
"
,
tsArgument
s
.
inpath
);
fprintf
(
g_fpOfResult
,
"inpath: %s
\n
"
,
g_arg
s
.
inpath
);
fprintf
(
g_fpOfResult
,
"resultFile: %s
\n
"
,
tsArgument
s
.
resultFile
);
fprintf
(
g_fpOfResult
,
"resultFile: %s
\n
"
,
g_arg
s
.
resultFile
);
fprintf
(
g_fpOfResult
,
"encode: %s
\n
"
,
tsArgument
s
.
encode
);
fprintf
(
g_fpOfResult
,
"encode: %s
\n
"
,
g_arg
s
.
encode
);
fprintf
(
g_fpOfResult
,
"all_databases: %d
\n
"
,
tsArgument
s
.
all_databases
);
fprintf
(
g_fpOfResult
,
"all_databases: %d
\n
"
,
g_arg
s
.
all_databases
);
fprintf
(
g_fpOfResult
,
"databases: %d
\n
"
,
tsArgument
s
.
databases
);
fprintf
(
g_fpOfResult
,
"databases: %d
\n
"
,
g_arg
s
.
databases
);
fprintf
(
g_fpOfResult
,
"schemaonly: %d
\n
"
,
tsArgument
s
.
schemaonly
);
fprintf
(
g_fpOfResult
,
"schemaonly: %d
\n
"
,
g_arg
s
.
schemaonly
);
fprintf
(
g_fpOfResult
,
"with_property: %d
\n
"
,
tsArgument
s
.
with_property
);
fprintf
(
g_fpOfResult
,
"with_property: %d
\n
"
,
g_arg
s
.
with_property
);
fprintf
(
g_fpOfResult
,
"start_time: %"
PRId64
"
\n
"
,
tsArgument
s
.
start_time
);
fprintf
(
g_fpOfResult
,
"start_time: %"
PRId64
"
\n
"
,
g_arg
s
.
start_time
);
fprintf
(
g_fpOfResult
,
"end_time: %"
PRId64
"
\n
"
,
tsArgument
s
.
end_time
);
fprintf
(
g_fpOfResult
,
"end_time: %"
PRId64
"
\n
"
,
g_arg
s
.
end_time
);
fprintf
(
g_fpOfResult
,
"data_batch: %d
\n
"
,
tsArgument
s
.
data_batch
);
fprintf
(
g_fpOfResult
,
"data_batch: %d
\n
"
,
g_arg
s
.
data_batch
);
fprintf
(
g_fpOfResult
,
"max_sql_len: %d
\n
"
,
tsArgument
s
.
max_sql_len
);
fprintf
(
g_fpOfResult
,
"max_sql_len: %d
\n
"
,
g_arg
s
.
max_sql_len
);
fprintf
(
g_fpOfResult
,
"table_batch: %d
\n
"
,
tsArgument
s
.
table_batch
);
fprintf
(
g_fpOfResult
,
"table_batch: %d
\n
"
,
g_arg
s
.
table_batch
);
fprintf
(
g_fpOfResult
,
"thread_num: %d
\n
"
,
tsArguments
.
thread_num
);
fprintf
(
g_fpOfResult
,
"thread_num: %d
\n
"
,
g_args
.
thread_num
);
fprintf
(
g_fpOfResult
,
"allow_sys: %d
\n
"
,
tsArgument
s
.
allow_sys
);
fprintf
(
g_fpOfResult
,
"allow_sys: %d
\n
"
,
g_arg
s
.
allow_sys
);
fprintf
(
g_fpOfResult
,
"abort: %d
\n
"
,
tsArgument
s
.
abort
);
fprintf
(
g_fpOfResult
,
"abort: %d
\n
"
,
g_arg
s
.
abort
);
fprintf
(
g_fpOfResult
,
"isDumpIn: %d
\n
"
,
tsArgument
s
.
isDumpIn
);
fprintf
(
g_fpOfResult
,
"isDumpIn: %d
\n
"
,
g_arg
s
.
isDumpIn
);
fprintf
(
g_fpOfResult
,
"arg_list_len: %d
\n
"
,
tsArgument
s
.
arg_list_len
);
fprintf
(
g_fpOfResult
,
"arg_list_len: %d
\n
"
,
g_arg
s
.
arg_list_len
);
for
(
int32_t
i
=
0
;
i
<
tsArgument
s
.
arg_list_len
;
i
++
)
{
for
(
int32_t
i
=
0
;
i
<
g_arg
s
.
arg_list_len
;
i
++
)
{
fprintf
(
g_fpOfResult
,
"arg_list[%d]: %s
\n
"
,
i
,
tsArgument
s
.
arg_list
[
i
]);
fprintf
(
g_fpOfResult
,
"arg_list[%d]: %s
\n
"
,
i
,
g_arg
s
.
arg_list
[
i
]);
}
}
}
}
...
@@ -552,11 +611,11 @@ int main(int argc, char *argv[]) {
...
@@ -552,11 +611,11 @@ int main(int argc, char *argv[]) {
time_t
tTime
=
time
(
NULL
);
time_t
tTime
=
time
(
NULL
);
struct
tm
tm
=
*
localtime
(
&
tTime
);
struct
tm
tm
=
*
localtime
(
&
tTime
);
if
(
tsArguments
.
isDumpIn
)
{
if
(
g_args
.
isDumpIn
)
{
fprintf
(
g_fpOfResult
,
"============================== DUMP IN ==============================
\n
"
);
fprintf
(
g_fpOfResult
,
"============================== DUMP IN ==============================
\n
"
);
fprintf
(
g_fpOfResult
,
"# DumpIn start time: %d-%02d-%02d %02d:%02d:%02d
\n
"
,
tm
.
tm_year
+
1900
,
tm
.
tm_mon
+
1
,
fprintf
(
g_fpOfResult
,
"# DumpIn start time: %d-%02d-%02d %02d:%02d:%02d
\n
"
,
tm
.
tm_year
+
1900
,
tm
.
tm_mon
+
1
,
tm
.
tm_mday
,
tm
.
tm_hour
,
tm
.
tm_min
,
tm
.
tm_sec
);
tm
.
tm_mday
,
tm
.
tm_hour
,
tm
.
tm_min
,
tm
.
tm_sec
);
if
(
taosDumpIn
(
&
tsArgument
s
)
<
0
)
{
if
(
taosDumpIn
(
&
g_arg
s
)
<
0
)
{
fprintf
(
g_fpOfResult
,
"
\n
"
);
fprintf
(
g_fpOfResult
,
"
\n
"
);
fclose
(
g_fpOfResult
);
fclose
(
g_fpOfResult
);
return
-
1
;
return
-
1
;
...
@@ -565,7 +624,7 @@ int main(int argc, char *argv[]) {
...
@@ -565,7 +624,7 @@ int main(int argc, char *argv[]) {
fprintf
(
g_fpOfResult
,
"============================== DUMP OUT ==============================
\n
"
);
fprintf
(
g_fpOfResult
,
"============================== DUMP OUT ==============================
\n
"
);
fprintf
(
g_fpOfResult
,
"# DumpOut start time: %d-%02d-%02d %02d:%02d:%02d
\n
"
,
tm
.
tm_year
+
1900
,
tm
.
tm_mon
+
1
,
fprintf
(
g_fpOfResult
,
"# DumpOut start time: %d-%02d-%02d %02d:%02d:%02d
\n
"
,
tm
.
tm_year
+
1900
,
tm
.
tm_mon
+
1
,
tm
.
tm_mday
,
tm
.
tm_hour
,
tm
.
tm_min
,
tm
.
tm_sec
);
tm
.
tm_mday
,
tm
.
tm_hour
,
tm
.
tm_min
,
tm
.
tm_sec
);
if
(
taosDumpOut
(
&
tsArgument
s
)
<
0
)
{
if
(
taosDumpOut
(
&
g_arg
s
)
<
0
)
{
fprintf
(
g_fpOfResult
,
"
\n
"
);
fprintf
(
g_fpOfResult
,
"
\n
"
);
fclose
(
g_fpOfResult
);
fclose
(
g_fpOfResult
);
return
-
1
;
return
-
1
;
...
@@ -1236,8 +1295,8 @@ void* taosDumpOutWorkThreadFp(void *arg)
...
@@ -1236,8 +1295,8 @@ void* taosDumpOutWorkThreadFp(void *arg)
FILE
*
fp
=
NULL
;
FILE
*
fp
=
NULL
;
memset
(
tmpBuf
,
0
,
TSDB_FILENAME_LEN
+
128
);
memset
(
tmpBuf
,
0
,
TSDB_FILENAME_LEN
+
128
);
if
(
tsArgument
s
.
outpath
[
0
]
!=
0
)
{
if
(
g_arg
s
.
outpath
[
0
]
!=
0
)
{
sprintf
(
tmpBuf
,
"%s/%s.tables.%d.sql"
,
tsArgument
s
.
outpath
,
pThread
->
dbName
,
pThread
->
threadIndex
);
sprintf
(
tmpBuf
,
"%s/%s.tables.%d.sql"
,
g_arg
s
.
outpath
,
pThread
->
dbName
,
pThread
->
threadIndex
);
}
else
{
}
else
{
sprintf
(
tmpBuf
,
"%s.tables.%d.sql"
,
pThread
->
dbName
,
pThread
->
threadIndex
);
sprintf
(
tmpBuf
,
"%s.tables.%d.sql"
,
pThread
->
dbName
,
pThread
->
threadIndex
);
}
}
...
@@ -1270,7 +1329,7 @@ void* taosDumpOutWorkThreadFp(void *arg)
...
@@ -1270,7 +1329,7 @@ void* taosDumpOutWorkThreadFp(void *arg)
ssize_t
readLen
=
read
(
fd
,
&
tableRecord
,
sizeof
(
STableRecord
));
ssize_t
readLen
=
read
(
fd
,
&
tableRecord
,
sizeof
(
STableRecord
));
if
(
readLen
<=
0
)
break
;
if
(
readLen
<=
0
)
break
;
int
ret
=
taosDumpTable
(
tableRecord
.
name
,
tableRecord
.
metric
,
&
tsArgument
s
,
fp
,
pThread
->
taosCon
,
pThread
->
dbName
);
int
ret
=
taosDumpTable
(
tableRecord
.
name
,
tableRecord
.
metric
,
&
g_arg
s
,
fp
,
pThread
->
taosCon
,
pThread
->
dbName
);
if
(
ret
>=
0
)
{
if
(
ret
>=
0
)
{
// TODO: sum table count and table rows by self
// TODO: sum table count and table rows by self
pThread
->
tablesOfDumpOut
++
;
pThread
->
tablesOfDumpOut
++
;
...
@@ -1282,13 +1341,13 @@ void* taosDumpOutWorkThreadFp(void *arg)
...
@@ -1282,13 +1341,13 @@ void* taosDumpOutWorkThreadFp(void *arg)
}
}
tablesInOneFile
++
;
tablesInOneFile
++
;
if
(
tablesInOneFile
>=
tsArgument
s
.
table_batch
)
{
if
(
tablesInOneFile
>=
g_arg
s
.
table_batch
)
{
fclose
(
fp
);
fclose
(
fp
);
tablesInOneFile
=
0
;
tablesInOneFile
=
0
;
memset
(
tmpBuf
,
0
,
TSDB_FILENAME_LEN
+
128
);
memset
(
tmpBuf
,
0
,
TSDB_FILENAME_LEN
+
128
);
if
(
tsArgument
s
.
outpath
[
0
]
!=
0
)
{
if
(
g_arg
s
.
outpath
[
0
]
!=
0
)
{
sprintf
(
tmpBuf
,
"%s/%s.tables.%d-%d.sql"
,
tsArgument
s
.
outpath
,
pThread
->
dbName
,
pThread
->
threadIndex
,
fileNameIndex
);
sprintf
(
tmpBuf
,
"%s/%s.tables.%d-%d.sql"
,
g_arg
s
.
outpath
,
pThread
->
dbName
,
pThread
->
threadIndex
,
fileNameIndex
);
}
else
{
}
else
{
sprintf
(
tmpBuf
,
"%s.tables.%d-%d.sql"
,
pThread
->
dbName
,
pThread
->
threadIndex
,
fileNameIndex
);
sprintf
(
tmpBuf
,
"%s.tables.%d-%d.sql"
,
pThread
->
dbName
,
pThread
->
threadIndex
,
fileNameIndex
);
}
}
...
@@ -1491,14 +1550,14 @@ int taosDumpDb(SDbInfo *dbInfo, struct arguments *arguments, FILE *fp, TAOS *tao
...
@@ -1491,14 +1550,14 @@ int taosDumpDb(SDbInfo *dbInfo, struct arguments *arguments, FILE *fp, TAOS *tao
taos_free_result
(
res
);
taos_free_result
(
res
);
lseek
(
fd
,
0
,
SEEK_SET
);
lseek
(
fd
,
0
,
SEEK_SET
);
int
maxThreads
=
tsArgument
s
.
thread_num
;
int
maxThreads
=
g_arg
s
.
thread_num
;
int
tableOfPerFile
;
int
tableOfPerFile
;
if
(
numOfTable
<=
tsArgument
s
.
thread_num
)
{
if
(
numOfTable
<=
g_arg
s
.
thread_num
)
{
tableOfPerFile
=
1
;
tableOfPerFile
=
1
;
maxThreads
=
numOfTable
;
maxThreads
=
numOfTable
;
}
else
{
}
else
{
tableOfPerFile
=
numOfTable
/
tsArgument
s
.
thread_num
;
tableOfPerFile
=
numOfTable
/
g_arg
s
.
thread_num
;
if
(
0
!=
numOfTable
%
tsArgument
s
.
thread_num
)
{
if
(
0
!=
numOfTable
%
g_arg
s
.
thread_num
)
{
tableOfPerFile
+=
1
;
tableOfPerFile
+=
1
;
}
}
}
}
...
@@ -2214,7 +2273,7 @@ void* taosDumpInWorkThreadFp(void *arg)
...
@@ -2214,7 +2273,7 @@ void* taosDumpInWorkThreadFp(void *arg)
continue
;
continue
;
}
}
fprintf
(
stderr
,
"Success Open input file: %s
\n
"
,
SQLFileName
);
fprintf
(
stderr
,
"Success Open input file: %s
\n
"
,
SQLFileName
);
taosDumpInOneFile
(
pThread
->
taosCon
,
fp
,
tsfCharset
,
tsArgument
s
.
encode
,
SQLFileName
);
taosDumpInOneFile
(
pThread
->
taosCon
,
fp
,
tsfCharset
,
g_arg
s
.
encode
,
SQLFileName
);
}
}
}
}
...
...
src/mnode/src/mnodeDnode.c
浏览文件 @
64c06c95
...
@@ -628,6 +628,11 @@ static int32_t mnodeProcessDnodeStatusMsg(SMnodeMsg *pMsg) {
...
@@ -628,6 +628,11 @@ static int32_t mnodeProcessDnodeStatusMsg(SMnodeMsg *pMsg) {
bnNotify
();
bnNotify
();
}
}
if
(
!
tsEnableBalance
)
{
int32_t
numOfMnodes
=
mnodeGetMnodesNum
();
if
(
numOfMnodes
<
tsNumOfMnodes
)
bnNotify
();
}
if
(
openVnodes
!=
pDnode
->
openVnodes
)
{
if
(
openVnodes
!=
pDnode
->
openVnodes
)
{
mnodeCheckUnCreatedVgroup
(
pDnode
,
pStatus
->
load
,
openVnodes
);
mnodeCheckUnCreatedVgroup
(
pDnode
,
pStatus
->
load
,
openVnodes
);
}
}
...
...
src/mnode/src/mnodeMnode.c
浏览文件 @
64c06c95
...
@@ -381,6 +381,8 @@ static bool mnodeAllOnline() {
...
@@ -381,6 +381,8 @@ static bool mnodeAllOnline() {
void
*
pIter
=
NULL
;
void
*
pIter
=
NULL
;
bool
allOnline
=
true
;
bool
allOnline
=
true
;
sdbUpdateMnodeRoles
();
while
(
1
)
{
while
(
1
)
{
SMnodeObj
*
pMnode
=
NULL
;
SMnodeObj
*
pMnode
=
NULL
;
pIter
=
mnodeGetNextMnode
(
pIter
,
&
pMnode
);
pIter
=
mnodeGetNextMnode
(
pIter
,
&
pMnode
);
...
...
src/query/inc/qExecutor.h
浏览文件 @
64c06c95
...
@@ -86,7 +86,8 @@ typedef struct SResultRow {
...
@@ -86,7 +86,8 @@ typedef struct SResultRow {
bool
closed
;
// this result status: closed or opened
bool
closed
;
// this result status: closed or opened
uint32_t
numOfRows
;
// number of rows of current time window
uint32_t
numOfRows
;
// number of rows of current time window
SResultRowCellInfo
*
pCellInfo
;
// For each result column, there is a resultInfo
SResultRowCellInfo
*
pCellInfo
;
// For each result column, there is a resultInfo
union
{
STimeWindow
win
;
char
*
key
;};
// start key of current result row
STimeWindow
win
;
char
*
key
;
// start key of current result row
}
SResultRow
;
}
SResultRow
;
typedef
struct
SGroupResInfo
{
typedef
struct
SGroupResInfo
{
...
...
src/query/src/qExecutor.c
浏览文件 @
64c06c95
...
@@ -1876,14 +1876,15 @@ static void teardownQueryRuntimeEnv(SQueryRuntimeEnv *pRuntimeEnv) {
...
@@ -1876,14 +1876,15 @@ static void teardownQueryRuntimeEnv(SQueryRuntimeEnv *pRuntimeEnv) {
taosHashCleanup
(
pRuntimeEnv
->
pResultRowHashTable
);
taosHashCleanup
(
pRuntimeEnv
->
pResultRowHashTable
);
pRuntimeEnv
->
pResultRowHashTable
=
NULL
;
pRuntimeEnv
->
pResultRowHashTable
=
NULL
;
pRuntimeEnv
->
pool
=
destroyResultRowPool
(
pRuntimeEnv
->
pool
);
taosArrayDestroyEx
(
pRuntimeEnv
->
prevResult
,
freeInterResult
);
pRuntimeEnv
->
prevResult
=
NULL
;
taosHashCleanup
(
pRuntimeEnv
->
pTableRetrieveTsMap
);
taosHashCleanup
(
pRuntimeEnv
->
pTableRetrieveTsMap
);
pRuntimeEnv
->
pTableRetrieveTsMap
=
NULL
;
pRuntimeEnv
->
pTableRetrieveTsMap
=
NULL
;
destroyOperatorInfo
(
pRuntimeEnv
->
proot
);
destroyOperatorInfo
(
pRuntimeEnv
->
proot
);
pRuntimeEnv
->
pool
=
destroyResultRowPool
(
pRuntimeEnv
->
pool
);
taosArrayDestroyEx
(
pRuntimeEnv
->
prevResult
,
freeInterResult
);
pRuntimeEnv
->
prevResult
=
NULL
;
}
}
static
bool
needBuildResAfterQueryComplete
(
SQInfo
*
pQInfo
)
{
static
bool
needBuildResAfterQueryComplete
(
SQInfo
*
pQInfo
)
{
...
@@ -2630,6 +2631,21 @@ int32_t loadDataBlockOnDemand(SQueryRuntimeEnv* pRuntimeEnv, STableScanInfo* pTa
...
@@ -2630,6 +2631,21 @@ int32_t loadDataBlockOnDemand(SQueryRuntimeEnv* pRuntimeEnv, STableScanInfo* pTa
tsdbRetrieveDataBlockStatisInfo
(
pTableScanInfo
->
pQueryHandle
,
&
pBlock
->
pBlockStatis
);
tsdbRetrieveDataBlockStatisInfo
(
pTableScanInfo
->
pQueryHandle
,
&
pBlock
->
pBlockStatis
);
if
(
pQuery
->
topBotQuery
&&
pBlock
->
pBlockStatis
!=
NULL
)
{
if
(
pQuery
->
topBotQuery
&&
pBlock
->
pBlockStatis
!=
NULL
)
{
{
// set previous window
if
(
QUERY_IS_INTERVAL_QUERY
(
pQuery
))
{
SResultRow
*
pResult
=
NULL
;
bool
masterScan
=
IS_MASTER_SCAN
(
pRuntimeEnv
);
TSKEY
k
=
ascQuery
?
pBlock
->
info
.
window
.
skey
:
pBlock
->
info
.
window
.
ekey
;
STimeWindow
win
=
getActiveTimeWindow
(
pTableScanInfo
->
pResultRowInfo
,
k
,
pQuery
);
if
(
setWindowOutputBufByKey
(
pRuntimeEnv
,
pTableScanInfo
->
pResultRowInfo
,
&
win
,
masterScan
,
&
pResult
,
groupId
,
pTableScanInfo
->
pCtx
,
pTableScanInfo
->
numOfOutput
,
pTableScanInfo
->
rowCellInfoOffset
)
!=
TSDB_CODE_SUCCESS
)
{
longjmp
(
pRuntimeEnv
->
env
,
TSDB_CODE_QRY_OUT_OF_MEMORY
);
}
}
}
bool
load
=
false
;
bool
load
=
false
;
for
(
int32_t
i
=
0
;
i
<
pQuery
->
numOfOutput
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
pQuery
->
numOfOutput
;
++
i
)
{
int32_t
functionId
=
pTableScanInfo
->
pCtx
[
i
].
functionId
;
int32_t
functionId
=
pTableScanInfo
->
pCtx
[
i
].
functionId
;
...
@@ -6463,6 +6479,9 @@ void freeQInfo(SQInfo *pQInfo) {
...
@@ -6463,6 +6479,9 @@ void freeQInfo(SQInfo *pQInfo) {
SQueryRuntimeEnv
*
pRuntimeEnv
=
&
pQInfo
->
runtimeEnv
;
SQueryRuntimeEnv
*
pRuntimeEnv
=
&
pQInfo
->
runtimeEnv
;
releaseQueryBuf
(
pRuntimeEnv
->
tableqinfoGroupInfo
.
numOfTables
);
releaseQueryBuf
(
pRuntimeEnv
->
tableqinfoGroupInfo
.
numOfTables
);
doDestroyTableQueryInfo
(
&
pRuntimeEnv
->
tableqinfoGroupInfo
);
teardownQueryRuntimeEnv
(
&
pQInfo
->
runtimeEnv
);
teardownQueryRuntimeEnv
(
&
pQInfo
->
runtimeEnv
);
SQuery
*
pQuery
=
pQInfo
->
runtimeEnv
.
pQuery
;
SQuery
*
pQuery
=
pQInfo
->
runtimeEnv
.
pQuery
;
...
@@ -6498,7 +6517,6 @@ void freeQInfo(SQInfo *pQInfo) {
...
@@ -6498,7 +6517,6 @@ void freeQInfo(SQInfo *pQInfo) {
}
}
}
}
doDestroyTableQueryInfo
(
&
pRuntimeEnv
->
tableqinfoGroupInfo
);
tfree
(
pQInfo
->
pBuf
);
tfree
(
pQInfo
->
pBuf
);
tfree
(
pQInfo
->
sql
);
tfree
(
pQInfo
->
sql
);
...
...
src/query/src/qTokenizer.c
浏览文件 @
64c06c95
...
@@ -560,7 +560,7 @@ uint32_t tSQLGetToken(char* z, uint32_t* tokenId) {
...
@@ -560,7 +560,7 @@ uint32_t tSQLGetToken(char* z, uint32_t* tokenId) {
return
0
;
return
0
;
}
}
SStrToken
tStrGetToken
(
char
*
str
,
int32_t
*
i
,
bool
isPrevOptr
,
uint32_t
numOfIgnoreToken
,
uint32_t
*
ignoreTokenTypes
)
{
SStrToken
tStrGetToken
(
char
*
str
,
int32_t
*
i
,
bool
isPrevOptr
)
{
SStrToken
t0
=
{
0
};
SStrToken
t0
=
{
0
};
// here we reach the end of sql string, null-terminated string
// here we reach the end of sql string, null-terminated string
...
@@ -585,7 +585,10 @@ SStrToken tStrGetToken(char* str, int32_t* i, bool isPrevOptr, uint32_t numOfIgn
...
@@ -585,7 +585,10 @@ SStrToken tStrGetToken(char* str, int32_t* i, bool isPrevOptr, uint32_t numOfIgn
}
}
t0
.
n
=
tSQLGetToken
(
&
str
[
*
i
],
&
t0
.
type
);
t0
.
n
=
tSQLGetToken
(
&
str
[
*
i
],
&
t0
.
type
);
break
;
// not support user specfied ignored symbol list
#if 0
bool ignore = false;
bool ignore = false;
for (uint32_t k = 0; k < numOfIgnoreToken; k++) {
for (uint32_t k = 0; k < numOfIgnoreToken; k++) {
if (t0.type == ignoreTokenTypes[k]) {
if (t0.type == ignoreTokenTypes[k]) {
...
@@ -597,6 +600,7 @@ SStrToken tStrGetToken(char* str, int32_t* i, bool isPrevOptr, uint32_t numOfIgn
...
@@ -597,6 +600,7 @@ SStrToken tStrGetToken(char* str, int32_t* i, bool isPrevOptr, uint32_t numOfIgn
if (!ignore) {
if (!ignore) {
break;
break;
}
}
#endif
}
}
if
(
t0
.
type
==
TK_SEMI
)
{
if
(
t0
.
type
==
TK_SEMI
)
{
...
...
src/query/src/qUtil.c
浏览文件 @
64c06c95
...
@@ -66,8 +66,8 @@ void cleanupResultRowInfo(SResultRowInfo *pResultRowInfo) {
...
@@ -66,8 +66,8 @@ void cleanupResultRowInfo(SResultRowInfo *pResultRowInfo) {
return
;
return
;
}
}
if
(
pResultRowInfo
->
type
==
TSDB_DATA_TYPE_BINARY
||
pResultRowInfo
->
type
==
TSDB_DATA_TYPE_NCHAR
)
{
for
(
int32_t
i
=
0
;
i
<
pResultRowInfo
->
size
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
pResultRowInfo
->
size
;
++
i
)
{
if
(
pResultRowInfo
->
pResult
[
i
])
{
tfree
(
pResultRowInfo
->
pResult
[
i
]
->
key
);
tfree
(
pResultRowInfo
->
pResult
[
i
]
->
key
);
}
}
}
}
...
@@ -153,11 +153,8 @@ void clearResultRow(SQueryRuntimeEnv *pRuntimeEnv, SResultRow *pResultRow, int16
...
@@ -153,11 +153,8 @@ void clearResultRow(SQueryRuntimeEnv *pRuntimeEnv, SResultRow *pResultRow, int16
pResultRow
->
offset
=
-
1
;
pResultRow
->
offset
=
-
1
;
pResultRow
->
closed
=
false
;
pResultRow
->
closed
=
false
;
if
(
type
==
TSDB_DATA_TYPE_BINARY
||
type
==
TSDB_DATA_TYPE_NCHAR
)
{
tfree
(
pResultRow
->
key
);
tfree
(
pResultRow
->
key
);
}
else
{
pResultRow
->
win
=
TSWINDOW_INITIALIZER
;
pResultRow
->
win
=
TSWINDOW_INITIALIZER
;
}
}
}
// TODO refactor: use macro
// TODO refactor: use macro
...
...
src/query/tests/resultBufferTest.cpp
浏览文件 @
64c06c95
...
@@ -10,7 +10,7 @@ namespace {
...
@@ -10,7 +10,7 @@ namespace {
// simple test
// simple test
void
simpleTest
()
{
void
simpleTest
()
{
SDiskbasedResultBuf
*
pResultBuf
=
NULL
;
SDiskbasedResultBuf
*
pResultBuf
=
NULL
;
int32_t
ret
=
createDiskbasedResultBuffer
(
&
pResultBuf
,
1024
,
4096
,
NULL
);
int32_t
ret
=
createDiskbasedResultBuffer
(
&
pResultBuf
,
1024
,
4096
,
1
);
int32_t
pageId
=
0
;
int32_t
pageId
=
0
;
int32_t
groupId
=
0
;
int32_t
groupId
=
0
;
...
@@ -52,7 +52,7 @@ void simpleTest() {
...
@@ -52,7 +52,7 @@ void simpleTest() {
void
writeDownTest
()
{
void
writeDownTest
()
{
SDiskbasedResultBuf
*
pResultBuf
=
NULL
;
SDiskbasedResultBuf
*
pResultBuf
=
NULL
;
int32_t
ret
=
createDiskbasedResultBuffer
(
&
pResultBuf
,
1024
,
4
*
1024
,
NULL
);
int32_t
ret
=
createDiskbasedResultBuffer
(
&
pResultBuf
,
1024
,
4
*
1024
,
1
);
int32_t
pageId
=
0
;
int32_t
pageId
=
0
;
int32_t
writePageId
=
0
;
int32_t
writePageId
=
0
;
...
@@ -99,7 +99,7 @@ void writeDownTest() {
...
@@ -99,7 +99,7 @@ void writeDownTest() {
void
recyclePageTest
()
{
void
recyclePageTest
()
{
SDiskbasedResultBuf
*
pResultBuf
=
NULL
;
SDiskbasedResultBuf
*
pResultBuf
=
NULL
;
int32_t
ret
=
createDiskbasedResultBuffer
(
&
pResultBuf
,
1024
,
4
*
1024
,
NULL
);
int32_t
ret
=
createDiskbasedResultBuffer
(
&
pResultBuf
,
1024
,
4
*
1024
,
1
);
int32_t
pageId
=
0
;
int32_t
pageId
=
0
;
int32_t
writePageId
=
0
;
int32_t
writePageId
=
0
;
...
...
src/sync/inc/syncInt.h
浏览文件 @
64c06c95
...
@@ -35,7 +35,7 @@ extern "C" {
...
@@ -35,7 +35,7 @@ extern "C" {
#define SYNC_MAX_SIZE (TSDB_MAX_WAL_SIZE + sizeof(SWalHead) + sizeof(SSyncHead) + 16)
#define SYNC_MAX_SIZE (TSDB_MAX_WAL_SIZE + sizeof(SWalHead) + sizeof(SSyncHead) + 16)
#define SYNC_RECV_BUFFER_SIZE (5*1024*1024)
#define SYNC_RECV_BUFFER_SIZE (5*1024*1024)
#define SYNC_MAX_FWDS
512
#define SYNC_MAX_FWDS
1024
#define SYNC_FWD_TIMER 300
#define SYNC_FWD_TIMER 300
#define SYNC_ROLE_TIMER 15000 // ms
#define SYNC_ROLE_TIMER 15000 // ms
#define SYNC_CHECK_INTERVAL 1000 // ms
#define SYNC_CHECK_INTERVAL 1000 // ms
...
...
src/sync/src/syncMain.c
浏览文件 @
64c06c95
...
@@ -1372,7 +1372,7 @@ static void syncMonitorNodeRole(void *param, void *tmrId) {
...
@@ -1372,7 +1372,7 @@ static void syncMonitorNodeRole(void *param, void *tmrId) {
if
(
/*pPeer->role > TAOS_SYNC_ROLE_UNSYNCED && */
nodeRole
>
TAOS_SYNC_ROLE_UNSYNCED
)
continue
;
if
(
/*pPeer->role > TAOS_SYNC_ROLE_UNSYNCED && */
nodeRole
>
TAOS_SYNC_ROLE_UNSYNCED
)
continue
;
if
(
/*pPeer->sstatus > TAOS_SYNC_STATUS_INIT || */
nodeSStatus
>
TAOS_SYNC_STATUS_INIT
)
continue
;
if
(
/*pPeer->sstatus > TAOS_SYNC_STATUS_INIT || */
nodeSStatus
>
TAOS_SYNC_STATUS_INIT
)
continue
;
sDebug
(
"%s, check roles since
self:%s sstatus:%s, peer
:%s sstatus:%s"
,
pPeer
->
id
,
syncRole
[
pPeer
->
role
],
sDebug
(
"%s, check roles since
peer:%s sstatus:%s, self
:%s sstatus:%s"
,
pPeer
->
id
,
syncRole
[
pPeer
->
role
],
syncStatus
[
pPeer
->
sstatus
],
syncRole
[
nodeRole
],
syncStatus
[
nodeSStatus
]);
syncStatus
[
pPeer
->
sstatus
],
syncRole
[
nodeRole
],
syncStatus
[
nodeSStatus
]);
syncSendPeersStatusMsgToPeer
(
pPeer
,
1
,
SYNC_STATUS_CHECK_ROLE
,
syncGenTranId
());
syncSendPeersStatusMsgToPeer
(
pPeer
,
1
,
SYNC_STATUS_CHECK_ROLE
,
syncGenTranId
());
break
;
break
;
...
@@ -1459,7 +1459,12 @@ static int32_t syncForwardToPeerImpl(SSyncNode *pNode, void *data, void *mhandle
...
@@ -1459,7 +1459,12 @@ static int32_t syncForwardToPeerImpl(SSyncNode *pNode, void *data, void *mhandle
if
((
pNode
->
quorum
>
1
||
force
)
&&
code
==
0
)
{
if
((
pNode
->
quorum
>
1
||
force
)
&&
code
==
0
)
{
code
=
syncSaveFwdInfo
(
pNode
,
pWalHead
->
version
,
mhandle
);
code
=
syncSaveFwdInfo
(
pNode
,
pWalHead
->
version
,
mhandle
);
if
(
code
>=
0
)
code
=
1
;
if
(
code
>=
0
)
{
code
=
1
;
}
else
{
pthread_mutex_unlock
(
&
pNode
->
mutex
);
return
code
;
}
}
}
int32_t
retLen
=
taosWriteMsg
(
pPeer
->
peerFd
,
pSyncHead
,
fwdLen
);
int32_t
retLen
=
taosWriteMsg
(
pPeer
->
peerFd
,
pSyncHead
,
fwdLen
);
...
...
src/tsdb/src/tsdbMain.c
浏览文件 @
64c06c95
...
@@ -526,7 +526,7 @@ static void tsdbStartStream(STsdbRepo *pRepo) {
...
@@ -526,7 +526,7 @@ static void tsdbStartStream(STsdbRepo *pRepo) {
STable
*
pTable
=
pMeta
->
tables
[
i
];
STable
*
pTable
=
pMeta
->
tables
[
i
];
if
(
pTable
&&
pTable
->
type
==
TSDB_STREAM_TABLE
)
{
if
(
pTable
&&
pTable
->
type
==
TSDB_STREAM_TABLE
)
{
pTable
->
cqhandle
=
(
*
pRepo
->
appH
.
cqCreateFunc
)(
pRepo
->
appH
.
cqH
,
TABLE_UID
(
pTable
),
TABLE_TID
(
pTable
),
TABLE_NAME
(
pTable
)
->
data
,
pTable
->
sql
,
pTable
->
cqhandle
=
(
*
pRepo
->
appH
.
cqCreateFunc
)(
pRepo
->
appH
.
cqH
,
TABLE_UID
(
pTable
),
TABLE_TID
(
pTable
),
TABLE_NAME
(
pTable
)
->
data
,
pTable
->
sql
,
tsdbGetTableSchemaImpl
(
pTable
,
false
,
false
,
-
1
));
tsdbGetTableSchemaImpl
(
pTable
,
false
,
false
,
-
1
)
,
0
);
}
}
}
}
}
}
...
...
src/tsdb/src/tsdbMeta.c
浏览文件 @
64c06c95
...
@@ -840,7 +840,7 @@ static int tsdbAddTableToMeta(STsdbRepo *pRepo, STable *pTable, bool addIdx, boo
...
@@ -840,7 +840,7 @@ static int tsdbAddTableToMeta(STsdbRepo *pRepo, STable *pTable, bool addIdx, boo
if
(
lock
&&
tsdbUnlockRepoMeta
(
pRepo
)
<
0
)
return
-
1
;
if
(
lock
&&
tsdbUnlockRepoMeta
(
pRepo
)
<
0
)
return
-
1
;
if
(
TABLE_TYPE
(
pTable
)
==
TSDB_STREAM_TABLE
&&
addIdx
)
{
if
(
TABLE_TYPE
(
pTable
)
==
TSDB_STREAM_TABLE
&&
addIdx
)
{
pTable
->
cqhandle
=
(
*
pRepo
->
appH
.
cqCreateFunc
)(
pRepo
->
appH
.
cqH
,
TABLE_UID
(
pTable
),
TABLE_TID
(
pTable
),
TABLE_NAME
(
pTable
)
->
data
,
pTable
->
sql
,
pTable
->
cqhandle
=
(
*
pRepo
->
appH
.
cqCreateFunc
)(
pRepo
->
appH
.
cqH
,
TABLE_UID
(
pTable
),
TABLE_TID
(
pTable
),
TABLE_NAME
(
pTable
)
->
data
,
pTable
->
sql
,
tsdbGetTableSchemaImpl
(
pTable
,
false
,
false
,
-
1
));
tsdbGetTableSchemaImpl
(
pTable
,
false
,
false
,
-
1
)
,
1
);
}
}
tsdbDebug
(
"vgId:%d table %s tid %d uid %"
PRIu64
" is added to meta"
,
REPO_ID
(
pRepo
),
TABLE_CHAR_NAME
(
pTable
),
tsdbDebug
(
"vgId:%d table %s tid %d uid %"
PRIu64
" is added to meta"
,
REPO_ID
(
pRepo
),
TABLE_CHAR_NAME
(
pTable
),
...
...
src/util/inc/tstoken.h
浏览文件 @
64c06c95
...
@@ -51,11 +51,9 @@ uint32_t tSQLGetToken(char *z, uint32_t *tokenType);
...
@@ -51,11 +51,9 @@ uint32_t tSQLGetToken(char *z, uint32_t *tokenType);
* @param str
* @param str
* @param i
* @param i
* @param isPrevOptr
* @param isPrevOptr
* @param numOfIgnoreToken
* @param ignoreTokenTypes
* @return
* @return
*/
*/
SStrToken
tStrGetToken
(
char
*
str
,
int32_t
*
i
,
bool
isPrevOptr
,
uint32_t
numOfIgnoreToken
,
uint32_t
*
ignoreTokenTypes
);
SStrToken
tStrGetToken
(
char
*
str
,
int32_t
*
i
,
bool
isPrevOptr
);
/**
/**
* check if it is a keyword or not
* check if it is a keyword or not
...
...
src/vnode/src/vnodeWrite.c
浏览文件 @
64c06c95
...
@@ -91,13 +91,17 @@ int32_t vnodeProcessWrite(void *vparam, void *wparam, int32_t qtype, void *rpara
...
@@ -91,13 +91,17 @@ int32_t vnodeProcessWrite(void *vparam, void *wparam, int32_t qtype, void *rpara
int32_t
syncCode
=
0
;
int32_t
syncCode
=
0
;
bool
force
=
(
pWrite
==
NULL
?
false
:
pWrite
->
pHead
.
msgType
!=
TSDB_MSG_TYPE_SUBMIT
);
bool
force
=
(
pWrite
==
NULL
?
false
:
pWrite
->
pHead
.
msgType
!=
TSDB_MSG_TYPE_SUBMIT
);
syncCode
=
syncForwardToPeer
(
pVnode
->
sync
,
pHead
,
pWrite
,
qtype
,
force
);
syncCode
=
syncForwardToPeer
(
pVnode
->
sync
,
pHead
,
pWrite
,
qtype
,
force
);
if
(
syncCode
<
0
)
return
syncCode
;
if
(
syncCode
<
0
)
{
pHead
->
version
=
0
;
return
syncCode
;
}
// write into WAL
// write into WAL
code
=
walWrite
(
pVnode
->
wal
,
pHead
);
code
=
walWrite
(
pVnode
->
wal
,
pHead
);
if
(
code
<
0
)
{
if
(
code
<
0
)
{
if
(
syncCode
>
0
)
atomic_sub_fetch_32
(
&
pWrite
->
processedCount
,
1
);
if
(
syncCode
>
0
)
atomic_sub_fetch_32
(
&
pWrite
->
processedCount
,
1
);
vError
(
"vgId:%d, hver:%"
PRIu64
" vver:%"
PRIu64
" code:0x%x"
,
pVnode
->
vgId
,
pHead
->
version
,
pVnode
->
version
,
code
);
vError
(
"vgId:%d, hver:%"
PRIu64
" vver:%"
PRIu64
" code:0x%x"
,
pVnode
->
vgId
,
pHead
->
version
,
pVnode
->
version
,
code
);
pHead
->
version
=
0
;
return
code
;
return
code
;
}
}
...
...
tests/pytest/fulltest.sh
浏览文件 @
64c06c95
...
@@ -178,7 +178,7 @@ python3 ./test.py -f stable/query_after_reset.py
...
@@ -178,7 +178,7 @@ python3 ./test.py -f stable/query_after_reset.py
# perfbenchmark
# perfbenchmark
python3 ./test.py
-f
perfbenchmark/bug3433.py
python3 ./test.py
-f
perfbenchmark/bug3433.py
python3 ./test.py
-f
perfbenchmark/bug3589.py
#
python3 ./test.py -f perfbenchmark/bug3589.py
#query
#query
...
...
tests/pytest/insert/metadataUpdate.py
浏览文件 @
64c06c95
...
@@ -11,13 +11,13 @@
...
@@ -11,13 +11,13 @@
# -*- coding: utf-8 -*-
# -*- coding: utf-8 -*-
import
sys
import
taos
import
taos
from
util.log
import
tdLog
from
util.log
import
tdLog
from
util.cases
import
tdCases
from
util.cases
import
tdCases
from
util.sql
import
tdSql
from
util.sql
import
tdSql
from
util.dnodes
import
tdDnodes
from
util.dnodes
import
tdDnodes
from
multiprocessing
import
Process
from
multiprocessing
import
Process
import
subprocess
class
TDTestCase
:
class
TDTestCase
:
def
init
(
self
,
conn
,
logSql
):
def
init
(
self
,
conn
,
logSql
):
...
@@ -40,27 +40,22 @@ class TDTestCase:
...
@@ -40,27 +40,22 @@ class TDTestCase:
print
(
"alter table done"
)
print
(
"alter table done"
)
def
deleteTableAndRecreate
(
self
):
def
deleteTableAndRecreate
(
self
):
self
.
host
=
"127.0.0.1"
self
.
user
=
"root"
self
.
password
=
"taosdata"
self
.
config
=
tdDnodes
.
getSimCfgPath
()
self
.
config
=
tdDnodes
.
getSimCfgPath
()
self
.
conn
=
taos
.
connect
(
host
=
self
.
host
,
user
=
self
.
user
,
password
=
self
.
password
,
config
=
self
.
config
)
sqlCmds
=
"use test; drop table stb;"
self
.
cursor
=
self
.
conn
.
cursor
()
sqlCmds
+=
"create table if not exists stb (ts timestamp, col1 int) tags(areaid int, city nchar(20));"
self
.
cursor
.
execute
(
"use test"
)
print
(
"drop table stb"
)
self
.
cursor
.
execute
(
"drop table stb"
)
print
(
"create table stb"
)
self
.
cursor
.
execute
(
"create table if not exists stb (ts timestamp, col1 int) tags(areaid int, city nchar(20))"
)
print
(
"insert data"
)
for
i
in
range
(
self
.
tables
):
for
i
in
range
(
self
.
tables
):
city
=
"beijing"
if
i
%
2
==
0
else
"shanghai"
city
=
"beijing"
if
i
%
2
==
0
else
"shanghai"
self
.
cursor
.
execute
(
"create table tb%d using stb tags(%d, '%s')"
%
(
i
,
i
,
city
))
sqlCmds
+=
"create table tb%d using stb tags(%d, '%s');"
%
(
i
,
i
,
city
)
for
j
in
range
(
self
.
rows
):
for
j
in
range
(
5
):
self
.
cursor
.
execute
(
"insert into tb%d values(%d, %d)"
%
(
i
,
self
.
ts
+
j
,
j
*
100000
))
sqlCmds
+=
"insert into tb%d values(%d, %d);"
%
(
i
,
self
.
ts
+
j
,
j
*
100000
)
command
=
[
"taos"
,
"-c"
,
self
.
config
,
"-s"
,
sqlCmds
]
print
(
"drop stb, recreate stb and insert data "
)
result
=
subprocess
.
run
(
command
,
stdout
=
subprocess
.
PIPE
,
stderr
=
subprocess
.
PIPE
,
encoding
=
"utf-8"
)
if
result
.
returncode
==
0
:
print
(
"success:"
,
result
)
else
:
print
(
"error:"
,
result
)
def
run
(
self
):
def
run
(
self
):
tdSql
.
prepare
()
tdSql
.
prepare
()
...
@@ -100,19 +95,17 @@ class TDTestCase:
...
@@ -100,19 +95,17 @@ class TDTestCase:
tdSql
.
query
(
"select count(*) from stb"
)
tdSql
.
query
(
"select count(*) from stb"
)
tdSql
.
checkData
(
0
,
0
,
10000
)
tdSql
.
checkData
(
0
,
0
,
10000
)
tdSql
.
query
(
"select count(*) from tb
1
"
)
tdSql
.
query
(
"select count(*) from tb
0
"
)
tdSql
.
checkData
(
0
,
0
,
1000
)
tdSql
.
checkData
(
0
,
0
,
1000
)
p
=
Process
(
target
=
self
.
deleteTableAndRecreate
,
args
=
())
# drop stable in subprocess
p
.
start
()
self
.
deleteTableAndRecreate
()
p
.
join
()
p
.
terminate
()
tdSql
.
query
(
"select count(*) from stb"
)
tdSql
.
query
(
"select count(*) from stb"
)
tdSql
.
checkData
(
0
,
0
,
10000
)
tdSql
.
checkData
(
0
,
0
,
5
*
self
.
tables
)
tdSql
.
query
(
"select count(*) from tb
1
"
)
tdSql
.
query
(
"select count(*) from tb
0
"
)
tdSql
.
checkData
(
0
,
0
,
1000
)
tdSql
.
checkData
(
0
,
0
,
5
)
def
stop
(
self
):
def
stop
(
self
):
tdSql
.
close
()
tdSql
.
close
()
...
...
tests/pytest/tools/insert-tblimit-tboffset-createdb.json
0 → 100644
浏览文件 @
64c06c95
{
"filetype"
:
"insert"
,
"cfgdir"
:
"/etc/taos"
,
"host"
:
"127.0.0.1"
,
"port"
:
6030
,
"user"
:
"root"
,
"password"
:
"taosdata"
,
"thread_count"
:
4
,
"thread_count_create_tbl"
:
4
,
"result_file"
:
"./insert_res.txt"
,
"confirm_parameter_prompt"
:
"no"
,
"insert_interval"
:
0
,
"num_of_records_per_req"
:
100
,
"max_sql_len"
:
1024000
,
"databases"
:
[{
"dbinfo"
:
{
"name"
:
"db"
,
"drop"
:
"yes"
,
"replica"
:
1
,
"days"
:
10
,
"cache"
:
16
,
"blocks"
:
8
,
"precision"
:
"ms"
,
"keep"
:
365
,
"minRows"
:
100
,
"maxRows"
:
4096
,
"comp"
:
2
,
"walLevel"
:
1
,
"cachelast"
:
0
,
"quorum"
:
1
,
"fsync"
:
3000
,
"update"
:
0
},
"super_tables"
:
[{
"name"
:
"stb"
,
"child_table_exists"
:
"no"
,
"childtable_count"
:
100
,
"childtable_prefix"
:
"stb_"
,
"auto_create_table"
:
"no"
,
"data_source"
:
"rand"
,
"insert_mode"
:
"taosc"
,
"insert_rows"
:
0
,
"multi_thread_write_one_tbl"
:
"no"
,
"number_of_tbl_in_one_sql"
:
0
,
"max_sql_len"
:
1024000
,
"disorder_ratio"
:
0
,
"disorder_range"
:
1000
,
"timestamp_step"
:
1
,
"start_timestamp"
:
"2020-10-01 00:00:00.000"
,
"sample_format"
:
"csv"
,
"sample_file"
:
"./sample.csv"
,
"tags_file"
:
""
,
"columns"
:
[{
"type"
:
"INT"
},
{
"type"
:
"DOUBLE"
,
"count"
:
10
},
{
"type"
:
"BINARY"
,
"len"
:
16
,
"count"
:
3
},
{
"type"
:
"BINARY"
,
"len"
:
32
,
"count"
:
6
}],
"tags"
:
[{
"type"
:
"TINYINT"
,
"count"
:
2
},
{
"type"
:
"BINARY"
,
"len"
:
16
,
"count"
:
5
}]
}]
}]
}
tests/pytest/tools/insert-tblimit-tboffset-insertrec.json
0 → 100644
浏览文件 @
64c06c95
{
"filetype"
:
"insert"
,
"cfgdir"
:
"/etc/taos"
,
"host"
:
"127.0.0.1"
,
"port"
:
6030
,
"user"
:
"root"
,
"password"
:
"taosdata"
,
"thread_count"
:
4
,
"thread_count_create_tbl"
:
4
,
"result_file"
:
"./insert_res.txt"
,
"confirm_parameter_prompt"
:
"no"
,
"insert_interval"
:
0
,
"num_of_records_per_req"
:
100
,
"max_sql_len"
:
1024000
,
"databases"
:
[{
"dbinfo"
:
{
"name"
:
"db"
,
"drop"
:
"no"
,
"replica"
:
1
,
"days"
:
10
,
"cache"
:
16
,
"blocks"
:
8
,
"precision"
:
"ms"
,
"keep"
:
365
,
"minRows"
:
100
,
"maxRows"
:
4096
,
"comp"
:
2
,
"walLevel"
:
1
,
"cachelast"
:
0
,
"quorum"
:
1
,
"fsync"
:
3000
,
"update"
:
0
},
"super_tables"
:
[{
"name"
:
"stb"
,
"child_table_exists"
:
"yes"
,
"childtable_count"
:
100
,
"childtable_prefix"
:
"stb_"
,
"auto_create_table"
:
"no"
,
"data_source"
:
"rand"
,
"insert_mode"
:
"taosc"
,
"insert_rows"
:
1000
,
"childtable_limit"
:
33
,
"childtable_offset"
:
33
,
"multi_thread_write_one_tbl"
:
"no"
,
"number_of_tbl_in_one_sql"
:
0
,
"max_sql_len"
:
1024000
,
"disorder_ratio"
:
0
,
"disorder_range"
:
1000
,
"timestamp_step"
:
1
,
"start_timestamp"
:
"2020-10-01 00:00:00.000"
,
"sample_format"
:
"csv"
,
"sample_file"
:
"./sample.csv"
,
"tags_file"
:
""
,
"columns"
:
[{
"type"
:
"INT"
},
{
"type"
:
"DOUBLE"
,
"count"
:
10
},
{
"type"
:
"BINARY"
,
"len"
:
16
,
"count"
:
3
},
{
"type"
:
"BINARY"
,
"len"
:
32
,
"count"
:
6
}],
"tags"
:
[{
"type"
:
"TINYINT"
,
"count"
:
2
},
{
"type"
:
"BINARY"
,
"len"
:
16
,
"count"
:
5
}]
}]
}]
}
tests/pytest/tools/insert-tblimit-tboffset0.json
浏览文件 @
64c06c95
...
@@ -15,7 +15,7 @@
...
@@ -15,7 +15,7 @@
"databases"
:
[{
"databases"
:
[{
"dbinfo"
:
{
"dbinfo"
:
{
"name"
:
"db"
,
"name"
:
"db"
,
"drop"
:
"
yes
"
,
"drop"
:
"
no
"
,
"replica"
:
1
,
"replica"
:
1
,
"days"
:
10
,
"days"
:
10
,
"cache"
:
16
,
"cache"
:
16
,
...
@@ -33,7 +33,7 @@
...
@@ -33,7 +33,7 @@
},
},
"super_tables"
:
[{
"super_tables"
:
[{
"name"
:
"stb"
,
"name"
:
"stb"
,
"child_table_exists"
:
"
no
"
,
"child_table_exists"
:
"
yes
"
,
"childtable_count"
:
100
,
"childtable_count"
:
100
,
"childtable_prefix"
:
"stb_"
,
"childtable_prefix"
:
"stb_"
,
"auto_create_table"
:
"no"
,
"auto_create_table"
:
"no"
,
...
...
tests/pytest/tools/insert-tblimit1-tboffset.json
浏览文件 @
64c06c95
...
@@ -15,7 +15,7 @@
...
@@ -15,7 +15,7 @@
"databases"
:
[{
"databases"
:
[{
"dbinfo"
:
{
"dbinfo"
:
{
"name"
:
"db"
,
"name"
:
"db"
,
"drop"
:
"
yes
"
,
"drop"
:
"
no
"
,
"replica"
:
1
,
"replica"
:
1
,
"days"
:
10
,
"days"
:
10
,
"cache"
:
16
,
"cache"
:
16
,
...
@@ -33,7 +33,7 @@
...
@@ -33,7 +33,7 @@
},
},
"super_tables"
:
[{
"super_tables"
:
[{
"name"
:
"stb"
,
"name"
:
"stb"
,
"child_table_exists"
:
"
no
"
,
"child_table_exists"
:
"
yes
"
,
"childtable_count"
:
100
,
"childtable_count"
:
100
,
"childtable_prefix"
:
"stb_"
,
"childtable_prefix"
:
"stb_"
,
"auto_create_table"
:
"no"
,
"auto_create_table"
:
"no"
,
...
...
tests/pytest/tools/taosdemo-sampledata.json
浏览文件 @
64c06c95
...
@@ -16,8 +16,6 @@
...
@@ -16,8 +16,6 @@
"name"
:
"stb"
,
"name"
:
"stb"
,
"child_table_exists"
:
"no"
,
"child_table_exists"
:
"no"
,
"childtable_count"
:
20
,
"childtable_count"
:
20
,
"childtable_limit"
:
10
,
"childtable_offset"
:
0
,
"childtable_prefix"
:
"t_"
,
"childtable_prefix"
:
"t_"
,
"auto_create_table"
:
"no"
,
"auto_create_table"
:
"no"
,
"data_source"
:
"sample"
,
"data_source"
:
"sample"
,
...
...
tests/pytest/tools/taosdemoTestLimitOffset.py
浏览文件 @
64c06c95
...
@@ -51,7 +51,8 @@ class TDTestCase:
...
@@ -51,7 +51,8 @@ class TDTestCase:
else
:
else
:
tdLog
.
info
(
"taosd found in %s"
%
buildPath
)
tdLog
.
info
(
"taosd found in %s"
%
buildPath
)
binPath
=
buildPath
+
"/build/bin/"
binPath
=
buildPath
+
"/build/bin/"
os
.
system
(
"%staosdemo -f tools/insert-tblimit-tboffset.json"
%
binPath
)
os
.
system
(
"%staosdemo -f tools/insert-tblimit-tboffset-createdb.json"
%
binPath
)
os
.
system
(
"%staosdemo -f tools/insert-tblimit-tboffset-insertrec.json"
%
binPath
)
tdSql
.
execute
(
"use db"
)
tdSql
.
execute
(
"use db"
)
tdSql
.
query
(
"select count(tbname) from db.stb"
)
tdSql
.
query
(
"select count(tbname) from db.stb"
)
...
@@ -59,6 +60,7 @@ class TDTestCase:
...
@@ -59,6 +60,7 @@ class TDTestCase:
tdSql
.
query
(
"select count(*) from db.stb"
)
tdSql
.
query
(
"select count(*) from db.stb"
)
tdSql
.
checkData
(
0
,
0
,
33000
)
tdSql
.
checkData
(
0
,
0
,
33000
)
os
.
system
(
"%staosdemo -f tools/insert-tblimit-tboffset-createdb.json"
%
binPath
)
os
.
system
(
"%staosdemo -f tools/insert-tblimit-tboffset0.json"
%
binPath
)
os
.
system
(
"%staosdemo -f tools/insert-tblimit-tboffset0.json"
%
binPath
)
tdSql
.
execute
(
"reset query cache"
)
tdSql
.
execute
(
"reset query cache"
)
...
@@ -68,6 +70,7 @@ class TDTestCase:
...
@@ -68,6 +70,7 @@ class TDTestCase:
tdSql
.
query
(
"select count(*) from db.stb"
)
tdSql
.
query
(
"select count(*) from db.stb"
)
tdSql
.
checkData
(
0
,
0
,
20000
)
tdSql
.
checkData
(
0
,
0
,
20000
)
os
.
system
(
"%staosdemo -f tools/insert-tblimit-tboffset-createdb.json"
%
binPath
)
os
.
system
(
"%staosdemo -f tools/insert-tblimit1-tboffset.json"
%
binPath
)
os
.
system
(
"%staosdemo -f tools/insert-tblimit1-tboffset.json"
%
binPath
)
tdSql
.
execute
(
"reset query cache"
)
tdSql
.
execute
(
"reset query cache"
)
...
...
tests/pytest/tools/taosdemoTestSampleData.py
浏览文件 @
64c06c95
...
@@ -57,7 +57,7 @@ class TDTestCase:
...
@@ -57,7 +57,7 @@ class TDTestCase:
tdSql
.
query
(
"select count(tbname) from db.stb"
)
tdSql
.
query
(
"select count(tbname) from db.stb"
)
tdSql
.
checkData
(
0
,
0
,
20
)
tdSql
.
checkData
(
0
,
0
,
20
)
tdSql
.
query
(
"select count(*) from db.stb"
)
tdSql
.
query
(
"select count(*) from db.stb"
)
tdSql
.
checkData
(
0
,
0
,
2
00
)
tdSql
.
checkData
(
0
,
0
,
4
00
)
def
stop
(
self
):
def
stop
(
self
):
tdSql
.
close
()
tdSql
.
close
()
...
...
tests/script/general/parser/alter.sim
浏览文件 @
64c06c95
...
@@ -204,7 +204,13 @@ if $data03 != NULL then
...
@@ -204,7 +204,13 @@ if $data03 != NULL then
return -1
return -1
endi
endi
sql reset query cache
print ============================>TD-3366 TD-3486
sql insert into td_3366(ts, c3, c1) using mt(t1) tags(911) values('2018-1-1 11:11:11', 'new1', 12);
sql insert into td_3486(ts, c3, c1) using mt(t1) tags(-12) values('2018-1-1 11:11:11', 'new1', 12);
sql insert into ttxu(ts, c3, c1) using mt(t1) tags('-121') values('2018-1-1 11:11:11', 'new1', 12);
sql insert into tb(ts, c1, c3) using mt(t1) tags(123) values('2018-11-01 16:29:58.000', 2, 'port')
sql insert into tb values ('2018-11-01 16:29:58.000', 2, 'import', 3)
sql insert into tb values ('2018-11-01 16:29:58.000', 2, 'import', 3)
sql import into tb values ('2018-11-01 16:29:58.000', 2, 'import', 3)
sql import into tb values ('2018-11-01 16:29:58.000', 2, 'import', 3)
sql import into tb values ('2018-11-01 16:39:58.000', 2, 'import', 3)
sql import into tb values ('2018-11-01 16:39:58.000', 2, 'import', 3)
...
@@ -212,6 +218,7 @@ sql select * from tb order by ts desc
...
@@ -212,6 +218,7 @@ sql select * from tb order by ts desc
if $rows != 4 then
if $rows != 4 then
return -1
return -1
endi
endi
if $data03 != 3 then
if $data03 != 3 then
return -1
return -1
endi
endi
...
@@ -233,10 +240,10 @@ sql_error alter table mt add column c1 int
...
@@ -233,10 +240,10 @@ sql_error alter table mt add column c1 int
# drop non-existing columns
# drop non-existing columns
sql_error alter table mt drop column c9
sql_error alter table mt drop column c9
sql drop database $db
#
sql drop database $db
sql show databases
#
sql show databases
if $rows != 0 then
#if $rows != 0 then
return -1
#
return -1
endi
#
endi
system sh/exec.sh -n dnode1 -s stop -x SIGINT
system sh/exec.sh -n dnode1 -s stop -x SIGINT
tests/script/general/parser/gendata.sh
0 → 100755
浏览文件 @
64c06c95
#!/bin/bash
Cur_Dir
=
$(
pwd
)
echo
$Cur_Dir
echo
"'2020-1-1 1:1:1','abc','device',123,'9876', 'abc', 'net', 'mno', 'province', 'city', 'al'"
>>
~/data.sql
tests/script/general/parser/import_file.sim
浏览文件 @
64c06c95
...
@@ -8,32 +8,28 @@ sql connect
...
@@ -8,32 +8,28 @@ sql connect
sleep 500
sleep 500
sql drop database if exists indb
sql drop database if exists indb
sql create database if not exists indb
sql create database if not exists indb
sql use indb
sql use indb
$inFileName = '~/data.csv'
$inFileName = '~/data.csv'
$numOfRows = 10000
$numOfRows = 10000
#system sh/gendata.sh $inFileName $numOfRows # input file invalid
system general/parser/gendata.sh
system sh/gendata.sh ~/data.csv $numOfRows
sql create table tbx (ts TIMESTAMP, collect_area NCHAR(12), device_id BINARY(16), imsi BINARY(16), imei BINARY(16), mdn BINARY(10), net_type BINARY(4), mno NCHAR(4), province NCHAR(10), city NCHAR(16), alarm BINARY(2))
sql create table tbx (ts TIMESTAMP, collect_area NCHAR(12), device_id BINARY(16), imsi BINARY(16), imei BINARY(16), mdn BINARY(10), net_type BINARY(4), mno NCHAR(4), province NCHAR(10), city NCHAR(16), alarm BINARY(2))
print ====== create tables success, starting import data
print ====== create tables success, starting import data
sql import into tbx file
$inFileName
sql import into tbx file
'~/data.sql'
sql select count(*) from tbx
sql select count(*) from tbx
if $rows != 1 then
if $rows != 1 then
return -1
return -1
endi
endi
if $data00 != $numOfRows then
print "expect: $numOfRows, act: $data00"
return -1
endi
#if $data00 != $numOfRows then
# print "expect: $numOfRows, act: $data00"
# return -1
#endi
#system rm -f $inFileName # invalid shell
system rm -f ~/data.sql
system rm -f ~/data.csv
system sh/exec.sh -n dnode1 -s stop -x SIGINT
system sh/exec.sh -n dnode1 -s stop -x SIGINT
\ No newline at end of file
tests/script/general/parser/select_with_tags.sim
浏览文件 @
64c06c95
...
@@ -159,6 +159,15 @@ if $data03 != @abc15@ then
...
@@ -159,6 +159,15 @@ if $data03 != @abc15@ then
return -1
return -1
endi
endi
sql select top(c6, 3) from select_tags_mt0 interval(10a)
sql select top(c3,10) from select_tags_mt0 interval(10a) group by tbname
sql select top(c6, 3) from select_tags_mt0 interval(10a) group by tbname;
sql select top(c6, 10) from select_tags_mt0 interval(10a);
if $rows != 12800 then
return -1
endi
sql select top(c1, 100), tbname, t1, t2 from select_tags_mt0;
sql select top(c1, 100), tbname, t1, t2 from select_tags_mt0;
if $rows != 100 then
if $rows != 100 then
return -1
return -1
...
...
tests/tsim/inc/sim.h
浏览文件 @
64c06c95
...
@@ -149,6 +149,7 @@ extern int32_t simScriptSucced;
...
@@ -149,6 +149,7 @@ extern int32_t simScriptSucced;
extern
int32_t
simDebugFlag
;
extern
int32_t
simDebugFlag
;
extern
char
tsScriptDir
[];
extern
char
tsScriptDir
[];
extern
bool
simAsyncQuery
;
extern
bool
simAsyncQuery
;
extern
bool
abortExecution
;
SScript
*
simParseScript
(
char
*
fileName
);
SScript
*
simParseScript
(
char
*
fileName
);
SScript
*
simProcessCallOver
(
SScript
*
script
);
SScript
*
simProcessCallOver
(
SScript
*
script
);
...
...
tests/tsim/src/simExe.c
浏览文件 @
64c06c95
...
@@ -645,8 +645,12 @@ bool simCreateRestFulConnect(SScript *script, char *user, char *pass) {
...
@@ -645,8 +645,12 @@ bool simCreateRestFulConnect(SScript *script, char *user, char *pass) {
bool
simCreateNativeConnect
(
SScript
*
script
,
char
*
user
,
char
*
pass
)
{
bool
simCreateNativeConnect
(
SScript
*
script
,
char
*
user
,
char
*
pass
)
{
simCloseTaosdConnect
(
script
);
simCloseTaosdConnect
(
script
);
void
*
taos
=
NULL
;
void
*
taos
=
NULL
;
taosMsleep
(
2000
);
for
(
int32_t
attempt
=
0
;
attempt
<
10
;
++
attempt
)
{
for
(
int32_t
attempt
=
0
;
attempt
<
10
;
++
attempt
)
{
if
(
abortExecution
)
{
script
->
killed
=
true
;
return
false
;
}
taos
=
taos_connect
(
NULL
,
user
,
pass
,
NULL
,
tsDnodeShellPort
);
taos
=
taos_connect
(
NULL
,
user
,
pass
,
NULL
,
tsDnodeShellPort
);
if
(
taos
==
NULL
)
{
if
(
taos
==
NULL
)
{
simDebug
(
"script:%s, user:%s connect taosd failed:%s, attempt:%d"
,
script
->
fileName
,
user
,
taos_errstr
(
NULL
),
simDebug
(
"script:%s, user:%s connect taosd failed:%s, attempt:%d"
,
script
->
fileName
,
user
,
taos_errstr
(
NULL
),
...
@@ -697,6 +701,11 @@ bool simExecuteNativeSqlCommand(SScript *script, char *rest, bool isSlow) {
...
@@ -697,6 +701,11 @@ bool simExecuteNativeSqlCommand(SScript *script, char *rest, bool isSlow) {
TAOS_RES
*
pSql
=
NULL
;
TAOS_RES
*
pSql
=
NULL
;
for
(
int32_t
attempt
=
0
;
attempt
<
10
;
++
attempt
)
{
for
(
int32_t
attempt
=
0
;
attempt
<
10
;
++
attempt
)
{
if
(
abortExecution
)
{
script
->
killed
=
true
;
return
false
;
}
simLogSql
(
rest
,
false
);
simLogSql
(
rest
,
false
);
pSql
=
taos_query
(
script
->
taos
,
rest
);
pSql
=
taos_query
(
script
->
taos
,
rest
);
ret
=
taos_errno
(
pSql
);
ret
=
taos_errno
(
pSql
);
...
...
tests/tsim/src/simMain.c
浏览文件 @
64c06c95
...
@@ -21,10 +21,13 @@
...
@@ -21,10 +21,13 @@
bool
simAsyncQuery
=
false
;
bool
simAsyncQuery
=
false
;
bool
simExecSuccess
=
false
;
bool
simExecSuccess
=
false
;
bool
abortExecution
=
false
;
void
simHandleSignal
(
int32_t
signo
,
void
*
sigInfo
,
void
*
context
)
{
void
simHandleSignal
(
int32_t
signo
,
void
*
sigInfo
,
void
*
context
)
{
simSystemCleanUp
();
simSystemCleanUp
();
exit
(
1
);
abortExecution
=
true
;
// runningScript->killed = true;
// exit(1);
}
}
int32_t
main
(
int32_t
argc
,
char
*
argv
[])
{
int32_t
main
(
int32_t
argc
,
char
*
argv
[])
{
...
@@ -60,6 +63,11 @@ int32_t main(int32_t argc, char *argv[]) {
...
@@ -60,6 +63,11 @@ int32_t main(int32_t argc, char *argv[]) {
return
-
1
;
return
-
1
;
}
}
if
(
abortExecution
)
{
simError
(
"execute abort"
);
return
-
1
;
}
simScriptList
[
++
simScriptPos
]
=
script
;
simScriptList
[
++
simScriptPos
]
=
script
;
simExecuteScript
(
script
);
simExecuteScript
(
script
);
...
...
tests/tsim/src/simSystem.c
浏览文件 @
64c06c95
...
@@ -159,9 +159,17 @@ void *simExecuteScript(void *inputScript) {
...
@@ -159,9 +159,17 @@ void *simExecuteScript(void *inputScript) {
script
=
simScriptList
[
simScriptPos
];
script
=
simScriptList
[
simScriptPos
];
}
}
if
(
abortExecution
)
{
script
->
killed
=
true
;
}
if
(
script
->
killed
||
script
->
linePos
>=
script
->
numOfLines
)
{
if
(
script
->
killed
||
script
->
linePos
>=
script
->
numOfLines
)
{
printf
(
"killed ---------------------->
\n
"
);
script
=
simProcessCallOver
(
script
);
script
=
simProcessCallOver
(
script
);
if
(
script
==
NULL
)
break
;
if
(
script
==
NULL
)
{
printf
(
"abort now!
\n
"
);
break
;
}
}
else
{
}
else
{
SCmdLine
*
line
=
&
script
->
lines
[
script
->
linePos
];
SCmdLine
*
line
=
&
script
->
lines
[
script
->
linePos
];
char
*
option
=
script
->
optionBuffer
+
line
->
optionOffset
;
char
*
option
=
script
->
optionBuffer
+
line
->
optionOffset
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录