Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
48535f8b
T
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1185
Star
22017
Fork
4786
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
48535f8b
编写于
9月 29, 2021
作者:
W
wenzhouwww
浏览文件
操作
浏览文件
下载
差异文件
Merge branch 'master' into test/udf_for_master
上级
d34b1742
cf871c4c
变更
11
展开全部
显示空白变更内容
内联
并排
Showing
11 changed file
with
1114 addition
and
385 deletion
+1114
-385
src/client/src/tscSQLParser.c
src/client/src/tscSQLParser.c
+1
-1
src/kit/taosdemo/taosdemo.c
src/kit/taosdemo/taosdemo.c
+171
-120
src/kit/taosdump/taosdump.c
src/kit/taosdump/taosdump.c
+421
-259
tests/gotest/batchtest.bat
tests/gotest/batchtest.bat
+8
-0
tests/gotest/batchtest.sh
tests/gotest/batchtest.sh
+1
-0
tests/gotest/case001/case001.sh
tests/gotest/case001/case001.sh
+2
-3
tests/gotest/case002/case002.go
tests/gotest/case002/case002.go
+2
-2
tests/gotest/nanosupport/connector/executor.go
tests/gotest/nanosupport/connector/executor.go
+208
-0
tests/gotest/nanosupport/nanoCase.bat
tests/gotest/nanosupport/nanoCase.bat
+9
-0
tests/gotest/nanosupport/nanoCase.sh
tests/gotest/nanosupport/nanoCase.sh
+22
-0
tests/gotest/nanosupport/nanosupport.go
tests/gotest/nanosupport/nanosupport.go
+269
-0
未找到文件。
src/client/src/tscSQLParser.c
浏览文件 @
48535f8b
...
...
@@ -3011,7 +3011,7 @@ int32_t addExprAndResultField(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, int32_t col
return
invalidOperationMsg
(
tscGetErrorMsgPayload
(
pCmd
),
msg9
);
}
if
(
taosArrayGetSize
(
pItem
->
pNode
->
Expr
.
paramList
)
<=
0
)
{
if
(
pItem
->
pNode
->
Expr
.
paramList
==
NULL
||
taosArrayGetSize
(
pItem
->
pNode
->
Expr
.
paramList
)
<=
0
)
{
return
invalidOperationMsg
(
tscGetErrorMsgPayload
(
pCmd
),
msg13
);
}
...
...
src/kit/taosdemo/taosdemo.c
浏览文件 @
48535f8b
...
...
@@ -586,6 +586,7 @@ static int64_t getTSRandTail(int64_t timeStampStep, int32_t seq,
int
disorderRatio
,
int
disorderRange
);
static
bool
getInfoFromJsonFile
(
char
*
file
);
static
void
init_rand_data
();
static
int
regexMatch
(
const
char
*
s
,
const
char
*
reg
,
int
cflags
);
/* ************ Global variables ************ */
...
...
@@ -803,7 +804,7 @@ static void printHelp() {
printf
(
"%s%s%s%s
\n
"
,
indent
,
"-q, --query-mode=MODE"
,
"
\t\t
"
,
"Query mode -- 0: SYNC, 1: ASYNC. By default use SYNC."
);
printf
(
"%s%s%s%s
\n
"
,
indent
,
"-b, --data-type=DATATYPE"
,
"
\t
"
,
"The data_type of columns, By default use: FLOAT,
INT, FLOAT.
"
);
"The data_type of columns, By default use: FLOAT,
INT,FLOAT. NCHAR and BINARY can also use custom length. Eg: NCHAR(16),BINARY(8)
"
);
printf
(
"%s%s%s%s%d
\n
"
,
indent
,
"-w, --binwidth=WIDTH"
,
"
\t\t
"
,
"The width of data_type 'BINARY' or 'NCHAR'. By default use "
,
g_args
.
binwidth
);
...
...
@@ -985,36 +986,55 @@ static void parse_args(int argc, char *argv[], SArguments *arguments) {
arguments
->
performance_print
=
true
;
}
else
if
((
0
==
strncmp
(
argv
[
i
],
"-P"
,
strlen
(
"-P"
)))
||
(
0
==
strncmp
(
argv
[
i
],
"--port"
,
strlen
(
"--port"
))))
{
uint64_t
port
;
char
strPort
[
BIGINT_BUFF_LEN
];
if
(
2
==
strlen
(
argv
[
i
]))
{
if
(
argc
==
i
+
1
)
{
errorPrintReqArg
(
argv
[
0
],
"P"
);
exit
(
EXIT_FAILURE
);
}
else
if
(
!
isStringNumber
(
argv
[
i
+
1
]))
{
}
else
if
(
isStringNumber
(
argv
[
i
+
1
]))
{
tstrncpy
(
strPort
,
argv
[
++
i
],
BIGINT_BUFF_LEN
);
}
else
{
errorPrintReqArg2
(
argv
[
0
],
"P"
);
exit
(
EXIT_FAILURE
);
}
arguments
->
port
=
atoi
(
argv
[
++
i
]);
}
else
if
(
0
==
strncmp
(
argv
[
i
],
"--port="
,
strlen
(
"--port="
)))
{
if
(
isStringNumber
((
char
*
)(
argv
[
i
]
+
strlen
(
"--port="
))))
{
arguments
->
port
=
atoi
((
char
*
)(
argv
[
i
]
+
strlen
(
"--port="
)));
tstrncpy
(
strPort
,
(
char
*
)(
argv
[
i
]
+
strlen
(
"--port="
)),
BIGINT_BUFF_LEN
);
}
else
{
errorPrintReqArg2
(
argv
[
0
],
"--port"
);
exit
(
EXIT_FAILURE
);
}
}
else
if
(
0
==
strncmp
(
argv
[
i
],
"-P"
,
strlen
(
"-P"
)))
{
if
(
isStringNumber
((
char
*
)(
argv
[
i
]
+
strlen
(
"-P"
))))
{
arguments
->
port
=
atoi
((
char
*
)(
argv
[
i
]
+
strlen
(
"-P"
)));
tstrncpy
(
strPort
,
(
char
*
)(
argv
[
i
]
+
strlen
(
"-P"
)),
BIGINT_BUFF_LEN
);
}
else
{
errorPrintReqArg2
(
argv
[
0
],
"--port"
);
exit
(
EXIT_FAILURE
);
}
}
else
if
(
strlen
(
"--port"
)
==
strlen
(
argv
[
i
]))
{
if
(
argc
==
i
+
1
)
{
errorPrintReqArg3
(
argv
[
0
],
"--port"
);
exit
(
EXIT_FAILURE
);
}
else
if
(
!
isStringNumber
(
argv
[
i
+
1
]))
{
}
else
if
(
isStringNumber
(
argv
[
i
+
1
]))
{
tstrncpy
(
strPort
,
argv
[
++
i
],
BIGINT_BUFF_LEN
);
}
else
{
errorPrintReqArg2
(
argv
[
0
],
"--port"
);
exit
(
EXIT_FAILURE
);
}
arguments
->
port
=
atoi
(
argv
[
++
i
]);
}
else
{
errorUnrecognized
(
argv
[
0
],
argv
[
i
]);
exit
(
EXIT_FAILURE
);
}
port
=
atoi
(
strPort
);
if
(
port
>
65535
)
{
errorWrongValue
(
"taosdump"
,
"-P or --port"
,
strPort
);
exit
(
EXIT_FAILURE
);
}
arguments
->
port
=
(
uint16_t
)
port
;
}
else
if
((
0
==
strncmp
(
argv
[
i
],
"-I"
,
strlen
(
"-I"
)))
||
(
0
==
strncmp
(
argv
[
i
],
"--interface"
,
strlen
(
"--interface"
))))
{
if
(
2
==
strlen
(
argv
[
i
]))
{
...
...
@@ -1579,9 +1599,10 @@ static void parse_args(int argc, char *argv[], SArguments *arguments) {
&&
strcasecmp
(
dataType
,
"SMALLINT"
)
&&
strcasecmp
(
dataType
,
"BIGINT"
)
&&
strcasecmp
(
dataType
,
"DOUBLE"
)
&&
strcasecmp
(
dataType
,
"BINARY"
)
&&
strcasecmp
(
dataType
,
"TIMESTAMP"
)
&&
strcasecmp
(
dataType
,
"NCHAR"
)
&&
!
regexMatch
(
dataType
,
"^(NCHAR|BINARY)(
\\
([1-9][0-9]*
\\
))?$"
,
REG_ICASE
|
REG_EXTENDED
)
&&
strcasecmp
(
dataType
,
"UTINYINT"
)
&&
strcasecmp
(
dataType
,
"USMALLINT"
)
&&
strcasecmp
(
dataType
,
"UINT"
)
...
...
@@ -1603,9 +1624,13 @@ static void parse_args(int argc, char *argv[], SArguments *arguments) {
arguments
->
data_type
[
0
]
=
TSDB_DATA_TYPE_FLOAT
;
}
else
if
(
0
==
strcasecmp
(
dataType
,
"DOUBLE"
))
{
arguments
->
data_type
[
0
]
=
TSDB_DATA_TYPE_DOUBLE
;
}
else
if
(
0
==
strcasecmp
(
dataType
,
"BINARY"
))
{
}
else
if
(
1
==
regexMatch
(
dataType
,
"^BINARY(
\\
([1-9][0-9]*
\\
))?$"
,
REG_ICASE
|
REG_EXTENDED
))
{
arguments
->
data_type
[
0
]
=
TSDB_DATA_TYPE_BINARY
;
}
else
if
(
0
==
strcasecmp
(
dataType
,
"NCHAR"
))
{
}
else
if
(
1
==
regexMatch
(
dataType
,
"^NCHAR(
\\
([1-9][0-9]*
\\
))?$"
,
REG_ICASE
|
REG_EXTENDED
))
{
arguments
->
data_type
[
0
]
=
TSDB_DATA_TYPE_NCHAR
;
}
else
if
(
0
==
strcasecmp
(
dataType
,
"BOOL"
))
{
arguments
->
data_type
[
0
]
=
TSDB_DATA_TYPE_BOOL
;
...
...
@@ -1638,9 +1663,8 @@ static void parse_args(int argc, char *argv[], SArguments *arguments) {
&&
strcasecmp
(
token
,
"SMALLINT"
)
&&
strcasecmp
(
token
,
"BIGINT"
)
&&
strcasecmp
(
token
,
"DOUBLE"
)
&&
strcasecmp
(
token
,
"BINARY"
)
&&
strcasecmp
(
token
,
"TIMESTAMP"
)
&&
strcasecmp
(
token
,
"NCHAR"
)
&&
!
regexMatch
(
token
,
"^(NCHAR|BINARY)(
\\
([1-9][0-9]*
\\
))?$"
,
REG_ICASE
|
REG_EXTENDED
)
&&
strcasecmp
(
token
,
"UTINYINT"
)
&&
strcasecmp
(
token
,
"USMALLINT"
)
&&
strcasecmp
(
token
,
"UINT"
)
...
...
@@ -1663,9 +1687,11 @@ static void parse_args(int argc, char *argv[], SArguments *arguments) {
arguments
->
data_type
[
index
]
=
TSDB_DATA_TYPE_DOUBLE
;
}
else
if
(
0
==
strcasecmp
(
token
,
"TINYINT"
))
{
arguments
->
data_type
[
index
]
=
TSDB_DATA_TYPE_TINYINT
;
}
else
if
(
0
==
strcasecmp
(
token
,
"BINARY"
))
{
}
else
if
(
1
==
regexMatch
(
token
,
"^BINARY(
\\
([1-9][0-9]*
\\
))?$"
,
REG_ICASE
|
REG_EXTENDED
))
{
arguments
->
data_type
[
index
]
=
TSDB_DATA_TYPE_BINARY
;
}
else
if
(
0
==
strcasecmp
(
token
,
"NCHAR"
))
{
}
else
if
(
1
==
regexMatch
(
token
,
"^NCHAR(
\\
([1-9][0-9]*
\\
))?$"
,
REG_ICASE
|
REG_EXTENDED
))
{
arguments
->
data_type
[
index
]
=
TSDB_DATA_TYPE_NCHAR
;
}
else
if
(
0
==
strcasecmp
(
token
,
"BOOL"
))
{
arguments
->
data_type
[
index
]
=
TSDB_DATA_TYPE_BOOL
;
...
...
@@ -2660,6 +2686,8 @@ static int printfInsertMeta() {
}
}
if
(
g_args
.
use_metric
)
{
printf
(
" super table count:
\033
[33m%"
PRIu64
"
\033
[0m
\n
"
,
g_Dbs
.
db
[
i
].
superTblCount
);
for
(
uint64_t
j
=
0
;
j
<
g_Dbs
.
db
[
i
].
superTblCount
;
j
++
)
{
...
...
@@ -2735,7 +2763,7 @@ static int printfInsertMeta() {
g_Dbs
.
db
[
i
].
superTbls
[
j
].
sampleFile
);
printf
(
" tagsFile:
\033
[33m%s
\033
[0m
\n
"
,
g_Dbs
.
db
[
i
].
superTbls
[
j
].
tagsFile
);
printf
(
" columnCount:
\033
[33m%d
\033
[0m
\n
"
,
printf
(
" columnCount:
\033
[33m%d
\033
[0m
\n
"
,
g_Dbs
.
db
[
i
].
superTbls
[
j
].
columnCount
);
for
(
int
k
=
0
;
k
<
g_Dbs
.
db
[
i
].
superTbls
[
j
].
columnCount
;
k
++
)
{
//printf("dataType:%s, dataLen:%d\t", g_Dbs.db[i].superTbls[j].columns[k].dataType, g_Dbs.db[i].superTbls[j].columns[k].dataLen);
...
...
@@ -2743,7 +2771,7 @@ static int printfInsertMeta() {
"binary"
,
6
))
||
(
0
==
strncasecmp
(
g_Dbs
.
db
[
i
].
superTbls
[
j
].
columns
[
k
].
dataType
,
"nchar"
,
5
)))
{
printf
(
"column[
\033
[33m%d
\033
[0m
]:
\033
[33m%s(%d)
\033
[0m "
,
k
,
printf
(
"column[%d
]:
\033
[33m%s(%d)
\033
[0m "
,
k
,
g_Dbs
.
db
[
i
].
superTbls
[
j
].
columns
[
k
].
dataType
,
g_Dbs
.
db
[
i
].
superTbls
[
j
].
columns
[
k
].
dataLen
);
}
else
{
...
...
@@ -2771,6 +2799,14 @@ static int printfInsertMeta() {
}
printf
(
"
\n
"
);
}
}
else
{
printf
(
" childTblCount:
\033
[33m%"
PRId64
"
\033
[0m
\n
"
,
g_args
.
ntables
);
printf
(
" insertRows:
\033
[33m%"
PRId64
"
\033
[0m
\n
"
,
g_args
.
insertRows
);
}
printf
(
"
\n
"
);
}
...
...
@@ -4271,6 +4307,10 @@ static int createSuperTable(
len
+=
snprintf
(
tags
+
len
,
TSDB_MAX_TAGS_LEN
-
len
,
"T%d %s,"
,
tagIndex
,
"BIGINT UNSIGNED"
);
lenOfTagOfOneRow
+=
superTbl
->
tags
[
tagIndex
].
dataLen
+
BIGINT_BUFF_LEN
;
}
else
if
(
strcasecmp
(
dataType
,
"TIMESTAMP"
)
==
0
)
{
len
+=
snprintf
(
tags
+
len
,
TSDB_MAX_TAGS_LEN
-
len
,
"T%d %s,"
,
tagIndex
,
"TIMESTAMP"
);
lenOfTagOfOneRow
+=
superTbl
->
tags
[
tagIndex
].
dataLen
+
TIMESTAMP_BUFF_LEN
;
}
else
{
taos_close
(
taos
);
free
(
command
);
...
...
@@ -10263,7 +10303,7 @@ static void startMultiThreadInsertData(int threads, char* db_name,
&
stbInfo
->
childTblName
,
&
childTblCount
,
limit
,
offset
);
ntables
=
childTblCount
;
// CBD
ntables
=
childTblCount
;
}
else
{
ntables
=
g_args
.
ntables
;
tableFrom
=
0
;
...
...
@@ -10282,8 +10322,7 @@ static void startMultiThreadInsertData(int threads, char* db_name,
b
=
ntables
%
threads
;
}
if
((
stbInfo
)
&&
(
stbInfo
->
iface
==
REST_IFACE
))
{
if
(
g_args
.
iface
==
REST_IFACE
||
((
stbInfo
)
&&
(
stbInfo
->
iface
==
REST_IFACE
)))
{
if
(
convertHostToServAddr
(
g_Dbs
.
host
,
g_Dbs
.
port
,
&
(
g_Dbs
.
serv_addr
))
!=
0
)
{
ERROR_EXIT
(
"convert host to server address"
);
...
...
@@ -11734,6 +11773,8 @@ static void initOfQueryMeta() {
}
static
void
setParaFromArg
()
{
char
type
[
20
];
char
length
[
20
];
if
(
g_args
.
host
)
{
tstrncpy
(
g_Dbs
.
host
,
g_args
.
host
,
MAX_HOSTNAME_SIZE
);
}
else
{
...
...
@@ -11815,7 +11856,17 @@ static void setParaFromArg() {
g_Dbs
.
db
[
0
].
superTbls
[
0
].
columns
[
i
].
data_type
=
data_type
[
i
];
tstrncpy
(
g_Dbs
.
db
[
0
].
superTbls
[
0
].
columns
[
i
].
dataType
,
dataType
[
i
],
min
(
DATATYPE_BUFF_LEN
,
strlen
(
dataType
[
i
])
+
1
));
if
(
1
==
regexMatch
(
dataType
[
i
],
"^(NCHAR|BINARY)(
\\
([1-9][0-9]*
\\
))$"
,
REG_ICASE
|
REG_EXTENDED
))
{
sscanf
(
dataType
[
i
],
"%[^(](%[^)]"
,
type
,
length
);
g_Dbs
.
db
[
0
].
superTbls
[
0
].
columns
[
i
].
dataLen
=
atoi
(
length
);
tstrncpy
(
g_Dbs
.
db
[
0
].
superTbls
[
0
].
columns
[
i
].
dataType
,
type
,
min
(
DATATYPE_BUFF_LEN
,
strlen
(
type
)
+
1
));
}
else
{
g_Dbs
.
db
[
0
].
superTbls
[
0
].
columns
[
i
].
dataLen
=
g_args
.
binwidth
;
tstrncpy
(
g_Dbs
.
db
[
0
].
superTbls
[
0
].
columns
[
i
].
dataType
,
dataType
[
i
],
min
(
DATATYPE_BUFF_LEN
,
strlen
(
dataType
[
i
])
+
1
));
}
g_Dbs
.
db
[
0
].
superTbls
[
0
].
columnCount
++
;
}
...
...
src/kit/taosdump/taosdump.c
浏览文件 @
48535f8b
此差异已折叠。
点击以展开。
tests/gotest/batchtest.bat
浏览文件 @
48535f8b
@echo
off
echo
====
start
Go
connector
test
cases
test
====
cd
/d
%~dp0
...
...
@@ -18,3 +19,10 @@ rem case002.bat
:: cd case002
:: case002.bat
rem cd nanosupport
rem nanoCase.bat
:: cd nanosupport
:: nanoCase.bat
tests/gotest/batchtest.sh
浏览文件 @
48535f8b
...
...
@@ -19,3 +19,4 @@ go env -w GOPROXY=https://goproxy.cn,direct
bash ./case001/case001.sh
$severIp
$serverPort
bash ./case002/case002.sh
$severIp
$serverPort
#bash ./case003/case003.sh $severIp $serverPort
bash ./nanosupport/nanoCase.sh
$severIp
$serverPort
tests/gotest/case001/case001.sh
浏览文件 @
48535f8b
...
...
@@ -15,8 +15,7 @@ script_dir="$(dirname $(readlink -f $0))"
###### step 3: start build
cd
$script_dir
rm
-f
go.
*
go mod init demotest
>
/dev/null 2>&1
go mod tidy
>
/dev/null 2>&1
go build
>
/dev/null 2>&1
go mod init demotest
go build
sleep
1s
./demotest
-h
$1
-p
$2
tests/gotest/case002/case002.go
浏览文件 @
48535f8b
...
...
@@ -44,7 +44,7 @@ func main() {
}
defer
db
.
Close
()
db
.
Exec
(
"drop database if exists test"
)
db
.
Exec
(
"create database if not exists test"
)
db
.
Exec
(
"create database if not exists test
"
)
db
.
Exec
(
"use test"
)
db
.
Exec
(
"create table test (ts timestamp ,level int)"
)
for
i
:=
0
;
i
<
10
;
i
++
{
...
...
tests/gotest/nanosupport/connector/executor.go
0 → 100644
浏览文件 @
48535f8b
package
connector
import
(
"context"
"fmt"
"reflect"
"time"
"github.com/taosdata/go-utils/log"
"github.com/taosdata/go-utils/tdengine/config"
"github.com/taosdata/go-utils/tdengine/connector"
tdengineExecutor
"github.com/taosdata/go-utils/tdengine/executor"
)
type
Executor
struct
{
executor
*
tdengineExecutor
.
Executor
ctx
context
.
Context
}
var
Logger
=
log
.
NewLogger
(
"taos test"
)
func
NewExecutor
(
conf
*
config
.
TDengineGo
,
db
string
,
showSql
bool
)
(
*
Executor
,
error
)
{
tdengineConnector
,
err
:=
connector
.
NewTDengineConnector
(
"go"
,
conf
)
if
err
!=
nil
{
return
nil
,
err
}
executor
:=
tdengineExecutor
.
NewExecutor
(
tdengineConnector
,
db
,
showSql
,
Logger
)
return
&
Executor
{
executor
:
executor
,
ctx
:
context
.
Background
(),
},
nil
}
func
(
e
*
Executor
)
Execute
(
sql
string
)
(
int64
,
error
)
{
return
e
.
executor
.
DoExec
(
e
.
ctx
,
sql
)
}
func
(
e
*
Executor
)
Query
(
sql
string
)
(
*
connector
.
Data
,
error
)
{
fmt
.
Println
(
"query :"
,
sql
)
return
e
.
executor
.
DoQuery
(
e
.
ctx
,
sql
)
}
func
(
e
*
Executor
)
CheckData
(
row
,
col
int
,
value
interface
{},
data
*
connector
.
Data
)
(
bool
,
error
)
{
if
data
==
nil
{
return
false
,
fmt
.
Errorf
(
"data is nil"
)
}
if
col
>=
len
(
data
.
Head
)
{
return
false
,
fmt
.
Errorf
(
"col out of data"
)
}
if
row
>=
len
(
data
.
Data
)
{
return
false
,
fmt
.
Errorf
(
"row out of data"
)
}
dataValue
:=
data
.
Data
[
row
][
col
]
if
dataValue
==
nil
&&
value
!=
nil
{
return
false
,
fmt
.
Errorf
(
"dataValue is nil but value is not nil"
)
}
if
dataValue
==
nil
&&
value
==
nil
{
return
true
,
nil
}
if
reflect
.
TypeOf
(
dataValue
)
!=
reflect
.
TypeOf
(
value
)
{
return
false
,
fmt
.
Errorf
(
"type not match expect %s got %s"
,
reflect
.
TypeOf
(
value
),
reflect
.
TypeOf
(
dataValue
))
}
switch
value
.
(
type
)
{
case
time
.
Time
:
t
,
_
:=
dataValue
.
(
time
.
Time
)
if
value
.
(
time
.
Time
)
.
Nanosecond
()
!=
t
.
Nanosecond
()
{
return
false
,
fmt
.
Errorf
(
"value not match expect %d got %d"
,
value
.
(
time
.
Time
)
.
Nanosecond
(),
t
.
Nanosecond
())
}
case
string
:
if
value
.
(
string
)
!=
dataValue
.
(
string
)
{
return
false
,
fmt
.
Errorf
(
"value not match expect %s got %s"
,
value
.
(
string
),
dataValue
.
(
string
))
}
case
int8
:
if
value
.
(
int8
)
!=
dataValue
.
(
int8
)
{
return
false
,
fmt
.
Errorf
(
"value not match expect %d got %d"
,
value
.
(
int8
),
dataValue
.
(
int8
))
}
case
int16
:
if
value
.
(
int16
)
!=
dataValue
.
(
int16
)
{
return
false
,
fmt
.
Errorf
(
"value not match expect %d got %d"
,
value
.
(
int16
),
dataValue
.
(
int16
))
}
case
int32
:
if
value
.
(
int32
)
!=
dataValue
.
(
int32
)
{
return
false
,
fmt
.
Errorf
(
"value not match expect %d got %d"
,
value
.
(
int32
),
dataValue
.
(
int32
))
}
case
int64
:
if
value
.
(
int64
)
!=
dataValue
.
(
int64
)
{
return
false
,
fmt
.
Errorf
(
"value not match expect %d got %d"
,
value
.
(
int64
),
dataValue
.
(
int64
))
}
case
float32
:
if
value
.
(
float32
)
!=
dataValue
.
(
float32
)
{
return
false
,
fmt
.
Errorf
(
"value not match expect %f got %f"
,
value
.
(
float32
),
dataValue
.
(
float32
))
}
case
float64
:
if
value
.
(
float64
)
!=
dataValue
.
(
float64
)
{
return
false
,
fmt
.
Errorf
(
"value not match expect %f got %f"
,
value
.
(
float32
),
dataValue
.
(
float32
))
}
case
bool
:
if
value
.
(
bool
)
!=
dataValue
.
(
bool
)
{
return
false
,
fmt
.
Errorf
(
"value not match expect %t got %t"
,
value
.
(
bool
),
dataValue
.
(
bool
))
}
default
:
return
false
,
fmt
.
Errorf
(
"unsupport type %v"
,
reflect
.
TypeOf
(
value
))
}
return
true
,
nil
}
func
(
e
*
Executor
)
CheckData2
(
row
,
col
int
,
value
interface
{},
data
*
connector
.
Data
)
{
match
,
err
:=
e
.
CheckData
(
row
,
col
,
value
,
data
)
fmt
.
Println
(
"expect data is :"
,
value
)
fmt
.
Println
(
"go got data is :"
,
data
.
Data
[
row
][
col
])
if
err
!=
nil
{
fmt
.
Println
(
err
)
}
if
!
match
{
fmt
.
Println
(
" data not match"
)
}
/*
fmt.Println(value)
if data == nil {
// return false, fmt.Errorf("data is nil")
// fmt.Println("check failed")
}
if col >= len(data.Head) {
// return false, fmt.Errorf("col out of data")
// fmt.Println("check failed")
}
if row >= len(data.Data) {
// return false, fmt.Errorf("row out of data")
// fmt.Println("check failed")
}
dataValue := data.Data[row][col]
if dataValue == nil && value != nil {
// return false, fmt.Errorf("dataValue is nil but value is not nil")
// fmt.Println("check failed")
}
if dataValue == nil && value == nil {
// return true, nil
fmt.Println("check pass")
}
if reflect.TypeOf(dataValue) != reflect.TypeOf(value) {
// return false, fmt.Errorf("type not match expect %s got %s", reflect.TypeOf(value), reflect.TypeOf(dataValue))
fmt.Println("check failed")
}
switch value.(type) {
case time.Time:
t, _ := dataValue.(time.Time)
if value.(time.Time).Nanosecond() != t.Nanosecond() {
// return false, fmt.Errorf("value not match expect %d got %d", value.(time.Time).Nanosecond(), t.Nanosecond())
// fmt.Println("check failed")
}
case string:
if value.(string) != dataValue.(string) {
// return false, fmt.Errorf("value not match expect %s got %s", value.(string), dataValue.(string))
// fmt.Println("check failed")
}
case int8:
if value.(int8) != dataValue.(int8) {
// return false, fmt.Errorf("value not match expect %d got %d", value.(int8), dataValue.(int8))
// fmt.Println("check failed")
}
case int16:
if value.(int16) != dataValue.(int16) {
// return false, fmt.Errorf("value not match expect %d got %d", value.(int16), dataValue.(int16))
// fmt.Println("check failed")
}
case int32:
if value.(int32) != dataValue.(int32) {
// return false, fmt.Errorf("value not match expect %d got %d", value.(int32), dataValue.(int32))
// fmt.Println("check failed")
}
case int64:
if value.(int64) != dataValue.(int64) {
// return false, fmt.Errorf("value not match expect %d got %d", value.(int64), dataValue.(int64))
// fmt.Println("check failed")
}
case float32:
if value.(float32) != dataValue.(float32) {
// return false, fmt.Errorf("value not match expect %f got %f", value.(float32), dataValue.(float32))
// fmt.Println("check failed")
}
case float64:
if value.(float64) != dataValue.(float64) {
// return false, fmt.Errorf("value not match expect %f got %f", value.(float32), dataValue.(float32))
// fmt.Println("check failed")
}
case bool:
if value.(bool) != dataValue.(bool) {
// return false, fmt.Errorf("value not match expect %t got %t", value.(bool), dataValue.(bool))
// fmt.Println("check failed")
}
default:
// return false, fmt.Errorf("unsupport type %v", reflect.TypeOf(value))
// fmt.Println("check failed")
}
// return true, nil
// fmt.Println("check pass")
*/
}
func
(
e
*
Executor
)
CheckRow
(
count
int
,
data
*
connector
.
Data
)
{
if
len
(
data
.
Data
)
!=
count
{
fmt
.
Println
(
"check failed !"
)
}
}
tests/gotest/nanosupport/nanoCase.bat
0 → 100644
浏览文件 @
48535f8b
@echo
off
echo
====
start
run
nanosupport
.go
del
go
.
*
go
mod
init
nano
go
mod
tidy
go
build
nano
.exe
-h
%
1
-p
%
2
cd
..
tests/gotest/nanosupport/nanoCase.sh
0 → 100644
浏览文件 @
48535f8b
#!/bin/bash
echo
"==== start run nanosupport.go "
set
+e
#set -x
script_dir
=
"
$(
dirname
$(
readlink
-f
$0
))
"
#echo "pwd: $script_dir, para0: $0"
#execName=$0
#execName=`echo ${execName##*/}`
#goName=`echo ${execName%.*}`
###### step 3: start build
cd
$script_dir
rm
-f
go.
*
go mod init nano
go mod tidy
go build
sleep
10s
./nano
-h
$1
-p
$2
tests/gotest/nanosupport/nanosupport.go
0 → 100644
浏览文件 @
48535f8b
package
main
import
(
"fmt"
"log"
"nano/connector"
"time"
"github.com/taosdata/go-utils/tdengine/config"
)
func
main
()
{
e
,
err
:=
connector
.
NewExecutor
(
&
config
.
TDengineGo
{
Address
:
"root:taosdata@/tcp(127.0.0.1:6030)/"
,
MaxIdle
:
20
,
MaxOpen
:
30
,
MaxLifetime
:
30
,
},
"db"
,
false
)
if
err
!=
nil
{
panic
(
err
)
}
prepareData
(
e
)
data
,
err
:=
e
.
Query
(
"select * from tb"
)
if
err
!=
nil
{
panic
(
err
)
}
layout
:=
"2006-01-02 15:04:05.999999999"
t0
,
_
:=
time
.
Parse
(
layout
,
"2021-06-10 00:00:00.100000001"
)
t1
,
_
:=
time
.
Parse
(
layout
,
"2021-06-10 00:00:00.150000000"
)
t2
,
_
:=
time
.
Parse
(
layout
,
"2021-06-10 00:00:00.299999999"
)
t3
,
_
:=
time
.
Parse
(
layout
,
"2021-06-10 00:00:00.300000000"
)
t4
,
_
:=
time
.
Parse
(
layout
,
"2021-06-10 00:00:00.300000001"
)
t5
,
_
:=
time
.
Parse
(
layout
,
"2021-06-10 00:00:00.999999999"
)
e
.
CheckData2
(
0
,
0
,
t0
,
data
)
e
.
CheckData2
(
1
,
0
,
t1
,
data
)
e
.
CheckData2
(
2
,
0
,
t2
,
data
)
e
.
CheckData2
(
3
,
0
,
t3
,
data
)
e
.
CheckData2
(
4
,
0
,
t4
,
data
)
e
.
CheckData2
(
5
,
0
,
t5
,
data
)
e
.
CheckData2
(
3
,
1
,
int32
(
3
),
data
)
e
.
CheckData2
(
4
,
1
,
int32
(
5
),
data
)
e
.
CheckData2
(
5
,
1
,
int32
(
7
),
data
)
fmt
.
Println
(
" start check nano support!"
)
data
,
_
=
e
.
Query
(
"select count(*) from tb where ts > 1623254400100000000 and ts < 1623254400100000002;"
)
e
.
CheckData2
(
0
,
0
,
int64
(
1
),
data
)
data
,
_
=
e
.
Query
(
"select count(*) from tb where ts >
\"
2021-06-10 0:00:00.100000001
\"
and ts <
\"
2021-06-10 0:00:00.160000000
\"
;"
)
e
.
CheckData2
(
0
,
0
,
int64
(
1
),
data
)
data
,
_
=
e
.
Query
(
"select count(*) from tb where ts > 1623254400100000000 and ts < 1623254400150000000;"
)
e
.
CheckData2
(
0
,
0
,
int64
(
1
),
data
)
data
,
_
=
e
.
Query
(
"select count(*) from tb where ts >
\"
2021-06-10 0:00:00.100000000
\"
and ts <
\"
2021-06-10 0:00:00.150000000
\"
;"
)
e
.
CheckData2
(
0
,
0
,
int64
(
1
),
data
)
data
,
_
=
e
.
Query
(
"select count(*) from tb where ts > 1623254400400000000;"
)
e
.
CheckData2
(
0
,
0
,
int64
(
1
),
data
)
data
,
_
=
e
.
Query
(
"select count(*) from tb where ts <
\"
2021-06-10 00:00:00.400000000
\"
;"
)
e
.
CheckData2
(
0
,
0
,
int64
(
5
),
data
)
data
,
_
=
e
.
Query
(
"select count(*) from tb where ts < now + 400000000b;"
)
e
.
CheckData2
(
0
,
0
,
int64
(
6
),
data
)
data
,
_
=
e
.
Query
(
"select count(*) from tb where ts >=
\"
2021-06-10 0:00:00.100000001
\"
;"
)
e
.
CheckData2
(
0
,
0
,
int64
(
6
),
data
)
data
,
_
=
e
.
Query
(
"select count(*) from tb where ts <= 1623254400300000000;"
)
e
.
CheckData2
(
0
,
0
,
int64
(
4
),
data
)
data
,
_
=
e
.
Query
(
"select count(*) from tb where ts =
\"
2021-06-10 0:00:00.000000000
\"
;"
)
data
,
_
=
e
.
Query
(
"select count(*) from tb where ts = 1623254400150000000;"
)
e
.
CheckData2
(
0
,
0
,
int64
(
1
),
data
)
data
,
_
=
e
.
Query
(
"select count(*) from tb where ts =
\"
2021-06-10 0:00:00.100000001
\"
;"
)
e
.
CheckData2
(
0
,
0
,
int64
(
1
),
data
)
data
,
_
=
e
.
Query
(
"select count(*) from tb where ts between 1623254400000000000 and 1623254400400000000;"
)
e
.
CheckData2
(
0
,
0
,
int64
(
5
),
data
)
data
,
_
=
e
.
Query
(
"select count(*) from tb where ts between
\"
2021-06-10 0:00:00.299999999
\"
and
\"
2021-06-10 0:00:00.300000001
\"
;"
)
e
.
CheckData2
(
0
,
0
,
int64
(
3
),
data
)
data
,
_
=
e
.
Query
(
"select avg(speed) from tb interval(5000000000b);"
)
e
.
CheckRow
(
1
,
data
)
data
,
_
=
e
.
Query
(
"select avg(speed) from tb interval(100000000b)"
)
e
.
CheckRow
(
4
,
data
)
data
,
_
=
e
.
Query
(
"select avg(speed) from tb interval(1000b);"
)
e
.
CheckRow
(
5
,
data
)
data
,
_
=
e
.
Query
(
"select avg(speed) from tb interval(1u);"
)
e
.
CheckRow
(
5
,
data
)
data
,
_
=
e
.
Query
(
"select avg(speed) from tb interval(100000000b) sliding (100000000b);"
)
e
.
CheckRow
(
4
,
data
)
data
,
_
=
e
.
Query
(
"select last(*) from tb"
)
tt
,
_
:=
time
.
Parse
(
layout
,
"2021-06-10 0:00:00.999999999"
)
e
.
CheckData2
(
0
,
0
,
tt
,
data
)
data
,
_
=
e
.
Query
(
"select first(*) from tb"
)
tt1
,
_
:=
time
.
Parse
(
layout
,
"2021-06-10 0:00:00.100000001"
)
e
.
CheckData2
(
0
,
0
,
tt1
,
data
)
e
.
Execute
(
"insert into tb values(now + 500000000b, 6);"
)
data
,
_
=
e
.
Query
(
"select * from tb;"
)
e
.
CheckRow
(
7
,
data
)
e
.
Execute
(
"create table tb2 (ts timestamp, speed int, ts2 timestamp);"
)
e
.
Execute
(
"insert into tb2 values(
\"
2021-06-10 0:00:00.100000001
\"
, 1,
\"
2021-06-11 0:00:00.100000001
\"
);"
)
e
.
Execute
(
"insert into tb2 values(1623254400150000000, 2, 1623340800150000000);"
)
e
.
Execute
(
"import into tb2 values(1623254400300000000, 3, 1623340800300000000);"
)
e
.
Execute
(
"import into tb2 values(1623254400299999999, 4, 1623340800299999999);"
)
e
.
Execute
(
"insert into tb2 values(1623254400300000001, 5, 1623340800300000001);"
)
e
.
Execute
(
"insert into tb2 values(1623254400999999999, 7, 1623513600999999999);"
)
data
,
_
=
e
.
Query
(
"select * from tb2;"
)
tt2
,
_
:=
time
.
Parse
(
layout
,
"2021-06-10 0:00:00.100000001"
)
tt3
,
_
:=
time
.
Parse
(
layout
,
"2021-06-10 0:00:00.150000000"
)
e
.
CheckData2
(
0
,
0
,
tt2
,
data
)
e
.
CheckData2
(
1
,
0
,
tt3
,
data
)
e
.
CheckData2
(
2
,
1
,
int32
(
4
),
data
)
e
.
CheckData2
(
3
,
1
,
int32
(
3
),
data
)
tt4
,
_
:=
time
.
Parse
(
layout
,
"2021-06-11 00:00:00.300000001"
)
e
.
CheckData2
(
4
,
2
,
tt4
,
data
)
e
.
CheckRow
(
6
,
data
)
data
,
_
=
e
.
Query
(
"select count(*) from tb2 where ts2 > 1623340800000000000 and ts2 < 1623340800150000000;"
)
e
.
CheckData2
(
0
,
0
,
int64
(
1
),
data
)
data
,
_
=
e
.
Query
(
"select count(*) from tb2 where ts2 >
\"
2021-06-11 0:00:00.100000000
\"
and ts2 <
\"
2021-06-11 0:00:00.100000002
\"
;"
)
e
.
CheckData2
(
0
,
0
,
int64
(
1
),
data
)
data
,
_
=
e
.
Query
(
"select count(*) from tb2 where ts2 > 1623340800500000000;"
)
e
.
CheckData2
(
0
,
0
,
int64
(
1
),
data
)
data
,
_
=
e
.
Query
(
"select count(*) from tb2 where ts2 <
\"
2021-06-11 0:00:00.400000000
\"
;"
)
e
.
CheckData2
(
0
,
0
,
int64
(
5
),
data
)
data
,
_
=
e
.
Query
(
"select count(*) from tb2 where ts2 < now + 400000000b;"
)
e
.
CheckData2
(
0
,
0
,
int64
(
6
),
data
)
data
,
_
=
e
.
Query
(
"select count(*) from tb2 where ts2 >=
\"
2021-06-11 0:00:00.100000001
\"
;"
)
e
.
CheckData2
(
0
,
0
,
int64
(
6
),
data
)
data
,
_
=
e
.
Query
(
"select count(*) from tb2 where ts2 <= 1623340800400000000;"
)
e
.
CheckData2
(
0
,
0
,
int64
(
5
),
data
)
data
,
_
=
e
.
Query
(
"select count(*) from tb2 where ts2 =
\"
2021-06-11 0:00:00.000000000
\"
;"
)
data
,
_
=
e
.
Query
(
"select count(*) from tb2 where ts2 =
\"
2021-06-11 0:00:00.300000001
\"
;"
)
e
.
CheckData2
(
0
,
0
,
int64
(
1
),
data
)
data
,
_
=
e
.
Query
(
"select count(*) from tb2 where ts2 = 1623340800300000001;"
)
e
.
CheckData2
(
0
,
0
,
int64
(
1
),
data
)
data
,
_
=
e
.
Query
(
"select count(*) from tb2 where ts2 between 1623340800000000000 and 1623340800450000000;"
)
e
.
CheckData2
(
0
,
0
,
int64
(
5
),
data
)
data
,
_
=
e
.
Query
(
"select count(*) from tb2 where ts2 between
\"
2021-06-11 0:00:00.299999999
\"
and
\"
2021-06-11 0:00:00.300000001
\"
;"
)
e
.
CheckData2
(
0
,
0
,
int64
(
3
),
data
)
data
,
_
=
e
.
Query
(
"select count(*) from tb2 where ts2 <> 1623513600999999999;"
)
e
.
CheckData2
(
0
,
0
,
int64
(
5
),
data
)
data
,
_
=
e
.
Query
(
"select count(*) from tb2 where ts2 <>
\"
2021-06-11 0:00:00.100000001
\"
;"
)
e
.
CheckData2
(
0
,
0
,
int64
(
5
),
data
)
data
,
_
=
e
.
Query
(
"select count(*) from tb2 where ts2 <>
\"
2021-06-11 0:00:00.100000000
\"
;"
)
e
.
CheckData2
(
0
,
0
,
int64
(
6
),
data
)
data
,
_
=
e
.
Query
(
"select count(*) from tb2 where ts2 != 1623513600999999999;"
)
e
.
CheckData2
(
0
,
0
,
int64
(
5
),
data
)
data
,
_
=
e
.
Query
(
"select count(*) from tb2 where ts2 !=
\"
2021-06-11 0:00:00.100000001
\"
;"
)
e
.
CheckData2
(
0
,
0
,
int64
(
5
),
data
)
data
,
_
=
e
.
Query
(
"select count(*) from tb2 where ts2 !=
\"
2021-06-11 0:00:00.100000000
\"
;"
)
e
.
CheckData2
(
0
,
0
,
int64
(
6
),
data
)
e
.
Execute
(
"insert into tb2 values(now + 500000000b, 6, now +2d);"
)
data
,
_
=
e
.
Query
(
"select * from tb2;"
)
e
.
CheckRow
(
7
,
data
)
e
.
Execute
(
"create table tb3 (ts timestamp, speed int);"
)
_
,
err
=
e
.
Execute
(
"insert into tb3 values(16232544001500000, 2);"
)
if
err
!=
nil
{
fmt
.
Println
(
"check pass! "
)
}
e
.
Execute
(
"insert into tb3 values(
\"
2021-06-10 0:00:00.123456
\"
, 2);"
)
data
,
_
=
e
.
Query
(
"select * from tb3 where ts =
\"
2021-06-10 0:00:00.123456000
\"
;"
)
e
.
CheckRow
(
1
,
data
)
e
.
Execute
(
"insert into tb3 values(
\"
2021-06-10 0:00:00.123456789000
\"
, 2);"
)
data
,
_
=
e
.
Query
(
"select * from tb3 where ts =
\"
2021-06-10 0:00:00.123456789
\"
;"
)
e
.
CheckRow
(
1
,
data
)
// check timezone support
e
.
Execute
(
"drop database if exists nsdb;"
)
e
.
Execute
(
"create database nsdb precision 'ns';"
)
e
.
Execute
(
"use nsdb;"
)
e
.
Execute
(
"create stable st (ts timestamp ,speed float ) tags(time timestamp ,id int);"
)
e
.
Execute
(
"insert into tb1 using st tags('2021-06-10 0:00:00.123456789' , 1 ) values('2021-06-10T0:00:00.123456789+07:00' , 1.0);"
)
data
,
_
=
e
.
Query
(
"select first(*) from tb1;"
)
ttt
,
_
:=
time
.
Parse
(
layout
,
"2021-06-10 01:00:00.123456789"
)
e
.
CheckData2
(
0
,
0
,
ttt
,
data
)
e
.
Execute
(
"create database usdb precision 'us';"
)
e
.
Execute
(
"use usdb;"
)
e
.
Execute
(
"create stable st (ts timestamp ,speed float ) tags(time timestamp ,id int);"
)
e
.
Execute
(
"insert into tb1 using st tags('2021-06-10 0:00:00.123456' , 1 ) values('2021-06-10T0:00:00.123456+07:00' , 1.0);"
)
data
,
_
=
e
.
Query
(
"select first(*) from tb1;"
)
ttt2
,
_
:=
time
.
Parse
(
layout
,
"2021-06-10 01:00:00.123456"
)
e
.
CheckData2
(
0
,
0
,
ttt2
,
data
)
e
.
Execute
(
"drop database if exists msdb;"
)
e
.
Execute
(
"create database msdb precision 'ms';"
)
e
.
Execute
(
"use msdb;"
)
e
.
Execute
(
"create stable st (ts timestamp ,speed float ) tags(time timestamp ,id int);"
)
e
.
Execute
(
"insert into tb1 using st tags('2021-06-10 0:00:00.123' , 1 ) values('2021-06-10T0:00:00.123+07:00' , 1.0);"
)
data
,
_
=
e
.
Query
(
"select first(*) from tb1;"
)
ttt3
,
_
:=
time
.
Parse
(
layout
,
"2021-06-10 01:00:00.123"
)
e
.
CheckData2
(
0
,
0
,
ttt3
,
data
)
fmt
.
Println
(
"all test done!"
)
}
func
prepareData
(
e
*
connector
.
Executor
)
{
sqlList
:=
[]
string
{
"reset query cache;"
,
"drop database if exists db;"
,
"create database db;"
,
"use db;"
,
"reset query cache;"
,
"drop database if exists db;"
,
"create database db precision 'ns';"
,
"show databases;"
,
"use db;"
,
"create table tb (ts timestamp, speed int);"
,
"insert into tb values('2021-06-10 0:00:00.100000001', 1);"
,
"insert into tb values(1623254400150000000, 2);"
,
"import into tb values(1623254400300000000, 3);"
,
"import into tb values(1623254400299999999, 4);"
,
"insert into tb values(1623254400300000001, 5);"
,
"insert into tb values(1623254400999999999, 7);"
,
}
for
_
,
sql
:=
range
sqlList
{
err
:=
executeSql
(
e
,
sql
)
if
err
!=
nil
{
log
.
Fatalf
(
"prepare data error:%v, sql:%s"
,
err
,
sql
)
}
}
}
func
executeSql
(
e
*
connector
.
Executor
,
sql
string
)
error
{
_
,
err
:=
e
.
Execute
(
sql
)
if
err
!=
nil
{
return
err
}
return
nil
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录