Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
weixin_41057677
TDengine
提交
7a82c2c6
T
TDengine
项目概览
weixin_41057677
/
TDengine
与 Fork 源项目一致
Fork自
taosdata / TDengine
通知
1
Star
0
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,体验更适合开发者的 AI 搜索 >>
提交
7a82c2c6
编写于
10月 21, 2020
作者:
S
Shengliang Guan
浏览文件
操作
浏览文件
下载
差异文件
Merge remote-tracking branch 'origin/develop' into feature/os
上级
c7d95710
58243ab3
变更
30
隐藏空白更改
内联
并排
Showing
30 changed file
with
339 addition
and
150 deletion
+339
-150
Jenkinsfile
Jenkinsfile
+16
-0
documentation20/webdocs/markdowndocs/cluster-ch.md
documentation20/webdocs/markdowndocs/cluster-ch.md
+2
-4
documentation20/webdocs/markdowndocs/taosd-ch.md
documentation20/webdocs/markdowndocs/taosd-ch.md
+1
-1
src/client/inc/tscSubquery.h
src/client/inc/tscSubquery.h
+1
-1
src/client/inc/tsclient.h
src/client/inc/tsclient.h
+6
-7
src/client/src/tscLocal.c
src/client/src/tscLocal.c
+1
-1
src/client/src/tscProfile.c
src/client/src/tscProfile.c
+3
-1
src/client/src/tscServer.c
src/client/src/tscServer.c
+1
-1
src/client/src/tscSql.c
src/client/src/tscSql.c
+13
-10
src/client/src/tscSubquery.c
src/client/src/tscSubquery.c
+3
-3
src/connector/python/linux/python2/taos/cursor.py
src/connector/python/linux/python2/taos/cursor.py
+4
-2
src/connector/python/linux/python3/taos/cursor.py
src/connector/python/linux/python3/taos/cursor.py
+4
-2
src/connector/python/windows/python2/taos/cursor.py
src/connector/python/windows/python2/taos/cursor.py
+3
-0
src/connector/python/windows/python3/taos/cursor.py
src/connector/python/windows/python3/taos/cursor.py
+3
-0
src/inc/taos.h
src/inc/taos.h
+7
-6
src/kit/shell/inc/shell.h
src/kit/shell/inc/shell.h
+2
-2
src/kit/shell/src/shellEngine.c
src/kit/shell/src/shellEngine.c
+3
-3
src/kit/shell/src/shellImport.c
src/kit/shell/src/shellImport.c
+2
-2
src/plugins/http/inc/httpInt.h
src/plugins/http/inc/httpInt.h
+3
-3
src/plugins/http/src/httpGcJson.c
src/plugins/http/src/httpGcJson.c
+1
-1
src/plugins/http/src/httpRestJson.c
src/plugins/http/src/httpRestJson.c
+2
-2
src/plugins/http/src/httpSql.c
src/plugins/http/src/httpSql.c
+0
-2
src/query/src/qExecutor.c
src/query/src/qExecutor.c
+3
-0
src/vnode/src/vnodeRead.c
src/vnode/src/vnodeRead.c
+3
-1
tests/comparisonTest/tdengine/tdengineTest.c
tests/comparisonTest/tdengine/tdengineTest.c
+31
-14
tests/examples/c/demo.c
tests/examples/c/demo.c
+15
-5
tests/pytest/concurrent_inquiry.py
tests/pytest/concurrent_inquiry.py
+78
-76
tests/pytest/fulltest.sh
tests/pytest/fulltest.sh
+2
-0
tests/pytest/insert/insertIntoTwoTables.py
tests/pytest/insert/insertIntoTwoTables.py
+53
-0
tests/pytest/query/bug1471.py
tests/pytest/query/bug1471.py
+73
-0
未找到文件。
Jenkinsfile
浏览文件 @
7a82c2c6
...
...
@@ -118,6 +118,22 @@ pipeline {
date'''
}
}
stage
(
'connector'
){
agent
{
label
"release"
}
steps
{
sh
'''
cd ${WORKSPACE}
git checkout develop
cd tests/gotest
bash batchtest.sh
cd ${WORKSPACE}/tests/examples/JDBC/JDBCDemo/
mvn clean package assembly:single >/dev/null
java -jar target/jdbcChecker-SNAPSHOT-jar-with-dependencies.jar -host 127.0.0.1
cd ${WORKSPACE}/tests/examples/python/PYTHONConnectorChecker
python3 PythonChecker.py
'''
}
}
}
}
...
...
documentation20/webdocs/markdowndocs/cluster-ch.md
浏览文件 @
7a82c2c6
...
...
@@ -213,8 +213,6 @@ SHOW MNODES;
## Arbitrator的使用
如果副本数为偶数,当一个vnode group里一半
或超过一半的vnode不工作时,是无法从中选出master的。同理,一半或超过一半的
mnode不工作时,是无法选出mnode的master的,因为存在“split brain”问题。为解决这个问题,TDengine引入了arbitrator的概念。Arbitrator模拟一个vnode或mnode在工作,但只简单的负责网络连接,不处理任何数据插入或访问。只要包含arbitrator在内,超过半数的vnode或mnode工作,那么该vnode group或mnode组就可以正常的提供数据插入或查询服务。比如对于副本数为2的情形,如果一个节点A离线,但另外一个节点B正常,而且能连接到arbitrator, 那么节点B就能正常工作。
如果副本数为偶数,当一个vnode group里一半
vnode不工作时,是无法从中选出master的。同理,一半
mnode不工作时,是无法选出mnode的master的,因为存在“split brain”问题。为解决这个问题,TDengine引入了arbitrator的概念。Arbitrator模拟一个vnode或mnode在工作,但只简单的负责网络连接,不处理任何数据插入或访问。只要包含arbitrator在内,超过半数的vnode或mnode工作,那么该vnode group或mnode组就可以正常的提供数据插入或查询服务。比如对于副本数为2的情形,如果一个节点A离线,但另外一个节点B正常,而且能连接到arbitrator, 那么节点B就能正常工作。
下载最新arbitrator及之前版本的安装包,请点击
[
安装包下载
](
https://www.taosdata.com/cn/all-downloads/
)
,在TDengine Arbitrator Linux一节中,选择适合的版本下载并安装。
TDengine Arbitrator安装包里带有一个执行程序tarbitrator, 找任何一台Linux服务器运行它即可。该程序对系统资源几乎没有要求,只需要保证有网络连接即可。该应用的命令行参数
`-p`
可以指定其对外服务的端口号,缺省是6042。配置每个taosd实例时,可以在配置文件taos.cfg里将参数arbitrator设置为arbitrator的End Point。如果该参数配置了,当副本数为偶数数,系统将自动连接配置的arbitrator。
TDengine提供一个执行程序tarbitrator, 找任何一台Linux服务器运行它即可。请点击
[
安装包下载
](
https://www.taosdata.com/cn/all-downloads/
)
,在TDengine Arbitrator Linux一节中,选择适合的版本下载并安装。该程序对系统资源几乎没有要求,只需要保证有网络连接即可。该应用的命令行参数
`-p`
可以指定其对外服务的端口号,缺省是6042。配置每个taosd实例时,可以在配置文件taos.cfg里将参数arbitrator设置为arbitrator的End Point。如果该参数配置了,当副本数为偶数数,系统将自动连接配置的arbitrator。如果副本数为奇数,即使配置了arbitrator, 系统也不会去建立连接。
documentation20/webdocs/markdowndocs/taosd-ch.md
浏览文件 @
7a82c2c6
...
...
@@ -61,7 +61,7 @@ vnode与其子模块是通过API直接调用,而不是通过消息队列传递
mnode是整个系统的大脑,负责整个系统的资源调度,负责meta data的管理与存储。
一个运行的系统里,只有一个mnode,但它有多个副本(由系统配置参数numOfM
peer
s控制)。这些副本分布在不同的dnode里,目的是保证系统的高可靠运行。副本之间的数据复制是采用同步而非异步的方式,以确保数据的一致性,确保数据不会丢失。这些副本会自动选举一个Master,其他副本是slave。所有数据更新类的操作,都只能在master上进行,而查询类的可以在slave节点上进行。代码实现上,同步模块与vnode共享,但mnode被分配一个特殊的vgroup ID: 1,而且quorum大于1。整个集群系统是由多个dnode组成的,运行的mnode的副本数不可能超过dnode的个数,但不会超过配置的副本数。如果某个mnode副本宕机一段时间,只要超过半数的mnode副本仍在运行,运行的mnode会自动根据整个系统的资源情况,在其他dnode里再启动一个mnode, 以保证运行的副本数。
一个运行的系统里,只有一个mnode,但它有多个副本(由系统配置参数numOfM
node
s控制)。这些副本分布在不同的dnode里,目的是保证系统的高可靠运行。副本之间的数据复制是采用同步而非异步的方式,以确保数据的一致性,确保数据不会丢失。这些副本会自动选举一个Master,其他副本是slave。所有数据更新类的操作,都只能在master上进行,而查询类的可以在slave节点上进行。代码实现上,同步模块与vnode共享,但mnode被分配一个特殊的vgroup ID: 1,而且quorum大于1。整个集群系统是由多个dnode组成的,运行的mnode的副本数不可能超过dnode的个数,但不会超过配置的副本数。如果某个mnode副本宕机一段时间,只要超过半数的mnode副本仍在运行,运行的mnode会自动根据整个系统的资源情况,在其他dnode里再启动一个mnode, 以保证运行的副本数。
各个dnode通过信息交换,保存有mnode各个副本的End Point列表,并向其中的master节点定时(间隔由系统配置参数statusInterval控制)发送status消息,消息体里包含该dnode的CPU、内存、剩余存储空间、vnode个数,以及各个vnode的状态(存储空间、原始数据大小、记录条数、角色等)。这样mnode就了解整个系统的资源情况,如果用户创建新的表,就可以决定需要在哪个dnode创建;如果增加或删除dnode, 或者监测到某dnode数据过热、或离线太长,就可以决定需要挪动那些vnode,以实现负载均衡。
...
...
src/client/inc/tscSubquery.h
浏览文件 @
7a82c2c6
...
...
@@ -39,7 +39,7 @@ int32_t tscHandleMultivnodeInsert(SSqlObj *pSql);
int32_t
tscHandleInsertRetry
(
SSqlObj
*
pSql
);
void
tscBuildResFromSubqueries
(
SSqlObj
*
pSql
);
void
**
doSetResultRowData
(
SSqlObj
*
pSql
,
bool
finalResult
);
TAOS_ROW
doSetResultRowData
(
SSqlObj
*
pSql
,
bool
finalResult
);
#ifdef __cplusplus
}
...
...
src/client/inc/tsclient.h
浏览文件 @
7a82c2c6
...
...
@@ -308,7 +308,7 @@ typedef struct {
int32_t
numOfGroups
;
SResRec
*
pGroupRec
;
char
*
data
;
void
**
tsrow
;
TAOS_ROW
tsrow
;
int32_t
*
length
;
// length for each field for current row
char
**
buffer
;
// Buffer used to put multibytes encoded using unicode (wchar_t)
SColumnIndex
*
pColumnIndex
;
...
...
@@ -448,9 +448,8 @@ void tscCloseTscObj(STscObj *pObj);
// todo move to taos? or create a new file: taos_internal.h
TAOS
*
taos_connect_a
(
char
*
ip
,
char
*
user
,
char
*
pass
,
char
*
db
,
uint16_t
port
,
void
(
*
fp
)(
void
*
,
TAOS_RES
*
,
int
),
void
*
param
,
void
**
taos
);
void
*
param
,
TAOS
**
taos
);
TAOS_RES
*
taos_query_h
(
TAOS
*
taos
,
const
char
*
sqlstr
,
TAOS_RES
**
res
);
void
waitForQueryRsp
(
void
*
param
,
TAOS_RES
*
tres
,
int
code
);
void
doAsyncQuery
(
STscObj
*
pObj
,
SSqlObj
*
pSql
,
__async_cb_func_t
fp
,
void
*
param
,
const
char
*
sqlstr
,
size_t
sqlLen
);
...
...
@@ -481,11 +480,11 @@ static FORCE_INLINE void tscGetResultColumnChr(SSqlRes* pRes, SFieldInfo* pField
if
(
type
==
TSDB_DATA_TYPE_NCHAR
||
type
==
TSDB_DATA_TYPE_BINARY
)
{
pData
=
pInfo
->
pSqlExpr
->
param
[
1
].
pz
;
pRes
->
length
[
columnIndex
]
=
pInfo
->
pSqlExpr
->
param
[
1
].
nLen
;
pRes
->
tsrow
[
columnIndex
]
=
(
pInfo
->
pSqlExpr
->
param
[
1
].
nType
==
TSDB_DATA_TYPE_NULL
)
?
NULL
:
pData
;
pRes
->
tsrow
[
columnIndex
]
=
(
pInfo
->
pSqlExpr
->
param
[
1
].
nType
==
TSDB_DATA_TYPE_NULL
)
?
NULL
:
(
unsigned
char
*
)
pData
;
}
else
{
assert
(
bytes
==
tDataTypeDesc
[
type
].
nSize
);
pRes
->
tsrow
[
columnIndex
]
=
isNull
(
pData
,
type
)
?
NULL
:
&
pInfo
->
pSqlExpr
->
param
[
1
].
i64Key
;
pRes
->
tsrow
[
columnIndex
]
=
isNull
(
pData
,
type
)
?
NULL
:
(
unsigned
char
*
)
&
pInfo
->
pSqlExpr
->
param
[
1
].
i64Key
;
pRes
->
length
[
columnIndex
]
=
bytes
;
}
}
else
{
...
...
@@ -493,7 +492,7 @@ static FORCE_INLINE void tscGetResultColumnChr(SSqlRes* pRes, SFieldInfo* pField
int32_t
realLen
=
varDataLen
(
pData
);
assert
(
realLen
<=
bytes
-
VARSTR_HEADER_SIZE
);
pRes
->
tsrow
[
columnIndex
]
=
(
isNull
(
pData
,
type
))
?
NULL
:
((
tstr
*
)
pData
)
->
data
;
pRes
->
tsrow
[
columnIndex
]
=
(
isNull
(
pData
,
type
))
?
NULL
:
(
unsigned
char
*
)(
(
tstr
*
)
pData
)
->
data
;
if
(
realLen
<
pInfo
->
pSqlExpr
->
resBytes
-
VARSTR_HEADER_SIZE
)
{
// todo refactor
*
(
pData
+
realLen
+
VARSTR_HEADER_SIZE
)
=
0
;
}
...
...
@@ -502,7 +501,7 @@ static FORCE_INLINE void tscGetResultColumnChr(SSqlRes* pRes, SFieldInfo* pField
}
else
{
assert
(
bytes
==
tDataTypeDesc
[
type
].
nSize
);
pRes
->
tsrow
[
columnIndex
]
=
isNull
(
pData
,
type
)
?
NULL
:
pData
;
pRes
->
tsrow
[
columnIndex
]
=
isNull
(
pData
,
type
)
?
NULL
:
(
unsigned
char
*
)
pData
;
pRes
->
length
[
columnIndex
]
=
bytes
;
}
}
...
...
src/client/src/tscLocal.c
浏览文件 @
7a82c2c6
...
...
@@ -296,7 +296,7 @@ static int32_t tscProcessDescribeTable(SSqlObj *pSql) {
return
tscSetValueToResObj
(
pSql
,
rowLen
);
}
static
int32_t
tscGetNthFieldResult
(
TAOS_ROW
row
,
TAOS_FIELD
*
fields
,
int
*
lengths
,
int
idx
,
char
*
result
)
{
const
char
*
val
=
row
[
idx
];
const
char
*
val
=
(
const
char
*
)
row
[
idx
];
if
(
val
==
NULL
)
{
sprintf
(
result
,
"%s"
,
TSDB_DATA_NULL_STR
);
return
-
1
;
...
...
src/client/src/tscProfile.c
浏览文件 @
7a82c2c6
...
...
@@ -20,8 +20,10 @@
#include "tutil.h"
#include "taosmsg.h"
#include "taos.h"
void
tscSaveSlowQueryFp
(
void
*
handle
,
void
*
tmrId
);
void
*
tscSlowQueryConn
=
NULL
;
TAOS
*
tscSlowQueryConn
=
NULL
;
bool
tscSlowQueryConnInitialized
=
false
;
void
tscInitConnCb
(
void
*
param
,
TAOS_RES
*
result
,
int
code
)
{
...
...
src/client/src/tscServer.c
浏览文件 @
7a82c2c6
...
...
@@ -1366,7 +1366,7 @@ static int tscSetResultPointer(SQueryInfo *pQueryInfo, SSqlRes *pRes) {
for
(
int
i
=
0
;
i
<
pQueryInfo
->
fieldsInfo
.
numOfOutput
;
++
i
)
{
int16_t
offset
=
tscFieldInfoGetOffset
(
pQueryInfo
,
i
);
pRes
->
tsrow
[
i
]
=
((
char
*
)
pRes
->
data
+
offset
*
pRes
->
numOfRows
);
pRes
->
tsrow
[
i
]
=
(
unsigned
char
*
)(
(
char
*
)
pRes
->
data
+
offset
*
pRes
->
numOfRows
);
}
return
0
;
...
...
src/client/src/tscSql.c
浏览文件 @
7a82c2c6
...
...
@@ -51,8 +51,8 @@ static bool validPassword(const char* passwd) {
return
validImpl
(
passwd
,
TSDB_PASSWORD_LEN
-
1
);
}
SSqlObj
*
taosConnectImpl
(
const
char
*
ip
,
const
char
*
user
,
const
char
*
pass
,
const
char
*
auth
,
const
char
*
db
,
uint16_t
port
,
void
(
*
fp
)(
void
*
,
TAOS_RES
*
,
int
),
void
*
param
,
void
**
taos
)
{
static
SSqlObj
*
taosConnectImpl
(
const
char
*
ip
,
const
char
*
user
,
const
char
*
pass
,
const
char
*
auth
,
const
char
*
db
,
uint16_t
port
,
void
(
*
fp
)(
void
*
,
TAOS_RES
*
,
int
),
void
*
param
,
TAOS
**
taos
)
{
taos_init
();
if
(
!
validUserName
(
user
))
{
...
...
@@ -174,7 +174,7 @@ static void syncConnCallback(void *param, TAOS_RES *tres, int code) {
TAOS
*
taos_connect_internal
(
const
char
*
ip
,
const
char
*
user
,
const
char
*
pass
,
const
char
*
auth
,
const
char
*
db
,
uint16_t
port
)
{
STscObj
*
pObj
=
NULL
;
SSqlObj
*
pSql
=
taosConnectImpl
(
ip
,
user
,
pass
,
auth
,
db
,
port
,
syncConnCallback
,
NULL
,
(
void
**
)
&
pObj
);
SSqlObj
*
pSql
=
taosConnectImpl
(
ip
,
user
,
pass
,
auth
,
db
,
port
,
syncConnCallback
,
NULL
,
&
pObj
);
if
(
pSql
!=
NULL
)
{
pSql
->
fp
=
syncConnCallback
;
pSql
->
param
=
pSql
;
...
...
@@ -243,16 +243,19 @@ static void asyncConnCallback(void *param, TAOS_RES *tres, int code) {
}
TAOS
*
taos_connect_a
(
char
*
ip
,
char
*
user
,
char
*
pass
,
char
*
db
,
uint16_t
port
,
void
(
*
fp
)(
void
*
,
TAOS_RES
*
,
int
),
void
*
param
,
void
**
taos
)
{
SSqlObj
*
pSql
=
taosConnectImpl
(
ip
,
user
,
pass
,
NULL
,
db
,
port
,
asyncConnCallback
,
param
,
taos
);
void
*
param
,
TAOS
**
taos
)
{
STscObj
*
pObj
=
NULL
;
SSqlObj
*
pSql
=
taosConnectImpl
(
ip
,
user
,
pass
,
NULL
,
db
,
port
,
asyncConnCallback
,
param
,
&
pObj
);
if
(
pSql
==
NULL
)
{
return
NULL
;
}
if
(
taos
)
*
taos
=
pObj
;
pSql
->
fetchFp
=
fp
;
pSql
->
res
.
code
=
tscProcessSql
(
pSql
);
tscDebug
(
"%p DB async connection is opening"
,
taos
);
return
taos
;
return
pObj
;
}
void
taos_close
(
TAOS
*
taos
)
{
...
...
@@ -881,7 +884,7 @@ int taos_validate_sql(TAOS *taos, const char *sql) {
if
(
pSql
->
sqlstr
==
NULL
)
{
pRes
->
code
=
TSDB_CODE_TSC_OUT_OF_MEMORY
;
tscError
(
"%p failed to malloc sql string buffer"
,
pSql
);
tscDebug
(
"%p Valid SQL result:%d, %s pObj:%p"
,
pSql
,
pRes
->
code
,
taos_errstr
(
taos
),
pObj
);
tscDebug
(
"%p Valid SQL result:%d, %s pObj:%p"
,
pSql
,
pRes
->
code
,
taos_errstr
(
pSql
),
pObj
);
taosTFree
(
pSql
);
return
pRes
->
code
;
}
...
...
@@ -906,7 +909,7 @@ int taos_validate_sql(TAOS *taos, const char *sql) {
}
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
tscDebug
(
"%p Valid SQL result:%d, %s pObj:%p"
,
pSql
,
code
,
taos_errstr
(
taos
),
pObj
);
tscDebug
(
"%p Valid SQL result:%d, %s pObj:%p"
,
pSql
,
code
,
taos_errstr
(
pSql
),
pObj
);
}
taos_free_result
(
pSql
);
...
...
@@ -1050,7 +1053,7 @@ int taos_load_table_info(TAOS *taos, const char *tableNameList) {
tscDoQuery
(
pSql
);
tscDebug
(
"%p load multi table meta result:%d %s pObj:%p"
,
pSql
,
pRes
->
code
,
taos_errstr
(
taos
),
pObj
);
tscDebug
(
"%p load multi table meta result:%d %s pObj:%p"
,
pSql
,
pRes
->
code
,
taos_errstr
(
pSql
),
pObj
);
if
((
code
=
pRes
->
code
)
!=
TSDB_CODE_SUCCESS
)
{
tscFreeSqlObj
(
pSql
);
}
...
...
src/client/src/tscSubquery.c
浏览文件 @
7a82c2c6
...
...
@@ -2130,7 +2130,7 @@ static void transferNcharData(SSqlObj *pSql, int32_t columnIndex, TAOS_FIELD *pF
int32_t
length
=
taosUcs4ToMbs
(
pRes
->
tsrow
[
columnIndex
],
pRes
->
length
[
columnIndex
],
pRes
->
buffer
[
columnIndex
]);
if
(
length
>=
0
)
{
pRes
->
tsrow
[
columnIndex
]
=
pRes
->
buffer
[
columnIndex
];
pRes
->
tsrow
[
columnIndex
]
=
(
unsigned
char
*
)
pRes
->
buffer
[
columnIndex
];
pRes
->
length
[
columnIndex
]
=
length
;
}
else
{
tscError
(
"%p charset:%s to %s. val:%s convert failed."
,
pSql
,
DEFAULT_UNICODE_ENCODEC
,
tsCharset
,
(
char
*
)
pRes
->
tsrow
[
columnIndex
]);
...
...
@@ -2158,7 +2158,7 @@ static char *getArithemicInputSrc(void *param, const char *name, int32_t colId)
return
pSupport
->
data
[
index
]
+
pSupport
->
offset
*
pExpr
->
resBytes
;
}
void
**
doSetResultRowData
(
SSqlObj
*
pSql
,
bool
finalResult
)
{
TAOS_ROW
doSetResultRowData
(
SSqlObj
*
pSql
,
bool
finalResult
)
{
SSqlCmd
*
pCmd
=
&
pSql
->
cmd
;
SSqlRes
*
pRes
=
&
pSql
->
res
;
...
...
@@ -2211,7 +2211,7 @@ void **doSetResultRowData(SSqlObj *pSql, bool finalResult) {
tExprTreeCalcTraverse
(
pRes
->
pArithSup
->
pArithExpr
->
pExpr
,
1
,
pRes
->
buffer
[
i
],
pRes
->
pArithSup
,
TSDB_ORDER_ASC
,
getArithemicInputSrc
);
pRes
->
tsrow
[
i
]
=
pRes
->
buffer
[
i
];
pRes
->
tsrow
[
i
]
=
(
unsigned
char
*
)
pRes
->
buffer
[
i
];
}
}
...
...
src/connector/python/linux/python2/taos/cursor.py
浏览文件 @
7a82c2c6
...
...
@@ -192,8 +192,10 @@ class TDengineCursor(object):
buffer
=
[[]
for
i
in
range
(
len
(
self
.
_fields
))]
self
.
_rowcount
=
0
while
True
:
block
,
num_of_fields
=
CTaosInterface
.
fetchBlock
(
self
.
_result
,
self
.
_fields
)
block
,
num_of_fields
=
CTaosInterface
.
fetchBlock
(
self
.
_result
,
self
.
_fields
)
errno
=
CTaosInterface
.
libtaos
.
taos_errno
(
self
.
_result
)
if
errno
!=
0
:
raise
ProgrammingError
(
CTaosInterface
.
errStr
(
self
.
_result
),
errno
)
if
num_of_fields
==
0
:
break
self
.
_rowcount
+=
num_of_fields
...
...
src/connector/python/linux/python3/taos/cursor.py
浏览文件 @
7a82c2c6
...
...
@@ -207,8 +207,10 @@ class TDengineCursor(object):
buffer
=
[[]
for
i
in
range
(
len
(
self
.
_fields
))]
self
.
_rowcount
=
0
while
True
:
block
,
num_of_fields
=
CTaosInterface
.
fetchBlock
(
self
.
_result
,
self
.
_fields
)
block
,
num_of_fields
=
CTaosInterface
.
fetchBlock
(
self
.
_result
,
self
.
_fields
)
errno
=
CTaosInterface
.
libtaos
.
taos_errno
(
self
.
_result
)
if
errno
!=
0
:
raise
ProgrammingError
(
CTaosInterface
.
errStr
(
self
.
_result
),
errno
)
if
num_of_fields
==
0
:
break
self
.
_rowcount
+=
num_of_fields
...
...
src/connector/python/windows/python2/taos/cursor.py
浏览文件 @
7a82c2c6
...
...
@@ -142,6 +142,9 @@ class TDengineCursor(object):
self
.
_rowcount
=
0
while
True
:
block
,
num_of_fields
=
CTaosInterface
.
fetchBlock
(
self
.
_result
,
self
.
_fields
)
errno
=
CTaosInterface
.
libtaos
.
taos_errno
(
self
.
_result
)
if
errno
!=
0
:
raise
ProgrammingError
(
CTaosInterface
.
errStr
(
self
.
_result
),
errno
)
if
num_of_fields
==
0
:
break
self
.
_rowcount
+=
num_of_fields
for
i
in
range
(
len
(
self
.
_fields
)):
...
...
src/connector/python/windows/python3/taos/cursor.py
浏览文件 @
7a82c2c6
...
...
@@ -142,6 +142,9 @@ class TDengineCursor(object):
self
.
_rowcount
=
0
while
True
:
block
,
num_of_fields
=
CTaosInterface
.
fetchBlock
(
self
.
_result
,
self
.
_fields
)
errno
=
CTaosInterface
.
libtaos
.
taos_errno
(
self
.
_result
)
if
errno
!=
0
:
raise
ProgrammingError
(
CTaosInterface
.
errStr
(
self
.
_result
),
errno
)
if
num_of_fields
==
0
:
break
self
.
_rowcount
+=
num_of_fields
for
i
in
range
(
len
(
self
.
_fields
)):
...
...
src/inc/taos.h
浏览文件 @
7a82c2c6
...
...
@@ -22,12 +22,13 @@
extern
"C"
{
#endif
typedef
void
TAOS
;
typedef
void
**
TAOS_ROW
;
typedef
void
TAOS_RES
;
typedef
void
TAOS_SUB
;
typedef
void
TAOS_STREAM
;
typedef
void
TAOS_STMT
;
typedef
struct
STscObj
TAOS
;
typedef
struct
STscStmt
TAOS_STMT
;
typedef
struct
SSqlObj
TAOS_RES
;
typedef
struct
SSqlStream
TAOS_STREAM
;
typedef
struct
SSub
TAOS_SUB
;
typedef
unsigned
char
**
TAOS_ROW
;
// Data type definition
#define TSDB_DATA_TYPE_NULL 0 // 1 bytes
...
...
src/kit/shell/inc/shell.h
浏览文件 @
7a82c2c6
...
...
@@ -60,7 +60,7 @@ typedef struct SShellArguments {
extern
void
shellParseArgument
(
int
argc
,
char
*
argv
[],
SShellArguments
*
arguments
);
extern
TAOS
*
shellInit
(
SShellArguments
*
args
);
extern
void
*
shellLoopQuery
(
void
*
arg
);
extern
void
taos_error
(
TAOS
*
con
);
extern
void
taos_error
(
TAOS
_RES
*
tres
);
extern
int
regex_match
(
const
char
*
s
,
const
char
*
reg
,
int
cflags
);
void
shellReadCommand
(
TAOS
*
con
,
char
command
[]);
int32_t
shellRunCommand
(
TAOS
*
con
,
char
*
command
);
...
...
@@ -72,7 +72,7 @@ void source_dir(TAOS* con, SShellArguments* args);
void
get_history_path
(
char
*
history
);
void
cleanup_handler
(
void
*
arg
);
void
exitShell
();
int
shellDumpResult
(
TAOS
*
con
,
char
*
fname
,
int
*
error_no
,
bool
printMode
);
int
shellDumpResult
(
TAOS
_RES
*
con
,
char
*
fname
,
int
*
error_no
,
bool
printMode
);
void
shellGetGrantInfo
(
void
*
con
);
int
isCommentLine
(
char
*
line
);
...
...
src/kit/shell/src/shellEngine.c
浏览文件 @
7a82c2c6
...
...
@@ -493,7 +493,7 @@ static int dumpResultToFile(const char* fname, TAOS_RES* tres) {
if
(
i
>
0
)
{
fputc
(
','
,
fp
);
}
dumpFieldToFile
(
fp
,
row
[
i
],
fields
+
i
,
length
[
i
],
precision
);
dumpFieldToFile
(
fp
,
(
const
char
*
)
row
[
i
],
fields
+
i
,
length
[
i
],
precision
);
}
fputc
(
'\n'
,
fp
);
...
...
@@ -619,7 +619,7 @@ static int verticalPrintResult(TAOS_RES* tres) {
int
padding
=
(
int
)(
maxColNameLen
-
strlen
(
field
->
name
));
printf
(
"%*.s%s: "
,
padding
,
" "
,
field
->
name
);
printField
(
row
[
i
],
field
,
0
,
length
[
i
],
precision
);
printField
(
(
const
char
*
)
row
[
i
],
field
,
0
,
length
[
i
],
precision
);
putchar
(
'\n'
);
}
...
...
@@ -720,7 +720,7 @@ static int horizontalPrintResult(TAOS_RES* tres) {
int32_t
*
length
=
taos_fetch_lengths
(
tres
);
for
(
int
i
=
0
;
i
<
num_fields
;
i
++
)
{
putchar
(
' '
);
printField
(
row
[
i
],
fields
+
i
,
width
[
i
],
length
[
i
],
precision
);
printField
(
(
const
char
*
)
row
[
i
],
fields
+
i
,
width
[
i
],
length
[
i
],
precision
);
putchar
(
' '
);
putchar
(
'|'
);
}
...
...
src/kit/shell/src/shellImport.c
浏览文件 @
7a82c2c6
...
...
@@ -204,7 +204,7 @@ static void shellSourceFile(TAOS *con, char *fptr) {
int32_t
code
=
taos_errno
(
pSql
);
if
(
code
!=
0
)
{
fprintf
(
stderr
,
"DB error: %s: %s (%d)
\n
"
,
taos_errstr
(
con
),
fname
,
lineNo
);
fprintf
(
stderr
,
"DB error: %s: %s (%d)
\n
"
,
taos_errstr
(
pSql
),
fname
,
lineNo
);
}
/* free local resouce: allocated memory/metric-meta refcnt */
...
...
@@ -243,7 +243,7 @@ static void shellRunImportThreads(SShellArguments* args)
pThread
->
totalThreads
=
args
->
threadNum
;
pThread
->
taos
=
taos_connect
(
args
->
host
,
args
->
user
,
args
->
password
,
args
->
database
,
tsDnodeShellPort
);
if
(
pThread
->
taos
==
NULL
)
{
fprintf
(
stderr
,
"ERROR: thread:%d failed connect to TDengine, error:%s
\n
"
,
pThread
->
threadIndex
,
taos_errstr
(
pThread
->
taos
)
);
fprintf
(
stderr
,
"ERROR: thread:%d failed connect to TDengine, error:%s
\n
"
,
pThread
->
threadIndex
,
"null taos"
/*taos_errstr(pThread->taos)*/
);
exit
(
0
);
}
...
...
src/plugins/http/inc/httpInt.h
浏览文件 @
7a82c2c6
...
...
@@ -122,9 +122,9 @@ typedef struct {
}
HttpDecodeMethod
;
typedef
struct
{
void
(
*
startJsonFp
)(
struct
HttpContext
*
pContext
,
HttpSqlCmd
*
cmd
,
void
*
result
);
void
(
*
startJsonFp
)(
struct
HttpContext
*
pContext
,
HttpSqlCmd
*
cmd
,
TAOS_RES
*
result
);
void
(
*
stopJsonFp
)(
struct
HttpContext
*
pContext
,
HttpSqlCmd
*
cmd
);
bool
(
*
buildQueryJsonFp
)(
struct
HttpContext
*
pContext
,
HttpSqlCmd
*
cmd
,
void
*
result
,
int
numOfRows
);
bool
(
*
buildQueryJsonFp
)(
struct
HttpContext
*
pContext
,
HttpSqlCmd
*
cmd
,
TAOS_RES
*
result
,
int
numOfRows
);
void
(
*
buildAffectRowJsonFp
)(
struct
HttpContext
*
pContext
,
HttpSqlCmd
*
cmd
,
int
affectRows
);
void
(
*
initJsonFp
)(
struct
HttpContext
*
pContext
);
void
(
*
cleanJsonFp
)(
struct
HttpContext
*
pContext
);
...
...
@@ -148,7 +148,7 @@ typedef struct HttpContext {
char
ipstr
[
22
];
char
user
[
TSDB_USER_LEN
];
// parsed from auth token or login message
char
pass
[
TSDB_PASSWORD_LEN
];
void
*
taos
;
TAOS
*
taos
;
void
*
ppContext
;
HttpSession
*
session
;
z_stream
gzipStream
;
...
...
src/plugins/http/src/httpGcJson.c
浏览文件 @
7a82c2c6
...
...
@@ -217,7 +217,7 @@ bool gcBuildQueryJson(HttpContext *pContext, HttpSqlCmd *cmd, TAOS_RES *result,
break
;
case
TSDB_DATA_TYPE_BINARY
:
case
TSDB_DATA_TYPE_NCHAR
:
httpJsonStringForTransMean
(
jsonBuf
,
row
[
i
],
fields
[
i
].
bytes
);
httpJsonStringForTransMean
(
jsonBuf
,
(
char
*
)
row
[
i
],
fields
[
i
].
bytes
);
break
;
case
TSDB_DATA_TYPE_TIMESTAMP
:
if
(
precision
==
TSDB_TIME_PRECISION_MILLI
)
{
//ms
...
...
src/plugins/http/src/httpRestJson.c
浏览文件 @
7a82c2c6
...
...
@@ -131,7 +131,7 @@ bool restBuildSqlJson(HttpContext *pContext, HttpSqlCmd *cmd, TAOS_RES *result,
break
;
case
TSDB_DATA_TYPE_BINARY
:
case
TSDB_DATA_TYPE_NCHAR
:
httpJsonStringForTransMean
(
jsonBuf
,
row
[
i
],
length
[
i
]);
httpJsonStringForTransMean
(
jsonBuf
,
(
char
*
)
row
[
i
],
length
[
i
]);
break
;
case
TSDB_DATA_TYPE_TIMESTAMP
:
if
(
timestampFormat
==
REST_TIMESTAMP_FMT_LOCAL_STRING
)
{
...
...
@@ -195,4 +195,4 @@ void restStopSqlJson(HttpContext *pContext, HttpSqlCmd *cmd) {
httpJsonToken
(
jsonBuf
,
JsonObjEnd
);
httpWriteJsonBufEnd
(
jsonBuf
);
}
\ No newline at end of file
}
src/plugins/http/src/httpSql.c
浏览文件 @
7a82c2c6
...
...
@@ -27,8 +27,6 @@
#include "httpSession.h"
#include "httpQueue.h"
void
*
taos_connect_a
(
char
*
ip
,
char
*
user
,
char
*
pass
,
char
*
db
,
uint16_t
port
,
void
(
*
fp
)(
void
*
,
TAOS_RES
*
,
int
),
void
*
param
,
void
**
taos
);
void
httpProcessMultiSql
(
HttpContext
*
pContext
);
void
httpProcessMultiSqlRetrieveCallBack
(
void
*
param
,
TAOS_RES
*
result
,
int
numOfRows
);
...
...
src/query/src/qExecutor.c
浏览文件 @
7a82c2c6
...
...
@@ -7101,6 +7101,7 @@ void qCleanupQueryMgmt(void* pQMgmt) {
void
**
qRegisterQInfo
(
void
*
pMgmt
,
uint64_t
qInfo
)
{
if
(
pMgmt
==
NULL
)
{
terrno
=
TSDB_CODE_VND_INVALID_VGROUP_ID
;
return
NULL
;
}
...
...
@@ -7109,6 +7110,7 @@ void** qRegisterQInfo(void* pMgmt, uint64_t qInfo) {
SQueryMgmt
*
pQueryMgmt
=
pMgmt
;
if
(
pQueryMgmt
->
qinfoPool
==
NULL
)
{
qError
(
"QInfo:%p failed to add qhandle into qMgmt, since qMgmt is closed"
,
(
void
*
)
qInfo
);
terrno
=
TSDB_CODE_VND_INVALID_VGROUP_ID
;
return
NULL
;
}
...
...
@@ -7116,6 +7118,7 @@ void** qRegisterQInfo(void* pMgmt, uint64_t qInfo) {
if
(
pQueryMgmt
->
closed
)
{
// pthread_mutex_unlock(&pQueryMgmt->lock);
qError
(
"QInfo:%p failed to add qhandle into cache, since qMgmt is colsing"
,
(
void
*
)
qInfo
);
terrno
=
TSDB_CODE_VND_INVALID_VGROUP_ID
;
return
NULL
;
}
else
{
TSDB_CACHE_PTR_TYPE
handleVal
=
(
TSDB_CACHE_PTR_TYPE
)
qInfo
;
...
...
src/vnode/src/vnodeRead.c
浏览文件 @
7a82c2c6
...
...
@@ -187,10 +187,12 @@ static int32_t vnodeProcessQueryMsg(SVnodeObj *pVnode, SReadMsg *pReadMsg) {
if
(
code
==
TSDB_CODE_SUCCESS
)
{
handle
=
qRegisterQInfo
(
pVnode
->
qMgmt
,
(
uint64_t
)
pQInfo
);
if
(
handle
==
NULL
)
{
// failed to register qhandle, todo add error test case
pRsp
->
code
=
terrno
;
terrno
=
0
;
vError
(
"vgId:%d QInfo:%p register qhandle failed, return to app, code:%s"
,
pVnode
->
vgId
,
(
void
*
)
pQInfo
,
tstrerror
(
pRsp
->
code
));
pRsp
->
code
=
TSDB_CODE_QRY_INVALID_QHANDLE
;
qDestroyQueryInfo
(
pQInfo
);
// destroy it directly
return
pRsp
->
code
;
}
else
{
assert
(
*
handle
==
pQInfo
);
pRsp
->
qhandle
=
htobe64
((
uint64_t
)
pQInfo
);
...
...
tests/comparisonTest/tdengine/tdengineTest.c
浏览文件 @
7a82c2c6
...
...
@@ -108,9 +108,9 @@ void parseArg(int argc, char *argv[]) {
}
}
void
taos_error
(
TAOS
*
co
n
)
{
printf
(
"TDengine error: %s
\n
"
,
t
aos_errstr
(
con
)
);
taos_close
(
con
);
static
void
taos_error
(
TAOS_RES
*
tres
,
TAOS
*
con
n
)
{
printf
(
"TDengine error: %s
\n
"
,
t
res
?
taos_errstr
(
tres
)
:
"null result"
);
taos_close
(
con
n
);
exit
(
1
);
}
...
...
@@ -125,13 +125,17 @@ void writeDataImp(void *param) {
printf
(
"Thread %d, writing sID %d, eID %d
\n
"
,
pThread
->
threadId
,
pThread
->
sID
,
pThread
->
eID
);
void
*
taos
=
taos_connect
(
"127.0.0.1"
,
"root"
,
"taosdata"
,
NULL
,
0
);
if
(
taos
==
NULL
)
taos_error
(
taos
);
if
(
taos
==
NULL
)
{
// where to find errstr?
// taos_error(NULL, taos);
printf
(
"TDengine error: %s
\n
"
,
"failed to connect"
);
exit
(
1
);
}
TAOS_RES
*
result
=
taos_query
(
taos
,
"use db"
);
int32_t
code
=
taos_errno
(
result
);
if
(
code
!=
0
)
{
taos_error
(
taos
);
taos_error
(
result
,
taos
);
}
taos_free_result
(
result
);
...
...
@@ -227,12 +231,17 @@ void writeData() {
taos_init
();
void
*
taos
=
taos_connect
(
"127.0.0.1"
,
"root"
,
"taosdata"
,
NULL
,
0
);
if
(
taos
==
NULL
)
taos_error
(
taos
);
if
(
taos
==
NULL
)
{
// where to find errstr?
// taos_error(NULL, taos);
printf
(
"TDengine error: %s
\n
"
,
"failed to connect"
);
exit
(
1
);
}
TAOS_RES
*
result
=
taos_query
(
taos
,
"create database if not exists db"
);
int32_t
code
=
taos_errno
(
result
);
if
(
code
!=
0
)
{
taos_error
(
taos
);
taos_error
(
result
,
taos
);
}
taos_free_result
(
result
);
...
...
@@ -241,7 +250,7 @@ void writeData() {
"tags(devid int, devname binary(16), devgroup int)"
);
code
=
taos_errno
(
result
);
if
(
code
!=
0
)
{
taos_error
(
taos
);
taos_error
(
result
,
taos
);
}
taos_free_result
(
result
);
...
...
@@ -293,8 +302,12 @@ void readDataImp(void *param)
printf
(
"open file %s success
\n
"
,
arguments
.
sql
);
void
*
taos
=
taos_connect
(
"127.0.0.1"
,
"root"
,
"taosdata"
,
NULL
,
0
);
if
(
taos
==
NULL
)
taos_error
(
taos
);
if
(
taos
==
NULL
)
{
// where to find errstr?
// taos_error(NULL, taos);
printf
(
"TDengine error: %s
\n
"
,
"failed to connect"
);
exit
(
1
);
}
char
*
line
=
NULL
;
size_t
len
=
0
;
...
...
@@ -313,7 +326,7 @@ void readDataImp(void *param)
TAOS_RES
*
result
=
taos_query
(
taos
,
line
);
int32_t
code
=
taos_errno
(
result
);
if
(
code
!=
0
)
{
taos_error
(
taos
);
taos_error
(
result
,
taos
);
}
TAOS_ROW
row
;
...
...
@@ -343,8 +356,12 @@ void readData() {
printf
(
"---- clients: %d
\n
"
,
arguments
.
clients
);
void
*
taos
=
taos_connect
(
"127.0.0.1"
,
"root"
,
"taosdata"
,
NULL
,
0
);
if
(
taos
==
NULL
)
taos_error
(
taos
);
if
(
taos
==
NULL
)
{
// where to find errstr?
// taos_error(NULL, taos);
printf
(
"TDengine error: %s
\n
"
,
"failed to connect"
);
exit
(
1
);
}
ThreadObj
*
threads
=
calloc
((
size_t
)
arguments
.
clients
,
sizeof
(
ThreadObj
));
...
...
tests/examples/c/demo.c
浏览文件 @
7a82c2c6
...
...
@@ -38,7 +38,7 @@ int main(int argc, char *argv[]) {
taos
=
taos_connect
(
argv
[
1
],
"root"
,
"taosdata"
,
NULL
,
0
);
if
(
taos
==
NULL
)
{
printf
(
"failed to connect to server, reason:%s
\n
"
,
taos_errstr
(
taos
)
);
printf
(
"failed to connect to server, reason:%s
\n
"
,
"null taos"
/*taos_errstr(taos)*/
);
exit
(
1
);
}
printf
(
"success to connect to server
\n
"
);
...
...
@@ -48,7 +48,7 @@ int main(int argc, char *argv[]) {
result
=
taos_query
(
taos
,
"create database demo"
);
if
(
result
==
NULL
)
{
printf
(
"failed to create database, reason:%s
\n
"
,
taos_errstr
(
taos
)
);
printf
(
"failed to create database, reason:%s
\n
"
,
"null result"
/*taos_errstr(taos)*/
);
exit
(
1
);
}
printf
(
"success to create database
\n
"
);
...
...
@@ -57,7 +57,7 @@ int main(int argc, char *argv[]) {
// create table
if
(
taos_query
(
taos
,
"create table m1 (ts timestamp, ti tinyint, si smallint, i int, bi bigint, f float, d double, b binary(10))"
)
==
0
)
{
printf
(
"failed to create table, reason:%s
\n
"
,
taos_errstr
(
taos
));
printf
(
"failed to create table, reason:%s
\n
"
,
taos_errstr
(
result
));
exit
(
1
);
}
printf
(
"success to create table
\n
"
);
...
...
@@ -70,9 +70,19 @@ int main(int argc, char *argv[]) {
for
(
i
=
0
;
i
<
10
;
++
i
)
{
sprintf
(
qstr
,
"insert into m1 values (%"
PRId64
", %d, %d, %d, %d, %f, %lf, '%s')"
,
1546300800000
+
i
*
1000
,
i
,
i
,
i
,
i
*
10000000
,
i
*
1
.
0
,
i
*
2
.
0
,
"hello"
);
printf
(
"qstr: %s
\n
"
,
qstr
);
if
(
taos_query
(
taos
,
qstr
))
{
printf
(
"insert row: %i, reason:%s
\n
"
,
i
,
taos_errstr
(
taos
));
// note: how do you wanna do if taos_query returns non-NULL
// if (taos_query(taos, qstr)) {
// printf("insert row: %i, reason:%s\n", i, taos_errstr(taos));
// }
TAOS_RES
*
result
=
taos_query
(
taos
,
qstr
);
if
(
result
)
{
printf
(
"insert row: %i
\n
"
,
i
);
}
else
{
printf
(
"failed to insert row: %i, reason:%s
\n
"
,
i
,
"null result"
/*taos_errstr(result)*/
);
exit
(
1
);
}
//sleep(1);
}
printf
(
"success to insert rows, total %d rows
\n
"
,
i
);
...
...
tests/pytest/concurrent_inquiry.py
浏览文件 @
7a82c2c6
...
...
@@ -12,108 +12,105 @@
# -*- coding: utf-8 -*-
import
threading
import
taos
import
sys
import
json
import
time
import
random
# query sql
query_sql
=
[
# first supertable
"select count(*) from test.meters where c1 > 50;"
,
"select count(*) from test.meters where c2 >= 50 and c2 < 100;"
,
"select count(*) from test.meters where c3 != 5;"
,
"select count(*) from test.meters ;"
,
"select count(*) from test.meters where t3 > 2;"
,
"select count(*) from test.meters where ts <> '2020-05-13 10:00:00.002';"
,
"select count(*) from test.meters where t7 like 'fi%';"
,
"select count(*) from test.meters where t7 like '_econd';"
,
"select count(*) from test.meters where t7 like 'taos_1%';"
,
"select count(*) from test.meters where t7 like '_____2';"
,
"select count(*) from test.meters where t8 like '%思%';"
,
"select count(*) from test.meters interval(1n) order by ts desc;"
,
"select max(c0) from test.meters group by tbname"
,
"select first(
*) from test.meters
;"
,
"select last(
*) from test.meters
;"
,
#
"select max(c0) from test.meters group by tbname",
"select first(
ts) from test.meters where t5 >5000 and t5<5100
;"
,
"select last(
ts) from test.meters where t5 >5000 and t5<5100
;"
,
"select last_row(*) from test.meters;"
,
"select twa(c1) from test.t1 where ts > 1500000001000 and ts < 1500000101000"
,
"select avg(c1) from test.meters;"
,
"select avg(c1) from test.meters
where t5 >5000 and t5<5100
;"
,
"select bottom(c1, 2) from test.t1;"
,
"select diff(c1) from test.t1;"
,
"select leastsquares(c1, 1, 1) from test.t1 ;"
,
"select max(c1) from test.meters;"
,
"select min(c1) from test.meters;"
,
"select c1 + c2
* c3
+ c1 / c5 + c4 + c2 from test.t1;"
,
"select max(c1) from test.meters
where t5 >5000 and t5<5100
;"
,
"select min(c1) from test.meters
where t5 >5000 and t5<5100
;"
,
"select c1 + c2 + c1 / c5 + c4 + c2 from test.t1;"
,
"select percentile(c1, 50) from test.t1;"
,
"select spread(c1) from test.t1 ;"
,
"select stddev(c1) from test.t1;"
,
"select sum(c1) from test.meters;"
,
"select top(c1, 2) from test.meters;"
"select twa(c
6
) from test.t1 where ts > 1500000001000 and ts < 1500000101000"
,
"select avg(c
6) from test.meters
;"
,
"select bottom(c
6, 2) from test.t1
;"
,
"select diff(c
6) from test.t1
;"
,
"select leastsquares(c
6
, 1, 1) from test.t1 ;"
,
"select max(c
6) from test.meters
;"
,
"select min(c
6) from test.meters
;"
,
"select c
6 + c2 * c3 + c6 / c5 + c4 + c2 from test.t1
;"
,
"select percentile(c
6
, 50) from test.t1;"
,
"select spread(c
6
) from test.t1 ;"
,
"select stddev(c
6) from test.t1
;"
,
"select sum(c
6) from test.meters
;"
,
"select top(c
6, 2) from test.meters
;"
,
"select sum(c1) from test.meters
where t5 >5000 and t5<5100
;"
,
"select top(c1, 2) from test.meters
where t5 >5000 and t5<5100
;"
"select twa(c
4
) from test.t1 where ts > 1500000001000 and ts < 1500000101000"
,
"select avg(c
4) from test.meters where t5 >5000 and t5<5100
;"
,
"select bottom(c
4, 2) from test.t1 where t5 >5000 and t5<5100
;"
,
"select diff(c
4) from test.t1 where t5 >5000 and t5<5100
;"
,
"select leastsquares(c
4
, 1, 1) from test.t1 ;"
,
"select max(c
4) from test.meters where t5 >5000 and t5<5100
;"
,
"select min(c
4) from test.meters where t5 >5000 and t5<5100
;"
,
"select c
5 + c2 + c4 / c5 + c4 + c2 from test.t1
;"
,
"select percentile(c
5
, 50) from test.t1;"
,
"select spread(c
5
) from test.t1 ;"
,
"select stddev(c
5) from test.t1 where t5 >5000 and t5<5100
;"
,
"select sum(c
5) from test.meters where t5 >5000 and t5<5100
;"
,
"select top(c
5, 2) from test.meters where t5 >5000 and t5<5100
;"
,
#all vnode
"select count(*) from test.meters where t5 >
2500 and t5<75
00"
,
"select max(c0),avg(c1) from test.meters where t5 >
2500 and t5<75
00"
,
"select sum(c5),avg(c1) from test.meters where t5 >
2500 and t5<75
00"
,
"select max(c0),min(c
6) from test.meters where t5 >2500 and t5<75
00"
,
"select min(c0),avg(c
6) from test.meters where t5 >2500 and t5<75
00"
,
"select count(*) from test.meters where t5 >
5000 and t5<51
00"
,
"select max(c0),avg(c1) from test.meters where t5 >
5000 and t5<51
00"
,
"select sum(c5),avg(c1) from test.meters where t5 >
5000 and t5<51
00"
,
"select max(c0),min(c
5) from test.meters where t5 >5000 and t5<51
00"
,
"select min(c0),avg(c
5) from test.meters where t5 >5000 and t5<51
00"
,
# second supertable
"select count(*) from test.meters1 where c1 > 50;"
,
"select count(*) from test.meters1 where c2 >= 50 and c2 < 100;"
,
"select count(*) from test.meters1 where c3 != 5;"
,
"select count(*) from test.meters1 where t3 > 2;"
,
"select count(*) from test.meters1 where ts <> '2020-05-13 10:00:00.002';"
,
"select count(*) from test.meters1 where t7 like 'fi%';"
,
"select count(*) from test.meters1 where t7 like '_econd';"
,
"select count(*) from test.meters where t7 like 'taos_1%';"
,
"select count(*) from test.meters where t7 like '_____2';"
,
"select count(*) from test.meters where t8 like '%思%';"
,
"select count(*) from test.meters1 interval(1n) order by ts desc;"
,
"select max(c0) from test.meters1 group by tbname"
,
"select first(
*) from test.meters1
;"
,
"select last(
*) from test.meters1
;"
,
"select last_row(*) from test.meters1;"
,
#
"select max(c0) from test.meters1 group by tbname",
"select first(
ts) from test.meters1 where t5 >5000 and t5<5100
;"
,
"select last(
ts) from test.meters1 where t5 >5000 and t5<5100
;"
,
"select last_row(*) from test.meters1
;"
,
"select twa(c1) from test.m1 where ts > 1500000001000 and ts < 1500000101000"
,
"select avg(c1) from test.meters1;"
,
"select bottom(c1, 2) from test.m1;"
,
"select diff(c1) from test.m1;"
,
"select avg(c1) from test.meters1
where t5 >5000 and t5<5100
;"
,
"select bottom(c1, 2) from test.m1
where t5 >5000 and t5<5100
;"
,
"select diff(c1) from test.m1
;"
,
"select leastsquares(c1, 1, 1) from test.m1 ;"
,
"select max(c1) from test.meters1;"
,
"select min(c1) from test.meters1;"
,
"select c1 + c2
* c3 + c1 / c5 + c3 + c2 from test.m1
;"
,
"select max(c1) from test.meters1
where t5 >5000 and t5<5100
;"
,
"select min(c1) from test.meters1
where t5 >5000 and t5<5100
;"
,
"select c1 + c2
+ c1 / c0 + c2 from test.m1
;"
,
"select percentile(c1, 50) from test.m1;"
,
"select spread(c1) from test.m1 ;"
,
"select stddev(c1) from test.m1;"
,
"select sum(c1) from test.meters1;"
,
"select top(c1, 2) from test.meters1;"
,
"select twa(c
6
) from test.m1 where ts > 1500000001000 and ts < 1500000101000"
,
"select avg(c
6) from test.meters1
;"
,
"select bottom(c
6
, 2) from test.m1;"
,
"select diff(c
6
) from test.m1;"
,
"select leastsquares(c
6
, 1, 1) from test.m1 ;"
,
"select max(c
6) from test.meters1
;"
,
"select min(c
6) from test.meters1
;"
,
"select c
6 + c2 * c3 + c6 / c5 + c3 + c2
from test.m1;"
,
"select percentile(c
6
, 50) from test.m1;"
,
"select spread(c
6
) from test.m1 ;"
,
"select stddev(c
6
) from test.m1;"
,
"select sum(c
6) from test.meters1
;"
,
"select top(c
6, 2) from test.meters1
;"
,
"select count(*) from test.meters1 where t5 >
2500 and t5<75
00"
,
"select sum(c1) from test.meters1
where t5 >5000 and t5<5100
;"
,
"select top(c1, 2) from test.meters1
where t5 >5000 and t5<5100
;"
,
"select twa(c
5
) from test.m1 where ts > 1500000001000 and ts < 1500000101000"
,
"select avg(c
5) from test.meters1 where t5 >5000 and t5<5100
;"
,
"select bottom(c
5
, 2) from test.m1;"
,
"select diff(c
5
) from test.m1;"
,
"select leastsquares(c
5
, 1, 1) from test.m1 ;"
,
"select max(c
5) from test.meters1 where t5 >5000 and t5<5100
;"
,
"select min(c
5) from test.meters1 where t5 >5000 and t5<5100
;"
,
"select c
5 + c2 + c4 / c5 + c0
from test.m1;"
,
"select percentile(c
4
, 50) from test.m1;"
,
"select spread(c
4
) from test.m1 ;"
,
"select stddev(c
4
) from test.m1;"
,
"select sum(c
4) from test.meters1 where t5 >5100 and t5<5300
;"
,
"select top(c
4, 2) from test.meters1 where t5 >5100 and t5<5300
;"
,
"select count(*) from test.meters1 where t5 >
5100 and t5<53
00"
,
#all vnode
"select count(*) from test.meters1 where t5 >
2500 and t5<75
00"
,
"select max(c0),avg(c1) from test.meters1 where t5 >
2500 and t5<75
00"
,
"select sum(c5),avg(c1) from test.meters1 where t5 >
2500 and t5<75
00"
,
"select max(c0),min(c
6) from test.meters1 where t5 >2500 and t5<75
00"
,
"select min(c0),avg(c
6) from test.meters1 where t5 >2500 and t5<75
00"
,
"select count(*) from test.meters1 where t5 >
5100 and t5<53
00"
,
"select max(c0),avg(c1) from test.meters1 where t5 >
5000 and t5<51
00"
,
"select sum(c5),avg(c1) from test.meters1 where t5 >
5000 and t5<51
00"
,
"select max(c0),min(c
5) from test.meters1 where t5 >5000 and t5<51
00"
,
"select min(c0),avg(c
5) from test.meters1 where t5 >5000 and t5<51
00"
,
#join
"select * from meters,meters1 where meters.ts = meters1.ts and meters.t5 = meters1.t5"
,
"select * from meters,meters1 where meters.ts = meters1.ts and meters.t7 = meters1.t7"
,
"select * from meters,meters1 where meters.ts = meters1.ts and meters.t8 = meters1.t8"
,
"select meters.ts,meters1.c2 from meters,meters1 where meters.ts = meters1.ts and meters.t8 = meters1.t8"
#
"select * from meters,meters1 where meters.ts = meters1.ts and meters.t5 = meters1.t5",
#
"select * from meters,meters1 where meters.ts = meters1.ts and meters.t7 = meters1.t7",
#
"select * from meters,meters1 where meters.ts = meters1.ts and meters.t8 = meters1.t8",
#
"select meters.ts,meters1.c2 from meters,meters1 where meters.ts = meters1.ts and meters.t8 = meters1.t8"
]
class
ConcurrentInquiry
:
...
...
@@ -121,7 +118,8 @@ class ConcurrentInquiry:
self
.
numOfTherads
=
50
self
.
ts
=
1500000001000
def
SetThreadsNum
(
self
,
num
):
self
.
numOfTherads
=
num
def
query_thread
(
self
,
threadID
):
host
=
"10.211.55.14"
user
=
"root"
...
...
@@ -142,12 +140,16 @@ class ConcurrentInquiry:
for
i
in
ran_query_sql
:
print
(
"Thread %d : %s"
%
(
threadID
,
i
))
try
:
start
=
time
.
time
()
cl
.
execute
(
i
)
cl
.
fetchall
end
=
time
.
time
()
print
(
"time cost :"
,
end
-
start
)
except
Exception
as
e
:
print
(
"Failure thread%d, sql: %s,exception: %s"
%
(
threadID
,
str
(
i
),
str
(
e
)))
exit
(
-
1
)
print
(
"Thread %d: finishing"
%
threadID
)
...
...
@@ -155,9 +157,9 @@ class ConcurrentInquiry:
def
run
(
self
):
threads
=
[]
for
i
in
range
(
50
):
for
i
in
range
(
self
.
numOfTherads
):
thread
=
threading
.
Thread
(
target
=
self
.
query_thread
,
args
=
(
i
,))
threads
.
append
(
thread
)
thread
.
start
()
...
...
tests/pytest/fulltest.sh
浏览文件 @
7a82c2c6
...
...
@@ -18,6 +18,7 @@ python3 ./test.py -f insert/multi.py
python3 ./test.py
-f
insert/randomNullCommit.py
python3 insert/retentionpolicy.py
python3 ./test.py
-f
insert/alterTableAndInsert.py
python3 ./test.py
-f
insert/insertIntoTwoTables.py
python3 ./test.py
-f
table/column_name.py
python3 ./test.py
-f
table/column_num.py
...
...
@@ -149,6 +150,7 @@ python3 ./test.py -f query/queryNullValueTest.py
python3 ./test.py
-f
query/queryInsertValue.py
python3 ./test.py
-f
query/queryConnection.py
python3 ./test.py
-f
query/natualInterval.py
python3 ./test.py
-f
query/bug1471.py
#stream
python3 ./test.py
-f
stream/metric_1.py
...
...
tests/pytest/insert/insertIntoTwoTables.py
0 → 100644
浏览文件 @
7a82c2c6
###################################################################
# Copyright (c) 2016 by TAOS Technologies, Inc.
# All rights reserved.
#
# This file is proprietary and confidential to TAOS Technologies.
# No part of this file may be reproduced, stored, transmitted,
# disclosed or used in any form or by any means other than as
# expressly provided by the written permission from Jianhui Tao
#
###################################################################
# -*- coding: utf-8 -*-
import
sys
import
taos
from
util.log
import
tdLog
from
util.cases
import
tdCases
from
util.sql
import
tdSql
class
TDTestCase
:
def
init
(
self
,
conn
,
logSql
):
tdLog
.
debug
(
"start to execute %s"
%
__file__
)
tdSql
.
init
(
conn
.
cursor
(),
logSql
)
def
run
(
self
):
tdSql
.
prepare
()
### test case for TD-1758 ###
print
(
"==============step1"
)
tdSql
.
execute
(
"create table t0(ts timestamp, c int)"
)
tdSql
.
execute
(
'create table t1(ts timestamp, c binary(1))'
)
tdSql
.
execute
(
"insert into t0 values(now,1) t1 values(now,'0')(now+1a,'1')(now+2a,'2')(now+3a,'3')(now+4a,'4')"
)
print
(
"==============step2"
)
tdSql
.
query
(
"select * from t0"
)
tdSql
.
checkRows
(
1
)
tdSql
.
checkData
(
0
,
0
,
1
)
tdSql
.
query
(
"select * from t1"
)
tdSql
.
checkRows
(
5
)
def
stop
(
self
):
tdSql
.
close
()
tdLog
.
success
(
"%s successfully executed"
%
__file__
)
tdCases
.
addWindows
(
__file__
,
TDTestCase
())
tdCases
.
addLinux
(
__file__
,
TDTestCase
())
tests/pytest/query/bug1471.py
0 → 100644
浏览文件 @
7a82c2c6
###################################################################
# Copyright (c) 2016 by TAOS Technologies, Inc.
# All rights reserved.
#
# This file is proprietary and confidential to TAOS Technologies.
# No part of this file may be reproduced, stored, transmitted,
# disclosed or used in any form or by any means other than as
# expressly provided by the written permission from Jianhui Tao
#
###################################################################
# -*- coding: utf-8 -*-
import
sys
import
taos
from
util.log
import
*
from
util.cases
import
*
from
util.sql
import
*
import
time
import
threading
class
myThread
(
threading
.
Thread
):
def
__init__
(
self
,
conn
):
threading
.
Thread
.
__init__
(
self
)
self
.
event
=
threading
.
Event
()
self
.
conn
=
taos
.
connect
(
conn
.
_host
,
port
=
conn
.
_port
,
config
=
conn
.
_config
)
def
run
(
self
):
cur
=
self
.
conn
.
cursor
()
self
.
event
.
wait
()
cur
.
execute
(
"drop database db"
)
cur
.
close
()
self
.
conn
.
close
()
class
TDTestCase
:
def
init
(
self
,
conn
,
logSql
):
tdLog
.
debug
(
"start to execute %s"
%
__file__
)
tdSql
.
init
(
conn
.
cursor
())
def
run
(
self
):
for
i
in
range
(
50
):
print
(
"round"
,
i
)
thread
=
myThread
(
tdSql
.
cursor
.
_connection
)
thread
.
start
()
tdSql
.
execute
(
'reset query cache'
)
tdSql
.
execute
(
'drop database if exists db'
)
tdSql
.
execute
(
'create database db'
)
tdSql
.
execute
(
'use db'
)
tdSql
.
execute
(
"create table car (ts timestamp, s int)"
)
tdSql
.
execute
(
"insert into car values('2020-10-19 17:00:00', 123)"
)
thread
.
event
.
set
()
try
:
tdSql
.
query
(
"select s from car where ts = '2020-10-19 17:00:00'"
)
except
Exception
as
e
:
pass
else
:
tdSql
.
checkData
(
0
,
0
,
123
)
thread
.
join
()
time
.
sleep
(
0.2
)
def
stop
(
self
):
tdSql
.
close
()
tdLog
.
success
(
"%s successfully executed"
%
__file__
)
tdCases
.
addWindows
(
__file__
,
TDTestCase
())
tdCases
.
addLinux
(
__file__
,
TDTestCase
())
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录