Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
慢慢CG
TDengine
提交
d37fad65
T
TDengine
项目概览
慢慢CG
/
TDengine
与 Fork 源项目一致
Fork自
taosdata / TDengine
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
d37fad65
编写于
4月 21, 2021
作者:
H
Haojun Liao
浏览文件
操作
浏览文件
下载
差异文件
Merge branch 'master' into feature/qrefactor
上级
64d0f679
e663bc6f
变更
18
显示空白变更内容
内联
并排
Showing
18 changed file
with
1094 addition
and
655 deletion
+1094
-655
cmake/version.inc
cmake/version.inc
+1
-1
snap/snapcraft.yaml
snap/snapcraft.yaml
+2
-2
src/connector/C#/TDengineDriver.cs
src/connector/C#/TDengineDriver.cs
+17
-5
src/connector/go
src/connector/go
+1
-1
src/kit/taosdemo/taosdemo.c
src/kit/taosdemo/taosdemo.c
+213
-132
src/kit/taosdump/taosdump.c
src/kit/taosdump/taosdump.c
+2
-1
src/os/src/darwin/darwinSysInfo.c
src/os/src/darwin/darwinSysInfo.c
+1
-1
src/os/src/detail/osSysinfo.c
src/os/src/detail/osSysinfo.c
+1
-1
src/tsdb/src/tsdbRead.c
src/tsdb/src/tsdbRead.c
+5
-1
tests/examples/C#/C#checker/C#checker.cs
tests/examples/C#/C#checker/C#checker.cs
+357
-348
tests/examples/C#/TDengineDriver.cs
tests/examples/C#/TDengineDriver.cs
+130
-117
tests/examples/C#/TDengineTest.cs
tests/examples/C#/TDengineTest.cs
+65
-23
tests/examples/C#/taosdemo/taosdemo.cs
tests/examples/C#/taosdemo/taosdemo.cs
+44
-21
tests/pytest/alter/alterTabAddTagWithNULL.py
tests/pytest/alter/alterTabAddTagWithNULL.py
+85
-0
tests/pytest/fulltest.sh
tests/pytest/fulltest.sh
+4
-0
tests/pytest/query/queryNormal.py
tests/pytest/query/queryNormal.py
+27
-1
tests/pytest/query/querySecondtscolumnTowherenow.py
tests/pytest/query/querySecondtscolumnTowherenow.py
+131
-0
tests/pytest/util/sql.py
tests/pytest/util/sql.py
+8
-0
未找到文件。
cmake/version.inc
浏览文件 @
d37fad65
...
@@ -4,7 +4,7 @@ PROJECT(TDengine)
...
@@ -4,7 +4,7 @@ PROJECT(TDengine)
IF
(
DEFINED
VERNUMBER
)
IF
(
DEFINED
VERNUMBER
)
SET
(
TD_VER_NUMBER
$
{
VERNUMBER
})
SET
(
TD_VER_NUMBER
$
{
VERNUMBER
})
ELSE
()
ELSE
()
SET
(
TD_VER_NUMBER
"2.0.
19
.0"
)
SET
(
TD_VER_NUMBER
"2.0.
20
.0"
)
ENDIF
()
ENDIF
()
IF
(
DEFINED
VERCOMPATIBLE
)
IF
(
DEFINED
VERCOMPATIBLE
)
...
...
snap/snapcraft.yaml
浏览文件 @
d37fad65
name
:
tdengine
name
:
tdengine
base
:
core18
base
:
core18
version
:
'
2.0.
19
.0'
version
:
'
2.0.
20
.0'
icon
:
snap/gui/t-dengine.svg
icon
:
snap/gui/t-dengine.svg
summary
:
an open-source big data platform designed and optimized for IoT.
summary
:
an open-source big data platform designed and optimized for IoT.
description
:
|
description
:
|
...
@@ -72,7 +72,7 @@ parts:
...
@@ -72,7 +72,7 @@ parts:
-
usr/bin/taosd
-
usr/bin/taosd
-
usr/bin/taos
-
usr/bin/taos
-
usr/bin/taosdemo
-
usr/bin/taosdemo
-
usr/lib/libtaos.so.2.0.
19
.0
-
usr/lib/libtaos.so.2.0.
20
.0
-
usr/lib/libtaos.so.1
-
usr/lib/libtaos.so.1
-
usr/lib/libtaos.so
-
usr/lib/libtaos.so
...
...
src/connector/C#/TDengineDriver.cs
浏览文件 @
d37fad65
...
@@ -31,7 +31,11 @@ namespace TDengineDriver
...
@@ -31,7 +31,11 @@ namespace TDengineDriver
TSDB_DATA_TYPE_DOUBLE
=
7
,
// 8 bytes
TSDB_DATA_TYPE_DOUBLE
=
7
,
// 8 bytes
TSDB_DATA_TYPE_BINARY
=
8
,
// string
TSDB_DATA_TYPE_BINARY
=
8
,
// string
TSDB_DATA_TYPE_TIMESTAMP
=
9
,
// 8 bytes
TSDB_DATA_TYPE_TIMESTAMP
=
9
,
// 8 bytes
TSDB_DATA_TYPE_NCHAR
=
10
// unicode string
TSDB_DATA_TYPE_NCHAR
=
10
,
// unicode string
TSDB_DATA_TYPE_UTINYINT
=
11
,
// 1 byte
TSDB_DATA_TYPE_USMALLINT
=
12
,
// 2 bytes
TSDB_DATA_TYPE_UINT
=
13
,
// 4 bytes
TSDB_DATA_TYPE_UBIGINT
=
14
// 8 bytes
}
}
enum
TDengineInitOption
enum
TDengineInitOption
...
@@ -53,15 +57,23 @@ namespace TDengineDriver
...
@@ -53,15 +57,23 @@ namespace TDengineDriver
switch
((
TDengineDataType
)
type
)
switch
((
TDengineDataType
)
type
)
{
{
case
TDengineDataType
.
TSDB_DATA_TYPE_BOOL
:
case
TDengineDataType
.
TSDB_DATA_TYPE_BOOL
:
return
"BOOL
EAN
"
;
return
"BOOL"
;
case
TDengineDataType
.
TSDB_DATA_TYPE_TINYINT
:
case
TDengineDataType
.
TSDB_DATA_TYPE_TINYINT
:
return
"
BYTE
"
;
return
"
TINYINT
"
;
case
TDengineDataType
.
TSDB_DATA_TYPE_SMALLINT
:
case
TDengineDataType
.
TSDB_DATA_TYPE_SMALLINT
:
return
"S
HOR
T"
;
return
"S
MALLIN
T"
;
case
TDengineDataType
.
TSDB_DATA_TYPE_INT
:
case
TDengineDataType
.
TSDB_DATA_TYPE_INT
:
return
"INT"
;
return
"INT"
;
case
TDengineDataType
.
TSDB_DATA_TYPE_BIGINT
:
case
TDengineDataType
.
TSDB_DATA_TYPE_BIGINT
:
return
"LONG"
;
return
"BIGINT"
;
case
TDengineDataType
.
TSDB_DATA_TYPE_UTINYINT
:
return
"TINYINT UNSIGNED"
;
case
TDengineDataType
.
TSDB_DATA_TYPE_USMALLINT
:
return
"SMALLINT UNSIGNED"
;
case
TDengineDataType
.
TSDB_DATA_TYPE_UINT
:
return
"INT UNSIGNED"
;
case
TDengineDataType
.
TSDB_DATA_TYPE_UBIGINT
:
return
"BIGINT UNSIGNED"
;
case
TDengineDataType
.
TSDB_DATA_TYPE_FLOAT
:
case
TDengineDataType
.
TSDB_DATA_TYPE_FLOAT
:
return
"FLOAT"
;
return
"FLOAT"
;
case
TDengineDataType
.
TSDB_DATA_TYPE_DOUBLE
:
case
TDengineDataType
.
TSDB_DATA_TYPE_DOUBLE
:
...
...
go
@
d9975135
比较
050667e5
...
d9975135
Subproject commit
050667e5b4d0eafa5387e4283e713559b421203f
Subproject commit
d99751356e285696f57bc604304ffafd10287439
src/kit/taosdemo/taosdemo.c
浏览文件 @
d37fad65
...
@@ -97,7 +97,7 @@ enum QUERY_MODE {
...
@@ -97,7 +97,7 @@ enum QUERY_MODE {
#define MAX_TAG_COUNT 128
#define MAX_TAG_COUNT 128
#define MAX_QUERY_SQL_COUNT 100
#define MAX_QUERY_SQL_COUNT 100
#define MAX_QUERY_SQL_LENGTH
256
#define MAX_QUERY_SQL_LENGTH
1024
#define MAX_DATABASE_COUNT 256
#define MAX_DATABASE_COUNT 256
#define INPUT_BUF_LEN 256
#define INPUT_BUF_LEN 256
...
@@ -355,7 +355,7 @@ typedef struct SDbs_S {
...
@@ -355,7 +355,7 @@ typedef struct SDbs_S {
}
SDbs
;
}
SDbs
;
typedef
struct
SpecifiedQueryInfo_S
{
typedef
struct
SpecifiedQueryInfo_S
{
int
rate
;
// 0: unlimit > 0 loop/s
int
queryInterval
;
// 0: unlimit > 0 loop/s
int
concurrent
;
int
concurrent
;
int
sqlCount
;
int
sqlCount
;
int
mode
;
// 0: sync, 1: async
int
mode
;
// 0: sync, 1: async
...
@@ -371,7 +371,7 @@ typedef struct SpecifiedQueryInfo_S {
...
@@ -371,7 +371,7 @@ typedef struct SpecifiedQueryInfo_S {
typedef
struct
SuperQueryInfo_S
{
typedef
struct
SuperQueryInfo_S
{
char
sTblName
[
MAX_TB_NAME_SIZE
+
1
];
char
sTblName
[
MAX_TB_NAME_SIZE
+
1
];
int
rate
;
// 0: unlimit > 0 loop/s
int
queryInterval
;
// 0: unlimit > 0 loop/s
int
threadCnt
;
int
threadCnt
;
int
mode
;
// 0: sync, 1: async
int
mode
;
// 0: sync, 1: async
int
subscribeInterval
;
// ms
int
subscribeInterval
;
// ms
...
@@ -571,8 +571,8 @@ SArguments g_args = {
...
@@ -571,8 +571,8 @@ SArguments g_args = {
0
,
// insert_interval
0
,
// insert_interval
1
,
// query_times
1
,
// query_times
0
,
// interlace_rows;
0
,
// interlace_rows;
100
,
// num_of_RPR
30000
,
// num_of_RPR
TSDB_PAYLOAD_SIZE
,
// max_sql_len
1024000
,
// max_sql_len
10000
,
// num_of_tables
10000
,
// num_of_tables
10000
,
// num_of_DPT
10000
,
// num_of_DPT
0
,
// abort
0
,
// abort
...
@@ -667,7 +667,7 @@ static void printHelp() {
...
@@ -667,7 +667,7 @@ static void printHelp() {
printf
(
"%s%s%s%s
\n
"
,
indent
,
"-o"
,
indent
,
printf
(
"%s%s%s%s
\n
"
,
indent
,
"-o"
,
indent
,
"Direct output to the named file. Default is './output.txt'."
);
"Direct output to the named file. Default is './output.txt'."
);
printf
(
"%s%s%s%s
\n
"
,
indent
,
"-q"
,
indent
,
printf
(
"%s%s%s%s
\n
"
,
indent
,
"-q"
,
indent
,
"Query mode
--
0: SYNC, 1: ASYNC. Default is SYNC."
);
"Query mode
--
0: SYNC, 1: ASYNC. Default is SYNC."
);
printf
(
"%s%s%s%s
\n
"
,
indent
,
"-b"
,
indent
,
printf
(
"%s%s%s%s
\n
"
,
indent
,
"-b"
,
indent
,
"The data_type of columns, default: TINYINT,SMALLINT,INT,BIGINT,FLOAT,DOUBLE,BINARY,NCHAR,BOOL,TIMESTAMP."
);
"The data_type of columns, default: TINYINT,SMALLINT,INT,BIGINT,FLOAT,DOUBLE,BINARY,NCHAR,BOOL,TIMESTAMP."
);
printf
(
"%s%s%s%s
\n
"
,
indent
,
"-w"
,
indent
,
printf
(
"%s%s%s%s
\n
"
,
indent
,
"-w"
,
indent
,
...
@@ -679,7 +679,7 @@ static void printHelp() {
...
@@ -679,7 +679,7 @@ static void printHelp() {
printf
(
"%s%s%s%s
\n
"
,
indent
,
"-i"
,
indent
,
printf
(
"%s%s%s%s
\n
"
,
indent
,
"-i"
,
indent
,
"The sleep time (ms) between insertion. Default is 0."
);
"The sleep time (ms) between insertion. Default is 0."
);
printf
(
"%s%s%s%s
\n
"
,
indent
,
"-r"
,
indent
,
printf
(
"%s%s%s%s
\n
"
,
indent
,
"-r"
,
indent
,
"The number of records per request. Default is
1
00."
);
"The number of records per request. Default is
300
00."
);
printf
(
"%s%s%s%s
\n
"
,
indent
,
"-t"
,
indent
,
printf
(
"%s%s%s%s
\n
"
,
indent
,
"-t"
,
indent
,
"The number of tables. Default is 10000."
);
"The number of tables. Default is 10000."
);
printf
(
"%s%s%s%s
\n
"
,
indent
,
"-n"
,
indent
,
printf
(
"%s%s%s%s
\n
"
,
indent
,
"-n"
,
indent
,
...
@@ -692,13 +692,30 @@ static void printHelp() {
...
@@ -692,13 +692,30 @@ static void printHelp() {
"Out of order data's range, ms, default is 1000."
);
"Out of order data's range, ms, default is 1000."
);
printf
(
"%s%s%s%s
\n
"
,
indent
,
"-g"
,
indent
,
printf
(
"%s%s%s%s
\n
"
,
indent
,
"-g"
,
indent
,
"Print debug info."
);
"Print debug info."
);
printf
(
"%s%s%s
%s
\n
"
,
indent
,
"-V, --version"
,
indent
,
printf
(
"%s%s%s
\n
"
,
indent
,
"-V, --version
\t
"
,
"Print version info."
);
"Print version info."
);
printf
(
"%s%s%s%s
\n
"
,
indent
,
"--help
\t
"
,
indent
,
"Print command line arguments list info."
);
/* printf("%s%s%s%s\n", indent, "-D", indent,
/* printf("%s%s%s%s\n", indent, "-D", indent,
"if elete database if exists. 0: no, 1: yes, default is 1");
"if elete database if exists. 0: no, 1: yes, default is 1");
*/
*/
}
}
static
bool
isStringNumber
(
char
*
input
)
{
int
len
=
strlen
(
input
);
if
(
0
==
len
)
{
return
false
;
}
for
(
int
i
=
0
;
i
<
len
;
i
++
)
{
if
(
!
isdigit
(
input
[
i
]))
return
false
;
}
return
true
;
}
static
void
parse_args
(
int
argc
,
char
*
argv
[],
SArguments
*
arguments
)
{
static
void
parse_args
(
int
argc
,
char
*
argv
[],
SArguments
*
arguments
)
{
char
**
sptr
;
char
**
sptr
;
...
@@ -711,6 +728,12 @@ static void parse_args(int argc, char *argv[], SArguments *arguments) {
...
@@ -711,6 +728,12 @@ static void parse_args(int argc, char *argv[], SArguments *arguments) {
}
else
if
(
strcmp
(
argv
[
i
],
"-h"
)
==
0
)
{
}
else
if
(
strcmp
(
argv
[
i
],
"-h"
)
==
0
)
{
arguments
->
host
=
argv
[
++
i
];
arguments
->
host
=
argv
[
++
i
];
}
else
if
(
strcmp
(
argv
[
i
],
"-p"
)
==
0
)
{
}
else
if
(
strcmp
(
argv
[
i
],
"-p"
)
==
0
)
{
if
((
argc
==
i
+
1
)
||
(
!
isStringNumber
(
argv
[
i
+
1
])))
{
printHelp
();
errorPrint
(
"%s"
,
"
\n\t
-p need a number following!
\n
"
);
exit
(
EXIT_FAILURE
);
}
arguments
->
port
=
atoi
(
argv
[
++
i
]);
arguments
->
port
=
atoi
(
argv
[
++
i
]);
}
else
if
(
strcmp
(
argv
[
i
],
"-u"
)
==
0
)
{
}
else
if
(
strcmp
(
argv
[
i
],
"-u"
)
==
0
)
{
arguments
->
user
=
argv
[
++
i
];
arguments
->
user
=
argv
[
++
i
];
...
@@ -721,24 +744,66 @@ static void parse_args(int argc, char *argv[], SArguments *arguments) {
...
@@ -721,24 +744,66 @@ static void parse_args(int argc, char *argv[], SArguments *arguments) {
}
else
if
(
strcmp
(
argv
[
i
],
"-s"
)
==
0
)
{
}
else
if
(
strcmp
(
argv
[
i
],
"-s"
)
==
0
)
{
arguments
->
sqlFile
=
argv
[
++
i
];
arguments
->
sqlFile
=
argv
[
++
i
];
}
else
if
(
strcmp
(
argv
[
i
],
"-q"
)
==
0
)
{
}
else
if
(
strcmp
(
argv
[
i
],
"-q"
)
==
0
)
{
if
((
argc
==
i
+
1
)
||
(
!
isStringNumber
(
argv
[
i
+
1
])))
{
printHelp
();
errorPrint
(
"%s"
,
"
\n\t
-q need a number following!
\n
Query mode -- 0: SYNC, 1: ASYNC. Default is SYNC.
\n
"
);
exit
(
EXIT_FAILURE
);
}
arguments
->
query_mode
=
atoi
(
argv
[
++
i
]);
arguments
->
query_mode
=
atoi
(
argv
[
++
i
]);
}
else
if
(
strcmp
(
argv
[
i
],
"-T"
)
==
0
)
{
}
else
if
(
strcmp
(
argv
[
i
],
"-T"
)
==
0
)
{
if
((
argc
==
i
+
1
)
||
(
!
isStringNumber
(
argv
[
i
+
1
])))
{
printHelp
();
errorPrint
(
"%s"
,
"
\n\t
-T need a number following!
\n
"
);
exit
(
EXIT_FAILURE
);
}
arguments
->
num_of_threads
=
atoi
(
argv
[
++
i
]);
arguments
->
num_of_threads
=
atoi
(
argv
[
++
i
]);
}
else
if
(
strcmp
(
argv
[
i
],
"-i"
)
==
0
)
{
}
else
if
(
strcmp
(
argv
[
i
],
"-i"
)
==
0
)
{
if
((
argc
==
i
+
1
)
||
(
!
isStringNumber
(
argv
[
i
+
1
])))
{
printHelp
();
errorPrint
(
"%s"
,
"
\n\t
-i need a number following!
\n
"
);
exit
(
EXIT_FAILURE
);
}
arguments
->
insert_interval
=
atoi
(
argv
[
++
i
]);
arguments
->
insert_interval
=
atoi
(
argv
[
++
i
]);
}
else
if
(
strcmp
(
argv
[
i
],
"-qt"
)
==
0
)
{
}
else
if
(
strcmp
(
argv
[
i
],
"-qt"
)
==
0
)
{
arguments
->
query_times
=
atoi
(
argv
[
++
i
]);
arguments
->
query_times
=
atoi
(
argv
[
++
i
]);
}
else
if
(
strcmp
(
argv
[
i
],
"-B"
)
==
0
)
{
}
else
if
(
strcmp
(
argv
[
i
],
"-B"
)
==
0
)
{
arguments
->
interlace_rows
=
atoi
(
argv
[
++
i
]);
arguments
->
interlace_rows
=
atoi
(
argv
[
++
i
]);
}
else
if
(
strcmp
(
argv
[
i
],
"-r"
)
==
0
)
{
}
else
if
(
strcmp
(
argv
[
i
],
"-r"
)
==
0
)
{
if
((
argc
==
i
+
1
)
||
(
!
isStringNumber
(
argv
[
i
+
1
])))
{
printHelp
();
errorPrint
(
"%s"
,
"
\n\t
-r need a number following!
\n
"
);
exit
(
EXIT_FAILURE
);
}
arguments
->
num_of_RPR
=
atoi
(
argv
[
++
i
]);
arguments
->
num_of_RPR
=
atoi
(
argv
[
++
i
]);
}
else
if
(
strcmp
(
argv
[
i
],
"-t"
)
==
0
)
{
}
else
if
(
strcmp
(
argv
[
i
],
"-t"
)
==
0
)
{
if
((
argc
==
i
+
1
)
||
(
!
isStringNumber
(
argv
[
i
+
1
])))
{
printHelp
();
errorPrint
(
"%s"
,
"
\n\t
-t need a number following!
\n
"
);
exit
(
EXIT_FAILURE
);
}
arguments
->
num_of_tables
=
atoi
(
argv
[
++
i
]);
arguments
->
num_of_tables
=
atoi
(
argv
[
++
i
]);
}
else
if
(
strcmp
(
argv
[
i
],
"-n"
)
==
0
)
{
}
else
if
(
strcmp
(
argv
[
i
],
"-n"
)
==
0
)
{
if
((
argc
==
i
+
1
)
||
(
!
isStringNumber
(
argv
[
i
+
1
])))
{
printHelp
();
errorPrint
(
"%s"
,
"
\n\t
-n need a number following!
\n
"
);
exit
(
EXIT_FAILURE
);
}
arguments
->
num_of_DPT
=
atoi
(
argv
[
++
i
]);
arguments
->
num_of_DPT
=
atoi
(
argv
[
++
i
]);
}
else
if
(
strcmp
(
argv
[
i
],
"-d"
)
==
0
)
{
}
else
if
(
strcmp
(
argv
[
i
],
"-d"
)
==
0
)
{
arguments
->
database
=
argv
[
++
i
];
arguments
->
database
=
argv
[
++
i
];
}
else
if
(
strcmp
(
argv
[
i
],
"-l"
)
==
0
)
{
}
else
if
(
strcmp
(
argv
[
i
],
"-l"
)
==
0
)
{
if
((
argc
==
i
+
1
)
||
(
!
isStringNumber
(
argv
[
i
+
1
])))
{
printHelp
();
errorPrint
(
"%s"
,
"
\n\t
-l need a number following!
\n
"
);
exit
(
EXIT_FAILURE
);
}
arguments
->
num_of_CPR
=
atoi
(
argv
[
++
i
]);
arguments
->
num_of_CPR
=
atoi
(
argv
[
++
i
]);
}
else
if
(
strcmp
(
argv
[
i
],
"-b"
)
==
0
)
{
}
else
if
(
strcmp
(
argv
[
i
],
"-b"
)
==
0
)
{
sptr
=
arguments
->
datatype
;
sptr
=
arguments
->
datatype
;
...
@@ -755,7 +820,7 @@ static void parse_args(int argc, char *argv[], SArguments *arguments) {
...
@@ -755,7 +820,7 @@ static void parse_args(int argc, char *argv[], SArguments *arguments) {
&&
strcasecmp
(
argv
[
i
],
"BINARY"
)
&&
strcasecmp
(
argv
[
i
],
"BINARY"
)
&&
strcasecmp
(
argv
[
i
],
"NCHAR"
))
{
&&
strcasecmp
(
argv
[
i
],
"NCHAR"
))
{
printHelp
();
printHelp
();
ERROR_EXIT
(
"
Invalid data_type!
\n
"
);
errorPrint
(
"%s"
,
"-b:
Invalid data_type!
\n
"
);
exit
(
EXIT_FAILURE
);
exit
(
EXIT_FAILURE
);
}
}
sptr
[
0
]
=
argv
[
i
];
sptr
[
0
]
=
argv
[
i
];
...
@@ -777,7 +842,7 @@ static void parse_args(int argc, char *argv[], SArguments *arguments) {
...
@@ -777,7 +842,7 @@ static void parse_args(int argc, char *argv[], SArguments *arguments) {
&&
strcasecmp
(
token
,
"NCHAR"
))
{
&&
strcasecmp
(
token
,
"NCHAR"
))
{
printHelp
();
printHelp
();
free
(
dupstr
);
free
(
dupstr
);
ERROR_EXIT
(
"
Invalid data_type!
\n
"
);
errorPrint
(
"%s"
,
"-b:
Invalid data_type!
\n
"
);
exit
(
EXIT_FAILURE
);
exit
(
EXIT_FAILURE
);
}
}
sptr
[
index
++
]
=
token
;
sptr
[
index
++
]
=
token
;
...
@@ -788,6 +853,12 @@ static void parse_args(int argc, char *argv[], SArguments *arguments) {
...
@@ -788,6 +853,12 @@ static void parse_args(int argc, char *argv[], SArguments *arguments) {
sptr
[
index
]
=
NULL
;
sptr
[
index
]
=
NULL
;
}
}
}
else
if
(
strcmp
(
argv
[
i
],
"-w"
)
==
0
)
{
}
else
if
(
strcmp
(
argv
[
i
],
"-w"
)
==
0
)
{
if
((
argc
==
i
+
1
)
||
(
!
isStringNumber
(
argv
[
i
+
1
])))
{
printHelp
();
errorPrint
(
"%s"
,
"
\n\t
-w need a number following!
\n
"
);
exit
(
EXIT_FAILURE
);
}
arguments
->
len_of_binary
=
atoi
(
argv
[
++
i
]);
arguments
->
len_of_binary
=
atoi
(
argv
[
++
i
]);
}
else
if
(
strcmp
(
argv
[
i
],
"-m"
)
==
0
)
{
}
else
if
(
strcmp
(
argv
[
i
],
"-m"
)
==
0
)
{
arguments
->
tb_prefix
=
argv
[
++
i
];
arguments
->
tb_prefix
=
argv
[
++
i
];
...
@@ -804,22 +875,42 @@ static void parse_args(int argc, char *argv[], SArguments *arguments) {
...
@@ -804,22 +875,42 @@ static void parse_args(int argc, char *argv[], SArguments *arguments) {
}
else
if
(
strcmp
(
argv
[
i
],
"-pp"
)
==
0
)
{
}
else
if
(
strcmp
(
argv
[
i
],
"-pp"
)
==
0
)
{
arguments
->
performance_print
=
true
;
arguments
->
performance_print
=
true
;
}
else
if
(
strcmp
(
argv
[
i
],
"-O"
)
==
0
)
{
}
else
if
(
strcmp
(
argv
[
i
],
"-O"
)
==
0
)
{
if
((
argc
==
i
+
1
)
||
(
!
isStringNumber
(
argv
[
i
+
1
])))
{
printHelp
();
errorPrint
(
"%s"
,
"
\n\t
-O need a number following!
\n
"
);
exit
(
EXIT_FAILURE
);
}
arguments
->
disorderRatio
=
atoi
(
argv
[
++
i
]);
arguments
->
disorderRatio
=
atoi
(
argv
[
++
i
]);
if
(
arguments
->
disorderRatio
>
50
)
if
(
arguments
->
disorderRatio
>
50
)
{
arguments
->
disorderRatio
=
50
;
arguments
->
disorderRatio
=
50
;
}
if
(
arguments
->
disorderRatio
<
0
)
if
(
arguments
->
disorderRatio
<
0
)
{
arguments
->
disorderRatio
=
0
;
arguments
->
disorderRatio
=
0
;
}
}
else
if
(
strcmp
(
argv
[
i
],
"-R"
)
==
0
)
{
}
else
if
(
strcmp
(
argv
[
i
],
"-R"
)
==
0
)
{
if
((
argc
==
i
+
1
)
||
(
!
isStringNumber
(
argv
[
i
+
1
])))
{
printHelp
();
errorPrint
(
"%s"
,
"
\n\t
-R need a number following!
\n
"
);
exit
(
EXIT_FAILURE
);
}
arguments
->
disorderRange
=
atoi
(
argv
[
++
i
]);
arguments
->
disorderRange
=
atoi
(
argv
[
++
i
]);
if
(
arguments
->
disorderRange
<
0
)
if
(
arguments
->
disorderRange
<
0
)
arguments
->
disorderRange
=
1000
;
arguments
->
disorderRange
=
1000
;
}
else
if
(
strcmp
(
argv
[
i
],
"-a"
)
==
0
)
{
}
else
if
(
strcmp
(
argv
[
i
],
"-a"
)
==
0
)
{
if
((
argc
==
i
+
1
)
||
(
!
isStringNumber
(
argv
[
i
+
1
])))
{
printHelp
();
errorPrint
(
"%s"
,
"
\n\t
-a need a number following!
\n
"
);
exit
(
EXIT_FAILURE
);
}
arguments
->
replica
=
atoi
(
argv
[
++
i
]);
arguments
->
replica
=
atoi
(
argv
[
++
i
]);
if
(
arguments
->
replica
>
3
||
arguments
->
replica
<
1
)
{
if
(
arguments
->
replica
>
3
||
arguments
->
replica
<
1
)
{
arguments
->
replica
=
1
;
arguments
->
replica
=
1
;
...
@@ -839,7 +930,7 @@ static void parse_args(int argc, char *argv[], SArguments *arguments) {
...
@@ -839,7 +930,7 @@ static void parse_args(int argc, char *argv[], SArguments *arguments) {
exit
(
0
);
exit
(
0
);
}
else
{
}
else
{
printHelp
();
printHelp
();
ERROR_EXIT
(
"ERROR: wrong options
\n
"
);
errorPrint
(
"%s"
,
"ERROR: wrong options
\n
"
);
exit
(
EXIT_FAILURE
);
exit
(
EXIT_FAILURE
);
}
}
}
}
...
@@ -1003,17 +1094,6 @@ static void selectAndGetResult(TAOS *taos, char *command, char* resultFileName)
...
@@ -1003,17 +1094,6 @@ static void selectAndGetResult(TAOS *taos, char *command, char* resultFileName)
taos_free_result
(
res
);
taos_free_result
(
res
);
}
}
static
double
getCurrentTimeUs
()
{
struct
timeval
tv
;
if
(
gettimeofday
(
&
tv
,
NULL
)
!=
0
)
{
perror
(
"Failed to get current time in ms"
);
return
0
.
0
;
}
return
tv
.
tv_sec
+
tv
.
tv_usec
/
1E6
;
}
static
int32_t
rand_bool
(){
static
int32_t
rand_bool
(){
static
int
cursor
;
static
int
cursor
;
cursor
++
;
cursor
++
;
...
@@ -1470,8 +1550,8 @@ static void printfQueryMeta() {
...
@@ -1470,8 +1550,8 @@ static void printfQueryMeta() {
printf
(
"
\n
"
);
printf
(
"
\n
"
);
printf
(
"specified table query info:
\n
"
);
printf
(
"specified table query info:
\n
"
);
printf
(
"query interval:
\033
[33m%d
\033
[0m
\n
"
,
printf
(
"query interval:
\033
[33m%d
ms
\033
[0m
\n
"
,
g_queryInfo
.
specifiedQueryInfo
.
rate
);
g_queryInfo
.
specifiedQueryInfo
.
queryInterval
);
printf
(
"top query times:
\033
[33m%d
\033
[0m
\n
"
,
g_args
.
query_times
);
printf
(
"top query times:
\033
[33m%d
\033
[0m
\n
"
,
g_args
.
query_times
);
printf
(
"concurrent:
\033
[33m%d
\033
[0m
\n
"
,
printf
(
"concurrent:
\033
[33m%d
\033
[0m
\n
"
,
g_queryInfo
.
specifiedQueryInfo
.
concurrent
);
g_queryInfo
.
specifiedQueryInfo
.
concurrent
);
...
@@ -1499,7 +1579,7 @@ static void printfQueryMeta() {
...
@@ -1499,7 +1579,7 @@ static void printfQueryMeta() {
printf
(
"
\n
"
);
printf
(
"
\n
"
);
printf
(
"super table query info:
\n
"
);
printf
(
"super table query info:
\n
"
);
printf
(
"query interval:
\033
[33m%d
\033
[0m
\n
"
,
printf
(
"query interval:
\033
[33m%d
\033
[0m
\n
"
,
g_queryInfo
.
superQueryInfo
.
rate
);
g_queryInfo
.
superQueryInfo
.
queryInterval
);
printf
(
"threadCnt:
\033
[33m%d
\033
[0m
\n
"
,
printf
(
"threadCnt:
\033
[33m%d
\033
[0m
\n
"
,
g_queryInfo
.
superQueryInfo
.
threadCnt
);
g_queryInfo
.
superQueryInfo
.
threadCnt
);
printf
(
"childTblCount:
\033
[33m%d
\033
[0m
\n
"
,
printf
(
"childTblCount:
\033
[33m%d
\033
[0m
\n
"
,
...
@@ -1831,8 +1911,10 @@ static int postProceSql(char* host, uint16_t port, char* sqlstr)
...
@@ -1831,8 +1911,10 @@ static int postProceSql(char* host, uint16_t port, char* sqlstr)
int
req_buf_len
=
strlen
(
sqlstr
)
+
REQ_EXTRA_BUF_LEN
;
int
req_buf_len
=
strlen
(
sqlstr
)
+
REQ_EXTRA_BUF_LEN
;
request_buf
=
malloc
(
req_buf_len
);
request_buf
=
malloc
(
req_buf_len
);
if
(
NULL
==
request_buf
)
if
(
NULL
==
request_buf
)
{
ERROR_EXIT
(
"ERROR, cannot allocate memory."
);
errorPrint
(
"%s"
,
"ERROR, cannot allocate memory.
\n
"
);
exit
(
EXIT_FAILURE
);
}
char
userpass_buf
[
INPUT_BUF_LEN
];
char
userpass_buf
[
INPUT_BUF_LEN
];
int
mod_table
[]
=
{
0
,
2
,
1
};
int
mod_table
[]
=
{
0
,
2
,
1
};
...
@@ -3235,7 +3317,7 @@ static bool getMetaFromInsertJsonFile(cJSON* root) {
...
@@ -3235,7 +3317,7 @@ static bool getMetaFromInsertJsonFile(cJSON* root) {
if
(
maxSqlLen
&&
maxSqlLen
->
type
==
cJSON_Number
)
{
if
(
maxSqlLen
&&
maxSqlLen
->
type
==
cJSON_Number
)
{
g_args
.
max_sql_len
=
maxSqlLen
->
valueint
;
g_args
.
max_sql_len
=
maxSqlLen
->
valueint
;
}
else
if
(
!
maxSqlLen
)
{
}
else
if
(
!
maxSqlLen
)
{
g_args
.
max_sql_len
=
TSDB_PAYLOAD_SIZE
;
g_args
.
max_sql_len
=
1024000
;
}
else
{
}
else
{
errorPrint
(
"%s() LN%d, failed to read json, max_sql_len input mistake
\n
"
,
errorPrint
(
"%s() LN%d, failed to read json, max_sql_len input mistake
\n
"
,
__func__
,
__LINE__
);
__func__
,
__LINE__
);
...
@@ -3895,11 +3977,11 @@ static bool getMetaFromQueryJsonFile(cJSON* root) {
...
@@ -3895,11 +3977,11 @@ static bool getMetaFromQueryJsonFile(cJSON* root) {
printf
(
"ERROR: failed to read json, super_table_query not found
\n
"
);
printf
(
"ERROR: failed to read json, super_table_query not found
\n
"
);
goto
PARSE_OVER
;
goto
PARSE_OVER
;
}
else
{
}
else
{
cJSON
*
rate
=
cJSON_GetObjectItem
(
specifiedQuery
,
"query_interval"
);
cJSON
*
queryInterval
=
cJSON_GetObjectItem
(
specifiedQuery
,
"query_interval"
);
if
(
rate
&&
rate
->
type
==
cJSON_Number
)
{
if
(
queryInterval
&&
queryInterval
->
type
==
cJSON_Number
)
{
g_queryInfo
.
specifiedQueryInfo
.
rate
=
rate
->
valueint
;
g_queryInfo
.
specifiedQueryInfo
.
queryInterval
=
queryInterval
->
valueint
;
}
else
if
(
!
rate
)
{
}
else
if
(
!
queryInterval
)
{
g_queryInfo
.
specifiedQueryInfo
.
rate
=
0
;
g_queryInfo
.
specifiedQueryInfo
.
queryInterval
=
0
;
}
}
cJSON
*
specifiedQueryTimes
=
cJSON_GetObjectItem
(
specifiedQuery
,
cJSON
*
specifiedQueryTimes
=
cJSON_GetObjectItem
(
specifiedQuery
,
...
@@ -3927,12 +4009,12 @@ static bool getMetaFromQueryJsonFile(cJSON* root) {
...
@@ -3927,12 +4009,12 @@ static bool getMetaFromQueryJsonFile(cJSON* root) {
g_queryInfo
.
specifiedQueryInfo
.
concurrent
=
1
;
g_queryInfo
.
specifiedQueryInfo
.
concurrent
=
1
;
}
}
cJSON
*
queryM
ode
=
cJSON_GetObjectItem
(
specifiedQuery
,
"mode"
);
cJSON
*
m
ode
=
cJSON_GetObjectItem
(
specifiedQuery
,
"mode"
);
if
(
queryMode
&&
queryM
ode
->
type
==
cJSON_String
if
(
mode
&&
m
ode
->
type
==
cJSON_String
&&
queryM
ode
->
valuestring
!=
NULL
)
{
&&
m
ode
->
valuestring
!=
NULL
)
{
if
(
0
==
strcmp
(
"sync"
,
queryM
ode
->
valuestring
))
{
if
(
0
==
strcmp
(
"sync"
,
m
ode
->
valuestring
))
{
g_queryInfo
.
specifiedQueryInfo
.
mode
=
SYNC_QUERY_MODE
;
g_queryInfo
.
specifiedQueryInfo
.
mode
=
SYNC_QUERY_MODE
;
}
else
if
(
0
==
strcmp
(
"async"
,
queryM
ode
->
valuestring
))
{
}
else
if
(
0
==
strcmp
(
"async"
,
m
ode
->
valuestring
))
{
g_queryInfo
.
specifiedQueryInfo
.
mode
=
ASYNC_QUERY_MODE
;
g_queryInfo
.
specifiedQueryInfo
.
mode
=
ASYNC_QUERY_MODE
;
}
else
{
}
else
{
errorPrint
(
"%s() LN%d, failed to read json, query mode input error
\n
"
,
errorPrint
(
"%s() LN%d, failed to read json, query mode input error
\n
"
,
...
@@ -4035,9 +4117,9 @@ static bool getMetaFromQueryJsonFile(cJSON* root) {
...
@@ -4035,9 +4117,9 @@ static bool getMetaFromQueryJsonFile(cJSON* root) {
}
else
{
}
else
{
cJSON
*
subrate
=
cJSON_GetObjectItem
(
superQuery
,
"query_interval"
);
cJSON
*
subrate
=
cJSON_GetObjectItem
(
superQuery
,
"query_interval"
);
if
(
subrate
&&
subrate
->
type
==
cJSON_Number
)
{
if
(
subrate
&&
subrate
->
type
==
cJSON_Number
)
{
g_queryInfo
.
superQueryInfo
.
rate
=
subrate
->
valueint
;
g_queryInfo
.
superQueryInfo
.
queryInterval
=
subrate
->
valueint
;
}
else
if
(
!
subrate
)
{
}
else
if
(
!
subrate
)
{
g_queryInfo
.
superQueryInfo
.
rate
=
0
;
g_queryInfo
.
superQueryInfo
.
queryInterval
=
0
;
}
}
cJSON
*
superQueryTimes
=
cJSON_GetObjectItem
(
superQuery
,
"query_times"
);
cJSON
*
superQueryTimes
=
cJSON_GetObjectItem
(
superQuery
,
"query_times"
);
...
@@ -4839,7 +4921,7 @@ static void* syncWriteInterlace(threadInfo *pThreadInfo) {
...
@@ -4839,7 +4921,7 @@ static void* syncWriteInterlace(threadInfo *pThreadInfo) {
uint64_t
et
=
0xffffffff
;
uint64_t
et
=
0xffffffff
;
int64_t
lastPrintTime
=
taosGetTimestampMs
();
int64_t
lastPrintTime
=
taosGetTimestampMs
();
int64_t
startTs
=
taosGetTimestamp
U
s
();
int64_t
startTs
=
taosGetTimestamp
M
s
();
int64_t
endTs
;
int64_t
endTs
;
int
tableSeq
=
pThreadInfo
->
start_table_from
;
int
tableSeq
=
pThreadInfo
->
start_table_from
;
...
@@ -4871,7 +4953,7 @@ static void* syncWriteInterlace(threadInfo *pThreadInfo) {
...
@@ -4871,7 +4953,7 @@ static void* syncWriteInterlace(threadInfo *pThreadInfo) {
while
(
pThreadInfo
->
totalInsertRows
<
pThreadInfo
->
ntables
*
insertRows
)
{
while
(
pThreadInfo
->
totalInsertRows
<
pThreadInfo
->
ntables
*
insertRows
)
{
if
((
flagSleep
)
&&
(
insert_interval
))
{
if
((
flagSleep
)
&&
(
insert_interval
))
{
st
=
taosGetTimestamp
U
s
();
st
=
taosGetTimestamp
M
s
();
flagSleep
=
false
;
flagSleep
=
false
;
}
}
// generate data
// generate data
...
@@ -4957,14 +5039,14 @@ static void* syncWriteInterlace(threadInfo *pThreadInfo) {
...
@@ -4957,14 +5039,14 @@ static void* syncWriteInterlace(threadInfo *pThreadInfo) {
verbosePrint
(
"[%d] %s() LN%d, buffer=%s
\n
"
,
verbosePrint
(
"[%d] %s() LN%d, buffer=%s
\n
"
,
pThreadInfo
->
threadID
,
__func__
,
__LINE__
,
buffer
);
pThreadInfo
->
threadID
,
__func__
,
__LINE__
,
buffer
);
startTs
=
taosGetTimestamp
U
s
();
startTs
=
taosGetTimestamp
M
s
();
int
affectedRows
=
execInsert
(
pThreadInfo
,
buffer
,
recOfBatch
);
int
affectedRows
=
execInsert
(
pThreadInfo
,
buffer
,
recOfBatch
);
endTs
=
taosGetTimestamp
U
s
();
endTs
=
taosGetTimestamp
M
s
();
int64_t
delay
=
endTs
-
startTs
;
int64_t
delay
=
endTs
-
startTs
;
performancePrint
(
"%s() LN%d, insert execution time is %
10.6f
ms
\n
"
,
performancePrint
(
"%s() LN%d, insert execution time is %
"
PRId64
"
ms
\n
"
,
__func__
,
__LINE__
,
delay
/
1000
.
0
);
__func__
,
__LINE__
,
delay
);
if
(
delay
>
pThreadInfo
->
maxDelay
)
pThreadInfo
->
maxDelay
=
delay
;
if
(
delay
>
pThreadInfo
->
maxDelay
)
pThreadInfo
->
maxDelay
=
delay
;
if
(
delay
<
pThreadInfo
->
minDelay
)
pThreadInfo
->
minDelay
=
delay
;
if
(
delay
<
pThreadInfo
->
minDelay
)
pThreadInfo
->
minDelay
=
delay
;
...
@@ -4992,10 +5074,10 @@ static void* syncWriteInterlace(threadInfo *pThreadInfo) {
...
@@ -4992,10 +5074,10 @@ static void* syncWriteInterlace(threadInfo *pThreadInfo) {
}
}
if
((
insert_interval
)
&&
flagSleep
)
{
if
((
insert_interval
)
&&
flagSleep
)
{
et
=
taosGetTimestamp
U
s
();
et
=
taosGetTimestamp
M
s
();
if
(
insert_interval
>
(
(
et
-
st
)
/
1000
)
)
{
if
(
insert_interval
>
(
et
-
st
)
)
{
int
sleepTime
=
insert_interval
-
(
et
-
st
)
/
1000
;
int
sleepTime
=
insert_interval
-
(
et
-
st
);
performancePrint
(
"%s() LN%d sleep: %d ms for insert interval
\n
"
,
performancePrint
(
"%s() LN%d sleep: %d ms for insert interval
\n
"
,
__func__
,
__LINE__
,
sleepTime
);
__func__
,
__LINE__
,
sleepTime
);
taosMsleep
(
sleepTime
);
// ms
taosMsleep
(
sleepTime
);
// ms
...
@@ -5037,7 +5119,7 @@ static void* syncWriteProgressive(threadInfo *pThreadInfo) {
...
@@ -5037,7 +5119,7 @@ static void* syncWriteProgressive(threadInfo *pThreadInfo) {
}
}
int64_t
lastPrintTime
=
taosGetTimestampMs
();
int64_t
lastPrintTime
=
taosGetTimestampMs
();
int64_t
startTs
=
taosGetTimestamp
U
s
();
int64_t
startTs
=
taosGetTimestamp
M
s
();
int64_t
endTs
;
int64_t
endTs
;
int
timeStampStep
=
int
timeStampStep
=
...
@@ -5064,7 +5146,7 @@ static void* syncWriteProgressive(threadInfo *pThreadInfo) {
...
@@ -5064,7 +5146,7 @@ static void* syncWriteProgressive(threadInfo *pThreadInfo) {
for
(
int64_t
i
=
0
;
i
<
insertRows
;)
{
for
(
int64_t
i
=
0
;
i
<
insertRows
;)
{
/*
/*
if (insert_interval) {
if (insert_interval) {
st = taosGetTimestamp
U
s();
st = taosGetTimestamp
M
s();
}
}
*/
*/
...
@@ -5096,14 +5178,14 @@ static void* syncWriteProgressive(threadInfo *pThreadInfo) {
...
@@ -5096,14 +5178,14 @@ static void* syncWriteProgressive(threadInfo *pThreadInfo) {
start_time
+=
generated
*
timeStampStep
;
start_time
+=
generated
*
timeStampStep
;
pThreadInfo
->
totalInsertRows
+=
generated
;
pThreadInfo
->
totalInsertRows
+=
generated
;
startTs
=
taosGetTimestamp
U
s
();
startTs
=
taosGetTimestamp
M
s
();
int
affectedRows
=
execInsert
(
pThreadInfo
,
buffer
,
generated
);
int
affectedRows
=
execInsert
(
pThreadInfo
,
buffer
,
generated
);
endTs
=
taosGetTimestamp
U
s
();
endTs
=
taosGetTimestamp
M
s
();
int64_t
delay
=
endTs
-
startTs
;
int64_t
delay
=
endTs
-
startTs
;
performancePrint
(
"%s() LN%d, insert execution time is %
10.6f
ms
\n
"
,
performancePrint
(
"%s() LN%d, insert execution time is %
"
PRId64
"
ms
\n
"
,
__func__
,
__LINE__
,
delay
/
1000
.
0
);
__func__
,
__LINE__
,
delay
);
if
(
delay
>
pThreadInfo
->
maxDelay
)
pThreadInfo
->
maxDelay
=
delay
;
if
(
delay
>
pThreadInfo
->
maxDelay
)
pThreadInfo
->
maxDelay
=
delay
;
if
(
delay
<
pThreadInfo
->
minDelay
)
pThreadInfo
->
minDelay
=
delay
;
if
(
delay
<
pThreadInfo
->
minDelay
)
pThreadInfo
->
minDelay
=
delay
;
...
@@ -5128,10 +5210,10 @@ static void* syncWriteProgressive(threadInfo *pThreadInfo) {
...
@@ -5128,10 +5210,10 @@ static void* syncWriteProgressive(threadInfo *pThreadInfo) {
break
;
break
;
/*
/*
if (insert_interval) {
if (insert_interval) {
et = taosGetTimestamp
U
s();
et = taosGetTimestamp
M
s();
if (insert_interval > ((et - st)
/1000
) ) {
if (insert_interval > ((et - st)) ) {
int sleep_time = insert_interval - (et -st)
/1000
;
int sleep_time = insert_interval - (et -st);
performancePrint("%s() LN%d sleep: %d ms for insert interval\n",
performancePrint("%s() LN%d sleep: %d ms for insert interval\n",
__func__, __LINE__, sleep_time);
__func__, __LINE__, sleep_time);
taosMsleep(sleep_time); // ms
taosMsleep(sleep_time); // ms
...
@@ -5183,9 +5265,9 @@ static void callBack(void *param, TAOS_RES *res, int code) {
...
@@ -5183,9 +5265,9 @@ static void callBack(void *param, TAOS_RES *res, int code) {
int
insert_interval
=
int
insert_interval
=
superTblInfo
?
superTblInfo
->
insertInterval
:
g_args
.
insert_interval
;
superTblInfo
?
superTblInfo
->
insertInterval
:
g_args
.
insert_interval
;
if
(
insert_interval
)
{
if
(
insert_interval
)
{
pThreadInfo
->
et
=
taosGetTimestamp
U
s
();
pThreadInfo
->
et
=
taosGetTimestamp
M
s
();
if
((
(
pThreadInfo
->
et
-
pThreadInfo
->
st
)
/
1000
)
<
insert_interval
)
{
if
((
pThreadInfo
->
et
-
pThreadInfo
->
st
)
<
insert_interval
)
{
taosMsleep
(
insert_interval
-
(
pThreadInfo
->
et
-
pThreadInfo
->
st
)
/
1000
);
// ms
taosMsleep
(
insert_interval
-
(
pThreadInfo
->
et
-
pThreadInfo
->
st
));
// ms
}
}
}
}
...
@@ -5224,7 +5306,7 @@ static void callBack(void *param, TAOS_RES *res, int code) {
...
@@ -5224,7 +5306,7 @@ static void callBack(void *param, TAOS_RES *res, int code) {
}
}
if
(
insert_interval
)
{
if
(
insert_interval
)
{
pThreadInfo
->
st
=
taosGetTimestamp
U
s
();
pThreadInfo
->
st
=
taosGetTimestamp
M
s
();
}
}
taos_query_a
(
pThreadInfo
->
taos
,
buffer
,
callBack
,
pThreadInfo
);
taos_query_a
(
pThreadInfo
->
taos
,
buffer
,
callBack
,
pThreadInfo
);
free
(
buffer
);
free
(
buffer
);
...
@@ -5243,7 +5325,7 @@ static void *asyncWrite(void *sarg) {
...
@@ -5243,7 +5325,7 @@ static void *asyncWrite(void *sarg) {
int
insert_interval
=
int
insert_interval
=
superTblInfo
?
superTblInfo
->
insertInterval
:
g_args
.
insert_interval
;
superTblInfo
?
superTblInfo
->
insertInterval
:
g_args
.
insert_interval
;
if
(
insert_interval
)
{
if
(
insert_interval
)
{
pThreadInfo
->
st
=
taosGetTimestamp
U
s
();
pThreadInfo
->
st
=
taosGetTimestamp
M
s
();
}
}
taos_query_a
(
pThreadInfo
->
taos
,
"show databases"
,
callBack
,
pThreadInfo
);
taos_query_a
(
pThreadInfo
->
taos
,
"show databases"
,
callBack
,
pThreadInfo
);
...
@@ -5302,7 +5384,7 @@ static void startMultiThreadInsertData(int threads, char* db_name,
...
@@ -5302,7 +5384,7 @@ static void startMultiThreadInsertData(int threads, char* db_name,
start_time
=
1500000000000
;
start_time
=
1500000000000
;
}
}
double
start
=
getCurrentTimeU
s
();
int64_t
start
=
taosGetTimestampM
s
();
// read sample data from file first
// read sample data from file first
if
((
superTblInfo
)
&&
(
0
==
strncasecmp
(
superTblInfo
->
dataSource
,
if
((
superTblInfo
)
&&
(
0
==
strncasecmp
(
superTblInfo
->
dataSource
,
...
@@ -5499,39 +5581,39 @@ static void startMultiThreadInsertData(int threads, char* db_name,
...
@@ -5499,39 +5581,39 @@ static void startMultiThreadInsertData(int threads, char* db_name,
if
(
cntDelay
==
0
)
cntDelay
=
1
;
if
(
cntDelay
==
0
)
cntDelay
=
1
;
avgDelay
=
(
double
)
totalDelay
/
cntDelay
;
avgDelay
=
(
double
)
totalDelay
/
cntDelay
;
double
end
=
getCurrentTimeU
s
();
int64_t
end
=
taosGetTimestampM
s
();
double
t
=
end
-
start
;
int64_t
t
=
end
-
start
;
if
(
superTblInfo
)
{
if
(
superTblInfo
)
{
printf
(
"Spent %.
4
f seconds to insert rows: %"
PRId64
", affected rows: %"
PRId64
" with %d thread(s) into %s.%s. %2.f records/second
\n\n
"
,
printf
(
"Spent %.
2
f seconds to insert rows: %"
PRId64
", affected rows: %"
PRId64
" with %d thread(s) into %s.%s. %2.f records/second
\n\n
"
,
t
,
superTblInfo
->
totalInsertRows
,
t
/
1000
.
0
,
superTblInfo
->
totalInsertRows
,
superTblInfo
->
totalAffectedRows
,
superTblInfo
->
totalAffectedRows
,
threads
,
db_name
,
superTblInfo
->
sTblName
,
threads
,
db_name
,
superTblInfo
->
sTblName
,
superTblInfo
->
totalInsertRows
/
t
);
(
double
)
superTblInfo
->
totalInsertRows
/
(
t
/
1000
.
0
)
);
fprintf
(
g_fpOfInsertResult
,
fprintf
(
g_fpOfInsertResult
,
"Spent %.
4
f seconds to insert rows: %"
PRId64
", affected rows: %"
PRId64
" with %d thread(s) into %s.%s. %2.f records/second
\n\n
"
,
"Spent %.
2
f seconds to insert rows: %"
PRId64
", affected rows: %"
PRId64
" with %d thread(s) into %s.%s. %2.f records/second
\n\n
"
,
t
,
superTblInfo
->
totalInsertRows
,
t
/
1000
.
0
,
superTblInfo
->
totalInsertRows
,
superTblInfo
->
totalAffectedRows
,
superTblInfo
->
totalAffectedRows
,
threads
,
db_name
,
superTblInfo
->
sTblName
,
threads
,
db_name
,
superTblInfo
->
sTblName
,
superTblInfo
->
totalInsertRows
/
t
);
(
double
)
superTblInfo
->
totalInsertRows
/
(
t
/
1000
.
0
)
);
}
else
{
}
else
{
printf
(
"Spent %.
4
f seconds to insert rows: %"
PRId64
", affected rows: %"
PRId64
" with %d thread(s) into %s %2.f records/second
\n\n
"
,
printf
(
"Spent %.
2
f seconds to insert rows: %"
PRId64
", affected rows: %"
PRId64
" with %d thread(s) into %s %2.f records/second
\n\n
"
,
t
,
g_args
.
totalInsertRows
,
t
/
1000
.
0
,
g_args
.
totalInsertRows
,
g_args
.
totalAffectedRows
,
g_args
.
totalAffectedRows
,
threads
,
db_name
,
threads
,
db_name
,
g_args
.
totalInsertRows
/
t
);
(
double
)
g_args
.
totalInsertRows
/
(
t
/
1000
.
0
)
);
fprintf
(
g_fpOfInsertResult
,
fprintf
(
g_fpOfInsertResult
,
"Spent %.
4
f seconds to insert rows: %"
PRId64
", affected rows: %"
PRId64
" with %d thread(s) into %s %2.f records/second
\n\n
"
,
"Spent %.
2
f seconds to insert rows: %"
PRId64
", affected rows: %"
PRId64
" with %d thread(s) into %s %2.f records/second
\n\n
"
,
t
,
g_args
.
totalInsertRows
,
t
*
1000
.
0
,
g_args
.
totalInsertRows
,
g_args
.
totalAffectedRows
,
g_args
.
totalAffectedRows
,
threads
,
db_name
,
threads
,
db_name
,
g_args
.
totalInsertRows
/
t
);
(
double
)
g_args
.
totalInsertRows
/
(
t
/
1000
.
0
)
);
}
}
printf
(
"insert delay, avg: %10.
6fms, max: %10.6fms, min: %10.6f
ms
\n\n
"
,
printf
(
"insert delay, avg: %10.
2fms, max: %"
PRId64
"ms, min: %"
PRId64
"
ms
\n\n
"
,
avgDelay
/
1000
.
0
,
(
double
)
maxDelay
/
1000
.
0
,
(
double
)
minDelay
/
1000
.
0
);
avgDelay
,
maxDelay
,
minDelay
);
fprintf
(
g_fpOfInsertResult
,
"insert delay, avg:%10.
6fms, max: %10.6fms, min: %10.6f
ms
\n\n
"
,
fprintf
(
g_fpOfInsertResult
,
"insert delay, avg:%10.
2fms, max: %"
PRId64
"ms, min: %"
PRId64
"
ms
\n\n
"
,
avgDelay
/
1000
.
0
,
(
double
)
maxDelay
/
1000
.
0
,
(
double
)
minDelay
/
1000
.
0
);
avgDelay
,
maxDelay
,
minDelay
);
//taos_close(taos);
//taos_close(taos);
...
@@ -5578,7 +5660,7 @@ static void *readTable(void *sarg) {
...
@@ -5578,7 +5660,7 @@ static void *readTable(void *sarg) {
sprintf
(
command
,
"select %s from %s%d where ts>= %"
PRId64
,
sprintf
(
command
,
"select %s from %s%d where ts>= %"
PRId64
,
aggreFunc
[
j
],
tb_prefix
,
i
,
sTime
);
aggreFunc
[
j
],
tb_prefix
,
i
,
sTime
);
double
t
=
getCurrentTimeU
s
();
double
t
=
taosGetTimestampM
s
();
TAOS_RES
*
pSql
=
taos_query
(
taos
,
command
);
TAOS_RES
*
pSql
=
taos_query
(
taos
,
command
);
int32_t
code
=
taos_errno
(
pSql
);
int32_t
code
=
taos_errno
(
pSql
);
...
@@ -5594,7 +5676,7 @@ static void *readTable(void *sarg) {
...
@@ -5594,7 +5676,7 @@ static void *readTable(void *sarg) {
count
++
;
count
++
;
}
}
t
=
getCurrentTimeU
s
()
-
t
;
t
=
taosGetTimestampM
s
()
-
t
;
totalT
+=
t
;
totalT
+=
t
;
taos_free_result
(
pSql
);
taos_free_result
(
pSql
);
...
@@ -5603,7 +5685,7 @@ static void *readTable(void *sarg) {
...
@@ -5603,7 +5685,7 @@ static void *readTable(void *sarg) {
fprintf
(
fp
,
"|%10s | %10d | %12.2f | %10.2f |
\n
"
,
fprintf
(
fp
,
"|%10s | %10d | %12.2f | %10.2f |
\n
"
,
aggreFunc
[
j
][
0
]
==
'*'
?
" * "
:
aggreFunc
[
j
],
totalData
,
aggreFunc
[
j
][
0
]
==
'*'
?
" * "
:
aggreFunc
[
j
],
totalData
,
(
double
)(
num_of_tables
*
num_of_DPT
)
/
totalT
,
totalT
*
1000
);
(
double
)(
num_of_tables
*
num_of_DPT
)
/
totalT
,
totalT
*
1000
);
printf
(
"select %10s took %.6f second(s)
\n
"
,
aggreFunc
[
j
],
totalT
);
printf
(
"select %10s took %.6f second(s)
\n
"
,
aggreFunc
[
j
],
totalT
*
1000
);
}
}
fprintf
(
fp
,
"
\n
"
);
fprintf
(
fp
,
"
\n
"
);
fclose
(
fp
);
fclose
(
fp
);
...
@@ -5653,7 +5735,7 @@ static void *readMetric(void *sarg) {
...
@@ -5653,7 +5735,7 @@ static void *readMetric(void *sarg) {
printf
(
"Where condition: %s
\n
"
,
condition
);
printf
(
"Where condition: %s
\n
"
,
condition
);
fprintf
(
fp
,
"%s
\n
"
,
command
);
fprintf
(
fp
,
"%s
\n
"
,
command
);
double
t
=
getCurrentTimeU
s
();
double
t
=
taosGetTimestampM
s
();
TAOS_RES
*
pSql
=
taos_query
(
taos
,
command
);
TAOS_RES
*
pSql
=
taos_query
(
taos
,
command
);
int32_t
code
=
taos_errno
(
pSql
);
int32_t
code
=
taos_errno
(
pSql
);
...
@@ -5669,11 +5751,11 @@ static void *readMetric(void *sarg) {
...
@@ -5669,11 +5751,11 @@ static void *readMetric(void *sarg) {
while
(
taos_fetch_row
(
pSql
)
!=
NULL
)
{
while
(
taos_fetch_row
(
pSql
)
!=
NULL
)
{
count
++
;
count
++
;
}
}
t
=
getCurrentTimeU
s
()
-
t
;
t
=
taosGetTimestampM
s
()
-
t
;
fprintf
(
fp
,
"| Speed: %12.2f(per s) | Latency: %.4f(ms) |
\n
"
,
fprintf
(
fp
,
"| Speed: %12.2f(per s) | Latency: %.4f(ms) |
\n
"
,
num_of_tables
*
num_of_DPT
/
t
,
t
*
1000
);
num_of_tables
*
num_of_DPT
/
(
t
*
1000
.
0
),
t
);
printf
(
"select %10s took %.6f second(s)
\n\n
"
,
aggreFunc
[
j
],
t
);
printf
(
"select %10s took %.6f second(s)
\n\n
"
,
aggreFunc
[
j
],
t
*
1000
.
0
);
taos_free_result
(
pSql
);
taos_free_result
(
pSql
);
}
}
...
@@ -5723,21 +5805,21 @@ static int insertTestProcess() {
...
@@ -5723,21 +5805,21 @@ static int insertTestProcess() {
double
end
;
double
end
;
// create child tables
// create child tables
start
=
getCurrentTimeU
s
();
start
=
taosGetTimestampM
s
();
createChildTables
();
createChildTables
();
end
=
getCurrentTimeU
s
();
end
=
taosGetTimestampM
s
();
if
(
g_totalChildTables
>
0
)
{
if
(
g_totalChildTables
>
0
)
{
printf
(
"Spent %.4f seconds to create %d tables with %d thread(s)
\n\n
"
,
printf
(
"Spent %.4f seconds to create %d tables with %d thread(s)
\n\n
"
,
end
-
start
,
g_totalChildTables
,
g_Dbs
.
threadCountByCreateTbl
);
(
end
-
start
)
/
1000
.
0
,
g_totalChildTables
,
g_Dbs
.
threadCountByCreateTbl
);
fprintf
(
g_fpOfInsertResult
,
fprintf
(
g_fpOfInsertResult
,
"Spent %.4f seconds to create %d tables with %d thread(s)
\n\n
"
,
"Spent %.4f seconds to create %d tables with %d thread(s)
\n\n
"
,
end
-
start
,
g_totalChildTables
,
g_Dbs
.
threadCountByCreateTbl
);
(
end
-
start
)
/
1000
.
0
,
g_totalChildTables
,
g_Dbs
.
threadCountByCreateTbl
);
}
}
taosMsleep
(
1000
);
taosMsleep
(
1000
);
// create sub threads for inserting data
// create sub threads for inserting data
//start =
getCurrentTimeU
s();
//start =
taosGetTimestampM
s();
for
(
int
i
=
0
;
i
<
g_Dbs
.
dbCount
;
i
++
)
{
for
(
int
i
=
0
;
i
<
g_Dbs
.
dbCount
;
i
++
)
{
if
(
g_Dbs
.
use_metric
)
{
if
(
g_Dbs
.
use_metric
)
{
if
(
g_Dbs
.
db
[
i
].
superTblCount
>
0
)
{
if
(
g_Dbs
.
db
[
i
].
superTblCount
>
0
)
{
...
@@ -5762,7 +5844,7 @@ static int insertTestProcess() {
...
@@ -5762,7 +5844,7 @@ static int insertTestProcess() {
NULL
);
NULL
);
}
}
}
}
//end =
getCurrentTimeU
s();
//end =
taosGetTimestampM
s();
//int64_t totalInsertRows = 0;
//int64_t totalInsertRows = 0;
//int64_t totalAffectedRows = 0;
//int64_t totalAffectedRows = 0;
...
@@ -5815,16 +5897,15 @@ static void *specifiedTableQuery(void *sarg) {
...
@@ -5815,16 +5897,15 @@ static void *specifiedTableQuery(void *sarg) {
int64_t
startTs
=
taosGetTimestampMs
();
int64_t
startTs
=
taosGetTimestampMs
();
while
(
queryTimes
--
)
{
while
(
queryTimes
--
)
{
if
(
g_queryInfo
.
specifiedQueryInfo
.
rate
&&
(
et
-
st
)
<
if
(
g_queryInfo
.
specifiedQueryInfo
.
queryInterval
&&
(
et
-
st
)
<
(
int64_t
)
g_queryInfo
.
specifiedQueryInfo
.
rate
*
1000
)
{
(
int64_t
)
g_queryInfo
.
specifiedQueryInfo
.
queryInterval
)
{
taosMsleep
(
g_queryInfo
.
specifiedQueryInfo
.
rate
*
1000
-
(
et
-
st
));
// ms
taosMsleep
(
g_queryInfo
.
specifiedQueryInfo
.
queryInterval
-
(
et
-
st
));
// ms
//printf("========sleep duration:%"PRId64 "========inserted rows:%d, table range:%d - %d\n", (1000 - (et - st)), i, pThreadInfo->start_table_from, pThreadInfo->end_table_to);
}
}
st
=
taosGetTimestamp
U
s
();
st
=
taosGetTimestamp
M
s
();
if
(
0
==
strncasecmp
(
g_queryInfo
.
queryMode
,
"taosc"
,
5
))
{
if
(
0
==
strncasecmp
(
g_queryInfo
.
queryMode
,
"taosc"
,
5
))
{
int64_t
t1
=
taosGetTimestamp
U
s
();
int64_t
t1
=
taosGetTimestamp
M
s
();
char
tmpFile
[
MAX_FILE_NAME_LEN
*
2
]
=
{
0
};
char
tmpFile
[
MAX_FILE_NAME_LEN
*
2
]
=
{
0
};
if
(
g_queryInfo
.
specifiedQueryInfo
.
result
[
pThreadInfo
->
querySeq
][
0
]
!=
0
)
{
if
(
g_queryInfo
.
specifiedQueryInfo
.
result
[
pThreadInfo
->
querySeq
][
0
]
!=
0
)
{
sprintf
(
tmpFile
,
"%s-%d"
,
sprintf
(
tmpFile
,
"%s-%d"
,
...
@@ -5833,11 +5914,11 @@ static void *specifiedTableQuery(void *sarg) {
...
@@ -5833,11 +5914,11 @@ static void *specifiedTableQuery(void *sarg) {
}
}
selectAndGetResult
(
pThreadInfo
->
taos
,
selectAndGetResult
(
pThreadInfo
->
taos
,
g_queryInfo
.
specifiedQueryInfo
.
sql
[
pThreadInfo
->
querySeq
],
tmpFile
);
g_queryInfo
.
specifiedQueryInfo
.
sql
[
pThreadInfo
->
querySeq
],
tmpFile
);
int64_t
t2
=
taosGetTimestamp
U
s
();
int64_t
t2
=
taosGetTimestamp
M
s
();
printf
(
"=[taosc] thread[%"
PRId64
"] complete one sql, Spent %f s
\n
"
,
printf
(
"=[taosc] thread[%"
PRId64
"] complete one sql, Spent %
10.3
f s
\n
"
,
taosGetSelfPthreadId
(),
(
t2
-
t1
)
/
1000
000
.
0
);
taosGetSelfPthreadId
(),
(
t2
-
t1
)
/
1000
.
0
);
}
else
{
}
else
{
int64_t
t1
=
taosGetTimestamp
U
s
();
int64_t
t1
=
taosGetTimestamp
M
s
();
int
retCode
=
postProceSql
(
g_queryInfo
.
host
,
int
retCode
=
postProceSql
(
g_queryInfo
.
host
,
g_queryInfo
.
port
,
g_queryInfo
.
port
,
g_queryInfo
.
specifiedQueryInfo
.
sql
[
pThreadInfo
->
querySeq
]);
g_queryInfo
.
specifiedQueryInfo
.
sql
[
pThreadInfo
->
querySeq
]);
...
@@ -5845,25 +5926,25 @@ static void *specifiedTableQuery(void *sarg) {
...
@@ -5845,25 +5926,25 @@ static void *specifiedTableQuery(void *sarg) {
printf
(
"====restful return fail, threadID[%d]
\n
"
,
pThreadInfo
->
threadID
);
printf
(
"====restful return fail, threadID[%d]
\n
"
,
pThreadInfo
->
threadID
);
return
NULL
;
return
NULL
;
}
}
int64_t
t2
=
taosGetTimestamp
U
s
();
int64_t
t2
=
taosGetTimestamp
M
s
();
printf
(
"=[restful] thread[%"
PRId64
"] complete one sql, Spent %f s
\n
"
,
printf
(
"=[restful] thread[%"
PRId64
"] complete one sql, Spent %
10.3
f s
\n
"
,
taosGetSelfPthreadId
(),
(
t2
-
t1
)
/
1000
000
.
0
);
taosGetSelfPthreadId
(),
(
t2
-
t1
)
/
1000
.
0
);
}
}
totalQueried
++
;
totalQueried
++
;
g_queryInfo
.
specifiedQueryInfo
.
totalQueried
++
;
g_queryInfo
.
specifiedQueryInfo
.
totalQueried
++
;
et
=
taosGetTimestampUs
();
et
=
taosGetTimestampMs
();
printf
(
"==thread[%"
PRId64
"] complete all sqls to specify tables once queries duration:%.6fs
\n\n
"
,
taosGetSelfPthreadId
(),
(
double
)(
et
-
st
)
/
1000
.
0
);
int64_t
currentPrintTime
=
taosGetTimestampMs
();
int64_t
currentPrintTime
=
taosGetTimestampMs
();
int64_t
endTs
=
taosGetTimestampMs
();
int64_t
endTs
=
taosGetTimestampMs
();
if
(
currentPrintTime
-
lastPrintTime
>
30
*
1000
)
{
if
(
currentPrintTime
-
lastPrintTime
>
30
*
1000
)
{
printf
(
"thread[%d] has currently completed queries: %d, QPS: %10.2f
\n
"
,
debugPrint
(
"%s() LN%d, endTs=%"
PRId64
"ms, startTs=%"
PRId64
"ms
\n
"
,
__func__
,
__LINE__
,
endTs
,
startTs
);
printf
(
"thread[%d] has currently completed queries: %d, QPS: %10.6f
\n
"
,
pThreadInfo
->
threadID
,
pThreadInfo
->
threadID
,
totalQueried
,
totalQueried
,
totalQueried
/
((
endTs
-
startTs
)
/
1000
.
0
));
(
double
)(
totalQueried
/
((
endTs
-
startTs
)
/
1000
.
0
)
));
}
}
lastPrintTime
=
currentPrintTime
;
lastPrintTime
=
currentPrintTime
;
}
}
...
@@ -5913,7 +5994,7 @@ static void *superTableQuery(void *sarg) {
...
@@ -5913,7 +5994,7 @@ static void *superTableQuery(void *sarg) {
}
}
int64_t
st
=
0
;
int64_t
st
=
0
;
int64_t
et
=
(
int64_t
)
g_queryInfo
.
superQueryInfo
.
rate
*
1000
;
int64_t
et
=
(
int64_t
)
g_queryInfo
.
superQueryInfo
.
queryInterval
;
int
queryTimes
=
g_queryInfo
.
superQueryInfo
.
queryTimes
;
int
queryTimes
=
g_queryInfo
.
superQueryInfo
.
queryTimes
;
int
totalQueried
=
0
;
int
totalQueried
=
0
;
...
@@ -5921,13 +6002,13 @@ static void *superTableQuery(void *sarg) {
...
@@ -5921,13 +6002,13 @@ static void *superTableQuery(void *sarg) {
int64_t
lastPrintTime
=
taosGetTimestampMs
();
int64_t
lastPrintTime
=
taosGetTimestampMs
();
while
(
queryTimes
--
)
{
while
(
queryTimes
--
)
{
if
(
g_queryInfo
.
superQueryInfo
.
rate
if
(
g_queryInfo
.
superQueryInfo
.
queryInterval
&&
(
et
-
st
)
<
(
int64_t
)
g_queryInfo
.
superQueryInfo
.
rate
*
1000
)
{
&&
(
et
-
st
)
<
(
int64_t
)
g_queryInfo
.
superQueryInfo
.
queryInterval
)
{
taosMsleep
(
g_queryInfo
.
superQueryInfo
.
rate
*
1000
-
(
et
-
st
));
// ms
taosMsleep
(
g_queryInfo
.
superQueryInfo
.
queryInterval
-
(
et
-
st
));
// ms
//printf("========sleep duration:%"PRId64 "========inserted rows:%d, table range:%d - %d\n", (1000 - (et - st)), i, pThreadInfo->start_table_from, pThreadInfo->end_table_to);
//printf("========sleep duration:%"PRId64 "========inserted rows:%d, table range:%d - %d\n", (1000 - (et - st)), i, pThreadInfo->start_table_from, pThreadInfo->end_table_to);
}
}
st
=
taosGetTimestamp
U
s
();
st
=
taosGetTimestamp
M
s
();
for
(
int
i
=
pThreadInfo
->
start_table_from
;
i
<=
pThreadInfo
->
end_table_to
;
i
++
)
{
for
(
int
i
=
pThreadInfo
->
start_table_from
;
i
<=
pThreadInfo
->
end_table_to
;
i
++
)
{
for
(
int
j
=
0
;
j
<
g_queryInfo
.
superQueryInfo
.
sqlCount
;
j
++
)
{
for
(
int
j
=
0
;
j
<
g_queryInfo
.
superQueryInfo
.
sqlCount
;
j
++
)
{
memset
(
sqlstr
,
0
,
sizeof
(
sqlstr
));
memset
(
sqlstr
,
0
,
sizeof
(
sqlstr
));
...
@@ -5946,20 +6027,20 @@ static void *superTableQuery(void *sarg) {
...
@@ -5946,20 +6027,20 @@ static void *superTableQuery(void *sarg) {
int64_t
currentPrintTime
=
taosGetTimestampMs
();
int64_t
currentPrintTime
=
taosGetTimestampMs
();
int64_t
endTs
=
taosGetTimestampMs
();
int64_t
endTs
=
taosGetTimestampMs
();
if
(
currentPrintTime
-
lastPrintTime
>
30
*
1000
)
{
if
(
currentPrintTime
-
lastPrintTime
>
30
*
1000
)
{
printf
(
"thread[%d] has currently completed queries: %d, QPS: %10.
2
f
\n
"
,
printf
(
"thread[%d] has currently completed queries: %d, QPS: %10.
3
f
\n
"
,
pThreadInfo
->
threadID
,
pThreadInfo
->
threadID
,
totalQueried
,
totalQueried
,
totalQueried
/
((
endTs
-
startTs
)
/
1000
.
0
));
(
double
)(
totalQueried
/
((
endTs
-
startTs
)
/
1000
.
0
)
));
}
}
lastPrintTime
=
currentPrintTime
;
lastPrintTime
=
currentPrintTime
;
}
}
}
}
et
=
taosGetTimestamp
U
s
();
et
=
taosGetTimestamp
M
s
();
printf
(
"####thread[%"
PRId64
"] complete all sqls to allocate all sub-tables[%d - %d] once queries duration:%.4fs
\n\n
"
,
printf
(
"####thread[%"
PRId64
"] complete all sqls to allocate all sub-tables[%d - %d] once queries duration:%.4fs
\n\n
"
,
taosGetSelfPthreadId
(),
taosGetSelfPthreadId
(),
pThreadInfo
->
start_table_from
,
pThreadInfo
->
start_table_from
,
pThreadInfo
->
end_table_to
,
pThreadInfo
->
end_table_to
,
(
double
)(
et
-
st
)
/
1000
000
.
0
);
(
double
)(
et
-
st
)
/
1000
.
0
);
}
}
return
NULL
;
return
NULL
;
...
@@ -6120,9 +6201,9 @@ static int queryTestProcess() {
...
@@ -6120,9 +6201,9 @@ static int queryTestProcess() {
int
totalQueried
=
g_queryInfo
.
specifiedQueryInfo
.
totalQueried
+
int
totalQueried
=
g_queryInfo
.
specifiedQueryInfo
.
totalQueried
+
g_queryInfo
.
superQueryInfo
.
totalQueried
;
g_queryInfo
.
superQueryInfo
.
totalQueried
;
printf
(
"==== completed total queries: %d, the QPS of all threads: %10.
2
f====
\n
"
,
printf
(
"==== completed total queries: %d, the QPS of all threads: %10.
3
f====
\n
"
,
totalQueried
,
totalQueried
,
totalQueried
/
((
endTs
-
startTs
)
/
1000
.
0
));
(
double
)(
totalQueried
/
((
endTs
-
startTs
)
/
1000
.
0
)
));
return
0
;
return
0
;
}
}
...
@@ -6192,8 +6273,8 @@ static void *superSubscribe(void *sarg) {
...
@@ -6192,8 +6273,8 @@ static void *superSubscribe(void *sarg) {
//int64_t st = 0;
//int64_t st = 0;
//int64_t et = 0;
//int64_t et = 0;
do
{
do
{
//if (g_queryInfo.specifiedQueryInfo.
rate && (et - st) < g_queryInfo.specifiedQueryInfo.rate*1000
) {
//if (g_queryInfo.specifiedQueryInfo.
queryInterval && (et - st) < g_queryInfo.specifiedQueryInfo.queryInterval
) {
// taosMsleep(g_queryInfo.specifiedQueryInfo.
rate*1000
- (et - st)); // ms
// taosMsleep(g_queryInfo.specifiedQueryInfo.
queryInterval
- (et - st)); // ms
// //printf("========sleep duration:%"PRId64 "========inserted rows:%d, table range:%d - %d\n", (1000 - (et - st)), i, pThreadInfo->start_table_from, pThreadInfo->end_table_to);
// //printf("========sleep duration:%"PRId64 "========inserted rows:%d, table range:%d - %d\n", (1000 - (et - st)), i, pThreadInfo->start_table_from, pThreadInfo->end_table_to);
//}
//}
...
@@ -6279,8 +6360,8 @@ static void *specifiedSubscribe(void *sarg) {
...
@@ -6279,8 +6360,8 @@ static void *specifiedSubscribe(void *sarg) {
//int64_t st = 0;
//int64_t st = 0;
//int64_t et = 0;
//int64_t et = 0;
do
{
do
{
//if (g_queryInfo.specifiedQueryInfo.
rate && (et - st) < g_queryInfo.specifiedQueryInfo.rate*1000
) {
//if (g_queryInfo.specifiedQueryInfo.
queryInterval && (et - st) < g_queryInfo.specifiedQueryInfo.queryInterval
) {
// taosMsleep(g_queryInfo.specifiedQueryInfo.
rate*1000
- (et - st)); // ms
// taosMsleep(g_queryInfo.specifiedQueryInfo.
queryInterval
- (et - st)); // ms
// //printf("========sleep duration:%"PRId64 "========inserted rows:%d, table range:%d - %d\n", (1000 - (et - st)), i, pThreadInfo->start_table_from, pThreadInfo->end_table_to);
// //printf("========sleep duration:%"PRId64 "========inserted rows:%d, table range:%d - %d\n", (1000 - (et - st)), i, pThreadInfo->start_table_from, pThreadInfo->end_table_to);
//}
//}
...
@@ -6630,7 +6711,7 @@ static void querySqlFile(TAOS* taos, char* sqlFile)
...
@@ -6630,7 +6711,7 @@ static void querySqlFile(TAOS* taos, char* sqlFile)
char
*
line
=
NULL
;
char
*
line
=
NULL
;
size_t
line_len
=
0
;
size_t
line_len
=
0
;
double
t
=
getCurrentTimeU
s
();
double
t
=
taosGetTimestampM
s
();
while
((
read_len
=
tgetline
(
&
line
,
&
line_len
,
fp
))
!=
-
1
)
{
while
((
read_len
=
tgetline
(
&
line
,
&
line_len
,
fp
))
!=
-
1
)
{
if
(
read_len
>=
MAX_SQL_SIZE
)
continue
;
if
(
read_len
>=
MAX_SQL_SIZE
)
continue
;
...
@@ -6661,7 +6742,7 @@ static void querySqlFile(TAOS* taos, char* sqlFile)
...
@@ -6661,7 +6742,7 @@ static void querySqlFile(TAOS* taos, char* sqlFile)
cmd_len
=
0
;
cmd_len
=
0
;
}
}
t
=
getCurrentTimeU
s
()
-
t
;
t
=
taosGetTimestampM
s
()
-
t
;
printf
(
"run %s took %.6f second(s)
\n\n
"
,
sqlFile
,
t
);
printf
(
"run %s took %.6f second(s)
\n\n
"
,
sqlFile
,
t
);
tmfree
(
cmd
);
tmfree
(
cmd
);
...
...
src/kit/taosdump/taosdump.c
浏览文件 @
d37fad65
...
@@ -517,6 +517,7 @@ int main(int argc, char *argv[]) {
...
@@ -517,6 +517,7 @@ int main(int argc, char *argv[]) {
/* Parse our arguments; every option seen by parse_opt will be
/* Parse our arguments; every option seen by parse_opt will be
reflected in arguments. */
reflected in arguments. */
if
(
argc
>
1
)
parse_args
(
argc
,
argv
,
&
g_args
);
parse_args
(
argc
,
argv
,
&
g_args
);
argp_parse
(
&
argp
,
argc
,
argv
,
0
,
0
,
&
g_args
);
argp_parse
(
&
argp
,
argc
,
argv
,
0
,
0
,
&
g_args
);
...
...
src/os/src/darwin/darwinSysInfo.c
浏览文件 @
d37fad65
...
@@ -217,7 +217,7 @@ void taosSetCoreDump() {}
...
@@ -217,7 +217,7 @@ void taosSetCoreDump() {}
int32_t
taosGetDiskSize
(
char
*
dataDir
,
SysDiskSize
*
diskSize
)
{
int32_t
taosGetDiskSize
(
char
*
dataDir
,
SysDiskSize
*
diskSize
)
{
struct
statvfs
info
;
struct
statvfs
info
;
if
(
statvfs
(
tsD
ataDir
,
&
info
))
{
if
(
statvfs
(
d
ataDir
,
&
info
))
{
uError
(
"failed to get disk size, dataDir:%s errno:%s"
,
tsDataDir
,
strerror
(
errno
));
uError
(
"failed to get disk size, dataDir:%s errno:%s"
,
tsDataDir
,
strerror
(
errno
));
terrno
=
TAOS_SYSTEM_ERROR
(
errno
);
terrno
=
TAOS_SYSTEM_ERROR
(
errno
);
return
-
1
;
return
-
1
;
...
...
src/os/src/detail/osSysinfo.c
浏览文件 @
d37fad65
...
@@ -319,7 +319,7 @@ bool taosGetCpuUsage(float *sysCpuUsage, float *procCpuUsage) {
...
@@ -319,7 +319,7 @@ bool taosGetCpuUsage(float *sysCpuUsage, float *procCpuUsage) {
int32_t
taosGetDiskSize
(
char
*
dataDir
,
SysDiskSize
*
diskSize
)
{
int32_t
taosGetDiskSize
(
char
*
dataDir
,
SysDiskSize
*
diskSize
)
{
struct
statvfs
info
;
struct
statvfs
info
;
if
(
statvfs
(
tsD
ataDir
,
&
info
))
{
if
(
statvfs
(
d
ataDir
,
&
info
))
{
uError
(
"failed to get disk size, dataDir:%s errno:%s"
,
tsDataDir
,
strerror
(
errno
));
uError
(
"failed to get disk size, dataDir:%s errno:%s"
,
tsDataDir
,
strerror
(
errno
));
terrno
=
TAOS_SYSTEM_ERROR
(
errno
);
terrno
=
TAOS_SYSTEM_ERROR
(
errno
);
return
-
1
;
return
-
1
;
...
...
src/tsdb/src/tsdbRead.c
浏览文件 @
d37fad65
...
@@ -1406,7 +1406,11 @@ static void copyOneRowFromMem(STsdbQueryHandle* pQueryHandle, int32_t capacity,
...
@@ -1406,7 +1406,11 @@ static void copyOneRowFromMem(STsdbQueryHandle* pQueryHandle, int32_t capacity,
SET_DOUBLE_PTR
(
pData
,
value
);
SET_DOUBLE_PTR
(
pData
,
value
);
break
;
break
;
case
TSDB_DATA_TYPE_TIMESTAMP
:
case
TSDB_DATA_TYPE_TIMESTAMP
:
if
(
pColInfo
->
info
.
colId
==
PRIMARYKEY_TIMESTAMP_COL_INDEX
)
{
*
(
TSKEY
*
)
pData
=
tdGetKey
(
*
(
TKEY
*
)
value
);
*
(
TSKEY
*
)
pData
=
tdGetKey
(
*
(
TKEY
*
)
value
);
}
else
{
*
(
TSKEY
*
)
pData
=
*
(
TSKEY
*
)
value
;
}
break
;
break
;
default:
default:
memcpy
(
pData
,
value
,
pColInfo
->
info
.
bytes
);
memcpy
(
pData
,
value
,
pColInfo
->
info
.
bytes
);
...
...
tests/examples/C#/C#checker/C#checker.cs
浏览文件 @
d37fad65
...
@@ -244,14 +244,18 @@ namespace TDengineDriver
...
@@ -244,14 +244,18 @@ namespace TDengineDriver
DateTime
dt2
=
DateTime
.
Now
;
DateTime
dt2
=
DateTime
.
Now
;
TimeSpan
span
=
dt2
-
dt1
;
TimeSpan
span
=
dt2
-
dt1
;
if
(
res
!=
IntPtr
.
Zero
)
if
(
(
res
==
IntPtr
.
Zero
)
||
(
TDengine
.
ErrorNo
(
res
)
!=
0
))
{
{
Console
.
WriteLine
(
"[OK] time cost: "
+
span
.
ToString
()
+
"ms, execute statement ====> "
+
sql
.
ToString
());
Console
.
Write
(
sql
.
ToString
()
+
" failure, "
);
if
(
res
!=
IntPtr
.
Zero
)
{
Console
.
Write
(
"reason: "
+
TDengine
.
Error
(
res
));
}
Console
.
WriteLine
(
""
);
ExitProgram
();
}
}
else
else
{
{
Console
.
WriteLine
(
sql
.
ToString
()
+
" failure, reason: "
+
TDengine
.
Error
(
res
));
Console
.
WriteLine
(
sql
.
ToString
()
+
" success"
);
ExitProgram
();
}
}
TDengine
.
FreeResult
(
res
);
TDengine
.
FreeResult
(
res
);
}
}
...
@@ -262,9 +266,13 @@ namespace TDengineDriver
...
@@ -262,9 +266,13 @@ namespace TDengineDriver
DateTime
dt1
=
DateTime
.
Now
;
DateTime
dt1
=
DateTime
.
Now
;
long
queryRows
=
0
;
long
queryRows
=
0
;
IntPtr
res
=
TDengine
.
Query
(
conn
,
sql
);
IntPtr
res
=
TDengine
.
Query
(
conn
,
sql
);
if
(
res
==
IntPtr
.
Zero
)
if
(
(
res
==
IntPtr
.
Zero
)
||
(
TDengine
.
ErrorNo
(
res
)
!=
0
))
{
{
Console
.
WriteLine
(
sql
+
" failure, reason: "
+
TDengine
.
Error
(
res
));
Console
.
Write
(
sql
.
ToString
()
+
" failure, "
);
if
(
res
!=
IntPtr
.
Zero
)
{
Console
.
Write
(
"reason: "
+
TDengine
.
Error
(
res
));
}
Console
.
WriteLine
(
""
);
ExitProgram
();
ExitProgram
();
}
}
DateTime
dt2
=
DateTime
.
Now
;
DateTime
dt2
=
DateTime
.
Now
;
...
@@ -354,6 +362,7 @@ namespace TDengineDriver
...
@@ -354,6 +362,7 @@ namespace TDengineDriver
{
{
Console
.
Write
(
"Query is not complete, Error {0:G}"
,
TDengine
.
ErrorNo
(
res
),
TDengine
.
Error
(
res
));
Console
.
Write
(
"Query is not complete, Error {0:G}"
,
TDengine
.
ErrorNo
(
res
),
TDengine
.
Error
(
res
));
}
}
Console
.
WriteLine
(
""
);
TDengine
.
FreeResult
(
res
);
TDengine
.
FreeResult
(
res
);
...
...
tests/examples/C#/TDengineDriver.cs
浏览文件 @
d37fad65
...
@@ -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
...
@@ -30,7 +31,11 @@ namespace TDengineDriver
...
@@ -30,7 +31,11 @@ namespace TDengineDriver
TSDB_DATA_TYPE_DOUBLE
=
7
,
// 8 bytes
TSDB_DATA_TYPE_DOUBLE
=
7
,
// 8 bytes
TSDB_DATA_TYPE_BINARY
=
8
,
// string
TSDB_DATA_TYPE_BINARY
=
8
,
// string
TSDB_DATA_TYPE_TIMESTAMP
=
9
,
// 8 bytes
TSDB_DATA_TYPE_TIMESTAMP
=
9
,
// 8 bytes
TSDB_DATA_TYPE_NCHAR
=
10
// unicode string
TSDB_DATA_TYPE_NCHAR
=
10
,
// unicode string
TSDB_DATA_TYPE_UTINYINT
=
11
,
// 1 byte
TSDB_DATA_TYPE_USMALLINT
=
12
,
// 2 bytes
TSDB_DATA_TYPE_UINT
=
13
,
// 4 bytes
TSDB_DATA_TYPE_UBIGINT
=
14
// 8 bytes
}
}
enum
TDengineInitOption
enum
TDengineInitOption
...
@@ -52,15 +57,23 @@ namespace TDengineDriver
...
@@ -52,15 +57,23 @@ namespace TDengineDriver
switch
((
TDengineDataType
)
type
)
switch
((
TDengineDataType
)
type
)
{
{
case
TDengineDataType
.
TSDB_DATA_TYPE_BOOL
:
case
TDengineDataType
.
TSDB_DATA_TYPE_BOOL
:
return
"BOOLEAN
"
;
return
"BOOL
"
;
case
TDengineDataType
.
TSDB_DATA_TYPE_TINYINT
:
case
TDengineDataType
.
TSDB_DATA_TYPE_TINYINT
:
return
"BYTE
"
;
return
"TINYINT
"
;
case
TDengineDataType
.
TSDB_DATA_TYPE_SMALLINT
:
case
TDengineDataType
.
TSDB_DATA_TYPE_SMALLINT
:
return
"SHOR
T"
;
return
"SMALLIN
T"
;
case
TDengineDataType
.
TSDB_DATA_TYPE_INT
:
case
TDengineDataType
.
TSDB_DATA_TYPE_INT
:
return
"INT"
;
return
"INT"
;
case
TDengineDataType
.
TSDB_DATA_TYPE_BIGINT
:
case
TDengineDataType
.
TSDB_DATA_TYPE_BIGINT
:
return
"LONG"
;
return
"BIGINT"
;
case
TDengineDataType
.
TSDB_DATA_TYPE_UTINYINT
:
return
"TINYINT UNSIGNED"
;
case
TDengineDataType
.
TSDB_DATA_TYPE_USMALLINT
:
return
"SMALLINT UNSIGNED"
;
case
TDengineDataType
.
TSDB_DATA_TYPE_UINT
:
return
"INT UNSIGNED"
;
case
TDengineDataType
.
TSDB_DATA_TYPE_UBIGINT
:
return
"BIGINT UNSIGNED"
;
case
TDengineDataType
.
TSDB_DATA_TYPE_FLOAT
:
case
TDengineDataType
.
TSDB_DATA_TYPE_FLOAT
:
return
"FLOAT"
;
return
"FLOAT"
;
case
TDengineDataType
.
TSDB_DATA_TYPE_DOUBLE
:
case
TDengineDataType
.
TSDB_DATA_TYPE_DOUBLE
:
...
@@ -81,19 +94,19 @@ namespace TDengineDriver
...
@@ -81,19 +94,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 +114,19 @@ namespace TDengineDriver
...
@@ -101,19 +114,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 +155,13 @@ namespace TDengineDriver
...
@@ -142,13 +155,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
);
}
}
}
}
tests/examples/C#/TDengineTest.cs
浏览文件 @
d37fad65
...
@@ -165,7 +165,7 @@ namespace TDengineDriver
...
@@ -165,7 +165,7 @@ namespace TDengineDriver
public
void
ReadArgument
(
String
[]
argv
)
public
void
ReadArgument
(
String
[]
argv
)
{
{
PrintHelp
(
argv
);
PrintHelp
(
argv
);
host
=
this
.
GetArgumentAsString
(
argv
,
"-h"
,
"1
92.168.100.128
"
);
host
=
this
.
GetArgumentAsString
(
argv
,
"-h"
,
"1
27.0.0.1
"
);
user
=
this
.
GetArgumentAsString
(
argv
,
"-u"
,
"root"
);
user
=
this
.
GetArgumentAsString
(
argv
,
"-u"
,
"root"
);
password
=
this
.
GetArgumentAsString
(
argv
,
"-p"
,
"taosdata"
);
password
=
this
.
GetArgumentAsString
(
argv
,
"-p"
,
"taosdata"
);
dbName
=
this
.
GetArgumentAsString
(
argv
,
"-d"
,
"db"
);
dbName
=
this
.
GetArgumentAsString
(
argv
,
"-d"
,
"db"
);
...
@@ -212,42 +212,54 @@ namespace TDengineDriver
...
@@ -212,42 +212,54 @@ namespace TDengineDriver
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
);
IntPtr
res
=
TDengine
.
Query
(
this
.
conn
,
sql
.
ToString
());
IntPtr
res
=
TDengine
.
Query
(
this
.
conn
,
sql
.
ToString
());
if
(
res
!=
IntPtr
.
Zero
)
if
(
(
res
==
IntPtr
.
Zero
)
||
(
TDengine
.
ErrorNo
(
res
)
!=
0
)
)
{
{
Console
.
WriteLine
(
sql
.
ToString
()
+
" success"
);
Console
.
Write
(
sql
.
ToString
()
+
" failure, "
);
if
(
res
!=
IntPtr
.
Zero
)
{
Console
.
Write
(
"reason: "
+
TDengine
.
Error
(
res
));
}
Console
.
WriteLine
(
""
);
ExitProgram
();
}
}
else
else
{
{
Console
.
WriteLine
(
sql
.
ToString
()
+
" failure, reason: "
+
TDengine
.
Error
(
res
));
Console
.
WriteLine
(
sql
.
ToString
()
+
" success"
);
ExitProgram
();
}
}
TDengine
.
FreeResult
(
res
);
TDengine
.
FreeResult
(
res
);
sql
.
Clear
();
sql
.
Clear
();
sql
.
Append
(
"use "
).
Append
(
this
.
dbName
);
sql
.
Append
(
"use "
).
Append
(
this
.
dbName
);
res
=
TDengine
.
Query
(
this
.
conn
,
sql
.
ToString
());
res
=
TDengine
.
Query
(
this
.
conn
,
sql
.
ToString
());
if
(
res
!=
IntPtr
.
Zero
)
if
(
(
res
==
IntPtr
.
Zero
)
||
(
TDengine
.
ErrorNo
(
res
)
!=
0
)
)
{
{
Console
.
WriteLine
(
sql
.
ToString
()
+
" success"
);
Console
.
Write
(
sql
.
ToString
()
+
" failure, "
);
if
(
res
!=
IntPtr
.
Zero
)
{
Console
.
Write
(
"reason: "
+
TDengine
.
Error
(
res
));
}
Console
.
WriteLine
(
""
);
ExitProgram
();
}
}
else
else
{
{
Console
.
WriteLine
(
sql
.
ToString
()
+
" failure, reason: "
+
TDengine
.
Error
(
res
));
Console
.
WriteLine
(
sql
.
ToString
()
+
" success"
);
ExitProgram
();
}
}
TDengine
.
FreeResult
(
res
);
TDengine
.
FreeResult
(
res
);
sql
.
Clear
();
sql
.
Clear
();
sql
.
Append
(
"create table if not exists "
).
Append
(
this
.
stableName
).
Append
(
"(ts timestamp, v1 bool, v2 tinyint, v3 smallint, v4 int, v5 bigint, v6 float, v7 double, v8 binary(10), v9 nchar(10)) tags(t1 int)"
);
sql
.
Append
(
"create table if not exists "
).
Append
(
this
.
stableName
).
Append
(
"(ts timestamp, v1 bool, v2 tinyint, v3 smallint, v4 int, v5 bigint, v6 float, v7 double, v8 binary(10), v9 nchar(10)) tags(t1 int)"
);
res
=
TDengine
.
Query
(
this
.
conn
,
sql
.
ToString
());
res
=
TDengine
.
Query
(
this
.
conn
,
sql
.
ToString
());
if
(
res
!=
IntPtr
.
Zero
)
if
(
(
res
==
IntPtr
.
Zero
)
||
(
TDengine
.
ErrorNo
(
res
)
!=
0
)
)
{
{
Console
.
WriteLine
(
sql
.
ToString
()
+
" success"
);
Console
.
Write
(
sql
.
ToString
()
+
" failure, "
);
if
(
res
!=
IntPtr
.
Zero
)
{
Console
.
Write
(
"reason: "
+
TDengine
.
Error
(
res
));
}
Console
.
WriteLine
(
""
);
ExitProgram
();
}
}
else
else
{
{
Console
.
WriteLine
(
sql
.
ToString
()
+
" failure, reason: "
+
TDengine
.
Error
(
res
));
Console
.
WriteLine
(
sql
.
ToString
()
+
" success"
);
ExitProgram
();
}
}
TDengine
.
FreeResult
(
res
);
TDengine
.
FreeResult
(
res
);
...
@@ -257,14 +269,18 @@ namespace TDengineDriver
...
@@ -257,14 +269,18 @@ namespace TDengineDriver
sql
=
sql
.
Append
(
"create table if not exists "
).
Append
(
this
.
tablePrefix
).
Append
(
i
)
sql
=
sql
.
Append
(
"create table if not exists "
).
Append
(
this
.
tablePrefix
).
Append
(
i
)
.
Append
(
" using "
).
Append
(
this
.
stableName
).
Append
(
" tags("
).
Append
(
i
).
Append
(
")"
);
.
Append
(
" using "
).
Append
(
this
.
stableName
).
Append
(
" tags("
).
Append
(
i
).
Append
(
")"
);
res
=
TDengine
.
Query
(
this
.
conn
,
sql
.
ToString
());
res
=
TDengine
.
Query
(
this
.
conn
,
sql
.
ToString
());
if
(
res
!=
IntPtr
.
Zero
)
if
(
(
res
==
IntPtr
.
Zero
)
||
(
TDengine
.
ErrorNo
(
res
)
!=
0
)
)
{
{
Console
.
WriteLine
(
sql
.
ToString
()
+
" success"
);
Console
.
Write
(
sql
.
ToString
()
+
" failure, "
);
if
(
res
!=
IntPtr
.
Zero
)
{
Console
.
Write
(
"reason: "
+
TDengine
.
Error
(
res
));
}
Console
.
WriteLine
(
""
);
ExitProgram
();
}
}
else
else
{
{
Console
.
WriteLine
(
sql
.
ToString
()
+
" failure, reason: "
+
TDengine
.
Error
(
res
));
Console
.
WriteLine
(
sql
.
ToString
()
+
" success"
);
ExitProgram
();
}
}
TDengine
.
FreeResult
(
res
);
TDengine
.
FreeResult
(
res
);
}
}
...
@@ -298,9 +314,13 @@ namespace TDengineDriver
...
@@ -298,9 +314,13 @@ namespace TDengineDriver
.
Append
(
", 5, 6, 7, 'abc', 'def')"
);
.
Append
(
", 5, 6, 7, 'abc', 'def')"
);
}
}
IntPtr
res
=
TDengine
.
Query
(
this
.
conn
,
sql
.
ToString
());
IntPtr
res
=
TDengine
.
Query
(
this
.
conn
,
sql
.
ToString
());
if
(
res
==
IntPtr
.
Zero
)
if
(
(
res
==
IntPtr
.
Zero
)
||
(
TDengine
.
ErrorNo
(
res
)
!=
0
)
)
{
{
Console
.
WriteLine
(
sql
.
ToString
()
+
" failure, reason: "
+
TDengine
.
Error
(
res
));
Console
.
Write
(
sql
.
ToString
()
+
" failure, "
);
if
(
res
!=
IntPtr
.
Zero
)
{
Console
.
Write
(
"reason: "
+
TDengine
.
Error
(
res
));
}
Console
.
WriteLine
(
""
);
}
}
int
affectRows
=
TDengine
.
AffectRows
(
res
);
int
affectRows
=
TDengine
.
AffectRows
(
res
);
...
@@ -333,9 +353,13 @@ namespace TDengineDriver
...
@@ -333,9 +353,13 @@ namespace TDengineDriver
Console
.
WriteLine
(
sql
);
Console
.
WriteLine
(
sql
);
IntPtr
res
=
TDengine
.
Query
(
conn
,
sql
);
IntPtr
res
=
TDengine
.
Query
(
conn
,
sql
);
if
(
res
==
IntPtr
.
Zero
)
if
(
(
res
==
IntPtr
.
Zero
)
||
(
TDengine
.
ErrorNo
(
res
)
!=
0
)
)
{
{
Console
.
WriteLine
(
sql
+
" failure, reason: "
+
TDengine
.
Error
(
res
));
Console
.
Write
(
sql
.
ToString
()
+
" failure, "
);
if
(
res
!=
IntPtr
.
Zero
)
{
Console
.
Write
(
"reason: "
+
TDengine
.
Error
(
res
));
}
Console
.
WriteLine
(
""
);
ExitProgram
();
ExitProgram
();
}
}
...
@@ -410,6 +434,22 @@ namespace TDengineDriver
...
@@ -410,6 +434,22 @@ namespace TDengineDriver
string
v10
=
Marshal
.
PtrToStringAnsi
(
data
);
string
v10
=
Marshal
.
PtrToStringAnsi
(
data
);
builder
.
Append
(
v10
);
builder
.
Append
(
v10
);
break
;
break
;
case
TDengineDataType
.
TSDB_DATA_TYPE_UTINYINT
:
byte
v11
=
Marshal
.
ReadByte
(
data
);
builder
.
Append
(
v11
);
break
;
case
TDengineDataType
.
TSDB_DATA_TYPE_USMALLINT
:
ushort
v12
=
(
ushort
)
Marshal
.
ReadInt16
(
data
);
builder
.
Append
(
v12
);
break
;
case
TDengineDataType
.
TSDB_DATA_TYPE_UINT
:
uint
v13
=
(
uint
)
Marshal
.
ReadInt32
(
data
);
builder
.
Append
(
v13
);
break
;
case
TDengineDataType
.
TSDB_DATA_TYPE_UBIGINT
:
ulong
v14
=
(
ulong
)
Marshal
.
ReadInt64
(
data
);
builder
.
Append
(
v14
);
break
;
}
}
}
}
builder
.
Append
(
"---"
);
builder
.
Append
(
"---"
);
...
@@ -423,8 +463,10 @@ namespace TDengineDriver
...
@@ -423,8 +463,10 @@ namespace TDengineDriver
if
(
TDengine
.
ErrorNo
(
res
)
!=
0
)
if
(
TDengine
.
ErrorNo
(
res
)
!=
0
)
{
{
Console
.
Write
(
"Query is not complete, Error {0:G}"
,
TDengine
.
ErrorNo
(
res
),
TDengine
.
Error
(
res
));
Console
.
Write
(
"Query is not complete, Error {0:G}"
,
TDengine
.
ErrorNo
(
res
),
TDengine
.
Error
(
res
));
}
}
Console
.
WriteLine
(
""
);
TDengine
.
FreeResult
(
res
);
TDengine
.
FreeResult
(
res
);
}
}
...
...
tests/examples/C#/taosdemo/taosdemo.cs
浏览文件 @
d37fad65
...
@@ -370,16 +370,19 @@ namespace TDengineDriver
...
@@ -370,16 +370,19 @@ namespace TDengineDriver
StringBuilder
sql
=
new
StringBuilder
();
StringBuilder
sql
=
new
StringBuilder
();
sql
.
Append
(
"DROP DATABASE IF EXISTS "
).
Append
(
this
.
dbName
);
sql
.
Append
(
"DROP DATABASE IF EXISTS "
).
Append
(
this
.
dbName
);
IntPtr
res
=
TDengine
.
Query
(
this
.
conn
,
sql
.
ToString
());
IntPtr
res
=
TDengine
.
Query
(
this
.
conn
,
sql
.
ToString
());
if
(
res
!=
IntPtr
.
Zero
)
if
(
(
res
==
IntPtr
.
Zero
)
||
(
TDengine
.
ErrorNo
(
res
)
!=
0
)
)
{
{
VerbosePrint
(
sql
.
ToString
()
+
" success\n"
);
Console
.
Write
(
sql
.
ToString
()
+
" failure, "
);
if
(
res
!=
IntPtr
.
Zero
)
{
Console
.
Write
(
"reason: "
+
TDengine
.
Error
(
res
));
}
Console
.
WriteLine
(
""
);
CleanAndExitProgram
(
1
);
}
}
else
else
{
{
Console
.
WriteLine
(
sql
.
ToString
()
+
" failure, reason: "
+
TDengine
.
Error
(
res
));
VerbosePrint
(
sql
.
ToString
()
+
" success\n"
);
CleanAndExitProgram
(
1
);
}
}
}
}
public
void
CreateDb
()
public
void
CreateDb
()
...
@@ -387,14 +390,18 @@ namespace TDengineDriver
...
@@ -387,14 +390,18 @@ namespace TDengineDriver
StringBuilder
sql
=
new
StringBuilder
();
StringBuilder
sql
=
new
StringBuilder
();
sql
.
Append
(
"CREATE DATABASE IF NOT EXISTS "
).
Append
(
this
.
dbName
).
Append
(
" replica "
).
Append
(
this
.
replica
);
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
)
||
(
TDengine
.
ErrorNo
(
res
)
!=
0
)
)
{
{
VerbosePrint
(
sql
.
ToString
()
+
" success\n"
);
Console
.
Write
(
sql
.
ToString
()
+
" failure, "
);
if
(
res
!=
IntPtr
.
Zero
)
{
Console
.
Write
(
"reason: "
+
TDengine
.
Error
(
res
));
}
Console
.
WriteLine
(
""
);
CleanAndExitProgram
(
1
);
}
}
else
else
{
{
Console
.
WriteLine
(
sql
.
ToString
()
+
" failure, reason: "
+
TDengine
.
Error
(
res
));
VerbosePrint
(
sql
.
ToString
()
+
" success\n"
);
CleanAndExitProgram
(
1
);
}
}
TDengine
.
FreeResult
(
res
);
TDengine
.
FreeResult
(
res
);
}
}
...
@@ -408,14 +415,18 @@ namespace TDengineDriver
...
@@ -408,14 +415,18 @@ namespace TDengineDriver
Append
(
this
.
dbName
).
Append
(
"."
).
Append
(
this
.
stablePrefix
).
Append
(
this
.
dbName
).
Append
(
"."
).
Append
(
this
.
stablePrefix
).
Append
(
"(ts timestamp, v1 bool, v2 tinyint, v3 smallint, v4 int, v5 bigint, v6 float, v7 double, v8 binary(10), v9 nchar(10)) tags(t1 int)"
);
Append
(
"(ts timestamp, v1 bool, v2 tinyint, v3 smallint, v4 int, v5 bigint, v6 float, v7 double, v8 binary(10), v9 nchar(10)) tags(t1 int)"
);
IntPtr
res
=
TDengine
.
Query
(
this
.
conn
,
sql
.
ToString
());
IntPtr
res
=
TDengine
.
Query
(
this
.
conn
,
sql
.
ToString
());
if
(
res
!=
IntPtr
.
Zero
)
if
(
(
res
==
IntPtr
.
Zero
)
||
(
TDengine
.
ErrorNo
(
res
)
!=
0
)
)
{
{
VerbosePrint
(
sql
.
ToString
()
+
" success\n"
);
Console
.
Write
(
sql
.
ToString
()
+
" failure, "
);
if
(
res
!=
IntPtr
.
Zero
)
{
Console
.
Write
(
"reason: "
+
TDengine
.
Error
(
res
));
}
Console
.
WriteLine
(
""
);
CleanAndExitProgram
(
1
);
}
}
else
else
{
{
Console
.
WriteLine
(
sql
.
ToString
()
+
" failure, reason: "
+
TDengine
.
Error
(
res
));
VerbosePrint
(
sql
.
ToString
()
+
" success\n"
);
CleanAndExitProgram
(
1
);
}
}
TDengine
.
FreeResult
(
res
);
TDengine
.
FreeResult
(
res
);
}
}
...
@@ -495,9 +506,13 @@ namespace TDengineDriver
...
@@ -495,9 +506,13 @@ namespace TDengineDriver
IntPtr
res
=
TDengine
.
Query
(
conn
,
sql
);
IntPtr
res
=
TDengine
.
Query
(
conn
,
sql
);
DebugPrintFormat
(
"res: {0}\n"
,
res
);
DebugPrintFormat
(
"res: {0}\n"
,
res
);
if
(
res
==
IntPtr
.
Zero
)
if
(
(
res
==
IntPtr
.
Zero
)
||
(
TDengine
.
ErrorNo
(
res
)
!=
0
)
)
{
{
Console
.
WriteLine
(
sql
+
" failure, reason: "
+
TDengine
.
Error
(
res
));
Console
.
Write
(
sql
.
ToString
()
+
" failure, "
);
if
(
res
!=
IntPtr
.
Zero
)
{
Console
.
Write
(
"reason: "
+
TDengine
.
Error
(
res
));
}
Console
.
WriteLine
(
""
);
CleanAndExitProgram
(
1
);
CleanAndExitProgram
(
1
);
}
}
...
@@ -761,9 +776,13 @@ namespace TDengineDriver
...
@@ -761,9 +776,13 @@ namespace TDengineDriver
}
}
IntPtr
res
=
TDengine
.
Query
(
this
.
conn
,
sql
.
ToString
());
IntPtr
res
=
TDengine
.
Query
(
this
.
conn
,
sql
.
ToString
());
if
(
res
==
IntPtr
.
Zero
)
if
(
(
res
==
IntPtr
.
Zero
)
||
(
TDengine
.
ErrorNo
(
res
)
!=
0
)
)
{
{
VerbosePrint
(
sql
.
ToString
()
+
" failure, reason: "
+
TDengine
.
Error
(
res
)
+
"\n"
);
Console
.
Write
(
sql
.
ToString
()
+
" failure, "
);
if
(
res
!=
IntPtr
.
Zero
)
{
Console
.
Write
(
"reason: "
+
TDengine
.
Error
(
res
));
}
Console
.
WriteLine
(
""
);
}
}
inserted
+=
this
.
batchRows
;
inserted
+=
this
.
batchRows
;
...
@@ -840,14 +859,18 @@ namespace TDengineDriver
...
@@ -840,14 +859,18 @@ namespace TDengineDriver
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))"
);
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
)
||
(
TDengine
.
ErrorNo
(
res
)
!=
0
)
)
{
{
VerbosePrint
(
sql
.
ToString
()
+
" success\n"
);
Console
.
Write
(
sql
.
ToString
()
+
" failure, "
);
if
(
res
!=
IntPtr
.
Zero
)
{
Console
.
Write
(
"reason: "
+
TDengine
.
Error
(
res
));
}
Console
.
WriteLine
(
""
);
CleanAndExitProgram
(
1
);
}
}
else
else
{
{
VerbosePrint
(
sql
.
ToString
()
+
" failure, reason: "
+
TDengine
.
Error
(
res
)
+
"\n"
);
VerbosePrint
(
sql
.
ToString
()
+
" success\n"
);
CleanAndExitProgram
(
1
);
}
}
TDengine
.
FreeResult
(
res
);
TDengine
.
FreeResult
(
res
);
}
}
...
...
tests/pytest/alter/alterTabAddTagWithNULL.py
0 → 100644
浏览文件 @
d37fad65
###################################################################
# 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
from
util.log
import
*
from
util.cases
import
*
from
util.sql
import
*
from
util.dnodes
import
*
class
TDTestCase
:
def
init
(
self
,
conn
,
logSql
):
tdLog
.
debug
(
f
"start to execute
{
__file__
}
"
)
tdSql
.
init
(
conn
.
cursor
(),
logSql
)
def
run
(
self
):
tdSql
.
execute
(
"drop database if exists db"
)
tdSql
.
execute
(
"create database if not exists db keep 36500"
)
tdSql
.
execute
(
"use db"
)
tdLog
.
printNoPrefix
(
"==========step1:create table && insert data"
)
tdSql
.
execute
(
"create table stbtag (ts timestamp, c1 int) TAGS(t1 int)"
)
tdSql
.
execute
(
"create table tag1 using stbtag tags(1)"
)
tdLog
.
printNoPrefix
(
"==========step2:alter stb add tag create new chiltable"
)
tdSql
.
execute
(
"alter table stbtag add tag t2 int"
)
tdSql
.
execute
(
"alter table stbtag add tag t3 tinyint"
)
tdSql
.
execute
(
"alter table stbtag add tag t4 smallint "
)
tdSql
.
execute
(
"alter table stbtag add tag t5 bigint"
)
tdSql
.
execute
(
"alter table stbtag add tag t6 float "
)
tdSql
.
execute
(
"alter table stbtag add tag t7 double "
)
tdSql
.
execute
(
"alter table stbtag add tag t8 bool "
)
tdSql
.
execute
(
"alter table stbtag add tag t9 binary(10) "
)
tdSql
.
execute
(
"alter table stbtag add tag t10 nchar(10)"
)
tdSql
.
execute
(
"create table tag2 using stbtag tags(2, 22, 23, 24, 25, 26.1, 27.1, 1, 'binary9', 'nchar10')"
)
tdSql
.
query
(
"select tbname, t1, t2, t3, t4, t5, t6, t7, t8, t9, t10 from stbtag"
)
tdSql
.
checkData
(
1
,
0
,
"tag2"
)
tdSql
.
checkData
(
1
,
1
,
2
)
tdSql
.
checkData
(
1
,
2
,
22
)
tdSql
.
checkData
(
1
,
3
,
23
)
tdSql
.
checkData
(
1
,
4
,
24
)
tdSql
.
checkData
(
1
,
5
,
25
)
tdSql
.
checkData
(
1
,
6
,
26.1
)
tdSql
.
checkData
(
1
,
7
,
27.1
)
tdSql
.
checkData
(
1
,
8
,
1
)
tdSql
.
checkData
(
1
,
9
,
"binary9"
)
tdSql
.
checkData
(
1
,
10
,
"nchar10"
)
tdLog
.
printNoPrefix
(
"==========step3:alter stb drop tag create new chiltable"
)
tdSql
.
execute
(
"alter table stbtag drop tag t2 "
)
tdSql
.
execute
(
"alter table stbtag drop tag t3 "
)
tdSql
.
execute
(
"alter table stbtag drop tag t4 "
)
tdSql
.
execute
(
"alter table stbtag drop tag t5 "
)
tdSql
.
execute
(
"alter table stbtag drop tag t6 "
)
tdSql
.
execute
(
"alter table stbtag drop tag t7 "
)
tdSql
.
execute
(
"alter table stbtag drop tag t8 "
)
tdSql
.
execute
(
"alter table stbtag drop tag t9 "
)
tdSql
.
execute
(
"alter table stbtag drop tag t10 "
)
tdSql
.
execute
(
"create table tag3 using stbtag tags(3)"
)
tdSql
.
query
(
"select * from stbtag where tbname like 'tag3' "
)
tdSql
.
checkCols
(
3
)
tdSql
.
query
(
"select tbname, t1 from stbtag where tbname like 'tag3' "
)
tdSql
.
checkData
(
0
,
1
,
3
)
def
stop
(
self
):
tdSql
.
close
()
tdLog
.
success
(
f
"
{
__file__
}
successfully executed"
)
tdCases
.
addWindows
(
__file__
,
TDTestCase
())
tdCases
.
addLinux
(
__file__
,
TDTestCase
())
\ No newline at end of file
tests/pytest/fulltest.sh
浏览文件 @
d37fad65
...
@@ -219,6 +219,9 @@ python3 ./test.py -f query/bug3351.py
...
@@ -219,6 +219,9 @@ python3 ./test.py -f query/bug3351.py
python3 ./test.py
-f
query/bug3375.py
python3 ./test.py
-f
query/bug3375.py
python3 ./test.py
-f
query/queryJoin10tables.py
python3 ./test.py
-f
query/queryJoin10tables.py
python3 ./test.py
-f
query/queryStddevWithGroupby.py
python3 ./test.py
-f
query/queryStddevWithGroupby.py
python3 ./test.py
-f
query/querySecondtscolumnTowherenow.py
#stream
#stream
python3 ./test.py
-f
stream/metric_1.py
python3 ./test.py
-f
stream/metric_1.py
...
@@ -234,6 +237,7 @@ python3 ./test.py -f stream/table_n.py
...
@@ -234,6 +237,7 @@ python3 ./test.py -f stream/table_n.py
#alter table
#alter table
python3 ./test.py
-f
alter/alter_table_crash.py
python3 ./test.py
-f
alter/alter_table_crash.py
python3 ./test.py
-f
alter/alterTabAddTagWithNULL.py
# client
# client
python3 ./test.py
-f
client/client.py
python3 ./test.py
-f
client/client.py
...
...
tests/pytest/query/queryNormal.py
浏览文件 @
d37fad65
...
@@ -16,7 +16,7 @@ import taos
...
@@ -16,7 +16,7 @@ import taos
from
util.log
import
*
from
util.log
import
*
from
util.cases
import
*
from
util.cases
import
*
from
util.sql
import
*
from
util.sql
import
*
from
util.dnodes
import
*
class
TDTestCase
:
class
TDTestCase
:
def
init
(
self
,
conn
,
logSql
):
def
init
(
self
,
conn
,
logSql
):
...
@@ -122,6 +122,32 @@ class TDTestCase:
...
@@ -122,6 +122,32 @@ class TDTestCase:
tdSql
.
query
(
"SELECT server_status()"
)
tdSql
.
query
(
"SELECT server_status()"
)
tdSql
.
checkRows
(
1
)
tdSql
.
checkRows
(
1
)
# https://jira.taosdata.com:18080/browse/TD-3800
tdSql
.
execute
(
"create table m1(ts timestamp, k int) tags(a int)"
)
tdSql
.
execute
(
"create table tm0 using m1 tags(1)"
)
tdSql
.
execute
(
"create table tm1 using m1 tags(2)"
)
tdSql
.
execute
(
"insert into tm0 values('2020-3-1 1:1:1', 112)"
)
tdSql
.
execute
(
"insert into tm1 values('2020-1-1 1:1:1', 1)('2020-3-1 0:1:1', 421)"
)
tdSql
.
query
(
"select last(*) from m1 group by tbname"
)
tdSql
.
checkData
(
0
,
0
,
"2020-03-01 01:01:01"
)
tdSql
.
checkData
(
0
,
1
,
112
)
tdSql
.
checkData
(
0
,
2
,
"tm0"
)
tdSql
.
checkData
(
1
,
0
,
"2020-03-01 00:01:01"
)
tdSql
.
checkData
(
1
,
1
,
421
)
tdSql
.
checkData
(
1
,
2
,
"tm1"
)
tdDnodes
.
stop
(
1
)
tdDnodes
.
start
(
1
)
tdSql
.
query
(
"select last(*) from m1 group by tbname"
)
tdSql
.
checkData
(
0
,
0
,
"2020-03-01 01:01:01"
)
tdSql
.
checkData
(
0
,
1
,
112
)
tdSql
.
checkData
(
0
,
2
,
"tm0"
)
tdSql
.
checkData
(
1
,
0
,
"2020-03-01 00:01:01"
)
tdSql
.
checkData
(
1
,
1
,
421
)
tdSql
.
checkData
(
1
,
2
,
"tm1"
)
def
stop
(
self
):
def
stop
(
self
):
tdSql
.
close
()
tdSql
.
close
()
tdLog
.
success
(
"%s successfully executed"
%
__file__
)
tdLog
.
success
(
"%s successfully executed"
%
__file__
)
...
...
tests/pytest/query/querySecondtscolumnTowherenow.py
0 → 100644
浏览文件 @
d37fad65
###################################################################
# 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
from
util.log
import
*
from
util.cases
import
*
from
util.sql
import
*
from
util.dnodes
import
*
class
TDTestCase
:
def
init
(
self
,
conn
,
logSql
):
tdLog
.
debug
(
f
"start to execute
{
__file__
}
"
)
tdSql
.
init
(
conn
.
cursor
(),
logSql
)
def
run
(
self
):
tdSql
.
execute
(
"drop database if exists db"
)
tdSql
.
execute
(
"create database if not exists db keep 36500"
)
tdSql
.
execute
(
"use db"
)
tdLog
.
printNoPrefix
(
"==========step1:create table && insert data"
)
# timestamp list:
# 0->"1970-01-01 08:00:00" | -28800000->"1970-01-01 00:00:00" | -946800000000->"1940-01-01 00:00:00"
ts1
=
0
ts2
=
-
28800000
ts3
=
-
946800000000
tdSql
.
execute
(
"create table stb2ts (ts timestamp, ts1 timestamp, ts2 timestamp, c1 int, ts3 timestamp) TAGS(t1 int)"
)
tdSql
.
execute
(
"create table t2ts1 using stb2ts tags(1)"
)
tdSql
.
execute
(
"insert into t2ts1 values (now, now, now, 1, now)"
)
tdSql
.
execute
(
"insert into t2ts1 values (now-1m, now-1m, now-1m, 1, now-1m)"
)
tdSql
.
execute
(
f
"insert into t2ts1 values (
{
ts1
}
,
{
ts1
}
,
{
ts1
}
, 1,
{
ts1
}
)"
)
# tdSql.execute(f"insert into t2ts1 values ({ts2}, {ts2}, {ts2}, 1, {ts2})")
# tdSql.execute(f"insert into t2ts1 values ({ts3}, {ts3}, {ts3}, 1, {ts3})")
tdLog
.
printNoPrefix
(
"==========step2:query"
)
time
.
sleep
(
1
)
# query primary key timestamp column
tdSql
.
execute
(
"select * from t2ts1 where ts < now"
)
ts_len1
=
len
(
tdSql
.
cursor
.
fetchall
())
tdSql
.
execute
(
"select * from t2ts1 where ts <= now"
)
ts_len2
=
len
(
tdSql
.
cursor
.
fetchall
())
tdSql
.
execute
(
"select * from t2ts1 where ts > now"
)
ts_len3
=
len
(
tdSql
.
cursor
.
fetchall
())
tdSql
.
execute
(
"select * from t2ts1 where ts >= now"
)
ts_len4
=
len
(
tdSql
.
cursor
.
fetchall
())
tdSql
.
execute
(
"select * from t2ts1 where ts = now"
)
ts_len5
=
len
(
tdSql
.
cursor
.
fetchall
())
tdSql
.
execute
(
"select * from t2ts1 where ts <> now"
)
ts_len6
=
len
(
tdSql
.
cursor
.
fetchall
())
tdSql
.
execute
(
"select * from t2ts1 where ts between 0 and now"
)
ts_len7
=
len
(
tdSql
.
cursor
.
fetchall
())
tdSql
.
execute
(
"select * from t2ts1 where ts between now and now+100d"
)
ts_len8
=
len
(
tdSql
.
cursor
.
fetchall
())
# query noemal timestamp column
tdSql
.
query
(
"select * from t2ts1 where ts1 < now"
)
tdSql
.
checkRows
(
ts_len1
)
tdSql
.
query
(
"select * from t2ts1 where ts2 < now"
)
tdSql
.
checkRows
(
ts_len1
)
tdSql
.
query
(
"select * from t2ts1 where ts3 < now"
)
tdSql
.
checkRows
(
ts_len1
)
tdSql
.
query
(
"select * from t2ts1 where ts1 <= now"
)
tdSql
.
checkRows
(
ts_len2
)
tdSql
.
query
(
"select * from t2ts1 where ts2 <= now"
)
tdSql
.
checkRows
(
ts_len2
)
tdSql
.
query
(
"select * from t2ts1 where ts3 <= now"
)
tdSql
.
checkRows
(
ts_len2
)
tdSql
.
query
(
"select * from t2ts1 where ts1 > now"
)
tdSql
.
checkRows
(
ts_len3
)
tdSql
.
query
(
"select * from t2ts1 where ts2 > now"
)
tdSql
.
checkRows
(
ts_len3
)
tdSql
.
query
(
"select * from t2ts1 where ts3 > now"
)
tdSql
.
checkRows
(
ts_len3
)
tdSql
.
query
(
"select * from t2ts1 where ts1 >= now"
)
tdSql
.
checkRows
(
ts_len4
)
tdSql
.
query
(
"select * from t2ts1 where ts2 >= now"
)
tdSql
.
checkRows
(
ts_len4
)
tdSql
.
query
(
"select * from t2ts1 where ts3 >= now"
)
tdSql
.
checkRows
(
ts_len4
)
tdSql
.
query
(
"select * from t2ts1 where ts1 = now"
)
tdSql
.
checkRows
(
ts_len5
)
tdSql
.
query
(
"select * from t2ts1 where ts2 = now"
)
tdSql
.
checkRows
(
ts_len5
)
tdSql
.
query
(
"select * from t2ts1 where ts2 = now"
)
tdSql
.
checkRows
(
ts_len5
)
tdSql
.
query
(
"select * from t2ts1 where ts1 <> now"
)
tdSql
.
checkRows
(
ts_len6
)
tdSql
.
query
(
"select * from t2ts1 where ts2 <> now"
)
tdSql
.
checkRows
(
ts_len6
)
tdSql
.
query
(
"select * from t2ts1 where ts3 <> now"
)
tdSql
.
checkRows
(
ts_len6
)
tdSql
.
query
(
"select * from t2ts1 where ts1 between 0 and now"
)
tdSql
.
checkRows
(
ts_len7
)
tdSql
.
query
(
"select * from t2ts1 where ts2 between 0 and now"
)
tdSql
.
checkRows
(
ts_len7
)
tdSql
.
query
(
"select * from t2ts1 where ts3 between 0 and now"
)
tdSql
.
checkRows
(
ts_len7
)
tdSql
.
query
(
"select * from t2ts1 where ts1 between now and now+100d"
)
tdSql
.
checkRows
(
ts_len8
)
tdSql
.
query
(
"select * from t2ts1 where ts2 between now and now+100d"
)
tdSql
.
checkRows
(
ts_len8
)
tdSql
.
query
(
"select * from t2ts1 where ts3 between now and now+100d"
)
tdSql
.
checkRows
(
ts_len8
)
def
stop
(
self
):
tdSql
.
close
()
tdLog
.
success
(
f
"
{
__file__
}
successfully executed"
)
tdCases
.
addWindows
(
__file__
,
TDTestCase
())
tdCases
.
addLinux
(
__file__
,
TDTestCase
())
\ No newline at end of file
tests/pytest/util/sql.py
浏览文件 @
d37fad65
...
@@ -105,6 +105,14 @@ class TDSql:
...
@@ -105,6 +105,14 @@ class TDSql:
args
=
(
caller
.
filename
,
caller
.
lineno
,
self
.
sql
,
self
.
queryRows
,
expectRows
)
args
=
(
caller
.
filename
,
caller
.
lineno
,
self
.
sql
,
self
.
queryRows
,
expectRows
)
tdLog
.
exit
(
"%s(%d) failed: sql:%s, queryRows:%d != expect:%d"
%
args
)
tdLog
.
exit
(
"%s(%d) failed: sql:%s, queryRows:%d != expect:%d"
%
args
)
def
checkCols
(
self
,
expectCols
):
if
self
.
queryCols
==
expectCols
:
tdLog
.
info
(
"sql:%s, queryCols:%d == expect:%d"
%
(
self
.
sql
,
self
.
queryCols
,
expectCols
))
else
:
caller
=
inspect
.
getframeinfo
(
inspect
.
stack
()[
1
][
0
])
args
=
(
caller
.
filename
,
caller
.
lineno
,
self
.
sql
,
self
.
queryCols
,
expectCols
)
tdLog
.
exit
(
"%s(%d) failed: sql:%s, queryCols:%d != expect:%d"
%
args
)
def
checkRowCol
(
self
,
row
,
col
):
def
checkRowCol
(
self
,
row
,
col
):
caller
=
inspect
.
getframeinfo
(
inspect
.
stack
()[
2
][
0
])
caller
=
inspect
.
getframeinfo
(
inspect
.
stack
()[
2
][
0
])
if
row
<
0
:
if
row
<
0
:
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录