Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
24a0b291
T
TDengine
项目概览
taosdata
/
TDengine
大约 1 年 前同步成功
通知
1181
Star
22014
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看板
体验新版 GitCode,发现更多精彩内容 >>
提交
24a0b291
编写于
1月 08, 2021
作者:
P
Ping Xiao
浏览文件
操作
浏览文件
下载
差异文件
Merge branch 'develop' into xiaoping/add_test_case
上级
e3d65a9a
18068743
变更
22
显示空白变更内容
内联
并排
Showing
22 changed file
with
708 addition
and
258 deletion
+708
-258
src/client/src/tscSQLParser.c
src/client/src/tscSQLParser.c
+29
-0
src/client/src/tscSubquery.c
src/client/src/tscSubquery.c
+34
-7
src/connector/C#/TDengineDriver.cs
src/connector/C#/TDengineDriver.cs
+118
-117
src/connector/jdbc/src/test/java/com/taosdata/jdbc/DatabaseMetaDataTest.java
...src/test/java/com/taosdata/jdbc/DatabaseMetaDataTest.java
+5
-4
src/connector/jdbc/src/test/java/com/taosdata/jdbc/cases/AppMemoryLeakTest.java
.../test/java/com/taosdata/jdbc/cases/AppMemoryLeakTest.java
+1
-12
src/connector/jdbc/src/test/java/com/taosdata/jdbc/cases/ConnectWrongDatabaseTest.java
...ava/com/taosdata/jdbc/cases/ConnectWrongDatabaseTest.java
+24
-0
src/connector/jdbc/src/test/java/com/taosdata/jdbc/utils/SqlSyntaxValidatorTest.java
.../java/com/taosdata/jdbc/utils/SqlSyntaxValidatorTest.java
+0
-4
src/query/inc/qTsbuf.h
src/query/inc/qTsbuf.h
+1
-0
src/query/src/qAggMain.c
src/query/src/qAggMain.c
+8
-4
src/query/src/qExecutor.c
src/query/src/qExecutor.c
+25
-20
src/query/src/qTsbuf.c
src/query/src/qTsbuf.c
+13
-5
src/util/src/hash.c
src/util/src/hash.c
+0
-2
tests/examples/C#/taosdemo/README.md
tests/examples/C#/taosdemo/README.md
+5
-3
tests/examples/C#/taosdemo/TDengineDriver.cs
tests/examples/C#/taosdemo/TDengineDriver.cs
+155
-1
tests/examples/C#/taosdemo/TDengineDriver.cs
tests/examples/C#/taosdemo/TDengineDriver.cs
+155
-1
tests/examples/C#/taosdemo/taosdemo.cs
tests/examples/C#/taosdemo/taosdemo.cs
+61
-29
tests/examples/JDBC/JDBCDemo/pom.xml
tests/examples/JDBC/JDBCDemo/pom.xml
+8
-0
tests/examples/JDBC/JDBCDemo/src/main/java/com/taosdata/example/JDBCDemo.java
...JDBCDemo/src/main/java/com/taosdata/example/JDBCDemo.java
+2
-2
tests/script/general/parser/first_last_query.sim
tests/script/general/parser/first_last_query.sim
+1
-0
tests/script/general/parser/function.sim
tests/script/general/parser/function.sim
+12
-0
tests/script/general/parser/groupby.sim
tests/script/general/parser/groupby.sim
+4
-0
tests/script/general/parser/testSuite.sim
tests/script/general/parser/testSuite.sim
+47
-47
未找到文件。
src/client/src/tscSQLParser.c
浏览文件 @
24a0b291
...
@@ -5833,14 +5833,43 @@ static int32_t doAddGroupbyColumnsOnDemand(SSqlCmd* pCmd, SQueryInfo* pQueryInfo
...
@@ -5833,14 +5833,43 @@ static int32_t doAddGroupbyColumnsOnDemand(SSqlCmd* pCmd, SQueryInfo* pQueryInfo
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
static
int32_t
doTagFunctionCheck
(
SQueryInfo
*
pQueryInfo
)
{
bool
tagProjection
=
false
;
bool
tableCounting
=
false
;
int32_t
numOfCols
=
(
int32_t
)
tscSqlExprNumOfExprs
(
pQueryInfo
);
for
(
int32_t
i
=
0
;
i
<
numOfCols
;
++
i
)
{
SSqlExpr
*
pExpr
=
tscSqlExprGet
(
pQueryInfo
,
i
);
int32_t
functionId
=
pExpr
->
functionId
;
if
(
functionId
==
TSDB_FUNC_TAGPRJ
)
{
tagProjection
=
true
;
continue
;
}
if
(
functionId
==
TSDB_FUNC_COUNT
)
{
assert
(
pExpr
->
colInfo
.
colId
==
TSDB_TBNAME_COLUMN_INDEX
);
tableCounting
=
true
;
}
}
return
(
tableCounting
&&
tagProjection
)
?
-
1
:
0
;
}
int32_t
doFunctionsCompatibleCheck
(
SSqlCmd
*
pCmd
,
SQueryInfo
*
pQueryInfo
)
{
int32_t
doFunctionsCompatibleCheck
(
SSqlCmd
*
pCmd
,
SQueryInfo
*
pQueryInfo
)
{
const
char
*
msg1
=
"functions/columns not allowed in group by query"
;
const
char
*
msg1
=
"functions/columns not allowed in group by query"
;
const
char
*
msg2
=
"projection query on columns not allowed"
;
const
char
*
msg2
=
"projection query on columns not allowed"
;
const
char
*
msg3
=
"group by not allowed on projection query"
;
const
char
*
msg3
=
"group by not allowed on projection query"
;
const
char
*
msg4
=
"retrieve tags not compatible with group by or interval query"
;
const
char
*
msg4
=
"retrieve tags not compatible with group by or interval query"
;
const
char
*
msg5
=
"functions can not be mixed up"
;
// only retrieve tags, group by is not supportted
// only retrieve tags, group by is not supportted
if
(
tscQueryTags
(
pQueryInfo
))
{
if
(
tscQueryTags
(
pQueryInfo
))
{
if
(
doTagFunctionCheck
(
pQueryInfo
)
!=
TSDB_CODE_SUCCESS
)
{
return
invalidSqlErrMsg
(
tscGetErrorMsgPayload
(
pCmd
),
msg5
);
}
if
(
pQueryInfo
->
groupbyExpr
.
numOfGroupCols
>
0
||
pQueryInfo
->
interval
.
interval
>
0
)
{
if
(
pQueryInfo
->
groupbyExpr
.
numOfGroupCols
>
0
||
pQueryInfo
->
interval
.
interval
>
0
)
{
return
invalidSqlErrMsg
(
tscGetErrorMsgPayload
(
pCmd
),
msg4
);
return
invalidSqlErrMsg
(
tscGetErrorMsgPayload
(
pCmd
),
msg4
);
}
else
{
}
else
{
...
...
src/client/src/tscSubquery.c
浏览文件 @
24a0b291
...
@@ -188,7 +188,9 @@ static int64_t doTSBlockIntersect(SSqlObj* pSql, SJoinSupporter* pSupporter1, SJ
...
@@ -188,7 +188,9 @@ static int64_t doTSBlockIntersect(SSqlObj* pSql, SJoinSupporter* pSupporter1, SJ
tsBufFlush
(
output2
);
tsBufFlush
(
output2
);
tsBufDestroy
(
pSupporter1
->
pTSBuf
);
tsBufDestroy
(
pSupporter1
->
pTSBuf
);
pSupporter1
->
pTSBuf
=
NULL
;
tsBufDestroy
(
pSupporter2
->
pTSBuf
);
tsBufDestroy
(
pSupporter2
->
pTSBuf
);
pSupporter2
->
pTSBuf
=
NULL
;
TSKEY
et
=
taosGetTimestampUs
();
TSKEY
et
=
taosGetTimestampUs
();
tscDebug
(
"%p input1:%"
PRId64
", input2:%"
PRId64
", final:%"
PRId64
" in %d vnodes for secondary query after ts blocks "
tscDebug
(
"%p input1:%"
PRId64
", input2:%"
PRId64
", final:%"
PRId64
" in %d vnodes for secondary query after ts blocks "
...
@@ -219,12 +221,9 @@ SJoinSupporter* tscCreateJoinSupporter(SSqlObj* pSql, int32_t index) {
...
@@ -219,12 +221,9 @@ SJoinSupporter* tscCreateJoinSupporter(SSqlObj* pSql, int32_t index) {
assert
(
pSupporter
->
uid
!=
0
);
assert
(
pSupporter
->
uid
!=
0
);
taosGetTmpfilePath
(
"join-"
,
pSupporter
->
path
);
taosGetTmpfilePath
(
"join-"
,
pSupporter
->
path
);
pSupporter
->
f
=
fopen
(
pSupporter
->
path
,
"w"
);
// todo handle error
// do NOT create file here to reduce crash generated file left issue
if
(
pSupporter
->
f
==
NULL
)
{
pSupporter
->
f
=
NULL
;
tscError
(
"%p failed to create tmp file:%s, reason:%s"
,
pSql
,
pSupporter
->
path
,
strerror
(
errno
));
}
return
pSupporter
;
return
pSupporter
;
}
}
...
@@ -244,12 +243,19 @@ static void tscDestroyJoinSupporter(SJoinSupporter* pSupporter) {
...
@@ -244,12 +243,19 @@ static void tscDestroyJoinSupporter(SJoinSupporter* pSupporter) {
tscFieldInfoClear
(
&
pSupporter
->
fieldsInfo
);
tscFieldInfoClear
(
&
pSupporter
->
fieldsInfo
);
if
(
pSupporter
->
pTSBuf
!=
NULL
)
{
tsBufDestroy
(
pSupporter
->
pTSBuf
);
pSupporter
->
pTSBuf
=
NULL
;
}
unlink
(
pSupporter
->
path
);
if
(
pSupporter
->
f
!=
NULL
)
{
if
(
pSupporter
->
f
!=
NULL
)
{
fclose
(
pSupporter
->
f
);
fclose
(
pSupporter
->
f
);
unlink
(
pSupporter
->
path
);
pSupporter
->
f
=
NULL
;
pSupporter
->
f
=
NULL
;
}
}
if
(
pSupporter
->
pVgroupTables
!=
NULL
)
{
if
(
pSupporter
->
pVgroupTables
!=
NULL
)
{
taosArrayDestroy
(
pSupporter
->
pVgroupTables
);
taosArrayDestroy
(
pSupporter
->
pVgroupTables
);
pSupporter
->
pVgroupTables
=
NULL
;
pSupporter
->
pVgroupTables
=
NULL
;
...
@@ -526,6 +532,8 @@ static void quitAllSubquery(SSqlObj* pSqlObj, SJoinSupporter* pSupporter) {
...
@@ -526,6 +532,8 @@ static void quitAllSubquery(SSqlObj* pSqlObj, SJoinSupporter* pSupporter) {
tscError
(
"%p all subquery return and query failed, global code:%s"
,
pSqlObj
,
tstrerror
(
pSqlObj
->
res
.
code
));
tscError
(
"%p all subquery return and query failed, global code:%s"
,
pSqlObj
,
tstrerror
(
pSqlObj
->
res
.
code
));
freeJoinSubqueryObj
(
pSqlObj
);
freeJoinSubqueryObj
(
pSqlObj
);
}
}
tscDestroyJoinSupporter
(
pSupporter
);
}
}
// update the query time range according to the join results on timestamp
// update the query time range according to the join results on timestamp
...
@@ -921,6 +929,22 @@ static void tsCompRetrieveCallback(void* param, TAOS_RES* tres, int32_t numOfRow
...
@@ -921,6 +929,22 @@ static void tsCompRetrieveCallback(void* param, TAOS_RES* tres, int32_t numOfRow
}
}
if
(
numOfRows
>
0
)
{
// write the compressed timestamp to disk file
if
(
numOfRows
>
0
)
{
// write the compressed timestamp to disk file
if
(
pSupporter
->
f
==
NULL
)
{
pSupporter
->
f
=
fopen
(
pSupporter
->
path
,
"w"
);
if
(
pSupporter
->
f
==
NULL
)
{
tscError
(
"%p failed to create tmp file:%s, reason:%s"
,
pSql
,
pSupporter
->
path
,
strerror
(
errno
));
pParentSql
->
res
.
code
=
TAOS_SYSTEM_ERROR
(
errno
);
quitAllSubquery
(
pParentSql
,
pSupporter
);
tscAsyncResultOnError
(
pParentSql
);
return
;
}
}
fwrite
(
pRes
->
data
,
(
size_t
)
pRes
->
numOfRows
,
1
,
pSupporter
->
f
);
fwrite
(
pRes
->
data
,
(
size_t
)
pRes
->
numOfRows
,
1
,
pSupporter
->
f
);
fclose
(
pSupporter
->
f
);
fclose
(
pSupporter
->
f
);
pSupporter
->
f
=
NULL
;
pSupporter
->
f
=
NULL
;
...
@@ -930,6 +954,9 @@ static void tsCompRetrieveCallback(void* param, TAOS_RES* tres, int32_t numOfRow
...
@@ -930,6 +954,9 @@ static void tsCompRetrieveCallback(void* param, TAOS_RES* tres, int32_t numOfRow
tscError
(
"%p invalid ts comp file from vnode, abort subquery, file size:%d"
,
pSql
,
numOfRows
);
tscError
(
"%p invalid ts comp file from vnode, abort subquery, file size:%d"
,
pSql
,
numOfRows
);
pParentSql
->
res
.
code
=
TAOS_SYSTEM_ERROR
(
errno
);
pParentSql
->
res
.
code
=
TAOS_SYSTEM_ERROR
(
errno
);
quitAllSubquery
(
pParentSql
,
pSupporter
);
tscAsyncResultOnError
(
pParentSql
);
tscAsyncResultOnError
(
pParentSql
);
return
;
return
;
...
...
src/connector/C#/TDengineDriver.cs
浏览文件 @
24a0b291
...
@@ -19,7 +19,8 @@ using System.Runtime.InteropServices;
...
@@ -19,7 +19,8 @@ using System.Runtime.InteropServices;
namespace
TDengineDriver
namespace
TDengineDriver
{
{
enum
TDengineDataType
{
enum
TDengineDataType
{
TSDB_DATA_TYPE_NULL
=
0
,
// 1 bytes
TSDB_DATA_TYPE_NULL
=
0
,
// 1 bytes
TSDB_DATA_TYPE_BOOL
=
1
,
// 1 bytes
TSDB_DATA_TYPE_BOOL
=
1
,
// 1 bytes
TSDB_DATA_TYPE_TINYINT
=
2
,
// 1 bytes
TSDB_DATA_TYPE_TINYINT
=
2
,
// 1 bytes
...
@@ -81,19 +82,19 @@ namespace TDengineDriver
...
@@ -81,19 +82,19 @@ namespace TDengineDriver
{
{
public
const
int
TSDB_CODE_SUCCESS
=
0
;
public
const
int
TSDB_CODE_SUCCESS
=
0
;
[
DllImport
(
"taos.dll
"
,
EntryPoint
=
"taos_init"
,
CallingConvention
=
CallingConvention
.
Cdecl
)]
[
DllImport
(
"taos
"
,
EntryPoint
=
"taos_init"
,
CallingConvention
=
CallingConvention
.
Cdecl
)]
static
extern
public
void
Init
();
static
extern
public
void
Init
();
[
DllImport
(
"taos.dll
"
,
EntryPoint
=
"taos_cleanup"
,
CallingConvention
=
CallingConvention
.
Cdecl
)]
[
DllImport
(
"taos
"
,
EntryPoint
=
"taos_cleanup"
,
CallingConvention
=
CallingConvention
.
Cdecl
)]
static
extern
public
void
Cleanup
();
static
extern
public
void
Cleanup
();
[
DllImport
(
"taos.dll
"
,
EntryPoint
=
"taos_options"
,
CallingConvention
=
CallingConvention
.
Cdecl
)]
[
DllImport
(
"taos
"
,
EntryPoint
=
"taos_options"
,
CallingConvention
=
CallingConvention
.
Cdecl
)]
static
extern
public
void
Options
(
int
option
,
string
value
);
static
extern
public
void
Options
(
int
option
,
string
value
);
[
DllImport
(
"taos.dll
"
,
EntryPoint
=
"taos_connect"
,
CallingConvention
=
CallingConvention
.
Cdecl
)]
[
DllImport
(
"taos
"
,
EntryPoint
=
"taos_connect"
,
CallingConvention
=
CallingConvention
.
Cdecl
)]
static
extern
public
IntPtr
Connect
(
string
ip
,
string
user
,
string
password
,
string
db
,
short
port
);
static
extern
public
IntPtr
Connect
(
string
ip
,
string
user
,
string
password
,
string
db
,
short
port
);
[
DllImport
(
"taos.dll
"
,
EntryPoint
=
"taos_errstr"
,
CallingConvention
=
CallingConvention
.
Cdecl
)]
[
DllImport
(
"taos
"
,
EntryPoint
=
"taos_errstr"
,
CallingConvention
=
CallingConvention
.
Cdecl
)]
static
extern
private
IntPtr
taos_errstr
(
IntPtr
res
);
static
extern
private
IntPtr
taos_errstr
(
IntPtr
res
);
static
public
string
Error
(
IntPtr
res
)
static
public
string
Error
(
IntPtr
res
)
{
{
...
@@ -101,19 +102,19 @@ namespace TDengineDriver
...
@@ -101,19 +102,19 @@ namespace TDengineDriver
return
Marshal
.
PtrToStringAnsi
(
errPtr
);
return
Marshal
.
PtrToStringAnsi
(
errPtr
);
}
}
[
DllImport
(
"taos.dll
"
,
EntryPoint
=
"taos_errno"
,
CallingConvention
=
CallingConvention
.
Cdecl
)]
[
DllImport
(
"taos
"
,
EntryPoint
=
"taos_errno"
,
CallingConvention
=
CallingConvention
.
Cdecl
)]
static
extern
public
int
ErrorNo
(
IntPtr
res
);
static
extern
public
int
ErrorNo
(
IntPtr
res
);
[
DllImport
(
"taos.dll
"
,
EntryPoint
=
"taos_query"
,
CallingConvention
=
CallingConvention
.
Cdecl
)]
[
DllImport
(
"taos
"
,
EntryPoint
=
"taos_query"
,
CallingConvention
=
CallingConvention
.
Cdecl
)]
static
extern
public
IntPtr
Query
(
IntPtr
conn
,
string
sqlstr
);
static
extern
public
IntPtr
Query
(
IntPtr
conn
,
string
sqlstr
);
[
DllImport
(
"taos.dll
"
,
EntryPoint
=
"taos_affected_rows"
,
CallingConvention
=
CallingConvention
.
Cdecl
)]
[
DllImport
(
"taos
"
,
EntryPoint
=
"taos_affected_rows"
,
CallingConvention
=
CallingConvention
.
Cdecl
)]
static
extern
public
int
AffectRows
(
IntPtr
res
);
static
extern
public
int
AffectRows
(
IntPtr
res
);
[
DllImport
(
"taos.dll
"
,
EntryPoint
=
"taos_field_count"
,
CallingConvention
=
CallingConvention
.
Cdecl
)]
[
DllImport
(
"taos
"
,
EntryPoint
=
"taos_field_count"
,
CallingConvention
=
CallingConvention
.
Cdecl
)]
static
extern
public
int
FieldCount
(
IntPtr
res
);
static
extern
public
int
FieldCount
(
IntPtr
res
);
[
DllImport
(
"taos.dll
"
,
EntryPoint
=
"taos_fetch_fields"
,
CallingConvention
=
CallingConvention
.
Cdecl
)]
[
DllImport
(
"taos
"
,
EntryPoint
=
"taos_fetch_fields"
,
CallingConvention
=
CallingConvention
.
Cdecl
)]
static
extern
private
IntPtr
taos_fetch_fields
(
IntPtr
res
);
static
extern
private
IntPtr
taos_fetch_fields
(
IntPtr
res
);
static
public
List
<
TDengineMeta
>
FetchFields
(
IntPtr
res
)
static
public
List
<
TDengineMeta
>
FetchFields
(
IntPtr
res
)
{
{
...
@@ -142,13 +143,13 @@ namespace TDengineDriver
...
@@ -142,13 +143,13 @@ namespace TDengineDriver
return
metas
;
return
metas
;
}
}
[
DllImport
(
"taos.dll
"
,
EntryPoint
=
"taos_fetch_row"
,
CallingConvention
=
CallingConvention
.
Cdecl
)]
[
DllImport
(
"taos
"
,
EntryPoint
=
"taos_fetch_row"
,
CallingConvention
=
CallingConvention
.
Cdecl
)]
static
extern
public
IntPtr
FetchRows
(
IntPtr
res
);
static
extern
public
IntPtr
FetchRows
(
IntPtr
res
);
[
DllImport
(
"taos.dll
"
,
EntryPoint
=
"taos_free_result"
,
CallingConvention
=
CallingConvention
.
Cdecl
)]
[
DllImport
(
"taos
"
,
EntryPoint
=
"taos_free_result"
,
CallingConvention
=
CallingConvention
.
Cdecl
)]
static
extern
public
IntPtr
FreeResult
(
IntPtr
res
);
static
extern
public
IntPtr
FreeResult
(
IntPtr
res
);
[
DllImport
(
"taos.dll
"
,
EntryPoint
=
"taos_close"
,
CallingConvention
=
CallingConvention
.
Cdecl
)]
[
DllImport
(
"taos
"
,
EntryPoint
=
"taos_close"
,
CallingConvention
=
CallingConvention
.
Cdecl
)]
static
extern
public
int
Close
(
IntPtr
taos
);
static
extern
public
int
Close
(
IntPtr
taos
);
}
}
}
}
src/connector/jdbc/src/test/java/com/taosdata/jdbc/DatabaseMetaDataTest.java
浏览文件 @
24a0b291
...
@@ -7,7 +7,7 @@ import org.junit.Test;
...
@@ -7,7 +7,7 @@ import org.junit.Test;
import
java.sql.*
;
import
java.sql.*
;
import
java.util.Properties
;
import
java.util.Properties
;
public
class
DatabaseMetaDataTest
extends
BaseTest
{
public
class
DatabaseMetaDataTest
{
static
Connection
connection
=
null
;
static
Connection
connection
=
null
;
static
PreparedStatement
statement
=
null
;
static
PreparedStatement
statement
=
null
;
static
String
dbName
=
"test"
;
static
String
dbName
=
"test"
;
...
@@ -23,20 +23,21 @@ public class DatabaseMetaDataTest extends BaseTest {
...
@@ -23,20 +23,21 @@ public class DatabaseMetaDataTest extends BaseTest {
}
}
Properties
properties
=
new
Properties
();
Properties
properties
=
new
Properties
();
properties
.
setProperty
(
TSDBDriver
.
PROPERTY_KEY_HOST
,
host
);
properties
.
setProperty
(
TSDBDriver
.
PROPERTY_KEY_HOST
,
host
);
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"
);
connection
=
DriverManager
.
getConnection
(
"jdbc:TAOS://"
+
host
+
":0/"
,
properties
);
connection
=
DriverManager
.
getConnection
(
"jdbc:TAOS://"
+
host
+
":0/"
,
properties
);
String
sql
=
"drop database if exists "
+
dbName
;
String
sql
=
"drop database if exists "
+
dbName
;
statement
=
(
TSDBPreparedStatement
)
connection
.
prepareStatement
(
sql
);
statement
=
connection
.
prepareStatement
(
sql
);
statement
.
executeUpdate
(
"create database if not exists "
+
dbName
);
statement
.
executeUpdate
(
"create database if not exists "
+
dbName
);
statement
.
executeUpdate
(
"create table if not exists "
+
dbName
+
"."
+
tName
+
" (ts timestamp, k int, v int)"
);
statement
.
executeUpdate
(
"create table if not exists "
+
dbName
+
"."
+
tName
+
" (ts timestamp, k int, v int)"
);
}
}
@Test
@Test
public
void
testMetaDataTest
()
throws
SQLException
{
public
void
testMetaDataTest
()
throws
SQLException
{
DatabaseMetaData
databaseMetaData
=
connection
.
getMetaData
();
DatabaseMetaData
databaseMetaData
=
connection
.
getMetaData
();
ResultSet
resultSet
=
databaseMetaData
.
getTables
(
dbName
,
"t*"
,
"t*"
,
new
String
[]{
"t"
});
ResultSet
resultSet
=
databaseMetaData
.
getTables
(
dbName
,
"t*"
,
"t*"
,
new
String
[]{
"t"
});
while
(
resultSet
.
next
())
{
while
(
resultSet
.
next
())
{
...
@@ -180,7 +181,7 @@ public class DatabaseMetaDataTest extends BaseTest {
...
@@ -180,7 +181,7 @@ public class DatabaseMetaDataTest extends BaseTest {
databaseMetaData
.
getCatalogs
();
databaseMetaData
.
getCatalogs
();
// databaseMetaData.getTableTypes();
// databaseMetaData.getTableTypes();
databaseMetaData
.
getColumns
(
""
,
""
,
""
,
""
);
databaseMetaData
.
getColumns
(
dbName
,
""
,
tName
,
""
);
databaseMetaData
.
getColumnPrivileges
(
""
,
""
,
""
,
""
);
databaseMetaData
.
getColumnPrivileges
(
""
,
""
,
""
,
""
);
databaseMetaData
.
getTablePrivileges
(
""
,
""
,
""
);
databaseMetaData
.
getTablePrivileges
(
""
,
""
,
""
);
databaseMetaData
.
getBestRowIdentifier
(
""
,
""
,
""
,
0
,
false
);
databaseMetaData
.
getBestRowIdentifier
(
""
,
""
,
""
,
0
,
false
);
...
...
src/connector/jdbc/src/test/java/com/taosdata/jdbc/cases/AppMemoryLeakTest.java
浏览文件 @
24a0b291
...
@@ -19,7 +19,7 @@ public class AppMemoryLeakTest {
...
@@ -19,7 +19,7 @@ public class AppMemoryLeakTest {
}
}
}
}
@Test
@Test
(
expected
=
Exception
.
class
)
public
void
testCreateTooManyStatement
()
throws
ClassNotFoundException
,
SQLException
{
public
void
testCreateTooManyStatement
()
throws
ClassNotFoundException
,
SQLException
{
Class
.
forName
(
"com.taosdata.jdbc.TSDBDriver"
);
Class
.
forName
(
"com.taosdata.jdbc.TSDBDriver"
);
int
stmtCnt
=
0
;
int
stmtCnt
=
0
;
...
@@ -30,15 +30,4 @@ public class AppMemoryLeakTest {
...
@@ -30,15 +30,4 @@ public class AppMemoryLeakTest {
}
}
}
}
public
static
void
main
(
String
[]
args
)
throws
ClassNotFoundException
,
SQLException
{
Class
.
forName
(
"com.taosdata.jdbc.TSDBDriver"
);
int
stmtCnt
=
0
;
Connection
conn
=
DriverManager
.
getConnection
(
"jdbc:TAOS://localhost:6030/?user=root&password=taosdata"
);
while
(
true
)
{
Statement
stmt
=
conn
.
createStatement
();
System
.
out
.
println
(++
stmtCnt
+
" : "
+
stmt
);
}
}
}
}
src/connector/jdbc/src/test/java/com/taosdata/jdbc/cases/ConnectWrongDatabaseTest.java
0 → 100644
浏览文件 @
24a0b291
package
com.taosdata.jdbc.cases
;
import
org.junit.Assert
;
import
org.junit.Test
;
import
java.sql.DriverManager
;
import
java.sql.SQLException
;
public
class
ConnectWrongDatabaseTest
{
@Test
public
void
connect
()
{
try
{
Class
.
forName
(
"com.taosdata.jdbc.TSDBDriver"
);
DriverManager
.
getConnection
(
"jdbc:TAOS://localhost:6030/wrong_db?user=root&password=taosdata"
);
}
catch
(
ClassNotFoundException
e
)
{
e
.
printStackTrace
();
}
catch
(
SQLException
e
)
{
System
.
out
.
println
(
e
.
getMessage
());
Assert
.
assertEquals
(
"TDengine Error: Invalid database name"
,
e
.
getMessage
());
}
}
}
src/connector/jdbc/src/test/java/com/taosdata/jdbc/utils/SqlSyntaxValidatorTest.java
浏览文件 @
24a0b291
...
@@ -5,10 +5,6 @@ import org.junit.Test;
...
@@ -5,10 +5,6 @@ import org.junit.Test;
public
class
SqlSyntaxValidatorTest
{
public
class
SqlSyntaxValidatorTest
{
@Test
public
void
validateSqlSyntax
()
{
}
@Test
@Test
public
void
isSelectSQL
()
{
public
void
isSelectSQL
()
{
Assert
.
assertTrue
(
SqlSyntaxValidator
.
isSelectSql
(
"select * from test.weather"
));
Assert
.
assertTrue
(
SqlSyntaxValidator
.
isSelectSql
(
"select * from test.weather"
));
...
...
src/query/inc/qTsbuf.h
浏览文件 @
24a0b291
...
@@ -88,6 +88,7 @@ typedef struct STSBuf {
...
@@ -88,6 +88,7 @@ typedef struct STSBuf {
STSList
tsData
;
// uncompressed raw ts data
STSList
tsData
;
// uncompressed raw ts data
uint64_t
numOfTotal
;
uint64_t
numOfTotal
;
bool
autoDelete
;
bool
autoDelete
;
bool
remainOpen
;
int32_t
tsOrder
;
// order of timestamp in ts comp buffer
int32_t
tsOrder
;
// order of timestamp in ts comp buffer
STSCursor
cur
;
STSCursor
cur
;
}
STSBuf
;
}
STSBuf
;
...
...
src/query/src/qAggMain.c
浏览文件 @
24a0b291
...
@@ -1268,12 +1268,14 @@ static void min_function_f(SQLFunctionCtx *pCtx, int32_t index) {
...
@@ -1268,12 +1268,14 @@ static void min_function_f(SQLFunctionCtx *pCtx, int32_t index) {
}
}
static
void
stddev_function
(
SQLFunctionCtx
*
pCtx
)
{
static
void
stddev_function
(
SQLFunctionCtx
*
pCtx
)
{
// the second stage to calculate standard deviation
SStddevInfo
*
pStd
=
GET_ROWCELL_INTERBUF
(
GET_RES_INFO
(
pCtx
));
SStddevInfo
*
pStd
=
GET_ROWCELL_INTERBUF
(
GET_RES_INFO
(
pCtx
));
if
(
pStd
->
stage
==
0
)
{
// the first stage is to calculate average value
if
(
pStd
->
stage
==
0
)
{
// the first stage is to calculate average value
avg_function
(
pCtx
);
avg_function
(
pCtx
);
}
else
{
}
else
if
(
pStd
->
num
>
0
)
{
// the second stage to calculate standard deviation
// if pStd->num == 0, there are no numbers in the first round check. No need to do the second round
double
*
retVal
=
&
pStd
->
res
;
double
*
retVal
=
&
pStd
->
res
;
double
avg
=
pStd
->
avg
;
double
avg
=
pStd
->
avg
;
...
@@ -3836,8 +3838,10 @@ static void ts_comp_finalize(SQLFunctionCtx *pCtx) {
...
@@ -3836,8 +3838,10 @@ static void ts_comp_finalize(SQLFunctionCtx *pCtx) {
STSBuf
*
pTSbuf
=
pInfo
->
pTSBuf
;
STSBuf
*
pTSbuf
=
pInfo
->
pTSBuf
;
tsBufFlush
(
pTSbuf
);
tsBufFlush
(
pTSbuf
);
strcpy
(
pCtx
->
aOutputBuf
,
pTSbuf
->
path
);
*
(
FILE
**
)
pCtx
->
aOutputBuf
=
pTSbuf
->
f
;
pTSbuf
->
remainOpen
=
true
;
tsBufDestroy
(
pTSbuf
);
tsBufDestroy
(
pTSbuf
);
doFinalizer
(
pCtx
);
doFinalizer
(
pCtx
);
}
}
...
...
src/query/src/qExecutor.c
浏览文件 @
24a0b291
...
@@ -548,7 +548,7 @@ static STimeWindow getActiveTimeWindow(SResultRowInfo *pWindowResInfo, int64_t t
...
@@ -548,7 +548,7 @@ static STimeWindow getActiveTimeWindow(SResultRowInfo *pWindowResInfo, int64_t t
if
(
pWindowResInfo
->
curIndex
==
-
1
)
{
// the first window, from the previous stored value
if
(
pWindowResInfo
->
curIndex
==
-
1
)
{
// the first window, from the previous stored value
w
.
skey
=
pWindowResInfo
->
prevSKey
;
w
.
skey
=
pWindowResInfo
->
prevSKey
;
if
(
pQuery
->
interval
.
intervalUnit
==
'n'
||
pQuery
->
interval
.
intervalUnit
==
'y'
)
{
if
(
pQuery
->
interval
.
intervalUnit
==
'n'
||
pQuery
->
interval
.
intervalUnit
==
'y'
)
{
w
.
ekey
=
taosTimeAdd
(
w
.
skey
,
pQuery
->
interval
.
interval
,
pQuery
->
interval
.
intervalUnit
,
pQuery
->
precision
);
w
.
ekey
=
taosTimeAdd
(
w
.
skey
,
pQuery
->
interval
.
interval
,
pQuery
->
interval
.
intervalUnit
,
pQuery
->
precision
)
-
1
;
}
else
{
}
else
{
w
.
ekey
=
w
.
skey
+
pQuery
->
interval
.
interval
-
1
;
w
.
ekey
=
w
.
skey
+
pQuery
->
interval
.
interval
-
1
;
}
}
...
@@ -2010,6 +2010,7 @@ static void doFreeQueryHandle(SQInfo* pQInfo) {
...
@@ -2010,6 +2010,7 @@ static void doFreeQueryHandle(SQInfo* pQInfo) {
assert
(
pMemRef
->
ref
==
0
&&
pMemRef
->
imem
==
NULL
&&
pMemRef
->
mem
==
NULL
);
assert
(
pMemRef
->
ref
==
0
&&
pMemRef
->
imem
==
NULL
&&
pMemRef
->
mem
==
NULL
);
}
}
static
void
teardownQueryRuntimeEnv
(
SQueryRuntimeEnv
*
pRuntimeEnv
)
{
static
void
teardownQueryRuntimeEnv
(
SQueryRuntimeEnv
*
pRuntimeEnv
)
{
if
(
pRuntimeEnv
->
pQuery
==
NULL
)
{
if
(
pRuntimeEnv
->
pQuery
==
NULL
)
{
return
;
return
;
...
@@ -2021,6 +2022,16 @@ static void teardownQueryRuntimeEnv(SQueryRuntimeEnv *pRuntimeEnv) {
...
@@ -2021,6 +2022,16 @@ static void teardownQueryRuntimeEnv(SQueryRuntimeEnv *pRuntimeEnv) {
qDebug
(
"QInfo:%p teardown runtime env"
,
pQInfo
);
qDebug
(
"QInfo:%p teardown runtime env"
,
pQInfo
);
cleanupResultRowInfo
(
&
pRuntimeEnv
->
windowResInfo
);
cleanupResultRowInfo
(
&
pRuntimeEnv
->
windowResInfo
);
if
(
isTSCompQuery
(
pQuery
))
{
FILE
*
f
=
*
(
FILE
**
)
pQuery
->
sdata
[
0
]
->
data
;
if
(
f
)
{
fclose
(
f
);
*
(
FILE
**
)
pQuery
->
sdata
[
0
]
->
data
=
NULL
;
}
}
if
(
pRuntimeEnv
->
pCtx
!=
NULL
)
{
if
(
pRuntimeEnv
->
pCtx
!=
NULL
)
{
for
(
int32_t
i
=
0
;
i
<
pQuery
->
numOfOutput
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
pQuery
->
numOfOutput
;
++
i
)
{
SQLFunctionCtx
*
pCtx
=
&
pRuntimeEnv
->
pCtx
[
i
];
SQLFunctionCtx
*
pCtx
=
&
pRuntimeEnv
->
pCtx
[
i
];
...
@@ -6949,10 +6960,10 @@ static size_t getResultSize(SQInfo *pQInfo, int64_t *numOfRows) {
...
@@ -6949,10 +6960,10 @@ static size_t getResultSize(SQInfo *pQInfo, int64_t *numOfRows) {
* TODO handle the case that the file is too large to send back one time
* TODO handle the case that the file is too large to send back one time
*/
*/
if
(
isTSCompQuery
(
pQuery
)
&&
(
*
numOfRows
)
>
0
)
{
if
(
isTSCompQuery
(
pQuery
)
&&
(
*
numOfRows
)
>
0
)
{
struct
stat
f
s
tat
;
struct
stat
f
S
tat
;
if
(
stat
(
pQuery
->
sdata
[
0
]
->
data
,
&
fs
tat
)
==
0
)
{
if
(
fstat
(
fileno
(
*
(
FILE
**
)
pQuery
->
sdata
[
0
]
->
data
),
&
fS
tat
)
==
0
)
{
*
numOfRows
=
f
s
tat
.
st_size
;
*
numOfRows
=
f
S
tat
.
st_size
;
return
f
s
tat
.
st_size
;
return
f
S
tat
.
st_size
;
}
else
{
}
else
{
qError
(
"QInfo:%p failed to get file info, path:%s, reason:%s"
,
pQInfo
,
pQuery
->
sdata
[
0
]
->
data
,
strerror
(
errno
));
qError
(
"QInfo:%p failed to get file info, path:%s, reason:%s"
,
pQInfo
,
pQuery
->
sdata
[
0
]
->
data
,
strerror
(
errno
));
return
0
;
return
0
;
...
@@ -6968,15 +6979,16 @@ static int32_t doDumpQueryResult(SQInfo *pQInfo, char *data) {
...
@@ -6968,15 +6979,16 @@ static int32_t doDumpQueryResult(SQInfo *pQInfo, char *data) {
// load data from file to msg buffer
// load data from file to msg buffer
if
(
isTSCompQuery
(
pQuery
))
{
if
(
isTSCompQuery
(
pQuery
))
{
int32_t
fd
=
open
(
pQuery
->
sdata
[
0
]
->
data
,
O_RDONLY
,
0666
);
FILE
*
f
=
*
(
FILE
**
)
pQuery
->
sdata
[
0
]
->
data
;
// make sure file exist
// make sure file exist
if
(
FD_VALID
(
fd
)
)
{
if
(
f
)
{
uint64_t
s
=
lseek
(
fd
,
0
,
SEEK_END
);
off_t
s
=
lseek
(
fileno
(
f
)
,
0
,
SEEK_END
);
qDebug
(
"QInfo:%p ts comp data return, file:%
s, size:%"
PRId64
,
pQInfo
,
pQuery
->
sdata
[
0
]
->
data
,
s
);
qDebug
(
"QInfo:%p ts comp data return, file:%
p, size:%"
PRId64
,
pQInfo
,
f
,
s
);
if
(
lseek
(
fd
,
0
,
SEEK_SET
)
>=
0
)
{
if
(
fseek
(
f
,
0
,
SEEK_SET
)
>=
0
)
{
size_t
sz
=
read
(
fd
,
data
,
(
uint32_t
)
s
);
size_t
sz
=
fread
(
data
,
1
,
s
,
f
);
if
(
sz
<
s
)
{
// todo handle error
if
(
sz
<
s
)
{
// todo handle error
assert
(
0
);
assert
(
0
);
}
}
...
@@ -6984,15 +6996,8 @@ static int32_t doDumpQueryResult(SQInfo *pQInfo, char *data) {
...
@@ -6984,15 +6996,8 @@ static int32_t doDumpQueryResult(SQInfo *pQInfo, char *data) {
UNUSED
(
s
);
UNUSED
(
s
);
}
}
close
(
fd
);
fclose
(
f
);
unlink
(
pQuery
->
sdata
[
0
]
->
data
);
*
(
FILE
**
)
pQuery
->
sdata
[
0
]
->
data
=
NULL
;
}
else
{
// todo return the error code to client and handle invalid fd
qError
(
"QInfo:%p failed to open tmp file to send ts-comp data to client, path:%s, reason:%s"
,
pQInfo
,
pQuery
->
sdata
[
0
]
->
data
,
strerror
(
errno
));
if
(
fd
!=
-
1
)
{
close
(
fd
);
}
}
}
// all data returned, set query over
// all data returned, set query over
...
...
src/query/src/qTsbuf.c
浏览文件 @
24a0b291
...
@@ -20,6 +20,8 @@ STSBuf* tsBufCreate(bool autoDelete, int32_t order) {
...
@@ -20,6 +20,8 @@ STSBuf* tsBufCreate(bool autoDelete, int32_t order) {
return
NULL
;
return
NULL
;
}
}
pTSBuf
->
autoDelete
=
autoDelete
;
taosGetTmpfilePath
(
"join"
,
pTSBuf
->
path
);
taosGetTmpfilePath
(
"join"
,
pTSBuf
->
path
);
pTSBuf
->
f
=
fopen
(
pTSBuf
->
path
,
"w+"
);
pTSBuf
->
f
=
fopen
(
pTSBuf
->
path
,
"w+"
);
if
(
pTSBuf
->
f
==
NULL
)
{
if
(
pTSBuf
->
f
==
NULL
)
{
...
@@ -27,6 +29,10 @@ STSBuf* tsBufCreate(bool autoDelete, int32_t order) {
...
@@ -27,6 +29,10 @@ STSBuf* tsBufCreate(bool autoDelete, int32_t order) {
return
NULL
;
return
NULL
;
}
}
if
(
!
autoDelete
)
{
unlink
(
pTSBuf
->
path
);
}
if
(
NULL
==
allocResForTSBuf
(
pTSBuf
))
{
if
(
NULL
==
allocResForTSBuf
(
pTSBuf
))
{
return
NULL
;
return
NULL
;
}
}
...
@@ -38,7 +44,6 @@ STSBuf* tsBufCreate(bool autoDelete, int32_t order) {
...
@@ -38,7 +44,6 @@ STSBuf* tsBufCreate(bool autoDelete, int32_t order) {
tsBufResetPos
(
pTSBuf
);
tsBufResetPos
(
pTSBuf
);
pTSBuf
->
cur
.
order
=
TSDB_ORDER_ASC
;
pTSBuf
->
cur
.
order
=
TSDB_ORDER_ASC
;
pTSBuf
->
autoDelete
=
autoDelete
;
pTSBuf
->
tsOrder
=
order
;
pTSBuf
->
tsOrder
=
order
;
return
pTSBuf
;
return
pTSBuf
;
...
@@ -50,6 +55,8 @@ STSBuf* tsBufCreateFromFile(const char* path, bool autoDelete) {
...
@@ -50,6 +55,8 @@ STSBuf* tsBufCreateFromFile(const char* path, bool autoDelete) {
return
NULL
;
return
NULL
;
}
}
pTSBuf
->
autoDelete
=
autoDelete
;
tstrncpy
(
pTSBuf
->
path
,
path
,
sizeof
(
pTSBuf
->
path
));
tstrncpy
(
pTSBuf
->
path
,
path
,
sizeof
(
pTSBuf
->
path
));
pTSBuf
->
f
=
fopen
(
pTSBuf
->
path
,
"r+"
);
pTSBuf
->
f
=
fopen
(
pTSBuf
->
path
,
"r+"
);
...
@@ -129,7 +136,6 @@ STSBuf* tsBufCreateFromFile(const char* path, bool autoDelete) {
...
@@ -129,7 +136,6 @@ STSBuf* tsBufCreateFromFile(const char* path, bool autoDelete) {
// ascending by default
// ascending by default
pTSBuf
->
cur
.
order
=
TSDB_ORDER_ASC
;
pTSBuf
->
cur
.
order
=
TSDB_ORDER_ASC
;
pTSBuf
->
autoDelete
=
autoDelete
;
// tscDebug("create tsBuf from file:%s, fd:%d, size:%d, numOfGroups:%d, autoDelete:%d", pTSBuf->path, fileno(pTSBuf->f),
// tscDebug("create tsBuf from file:%s, fd:%d, size:%d, numOfGroups:%d, autoDelete:%d", pTSBuf->path, fileno(pTSBuf->f),
// pTSBuf->fileSize, pTSBuf->numOfGroups, pTSBuf->autoDelete);
// pTSBuf->fileSize, pTSBuf->numOfGroups, pTSBuf->autoDelete);
...
@@ -148,7 +154,9 @@ void* tsBufDestroy(STSBuf* pTSBuf) {
...
@@ -148,7 +154,9 @@ void* tsBufDestroy(STSBuf* pTSBuf) {
tfree
(
pTSBuf
->
pData
);
tfree
(
pTSBuf
->
pData
);
tfree
(
pTSBuf
->
block
.
payload
);
tfree
(
pTSBuf
->
block
.
payload
);
if
(
!
pTSBuf
->
remainOpen
)
{
fclose
(
pTSBuf
->
f
);
fclose
(
pTSBuf
->
f
);
}
if
(
pTSBuf
->
autoDelete
)
{
if
(
pTSBuf
->
autoDelete
)
{
// ("tsBuf %p destroyed, delete tmp file:%s", pTSBuf, pTSBuf->path);
// ("tsBuf %p destroyed, delete tmp file:%s", pTSBuf, pTSBuf->path);
...
...
src/util/src/hash.c
浏览文件 @
24a0b291
...
@@ -477,8 +477,6 @@ void taosHashEmpty(SHashObj *pHashObj) {
...
@@ -477,8 +477,6 @@ void taosHashEmpty(SHashObj *pHashObj) {
return
;
return
;
}
}
uDebug
(
"hash:%p cleanup hash table"
,
pHashObj
);
SHashNode
*
pNode
,
*
pNext
;
SHashNode
*
pNode
,
*
pNext
;
__wr_lock
(
&
pHashObj
->
lock
,
pHashObj
->
type
);
__wr_lock
(
&
pHashObj
->
lock
,
pHashObj
->
type
);
...
...
tests/examples/C#/taosdemo/README.md
浏览文件 @
24a0b291
...
@@ -10,12 +10,14 @@ run C# version taosdemo
...
@@ -10,12 +10,14 @@ run C# version taosdemo
===
===
Usage: mono taosdemo.exe [OPTION...]
Usage: mono taosdemo.exe [OPTION...]
--help Show usage.
-h host, The host to connect to TDengine. Default is localhost.
-h host, The host to connect to TDengine. Default is localhost.
-p port, The TCP/IP port number to use for the connection. Default is 0.
-p port, The TCP/IP port number to use for the connection. Default is 0.
-u user, The user name to use when connecting to the server. Default is 'root'.
-u user, The user name to use when connecting to the server. Default is 'root'.
-P password, The password to use when connecting to the server. Default is 'taosdata'.
-P password, The password to use when connecting to the server. Default is 'taosdata'.
-d database, Destination database. Default is 'test'.
-d database, Destination database. Default is 'test'.
-a replica, Set the replica parameters of the database, Default 1, min: 1, max:
3
.
-a replica, Set the replica parameters of the database, Default 1, min: 1, max:
5
.
-m table_prefix, Table prefix name. Default is 't'.
-m table_prefix, Table prefix name. Default is 't'.
-s sql file, The select sql file.
-s sql file, The select sql file.
-M stable, Use super table.
-M stable, Use super table.
...
@@ -26,8 +28,8 @@ Usage: mono taosdemo.exe [OPTION...]
...
@@ -26,8 +28,8 @@ Usage: mono taosdemo.exe [OPTION...]
-l num_of_cols_per_record, The number of columns per record. Default is 3.
-l num_of_cols_per_record, The number of columns per record. Default is 3.
-T num_of_threads, The number of threads. Default is 10.
-T num_of_threads, The number of threads. Default is 10.
-r num_of_records_per_req, The number of records per request. Default is 1000.
-r num_of_records_per_req, The number of records per request. Default is 1000.
-t num_of_tables, The number of tables. Default is 1
0000
.
-t num_of_tables, The number of tables. Default is 1.
-n num_of_records_per_table, The number of records per table. Default is 1
0000
.
-n num_of_records_per_table, The number of records per table. Default is 1.
-c config_directory, Configuration directory. Default is '/etc/taos/'.
-c config_directory, Configuration directory. Default is '/etc/taos/'.
-x flag, Insert only flag.
-x flag, Insert only flag.
-O order, Insert mode--0: In order, 1: Out of order. Default is in order.
-O order, Insert mode--0: In order, 1: Out of order. Default is in order.
...
...
tests/examples/C#/taosdemo/TDengineDriver.cs
已删除
120000 → 0
浏览文件 @
e3d65a9a
../../../../
src
/
connector
/
C
#
/
TDengineDriver
.
cs
\ No newline at end of file
tests/examples/C#/taosdemo/TDengineDriver.cs
0 → 100644
浏览文件 @
24a0b291
/*
* Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
*
* This program is free software: you can use, redistribute, and/or modify
* it under the terms of the GNU Affero General Public License, version 3
* or later ("AGPL"), as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
using
System
;
using
System.Collections.Generic
;
using
System.Runtime.InteropServices
;
namespace
TDengineDriver
{
enum
TDengineDataType
{
TSDB_DATA_TYPE_NULL
=
0
,
// 1 bytes
TSDB_DATA_TYPE_BOOL
=
1
,
// 1 bytes
TSDB_DATA_TYPE_TINYINT
=
2
,
// 1 bytes
TSDB_DATA_TYPE_SMALLINT
=
3
,
// 2 bytes
TSDB_DATA_TYPE_INT
=
4
,
// 4 bytes
TSDB_DATA_TYPE_BIGINT
=
5
,
// 8 bytes
TSDB_DATA_TYPE_FLOAT
=
6
,
// 4 bytes
TSDB_DATA_TYPE_DOUBLE
=
7
,
// 8 bytes
TSDB_DATA_TYPE_BINARY
=
8
,
// string
TSDB_DATA_TYPE_TIMESTAMP
=
9
,
// 8 bytes
TSDB_DATA_TYPE_NCHAR
=
10
// unicode string
}
enum
TDengineInitOption
{
TSDB_OPTION_LOCALE
=
0
,
TSDB_OPTION_CHARSET
=
1
,
TSDB_OPTION_TIMEZONE
=
2
,
TDDB_OPTION_CONFIGDIR
=
3
,
TDDB_OPTION_SHELL_ACTIVITY_TIMER
=
4
}
class
TDengineMeta
{
public
string
name
;
public
short
size
;
public
byte
type
;
public
string
TypeName
()
{
switch
((
TDengineDataType
)
type
)
{
case
TDengineDataType
.
TSDB_DATA_TYPE_BOOL
:
return
"BOOLEAN"
;
case
TDengineDataType
.
TSDB_DATA_TYPE_TINYINT
:
return
"BYTE"
;
case
TDengineDataType
.
TSDB_DATA_TYPE_SMALLINT
:
return
"SHORT"
;
case
TDengineDataType
.
TSDB_DATA_TYPE_INT
:
return
"INT"
;
case
TDengineDataType
.
TSDB_DATA_TYPE_BIGINT
:
return
"LONG"
;
case
TDengineDataType
.
TSDB_DATA_TYPE_FLOAT
:
return
"FLOAT"
;
case
TDengineDataType
.
TSDB_DATA_TYPE_DOUBLE
:
return
"DOUBLE"
;
case
TDengineDataType
.
TSDB_DATA_TYPE_BINARY
:
return
"STRING"
;
case
TDengineDataType
.
TSDB_DATA_TYPE_TIMESTAMP
:
return
"TIMESTAMP"
;
case
TDengineDataType
.
TSDB_DATA_TYPE_NCHAR
:
return
"NCHAR"
;
default
:
return
"undefine"
;
}
}
}
class
TDengine
{
public
const
int
TSDB_CODE_SUCCESS
=
0
;
[
DllImport
(
"taos"
,
EntryPoint
=
"taos_init"
,
CallingConvention
=
CallingConvention
.
Cdecl
)]
static
extern
public
void
Init
();
[
DllImport
(
"taos"
,
EntryPoint
=
"taos_cleanup"
,
CallingConvention
=
CallingConvention
.
Cdecl
)]
static
extern
public
void
Cleanup
();
[
DllImport
(
"taos"
,
EntryPoint
=
"taos_options"
,
CallingConvention
=
CallingConvention
.
Cdecl
)]
static
extern
public
void
Options
(
int
option
,
string
value
);
[
DllImport
(
"taos"
,
EntryPoint
=
"taos_connect"
,
CallingConvention
=
CallingConvention
.
Cdecl
)]
static
extern
public
IntPtr
Connect
(
string
ip
,
string
user
,
string
password
,
string
db
,
short
port
);
[
DllImport
(
"taos"
,
EntryPoint
=
"taos_errstr"
,
CallingConvention
=
CallingConvention
.
Cdecl
)]
static
extern
private
IntPtr
taos_errstr
(
IntPtr
res
);
static
public
string
Error
(
IntPtr
res
)
{
IntPtr
errPtr
=
taos_errstr
(
res
);
return
Marshal
.
PtrToStringAnsi
(
errPtr
);
}
[
DllImport
(
"taos"
,
EntryPoint
=
"taos_errno"
,
CallingConvention
=
CallingConvention
.
Cdecl
)]
static
extern
public
int
ErrorNo
(
IntPtr
res
);
[
DllImport
(
"taos"
,
EntryPoint
=
"taos_query"
,
CallingConvention
=
CallingConvention
.
Cdecl
)]
static
extern
public
IntPtr
Query
(
IntPtr
conn
,
string
sqlstr
);
[
DllImport
(
"taos"
,
EntryPoint
=
"taos_affected_rows"
,
CallingConvention
=
CallingConvention
.
Cdecl
)]
static
extern
public
int
AffectRows
(
IntPtr
res
);
[
DllImport
(
"taos"
,
EntryPoint
=
"taos_field_count"
,
CallingConvention
=
CallingConvention
.
Cdecl
)]
static
extern
public
int
FieldCount
(
IntPtr
res
);
[
DllImport
(
"taos"
,
EntryPoint
=
"taos_fetch_fields"
,
CallingConvention
=
CallingConvention
.
Cdecl
)]
static
extern
private
IntPtr
taos_fetch_fields
(
IntPtr
res
);
static
public
List
<
TDengineMeta
>
FetchFields
(
IntPtr
res
)
{
const
int
fieldSize
=
68
;
List
<
TDengineMeta
>
metas
=
new
List
<
TDengineMeta
>();
if
(
res
==
IntPtr
.
Zero
)
{
return
metas
;
}
int
fieldCount
=
FieldCount
(
res
);
IntPtr
fieldsPtr
=
taos_fetch_fields
(
res
);
for
(
int
i
=
0
;
i
<
fieldCount
;
++
i
)
{
int
offset
=
i
*
fieldSize
;
TDengineMeta
meta
=
new
TDengineMeta
();
meta
.
name
=
Marshal
.
PtrToStringAnsi
(
fieldsPtr
+
offset
);
meta
.
type
=
Marshal
.
ReadByte
(
fieldsPtr
+
offset
+
65
);
meta
.
size
=
Marshal
.
ReadInt16
(
fieldsPtr
+
offset
+
66
);
metas
.
Add
(
meta
);
}
return
metas
;
}
[
DllImport
(
"taos"
,
EntryPoint
=
"taos_fetch_row"
,
CallingConvention
=
CallingConvention
.
Cdecl
)]
static
extern
public
IntPtr
FetchRows
(
IntPtr
res
);
[
DllImport
(
"taos"
,
EntryPoint
=
"taos_free_result"
,
CallingConvention
=
CallingConvention
.
Cdecl
)]
static
extern
public
IntPtr
FreeResult
(
IntPtr
res
);
[
DllImport
(
"taos"
,
EntryPoint
=
"taos_close"
,
CallingConvention
=
CallingConvention
.
Cdecl
)]
static
extern
public
int
Close
(
IntPtr
taos
);
}
}
tests/examples/C#/taosdemo/taosdemo.cs
浏览文件 @
24a0b291
...
@@ -26,10 +26,10 @@ namespace TDengineDriver
...
@@ -26,10 +26,10 @@ namespace TDengineDriver
class
TDengineTest
class
TDengineTest
{
{
//connect parameters
//connect parameters
private
string
host
;
private
string
host
=
"127.0.0.1"
;
private
string
configDir
;
private
string
configDir
=
"C:/TDengine/cfg"
;
private
string
user
;
private
string
user
=
"root"
;
private
string
password
;
private
string
password
=
"taosdata"
;
private
short
port
=
0
;
private
short
port
=
0
;
//sql parameters
//sql parameters
...
@@ -40,11 +40,12 @@ namespace TDengineDriver
...
@@ -40,11 +40,12 @@ namespace TDengineDriver
private
bool
isInsertOnly
=
false
;
private
bool
isInsertOnly
=
false
;
private
int
queryMode
=
1
;
private
int
queryMode
=
1
;
private
long
recordsPerTable
=
1
0000
;
private
long
recordsPerTable
=
1
;
private
int
recordsPerRequest
=
1
;
private
int
recordsPerRequest
=
1
;
private
int
colsPerRecord
=
3
;
private
int
colsPerRecord
=
3
;
private
long
batchRows
=
1000
;
private
long
batchRows
=
1000
;
private
long
numOfTables
=
10000
;
private
long
numOfTables
=
1
;
private
short
replica
=
1
;
private
IntPtr
conn
=
IntPtr
.
Zero
;
private
IntPtr
conn
=
IntPtr
.
Zero
;
// private long rowsInserted = 0;
// private long rowsInserted = 0;
...
@@ -66,6 +67,8 @@ namespace TDengineDriver
...
@@ -66,6 +67,8 @@ namespace TDengineDriver
Console
.
WriteLine
(
"Usage: mono taosdemo.exe [OPTION...]"
);
Console
.
WriteLine
(
"Usage: mono taosdemo.exe [OPTION...]"
);
Console
.
WriteLine
(
""
);
Console
.
WriteLine
(
""
);
string
indent
=
" "
;
string
indent
=
" "
;
Console
.
WriteLine
(
"{0}{1}"
,
indent
,
"--help Show usage."
);
Console
.
WriteLine
(
""
);
Console
.
Write
(
"{0}{1}"
,
indent
,
"-h"
);
Console
.
Write
(
"{0}{1}"
,
indent
,
"-h"
);
Console
.
Write
(
"{0}{1}{2}\n"
,
indent
,
indent
,
"host, The host to connect to TDengine. Default is localhost."
);
Console
.
Write
(
"{0}{1}{2}\n"
,
indent
,
indent
,
"host, The host to connect to TDengine. Default is localhost."
);
Console
.
Write
(
"{0}{1}"
,
indent
,
"-p"
);
Console
.
Write
(
"{0}{1}"
,
indent
,
"-p"
);
...
@@ -77,7 +80,7 @@ namespace TDengineDriver
...
@@ -77,7 +80,7 @@ namespace TDengineDriver
Console
.
Write
(
"{0}{1}"
,
indent
,
"-d"
);
Console
.
Write
(
"{0}{1}"
,
indent
,
"-d"
);
Console
.
Write
(
"{0}{1}{2}\n"
,
indent
,
indent
,
"database, Destination database. Default is 'test'."
);
Console
.
Write
(
"{0}{1}{2}\n"
,
indent
,
indent
,
"database, Destination database. Default is 'test'."
);
Console
.
Write
(
"{0}{1}"
,
indent
,
"-a"
);
Console
.
Write
(
"{0}{1}"
,
indent
,
"-a"
);
Console
.
Write
(
"{0}{1}{2}\n"
,
indent
,
indent
,
"replica, Set the replica parameters of the database, Default 1, min: 1, max:
3
."
);
Console
.
Write
(
"{0}{1}{2}\n"
,
indent
,
indent
,
"replica, Set the replica parameters of the database, Default 1, min: 1, max:
5
."
);
Console
.
Write
(
"{0}{1}"
,
indent
,
"-m"
);
Console
.
Write
(
"{0}{1}"
,
indent
,
"-m"
);
Console
.
Write
(
"{0}{1}{2}\n"
,
indent
,
indent
,
"table_prefix, Table prefix name. Default is 't'."
);
Console
.
Write
(
"{0}{1}{2}\n"
,
indent
,
indent
,
"table_prefix, Table prefix name. Default is 't'."
);
Console
.
Write
(
"{0}{1}"
,
indent
,
"-s"
);
Console
.
Write
(
"{0}{1}"
,
indent
,
"-s"
);
...
@@ -99,9 +102,9 @@ namespace TDengineDriver
...
@@ -99,9 +102,9 @@ namespace TDengineDriver
Console
.
Write
(
"{0}{1}"
,
indent
,
"-r"
);
Console
.
Write
(
"{0}{1}"
,
indent
,
"-r"
);
Console
.
Write
(
"{0}{1}{2}\n"
,
indent
,
indent
,
"num_of_records_per_req, The number of records per request. Default is 1000."
);
Console
.
Write
(
"{0}{1}{2}\n"
,
indent
,
indent
,
"num_of_records_per_req, The number of records per request. Default is 1000."
);
Console
.
Write
(
"{0}{1}"
,
indent
,
"-t"
);
Console
.
Write
(
"{0}{1}"
,
indent
,
"-t"
);
Console
.
Write
(
"{0}{1}{2}\n"
,
indent
,
indent
,
"num_of_tables, The number of tables. Default is 1
0000
."
);
Console
.
Write
(
"{0}{1}{2}\n"
,
indent
,
indent
,
"num_of_tables, The number of tables. Default is 1."
);
Console
.
Write
(
"{0}{1}"
,
indent
,
"-n"
);
Console
.
Write
(
"{0}{1}"
,
indent
,
"-n"
);
Console
.
Write
(
"{0}{1}{2}\n"
,
indent
,
indent
,
"num_of_records_per_table, The number of records per table. Default is 1
0000
."
);
Console
.
Write
(
"{0}{1}{2}\n"
,
indent
,
indent
,
"num_of_records_per_table, The number of records per table. Default is 1."
);
Console
.
Write
(
"{0}{1}"
,
indent
,
"-c"
);
Console
.
Write
(
"{0}{1}"
,
indent
,
"-c"
);
Console
.
Write
(
"{0}{1}{2}\n"
,
indent
,
indent
,
"config_directory, Configuration directory. Default is '/etc/taos/'."
);
Console
.
Write
(
"{0}{1}{2}\n"
,
indent
,
indent
,
"config_directory, Configuration directory. Default is '/etc/taos/'."
);
Console
.
Write
(
"{0}{1}"
,
indent
,
"-x"
);
Console
.
Write
(
"{0}{1}"
,
indent
,
"-x"
);
...
@@ -133,14 +136,15 @@ namespace TDengineDriver
...
@@ -133,14 +136,15 @@ namespace TDengineDriver
tablePrefix
=
this
.
GetArgumentAsString
(
argv
,
"-m"
,
"t"
);
tablePrefix
=
this
.
GetArgumentAsString
(
argv
,
"-m"
,
"t"
);
isInsertOnly
=
this
.
GetArgumentAsFlag
(
argv
,
"-x"
);
isInsertOnly
=
this
.
GetArgumentAsFlag
(
argv
,
"-x"
);
queryMode
=
(
int
)
this
.
GetArgumentAsLong
(
argv
,
"-q"
,
0
,
1
,
0
);
queryMode
=
(
int
)
this
.
GetArgumentAsLong
(
argv
,
"-q"
,
0
,
1
,
0
);
numOfTables
=
this
.
GetArgumentAsLong
(
argv
,
"-t"
,
1
,
1000000000
,
1
0000
);
numOfTables
=
this
.
GetArgumentAsLong
(
argv
,
"-t"
,
1
,
1000000000
,
1
);
batchRows
=
this
.
GetArgumentAsLong
(
argv
,
"-r"
,
1
,
10000
,
1000
);
batchRows
=
this
.
GetArgumentAsLong
(
argv
,
"-r"
,
1
,
10000
,
1000
);
recordsPerTable
=
this
.
GetArgumentAsLong
(
argv
,
"-n"
,
1
,
100000000000
,
1
0000
);
recordsPerTable
=
this
.
GetArgumentAsLong
(
argv
,
"-n"
,
1
,
100000000000
,
1
);
recordsPerRequest
=
(
int
)
this
.
GetArgumentAsLong
(
argv
,
"-r"
,
1
,
10000
,
1
);
recordsPerRequest
=
(
int
)
this
.
GetArgumentAsLong
(
argv
,
"-r"
,
1
,
10000
,
1
);
colsPerRecord
=
(
int
)
this
.
GetArgumentAsLong
(
argv
,
"-l"
,
1
,
1024
,
3
);
colsPerRecord
=
(
int
)
this
.
GetArgumentAsLong
(
argv
,
"-l"
,
1
,
1024
,
3
);
configDir
=
this
.
GetArgumentAsString
(
argv
,
"-c"
,
"C:/TDengine/cfg"
);
configDir
=
this
.
GetArgumentAsString
(
argv
,
"-c"
,
"C:/TDengine/cfg"
);
useStable
=
this
.
GetArgumentAsFlag
(
argv
,
"-M"
);
useStable
=
this
.
GetArgumentAsFlag
(
argv
,
"-M"
);
replica
=
(
short
)
this
.
GetArgumentAsLong
(
argv
,
"-a"
,
1
,
5
,
1
);
methodOfDelete
=
(
short
)
this
.
GetArgumentAsLong
(
argv
,
"-D"
,
0
,
3
,
0
);
methodOfDelete
=
(
short
)
this
.
GetArgumentAsLong
(
argv
,
"-D"
,
0
,
3
,
0
);
numOfThreads
=
(
short
)
this
.
GetArgumentAsLong
(
argv
,
"-T"
,
1
,
10000
,
1
);
numOfThreads
=
(
short
)
this
.
GetArgumentAsLong
(
argv
,
"-T"
,
1
,
10000
,
1
);
order
=
this
.
GetArgumentAsFlag
(
argv
,
"-O"
);
order
=
this
.
GetArgumentAsFlag
(
argv
,
"-O"
);
...
@@ -153,13 +157,14 @@ namespace TDengineDriver
...
@@ -153,13 +157,14 @@ namespace TDengineDriver
Console
.
Write
(
"# Server IP: {0}\n"
,
host
);
Console
.
Write
(
"# Server IP: {0}\n"
,
host
);
Console
.
Write
(
"# User: {0}\n"
,
user
);
Console
.
Write
(
"# User: {0}\n"
,
user
);
Console
.
Write
(
"# Password: {0}\n"
,
password
);
Console
.
Write
(
"# Password: {0}\n"
,
password
);
Console
.
Write
(
"# Use super table: {0}\n"
,
useStable
);
Console
.
Write
(
"# Number of Columns per record: {0}\n"
,
colsPerRecord
);
Console
.
Write
(
"# Number of Columns per record: {0}\n"
,
colsPerRecord
);
Console
.
Write
(
"# Number of Threads: {0}\n"
,
numOfThreads
);
Console
.
Write
(
"# Number of Threads: {0}\n"
,
numOfThreads
);
Console
.
Write
(
"# Number of Tables: {0}\n"
,
numOfTables
);
Console
.
Write
(
"# Number of Tables: {0}\n"
,
numOfTables
);
Console
.
Write
(
"# Number of Data per Table: {0}\n"
,
recordsPerTable
);
Console
.
Write
(
"# Number of Data per Table: {0}\n"
,
recordsPerTable
);
Console
.
Write
(
"# Records/Request: {0}\n"
,
recordsPerRequest
);
Console
.
Write
(
"# Records/Request: {0}\n"
,
recordsPerRequest
);
Console
.
Write
(
"# Database name: {0}\n"
,
dbName
);
Console
.
Write
(
"# Database name: {0}\n"
,
dbName
);
Console
.
Write
(
"# Replica: {0}\n"
,
replica
);
Console
.
Write
(
"# Use STable: {0}\n"
,
useStable
);
Console
.
Write
(
"# Table prefix: {0}\n"
,
tablePrefix
);
Console
.
Write
(
"# Table prefix: {0}\n"
,
tablePrefix
);
Console
.
Write
(
"# Data order: {0}\n"
,
order
);
Console
.
Write
(
"# Data order: {0}\n"
,
order
);
Console
.
Write
(
"# Data out of order rate: {0}\n"
,
rateOfOutorder
);
Console
.
Write
(
"# Data out of order rate: {0}\n"
,
rateOfOutorder
);
...
@@ -280,7 +285,7 @@ namespace TDengineDriver
...
@@ -280,7 +285,7 @@ namespace TDengineDriver
public
void
ConnectTDengine
()
public
void
ConnectTDengine
()
{
{
string
db
=
""
;
string
db
=
""
;
DebugPrintFormat
(
"host:{0} user:{1}, pass:{2}; db:{3}, port:{4}"
,
DebugPrintFormat
(
"host:{0} user:{1}, pass:{2}; db:{3}, port:{4}
\n
"
,
this
.
host
,
this
.
user
,
this
.
password
,
db
,
this
.
port
);
this
.
host
,
this
.
user
,
this
.
password
,
db
,
this
.
port
);
this
.
conn
=
TDengine
.
Connect
(
this
.
host
,
this
.
user
,
this
.
password
,
db
,
this
.
port
);
this
.
conn
=
TDengine
.
Connect
(
this
.
host
,
this
.
user
,
this
.
password
,
db
,
this
.
port
);
if
(
this
.
conn
==
IntPtr
.
Zero
)
if
(
this
.
conn
==
IntPtr
.
Zero
)
...
@@ -320,6 +325,7 @@ namespace TDengineDriver
...
@@ -320,6 +325,7 @@ namespace TDengineDriver
createTableThread
.
verbose
=
verbose
;
createTableThread
.
verbose
=
verbose
;
createTableThread
.
dbName
=
this
.
dbName
;
createTableThread
.
dbName
=
this
.
dbName
;
createTableThread
.
tablePrefix
=
this
.
tablePrefix
;
createTableThread
.
tablePrefix
=
this
.
tablePrefix
;
createTableThread
.
useStable
=
useStable
;
if
(
useStable
)
if
(
useStable
)
{
{
createTableThread
.
stableName
=
stableName
;
createTableThread
.
stableName
=
stableName
;
...
@@ -363,7 +369,7 @@ namespace TDengineDriver
...
@@ -363,7 +369,7 @@ namespace TDengineDriver
public
void
CreateDb
()
public
void
CreateDb
()
{
{
StringBuilder
sql
=
new
StringBuilder
();
StringBuilder
sql
=
new
StringBuilder
();
sql
.
Append
(
"CREATE DATABASE IF NOT EXISTS "
).
Append
(
this
.
dbName
);
sql
.
Append
(
"CREATE DATABASE IF NOT EXISTS "
).
Append
(
this
.
dbName
)
.
Append
(
" replica "
).
Append
(
this
.
replica
)
;
IntPtr
res
=
TDengine
.
Query
(
this
.
conn
,
sql
.
ToString
());
IntPtr
res
=
TDengine
.
Query
(
this
.
conn
,
sql
.
ToString
());
if
(
res
!=
IntPtr
.
Zero
)
if
(
res
!=
IntPtr
.
Zero
)
{
{
...
@@ -429,7 +435,7 @@ namespace TDengineDriver
...
@@ -429,7 +435,7 @@ namespace TDengineDriver
insertThread
.
tablePrefix
=
this
.
tablePrefix
;
insertThread
.
tablePrefix
=
this
.
tablePrefix
;
if
(
useStable
)
if
(
useStable
)
{
{
insertThread
.
stableName
=
stableName
;
//
insertThread.stableName = stableName;
}
}
insertThread
.
conn
=
conn
;
insertThread
.
conn
=
conn
;
...
@@ -584,15 +590,20 @@ namespace TDengineDriver
...
@@ -584,15 +590,20 @@ namespace TDengineDriver
tester
.
InitTDengine
();
tester
.
InitTDengine
();
tester
.
ConnectTDengine
();
tester
.
ConnectTDengine
();
if
(
tester
.
isInsertOnly
==
false
)
{
tester
.
dropDatabase
();
tester
.
dropDatabase
();
tester
.
CreateDb
();
tester
.
CreateDb
();
if
(
tester
.
useStable
==
true
)
if
(
tester
.
useStable
==
true
)
{
{
tester
.
CreateStable
();
tester
.
CreateStable
();
}
}
tester
.
CreateTablesByThreads
();
tester
.
CreateTablesByThreads
();
}
Stopwatch
watch
=
Stopwatch
.
StartNew
();
Stopwatch
watch
=
Stopwatch
.
StartNew
();
tester
.
InsertByThreads
();
tester
.
InsertByThreads
();
...
@@ -619,7 +630,7 @@ namespace TDengineDriver
...
@@ -619,7 +630,7 @@ namespace TDengineDriver
public
string
dbName
{
set
;
get
;
}
public
string
dbName
{
set
;
get
;
}
public
IntPtr
conn
{
set
;
get
;
}
public
IntPtr
conn
{
set
;
get
;
}
public
string
tablePrefix
{
set
;
get
;
}
public
string
tablePrefix
{
set
;
get
;
}
public
string
stableName
{
set
;
get
;
}
//
public string stableName { set; get; }
public
long
recordsPerTable
{
set
;
get
;
}
public
long
recordsPerTable
{
set
;
get
;
}
public
long
batchRows
{
set
;
get
;
}
public
long
batchRows
{
set
;
get
;
}
public
long
numOfTables
{
set
;
get
;
}
public
long
numOfTables
{
set
;
get
;
}
...
@@ -643,9 +654,18 @@ namespace TDengineDriver
...
@@ -643,9 +654,18 @@ namespace TDengineDriver
public
void
ThreadMain
()
public
void
ThreadMain
()
{
{
DebugPrintFormat
(
"InsertDataThread {0} from {1} to {2}"
,
id
,
start
,
end
);
DebugPrintFormat
(
"InsertDataThread {0} from {1} to {2}
\n
"
,
id
,
start
,
end
);
StringBuilder
sql
=
new
StringBuilder
();
StringBuilder
sql
=
new
StringBuilder
();
long
beginTimestamp
=
1551369600000L
;
DateTime
now
=
DateTime
.
Now
;
int
h
=
now
.
Hour
;
int
m
=
now
.
Minute
;
int
s
=
now
.
Second
;
long
baseTimestamp
=
1609430400000
;
// 2021/01/01 0:0:0
DebugPrintFormat
(
"beginTime is {0} + {1}h:{2}m:{3}s\n"
,
baseTimestamp
,
h
,
m
,
s
);
long
beginTimestamp
=
baseTimestamp
+
((
h
*
60
+
m
)
*
60
+
s
)
*
1000
;
long
rowsInserted
=
0
;
long
rowsInserted
=
0
;
// System.DateTime startTime = new System.DateTime();
// System.DateTime startTime = new System.DateTime();
...
@@ -660,7 +680,11 @@ namespace TDengineDriver
...
@@ -660,7 +680,11 @@ namespace TDengineDriver
sql
.
Append
(
"INSERT INTO "
).
sql
.
Append
(
"INSERT INTO "
).
Append
(
this
.
dbName
).
Append
(
"."
).
Append
(
this
.
tablePrefix
).
Append
(
table
).
Append
(
this
.
dbName
).
Append
(
"."
).
Append
(
this
.
tablePrefix
).
Append
(
table
).
Append
(
" VALUES"
);
Append
(
" VALUES"
);
for
(
int
batch
=
0
;
batch
<
this
.
batchRows
;
++
batch
)
if
(
recordsPerTable
<
batchRows
)
{
batchRows
=
recordsPerTable
;
}
for
(
int
batch
=
0
;
batch
<
batchRows
;
++
batch
)
{
{
sql
.
Append
(
"("
)
sql
.
Append
(
"("
)
.
Append
(
beginTimestamp
+
i
+
batch
)
.
Append
(
beginTimestamp
+
i
+
batch
)
...
@@ -701,6 +725,7 @@ namespace TDengineDriver
...
@@ -701,6 +725,7 @@ namespace TDengineDriver
public
string
tablePrefix
{
set
;
get
;
}
public
string
tablePrefix
{
set
;
get
;
}
public
string
stableName
{
set
;
get
;
}
public
string
stableName
{
set
;
get
;
}
public
bool
verbose
{
set
;
get
;
}
public
bool
verbose
{
set
;
get
;
}
public
bool
useStable
{
set
;
get
;
}
private
void
DebugPrintFormat
(
string
format
,
params
object
[]
parameters
)
private
void
DebugPrintFormat
(
string
format
,
params
object
[]
parameters
)
{
{
...
@@ -720,7 +745,7 @@ namespace TDengineDriver
...
@@ -720,7 +745,7 @@ namespace TDengineDriver
public
void
ThreadMain
()
public
void
ThreadMain
()
{
{
DebugPrintFormat
(
"CreateTable {0} from {1} to {2}"
,
id
,
start
,
end
);
DebugPrintFormat
(
"CreateTable {0} from {1} to {2}
\n
"
,
id
,
start
,
end
);
StringBuilder
sql
=
new
StringBuilder
();
StringBuilder
sql
=
new
StringBuilder
();
...
@@ -728,9 +753,16 @@ namespace TDengineDriver
...
@@ -728,9 +753,16 @@ namespace TDengineDriver
{
{
sql
.
Clear
();
sql
.
Clear
();
sql
=
sql
.
Append
(
"CREATE TABLE IF NOT EXISTS "
).
sql
=
sql
.
Append
(
"CREATE TABLE IF NOT EXISTS "
).
Append
(
this
.
dbName
).
Append
(
"."
).
Append
(
this
.
tablePrefix
).
Append
(
tableId
).
Append
(
this
.
dbName
).
Append
(
"."
).
Append
(
this
.
tablePrefix
).
Append
(
tableId
);
Append
(
" USING "
).
Append
(
this
.
dbName
).
Append
(
"."
).
Append
(
this
.
stableName
).
if
(
useStable
==
true
)
{
sql
=
sql
.
Append
(
" USING "
).
Append
(
this
.
dbName
).
Append
(
"."
).
Append
(
this
.
stableName
).
Append
(
" TAGS("
).
Append
(
tableId
).
Append
(
")"
);
Append
(
" TAGS("
).
Append
(
tableId
).
Append
(
")"
);
}
else
{
sql
=
sql
.
Append
(
"(ts timestamp, v1 bool, v2 tinyint, v3 smallint, v4 int, v5 bigint, v6 float, v7 double, v8 binary(10), v9 nchar(10))"
);
}
IntPtr
res
=
TDengine
.
Query
(
this
.
conn
,
sql
.
ToString
());
IntPtr
res
=
TDengine
.
Query
(
this
.
conn
,
sql
.
ToString
());
if
(
res
!=
IntPtr
.
Zero
)
if
(
res
!=
IntPtr
.
Zero
)
{
{
...
...
tests/examples/JDBC/JDBCDemo/pom.xml
浏览文件 @
24a0b291
...
@@ -48,4 +48,12 @@
...
@@ -48,4 +48,12 @@
</plugins>
</plugins>
</build>
</build>
<dependencies>
<dependency>
<groupId>
com.taosdata.jdbc
</groupId>
<artifactId>
taos-jdbcdriver
</artifactId>
<version>
2.0.15
</version>
</dependency>
</dependencies>
</project>
</project>
tests/examples/JDBC/JDBCDemo/src/main/java/com/taosdata/example/JDBCDemo.java
浏览文件 @
24a0b291
...
@@ -5,7 +5,7 @@ import java.util.Properties;
...
@@ -5,7 +5,7 @@ import java.util.Properties;
public
class
JDBCDemo
{
public
class
JDBCDemo
{
private
static
String
host
;
private
static
String
host
;
private
static
String
driverType
;
private
static
String
driverType
=
"jni"
;
private
static
final
String
dbName
=
"test"
;
private
static
final
String
dbName
=
"test"
;
private
static
final
String
tbName
=
"weather"
;
private
static
final
String
tbName
=
"weather"
;
private
Connection
connection
;
private
Connection
connection
;
...
@@ -21,7 +21,7 @@ public class JDBCDemo {
...
@@ -21,7 +21,7 @@ public class JDBCDemo {
}
}
}
}
if
(
host
==
null
||
driverType
==
null
)
{
if
(
host
==
null
)
{
printHelp
();
printHelp
();
}
}
...
...
tests/script/general/parser/first_last_query.sim
浏览文件 @
24a0b291
...
@@ -37,6 +37,7 @@ if $data02 != 0 then
...
@@ -37,6 +37,7 @@ if $data02 != 0 then
endi
endi
print data03 = $data03
print data03 = $data03
if $data03 != 0.00000 then
if $data03 != 0.00000 then
print expect 0.00000, actual: $data03
return -1
return -1
endi
endi
if $data04 != 0.000000000 then
if $data04 != 0.000000000 then
...
...
tests/script/general/parser/function.sim
浏览文件 @
24a0b291
...
@@ -361,3 +361,15 @@ endi
...
@@ -361,3 +361,15 @@ endi
if $data10 != @20-07-30 17:43:59.000@ then
if $data10 != @20-07-30 17:43:59.000@ then
return -1
return -1
endi
endi
print =================>td-2610
sql select stddev(k) from tm2 where ts='2020-12-29 18:46:19.109'
if $rows != 0 then
print expect 0, actual:$rows
return -1
endi
sql select twa(k) from tm2 where ts='2020-12-29 18:46:19.109'
if $rows != 0 then
return -1
endi
tests/script/general/parser/groupby.sim
浏览文件 @
24a0b291
...
@@ -606,6 +606,10 @@ sql insert into t1 values ('2020-03-27 04:21:16.000', 1)('2020-03-27 04:31:17.00
...
@@ -606,6 +606,10 @@ sql insert into t1 values ('2020-03-27 04:21:16.000', 1)('2020-03-27 04:31:17.00
sql insert into t2 values ('2020-03-27 04:11:16.000', 1)('2020-03-27 04:11:17.000', 2) ('2020-03-27 04:11:18.000', 3) ('2020-03-27 04:11:19.000', 4) ;
sql insert into t2 values ('2020-03-27 04:11:16.000', 1)('2020-03-27 04:11:17.000', 2) ('2020-03-27 04:11:18.000', 3) ('2020-03-27 04:11:19.000', 4) ;
sql insert into t2 values ('2020-03-27 04:21:16.000', 1)('2020-03-27 04:31:17.000', 2) ('2020-03-27 04:51:18.000', 3) ('2020-03-27 05:10:19.000', 4) ;
sql insert into t2 values ('2020-03-27 04:21:16.000', 1)('2020-03-27 04:31:17.000', 2) ('2020-03-27 04:51:18.000', 3) ('2020-03-27 05:10:19.000', 4) ;
print =================>TD-2665
sql_error create table txx as select avg(c) as t from st;
sql_error create table txx1 as select avg(c) as t from t1;
print =================>TD-2236
print =================>TD-2236
sql select first(ts),last(ts) from t1 group by c;
sql select first(ts),last(ts) from t1 group by c;
if $rows != 4 then
if $rows != 4 then
...
...
tests/script/general/parser/testSuite.sim
浏览文件 @
24a0b291
run general/parser/alter.sim
#
run general/parser/alter.sim
sleep 500
#
sleep 500
run general/parser/alter1.sim
#
run general/parser/alter1.sim
sleep 500
#
sleep 500
run general/parser/alter_stable.sim
#
run general/parser/alter_stable.sim
sleep 500
#
sleep 500
run general/parser/auto_create_tb.sim
#
run general/parser/auto_create_tb.sim
sleep 500
#
sleep 500
run general/parser/auto_create_tb_drop_tb.sim
#
run general/parser/auto_create_tb_drop_tb.sim
sleep 500
#
sleep 500
run general/parser/col_arithmetic_operation.sim
#
run general/parser/col_arithmetic_operation.sim
sleep 500
#
sleep 500
run general/parser/columnValue.sim
#
run general/parser/columnValue.sim
sleep 500
#
sleep 500
run general/parser/commit.sim
#
run general/parser/commit.sim
sleep 500
#
sleep 500
run general/parser/create_db.sim
#
run general/parser/create_db.sim
sleep 500
#
sleep 500
run general/parser/create_mt.sim
#
run general/parser/create_mt.sim
sleep 500
#
sleep 500
run general/parser/create_tb.sim
#
run general/parser/create_tb.sim
sleep 500
#
sleep 500
run general/parser/dbtbnameValidate.sim
#
run general/parser/dbtbnameValidate.sim
sleep 500
#
sleep 500
run general/parser/fill.sim
#
run general/parser/fill.sim
sleep 500
#
sleep 500
run general/parser/fill_stb.sim
#
run general/parser/fill_stb.sim
sleep 500
#
sleep 500
#run general/parser/fill_us.sim #
#
#
run general/parser/fill_us.sim #
sleep 500
#
sleep 500
run general/parser/first_last.sim
#
run general/parser/first_last.sim
sleep 500
#
sleep 500
run general/parser/import_commit1.sim
#
run general/parser/import_commit1.sim
sleep 500
#
sleep 500
run general/parser/import_commit2.sim
#
run general/parser/import_commit2.sim
sleep 500
#
sleep 500
run general/parser/import_commit3.sim
#
run general/parser/import_commit3.sim
sleep 500
#
sleep 500
#run general/parser/import_file.sim
#
#
run general/parser/import_file.sim
sleep 500
#
sleep 500
run general/parser/insert_tb.sim
#
run general/parser/insert_tb.sim
sleep 500
#
sleep 500
run general/parser/tags_dynamically_specifiy.sim
#
run general/parser/tags_dynamically_specifiy.sim
sleep 500
#
sleep 500
run general/parser/interp.sim
#
run general/parser/interp.sim
sleep 500
#
sleep 500
run general/parser/lastrow.sim
#
run general/parser/lastrow.sim
sleep 500
sleep 500
run general/parser/limit.sim
run general/parser/limit.sim
sleep 500
sleep 500
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录