Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
7b67e43c
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看板
提交
7b67e43c
编写于
8月 09, 2021
作者:
W
wpan
浏览文件
操作
浏览文件
下载
差异文件
Merge branch 'develop' into feature/TD-2581
上级
abbc1a72
f73d68a5
变更
44
展开全部
隐藏空白更改
内联
并排
Showing
44 changed file
with
2907 addition
and
1439 deletion
+2907
-1439
packaging/cfg/taos.cfg
packaging/cfg/taos.cfg
+3
-0
src/client/src/tscAsync.c
src/client/src/tscAsync.c
+5
-0
src/client/src/tscSQLParser.c
src/client/src/tscSQLParser.c
+18
-26
src/client/src/tscServer.c
src/client/src/tscServer.c
+9
-0
src/client/src/tscSql.c
src/client/src/tscSql.c
+6
-1
src/common/inc/tglobal.h
src/common/inc/tglobal.h
+1
-0
src/common/src/tglobal.c
src/common/src/tglobal.c
+13
-0
src/connector/jdbc/pom.xml
src/connector/jdbc/pom.xml
+0
-1
src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBDriver.java
...ctor/jdbc/src/main/java/com/taosdata/jdbc/TSDBDriver.java
+7
-0
src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBError.java
...ector/jdbc/src/main/java/com/taosdata/jdbc/TSDBError.java
+2
-0
src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBErrorNumbers.java
...dbc/src/main/java/com/taosdata/jdbc/TSDBErrorNumbers.java
+5
-0
src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBJNIConnector.java
...dbc/src/main/java/com/taosdata/jdbc/TSDBJNIConnector.java
+0
-1
src/connector/jdbc/src/main/java/com/taosdata/jdbc/rs/RestfulDriver.java
...dbc/src/main/java/com/taosdata/jdbc/rs/RestfulDriver.java
+8
-2
src/connector/jdbc/src/main/java/com/taosdata/jdbc/rs/RestfulStatement.java
.../src/main/java/com/taosdata/jdbc/rs/RestfulStatement.java
+26
-33
src/connector/jdbc/src/main/java/com/taosdata/jdbc/utils/SqlSyntaxValidator.java
...main/java/com/taosdata/jdbc/utils/SqlSyntaxValidator.java
+1
-14
src/connector/jdbc/src/test/java/com/taosdata/jdbc/SubscribeTest.java
...r/jdbc/src/test/java/com/taosdata/jdbc/SubscribeTest.java
+2
-0
src/connector/jdbc/src/test/java/com/taosdata/jdbc/cases/AuthenticationTest.java
...test/java/com/taosdata/jdbc/cases/AuthenticationTest.java
+44
-0
src/connector/jdbc/src/test/java/com/taosdata/jdbc/cases/BatchInsertTest.java
...rc/test/java/com/taosdata/jdbc/cases/BatchInsertTest.java
+2
-0
src/connector/jdbc/src/test/java/com/taosdata/jdbc/cases/ImportTest.java
...dbc/src/test/java/com/taosdata/jdbc/cases/ImportTest.java
+2
-0
src/connector/jdbc/src/test/java/com/taosdata/jdbc/cases/InsertSpecialCharacterJniTest.java
...om/taosdata/jdbc/cases/InsertSpecialCharacterJniTest.java
+37
-4
src/connector/jdbc/src/test/java/com/taosdata/jdbc/cases/InsertSpecialCharacterRestfulTest.java
...aosdata/jdbc/cases/InsertSpecialCharacterRestfulTest.java
+2
-4
src/connector/jdbc/src/test/java/com/taosdata/jdbc/cases/QueryDataTest.java
.../src/test/java/com/taosdata/jdbc/cases/QueryDataTest.java
+2
-0
src/connector/jdbc/src/test/java/com/taosdata/jdbc/cases/ResetQueryCacheTest.java
...est/java/com/taosdata/jdbc/cases/ResetQueryCacheTest.java
+33
-35
src/connector/jdbc/src/test/java/com/taosdata/jdbc/cases/SelectTest.java
...dbc/src/test/java/com/taosdata/jdbc/cases/SelectTest.java
+2
-0
src/connector/jdbc/src/test/java/com/taosdata/jdbc/cases/StableTest.java
...dbc/src/test/java/com/taosdata/jdbc/cases/StableTest.java
+2
-0
src/connector/jdbc/src/test/java/com/taosdata/jdbc/utils/SqlSyntaxValidatorTest.java
.../java/com/taosdata/jdbc/utils/SqlSyntaxValidatorTest.java
+0
-21
src/inc/ttokendef.h
src/inc/ttokendef.h
+125
-125
src/kit/shell/src/shellEngine.c
src/kit/shell/src/shellEngine.c
+0
-1
src/mnode/inc/mnodeDef.h
src/mnode/inc/mnodeDef.h
+1
-0
src/mnode/src/mnodeDnode.c
src/mnode/src/mnodeDnode.c
+4
-2
src/mnode/src/mnodeMnode.c
src/mnode/src/mnodeMnode.c
+12
-1
src/mnode/src/mnodeSdb.c
src/mnode/src/mnodeSdb.c
+1
-0
src/os/src/detail/osTime.c
src/os/src/detail/osTime.c
+46
-9
src/query/inc/sql.y
src/query/inc/sql.y
+1
-1
src/query/src/qSqlParser.c
src/query/src/qSqlParser.c
+2
-0
src/query/src/sql.c
src/query/src/sql.c
+1949
-1148
src/query/tests/unitTest.cpp
src/query/tests/unitTest.cpp
+142
-3
src/tfs/src/tfs.c
src/tfs/src/tfs.c
+12
-3
src/util/inc/tcompare.h
src/util/inc/tcompare.h
+1
-1
tests/pytest/TimeZone/TestCaseTimeZone.py
tests/pytest/TimeZone/TestCaseTimeZone.py
+176
-0
tests/pytest/ZoneTimeTest.py
tests/pytest/ZoneTimeTest.py
+174
-0
tests/pytest/client/client.py
tests/pytest/client/client.py
+24
-2
tests/pytest/fulltest.sh
tests/pytest/fulltest.sh
+4
-0
tests/pytest/functions/showOfflineThresholdIs864000.py
tests/pytest/functions/showOfflineThresholdIs864000.py
+1
-1
未找到文件。
packaging/cfg/taos.cfg
浏览文件 @
7b67e43c
...
@@ -144,6 +144,9 @@ keepColumnName 1
...
@@ -144,6 +144,9 @@ keepColumnName 1
# max length of an SQL
# max length of an SQL
# maxSQLLength 65480
# maxSQLLength 65480
# max length of WildCards
# maxWildCardsLength 100
# the maximum number of records allowed for super table time sorting
# the maximum number of records allowed for super table time sorting
# maxNumOfOrderedRes 100000
# maxNumOfOrderedRes 100000
...
...
src/client/src/tscAsync.c
浏览文件 @
7b67e43c
...
@@ -339,6 +339,11 @@ void tscTableMetaCallBack(void *param, TAOS_RES *res, int code) {
...
@@ -339,6 +339,11 @@ void tscTableMetaCallBack(void *param, TAOS_RES *res, int code) {
const
char
*
msg
=
(
sub
->
cmd
.
command
==
TSDB_SQL_STABLEVGROUP
)
?
"vgroup-list"
:
"multi-tableMeta"
;
const
char
*
msg
=
(
sub
->
cmd
.
command
==
TSDB_SQL_STABLEVGROUP
)
?
"vgroup-list"
:
"multi-tableMeta"
;
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
tscError
(
"0x%"
PRIx64
" get %s failed, code:%s"
,
pSql
->
self
,
msg
,
tstrerror
(
code
));
tscError
(
"0x%"
PRIx64
" get %s failed, code:%s"
,
pSql
->
self
,
msg
,
tstrerror
(
code
));
if
(
code
==
TSDB_CODE_RPC_FQDN_ERROR
)
{
size_t
sz
=
strlen
(
tscGetErrorMsgPayload
(
&
sub
->
cmd
));
tscAllocPayload
(
&
pSql
->
cmd
,
(
int
)
sz
+
1
);
memcpy
(
tscGetErrorMsgPayload
(
&
pSql
->
cmd
),
tscGetErrorMsgPayload
(
&
sub
->
cmd
),
sz
);
}
goto
_error
;
goto
_error
;
}
}
...
...
src/client/src/tscSQLParser.c
浏览文件 @
7b67e43c
...
@@ -88,7 +88,6 @@ static uint8_t convertRelationalOperator(SStrToken *pToken);
...
@@ -88,7 +88,6 @@ static uint8_t convertRelationalOperator(SStrToken *pToken);
static
int32_t
validateSelectNodeList
(
SSqlCmd
*
pCmd
,
SQueryInfo
*
pQueryInfo
,
SArray
*
pSelNodeList
,
bool
isSTable
,
bool
joinQuery
,
bool
timeWindowQuery
);
static
int32_t
validateSelectNodeList
(
SSqlCmd
*
pCmd
,
SQueryInfo
*
pQueryInfo
,
SArray
*
pSelNodeList
,
bool
isSTable
,
bool
joinQuery
,
bool
timeWindowQuery
);
static
bool
validateIpAddress
(
const
char
*
ip
,
size_t
size
);
static
bool
hasUnsupportFunctionsForSTableQuery
(
SSqlCmd
*
pCmd
,
SQueryInfo
*
pQueryInfo
);
static
bool
hasUnsupportFunctionsForSTableQuery
(
SSqlCmd
*
pCmd
,
SQueryInfo
*
pQueryInfo
);
static
bool
functionCompatibleCheck
(
SQueryInfo
*
pQueryInfo
,
bool
joinQuery
,
bool
twQuery
);
static
bool
functionCompatibleCheck
(
SQueryInfo
*
pQueryInfo
,
bool
joinQuery
,
bool
twQuery
);
...
@@ -3225,7 +3224,6 @@ int32_t setShowInfo(SSqlObj* pSql, struct SSqlInfo* pInfo) {
...
@@ -3225,7 +3224,6 @@ int32_t setShowInfo(SSqlObj* pSql, struct SSqlInfo* pInfo) {
const
char
*
msg1
=
"invalid name"
;
const
char
*
msg1
=
"invalid name"
;
const
char
*
msg2
=
"pattern filter string too long"
;
const
char
*
msg2
=
"pattern filter string too long"
;
const
char
*
msg3
=
"database name too long"
;
const
char
*
msg3
=
"database name too long"
;
const
char
*
msg4
=
"invalid ip address"
;
const
char
*
msg5
=
"database name is empty"
;
const
char
*
msg5
=
"database name is empty"
;
const
char
*
msg6
=
"pattern string is empty"
;
const
char
*
msg6
=
"pattern string is empty"
;
...
@@ -3273,17 +3271,11 @@ int32_t setShowInfo(SSqlObj* pSql, struct SSqlInfo* pInfo) {
...
@@ -3273,17 +3271,11 @@ int32_t setShowInfo(SSqlObj* pSql, struct SSqlInfo* pInfo) {
}
}
}
else
if
(
showType
==
TSDB_MGMT_TABLE_VNODES
)
{
}
else
if
(
showType
==
TSDB_MGMT_TABLE_VNODES
)
{
if
(
pShowInfo
->
prefix
.
type
==
0
)
{
if
(
pShowInfo
->
prefix
.
type
==
0
)
{
return
invalidOperationMsg
(
tscGetErrorMsgPayload
(
pCmd
),
"No specified
ip of dnode
"
);
return
invalidOperationMsg
(
tscGetErrorMsgPayload
(
pCmd
),
"No specified
dnode ep
"
);
}
}
// show vnodes may be ip addr of dnode in payload
if
(
pShowInfo
->
prefix
.
type
==
TK_STRING
)
{
SStrToken
*
pDnodeIp
=
&
pShowInfo
->
prefix
;
pShowInfo
->
prefix
.
n
=
strdequote
(
pShowInfo
->
prefix
.
z
);
if
(
pDnodeIp
->
n
>=
TSDB_IPv4ADDR_LEN
)
{
// ip addr is too long
return
invalidOperationMsg
(
tscGetErrorMsgPayload
(
pCmd
),
msg3
);
}
if
(
!
validateIpAddress
(
pDnodeIp
->
z
,
pDnodeIp
->
n
))
{
return
invalidOperationMsg
(
tscGetErrorMsgPayload
(
pCmd
),
msg4
);
}
}
}
}
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
...
@@ -3336,16 +3328,6 @@ static int32_t setCompactVnodeInfo(SSqlObj* pSql, struct SSqlInfo* pInfo) {
...
@@ -3336,16 +3328,6 @@ static int32_t setCompactVnodeInfo(SSqlObj* pSql, struct SSqlInfo* pInfo) {
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
bool
validateIpAddress
(
const
char
*
ip
,
size_t
size
)
{
char
tmp
[
128
]
=
{
0
};
// buffer to build null-terminated string
assert
(
size
<
128
);
strncpy
(
tmp
,
ip
,
size
);
in_addr_t
epAddr
=
taosInetAddr
(
tmp
);
return
epAddr
!=
INADDR_NONE
;
}
int32_t
tscTansformFuncForSTableQuery
(
SQueryInfo
*
pQueryInfo
)
{
int32_t
tscTansformFuncForSTableQuery
(
SQueryInfo
*
pQueryInfo
)
{
STableMetaInfo
*
pTableMetaInfo
=
tscGetMetaInfo
(
pQueryInfo
,
0
);
STableMetaInfo
*
pTableMetaInfo
=
tscGetMetaInfo
(
pQueryInfo
,
0
);
...
@@ -4482,15 +4464,17 @@ static int32_t validateNullExpr(tSqlExpr* pExpr, STableMeta* pTableMeta, int32_t
...
@@ -4482,15 +4464,17 @@ static int32_t validateNullExpr(tSqlExpr* pExpr, STableMeta* pTableMeta, int32_t
// check for like expression
// check for like expression
static
int32_t
validateLikeExpr
(
tSqlExpr
*
pExpr
,
STableMeta
*
pTableMeta
,
int32_t
index
,
char
*
msgBuf
)
{
static
int32_t
validateLikeExpr
(
tSqlExpr
*
pExpr
,
STableMeta
*
pTableMeta
,
int32_t
index
,
char
*
msgBuf
)
{
const
char
*
msg1
=
"wildcard string should be less than
20
characters"
;
const
char
*
msg1
=
"wildcard string should be less than
%d
characters"
;
const
char
*
msg2
=
"illegal column type for like"
;
const
char
*
msg2
=
"illegal column type for like"
;
tSqlExpr
*
pLeft
=
pExpr
->
pLeft
;
tSqlExpr
*
pLeft
=
pExpr
->
pLeft
;
tSqlExpr
*
pRight
=
pExpr
->
pRight
;
tSqlExpr
*
pRight
=
pExpr
->
pRight
;
if
(
pExpr
->
tokenId
==
TK_LIKE
)
{
if
(
pExpr
->
tokenId
==
TK_LIKE
)
{
if
(
pRight
->
value
.
nLen
>
TSDB_PATTERN_STRING_MAX_LEN
)
{
if
(
pRight
->
value
.
nLen
>
tsMaxWildCardsLen
)
{
return
invalidOperationMsg
(
msgBuf
,
msg1
);
char
tmp
[
64
]
=
{
0
};
sprintf
(
tmp
,
msg1
,
tsMaxWildCardsLen
);
return
invalidOperationMsg
(
msgBuf
,
tmp
);
}
}
SSchema
*
pSchema
=
tscGetTableSchema
(
pTableMeta
);
SSchema
*
pSchema
=
tscGetTableSchema
(
pTableMeta
);
...
@@ -7838,6 +7822,8 @@ int32_t doCheckForStream(SSqlObj* pSql, SSqlInfo* pInfo) {
...
@@ -7838,6 +7822,8 @@ int32_t doCheckForStream(SSqlObj* pSql, SSqlInfo* pInfo) {
const
char
*
msg6
=
"from missing in subclause"
;
const
char
*
msg6
=
"from missing in subclause"
;
const
char
*
msg7
=
"time interval is required"
;
const
char
*
msg7
=
"time interval is required"
;
const
char
*
msg8
=
"the first column should be primary timestamp column"
;
const
char
*
msg8
=
"the first column should be primary timestamp column"
;
const
char
*
msg9
=
"Continuous query do not support sub query"
;
const
char
*
msg10
=
"illegal number of columns"
;
SSqlCmd
*
pCmd
=
&
pSql
->
cmd
;
SSqlCmd
*
pCmd
=
&
pSql
->
cmd
;
SQueryInfo
*
pQueryInfo
=
tscGetQueryInfo
(
pCmd
);
SQueryInfo
*
pQueryInfo
=
tscGetQueryInfo
(
pCmd
);
...
@@ -7858,7 +7844,11 @@ int32_t doCheckForStream(SSqlObj* pSql, SSqlInfo* pInfo) {
...
@@ -7858,7 +7844,11 @@ int32_t doCheckForStream(SSqlObj* pSql, SSqlInfo* pInfo) {
if
(
pFromInfo
==
NULL
||
taosArrayGetSize
(
pFromInfo
->
list
)
==
0
)
{
if
(
pFromInfo
==
NULL
||
taosArrayGetSize
(
pFromInfo
->
list
)
==
0
)
{
return
invalidOperationMsg
(
tscGetErrorMsgPayload
(
pCmd
),
msg6
);
return
invalidOperationMsg
(
tscGetErrorMsgPayload
(
pCmd
),
msg6
);
}
}
if
(
pFromInfo
->
type
==
SQL_NODE_FROM_SUBQUERY
){
return
invalidOperationMsg
(
tscGetErrorMsgPayload
(
pCmd
),
msg9
);
}
SRelElementPair
*
p1
=
taosArrayGet
(
pFromInfo
->
list
,
0
);
SRelElementPair
*
p1
=
taosArrayGet
(
pFromInfo
->
list
,
0
);
SStrToken
srcToken
=
{.
z
=
p1
->
tableName
.
z
,
.
n
=
p1
->
tableName
.
n
,
.
type
=
TK_STRING
};
SStrToken
srcToken
=
{.
z
=
p1
->
tableName
.
z
,
.
n
=
p1
->
tableName
.
n
,
.
type
=
TK_STRING
};
if
(
tscValidateName
(
&
srcToken
)
!=
TSDB_CODE_SUCCESS
)
{
if
(
tscValidateName
(
&
srcToken
)
!=
TSDB_CODE_SUCCESS
)
{
...
@@ -7920,7 +7910,9 @@ int32_t doCheckForStream(SSqlObj* pSql, SSqlInfo* pInfo) {
...
@@ -7920,7 +7910,9 @@ int32_t doCheckForStream(SSqlObj* pSql, SSqlInfo* pInfo) {
return
TSDB_CODE_TSC_INVALID_OPERATION
;
return
TSDB_CODE_TSC_INVALID_OPERATION
;
}
}
pCmd
->
numOfCols
=
pQueryInfo
->
fieldsInfo
.
numOfOutput
;
if
(
pQueryInfo
->
fieldsInfo
.
numOfOutput
<=
1
)
{
return
invalidOperationMsg
(
tscGetErrorMsgPayload
(
pCmd
),
msg10
);
}
if
(
validateSqlFunctionInStreamSql
(
pCmd
,
pQueryInfo
)
!=
TSDB_CODE_SUCCESS
)
{
if
(
validateSqlFunctionInStreamSql
(
pCmd
,
pQueryInfo
)
!=
TSDB_CODE_SUCCESS
)
{
return
TSDB_CODE_TSC_INVALID_OPERATION
;
return
TSDB_CODE_TSC_INVALID_OPERATION
;
...
...
src/client/src/tscServer.c
浏览文件 @
7b67e43c
...
@@ -501,6 +501,15 @@ static void doProcessMsgFromServer(SSchedMsg* pSchedMsg) {
...
@@ -501,6 +501,15 @@ static void doProcessMsgFromServer(SSchedMsg* pSchedMsg) {
pRes
->
code
=
rpcMsg
->
code
;
pRes
->
code
=
rpcMsg
->
code
;
}
}
rpcMsg
->
code
=
(
pRes
->
code
==
TSDB_CODE_SUCCESS
)
?
(
int32_t
)
pRes
->
numOfRows
:
pRes
->
code
;
rpcMsg
->
code
=
(
pRes
->
code
==
TSDB_CODE_SUCCESS
)
?
(
int32_t
)
pRes
->
numOfRows
:
pRes
->
code
;
if
(
pRes
->
code
==
TSDB_CODE_RPC_FQDN_ERROR
)
{
if
(
pEpSet
)
{
char
buf
[
TSDB_FQDN_LEN
+
64
]
=
{
0
};
tscAllocPayload
(
pCmd
,
sizeof
(
buf
));
sprintf
(
tscGetErrorMsgPayload
(
pCmd
),
"%s
\"
%s
\"
"
,
tstrerror
(
pRes
->
code
),
pEpSet
->
fqdn
[(
pEpSet
->
inUse
)
%
(
pEpSet
->
numOfEps
)]);
}
else
{
sprintf
(
tscGetErrorMsgPayload
(
pCmd
),
"%s"
,
tstrerror
(
pRes
->
code
));
}
}
(
*
pSql
->
fp
)(
pSql
->
param
,
pSql
,
rpcMsg
->
code
);
(
*
pSql
->
fp
)(
pSql
->
param
,
pSql
,
rpcMsg
->
code
);
}
}
...
...
src/client/src/tscSql.c
浏览文件 @
7b67e43c
...
@@ -196,6 +196,11 @@ TAOS *taos_connect_internal(const char *ip, const char *user, const char *pass,
...
@@ -196,6 +196,11 @@ TAOS *taos_connect_internal(const char *ip, const char *user, const char *pass,
if
(
pSql
->
res
.
code
!=
TSDB_CODE_SUCCESS
)
{
if
(
pSql
->
res
.
code
!=
TSDB_CODE_SUCCESS
)
{
terrno
=
pSql
->
res
.
code
;
terrno
=
pSql
->
res
.
code
;
if
(
terrno
==
TSDB_CODE_RPC_FQDN_ERROR
)
{
printf
(
"taos connect failed, reason: %s
\n\n
"
,
taos_errstr
(
pSql
));
}
else
{
printf
(
"taos connect failed, reason: %s.
\n\n
"
,
tstrerror
(
terrno
));
}
taos_free_result
(
pSql
);
taos_free_result
(
pSql
);
taos_close
(
pObj
);
taos_close
(
pObj
);
return
NULL
;
return
NULL
;
...
@@ -643,7 +648,7 @@ char *taos_errstr(TAOS_RES *tres) {
...
@@ -643,7 +648,7 @@ char *taos_errstr(TAOS_RES *tres) {
return
(
char
*
)
tstrerror
(
terrno
);
return
(
char
*
)
tstrerror
(
terrno
);
}
}
if
(
hasAdditionalErrorInfo
(
pSql
->
res
.
code
,
&
pSql
->
cmd
))
{
if
(
hasAdditionalErrorInfo
(
pSql
->
res
.
code
,
&
pSql
->
cmd
)
||
pSql
->
res
.
code
==
TSDB_CODE_RPC_FQDN_ERROR
)
{
return
pSql
->
cmd
.
payload
;
return
pSql
->
cmd
.
payload
;
}
else
{
}
else
{
return
(
char
*
)
tstrerror
(
pSql
->
res
.
code
);
return
(
char
*
)
tstrerror
(
pSql
->
res
.
code
);
...
...
src/common/inc/tglobal.h
浏览文件 @
7b67e43c
...
@@ -70,6 +70,7 @@ extern int8_t tsKeepOriginalColumnName;
...
@@ -70,6 +70,7 @@ extern int8_t tsKeepOriginalColumnName;
// client
// client
extern
int32_t
tsMaxSQLStringLen
;
extern
int32_t
tsMaxSQLStringLen
;
extern
int32_t
tsMaxWildCardsLen
;
extern
int8_t
tsTscEnableRecordSql
;
extern
int8_t
tsTscEnableRecordSql
;
extern
int32_t
tsMaxNumOfOrderedResults
;
extern
int32_t
tsMaxNumOfOrderedResults
;
extern
int32_t
tsMinSlidingTime
;
extern
int32_t
tsMinSlidingTime
;
...
...
src/common/src/tglobal.c
浏览文件 @
7b67e43c
...
@@ -25,6 +25,7 @@
...
@@ -25,6 +25,7 @@
#include "tutil.h"
#include "tutil.h"
#include "tlocale.h"
#include "tlocale.h"
#include "ttimezone.h"
#include "ttimezone.h"
#include "tcompare.h"
// cluster
// cluster
char
tsFirst
[
TSDB_EP_LEN
]
=
{
0
};
char
tsFirst
[
TSDB_EP_LEN
]
=
{
0
};
...
@@ -75,6 +76,7 @@ int32_t tsCompressMsgSize = -1;
...
@@ -75,6 +76,7 @@ int32_t tsCompressMsgSize = -1;
// client
// client
int32_t
tsMaxSQLStringLen
=
TSDB_MAX_ALLOWED_SQL_LEN
;
int32_t
tsMaxSQLStringLen
=
TSDB_MAX_ALLOWED_SQL_LEN
;
int32_t
tsMaxWildCardsLen
=
TSDB_PATTERN_STRING_MAX_LEN
;
int8_t
tsTscEnableRecordSql
=
0
;
int8_t
tsTscEnableRecordSql
=
0
;
// the maximum number of results for projection query on super table that are returned from
// the maximum number of results for projection query on super table that are returned from
...
@@ -984,6 +986,16 @@ static void doInitGlobalConfig(void) {
...
@@ -984,6 +986,16 @@ static void doInitGlobalConfig(void) {
cfg
.
unitType
=
TAOS_CFG_UTYPE_BYTE
;
cfg
.
unitType
=
TAOS_CFG_UTYPE_BYTE
;
taosInitConfigOption
(
cfg
);
taosInitConfigOption
(
cfg
);
cfg
.
option
=
"maxWildCardsLength"
;
cfg
.
ptr
=
&
tsMaxWildCardsLen
;
cfg
.
valType
=
TAOS_CFG_VTYPE_INT32
;
cfg
.
cfgType
=
TSDB_CFG_CTYPE_B_CONFIG
|
TSDB_CFG_CTYPE_B_CLIENT
|
TSDB_CFG_CTYPE_B_SHOW
;
cfg
.
minValue
=
0
;
cfg
.
maxValue
=
TSDB_MAX_ALLOWED_SQL_LEN
;
cfg
.
ptrLength
=
0
;
cfg
.
unitType
=
TAOS_CFG_UTYPE_BYTE
;
taosInitConfigOption
(
cfg
);
cfg
.
option
=
"maxNumOfOrderedRes"
;
cfg
.
option
=
"maxNumOfOrderedRes"
;
cfg
.
ptr
=
&
tsMaxNumOfOrderedResults
;
cfg
.
ptr
=
&
tsMaxNumOfOrderedResults
;
cfg
.
valType
=
TAOS_CFG_VTYPE_INT32
;
cfg
.
valType
=
TAOS_CFG_VTYPE_INT32
;
...
@@ -1531,6 +1543,7 @@ static void doInitGlobalConfig(void) {
...
@@ -1531,6 +1543,7 @@ static void doInitGlobalConfig(void) {
cfg
.
unitType
=
TAOS_CFG_UTYPE_NONE
;
cfg
.
unitType
=
TAOS_CFG_UTYPE_NONE
;
taosInitConfigOption
(
cfg
);
taosInitConfigOption
(
cfg
);
assert
(
tsGlobalConfigNum
<=
TSDB_CFG_MAX_NUM
);
#ifdef TD_TSZ
#ifdef TD_TSZ
// lossy compress
// lossy compress
cfg
.
option
=
"lossyColumns"
;
cfg
.
option
=
"lossyColumns"
;
...
...
src/connector/jdbc/pom.xml
浏览文件 @
7b67e43c
...
@@ -113,7 +113,6 @@
...
@@ -113,7 +113,6 @@
</includes>
</includes>
<excludes>
<excludes>
<exclude>
**/AppMemoryLeakTest.java
</exclude>
<exclude>
**/AppMemoryLeakTest.java
</exclude>
<exclude>
**/AuthenticationTest.java
</exclude>
<exclude>
**/ConnectMultiTaosdByRestfulWithDifferentTokenTest.java
</exclude>
<exclude>
**/ConnectMultiTaosdByRestfulWithDifferentTokenTest.java
</exclude>
<exclude>
**/DatetimeBefore1970Test.java
</exclude>
<exclude>
**/DatetimeBefore1970Test.java
</exclude>
<exclude>
**/FailOverTest.java
</exclude>
<exclude>
**/FailOverTest.java
</exclude>
...
...
src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBDriver.java
浏览文件 @
7b67e43c
...
@@ -14,6 +14,8 @@
...
@@ -14,6 +14,8 @@
*****************************************************************************/
*****************************************************************************/
package
com.taosdata.jdbc
;
package
com.taosdata.jdbc
;
import
java.net.URLEncoder
;
import
java.nio.charset.StandardCharsets
;
import
java.sql.*
;
import
java.sql.*
;
import
java.util.*
;
import
java.util.*
;
import
java.util.logging.Logger
;
import
java.util.logging.Logger
;
...
@@ -127,6 +129,11 @@ public class TSDBDriver extends AbstractDriver {
...
@@ -127,6 +129,11 @@ public class TSDBDriver extends AbstractDriver {
return
null
;
return
null
;
}
}
if
(!
props
.
containsKey
(
TSDBDriver
.
PROPERTY_KEY_USER
))
throw
TSDBError
.
createSQLException
(
TSDBErrorNumbers
.
ERROR_USER_IS_REQUIRED
);
if
(!
props
.
containsKey
(
TSDBDriver
.
PROPERTY_KEY_PASSWORD
))
throw
TSDBError
.
createSQLException
(
TSDBErrorNumbers
.
ERROR_PASSWORD_IS_REQUIRED
);
try
{
try
{
TSDBJNIConnector
.
init
((
String
)
props
.
get
(
PROPERTY_KEY_CONFIG_DIR
),
(
String
)
props
.
get
(
PROPERTY_KEY_LOCALE
),
TSDBJNIConnector
.
init
((
String
)
props
.
get
(
PROPERTY_KEY_CONFIG_DIR
),
(
String
)
props
.
get
(
PROPERTY_KEY_LOCALE
),
(
String
)
props
.
get
(
PROPERTY_KEY_CHARSET
),
(
String
)
props
.
get
(
PROPERTY_KEY_TIME_ZONE
));
(
String
)
props
.
get
(
PROPERTY_KEY_CHARSET
),
(
String
)
props
.
get
(
PROPERTY_KEY_TIME_ZONE
));
...
...
src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBError.java
浏览文件 @
7b67e43c
...
@@ -33,6 +33,8 @@ public class TSDBError {
...
@@ -33,6 +33,8 @@ public class TSDBError {
TSDBErrorMap
.
put
(
TSDBErrorNumbers
.
ERROR_NUMERIC_VALUE_OUT_OF_RANGE
,
"numeric value out of range"
);
TSDBErrorMap
.
put
(
TSDBErrorNumbers
.
ERROR_NUMERIC_VALUE_OUT_OF_RANGE
,
"numeric value out of range"
);
TSDBErrorMap
.
put
(
TSDBErrorNumbers
.
ERROR_UNKNOWN_TAOS_TYPE
,
"unknown taos type in tdengine"
);
TSDBErrorMap
.
put
(
TSDBErrorNumbers
.
ERROR_UNKNOWN_TAOS_TYPE
,
"unknown taos type in tdengine"
);
TSDBErrorMap
.
put
(
TSDBErrorNumbers
.
ERROR_UNKNOWN_TIMESTAMP_PRECISION
,
"unknown timestamp precision"
);
TSDBErrorMap
.
put
(
TSDBErrorNumbers
.
ERROR_UNKNOWN_TIMESTAMP_PRECISION
,
"unknown timestamp precision"
);
TSDBErrorMap
.
put
(
TSDBErrorNumbers
.
ERROR_USER_IS_REQUIRED
,
"user is required"
);
TSDBErrorMap
.
put
(
TSDBErrorNumbers
.
ERROR_PASSWORD_IS_REQUIRED
,
"password is required"
);
TSDBErrorMap
.
put
(
TSDBErrorNumbers
.
ERROR_UNKNOWN
,
"unknown error"
);
TSDBErrorMap
.
put
(
TSDBErrorNumbers
.
ERROR_UNKNOWN
,
"unknown error"
);
...
...
src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBErrorNumbers.java
浏览文件 @
7b67e43c
...
@@ -29,6 +29,9 @@ public class TSDBErrorNumbers {
...
@@ -29,6 +29,9 @@ public class TSDBErrorNumbers {
public
static
final
int
ERROR_UNKNOWN_TIMESTAMP_PRECISION
=
0x2316
;
// unknown timestamp precision
public
static
final
int
ERROR_UNKNOWN_TIMESTAMP_PRECISION
=
0x2316
;
// unknown timestamp precision
public
static
final
int
ERROR_RESTFul_Client_Protocol_Exception
=
0x2317
;
public
static
final
int
ERROR_RESTFul_Client_Protocol_Exception
=
0x2317
;
public
static
final
int
ERROR_RESTFul_Client_IOException
=
0x2318
;
public
static
final
int
ERROR_RESTFul_Client_IOException
=
0x2318
;
public
static
final
int
ERROR_USER_IS_REQUIRED
=
0x2319
;
// user is required
public
static
final
int
ERROR_PASSWORD_IS_REQUIRED
=
0x231a
;
// password is required
public
static
final
int
ERROR_UNKNOWN
=
0x2350
;
//unknown error
public
static
final
int
ERROR_UNKNOWN
=
0x2350
;
//unknown error
...
@@ -67,6 +70,8 @@ public class TSDBErrorNumbers {
...
@@ -67,6 +70,8 @@ public class TSDBErrorNumbers {
errorNumbers
.
add
(
ERROR_UNKNOWN_TAOS_TYPE
);
errorNumbers
.
add
(
ERROR_UNKNOWN_TAOS_TYPE
);
errorNumbers
.
add
(
ERROR_UNKNOWN_TIMESTAMP_PRECISION
);
errorNumbers
.
add
(
ERROR_UNKNOWN_TIMESTAMP_PRECISION
);
errorNumbers
.
add
(
ERROR_RESTFul_Client_IOException
);
errorNumbers
.
add
(
ERROR_RESTFul_Client_IOException
);
errorNumbers
.
add
(
ERROR_USER_IS_REQUIRED
);
errorNumbers
.
add
(
ERROR_PASSWORD_IS_REQUIRED
);
errorNumbers
.
add
(
ERROR_RESTFul_Client_Protocol_Exception
);
errorNumbers
.
add
(
ERROR_RESTFul_Client_Protocol_Exception
);
...
...
src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBJNIConnector.java
浏览文件 @
7b67e43c
...
@@ -36,7 +36,6 @@ public class TSDBJNIConnector {
...
@@ -36,7 +36,6 @@ public class TSDBJNIConnector {
static
{
static
{
System
.
loadLibrary
(
"taos"
);
System
.
loadLibrary
(
"taos"
);
System
.
out
.
println
(
"java.library.path:"
+
System
.
getProperty
(
"java.library.path"
));
}
}
public
boolean
isClosed
()
{
public
boolean
isClosed
()
{
...
...
src/connector/jdbc/src/main/java/com/taosdata/jdbc/rs/RestfulDriver.java
浏览文件 @
7b67e43c
...
@@ -7,6 +7,7 @@ import com.taosdata.jdbc.utils.HttpClientPoolUtil;
...
@@ -7,6 +7,7 @@ import com.taosdata.jdbc.utils.HttpClientPoolUtil;
import
java.io.UnsupportedEncodingException
;
import
java.io.UnsupportedEncodingException
;
import
java.net.URLEncoder
;
import
java.net.URLEncoder
;
import
java.nio.charset.StandardCharsets
;
import
java.sql.*
;
import
java.sql.*
;
import
java.util.Properties
;
import
java.util.Properties
;
import
java.util.logging.Logger
;
import
java.util.logging.Logger
;
...
@@ -40,8 +41,13 @@ public class RestfulDriver extends AbstractDriver {
...
@@ -40,8 +41,13 @@ public class RestfulDriver extends AbstractDriver {
String
loginUrl
=
"http://"
+
host
+
":"
+
port
+
"/rest/login/"
+
props
.
getProperty
(
TSDBDriver
.
PROPERTY_KEY_USER
)
+
"/"
+
props
.
getProperty
(
TSDBDriver
.
PROPERTY_KEY_PASSWORD
)
+
""
;
String
loginUrl
=
"http://"
+
host
+
":"
+
port
+
"/rest/login/"
+
props
.
getProperty
(
TSDBDriver
.
PROPERTY_KEY_USER
)
+
"/"
+
props
.
getProperty
(
TSDBDriver
.
PROPERTY_KEY_PASSWORD
)
+
""
;
try
{
try
{
String
user
=
URLEncoder
.
encode
(
props
.
getProperty
(
TSDBDriver
.
PROPERTY_KEY_USER
),
"UTF-8"
);
if
(!
props
.
containsKey
(
TSDBDriver
.
PROPERTY_KEY_USER
))
String
password
=
URLEncoder
.
encode
(
props
.
getProperty
(
TSDBDriver
.
PROPERTY_KEY_PASSWORD
),
"UTF-8"
);
throw
TSDBError
.
createSQLException
(
TSDBErrorNumbers
.
ERROR_USER_IS_REQUIRED
);
if
(!
props
.
containsKey
(
TSDBDriver
.
PROPERTY_KEY_PASSWORD
))
throw
TSDBError
.
createSQLException
(
TSDBErrorNumbers
.
ERROR_PASSWORD_IS_REQUIRED
);
String
user
=
URLEncoder
.
encode
(
props
.
getProperty
(
TSDBDriver
.
PROPERTY_KEY_USER
),
StandardCharsets
.
UTF_8
.
displayName
());
String
password
=
URLEncoder
.
encode
(
props
.
getProperty
(
TSDBDriver
.
PROPERTY_KEY_PASSWORD
),
StandardCharsets
.
UTF_8
.
displayName
());
loginUrl
=
"http://"
+
props
.
getProperty
(
TSDBDriver
.
PROPERTY_KEY_HOST
)
+
":"
+
props
.
getProperty
(
TSDBDriver
.
PROPERTY_KEY_PORT
)
+
"/rest/login/"
+
user
+
"/"
+
password
+
""
;
loginUrl
=
"http://"
+
props
.
getProperty
(
TSDBDriver
.
PROPERTY_KEY_HOST
)
+
":"
+
props
.
getProperty
(
TSDBDriver
.
PROPERTY_KEY_PORT
)
+
"/rest/login/"
+
user
+
"/"
+
password
+
""
;
}
catch
(
UnsupportedEncodingException
e
)
{
}
catch
(
UnsupportedEncodingException
e
)
{
e
.
printStackTrace
();
e
.
printStackTrace
();
...
...
src/connector/jdbc/src/main/java/com/taosdata/jdbc/rs/RestfulStatement.java
浏览文件 @
7b67e43c
...
@@ -7,6 +7,7 @@ import com.taosdata.jdbc.AbstractStatement;
...
@@ -7,6 +7,7 @@ import com.taosdata.jdbc.AbstractStatement;
import
com.taosdata.jdbc.TSDBDriver
;
import
com.taosdata.jdbc.TSDBDriver
;
import
com.taosdata.jdbc.TSDBError
;
import
com.taosdata.jdbc.TSDBError
;
import
com.taosdata.jdbc.TSDBErrorNumbers
;
import
com.taosdata.jdbc.TSDBErrorNumbers
;
import
com.taosdata.jdbc.enums.TimestampFormat
;
import
com.taosdata.jdbc.utils.HttpClientPoolUtil
;
import
com.taosdata.jdbc.utils.HttpClientPoolUtil
;
import
com.taosdata.jdbc.utils.SqlSyntaxValidator
;
import
com.taosdata.jdbc.utils.SqlSyntaxValidator
;
...
@@ -45,9 +46,7 @@ public class RestfulStatement extends AbstractStatement {
...
@@ -45,9 +46,7 @@ public class RestfulStatement extends AbstractStatement {
if
(!
SqlSyntaxValidator
.
isValidForExecuteUpdate
(
sql
))
if
(!
SqlSyntaxValidator
.
isValidForExecuteUpdate
(
sql
))
throw
TSDBError
.
createSQLException
(
TSDBErrorNumbers
.
ERROR_INVALID_FOR_EXECUTE_UPDATE
,
"not a valid sql for executeUpdate: "
+
sql
);
throw
TSDBError
.
createSQLException
(
TSDBErrorNumbers
.
ERROR_INVALID_FOR_EXECUTE_UPDATE
,
"not a valid sql for executeUpdate: "
+
sql
);
final
String
url
=
"http://"
+
conn
.
getHost
()
+
":"
+
conn
.
getPort
()
+
"/rest/sql"
;
return
executeOneUpdate
(
sql
);
return
executeOneUpdate
(
url
,
sql
);
}
}
@Override
@Override
...
@@ -62,34 +61,25 @@ public class RestfulStatement extends AbstractStatement {
...
@@ -62,34 +61,25 @@ public class RestfulStatement extends AbstractStatement {
public
boolean
execute
(
String
sql
)
throws
SQLException
{
public
boolean
execute
(
String
sql
)
throws
SQLException
{
if
(
isClosed
())
if
(
isClosed
())
throw
TSDBError
.
createSQLException
(
TSDBErrorNumbers
.
ERROR_STATEMENT_CLOSED
);
throw
TSDBError
.
createSQLException
(
TSDBErrorNumbers
.
ERROR_STATEMENT_CLOSED
);
if
(!
SqlSyntaxValidator
.
isValidForExecute
(
sql
))
throw
TSDBError
.
createSQLException
(
TSDBErrorNumbers
.
ERROR_INVALID_FOR_EXECUTE
,
"not a valid sql for execute: "
+
sql
);
//如果执行了use操作应该将当前Statement的catalog设置为新的database
//如果执行了use操作应该将当前Statement的catalog设置为新的database
boolean
result
=
true
;
boolean
result
=
true
;
String
url
=
"http://"
+
conn
.
getHost
()
+
":"
+
conn
.
getPort
()
+
"/rest/sql"
;
if
(
conn
.
getClientInfo
(
TSDBDriver
.
PROPERTY_KEY_TIMESTAMP_FORMAT
).
equals
(
"TIMESTAMP"
))
{
url
=
"http://"
+
conn
.
getHost
()
+
":"
+
conn
.
getPort
()
+
"/rest/sqlt"
;
}
if
(
conn
.
getClientInfo
(
TSDBDriver
.
PROPERTY_KEY_TIMESTAMP_FORMAT
).
equals
(
"UTC"
))
{
url
=
"http://"
+
conn
.
getHost
()
+
":"
+
conn
.
getPort
()
+
"/rest/sqlutc"
;
}
if
(
SqlSyntaxValidator
.
isUseSql
(
sql
))
{
if
(
SqlSyntaxValidator
.
isUseSql
(
sql
))
{
HttpClientPoolUtil
.
execute
(
url
,
sql
,
this
.
conn
.
getToken
());
HttpClientPoolUtil
.
execute
(
getUrl
()
,
sql
,
this
.
conn
.
getToken
());
this
.
database
=
sql
.
trim
().
replace
(
"use"
,
""
).
trim
();
this
.
database
=
sql
.
trim
().
replace
(
"use"
,
""
).
trim
();
this
.
conn
.
setCatalog
(
this
.
database
);
this
.
conn
.
setCatalog
(
this
.
database
);
result
=
false
;
result
=
false
;
}
else
if
(
SqlSyntaxValidator
.
isDatabaseUnspecifiedQuery
(
sql
))
{
}
else
if
(
SqlSyntaxValidator
.
isDatabaseUnspecifiedQuery
(
sql
))
{
executeOneQuery
(
sql
);
executeOneQuery
(
sql
);
}
else
if
(
SqlSyntaxValidator
.
isDatabaseUnspecifiedUpdate
(
sql
))
{
}
else
if
(
SqlSyntaxValidator
.
isDatabaseUnspecifiedUpdate
(
sql
))
{
executeOneUpdate
(
url
,
sql
);
executeOneUpdate
(
sql
);
result
=
false
;
result
=
false
;
}
else
{
}
else
{
if
(
SqlSyntaxValidator
.
isValidForExecuteQuery
(
sql
))
{
if
(
SqlSyntaxValidator
.
isValidForExecuteQuery
(
sql
))
{
executeQuery
(
sql
);
execute
One
Query
(
sql
);
}
else
{
}
else
{
executeUpdate
(
sql
);
execute
One
Update
(
sql
);
result
=
false
;
result
=
false
;
}
}
}
}
...
@@ -97,19 +87,25 @@ public class RestfulStatement extends AbstractStatement {
...
@@ -97,19 +87,25 @@ public class RestfulStatement extends AbstractStatement {
return
result
;
return
result
;
}
}
private
ResultSet
executeOneQuery
(
String
sql
)
throws
SQLException
{
private
String
getUrl
()
throws
SQLException
{
if
(!
SqlSyntaxValidator
.
isValidForExecuteQuery
(
sql
))
TimestampFormat
timestampFormat
=
TimestampFormat
.
valueOf
(
conn
.
getClientInfo
(
TSDBDriver
.
PROPERTY_KEY_TIMESTAMP_FORMAT
).
trim
().
toUpperCase
());
throw
TSDBError
.
createSQLException
(
TSDBErrorNumbers
.
ERROR_INVALID_FOR_EXECUTE_QUERY
,
"not a valid sql for executeQuery: "
+
sql
);
String
url
;
switch
(
timestampFormat
)
{
case
TIMESTAMP:
url
=
"http://"
+
conn
.
getHost
()
+
":"
+
conn
.
getPort
()
+
"/rest/sqlt"
;
break
;
case
UTC:
url
=
"http://"
+
conn
.
getHost
()
+
":"
+
conn
.
getPort
()
+
"/rest/sqlutc"
;
break
;
default
:
url
=
"http://"
+
conn
.
getHost
()
+
":"
+
conn
.
getPort
()
+
"/rest/sql"
;
}
return
url
;
}
private
ResultSet
executeOneQuery
(
String
sql
)
throws
SQLException
{
// row data
// row data
String
url
=
"http://"
+
conn
.
getHost
()
+
":"
+
conn
.
getPort
()
+
"/rest/sql"
;
String
result
=
HttpClientPoolUtil
.
execute
(
getUrl
(),
sql
,
this
.
conn
.
getToken
());
String
timestampFormat
=
conn
.
getClientInfo
(
TSDBDriver
.
PROPERTY_KEY_TIMESTAMP_FORMAT
);
if
(
"TIMESTAMP"
.
equalsIgnoreCase
(
timestampFormat
))
url
=
"http://"
+
conn
.
getHost
()
+
":"
+
conn
.
getPort
()
+
"/rest/sqlt"
;
if
(
"UTC"
.
equalsIgnoreCase
(
timestampFormat
))
url
=
"http://"
+
conn
.
getHost
()
+
":"
+
conn
.
getPort
()
+
"/rest/sqlutc"
;
String
result
=
HttpClientPoolUtil
.
execute
(
url
,
sql
,
this
.
conn
.
getToken
());
JSONObject
resultJson
=
JSON
.
parseObject
(
result
);
JSONObject
resultJson
=
JSON
.
parseObject
(
result
);
if
(
resultJson
.
getString
(
"status"
).
equals
(
"error"
))
{
if
(
resultJson
.
getString
(
"status"
).
equals
(
"error"
))
{
throw
TSDBError
.
createSQLException
(
resultJson
.
getInteger
(
"code"
),
resultJson
.
getString
(
"desc"
));
throw
TSDBError
.
createSQLException
(
resultJson
.
getInteger
(
"code"
),
resultJson
.
getString
(
"desc"
));
...
@@ -119,11 +115,8 @@ public class RestfulStatement extends AbstractStatement {
...
@@ -119,11 +115,8 @@ public class RestfulStatement extends AbstractStatement {
return
resultSet
;
return
resultSet
;
}
}
private
int
executeOneUpdate
(
String
url
,
String
sql
)
throws
SQLException
{
private
int
executeOneUpdate
(
String
sql
)
throws
SQLException
{
if
(!
SqlSyntaxValidator
.
isValidForExecuteUpdate
(
sql
))
String
result
=
HttpClientPoolUtil
.
execute
(
getUrl
(),
sql
,
this
.
conn
.
getToken
());
throw
TSDBError
.
createSQLException
(
TSDBErrorNumbers
.
ERROR_INVALID_FOR_EXECUTE_UPDATE
,
"not a valid sql for executeUpdate: "
+
sql
);
String
result
=
HttpClientPoolUtil
.
execute
(
url
,
sql
,
this
.
conn
.
getToken
());
JSONObject
jsonObject
=
JSON
.
parseObject
(
result
);
JSONObject
jsonObject
=
JSON
.
parseObject
(
result
);
if
(
jsonObject
.
getString
(
"status"
).
equals
(
"error"
))
{
if
(
jsonObject
.
getString
(
"status"
).
equals
(
"error"
))
{
throw
TSDBError
.
createSQLException
(
jsonObject
.
getInteger
(
"code"
),
jsonObject
.
getString
(
"desc"
));
throw
TSDBError
.
createSQLException
(
jsonObject
.
getInteger
(
"code"
),
jsonObject
.
getString
(
"desc"
));
...
@@ -134,7 +127,7 @@ public class RestfulStatement extends AbstractStatement {
...
@@ -134,7 +127,7 @@ public class RestfulStatement extends AbstractStatement {
}
}
private
int
getAffectedRows
(
JSONObject
jsonObject
)
throws
SQLException
{
private
int
getAffectedRows
(
JSONObject
jsonObject
)
throws
SQLException
{
// create ... SQLs should return 0 , and Restful result
is
this:
// create ... SQLs should return 0 , and Restful result
like
this:
// {"status": "succ", "head": ["affected_rows"], "data": [[0]], "rows": 1}
// {"status": "succ", "head": ["affected_rows"], "data": [[0]], "rows": 1}
JSONArray
head
=
jsonObject
.
getJSONArray
(
"head"
);
JSONArray
head
=
jsonObject
.
getJSONArray
(
"head"
);
if
(
head
.
size
()
!=
1
||
!
"affected_rows"
.
equals
(
head
.
getString
(
0
)))
if
(
head
.
size
()
!=
1
||
!
"affected_rows"
.
equals
(
head
.
getString
(
0
)))
...
...
src/connector/jdbc/src/main/java/com/taosdata/jdbc/utils/SqlSyntaxValidator.java
浏览文件 @
7b67e43c
...
@@ -16,8 +16,7 @@ package com.taosdata.jdbc.utils;
...
@@ -16,8 +16,7 @@ package com.taosdata.jdbc.utils;
public
class
SqlSyntaxValidator
{
public
class
SqlSyntaxValidator
{
private
static
final
String
[]
SQL
=
{
"select"
,
"insert"
,
"import"
,
"create"
,
"use"
,
"alter"
,
"drop"
,
"set"
,
"show"
,
"describe"
,
"reset"
};
private
static
final
String
[]
updateSQL
=
{
"insert"
,
"import"
,
"create"
,
"use"
,
"alter"
,
"drop"
,
"set"
,
"reset"
};
private
static
final
String
[]
updateSQL
=
{
"insert"
,
"import"
,
"create"
,
"use"
,
"alter"
,
"drop"
,
"set"
};
private
static
final
String
[]
querySQL
=
{
"select"
,
"show"
,
"describe"
};
private
static
final
String
[]
querySQL
=
{
"select"
,
"show"
,
"describe"
};
private
static
final
String
[]
databaseUnspecifiedShow
=
{
"databases"
,
"dnodes"
,
"mnodes"
,
"variables"
};
private
static
final
String
[]
databaseUnspecifiedShow
=
{
"databases"
,
"dnodes"
,
"mnodes"
,
"variables"
};
...
@@ -38,14 +37,6 @@ public class SqlSyntaxValidator {
...
@@ -38,14 +37,6 @@ public class SqlSyntaxValidator {
return
false
;
return
false
;
}
}
public
static
boolean
isValidForExecute
(
String
sql
)
{
for
(
String
prefix
:
SQL
)
{
if
(
sql
.
trim
().
toLowerCase
().
startsWith
(
prefix
))
return
true
;
}
return
false
;
}
public
static
boolean
isDatabaseUnspecifiedQuery
(
String
sql
)
{
public
static
boolean
isDatabaseUnspecifiedQuery
(
String
sql
)
{
for
(
String
databaseObj
:
databaseUnspecifiedShow
)
{
for
(
String
databaseObj
:
databaseUnspecifiedShow
)
{
if
(
sql
.
trim
().
toLowerCase
().
matches
(
"show\\s+"
+
databaseObj
+
".*"
))
if
(
sql
.
trim
().
toLowerCase
().
matches
(
"show\\s+"
+
databaseObj
+
".*"
))
...
@@ -63,9 +54,5 @@ public class SqlSyntaxValidator {
...
@@ -63,9 +54,5 @@ public class SqlSyntaxValidator {
return
sql
.
trim
().
toLowerCase
().
startsWith
(
"use"
);
return
sql
.
trim
().
toLowerCase
().
startsWith
(
"use"
);
}
}
public
static
boolean
isSelectSql
(
String
sql
)
{
return
sql
.
trim
().
toLowerCase
().
startsWith
(
"select"
);
}
}
}
src/connector/jdbc/src/test/java/com/taosdata/jdbc/SubscribeTest.java
浏览文件 @
7b67e43c
...
@@ -69,6 +69,8 @@ public class SubscribeTest {
...
@@ -69,6 +69,8 @@ public class SubscribeTest {
@Before
@Before
public
void
createDatabase
()
throws
SQLException
{
public
void
createDatabase
()
throws
SQLException
{
Properties
properties
=
new
Properties
();
Properties
properties
=
new
Properties
();
properties
.
setProperty
(
TSDBDriver
.
PROPERTY_KEY_USER
,
"root"
);
properties
.
setProperty
(
TSDBDriver
.
PROPERTY_KEY_PASSWORD
,
"taosdata"
);
properties
.
setProperty
(
TSDBDriver
.
PROPERTY_KEY_CHARSET
,
"UTF-8"
);
properties
.
setProperty
(
TSDBDriver
.
PROPERTY_KEY_CHARSET
,
"UTF-8"
);
properties
.
setProperty
(
TSDBDriver
.
PROPERTY_KEY_LOCALE
,
"en_US.UTF-8"
);
properties
.
setProperty
(
TSDBDriver
.
PROPERTY_KEY_LOCALE
,
"en_US.UTF-8"
);
properties
.
setProperty
(
TSDBDriver
.
PROPERTY_KEY_TIME_ZONE
,
"UTC-8"
);
properties
.
setProperty
(
TSDBDriver
.
PROPERTY_KEY_TIME_ZONE
,
"UTC-8"
);
...
...
src/connector/jdbc/src/test/java/com/taosdata/jdbc/cases/AuthenticationTest.java
浏览文件 @
7b67e43c
package
com.taosdata.jdbc.cases
;
package
com.taosdata.jdbc.cases
;
import
com.taosdata.jdbc.TSDBErrorNumbers
;
import
org.junit.Assert
;
import
org.junit.Before
;
import
org.junit.Before
;
import
org.junit.Ignore
;
import
org.junit.Test
;
import
org.junit.Test
;
import
java.sql.*
;
import
java.sql.*
;
...
@@ -12,6 +15,47 @@ public class AuthenticationTest {
...
@@ -12,6 +15,47 @@ public class AuthenticationTest {
private
static
final
String
password
=
"taos?data"
;
private
static
final
String
password
=
"taos?data"
;
private
Connection
conn
;
private
Connection
conn
;
@Test
public
void
connectWithoutUserByJni
()
{
try
{
DriverManager
.
getConnection
(
"jdbc:TAOS://"
+
host
+
":0/?"
);
}
catch
(
SQLException
e
)
{
Assert
.
assertEquals
(
TSDBErrorNumbers
.
ERROR_USER_IS_REQUIRED
,
e
.
getErrorCode
());
Assert
.
assertEquals
(
"ERROR (2319): user is required"
,
e
.
getMessage
());
}
}
@Test
public
void
connectWithoutUserByRestful
()
{
try
{
DriverManager
.
getConnection
(
"jdbc:TAOS-RS://"
+
host
+
":6041/?"
);
}
catch
(
SQLException
e
)
{
Assert
.
assertEquals
(
TSDBErrorNumbers
.
ERROR_USER_IS_REQUIRED
,
e
.
getErrorCode
());
Assert
.
assertEquals
(
"ERROR (2319): user is required"
,
e
.
getMessage
());
}
}
@Test
public
void
connectWithoutPasswordByJni
()
{
try
{
DriverManager
.
getConnection
(
"jdbc:TAOS://"
+
host
+
":0/?user=root"
);
}
catch
(
SQLException
e
)
{
Assert
.
assertEquals
(
TSDBErrorNumbers
.
ERROR_PASSWORD_IS_REQUIRED
,
e
.
getErrorCode
());
Assert
.
assertEquals
(
"ERROR (231a): password is required"
,
e
.
getMessage
());
}
}
@Test
public
void
connectWithoutPasswordByRestful
()
{
try
{
DriverManager
.
getConnection
(
"jdbc:TAOS-RS://"
+
host
+
":6041/?user=root"
);
}
catch
(
SQLException
e
)
{
Assert
.
assertEquals
(
TSDBErrorNumbers
.
ERROR_PASSWORD_IS_REQUIRED
,
e
.
getErrorCode
());
Assert
.
assertEquals
(
"ERROR (231a): password is required"
,
e
.
getMessage
());
}
}
@Ignore
@Test
@Test
public
void
test
()
{
public
void
test
()
{
// change password
// change password
...
...
src/connector/jdbc/src/test/java/com/taosdata/jdbc/cases/BatchInsertTest.java
浏览文件 @
7b67e43c
...
@@ -29,6 +29,8 @@ public class BatchInsertTest {
...
@@ -29,6 +29,8 @@ public class BatchInsertTest {
public
void
before
()
{
public
void
before
()
{
try
{
try
{
Properties
properties
=
new
Properties
();
Properties
properties
=
new
Properties
();
properties
.
setProperty
(
TSDBDriver
.
PROPERTY_KEY_USER
,
"root"
);
properties
.
setProperty
(
TSDBDriver
.
PROPERTY_KEY_PASSWORD
,
"taosdata"
);
properties
.
setProperty
(
TSDBDriver
.
PROPERTY_KEY_CHARSET
,
"UTF-8"
);
properties
.
setProperty
(
TSDBDriver
.
PROPERTY_KEY_CHARSET
,
"UTF-8"
);
properties
.
setProperty
(
TSDBDriver
.
PROPERTY_KEY_LOCALE
,
"en_US.UTF-8"
);
properties
.
setProperty
(
TSDBDriver
.
PROPERTY_KEY_LOCALE
,
"en_US.UTF-8"
);
properties
.
setProperty
(
TSDBDriver
.
PROPERTY_KEY_TIME_ZONE
,
"UTC-8"
);
properties
.
setProperty
(
TSDBDriver
.
PROPERTY_KEY_TIME_ZONE
,
"UTC-8"
);
...
...
src/connector/jdbc/src/test/java/com/taosdata/jdbc/cases/ImportTest.java
浏览文件 @
7b67e43c
...
@@ -21,6 +21,8 @@ public class ImportTest {
...
@@ -21,6 +21,8 @@ public class ImportTest {
public
static
void
before
()
{
public
static
void
before
()
{
try
{
try
{
Properties
properties
=
new
Properties
();
Properties
properties
=
new
Properties
();
properties
.
setProperty
(
TSDBDriver
.
PROPERTY_KEY_USER
,
"root"
);
properties
.
setProperty
(
TSDBDriver
.
PROPERTY_KEY_PASSWORD
,
"taosdata"
);
properties
.
setProperty
(
TSDBDriver
.
PROPERTY_KEY_CHARSET
,
"UTF-8"
);
properties
.
setProperty
(
TSDBDriver
.
PROPERTY_KEY_CHARSET
,
"UTF-8"
);
properties
.
setProperty
(
TSDBDriver
.
PROPERTY_KEY_LOCALE
,
"en_US.UTF-8"
);
properties
.
setProperty
(
TSDBDriver
.
PROPERTY_KEY_LOCALE
,
"en_US.UTF-8"
);
properties
.
setProperty
(
TSDBDriver
.
PROPERTY_KEY_TIME_ZONE
,
"UTC-8"
);
properties
.
setProperty
(
TSDBDriver
.
PROPERTY_KEY_TIME_ZONE
,
"UTC-8"
);
...
...
src/connector/jdbc/src/test/java/com/taosdata/jdbc/cases/InsertSpecialCharacterJniTest.java
浏览文件 @
7b67e43c
...
@@ -270,6 +270,41 @@ public class InsertSpecialCharacterJniTest {
...
@@ -270,6 +270,41 @@ public class InsertSpecialCharacterJniTest {
}
}
}
}
@Ignore
@Test
public
void
testSingleQuotaEscape
()
throws
SQLException
{
final
long
now
=
System
.
currentTimeMillis
();
final
String
sql
=
"insert into t? using ? tags(?) values(?, ?, ?) t? using "
+
tbname2
+
" tags(?) values(?,?,?) "
;
try
(
PreparedStatement
pstmt
=
conn
.
prepareStatement
(
sql
))
{
// t1
pstmt
.
setInt
(
1
,
1
);
pstmt
.
setString
(
2
,
tbname2
);
pstmt
.
setString
(
3
,
special_character_str_5
);
pstmt
.
setTimestamp
(
4
,
new
Timestamp
(
now
));
pstmt
.
setBytes
(
5
,
special_character_str_5
.
getBytes
());
// t2
pstmt
.
setInt
(
7
,
2
);
pstmt
.
setString
(
8
,
special_character_str_5
);
pstmt
.
setTimestamp
(
9
,
new
Timestamp
(
now
));
pstmt
.
setString
(
11
,
special_character_str_5
);
int
ret
=
pstmt
.
executeUpdate
();
Assert
.
assertEquals
(
2
,
ret
);
}
String
query
=
"select * from ?.t? where ? < ? and ts >= ? and f1 is not null"
;
try
(
PreparedStatement
pstmt
=
conn
.
prepareStatement
(
query
))
{
pstmt
.
setString
(
1
,
dbName
);
pstmt
.
setInt
(
2
,
1
);
pstmt
.
setString
(
3
,
"ts"
);
pstmt
.
setTimestamp
(
4
,
new
Timestamp
(
System
.
currentTimeMillis
()));
pstmt
.
setTimestamp
(
5
,
new
Timestamp
(
0
));
ResultSet
rs
=
pstmt
.
executeQuery
();
Assert
.
assertNotNull
(
rs
);
}
}
@Test
@Test
public
void
testCase10
()
throws
SQLException
{
public
void
testCase10
()
throws
SQLException
{
final
long
now
=
System
.
currentTimeMillis
();
final
long
now
=
System
.
currentTimeMillis
();
...
@@ -293,13 +328,12 @@ public class InsertSpecialCharacterJniTest {
...
@@ -293,13 +328,12 @@ public class InsertSpecialCharacterJniTest {
Assert
.
assertEquals
(
2
,
ret
);
Assert
.
assertEquals
(
2
,
ret
);
}
}
//query t1
//query t1
String
query
=
"select * from ?.t? where ts < ? and ts >= ? and
?
is not null"
;
String
query
=
"select * from ?.t? where ts < ? and ts >= ? and
f1
is not null"
;
try
(
PreparedStatement
pstmt
=
conn
.
prepareStatement
(
query
))
{
try
(
PreparedStatement
pstmt
=
conn
.
prepareStatement
(
query
))
{
pstmt
.
setString
(
1
,
dbName
);
pstmt
.
setString
(
1
,
dbName
);
pstmt
.
setInt
(
2
,
1
);
pstmt
.
setInt
(
2
,
1
);
pstmt
.
setTimestamp
(
3
,
new
Timestamp
(
System
.
currentTimeMillis
()));
pstmt
.
setTimestamp
(
3
,
new
Timestamp
(
System
.
currentTimeMillis
()));
pstmt
.
setTimestamp
(
4
,
new
Timestamp
(
0
));
pstmt
.
setTimestamp
(
4
,
new
Timestamp
(
0
));
pstmt
.
setString
(
5
,
"f1"
);
ResultSet
rs
=
pstmt
.
executeQuery
();
ResultSet
rs
=
pstmt
.
executeQuery
();
rs
.
next
();
rs
.
next
();
...
@@ -311,12 +345,11 @@ public class InsertSpecialCharacterJniTest {
...
@@ -311,12 +345,11 @@ public class InsertSpecialCharacterJniTest {
Assert
.
assertNull
(
f2
);
Assert
.
assertNull
(
f2
);
}
}
// query t2
// query t2
query
=
"select * from t? where ts < ? and ts >= ? and
?
is not null"
;
query
=
"select * from t? where ts < ? and ts >= ? and
f2
is not null"
;
try
(
PreparedStatement
pstmt
=
conn
.
prepareStatement
(
query
))
{
try
(
PreparedStatement
pstmt
=
conn
.
prepareStatement
(
query
))
{
pstmt
.
setInt
(
1
,
2
);
pstmt
.
setInt
(
1
,
2
);
pstmt
.
setTimestamp
(
2
,
new
Timestamp
(
System
.
currentTimeMillis
()));
pstmt
.
setTimestamp
(
2
,
new
Timestamp
(
System
.
currentTimeMillis
()));
pstmt
.
setTimestamp
(
3
,
new
Timestamp
(
0
));
pstmt
.
setTimestamp
(
3
,
new
Timestamp
(
0
));
pstmt
.
setString
(
4
,
"f2"
);
ResultSet
rs
=
pstmt
.
executeQuery
();
ResultSet
rs
=
pstmt
.
executeQuery
();
rs
.
next
();
rs
.
next
();
...
...
src/connector/jdbc/src/test/java/com/taosdata/jdbc/cases/InsertSpecialCharacterRestfulTest.java
浏览文件 @
7b67e43c
...
@@ -293,13 +293,12 @@ public class InsertSpecialCharacterRestfulTest {
...
@@ -293,13 +293,12 @@ public class InsertSpecialCharacterRestfulTest {
Assert
.
assertEquals
(
2
,
ret
);
Assert
.
assertEquals
(
2
,
ret
);
}
}
//query t1
//query t1
String
query
=
"select * from ?.t? where ts < ? and ts >= ? and
?
is not null"
;
String
query
=
"select * from ?.t? where ts < ? and ts >= ? and
f1
is not null"
;
try
(
PreparedStatement
pstmt
=
conn
.
prepareStatement
(
query
))
{
try
(
PreparedStatement
pstmt
=
conn
.
prepareStatement
(
query
))
{
pstmt
.
setString
(
1
,
dbName
);
pstmt
.
setString
(
1
,
dbName
);
pstmt
.
setInt
(
2
,
1
);
pstmt
.
setInt
(
2
,
1
);
pstmt
.
setTimestamp
(
3
,
new
Timestamp
(
System
.
currentTimeMillis
()));
pstmt
.
setTimestamp
(
3
,
new
Timestamp
(
System
.
currentTimeMillis
()));
pstmt
.
setTimestamp
(
4
,
new
Timestamp
(
0
));
pstmt
.
setTimestamp
(
4
,
new
Timestamp
(
0
));
pstmt
.
setString
(
5
,
"f1"
);
ResultSet
rs
=
pstmt
.
executeQuery
();
ResultSet
rs
=
pstmt
.
executeQuery
();
rs
.
next
();
rs
.
next
();
...
@@ -311,12 +310,11 @@ public class InsertSpecialCharacterRestfulTest {
...
@@ -311,12 +310,11 @@ public class InsertSpecialCharacterRestfulTest {
Assert
.
assertNull
(
f2
);
Assert
.
assertNull
(
f2
);
}
}
// query t2
// query t2
query
=
"select * from t? where ts < ? and ts >= ? and
?
is not null"
;
query
=
"select * from t? where ts < ? and ts >= ? and
f2
is not null"
;
try
(
PreparedStatement
pstmt
=
conn
.
prepareStatement
(
query
))
{
try
(
PreparedStatement
pstmt
=
conn
.
prepareStatement
(
query
))
{
pstmt
.
setInt
(
1
,
2
);
pstmt
.
setInt
(
1
,
2
);
pstmt
.
setTimestamp
(
2
,
new
Timestamp
(
System
.
currentTimeMillis
()));
pstmt
.
setTimestamp
(
2
,
new
Timestamp
(
System
.
currentTimeMillis
()));
pstmt
.
setTimestamp
(
3
,
new
Timestamp
(
0
));
pstmt
.
setTimestamp
(
3
,
new
Timestamp
(
0
));
pstmt
.
setString
(
4
,
"f2"
);
ResultSet
rs
=
pstmt
.
executeQuery
();
ResultSet
rs
=
pstmt
.
executeQuery
();
rs
.
next
();
rs
.
next
();
...
...
src/connector/jdbc/src/test/java/com/taosdata/jdbc/cases/QueryDataTest.java
浏览文件 @
7b67e43c
...
@@ -22,6 +22,8 @@ public class QueryDataTest {
...
@@ -22,6 +22,8 @@ public class QueryDataTest {
public
void
createDatabase
()
{
public
void
createDatabase
()
{
try
{
try
{
Properties
properties
=
new
Properties
();
Properties
properties
=
new
Properties
();
properties
.
setProperty
(
TSDBDriver
.
PROPERTY_KEY_USER
,
"root"
);
properties
.
setProperty
(
TSDBDriver
.
PROPERTY_KEY_PASSWORD
,
"taosdata"
);
properties
.
setProperty
(
TSDBDriver
.
PROPERTY_KEY_CHARSET
,
"UTF-8"
);
properties
.
setProperty
(
TSDBDriver
.
PROPERTY_KEY_CHARSET
,
"UTF-8"
);
properties
.
setProperty
(
TSDBDriver
.
PROPERTY_KEY_LOCALE
,
"en_US.UTF-8"
);
properties
.
setProperty
(
TSDBDriver
.
PROPERTY_KEY_LOCALE
,
"en_US.UTF-8"
);
properties
.
setProperty
(
TSDBDriver
.
PROPERTY_KEY_TIME_ZONE
,
"UTC-8"
);
properties
.
setProperty
(
TSDBDriver
.
PROPERTY_KEY_TIME_ZONE
,
"UTC-8"
);
...
...
src/connector/jdbc/src/test/java/com/taosdata/jdbc/cases/ResetQueryCacheTest.java
浏览文件 @
7b67e43c
package
com.taosdata.jdbc.cases
;
package
com.taosdata.jdbc.cases
;
import
com.taosdata.jdbc.TSDBDriver
;
import
org.junit.After
;
import
org.junit.Before
;
import
org.junit.Test
;
import
org.junit.Test
;
import
java.sql.*
;
import
java.sql.Connection
;
import
java.util.Properties
;
import
java.sql.DriverManager
;
import
java.sql.SQLException
;
import
java.sql.Statement
;
import
static
org
.
junit
.
Assert
.
assertEquals
;
import
static
org
.
junit
.
Assert
.
assertEquals
;
import
static
org
.
junit
.
Assert
.
assertFalse
;
public
class
ResetQueryCacheTest
{
public
class
ResetQueryCacheTest
{
static
Connection
connection
;
@Test
static
Statement
statement
;
public
void
jni
()
throws
SQLException
{
static
String
host
=
"127.0.0.1"
;
// given
Connection
connection
=
DriverManager
.
getConnection
(
"jdbc:TAOS://127.0.0.1:0/?user=root&password=taosdata&timezone=UTC-8&charset=UTF-8&locale=en_US.UTF-8"
);
@Before
Statement
statement
=
connection
.
createStatement
();
public
void
init
()
{
try
{
// when
Properties
properties
=
new
Properties
();
boolean
execute
=
statement
.
execute
(
"reset query cache"
);
properties
.
setProperty
(
TSDBDriver
.
PROPERTY_KEY_CHARSET
,
"UTF-8"
);
properties
.
setProperty
(
TSDBDriver
.
PROPERTY_KEY_LOCALE
,
"en_US.UTF-8"
);
// then
properties
.
setProperty
(
TSDBDriver
.
PROPERTY_KEY_TIME_ZONE
,
"UTC-8"
);
assertFalse
(
execute
);
connection
=
DriverManager
.
getConnection
(
"jdbc:TAOS://"
+
host
+
":0/"
,
properties
);
assertEquals
(
0
,
statement
.
getUpdateCount
());
statement
=
connection
.
createStatement
();
}
catch
(
SQLException
e
)
{
statement
.
close
();
return
;
connection
.
close
();
}
}
}
@Test
@Test
public
void
testResetQueryCache
()
throws
SQLException
{
public
void
restful
()
throws
SQLException
{
String
resetSql
=
"reset query cache"
;
// given
statement
.
execute
(
resetSql
);
Connection
connection
=
DriverManager
.
getConnection
(
"jdbc:TAOS-RS://127.0.0.1:6041/?user=root&password=taosdata&timezone=UTC-8&charset=UTF-8&locale=en_US.UTF-8"
);
}
Statement
statement
=
connection
.
createStatement
();
// when
boolean
execute
=
statement
.
execute
(
"reset query cache"
);
// then
assertFalse
(
execute
);
assertEquals
(
0
,
statement
.
getUpdateCount
());
@After
statement
.
close
();
public
void
close
()
{
connection
.
close
();
try
{
if
(
statement
!=
null
)
statement
.
close
();
if
(
connection
!=
null
)
connection
.
close
();
}
catch
(
SQLException
e
)
{
e
.
printStackTrace
();
}
}
}
}
}
\ No newline at end of file
src/connector/jdbc/src/test/java/com/taosdata/jdbc/cases/SelectTest.java
浏览文件 @
7b67e43c
...
@@ -20,6 +20,8 @@ public class SelectTest {
...
@@ -20,6 +20,8 @@ public class SelectTest {
public
void
createDatabaseAndTable
()
{
public
void
createDatabaseAndTable
()
{
try
{
try
{
Properties
properties
=
new
Properties
();
Properties
properties
=
new
Properties
();
properties
.
setProperty
(
TSDBDriver
.
PROPERTY_KEY_USER
,
"root"
);
properties
.
setProperty
(
TSDBDriver
.
PROPERTY_KEY_PASSWORD
,
"taosdata"
);
properties
.
setProperty
(
TSDBDriver
.
PROPERTY_KEY_CHARSET
,
"UTF-8"
);
properties
.
setProperty
(
TSDBDriver
.
PROPERTY_KEY_CHARSET
,
"UTF-8"
);
properties
.
setProperty
(
TSDBDriver
.
PROPERTY_KEY_LOCALE
,
"en_US.UTF-8"
);
properties
.
setProperty
(
TSDBDriver
.
PROPERTY_KEY_LOCALE
,
"en_US.UTF-8"
);
properties
.
setProperty
(
TSDBDriver
.
PROPERTY_KEY_TIME_ZONE
,
"UTC-8"
);
properties
.
setProperty
(
TSDBDriver
.
PROPERTY_KEY_TIME_ZONE
,
"UTC-8"
);
...
...
src/connector/jdbc/src/test/java/com/taosdata/jdbc/cases/StableTest.java
浏览文件 @
7b67e43c
...
@@ -24,6 +24,8 @@ public class StableTest {
...
@@ -24,6 +24,8 @@ public class StableTest {
public
static
void
createDatabase
()
{
public
static
void
createDatabase
()
{
try
{
try
{
Properties
properties
=
new
Properties
();
Properties
properties
=
new
Properties
();
properties
.
setProperty
(
TSDBDriver
.
PROPERTY_KEY_USER
,
"root"
);
properties
.
setProperty
(
TSDBDriver
.
PROPERTY_KEY_PASSWORD
,
"taosdata"
);
properties
.
setProperty
(
TSDBDriver
.
PROPERTY_KEY_CHARSET
,
"UTF-8"
);
properties
.
setProperty
(
TSDBDriver
.
PROPERTY_KEY_CHARSET
,
"UTF-8"
);
properties
.
setProperty
(
TSDBDriver
.
PROPERTY_KEY_LOCALE
,
"en_US.UTF-8"
);
properties
.
setProperty
(
TSDBDriver
.
PROPERTY_KEY_LOCALE
,
"en_US.UTF-8"
);
properties
.
setProperty
(
TSDBDriver
.
PROPERTY_KEY_TIME_ZONE
,
"UTC-8"
);
properties
.
setProperty
(
TSDBDriver
.
PROPERTY_KEY_TIME_ZONE
,
"UTC-8"
);
...
...
src/connector/jdbc/src/test/java/com/taosdata/jdbc/utils/SqlSyntaxValidatorTest.java
已删除
100644 → 0
浏览文件 @
abbc1a72
package
com.taosdata.jdbc.utils
;
import
org.junit.Assert
;
import
org.junit.Test
;
public
class
SqlSyntaxValidatorTest
{
@Test
public
void
isSelectSQL
()
{
Assert
.
assertTrue
(
SqlSyntaxValidator
.
isSelectSql
(
"select * from test.weather"
));
Assert
.
assertTrue
(
SqlSyntaxValidator
.
isSelectSql
(
" select * from test.weather"
));
Assert
.
assertTrue
(
SqlSyntaxValidator
.
isSelectSql
(
" select * from test.weather "
));
Assert
.
assertFalse
(
SqlSyntaxValidator
.
isSelectSql
(
"insert into test.weather values(now, 1.1, 2)"
));
}
@Test
public
void
isUseSQL
()
{
Assert
.
assertTrue
(
SqlSyntaxValidator
.
isUseSql
(
"use database test"
));
}
}
\ No newline at end of file
src/inc/ttokendef.h
浏览文件 @
7b67e43c
...
@@ -75,131 +75,131 @@
...
@@ -75,131 +75,131 @@
#define TK_SCORES 57
#define TK_SCORES 57
#define TK_GRANTS 58
#define TK_GRANTS 58
#define TK_VNODES 59
#define TK_VNODES 59
#define TK_
IPTOKEN
60
#define TK_
DOT
60
#define TK_
DOT
61
#define TK_
CREATE
61
#define TK_
CREATE
62
#define TK_
TABLE
62
#define TK_
TABLE
63
#define TK_
STABLE
63
#define TK_
STABLE
64
#define TK_
DATABASE
64
#define TK_
DATABASE
65
#define TK_
TABLES
65
#define TK_
TABLES
66
#define TK_
STABLES
66
#define TK_
STABLE
S 67
#define TK_
VGROUP
S 67
#define TK_
VGROUPS
68
#define TK_
DROP
68
#define TK_
DROP
69
#define TK_
TOPIC
69
#define TK_
TOPIC
70
#define TK_
FUNCTION
70
#define TK_
FUNCTION
71
#define TK_
DNODE
71
#define TK_
DNODE
72
#define TK_
USER
72
#define TK_
USER
73
#define TK_
ACCOUNT
73
#define TK_
ACCOUNT
74
#define TK_
USE
74
#define TK_
USE
75
#define TK_
DESCRIBE
75
#define TK_
DESCRIBE
76
#define TK_
ALTER
76
#define TK_
ALTER
77
#define TK_
PASS
77
#define TK_P
ASS
78
#define TK_P
RIVILEGE
78
#define TK_
PRIVILEGE
79
#define TK_
LOCAL
79
#define TK_
LOCAL
80
#define TK_
COMPACT
80
#define TK_
COMPACT
81
#define TK_
LP
81
#define TK_
L
P 82
#define TK_
R
P 82
#define TK_
RP
83
#define TK_
IF
83
#define TK_
IF
84
#define TK_
EXISTS
84
#define TK_
EXISTS
85
#define TK_
AS
85
#define TK_
AS
86
#define TK_
OUTPUTTYPE
86
#define TK_
OUTPUTTYPE
87
#define TK_
AGGREGATE
87
#define TK_
AGGREGATE
88
#define TK_
BUFSIZE
88
#define TK_
BUFSIZE
89
#define TK_
PPS
89
#define TK_
PPS
90
#define TK_
TSERIES
90
#define TK_
TSERIES
91
#define TK_
DBS
91
#define TK_
DBS
92
#define TK_
STORAGE
92
#define TK_
STORAGE
93
#define TK_
QTIME
93
#define TK_
QTIME
94
#define TK_
CONNS
94
#define TK_
CONNS
95
#define TK_
STATE
95
#define TK_
STATE
96
#define TK_
COMMA
96
#define TK_
COMMA
97
#define TK_
KEEP
97
#define TK_
KEEP
98
#define TK_
CACHE
98
#define TK_
CACHE
99
#define TK_
REPLICA
99
#define TK_
REPLICA
100
#define TK_
QUORUM
100
#define TK_
QUORUM
101
#define TK_
DAYS
101
#define TK_
DAYS
102
#define TK_
MINROWS
102
#define TK_M
IN
ROWS 103
#define TK_M
AX
ROWS 103
#define TK_
MAXROWS
104
#define TK_
BLOCKS
104
#define TK_
BLOCKS
105
#define TK_
CTIME
105
#define TK_
CTIME
106
#define TK_
WAL
106
#define TK_
WAL
107
#define TK_
FSYNC
107
#define TK_
FSYNC
108
#define TK_
COMP
108
#define TK_
COMP
109
#define TK_
PRECISION
109
#define TK_
PRECISION
110
#define TK_
UPDATE
110
#define TK_
UPDATE
111
#define TK_
CACHELAST
111
#define TK_
CACHELAST
112
#define TK_
PARTITIONS
112
#define TK_
PARTITIONS
113
#define TK_
UNSIGNED
113
#define TK_
UNSIGNED
114
#define TK_
TAGS
114
#define TK_
TAGS
115
#define TK_
USING
115
#define TK_
USING
116
#define TK_
NULL
116
#define TK_N
ULL
117
#define TK_N
OW
117
#define TK_
NOW
118
#define TK_
SELECT
118
#define TK_
SELECT
119
#define TK_
UNION
119
#define TK_
UNION
120
#define TK_
ALL
120
#define TK_
ALL
121
#define TK_
DISTINCT
121
#define TK_
DISTINCT
122
#define TK_
FROM
122
#define TK_
FROM
123
#define TK_
VARIABLE
123
#define TK_
VARIABLE
124
#define TK_
INTERVAL
124
#define TK_
INTERVAL
125
#define TK_
SESSION
125
#define TK_S
ESSION
126
#define TK_S
TATE_WINDOW
126
#define TK_
STATE_WINDOW
127
#define TK_
FILL
127
#define TK_
FILL
128
#define TK_
SLIDING
128
#define TK_
SLIDING
129
#define TK_
ORDER
129
#define TK_
ORDER
130
#define TK_
BY
130
#define TK_
BY
131
#define TK_
ASC
131
#define TK_
ASC
132
#define TK_
DESC
132
#define TK_
DESC
133
#define TK_
GROUP
133
#define TK_
GROUP
134
#define TK_
HAVING
134
#define TK_
HAVING
135
#define TK_
LIMIT
135
#define TK_
LIMIT
136
#define TK_
OFFSET
136
#define TK_
OFFSE
T 137
#define TK_
SLIMI
T 137
#define TK_S
LIMIT
138
#define TK_S
OFFSET
138
#define TK_
SOFFSET
139
#define TK_
WHERE
139
#define TK_
WHERE
140
#define TK_
RESET
140
#define TK_
RESET
141
#define TK_
QUERY
141
#define TK_
QUERY
142
#define TK_
SYNCDB
142
#define TK_
SYNCDB
143
#define TK_
ADD
143
#define TK_
ADD
144
#define TK_
COLUMN
144
#define TK_
COLUMN
145
#define TK_
MODIFY
145
#define TK_
MODIFY
146
#define TK_
TAG
146
#define TK_
TAG
147
#define TK_
CHANGE
147
#define TK_
CHANGE
148
#define TK_
SET
148
#define TK_
SET
149
#define TK_
KILL
149
#define TK_
KILL
150
#define TK_
CONNECTION
150
#define TK_
CONNECTION
151
#define TK_
STREAM
151
#define TK_
STREAM
152
#define TK_
COLON
152
#define TK_
COLON
153
#define TK_
ABORT
153
#define TK_A
BORT
154
#define TK_A
FTER
154
#define TK_A
FTER
155
#define TK_A
TTACH
155
#define TK_
ATTACH
156
#define TK_
BEFORE
156
#define TK_BE
FORE
157
#define TK_BE
GIN
157
#define TK_
BEGIN
158
#define TK_
CASCADE
158
#define TK_C
ASCADE
159
#define TK_C
LUSTER
159
#define TK_C
LUSTER
160
#define TK_C
ONFLICT
160
#define TK_CO
NFLICT
161
#define TK_CO
PY
161
#define TK_
COPY
162
#define TK_
DEFERRED
162
#define TK_DE
FERRED
163
#define TK_DE
LIMITERS
163
#define TK_DE
LIMITERS
164
#define TK_DE
TACH
164
#define TK_
DETACH
165
#define TK_
EACH
165
#define TK_E
ACH
166
#define TK_E
ND
166
#define TK_E
ND
167
#define TK_E
XPLAIN
167
#define TK_
EXPLAIN
168
#define TK_
FAIL
168
#define TK_F
AIL
169
#define TK_F
OR
169
#define TK_
FOR
170
#define TK_
IGNORE
170
#define TK_I
GNORE
171
#define TK_I
MMEDIATE
171
#define TK_I
MMEDIATE
172
#define TK_I
NITIALLY
172
#define TK_IN
ITIALLY
173
#define TK_IN
STEAD
173
#define TK_
INSTEAD
174
#define TK_
MATCH
174
#define TK_
MATCH
175
#define TK_
KEY
175
#define TK_
KEY
176
#define TK_
OF
176
#define TK_
OF
177
#define TK_
RAISE
177
#define TK_R
AISE
178
#define TK_R
EPLACE
178
#define TK_RE
PLACE
179
#define TK_RE
STRICT
179
#define TK_R
ESTRICT
180
#define TK_R
OW
180
#define TK_
ROW
181
#define TK_
STATEMENT
181
#define TK_
STATEMENT
182
#define TK_
TRIGGER
182
#define TK_
TRIGGER
183
#define TK_
VIEW
183
#define TK_
VIEW
184
#define TK_
IPTOKEN
184
#define TK_SEMI 185
#define TK_SEMI 185
#define TK_NONE 186
#define TK_NONE 186
#define TK_PREV 187
#define TK_PREV 187
...
...
src/kit/shell/src/shellEngine.c
浏览文件 @
7b67e43c
...
@@ -98,7 +98,6 @@ TAOS *shellInit(SShellArguments *_args) {
...
@@ -98,7 +98,6 @@ TAOS *shellInit(SShellArguments *_args) {
}
}
if
(
con
==
NULL
)
{
if
(
con
==
NULL
)
{
printf
(
"taos connect failed, reason: %s.
\n\n
"
,
tstrerror
(
terrno
));
fflush
(
stdout
);
fflush
(
stdout
);
return
con
;
return
con
;
}
}
...
...
src/mnode/inc/mnodeDef.h
浏览文件 @
7b67e43c
...
@@ -80,6 +80,7 @@ typedef struct SMnodeObj {
...
@@ -80,6 +80,7 @@ typedef struct SMnodeObj {
int8_t
updateEnd
[
4
];
int8_t
updateEnd
[
4
];
int32_t
refCount
;
int32_t
refCount
;
int8_t
role
;
int8_t
role
;
int64_t
roleTime
;
int8_t
reserved2
[
3
];
int8_t
reserved2
[
3
];
}
SMnodeObj
;
}
SMnodeObj
;
...
...
src/mnode/src/mnodeDnode.c
浏览文件 @
7b67e43c
...
@@ -1181,7 +1181,7 @@ static int32_t mnodeGetVnodeMeta(STableMetaMsg *pMeta, SShowObj *pShow, void *pC
...
@@ -1181,7 +1181,7 @@ static int32_t mnodeGetVnodeMeta(STableMetaMsg *pMeta, SShowObj *pShow, void *pC
pShow
->
bytes
[
cols
]
=
4
;
pShow
->
bytes
[
cols
]
=
4
;
pSchema
[
cols
].
type
=
TSDB_DATA_TYPE_INT
;
pSchema
[
cols
].
type
=
TSDB_DATA_TYPE_INT
;
strcpy
(
pSchema
[
cols
].
name
,
"v
node
"
);
strcpy
(
pSchema
[
cols
].
name
,
"v
gId
"
);
pSchema
[
cols
].
bytes
=
htons
(
pShow
->
bytes
[
cols
]);
pSchema
[
cols
].
bytes
=
htons
(
pShow
->
bytes
[
cols
]);
cols
++
;
cols
++
;
...
@@ -1243,8 +1243,10 @@ static int32_t mnodeRetrieveVnodes(SShowObj *pShow, char *data, int32_t rows, vo
...
@@ -1243,8 +1243,10 @@ static int32_t mnodeRetrieveVnodes(SShowObj *pShow, char *data, int32_t rows, vo
cols
++
;
cols
++
;
pWrite
=
data
+
pShow
->
offset
[
cols
]
*
rows
+
pShow
->
bytes
[
cols
]
*
numOfRows
;
pWrite
=
data
+
pShow
->
offset
[
cols
]
*
rows
+
pShow
->
bytes
[
cols
]
*
numOfRows
;
strcpy
(
pWrite
,
syncRole
[
pVgid
->
role
]);
STR_TO_VARSTR
(
pWrite
,
syncRole
[
pVgid
->
role
]);
cols
++
;
cols
++
;
numOfRows
++
;
}
}
}
}
...
...
src/mnode/src/mnodeMnode.c
浏览文件 @
7b67e43c
...
@@ -122,6 +122,7 @@ static int32_t mnodeMnodeActionRestored() {
...
@@ -122,6 +122,7 @@ static int32_t mnodeMnodeActionRestored() {
void
*
pIter
=
mnodeGetNextMnode
(
NULL
,
&
pMnode
);
void
*
pIter
=
mnodeGetNextMnode
(
NULL
,
&
pMnode
);
if
(
pMnode
!=
NULL
)
{
if
(
pMnode
!=
NULL
)
{
pMnode
->
role
=
TAOS_SYNC_ROLE_MASTER
;
pMnode
->
role
=
TAOS_SYNC_ROLE_MASTER
;
pMnode
->
roleTime
=
taosGetTimestampMs
();
mnodeDecMnodeRef
(
pMnode
);
mnodeDecMnodeRef
(
pMnode
);
}
}
mnodeCancelGetNextMnode
(
pIter
);
mnodeCancelGetNextMnode
(
pIter
);
...
@@ -496,7 +497,13 @@ static int32_t mnodeGetMnodeMeta(STableMetaMsg *pMeta, SShowObj *pShow, void *pC
...
@@ -496,7 +497,13 @@ static int32_t mnodeGetMnodeMeta(STableMetaMsg *pMeta, SShowObj *pShow, void *pC
strcpy
(
pSchema
[
cols
].
name
,
"role"
);
strcpy
(
pSchema
[
cols
].
name
,
"role"
);
pSchema
[
cols
].
bytes
=
htons
(
pShow
->
bytes
[
cols
]);
pSchema
[
cols
].
bytes
=
htons
(
pShow
->
bytes
[
cols
]);
cols
++
;
cols
++
;
pShow
->
bytes
[
cols
]
=
8
;
pSchema
[
cols
].
type
=
TSDB_DATA_TYPE_TIMESTAMP
;
strcpy
(
pSchema
[
cols
].
name
,
"role_time"
);
pSchema
[
cols
].
bytes
=
htons
(
pShow
->
bytes
[
cols
]);
cols
++
;
pShow
->
bytes
[
cols
]
=
8
;
pShow
->
bytes
[
cols
]
=
8
;
pSchema
[
cols
].
type
=
TSDB_DATA_TYPE_TIMESTAMP
;
pSchema
[
cols
].
type
=
TSDB_DATA_TYPE_TIMESTAMP
;
strcpy
(
pSchema
[
cols
].
name
,
"create_time"
);
strcpy
(
pSchema
[
cols
].
name
,
"create_time"
);
...
@@ -552,6 +559,10 @@ static int32_t mnodeRetrieveMnodes(SShowObj *pShow, char *data, int32_t rows, vo
...
@@ -552,6 +559,10 @@ static int32_t mnodeRetrieveMnodes(SShowObj *pShow, char *data, int32_t rows, vo
STR_WITH_MAXSIZE_TO_VARSTR
(
pWrite
,
roles
,
pShow
->
bytes
[
cols
]);
STR_WITH_MAXSIZE_TO_VARSTR
(
pWrite
,
roles
,
pShow
->
bytes
[
cols
]);
cols
++
;
cols
++
;
pWrite
=
data
+
pShow
->
offset
[
cols
]
*
rows
+
pShow
->
bytes
[
cols
]
*
numOfRows
;
*
(
int64_t
*
)
pWrite
=
pMnode
->
roleTime
;
cols
++
;
pWrite
=
data
+
pShow
->
offset
[
cols
]
*
rows
+
pShow
->
bytes
[
cols
]
*
numOfRows
;
pWrite
=
data
+
pShow
->
offset
[
cols
]
*
rows
+
pShow
->
bytes
[
cols
]
*
numOfRows
;
*
(
int64_t
*
)
pWrite
=
pMnode
->
createdTime
;
*
(
int64_t
*
)
pWrite
=
pMnode
->
createdTime
;
cols
++
;
cols
++
;
...
...
src/mnode/src/mnodeSdb.c
浏览文件 @
7b67e43c
...
@@ -227,6 +227,7 @@ void sdbUpdateMnodeRoles() {
...
@@ -227,6 +227,7 @@ void sdbUpdateMnodeRoles() {
SMnodeObj
*
pMnode
=
mnodeGetMnode
(
roles
.
nodeId
[
i
]);
SMnodeObj
*
pMnode
=
mnodeGetMnode
(
roles
.
nodeId
[
i
]);
if
(
pMnode
!=
NULL
)
{
if
(
pMnode
!=
NULL
)
{
if
(
pMnode
->
role
!=
roles
.
role
[
i
])
{
if
(
pMnode
->
role
!=
roles
.
role
[
i
])
{
pMnode
->
roleTime
=
taosGetTimestampMs
();
bnNotify
();
bnNotify
();
}
}
...
...
src/os/src/detail/osTime.c
浏览文件 @
7b67e43c
...
@@ -72,36 +72,55 @@ int64_t user_mktime64(const unsigned int year0, const unsigned int mon0,
...
@@ -72,36 +72,55 @@ int64_t user_mktime64(const unsigned int year0, const unsigned int mon0,
// ==== mktime() kernel code =================//
// ==== mktime() kernel code =================//
static
int64_t
m_deltaUtc
=
0
;
static
int64_t
m_deltaUtc
=
0
;
void
deltaToUtcInitOnce
()
{
void
deltaToUtcInitOnce
()
{
struct
tm
tm
=
{
0
};
struct
tm
tm
=
{
0
};
(
void
)
strptime
(
"1970-01-01 00:00:00"
,
(
const
char
*
)(
"%Y-%m-%d %H:%M:%S"
),
&
tm
);
(
void
)
strptime
(
"1970-01-01 00:00:00"
,
(
const
char
*
)(
"%Y-%m-%d %H:%M:%S"
),
&
tm
);
m_deltaUtc
=
(
int64_t
)
mktime
(
&
tm
);
m_deltaUtc
=
(
int64_t
)
mktime
(
&
tm
);
//printf("====delta:%lld\n\n", seconds);
//printf("====delta:%lld\n\n", seconds);
return
;
return
;
}
}
static
int64_t
parseFraction
(
char
*
str
,
char
**
end
,
int32_t
timePrec
);
static
int64_t
parseFraction
(
char
*
str
,
char
**
end
,
int32_t
timePrec
);
static
int32_t
parseTimeWithTz
(
char
*
timestr
,
int64_t
*
time
,
int32_t
timePrec
);
static
int32_t
parseTimeWithTz
(
char
*
timestr
,
int64_t
*
time
,
int32_t
timePrec
,
char
delim
);
static
int32_t
parseLocaltime
(
char
*
timestr
,
int64_t
*
time
,
int32_t
timePrec
);
static
int32_t
parseLocaltime
(
char
*
timestr
,
int64_t
*
time
,
int32_t
timePrec
);
static
int32_t
parseLocaltimeWithDst
(
char
*
timestr
,
int64_t
*
time
,
int32_t
timePrec
);
static
int32_t
parseLocaltimeWithDst
(
char
*
timestr
,
int64_t
*
time
,
int32_t
timePrec
);
static
char
*
forwardToTimeStringEnd
(
char
*
str
);
static
bool
checkTzPresent
(
char
*
str
,
int32_t
len
);
static
int32_t
(
*
parseLocaltimeFp
[])
(
char
*
timestr
,
int64_t
*
time
,
int32_t
timePrec
)
=
{
static
int32_t
(
*
parseLocaltimeFp
[])
(
char
*
timestr
,
int64_t
*
time
,
int32_t
timePrec
)
=
{
parseLocaltime
,
parseLocaltime
,
parseLocaltimeWithDst
parseLocaltimeWithDst
};
};
int32_t
taosGetTimestampSec
()
{
return
(
int32_t
)
time
(
NULL
);
}
int32_t
taosGetTimestampSec
()
{
return
(
int32_t
)
time
(
NULL
);
}
int32_t
taosParseTime
(
char
*
timestr
,
int64_t
*
time
,
int32_t
len
,
int32_t
timePrec
,
int8_t
day_light
)
{
int32_t
taosParseTime
(
char
*
timestr
,
int64_t
*
time
,
int32_t
len
,
int32_t
timePrec
,
int8_t
day_light
)
{
/* parse datatime string in with tz */
/* parse datatime string in with tz */
if
(
strnchr
(
timestr
,
'T'
,
len
,
false
)
!=
NULL
)
{
if
(
strnchr
(
timestr
,
'T'
,
len
,
false
)
!=
NULL
)
{
return
parseTimeWithTz
(
timestr
,
time
,
timePrec
);
return
parseTimeWithTz
(
timestr
,
time
,
timePrec
,
'T'
);
}
else
if
(
checkTzPresent
(
timestr
,
len
))
{
return
parseTimeWithTz
(
timestr
,
time
,
timePrec
,
0
);
}
else
{
}
else
{
return
(
*
parseLocaltimeFp
[
day_light
])(
timestr
,
time
,
timePrec
);
return
(
*
parseLocaltimeFp
[
day_light
])(
timestr
,
time
,
timePrec
);
}
}
}
}
bool
checkTzPresent
(
char
*
str
,
int32_t
len
)
{
char
*
seg
=
forwardToTimeStringEnd
(
str
);
int32_t
seg_len
=
len
-
(
int32_t
)(
seg
-
str
);
char
*
c
=
&
seg
[
seg_len
-
1
];
for
(
int
i
=
0
;
i
<
seg_len
;
++
i
)
{
if
(
*
c
==
'Z'
||
*
c
==
'z'
||
*
c
==
'+'
||
*
c
==
'-'
)
{
return
true
;
}
c
--
;
}
return
false
;
}
char
*
forwardToTimeStringEnd
(
char
*
str
)
{
char
*
forwardToTimeStringEnd
(
char
*
str
)
{
int32_t
i
=
0
;
int32_t
i
=
0
;
int32_t
numOfSep
=
0
;
int32_t
numOfSep
=
0
;
...
@@ -187,6 +206,13 @@ int32_t parseTimezone(char* str, int64_t* tzOffset) {
...
@@ -187,6 +206,13 @@ int32_t parseTimezone(char* str, int64_t* tzOffset) {
i
+=
2
;
i
+=
2
;
}
}
//return error if there're illegal charaters after min(2 Digits)
char
*
minStr
=
&
str
[
i
];
if
(
minStr
[
1
]
!=
'\0'
&&
minStr
[
2
]
!=
'\0'
)
{
return
-
1
;
}
int64_t
minute
=
strnatoi
(
&
str
[
i
],
2
);
int64_t
minute
=
strnatoi
(
&
str
[
i
],
2
);
if
(
minute
>
59
)
{
if
(
minute
>
59
)
{
return
-
1
;
return
-
1
;
...
@@ -213,14 +239,23 @@ int32_t parseTimezone(char* str, int64_t* tzOffset) {
...
@@ -213,14 +239,23 @@ int32_t parseTimezone(char* str, int64_t* tzOffset) {
* 2013-04-12T15:52:01+0800
* 2013-04-12T15:52:01+0800
* 2013-04-12T15:52:01.123+0800
* 2013-04-12T15:52:01.123+0800
*/
*/
int32_t
parseTimeWithTz
(
char
*
timestr
,
int64_t
*
time
,
int32_t
timePrec
)
{
int32_t
parseTimeWithTz
(
char
*
timestr
,
int64_t
*
time
,
int32_t
timePrec
,
char
delim
)
{
int64_t
factor
=
(
timePrec
==
TSDB_TIME_PRECISION_MILLI
)
?
1000
:
int64_t
factor
=
(
timePrec
==
TSDB_TIME_PRECISION_MILLI
)
?
1000
:
(
timePrec
==
TSDB_TIME_PRECISION_MICRO
?
1000000
:
1000000000
);
(
timePrec
==
TSDB_TIME_PRECISION_MICRO
?
1000000
:
1000000000
);
int64_t
tzOffset
=
0
;
int64_t
tzOffset
=
0
;
struct
tm
tm
=
{
0
};
struct
tm
tm
=
{
0
};
char
*
str
=
strptime
(
timestr
,
"%Y-%m-%dT%H:%M:%S"
,
&
tm
);
char
*
str
;
if
(
delim
==
'T'
)
{
str
=
strptime
(
timestr
,
"%Y-%m-%dT%H:%M:%S"
,
&
tm
);
}
else
if
(
delim
==
0
)
{
str
=
strptime
(
timestr
,
"%Y-%m-%d %H:%M:%S"
,
&
tm
);
}
else
{
str
=
NULL
;
}
if
(
str
==
NULL
)
{
if
(
str
==
NULL
)
{
return
-
1
;
return
-
1
;
}
}
...
@@ -236,7 +271,7 @@ int32_t parseTimeWithTz(char* timestr, int64_t* time, int32_t timePrec) {
...
@@ -236,7 +271,7 @@ int32_t parseTimeWithTz(char* timestr, int64_t* time, int32_t timePrec) {
int64_t
fraction
=
0
;
int64_t
fraction
=
0
;
str
=
forwardToTimeStringEnd
(
timestr
);
str
=
forwardToTimeStringEnd
(
timestr
);
if
(
str
[
0
]
==
'Z'
||
str
[
0
]
==
'z
'
)
{
if
(
(
str
[
0
]
==
'Z'
||
str
[
0
]
==
'z'
)
&&
str
[
1
]
==
'\0
'
)
{
/* utc time, no millisecond, return directly*/
/* utc time, no millisecond, return directly*/
*
time
=
seconds
*
factor
;
*
time
=
seconds
*
factor
;
}
else
if
(
str
[
0
]
==
'.'
)
{
}
else
if
(
str
[
0
]
==
'.'
)
{
...
@@ -250,6 +285,8 @@ int32_t parseTimeWithTz(char* timestr, int64_t* time, int32_t timePrec) {
...
@@ -250,6 +285,8 @@ int32_t parseTimeWithTz(char* timestr, int64_t* time, int32_t timePrec) {
char
seg
=
str
[
0
];
char
seg
=
str
[
0
];
if
(
seg
!=
'Z'
&&
seg
!=
'z'
&&
seg
!=
'+'
&&
seg
!=
'-'
)
{
if
(
seg
!=
'Z'
&&
seg
!=
'z'
&&
seg
!=
'+'
&&
seg
!=
'-'
)
{
return
-
1
;
return
-
1
;
}
else
if
((
seg
==
'Z'
||
seg
==
'z'
)
&&
str
[
1
]
!=
'\0'
)
{
return
-
1
;
}
else
if
(
seg
==
'+'
||
seg
==
'-'
)
{
}
else
if
(
seg
==
'+'
||
seg
==
'-'
)
{
// parse the timezone
// parse the timezone
if
(
parseTimezone
(
str
,
&
tzOffset
)
==
-
1
)
{
if
(
parseTimezone
(
str
,
&
tzOffset
)
==
-
1
)
{
...
...
src/query/inc/sql.y
浏览文件 @
7b67e43c
...
@@ -80,7 +80,7 @@ cmd ::= SHOW SCORES. { setShowOptions(pInfo, TSDB_MGMT_TABLE_SCORES, 0, 0);
...
@@ -80,7 +80,7 @@ cmd ::= SHOW SCORES. { setShowOptions(pInfo, TSDB_MGMT_TABLE_SCORES, 0, 0);
cmd ::= SHOW GRANTS. { setShowOptions(pInfo, TSDB_MGMT_TABLE_GRANTS, 0, 0); }
cmd ::= SHOW GRANTS. { setShowOptions(pInfo, TSDB_MGMT_TABLE_GRANTS, 0, 0); }
cmd ::= SHOW VNODES. { setShowOptions(pInfo, TSDB_MGMT_TABLE_VNODES, 0, 0); }
cmd ::= SHOW VNODES. { setShowOptions(pInfo, TSDB_MGMT_TABLE_VNODES, 0, 0); }
cmd ::= SHOW VNODES
IPTOKEN
(X). { setShowOptions(pInfo, TSDB_MGMT_TABLE_VNODES, &X, 0); }
cmd ::= SHOW VNODES
ids
(X). { setShowOptions(pInfo, TSDB_MGMT_TABLE_VNODES, &X, 0); }
%type dbPrefix {SStrToken}
%type dbPrefix {SStrToken}
...
...
src/query/src/qSqlParser.c
浏览文件 @
7b67e43c
...
@@ -955,6 +955,8 @@ void SqlInfoDestroy(SSqlInfo *pInfo) {
...
@@ -955,6 +955,8 @@ void SqlInfoDestroy(SSqlInfo *pInfo) {
taosArrayDestroy
(
pInfo
->
pAlterInfo
->
pAddColumns
);
taosArrayDestroy
(
pInfo
->
pAlterInfo
->
pAddColumns
);
tfree
(
pInfo
->
pAlterInfo
->
tagData
.
data
);
tfree
(
pInfo
->
pAlterInfo
->
tagData
.
data
);
tfree
(
pInfo
->
pAlterInfo
);
tfree
(
pInfo
->
pAlterInfo
);
}
else
if
(
pInfo
->
type
==
TSDB_SQL_COMPACT_VNODE
)
{
tSqlExprListDestroy
(
pInfo
->
list
);
}
else
{
}
else
{
if
(
pInfo
->
pMiscInfo
!=
NULL
)
{
if
(
pInfo
->
pMiscInfo
!=
NULL
)
{
taosArrayDestroy
(
pInfo
->
pMiscInfo
->
a
);
taosArrayDestroy
(
pInfo
->
pMiscInfo
->
a
);
...
...
src/query/src/sql.c
浏览文件 @
7b67e43c
此差异已折叠。
点击以展开。
src/query/tests/unitTest.cpp
浏览文件 @
7b67e43c
...
@@ -407,11 +407,56 @@ TEST(testCase, parse_time) {
...
@@ -407,11 +407,56 @@ TEST(testCase, parse_time) {
taosParseTime
(
t41
,
&
time
,
strlen
(
t41
),
TSDB_TIME_PRECISION_MILLI
,
0
);
taosParseTime
(
t41
,
&
time
,
strlen
(
t41
),
TSDB_TIME_PRECISION_MILLI
,
0
);
EXPECT_EQ
(
time
,
852048000999
);
EXPECT_EQ
(
time
,
852048000999
);
int64_t
k
=
timezone
;
char
t42
[]
=
"1997-1-1T0:0:0.999999999Z"
;
char
t42
[]
=
"1997-1-1T0:0:0.999999999Z"
;
taosParseTime
(
t42
,
&
time
,
strlen
(
t42
),
TSDB_TIME_PRECISION_MILLI
,
0
);
taosParseTime
(
t42
,
&
time
,
strlen
(
t42
),
TSDB_TIME_PRECISION_MILLI
,
0
);
EXPECT_EQ
(
time
,
852048000999
-
timezone
*
MILLISECOND_PER_SECOND
);
EXPECT_EQ
(
time
,
852048000999
-
timezone
*
MILLISECOND_PER_SECOND
);
// "%Y-%m-%d %H:%M:%S" format with TimeZone appendix is also treated as legal
// and TimeZone will be processed
char
t60
[]
=
"2017-4-3 1:1:2.980"
;
char
t61
[]
=
"2017-4-3 2:1:2.98+9:00"
;
taosParseTime
(
t60
,
&
time
,
strlen
(
t60
),
TSDB_TIME_PRECISION_MILLI
,
0
);
taosParseTime
(
t61
,
&
time1
,
strlen
(
t61
),
TSDB_TIME_PRECISION_MILLI
,
0
);
EXPECT_EQ
(
time
,
time1
);
char
t62
[]
=
"2017-4-3 2:1:2.98+09:00"
;
taosParseTime
(
t62
,
&
time
,
strlen
(
t62
),
TSDB_TIME_PRECISION_MILLI
,
0
);
taosParseTime
(
t61
,
&
time1
,
strlen
(
t61
),
TSDB_TIME_PRECISION_MILLI
,
0
);
EXPECT_EQ
(
time
,
time1
);
char
t63
[]
=
"2017-4-3 2:1:2.98+0900"
;
taosParseTime
(
t63
,
&
time
,
strlen
(
t63
),
TSDB_TIME_PRECISION_MILLI
,
0
);
taosParseTime
(
t62
,
&
time1
,
strlen
(
t62
),
TSDB_TIME_PRECISION_MILLI
,
0
);
EXPECT_EQ
(
time
,
time1
);
char
t64
[]
=
"2017-4-2 17:1:2.98Z"
;
taosParseTime
(
t63
,
&
time
,
strlen
(
t63
),
TSDB_TIME_PRECISION_MILLI
,
0
);
taosParseTime
(
t64
,
&
time1
,
strlen
(
t64
),
TSDB_TIME_PRECISION_MILLI
,
0
);
EXPECT_EQ
(
time
,
time1
);
// "%Y-%m-%d%H:%M:%S" format with TimeZone appendix is also treated as legal
// and TimeZone will be processed
char
t80
[]
=
"2017-4-51:1:2.980"
;
char
t81
[]
=
"2017-4-52:1:2.98+9:00"
;
taosParseTime
(
t80
,
&
time
,
strlen
(
t80
),
TSDB_TIME_PRECISION_MILLI
,
0
);
taosParseTime
(
t81
,
&
time1
,
strlen
(
t81
),
TSDB_TIME_PRECISION_MILLI
,
0
);
EXPECT_EQ
(
time
,
time1
);
char
t82
[]
=
"2017-4-52:1:2.98+09:00"
;
taosParseTime
(
t82
,
&
time
,
strlen
(
t82
),
TSDB_TIME_PRECISION_MILLI
,
0
);
taosParseTime
(
t81
,
&
time1
,
strlen
(
t81
),
TSDB_TIME_PRECISION_MILLI
,
0
);
EXPECT_EQ
(
time
,
time1
);
char
t83
[]
=
"2017-4-52:1:2.98+0900"
;
taosParseTime
(
t83
,
&
time
,
strlen
(
t83
),
TSDB_TIME_PRECISION_MILLI
,
0
);
taosParseTime
(
t82
,
&
time1
,
strlen
(
t82
),
TSDB_TIME_PRECISION_MILLI
,
0
);
EXPECT_EQ
(
time
,
time1
);
char
t84
[]
=
"2017-4-417:1:2.98Z"
;
taosParseTime
(
t83
,
&
time
,
strlen
(
t83
),
TSDB_TIME_PRECISION_MILLI
,
0
);
taosParseTime
(
t84
,
&
time1
,
strlen
(
t84
),
TSDB_TIME_PRECISION_MILLI
,
0
);
EXPECT_EQ
(
time
,
time1
);
////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////
// illegal timestamp format
// illegal timestamp format
char
t15
[]
=
"2017-12-33 0:0:0"
;
char
t15
[]
=
"2017-12-33 0:0:0"
;
...
@@ -430,8 +475,7 @@ TEST(testCase, parse_time) {
...
@@ -430,8 +475,7 @@ TEST(testCase, parse_time) {
EXPECT_EQ
(
taosParseTime
(
t19
,
&
time
,
strlen
(
t19
),
TSDB_TIME_PRECISION_MILLI
,
0
),
-
1
);
EXPECT_EQ
(
taosParseTime
(
t19
,
&
time
,
strlen
(
t19
),
TSDB_TIME_PRECISION_MILLI
,
0
),
-
1
);
char
t20
[]
=
"2017-12-31 9:0:0.1+12:99"
;
char
t20
[]
=
"2017-12-31 9:0:0.1+12:99"
;
EXPECT_EQ
(
taosParseTime
(
t20
,
&
time
,
strlen
(
t20
),
TSDB_TIME_PRECISION_MILLI
,
0
),
0
);
EXPECT_EQ
(
taosParseTime
(
t20
,
&
time
,
strlen
(
t20
),
TSDB_TIME_PRECISION_MILLI
,
0
),
-
1
);
EXPECT_EQ
(
time
,
1514682000100
);
char
t21
[]
=
"2017-12-31T9:0:0.1+12:99"
;
char
t21
[]
=
"2017-12-31T9:0:0.1+12:99"
;
EXPECT_EQ
(
taosParseTime
(
t21
,
&
time
,
strlen
(
t21
),
TSDB_TIME_PRECISION_MILLI
,
0
),
-
1
);
EXPECT_EQ
(
taosParseTime
(
t21
,
&
time
,
strlen
(
t21
),
TSDB_TIME_PRECISION_MILLI
,
0
),
-
1
);
...
@@ -441,8 +485,103 @@ TEST(testCase, parse_time) {
...
@@ -441,8 +485,103 @@ TEST(testCase, parse_time) {
char
t23
[]
=
"2017-12-31T9:0:0.1+13:1"
;
char
t23
[]
=
"2017-12-31T9:0:0.1+13:1"
;
EXPECT_EQ
(
taosParseTime
(
t23
,
&
time
,
strlen
(
t23
),
TSDB_TIME_PRECISION_MILLI
,
0
),
0
);
EXPECT_EQ
(
taosParseTime
(
t23
,
&
time
,
strlen
(
t23
),
TSDB_TIME_PRECISION_MILLI
,
0
),
0
);
char
t24
[]
=
"2017-12-31T9:0:0.1+13:001"
;
EXPECT_EQ
(
taosParseTime
(
t24
,
&
time
,
strlen
(
t24
),
TSDB_TIME_PRECISION_MILLI
,
0
),
-
1
);
char
t25
[]
=
"2017-12-31T9:0:0.1+13:00abc"
;
EXPECT_EQ
(
taosParseTime
(
t25
,
&
time
,
strlen
(
t25
),
TSDB_TIME_PRECISION_MILLI
,
0
),
-
1
);
char
t26
[]
=
"2017-12-31T9:0:0.1+13001"
;
EXPECT_EQ
(
taosParseTime
(
t26
,
&
time
,
strlen
(
t26
),
TSDB_TIME_PRECISION_MILLI
,
0
),
-
1
);
char
t27
[]
=
"2017-12-31T9:0:0.1+1300abc"
;
EXPECT_EQ
(
taosParseTime
(
t27
,
&
time
,
strlen
(
t27
),
TSDB_TIME_PRECISION_MILLI
,
0
),
-
1
);
char
t28
[]
=
"2017-12-31T9:0:0Z+12:00"
;
EXPECT_EQ
(
taosParseTime
(
t28
,
&
time
,
strlen
(
t28
),
TSDB_TIME_PRECISION_MILLI
,
0
),
-
1
);
char
t29
[]
=
"2017-12-31T9:0:0.123Z+12:00"
;
EXPECT_EQ
(
taosParseTime
(
t29
,
&
time
,
strlen
(
t29
),
TSDB_TIME_PRECISION_MILLI
,
0
),
-
1
);
char
t65
[]
=
"2017-12-31 9:0:0.1+13:001"
;
EXPECT_EQ
(
taosParseTime
(
t65
,
&
time
,
strlen
(
t65
),
TSDB_TIME_PRECISION_MILLI
,
0
),
-
1
);
char
t66
[]
=
"2017-12-31 9:0:0.1+13:00abc"
;
EXPECT_EQ
(
taosParseTime
(
t66
,
&
time
,
strlen
(
t66
),
TSDB_TIME_PRECISION_MILLI
,
0
),
-
1
);
char
t67
[]
=
"2017-12-31 9:0:0.1+13001"
;
EXPECT_EQ
(
taosParseTime
(
t67
,
&
time
,
strlen
(
t67
),
TSDB_TIME_PRECISION_MILLI
,
0
),
-
1
);
char
t68
[]
=
"2017-12-31 9:0:0.1+1300abc"
;
EXPECT_EQ
(
taosParseTime
(
t68
,
&
time
,
strlen
(
t68
),
TSDB_TIME_PRECISION_MILLI
,
0
),
-
1
);
char
t69
[]
=
"2017-12-31 9:0:0Z+12:00"
;
EXPECT_EQ
(
taosParseTime
(
t69
,
&
time
,
strlen
(
t69
),
TSDB_TIME_PRECISION_MILLI
,
0
),
-
1
);
char
t70
[]
=
"2017-12-31 9:0:0.123Z+12:00"
;
EXPECT_EQ
(
taosParseTime
(
t70
,
&
time
,
strlen
(
t70
),
TSDB_TIME_PRECISION_MILLI
,
0
),
-
1
);
}
/* test parse time profiling */
TEST
(
testCase
,
parse_time_profile
)
{
taos_options
(
TSDB_OPTION_TIMEZONE
,
"GMT-8"
);
char
t1
[]
=
"2018-1-8 1:1:1.952"
;
char
t2
[]
=
"2018-1-8T1:1:1.952+0800"
;
char
t3
[]
=
"2018-1-8 1:1:1.952+0800"
;
char
t4
[]
=
"2018-1-81:1:1.952+0800"
;
char
t5
[]
=
"2018-1-8 1:1:1.952"
;
char
t6
[]
=
"2018-1-8T1:1:1.952+08:00"
;
char
t7
[]
=
"2018-1-8 1:1:1.952+08:00"
;
char
t8
[]
=
"2018-1-81:1:1.952+08:00"
;
char
t9
[]
=
"2018-1-8 1:1:1.952"
;
char
t10
[]
=
"2018-1-8T1:1:1.952Z"
;
char
t11
[]
=
"2018-1-8 1:1:1.952z"
;
char
t12
[]
=
"2018-1-81:1:1.952Z"
;
struct
timeval
start
,
end
;
int64_t
time
=
0
,
time1
=
0
;
int32_t
total_run
=
100000000
;
long
total_time_us
;
gettimeofday
(
&
start
,
NULL
);
for
(
int
i
=
0
;
i
<
total_run
;
++
i
)
{
taosParseTime
(
t1
,
&
time
,
strlen
(
t1
),
TSDB_TIME_PRECISION_MILLI
,
0
);
}
gettimeofday
(
&
end
,
NULL
);
total_time_us
=
((
end
.
tv_sec
-
start
.
tv_sec
)
*
1000000
)
+
(
end
.
tv_usec
-
start
.
tv_usec
);
printf
(
"[t1] The elapsed time is %f seconds in %d run, average:%fns
\n
"
,
total_time_us
/
1000000.0
,
total_run
,
1000
*
(
float
)
total_time_us
/
(
float
)
total_run
);
gettimeofday
(
&
start
,
NULL
);
for
(
int
i
=
0
;
i
<
total_run
;
++
i
)
{
taosParseTime
(
t2
,
&
time
,
strlen
(
t2
),
TSDB_TIME_PRECISION_MILLI
,
0
);
}
gettimeofday
(
&
end
,
NULL
);
total_time_us
=
((
end
.
tv_sec
-
start
.
tv_sec
)
*
1000000
)
+
(
end
.
tv_usec
-
start
.
tv_usec
);
printf
(
"[t2] The elapsed time is %f seconds in %d run, average:%fns
\n
"
,
total_time_us
/
1000000.0
,
total_run
,
1000
*
(
float
)
total_time_us
/
(
float
)
total_run
);
gettimeofday
(
&
start
,
NULL
);
for
(
int
i
=
0
;
i
<
total_run
;
++
i
)
{
taosParseTime
(
t3
,
&
time
,
strlen
(
t3
),
TSDB_TIME_PRECISION_MILLI
,
0
);
}
gettimeofday
(
&
end
,
NULL
);
total_time_us
=
((
end
.
tv_sec
-
start
.
tv_sec
)
*
1000000
)
+
(
end
.
tv_usec
-
start
.
tv_usec
);
printf
(
"[t3] The elapsed time is %f seconds in %d run, average:%fns
\n
"
,
total_time_us
/
1000000.0
,
total_run
,
1000
*
(
float
)
total_time_us
/
(
float
)
total_run
);
gettimeofday
(
&
start
,
NULL
);
for
(
int
i
=
0
;
i
<
total_run
;
++
i
)
{
taosParseTime
(
t4
,
&
time
,
strlen
(
t4
),
TSDB_TIME_PRECISION_MILLI
,
0
);
}
gettimeofday
(
&
end
,
NULL
);
total_time_us
=
((
end
.
tv_sec
-
start
.
tv_sec
)
*
1000000
)
+
(
end
.
tv_usec
-
start
.
tv_usec
);
printf
(
"[t4] The elapsed time is %f seconds in %d run, average:%fns
\n
"
,
total_time_us
/
1000000.0
,
total_run
,
1000
*
(
float
)
total_time_us
/
(
float
)
total_run
);
}
}
TEST
(
testCase
,
tvariant_convert
)
{
TEST
(
testCase
,
tvariant_convert
)
{
// 1. bool data to all other data types
// 1. bool data to all other data types
tVariant
t
=
{
0
};
tVariant
t
=
{
0
};
...
...
src/tfs/src/tfs.c
浏览文件 @
7b67e43c
...
@@ -261,11 +261,20 @@ int tfsMkdirRecurAt(const char *rname, int level, int id) {
...
@@ -261,11 +261,20 @@ int tfsMkdirRecurAt(const char *rname, int level, int id) {
// Try to create upper
// Try to create upper
char
*
s
=
strdup
(
rname
);
char
*
s
=
strdup
(
rname
);
if
(
tfsMkdirRecurAt
(
dirname
(
s
),
level
,
id
)
<
0
)
{
// Make a copy of dirname(s) because the implementation of 'dirname' differs on different platforms.
tfree
(
s
);
// Some platform may modify the contents of the string passed into dirname(). Others may return a pointer to
// internal static storage space that will be overwritten by next call. For case like that, we should not use
// the pointer directly in this recursion.
// See https://developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man3/dirname.3.html
char
*
dir
=
strdup
(
dirname
(
s
));
if
(
tfsMkdirRecurAt
(
dir
,
level
,
id
)
<
0
)
{
free
(
s
);
free
(
dir
);
return
-
1
;
return
-
1
;
}
}
tfree
(
s
);
free
(
s
);
free
(
dir
);
if
(
tfsMkdirAt
(
rname
,
level
,
id
)
<
0
)
{
if
(
tfsMkdirAt
(
rname
,
level
,
id
)
<
0
)
{
return
-
1
;
return
-
1
;
...
...
src/util/inc/tcompare.h
浏览文件 @
7b67e43c
...
@@ -25,7 +25,7 @@ extern "C" {
...
@@ -25,7 +25,7 @@ extern "C" {
#define TSDB_PATTERN_MATCH 0
#define TSDB_PATTERN_MATCH 0
#define TSDB_PATTERN_NOMATCH 1
#define TSDB_PATTERN_NOMATCH 1
#define TSDB_PATTERN_NOWILDCARDMATCH 2
#define TSDB_PATTERN_NOWILDCARDMATCH 2
#define TSDB_PATTERN_STRING_MAX_LEN
2
0
#define TSDB_PATTERN_STRING_MAX_LEN
10
0
#define FLT_COMPAR_TOL_FACTOR 4
#define FLT_COMPAR_TOL_FACTOR 4
#define FLT_EQUAL(_x, _y) (fabs((_x) - (_y)) <= (FLT_COMPAR_TOL_FACTOR * FLT_EPSILON))
#define FLT_EQUAL(_x, _y) (fabs((_x) - (_y)) <= (FLT_COMPAR_TOL_FACTOR * FLT_EPSILON))
...
...
tests/pytest/TimeZone/TestCaseTimeZone.py
0 → 100644
浏览文件 @
7b67e43c
###################################################################
# 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
os
import
subprocess
import
time
from
util.log
import
*
from
util.cases
import
*
from
util.sql
import
*
from
util.dnodes
import
*
import
datetime
class
TDTestCase
:
def
init
(
self
,
conn
,
logSql
):
tdLog
.
debug
(
"start to execute %s"
%
__file__
)
tdSql
.
init
(
conn
.
cursor
(),
logSql
)
def
getBuildPath
(
self
):
selfPath
=
os
.
path
.
dirname
(
os
.
path
.
realpath
(
__file__
))
if
(
"community"
in
selfPath
):
projPath
=
selfPath
[:
selfPath
.
find
(
"community"
)]
else
:
projPath
=
selfPath
[:
selfPath
.
find
(
"tests"
)]
for
root
,
dirs
,
files
in
os
.
walk
(
projPath
):
if
(
"taosd"
in
files
):
rootRealPath
=
os
.
path
.
dirname
(
os
.
path
.
realpath
(
root
))
if
(
"packaging"
not
in
rootRealPath
):
buildPath
=
root
[:
len
(
root
)
-
len
(
"/build/bin"
)]
break
return
buildPath
def
run
(
self
):
tdSql
.
prepare
()
buildPath
=
self
.
getBuildPath
()
if
(
buildPath
==
""
):
tdLog
.
exit
(
"taosd not found!"
)
else
:
tdLog
.
info
(
"taosd found in %s"
%
buildPath
)
binPath
=
buildPath
+
"/build/bin/"
tdSql
.
execute
(
"create database timezone"
)
tdSql
.
execute
(
"use timezone"
)
tdSql
.
execute
(
"create stable st (ts timestamp, id int ) tags (index int)"
)
tdSql
.
execute
(
"insert into tb0 using st tags (1) values ('2021-07-01 00:00:00.000',0)"
)
tdSql
.
query
(
"select ts from tb0"
)
tdSql
.
checkData
(
0
,
0
,
"2021-07-01 00:00:00.000"
)
tdSql
.
execute
(
"insert into tb1 using st tags (1) values ('2021-07-01T00:00:00.000+07:50',1)"
)
tdSql
.
query
(
"select ts from tb1"
)
tdSql
.
checkData
(
0
,
0
,
"2021-07-01 00:10:00.000"
)
tdSql
.
execute
(
"insert into tb2 using st tags (1) values ('2021-07-01T00:00:00.000+08:00',2)"
)
tdSql
.
query
(
"select ts from tb2"
)
tdSql
.
checkData
(
0
,
0
,
"2021-07-01 00:00:00.000"
)
tdSql
.
execute
(
"insert into tb3 using st tags (1) values ('2021-07-01T00:00:00.000Z',3)"
)
tdSql
.
query
(
"select ts from tb3"
)
tdSql
.
checkData
(
0
,
0
,
"2021-07-01 08:00:00.000"
)
tdSql
.
execute
(
"insert into tb4 using st tags (1) values ('2021-07-01 00:00:00.000+07:50',4)"
)
tdSql
.
query
(
"select ts from tb4"
)
tdSql
.
checkData
(
0
,
0
,
"2021-07-01 00:10:00.000"
)
tdSql
.
execute
(
"insert into tb5 using st tags (1) values ('2021-07-01 00:00:00.000Z',5)"
)
tdSql
.
query
(
"select ts from tb5"
)
tdSql
.
checkData
(
0
,
0
,
"2021-07-01 08:00:00.000"
)
tdSql
.
execute
(
"insert into tb6 using st tags (1) values ('2021-07-01T00:00:00.000+0800',6)"
)
tdSql
.
query
(
"select ts from tb6"
)
tdSql
.
checkData
(
0
,
0
,
"2021-07-01 00:00:00.000"
)
tdSql
.
execute
(
"insert into tb7 using st tags (1) values ('2021-07-01 00:00:00.000+0800',7)"
)
tdSql
.
query
(
"select ts from tb7"
)
tdSql
.
checkData
(
0
,
0
,
"2021-07-01 00:00:00.000"
)
tdSql
.
execute
(
"insert into tb8 using st tags (1) values ('2021-07-0100:00:00.000',8)"
)
tdSql
.
query
(
"select ts from tb8"
)
tdSql
.
checkData
(
0
,
0
,
"2021-07-01 00:00:00.000"
)
tdSql
.
execute
(
"insert into tb9 using st tags (1) values ('2021-07-0100:00:00.000+0800',9)"
)
tdSql
.
query
(
"select ts from tb9"
)
tdSql
.
checkData
(
0
,
0
,
"2021-07-01 00:00:00.000"
)
tdSql
.
execute
(
"insert into tb10 using st tags (1) values ('2021-07-0100:00:00.000+08:00',10)"
)
tdSql
.
query
(
"select ts from tb10"
)
tdSql
.
checkData
(
0
,
0
,
"2021-07-01 00:00:00.000"
)
tdSql
.
execute
(
"insert into tb11 using st tags (1) values ('2021-07-0100:00:00.000+07:00',11)"
)
tdSql
.
query
(
"select ts from tb11"
)
tdSql
.
checkData
(
0
,
0
,
"2021-07-01 01:00:00.000"
)
tdSql
.
execute
(
"insert into tb12 using st tags (1) values ('2021-07-0100:00:00.000+0700',12)"
)
tdSql
.
query
(
"select ts from tb12"
)
tdSql
.
checkData
(
0
,
0
,
"2021-07-01 01:00:00.000"
)
tdSql
.
execute
(
"insert into tb13 using st tags (1) values ('2021-07-0100:00:00.000+07:12',13)"
)
tdSql
.
query
(
"select ts from tb13"
)
tdSql
.
checkData
(
0
,
0
,
"2021-07-01 00:48:00.000"
)
tdSql
.
execute
(
"insert into tb14 using st tags (1) values ('2021-07-0100:00:00.000+712',14)"
)
tdSql
.
query
(
"select ts from tb14"
)
tdSql
.
checkData
(
0
,
0
,
"2021-06-28 08:58:00.000"
)
tdSql
.
execute
(
"insert into tb15 using st tags (1) values ('2021-07-0100:00:00.000Z',15)"
)
tdSql
.
query
(
"select ts from tb15"
)
tdSql
.
checkData
(
0
,
0
,
"2021-07-01 08:00:00.000"
)
tdSql
.
execute
(
"insert into tb16 using st tags (1) values ('2021-7-1 00:00:00.000Z',16)"
)
tdSql
.
query
(
"select ts from tb16"
)
tdSql
.
checkData
(
0
,
0
,
"2021-07-01 08:00:00.000"
)
tdSql
.
execute
(
"insert into tb17 using st tags (1) values ('2021-07-0100:00:00.000+0750',17)"
)
tdSql
.
query
(
"select ts from tb17"
)
tdSql
.
checkData
(
0
,
0
,
"2021-07-01 00:10:00.000"
)
tdSql
.
execute
(
"insert into tb18 using st tags (1) values ('2021-07-0100:00:00.000+0752',18)"
)
tdSql
.
query
(
"select ts from tb18"
)
tdSql
.
checkData
(
0
,
0
,
"2021-07-01 00:08:00.000"
)
tdSql
.
execute
(
"insert into tb19 using st tags (1) values ('2021-07-0100:00:00.000+075',19)"
)
tdSql
.
query
(
"select ts from tb19"
)
tdSql
.
checkData
(
0
,
0
,
"2021-07-01 00:55:00.000"
)
tdSql
.
execute
(
"insert into tb20 using st tags (1) values ('2021-07-0100:00:00.000+75',20)"
)
tdSql
.
query
(
"select ts from tb20"
)
tdSql
.
checkData
(
0
,
0
,
"2021-06-28 05:00:00.000"
)
tdSql
.
execute
(
"insert into tb21 using st tags (1) values ('2021-7-1 1:1:1.234+075',21)"
)
tdSql
.
query
(
"select ts from tb21"
)
tdSql
.
checkData
(
0
,
0
,
"2021-07-01 01:56:01.234"
)
tdSql
.
execute
(
"insert into tb22 using st tags (1) values ('2021-7-1T1:1:1.234+075',22)"
)
tdSql
.
query
(
"select ts from tb22"
)
tdSql
.
checkData
(
0
,
0
,
"2021-07-01 01:56:01.234"
)
tdSql
.
execute
(
"insert into tb23 using st tags (1) values ('2021-7-131:1:1.234+075',22)"
)
tdSql
.
query
(
"select ts from tb23"
)
tdSql
.
checkData
(
0
,
0
,
"2021-07-13 01:56:01.234"
)
tdSql
.
error
(
"insert into tberror using st tags (1) values ('20210701 00:00:00.000+0800',0)"
)
tdSql
.
error
(
"insert into tberror using st tags (1) values ('2021070100:00:00.000+0800',0)"
)
tdSql
.
error
(
"insert into tberror using st tags (1) values ('202171 00:00:00.000+0800',0)"
)
tdSql
.
error
(
"insert into tberror using st tags (1) values ('2021 07 01 00:00:00.000+0800',0)"
)
tdSql
.
error
(
"insert into tberror using st tags (1) values ('2021 -07-0100:00:00.000+0800',0)"
)
tdSql
.
error
(
"insert into tberror using st tags (1) values ('2021-7-11:1:1.234+075',0)"
)
os
.
system
(
"rm -rf ./TimeZone/*.py.sql"
)
def
stop
(
self
):
tdSql
.
close
()
tdLog
.
success
(
"%s successfully executed"
%
__file__
)
tdCases
.
addWindows
(
__file__
,
TDTestCase
())
tdCases
.
addLinux
(
__file__
,
TDTestCase
())
tests/pytest/ZoneTimeTest.py
0 → 100644
浏览文件 @
7b67e43c
###################################################################
# 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
os
from
util.log
import
*
from
util.cases
import
*
from
util.sql
import
*
from
util.dnodes
import
*
import
datetime
class
TDTestCase
:
def
init
(
self
,
conn
,
logSql
):
tdLog
.
debug
(
"start to execute %s"
%
__file__
)
tdSql
.
init
(
conn
.
cursor
(),
logSql
)
def
checkCommunity
(
self
):
selfPath
=
os
.
path
.
dirname
(
os
.
path
.
realpath
(
__file__
))
if
(
"community"
in
selfPath
):
return
False
else
:
return
True
def
getBuildPath
(
self
):
selfPath
=
os
.
path
.
dirname
(
os
.
path
.
realpath
(
__file__
))
if
(
"community"
in
selfPath
):
projPath
=
selfPath
[:
selfPath
.
find
(
"community"
)]
else
:
projPath
=
selfPath
[:
selfPath
.
find
(
"tests"
)]
for
root
,
dirs
,
files
in
os
.
walk
(
projPath
):
if
(
"taosdump"
in
files
):
rootRealPath
=
os
.
path
.
dirname
(
os
.
path
.
realpath
(
root
))
if
(
"packaging"
not
in
rootRealPath
):
buildPath
=
root
[:
len
(
root
)
-
len
(
"/build/bin"
)]
break
return
buildPath
def
run
(
self
):
# clear envs
tdSql
.
execute
(
" create database ZoneTime precision 'us' "
)
tdSql
.
execute
(
" use ZoneTime "
)
tdSql
.
execute
(
" create stable st (ts timestamp , id int , val float) tags (tag1 timestamp ,tag2 int) "
)
# standard case for Timestamp
tdSql
.
execute
(
" insert into tb1 using st tags (
\"
2021-07-01 00:00:00.000
\"
, 2) values(
\"
2021-07-01 00:00:00.000
\"
, 1 , 1.0 ) "
)
case1
=
(
tdSql
.
getResult
(
"select * from tb1"
))
print
(
case1
)
if
case1
==
[(
datetime
.
datetime
(
2021
,
7
,
1
,
0
,
0
),
1
,
1.0
)]:
print
(
"check pass! "
)
else
:
print
(
"check failed about timestamp '2021-07-01 00:00:00.000' "
)
# RCF-3339 : it allows "T" is replaced by " "
tdSql
.
execute
(
" insert into tb2 using st tags (
\"
2021-07-01T00:00:00.000+07:50
\"
, 2) values(
\"
2021-07-01T00:00:00.000+07:50
\"
, 2 , 2.0 ) "
)
case2
=
(
tdSql
.
getResult
(
"select * from tb2"
))
print
(
case2
)
if
case2
==
[(
datetime
.
datetime
(
2021
,
7
,
1
,
0
,
10
),
2
,
2.0
)]:
print
(
"check pass! "
)
else
:
print
(
"check failed about timestamp '2021-07-01T00:00:00.000+07:50'! "
)
tdSql
.
execute
(
" insert into tb3 using st tags (
\"
2021-07-01T00:00:00.000+08:00
\"
, 3) values(
\"
2021-07-01T00:00:00.000+08:00
\"
, 3 , 3.0 ) "
)
case3
=
(
tdSql
.
getResult
(
"select * from tb3"
))
print
(
case3
)
if
case3
==
[(
datetime
.
datetime
(
2021
,
7
,
1
,
0
,
0
),
3
,
3.0
)]:
print
(
"check pass! "
)
else
:
print
(
"check failed about timestamp '2021-07-01T00:00:00.000+08:00'! "
)
tdSql
.
execute
(
" insert into tb4 using st tags (
\"
2021-07-01T00:00:00.000Z
\"
, 4) values(
\"
2021-07-01T00:00:00.000Z
\"
, 4 , 4.0 ) "
)
case4
=
(
tdSql
.
getResult
(
"select * from tb4"
))
print
(
case4
)
if
case4
==
[(
datetime
.
datetime
(
2021
,
7
,
1
,
8
,
0
),
4
,
4.0
)]:
print
(
"check pass! "
)
else
:
print
(
"check failed about timestamp '2021-07-01T00:00:00.000Z'! "
)
tdSql
.
execute
(
" insert into tb5 using st tags (
\"
2021-07-01 00:00:00.000+07:50
\"
, 5) values(
\"
2021-07-01 00:00:00.000+07:50
\"
, 5 , 5.0 ) "
)
case5
=
(
tdSql
.
getResult
(
"select * from tb5"
))
print
(
case5
)
if
case5
==
[(
datetime
.
datetime
(
2021
,
7
,
1
,
0
,
10
),
5
,
5.0
)]:
print
(
"check pass! "
)
else
:
print
(
"check failed about timestamp '2021-07-01 00:00:00.000+08:00 "
)
tdSql
.
execute
(
" insert into tb6 using st tags (
\"
2021-07-01 00:00:00.000Z
\"
, 6) values(
\"
2021-07-01 00:00:00.000Z
\"
, 6 , 6.0 ) "
)
case6
=
(
tdSql
.
getResult
(
"select * from tb6"
))
print
(
case6
)
if
case6
==
[(
datetime
.
datetime
(
2021
,
7
,
1
,
8
,
0
),
6
,
6.0
)]:
print
(
"check pass! "
)
else
:
print
(
"check failed about timestamp '2021-07-01 00:00:00.000Z'! "
)
# ISO 8610 timestamp format , time days and hours must be split by "T"
tdSql
.
execute
(
" insert into tb7 using st tags (
\"
2021-07-01T00:00:00.000+0800
\"
, 7) values(
\"
2021-07-01T00:00:00.000+0800
\"
, 7 , 7.0 ) "
)
case7
=
(
tdSql
.
getResult
(
"select * from tb7"
))
print
(
case7
)
if
case7
==
[(
datetime
.
datetime
(
2021
,
7
,
1
,
0
,
0
),
7
,
7.0
)]:
print
(
"check pass! "
)
else
:
print
(
"check failed about timestamp '2021-07-01T00:00:00.000+0800'! "
)
tdSql
.
execute
(
" insert into tb8 using st tags (
\"
2021-07-01T00:00:00.000+08
\"
, 8) values(
\"
2021-07-01T00:00:00.000+08
\"
, 8 , 8.0 ) "
)
case8
=
(
tdSql
.
getResult
(
"select * from tb8"
))
print
(
case8
)
if
case8
==
[(
datetime
.
datetime
(
2021
,
7
,
1
,
0
,
0
),
8
,
8.0
)]:
print
(
"check pass! "
)
else
:
print
(
"check failed about timestamp '2021-07-01T00:00:00.000+08'! "
)
# Non-standard case for Timestamp
tdSql
.
execute
(
" insert into tb9 using st tags (
\"
2021-07-01 00:00:00.000+0800
\"
, 9) values(
\"
2021-07-01 00:00:00.000+0800
\"
, 9 , 9.0 ) "
)
case9
=
(
tdSql
.
getResult
(
"select * from tb9"
))
print
(
case9
)
tdSql
.
execute
(
" insert into tb10 using st tags (
\"
2021-07-0100:00:00.000
\"
, 10) values(
\"
2021-07-0100:00:00.000
\"
, 10 , 10.0 ) "
)
case10
=
(
tdSql
.
getResult
(
"select * from tb10"
))
print
(
case10
)
tdSql
.
execute
(
" insert into tb11 using st tags (
\"
2021-07-0100:00:00.000+0800
\"
, 11) values(
\"
2021-07-0100:00:00.000+0800
\"
, 11 , 11.0 ) "
)
case11
=
(
tdSql
.
getResult
(
"select * from tb11"
))
print
(
case11
)
tdSql
.
execute
(
" insert into tb12 using st tags (
\"
2021-07-0100:00:00.000+08:00
\"
, 12) values(
\"
2021-07-0100:00:00.000+08:00
\"
, 12 , 12.0 ) "
)
case12
=
(
tdSql
.
getResult
(
"select * from tb12"
))
print
(
case12
)
tdSql
.
execute
(
" insert into tb13 using st tags (
\"
2021-07-0100:00:00.000Z
\"
, 13) values(
\"
2021-07-0100:00:00.000Z
\"
, 13 , 13.0 ) "
)
case13
=
(
tdSql
.
getResult
(
"select * from tb13"
))
print
(
case13
)
tdSql
.
execute
(
" insert into tb14 using st tags (
\"
2021-07-0100:00:00.000Z
\"
, 14) values(
\"
2021-07-0100:00:00.000Z
\"
, 14 , 14.0 ) "
)
case14
=
(
tdSql
.
getResult
(
"select * from tb14"
))
print
(
case14
)
tdSql
.
execute
(
" insert into tb15 using st tags (
\"
2021-07-0100:00:00.000+08
\"
, 15) values(
\"
2021-07-0100:00:00.000+08
\"
, 15 , 15.0 ) "
)
case15
=
(
tdSql
.
getResult
(
"select * from tb15"
))
print
(
case15
)
tdSql
.
execute
(
" insert into tb16 using st tags (
\"
2021-07-0100:00:00.000+07:50
\"
, 16) values(
\"
2021-07-0100:00:00.000+07:50
\"
, 16 , 16.0 ) "
)
case16
=
(
tdSql
.
getResult
(
"select * from tb16"
))
print
(
case16
)
os
.
system
(
"rm -rf *.py.sql"
)
def
stop
(
self
):
tdSql
.
close
()
tdLog
.
success
(
"%s successfully executed"
%
__file__
)
tdCases
.
addWindows
(
__file__
,
TDTestCase
())
tdCases
.
addLinux
(
__file__
,
TDTestCase
())
tests/pytest/client/client.py
浏览文件 @
7b67e43c
...
@@ -16,6 +16,7 @@ from util.log import *
...
@@ -16,6 +16,7 @@ from util.log import *
from
util.cases
import
*
from
util.cases
import
*
from
util.sql
import
*
from
util.sql
import
*
from
datetime
import
timedelta
class
TDTestCase
:
class
TDTestCase
:
def
init
(
self
,
conn
,
logSql
):
def
init
(
self
,
conn
,
logSql
):
...
@@ -36,15 +37,36 @@ class TDTestCase:
...
@@ -36,15 +37,36 @@ class TDTestCase:
ret
=
tdSql
.
query
(
'show dnodes'
)
ret
=
tdSql
.
query
(
'show dnodes'
)
ret
=
tdSql
.
execute
(
'alter dnode "%s" debugFlag 135'
%
tdSql
.
getData
(
0
,
0
))
dnodeId
=
tdSql
.
getData
(
0
,
0
);
tdLog
.
info
(
'alter dnode "%s" debugFlag 135 -> ret: %d'
%
(
tdSql
.
getData
(
0
,
0
),
ret
))
dnodeEndpoint
=
tdSql
.
getData
(
0
,
1
);
ret
=
tdSql
.
execute
(
'alter dnode "%s" debugFlag 135'
%
dnodeId
)
tdLog
.
info
(
'alter dnode "%s" debugFlag 135 -> ret: %d'
%
(
dnodeId
,
ret
))
ret
=
tdSql
.
query
(
'show mnodes'
)
ret
=
tdSql
.
query
(
'show mnodes'
)
tdSql
.
checkRows
(
1
)
tdSql
.
checkRows
(
1
)
tdSql
.
checkData
(
0
,
2
,
"master"
)
role_time
=
tdSql
.
getData
(
0
,
3
)
create_time
=
tdSql
.
getData
(
0
,
4
)
time_delta
=
timedelta
(
milliseconds
=
100
)
if
create_time
-
time_delta
<
role_time
<
create_time
+
time_delta
:
tdLog
.
info
(
"role_time {} and create_time {} expected within range"
.
format
(
role_time
,
create_time
))
else
:
tdLog
.
exit
(
"role_time {} and create_time {} not expected within range"
.
format
(
role_time
,
create_time
))
ret
=
tdSql
.
query
(
'show vgroups'
)
ret
=
tdSql
.
query
(
'show vgroups'
)
tdSql
.
checkRows
(
0
)
tdSql
.
checkRows
(
0
)
tdSql
.
execute
(
'create stable st (ts timestamp, f int) tags(t int)'
)
tdSql
.
execute
(
'create table ct1 using st tags(1)'
);
tdSql
.
execute
(
'create table ct2 using st tags(2)'
);
ret
=
tdSql
.
query
(
'show vnodes "{}"'
.
format
(
dnodeEndpoint
))
tdSql
.
checkRows
(
1
)
tdSql
.
checkData
(
0
,
0
,
2
)
tdSql
.
checkData
(
0
,
1
,
"master"
)
def
stop
(
self
):
def
stop
(
self
):
tdSql
.
close
()
tdSql
.
close
()
...
...
tests/pytest/fulltest.sh
浏览文件 @
7b67e43c
...
@@ -29,6 +29,10 @@ python3 ./test.py -f insert/in_function.py
...
@@ -29,6 +29,10 @@ python3 ./test.py -f insert/in_function.py
python3 ./test.py
-f
insert/modify_column.py
python3 ./test.py
-f
insert/modify_column.py
python3 ./test.py
-f
insert/line_insert.py
python3 ./test.py
-f
insert/line_insert.py
# timezone
python3 ./test.py
-f
TimeZone/TestCaseTimeZone.py
#table
#table
python3 ./test.py
-f
table/alter_wal0.py
python3 ./test.py
-f
table/alter_wal0.py
python3 ./test.py
-f
table/column_name.py
python3 ./test.py
-f
table/column_name.py
...
...
tests/pytest/functions/showOfflineThresholdIs864000.py
浏览文件 @
7b67e43c
...
@@ -25,7 +25,7 @@ class TDTestCase:
...
@@ -25,7 +25,7 @@ class TDTestCase:
def
run
(
self
):
def
run
(
self
):
tdSql
.
query
(
"show variables"
)
tdSql
.
query
(
"show variables"
)
tdSql
.
checkData
(
5
3
,
1
,
864000
)
tdSql
.
checkData
(
5
4
,
1
,
864000
)
def
stop
(
self
):
def
stop
(
self
):
tdSql
.
close
()
tdSql
.
close
()
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录