Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
慢慢CG
TDengine
提交
1347ddf8
T
TDengine
项目概览
慢慢CG
/
TDengine
与 Fork 源项目一致
Fork自
taosdata / TDengine
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
1347ddf8
编写于
7月 24, 2021
作者:
S
shenglian zhou
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix change tag values errors
上级
7d2cc83a
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
58 addition
and
23 deletion
+58
-23
src/client/src/tscParseLineProtocol.c
src/client/src/tscParseLineProtocol.c
+24
-17
tests/examples/c/apitest.c
tests/examples/c/apitest.c
+32
-4
tests/examples/c/schemaless.c
tests/examples/c/schemaless.c
+2
-2
未找到文件。
src/client/src/tscParseLineProtocol.c
浏览文件 @
1347ddf8
...
...
@@ -474,7 +474,7 @@ int32_t loadTableMeta(TAOS* taos, char* tableName, SSmlSTableSchema* schema) {
return
code
;
}
static
int32_t
reconcile
DBSchemas
(
TAOS
*
taos
,
SArray
*
stableSchemas
)
{
static
int32_t
modify
DBSchemas
(
TAOS
*
taos
,
SArray
*
stableSchemas
)
{
int32_t
code
=
0
;
size_t
numStable
=
taosArrayGetSize
(
stableSchemas
);
for
(
int
i
=
0
;
i
<
numStable
;
++
i
)
{
...
...
@@ -691,7 +691,6 @@ static int32_t insertChildTableBatch(TAOS* taos, char* cTableName, SArray* cols
}
do
{
code
=
taos_stmt_set_tbname
(
stmt
,
cTableName
);
if
(
code
!=
0
)
{
tscError
(
"%s"
,
taos_stmt_errstr
(
stmt
));
...
...
@@ -818,20 +817,22 @@ static int32_t applyChildTableTags(TAOS* taos, char* cTableName, char* sTableNam
}
// select tag1,tag2,... from stable where tbname in (ctable)
char
sql
[
TSDB_MAX_BINARY_LEN
]
;
int
capacity
=
TSDB_MAX_BINARY_LEN
;
snprintf
(
sql
,
capacity
,
"select tbname, "
);
char
*
sql
=
malloc
(
tsMaxSQLStringLen
+
1
)
;
int
freeBytes
=
tsMaxSQLStringLen
+
1
;
snprintf
(
sql
,
freeBytes
,
"select tbname, "
);
for
(
int
i
=
0
;
i
<
numNotNullTags
;
++
i
)
{
snprintf
(
sql
+
strlen
(
sql
),
capacity
-
strlen
(
sql
),
"%s,"
,
tagKVs
[
notNullTagsIndices
[
i
]]
->
key
);
snprintf
(
sql
+
strlen
(
sql
),
freeBytes
-
strlen
(
sql
),
"%s,"
,
tagKVs
[
notNullTagsIndices
[
i
]]
->
key
);
}
snprintf
(
sql
+
strlen
(
sql
)
-
1
,
capacity
-
strlen
(
sql
)
+
1
,
snprintf
(
sql
+
strlen
(
sql
)
-
1
,
freeBytes
-
strlen
(
sql
)
+
1
,
" from %s where tbname in (
\'
%s
\'
)"
,
sTableName
,
cTableName
);
sql
[
strlen
(
sql
)]
=
'\0'
;
TAOS_RES
*
result
=
taos_query
(
taos
,
sql
);
free
(
sql
);
int32_t
code
=
taos_errno
(
result
);
if
(
code
!=
0
)
{
tscError
(
"%s"
,
taos_errstr
(
result
));
taos_free_result
(
result
);
tscError
(
"get child table %s tags failed. error string %s"
,
cTableName
,
taos_errstr
(
result
));
goto
cleanup
;
}
...
...
@@ -842,18 +843,20 @@ static int32_t applyChildTableTags(TAOS* taos, char* cTableName, char* sTableNam
TAOS_FIELD
*
fields
=
taos_fetch_fields
(
result
);
int
*
lengths
=
taos_fetch_lengths
(
result
);
for
(
int
i
=
1
;
i
<
numFields
;
++
i
)
{
uint8_t
t
ype
=
fields
[
i
].
type
;
uint8_t
dbT
ype
=
fields
[
i
].
type
;
int32_t
length
=
lengths
[
i
];
char
*
val
=
row
[
i
];
TAOS_SML_KV
*
tagKV
=
tagKVs
[
notNullTagsIndices
[
i
-
1
]];
if
(
tagKV
->
type
!=
t
ype
)
{
if
(
tagKV
->
type
!=
dbT
ype
)
{
tscError
(
"child table %s tag %s type mismatch. point type : %d, db type : %d"
,
cTableName
,
tagKV
->
key
,
tagKV
->
type
,
t
ype
);
cTableName
,
tagKV
->
key
,
tagKV
->
type
,
dbT
ype
);
return
TSDB_CODE_TSC_INVALID_VALUE
;
}
if
(
memcmp
(
tagKV
->
value
,
val
,
length
)
!=
0
)
{
assert
(
tagKV
->
value
);
if
(
val
==
NULL
||
length
!=
tagKV
->
length
||
memcmp
(
tagKV
->
value
,
val
,
length
)
!=
0
)
{
TAOS_BIND
*
bind
=
taosArrayGet
(
tagBinds
,
tagKV
->
fieldSchemaIdx
);
code
=
changeChildTableTagValue
(
taos
,
cTableName
,
tagKV
->
key
,
bind
);
if
(
code
!=
0
)
{
...
...
@@ -861,8 +864,8 @@ static int32_t applyChildTableTags(TAOS* taos, char* cTableName, char* sTableNam
goto
cleanup
;
}
}
}
tscDebug
(
"successfully applied point tags. child table: %s"
,
cTableName
);
}
else
{
code
=
creatChildTableIfNotExists
(
taos
,
cTableName
,
sTableName
,
sTableSchema
->
tags
,
tagBinds
);
if
(
code
!=
0
)
{
...
...
@@ -871,6 +874,7 @@ static int32_t applyChildTableTags(TAOS* taos, char* cTableName, char* sTableNam
}
cleanup:
taos_free_result
(
result
);
for
(
int
i
=
0
;
i
<
taosArrayGetSize
(
tagBinds
);
++
i
)
{
TAOS_BIND
*
bind
=
taosArrayGet
(
tagBinds
,
i
);
free
(
bind
->
length
);
...
...
@@ -953,6 +957,8 @@ static int32_t applyDataPoints(TAOS* taos, TAOS_SML_DATA_POINT* points, int32_t
goto
cleanup
;
}
tscDebug
(
"successfully applied data points of child table %s"
,
point
->
childTableName
);
pCTablePoints
=
taosHashIterate
(
cname2points
,
pCTablePoints
);
}
...
...
@@ -961,6 +967,7 @@ cleanup:
while
(
pCTablePoints
)
{
SArray
*
pPoints
=
*
pCTablePoints
;
taosArrayDestroy
(
pPoints
);
pCTablePoints
=
taosHashIterate
(
cname2points
,
pCTablePoints
);
}
taosHashCleanup
(
cname2points
);
return
code
;
...
...
@@ -978,7 +985,7 @@ int taos_sml_insert(TAOS* taos, TAOS_SML_DATA_POINT* points, int numPoint) {
goto
clean_up
;
}
code
=
reconcile
DBSchemas
(
taos
,
stableSchemas
);
code
=
modify
DBSchemas
(
taos
,
stableSchemas
);
if
(
code
!=
0
)
{
tscError
(
"error change db schema : %s"
,
tstrerror
(
code
));
goto
clean_up
;
...
...
@@ -986,7 +993,7 @@ int taos_sml_insert(TAOS* taos, TAOS_SML_DATA_POINT* points, int numPoint) {
code
=
applyDataPoints
(
taos
,
points
,
numPoint
,
stableSchemas
);
if
(
code
!=
0
)
{
tscError
(
"error
insert
points : %s"
,
tstrerror
(
code
));
tscError
(
"error
apply data
points : %s"
,
tstrerror
(
code
));
}
clean_up:
...
...
tests/examples/c/apitest.c
浏览文件 @
1347ddf8
...
...
@@ -963,11 +963,25 @@ int32_t verify_schema_less(TAOS* taos) {
taos_free_result
(
result
);
usleep
(
100000
);
int
code
=
0
;
char
*
lines
[]
=
{
"st,t1=3i64,t2=4f64,t3=
\"
t3
\"
c1=3i64,c3=L
\"
passit
\"
,c2=false,c4=4f64 1626006833639000000ns"
,
"st,t1=4i64,t3=
\"
t4
\"
,t2=5f64,t4=5f64 c1=3i64,c3=L
\"
passitagin
\"
,c2=true,c4=5f64,c5=5f64 1626006833640000000ns"
,
"ste,t2=5f64,t3=L
\"
ste
\"
c1=true,c2=4i64,c3=
\"
iam
\"
1626056811823316532ns"
,
"st,t1=4i64,t2=5f64,t3=
\"
t4
\"
c1=3i64,c3=L
\"
passitagain
\"
,c2=true,c4=5f64 1626006833642000000ns"
,
"ste,t2=5f64,t3=L
\"
ste2
\"
c3=
\"
iamszhou
\"
,c4=false 1626056811843316532ns"
,
"ste,t2=5f64,t3=L
\"
ste2
\"
c3=
\"
iamszhou
\"
,c4=false,c5=32i8,c6=64i16,c7=32i32,c8=88.88f32 1626056812843316532ns"
,
"st,t1=4i64,t3=
\"
t4
\"
,t2=5f64,t4=5f64 c1=3i64,c3=L
\"
passitagin
\"
,c2=true,c4=5f64,c5=5f64,c6=7u64 1626006933640000000ns"
,
"stf,t1=4i64,t3=
\"
t4
\"
,t2=5f64,t4=5f64 c1=3i64,c3=L
\"
passitagin
\"
,c2=true,c4=5f64,c5=5f64,c6=7u64 1626006933640000000ns"
,
"stf,t1=4i64,t3=
\"
t4
\"
,t2=5f64,t4=5f64 c1=3i64,c3=L
\"
passitagin_stf
\"
,c2=false,c5=5f64,c6=7u64 1626006933641000000ns"
};
code
=
taos_insert_lines
(
taos
,
lines
,
sizeof
(
lines
)
/
sizeof
(
char
*
));
char
*
lines2
[]
=
{
"
zqlbgs,id=
\"
zqlbgs_39302_21680
\"
,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=7u
64 1626006833639000000ns"
,
"
zqlbgs,t9=f,id=
\"
zqlbgs_39302_21680
\"
,t0=f,t1=127i8,t11=127i8,t2=32767i16,t3=2147483647i32,t4=9223372036854775807i64,t5=11.12345f32,t6=22.123456789f64,t7=
\"
binaryTagValue
\"
,t8=L
\"
ncharTagValue
\"
,t10=L
\"
ncharTagValue
\"
c10=f,c0=f,c1=127i8,c12=127i8,c2=32767i16,c3=2147483647i32,c4=9223372036854775807i64,c5=11.12345f32,c6=22.123456789f64,c7=
\"
binaryColValue
\"
,c8=L
\"
ncharColValue
\"
,c9=7u64,c11=L
\"
ncharColValue
\"
1626006833639
000000ns"
"
stg,t1=3i64,t2=4f64,t3=
\"
t3
\"
c1=3i64,c3=L
\"
passit
\"
,c2=false,c4=4f
64 1626006833639000000ns"
,
"
stg,t1=4i64,t3=
\"
t4
\"
,t2=5f64,t4=5f64 c1=3i64,c3=L
\"
passitagin
\"
,c2=true,c4=5f64,c5=5f64 1626006833640
000000ns"
};
code
=
taos_insert_lines
(
taos
,
&
lines2
[
0
],
1
);
code
=
taos_insert_lines
(
taos
,
&
lines2
[
1
],
1
);
...
...
@@ -983,7 +997,21 @@ int32_t verify_schema_less(TAOS* taos) {
"dgtyqodr,t2=5f64,t3=L
\"
ste
\"
c1=tRue,c2=4i64,c3=
\"
iam
\"
1626056811823316532ns"
};
code
=
taos_insert_lines
(
taos
,
lines4
,
2
);
return
code
;
char
*
lines5
[]
=
{
"zqlbgs,id=
\"
zqlbgs_39302_21680
\"
,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 1626006833639000000ns"
,
"zqlbgs,t9=f,id=
\"
zqlbgs_39302_21680
\"
,t0=f,t1=127i8,t11=127i8,t2=32767i16,t3=2147483647i32,t4=9223372036854775807i64,t5=11.12345f32,t6=22.123456789f64,t7=
\"
binaryTagValue
\"
,t8=L
\"
ncharTagValue
\"
,t10=L
\"
ncharTagValue
\"
c10=f,c0=f,c1=127i8,c12=127i8,c2=32767i16,c3=2147483647i32,c4=9223372036854775807i64,c5=11.12345f32,c6=22.123456789f64,c7=
\"
binaryColValue
\"
,c8=L
\"
ncharColValue
\"
,c9=7u64,c11=L
\"
ncharColValue
\"
1626006833639000000ns"
};
code
=
taos_insert_lines
(
taos
,
&
lines5
[
0
],
1
);
code
=
taos_insert_lines
(
taos
,
&
lines5
[
1
],
1
);
char
*
lines6
[]
=
{
"st123456,t1=3i64,t2=4f64,t3=
\"
t3
\"
c1=3i64,c3=L
\"
passit
\"
,c2=false,c4=4f64 1626006833639000000ns"
,
"dgtyqodr,t2=5f64,t3=L
\"
ste
\"
c1=tRue,c2=4i64,c3=
\"
iam
\"
1626056811823316532ns"
};
code
=
taos_insert_lines
(
taos
,
lines6
,
2
);
return
(
code
);
}
int
main
(
int
argc
,
char
*
argv
[])
{
...
...
tests/examples/c/schemaless.c
浏览文件 @
1347ddf8
...
...
@@ -9,8 +9,8 @@
#include <unistd.h>
int
numSuperTables
=
8
;
int
numChildTables
=
102
4
;
int
numRowsPerChildTable
=
12
8
;
int
numChildTables
=
4
;
int
numRowsPerChildTable
=
204
8
;
void
shuffle
(
char
**
lines
,
size_t
n
)
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录