Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
a7eee2c1
T
TDengine
项目概览
taosdata
/
TDengine
接近 2 年 前同步成功
通知
1192
Star
22018
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看板
提交
a7eee2c1
编写于
1月 11, 2023
作者:
dengyihao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add/delete tag idx
上级
3e738363
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
36 addition
and
70 deletion
+36
-70
source/dnode/vnode/src/meta/metaTable.c
source/dnode/vnode/src/meta/metaTable.c
+36
-70
未找到文件。
source/dnode/vnode/src/meta/metaTable.c
浏览文件 @
a7eee2c1
...
@@ -393,10 +393,12 @@ int metaAddIndexToSTable(SMeta *pMeta, int64_t version, SVCreateStbReq *pReq) {
...
@@ -393,10 +393,12 @@ int metaAddIndexToSTable(SMeta *pMeta, int64_t version, SVCreateStbReq *pReq) {
SMetaEntry
oStbEntry
=
{
0
};
SMetaEntry
oStbEntry
=
{
0
};
SMetaEntry
nStbEntry
=
{
0
};
SMetaEntry
nStbEntry
=
{
0
};
STbDbKey
tbDbKey
=
{
0
};
TBC
*
pUidIdxc
=
NULL
;
TBC
*
pUidIdxc
=
NULL
;
TBC
*
pTbDbc
=
NULL
;
TBC
*
pTbDbc
=
NULL
;
void
*
pData
;
void
*
pData
=
NULL
;
int
nData
;
int
nData
=
0
;
int64_t
oversion
;
int64_t
oversion
;
SDecoder
dc
=
{
0
};
SDecoder
dc
=
{
0
};
int32_t
ret
;
int32_t
ret
;
...
@@ -409,60 +411,44 @@ int metaAddIndexToSTable(SMeta *pMeta, int64_t version, SVCreateStbReq *pReq) {
...
@@ -409,60 +411,44 @@ int metaAddIndexToSTable(SMeta *pMeta, int64_t version, SVCreateStbReq *pReq) {
goto
_err
;
goto
_err
;
}
}
// tdbTbcOpen(pMeta->pUidIdx, &pUidIdxc, NULL);
tbDbKey
.
uid
=
suid
;
// ret = tdbTbcMoveTo(pUidIdxc, &pReq->suid, sizeof(tb_uid_t), &c);
tbDbKey
.
version
=
((
SUidIdxVal
*
)
pData
)[
0
].
version
;
// if (ret < 0 || c) {
tdbTbGet
(
pMeta
->
pTbDb
,
&
tbDbKey
,
sizeof
(
tbDbKey
),
&
pData
,
&
nData
);
// tdbTbcClose(pUidIdxc);
// terrno = TSDB_CODE_TDB_STB_NOT_EXIST;
// return -1;
//}
// ret = tdbTbcGet(pUidIdxc, NULL, NULL, &pData, &nData);
// if (ret < 0) {
// tdbTbcClose(pUidIdxc);
// terrno = TSDB_CODE_TDB_STB_NOT_EXIST;
// return -1;
//}
// oversion = ((SUidIdxVal *)pData)[0].version;
// tdbTbcOpen(pMeta->pTbDb, &pTbDbc, NULL);
tDecoderInit
(
&
dc
,
pData
,
nData
);
// ret = tdbTbcMoveTo(pTbDbc, &((STbDbKey){.uid = pReq->suid, .version = oversion}), sizeof(STbDbKey), &c);
ret
=
metaDecodeEntry
(
&
dc
,
&
oStbEntry
);
// if (!(ret == 0 && c == 0)) {
if
(
ret
<
0
)
{
// metaError("meta/table: invalide ret: %" PRId32 " or c: %" PRId32 "alter stb failed.", ret, c);
goto
_err
;
// return -1;
}
// }
// ret = tdbTbcGet(pTbDbc, NULL, NULL, &pData, &nData);
// if (ret < 0) {
// tdbTbcClose(pTbDbc);
// terrno = TSDB_CODE_TDB_STB_NOT_EXIST;
if
(
oStbEntry
.
stbEntry
.
schemaTag
.
pSchema
==
NULL
||
oStbEntry
.
stbEntry
.
schemaTag
.
pSchema
==
NULL
)
{
// return -1
;
goto
_err
;
//
}
}
oStbEntry
.
pBuf
=
taosMemoryMalloc
(
nData
);
if
(
oStbEntry
.
stbEntry
.
schemaTag
.
version
!=
pReq
->
schemaTag
.
version
)
{
memcpy
(
oStbEntry
.
pBuf
,
pData
,
nData
);
goto
_err
;
tDecoderInit
(
&
dc
,
oStbEntry
.
pBuf
,
nData
);
}
metaDecodeEntry
(
&
dc
,
&
oStbEntry
);
nStbEntry
.
version
=
version
;
if
(
oStbEntry
.
stbEntry
.
schemaTag
.
nCols
!=
pReq
->
schemaTag
.
nCols
)
{
nStbEntry
.
type
=
TSDB_SUPER_TABLE
;
goto
_err
;
nStbEntry
.
uid
=
pReq
->
suid
;
}
nStbEntry
.
name
=
pReq
->
name
;
nStbEntry
.
stbEntry
.
schemaRow
=
pReq
->
schemaRow
;
nStbEntry
.
stbEntry
.
schemaTag
=
pReq
->
schemaTag
;
metaWLock
(
pMeta
);
int
diffIdx
=
-
1
;
// compare two entry
for
(
int
i
=
0
;
i
<
pReq
->
schemaTag
.
nCols
;
i
++
)
{
if
(
oStbEntry
.
stbEntry
.
schemaRow
.
version
!=
pReq
->
schemaRow
.
version
)
{
SSchema
*
pNew
=
pReq
->
schemaTag
.
pSchema
+
i
;
metaSaveToSkmDb
(
pMeta
,
&
nStbEntry
);
SSchema
*
pOld
=
oStbEntry
.
stbEntry
.
schemaTag
.
pSchema
+
i
;
if
(
pNew
->
type
!=
pOld
->
type
||
pNew
->
colId
!=
pOld
->
colId
||
pNew
->
bytes
!=
pOld
->
bytes
||
strncmp
(
pOld
->
name
,
pNew
->
name
,
sizeof
(
pNew
->
name
)))
{
goto
_err
;
}
if
(
IS_IDX_ON
(
pNew
)
&&
!
IS_IDX_ON
(
pOld
))
{
if
(
diffIdx
!=
-
1
)
goto
_err
;
diffIdx
=
i
;
}
}
}
// update table.db
// update table.db
metaSaveToTbDb
(
pMeta
,
&
nStbEntry
);
metaSaveToTbDb
(
pMeta
,
&
nStbEntry
);
// update uid index
// update uid index
metaUpdateUidIdx
(
pMeta
,
&
nStbEntry
);
metaUpdateUidIdx
(
pMeta
,
&
nStbEntry
);
...
@@ -471,30 +457,12 @@ int metaAddIndexToSTable(SMeta *pMeta, int64_t version, SVCreateStbReq *pReq) {
...
@@ -471,30 +457,12 @@ int metaAddIndexToSTable(SMeta *pMeta, int64_t version, SVCreateStbReq *pReq) {
metaULock
(
pMeta
);
metaULock
(
pMeta
);
// Get target schema info
// Get target schema info
SSchemaWrapper
*
pTagSchema
=
&
nStbEntry
.
stbEntry
.
schemaTag
;
SSchemaWrapper
*
pTagSchema
=
&
pReq
->
schemaTag
;
if
(
pTagSchema
->
nCols
==
1
&&
pTagSchema
->
pSchema
[
0
].
type
==
TSDB_DATA_TYPE_JSON
)
{
if
(
pTagSchema
->
nCols
==
1
&&
pTagSchema
->
pSchema
[
0
].
type
==
TSDB_DATA_TYPE_JSON
)
{
terrno
=
TSDB_CODE_VND_COL_ALREADY_EXISTS
;
terrno
=
TSDB_CODE_VND_COL_ALREADY_EXISTS
;
goto
_err
;
goto
_err
;
}
}
SSchema
*
pCol
=
pTagSchema
->
pSchema
+
diffIdx
;
char
*
tagName
=
"tag_col"
;
SSchema
*
pCol
=
NULL
;
int32_t
iCol
=
0
;
for
(;;)
{
pCol
=
NULL
;
if
(
iCol
>=
pTagSchema
->
nCols
)
break
;
pCol
=
&
pTagSchema
->
pSchema
[
iCol
];
if
(
strcmp
(
pCol
->
name
,
tagName
)
==
0
)
break
;
iCol
++
;
}
if
(
iCol
==
0
)
{
terrno
=
TSDB_CODE_VND_COL_ALREADY_EXISTS
;
goto
_err
;
}
if
(
pCol
==
NULL
)
{
terrno
=
TSDB_CODE_VND_COL_NOT_EXISTS
;
goto
_err
;
}
/*
/*
* iterator all pTdDbc by uid and version
* iterator all pTdDbc by uid and version
...
@@ -541,12 +509,10 @@ int metaAddIndexToSTable(SMeta *pMeta, int64_t version, SVCreateStbReq *pReq) {
...
@@ -541,12 +509,10 @@ int metaAddIndexToSTable(SMeta *pMeta, int64_t version, SVCreateStbReq *pReq) {
tdbTbUpsert
(
pMeta
->
pTagIdx
,
pTagIdxKey
,
nTagIdxKey
,
NULL
,
0
,
pMeta
->
txn
);
tdbTbUpsert
(
pMeta
->
pTagIdx
,
pTagIdxKey
,
nTagIdxKey
,
NULL
,
0
,
pMeta
->
txn
);
metaDestroyTagIdxKey
(
pTagIdxKey
);
metaDestroyTagIdxKey
(
pTagIdxKey
);
}
}
metaWLock
(
pMeta
);
if
(
oStbEntry
.
pBuf
)
taosMemoryFree
(
oStbEntry
.
pBuf
);
if
(
oStbEntry
.
pBuf
)
taosMemoryFree
(
oStbEntry
.
pBuf
);
tDecoderClear
(
&
dc
);
tDecoderClear
(
&
dc
);
tdbTbcClose
(
pTbDbc
);
tdbTbcClose
(
pUidIdxc
);
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
_err:
_err:
return
TSDB_CODE_VND_COL_ALREADY_EXISTS
;
return
TSDB_CODE_VND_COL_ALREADY_EXISTS
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录