Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
5caf1148
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看板
提交
5caf1148
编写于
7月 29, 2022
作者:
wmmhello
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix:error in sml meta change
上级
75e42d92
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
108 addition
and
33 deletion
+108
-33
source/client/src/clientSml.c
source/client/src/clientSml.c
+74
-33
tests/system-test/2-query/sml.py
tests/system-test/2-query/sml.py
+2
-0
tests/test/c/sml_test.c
tests/test/c/sml_test.c
+32
-0
未找到文件。
source/client/src/clientSml.c
浏览文件 @
5caf1148
...
@@ -310,8 +310,11 @@ static int32_t getBytes(uint8_t type, int32_t length){
...
@@ -310,8 +310,11 @@ static int32_t getBytes(uint8_t type, int32_t length){
}
}
}
}
static
int32_t
smlSendMetaMsg
(
SSmlHandle
*
info
,
SName
*
pName
,
SSmlSTableMeta
*
sTableData
,
//static int32_t smlSendMetaMsg(SSmlHandle *info, SName *pName, SSmlSTableMeta *sTableData,
int32_t
colVer
,
int32_t
tagVer
,
int8_t
source
,
uint64_t
suid
){
// int32_t colVer, int32_t tagVer, int8_t source, uint64_t suid){
static
int32_t
smlSendMetaMsg
(
SSmlHandle
*
info
,
SName
*
pName
,
SSmlSTableMeta
*
sTableData
,
STableMeta
*
pTableMeta
,
ESchemaAction
action
){
SRequestObj
*
pRequest
=
NULL
;
SRequestObj
*
pRequest
=
NULL
;
SMCreateStbReq
pReq
=
{
0
};
SMCreateStbReq
pReq
=
{
0
};
int32_t
code
=
TSDB_CODE_SUCCESS
;
int32_t
code
=
TSDB_CODE_SUCCESS
;
...
@@ -327,43 +330,81 @@ static int32_t smlSendMetaMsg(SSmlHandle *info, SName *pName, SSmlSTableMeta *sT
...
@@ -327,43 +330,81 @@ static int32_t smlSendMetaMsg(SSmlHandle *info, SName *pName, SSmlSTableMeta *sT
goto
end
;
goto
end
;
}
}
pReq
.
colVer
=
colVer
;
if
(
action
==
SCHEMA_ACTION_NULL
){
pReq
.
tagVer
=
tagVer
;
pReq
.
colVer
=
1
;
pReq
.
source
=
source
;
pReq
.
tagVer
=
1
;
pReq
.
suid
=
0
;
pReq
.
source
=
TD_REQ_FROM_APP
;
}
else
if
(
action
==
SCHEMA_ACTION_TAG
){
pReq
.
colVer
=
pTableMeta
->
sversion
;
pReq
.
tagVer
=
pTableMeta
->
tversion
+
1
;
pReq
.
suid
=
pTableMeta
->
uid
;
pReq
.
source
=
TD_REQ_FROM_TAOX
;
}
else
if
(
action
==
SCHEMA_ACTION_COLUMN
){
pReq
.
colVer
=
pTableMeta
->
sversion
+
1
;
pReq
.
tagVer
=
pTableMeta
->
tversion
;
pReq
.
suid
=
pTableMeta
->
uid
;
pReq
.
source
=
TD_REQ_FROM_TAOX
;
}
pReq
.
commentLen
=
-
1
;
pReq
.
commentLen
=
-
1
;
pReq
.
igExists
=
true
;
pReq
.
igExists
=
true
;
pReq
.
suid
=
suid
;
tNameExtractFullName
(
pName
,
pReq
.
name
);
tNameExtractFullName
(
pName
,
pReq
.
name
);
pReq
.
numOfColumns
=
taosArrayGetSize
(
sTableData
->
cols
);
if
(
action
==
SCHEMA_ACTION_NULL
||
action
==
SCHEMA_ACTION_COLUMN
){
pReq
.
numOfTags
=
taosArrayGetSize
(
sTableData
->
tags
);
pReq
.
numOfColumns
=
taosArrayGetSize
(
sTableData
->
cols
);
pReq
.
pColumns
=
taosArrayInit
(
pReq
.
numOfColumns
,
sizeof
(
SField
));
pReq
.
pColumns
=
taosArrayInit
(
pReq
.
numOfColumns
,
sizeof
(
SField
));
for
(
int
i
=
0
;
i
<
pReq
.
numOfColumns
;
i
++
)
{
for
(
int
i
=
0
;
i
<
pReq
.
numOfColumns
;
i
++
)
{
SSmlKv
*
kv
=
(
SSmlKv
*
)
taosArrayGetP
(
sTableData
->
cols
,
i
);
SSmlKv
*
kv
=
(
SSmlKv
*
)
taosArrayGetP
(
sTableData
->
cols
,
i
);
SField
field
=
{
0
};
SField
field
=
{
0
};
field
.
type
=
kv
->
type
;
field
.
type
=
kv
->
type
;
field
.
bytes
=
getBytes
(
kv
->
type
,
kv
->
length
);
field
.
bytes
=
getBytes
(
kv
->
type
,
kv
->
length
);
memcpy
(
field
.
name
,
kv
->
key
,
kv
->
keyLen
);
memcpy
(
field
.
name
,
kv
->
key
,
kv
->
keyLen
);
taosArrayPush
(
pReq
.
pColumns
,
&
field
);
taosArrayPush
(
pReq
.
pColumns
,
&
field
);
}
}
else
if
(
action
==
SCHEMA_ACTION_TAG
){
pReq
.
numOfColumns
=
pTableMeta
->
tableInfo
.
numOfColumns
;
pReq
.
pColumns
=
taosArrayInit
(
pReq
.
numOfColumns
,
sizeof
(
SField
));
for
(
int
i
=
0
;
i
<
pReq
.
numOfColumns
;
i
++
)
{
SSchema
*
s
=
&
pTableMeta
->
schema
[
i
];
SField
field
=
{
0
};
field
.
type
=
s
->
type
;
field
.
bytes
=
s
->
bytes
;
strcpy
(
field
.
name
,
s
->
name
);
taosArrayPush
(
pReq
.
pColumns
,
&
field
);
}
}
}
if
(
pReq
.
numOfTags
==
0
){
if
(
action
==
SCHEMA_ACTION_NULL
||
action
==
SCHEMA_ACTION_TAG
){
pReq
.
numOfTags
=
1
;
pReq
.
numOfTags
=
taosArrayGetSize
(
sTableData
->
tags
);
pReq
.
pTags
=
taosArrayInit
(
pReq
.
numOfTags
,
sizeof
(
SField
));
if
(
pReq
.
numOfTags
==
0
){
SField
field
=
{
0
};
pReq
.
numOfTags
=
1
;
field
.
type
=
TSDB_DATA_TYPE_NCHAR
;
pReq
.
pTags
=
taosArrayInit
(
pReq
.
numOfTags
,
sizeof
(
SField
));
field
.
bytes
=
1
;
SField
field
=
{
0
};
strcpy
(
field
.
name
,
tsSmlTagName
);
field
.
type
=
TSDB_DATA_TYPE_NCHAR
;
taosArrayPush
(
pReq
.
pTags
,
&
field
);
field
.
bytes
=
1
;
}
else
{
strcpy
(
field
.
name
,
tsSmlTagName
);
taosArrayPush
(
pReq
.
pTags
,
&
field
);
}
else
{
pReq
.
pTags
=
taosArrayInit
(
pReq
.
numOfTags
,
sizeof
(
SField
));
for
(
int
i
=
0
;
i
<
pReq
.
numOfTags
;
i
++
)
{
SSmlKv
*
kv
=
(
SSmlKv
*
)
taosArrayGetP
(
sTableData
->
tags
,
i
);
SField
field
=
{
0
};
field
.
type
=
kv
->
type
;
field
.
bytes
=
getBytes
(
kv
->
type
,
kv
->
length
);
memcpy
(
field
.
name
,
kv
->
key
,
kv
->
keyLen
);
taosArrayPush
(
pReq
.
pTags
,
&
field
);
}
}
}
else
if
(
action
==
SCHEMA_ACTION_COLUMN
){
pReq
.
numOfTags
=
pTableMeta
->
tableInfo
.
numOfTags
;
pReq
.
pTags
=
taosArrayInit
(
pReq
.
numOfTags
,
sizeof
(
SField
));
pReq
.
pTags
=
taosArrayInit
(
pReq
.
numOfTags
,
sizeof
(
SField
));
for
(
int
i
=
0
;
i
<
pReq
.
numOfTags
;
i
++
)
{
for
(
int
i
=
0
;
i
<
pReq
.
numOfTags
;
i
++
)
{
SS
mlKv
*
kv
=
(
SSmlKv
*
)
taosArrayGetP
(
sTableData
->
tags
,
i
)
;
SS
chema
*
s
=
&
pTableMeta
->
schema
[
i
+
pTableMeta
->
tableInfo
.
numOfColumns
]
;
SField
field
=
{
0
};
SField
field
=
{
0
};
field
.
type
=
kv
->
type
;
field
.
type
=
s
->
type
;
field
.
bytes
=
getBytes
(
kv
->
type
,
kv
->
length
)
;
field
.
bytes
=
s
->
bytes
;
memcpy
(
field
.
name
,
kv
->
key
,
kv
->
keyLen
);
strcpy
(
field
.
name
,
s
->
name
);
taosArrayPush
(
pReq
.
pTags
,
&
field
);
taosArrayPush
(
pReq
.
pTags
,
&
field
);
}
}
}
}
...
@@ -424,7 +465,7 @@ static int32_t smlModifyDBSchemas(SSmlHandle *info) {
...
@@ -424,7 +465,7 @@ static int32_t smlModifyDBSchemas(SSmlHandle *info) {
code
=
catalogGetSTableMeta
(
info
->
pCatalog
,
&
conn
,
&
pName
,
&
pTableMeta
);
code
=
catalogGetSTableMeta
(
info
->
pCatalog
,
&
conn
,
&
pName
,
&
pTableMeta
);
if
(
code
==
TSDB_CODE_PAR_TABLE_NOT_EXIST
||
code
==
TSDB_CODE_MND_STB_NOT_EXIST
)
{
if
(
code
==
TSDB_CODE_PAR_TABLE_NOT_EXIST
||
code
==
TSDB_CODE_MND_STB_NOT_EXIST
)
{
code
=
smlSendMetaMsg
(
info
,
&
pName
,
sTableData
,
1
,
1
,
TD_REQ_FROM_APP
,
0
);
code
=
smlSendMetaMsg
(
info
,
&
pName
,
sTableData
,
NULL
,
SCHEMA_ACTION_NULL
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
uError
(
"SML:0x%"
PRIx64
" smlSendMetaMsg failed. can not create %s"
,
info
->
id
,
superTable
);
uError
(
"SML:0x%"
PRIx64
" smlSendMetaMsg failed. can not create %s"
,
info
->
id
,
superTable
);
goto
end
;
goto
end
;
...
@@ -445,7 +486,7 @@ static int32_t smlModifyDBSchemas(SSmlHandle *info) {
...
@@ -445,7 +486,7 @@ static int32_t smlModifyDBSchemas(SSmlHandle *info) {
goto
end
;
goto
end
;
}
}
if
(
action
==
SCHEMA_ACTION_TAG
){
if
(
action
==
SCHEMA_ACTION_TAG
){
code
=
smlSendMetaMsg
(
info
,
&
pName
,
sTableData
,
pTableMeta
->
sversion
,
pTableMeta
->
tversion
+
1
,
TD_REQ_FROM_TAOX
,
pTableMeta
->
uid
);
code
=
smlSendMetaMsg
(
info
,
&
pName
,
sTableData
,
pTableMeta
,
action
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
uError
(
"SML:0x%"
PRIx64
" smlSendMetaMsg failed. can not create %s"
,
info
->
id
,
superTable
);
uError
(
"SML:0x%"
PRIx64
" smlSendMetaMsg failed. can not create %s"
,
info
->
id
,
superTable
);
goto
end
;
goto
end
;
...
@@ -468,7 +509,7 @@ static int32_t smlModifyDBSchemas(SSmlHandle *info) {
...
@@ -468,7 +509,7 @@ static int32_t smlModifyDBSchemas(SSmlHandle *info) {
goto
end
;
goto
end
;
}
}
if
(
action
==
SCHEMA_ACTION_COLUMN
){
if
(
action
==
SCHEMA_ACTION_COLUMN
){
code
=
smlSendMetaMsg
(
info
,
&
pName
,
sTableData
,
pTableMeta
->
sversion
+
1
,
pTableMeta
->
tversion
,
TD_REQ_FROM_TAOX
,
pTableMeta
->
uid
);
code
=
smlSendMetaMsg
(
info
,
&
pName
,
sTableData
,
pTableMeta
,
action
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
uError
(
"SML:0x%"
PRIx64
" smlSendMetaMsg failed. can not create %s"
,
info
->
id
,
superTable
);
uError
(
"SML:0x%"
PRIx64
" smlSendMetaMsg failed. can not create %s"
,
info
->
id
,
superTable
);
goto
end
;
goto
end
;
...
...
tests/system-test/2-query/sml.py
浏览文件 @
5caf1148
...
@@ -83,6 +83,8 @@ class TDTestCase:
...
@@ -83,6 +83,8 @@ class TDTestCase:
tdSql
.
checkData
(
1
,
3
,
"web01"
)
tdSql
.
checkData
(
1
,
3
,
"web01"
)
tdSql
.
checkData
(
1
,
4
,
"t1"
)
tdSql
.
checkData
(
1
,
4
,
"t1"
)
tdSql
.
query
(
"select * from macylr"
)
tdSql
.
checkRows
(
2
)
return
return
def
run
(
self
):
def
run
(
self
):
...
...
tests/test/c/sml_test.c
浏览文件 @
5caf1148
...
@@ -1070,6 +1070,36 @@ int sml_16960_Test() {
...
@@ -1070,6 +1070,36 @@ int sml_16960_Test() {
return
code
;
return
code
;
}
}
int
sml_add_tag_col_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
);
const
char
*
sql
[]
=
{
"macylr,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 1626006833639000000"
};
pRes
=
taos_query
(
taos
,
"use sml_db"
);
taos_free_result
(
pRes
);
pRes
=
taos_schemaless_insert
(
taos
,
(
char
**
)
sql
,
sizeof
(
sql
)
/
sizeof
(
sql
[
0
]),
TSDB_SML_LINE_PROTOCOL
,
0
);
printf
(
"%s result:%s
\n
"
,
__FUNCTION__
,
taos_errstr
(
pRes
));
int
code
=
taos_errno
(
pRes
);
taos_free_result
(
pRes
);
if
(
code
)
return
code
;
const
char
*
sql1
[]
=
{
"macylr,id=macylr_17875_1804,t0=f,t1=127i8,t2=32767i16,t3=2147483647i32,t4=9223372036854775807i64,t5=11.12345f32,t6=22.123456789f64,t7=
\"
binaryTagValue
\"
,t8=L
\"
ncharTagValue
\"
,t11=127i8,t10=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,c11=L
\"
ncharColValue
\"
,c10=f 1626006833639000000"
};
pRes
=
taos_schemaless_insert
(
taos
,
(
char
**
)
sql1
,
sizeof
(
sql1
)
/
sizeof
(
sql1
[
0
]),
TSDB_SML_LINE_PROTOCOL
,
0
);
printf
(
"%s result:%s
\n
"
,
__FUNCTION__
,
taos_errstr
(
pRes
));
code
=
taos_errno
(
pRes
);
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
();
...
@@ -1097,5 +1127,7 @@ int main(int argc, char *argv[]) {
...
@@ -1097,5 +1127,7 @@ int main(int argc, char *argv[]) {
ret
=
sml_dup_time_Test
();
ret
=
sml_dup_time_Test
();
if
(
ret
)
return
ret
;
if
(
ret
)
return
ret
;
ret
=
sml_16960_Test
();
ret
=
sml_16960_Test
();
if
(
ret
)
return
ret
;
ret
=
sml_add_tag_col_Test
();
return
ret
;
return
ret
;
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录