Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
a18638f0
T
TDengine
项目概览
taosdata
/
TDengine
大约 2 年 前同步成功
通知
1192
Star
22018
Fork
4786
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
a18638f0
编写于
12月 07, 2021
作者:
C
Cary Xu
浏览文件
操作
浏览文件
下载
差异文件
Merge branch 'master' into hotfix/TS-787
上级
3cece8da
a805acce
变更
31
隐藏空白更改
内联
并排
Showing
31 changed file
with
286 addition
and
214 deletion
+286
-214
cmake/install.inc
cmake/install.inc
+6
-6
src/client/src/tscSQLParser.c
src/client/src/tscSQLParser.c
+25
-12
src/client/src/tscServer.c
src/client/src/tscServer.c
+5
-1
src/common/inc/tdataformat.h
src/common/inc/tdataformat.h
+3
-2
src/connector/jdbc/src/main/java/com/taosdata/jdbc/rs/RestfulStatement.java
.../src/main/java/com/taosdata/jdbc/rs/RestfulStatement.java
+9
-8
src/connector/jdbc/src/test/java/com/taosdata/jdbc/cases/AuthenticationTest.java
...test/java/com/taosdata/jdbc/cases/AuthenticationTest.java
+22
-42
src/connector/jdbc/src/test/java/com/taosdata/jdbc/cases/ConnectWrongDatabaseTest.java
...ava/com/taosdata/jdbc/cases/ConnectWrongDatabaseTest.java
+8
-12
src/connector/jdbc/src/test/java/com/taosdata/jdbc/cases/InsertDbwithoutUseDbTest.java
...ava/com/taosdata/jdbc/cases/InsertDbwithoutUseDbTest.java
+2
-4
src/connector/jdbc/src/test/java/com/taosdata/jdbc/rs/RestfulConnectionTest.java
...test/java/com/taosdata/jdbc/rs/RestfulConnectionTest.java
+10
-15
src/connector/jdbc/src/test/java/com/taosdata/jdbc/rs/RestfulJDBCTest.java
...c/src/test/java/com/taosdata/jdbc/rs/RestfulJDBCTest.java
+20
-29
src/connector/jdbc/src/test/java/com/taosdata/jdbc/rs/RestfulResultSetMetaDataTest.java
...va/com/taosdata/jdbc/rs/RestfulResultSetMetaDataTest.java
+11
-16
src/connector/jdbc/src/test/java/com/taosdata/jdbc/rs/RestfulResultSetTest.java
.../test/java/com/taosdata/jdbc/rs/RestfulResultSetTest.java
+19
-26
src/connector/jdbc/src/test/java/com/taosdata/jdbc/rs/SQLTest.java
...ctor/jdbc/src/test/java/com/taosdata/jdbc/rs/SQLTest.java
+4
-1
src/connector/python/taos/cinterface.py
src/connector/python/taos/cinterface.py
+2
-2
src/connector/python/taos/field.py
src/connector/python/taos/field.py
+3
-3
src/connector/python/taos/result.py
src/connector/python/taos/result.py
+7
-1
src/connector/python/tests/test_lines.py
src/connector/python/tests/test_lines.py
+0
-1
src/connector/python/tests/test_stmt.py
src/connector/python/tests/test_stmt.py
+1
-0
src/connector/python/tests/test_stream.py
src/connector/python/tests/test_stream.py
+2
-1
src/inc/taoserror.h
src/inc/taoserror.h
+1
-0
src/query/src/qAggMain.c
src/query/src/qAggMain.c
+4
-4
src/tsdb/src/tsdbMemTable.c
src/tsdb/src/tsdbMemTable.c
+1
-1
src/util/src/terror.c
src/util/src/terror.c
+4
-3
tests/examples/python/taosdemo/taosdemo.py
tests/examples/python/taosdemo/taosdemo.py
+37
-17
tests/pytest/fulltest.bat
tests/pytest/fulltest.bat
+0
-1
tests/pytest/fulltest.sh
tests/pytest/fulltest.sh
+1
-0
tests/pytest/query/unionAllTest.py
tests/pytest/query/unionAllTest.py
+18
-1
tests/pytest/table/create_db_from_normal_db.py
tests/pytest/table/create_db_from_normal_db.py
+45
-0
tests/pytest/tools/windows_input.py
tests/pytest/tools/windows_input.py
+8
-1
tests/script/general/parser/nestquery.sim
tests/script/general/parser/nestquery.sim
+6
-4
tests/script/general/parser/slimit_query.sim
tests/script/general/parser/slimit_query.sim
+2
-0
未找到文件。
cmake/install.inc
浏览文件 @
a18638f0
...
...
@@ -24,19 +24,19 @@ ELSEIF (TD_WINDOWS)
INSTALL
(
FILES
$
{
LIBRARY_OUTPUT_PATH
}
/
taos
.
dll
DESTINATION
driver
)
IF
(
TD_POWER
)
INSTALL
(
DIRECTORY
$
{
TD_COMMUNITY_DIR
}
/
packaging
/
cfg
DESTINATION
.
)
INSTALL
(
FILES
$
{
TD_COMMUNITY_DIR
}
/
packaging
/
cfg
/
taos
.
cfg
DESTINATION
cfg
)
INSTALL
(
FILES
$
{
EXECUTABLE_OUTPUT_PATH
}
/
power
.
exe
DESTINATION
.
)
ELSEIF
(
TD_TQ
)
INSTALL
(
DIRECTORY
$
{
TD_COMMUNITY_DIR
}
/
packaging
/
cfg
DESTINATION
.
)
INSTALL
(
FILES
$
{
TD_COMMUNITY_DIR
}
/
packaging
/
cfg
/
taos
.
cfg
DESTINATION
cfg
)
INSTALL
(
FILES
$
{
EXECUTABLE_OUTPUT_PATH
}
/
tq
.
exe
DESTINATION
.
)
ELSEIF
(
TD_PRO
)
INSTALL
(
DIRECTORY
$
{
TD_COMMUNITY_DIR
}
/
packaging
/
cfg
DESTINATION
.
)
INSTALL
(
FILES
$
{
TD_COMMUNITY_DIR
}
/
packaging
/
cfg
/
taos
.
cfg
DESTINATION
cfg
)
INSTALL
(
FILES
$
{
EXECUTABLE_OUTPUT_PATH
}
/
prodbc
.
exe
DESTINATION
.
)
ELSEIF
(
TD_KH
)
INSTALL
(
FILES
$
{
TD_COMMUNITY_DIR
}
/
packaging
/
cfg
/
kinghistorian
.
cfg
DESTINATION
cfg
)
INSTALL
(
FILES
$
{
EXECUTABLE_OUTPUT_PATH
}
/
khclient
.
exe
DESTINATION
.
)
ELSEIF
(
TD_JH
)
INSTALL
(
DIRECTORY
$
{
TD_COMMUNITY_DIR
}
/
packaging
/
cfg
DESTINATION
.
)
INSTALL
(
FILES
$
{
TD_COMMUNITY_DIR
}
/
packaging
/
cfg
/
taos
.
cfg
DESTINATION
cfg
)
INSTALL
(
FILES
$
{
EXECUTABLE_OUTPUT_PATH
}
/
jh_taos
.
exe
DESTINATION
.
)
ELSE
()
INSTALL
(
DIRECTORY
$
{
TD_COMMUNITY_DIR
}
/
src
/
connector
/
go
DESTINATION
connector
)
...
...
@@ -44,8 +44,8 @@ ELSEIF (TD_WINDOWS)
INSTALL
(
DIRECTORY
$
{
TD_COMMUNITY_DIR
}
/
src
/
connector
/
python
DESTINATION
connector
)
INSTALL
(
DIRECTORY
$
{
TD_COMMUNITY_DIR
}
/
src
/
connector
/
C
\
# DESTINATION connector)
INSTALL
(
DIRECTORY
$
{
TD_COMMUNITY_DIR
}
/
tests
/
examples
DESTINATION
.
)
INSTALL
(
DIRECTORY
$
{
TD_COMMUNITY_DIR
}
/
packaging
/
cfg
DESTINATION
.
)
INSTALL
(
FILES
$
{
TD_COMMUNITY_DIR
}
/
packaging
/
cfg
/
taos
.
cfg
DESTINATION
cfg
)
INSTALL
(
FILES
$
{
EXECUTABLE_OUTPUT_PATH
}
/
taos
.
exe
DESTINATION
.
)
INSTALL
(
FILES
$
{
EXECUTABLE_OUTPUT_PATH
}
/
taosdemo
.
exe
DESTINATION
.
)
ENDIF
()
...
...
src/client/src/tscSQLParser.c
浏览文件 @
a18638f0
...
...
@@ -358,19 +358,28 @@ static int32_t handlePassword(SSqlCmd* pCmd, SStrToken* pPwd) {
// validate the out put field type for "UNION ALL" subclause
static
int32_t
normalizeVarDataTypeLength
(
SSqlCmd
*
pCmd
)
{
const
char
*
msg1
=
"columns in select clause not identical"
;
const
char
*
msg2
=
"too many select clause siblings, at most 100 allowed"
;
int32_t
siblings
=
0
;
int32_t
diffSize
=
0
;
// if there is only one element, the limit of clause is the limit of global result.
SQueryInfo
*
pQueryInfo1
=
pCmd
->
pQueryInfo
;
SQueryInfo
*
pSibling
=
pQueryInfo1
->
sibling
;
// pQueryInfo1 itself
++
siblings
;
while
(
pSibling
!=
NULL
)
{
int32_t
ret
=
tscFieldInfoCompare
(
&
pQueryInfo1
->
fieldsInfo
,
&
pSibling
->
fieldsInfo
,
&
diffSize
);
if
(
ret
!=
0
)
{
return
invalidOperationMsg
(
tscGetErrorMsgPayload
(
pCmd
),
msg1
);
}
if
(
++
siblings
>
100
)
{
return
invalidOperationMsg
(
tscGetErrorMsgPayload
(
pCmd
),
msg2
);
}
pSibling
=
pSibling
->
sibling
;
}
...
...
@@ -6550,17 +6559,15 @@ int32_t validateLimitNode(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, SSqlNode* pSqlN
// todo refactor
if
(
UTIL_TABLE_IS_SUPER_TABLE
(
pTableMetaInfo
))
{
if
(
!
tscQueryTags
(
pQueryInfo
))
{
// local handle the super table tag query
if
(
tscIsProjectionQueryOnSTable
(
pQueryInfo
,
0
))
{
if
(
pQueryInfo
->
slimit
.
limit
>
0
||
pQueryInfo
->
slimit
.
offset
>
0
)
{
return
invalidOperationMsg
(
tscGetErrorMsgPayload
(
pCmd
),
msg2
);
}
if
(
tscIsProjectionQueryOnSTable
(
pQueryInfo
,
0
))
{
if
(
pQueryInfo
->
slimit
.
limit
>
0
||
pQueryInfo
->
slimit
.
offset
>
0
)
{
return
invalidOperationMsg
(
tscGetErrorMsgPayload
(
pCmd
),
msg2
);
}
// for projection query on super table, all queries are subqueries
if
(
tscNonOrderedProjectionQueryOnSTable
(
pQueryInfo
,
0
)
&&
!
TSDB_QUERY_HAS_TYPE
(
pQueryInfo
->
type
,
TSDB_QUERY_TYPE_JOIN_QUERY
))
{
pQueryInfo
->
type
|=
TSDB_QUERY_TYPE_SUBQUERY
;
}
// for projection query on super table, all queries are subqueries
if
(
tscNonOrderedProjectionQueryOnSTable
(
pQueryInfo
,
0
)
&&
!
TSDB_QUERY_HAS_TYPE
(
pQueryInfo
->
type
,
TSDB_QUERY_TYPE_JOIN_QUERY
))
{
pQueryInfo
->
type
|=
TSDB_QUERY_TYPE_SUBQUERY
;
}
}
...
...
@@ -7535,6 +7542,7 @@ int32_t doCheckForCreateFromStable(SSqlObj* pSql, SSqlInfo* pInfo) {
const
char
*
msg3
=
"tag value too long"
;
const
char
*
msg4
=
"illegal value or data overflow"
;
const
char
*
msg5
=
"tags number not matched"
;
const
char
*
msg6
=
"create table only from super table is allowed"
;
SSqlCmd
*
pCmd
=
&
pSql
->
cmd
;
...
...
@@ -7575,6 +7583,10 @@ int32_t doCheckForCreateFromStable(SSqlObj* pSql, SSqlInfo* pInfo) {
return
code
;
}
if
(
!
UTIL_TABLE_IS_SUPER_TABLE
(
pStableMetaInfo
))
{
return
invalidOperationMsg
(
tscGetErrorMsgPayload
(
pCmd
),
msg6
);
}
size_t
valSize
=
taosArrayGetSize
(
pValList
);
// too long tag values will return invalid sql, not be truncated automatically
...
...
@@ -8685,7 +8697,7 @@ int32_t validateSqlNode(SSqlObj* pSql, SSqlNode* pSqlNode, SQueryInfo* pQueryInf
const
char
*
msg4
=
"interval query not supported, since the result of sub query not include valid timestamp column"
;
const
char
*
msg5
=
"only tag query not compatible with normal column filter"
;
const
char
*
msg6
=
"not support stddev/percentile/interp in the outer query yet"
;
const
char
*
msg7
=
"derivative/twa/
irate
requires timestamp column exists in subquery"
;
const
char
*
msg7
=
"derivative/twa/
rate/irate/diff
requires timestamp column exists in subquery"
;
const
char
*
msg8
=
"condition missing for join query"
;
const
char
*
msg9
=
"not support 3 level select"
;
...
...
@@ -8769,7 +8781,8 @@ int32_t validateSqlNode(SSqlObj* pSql, SSqlNode* pSqlNode, SQueryInfo* pQueryInf
SExprInfo
*
pExpr
=
tscExprGet
(
pQueryInfo
,
i
);
int32_t
f
=
pExpr
->
base
.
functionId
;
if
(
f
==
TSDB_FUNC_DERIVATIVE
||
f
==
TSDB_FUNC_TWA
||
f
==
TSDB_FUNC_IRATE
)
{
if
(
f
==
TSDB_FUNC_DERIVATIVE
||
f
==
TSDB_FUNC_TWA
||
f
==
TSDB_FUNC_IRATE
||
f
==
TSDB_FUNC_RATE
||
f
==
TSDB_FUNC_DIFF
)
{
return
invalidOperationMsg
(
tscGetErrorMsgPayload
(
pCmd
),
msg7
);
}
}
...
...
src/client/src/tscServer.c
浏览文件 @
a18638f0
...
...
@@ -980,7 +980,11 @@ static int32_t serializeSqlExpr(SSqlExpr* pExpr, STableMetaInfo* pTableMetaInfo,
return
TSDB_CODE_TSC_INVALID_OPERATION
;
}
assert
(
pExpr
->
resColId
<
0
);
if
(
pExpr
->
resColId
>=
0
)
{
tscError
(
"result column id underflowed: %d"
,
pExpr
->
resColId
);
return
TSDB_CODE_TSC_RES_TOO_MANY
;
}
SSqlExpr
*
pSqlExpr
=
(
SSqlExpr
*
)(
*
pMsg
);
SColIndex
*
pIndex
=
&
pSqlExpr
->
colInfo
;
...
...
src/common/inc/tdataformat.h
浏览文件 @
a18638f0
...
...
@@ -448,13 +448,14 @@ typedef struct {
#define kvRowSetNCols(r, n) kvRowNCols(r) = (n)
#define kvRowColIdx(r) (SColIdx *)POINTER_SHIFT(r, TD_KV_ROW_HEAD_SIZE)
#define kvRowValues(r) POINTER_SHIFT(r, TD_KV_ROW_HEAD_SIZE + sizeof(SColIdx) * kvRowNCols(r))
#define kvRowKeys(r) POINTER_SHIFT(r, *(uint16_t *)POINTER_SHIFT(r, TD_KV_ROW_HEAD_SIZE + sizeof(int16_t)))
#define kvRowCpy(dst, r) memcpy((dst), (r), kvRowLen(r))
#define kvRowColVal(r, colIdx) POINTER_SHIFT(kvRowValues(r), (colIdx)->offset)
#define kvRowColIdxAt(r, i) (kvRowColIdx(r) + (i))
#define kvRowFree(r) tfree(r)
#define kvRowEnd(r) POINTER_SHIFT(r, kvRowLen(r))
#define kvRowValLen(r) (kvRowLen(r) - TD_KV_ROW_HEAD_SIZE - sizeof(SColIdx) * kvRowNCols(r))
#define kvRowTKey(r) (*(TKEY *)(kvRow
Value
s(r)))
#define kvRowTKey(r) (*(TKEY *)(kvRow
Key
s(r)))
#define kvRowKey(r) tdGetKey(kvRowTKey(r))
#define kvRowDeleted(r) TKEY_IS_DELETED(kvRowTKey(r))
...
...
@@ -652,7 +653,7 @@ static FORCE_INLINE char *memRowEnd(SMemRow row) {
#define memRowKvVersion(r) (*(int16_t *)POINTER_SHIFT(r, TD_MEM_ROW_TYPE_SIZE))
#define memRowVersion(r) (isDataRow(r) ? memRowDataVersion(r) : memRowKvVersion(r)) // schema version
#define memRowSetKvVersion(r, v) (memRowKvVersion(r) = (v))
#define memRow
Tuple(r) (isDataRow(r) ? dataRowTuple(memRowDataBody(r)) : kvRowValue
s(memRowKvBody(r)))
#define memRow
Keys(r) (isDataRow(r) ? dataRowTuple(memRowDataBody(r)) : kvRowKey
s(memRowKvBody(r)))
#define memRowTKey(r) (isDataRow(r) ? dataRowTKey(memRowDataBody(r)) : kvRowTKey(memRowKvBody(r)))
#define memRowKey(r) (isDataRow(r) ? dataRowKey(memRowDataBody(r)) : kvRowKey(memRowKvBody(r)))
...
...
src/connector/jdbc/src/main/java/com/taosdata/jdbc/rs/RestfulStatement.java
浏览文件 @
a18638f0
...
...
@@ -66,7 +66,11 @@ public class RestfulStatement extends AbstractStatement {
boolean
result
=
true
;
if
(
SqlSyntaxValidator
.
isUseSql
(
sql
))
{
HttpClientPoolUtil
.
execute
(
getUrl
(),
sql
,
this
.
conn
.
getToken
());
String
ret
=
HttpClientPoolUtil
.
execute
(
getUrl
(),
sql
,
this
.
conn
.
getToken
());
JSONObject
resultJson
=
JSON
.
parseObject
(
ret
);
if
(
resultJson
.
getString
(
"status"
).
equals
(
"error"
))
{
throw
TSDBError
.
createSQLException
(
resultJson
.
getInteger
(
"code"
),
"sql: "
+
sql
+
", desc: "
+
resultJson
.
getString
(
"desc"
));
}
this
.
database
=
sql
.
trim
().
replace
(
"use"
,
""
).
trim
();
this
.
conn
.
setCatalog
(
this
.
database
);
result
=
false
;
...
...
@@ -115,7 +119,7 @@ public class RestfulStatement extends AbstractStatement {
String
result
=
HttpClientPoolUtil
.
execute
(
getUrl
(),
sql
,
this
.
conn
.
getToken
());
JSONObject
resultJson
=
JSON
.
parseObject
(
result
);
if
(
resultJson
.
getString
(
"status"
).
equals
(
"error"
))
{
throw
TSDBError
.
createSQLException
(
resultJson
.
getInteger
(
"code"
),
resultJson
.
getString
(
"desc"
));
throw
TSDBError
.
createSQLException
(
resultJson
.
getInteger
(
"code"
),
"sql: "
+
sql
+
", desc: "
+
resultJson
.
getString
(
"desc"
));
}
this
.
resultSet
=
new
RestfulResultSet
(
database
,
this
,
resultJson
);
this
.
affectedRows
=
0
;
...
...
@@ -126,7 +130,7 @@ public class RestfulStatement extends AbstractStatement {
String
result
=
HttpClientPoolUtil
.
execute
(
getUrl
(),
sql
,
this
.
conn
.
getToken
());
JSONObject
jsonObject
=
JSON
.
parseObject
(
result
);
if
(
jsonObject
.
getString
(
"status"
).
equals
(
"error"
))
{
throw
TSDBError
.
createSQLException
(
jsonObject
.
getInteger
(
"code"
),
jsonObject
.
getString
(
"desc"
));
throw
TSDBError
.
createSQLException
(
jsonObject
.
getInteger
(
"code"
),
"sql: "
+
sql
+
", desc: "
+
jsonObject
.
getString
(
"desc"
));
}
this
.
resultSet
=
null
;
this
.
affectedRows
=
getAffectedRows
(
jsonObject
);
...
...
@@ -134,16 +138,13 @@ public class RestfulStatement extends AbstractStatement {
}
private
int
getAffectedRows
(
JSONObject
jsonObject
)
throws
SQLException
{
// create ... SQLs should return 0 , and Restful result like this:
// {"status": "succ", "head": ["affected_rows"], "data": [[0]], "rows": 1}
JSONArray
head
=
jsonObject
.
getJSONArray
(
"head"
);
if
(
head
.
size
()
!=
1
||
!
"affected_rows"
.
equals
(
head
.
getString
(
0
)))
throw
TSDBError
.
createSQLException
(
TSDBErrorNumbers
.
ERROR_INVALID_VARIABLE
);
throw
TSDBError
.
createSQLException
(
TSDBErrorNumbers
.
ERROR_INVALID_VARIABLE
,
"invalid variable: ["
+
head
.
toJSONString
()
+
"]"
);
JSONArray
data
=
jsonObject
.
getJSONArray
(
"data"
);
if
(
data
!=
null
)
return
data
.
getJSONArray
(
0
).
getInteger
(
0
);
throw
TSDBError
.
createSQLException
(
TSDBErrorNumbers
.
ERROR_INVALID_VARIABLE
);
throw
TSDBError
.
createSQLException
(
TSDBErrorNumbers
.
ERROR_INVALID_VARIABLE
,
"invalid variable: ["
+
jsonObject
.
toJSONString
()
+
"]"
);
}
@Override
...
...
src/connector/jdbc/src/test/java/com/taosdata/jdbc/cases/AuthenticationTest.java
浏览文件 @
a18638f0
...
...
@@ -57,53 +57,33 @@ public class AuthenticationTest {
@Ignore
@Test
public
void
test
()
{
public
void
test
()
throws
SQLException
{
// change password
try
{
conn
=
DriverManager
.
getConnection
(
"jdbc:TAOS-RS://"
+
host
+
":6041/restful_test?user="
+
user
+
"&password=taosdata"
);
Statement
stmt
=
conn
.
createStatement
();
stmt
.
execute
(
"alter user "
+
user
+
" pass '"
+
password
+
"'"
);
stmt
.
close
();
conn
.
close
();
}
catch
(
SQLException
e
)
{
e
.
printStackTrace
();
}
conn
=
DriverManager
.
getConnection
(
"jdbc:TAOS-RS://"
+
host
+
":6041/?user="
+
user
+
"&password=taosdata"
);
Statement
stmt
=
conn
.
createStatement
();
stmt
.
execute
(
"alter user "
+
user
+
" pass '"
+
password
+
"'"
);
stmt
.
close
();
conn
.
close
();
// use new to login and execute query
try
{
conn
=
DriverManager
.
getConnection
(
"jdbc:TAOS-RS://"
+
host
+
":6041/restful_test?user="
+
user
+
"&password="
+
password
);
Statement
stmt
=
conn
.
createStatement
();
stmt
.
execute
(
"show databases"
);
ResultSet
rs
=
stmt
.
getResultSet
();
ResultSetMetaData
meta
=
rs
.
getMetaData
();
while
(
rs
.
next
())
{
for
(
int
i
=
1
;
i
<=
meta
.
getColumnCount
();
i
++)
{
System
.
out
.
print
(
meta
.
getColumnLabel
(
i
)
+
":"
+
rs
.
getString
(
i
)
+
"\t"
);
}
System
.
out
.
println
();
conn
=
DriverManager
.
getConnection
(
"jdbc:TAOS-RS://"
+
host
+
":6041/?user="
+
user
+
"&password="
+
password
);
stmt
=
conn
.
createStatement
();
stmt
.
execute
(
"show databases"
);
ResultSet
rs
=
stmt
.
getResultSet
();
ResultSetMetaData
meta
=
rs
.
getMetaData
();
while
(
rs
.
next
())
{
for
(
int
i
=
1
;
i
<=
meta
.
getColumnCount
();
i
++)
{
System
.
out
.
print
(
meta
.
getColumnLabel
(
i
)
+
":"
+
rs
.
getString
(
i
)
+
"\t"
);
}
}
catch
(
SQLException
e
)
{
e
.
printStackTrace
();
System
.
out
.
println
();
}
// change password back
try
{
conn
=
DriverManager
.
getConnection
(
"jdbc:TAOS-RS://"
+
host
+
":6041/restful_test?user="
+
user
+
"&password="
+
password
);
Statement
stmt
=
conn
.
createStatement
();
stmt
.
execute
(
"alter user "
+
user
+
" pass 'taosdata'"
);
stmt
.
close
();
conn
.
close
();
}
catch
(
SQLException
e
)
{
e
.
printStackTrace
();
}
}
@Before
public
void
before
()
{
try
{
Class
.
forName
(
"com.taosdata.jdbc.rs.RestfulDriver"
);
}
catch
(
ClassNotFoundException
e
)
{
e
.
printStackTrace
();
}
// change password back
conn
=
DriverManager
.
getConnection
(
"jdbc:TAOS-RS://"
+
host
+
":6041/?user="
+
user
+
"&password="
+
password
);
stmt
=
conn
.
createStatement
();
stmt
.
execute
(
"alter user "
+
user
+
" pass 'taosdata'"
);
stmt
.
close
();
conn
.
close
();
}
}
src/connector/jdbc/src/test/java/com/taosdata/jdbc/cases/ConnectWrongDatabaseTest.java
浏览文件 @
a18638f0
package
com.taosdata.jdbc.cases
;
import
com.taosdata.jdbc.TSDBErrorNumbers
;
import
org.junit.Assert
;
import
org.junit.Test
;
import
java.sql.DriverManager
;
...
...
@@ -9,16 +7,14 @@ import java.sql.SQLException;
public
class
ConnectWrongDatabaseTest
{
@Test
public
void
connect
()
{
try
{
Class
.
forName
(
"com.taosdata.jdbc.TSDBDriver"
);
DriverManager
.
getConnection
(
"jdbc:TAOS://localhost:6030/wrong_db?user=root&password=taosdata"
);
}
catch
(
ClassNotFoundException
e
)
{
e
.
printStackTrace
();
}
catch
(
SQLException
e
)
{
Assert
.
assertEquals
(
TSDBErrorNumbers
.
ERROR_JNI_CONNECTION_NULL
,
e
.
getErrorCode
());
}
@Test
(
expected
=
SQLException
.
class
)
public
void
connectByJni
()
throws
SQLException
{
DriverManager
.
getConnection
(
"jdbc:TAOS://localhost:6030/wrong_db?user=root&password=taosdata"
);
}
@Test
(
expected
=
SQLException
.
class
)
public
void
connectByRestful
()
throws
SQLException
{
DriverManager
.
getConnection
(
"jdbc:TAOS-RS://localhost:6041/wrong_db?user=root&password=taosdata"
);
}
}
src/connector/jdbc/src/test/java/com/taosdata/jdbc/cases/InsertDbwithoutUseDbTest.java
浏览文件 @
a18638f0
...
...
@@ -18,9 +18,8 @@ public class InsertDbwithoutUseDbTest {
private
static
final
Random
random
=
new
Random
(
System
.
currentTimeMillis
());
@Test
public
void
case001
()
throws
ClassNotFoundException
,
SQLException
{
public
void
case001
()
throws
SQLException
{
// prepare schema
Class
.
forName
(
"com.taosdata.jdbc.TSDBDriver"
);
String
url
=
"jdbc:TAOS://127.0.0.1:6030/?user=root&password=taosdata"
;
Connection
conn
=
DriverManager
.
getConnection
(
url
,
properties
);
try
(
Statement
stmt
=
conn
.
createStatement
())
{
...
...
@@ -51,9 +50,8 @@ public class InsertDbwithoutUseDbTest {
}
@Test
public
void
case002
()
throws
ClassNotFoundException
,
SQLException
{
public
void
case002
()
throws
SQLException
{
// prepare the schema
Class
.
forName
(
"com.taosdata.jdbc.rs.RestfulDriver"
);
final
String
url
=
"jdbc:TAOS-RS://"
+
host
+
":6041/inWithoutDb?user=root&password=taosdata"
;
Connection
conn
=
DriverManager
.
getConnection
(
url
,
properties
);
try
(
Statement
stmt
=
conn
.
createStatement
())
{
...
...
src/connector/jdbc/src/test/java/com/taosdata/jdbc/rs/RestfulConnectionTest.java
浏览文件 @
a18638f0
...
...
@@ -374,22 +374,17 @@ public class RestfulConnectionTest {
}
@BeforeClass
public
static
void
beforeClass
()
{
try
{
Class
.
forName
(
"com.taosdata.jdbc.rs.RestfulDriver"
);
Properties
properties
=
new
Properties
();
properties
.
setProperty
(
TSDBDriver
.
PROPERTY_KEY_CHARSET
,
"UTF-8"
);
properties
.
setProperty
(
TSDBDriver
.
PROPERTY_KEY_LOCALE
,
"en_US.UTF-8"
);
properties
.
setProperty
(
TSDBDriver
.
PROPERTY_KEY_TIME_ZONE
,
"UTC-8"
);
conn
=
DriverManager
.
getConnection
(
"jdbc:TAOS-RS://"
+
host
+
":6041/log?user=root&password=taosdata"
,
properties
);
// create test database for test cases
try
(
Statement
stmt
=
conn
.
createStatement
())
{
stmt
.
execute
(
"create database if not exists test"
);
}
}
catch
(
ClassNotFoundException
|
SQLException
e
)
{
e
.
printStackTrace
();
public
static
void
beforeClass
()
throws
SQLException
{
Properties
properties
=
new
Properties
();
properties
.
setProperty
(
TSDBDriver
.
PROPERTY_KEY_CHARSET
,
"UTF-8"
);
properties
.
setProperty
(
TSDBDriver
.
PROPERTY_KEY_LOCALE
,
"en_US.UTF-8"
);
properties
.
setProperty
(
TSDBDriver
.
PROPERTY_KEY_TIME_ZONE
,
"UTC-8"
);
conn
=
DriverManager
.
getConnection
(
"jdbc:TAOS-RS://"
+
host
+
":6041/?user=root&password=taosdata"
,
properties
);
// create test database for test cases
try
(
Statement
stmt
=
conn
.
createStatement
())
{
stmt
.
execute
(
"create database if not exists test"
);
}
}
@AfterClass
...
...
src/connector/jdbc/src/test/java/com/taosdata/jdbc/rs/RestfulJDBCTest.java
浏览文件 @
a18638f0
...
...
@@ -10,11 +10,11 @@ import java.util.Random;
public
class
RestfulJDBCTest
{
private
static
final
String
host
=
"127.0.0.1"
;
private
final
Random
random
=
new
Random
(
System
.
currentTimeMillis
());
private
Connection
connection
;
private
static
final
Random
random
=
new
Random
(
System
.
currentTimeMillis
());
private
static
Connection
connection
;
@Test
public
void
testCase001
()
{
public
void
testCase001
()
throws
SQLException
{
// given
String
sql
=
"drop database if exists restful_test"
;
// when
...
...
@@ -38,7 +38,7 @@ public class RestfulJDBCTest {
}
@Test
public
void
testCase002
()
{
public
void
testCase002
()
throws
SQLException
{
// given
String
sql
=
"create table weather(ts timestamp, temperature float, humidity int) tags(location nchar(64), groupId int)"
;
// when
...
...
@@ -48,7 +48,7 @@ public class RestfulJDBCTest {
}
@Test
public
void
testCase004
()
{
public
void
testCase004
()
throws
SQLException
{
for
(
int
i
=
1
;
i
<=
100
;
i
++)
{
// given
String
sql
=
"create table t"
+
i
+
" using weather tags('beijing', '"
+
i
+
"')"
;
...
...
@@ -60,7 +60,7 @@ public class RestfulJDBCTest {
}
@Test
public
void
testCase005
()
{
public
void
testCase005
()
throws
SQLException
{
int
rows
=
0
;
for
(
int
i
=
0
;
i
<
10
;
i
++)
{
for
(
int
j
=
1
;
j
<=
100
;
j
++)
{
...
...
@@ -99,7 +99,7 @@ public class RestfulJDBCTest {
}
@Test
public
void
testCase007
()
{
public
void
testCase007
()
throws
SQLException
{
// given
String
sql
=
"drop database restful_test"
;
...
...
@@ -110,50 +110,41 @@ public class RestfulJDBCTest {
Assert
.
assertFalse
(
execute
);
}
private
int
executeUpdate
(
Connection
connection
,
String
sql
)
{
private
int
executeUpdate
(
Connection
connection
,
String
sql
)
throws
SQLException
{
try
(
Statement
stmt
=
connection
.
createStatement
())
{
return
stmt
.
executeUpdate
(
sql
);
}
catch
(
SQLException
e
)
{
e
.
printStackTrace
();
}
return
0
;
}
private
boolean
execute
(
Connection
connection
,
String
sql
)
{
private
boolean
execute
(
Connection
connection
,
String
sql
)
throws
SQLException
{
try
(
Statement
stmt
=
connection
.
createStatement
())
{
return
stmt
.
execute
(
sql
);
}
catch
(
SQLException
e
)
{
e
.
printStackTrace
();
}
return
false
;
}
private
ResultSet
executeQuery
(
Connection
connection
,
String
sql
)
{
private
ResultSet
executeQuery
(
Connection
connection
,
String
sql
)
throws
SQLException
{
try
(
Statement
statement
=
connection
.
createStatement
())
{
return
statement
.
executeQuery
(
sql
);
}
catch
(
SQLException
e
)
{
e
.
printStackTrace
();
}
return
null
;
}
@Before
public
void
before
()
{
@Before
Class
public
static
void
beforeClass
()
{
try
{
connection
=
DriverManager
.
getConnection
(
"jdbc:TAOS-RS://"
+
host
+
":6041/
restful_test
?user=root&password=taosdata"
);
connection
=
DriverManager
.
getConnection
(
"jdbc:TAOS-RS://"
+
host
+
":6041/?user=root&password=taosdata"
);
}
catch
(
SQLException
e
)
{
e
.
printStackTrace
();
}
}
@After
public
void
after
()
{
try
{
if
(
connection
!=
null
)
connection
.
close
(
);
}
catch
(
SQLException
e
)
{
e
.
printStackTrac
e
();
@After
Class
public
static
void
afterClass
()
throws
SQLException
{
if
(
connection
!=
null
)
{
Statement
stmt
=
connection
.
createStatement
();
stmt
.
execute
(
"drop database if exists restful_test"
);
stmt
.
close
();
connection
.
clos
e
();
}
}
...
...
src/connector/jdbc/src/test/java/com/taosdata/jdbc/rs/RestfulResultSetMetaDataTest.java
浏览文件 @
a18638f0
...
...
@@ -186,22 +186,17 @@ public class RestfulResultSetMetaDataTest {
}
@BeforeClass
public
static
void
beforeClass
()
{
try
{
Class
.
forName
(
"com.taosdata.jdbc.rs.RestfulDriver"
);
conn
=
DriverManager
.
getConnection
(
"jdbc:TAOS-RS://"
+
host
+
":6041/restful_test?user=root&password=taosdata"
);
stmt
=
conn
.
createStatement
();
stmt
.
execute
(
"create database if not exists restful_test"
);
stmt
.
execute
(
"use restful_test"
);
stmt
.
execute
(
"drop table if exists weather"
);
stmt
.
execute
(
"create table if not exists weather(f1 timestamp, f2 int, f3 bigint, f4 float, f5 double, f6 binary(64), f7 smallint, f8 tinyint, f9 bool, f10 nchar(64))"
);
stmt
.
execute
(
"insert into restful_test.weather values('2021-01-01 00:00:00.000', 1, 100, 3.1415, 3.1415926, 'abc', 10, 10, true, '涛思数据')"
);
rs
=
stmt
.
executeQuery
(
"select * from restful_test.weather"
);
rs
.
next
();
meta
=
rs
.
getMetaData
();
}
catch
(
ClassNotFoundException
|
SQLException
e
)
{
e
.
printStackTrace
();
}
public
static
void
beforeClass
()
throws
SQLException
{
conn
=
DriverManager
.
getConnection
(
"jdbc:TAOS-RS://"
+
host
+
":6041/?user=root&password=taosdata"
);
stmt
=
conn
.
createStatement
();
stmt
.
execute
(
"create database if not exists restful_test"
);
stmt
.
execute
(
"use restful_test"
);
stmt
.
execute
(
"drop table if exists weather"
);
stmt
.
execute
(
"create table if not exists weather(f1 timestamp, f2 int, f3 bigint, f4 float, f5 double, f6 binary(64), f7 smallint, f8 tinyint, f9 bool, f10 nchar(64))"
);
stmt
.
execute
(
"insert into restful_test.weather values('2021-01-01 00:00:00.000', 1, 100, 3.1415, 3.1415926, 'abc', 10, 10, true, '涛思数据')"
);
rs
=
stmt
.
executeQuery
(
"select * from restful_test.weather"
);
rs
.
next
();
meta
=
rs
.
getMetaData
();
}
@AfterClass
...
...
src/connector/jdbc/src/test/java/com/taosdata/jdbc/rs/RestfulResultSetTest.java
浏览文件 @
a18638f0
...
...
@@ -658,36 +658,29 @@ public class RestfulResultSetTest {
}
@BeforeClass
public
static
void
beforeClass
()
{
try
{
Class
.
forName
(
"com.taosdata.jdbc.rs.RestfulDriver"
);
conn
=
DriverManager
.
getConnection
(
"jdbc:TAOS-RS://"
+
host
+
":6041/restful_test?user=root&password=taosdata"
);
stmt
=
conn
.
createStatement
();
stmt
.
execute
(
"create database if not exists restful_test"
);
stmt
.
execute
(
"use restful_test"
);
stmt
.
execute
(
"drop table if exists weather"
);
stmt
.
execute
(
"create table if not exists weather(f1 timestamp, f2 int, f3 bigint, f4 float, f5 double, f6 binary(64), f7 smallint, f8 tinyint, f9 bool, f10 nchar(64))"
);
stmt
.
execute
(
"insert into restful_test.weather values('2021-01-01 00:00:00.000', 1, 100, 3.1415, 3.1415926, 'abc', 10, 10, true, '涛思数据')"
);
rs
=
stmt
.
executeQuery
(
"select * from restful_test.weather"
);
rs
.
next
();
}
catch
(
ClassNotFoundException
|
SQLException
e
)
{
e
.
printStackTrace
();
}
public
static
void
beforeClass
()
throws
SQLException
{
conn
=
DriverManager
.
getConnection
(
"jdbc:TAOS-RS://"
+
host
+
":6041/?user=root&password=taosdata"
);
stmt
=
conn
.
createStatement
();
stmt
.
execute
(
"drop database if exists restful_test"
);
stmt
.
execute
(
"create database if not exists restful_test"
);
stmt
.
execute
(
"use restful_test"
);
stmt
.
execute
(
"drop table if exists weather"
);
stmt
.
execute
(
"create table if not exists weather(f1 timestamp, f2 int, f3 bigint, f4 float, f5 double, f6 binary(64), f7 smallint, f8 tinyint, f9 bool, f10 nchar(64))"
);
stmt
.
execute
(
"insert into restful_test.weather values('2021-01-01 00:00:00.000', 1, 100, 3.1415, 3.1415926, 'abc', 10, 10, true, '涛思数据')"
);
rs
=
stmt
.
executeQuery
(
"select * from restful_test.weather"
);
rs
.
next
();
}
@AfterClass
public
static
void
afterClass
()
{
try
{
if
(
rs
!=
null
)
rs
.
close
();
if
(
stmt
!=
null
)
stmt
.
close
();
if
(
conn
!=
null
)
conn
.
close
();
}
catch
(
SQLException
e
)
{
e
.
printStackTrace
();
public
static
void
afterClass
()
throws
SQLException
{
if
(
rs
!=
null
)
rs
.
close
();
if
(
stmt
!=
null
)
{
stmt
.
execute
(
"drop database if exists restful_test"
);
stmt
.
close
();
}
if
(
conn
!=
null
)
conn
.
close
();
}
}
\ No newline at end of file
src/connector/jdbc/src/test/java/com/taosdata/jdbc/rs/SQLTest.java
浏览文件 @
a18638f0
...
...
@@ -581,11 +581,14 @@ public class SQLTest {
@BeforeClass
public
static
void
before
()
throws
SQLException
{
connection
=
DriverManager
.
getConnection
(
"jdbc:TAOS-RS://"
+
host
+
":6041/
restful_test
?user=root&password=taosdata"
);
connection
=
DriverManager
.
getConnection
(
"jdbc:TAOS-RS://"
+
host
+
":6041/?user=root&password=taosdata"
);
}
@AfterClass
public
static
void
after
()
throws
SQLException
{
Statement
stmt
=
connection
.
createStatement
();
stmt
.
execute
(
"drop database if exists restful_test"
);
stmt
.
close
();
connection
.
close
();
}
...
...
src/connector/python/taos/cinterface.py
浏览文件 @
a18638f0
...
...
@@ -103,7 +103,7 @@ _libtaos.taos_get_client_info.restype = c_char_p
def
taos_get_client_info
():
# type: () -> str
"""Get client version info."""
return
_libtaos
.
taos_get_client_info
().
decode
()
return
_libtaos
.
taos_get_client_info
().
decode
(
"utf-8"
)
_libtaos
.
taos_get_server_info
.
restype
=
c_char_p
...
...
@@ -113,7 +113,7 @@ _libtaos.taos_get_server_info.argtypes = (c_void_p,)
def
taos_get_server_info
(
connection
):
# type: (c_void_p) -> str
"""Get server version as string."""
return
_libtaos
.
taos_get_server_info
(
connection
).
decode
()
return
_libtaos
.
taos_get_server_info
(
connection
).
decode
(
"utf-8"
)
_libtaos
.
taos_close
.
restype
=
None
...
...
src/connector/python/taos/field.py
浏览文件 @
a18638f0
...
...
@@ -144,7 +144,7 @@ def _crow_nchar_to_python(data, num_of_rows, nbytes=None, precision=FieldType.C_
try
:
if
num_of_rows
>=
0
:
tmpstr
=
ctypes
.
c_char_p
(
data
)
res
.
append
(
tmpstr
.
value
.
decode
())
res
.
append
(
tmpstr
.
value
.
decode
(
"utf-8"
))
else
:
res
.
append
(
(
...
...
@@ -172,7 +172,7 @@ def _crow_binary_to_python_block(data, num_of_rows, nbytes=None, precision=Field
if
rbyte
==
1
and
buffer
[
0
]
==
b
'
\xff
'
:
res
.
append
(
None
)
else
:
res
.
append
(
cast
(
buffer
,
c_char_p
).
value
.
decode
())
res
.
append
(
cast
(
buffer
,
c_char_p
).
value
.
decode
(
"utf-8"
))
return
res
...
...
@@ -188,7 +188,7 @@ def _crow_nchar_to_python_block(data, num_of_rows, nbytes=None, precision=FieldT
if
rbyte
==
4
and
buffer
[:
4
]
==
b
'
\xff
'
*
4
:
res
.
append
(
None
)
else
:
res
.
append
(
cast
(
buffer
,
c_char_p
).
value
.
decode
())
res
.
append
(
cast
(
buffer
,
c_char_p
).
value
.
decode
(
"utf-8"
))
return
res
...
...
src/connector/python/taos/result.py
浏览文件 @
a18638f0
...
...
@@ -3,6 +3,8 @@ from .cinterface import *
# from .connection import TaosConnection
from
.error
import
*
from
ctypes
import
c_void_p
class
TaosResult
(
object
):
"""TDengine result interface"""
...
...
@@ -12,7 +14,11 @@ class TaosResult(object):
# to make the __del__ order right
self
.
_conn
=
conn
self
.
_close_after
=
close_after
self
.
_result
=
result
if
isinstance
(
result
,
c_void_p
):
self
.
_result
=
result
else
:
self
.
_result
=
c_void_p
(
result
)
self
.
_fields
=
None
self
.
_field_count
=
None
self
.
_precision
=
None
...
...
src/connector/python/tests/test_lines.py
浏览文件 @
a18638f0
...
...
@@ -36,7 +36,6 @@ def test_insert_lines(conn):
conn
.
insert_lines
(
lines
)
print
(
"inserted"
)
result
=
conn
.
query
(
"select * from st"
)
print
(
*
result
.
fields
)
all
=
result
.
rows_iter
()
for
row
in
all
:
print
(
row
)
...
...
src/connector/python/tests/test_stmt.py
浏览文件 @
a18638f0
# encoding:UTF-8
from
taos
import
*
from
ctypes
import
*
...
...
src/connector/python/tests/test_stream.py
浏览文件 @
a18638f0
...
...
@@ -20,7 +20,8 @@ def stream_callback(p_param, p_result, p_row):
result
=
TaosResult
(
p_result
)
row
=
TaosRow
(
result
,
p_row
)
try
:
ts
,
count
=
row
()
ts
,
count
=
row
.
as_tuple
()
print
(
ts
,
count
)
p
=
cast
(
p_param
,
POINTER
(
Counter
))
p
.
contents
.
count
+=
count
print
(
"[%s] inserted %d in 5s, total count: %d"
%
(
ts
.
strftime
(
"%Y-%m-%d %H:%M:%S"
),
count
,
p
.
contents
.
count
))
...
...
src/inc/taoserror.h
浏览文件 @
a18638f0
...
...
@@ -107,6 +107,7 @@ int32_t* taosGetErrno();
#define TSDB_CODE_TSC_DUP_COL_NAMES TAOS_DEF_ERROR_CODE(0, 0x021D) //"duplicated column names")
#define TSDB_CODE_TSC_INVALID_TAG_LENGTH TAOS_DEF_ERROR_CODE(0, 0x021E) //"Invalid tag length")
#define TSDB_CODE_TSC_INVALID_COLUMN_LENGTH TAOS_DEF_ERROR_CODE(0, 0x021F) //"Invalid column length")
#define TSDB_CODE_TSC_RES_TOO_MANY TAOS_DEF_ERROR_CODE(0, 0x0227) //"Result set too large to be output")
// mnode
#define TSDB_CODE_MND_MSG_NOT_PROCESSED TAOS_DEF_ERROR_CODE(0, 0x0300) //"Message not processed")
...
...
src/query/src/qAggMain.c
浏览文件 @
a18638f0
...
...
@@ -1005,11 +1005,11 @@ static void minMax_function(SQLFunctionCtx *pCtx, char *pOutput, int32_t isMin,
if
((
*
retVal
<
pData
[
i
])
^
isMin
)
{
*
retVal
=
pData
[
i
];
TSKEY
k
=
tsList
[
i
];
DO_UPDATE_TAG_COLUMNS
(
pCtx
,
k
);
if
(
tsList
)
{
TSKEY
k
=
tsList
[
i
];
DO_UPDATE_TAG_COLUMNS
(
pCtx
,
k
);
}
}
*
notNullElems
+=
1
;
}
#if defined(_DEBUG_VIEW)
...
...
src/tsdb/src/tsdbMemTable.c
浏览文件 @
a18638f0
...
...
@@ -560,7 +560,7 @@ static void tsdbFreeTableData(STableData *pTableData) {
}
}
static
char
*
tsdbGetTsTupleKey
(
const
void
*
data
)
{
return
memRow
Tuple
((
SMemRow
)
data
);
}
static
char
*
tsdbGetTsTupleKey
(
const
void
*
data
)
{
return
memRow
Keys
((
SMemRow
)
data
);
}
static
int
tsdbAdjustMemMaxTables
(
SMemTable
*
pMemTable
,
int
maxTables
)
{
ASSERT
(
pMemTable
->
maxTables
<
maxTables
);
...
...
src/util/src/terror.c
浏览文件 @
a18638f0
...
...
@@ -112,9 +112,10 @@ TAOS_DEFINE_ERROR(TSDB_CODE_TSC_EXCEED_SQL_LIMIT, "SQL statement too lon
TAOS_DEFINE_ERROR
(
TSDB_CODE_TSC_FILE_EMPTY
,
"File is empty"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_TSC_LINE_SYNTAX_ERROR
,
"Syntax error in Line"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_TSC_NO_META_CACHED
,
"No table meta cached"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_TSC_DUP_COL_NAMES
,
"duplicated column names"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_TSC_INVALID_TAG_LENGTH
,
"Invalid tag length"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_TSC_INVALID_COLUMN_LENGTH
,
"Invalid column length"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_TSC_DUP_COL_NAMES
,
"duplicated column names"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_TSC_INVALID_TAG_LENGTH
,
"Invalid tag length"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_TSC_INVALID_COLUMN_LENGTH
,
"Invalid column length"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_TSC_RES_TOO_MANY
,
"Result set too large to be output"
)
// mnode
TAOS_DEFINE_ERROR
(
TSDB_CODE_MND_MSG_NOT_PROCESSED
,
"Message not processed"
)
...
...
tests/examples/python/taosdemo/taosdemo.py
浏览文件 @
a18638f0
...
...
@@ -21,78 +21,91 @@ import json
import
random
import
time
import
datetime
import
multiprocessing
from
multiprocessing
import
Manager
,
Pool
,
Lock
from
multipledispatch
import
dispatch
from
concurrent.futures
import
ThreadPoolExecutor
,
wait
,
ALL_COMPLETED
@
dispatch
(
str
,
str
)
def
v_print
(
msg
:
str
,
arg
:
str
):
def
v_print
(
msg
,
arg
):
# type: (str, str) -> None
if
verbose
:
print
(
msg
%
arg
)
@
dispatch
(
str
,
str
,
str
)
def
v_print
(
msg
:
str
,
arg1
:
str
,
arg2
:
str
):
def
v_print
(
msg
,
arg1
,
arg2
):
# type: (str, str, str) -> None
if
verbose
:
print
(
msg
%
(
arg1
,
arg2
))
@
dispatch
(
str
,
str
,
str
,
str
)
def
v_print
(
msg
:
str
,
arg1
:
str
,
arg2
:
str
,
arg3
:
str
):
def
v_print
(
msg
,
arg1
,
arg2
,
arg3
):
# type: (str, str, str, str) -> None
if
verbose
:
print
(
msg
%
(
arg1
,
arg2
,
arg3
))
@
dispatch
(
str
,
str
,
str
,
str
,
str
)
def
v_print
(
msg
:
str
,
arg1
:
str
,
arg2
:
str
,
arg3
:
str
,
arg4
:
str
):
def
v_print
(
msg
,
arg1
,
arg2
,
arg3
,
arg4
):
# type: (str, str, str, str, str) -> None
if
verbose
:
print
(
msg
%
(
arg1
,
arg2
,
arg3
,
arg4
))
@
dispatch
(
str
,
int
)
def
v_print
(
msg
:
str
,
arg
:
int
):
def
v_print
(
msg
,
arg
):
# type: (str, int) -> None
if
verbose
:
print
(
msg
%
int
(
arg
))
@
dispatch
(
str
,
int
,
str
)
def
v_print
(
msg
:
str
,
arg1
:
int
,
arg2
:
str
):
def
v_print
(
msg
,
arg1
,
arg2
):
# type: (str, int, str) -> None
if
verbose
:
print
(
msg
%
(
int
(
arg1
),
str
(
arg2
)))
@
dispatch
(
str
,
str
,
int
)
def
v_print
(
msg
:
str
,
arg1
:
str
,
arg2
:
int
):
def
v_print
(
msg
,
arg1
,
arg2
):
# type: (str, str, int) -> None
if
verbose
:
print
(
msg
%
(
arg1
,
int
(
arg2
)))
@
dispatch
(
str
,
int
,
int
)
def
v_print
(
msg
:
str
,
arg1
:
int
,
arg2
:
int
):
def
v_print
(
msg
,
arg1
,
arg2
):
# type: (str, int, int) -> None
if
verbose
:
print
(
msg
%
(
int
(
arg1
),
int
(
arg2
)))
@
dispatch
(
str
,
int
,
int
,
str
)
def
v_print
(
msg
:
str
,
arg1
:
int
,
arg2
:
int
,
arg3
:
str
):
def
v_print
(
msg
,
arg1
,
arg2
,
arg3
):
# type: (str, int, int, str) -> None
if
verbose
:
print
(
msg
%
(
int
(
arg1
),
int
(
arg2
),
str
(
arg3
)))
@
dispatch
(
str
,
int
,
int
,
int
)
def
v_print
(
msg
:
str
,
arg1
:
int
,
arg2
:
int
,
arg3
:
int
):
def
v_print
(
msg
,
arg1
,
arg2
,
arg3
):
# type: (str, int, int, int) -> None
if
verbose
:
print
(
msg
%
(
int
(
arg1
),
int
(
arg2
),
int
(
arg3
)))
@
dispatch
(
str
,
int
,
int
,
int
,
int
)
def
v_print
(
msg
:
str
,
arg1
:
int
,
arg2
:
int
,
arg3
:
int
,
arg4
:
int
):
def
v_print
(
msg
,
arg1
,
arg2
,
arg3
,
arg4
):
# type: (str, int, int, int, int) -> None
if
verbose
:
print
(
msg
%
(
int
(
arg1
),
int
(
arg2
),
int
(
arg3
),
int
(
arg4
)))
def
restful_execute
(
host
:
str
,
port
:
int
,
user
:
str
,
password
:
str
,
cmd
:
str
):
def
restful_execute
(
host
,
port
,
user
,
password
,
cmd
):
# type: (str, int, str, str, str) -> None
url
=
"http://%s:%d/rest/sql"
%
(
host
,
restPort
)
v_print
(
"restful_execute - cmd: %s"
,
cmd
)
...
...
@@ -112,7 +125,8 @@ def restful_execute(host: str, port: int, user: str, password: str, cmd: str):
print
(
"resp: %s"
%
json
.
dumps
(
resp
.
json
()))
def
query_func
(
process
:
int
,
thread
:
int
,
cmd
:
str
):
def
query_func
(
process
,
thread
,
cmd
):
# type: (int, int, str) -> None
v_print
(
"%d process %d thread cmd: %s"
,
process
,
thread
,
cmd
)
if
oneMoreHost
!=
"NotSupported"
and
random
.
randint
(
...
...
@@ -133,7 +147,8 @@ def query_func(process: int, thread: int, cmd: str):
host
,
port
,
user
,
password
,
cmd
)
def
query_data_process
(
cmd
:
str
):
def
query_data_process
(
cmd
):
# type: (str) -> None
# establish connection if native
if
native
:
v_print
(
"host:%s, user:%s passwd:%s configDir:%s "
,
host
,
user
,
password
,
configDir
)
...
...
@@ -256,7 +271,8 @@ def drop_databases():
(
dbName
,
i
))
def
insert_func
(
process
:
int
,
thread
:
int
):
def
insert_func
(
process
,
thread
):
# type: (int, int) -> None
v_print
(
"%d process %d thread, insert_func "
,
process
,
thread
)
# generate uuid
...
...
@@ -374,7 +390,8 @@ def create_tb():
(
tbName
,
j
))
def
insert_data_process
(
lock
,
i
:
int
,
begin
:
int
,
end
:
int
):
def
insert_data_process
(
lock
,
i
,
begin
,
end
):
# type: (multiprocessing._LockType, int, int, int) -> None
lock
.
acquire
()
tasks
=
end
-
begin
v_print
(
"insert_data_process:%d table from %d to %d, tasks %d"
,
i
,
begin
,
end
,
tasks
)
...
...
@@ -675,7 +692,10 @@ if __name__ == "__main__":
printConfig
()
if
not
skipPrompt
:
input
(
"Press any key to continue.."
)
try
:
input
(
"Press any key to continue.."
)
except
SyntaxError
:
pass
# establish connection first if native
if
native
:
...
...
tests/pytest/fulltest.bat
浏览文件 @
a18638f0
...
...
@@ -19,4 +19,3 @@ python .\test.py -f query\filterFloatAndDouble.py
python
.\test.py
-f
query
\filterOtherTypes.py
python
.\test.py
-f
query
\querySort.py
python
.\test.py
-f
query
\queryJoin.py
python
.\test.py
-f
tools
\windows_input.py
\ No newline at end of file
tests/pytest/fulltest.sh
浏览文件 @
a18638f0
...
...
@@ -42,6 +42,7 @@ python3 ./test.py -f table/alter_column.py
python3 ./test.py
-f
table/boundary.py
python3 ./test.py
-f
table/create.py
python3 ./test.py
-f
table/del_stable.py
python3 ./test.py
-f
table/create_db_from_normal_db.py
#stable
python3 ./test.py
-f
stable/insert.py
...
...
tests/pytest/query/unionAllTest.py
浏览文件 @
a18638f0
...
...
@@ -103,10 +103,27 @@ class TDTestCase:
select count(*) as count, loc from st where ts between 1600000000000 and 1600000000010 group by loc'''
)
tdSql
.
checkRows
(
6
)
# https://jira.taosdata.com:18080/browse/TS-715
tdLog
.
info
(
"test case for TS-715"
)
sql
=
""
tdSql
.
execute
(
"create table st2(ts timestamp, c1 int, c2 int, c3 int) tags(loc nchar(20))"
)
for
i
in
range
(
101
):
if
i
==
0
:
sql
=
"select last(*) from sub0 "
else
:
sql
+=
f
"union all select last(*) from sub
{
i
}
"
tdSql
.
execute
(
"create table sub%d using st2 tags('nchar%d')"
%
(
i
,
i
))
tdSql
.
execute
(
"insert into sub%d values(%d, %d, %d, %d)"
%
(
i
,
self
.
ts
+
i
,
i
,
i
,
i
))
tdSql
.
error
(
sql
)
def
stop
(
self
):
tdSql
.
close
()
tdLog
.
success
(
"%s successfully executed"
%
__file__
)
tdCases
.
addWindows
(
__file__
,
TDTestCase
())
tdCases
.
addLinux
(
__file__
,
TDTestCase
())
\ No newline at end of file
tdCases
.
addLinux
(
__file__
,
TDTestCase
())
tests/pytest/table/create_db_from_normal_db.py
0 → 100644
浏览文件 @
a18638f0
###################################################################
# 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
()
print
(
"test case for TS-783"
)
tdSql
.
execute
(
"drop table if exists db.state1;"
)
tdSql
.
execute
(
"create table db.state1 (ts timestamp, c1 int);"
)
tdSql
.
error
(
"create table db.test1 using db.state1 tags('tt');"
)
tdSql
.
execute
(
"drop table if exists db.state2;"
)
tdSql
.
execute
(
"create table db.state2 (ts timestamp, c1 int) tags (t binary(20));"
)
tdSql
.
query
(
"create table db.test2 using db.state2 tags('tt');"
)
tdSql
.
error
(
"create table db.test22 using db.test2 tags('tt');"
)
def
stop
(
self
):
tdSql
.
close
()
tdLog
.
success
(
"%s successfully executed"
%
__file__
)
tdCases
.
addWindows
(
__file__
,
TDTestCase
())
tdCases
.
addLinux
(
__file__
,
TDTestCase
())
tests/pytest/tools/windows_input.py
浏览文件 @
a18638f0
...
...
@@ -15,6 +15,7 @@ import os
from
uiautomation
import
WindowControl
from
util.cases
import
*
from
util.sql
import
*
import
clipboard
class
TDTestCase
:
...
...
@@ -55,16 +56,22 @@ class TDTestCase:
sql
=
"insert into db.tb values(now,'%s');"
%
temp
window
.
SendKeys
(
sql
)
window
.
SendKeys
(
'{Enter}'
)
window
.
SendKeys
(
'{Ctrl}A'
)
window
.
SendKeys
(
'{Ctrl}C'
)
# 获取剪切板里面的复制内容
result
=
clipboard
.
paste
()
window
.
SendKeys
(
'{Ctrl}C'
)
window
.
SendKeys
(
'exit'
)
window
.
SendKeys
(
'{Enter}'
)
return
result
def
run
(
self
):
tdSql
.
prepare
()
ret
=
tdSql
.
execute
(
'create table tb (ts timestamp, i binary(300))'
)
self
.
win_input_test
()
result
=
self
.
win_input_test
()
tdLog
.
info
(
result
)
tdSql
.
query
(
"select * from tb"
)
tdSql
.
checkRows
(
1
)
...
...
tests/script/general/parser/nestquery.sim
浏览文件 @
a18638f0
...
...
@@ -330,9 +330,9 @@ if $data12 != 71680.000000000 then
return -1
endi
sql select top(x, 20) from (select c1 x from nest_tb0);
sql select top(x, 20) from (select
ts,
c1 x from nest_tb0);
sql select bottom(x, 20) from (select c1 x from nest_tb0)
sql select bottom(x, 20) from (select
ts,
c1 x from nest_tb0)
print ===================> group by + having
...
...
@@ -407,12 +407,14 @@ if $data03 != @20-09-15 00:00:00.000@ then
return -1
endi
sql select diff(val) from (select c1 val from nest_tb0);
sql_error select diff(val) from (select c1 val from nest_tb0);
sql select diff(val) from (select ts,c1 val from nest_tb0);
if $rows != 9999 then
return -1
endi
if $data00 != @
70-01-01 08:00
:00.000@ then
if $data00 != @
20-09-15 00:01
:00.000@ then
return -1
endi
...
...
tests/script/general/parser/slimit_query.sim
浏览文件 @
a18638f0
...
...
@@ -31,6 +31,8 @@ $tsu = $tsu + $ts0
#sql_error select top(c1, 1) from $stb where ts >= $ts0 and ts <= $tsu slimit 5 offset 1
#sql_error select bottom(c1, 1) from $stb where ts >= $ts0 and ts <= $tsu slimit 5 offset 1
sql_error select t1 from $stb slimit 5 offset 1;
### select from stb + group by + slimit offset
sql select max(c1), min(c2), avg(c3), sum(c4), spread(c5), sum(c6), count(c7), first(c8), last(c9) from $stb group by t1 slimit 5 soffset 0
if $rows != 5 then
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录