Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
cef9aa76
T
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1185
Star
22016
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看板
提交
cef9aa76
编写于
8月 27, 2021
作者:
H
Haojun Liao
浏览文件
操作
浏览文件
下载
差异文件
Merge remote-tracking branch 'origin/develop' into develop
上级
5b74524c
dd48e67c
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
121 addition
and
41 deletion
+121
-41
src/connector/jdbc/pom.xml
src/connector/jdbc/pom.xml
+0
-1
src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBError.java
...ector/jdbc/src/main/java/com/taosdata/jdbc/TSDBError.java
+2
-2
src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBJNIConnector.java
...dbc/src/main/java/com/taosdata/jdbc/TSDBJNIConnector.java
+6
-12
src/connector/jdbc/src/test/java/com/taosdata/jdbc/cases/UseNowInsertTimestampTest.java
...va/com/taosdata/jdbc/cases/UseNowInsertTimestampTest.java
+84
-0
src/connector/jdbc/src/test/java/com/taosdata/jdbc/rs/RestfulConnectionTest.java
...test/java/com/taosdata/jdbc/rs/RestfulConnectionTest.java
+26
-23
tests/pytest/query/last_row_cache.py
tests/pytest/query/last_row_cache.py
+3
-3
未找到文件。
src/connector/jdbc/pom.xml
浏览文件 @
cef9aa76
...
...
@@ -117,7 +117,6 @@
<exclude>
**/DatetimeBefore1970Test.java
</exclude>
<exclude>
**/FailOverTest.java
</exclude>
<exclude>
**/InvalidResultSetPointerTest.java
</exclude>
<exclude>
**/RestfulConnectionTest.java
</exclude>
<exclude>
**/TSDBJNIConnectorTest.java
</exclude>
<exclude>
**/TaosInfoMonitorTest.java
</exclude>
<exclude>
**/UnsignedNumberJniTest.java
</exclude>
...
...
src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBError.java
浏览文件 @
cef9aa76
...
...
@@ -40,13 +40,13 @@ public class TSDBError {
TSDBErrorMap
.
put
(
TSDBErrorNumbers
.
ERROR_SUBSCRIBE_FAILED
,
"failed to create subscription"
);
TSDBErrorMap
.
put
(
TSDBErrorNumbers
.
ERROR_UNSUPPORTED_ENCODING
,
"Unsupported encoding"
);
TSDBErrorMap
.
put
(
TSDBErrorNumbers
.
ERROR_JNI_TDENGINE_ERROR
,
"internal error of database"
);
TSDBErrorMap
.
put
(
TSDBErrorNumbers
.
ERROR_JNI_TDENGINE_ERROR
,
"internal error of database
, please see taoslog for more details
"
);
TSDBErrorMap
.
put
(
TSDBErrorNumbers
.
ERROR_JNI_CONNECTION_NULL
,
"JNI connection is NULL"
);
TSDBErrorMap
.
put
(
TSDBErrorNumbers
.
ERROR_JNI_RESULT_SET_NULL
,
"JNI result set is NULL"
);
TSDBErrorMap
.
put
(
TSDBErrorNumbers
.
ERROR_JNI_NUM_OF_FIELDS_0
,
"invalid num of fields"
);
TSDBErrorMap
.
put
(
TSDBErrorNumbers
.
ERROR_JNI_SQL_NULL
,
"empty sql string"
);
TSDBErrorMap
.
put
(
TSDBErrorNumbers
.
ERROR_JNI_FETCH_END
,
"fetch to the end of resultSet"
);
TSDBErrorMap
.
put
(
TSDBErrorNumbers
.
ERROR_JNI_OUT_OF_MEMORY
,
"JNI alloc memory failed"
);
TSDBErrorMap
.
put
(
TSDBErrorNumbers
.
ERROR_JNI_OUT_OF_MEMORY
,
"JNI alloc memory failed
, please see taoslog for more details
"
);
}
public
static
SQLException
createSQLException
(
int
errorCode
)
{
...
...
src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBJNIConnector.java
浏览文件 @
cef9aa76
...
...
@@ -278,25 +278,20 @@ public class TSDBJNIConnector {
private
native
int
validateCreateTableSqlImp
(
long
connection
,
byte
[]
sqlBytes
);
public
long
prepareStmt
(
String
sql
)
throws
SQLException
{
long
stmt
;
try
{
stmt
=
prepareStmtImp
(
sql
.
getBytes
(),
this
.
taos
);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
throw
TSDBError
.
createSQLException
(
TSDBErrorNumbers
.
ERROR_UNSUPPORTED_ENCODING
);
}
long
stmt
=
prepareStmtImp
(
sql
.
getBytes
(),
this
.
taos
);
if
(
stmt
==
TSDBConstants
.
JNI_CONNECTION_NULL
)
{
throw
TSDBError
.
createSQLException
(
TSDBErrorNumbers
.
ERROR_JNI_CONNECTION_NULL
);
throw
TSDBError
.
createSQLException
(
TSDBErrorNumbers
.
ERROR_JNI_CONNECTION_NULL
,
"connection already closed"
);
}
if
(
stmt
==
TSDBConstants
.
JNI_SQL_NULL
)
{
throw
TSDBError
.
createSQLException
(
TSDBErrorNumbers
.
ERROR_JNI_SQL_NULL
);
}
if
(
stmt
==
TSDBConstants
.
JNI_OUT_OF_MEMORY
)
{
throw
TSDBError
.
createSQLException
(
TSDBErrorNumbers
.
ERROR_JNI_OUT_OF_MEMORY
);
}
if
(
stmt
==
TSDBConstants
.
JNI_TDENGINE_ERROR
)
{
throw
TSDBError
.
createSQLException
(
TSDBErrorNumbers
.
ERROR_JNI_TDENGINE_ERROR
);
}
return
stmt
;
}
...
...
@@ -313,8 +308,7 @@ public class TSDBJNIConnector {
private
native
int
setBindTableNameImp
(
long
stmt
,
String
name
,
long
conn
);
public
void
setBindTableNameAndTags
(
long
stmt
,
String
tableName
,
int
numOfTags
,
ByteBuffer
tags
,
ByteBuffer
typeList
,
ByteBuffer
lengthList
,
ByteBuffer
nullList
)
throws
SQLException
{
int
code
=
setTableNameTagsImp
(
stmt
,
tableName
,
numOfTags
,
tags
.
array
(),
typeList
.
array
(),
lengthList
.
array
(),
nullList
.
array
(),
this
.
taos
);
int
code
=
setTableNameTagsImp
(
stmt
,
tableName
,
numOfTags
,
tags
.
array
(),
typeList
.
array
(),
lengthList
.
array
(),
nullList
.
array
(),
this
.
taos
);
if
(
code
!=
TSDBConstants
.
JNI_SUCCESS
)
{
throw
TSDBError
.
createSQLException
(
TSDBErrorNumbers
.
ERROR_UNKNOWN
,
"failed to bind table name and corresponding tags"
);
}
...
...
src/connector/jdbc/src/test/java/com/taosdata/jdbc/cases/UseNowInsertTimestampTest.java
0 → 100644
浏览文件 @
cef9aa76
package
com.taosdata.jdbc.cases
;
import
org.junit.Before
;
import
org.junit.Test
;
import
java.sql.*
;
import
static
org
.
junit
.
Assert
.
assertEquals
;
import
static
org
.
junit
.
Assert
.
assertTrue
;
public
class
UseNowInsertTimestampTest
{
String
url
=
"jdbc:TAOS://127.0.0.1:6030/?user=root&password=taosdata"
;
@Test
public
void
millisec
()
{
try
(
Connection
conn
=
DriverManager
.
getConnection
(
url
))
{
Statement
stmt
=
conn
.
createStatement
();
stmt
.
execute
(
"drop database if exists test"
);
stmt
.
execute
(
"create database if not exists test precision 'ms'"
);
stmt
.
execute
(
"use test"
);
stmt
.
execute
(
"create table weather(ts timestamp, f1 int)"
);
stmt
.
execute
(
"insert into weather values(now, 1)"
);
ResultSet
rs
=
stmt
.
executeQuery
(
"select * from weather"
);
rs
.
next
();
Timestamp
ts
=
rs
.
getTimestamp
(
"ts"
);
assertEquals
(
13
,
Long
.
toString
(
ts
.
getTime
()).
length
());
int
nanos
=
ts
.
getNanos
();
assertEquals
(
0
,
nanos
%
1000_000
);
stmt
.
execute
(
"drop database if exists test"
);
}
catch
(
SQLException
e
)
{
e
.
printStackTrace
();
}
}
@Test
public
void
microsec
()
{
try
(
Connection
conn
=
DriverManager
.
getConnection
(
url
))
{
Statement
stmt
=
conn
.
createStatement
();
stmt
.
execute
(
"drop database if exists test"
);
stmt
.
execute
(
"create database if not exists test precision 'us'"
);
stmt
.
execute
(
"use test"
);
stmt
.
execute
(
"create table weather(ts timestamp, f1 int)"
);
stmt
.
execute
(
"insert into weather values(now, 1)"
);
ResultSet
rs
=
stmt
.
executeQuery
(
"select * from weather"
);
rs
.
next
();
Timestamp
ts
=
rs
.
getTimestamp
(
"ts"
);
int
nanos
=
ts
.
getNanos
();
assertEquals
(
0
,
nanos
%
1000
);
stmt
.
execute
(
"drop database if exists test"
);
}
catch
(
SQLException
e
)
{
e
.
printStackTrace
();
}
}
@Test
public
void
nanosec
()
{
try
(
Connection
conn
=
DriverManager
.
getConnection
(
url
))
{
Statement
stmt
=
conn
.
createStatement
();
stmt
.
execute
(
"drop database if exists test"
);
stmt
.
execute
(
"create database if not exists test precision 'ns'"
);
stmt
.
execute
(
"use test"
);
stmt
.
execute
(
"create table weather(ts timestamp, f1 int)"
);
stmt
.
execute
(
"insert into weather values(now, 1)"
);
ResultSet
rs
=
stmt
.
executeQuery
(
"select * from weather"
);
rs
.
next
();
Timestamp
ts
=
rs
.
getTimestamp
(
"ts"
);
int
nanos
=
ts
.
getNanos
();
assertTrue
(
nanos
%
1000
!=
0
);
stmt
.
execute
(
"drop database if exists test"
);
}
catch
(
SQLException
e
)
{
e
.
printStackTrace
();
}
}
}
src/connector/jdbc/src/test/java/com/taosdata/jdbc/rs/RestfulConnectionTest.java
浏览文件 @
cef9aa76
...
...
@@ -9,6 +9,8 @@ import org.junit.Test;
import
java.sql.*
;
import
java.util.Properties
;
import
static
org
.
junit
.
Assert
.
assertEquals
;
public
class
RestfulConnectionTest
{
private
static
final
String
host
=
"127.0.0.1"
;
...
...
@@ -26,7 +28,7 @@ public class RestfulConnectionTest {
ResultSet
rs
=
stmt
.
executeQuery
(
"select server_status()"
);
rs
.
next
();
int
status
=
rs
.
getInt
(
"server_status()"
);
Assert
.
assertEquals
(
1
,
status
);
assertEquals
(
1
,
status
);
}
catch
(
SQLException
e
)
{
e
.
printStackTrace
();
}
...
...
@@ -38,7 +40,7 @@ public class RestfulConnectionTest {
ResultSet
rs
=
pstmt
.
executeQuery
();
rs
.
next
();
int
status
=
rs
.
getInt
(
"server_status()"
);
Assert
.
assertEquals
(
1
,
status
);
assertEquals
(
1
,
status
);
}
@Test
(
expected
=
SQLFeatureNotSupportedException
.
class
)
...
...
@@ -49,7 +51,7 @@ public class RestfulConnectionTest {
@Test
public
void
nativeSQL
()
throws
SQLException
{
String
nativeSQL
=
conn
.
nativeSQL
(
"select * from log.log"
);
Assert
.
assertEquals
(
"select * from log.log"
,
nativeSQL
);
assertEquals
(
"select * from log.log"
,
nativeSQL
);
}
@Test
...
...
@@ -87,7 +89,7 @@ public class RestfulConnectionTest {
public
void
getMetaData
()
throws
SQLException
{
DatabaseMetaData
meta
=
conn
.
getMetaData
();
Assert
.
assertNotNull
(
meta
);
Assert
.
assertEquals
(
"com.taosdata.jdbc.rs.RestfulDriver"
,
meta
.
getDriverName
());
assertEquals
(
"com.taosdata.jdbc.rs.RestfulDriver"
,
meta
.
getDriverName
());
}
@Test
...
...
@@ -103,25 +105,25 @@ public class RestfulConnectionTest {
@Test
public
void
setCatalog
()
throws
SQLException
{
conn
.
setCatalog
(
"test"
);
Assert
.
assertEquals
(
"test"
,
conn
.
getCatalog
());
assertEquals
(
"test"
,
conn
.
getCatalog
());
}
@Test
public
void
getCatalog
()
throws
SQLException
{
conn
.
setCatalog
(
"log"
);
Assert
.
assertEquals
(
"log"
,
conn
.
getCatalog
());
assertEquals
(
"log"
,
conn
.
getCatalog
());
}
@Test
(
expected
=
SQLFeatureNotSupportedException
.
class
)
public
void
setTransactionIsolation
()
throws
SQLException
{
conn
.
setTransactionIsolation
(
Connection
.
TRANSACTION_NONE
);
Assert
.
assertEquals
(
Connection
.
TRANSACTION_NONE
,
conn
.
getTransactionIsolation
());
assertEquals
(
Connection
.
TRANSACTION_NONE
,
conn
.
getTransactionIsolation
());
conn
.
setTransactionIsolation
(
Connection
.
TRANSACTION_READ_UNCOMMITTED
);
}
@Test
public
void
getTransactionIsolation
()
throws
SQLException
{
Assert
.
assertEquals
(
Connection
.
TRANSACTION_NONE
,
conn
.
getTransactionIsolation
());
assertEquals
(
Connection
.
TRANSACTION_NONE
,
conn
.
getTransactionIsolation
());
}
@Test
...
...
@@ -140,7 +142,7 @@ public class RestfulConnectionTest {
ResultSet
rs
=
stmt
.
executeQuery
(
"select server_status()"
);
rs
.
next
();
int
status
=
rs
.
getInt
(
"server_status()"
);
Assert
.
assertEquals
(
1
,
status
);
assertEquals
(
1
,
status
);
conn
.
createStatement
(
ResultSet
.
TYPE_SCROLL_INSENSITIVE
,
ResultSet
.
CONCUR_READ_ONLY
);
}
...
...
@@ -152,7 +154,7 @@ public class RestfulConnectionTest {
ResultSet
rs
=
pstmt
.
executeQuery
();
rs
.
next
();
int
status
=
rs
.
getInt
(
"server_status()"
);
Assert
.
assertEquals
(
1
,
status
);
assertEquals
(
1
,
status
);
conn
.
prepareStatement
(
"select server_status"
,
ResultSet
.
TYPE_SCROLL_INSENSITIVE
,
ResultSet
.
CONCUR_READ_ONLY
);
}
...
...
@@ -175,13 +177,13 @@ public class RestfulConnectionTest {
@Test
(
expected
=
SQLFeatureNotSupportedException
.
class
)
public
void
setHoldability
()
throws
SQLException
{
conn
.
setHoldability
(
ResultSet
.
HOLD_CURSORS_OVER_COMMIT
);
Assert
.
assertEquals
(
ResultSet
.
HOLD_CURSORS_OVER_COMMIT
,
conn
.
getHoldability
());
assertEquals
(
ResultSet
.
HOLD_CURSORS_OVER_COMMIT
,
conn
.
getHoldability
());
conn
.
setHoldability
(
ResultSet
.
CLOSE_CURSORS_AT_COMMIT
);
}
@Test
public
void
getHoldability
()
throws
SQLException
{
Assert
.
assertEquals
(
ResultSet
.
HOLD_CURSORS_OVER_COMMIT
,
conn
.
getHoldability
());
assertEquals
(
ResultSet
.
HOLD_CURSORS_OVER_COMMIT
,
conn
.
getHoldability
());
}
@Test
(
expected
=
SQLFeatureNotSupportedException
.
class
)
...
...
@@ -210,7 +212,7 @@ public class RestfulConnectionTest {
ResultSet
rs
=
stmt
.
executeQuery
(
"select server_status()"
);
rs
.
next
();
int
status
=
rs
.
getInt
(
"server_status()"
);
Assert
.
assertEquals
(
1
,
status
);
assertEquals
(
1
,
status
);
conn
.
createStatement
(
ResultSet
.
TYPE_SCROLL_INSENSITIVE
,
ResultSet
.
CONCUR_READ_ONLY
,
ResultSet
.
HOLD_CURSORS_OVER_COMMIT
);
}
...
...
@@ -222,7 +224,7 @@ public class RestfulConnectionTest {
ResultSet
rs
=
pstmt
.
executeQuery
();
rs
.
next
();
int
status
=
rs
.
getInt
(
"server_status()"
);
Assert
.
assertEquals
(
1
,
status
);
assertEquals
(
1
,
status
);
conn
.
prepareStatement
(
"select server_status"
,
ResultSet
.
TYPE_SCROLL_INSENSITIVE
,
ResultSet
.
CONCUR_READ_ONLY
,
ResultSet
.
HOLD_CURSORS_OVER_COMMIT
);
}
...
...
@@ -299,11 +301,11 @@ public class RestfulConnectionTest {
Properties
info
=
conn
.
getClientInfo
();
String
charset
=
info
.
getProperty
(
TSDBDriver
.
PROPERTY_KEY_CHARSET
);
Assert
.
assertEquals
(
"UTF-8"
,
charset
);
assertEquals
(
"UTF-8"
,
charset
);
String
locale
=
info
.
getProperty
(
TSDBDriver
.
PROPERTY_KEY_LOCALE
);
Assert
.
assertEquals
(
"en_US.UTF-8"
,
locale
);
assertEquals
(
"en_US.UTF-8"
,
locale
);
String
timezone
=
info
.
getProperty
(
TSDBDriver
.
PROPERTY_KEY_TIME_ZONE
);
Assert
.
assertEquals
(
"UTC-8"
,
timezone
);
assertEquals
(
"UTC-8"
,
timezone
);
}
@Test
...
...
@@ -313,11 +315,11 @@ public class RestfulConnectionTest {
conn
.
setClientInfo
(
TSDBDriver
.
PROPERTY_KEY_TIME_ZONE
,
"UTC-8"
);
String
charset
=
conn
.
getClientInfo
(
TSDBDriver
.
PROPERTY_KEY_CHARSET
);
Assert
.
assertEquals
(
"UTF-8"
,
charset
);
assertEquals
(
"UTF-8"
,
charset
);
String
locale
=
conn
.
getClientInfo
(
TSDBDriver
.
PROPERTY_KEY_LOCALE
);
Assert
.
assertEquals
(
"en_US.UTF-8"
,
locale
);
assertEquals
(
"en_US.UTF-8"
,
locale
);
String
timezone
=
conn
.
getClientInfo
(
TSDBDriver
.
PROPERTY_KEY_TIME_ZONE
);
Assert
.
assertEquals
(
"UTC-8"
,
timezone
);
assertEquals
(
"UTC-8"
,
timezone
);
}
@Test
(
expected
=
SQLFeatureNotSupportedException
.
class
)
...
...
@@ -345,14 +347,15 @@ public class RestfulConnectionTest {
conn
.
abort
(
null
);
}
@Test
(
expected
=
SQLFeatureNotSupportedException
.
class
)
@Test
public
void
setNetworkTimeout
()
throws
SQLException
{
conn
.
setNetworkTimeout
(
null
,
1000
);
}
@Test
(
expected
=
SQLFeatureNotSupportedException
.
class
)
@Test
public
void
getNetworkTimeout
()
throws
SQLException
{
conn
.
getNetworkTimeout
();
int
timeout
=
conn
.
getNetworkTimeout
();
assertEquals
(
0
,
timeout
);
}
@Test
...
...
tests/pytest/query/last_row_cache.py
浏览文件 @
cef9aa76
...
...
@@ -25,7 +25,7 @@ class TDTestCase:
self
.
tables
=
10
self
.
rows
=
20
self
.
columns
=
5
self
.
columns
=
100
self
.
perfix
=
't'
self
.
ts
=
1601481600000
...
...
@@ -33,8 +33,8 @@ class TDTestCase:
print
(
"==============step1"
)
sql
=
"create table st(ts timestamp, "
for
i
in
range
(
self
.
columns
-
1
):
sql
+=
"c%d int, "
%
(
i
+
1
)
sql
+=
"c
5
int) tags(t1 int)"
sql
+=
"c%d
big
int, "
%
(
i
+
1
)
sql
+=
"c
100 big
int) tags(t1 int)"
tdSql
.
execute
(
sql
)
for
i
in
range
(
self
.
tables
):
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录