Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
3d0a2181
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看板
未验证
提交
3d0a2181
编写于
5月 20, 2022
作者:
wmmhello
提交者:
GitHub
5月 20, 2022
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #12757 from taosdata/feature/TD-14761
fix: deal with error in schemaless
上级
0a168cba
79138872
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
29 addition
and
50 deletion
+29
-50
source/client/src/clientSml.c
source/client/src/clientSml.c
+23
-37
source/client/test/smlTest.cpp
source/client/test/smlTest.cpp
+6
-13
未找到文件。
source/client/src/clientSml.c
浏览文件 @
3d0a2181
...
...
@@ -58,13 +58,9 @@ for (int i = 1; i < keyLen; ++i) { \
#define IS_INVALID_COL_LEN(len) ((len) <= 0 || (len) >= TSDB_COL_NAME_LEN)
#define IS_INVALID_TABLE_LEN(len) ((len) <= 0 || (len) >= TSDB_TABLE_NAME_LEN)
#define OTD_MAX_FIELDS_NUM 2
#define OTD_JSON_SUB_FIELDS_NUM 2
#define OTD_JSON_FIELDS_NUM 4
#define OTD_TIMESTAMP_COLUMN_NAME "ts"
#define OTD_METRIC_VALUE_COLUMN_NAME "value"
#define TS "_ts"
#define TS_LEN 3
#define TAG "_tag"
...
...
@@ -728,57 +724,43 @@ static int64_t smlGetTimeValue(const char *value, int32_t len, int8_t type) {
if
(
value
+
len
!=
endPtr
){
return
-
1
;
}
if
(
tsInt64
==
0
){
return
taosGetTimestampNs
();
}
double
ts
=
tsInt64
;
switch
(
type
)
{
case
TSDB_TIME_PRECISION_HOURS
:
ts
*=
(
3600
*
1e9
)
;
tsInt64
*=
(
3600
*
1e9
)
;
ts
*=
NANOSECOND_PER_HOUR
;
tsInt64
*=
NANOSECOND_PER_HOUR
;
break
;
case
TSDB_TIME_PRECISION_MINUTES
:
ts
*=
(
60
*
1e9
)
;
tsInt64
*=
(
60
*
1e9
)
;
ts
*=
NANOSECOND_PER_MINUTE
;
tsInt64
*=
NANOSECOND_PER_MINUTE
;
break
;
case
TSDB_TIME_PRECISION_SECONDS
:
ts
*=
(
1e9
)
;
tsInt64
*=
(
1e9
)
;
ts
*=
NANOSECOND_PER_SEC
;
tsInt64
*=
NANOSECOND_PER_SEC
;
break
;
case
TSDB_TIME_PRECISION_MILLI
:
ts
*=
(
1e6
)
;
tsInt64
*=
(
1e6
)
;
ts
*=
NANOSECOND_PER_MSEC
;
tsInt64
*=
NANOSECOND_PER_MSEC
;
break
;
case
TSDB_TIME_PRECISION_MICRO
:
ts
*=
(
1e3
)
;
tsInt64
*=
(
1e3
)
;
ts
*=
NANOSECOND_PER_USEC
;
tsInt64
*=
NANOSECOND_PER_USEC
;
break
;
case
TSDB_TIME_PRECISION_NANO
:
break
;
default:
ASSERT
(
0
);
}
if
(
ts
>=
(
double
)
INT64_MAX
||
ts
<
=
0
){
if
(
ts
>=
(
double
)
INT64_MAX
||
ts
<
0
){
return
-
1
;
}
return
tsInt64
;
}
static
int64_t
smlGetTimeNow
(
int8_t
precision
)
{
switch
(
precision
)
{
case
TSDB_TIME_PRECISION_HOURS
:
return
taosGetTimestampMs
()
/
1000
/
3600
;
case
TSDB_TIME_PRECISION_MINUTES
:
return
taosGetTimestampMs
()
/
1000
/
60
;
case
TSDB_TIME_PRECISION_SECONDS
:
return
taosGetTimestampMs
()
/
1000
;
case
TSDB_TIME_PRECISION_MILLI
:
case
TSDB_TIME_PRECISION_MICRO
:
case
TSDB_TIME_PRECISION_NANO
:
return
taosGetTimestamp
(
precision
);
default:
ASSERT
(
0
);
}
}
static
int8_t
smlGetTsTypeByLen
(
int32_t
len
)
{
if
(
len
==
TSDB_TIME_PRECISION_SEC_DIGITS
)
{
return
TSDB_TIME_PRECISION_SECONDS
;
...
...
@@ -810,14 +792,15 @@ static int8_t smlGetTsTypeByPrecision(int8_t precision) {
}
static
int64_t
smlParseInfluxTime
(
SSmlHandle
*
info
,
const
char
*
data
,
int32_t
len
){
if
(
len
==
0
){
return
taosGetTimestamp
(
TSDB_TIME_PRECISION_NANO
);
}
int8_t
tsType
=
smlGetTsTypeByPrecision
(
info
->
precision
);
if
(
tsType
==
-
1
)
{
smlBuildInvalidDataMsg
(
&
info
->
msgBuf
,
"invalid timestamp precision"
,
NULL
);
return
-
1
;
}
if
(
len
==
0
){
return
smlGetTimeNow
(
tsType
);
}
int64_t
ts
=
smlGetTimeValue
(
data
,
len
,
tsType
);
if
(
ts
==
-
1
){
...
...
@@ -1619,7 +1602,8 @@ static int32_t smlParseTSFromJSON(SSmlHandle *info, cJSON *root, SArray *cols) {
smlBuildInvalidDataMsg
(
&
info
->
msgBuf
,
"timestamp is too large"
,
NULL
);
return
TSDB_CODE_TSC_INVALID_TIME_STAMP
;
}
if
(
timeDouble
<=
0
){
if
(
timeDouble
<
0
){
return
TSDB_CODE_TSC_INVALID_TIME_STAMP
;
}
uint8_t
tsLen
=
smlGetTimestampLen
((
int64_t
)
timeDouble
);
...
...
@@ -1637,7 +1621,9 @@ static int32_t smlParseTSFromJSON(SSmlHandle *info, cJSON *root, SArray *cols) {
return
TSDB_CODE_TSC_INVALID_TIME_STAMP
;
}
tsVal
=
timeDouble
;
}
else
{
}
else
if
(
timeDouble
==
0
){
tsVal
=
taosGetTimestampNs
();
}
else
{
return
TSDB_CODE_TSC_INVALID_TIME_STAMP
;
}
}
else
if
(
cJSON_IsObject
(
timestamp
))
{
...
...
source/client/test/smlTest.cpp
浏览文件 @
3d0a2181
...
...
@@ -1203,24 +1203,17 @@ TEST(testCase, sml_TD15662_Test) {
SRequestObj
*
request
=
(
SRequestObj
*
)
createRequest
((
STscObj
*
)
taos
,
NULL
,
NULL
,
TSDB_SQL_INSERT
);
ASSERT_NE
(
request
,
nullptr
);
SSmlHandle
*
info
=
smlBuildSmlInfo
(
taos
,
request
,
TSDB_SML_LINE_PROTOCOL
,
TSDB_SML_TIMESTAMP_
NANO
_SECONDS
);
SSmlHandle
*
info
=
smlBuildSmlInfo
(
taos
,
request
,
TSDB_SML_LINE_PROTOCOL
,
TSDB_SML_TIMESTAMP_
MILLI
_SECONDS
);
ASSERT_NE
(
info
,
nullptr
);
const
char
*
sql
[]
=
{
"
iyyyje,id=iyyyje_41943_1303,t0=t,t1=127i8,t2=32767i16,t3=2147483647i32,t4=9223372036854775807i64,t5=11.12345f32,t6=22.123456789f64,t7=
\"
binaryTagValue
\"
,t8=L
\"
ncharTagValue
\"
c0=false,c1=127i8,c2=32767i16,c3=2147483647i32,c4=9223372036854775807i64,c5=11.12345f32,c6=22.123456789f64,c7=
\"
binaryColValue
\"
,c8=L
\"
ncharColValue
\"
,c9=7u64 1626006833639000000
"
,
"
hetrey,id=sub_table_0123456,t0=f,t1=127i8,t2=32767i16,t3=2147483647i32,t4=9223372036854775807i64,t5=11.12345f32,t6=22.123456789f64,t7=
\"
binaryTagValue
\"
,t8=L
\"
ncharTagValue
\"
c0=f,c1=127i8,c2=32767i16,c3=2147483647i32,c4=9223372036854775807i64,c5=11.12345f32,c6=22.123456789f64,c7=
\"
binaryColValue
\"
,c8=L
\"
ncharColValue
\"
,c9=7u64
"
,
};
int
ret
=
smlProcess
(
info
,
(
char
**
)
sql
,
sizeof
(
sql
)
/
sizeof
(
sql
[
0
]));
ASSERT_EQ
(
ret
,
0
);
// case 1
TAOS_RES
*
res
=
taos_query
(
taos
,
"select * from t_a5615048edae55218a22a149edebdc82"
);
ASSERT_NE
(
res
,
nullptr
);
TAOS_ROW
row
=
taos_fetch_row
(
res
);
int64_t
ts
=
*
(
int64_t
*
)
row
[
0
];
ASSERT_EQ
(
ts
,
1626006833639000000
);
taos_free_result
(
res
);
destroyRequest
(
request
);
smlDestroyInfo
(
info
);
}
TEST
(
testCase
,
sml_TD15735_Test
)
{
...
...
@@ -1262,11 +1255,11 @@ TEST(testCase, sml_TD15742_Test) {
SRequestObj
*
request
=
(
SRequestObj
*
)
createRequest
((
STscObj
*
)
taos
,
NULL
,
NULL
,
TSDB_SQL_INSERT
);
ASSERT_NE
(
request
,
nullptr
);
SSmlHandle
*
info
=
smlBuildSmlInfo
(
taos
,
request
,
TSDB_SML_
TELNET_PROTOCOL
,
TSDB_SML_TIMESTAMP_NANO
_SECONDS
);
SSmlHandle
*
info
=
smlBuildSmlInfo
(
taos
,
request
,
TSDB_SML_
LINE_PROTOCOL
,
TSDB_SML_TIMESTAMP_MILLI
_SECONDS
);
ASSERT_NE
(
info
,
nullptr
);
const
char
*
sql
[]
=
{
"
zgzbix 1626006833641 False id=zgzbix_992_38861 t0=t t1=127i8 t2=32767i16 t3=2147483647i32 t4=9223372036854775807i64 t5=11.12345f32 t6=22.123456789f64 t7=
\"
binaryTagValue
\"
t8=L
\"
ncharTagValue
\"
"
,
"
test_ms,t0=t c0=f 1626006833641
"
,
};
int
ret
=
smlProcess
(
info
,
(
char
**
)
sql
,
sizeof
(
sql
)
/
sizeof
(
sql
[
0
]));
ASSERT_EQ
(
ret
,
0
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录