Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
aae8adeb
T
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1185
Star
22016
Fork
4786
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
aae8adeb
编写于
7月 06, 2022
作者:
wmmhello
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix:timestamp precision in josn protocol
上级
ee395f8e
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
220 addition
and
13 deletion
+220
-13
source/client/src/clientSml.c
source/client/src/clientSml.c
+13
-12
source/client/test/smlTest.cpp
source/client/test/smlTest.cpp
+207
-1
未找到文件。
source/client/src/clientSml.c
浏览文件 @
aae8adeb
...
@@ -1570,41 +1570,40 @@ static int32_t smlParseTSFromJSONObj(SSmlHandle *info, cJSON *root, int64_t *tsV
...
@@ -1570,41 +1570,40 @@ static int32_t smlParseTSFromJSONObj(SSmlHandle *info, cJSON *root, int64_t *tsV
return
TSDB_CODE_TSC_INVALID_TIME_STAMP
;
return
TSDB_CODE_TSC_INVALID_TIME_STAMP
;
}
}
*
tsVal
=
timeDouble
;
size_t
typeLen
=
strlen
(
type
->
valuestring
);
size_t
typeLen
=
strlen
(
type
->
valuestring
);
if
(
typeLen
==
1
&&
(
type
->
valuestring
[
0
]
==
's'
||
type
->
valuestring
[
0
]
==
'S'
))
{
if
(
typeLen
==
1
&&
(
type
->
valuestring
[
0
]
==
's'
||
type
->
valuestring
[
0
]
==
'S'
))
{
// seconds
// seconds
timeDouble
=
timeDouble
*
1e9
;
*
tsVal
=
*
tsVal
*
NANOSECOND_PER_SEC
;
timeDouble
=
timeDouble
*
NANOSECOND_PER_SEC
;
if
(
smlDoubleToInt64OverFlow
(
timeDouble
))
{
if
(
smlDoubleToInt64OverFlow
(
timeDouble
))
{
smlBuildInvalidDataMsg
(
&
info
->
msgBuf
,
"timestamp is too large"
,
NULL
);
smlBuildInvalidDataMsg
(
&
info
->
msgBuf
,
"timestamp is too large"
,
NULL
);
return
TSDB_CODE_TSC_INVALID_TIME_STAMP
;
return
TSDB_CODE_TSC_INVALID_TIME_STAMP
;
}
}
*
tsVal
=
timeDouble
;
}
else
if
(
typeLen
==
2
&&
(
type
->
valuestring
[
1
]
==
's'
||
type
->
valuestring
[
1
]
==
'S'
))
{
}
else
if
(
typeLen
==
2
&&
(
type
->
valuestring
[
1
]
==
's'
||
type
->
valuestring
[
1
]
==
'S'
))
{
switch
(
type
->
valuestring
[
0
])
{
switch
(
type
->
valuestring
[
0
])
{
case
'm'
:
case
'm'
:
case
'M'
:
case
'M'
:
// milliseconds
// milliseconds
timeDouble
=
timeDouble
*
1e6
;
*
tsVal
=
*
tsVal
*
NANOSECOND_PER_MSEC
;
timeDouble
=
timeDouble
*
NANOSECOND_PER_MSEC
;
if
(
smlDoubleToInt64OverFlow
(
timeDouble
))
{
if
(
smlDoubleToInt64OverFlow
(
timeDouble
))
{
smlBuildInvalidDataMsg
(
&
info
->
msgBuf
,
"timestamp is too large"
,
NULL
);
smlBuildInvalidDataMsg
(
&
info
->
msgBuf
,
"timestamp is too large"
,
NULL
);
return
TSDB_CODE_TSC_INVALID_TIME_STAMP
;
return
TSDB_CODE_TSC_INVALID_TIME_STAMP
;
}
}
*
tsVal
=
timeDouble
;
break
;
break
;
case
'u'
:
case
'u'
:
case
'U'
:
case
'U'
:
// microseconds
// microseconds
timeDouble
=
timeDouble
*
1e3
;
*
tsVal
=
*
tsVal
*
NANOSECOND_PER_USEC
;
timeDouble
=
timeDouble
*
NANOSECOND_PER_USEC
;
if
(
smlDoubleToInt64OverFlow
(
timeDouble
))
{
if
(
smlDoubleToInt64OverFlow
(
timeDouble
))
{
smlBuildInvalidDataMsg
(
&
info
->
msgBuf
,
"timestamp is too large"
,
NULL
);
smlBuildInvalidDataMsg
(
&
info
->
msgBuf
,
"timestamp is too large"
,
NULL
);
return
TSDB_CODE_TSC_INVALID_TIME_STAMP
;
return
TSDB_CODE_TSC_INVALID_TIME_STAMP
;
}
}
*
tsVal
=
timeDouble
;
break
;
break
;
case
'n'
:
case
'n'
:
case
'N'
:
case
'N'
:
// nanoseconds
*
tsVal
=
timeDouble
;
break
;
break
;
default:
default:
return
TSDB_CODE_TSC_INVALID_JSON
;
return
TSDB_CODE_TSC_INVALID_JSON
;
...
@@ -1641,21 +1640,23 @@ static int32_t smlParseTSFromJSON(SSmlHandle *info, cJSON *root, SArray *cols) {
...
@@ -1641,21 +1640,23 @@ static int32_t smlParseTSFromJSON(SSmlHandle *info, cJSON *root, SArray *cols) {
if
(
timeDouble
<
0
)
{
if
(
timeDouble
<
0
)
{
return
TSDB_CODE_TSC_INVALID_TIME_STAMP
;
return
TSDB_CODE_TSC_INVALID_TIME_STAMP
;
}
}
uint8_t
tsLen
=
smlGetTimestampLen
((
int64_t
)
timeDouble
);
uint8_t
tsLen
=
smlGetTimestampLen
((
int64_t
)
timeDouble
);
tsVal
=
(
int64_t
)
timeDouble
;
if
(
tsLen
==
TSDB_TIME_PRECISION_SEC_DIGITS
)
{
if
(
tsLen
==
TSDB_TIME_PRECISION_SEC_DIGITS
)
{
timeDouble
=
timeDouble
*
1e9
;
tsVal
=
tsVal
*
NANOSECOND_PER_SEC
;
timeDouble
=
timeDouble
*
NANOSECOND_PER_SEC
;
if
(
smlDoubleToInt64OverFlow
(
timeDouble
))
{
if
(
smlDoubleToInt64OverFlow
(
timeDouble
))
{
smlBuildInvalidDataMsg
(
&
info
->
msgBuf
,
"timestamp is too large"
,
NULL
);
smlBuildInvalidDataMsg
(
&
info
->
msgBuf
,
"timestamp is too large"
,
NULL
);
return
TSDB_CODE_TSC_INVALID_TIME_STAMP
;
return
TSDB_CODE_TSC_INVALID_TIME_STAMP
;
}
}
tsVal
=
timeDouble
;
}
else
if
(
tsLen
==
TSDB_TIME_PRECISION_MILLI_DIGITS
)
{
}
else
if
(
tsLen
==
TSDB_TIME_PRECISION_MILLI_DIGITS
)
{
timeDouble
=
timeDouble
*
1e6
;
tsVal
=
tsVal
*
NANOSECOND_PER_MSEC
;
timeDouble
=
timeDouble
*
NANOSECOND_PER_MSEC
;
if
(
smlDoubleToInt64OverFlow
(
timeDouble
))
{
if
(
smlDoubleToInt64OverFlow
(
timeDouble
))
{
smlBuildInvalidDataMsg
(
&
info
->
msgBuf
,
"timestamp is too large"
,
NULL
);
smlBuildInvalidDataMsg
(
&
info
->
msgBuf
,
"timestamp is too large"
,
NULL
);
return
TSDB_CODE_TSC_INVALID_TIME_STAMP
;
return
TSDB_CODE_TSC_INVALID_TIME_STAMP
;
}
}
tsVal
=
timeDouble
;
}
else
if
(
timeDouble
==
0
)
{
}
else
if
(
timeDouble
==
0
)
{
tsVal
=
taosGetTimestampNs
();
tsVal
=
taosGetTimestampNs
();
}
else
{
}
else
{
...
...
source/client/test/smlTest.cpp
浏览文件 @
aae8adeb
...
@@ -1284,4 +1284,210 @@ TEST(testCase, sml_dup_time_Test) {
...
@@ -1284,4 +1284,210 @@ TEST(testCase, sml_dup_time_Test) {
ASSERT_EQ(taos_errno(pRes), 0);
ASSERT_EQ(taos_errno(pRes), 0);
taos_free_result(pRes);
taos_free_result(pRes);
}
}
*/
TEST(testCase, sml_16960_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 d16368 schemaless 1");
taos_free_result(pRes);
pRes = taos_query(taos, "use d16368");
taos_free_result(pRes);
const char *sql[] = {
"[\n"
"{\n"
"\"timestamp\":\n"
"\n"
"{ \"value\": 1349020800000, \"type\": \"ms\" }\n"
",\n"
"\"value\":\n"
"\n"
"{ \"value\": 830525384, \"type\": \"int\" }\n"
",\n"
"\"tags\": {\n"
"\"id\": \"stb00_0\",\n"
"\"t0\":\n"
"\n"
"{ \"value\": 83972721, \"type\": \"int\" }\n"
",\n"
"\"t1\":\n"
"\n"
"{ \"value\": 539147525, \"type\": \"int\" }\n"
",\n"
"\"t2\":\n"
"\n"
"{ \"value\": 618258572, \"type\": \"int\" }\n"
",\n"
"\"t3\":\n"
"\n"
"{ \"value\": -10536201, \"type\": \"int\" }\n"
",\n"
"\"t4\":\n"
"\n"
"{ \"value\": 349227409, \"type\": \"int\" }\n"
",\n"
"\"t5\":\n"
"\n"
"{ \"value\": 249347042, \"type\": \"int\" }\n"
"},\n"
"\"metric\": \"stb0\"\n"
"},\n"
"{\n"
"\"timestamp\":\n"
"\n"
"{ \"value\": 1349020800001, \"type\": \"ms\" }\n"
",\n"
"\"value\":\n"
"\n"
"{ \"value\": -588348364, \"type\": \"int\" }\n"
",\n"
"\"tags\": {\n"
"\"id\": \"stb00_0\",\n"
"\"t0\":\n"
"\n"
"{ \"value\": 83972721, \"type\": \"int\" }\n"
",\n"
"\"t1\":\n"
"\n"
"{ \"value\": 539147525, \"type\": \"int\" }\n"
",\n"
"\"t2\":\n"
"\n"
"{ \"value\": 618258572, \"type\": \"int\" }\n"
",\n"
"\"t3\":\n"
"\n"
"{ \"value\": -10536201, \"type\": \"int\" }\n"
",\n"
"\"t4\":\n"
"\n"
"{ \"value\": 349227409, \"type\": \"int\" }\n"
",\n"
"\"t5\":\n"
"\n"
"{ \"value\": 249347042, \"type\": \"int\" }\n"
"},\n"
"\"metric\": \"stb0\"\n"
"},\n"
"{\n"
"\"timestamp\":\n"
"\n"
"{ \"value\": 1349020800002, \"type\": \"ms\" }\n"
",\n"
"\"value\":\n"
"\n"
"{ \"value\": -370310823, \"type\": \"int\" }\n"
",\n"
"\"tags\": {\n"
"\"id\": \"stb00_0\",\n"
"\"t0\":\n"
"\n"
"{ \"value\": 83972721, \"type\": \"int\" }\n"
",\n"
"\"t1\":\n"
"\n"
"{ \"value\": 539147525, \"type\": \"int\" }\n"
",\n"
"\"t2\":\n"
"\n"
"{ \"value\": 618258572, \"type\": \"int\" }\n"
",\n"
"\"t3\":\n"
"\n"
"{ \"value\": -10536201, \"type\": \"int\" }\n"
",\n"
"\"t4\":\n"
"\n"
"{ \"value\": 349227409, \"type\": \"int\" }\n"
",\n"
"\"t5\":\n"
"\n"
"{ \"value\": 249347042, \"type\": \"int\" }\n"
"},\n"
"\"metric\": \"stb0\"\n"
"},\n"
"{\n"
"\"timestamp\":\n"
"\n"
"{ \"value\": 1349020800003, \"type\": \"ms\" }\n"
",\n"
"\"value\":\n"
"\n"
"{ \"value\": -811250191, \"type\": \"int\" }\n"
",\n"
"\"tags\": {\n"
"\"id\": \"stb00_0\",\n"
"\"t0\":\n"
"\n"
"{ \"value\": 83972721, \"type\": \"int\" }\n"
",\n"
"\"t1\":\n"
"\n"
"{ \"value\": 539147525, \"type\": \"int\" }\n"
",\n"
"\"t2\":\n"
"\n"
"{ \"value\": 618258572, \"type\": \"int\" }\n"
",\n"
"\"t3\":\n"
"\n"
"{ \"value\": -10536201, \"type\": \"int\" }\n"
",\n"
"\"t4\":\n"
"\n"
"{ \"value\": 349227409, \"type\": \"int\" }\n"
",\n"
"\"t5\":\n"
"\n"
"{ \"value\": 249347042, \"type\": \"int\" }\n"
"},\n"
"\"metric\": \"stb0\"\n"
"},\n"
"{\n"
"\"timestamp\":\n"
"\n"
"{ \"value\": 1349020800004, \"type\": \"ms\" }\n"
",\n"
"\"value\":\n"
"\n"
"{ \"value\": -330340558, \"type\": \"int\" }\n"
",\n"
"\"tags\": {\n"
"\"id\": \"stb00_0\",\n"
"\"t0\":\n"
"\n"
"{ \"value\": 83972721, \"type\": \"int\" }\n"
",\n"
"\"t1\":\n"
"\n"
"{ \"value\": 539147525, \"type\": \"int\" }\n"
",\n"
"\"t2\":\n"
"\n"
"{ \"value\": 618258572, \"type\": \"int\" }\n"
",\n"
"\"t3\":\n"
"\n"
"{ \"value\": -10536201, \"type\": \"int\" }\n"
",\n"
"\"t4\":\n"
"\n"
"{ \"value\": 349227409, \"type\": \"int\" }\n"
",\n"
"\"t5\":\n"
"\n"
"{ \"value\": 249347042, \"type\": \"int\" }\n"
"},\n"
"\"metric\": \"stb0\"\n"
"}\n"
"]"
};
pRes = taos_schemaless_insert(taos, (char**)sql, sizeof(sql)/sizeof(sql[0]), TSDB_SML_JSON_PROTOCOL, TSDB_SML_TIMESTAMP_MILLI_SECONDS);
ASSERT_EQ(taos_errno(pRes), 0);
taos_free_result(pRes);
}
*/
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录