Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
db3b9089
T
TDengine
项目概览
taosdata
/
TDengine
大约 1 年 前同步成功
通知
1185
Star
22015
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看板
提交
db3b9089
编写于
7月 02, 2020
作者:
H
Haojun Liao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[td-225] append the tag schema info to the msg of updating the tag value of table
上级
c9c38344
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
43 addition
and
11 deletion
+43
-11
src/tsdb/src/tsdbMeta.c
src/tsdb/src/tsdbMeta.c
+43
-11
未找到文件。
src/tsdb/src/tsdbMeta.c
浏览文件 @
db3b9089
...
...
@@ -255,17 +255,46 @@ _err:
return
NULL
;
}
static
int32_t
colIdCompar
(
const
void
*
left
,
const
void
*
right
)
{
int16_t
colId
=
*
(
int16_t
*
)
left
;
STColumn
*
p2
=
(
STColumn
*
)
right
;
if
(
colId
==
p2
->
colId
)
{
return
0
;
}
return
(
colId
<
p2
->
colId
)
?
-
1
:
1
;
}
int
tsdbUpdateTagValue
(
TSDB_REPO_T
*
repo
,
SUpdateTableTagValMsg
*
pMsg
)
{
STsdbRepo
*
pRepo
=
(
STsdbRepo
*
)
repo
;
STsdbMeta
*
pMeta
=
pRepo
->
tsdbMeta
;
int16_t
tversion
=
htons
(
pMsg
->
tversion
);
STable
*
pTable
=
tsdbGetTableByUid
(
pMeta
,
htobe64
(
pMsg
->
uid
));
pMsg
->
uid
=
htobe64
(
pMsg
->
uid
);
pMsg
->
tid
=
htonl
(
pMsg
->
tid
);
pMsg
->
tversion
=
htons
(
pMsg
->
tversion
);
pMsg
->
colId
=
htons
(
pMsg
->
colId
);
pMsg
->
tagValLen
=
htonl
(
pMsg
->
tagValLen
);
pMsg
->
numOfTags
=
htons
(
pMsg
->
numOfTags
);
pMsg
->
schemaLen
=
htonl
(
pMsg
->
schemaLen
);
assert
(
pMsg
->
schemaLen
==
sizeof
(
STColumn
)
*
pMsg
->
numOfTags
);
char
*
d
=
pMsg
->
data
;
for
(
int32_t
i
=
0
;
i
<
pMsg
->
numOfTags
;
++
i
)
{
STColumn
*
pCol
=
(
STColumn
*
)
d
;
pCol
->
colId
=
htons
(
pCol
->
colId
);
pCol
->
bytes
=
htonl
(
pCol
->
bytes
);
assert
(
pCol
->
offset
==
0
);
d
+=
sizeof
(
STColumn
);
}
STable
*
pTable
=
tsdbGetTableByUid
(
pMeta
,
pMsg
->
uid
);
if
(
pTable
==
NULL
)
{
terrno
=
TSDB_CODE_TDB_INVALID_TABLE_ID
;
return
-
1
;
}
if
(
TABLE_TID
(
pTable
)
!=
htonl
(
pMsg
->
tid
)
)
{
if
(
TABLE_TID
(
pTable
)
!=
pMsg
->
tid
)
{
terrno
=
TSDB_CODE_TDB_INVALID_TABLE_ID
;
return
-
1
;
}
...
...
@@ -277,10 +306,10 @@ int tsdbUpdateTagValue(TSDB_REPO_T *repo, SUpdateTableTagValMsg *pMsg) {
return
-
1
;
}
if
(
schemaVersion
(
tsdbGetTableTagSchema
(
pTable
))
<
tversion
)
{
if
(
schemaVersion
(
tsdbGetTableTagSchema
(
pTable
))
<
pMsg
->
tversion
)
{
tsdbDebug
(
"vgId:%d server tag version %d is older than client tag version %d, try to config"
,
REPO_ID
(
pRepo
),
schemaVersion
(
tsdbGetTableTagSchema
(
pTable
)),
tversion
);
void
*
msg
=
(
*
pRepo
->
appH
.
configFunc
)(
pRepo
->
config
.
tsdbId
,
htonl
(
pMsg
->
tid
)
);
schemaVersion
(
tsdbGetTableTagSchema
(
pTable
)),
pMsg
->
tversion
);
void
*
msg
=
(
*
pRepo
->
appH
.
configFunc
)(
pRepo
->
config
.
tsdbId
,
pMsg
->
tid
);
if
(
msg
==
NULL
)
return
-
1
;
// Deal with error her
...
...
@@ -299,21 +328,24 @@ int tsdbUpdateTagValue(TSDB_REPO_T *repo, SUpdateTableTagValMsg *pMsg) {
STSchema
*
pTagSchema
=
tsdbGetTableTagSchema
(
pTable
);
if
(
schemaVersion
(
pTagSchema
)
>
tversion
)
{
if
(
schemaVersion
(
pTagSchema
)
>
pMsg
->
tversion
)
{
tsdbError
(
"vgId:%d failed to update tag value of table %s since version out of date, client tag version %d server tag "
"version %d"
,
REPO_ID
(
pRepo
),
TABLE_CHAR_NAME
(
pTable
),
tversion
,
schemaVersion
(
pTable
->
tagSchema
));
REPO_ID
(
pRepo
),
TABLE_CHAR_NAME
(
pTable
),
pMsg
->
tversion
,
schemaVersion
(
pTable
->
tagSchema
));
return
TSDB_CODE_TDB_TAG_VER_OUT_OF_DATE
;
}
if
(
schemaColAt
(
pTagSchema
,
DEFAULT_TAG_INDEX_COLUMN
)
->
colId
==
htons
(
pMsg
->
colId
)
)
{
if
(
schemaColAt
(
pTagSchema
,
DEFAULT_TAG_INDEX_COLUMN
)
->
colId
==
pMsg
->
colId
)
{
tsdbRemoveTableFromIndex
(
pMeta
,
pTable
);
}
// TODO: remove table from index if it is the first column of tag
// TODO: convert the tag schema from client, and then extract the type and bytes from schema according to colId
STColumn
*
res
=
bsearch
(
&
pMsg
->
colId
,
pMsg
->
data
,
pMsg
->
numOfTags
,
sizeof
(
STColumn
),
colIdCompar
);
assert
(
res
!=
NULL
);
// tdSetKVRowDataOfCol(&pTable->tagVal, htons(pMsg->colId), htons(pMsg->type), pMsg->data
);
if
(
schemaColAt
(
pTagSchema
,
DEFAULT_TAG_INDEX_COLUMN
)
->
colId
==
htons
(
pMsg
->
colId
)
)
{
tdSetKVRowDataOfCol
(
&
pTable
->
tagVal
,
pMsg
->
colId
,
res
->
type
,
pMsg
->
data
+
pMsg
->
schemaLen
);
if
(
schemaColAt
(
pTagSchema
,
DEFAULT_TAG_INDEX_COLUMN
)
->
colId
==
pMsg
->
colId
)
{
tsdbAddTableIntoIndex
(
pMeta
,
pTable
);
}
return
TSDB_CODE_SUCCESS
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录