Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
621a7623
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看板
提交
621a7623
编写于
5月 20, 2022
作者:
wmmhello
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix:invalid data type in schemaless
上级
443a7a13
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
40 addition
and
29 deletion
+40
-29
source/client/src/clientSml.c
source/client/src/clientSml.c
+32
-22
source/client/test/smlTest.cpp
source/client/test/smlTest.cpp
+8
-7
未找到文件。
source/client/src/clientSml.c
浏览文件 @
621a7623
...
...
@@ -65,12 +65,14 @@ for (int i = 1; i < keyLen; ++i) { \
#define OTD_TIMESTAMP_COLUMN_NAME "ts"
#define OTD_METRIC_VALUE_COLUMN_NAME "value"
#define TS "_ts"
#define TS_LEN 3
#define TAG "_tagNone"
#define TAG_LEN 8
#define VALUE "value"
#define VALUE_LEN 5
#define TS "_ts"
#define TS_LEN 3
#define TAG "_tag"
#define TAG_LEN 4
#define TAG_VALUE "NULL"
#define TAG_VALUE_LEN 4
#define VALUE "value"
#define VALUE_LEN 5
#define BINARY_ADD_LEN 2 // "binary" 2 means " "
#define NCHAR_ADD_LEN 3 // L"nchar" 3 means L" "
...
...
@@ -598,25 +600,33 @@ static bool smlParseNumber(SSmlKv *kvVal, SSmlMsgBuf *msg){
kvVal
->
type
=
TSDB_DATA_TYPE_FLOAT
;
kvVal
->
f
=
(
float
)
result
;
}
else
if
((
left
==
1
&&
*
endptr
==
'i'
)
||
(
left
==
3
&&
strncasecmp
(
endptr
,
"i64"
,
left
)
==
0
)){
if
(
result
>=
(
double
)
INT64_MAX
){
kvVal
->
i
=
INT64_MAX
;
}
else
if
(
result
<=
(
double
)
INT64_MIN
){
kvVal
->
i
=
INT64_MIN
;
}
else
{
kvVal
->
i
=
result
;
if
(
smlDoubleToInt64OverFlow
(
result
)){
errno
=
0
;
int64_t
tmp
=
taosStr2Int64
(
pVal
,
&
endptr
,
10
);
if
(
errno
==
ERANGE
){
smlBuildInvalidDataMsg
(
msg
,
"big int out of range[-9223372036854775808,9223372036854775807]"
,
pVal
);
return
false
;
}
kvVal
->
type
=
TSDB_DATA_TYPE_BIGINT
;
kvVal
->
i
=
tmp
;
return
true
;
}
kvVal
->
type
=
TSDB_DATA_TYPE_BIGINT
;
kvVal
->
i
=
(
int64_t
)
result
;
}
else
if
((
left
==
3
&&
strncasecmp
(
endptr
,
"u64"
,
left
)
==
0
)){
if
(
result
<
0
){
smlBuildInvalidDataMsg
(
msg
,
"unsigned big int is too large, out of precision"
,
pVal
);
return
false
;
}
if
(
result
>=
(
double
)
UINT64_MAX
){
kvVal
->
u
=
UINT64_MAX
;
}
else
{
kvVal
->
u
=
result
;
if
(
result
>=
(
double
)
UINT64_MAX
||
result
<
0
){
errno
=
0
;
uint64_t
tmp
=
taosStr2UInt64
(
pVal
,
&
endptr
,
10
);
if
(
errno
==
ERANGE
||
result
<
0
){
smlBuildInvalidDataMsg
(
msg
,
"unsigned big int out of range[0,18446744073709551615]"
,
pVal
);
return
false
;
}
kvVal
->
type
=
TSDB_DATA_TYPE_UBIGINT
;
kvVal
->
u
=
tmp
;
return
true
;
}
kvVal
->
type
=
TSDB_DATA_TYPE_UBIGINT
;
kvVal
->
u
=
result
;
}
else
if
(
left
==
3
&&
strncasecmp
(
endptr
,
"i32"
,
left
)
==
0
){
if
(
!
IS_VALID_INT
(
result
)){
smlBuildInvalidDataMsg
(
msg
,
"int out of range[-2147483648,2147483647]"
,
pVal
);
...
...
@@ -1123,8 +1133,8 @@ static int32_t smlParseCols(const char* data, int32_t len, SArray *cols, char *c
if
(
!
kv
)
return
TSDB_CODE_OUT_OF_MEMORY
;
kv
->
key
=
TAG
;
kv
->
keyLen
=
TAG_LEN
;
kv
->
value
=
TAG
;
kv
->
length
=
TAG_LEN
;
kv
->
value
=
TAG
_VALUE
;
kv
->
length
=
TAG_
VALUE_
LEN
;
kv
->
type
=
TSDB_DATA_TYPE_NCHAR
;
if
(
cols
)
taosArrayPush
(
cols
,
&
kv
);
return
TSDB_CODE_SUCCESS
;
...
...
source/client/test/smlTest.cpp
浏览文件 @
621a7623
...
...
@@ -208,6 +208,7 @@ TEST(testCase, smlParseCols_Error_Test) {
memcpy
(
sql
,
data
[
i
],
len
+
1
);
SArray
*
cols
=
taosArrayInit
(
8
,
POINTER_BYTES
);
int32_t
ret
=
smlParseCols
(
sql
,
len
,
cols
,
NULL
,
false
,
dumplicateKey
,
&
msgBuf
);
printf
(
"i:%d
\n
"
,
i
);
ASSERT_NE
(
ret
,
TSDB_CODE_SUCCESS
);
taosHashClear
(
dumplicateKey
);
taosMemoryFree
(
sql
);
...
...
@@ -272,11 +273,11 @@ TEST(testCase, smlParseCols_tag_Test) {
// nchar
kv
=
(
SSmlKv
*
)
taosArrayGetP
(
cols
,
0
);
ASSERT_EQ
(
strncasecmp
(
kv
->
key
,
TAG
,
strlen
(
TAG
)
),
0
);
ASSERT_EQ
(
kv
->
keyLen
,
strlen
(
TAG
)
);
ASSERT_EQ
(
strncasecmp
(
kv
->
key
,
TAG
,
TAG_LEN
),
0
);
ASSERT_EQ
(
kv
->
keyLen
,
TAG_LEN
);
ASSERT_EQ
(
kv
->
type
,
TSDB_DATA_TYPE_NCHAR
);
ASSERT_EQ
(
kv
->
length
,
strlen
(
TAG
)
);
ASSERT_EQ
(
strncasecmp
(
kv
->
value
,
TAG
,
strlen
(
TAG
)
),
0
);
ASSERT_EQ
(
kv
->
length
,
TAG_LEN
);
ASSERT_EQ
(
strncasecmp
(
kv
->
value
,
TAG
_VALUE
,
TAG_VALUE_LEN
),
0
);
taosMemoryFree
(
kv
);
taosArrayDestroy
(
cols
);
...
...
@@ -506,7 +507,7 @@ TEST(testCase, smlProcess_influx_Test) {
"readings,name=truck_0,fleet=South,driver=Trish,model=H-2,device_version=v2.3 load_capacity=1500,fuel_capacity=150,nominal_fuel_consumption=12,latitude=52.31854,longitude=4.72037,elevation=124,heading=221,grade=0,fuel_consumption=25 1451608403000000000"
,
"readings,name=truck_0,fleet=South,driver=Trish,model=H-2,device_version=v2.3 fuel_capacity=150,nominal_fuel_consumption=12,latitude=52.31854,longitude=4.72037,elevation=124,velocity=0,heading=221,grade=0,fuel_consumption=25 1451609404000000000"
,
"readings,name=truck_0,fleet=South,driver=Trish,model=H-2,device_version=v2.3 fuel_consumption=25,grade=0 1451619405000000000"
,
"readings,name=truck_1,fleet=South,driver=Albert,model=F-150,device_version=v1.5 load_capacity=2000,fuel_capacity=200,nominal_fuel_consumption=15,latitude=72.45258,longitude=68.83761,elevation=255,velocity=0,heading=181,grade=0,fuel_consumption=25 145160640600000000"
,
"readings,name=truck_1,fleet=South,driver=Albert,model=F-150,device_version=v1.5 load_capacity=2000,fuel_capacity=200,nominal_fuel_consumption=15,latitude=72.45258,longitude=68.83761,elevation=255,velocity=0,heading=181,grade=0,fuel_consumption=25 145160640600000000
0
"
,
"readings,name=truck_2,driver=Derek,model=F-150,device_version=v1.5 load_capacity=2000,fuel_capacity=200,nominal_fuel_consumption=15,latitude=24.5208,longitude=28.09377,elevation=428,velocity=0,heading=304,grade=0,fuel_consumption=25 1451606407000000000"
,
"readings,name=truck_2,fleet=North,driver=Derek,model=F-150 load_capacity=2000,fuel_capacity=200,nominal_fuel_consumption=15,latitude=24.5208,longitude=28.09377,elevation=428,velocity=0,heading=304,grade=0,fuel_consumption=25 1451609408000000000"
,
"readings,fleet=South,name=truck_0,driver=Trish,model=H-2,device_version=v2.3 fuel_consumption=25,grade=0 1451629409000000000"
,
...
...
@@ -1252,10 +1253,10 @@ TEST(testCase, sml_TD15742_Test) {
TAOS
*
taos
=
taos_connect
(
"localhost"
,
"root"
,
"taosdata"
,
NULL
,
0
);
ASSERT_NE
(
taos
,
nullptr
);
TAOS_RES
*
pRes
=
taos_query
(
taos
,
"create database if not exists
telnet_db
"
);
TAOS_RES
*
pRes
=
taos_query
(
taos
,
"create database if not exists
TD15742
"
);
taos_free_result
(
pRes
);
pRes
=
taos_query
(
taos
,
"use
telnet_db
"
);
pRes
=
taos_query
(
taos
,
"use
TD15742
"
);
taos_free_result
(
pRes
);
SRequestObj
*
request
=
(
SRequestObj
*
)
createRequest
((
STscObj
*
)
taos
,
NULL
,
NULL
,
TSDB_SQL_INSERT
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录