Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
b1561c95
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看板
提交
b1561c95
编写于
4月 20, 2023
作者:
wmmhello
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix:add test cases for escape in schemaless
上级
5b3087e4
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
140 addition
and
12 deletion
+140
-12
source/client/src/clientSml.c
source/client/src/clientSml.c
+2
-0
source/client/src/clientSmlLine.c
source/client/src/clientSmlLine.c
+1
-1
source/client/src/clientTmq.c
source/client/src/clientTmq.c
+0
-3
source/client/test/smlTest.cpp
source/client/test/smlTest.cpp
+29
-7
source/common/src/tglobal.c
source/common/src/tglobal.c
+1
-1
utils/test/c/sml_test.c
utils/test/c/sml_test.c
+107
-0
未找到文件。
source/client/src/clientSml.c
浏览文件 @
b1561c95
...
...
@@ -1175,6 +1175,7 @@ static int32_t smlPushCols(SArray *colsArray, SArray *cols) {
}
for
(
size_t
i
=
0
;
i
<
taosArrayGetSize
(
cols
);
i
++
)
{
SSmlKv
*
kv
=
(
SSmlKv
*
)
taosArrayGet
(
cols
,
i
);
terrno
=
0
;
taosHashPut
(
kvHash
,
kv
->
key
,
kv
->
keyLen
,
&
kv
,
POINTER_BYTES
);
if
(
terrno
==
TSDB_CODE_DUP_KEY
)
{
return
terrno
;
...
...
@@ -1250,6 +1251,7 @@ static int32_t smlParseLineBottom(SSmlHandle *info) {
uDebug
(
"SML:0x%"
PRIx64
" smlParseLineBottom add meta, format:%d, linenum:%d"
,
info
->
id
,
info
->
dataFormat
,
info
->
lineNum
);
SSmlSTableMeta
*
meta
=
smlBuildSTableMeta
(
info
->
dataFormat
);
terrno
=
0
;
smlInsertMeta
(
meta
->
tagHash
,
meta
->
tags
,
tinfo
->
tags
);
if
(
terrno
==
TSDB_CODE_DUP_KEY
)
{
return
terrno
;
...
...
source/client/src/clientSmlLine.c
浏览文件 @
b1561c95
...
...
@@ -465,7 +465,7 @@ static int32_t smlParseColKv(SSmlHandle *info, char **sql, char *sqlEnd, SSmlLin
value
=
tmp
;
}
SSmlKv
kv
=
{.
key
=
key
,
.
keyLen
=
keyLen
,
.
value
=
value
,
.
length
=
valueLen
};
SSmlKv
kv
=
{.
key
=
key
,
.
keyLen
=
keyLen
,
.
value
=
value
,
.
length
=
valueLen
,
.
keyEscaped
=
keyEscaped
,
.
valueEscaped
=
valueEscaped
};
int32_t
ret
=
smlParseValue
(
&
kv
,
&
info
->
msgBuf
);
if
(
ret
!=
TSDB_CODE_SUCCESS
)
{
smlBuildInvalidDataMsg
(
&
info
->
msgBuf
,
"smlParseValue error"
,
value
);
...
...
source/client/src/clientTmq.c
浏览文件 @
b1561c95
...
...
@@ -373,9 +373,6 @@ int32_t tmq_list_append(tmq_list_t* list, const char* src) {
SArray
*
container
=
&
list
->
container
;
if
(
src
==
NULL
||
src
[
0
]
==
0
)
return
-
1
;
char
*
topic
=
taosStrdup
(
src
);
if
(
topic
[
0
]
!=
'`'
)
{
strtolower
(
topic
,
src
);
}
if
(
taosArrayPush
(
container
,
&
topic
)
==
NULL
)
return
-
1
;
return
0
;
}
...
...
source/client/test/smlTest.cpp
浏览文件 @
b1561c95
...
...
@@ -50,8 +50,9 @@ TEST(testCase, smlParseInfluxString_Test) {
int
ret
=
smlParseInfluxString
(
info
,
sql
,
sql
+
strlen
(
sql
),
&
elements
);
ASSERT_EQ
(
ret
,
0
);
ASSERT_EQ
(
elements
.
measure
,
sql
);
ASSERT_EQ
(
elements
.
measureLen
,
strlen
(
",st"
));
ASSERT_EQ
(
elements
.
measureTagsLen
,
strlen
(
",st,t1=3,t2=4,t3=t3"
));
ASSERT_EQ
(
elements
.
measureLen
,
strlen
(
"
\\
,st"
));
ASSERT_EQ
(
elements
.
measureEscaped
,
true
);
ASSERT_EQ
(
elements
.
measureTagsLen
,
strlen
(
"
\\
,st,t1=3,t2=4,t3=t3"
));
ASSERT_EQ
(
elements
.
tags
,
sql
+
elements
.
measureLen
+
1
);
ASSERT_EQ
(
elements
.
tagsLen
,
strlen
(
"t1=3,t2=4,t3=t3"
));
...
...
@@ -204,7 +205,26 @@ TEST(testCase, smlParseCols_Error_Test) {
"st,t=1 c=-3.402823466e+39u64 1626006833639000000"
,
"st,t=1 c=-339u64 1626006833639000000"
,
"st,t=1 c=18446744073709551616u64 1626006833639000000"
,
"st,t=1 c=1=2 1626006833639000000"
};
"st,t=1 c=1=2 1626006833639000000,"
,
// escape error test
// measure comma,space
"s,t,t=1 c=1 1626006833639000000,"
,
"s t,t=1 c=1 1626006833639000000,"
,
//tag key comma,equal,space
"st,t,t=1 c=2 1626006833639000000,"
,
"st,t=t=1 c=2 1626006833639000000,"
,
"st,t t=1 c=2 1626006833639000000,"
,
//tag value comma,equal,space
"st,tt=a,a c=2 1626006833639000000,"
,
"st,t=t=a a c=2 1626006833639000000,"
,
"st,t t=a=a c=2 1626006833639000000,"
,
//field key comma,equal,space
"st,tt=aa c,1=2 1626006833639000000,"
,
"st,tt=aa c=1=2 1626006833639000000,"
,
"st,tt=aa c 1=2 1626006833639000000,"
,
//field value double quote,slash
"st,tt=aa c=
\"
a
\"
a
\"
1626006833639000000,"
,
};
SSmlHandle
*
info
=
smlBuildSmlInfo
(
NULL
);
info
->
protocol
=
TSDB_SML_LINE_PROTOCOL
;
...
...
@@ -256,16 +276,18 @@ TEST(testCase, smlParseCols_Test) {
ASSERT_EQ
(
strncasecmp
(
kv
->
key
,
"cb=in"
,
5
),
0
);
ASSERT_EQ
(
kv
->
keyLen
,
5
);
ASSERT_EQ
(
kv
->
type
,
TSDB_DATA_TYPE_BINARY
);
ASSERT_EQ
(
kv
->
length
,
17
);
ASSERT_EQ
(
strncasecmp
(
kv
->
value
,
"pass,it "
,
8
),
0
);
ASSERT_EQ
(
kv
->
length
,
18
);
ASSERT_EQ
(
kv
->
keyEscaped
,
true
);
ASSERT_EQ
(
kv
->
valueEscaped
,
false
);
ASSERT_EQ
(
strncasecmp
(
kv
->
value
,
"pass
\\
,it "
,
9
),
0
);
// nchar
kv
=
(
SSmlKv
*
)
taosArrayGet
(
elements
.
colArray
,
2
);
ASSERT_EQ
(
strncasecmp
(
kv
->
key
,
"cnch"
,
4
),
0
);
ASSERT_EQ
(
kv
->
keyLen
,
4
);
ASSERT_EQ
(
kv
->
type
,
TSDB_DATA_TYPE_NCHAR
);
ASSERT_EQ
(
kv
->
length
,
8
);
ASSERT_EQ
(
strncasecmp
(
kv
->
value
,
"ii=sd"
,
5
),
0
);
ASSERT_EQ
(
kv
->
length
,
9
);
ASSERT_EQ
(
strncasecmp
(
kv
->
value
,
"ii
\\
=sd"
,
5
),
0
);
// bool
kv
=
(
SSmlKv
*
)
taosArrayGet
(
elements
.
colArray
,
3
);
...
...
source/common/src/tglobal.c
浏览文件 @
b1561c95
...
...
@@ -198,7 +198,7 @@ int32_t tsTransPullupInterval = 2;
int32_t
tsMqRebalanceInterval
=
2
;
int32_t
tsStreamCheckpointTickInterval
=
1
;
int32_t
tsTtlUnit
=
86400
;
int32_t
tsTtlPushInterval
=
864
00
;
int32_t
tsTtlPushInterval
=
36
00
;
int32_t
tsGrantHBInterval
=
60
;
int32_t
tsUptimeInterval
=
300
;
// seconds
char
tsUdfdResFuncs
[
512
]
=
""
;
// udfd resident funcs that teardown when udfd exits
...
...
utils/test/c/sml_test.c
浏览文件 @
b1561c95
...
...
@@ -895,6 +895,61 @@ int smlProcess_18784_Test() {
return
code
;
}
int
sml_escape_Test
()
{
TAOS
*
taos
=
taos_connect
(
"localhost"
,
"root"
,
"taosdata"
,
NULL
,
0
);
TAOS_RES
*
pRes
=
taos_query
(
taos
,
"create database if not exists db_escape"
);
taos_free_result
(
pRes
);
pRes
=
taos_query
(
taos
,
"use db_escape"
);
taos_free_result
(
pRes
);
const
char
*
sql
[]
=
{
"d
\\
,i=
\\
s
\\
k
\"
,dev
\"
i
\\
,
\\
=
\\
ce=s
\"
i
\\
,
\\
=
\\
dc inode
\"
i
\\
,
\\
=
\\
s_used=176059i,total=1076048383523889174i 1661943960000000000"
,
"d
\\
,i=
\\
s
\\
k
\"
,dev
\"
i
\\
,
\\
=
\\
ce=s
\"
i
\\
,
\\
=
\\
dc inode
\"
i
\\
,
\\
=
\\
s_free=
\"\\\"
id,= ei
\\\\\\
f
\"
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
)
==
1
);
taos_free_result
(
pRes
);
pRes
=
taos_query
(
taos
,
"select * from `d,i= s
\\
k
\"
`"
);
//check stable name
ASSERT
(
pRes
);
int
fieldNum
=
taos_field_count
(
pRes
);
ASSERT
(
fieldNum
==
5
);
printf
(
"fieldNum:%d
\n
"
,
fieldNum
);
int
numFields
=
taos_num_fields
(
pRes
);
TAOS_FIELD
*
fields
=
taos_fetch_fields
(
pRes
);
ASSERT
(
numFields
==
5
);
ASSERT
(
strcmp
(
fields
[
4
].
name
,
"dev
\"
i,= ce"
)
==
0
);
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
==
1076048383523889174
);
ASSERT
(
freed
==
66932805
);
ASSERT
(
strcmp
(
row
[
4
],
"s
\"
i,= dc"
)
==
0
);
}
rowIndex
++
;
}
taos_free_result
(
pRes
);
taos_close
(
taos
);
return
code
;
}
int
sml_19221_Test
()
{
TAOS
*
taos
=
taos_connect
(
"localhost"
,
"root"
,
"taosdata"
,
NULL
,
0
);
...
...
@@ -961,6 +1016,55 @@ int sml_ts2164_Test() {
return
code
;
}
int
sml_ts3116_Test
()
{
TAOS
*
taos
=
taos_connect
(
"localhost"
,
"root"
,
"taosdata"
,
NULL
,
0
);
TAOS_RES
*
pRes
=
taos_query
(
taos
,
"DROP DATABASE IF EXISTS ts3116"
);
taos_free_result
(
pRes
);
pRes
=
taos_query
(
taos
,
"CREATE DATABASE IF NOT EXISTS ts3116 BUFFER 384 MINROWS 1000 PAGES 256 PRECISION 'ns'"
);
taos_free_result
(
pRes
);
char
*
sql
=
{
"meters,location=la,groupid=ca current=11.8,voltage=221"
,
};
pRes
=
taos_query
(
taos
,
"use ts3116"
);
taos_free_result
(
pRes
);
int32_t
totalRows
=
0
;
char
*
tmp
=
(
char
*
)
taosMemoryCalloc
(
1024
,
1
);
memcpy
(
tmp
,
sql
,
strlen
(
sql
));
totalRows
=
0
;
pRes
=
taos_schemaless_insert_raw
(
taos
,
tmp
,
strlen
(
tmp
),
&
totalRows
,
TSDB_SML_LINE_PROTOCOL
,
TSDB_SML_TIMESTAMP_MILLI_SECONDS
);
taosMemoryFree
(
tmp
);
printf
(
"%s result:%s
\n
"
,
__FUNCTION__
,
taos_errstr
(
pRes
));
int
code
=
taos_errno
(
pRes
);
taos_free_result
(
pRes
);
char
*
sql1
=
{
"meters,location=la,groupid=ca
\\
=3 current=11.8,voltage=221
\n
meters,location=la,groupid=ca current=11.8,voltage=221,phase=0.27"
,
};
pRes
=
taos_query
(
taos
,
"use ts3116"
);
taos_free_result
(
pRes
);
tmp
=
(
char
*
)
taosMemoryCalloc
(
1024
,
1
);
memcpy
(
tmp
,
sql1
,
strlen
(
sql1
));
totalRows
=
0
;
pRes
=
taos_schemaless_insert_raw
(
taos
,
tmp
,
strlen
(
tmp
),
&
totalRows
,
TSDB_SML_LINE_PROTOCOL
,
TSDB_SML_TIMESTAMP_MILLI_SECONDS
);
taosMemoryFree
(
tmp
);
printf
(
"%s result:%s
\n
"
,
__FUNCTION__
,
taos_errstr
(
pRes
));
code
=
taos_errno
(
pRes
);
taos_free_result
(
pRes
);
taos_close
(
taos
);
return
code
;
}
int
sml_td22898_Test
()
{
TAOS
*
taos
=
taos_connect
(
"localhost"
,
"root"
,
"taosdata"
,
NULL
,
0
);
...
...
@@ -1195,6 +1299,9 @@ int main(int argc, char *argv[]) {
}
int
ret
=
0
;
ret
=
sml_escape_Test
();
ret
=
sml_ts3116_Test
();
ASSERT
(
!
ret
);
ret
=
sml_ts2385_Test
();
// this test case need config sml table name using ./sml_test config_file
ASSERT
(
!
ret
);
// for(int i = 0; i < sizeof(str)/sizeof(str[0]); i++){
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录