Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
d1bdea69
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1185
Star
22016
Fork
4786
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
d1bdea69
编写于
9月 01, 2022
作者:
wmmhello
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix:<TD-18784> data lost in schemaless if timestamp is same
上级
f7788543
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
117 addition
and
23 deletion
+117
-23
source/client/src/clientSml.c
source/client/src/clientSml.c
+3
-1
source/libs/parser/src/parInsert.c
source/libs/parser/src/parInsert.c
+4
-9
tests/test/c/sml_test.c
tests/test/c/sml_test.c
+110
-13
未找到文件。
source/client/src/clientSml.c
浏览文件 @
d1bdea69
...
@@ -2450,9 +2450,11 @@ static void smlInsertCallback(void *param, void *res, int32_t code) {
...
@@ -2450,9 +2450,11 @@ static void smlInsertCallback(void *param, void *res, int32_t code) {
uDebug
(
"SML:0x%"
PRIx64
" result. code:%d, msg:%s"
,
info
->
id
,
pRequest
->
code
,
pRequest
->
msgBuf
);
uDebug
(
"SML:0x%"
PRIx64
" result. code:%d, msg:%s"
,
info
->
id
,
pRequest
->
code
,
pRequest
->
msgBuf
);
// lock
// lock
taosThreadSpinLock
(
&
info
->
params
->
lock
);
taosThreadSpinLock
(
&
info
->
params
->
lock
);
info
->
params
->
request
->
body
.
resInfo
.
numOfRows
+=
rows
;
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
info
->
params
->
request
->
code
=
code
;
info
->
params
->
request
->
code
=
code
;
info
->
params
->
request
->
body
.
resInfo
.
numOfRows
+=
rows
;
}
else
{
info
->
params
->
request
->
body
.
resInfo
.
numOfRows
+=
info
->
affectedRows
;
}
}
taosThreadSpinUnlock
(
&
info
->
params
->
lock
);
taosThreadSpinUnlock
(
&
info
->
params
->
lock
);
// unlock
// unlock
...
...
source/libs/parser/src/parInsert.c
浏览文件 @
d1bdea69
...
@@ -2253,7 +2253,7 @@ static int32_t smlBoundColumnData(SArray* cols, SParsedDataColInfo* pColList, SS
...
@@ -2253,7 +2253,7 @@ static int32_t smlBoundColumnData(SArray* cols, SParsedDataColInfo* pColList, SS
SToken
sToken
=
{.
n
=
kv
->
keyLen
,
.
z
=
(
char
*
)
kv
->
key
};
SToken
sToken
=
{.
n
=
kv
->
keyLen
,
.
z
=
(
char
*
)
kv
->
key
};
col_id_t
t
=
lastColIdx
+
1
;
col_id_t
t
=
lastColIdx
+
1
;
col_id_t
index
=
((
t
==
0
&&
!
isTag
)
?
0
:
findCol
(
&
sToken
,
t
,
nCols
,
pSchema
));
col_id_t
index
=
((
t
==
0
&&
!
isTag
)
?
0
:
findCol
(
&
sToken
,
t
,
nCols
,
pSchema
));
uDebug
(
"SML, index:%d, t:%d, ncols:%d
, kv->name:%s"
,
index
,
t
,
nCols
,
kv
->
key
);
uDebug
(
"SML, index:%d, t:%d, ncols:%d
"
,
index
,
t
,
nCols
);
if
(
index
<
0
&&
t
>
0
)
{
if
(
index
<
0
&&
t
>
0
)
{
index
=
findCol
(
&
sToken
,
0
,
t
,
pSchema
);
index
=
findCol
(
&
sToken
,
0
,
t
,
pSchema
);
isOrdered
=
false
;
isOrdered
=
false
;
...
@@ -2474,9 +2474,7 @@ int32_t smlBindData(void* handle, SArray* tags, SArray* colsSchema, SArray* cols
...
@@ -2474,9 +2474,7 @@ int32_t smlBindData(void* handle, SArray* tags, SArray* colsSchema, SArray* cols
if
(
p
)
kv
=
*
p
;
if
(
p
)
kv
=
*
p
;
}
}
if
(
!
kv
||
kv
->
length
==
0
)
{
if
(
kv
){
MemRowAppend
(
&
pBuf
,
NULL
,
0
,
&
param
);
}
else
{
int32_t
colLen
=
kv
->
length
;
int32_t
colLen
=
kv
->
length
;
if
(
pColSchema
->
type
==
TSDB_DATA_TYPE_TIMESTAMP
)
{
if
(
pColSchema
->
type
==
TSDB_DATA_TYPE_TIMESTAMP
)
{
// uError("SML:data before:%" PRId64 ", precision:%d", kv->i, pTableMeta->tableInfo.precision);
// uError("SML:data before:%" PRId64 ", precision:%d", kv->i, pTableMeta->tableInfo.precision);
...
@@ -2489,6 +2487,8 @@ int32_t smlBindData(void* handle, SArray* tags, SArray* colsSchema, SArray* cols
...
@@ -2489,6 +2487,8 @@ int32_t smlBindData(void* handle, SArray* tags, SArray* colsSchema, SArray* cols
}
else
{
}
else
{
MemRowAppend
(
&
pBuf
,
&
(
kv
->
value
),
colLen
,
&
param
);
MemRowAppend
(
&
pBuf
,
&
(
kv
->
value
),
colLen
,
&
param
);
}
}
}
else
{
pBuilder
->
hasNone
=
true
;
}
}
if
(
PRIMARYKEY_TIMESTAMP_COL_ID
==
pColSchema
->
colId
)
{
if
(
PRIMARYKEY_TIMESTAMP_COL_ID
==
pColSchema
->
colId
)
{
...
@@ -2497,11 +2497,6 @@ int32_t smlBindData(void* handle, SArray* tags, SArray* colsSchema, SArray* cols
...
@@ -2497,11 +2497,6 @@ int32_t smlBindData(void* handle, SArray* tags, SArray* colsSchema, SArray* cols
}
}
}
}
// set the null value for the columns that do not assign values
if
((
spd
->
numOfBound
<
spd
->
numOfCols
)
&&
TD_IS_TP_ROW
(
row
))
{
pBuilder
->
hasNone
=
true
;
}
tdSRowEnd
(
pBuilder
);
tdSRowEnd
(
pBuilder
);
pDataBlock
->
size
+=
extendedRowSize
;
pDataBlock
->
size
+=
extendedRowSize
;
}
}
...
...
tests/test/c/sml_test.c
浏览文件 @
d1bdea69
...
@@ -63,6 +63,46 @@ int smlProcess_influx_Test() {
...
@@ -63,6 +63,46 @@ int smlProcess_influx_Test() {
printf
(
"%s result:%s
\n
"
,
__FUNCTION__
,
taos_errstr
(
pRes
));
printf
(
"%s result:%s
\n
"
,
__FUNCTION__
,
taos_errstr
(
pRes
));
int
code
=
taos_errno
(
pRes
);
int
code
=
taos_errno
(
pRes
);
taos_free_result
(
pRes
);
taos_free_result
(
pRes
);
// case 1
pRes
=
taos_query
(
taos
,
"select * from t_91e0b182be80332b5c530cbf872f760e"
);
ASSERT
(
pRes
);
int
fieldNum
=
taos_field_count
(
pRes
);
ASSERT
(
fieldNum
==
11
);
printf
(
"fieldNum:%d
\n
"
,
fieldNum
);
TAOS_ROW
row
=
NULL
;
int32_t
rowIndex
=
0
;
while
((
row
=
taos_fetch_row
(
pRes
))
!=
NULL
)
{
int64_t
ts
=
*
(
int64_t
*
)
row
[
0
];
double
load_capacity
=
*
(
double
*
)
row
[
1
];
double
fuel_capacity
=
*
(
double
*
)
row
[
2
];
double
nominal_fuel_consumption
=
*
(
double
*
)
row
[
3
];
double
latitude
=
*
(
double
*
)
row
[
4
];
double
longitude
=
*
(
double
*
)
row
[
5
];
double
elevation
=
*
(
double
*
)
row
[
6
];
double
velocity
=
*
(
double
*
)
row
[
7
];
double
heading
=
*
(
double
*
)
row
[
8
];
double
grade
=
*
(
double
*
)
row
[
9
];
double
fuel_consumption
=
*
(
double
*
)
row
[
10
];
if
(
rowIndex
==
0
){
ASSERT
(
ts
==
1451606407000
);
// ASSERT_EQ(load_capacity, 2000);
// ASSERT_EQ(fuel_capacity, 200);
// ASSERT_EQ(nominal_fuel_consumption, 15);
// ASSERT_EQ(latitude, 24.5208);
// ASSERT_EQ(longitude, 28.09377);
// ASSERT_EQ(elevation, 428);
// ASSERT_EQ(velocity, 0);
// ASSERT_EQ(heading, 304);
// ASSERT_EQ(grade, 0);
// ASSERT_EQ(fuel_consumption, 25);
}
else
{
// ASSERT(0);
}
rowIndex
++
;
}
taos_free_result
(
pRes
);
return
code
;
return
code
;
}
}
...
@@ -1100,34 +1140,91 @@ int sml_add_tag_col_Test() {
...
@@ -1100,34 +1140,91 @@ int sml_add_tag_col_Test() {
return
code
;
return
code
;
}
}
int
smlProcess_18784_Test
()
{
TAOS
*
taos
=
taos_connect
(
"localhost"
,
"root"
,
"taosdata"
,
NULL
,
0
);
TAOS_RES
*
pRes
=
taos_query
(
taos
,
"create database if not exists sml_db schemaless 1"
);
taos_free_result
(
pRes
);
pRes
=
taos_query
(
taos
,
"use sml_db"
);
taos_free_result
(
pRes
);
const
char
*
sql
[]
=
{
"disk,device=sdc inodes_used=176059i,total=1081101176832i 1661943960000000000"
,
"disk,device=sdc inodes_free=66932805i 1661943960000000000"
,
};
pRes
=
taos_schemaless_insert
(
taos
,
(
char
**
)
sql
,
sizeof
(
sql
)
/
sizeof
(
sql
[
0
]),
TSDB_SML_LINE_PROTOCOL
,
0
);
printf
(
"%s result:%s, rows:%d
\n
"
,
__FUNCTION__
,
taos_errstr
(
pRes
),
taos_affected_rows
(
pRes
));
int
code
=
taos_errno
(
pRes
);
ASSERT
(
!
code
);
ASSERT
(
taos_affected_rows
(
pRes
)
==
2
);
taos_free_result
(
pRes
);
pRes
=
taos_query
(
taos
,
"select * from disk"
);
ASSERT
(
pRes
);
int
fieldNum
=
taos_field_count
(
pRes
);
ASSERT
(
fieldNum
==
5
);
printf
(
"fieldNum:%d
\n
"
,
fieldNum
);
TAOS_ROW
row
=
NULL
;
int32_t
rowIndex
=
0
;
while
((
row
=
taos_fetch_row
(
pRes
))
!=
NULL
)
{
int64_t
ts
=
*
(
int64_t
*
)
row
[
0
];
int64_t
used
=
*
(
int64_t
*
)
row
[
1
];
int64_t
total
=
*
(
int64_t
*
)
row
[
2
];
int64_t
freed
=
*
(
int64_t
*
)
row
[
3
];
if
(
rowIndex
==
0
){
ASSERT
(
ts
==
1661943960000
);
ASSERT
(
used
==
176059
);
ASSERT
(
total
==
1081101176832
);
ASSERT
(
freed
==
66932805
);
// ASSERT_EQ(latitude, 24.5208);
// ASSERT_EQ(longitude, 28.09377);
// ASSERT_EQ(elevation, 428);
// ASSERT_EQ(velocity, 0);
// ASSERT_EQ(heading, 304);
// ASSERT_EQ(grade, 0);
// ASSERT_EQ(fuel_consumption, 25);
}
else
{
// ASSERT(0);
}
rowIndex
++
;
}
taos_free_result
(
pRes
);
return
code
;
}
int
main
(
int
argc
,
char
*
argv
[])
{
int
main
(
int
argc
,
char
*
argv
[])
{
int
ret
=
0
;
int
ret
=
0
;
ret
=
smlProcess_influx_Test
();
ret
=
smlProcess_influx_Test
();
if
(
ret
)
return
ret
;
ASSERT
(
!
ret
)
;
ret
=
smlProcess_telnet_Test
();
ret
=
smlProcess_telnet_Test
();
if
(
ret
)
return
ret
;
ASSERT
(
!
ret
)
;
ret
=
smlProcess_json1_Test
();
ret
=
smlProcess_json1_Test
();
if
(
ret
)
return
ret
;
ASSERT
(
!
ret
)
;
ret
=
smlProcess_json2_Test
();
ret
=
smlProcess_json2_Test
();
if
(
ret
)
return
ret
;
ASSERT
(
!
ret
)
;
ret
=
smlProcess_json3_Test
();
ret
=
smlProcess_json3_Test
();
if
(
ret
)
return
ret
;
ASSERT
(
!
ret
)
;
ret
=
smlProcess_json4_Test
();
ret
=
smlProcess_json4_Test
();
if
(
ret
)
return
ret
;
ASSERT
(
!
ret
)
;
ret
=
sml_TD15662_Test
();
ret
=
sml_TD15662_Test
();
if
(
ret
)
return
ret
;
ASSERT
(
!
ret
)
;
ret
=
sml_TD15742_Test
();
ret
=
sml_TD15742_Test
();
if
(
ret
)
return
ret
;
ASSERT
(
!
ret
)
;
ret
=
sml_16384_Test
();
ret
=
sml_16384_Test
();
if
(
ret
)
return
ret
;
ASSERT
(
!
ret
)
;
ret
=
sml_oom_Test
();
ret
=
sml_oom_Test
();
if
(
ret
)
return
ret
;
ASSERT
(
!
ret
)
;
ret
=
sml_16368_Test
();
ret
=
sml_16368_Test
();
if
(
ret
)
return
ret
;
ASSERT
(
!
ret
)
;
ret
=
sml_dup_time_Test
();
ret
=
sml_dup_time_Test
();
if
(
ret
)
return
ret
;
ASSERT
(
!
ret
)
;
ret
=
sml_16960_Test
();
ret
=
sml_16960_Test
();
if
(
ret
)
return
ret
;
ASSERT
(
!
ret
)
;
ret
=
sml_add_tag_col_Test
();
ret
=
sml_add_tag_col_Test
();
ASSERT
(
!
ret
);
ret
=
smlProcess_18784_Test
();
ASSERT
(
!
ret
);
return
ret
;
return
ret
;
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录