Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
哥们要飞
TDengine
提交
64c06c95
T
TDengine
项目概览
哥们要飞
/
TDengine
与 Fork 源项目一致
Fork自
taosdata / TDengine
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
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)
IF
(
DEFINED
VERNUMBER
)
SET
(
TD_VER_NUMBER
$
{
VERNUMBER
})
ELSE
()
SET
(
TD_VER_NUMBER
"2.0.1
8
.0"
)
SET
(
TD_VER_NUMBER
"2.0.1
9
.0"
)
ENDIF
()
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;"
### 运行SQL命令脚本
TDengine
终端可以通过
`source`
命令来运行SQL
命令脚本.
TDengine
终端可以通过
`source`
命令来运行 SQL
命令脚本.
```
mysql
taos> source <filename>;
...
...
@@ -109,10 +109,10 @@ taos> source <filename>;
### Shell小技巧
-
可以使用上下光标键查看
已经历史输入的命
令
-
修改用户密码。在
shell中使用alter user命
令
-
可以使用上下光标键查看
历史输入的指
令
-
修改用户密码。在
shell 中使用 alter user 指
令
-
ctrl+c 中止正在进行中的查询
-
执行
`RESET QUERY CACHE`
清空本地缓存的表的
schema
-
执行
`RESET QUERY CACHE`
清空本地缓存的表
schema
## <a class="anchor" id="demo"></a>TDengine 极速体验
...
...
@@ -212,7 +212,7 @@ taos> select avg(f1), max(f2), min(f3) from test.t10 interval(10s);
|
**Python**
| ● | ● | ● | ○ | ● | ● | ● | -- | ● |
|
**Go**
| ● | ● | ● | ○ | ● | ● | ○ | -- | -- |
|
**NodeJs**
| ● | ● | ○ | ○ | ● | ● | ○ | -- | -- |
|
**C#**
|
○ | ● | ●
| ○ | ○ | ○ | ○ | -- | -- |
|
**C#**
|
● | ● | ○
| ○ | ○ | ○ | ○ | -- | -- |
|
**RESTful**
| ● | ● | ● | ● | ● | ● | ● | ● | ● |
注: ● 表示经过官方测试验证, ○ 表示非官方测试验证。
...
...
documentation20/cn/08.connector/docs.md
浏览文件 @
64c06c95
...
...
@@ -14,7 +14,7 @@ TDengine提供了丰富的应用程序开发接口,其中包括C/C++、Java、
|
**Python**
| ● | ● | ● | ○ | ● | ● | ○ | -- | ○ |
|
**Go**
| ● | ● | ● | ○ | ● | ● | ○ | -- | -- |
|
**NodeJs**
| ● | ● | ○ | ○ | ● | ● | ○ | -- | -- |
|
**C#**
|
○ | ● | ●
| ○ | ○ | ○ | ○ | -- | -- |
|
**C#**
|
● | ● | ○
| ○ | ○ | ○ | ○ | -- | -- |
|
**RESTful**
| ● | ● | ● | ● | ● | ● | ○ | ○ | ○ |
其中 ● 表示经过官方测试验证, ○ 表示非官方测试验证。
...
...
@@ -23,7 +23,7 @@ TDengine提供了丰富的应用程序开发接口,其中包括C/C++、Java、
*
在没有安装TDengine服务端软件的系统中使用连接器(除RESTful外)访问 TDengine 数据库,需要安装相应版本的客户端安装包来使应用驱动(Linux系统中文件名为libtaos.so,Windows系统中为taos.dll)被安装在系统中,否则会产生无法找到相应库文件的错误。
*
所有执行 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”状态量在线程之间相互干扰(但连接的查询和写入操作都是线程安全的)。
## <a class="anchor" id="driver"></a>安装连接器驱动步骤
...
...
snap/snapcraft.yaml
浏览文件 @
64c06c95
name
:
tdengine
base
:
core18
version
:
'
2.0.1
8
.0'
version
:
'
2.0.1
9
.0'
icon
:
snap/gui/t-dengine.svg
summary
:
an open-source big data platform designed and optimized for IoT.
description
:
|
...
...
@@ -72,7 +72,7 @@ parts:
-
usr/bin/taosd
-
usr/bin/taos
-
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
...
...
src/client/inc/tscUtil.h
浏览文件 @
64c06c95
...
...
@@ -36,19 +36,6 @@ extern "C" {
#define UTIL_TABLE_IS_NORMAL_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)
// this struct is transfered as binary, padding two bytes to avoid
// 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
void
tscDestroyDataBlock
(
STableDataBlocks
*
pDataBlock
,
bool
removeMeta
);
void
tscSortRemoveDataBlockDupRows
(
STableDataBlocks
*
dataBuf
);
void
tscDestroyBoundColumnInfo
(
SParsedDataColInfo
*
pColInfo
);
SParamInfo
*
tscAddParamToDataBlock
(
STableDataBlocks
*
pDataBlock
,
char
type
,
uint8_t
timePrec
,
int16_t
bytes
,
uint32_t
offset
);
...
...
@@ -140,6 +129,8 @@ bool tscIsPointInterpQuery(SQueryInfo* pQueryInfo);
bool
tscIsTWAQuery
(
SQueryInfo
*
pQueryInfo
);
bool
tscIsSecondStageQuery
(
SQueryInfo
*
pQueryInfo
);
bool
tscGroupbyColumn
(
SQueryInfo
*
pQueryInfo
);
bool
tscIsTopbotQuery
(
SQueryInfo
*
pQueryInfo
);
int32_t
tscGetTopbotQueryParam
(
SQueryInfo
*
pQueryInfo
);
bool
tscNonOrderedProjectionQueryOnSTable
(
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 {
uint32_t
offset
;
}
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
{
SName
tableName
;
int8_t
tsSource
;
// where does the UNIX timestamp come from, server or client
...
...
@@ -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
char
*
pData
;
SParsedDataColInfo
boundColumnInfo
;
// for parameter ('?') binding
uint32_t
numOfAllocedParams
;
uint32_t
numOfParams
;
...
...
@@ -425,6 +440,7 @@ void tscRestoreFuncForSTableQuery(SQueryInfo *pQueryInfo);
int32_t
tscCreateResPointerInfo
(
SSqlRes
*
pRes
,
SQueryInfo
*
pQueryInfo
);
void
tscSetResRawPtr
(
SSqlRes
*
pRes
,
SQueryInfo
*
pQueryInfo
);
void
destroyTableNameList
(
SSqlCmd
*
pCmd
);
void
tscResetSqlCmd
(
SSqlCmd
*
pCmd
,
bool
removeMeta
);
...
...
@@ -462,6 +478,7 @@ char* tscGetSqlStr(SSqlObj* pSql);
bool
tscIsQueryWithLimit
(
SSqlObj
*
pSql
);
bool
tscHasReachLimitation
(
SQueryInfo
*
pQueryInfo
,
SSqlRes
*
pRes
);
void
tscSetBoundColumnInfo
(
SParsedDataColInfo
*
pColInfo
,
SSchema
*
pSchema
,
int32_t
numOfCols
);
char
*
tscGetErrorMsgPayload
(
SSqlCmd
*
pCmd
);
...
...
src/client/src/tscLocalMerge.c
浏览文件 @
64c06c95
...
...
@@ -338,11 +338,20 @@ void tscCreateLocalMerger(tExtMemBuffer **pMemBuffer, int32_t numOfBuffer, tOrde
pReducer
->
resColModel
->
capacity
=
pReducer
->
nResultBufSize
;
pReducer
->
finalModel
=
pFFModel
;
int32_t
expandFactor
=
1
;
if
(
finalmodel
->
rowSize
>
0
)
{
pReducer
->
resColModel
->
capacity
/=
finalmodel
->
rowSize
;
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
;
}
}
assert
(
finalmodel
->
rowSize
>
0
&&
finalmodel
->
rowSize
<=
pReducer
->
rowSize
);
pReducer
->
pFinalRes
=
calloc
(
1
,
pReducer
->
rowSize
*
pReducer
->
resColModel
->
capacity
);
if
(
pReducer
->
pTempBuffer
==
NULL
||
pReducer
->
discardData
==
NULL
||
pReducer
->
pResultBuf
==
NULL
||
...
...
@@ -1150,9 +1159,10 @@ static void fillMultiRowsOfTagsVal(SQueryInfo *pQueryInfo, int32_t numOfRes, SLo
memset
(
buf
,
0
,
(
size_t
)
maxBufSize
);
memcpy
(
buf
,
pCtx
->
pOutput
,
(
size_t
)
pCtx
->
outputBytes
);
char
*
next
=
pCtx
->
pOutput
;
for
(
int32_t
i
=
0
;
i
<
inc
;
++
i
)
{
pCtx
->
pOutpu
t
+=
pCtx
->
outputBytes
;
memcpy
(
pCtx
->
pOutpu
t
,
buf
,
(
size_t
)
pCtx
->
outputBytes
);
nex
t
+=
pCtx
->
outputBytes
;
memcpy
(
nex
t
,
buf
,
(
size_t
)
pCtx
->
outputBytes
);
}
}
...
...
@@ -1440,6 +1450,11 @@ int32_t tscDoLocalMerge(SSqlObj *pSql) {
SQueryInfo
*
pQueryInfo
=
tscGetQueryInfoDetail
(
pCmd
,
pCmd
->
clauseIndex
);
tFilePage
*
tmpBuffer
=
pLocalMerge
->
pTempBuffer
;
int32_t
remain
=
1
;
if
(
tscIsTopbotQuery
(
pQueryInfo
))
{
remain
=
tscGetTopbotQueryParam
(
pQueryInfo
);
}
if
(
doHandleLastRemainData
(
pSql
))
{
return
TSDB_CODE_SUCCESS
;
}
...
...
@@ -1528,7 +1543,7 @@ int32_t tscDoLocalMerge(SSqlObj *pSql) {
* if the previous group does NOT generate any result (pResBuf->num == 0),
* 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
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) {
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
)
{
if
(
!
tscIsPointInterpQuery
(
pQueryInfo
))
{
return
;
...
...
@@ -415,6 +450,20 @@ void tscFreeQueryInfo(SSqlCmd* pCmd, bool removeMeta) {
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
)
{
pCmd
->
command
=
0
;
pCmd
->
numOfCols
=
0
;
...
...
@@ -424,14 +473,7 @@ void tscResetSqlCmd(SSqlCmd* pCmd, bool removeMeta) {
pCmd
->
parseFinished
=
0
;
pCmd
->
autoCreated
=
0
;
for
(
int32_t
i
=
0
;
i
<
pCmd
->
numOfTables
;
++
i
)
{
if
(
pCmd
->
pTableNameList
&&
pCmd
->
pTableNameList
[
i
])
{
tfree
(
pCmd
->
pTableNameList
[
i
]);
}
}
pCmd
->
numOfTables
=
0
;
tfree
(
pCmd
->
pTableNameList
);
destroyTableNameList
(
pCmd
);
pCmd
->
pTableBlockHashList
=
tscDestroyBlockHashTable
(
pCmd
->
pTableBlockHashList
,
removeMeta
);
pCmd
->
pDataBlocks
=
tscDestroyBlockArrayList
(
pCmd
->
pDataBlocks
);
...
...
@@ -548,6 +590,11 @@ void tscFreeSqlObj(SSqlObj* pSql) {
free
(
pSql
);
}
void
tscDestroyBoundColumnInfo
(
SParsedDataColInfo
*
pColInfo
)
{
tfree
(
pColInfo
->
boundedColumns
);
tfree
(
pColInfo
->
cols
);
}
void
tscDestroyDataBlock
(
STableDataBlocks
*
pDataBlock
,
bool
removeMeta
)
{
if
(
pDataBlock
==
NULL
)
{
return
;
...
...
@@ -568,6 +615,7 @@ void tscDestroyDataBlock(STableDataBlocks* pDataBlock, bool removeMeta) {
taosHashRemove
(
tscTableMetaInfo
,
name
,
strnlen
(
name
,
TSDB_TABLE_FNAME_LEN
));
}
tscDestroyBoundColumnInfo
(
&
pDataBlock
->
boundColumnInfo
);
tfree
(
pDataBlock
);
}
...
...
@@ -678,7 +726,7 @@ int32_t tscCopyDataBlockToPayload(SSqlObj* pSql, STableDataBlocks* pDataBlock) {
* @param dataBlocks
* @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
)
{
STableDataBlocks
*
dataBuf
=
(
STableDataBlocks
*
)
calloc
(
1
,
sizeof
(
STableDataBlocks
));
if
(
dataBuf
==
NULL
)
{
...
...
@@ -686,10 +734,12 @@ int32_t tscCreateDataBlock(size_t initialSize, int32_t rowSize, int32_t startOff
return
TSDB_CODE_TSC_OUT_OF_MEMORY
;
}
dataBuf
->
nAllocSize
=
(
uint32_t
)
initialSize
;
dataBuf
->
headerSize
=
startOffset
;
// the header size will always be the startOffset value, reserved for the subumit block header
dataBuf
->
nAllocSize
=
(
uint32_t
)
defaultSize
;
dataBuf
->
headerSize
=
startOffset
;
// the header size will always be the startOffset value, reserved for the subumit block header
if
(
dataBuf
->
nAllocSize
<=
dataBuf
->
headerSize
)
{
dataBuf
->
nAllocSize
=
dataBuf
->
headerSize
*
2
;
dataBuf
->
nAllocSize
=
dataBuf
->
headerSize
*
2
;
}
dataBuf
->
pData
=
calloc
(
1
,
dataBuf
->
nAllocSize
);
...
...
@@ -699,25 +749,31 @@ int32_t tscCreateDataBlock(size_t initialSize, int32_t rowSize, int32_t startOff
return
TSDB_CODE_TSC_OUT_OF_MEMORY
;
}
dataBuf
->
ordered
=
true
;
dataBuf
->
prevTS
=
INT64_MIN
;
//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
->
rowSize
=
rowSize
;
dataBuf
->
size
=
startOffset
;
dataBuf
->
ordered
=
true
;
dataBuf
->
prevTS
=
INT64_MIN
;
dataBuf
->
rowSize
=
rowSize
;
dataBuf
->
size
=
startOffset
;
dataBuf
->
tsSource
=
-
1
;
dataBuf
->
vgId
=
dataBuf
->
pTableMeta
->
vgId
;
tNameAssign
(
&
dataBuf
->
tableName
,
name
);
//Here we keep the tableMeta to avoid it to be remove by other threads.
dataBuf
->
pTableMeta
=
tscTableMetaDup
(
pTableMeta
);
assert
(
initialSize
>
0
&&
pTableMeta
!=
NULL
&&
dataBuf
->
pTableMeta
!=
NULL
);
assert
(
defaultSize
>
0
&&
pTableMeta
!=
NULL
&&
dataBuf
->
pTableMeta
!=
NULL
);
*
dataBlocks
=
dataBuf
;
return
TSDB_CODE_SUCCESS
;
}
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
;
STableDataBlocks
**
t1
=
(
STableDataBlocks
**
)
taosHashGet
(
pHashList
,
(
const
char
*
)
&
id
,
sizeof
(
id
));
if
(
t1
!=
NULL
)
{
...
...
@@ -826,6 +882,8 @@ static void extractTableNameList(SSqlCmd* pCmd, bool freeBlockMap) {
int32_t
i
=
0
;
while
(
p1
)
{
STableDataBlocks
*
pBlocks
=
*
p1
;
tfree
(
pCmd
->
pTableNameList
[
i
]);
pCmd
->
pTableNameList
[
i
++
]
=
tNameDup
(
&
pBlocks
->
tableName
);
p1
=
taosHashIterate
(
pCmd
->
pTableBlockHashList
,
p1
);
}
...
...
@@ -942,7 +1000,7 @@ bool tscIsInsertData(char* sqlstr) {
int32_t
index
=
0
;
do
{
SStrToken
t0
=
tStrGetToken
(
sqlstr
,
&
index
,
false
,
0
,
NULL
);
SStrToken
t0
=
tStrGetToken
(
sqlstr
,
&
index
,
false
);
if
(
t0
.
type
!=
TK_LP
)
{
return
t0
.
type
==
TK_INSERT
||
t0
.
type
==
TK_IMPORT
;
}
...
...
src/cq/src/cqMain.c
浏览文件 @
64c06c95
...
...
@@ -294,7 +294,7 @@ void cqStop(void *handle) {
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
)
{
return
NULL
;
}
...
...
@@ -326,7 +326,11 @@ void *cqCreate(void *handle, uint64_t uid, int32_t sid, const char* dstTable, ch
pObj
->
rid
=
taosAddRef
(
cqObjRef
,
pObj
);
cqCreateStream
(
pContext
,
pObj
);
if
(
start
&&
pContext
->
master
)
{
cqCreateStream
(
pContext
,
pObj
);
}
else
{
pObj
->
pContext
=
pContext
;
}
rid
=
pObj
->
rid
;
...
...
src/cq/test/cqtest.c
浏览文件 @
64c06c95
...
...
@@ -70,7 +70,7 @@ int main(int argc, char *argv[]) {
tdDestroyTSchemaBuilder
(
&
schemaBuilder
);
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
);
...
...
src/dnode/src/dnodeVWrite.c
浏览文件 @
64c06c95
...
...
@@ -222,7 +222,7 @@ static void *dnodeProcessVWriteQueue(void *wparam) {
dnodeSendRpcVWriteRsp
(
pVnode
,
pWrite
,
pWrite
->
code
);
}
else
{
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
)
{
rpcFreeCont
(
pWrite
->
rspRet
.
rsp
);
...
...
src/inc/tcq.h
浏览文件 @
64c06c95
...
...
@@ -42,7 +42,7 @@ void cqStart(void *handle);
void
cqStop
(
void
*
handle
);
// 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
void
cqDrop
(
void
*
handle
);
...
...
src/inc/tsdb.h
浏览文件 @
64c06c95
...
...
@@ -51,7 +51,7 @@ typedef struct {
void
*
cqH
;
int
(
*
notifyStatus
)(
void
*
,
int
status
,
int
eno
);
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
);
}
STsdbAppH
;
...
...
src/kit/taosdemo/taosdemo.c
浏览文件 @
64c06c95
此差异已折叠。
点击以展开。
src/kit/taosdump/taosdump.c
浏览文件 @
64c06c95
此差异已折叠。
点击以展开。
src/mnode/src/mnodeDnode.c
浏览文件 @
64c06c95
...
...
@@ -628,6 +628,11 @@ static int32_t mnodeProcessDnodeStatusMsg(SMnodeMsg *pMsg) {
bnNotify
();
}
if
(
!
tsEnableBalance
)
{
int32_t
numOfMnodes
=
mnodeGetMnodesNum
();
if
(
numOfMnodes
<
tsNumOfMnodes
)
bnNotify
();
}
if
(
openVnodes
!=
pDnode
->
openVnodes
)
{
mnodeCheckUnCreatedVgroup
(
pDnode
,
pStatus
->
load
,
openVnodes
);
}
...
...
src/mnode/src/mnodeMnode.c
浏览文件 @
64c06c95
...
...
@@ -381,6 +381,8 @@ static bool mnodeAllOnline() {
void
*
pIter
=
NULL
;
bool
allOnline
=
true
;
sdbUpdateMnodeRoles
();
while
(
1
)
{
SMnodeObj
*
pMnode
=
NULL
;
pIter
=
mnodeGetNextMnode
(
pIter
,
&
pMnode
);
...
...
src/query/inc/qExecutor.h
浏览文件 @
64c06c95
...
...
@@ -86,7 +86,8 @@ typedef struct SResultRow {
bool
closed
;
// this result status: closed or opened
uint32_t
numOfRows
;
// number of rows of current time window
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
;
typedef
struct
SGroupResInfo
{
...
...
src/query/src/qExecutor.c
浏览文件 @
64c06c95
...
...
@@ -1876,14 +1876,15 @@ static void teardownQueryRuntimeEnv(SQueryRuntimeEnv *pRuntimeEnv) {
taosHashCleanup
(
pRuntimeEnv
->
pResultRowHashTable
);
pRuntimeEnv
->
pResultRowHashTable
=
NULL
;
pRuntimeEnv
->
pool
=
destroyResultRowPool
(
pRuntimeEnv
->
pool
);
taosArrayDestroyEx
(
pRuntimeEnv
->
prevResult
,
freeInterResult
);
pRuntimeEnv
->
prevResult
=
NULL
;
taosHashCleanup
(
pRuntimeEnv
->
pTableRetrieveTsMap
);
pRuntimeEnv
->
pTableRetrieveTsMap
=
NULL
;
destroyOperatorInfo
(
pRuntimeEnv
->
proot
);
pRuntimeEnv
->
pool
=
destroyResultRowPool
(
pRuntimeEnv
->
pool
);
taosArrayDestroyEx
(
pRuntimeEnv
->
prevResult
,
freeInterResult
);
pRuntimeEnv
->
prevResult
=
NULL
;
}
static
bool
needBuildResAfterQueryComplete
(
SQInfo
*
pQInfo
)
{
...
...
@@ -2630,6 +2631,21 @@ int32_t loadDataBlockOnDemand(SQueryRuntimeEnv* pRuntimeEnv, STableScanInfo* pTa
tsdbRetrieveDataBlockStatisInfo
(
pTableScanInfo
->
pQueryHandle
,
&
pBlock
->
pBlockStatis
);
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
;
for
(
int32_t
i
=
0
;
i
<
pQuery
->
numOfOutput
;
++
i
)
{
int32_t
functionId
=
pTableScanInfo
->
pCtx
[
i
].
functionId
;
...
...
@@ -6463,6 +6479,9 @@ void freeQInfo(SQInfo *pQInfo) {
SQueryRuntimeEnv
*
pRuntimeEnv
=
&
pQInfo
->
runtimeEnv
;
releaseQueryBuf
(
pRuntimeEnv
->
tableqinfoGroupInfo
.
numOfTables
);
doDestroyTableQueryInfo
(
&
pRuntimeEnv
->
tableqinfoGroupInfo
);
teardownQueryRuntimeEnv
(
&
pQInfo
->
runtimeEnv
);
SQuery
*
pQuery
=
pQInfo
->
runtimeEnv
.
pQuery
;
...
...
@@ -6498,7 +6517,6 @@ void freeQInfo(SQInfo *pQInfo) {
}
}
doDestroyTableQueryInfo
(
&
pRuntimeEnv
->
tableqinfoGroupInfo
);
tfree
(
pQInfo
->
pBuf
);
tfree
(
pQInfo
->
sql
);
...
...
src/query/src/qTokenizer.c
浏览文件 @
64c06c95
...
...
@@ -560,7 +560,7 @@ uint32_t tSQLGetToken(char* z, uint32_t* tokenId) {
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
};
// 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
}
t0
.
n
=
tSQLGetToken
(
&
str
[
*
i
],
&
t0
.
type
);
break
;
// not support user specfied ignored symbol list
#if 0
bool ignore = false;
for (uint32_t k = 0; k < numOfIgnoreToken; k++) {
if (t0.type == ignoreTokenTypes[k]) {
...
...
@@ -597,6 +600,7 @@ SStrToken tStrGetToken(char* str, int32_t* i, bool isPrevOptr, uint32_t numOfIgn
if (!ignore) {
break;
}
#endif
}
if
(
t0
.
type
==
TK_SEMI
)
{
...
...
src/query/src/qUtil.c
浏览文件 @
64c06c95
...
...
@@ -66,8 +66,8 @@ void cleanupResultRowInfo(SResultRowInfo *pResultRowInfo) {
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
);
}
}
...
...
@@ -153,11 +153,8 @@ void clearResultRow(SQueryRuntimeEnv *pRuntimeEnv, SResultRow *pResultRow, int16
pResultRow
->
offset
=
-
1
;
pResultRow
->
closed
=
false
;
if
(
type
==
TSDB_DATA_TYPE_BINARY
||
type
==
TSDB_DATA_TYPE_NCHAR
)
{
tfree
(
pResultRow
->
key
);
}
else
{
pResultRow
->
win
=
TSWINDOW_INITIALIZER
;
}
tfree
(
pResultRow
->
key
);
pResultRow
->
win
=
TSWINDOW_INITIALIZER
;
}
// TODO refactor: use macro
...
...
src/query/tests/resultBufferTest.cpp
浏览文件 @
64c06c95
...
...
@@ -10,7 +10,7 @@ namespace {
// simple test
void
simpleTest
()
{
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
groupId
=
0
;
...
...
@@ -52,7 +52,7 @@ void simpleTest() {
void
writeDownTest
()
{
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
writePageId
=
0
;
...
...
@@ -99,7 +99,7 @@ void writeDownTest() {
void
recyclePageTest
()
{
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
writePageId
=
0
;
...
...
src/sync/inc/syncInt.h
浏览文件 @
64c06c95
...
...
@@ -35,7 +35,7 @@ extern "C" {
#define SYNC_MAX_SIZE (TSDB_MAX_WAL_SIZE + sizeof(SWalHead) + sizeof(SSyncHead) + 16)
#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_ROLE_TIMER 15000 // ms
#define SYNC_CHECK_INTERVAL 1000 // ms
...
...
src/sync/src/syncMain.c
浏览文件 @
64c06c95
...
...
@@ -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->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
]);
syncSendPeersStatusMsgToPeer
(
pPeer
,
1
,
SYNC_STATUS_CHECK_ROLE
,
syncGenTranId
());
break
;
...
...
@@ -1459,7 +1459,12 @@ static int32_t syncForwardToPeerImpl(SSyncNode *pNode, void *data, void *mhandle
if
((
pNode
->
quorum
>
1
||
force
)
&&
code
==
0
)
{
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
);
...
...
src/tsdb/src/tsdbMain.c
浏览文件 @
64c06c95
...
...
@@ -526,7 +526,7 @@ static void tsdbStartStream(STsdbRepo *pRepo) {
STable
*
pTable
=
pMeta
->
tables
[
i
];
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
,
tsdbGetTableSchemaImpl
(
pTable
,
false
,
false
,
-
1
));
tsdbGetTableSchemaImpl
(
pTable
,
false
,
false
,
-
1
)
,
0
);
}
}
}
...
...
@@ -619,4 +619,4 @@ int tsdbRestoreInfo(STsdbRepo *pRepo) {
tsdbDestroyReadH
(
&
readh
);
return
0
;
}
\ No newline at end of file
}
src/tsdb/src/tsdbMeta.c
浏览文件 @
64c06c95
...
...
@@ -840,7 +840,7 @@ static int tsdbAddTableToMeta(STsdbRepo *pRepo, STable *pTable, bool addIdx, boo
if
(
lock
&&
tsdbUnlockRepoMeta
(
pRepo
)
<
0
)
return
-
1
;
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
,
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
),
...
...
@@ -1322,4 +1322,4 @@ static int tsdbCheckTableTagVal(SKVRow *pKVRow, STSchema *pSchema) {
}
return
0
;
}
\ No newline at end of file
}
src/util/inc/tstoken.h
浏览文件 @
64c06c95
...
...
@@ -51,11 +51,9 @@ uint32_t tSQLGetToken(char *z, uint32_t *tokenType);
* @param str
* @param i
* @param isPrevOptr
* @param numOfIgnoreToken
* @param ignoreTokenTypes
* @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
...
...
src/vnode/src/vnodeWrite.c
浏览文件 @
64c06c95
...
...
@@ -91,13 +91,17 @@ int32_t vnodeProcessWrite(void *vparam, void *wparam, int32_t qtype, void *rpara
int32_t
syncCode
=
0
;
bool
force
=
(
pWrite
==
NULL
?
false
:
pWrite
->
pHead
.
msgType
!=
TSDB_MSG_TYPE_SUBMIT
);
syncCode
=
syncForwardToPeer
(
pVnode
->
sync
,
pHead
,
pWrite
,
qtype
,
force
);
if
(
syncCode
<
0
)
return
syncCode
;
if
(
syncCode
<
0
)
{
pHead
->
version
=
0
;
return
syncCode
;
}
// write into WAL
code
=
walWrite
(
pVnode
->
wal
,
pHead
);
if
(
code
<
0
)
{
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
);
pHead
->
version
=
0
;
return
code
;
}
...
...
tests/pytest/fulltest.sh
浏览文件 @
64c06c95
...
...
@@ -178,7 +178,7 @@ python3 ./test.py -f stable/query_after_reset.py
# perfbenchmark
python3 ./test.py
-f
perfbenchmark/bug3433.py
python3 ./test.py
-f
perfbenchmark/bug3589.py
#
python3 ./test.py -f perfbenchmark/bug3589.py
#query
...
...
tests/pytest/insert/metadataUpdate.py
浏览文件 @
64c06c95
...
...
@@ -11,13 +11,13 @@
# -*- coding: utf-8 -*-
import
sys
import
taos
from
util.log
import
tdLog
from
util.cases
import
tdCases
from
util.sql
import
tdSql
from
util.dnodes
import
tdDnodes
from
multiprocessing
import
Process
from
multiprocessing
import
Process
import
subprocess
class
TDTestCase
:
def
init
(
self
,
conn
,
logSql
):
...
...
@@ -40,27 +40,22 @@ class TDTestCase:
print
(
"alter table done"
)
def
deleteTableAndRecreate
(
self
):
self
.
host
=
"127.0.0.1"
self
.
user
=
"root"
self
.
password
=
"taosdata"
self
.
config
=
tdDnodes
.
getSimCfgPath
()
self
.
conn
=
taos
.
connect
(
host
=
self
.
host
,
user
=
self
.
user
,
password
=
self
.
password
,
config
=
self
.
config
)
self
.
cursor
=
self
.
conn
.
cursor
()
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"
)
sqlCmds
=
"use test; drop table stb;"
sqlCmds
+=
"create table if not exists stb (ts timestamp, col1 int) tags(areaid int, city nchar(20));"
for
i
in
range
(
self
.
tables
):
city
=
"beijing"
if
i
%
2
==
0
else
"shanghai"
self
.
cursor
.
execute
(
"create table tb%d using stb tags(%d, '%s')"
%
(
i
,
i
,
city
))
for
j
in
range
(
self
.
rows
):
self
.
cursor
.
execute
(
"insert into tb%d values(%d, %d)"
%
(
i
,
self
.
ts
+
j
,
j
*
100000
))
sqlCmds
+=
"create table tb%d using stb tags(%d, '%s');"
%
(
i
,
i
,
city
)
for
j
in
range
(
5
):
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
):
tdSql
.
prepare
()
...
...
@@ -100,19 +95,17 @@ class TDTestCase:
tdSql
.
query
(
"select count(*) from stb"
)
tdSql
.
checkData
(
0
,
0
,
10000
)
tdSql
.
query
(
"select count(*) from tb
1
"
)
tdSql
.
query
(
"select count(*) from tb
0
"
)
tdSql
.
checkData
(
0
,
0
,
1000
)
p
=
Process
(
target
=
self
.
deleteTableAndRecreate
,
args
=
())
p
.
start
()
p
.
join
()
p
.
terminate
()
# drop stable in subprocess
self
.
deleteTableAndRecreate
()
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
.
checkData
(
0
,
0
,
1000
)
tdSql
.
query
(
"select count(*) from tb
0
"
)
tdSql
.
checkData
(
0
,
0
,
5
)
def
stop
(
self
):
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 @@
"databases"
:
[{
"dbinfo"
:
{
"name"
:
"db"
,
"drop"
:
"
yes
"
,
"drop"
:
"
no
"
,
"replica"
:
1
,
"days"
:
10
,
"cache"
:
16
,
...
...
@@ -33,7 +33,7 @@
},
"super_tables"
:
[{
"name"
:
"stb"
,
"child_table_exists"
:
"
no
"
,
"child_table_exists"
:
"
yes
"
,
"childtable_count"
:
100
,
"childtable_prefix"
:
"stb_"
,
"auto_create_table"
:
"no"
,
...
...
tests/pytest/tools/insert-tblimit1-tboffset.json
浏览文件 @
64c06c95
...
...
@@ -15,7 +15,7 @@
"databases"
:
[{
"dbinfo"
:
{
"name"
:
"db"
,
"drop"
:
"
yes
"
,
"drop"
:
"
no
"
,
"replica"
:
1
,
"days"
:
10
,
"cache"
:
16
,
...
...
@@ -33,7 +33,7 @@
},
"super_tables"
:
[{
"name"
:
"stb"
,
"child_table_exists"
:
"
no
"
,
"child_table_exists"
:
"
yes
"
,
"childtable_count"
:
100
,
"childtable_prefix"
:
"stb_"
,
"auto_create_table"
:
"no"
,
...
...
tests/pytest/tools/taosdemo-sampledata.json
浏览文件 @
64c06c95
...
...
@@ -16,8 +16,6 @@
"name"
:
"stb"
,
"child_table_exists"
:
"no"
,
"childtable_count"
:
20
,
"childtable_limit"
:
10
,
"childtable_offset"
:
0
,
"childtable_prefix"
:
"t_"
,
"auto_create_table"
:
"no"
,
"data_source"
:
"sample"
,
...
...
tests/pytest/tools/taosdemoTestLimitOffset.py
浏览文件 @
64c06c95
...
...
@@ -51,7 +51,8 @@ class TDTestCase:
else
:
tdLog
.
info
(
"taosd found in %s"
%
buildPath
)
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
.
query
(
"select count(tbname) from db.stb"
)
...
...
@@ -59,6 +60,7 @@ class TDTestCase:
tdSql
.
query
(
"select count(*) from db.stb"
)
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
)
tdSql
.
execute
(
"reset query cache"
)
...
...
@@ -68,6 +70,7 @@ class TDTestCase:
tdSql
.
query
(
"select count(*) from db.stb"
)
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
)
tdSql
.
execute
(
"reset query cache"
)
...
...
tests/pytest/tools/taosdemoTestSampleData.py
浏览文件 @
64c06c95
...
...
@@ -57,7 +57,7 @@ class TDTestCase:
tdSql
.
query
(
"select count(tbname) from db.stb"
)
tdSql
.
checkData
(
0
,
0
,
20
)
tdSql
.
query
(
"select count(*) from db.stb"
)
tdSql
.
checkData
(
0
,
0
,
2
00
)
tdSql
.
checkData
(
0
,
0
,
4
00
)
def
stop
(
self
):
tdSql
.
close
()
...
...
tests/script/general/parser/alter.sim
浏览文件 @
64c06c95
...
...
@@ -204,7 +204,13 @@ if $data03 != NULL then
return -1
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 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)
...
...
@@ -212,6 +218,7 @@ sql select * from tb order by ts desc
if $rows != 4 then
return -1
endi
if $data03 != 3 then
return -1
endi
...
...
@@ -233,10 +240,10 @@ sql_error alter table mt add column c1 int
# drop non-existing columns
sql_error alter table mt drop column c9
sql drop database $db
sql show databases
if $rows != 0 then
return -1
endi
#
sql drop database $db
#
sql show databases
#if $rows != 0 then
#
return -1
#
endi
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
sleep 500
sql drop database if exists indb
sql create database if not exists indb
sql use indb
$inFileName = '~/data.csv'
$numOfRows = 10000
#system sh/gendata.sh $inFileName $numOfRows # input file invalid
system sh/gendata.sh ~/data.csv $numOfRows
system general/parser/gendata.sh
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
sql import into tbx file
$inFileName
sql import into tbx file
'~/data.sql'
sql select count(*) from tbx
if $rows != 1 then
return -1
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.csv
system rm -f ~/data.sql
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
return -1
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;
if $rows != 100 then
return -1
...
...
tests/tsim/inc/sim.h
浏览文件 @
64c06c95
...
...
@@ -149,6 +149,7 @@ extern int32_t simScriptSucced;
extern
int32_t
simDebugFlag
;
extern
char
tsScriptDir
[];
extern
bool
simAsyncQuery
;
extern
bool
abortExecution
;
SScript
*
simParseScript
(
char
*
fileName
);
SScript
*
simProcessCallOver
(
SScript
*
script
);
...
...
tests/tsim/src/simExe.c
浏览文件 @
64c06c95
...
...
@@ -645,8 +645,12 @@ bool simCreateRestFulConnect(SScript *script, char *user, char *pass) {
bool
simCreateNativeConnect
(
SScript
*
script
,
char
*
user
,
char
*
pass
)
{
simCloseTaosdConnect
(
script
);
void
*
taos
=
NULL
;
taosMsleep
(
2000
);
for
(
int32_t
attempt
=
0
;
attempt
<
10
;
++
attempt
)
{
if
(
abortExecution
)
{
script
->
killed
=
true
;
return
false
;
}
taos
=
taos_connect
(
NULL
,
user
,
pass
,
NULL
,
tsDnodeShellPort
);
if
(
taos
==
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) {
TAOS_RES
*
pSql
=
NULL
;
for
(
int32_t
attempt
=
0
;
attempt
<
10
;
++
attempt
)
{
if
(
abortExecution
)
{
script
->
killed
=
true
;
return
false
;
}
simLogSql
(
rest
,
false
);
pSql
=
taos_query
(
script
->
taos
,
rest
);
ret
=
taos_errno
(
pSql
);
...
...
tests/tsim/src/simMain.c
浏览文件 @
64c06c95
...
...
@@ -21,10 +21,13 @@
bool
simAsyncQuery
=
false
;
bool
simExecSuccess
=
false
;
bool
abortExecution
=
false
;
void
simHandleSignal
(
int32_t
signo
,
void
*
sigInfo
,
void
*
context
)
{
simSystemCleanUp
();
exit
(
1
);
abortExecution
=
true
;
// runningScript->killed = true;
// exit(1);
}
int32_t
main
(
int32_t
argc
,
char
*
argv
[])
{
...
...
@@ -60,6 +63,11 @@ int32_t main(int32_t argc, char *argv[]) {
return
-
1
;
}
if
(
abortExecution
)
{
simError
(
"execute abort"
);
return
-
1
;
}
simScriptList
[
++
simScriptPos
]
=
script
;
simExecuteScript
(
script
);
...
...
tests/tsim/src/simSystem.c
浏览文件 @
64c06c95
...
...
@@ -159,9 +159,17 @@ void *simExecuteScript(void *inputScript) {
script
=
simScriptList
[
simScriptPos
];
}
if
(
abortExecution
)
{
script
->
killed
=
true
;
}
if
(
script
->
killed
||
script
->
linePos
>=
script
->
numOfLines
)
{
printf
(
"killed ---------------------->
\n
"
);
script
=
simProcessCallOver
(
script
);
if
(
script
==
NULL
)
break
;
if
(
script
==
NULL
)
{
printf
(
"abort now!
\n
"
);
break
;
}
}
else
{
SCmdLine
*
line
=
&
script
->
lines
[
script
->
linePos
];
char
*
option
=
script
->
optionBuffer
+
line
->
optionOffset
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录