Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
913589de
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看板
未验证
提交
913589de
编写于
10月 19, 2022
作者:
D
dapan1121
提交者:
GitHub
10月 19, 2022
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #17451 from taosdata/fix/TS-1911
fix:table does not exist if drop databse then create database in sche…
上级
41adb25a
7276b2a9
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
78 addition
and
52 deletion
+78
-52
src/client/src/tscParseLineProtocol.c
src/client/src/tscParseLineProtocol.c
+78
-52
未找到文件。
src/client/src/tscParseLineProtocol.c
浏览文件 @
913589de
...
...
@@ -757,25 +757,25 @@ static int32_t arrangePointsByChildTableName(TAOS_SML_DATA_POINT* points, int nu
SHashObj
*
cname2points
,
SArray
*
stableSchemas
,
SSmlLinesInfo
*
info
)
{
for
(
int32_t
i
=
0
;
i
<
numPoints
;
++
i
)
{
TAOS_SML_DATA_POINT
*
point
=
points
+
i
;
SSmlSTableSchema
*
stableSchema
=
taosArrayGet
(
stableSchemas
,
point
->
schemaIdx
);
for
(
int
j
=
0
;
j
<
point
->
tagNum
;
++
j
)
{
TAOS_SML_KV
*
kv
=
point
->
tags
+
j
;
if
(
kv
->
type
==
TSDB_DATA_TYPE_TIMESTAMP
)
{
int64_t
ts
=
*
(
int64_t
*
)(
kv
->
value
);
ts
=
convertTimePrecision
(
ts
,
TSDB_TIME_PRECISION_NANO
,
stableSchema
->
precision
);
*
(
int64_t
*
)(
kv
->
value
)
=
ts
;
}
}
for
(
int
j
=
0
;
j
<
point
->
fieldNum
;
++
j
)
{
TAOS_SML_KV
*
kv
=
point
->
fields
+
j
;
if
(
kv
->
type
==
TSDB_DATA_TYPE_TIMESTAMP
)
{
int64_t
ts
=
*
(
int64_t
*
)(
kv
->
value
);
ts
=
convertTimePrecision
(
ts
,
TSDB_TIME_PRECISION_NANO
,
stableSchema
->
precision
);
*
(
int64_t
*
)(
kv
->
value
)
=
ts
;
}
}
//
SSmlSTableSchema* stableSchema = taosArrayGet(stableSchemas, point->schemaIdx);
//
for (int j = 0; j < point->tagNum; ++j) {
//
TAOS_SML_KV* kv = point->tags + j;
//
if (kv->type == TSDB_DATA_TYPE_TIMESTAMP) {
//
int64_t ts = *(int64_t*)(kv->value);
//
ts = convertTimePrecision(ts, TSDB_TIME_PRECISION_NANO, stableSchema->precision);
//
*(int64_t*)(kv->value) = ts;
//
}
//
}
//
//
for (int j = 0; j < point->fieldNum; ++j) {
//
TAOS_SML_KV* kv = point->fields + j;
//
if (kv->type == TSDB_DATA_TYPE_TIMESTAMP) {
//
int64_t ts = *(int64_t*)(kv->value);
//
ts = convertTimePrecision(ts, TSDB_TIME_PRECISION_NANO, stableSchema->precision);
//
*(int64_t*)(kv->value) = ts;
//
}
//
}
SArray
*
cTablePoints
=
NULL
;
SArray
**
pCTablePoints
=
taosHashGet
(
cname2points
,
point
->
childTableName
,
strlen
(
point
->
childTableName
));
...
...
@@ -860,7 +860,14 @@ static int32_t addChildTableDataPointsToInsertSql(char* cTableName, char* sTable
TAOS_SML_KV
*
kv
=
tagKVs
[
i
];
size_t
beforeLen
=
totalLen
;
int32_t
len
=
0
;
converToStr
(
sql
+
beforeLen
,
kv
->
type
,
kv
->
value
,
kv
->
length
,
&
len
);
if
(
kv
->
type
==
TSDB_DATA_TYPE_TIMESTAMP
)
{
int64_t
ts
=
*
(
int64_t
*
)(
kv
->
value
);
ts
=
convertTimePrecision
(
ts
,
TSDB_TIME_PRECISION_NANO
,
sTableSchema
->
precision
);
converToStr
(
sql
+
beforeLen
,
kv
->
type
,
&
ts
,
kv
->
length
,
&
len
);
}
else
{
converToStr
(
sql
+
beforeLen
,
kv
->
type
,
kv
->
value
,
kv
->
length
,
&
len
);
}
totalLen
+=
len
;
ret
=
smlSnprintf
(
sql
,
&
totalLen
,
capacity
,
","
);
...
...
@@ -914,7 +921,13 @@ static int32_t addChildTableDataPointsToInsertSql(char* cTableName, char* sTable
TAOS_SML_KV
*
kv
=
colKVs
[
i
];
size_t
beforeLen
=
totalLen
;
int32_t
len
=
0
;
converToStr
(
sql
+
beforeLen
,
kv
->
type
,
kv
->
value
,
kv
->
length
,
&
len
);
if
(
kv
->
type
==
TSDB_DATA_TYPE_TIMESTAMP
)
{
int64_t
ts
=
*
(
int64_t
*
)(
kv
->
value
);
ts
=
convertTimePrecision
(
ts
,
TSDB_TIME_PRECISION_NANO
,
sTableSchema
->
precision
);
converToStr
(
sql
+
beforeLen
,
kv
->
type
,
&
ts
,
kv
->
length
,
&
len
);
}
else
{
converToStr
(
sql
+
beforeLen
,
kv
->
type
,
kv
->
value
,
kv
->
length
,
&
len
);
}
totalLen
+=
len
;
ret
=
smlSnprintf
(
sql
,
&
totalLen
,
capacity
,
","
);
if
(
ret
!=
0
)
{
...
...
@@ -965,7 +978,7 @@ static void insertCallback(void *param, TAOS_RES *res, int32_t notUsedCode) {
batch
->
tryAgain
=
true
;
}
if
(
code
==
TSDB_CODE_TDB_INVALID_TABLE_ID
||
code
==
TSDB_CODE_VND_INVALID_VGROUP_ID
)
{
if
(
code
==
TSDB_CODE_TDB_INVALID_TABLE_ID
||
code
==
TSDB_CODE_VND_INVALID_VGROUP_ID
||
code
==
TSDB_CODE_MND_INVALID_TABLE_NAME
)
{
batch
->
resetQueryCache
=
true
;
if
(
batch
->
tryAgain
)
{
batch
->
sleep
=
true
;
...
...
@@ -1105,6 +1118,9 @@ static int32_t applyDataPointsWithSqlInsert(TAOS* taos, TAOS_SML_DATA_POINT* poi
SSmlSqlInsertBatch
*
b
=
info
->
batches
+
i
;
if
(
b
->
code
!=
0
)
{
code
=
b
->
code
;
if
(
code
==
TSDB_CODE_MND_INVALID_TABLE_NAME
){
break
;
}
}
}
...
...
@@ -1221,42 +1237,52 @@ int tscSmlInsert(TAOS* taos, TAOS_SML_DATA_POINT* points, int numPoint, SSmlLine
info
->
affectedRows
=
0
;
if
(
numPoint
==
1
)
{
TAOS_SML_DATA_POINT
*
point
=
points
+
0
;
code
=
doSmlInsertOneDataPoint
(
taos
,
point
,
info
);
if
(
code
==
TSDB_CODE_SUCCESS
)
{
return
code
;
int32_t
tableNotExistTryTimes
=
3
;
while
(
tableNotExistTryTimes
){
if
(
numPoint
==
1
)
{
TAOS_SML_DATA_POINT
*
point
=
points
+
0
;
code
=
doSmlInsertOneDataPoint
(
taos
,
point
,
info
);
if
(
code
==
TSDB_CODE_SUCCESS
)
{
return
code
;
}
}
}
tscDebug
(
"SML:0x%"
PRIx64
" build data point schemas"
,
info
->
id
);
SArray
*
stableSchemas
=
taosArrayInit
(
32
,
sizeof
(
SSmlSTableSchema
));
// SArray<STableColumnsSchema>
code
=
buildDataPointSchemas
(
points
,
numPoint
,
stableSchemas
,
info
);
if
(
code
!=
0
)
{
tscError
(
"SML:0x%"
PRIx64
" error building data point schemas : %s"
,
info
->
id
,
tstrerror
(
code
));
goto
clean_up
;
}
tscDebug
(
"SML:0x%"
PRIx64
" build data point schemas"
,
info
->
id
);
SArray
*
stableSchemas
=
taosArrayInit
(
32
,
sizeof
(
SSmlSTableSchema
));
// SArray<STableColumnsSchema>
code
=
buildDataPointSchemas
(
points
,
numPoint
,
stableSchemas
,
info
);
if
(
code
!=
0
)
{
tscError
(
"SML:0x%"
PRIx64
" error building data point schemas : %s"
,
info
->
id
,
tstrerror
(
code
));
goto
clean_up
;
}
tscDebug
(
"SML:0x%"
PRIx64
" modify db schemas"
,
info
->
id
);
code
=
modifyDBSchemas
(
taos
,
stableSchemas
,
info
);
if
(
code
!=
0
)
{
tscError
(
"SML:0x%"
PRIx64
" error change db schema : %s"
,
info
->
id
,
tstrerror
(
code
));
goto
clean_up
;
}
tscDebug
(
"SML:0x%"
PRIx64
" modify db schemas"
,
info
->
id
);
code
=
modifyDBSchemas
(
taos
,
stableSchemas
,
info
);
if
(
code
!=
0
)
{
tscError
(
"SML:0x%"
PRIx64
" error change db schema : %s"
,
info
->
id
,
tstrerror
(
code
));
goto
clean_up
;
}
tscDebug
(
"SML:0x%"
PRIx64
" apply data points"
,
info
->
id
);
code
=
applyDataPointsWithSqlInsert
(
taos
,
points
,
numPoint
,
stableSchemas
,
info
);
if
(
code
!=
0
)
{
tscError
(
"SML:0x%"
PRIx64
" error apply data points : %s"
,
info
->
id
,
tstrerror
(
code
));
}
tscDebug
(
"SML:0x%"
PRIx64
" apply data points"
,
info
->
id
);
code
=
applyDataPointsWithSqlInsert
(
taos
,
points
,
numPoint
,
stableSchemas
,
info
);
if
(
code
!=
0
)
{
tscError
(
"SML:0x%"
PRIx64
" error apply data points : %s"
,
info
->
id
,
tstrerror
(
code
));
}
clean_up:
for
(
int
i
=
0
;
i
<
taosArrayGetSize
(
stableSchemas
);
++
i
)
{
SSmlSTableSchema
*
schema
=
taosArrayGet
(
stableSchemas
,
i
);
taosArrayDestroy
(
&
schema
->
fields
);
taosArrayDestroy
(
&
schema
->
tags
);
clean_up:
for
(
int
i
=
0
;
i
<
taosArrayGetSize
(
stableSchemas
);
++
i
)
{
SSmlSTableSchema
*
schema
=
taosArrayGet
(
stableSchemas
,
i
);
taosArrayDestroy
(
&
schema
->
fields
);
taosArrayDestroy
(
&
schema
->
tags
);
}
taosArrayDestroy
(
&
stableSchemas
);
if
(
code
==
TSDB_CODE_MND_INVALID_TABLE_NAME
){
tableNotExistTryTimes
--
;
}
else
{
tableNotExistTryTimes
=
0
;
}
}
taosArrayDestroy
(
&
stableSchemas
);
return
code
;
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录